diff options
author | Christian Tismer <tismer@stackless.com> | 2020-05-04 17:38:04 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2020-05-14 15:26:11 +0200 |
commit | d6b81b6303957803582d0fae95a9b25483d8e7f2 (patch) | |
tree | aab5f9f3438eb59c21ecc18530c0c48e5c10a393 /sources/shiboken2/generator/shiboken2/cppgenerator.cpp | |
parent | f6519b1d343bc26a53374d3066e90495f1959c78 (diff) |
shiboken: Prepare for introduction of __qualname__
To remove the groundwork from the next checkin, the step
of replacing PyType_FromSpec with SbkType_FromSpec
is extracted.
This change introduces a packageLevel number that is generated
as a name prefix in the class creation but does not use it, yet.
Change-Id: Ic9061231708b546dbd3620d148bca24c27df60a5
Task-number: PYSIDE-1286
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken2/generator/shiboken2/cppgenerator.cpp')
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index c0c54f274..64467e3d1 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -4037,8 +4037,10 @@ void CppGenerator::writeClassDefinition(QTextStream &s, } s << INDENT << "{0, " << NULL_PTR << "}\n"; s << "};\n"; + + int packageLevel = packageName().count(QLatin1Char('.')) + 1; s << "static PyType_Spec " << className << "_spec = {\n"; - s << INDENT << "\"" << computedClassTargetFullName << "\",\n"; + s << INDENT << '"' << packageLevel << ':' << computedClassTargetFullName << "\",\n"; s << INDENT << "sizeof(SbkObject),\n"; s << INDENT << "0,\n"; s << INDENT << tp_flags << ",\n"; @@ -4667,6 +4669,7 @@ void CppGenerator::writeEnumInitialization(QTextStream &s, const AbstractMetaEnu QString enumVarTypeObj; if (!cppEnum->isAnonymous()) { + int packageLevel = packageName().count(QLatin1Char('.')) + 1; FlagsTypeEntry *flags = enumTypeEntry->flags(); if (flags) { // The following could probably be made nicer: @@ -4674,7 +4677,7 @@ void CppGenerator::writeEnumInitialization(QTextStream &s, const AbstractMetaEnu QString fullPath = getClassTargetFullName(cppEnum); fullPath.truncate(fullPath.lastIndexOf(QLatin1Char('.')) + 1); s << INDENT << cpythonTypeNameExt(flags) << " = PySide::QFlags::create(\"" - << fullPath << flags->flagsName() << "\", " + << packageLevel << ':' << fullPath << flags->flagsName() << "\", " << cpythonEnumName(cppEnum) << "_number_slots);\n"; } @@ -4686,7 +4689,7 @@ void CppGenerator::writeEnumInitialization(QTextStream &s, const AbstractMetaEnu { Indentation indent(INDENT); s << INDENT << '"' << cppEnum->name() << "\",\n"; - s << INDENT << '"' << getClassTargetFullName(cppEnum) << "\",\n"; + s << INDENT << '"' << packageLevel << ':' << getClassTargetFullName(cppEnum) << "\",\n"; s << INDENT << '"' << (cppEnum->enclosingClass() ? (cppEnum->enclosingClass()->qualifiedCppName() + QLatin1String("::")) : QString()); s << cppEnum->name() << '"'; if (flags) |