diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-02-12 18:20:45 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-02-13 11:40:05 +0100 |
commit | 35f973d2224c514adcd2dfa48fa840d712ed9bf6 (patch) | |
tree | 35ae60cbaccdceac9cfef757b5d03446d27b9976 /src/tools | |
parent | 67491e2df5357706dbf88ddaf1f030ff095b4528 (diff) |
moc: Record whether a meta object is an object, gadget, or namespace
So far, objects had no identification, and both gadgets and namespaces
were called "gadget". qmltyperegistrar, however, is especially
interested in the distinction between namespaces and anything else.
Task-number: QTBUG-68796
Change-Id: Ic5739727bdef7766de6e535c6568920198fadb2b
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/moc/generator.cpp | 6 | ||||
-rw-r--r-- | src/tools/moc/moc.cpp | 6 | ||||
-rw-r--r-- | src/tools/moc/moc.h | 1 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 8d4fb2efc6..7264b5bf66 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -381,7 +381,7 @@ void Generator::generateCode() isConstructible ? index : 0); int flags = 0; - if (cdef->hasQGadget) { + if (cdef->hasQGadget || cdef->hasQNamespace) { // Ideally, all the classes could have that flag. But this broke classes generated // by qdbusxml2cpp which generate code that require that we call qt_metacall for properties flags |= PropertyAccessInStaticMetaCall; @@ -541,7 +541,7 @@ void Generator::generateCode() if (isQObject) fprintf(out, " nullptr,\n"); - else if (cdef->superclassList.size() && !cdef->hasQGadget) // for qobject, we know the super class must have a static metaobject + else if (cdef->superclassList.size() && !cdef->hasQGadget && !cdef->hasQNamespace) // for qobject, we know the super class must have a static metaobject fprintf(out, " QMetaObject::SuperData::link<%s::staticMetaObject>(),\n", purestSuperClass.constData()); else if (cdef->superclassList.size()) // for gadgets we need to query at compile time for it fprintf(out, " QtPrivate::MetaObjectForType<%s>::value(),\n", purestSuperClass.constData()); @@ -1179,7 +1179,7 @@ void Generator::generateStaticMetacall() } fprintf(out, ");\n"); fprintf(out, " if (_a[0]) *reinterpret_cast<%s**>(_a[0]) = _r; } break;\n", - cdef->hasQGadget ? "void" : "QObject"); + (cdef->hasQGadget || cdef->hasQNamespace) ? "void" : "QObject"); } fprintf(out, " default: break;\n"); fprintf(out, " }\n"); diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index b562416c31..c175d1d86d 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -923,7 +923,7 @@ void Moc::parse() ClassDef def; static_cast<BaseDef &>(def) = static_cast<BaseDef>(n); def.qualified += def.classname; - def.hasQGadget = true; + def.hasQNamespace = true; auto it = std::find_if(classList.begin(), classList.end(), [&def](const ClassDef &val) { return def.classname == val.classname && def.qualified == val.qualified; }); @@ -1846,8 +1846,12 @@ QJsonObject ClassDef::toJson() const if (!props.isEmpty()) cls[QLatin1String("properties")] = props; + if (hasQObject) + cls[QLatin1String("object")] = true; if (hasQGadget) cls[QLatin1String("gadget")] = true; + if (hasQNamespace) + cls[QLatin1String("namespace")] = true; QJsonArray superClasses; diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 04814b85a1..a3e20a061e 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -192,6 +192,7 @@ struct ClassDef : BaseDef { bool hasQObject = false; bool hasQGadget = false; + bool hasQNamespace = false; QJsonObject toJson() const; }; |