From e801fdab20ad4f5f47deaf49600af0d5f02ecc51 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 6 Oct 2020 08:37:26 +0200 Subject: shiboken2: Simplify the export of the generated module init function Remove the version-dependent #ifdef. Change-Id: I15907500ab95d9e48d90a57893197c9b4f18a037 Reviewed-by: Cristian Maureira-Fredes --- sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 13 ++++++------- sources/shiboken2/libshiboken/sbkmodule.h | 6 ------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index ab8f5a6fc..18137a985 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -5964,9 +5964,10 @@ bool CppGenerator::finishGeneration() // PYSIDE-510: Create a signatures string for the introspection feature. writeSignatureStrings(s, signatureStream, moduleName(), "global functions"); - s << "SBK_MODULE_INIT_FUNCTION_BEGIN(" << moduleName() << ")\n"; + s << "extern \"C\" LIBSHIBOKEN_EXPORT PyObject *PyInit_" + << moduleName() << "()\n{\n"; - ErrorCode errorCode(QLatin1String("SBK_MODULE_INIT_ERROR")); + ErrorCode errorCode(QLatin1String("nullptr")); // module inject-code target/beginning if (!snips.isEmpty()) writeCodeSnips(s, snips, TypeSystem::CodeSnipPositionBeginning, TypeSystem::TargetLangCode); @@ -5975,7 +5976,7 @@ bool CppGenerator::finishGeneration() s << INDENT << "{\n" << indent(INDENT) << INDENT << "Shiboken::AutoDecRef requiredModule(Shiboken::Module::import(\"" << requiredModule << "\"));\n" << INDENT << "if (requiredModule.isNull())\n" << indent(INDENT) - << INDENT << "return SBK_MODULE_INIT_ERROR;\n" << outdent(INDENT) + << INDENT << "return nullptr;\n" << outdent(INDENT) << INDENT << cppApiVariableName(requiredModule) << " = Shiboken::Module::getTypes(requiredModule);\n" << INDENT << convertersVariableName(requiredModule) @@ -6078,10 +6079,8 @@ bool CppGenerator::finishGeneration() // finish the rest of __signature__ initialization. s << INDENT << "FinishSignatureInitialization(module, " << moduleName() - << "_SignatureStrings);\n"; - - s << Qt::endl; - s << "SBK_MODULE_INIT_FUNCTION_END\n"; + << "_SignatureStrings);\n" + << INDENT << "\nreturn module;\n}\n"; return file.done() != FileOut::Failure; } diff --git a/sources/shiboken2/libshiboken/sbkmodule.h b/sources/shiboken2/libshiboken/sbkmodule.h index 87205a207..02e4a2706 100644 --- a/sources/shiboken2/libshiboken/sbkmodule.h +++ b/sources/shiboken2/libshiboken/sbkmodule.h @@ -43,12 +43,6 @@ #include "sbkpython.h" #include "shibokenmacros.h" -#define SBK_MODULE_INIT_ERROR 0 -#define SBK_MODULE_INIT_FUNCTION_BEGIN(ModuleName) \ - extern "C" LIBSHIBOKEN_EXPORT PyObject *PyInit_##ModuleName() { -#define SBK_MODULE_INIT_FUNCTION_END \ - return module; } - extern "C" { struct SbkConverter; -- cgit v1.2.3