aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2018-10-14 11:13:40 +0200
committerChristian Tismer <tismer@stackless.com>2018-11-15 10:24:23 +0000
commit2533dab013455bf94da2d4766e54abaf4d735e1e (patch)
tree506f169c2f3a44fed3bfe623c1f626d40836a379 /sources/shiboken2/generator
parent93b54f123771c5b7da9880e9a2f372562893707f (diff)
Signature: Implement Nested Classes and Functions for Shiboken
This patch again contains a complete overhaul of the signature module. The code was re-implemented to properly support nested classes. Also, the code was reduced by AutoDecRef and by adopting a concise C++ style. Note.. We will add a shiboken signature test and complete mapping.py after the split into three projects is done. The split changes a lot and is needed right now! Signatures were quite complete for PySide, but the support for Shiboken was under-developed. Since we are planning to generally enhance error messages by using the Signature module, we should be able to rely on them to always produce a signature. Therefore, a general overhaul was needed to resolve all cornes cases for Python 2 and 3. Nested classes are supported, as well as plain module functions. The usage of the typing module might improve over time, but the Signature implementation is now considered complete. The loader will respect now the path settings which might not be the package dir but the build dir. This is more consistens with COIN testing. Task-number: PYSIDE-795 Change-Id: I246449d4df895dadf2bcb4d997eaa13d78463d9b Reviewed-by: Simo Fält <simo.falt@qt.io>
Diffstat (limited to 'sources/shiboken2/generator')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 99947d347..393f8a850 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -5415,10 +5415,10 @@ bool CppGenerator::finishGeneration()
s << "#include <sbkpython.h>" << endl;
s << "#include <shiboken.h>" << endl;
s << "#include <algorithm>" << endl;
+ s << "#include <signature.h>" << endl;
if (usePySideExtensions()) {
s << includeQDebug;
s << "#include <pyside.h>" << endl;
- s << "#include <signature.h>" << endl;
s << "#include <qapp_macro.h>" << endl;
}
@@ -5714,22 +5714,25 @@ bool CppGenerator::finishGeneration()
// cleanup staticMetaObject attribute
s << INDENT << "PySide::registerCleanupFunction(cleanTypesAttributes);" << endl << endl;
+ }
- // PYSIDE-510: Create a signatures string for the introspection feature.
- s << "// The signatures string for the global functions." << endl;
- s << "// Multiple signatures have their index \"n:\" in front." << endl;
- s << "const char " << moduleName() << "_SignaturesString[] = \"\"" << endl;
- QString line;
- while (signatureStream.readLineInto(&line))
- s << INDENT << '"' << line << "\\n\"" << endl;
- s << ';' << endl;
- // finish the rest of __signature__ initialization.
- s << INDENT << "FinishSignatureInitialization(module, " << moduleName()
- << "_SignaturesString);" << endl;
+ // PYSIDE-510: Create a signatures string for the introspection feature.
+ s << "// The signatures string for the global functions." << endl;
+ s << "// Multiple signatures have their index \"n:\" in front." << endl;
+ s << "const char " << moduleName() << "_SignaturesString[] = \"\"" << endl;
+ QString line;
+ while (signatureStream.readLineInto(&line))
+ s << INDENT << '"' << line << "\\n\"" << endl;
+ s << ';' << endl;
+ // finish the rest of __signature__ initialization.
+ s << INDENT << "FinishSignatureInitialization(module, " << moduleName()
+ << "_SignaturesString);" << endl;
+
+ if (usePySideExtensions()) {
// initialize the qApp module.
- s << INDENT << "NotifyModuleForQApp(module);" << endl << endl;
+ s << INDENT << "NotifyModuleForQApp(module);" << endl;
}
-
+ s << endl;
s << "SBK_MODULE_INIT_FUNCTION_END" << endl;
return file.done() != FileOut::Failure;