/**
\class QxtMetaObject QxtMetaObject
-\ingroup core
+\ingroup QxtCore
\brief provides extensions to QMetaObject
#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
{
// 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));
}
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];
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]);
}
}
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:
return true;
}
};
+#endif
namespace QxtMetaObject
{
}
/**
-\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))
{
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)