We now have a current svn snapshot of libqxt in our contrib dir, and
[quassel.git] / src / contrib / libqxt-2007-10-24 / src / core / qxtmetaobject.cpp
similarity index 86%
rename from src/contrib/qxt/qxtmetaobject.cpp
rename to src/contrib/libqxt-2007-10-24/src/core/qxtmetaobject.cpp
index e6aa03c..e7723f1 100644 (file)
@@ -24,7 +24,7 @@
 /**
 \class QxtMetaObject QxtMetaObject
 
-\ingroup core
+\ingroup QxtCore
 
 \brief provides extensions to QMetaObject
 
@@ -34,12 +34,14 @@ including QxtMetaObject::bind \n
 #include "qxtmetaobject.h"
 #include "qxtboundfunction.h"
 #include "qxtboundcfunction.h"
+#include "qxtmetatype.h"
 
 #include <QByteArray>
 #include <QMetaObject>
 #include <QMetaMethod>
 #include <QtDebug>
 
+#ifndef QXT_DOXYGEN_RUN
 class QxtBoundArgument
 {
     // This class intentionally left blank
@@ -52,9 +54,8 @@ QxtBoundFunction::QxtBoundFunction(QObject* parent) : QObject(parent)
 {
     // initializer only
 }
+#endif
 
-#define QXT_ARG(i) ((argCount>i)?QGenericArgument(p ## i .typeName(), p ## i .constData()):QGenericArgument())
-#define QXT_VAR_ARG(i) (p ## i .isValid())?QGenericArgument(p ## i .typeName(), p ## i .constData()):QGenericArgument()
 bool QxtBoundFunction::invoke(Qt::ConnectionType type, QXT_IMPL_10ARGS(QVariant))
 {
     return invoke(type, QXT_VAR_ARG(1), QXT_VAR_ARG(2), QXT_VAR_ARG(3), QXT_VAR_ARG(4), QXT_VAR_ARG(5), QXT_VAR_ARG(6), QXT_VAR_ARG(7), QXT_VAR_ARG(8), QXT_VAR_ARG(9), QXT_VAR_ARG(10));
@@ -76,7 +77,7 @@ QxtBoundFunctionBase::QxtBoundFunctionBase(QObject* parent, QGenericArgument* pa
         }
         else
         {
-            data[i] = QMetaType::construct(QMetaType::type(params[i]->name()), params[i]->data());
+            data[i] = qxtConstructFromGenericArgument(*params[i]);
             arg[i] = p[i] = QGenericArgument(params[i]->name(), data[i]);
         }
         bindTypes[i] = types[i];
@@ -88,7 +89,7 @@ QxtBoundFunctionBase::~QxtBoundFunctionBase()
     for (int i=0; i<10; i++)
     {
         if (arg[i].name() == 0) return;
-        if (QByteArray(arg[i].name()) != "QxtBoundArgument") QMetaType::destroy(QMetaType::type(arg[i].name()), arg[i].data());
+        if (QByteArray(arg[i].name()) != "QxtBoundArgument") qxtDestroyFromGenericArgument(arg[i]);
     }
 }
 
@@ -133,6 +134,7 @@ bool QxtBoundFunction::invoke(Qt::ConnectionType type, QGenericReturnArgument re
     return reinterpret_cast<QxtBoundFunctionBase*>(this)->invokeBase(type, returnValue, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
 }
 
+#ifndef QXT_DOXYGEN_RUN
 class QxtBoundSlot : public QxtBoundFunctionBase
 {
 public:
@@ -153,6 +155,7 @@ public:
         return true;
     }
 };
+#endif
 
 namespace QxtMetaObject
 {
@@ -207,24 +210,21 @@ bool isSignalOrSlot (const char* method)
 }
 
 /**
-\relates QxtMetaObject
-\fn bind(QObject* recv, const char* invokable, QXT_IMPL_10ARGS(QVariant))
-
-creates a QxtBoundFunction from a slot + arguments \n
-can be used for QxtMetaObject::connect \
-
-\code
-QxtMetaObject::connect(\n
-       this, SIGNAL(init()), \\n
-       QxtMetaObject::bind(this, SLOT(say(QString)), Q_ARG(QString,"hello")));
-\endcode
-\n
-\code
-QxtMetaObject::connect( \n
-       this, SIGNAL(init(int i)), \n
-       QxtMetaObject::bind(this, SLOT(say(QString),int), Q_ARG(QString,"hello"),Q_BIND(1)));
-\endcode
-
+ * \relates QxtMetaObject
+ * \sa QxtMetaObject::connect
+ * \sa QxtBoundFunction
+ *
+ * Creates a binding to the provided signal, slot, or Q_INVOKABLE method using the
+ * provided parameter list. The type of each argument is deduced from the type of
+ * the QVariant. This function cannot bind positional arguments; see the
+ * overload using QGenericArgument.
+ *
+ * If the provided QObject does not implement the requested method, or if the
+ * argument list is incompatible with the method's function signature, this
+ * function returns NULL.
+ *
+ * The returned QxtBoundFunction is created as a child of the receiver.
+ * Changing the parent will result in undefined behavior.
  */
 QxtBoundFunction* bind(QObject* recv, const char* invokable, QXT_IMPL_10ARGS(QVariant))
 {
@@ -261,6 +261,24 @@ QxtBoundFunction* bind(QObject* recv, const char* invokable, QXT_IMPL_10ARGS(QVa
     return QxtMetaObject::bind(recv, invokable, QXT_ARG(1), QXT_ARG(2), QXT_ARG(3), QXT_ARG(4), QXT_ARG(5), QXT_ARG(6), QXT_ARG(7), QXT_ARG(8), QXT_ARG(9), QXT_ARG(10));
 }
 
+/**
+ * \relates QxtMetaObject
+ * \sa QxtMetaObject::connect
+ * \sa QxtBoundFunction
+ * \sa QXT_BIND
+ *
+ * Creates a binding to the provided signal, slot, or Q_INVOKABLE method using the
+ * provided parameter list. Use the Q_ARG macro to specify constant parameters, or
+ * use the QXT_BIND macro to relay a parameter from a connected signal or passed
+ * via the QxtBoundFunction::invoke() method.
+ * 
+ * If the provided QObject does not implement the requested method, or if the
+ * argument list is incompatible with the method's function signature, this
+ * function returns NULL.
+ *
+ * The returned QxtBoundFunction is created as a child of the receiver.
+ * Changing the parent will result in undefined behavior.
+ */
 QxtBoundFunction* bind(QObject* recv, const char* invokable, QXT_IMPL_10ARGS(QGenericArgument))
 {
     if (!recv)