diff --git a/ApiExtractor/CMakeLists.txt b/ApiExtractor/CMakeLists.txt index 1e6edaf..c352ba0 100644 --- a/ApiExtractor/CMakeLists.txt +++ b/ApiExtractor/CMakeLists.txt @@ -21,10 +21,9 @@ if(BUILD_TESTS) set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tests) endif () -set(QT_USE_QTCORE 1) -set(QT_USE_QTXML 1) -include(${QT_USE_FILE}) -add_definitions(${QT_DEFINITIONS}) +find_package(Qt5Core REQUIRED) +find_package(Qt5Xml REQUIRED) +find_package(Qt5XmlPatterns REQUIRED) add_definitions(-DQT_PLUGIN) add_definitions(-DQT_SHARED) add_definitions(-DRXX_ALLOCATOR_INIT_0) @@ -79,19 +78,17 @@ endif() set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) -qt4_add_resources(apiextractor_RCCS_SRC generator.qrc) -qt4_automoc(apiextractor_SRC) +qt5_add_resources(apiextractor_RCCS_SRC generator.qrc) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/parser ${CMAKE_CURRENT_SOURCE_DIR}/parser/rpp - ${QT_INCLUDE_DIR} ${APIEXTRACTOR_EXTRA_INCLUDES} ) add_library(apiextractor STATIC ${apiextractor_SRC} ${apiextractor_RCCS_SRC}) -target_link_libraries(apiextractor ${APIEXTRACTOR_EXTRA_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTXMLPATTERNS_LIBRARY} ${QT_QTXML_LIBRARY}) +target_link_libraries(apiextractor ${APIEXTRACTOR_EXTRA_LIBRARIES} Qt5::Core Qt5::XmlPatterns Qt5::Xml) if (BUILD_TESTS) enable_testing() diff --git a/ApiExtractor/abstractmetabuilder.cpp b/ApiExtractor/abstractmetabuilder.cpp index 51b1c7a..722bd12 100644 --- a/ApiExtractor/abstractmetabuilder.cpp +++ b/ApiExtractor/abstractmetabuilder.cpp @@ -34,20 +34,20 @@ #include "parser/parser.h" #include "parser/tokens.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include "graph.h" -#include +#include static QString stripTemplateArgs(const QString &name) { @@ -451,9 +451,8 @@ bool AbstractMetaBuilder::build(QIODevice* input) ReportHandler::flush(); // We need to know all global enums - QHash enumMap = m_dom->enumMap(); - ReportHandler::setProgressReference(enumMap); - foreach (EnumModelItem item, enumMap) { + ReportHandler::setProgressReference(m_dom->enumMap()); + foreach (EnumModelItem item, m_dom->enums()) { ReportHandler::progress("Generating enum model..."); AbstractMetaEnum *metaEnum = traverseEnum(item, 0, QSet()); if (metaEnum) { @@ -1501,26 +1500,33 @@ void AbstractMetaBuilder::traverseInstantiation(ComplexTypeEntry *entry, Abstrac addRedirections(entry, metaClass, argClass, accessor); + // Make pointer wrappers dependent on the wrapped object, in order + // to ensure that the pointer comes after the underlying class in + // topological sorting if (wrapsPointer - && entry->templateType()->wrapsPointerArg() == ordinal - && !argClass->baseClassName().isEmpty()) { - QStringList argList = parseTemplateType(metaClass->qualifiedCppName()); - QString templateClass = argList.takeFirst(); - argList[ordinal] = argClass->baseClass()->qualifiedCppName(); - QString baseTemplateClass = QString("%1< %2 >").arg(templateClass).arg(argList.join(", ")); - - AbstractMetaClass* baseMetaClass = m_metaClasses.findClass(baseTemplateClass); - - if (baseMetaClass) { - metaClass->setHasInjectedDependencies(); - baseMetaClass->setHasInjectedDependencies(); - if (!metaClass->baseClass()) - metaClass->setBaseClass(baseMetaClass); - metaClass->addBaseClassName(baseTemplateClass); - } else { - QString warn = QString("want to inherit %1 from same class with arg %2 replaced with %3, but it is an unknown type.") - .arg(metaClass->name()).arg(ordinal).arg(argClass->baseClass()->qualifiedCppName()); - ReportHandler::warning(warn); + && entry->templateType()->wrapsPointerArg() == ordinal) { + metaClass->addExtraDependency(argClass->qualifiedCppName()); + + // In case of a single template argument, make the pointer to + // base class a dependent of this pointer; needed for + // downcasting to work + if (argTypes.count() == 1 && !argClass->baseClassName().isEmpty()) { + QStringList argList = parseTemplateType(metaClass->qualifiedCppName()); + QString templateClass = argList.takeFirst(); + argList[ordinal] = argClass->baseClass()->qualifiedCppName(); + QString baseTemplateClass = QString("%1< %2 >").arg(templateClass).arg(argList.join(", ")); + + AbstractMetaClass* baseMetaClass = m_metaClasses.findClass(baseTemplateClass); + + if (baseMetaClass) { + if (!metaClass->baseClass()) + metaClass->setBaseClass(baseMetaClass); + metaClass->addBaseClassName(baseTemplateClass); + } else { + QString warn = QString("want to inherit %1 from same class with arg %2 replaced with %3, but it is an unknown type.") + .arg(metaClass->name()).arg(ordinal).arg(argClass->baseClass()->qualifiedCppName()); + ReportHandler::warning(warn); + } } } } @@ -2791,20 +2797,30 @@ AbstractMetaClass* AbstractMetaBuilder::findTemplateClass(const QString& name, c return 0; } -AbstractMetaClassList AbstractMetaBuilder::getBaseClasses(const AbstractMetaClass* metaClass, bool useTemplate) const +AbstractMetaClassList AbstractMetaBuilder::resolveClassDependencies(const AbstractMetaClass* metaClass, + const QStringList &names) const { - AbstractMetaClassList baseClasses; - foreach (const QString& parent, metaClass->baseClassNames()) { - AbstractMetaClass* cls = 0; - if (useTemplate && parent.contains('<')) + AbstractMetaClassList dependencies; + foreach (const QString& parent, names) { + AbstractMetaClass* cls = m_metaClasses.findClass(parent); + + if (!cls && parent.contains('<')) cls = findTemplateClass(parent, metaClass); - else - cls = m_metaClasses.findClass(parent); if (cls) - baseClasses << cls; + dependencies << cls; } - return baseClasses; + return dependencies; +} + +AbstractMetaClassList AbstractMetaBuilder::getBaseClasses(const AbstractMetaClass* metaClass) const +{ + return resolveClassDependencies(metaClass, metaClass->baseClassNames()); +} + +AbstractMetaClassList AbstractMetaBuilder::getExtraDependencyClasses(const AbstractMetaClass* metaClass) const +{ + return resolveClassDependencies(metaClass, metaClass->extraDependencies()); } bool AbstractMetaBuilder::ancestorHasPrivateCopyConstructor(const AbstractMetaClass* metaClass) const @@ -3213,14 +3229,10 @@ AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted(const Abstra QRegExp regex1("\\(.*\\)"); QRegExp regex2("::.*"); foreach (AbstractMetaClass* clazz, classList) { - if (!clazz->hasInjectedDependencies() && - (clazz->isInterface() || !clazz->typeEntry()->generateCode())) - continue; - if (clazz->enclosingClass() && map.contains(clazz->enclosingClass()->qualifiedCppName())) graph.addEdge(map[clazz->enclosingClass()->qualifiedCppName()], map[clazz->qualifiedCppName()]); - AbstractMetaClassList bases = getBaseClasses(clazz, false); + AbstractMetaClassList bases = getBaseClasses(clazz); foreach(AbstractMetaClass* baseClass, bases) { // Fix polymorphic expression if (clazz->baseClass() == baseClass) @@ -3230,6 +3242,12 @@ AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted(const Abstra graph.addEdge(map[baseClass->qualifiedCppName()], map[clazz->qualifiedCppName()]); } + AbstractMetaClassList extraDeps = getExtraDependencyClasses(clazz); + foreach(AbstractMetaClass* dependencyClass, extraDeps) { + if (map.contains(dependencyClass->qualifiedCppName())) + graph.addEdge(map[dependencyClass->qualifiedCppName()], map[clazz->qualifiedCppName()]); + } + foreach (AbstractMetaFunction* func, clazz->functions()) { foreach (AbstractMetaArgument* arg, func->arguments()) { // check methods with default args diff --git a/ApiExtractor/abstractmetabuilder.h b/ApiExtractor/abstractmetabuilder.h index ef1abb7..6580f28 100644 --- a/ApiExtractor/abstractmetabuilder.h +++ b/ApiExtractor/abstractmetabuilder.h @@ -29,8 +29,8 @@ #include "typesystem.h" #include "typeparser.h" -#include -#include +#include +#include class TypeDatabase; @@ -171,7 +171,8 @@ class AbstractMetaBuilder AbstractMetaClass *findTemplateClass(const QString& name, const AbstractMetaClass *context, TypeParser::Info *info = 0, ComplexTypeEntry **baseContainerType = 0) const; - AbstractMetaClassList getBaseClasses(const AbstractMetaClass* metaClass, bool useTemplate = true) const; + AbstractMetaClassList getBaseClasses(const AbstractMetaClass* metaClass) const; + AbstractMetaClassList getExtraDependencyClasses(const AbstractMetaClass* metaClass) const; bool ancestorHasPrivateCopyConstructor(const AbstractMetaClass* metaClass) const; bool inheritTemplate(AbstractMetaClass *subclass, @@ -244,6 +245,9 @@ class AbstractMetaBuilder void fixArgumentNames(AbstractMetaFunction* func); void fillAddedFunctions(AbstractMetaClass* metaClass); + AbstractMetaClassList resolveClassDependencies(const AbstractMetaClass* metaClass, + const QStringList &names) const; + AbstractMetaClassList m_metaClasses; AbstractMetaClassList m_templates; AbstractMetaFunctionList m_globalFunctions; diff --git a/ApiExtractor/abstractmetalang.h b/ApiExtractor/abstractmetalang.h index 3a63bfb..eb8b7e4 100644 --- a/ApiExtractor/abstractmetalang.h +++ b/ApiExtractor/abstractmetalang.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include class AbstractMeta; @@ -1429,7 +1429,7 @@ class AbstractMetaClass : public AbstractMetaAttributes m_primaryInterfaceImplementor(0), m_typeEntry(0), m_stream(false), - m_hasInjectedDependencies(false) + m_hasDependents(false) { } @@ -1701,20 +1701,24 @@ class AbstractMetaClass : public AbstractMetaAttributes */ bool hasProtectedMembers() const; - /** - * Tells if this class has dependencies injected by the metabuilder. - * \return true if the class has injected dependencies. - */ - bool hasInjectedDependencies() const + bool hasDependents() const { - return m_hasInjectedDependencies; + return m_hasDependents; } - /** - * Tell the metaclass that it has injected dependencies. - */ - void setHasInjectedDependencies() + + void setHasDependents(bool value) + { + m_hasDependents = value; + } + + QStringList extraDependencies() const + { + return m_extraDependencies; + } + + void addExtraDependency(const QString &name) { - m_hasInjectedDependencies = true; + m_extraDependencies.append(name); } QList templateArguments() const @@ -1982,12 +1986,13 @@ class AbstractMetaClass : public AbstractMetaAttributes AbstractMetaFunctionList m_externalConversionOperators; QStringList m_baseClassNames; + QStringList m_extraDependencies; QList m_templateArgs; ComplexTypeEntry *m_typeEntry; // FunctionModelItem m_qDebugStreamFunction; bool m_stream; - bool m_hasInjectedDependencies; + bool m_hasDependents; static int m_count; }; diff --git a/ApiExtractor/apiextractor.cpp b/ApiExtractor/apiextractor.cpp index c3c9e4a..e53db77 100644 --- a/ApiExtractor/apiextractor.cpp +++ b/ApiExtractor/apiextractor.cpp @@ -22,9 +22,9 @@ */ #include "apiextractor.h" -#include -#include -#include +#include +#include +#include #include #include "reporthandler.h" @@ -276,7 +276,7 @@ static bool preprocess(const QString& sourceFile, preprocess.push_include_path("."); foreach (QString include, includes) - preprocess.push_include_path(QDir::convertSeparators(include).toStdString()); + preprocess.push_include_path(QDir::toNativeSeparators(include).toStdString()); preprocess.push_include_path("/usr/include"); QString currentDir = QDir::current().absolutePath(); diff --git a/ApiExtractor/apiextractor.h b/ApiExtractor/apiextractor.h index f43c2c5..ad7701a 100644 --- a/ApiExtractor/apiextractor.h +++ b/ApiExtractor/apiextractor.h @@ -27,7 +27,7 @@ #include "reporthandler.h" #include "abstractmetalang.h" #include "apiextractormacros.h" -#include +#include class AbstractMetaBuilder; class QIODevice; diff --git a/ApiExtractor/docparser.cpp b/ApiExtractor/docparser.cpp index 56144c8..3e8e031 100644 --- a/ApiExtractor/docparser.cpp +++ b/ApiExtractor/docparser.cpp @@ -23,7 +23,7 @@ #include "docparser.h" #include #include -#include +#include #include #include diff --git a/ApiExtractor/docparser.h b/ApiExtractor/docparser.h index b7b0e44..ea4b828 100644 --- a/ApiExtractor/docparser.h +++ b/ApiExtractor/docparser.h @@ -23,8 +23,8 @@ #ifndef DOCPARSER_H #define DOCPARSER_H -#include -#include +#include +#include #include "abstractmetalang.h" diff --git a/ApiExtractor/fileout.cpp b/ApiExtractor/fileout.cpp index 9e8c2c7..4344668 100644 --- a/ApiExtractor/fileout.cpp +++ b/ApiExtractor/fileout.cpp @@ -206,7 +206,6 @@ bool FileOut::done() .arg(fileWrite.fileName())); return false; } - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); stream.setDevice(&fileWrite); stream << tmp; } diff --git a/ApiExtractor/graph.cpp b/ApiExtractor/graph.cpp index ef25447..8a147d4 100644 --- a/ApiExtractor/graph.cpp +++ b/ApiExtractor/graph.cpp @@ -22,14 +22,14 @@ */ #include "graph.h" -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include -#include +#include struct Graph::GraphPrivate { diff --git a/ApiExtractor/graph.h b/ApiExtractor/graph.h index ecdac9d..6607571 100644 --- a/ApiExtractor/graph.h +++ b/ApiExtractor/graph.h @@ -24,9 +24,9 @@ #ifndef GRAPH_H #define GRAPH_H -#include -#include -#include +#include +#include +#include /// A graph that can have their nodes topologically sorted. class Graph diff --git a/ApiExtractor/include.cpp b/ApiExtractor/include.cpp index a925006..8c1bbc2 100644 --- a/ApiExtractor/include.cpp +++ b/ApiExtractor/include.cpp @@ -22,8 +22,8 @@ */ #include "include.h" -#include -#include +#include +#include QString Include::toString() const { diff --git a/ApiExtractor/include.h b/ApiExtractor/include.h index 755cd9c..6213390 100644 --- a/ApiExtractor/include.h +++ b/ApiExtractor/include.h @@ -24,8 +24,8 @@ #ifndef INCLUDE_H #define INCLUDE_H -#include -#include +#include +#include class QTextStream; diff --git a/ApiExtractor/parser/codemodel.cpp b/ApiExtractor/parser/codemodel.cpp index 43a8c7e..7e3468a 100644 --- a/ApiExtractor/parser/codemodel.cpp +++ b/ApiExtractor/parser/codemodel.cpp @@ -406,7 +406,10 @@ FunctionDefinitionList _ScopeModelItem::functionDefinitions() const EnumList _ScopeModelItem::enums() const { - return _M_enums.values(); + EnumList result; + foreach (const QString& name, _M_enumNames) + result.append(_M_enums.value(name)); + return result; } void _ScopeModelItem::addClass(ClassModelItem item) @@ -440,7 +443,9 @@ void _ScopeModelItem::addTypeAlias(TypeAliasModelItem item) void _ScopeModelItem::addEnum(EnumModelItem item) { + _M_enumNames.removeOne(item->name()); _M_enums.insert(item->name(), item); + _M_enumNames.append(item->name()); } void _ScopeModelItem::removeClass(ClassModelItem item) @@ -499,8 +504,10 @@ void _ScopeModelItem::removeEnum(EnumModelItem item) { QHash::Iterator it = _M_enums.find(item->name()); - if (it != _M_enums.end() && it.value() == item) + if (it != _M_enums.end() && it.value() == item) { + _M_enumNames.removeOne(item->name()); _M_enums.erase(it); + } } ClassModelItem _ScopeModelItem::findClass(const QString &name) const diff --git a/ApiExtractor/parser/codemodel.h b/ApiExtractor/parser/codemodel.h index 3b3571f..82de75b 100644 --- a/ApiExtractor/parser/codemodel.h +++ b/ApiExtractor/parser/codemodel.h @@ -401,6 +401,7 @@ class _ScopeModelItem: public _CodeModelItem _ScopeModelItem(const _ScopeModelItem &other); void operator = (const _ScopeModelItem &other); + QStringList _M_enumNames; QStringList _M_enumsDeclarations; }; diff --git a/ApiExtractor/parser/codemodel_pointer.h b/ApiExtractor/parser/codemodel_pointer.h index 2c22f7a..fabc33c 100644 --- a/ApiExtractor/parser/codemodel_pointer.h +++ b/ApiExtractor/parser/codemodel_pointer.h @@ -26,7 +26,7 @@ #define CODEMODEL_POINTER_H #include -#include +#include template class CodeModelPointer : public QAtomicPointer { @@ -55,6 +55,11 @@ template class CodeModelPointer : public QAtomicPointer { return (const T *) *this; } + + inline T *operator->() const + { + return this->load(); + } }; #endif // CODEMODEL_POINTER_H diff --git a/ApiExtractor/parser/declarator_compiler.cpp b/ApiExtractor/parser/declarator_compiler.cpp index 2beef6d..5729893 100644 --- a/ApiExtractor/parser/declarator_compiler.cpp +++ b/ApiExtractor/parser/declarator_compiler.cpp @@ -31,7 +31,7 @@ #include "binder.h" #include "tokens.h" -#include +#include DeclaratorCompiler::DeclaratorCompiler(Binder *binder) : _M_binder(binder), _M_token_stream(binder->tokenStream()) diff --git a/ApiExtractor/parser/dumptree.cpp b/ApiExtractor/parser/dumptree.cpp index d65b232..98b9b30 100644 --- a/ApiExtractor/parser/dumptree.cpp +++ b/ApiExtractor/parser/dumptree.cpp @@ -114,7 +114,7 @@ void DumpTree::visit(AST *node) static int indent = 0; if (node) - qDebug() << QString(indent * 2, ' ').toLatin1().constData() << names[node->kind] + qDebug() << QString(indent * 2, ' ').toUtf8().constData() << names[node->kind] << '[' << node->start_token << ", " << node->end_token << ']'; ++indent; diff --git a/ApiExtractor/parser/rpp/preprocessor.cpp b/ApiExtractor/parser/rpp/preprocessor.cpp index 48ce87c..1813f61 100644 --- a/ApiExtractor/parser/rpp/preprocessor.cpp +++ b/ApiExtractor/parser/rpp/preprocessor.cpp @@ -75,7 +75,7 @@ void Preprocessor::processFile(const QString &fileName) d->result.reserve(d->result.size() + 20 * 1024); - d->result += "# 1 \"" + fileName.toLatin1() + "\"\n"; // ### REMOVE ME + d->result += "# 1 \"" + fileName.toUtf8() + "\"\n"; // ### REMOVE ME proc.file(fileName.toLocal8Bit().constData(), std::back_inserter(d->result)); } diff --git a/ApiExtractor/qtdocparser.cpp b/ApiExtractor/qtdocparser.cpp index 1fdff01..a5f94c7 100644 --- a/ApiExtractor/qtdocparser.cpp +++ b/ApiExtractor/qtdocparser.cpp @@ -24,7 +24,7 @@ #include "qtdocparser.h" #include "reporthandler.h" #include -#include +#include Documentation QtDocParser::retrieveModuleDocumentation() { diff --git a/ApiExtractor/reporthandler.cpp b/ApiExtractor/reporthandler.cpp index ed5938a..40668e8 100644 --- a/ApiExtractor/reporthandler.cpp +++ b/ApiExtractor/reporthandler.cpp @@ -54,7 +54,7 @@ static int m_step_warning = 0; static void printProgress() { - std::printf("%s", m_progressBuffer.toAscii().data()); + std::printf("%s", m_progressBuffer.toUtf8().data()); std::fflush(stdout); m_progressBuffer.clear(); } diff --git a/ApiExtractor/tests/CMakeLists.txt b/ApiExtractor/tests/CMakeLists.txt index dd3a326..b81b53c 100644 --- a/ApiExtractor/tests/CMakeLists.txt +++ b/ApiExtractor/tests/CMakeLists.txt @@ -1,9 +1,10 @@ +find_package(Qt5Widgets REQUIRED) +find_package(Qt5Test REQUIRED) macro(declare_test testname) - qt4_automoc("${testname}.cpp") add_executable(${testname} "${testname}.cpp") include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${apiextractor_SOURCE_DIR}) - target_link_libraries(${testname} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} apiextractor) + target_link_libraries(${testname} Qt5::Test Qt5::Core Qt5::Widgets apiextractor) add_test(${testname} ${testname}) if (INSTALL_TESTS) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${testname} DESTINATION share/apiextractor${apiextractor_SUFFIX}/tests) diff --git a/ApiExtractor/tests/testabstractmetaclass.h b/ApiExtractor/tests/testabstractmetaclass.h index 07069c2..ee5ebe0 100644 --- a/ApiExtractor/tests/testabstractmetaclass.h +++ b/ApiExtractor/tests/testabstractmetaclass.h @@ -24,7 +24,7 @@ #ifndef TESTABSTRACTMETACLASS_H #define TESTABSTRACTMETACLASS_H -#include +#include class AbstractMetaBuilder; diff --git a/ApiExtractor/tests/testabstractmetatype.h b/ApiExtractor/tests/testabstractmetatype.h index 520eebe..9e3289f 100644 --- a/ApiExtractor/tests/testabstractmetatype.h +++ b/ApiExtractor/tests/testabstractmetatype.h @@ -24,7 +24,7 @@ #ifndef TESTABSTRACTMETATYPE_H #define TESTABSTRACTMETATYPE_H -#include +#include class TestAbstractMetaType : public QObject { diff --git a/ApiExtractor/tests/testaddfunction.h b/ApiExtractor/tests/testaddfunction.h index 063997f..c071c29 100644 --- a/ApiExtractor/tests/testaddfunction.h +++ b/ApiExtractor/tests/testaddfunction.h @@ -23,7 +23,7 @@ #ifndef TESTADDFUNCTION_H #define TESTADDFUNCTION_H -#include +#include class TestAddFunction : public QObject { diff --git a/ApiExtractor/tests/testarrayargument.h b/ApiExtractor/tests/testarrayargument.h index a448dbc..c648619 100644 --- a/ApiExtractor/tests/testarrayargument.h +++ b/ApiExtractor/tests/testarrayargument.h @@ -23,7 +23,7 @@ #ifndef TESTARRAYARGUMENT_H #define TESTARRAYARGUMENT_H -#include +#include class TestArrayArgument : public QObject { diff --git a/ApiExtractor/tests/testcodeinjection.cpp b/ApiExtractor/tests/testcodeinjection.cpp index 922dd70..b0c40db 100644 --- a/ApiExtractor/tests/testcodeinjection.cpp +++ b/ApiExtractor/tests/testcodeinjection.cpp @@ -22,8 +22,8 @@ */ #include "testcodeinjection.h" -#include -#include +#include +#include #include #include "testutil.h" diff --git a/ApiExtractor/tests/testcodeinjection.h b/ApiExtractor/tests/testcodeinjection.h index 440bfc4..1e1c412 100644 --- a/ApiExtractor/tests/testcodeinjection.h +++ b/ApiExtractor/tests/testcodeinjection.h @@ -24,7 +24,7 @@ #ifndef TESTCODEINJECTIONS_H #define TESTCODEINJECTIONS_H -#include +#include class AbstractMetaBuilder; diff --git a/ApiExtractor/tests/testcontainer.h b/ApiExtractor/tests/testcontainer.h index fa2cdb4..ea9c212 100644 --- a/ApiExtractor/tests/testcontainer.h +++ b/ApiExtractor/tests/testcontainer.h @@ -23,7 +23,7 @@ #ifndef TESTCONTAINER_H #define TESTCONTAINER_H -#include +#include class TestContainer : public QObject { diff --git a/ApiExtractor/tests/testconversionoperator.h b/ApiExtractor/tests/testconversionoperator.h index 5d7cff2..56c5d00 100644 --- a/ApiExtractor/tests/testconversionoperator.h +++ b/ApiExtractor/tests/testconversionoperator.h @@ -23,7 +23,7 @@ #ifndef TESTCONVERSIONOPERATOR_H #define TESTCONVERSIONOPERATOR_H -#include +#include class TestConversionOperator : public QObject { diff --git a/ApiExtractor/tests/testconversionruletag.cpp b/ApiExtractor/tests/testconversionruletag.cpp index 9d0d3fd..d53e3de 100644 --- a/ApiExtractor/tests/testconversionruletag.cpp +++ b/ApiExtractor/tests/testconversionruletag.cpp @@ -24,8 +24,8 @@ #include "testconversionruletag.h" #include #include "testutil.h" -#include -#include +#include +#include void TestConversionRuleTag::testConversionRuleTagWithFile() { diff --git a/ApiExtractor/tests/testconversionruletag.h b/ApiExtractor/tests/testconversionruletag.h index e5a2648..5ad4794 100644 --- a/ApiExtractor/tests/testconversionruletag.h +++ b/ApiExtractor/tests/testconversionruletag.h @@ -23,7 +23,7 @@ #ifndef TESTCONVERSIONRULE_H #define TESTCONVERSIONRULE_H -#include +#include class TestConversionRuleTag : public QObject { diff --git a/ApiExtractor/tests/testctorinformation.h b/ApiExtractor/tests/testctorinformation.h index 21c9085..f99d37f 100644 --- a/ApiExtractor/tests/testctorinformation.h +++ b/ApiExtractor/tests/testctorinformation.h @@ -24,7 +24,7 @@ #ifndef TESTCTORINFORMATION_H #define TESTCTORINFORMATION_H -#include +#include class AbstractMetaBuilder; diff --git a/ApiExtractor/tests/testdroptypeentries.h b/ApiExtractor/tests/testdroptypeentries.h index 4185cf6..c4b692e 100644 --- a/ApiExtractor/tests/testdroptypeentries.h +++ b/ApiExtractor/tests/testdroptypeentries.h @@ -24,7 +24,7 @@ #ifndef TESTDROPTYPEENTRIES_H #define TESTDROPTYPEENTRIES_H -#include +#include class TestDropTypeEntries : public QObject { diff --git a/ApiExtractor/tests/testdtorinformation.h b/ApiExtractor/tests/testdtorinformation.h index 6b2461c..3baafa9 100644 --- a/ApiExtractor/tests/testdtorinformation.h +++ b/ApiExtractor/tests/testdtorinformation.h @@ -24,7 +24,7 @@ #ifndef TESTDTORINFORMATION_H #define TESTDTORINFORMATION_H -#include +#include class AbstractMetaBuilder; diff --git a/ApiExtractor/tests/testenum.h b/ApiExtractor/tests/testenum.h index 8fad455..5d7d900 100644 --- a/ApiExtractor/tests/testenum.h +++ b/ApiExtractor/tests/testenum.h @@ -23,7 +23,7 @@ #ifndef TESTENUM_H #define TESTENUM_H -#include +#include class TestEnum : public QObject { diff --git a/ApiExtractor/tests/testextrainclude.h b/ApiExtractor/tests/testextrainclude.h index e68ae0f..407552c 100644 --- a/ApiExtractor/tests/testextrainclude.h +++ b/ApiExtractor/tests/testextrainclude.h @@ -24,7 +24,7 @@ #ifndef TESTEXTRAINCLUDE_H #define TESTEXTRAINCLUDE_H -#include +#include class TestExtraInclude : public QObject { diff --git a/ApiExtractor/tests/testfunctiontag.h b/ApiExtractor/tests/testfunctiontag.h index 60ebff6..e45c413 100644 --- a/ApiExtractor/tests/testfunctiontag.h +++ b/ApiExtractor/tests/testfunctiontag.h @@ -23,7 +23,7 @@ #ifndef TESTFUNCTIONTAG_H #define TESTFUNCTIONTAG_H -#include +#include class TestFunctionTag : public QObject { diff --git a/ApiExtractor/tests/testimplicitconversions.h b/ApiExtractor/tests/testimplicitconversions.h index 1a7238f..3205fd1 100644 --- a/ApiExtractor/tests/testimplicitconversions.h +++ b/ApiExtractor/tests/testimplicitconversions.h @@ -24,7 +24,7 @@ #ifndef TESTIMPLICITCONVERSIONS_H #define TESTIMPLICITCONVERSIONS_H -#include +#include class AbstractMetaBuilder; diff --git a/ApiExtractor/tests/testinserttemplate.h b/ApiExtractor/tests/testinserttemplate.h index 8ed755e..c433b63 100644 --- a/ApiExtractor/tests/testinserttemplate.h +++ b/ApiExtractor/tests/testinserttemplate.h @@ -24,7 +24,7 @@ #ifndef TESTINSERTTEMPLATE_H #define TESTINSERTTEMPLATE_H -#include +#include class TestInsertTemplate : public QObject { diff --git a/ApiExtractor/tests/testmodifydocumentation.cpp b/ApiExtractor/tests/testmodifydocumentation.cpp index cafb5d7..fdb73bc 100644 --- a/ApiExtractor/tests/testmodifydocumentation.cpp +++ b/ApiExtractor/tests/testmodifydocumentation.cpp @@ -23,7 +23,7 @@ #include "testmodifydocumentation.h" -#include +#include #include #include "testutil.h" #include diff --git a/ApiExtractor/tests/testmodifydocumentation.h b/ApiExtractor/tests/testmodifydocumentation.h index f516188..6483572 100644 --- a/ApiExtractor/tests/testmodifydocumentation.h +++ b/ApiExtractor/tests/testmodifydocumentation.h @@ -24,7 +24,7 @@ #ifndef TESTMODIFYDOCUMENTATION_H #define TESTMODIFYDOCUMENTATION_H -#include +#include class TestModifyDocumentation : public QObject { diff --git a/ApiExtractor/tests/testmodifyfunction.h b/ApiExtractor/tests/testmodifyfunction.h index bce4f62..ff91396 100644 --- a/ApiExtractor/tests/testmodifyfunction.h +++ b/ApiExtractor/tests/testmodifyfunction.h @@ -24,7 +24,7 @@ #ifndef TESTABSTRACTMETACLASS_H #define TESTABSTRACTMETACLASS_H -#include +#include class TestModifyFunction : public QObject { diff --git a/ApiExtractor/tests/testmultipleinheritance.h b/ApiExtractor/tests/testmultipleinheritance.h index b153fb7..2de3952 100644 --- a/ApiExtractor/tests/testmultipleinheritance.h +++ b/ApiExtractor/tests/testmultipleinheritance.h @@ -24,7 +24,7 @@ #ifndef TESTMULTIPLEINHERITANCE_H #define TESTMULTIPLEINHERITANCE_H -#include +#include class AbstractMetaBuilder; diff --git a/ApiExtractor/tests/testnamespace.h b/ApiExtractor/tests/testnamespace.h index 813c77e..0623cb7 100644 --- a/ApiExtractor/tests/testnamespace.h +++ b/ApiExtractor/tests/testnamespace.h @@ -24,7 +24,7 @@ #ifndef TESTNAMESPACE_H #define TESTNAMESPACE_H -#include +#include class TestNamespace : public QObject { diff --git a/ApiExtractor/tests/testnestedtypes.h b/ApiExtractor/tests/testnestedtypes.h index 11ccb26..8e6a03f 100644 --- a/ApiExtractor/tests/testnestedtypes.h +++ b/ApiExtractor/tests/testnestedtypes.h @@ -23,7 +23,7 @@ #ifndef TESTNESTEDTYPES_H #define TESTNESTEDTYPES_H -#include +#include class TestNestedTypes : public QObject { diff --git a/ApiExtractor/tests/testnumericaltypedef.h b/ApiExtractor/tests/testnumericaltypedef.h index 70f35c8..62cc890 100644 --- a/ApiExtractor/tests/testnumericaltypedef.h +++ b/ApiExtractor/tests/testnumericaltypedef.h @@ -24,7 +24,7 @@ #ifndef TESTNUMERICALTYPEDEF_H #define TESTNUMERICALTYPEDEF_H -#include +#include class TestNumericalTypedef : public QObject { diff --git a/ApiExtractor/tests/testprimitivetypetag.h b/ApiExtractor/tests/testprimitivetypetag.h index 050f049..28dd9b4 100644 --- a/ApiExtractor/tests/testprimitivetypetag.h +++ b/ApiExtractor/tests/testprimitivetypetag.h @@ -24,7 +24,7 @@ #ifndef TESTPRIMITIVETYPETAG_H #define TESTPRIMITIVETYPETAG_H -#include +#include class TestPrimitiveTypeTag : public QObject { diff --git a/ApiExtractor/tests/testrefcounttag.h b/ApiExtractor/tests/testrefcounttag.h index 22cd257..d7e9aa1 100644 --- a/ApiExtractor/tests/testrefcounttag.h +++ b/ApiExtractor/tests/testrefcounttag.h @@ -24,7 +24,7 @@ #ifndef TESTREFCOUNTTAG_H #define TESTREFCOUNTTAG_H -#include +#include class TestRefCountTag : public QObject { diff --git a/ApiExtractor/tests/testreferencetopointer.h b/ApiExtractor/tests/testreferencetopointer.h index 9791a1d..52f85bb 100644 --- a/ApiExtractor/tests/testreferencetopointer.h +++ b/ApiExtractor/tests/testreferencetopointer.h @@ -24,7 +24,7 @@ #ifndef TESTREFERENCETOPOINTER_H #define TESTREFERENCETOPOINTER_H -#include +#include class TestReferenceToPointer : public QObject { diff --git a/ApiExtractor/tests/testremovefield.h b/ApiExtractor/tests/testremovefield.h index 4a2b5ad..3e40b28 100644 --- a/ApiExtractor/tests/testremovefield.h +++ b/ApiExtractor/tests/testremovefield.h @@ -24,7 +24,7 @@ #ifndef TESTREMOVEFIELD_H #define TESTREMOVEFIELD_H -#include +#include class TestRemoveField : public QObject { diff --git a/ApiExtractor/tests/testtyperevision.h b/ApiExtractor/tests/testtyperevision.h index 8fc0986..833a44c 100644 --- a/ApiExtractor/tests/testtyperevision.h +++ b/ApiExtractor/tests/testtyperevision.h @@ -23,7 +23,7 @@ #ifndef TESTTYPEREVISION_H #define TESTTYPEREVISION_H -#include +#include class TestTypeRevision : public QObject { diff --git a/ApiExtractor/typedatabase.cpp b/ApiExtractor/typedatabase.cpp index deaf04c..a66321e 100644 --- a/ApiExtractor/typedatabase.cpp +++ b/ApiExtractor/typedatabase.cpp @@ -25,8 +25,8 @@ #include "typesystem.h" #include "typesystem_p.h" -#include -#include +#include +#include #include "reporthandler.h" // #include #include diff --git a/ApiExtractor/typedatabase.h b/ApiExtractor/typedatabase.h index ffa1c62..9d41983 100644 --- a/ApiExtractor/typedatabase.h +++ b/ApiExtractor/typedatabase.h @@ -24,7 +24,7 @@ #ifndef TYPEDATABASE_H #define TYPEDATABASE_H -#include +#include #include "typesystem.h" #include "apiextractormacros.h" diff --git a/ApiExtractor/typesystem.cpp b/ApiExtractor/typesystem.cpp index 81de5f9..c98ecec 100644 --- a/ApiExtractor/typesystem.cpp +++ b/ApiExtractor/typesystem.cpp @@ -25,7 +25,7 @@ #include "typesystem_p.h" #include "typedatabase.h" #include "reporthandler.h" -#include +#include static QString strings_Object = QLatin1String("Object"); static QString strings_String = QLatin1String("String"); @@ -468,7 +468,7 @@ bool Handler::startElement(const QString &, const QString &n, if (!m_defaultPackage.isEmpty() && atts.index("since") != -1) { TypeDatabase* td = TypeDatabase::instance(); - if (!td->checkApiVersion(m_defaultPackage, atts.value("since").toAscii())) { + if (!td->checkApiVersion(m_defaultPackage, atts.value("since").toUtf8())) { ++m_ignoreDepth; return true; } @@ -901,7 +901,7 @@ bool Handler::startElement(const QString &, const QString &n, break; case StackElement::FunctionTypeEntry: { QString signature = attributes["signature"]; - signature = TypeDatabase::normalizedSignature(signature.toLatin1().constData()); + signature = TypeDatabase::normalizedSignature(signature.toUtf8().constData()); element->entry = m_database->findType(name); if (element->entry) { if (element->entry->type() == TypeEntry::FunctionType) { @@ -2384,7 +2384,7 @@ bool TypeEntry::isCppPrimitive() const return false; PrimitiveTypeEntry* aliasedType = ((PrimitiveTypeEntry*)this)->basicAliasedTypeEntry(); - QByteArray typeName = (aliasedType ? aliasedType->name() : m_name).toAscii(); + QByteArray typeName = (aliasedType ? aliasedType->name() : m_name).toUtf8(); if (typeName.contains(' ') || m_type == VoidType) return true; diff --git a/ApiExtractor/typesystem_p.h b/ApiExtractor/typesystem_p.h index 23d0ee1..ff5677a 100644 --- a/ApiExtractor/typesystem_p.h +++ b/ApiExtractor/typesystem_p.h @@ -23,8 +23,8 @@ #ifndef TYPESYSTEM_P_H #define TYPESYSTEM_P_H -#include -#include +#include +#include #include "typesystem.h" class TypeDatabase; diff --git a/CMakeLists.txt b/CMakeLists.txt index 00b352a..defb91c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,8 @@ cmake_minimum_required(VERSION 2.6) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/ ${CMAKE_MODULE_PATH}) -find_package(Qt4 4.5.0) - -add_definitions(${QT_DEFINITIONS}) +set(CMAKE_AUTOMOC TRUE) +find_package(Qt5 COMPONENTS Core) set(shiboken_MAJOR_VERSION "1") set(shiboken_MINOR_VERSION "2") @@ -115,7 +114,7 @@ add_subdirectory(libshiboken) add_subdirectory(doc) # deps found, compile the generator. -if (QT4_FOUND AND PYTHONINTERP_FOUND) +if (Qt5_FOUND AND PYTHONINTERP_FOUND) add_subdirectory(generator) add_subdirectory(shibokenmodule) diff --git a/generator/CMakeLists.txt b/generator/CMakeLists.txt index d18958c..b21681f 100644 --- a/generator/CMakeLists.txt +++ b/generator/CMakeLists.txt @@ -1,12 +1,15 @@ project(shibokengenerator) +find_package(Qt5Core REQUIRED) +find_package(Qt5Xml REQUIRED) +find_package(Qt5XmlPatterns REQUIRED) + set(shiboken_SRC generator.cpp shiboken/cppgenerator.cpp shiboken/headergenerator.cpp shiboken/overloaddata.cpp shiboken/shibokengenerator.cpp -shiboken/shibokennormalize.cpp main.cpp ) @@ -19,18 +22,15 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/shiboken ${CMAKE_CURRENT_SOURCE_DIR}/qtdoc ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${apiextractor_SOURCE_DIR} - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTXML_INCLUDE_DIR}) + ${apiextractor_SOURCE_DIR}) add_executable(shiboken ${shiboken_SRC}) add_dependencies(shiboken apiextractor) set_target_properties(shiboken PROPERTIES OUTPUT_NAME shiboken${shiboken_SUFFIX}) target_link_libraries(shiboken apiextractor - ${QT_QTCORE_LIBRARY} - ${QT_QTXML_LIBRARY}) + Qt5::Core + Qt5::Xml) configure_file(shibokenconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/shibokenconfig.h" @ONLY) diff --git a/generator/generator.cpp b/generator/generator.cpp index 2d2456a..28a7f31 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include struct Generator::GeneratorPrivate { diff --git a/generator/main.cpp b/generator/main.cpp index 88fe3a9..42cb90f 100644 --- a/generator/main.cpp +++ b/generator/main.cpp @@ -21,10 +21,10 @@ * */ -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include "generator.h" @@ -284,7 +284,7 @@ static inline void errorPrint(const QString& s, if (verAndBanner) printVerAndBanner(); - std::cerr << s.toAscii().constData() << std::endl; + std::cerr << s.toUtf8().constData() << std::endl; } int main(int argc, char *argv[]) @@ -380,7 +380,7 @@ int main(int argc, char *argv[]) QString version; package = parts.count() == 1 ? "*" : parts.first(); version = parts.last(); - extractor.setApiVersion(package, version.toAscii()); + extractor.setApiVersion(package, version.toUtf8()); } } diff --git a/generator/qtdoc/CMakeLists.txt b/generator/qtdoc/CMakeLists.txt index 541e7c6..31772b9 100644 --- a/generator/qtdoc/CMakeLists.txt +++ b/generator/qtdoc/CMakeLists.txt @@ -5,15 +5,14 @@ qtdocgenerator.cpp ) include_directories(${generators_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} ${APIEXTRACTOR_INCLUDE_DIR}) add_executable(docgenerator main.cpp) set_target_properties(docgenerator PROPERTIES OUTPUT_NAME docgenerator${generator_SUFFIX}) -target_link_libraries(docgenerator ${QT_QTCORE_LIBRARY}) +target_link_libraries(docgenerator Qt5::Core) add_library(qtdoc_generator SHARED ${qtdoc_generator_SRC}) -target_link_libraries(qtdoc_generator ${APIEXTRACTOR_LIBRARY} ${QT_QTCORE_LIBRARY} genrunner) +target_link_libraries(qtdoc_generator ${APIEXTRACTOR_LIBRARY} Qt5::Core genrunner) set_property(TARGET qtdoc_generator PROPERTY PREFIX "") install(TARGETS qtdoc_generator DESTINATION ${generator_plugin_DIR}) diff --git a/generator/qtdoc/qtdocgenerator.h b/generator/qtdoc/qtdocgenerator.h index b62fc28..df1e0de 100644 --- a/generator/qtdoc/qtdocgenerator.h +++ b/generator/qtdoc/qtdocgenerator.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include "generator.h" #include "docparser.h" diff --git a/generator/shiboken/CMakeLists.txt b/generator/shiboken/CMakeLists.txt index 57aac33..7e6e1c4 100644 --- a/generator/shiboken/CMakeLists.txt +++ b/generator/shiboken/CMakeLists.txt @@ -6,24 +6,20 @@ cppgenerator.cpp headergenerator.cpp overloaddata.cpp shibokengenerator.cpp -shibokennormalize.cpp main.cpp ) include_directories(${generators_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${APIEXTRACTOR_INCLUDE_DIR} - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTXML_INCLUDE_DIR}) + ${APIEXTRACTOR_INCLUDE_DIR}) add_executable(shiboken ${shiboken_SRC}) set_target_properties(shiboken PROPERTIES OUTPUT_NAME shiboken${shiboken_SUFFIX}) target_link_libraries(shiboken ${APIEXTRACTOR_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${QT_QTXML_LIBRARY}) + Qt5::Core + Qt5::Xml) configure_file(shibokenconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/shibokenconfig.h" @ONLY) diff --git a/generator/shiboken/cppgenerator.cpp b/generator/shiboken/cppgenerator.cpp index 181c846..13053c5 100644 --- a/generator/shiboken/cppgenerator.cpp +++ b/generator/shiboken/cppgenerator.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include QHash CppGenerator::m_nbFuncs = QHash(); QHash CppGenerator::m_sqFuncs = QHash(); @@ -3266,7 +3266,7 @@ void CppGenerator::writeEnumConverterInitialization(QTextStream& s, const TypeEn void CppGenerator::writeContainerConverterInitialization(QTextStream& s, const AbstractMetaType* type) { - QByteArray cppSignature = QMetaObject::normalizedSignature(type->cppSignature().toAscii()); + QByteArray cppSignature = QMetaObject::normalizedSignature(type->cppSignature().toUtf8()); s << INDENT << "// Register converter for type '" << cppSignature << "'." << endl; QString converter = converterObject(type); s << INDENT << converter << " = Shiboken::Conversions::createConverter("; @@ -4948,7 +4948,7 @@ void CppGenerator::finishGeneration() QString value = translateType(arg->type(), metaClass, ExcludeConst | ExcludeReference); if (value.startsWith("::")) value.remove(0, 2); - typeResolvers << SBK_NORMALIZED_TYPE(value.toAscii().constData()); + typeResolvers << SBK_NORMALIZED_TYPE(value.toUtf8().constData()); } } } diff --git a/generator/shiboken/overloaddata.cpp b/generator/shiboken/overloaddata.cpp index f0e65a4..d7dc940 100644 --- a/generator/shiboken/overloaddata.cpp +++ b/generator/shiboken/overloaddata.cpp @@ -26,7 +26,7 @@ #include #include "overloaddata.h" #include "shibokengenerator.h" -#include +#include static const TypeEntry* getAliasedTypeEntry(const TypeEntry* typeEntry) { diff --git a/generator/shiboken/shibokengenerator.cpp b/generator/shiboken/shibokengenerator.cpp index c57b3e0..caaa362 100644 --- a/generator/shiboken/shibokengenerator.cpp +++ b/generator/shiboken/shibokengenerator.cpp @@ -1737,7 +1737,7 @@ static QString getConverterTypeSystemVariableArgument(const QString& code, int p int parenthesisDepth = 0; int count = 0; while (pos + count < code.count()) { - char c = code.at(pos+count).toAscii(); + char c = code.at(pos+count).toLatin1(); if (c == '(') { ++parenthesisDepth; } else if (c == ')') { diff --git a/generator/shiboken/shibokennormalize.cpp b/generator/shiboken/shibokennormalize.cpp deleted file mode 100644 index aafb451..0000000 --- a/generator/shiboken/shibokennormalize.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/* - * This file is part of the PySide project. - * This code was extracted from qmetaobject_p.h present on Qt4.7. - * - * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - * Contact: PySide team - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "shibokennormalize_p.h" -#include - -#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 0)) - -// mirrored in moc's utils.h -static inline bool is_ident_char(char s) -{ - return ((s >= 'a' && s <= 'z') - || (s >= 'A' && s <= 'Z') - || (s >= '0' && s <= '9') - || s == '_' - ); -} - -static inline bool is_space(char s) -{ - return (s == ' ' || s == '\t'); -} - -static void qRemoveWhitespace(const char *s, char *d) -{ - char last = 0; - while (*s && is_space(*s)) - s++; - while (*s) { - while (*s && !is_space(*s)) - last = *d++ = *s++; - while (*s && is_space(*s)) - s++; - if (*s && ((is_ident_char(*s) && is_ident_char(last)) - || ((*s == ':') && (last == '<')))) { - last = *d++ = ' '; - } - } - *d = '\0'; -} - -// This code is shared with moc.cpp -static QByteArray normalizeTypeInternalQt47(const char *t, const char *e, bool fixScope = false, bool adjustConst = true) -{ - int len = e - t; - /* - Convert 'char const *' into 'const char *'. Start at index 1, - not 0, because 'const char *' is already OK. - */ - QByteArray constbuf; - for (int i = 1; i < len; i++) { - if ( t[i] == 'c' - && strncmp(t + i + 1, "onst", 4) == 0 - && (i + 5 >= len || !is_ident_char(t[i + 5])) - && !is_ident_char(t[i-1]) - ) { - constbuf = QByteArray(t, len); - if (is_space(t[i-1])) - constbuf.remove(i-1, 6); - else - constbuf.remove(i, 5); - constbuf.prepend("const "); - t = constbuf.data(); - e = constbuf.data() + constbuf.length(); - break; - } - /* - We musn't convert 'char * const *' into 'const char **' - and we must beware of 'Bar'. - */ - if (t[i] == '&' || t[i] == '*' ||t[i] == '<') - break; - } - if (adjustConst && e > t + 6 && strncmp("const ", t, 6) == 0) { - if (*(e-1) == '&') { // treat const reference as value - t += 6; - --e; - } else if (is_ident_char(*(e-1)) || *(e-1) == '>') { // treat const value as value - t += 6; - } - } - QByteArray result; - result.reserve(len); - -#if 1 - // consume initial 'const ' - if (strncmp("const ", t, 6) == 0) { - t+= 6; - result += "const "; - } -#endif - - // some type substitutions for 'unsigned x' - if (strncmp("unsigned", t, 8) == 0) { - // make sure "unsigned" is an isolated word before making substitutions - if (!t[8] || !is_ident_char(t[8])) { - if (strncmp(" int", t+8, 4) == 0) { - t += 8+4; - result += "uint"; - } else if (strncmp(" long", t+8, 5) == 0) { - if ((strlen(t + 8 + 5) < 4 || strncmp(t + 8 + 5, " int", 4) != 0) // preserve '[unsigned] long int' - && (strlen(t + 8 + 5) < 5 || strncmp(t + 8 + 5, " long", 5) != 0) // preserve '[unsigned] long long' - ) { - t += 8+5; - result += "ulong"; - } - } else if (strncmp(" short", t+8, 6) != 0 // preserve unsigned short - && strncmp(" char", t+8, 5) != 0) { // preserve unsigned char - // treat rest (unsigned) as uint - t += 8; - result += "uint"; - } - } - } else { - // discard 'struct', 'class', and 'enum'; they are optional - // and we don't want them in the normalized signature - struct { - const char *keyword; - int len; - } optional[] = { - { "struct ", 7 }, - { "class ", 6 }, - { "enum ", 5 }, - { 0, 0 } - }; - int i = 0; - do { - if (strncmp(optional[i].keyword, t, optional[i].len) == 0) { - t += optional[i].len; - break; - } - } while (optional[++i].keyword != 0); - } - - bool star = false; - while (t != e) { - char c = *t++; - if (fixScope && c == ':' && *t == ':' ) { - ++t; - c = *t++; - int i = result.size() - 1; - while (i >= 0 && is_ident_char(result.at(i))) - --i; - result.resize(i + 1); - } - star = star || c == '*'; - result += c; - if (c == '<') { - //template recursion - const char* tt = t; - int templdepth = 1; - while (t != e) { - c = *t++; - if (c == '<') - ++templdepth; - if (c == '>') - --templdepth; - if (templdepth == 0 || (templdepth == 1 && c == ',')) { - result += normalizeTypeInternalQt47(tt, t-1, fixScope, false); - result += c; - if (templdepth == 0) { - if (*t == '>') - result += ' '; // avoid >> - break; - } - tt = t; - } - } - } - - // cv qualifers can appear after the type as well - if (!is_ident_char(c) && t != e && (e - t >= 5 && strncmp("const", t, 5) == 0) - && (e - t == 5 || !is_ident_char(t[5]))) { - t += 5; - while (t != e && is_space(*t)) - ++t; - if (adjustConst && t != e && *t == '&') { - // treat const ref as value - ++t; - } else if (adjustConst && !star) { - // treat const as value - } else if (!star) { - // move const to the front (but not if const comes after a *) - result.prepend("const "); - } else { - // keep const after a * - result += "const"; - } - } - } - - return result; -} - -static char *qNormalizeTypeQt47(char *d, int &templdepth, QByteArray &result) -{ - const char *t = d; - while (*d && (templdepth - || (*d != ',' && *d != ')'))) { - if (*d == '<') - ++templdepth; - if (*d == '>') - --templdepth; - ++d; - } - if (strncmp("void", t, d - t) != 0) - result += normalizeTypeInternalQt47(t, d); - - return d; -} - - -QByteArray QMetaObject_normalizedTypeQt47(const char *type) -{ - QByteArray result; - - if (!type || !*type) - return result; - - QVarLengthArray stackbuf(qstrlen(type) + 1); - qRemoveWhitespace(type, stackbuf.data()); - int templdepth = 0; - qNormalizeTypeQt47(stackbuf.data(), templdepth, result); - - return result; -} - -QByteArray QMetaObject_normalizedSignatureQt47(const char *method) -{ - QByteArray result; - if (!method || !*method) - return result; - int len = int(strlen(method)); - QVarLengthArray stackbuf(len + 1); - char *d = stackbuf.data(); - qRemoveWhitespace(method, d); - - result.reserve(len); - - int argdepth = 0; - int templdepth = 0; - while (*d) { - if (argdepth == 1) - d = qNormalizeTypeQt47(d, templdepth, result); - if (*d == '(') - ++argdepth; - if (*d == ')') - --argdepth; - result += *d++; - } - - return result; -} -#endif diff --git a/generator/shiboken/shibokennormalize_p.h b/generator/shiboken/shibokennormalize_p.h index 5ecdb6a..0c51812 100644 --- a/generator/shiboken/shibokennormalize_p.h +++ b/generator/shiboken/shibokennormalize_p.h @@ -23,19 +23,10 @@ #ifndef SHIBOKENNORMALIZE_P_H #define SHIBOKENNORMALIZE_P_H -#include -#include +#include -#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 0)) - QByteArray QMetaObject_normalizedTypeQt47(const char *type); - QByteArray QMetaObject_normalizedSignatureQt47(const char *type); - - #define SBK_NORMALIZED_TYPE(x) QMetaObject_normalizedTypeQt47(x) - #define SBK_NORMALIZED_SIGNATURE(x) QMetaObject_normalizedSignatureQt47(x) -#else - #define SBK_NORMALIZED_TYPE(x) QMetaObject::normalizedType(x) - #define SBK_NORMALIZED_SIGNATURE(x) QMetaObject::normalizedSignature(x) -#endif +#define SBK_NORMALIZED_TYPE(x) QMetaObject::normalizedType(x) +#define SBK_NORMALIZED_SIGNATURE(x) QMetaObject::normalizedSignature(x) #endif //SHIBOKENNORMALIZE_P_H diff --git a/main.cpp b/main.cpp index 4979805..2a83a4d 100644 --- a/main.cpp +++ b/main.cpp @@ -282,7 +282,7 @@ static inline void errorPrint(const QString& s, if (verAndBanner) printVerAndBanner(); - std::cerr << s.toAscii().constData() << std::endl; + std::cerr << s.toUtf8().constData() << std::endl; } int main(int argc, char *argv[]) @@ -411,7 +411,7 @@ int main(int argc, char *argv[]) QString version; package = parts.count() == 1 ? "*" : parts.first(); version = parts.last(); - extractor.setApiVersion(package, version.toAscii()); + extractor.setApiVersion(package, version.toUtf8()); } } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ecea43c..08da927 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -74,15 +74,12 @@ if (NOT APIEXTRACTOR_DOCSTRINGS_DISABLED) # set(sphinxtabletest_SRC sphinxtabletest.cpp) # qt4_automoc(${sphinxtabletest_SRC}) # -# include_directories(${QT_INCLUDE_DIR} -# ${QT_QTCORE_INCLUDE_DIR} -# ${CMAKE_CURRENT_BINARY_DIR} -# ${qtdoc_generator_SOURCE_DIR}) +# include_directories(${qtdoc_generator_SOURCE_DIR}) # # add_executable(sphinxtabletest ${sphinxtabletest_SRC}) # # target_link_libraries(sphinxtabletest -# ${QT_QTTEST_LIBRARY} +# Qt5::Test # ${APIEXTRACTOR_LIBRARY} # qtdoc_generator # genrunner) diff --git a/tests/test_generator/CMakeLists.txt b/tests/test_generator/CMakeLists.txt index 498d662..c17e04d 100644 --- a/tests/test_generator/CMakeLists.txt +++ b/tests/test_generator/CMakeLists.txt @@ -2,13 +2,13 @@ project(test_generator) set(dummy_generator_SRC dummygenerator.cpp) add_library(dummy_generator SHARED ${dummy_generator_SRC}) -target_link_libraries(dummy_generator ${APIEXTRACTOR_LIBRARY} ${QT_QTCORE_LIBRARY} genrunner) +target_link_libraries(dummy_generator ${APIEXTRACTOR_LIBRARY} Qt5::Core genrunner) set_property(TARGET dummy_generator PROPERTY PREFIX "") add_executable(dummygenerator main.cpp) set(DUMMYGENERATOR_EXECUTABLE dummygenerator${generator_SUFFIX}) set_target_properties(dummygenerator PROPERTIES OUTPUT_NAME ${DUMMYGENERATOR_EXECUTABLE}) -target_link_libraries(dummygenerator ${QT_QTCORE_LIBRARY}) +target_link_libraries(dummygenerator Qt5::Core) configure_file(dummygentestconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/dummygentestconfig.h" @ONLY) @@ -47,7 +47,7 @@ macro(declare_test testname) qt4_automoc("${testname}.cpp") add_executable(${testname} "${testname}.cpp") include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(${testname} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY}) + target_link_libraries(${testname} Qt5::Test Qt5::Core) m_add_test(${testname}) endmacro(declare_test testname)