moc: Have a staticMetaCall in the Q_GADGET metaobject
This provides a way to invoke Q_INVOKABLE method Change-Id: I301cec2a21c2889fb9dde0b1eb6e92d0bd561bd7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>bb10
parent
af3bd5037a
commit
d49e7acc2b
|
|
@ -159,7 +159,8 @@ private: \
|
|||
#define Q_GADGET \
|
||||
public: \
|
||||
static const QMetaObject staticMetaObject; \
|
||||
private:
|
||||
private: \
|
||||
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);
|
||||
#endif // QT_NO_META_MACROS
|
||||
|
||||
#else // Q_MOC_RUN
|
||||
|
|
|
|||
|
|
@ -425,7 +425,8 @@ void Generator::generateCode()
|
|||
//
|
||||
// Generate internal qt_static_metacall() function
|
||||
//
|
||||
if (cdef->hasQObject && !isQt)
|
||||
const bool hasStaticMetaCall = (cdef->hasQObject || !cdef->methodList.isEmpty()) && !isQt;
|
||||
if (hasStaticMetaCall)
|
||||
generateStaticMetacall();
|
||||
|
||||
//
|
||||
|
|
@ -513,7 +514,7 @@ void Generator::generateCode()
|
|||
fprintf(out, "qt_meta_stringdata_%s.data,\n"
|
||||
" qt_meta_data_%s, ", qualifiedClassNameIdentifier.constData(),
|
||||
qualifiedClassNameIdentifier.constData());
|
||||
if (cdef->hasQObject && !isQt)
|
||||
if (hasStaticMetaCall)
|
||||
fprintf(out, " qt_static_metacall, ");
|
||||
else
|
||||
fprintf(out, " 0, ");
|
||||
|
|
@ -1246,10 +1247,14 @@ void Generator::generateStaticMetacall()
|
|||
else
|
||||
fprintf(out, " ");
|
||||
fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n");
|
||||
if (cdef->hasQObject) {
|
||||
#ifndef QT_NO_DEBUG
|
||||
fprintf(out, " Q_ASSERT(staticMetaObject.cast(_o));\n");
|
||||
fprintf(out, " Q_ASSERT(staticMetaObject.cast(_o));\n");
|
||||
#endif
|
||||
fprintf(out, " %s *_t = static_cast<%s *>(_o);\n", cdef->classname.constData(), cdef->classname.constData());
|
||||
fprintf(out, " %s *_t = static_cast<%s *>(_o);\n", cdef->classname.constData(), cdef->classname.constData());
|
||||
} else {
|
||||
fprintf(out, " %s *_t = reinterpret_cast<%s *>(_o);\n", cdef->classname.constData(), cdef->classname.constData());
|
||||
}
|
||||
fprintf(out, " switch (_id) {\n");
|
||||
for (int methodindex = 0; methodindex < methodList.size(); ++methodindex) {
|
||||
const FunctionDef &f = methodList.at(methodindex);
|
||||
|
|
|
|||
Loading…
Reference in New Issue