aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/generator')
-rw-r--r--sources/shiboken2/generator/CMakeLists.txt33
-rw-r--r--sources/shiboken2/generator/generator.cpp4
-rw-r--r--sources/shiboken2/generator/main.cpp6
-rw-r--r--sources/shiboken2/generator/qtdoc/CMakeLists.txt21
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp2
-rw-r--r--sources/shiboken2/generator/shiboken2/CMakeLists.txt28
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp39
-rw-r--r--sources/shiboken2/generator/shiboken2/overloaddata.cpp2
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp5
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.h2
10 files changed, 43 insertions, 99 deletions
diff --git a/sources/shiboken2/generator/CMakeLists.txt b/sources/shiboken2/generator/CMakeLists.txt
index 943e8d19b..745c366f5 100644
--- a/sources/shiboken2/generator/CMakeLists.txt
+++ b/sources/shiboken2/generator/CMakeLists.txt
@@ -1,8 +1,5 @@
project(shibokengenerator)
-find_package(Qt5Xml)
-find_package(Qt5XmlPatterns)
-
set(shiboken2_SRC
generator.cpp
shiboken2/cppgenerator.cpp
@@ -12,29 +9,23 @@ shiboken2/shibokengenerator.cpp
main.cpp
)
-if (NOT DISABLE_DOCSTRINGS)
- set(shiboken2_SRC ${shiboken2_SRC} qtdoc/qtdocgenerator.cpp)
- add_definitions(-DDOCSTRINGS_ENABLED)
-endif()
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/shiboken2
+add_executable(shiboken2 ${shiboken2_SRC})
+add_executable(Shiboken2::shiboken2 ALIAS shiboken2)
+add_dependencies(shiboken2 apiextractor)
+set_target_properties(shiboken2 PROPERTIES OUTPUT_NAME shiboken2${shiboken2_SUFFIX})
+target_include_directories(shiboken2 PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/shiboken2
${CMAKE_CURRENT_SOURCE_DIR}/qtdoc
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${apiextractor_SOURCE_DIR}
- ${Qt5Core_INCLUDE_DIRS}
- ${Qt5XmlPatterns_INCLUDE_DIRS}
)
-
-add_executable(shiboken2 ${shiboken2_SRC})
-add_executable(Shiboken2::shiboken2 ALIAS shiboken2)
-add_dependencies(shiboken2 apiextractor)
-set_target_properties(shiboken2 PROPERTIES OUTPUT_NAME shiboken2${shiboken2_SUFFIX})
-target_link_libraries(shiboken2
- apiextractor
- ${Qt5Core_LIBRARIES}
- ${Qt5XmlPatterns_LIBRARIES}
- )
+target_link_libraries(shiboken2 apiextractor Qt5::Core)
+if (NOT DISABLE_DOCSTRINGS)
+ target_sources(shiboken2 PRIVATE qtdoc/qtdocgenerator.cpp)
+ target_compile_definitions(shiboken2 PUBLIC DOCSTRINGS_ENABLED)
+ target_link_libraries(shiboken2 Qt5::XmlPatterns)
+endif()
configure_file(shibokenconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/shibokenconfig.h" @ONLY)
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp
index 91e940f51..87758e533 100644
--- a/sources/shiboken2/generator/generator.cpp
+++ b/sources/shiboken2/generator/generator.cpp
@@ -421,7 +421,7 @@ bool Generator::generate()
for (const AbstractMetaType *type : qAsConst(m_d->instantiatedSmartPointers)) {
AbstractMetaClass *smartPointerClass =
- AbstractMetaClass::findClass(m_d->apiextractor->smartPointers(), type->name());
+ AbstractMetaClass::findClass(m_d->apiextractor->smartPointers(), type->typeEntry());
GeneratorContext context(smartPointerClass, type, true);
if (!generateFileForContext(context))
return false;
@@ -538,7 +538,7 @@ bool Generator::isObjectType(const TypeEntry* type)
}
bool Generator::isObjectType(const ComplexTypeEntry* type)
{
- return type->isObject() || type->isQObject();
+ return type->isObject();
}
bool Generator::isObjectType(const AbstractMetaClass* metaClass)
{
diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp
index 094990b64..1817f6b03 100644
--- a/sources/shiboken2/generator/main.cpp
+++ b/sources/shiboken2/generator/main.cpp
@@ -373,8 +373,10 @@ static void parseIncludePathOption(const QString &option, HeaderType headerType,
const QStringList includePathListList =
it.value().split(pathSplitter, QString::SkipEmptyParts);
args.erase(it);
- for (const QString &s : includePathListList)
- extractor.addIncludePath(HeaderPath{QFile::encodeName(s), headerType});
+ for (const QString &s : includePathListList) {
+ auto path = QFile::encodeName(QDir::cleanPath(s));
+ extractor.addIncludePath(HeaderPath{path, headerType});
+ }
}
}
diff --git a/sources/shiboken2/generator/qtdoc/CMakeLists.txt b/sources/shiboken2/generator/qtdoc/CMakeLists.txt
deleted file mode 100644
index 1361ba8f1..000000000
--- a/sources/shiboken2/generator/qtdoc/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-project(qtdoc_generator)
-
-set(qtdoc_generator_SRC
-qtdocgenerator.cpp
-)
-
-include_directories(${generators_SOURCE_DIR}
- ${Qt5Core_INCLUDE_DIRS}
- ${APIEXTRACTOR_INCLUDE_DIR})
-add_executable(docgenerator main.cpp)
-set_target_properties(docgenerator PROPERTIES OUTPUT_NAME docgenerator${generator_SUFFIX})
-
-target_link_libraries(docgenerator ${Qt5Core_LIBRARES})
-
-add_library(qtdoc_generator SHARED ${qtdoc_generator_SRC})
-target_link_libraries(qtdoc_generator ${APIEXTRACTOR_LIBRARY} ${Qt5Core_LIBRARES} genrunner)
-set_property(TARGET qtdoc_generator PROPERTY PREFIX "")
-
-install(TARGETS qtdoc_generator DESTINATION ${generator_plugin_DIR})
-install(TARGETS docgenerator DESTINATION bin)
-
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 05729f4b5..6abfde7c9 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -1872,7 +1872,7 @@ QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* /* cppClass */
defValue.replace(QLatin1String("::"), QLatin1String("."));
if (defValue == QLatin1String("nullptr"))
defValue = none();
- else if (defValue == QLatin1String("0") && (arg->type()->isQObject() || arg->type()->isObject()))
+ else if (defValue == QLatin1String("0") && arg->type()->isObject())
defValue = none();
}
ret += QLatin1Char('=') + defValue;
diff --git a/sources/shiboken2/generator/shiboken2/CMakeLists.txt b/sources/shiboken2/generator/shiboken2/CMakeLists.txt
deleted file mode 100644
index 5c1b612dd..000000000
--- a/sources/shiboken2/generator/shiboken2/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-project(shibokengenerator)
-
-set(shiboken_SRC
-../generator.cpp
-cppgenerator.cpp
-headergenerator.cpp
-overloaddata.cpp
-shibokengenerator.cpp
-main.cpp
-)
-
-include_directories(${generators_SOURCE_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${APIEXTRACTOR_INCLUDE_DIR}
- ${Qt5Core_INCLUDE_DIRS}
- )
-
-add_executable(shiboken2 ${shiboken_SRC})
-set_target_properties(shiboken2 PROPERTIES OUTPUT_NAME shiboken2${shiboken_SUFFIX})
-target_link_libraries(shiboken2
- ${APIEXTRACTOR_LIBRARY}
- ${Qt5Core_LIBRARIES}
- )
-
-configure_file(shibokenconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/shibokenconfig.h" @ONLY)
-
-install(TARGETS shiboken2 DESTINATION bin)
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 2fedf9ae1..29220c739 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -664,7 +664,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
s << NULL_PTR;
s << "}," << endl;
}
- s << INDENT << '{' << NULL_PTR << "} // Sentinel" << endl;
+ s << INDENT << '{' << NULL_PTR << "} // Sentinel" << endl;
s << "};" << endl << endl;
}
@@ -907,7 +907,6 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
QTextStream ac(&argConv);
const PrimitiveTypeEntry* argType = (const PrimitiveTypeEntry*) arg->type()->typeEntry();
bool convert = argType->isObject()
- || arg->type()->isQObject()
|| argType->isValue()
|| arg->type()->isValuePointer()
|| arg->type()->isNativePointer()
@@ -3076,7 +3075,7 @@ QString CppGenerator::argumentNameFromIndex(const AbstractMetaFunction* func, in
AbstractMetaType *returnType = getTypeWithoutContainer(funcType);
if (returnType) {
pyArgName = QLatin1String(PYTHON_RETURN_VAR);
- *wrappedClass = AbstractMetaClass::findClass(classes(), returnType->typeEntry()->name());
+ *wrappedClass = AbstractMetaClass::findClass(classes(), returnType->typeEntry());
} else {
QString message = QLatin1String("Invalid Argument index (0, return value) on function modification: ")
+ (funcType ? funcType->name() : QLatin1String("void")) + QLatin1Char(' ');
@@ -3090,7 +3089,7 @@ QString CppGenerator::argumentNameFromIndex(const AbstractMetaFunction* func, in
AbstractMetaType* argType = getTypeWithoutContainer(func->arguments().at(realIndex)->type());
if (argType) {
- *wrappedClass = AbstractMetaClass::findClass(classes(), argType->typeEntry()->name());
+ *wrappedClass = AbstractMetaClass::findClass(classes(), argType->typeEntry());
if (argIndex == 1
&& !func->isConstructor()
&& OverloadData::isSingleArgument(getFunctionGroups(func->implementingClass())[func->name()]))
@@ -4925,11 +4924,11 @@ void CppGenerator::writeClassRegister(QTextStream &s,
// PYSIDE-510: Create a signatures string for the introspection feature.
s << "// The signatures string for the functions." << endl;
s << "// Multiple signatures have their index \"n:\" in front." << endl;
- s << "const char " << initFunctionName << "_SignaturesString[] = \"\"" << endl;
+ s << "static const char *" << initFunctionName << "_SignatureStrings[] = {" << endl;
QString line;
while (signatureStream.readLineInto(&line))
- s << INDENT << '"' << line << "\\n\"" << endl;
- s << ';' << endl << endl;
+ s << INDENT << '"' << line << "\"," << endl;
+ s << INDENT << NULL_PTR << "}; // Sentinel" << endl << endl;
s << "void init_" << initFunctionName;
s << "(PyObject* " << enclosingObjectVariable << ")" << endl;
s << '{' << endl;
@@ -4982,8 +4981,8 @@ void CppGenerator::writeClassRegister(QTextStream &s,
// 4:typeSpec
s << INDENT << '&' << chopType(pyTypeName) << "_spec," << endl;
- // 5:signaturesString
- s << INDENT << initFunctionName << "_SignaturesString," << endl;
+ // 5:signatureStrings
+ s << INDENT << initFunctionName << "_SignatureStrings," << endl;
// 6:cppObjDtor
s << INDENT;
@@ -5657,7 +5656,17 @@ bool CppGenerator::finishGeneration()
s << " /* m_clear */ nullptr," << endl;
s << " /* m_free */ nullptr" << endl;
s << "};" << endl << endl;
- s << "#endif" << endl;
+ s << "#endif" << 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 << "static const char *" << moduleName() << "_SignatureStrings[] = {" << endl;
+ QString line;
+ while (signatureStream.readLineInto(&line))
+ s << INDENT << '"' << line << "\"," << endl;
+ s << INDENT << NULL_PTR << "}; // Sentinel" << endl << endl;
+
s << "SBK_MODULE_INIT_FUNCTION_BEGIN(" << moduleName() << ")" << endl;
ErrorCode errorCode(QLatin1String("SBK_MODULE_INIT_ERROR"));
@@ -5788,17 +5797,9 @@ bool CppGenerator::finishGeneration()
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;
+ << "_SignatureStrings);" << endl;
if (usePySideExtensions()) {
// initialize the qApp module.
diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
index 9f0ac51e5..becd66879 100644
--- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp
+++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
@@ -322,7 +322,7 @@ void OverloadData::sortNextOverloads()
}
// Process inheritance relationships
- if (targetType->isValue() || targetType->isObject() || targetType->isQObject()) {
+ if (targetType->isValue() || targetType->isObject()) {
const AbstractMetaClass *metaClass = AbstractMetaClass::findClass(m_generator->classes(), targetType->typeEntry());
const AbstractMetaClassList &ancestors = m_generator->getAllAncestors(metaClass);
for (const AbstractMetaClass *ancestor : ancestors) {
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index b5069db14..002ab8cfb 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -373,7 +373,7 @@ QString ShibokenGenerator::fullPythonClassName(const AbstractMetaClass *metaClas
return fullClassName;
}
-QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunction *func) //WS
+QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunction *func)
{
QString funcName;
if (func->isOperatorOverload())
@@ -729,8 +729,7 @@ QString ShibokenGenerator::getFormatUnitString(const AbstractMetaFunction* func,
if (!func->typeReplaced(arg->argumentIndex() + 1).isEmpty()) {
result += QLatin1Char(objType);
- } else if (arg->type()->isQObject()
- || arg->type()->isObject()
+ } else if (arg->type()->isObject()
|| arg->type()->isValue()
|| arg->type()->isValuePointer()
|| arg->type()->isNativePointer()
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
index d2c4b3292..80b172778 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
@@ -216,7 +216,7 @@ protected:
QString wrapperName(const AbstractMetaType *metaType) const;
QString fullPythonClassName(const AbstractMetaClass *metaClass);
- QString fullPythonFunctionName(const AbstractMetaFunction *func); //WS
+ QString fullPythonFunctionName(const AbstractMetaFunction *func);
static QString protectedEnumSurrogateName(const AbstractMetaEnum* metaEnum);
static QString protectedFieldGetterName(const AbstractMetaField* field);