diff options
Diffstat (limited to 'tools/dumpcpp/main.cpp')
-rw-r--r-- | tools/dumpcpp/main.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/tools/dumpcpp/main.cpp b/tools/dumpcpp/main.cpp index 981039a..aa96d8c 100644 --- a/tools/dumpcpp/main.cpp +++ b/tools/dumpcpp/main.cpp @@ -65,6 +65,9 @@ enum ObjectCategory Licensed = 0x100, }; +Q_DECLARE_FLAGS(ObjectCategories, ObjectCategory) +Q_DECLARE_OPERATORS_FOR_FLAGS(ObjectCategories) + extern QMetaObject *qax_readEnumInfo(ITypeLib *typeLib, const QMetaObject *parentObject); extern QMetaObject *qax_readClassInfo(ITypeLib *typeLib, ITypeInfo *typeInfo, const QMetaObject *parentObject); extern QMetaObject *qax_readInterfaceInfo(ITypeLib *typeLib, ITypeInfo *typeInfo, const QMetaObject *parentObject); @@ -149,7 +152,9 @@ QByteArray constRefify(const QByteArray &type) return ctype; } -void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaObject *mo, const QByteArray &className, const QByteArray &nameSpace, ObjectCategory category) +void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaObject *mo, + const QByteArray &className, const QByteArray &nameSpace, + ObjectCategories category) { QList<QByteArray> functions; @@ -409,7 +414,7 @@ void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaOb if (slotSignature.endsWith("()")) { // no parameters - no names slotNamedSignature = slotSignature; } else { - slotNamedSignature = slotSignature.left(slotSignature.indexOf('(') + 1); + slotNamedSignature.truncate(slotSignature.indexOf('(') + 1); QByteArray slotSignatureTruncated(slotSignature.mid(slotNamedSignature.length())); slotSignatureTruncated.truncate(slotSignatureTruncated.length() - 1); @@ -684,7 +689,8 @@ void generateMethodParameters(QTextStream &out, const QMetaObject *mo, const QMe out << endl; } -void generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray &className, const QByteArray &nameSpace, ObjectCategory category) +void generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray &className, + const QByteArray &nameSpace, ObjectCategories category) { Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 7, "dumpcpp should generate the same version as moc"); @@ -928,7 +934,7 @@ static QByteArrayList vTableOnlyStubsFromTypeLib(ITypeLib *typelib, const QStrin } bool generateTypeLibrary(QString typeLibFile, QString outname, - const QString &nameSpace, ObjectCategory category) + const QString &nameSpace, ObjectCategories category) { typeLibFile.replace(QLatin1Char('/'), QLatin1Char('\\')); @@ -1087,7 +1093,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, QByteArray refTypeLib; if (refType.contains("::")) { refTypeLib = refType; - refType = refType.mid(refType.lastIndexOf("::") + 2); + refType.remove(0, refType.lastIndexOf("::") + 2); if (refTypeLib.contains(' ')) { refType = refTypeLib.left(refTypeLib.indexOf(' ')) + ' ' + refType; } @@ -1165,7 +1171,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, TYPEKIND typekind; typelib->GetTypeInfoType(index, &typekind); - uint object_category = category; + ObjectCategories object_category = category; if (!(typeattr->wTypeFlags & TYPEFLAG_FCANCREATE)) object_category |= SubObject; else if (typeattr->wTypeFlags & TYPEFLAG_FCONTROL) @@ -1219,18 +1225,22 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, if (typeattr->wTypeFlags & TYPEFLAG_FLICENSED) object_category |= Licensed; if (typekind == TKIND_COCLASS) { // write those later... - generateClassDecl(classesOut, guid.toString(), metaObject, className, libName.toLatin1(), (ObjectCategory)(object_category|NoInlines)); + generateClassDecl(classesOut, guid.toString(), metaObject, className, libName.toLatin1(), + object_category | NoInlines); classesOut << endl; } else { - generateClassDecl(declOut, guid.toString(), metaObject, className, libName.toLatin1(), (ObjectCategory)(object_category|NoInlines)); + generateClassDecl(declOut, guid.toString(), metaObject, className, libName.toLatin1(), + object_category | NoInlines); declOut << endl; } subtypes << className; - generateClassDecl(inlinesOut, guid.toString(), metaObject, className, libName.toLatin1(), (ObjectCategory)(object_category|OnlyInlines)); + generateClassDecl(inlinesOut, guid.toString(), metaObject, className, libName.toLatin1(), + object_category | OnlyInlines); inlinesOut << endl; } if (implFile.isOpen()) - generateClassImpl(classImplOut, metaObject, className, libName.toLatin1(), (ObjectCategory)object_category); + generateClassImpl(classImplOut, metaObject, className, libName.toLatin1(), + object_category); } currentTypeInfo = 0; } @@ -1411,7 +1421,7 @@ struct Options Options() : mode(GenerateMode), category(DefaultObject), dispatchEqualsIDispatch(false) {} ProgramMode mode; - uint category; + ObjectCategories category; bool dispatchEqualsIDispatch; QString outname; @@ -1594,7 +1604,7 @@ int main(int argc, char **argv) return -2; } - if (!generateTypeLibrary(typeLib, options.outname, options.nameSpace, (ObjectCategory)options.category)) { + if (!generateTypeLibrary(typeLib, options.outname, options.nameSpace, options.category)) { qWarning("dumpcpp: error processing type library '%s'", qPrintable(typeLib)); return -1; } |