diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-05-24 09:47:11 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-05-24 09:47:11 +0200 |
commit | 235092d72f57d42de04501b04f6a3ff4d77adf74 (patch) | |
tree | f887244a022ea8508055412cb3e85ba8158cf509 /sources/shiboken2/generator/shiboken2 | |
parent | 6ba23a245449aaa9c1a7ab8e954d93f5f4366530 (diff) | |
parent | 8c772c12612b408b42e66ad0627d37477f42255a (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I38964a8efc7905afd879cd2a96e75149d5942c8a
Diffstat (limited to 'sources/shiboken2/generator/shiboken2')
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 12 | ||||
-rw-r--r-- | sources/shiboken2/generator/shiboken2/shibokengenerator.cpp | 10 |
2 files changed, 17 insertions, 5 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 32b219fa2..5fbc6ed3e 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -4892,7 +4892,11 @@ void CppGenerator::writeFlagsUnaryOperator(QTextStream& s, const AbstractMetaEnu QString CppGenerator::getSimpleClassInitFunctionName(const AbstractMetaClass *metaClass) const { - QString initFunctionName = metaClass->qualifiedCppName(); + QString initFunctionName; + // Disambiguate namespaces per module to allow for extending them. + if (metaClass->isNamespace()) + initFunctionName += moduleName(); + initFunctionName += metaClass->qualifiedCppName(); initFunctionName.replace(QLatin1String("::"), QLatin1String("_")); return initFunctionName; } @@ -4996,9 +5000,11 @@ void CppGenerator::writeClassRegister(QTextStream &s, } // 7:baseType - if (metaClass->baseClass()) { + const auto base = metaClass->isNamespace() + ? metaClass->extendedNamespace() : metaClass->baseClass(); + if (base) { s << INDENT << "reinterpret_cast<SbkObjectType *>(" - << cpythonTypeNameExt(metaClass->baseClass()->typeEntry()) << ")," << endl; + << cpythonTypeNameExt(base->typeEntry()) << ")," << endl; } else { s << INDENT << "0," << endl; } diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 44405c700..2b3b20c75 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -2667,8 +2667,14 @@ QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry* type) if (trueType->basicReferencedTypeEntry()) type = trueType->basicReferencedTypeEntry(); } - QString result = QLatin1String("SBK_") - + _fixedCppTypeName(type->qualifiedCppName()).toUpper(); + QString result = QLatin1String("SBK_"); + // Disambiguate namespaces per module to allow for extending them. + if (type->isNamespace()) { + QString package = type->targetLangPackage(); + const int dot = package.lastIndexOf(QLatin1Char('.')); + result += package.rightRef(package.size() - (dot + 1)); + } + result += _fixedCppTypeName(type->qualifiedCppName()).toUpper(); appendIndexSuffix(&result); return result; } |