From ea7e7dd4538fcf8d17a640ca96dafbf201170a39 Mon Sep 17 00:00:00 2001 From: mrbean-bremen Date: Wed, 19 Nov 2025 12:55:08 +0100 Subject: [PATCH 1/4] Add pre-commit hook for clang-format - exclude unwanted directories by adding disabling .clang-format files - also add a hooks for line endings, trailing spaces and case/merge conflicts --- .pre-commit-config.yaml | 14 ++++++++++++++ generated_cpp_515/.clang-format | 2 ++ generator/simplecpp/.clang-format | 2 ++ run-clang-format.sh | 17 +---------------- 4 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 generated_cpp_515/.clang-format create mode 100644 generator/simplecpp/.clang-format diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..b2ae9a739 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +repos: + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: "v21.1.5" + hooks: + - id: clang-format + + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-case-conflict + - id: check-merge-conflict + - id: trailing-whitespace + - id: mixed-line-ending diff --git a/generated_cpp_515/.clang-format b/generated_cpp_515/.clang-format new file mode 100644 index 000000000..47a38a93f --- /dev/null +++ b/generated_cpp_515/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: Never diff --git a/generator/simplecpp/.clang-format b/generator/simplecpp/.clang-format new file mode 100644 index 000000000..47a38a93f --- /dev/null +++ b/generator/simplecpp/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: Never diff --git a/run-clang-format.sh b/run-clang-format.sh index 45e914b98..a809fa961 100755 --- a/run-clang-format.sh +++ b/run-clang-format.sh @@ -4,19 +4,4 @@ which -a clang-format-20 > /dev/null \ || (echo -e "20.0.0\n$(clang-format${1+-$1} --version | grep -Eo '([0-9]+\.[0-9]+\.[0-9]+)')" | sort -CV ) \ || { echo "use '${0} ' to call exact proper version" ; exit 1 ; } -IGNORED_DIRS=( - "./generated_cpp_515" - "./examples" - "./generator/simplecpp" - "./build" -) - -IGNORE_CMD="" - -for DIR in "${IGNORED_DIRS[@]}"; do - IGNORE_CMD+=" -path $DIR -o" -done - -IGNORE_CMD=${IGNORE_CMD% -o} - -find . \( $IGNORE_CMD \) -prune -o -name '*.cpp' -print0 -o -name '*.h' -print0 | xargs -0 clang-format-20 --style=file -i +find . -prune -o -name '*.cpp' -print0 -o -name '*.h' -print0 | xargs -0 clang-format-20 --style=file -i From afff139a67fbe9cecfc1d5a85919d65e2fc3cb15 Mon Sep 17 00:00:00 2001 From: mrbean-bremen Date: Wed, 19 Nov 2025 12:55:42 +0100 Subject: [PATCH 2/4] Changes after applying clang-format --- .../CPPPyWrapperExample.cpp | 83 +- .../PyCPPWrapperExample/CustomObjects.cpp | 1 - examples/PyCPPWrapperExample/CustomObjects.h | 16 +- examples/PyCPPWrapperExample/main.cpp | 7 +- .../PyCustomMetaTypeExample/CustomObject.cpp | 1 - .../PyCustomMetaTypeExample/CustomObject.h | 16 +- examples/PyCustomMetaTypeExample/main.cpp | 7 +- .../PyExampleDecorators.cpp | 1 - .../PyDecoratorsExample/PyExampleDecorators.h | 18 +- examples/PyDecoratorsExample/main.cpp | 9 +- examples/PyGettingStarted/main.cpp | 27 +- examples/PyGuiExample/main.cpp | 6 +- examples/PyLauncher/main.cpp | 6 +- .../PyScriptingConsole/PyExampleObject.cpp | 8 +- examples/PyScriptingConsole/PyExampleObject.h | 7 +- examples/PyScriptingConsole/main.cpp | 6 +- extensions/PythonQt_QtAll/PythonQt_QtAll.cpp | 32 +- extensions/PythonQt_QtAll/PythonQt_QtAll.h | 19 +- generator/abstractmetabuilder.cpp | 3776 ++++++------- generator/abstractmetabuilder.h | 234 +- generator/abstractmetalang.cpp | 2521 ++++----- generator/abstractmetalang.h | 1328 +++-- generator/asttoxml.cpp | 208 +- generator/asttoxml.h | 10 +- generator/fileout.cpp | 298 +- generator/fileout.h | 34 +- generator/generator.cpp | 115 +- generator/generator.h | 180 +- generator/generatorset.cpp | 22 +- generator/generatorset.h | 24 +- generator/generatorsetqtscript.cpp | 151 +- generator/generatorsetqtscript.h | 21 +- generator/main.cpp | 865 ++- generator/metajava.h | 2 - generator/metaqtscript.cpp | 1 - generator/metaqtscript.h | 4 +- generator/metaqtscriptbuilder.cpp | 1 - generator/metaqtscriptbuilder.h | 41 +- generator/parser/ast.cpp | 8 +- generator/parser/ast.h | 850 ++- generator/parser/binder.cpp | 1095 ++-- generator/parser/binder.h | 77 +- generator/parser/class_compiler.cpp | 24 +- generator/parser/class_compiler.h | 27 +- generator/parser/codemodel.cpp | 326 +- generator/parser/codemodel.h | 398 +- generator/parser/codemodel_finder.cpp | 56 +- generator/parser/codemodel_finder.h | 33 +- generator/parser/codemodel_fwd.h | 1 - generator/parser/compiler_utils.cpp | 27 +- generator/parser/compiler_utils.h | 12 +- generator/parser/control.cpp | 43 +- generator/parser/control.h | 82 +- generator/parser/declarator_compiler.cpp | 150 +- generator/parser/declarator_compiler.h | 32 +- generator/parser/default_visitor.cpp | 147 +- generator/parser/default_visitor.h | 155 +- generator/parser/dumptree.cpp | 100 +- generator/parser/dumptree.h | 11 +- generator/parser/include/stdarg.h | 19 +- generator/parser/lexer.cpp | 2423 ++++---- generator/parser/lexer.h | 160 +- generator/parser/list.cpp | 1 - generator/parser/list.h | 45 +- generator/parser/name_compiler.cpp | 130 +- generator/parser/name_compiler.h | 25 +- generator/parser/parser.cpp | 4985 ++++++++--------- generator/parser/parser.h | 242 +- generator/parser/rxx_allocator.h | 61 +- generator/parser/smallobject.cpp | 1 - generator/parser/smallobject.h | 11 +- generator/parser/symbol.h | 72 +- generator/parser/tokens.cpp | 348 +- generator/parser/tokens.h | 236 +- generator/parser/type_compiler.cpp | 78 +- generator/parser/type_compiler.h | 31 +- generator/parser/visitor.cpp | 17 +- generator/parser/visitor.h | 187 +- generator/prigenerator.cpp | 112 +- generator/prigenerator.h | 32 +- generator/qtscript_masterinclude.h | 2225 ++++---- generator/reporthandler.cpp | 31 +- generator/reporthandler.h | 38 +- generator/setupgenerator.cpp | 224 +- generator/setupgenerator.h | 32 +- generator/shellgenerator.cpp | 469 +- generator/shellgenerator.h | 86 +- generator/shellheadergenerator.cpp | 138 +- generator/shellheadergenerator.h | 22 +- generator/shellimplgenerator.cpp | 99 +- generator/shellimplgenerator.h | 14 +- generator/typeparser.cpp | 436 +- generator/typeparser.h | 31 +- generator/typesystem.cpp | 3640 ++++++------ generator/typesystem.h | 1738 +++--- src/PythonQt.cpp | 506 +- src/PythonQt.h | 135 +- src/PythonQtBoolResult.cpp | 148 +- src/PythonQtBoolResult.h | 5 +- src/PythonQtClassInfo.cpp | 256 +- src/PythonQtClassInfo.h | 96 +- src/PythonQtClassWrapper.cpp | 208 +- src/PythonQtConversion.cpp | 1381 +++-- src/PythonQtConversion.h | 212 +- src/PythonQtCppWrapperFactory.h | 9 +- src/PythonQtDoc.h | 2 +- src/PythonQtImportFileInterface.h | 5 +- src/PythonQtImporter.cpp | 443 +- src/PythonQtImporter.h | 33 +- src/PythonQtInstanceWrapper.cpp | 456 +- src/PythonQtInstanceWrapper.h | 25 +- src/PythonQtMethodInfo.cpp | 111 +- src/PythonQtMethodInfo.h | 53 +- src/PythonQtMisc.cpp | 10 +- src/PythonQtMisc.h | 67 +- src/PythonQtObjectPtr.cpp | 37 +- src/PythonQtObjectPtr.h | 129 +- src/PythonQtProperty.cpp | 144 +- src/PythonQtProperty.h | 6 +- src/PythonQtPythonInclude.h | 101 +- src/PythonQtQFileImporter.cpp | 21 +- src/PythonQtQFileImporter.h | 18 +- src/PythonQtSignal.cpp | 241 +- src/PythonQtSignal.h | 17 +- src/PythonQtSignalReceiver.cpp | 49 +- src/PythonQtSignalReceiver.h | 37 +- src/PythonQtSlot.cpp | 380 +- src/PythonQtSlot.h | 40 +- src/PythonQtSlotDecorator.cpp | 106 +- src/PythonQtStdDecorators.cpp | 87 +- src/PythonQtStdDecorators.h | 125 +- src/PythonQtStdIn.cpp | 102 +- src/PythonQtStdIn.h | 3 +- src/PythonQtStdOut.cpp | 121 +- src/PythonQtStdOut.h | 1 - src/PythonQtSystem.h | 23 +- src/PythonQtThreadSupport.cpp | 3 +- src/PythonQtThreadSupport.h | 27 +- src/PythonQtUtils.h | 86 +- src/PythonQtVariants.h | 3 +- src/gui/PythonQtScriptingConsole.cpp | 120 +- src/gui/PythonQtScriptingConsole.h | 22 +- tests/PythonQtTestCleanup.cpp | 70 +- tests/PythonQtTestCleanup.h | 7 +- tests/PythonQtTestMain.cpp | 3 +- tests/PythonQtTests.cpp | 291 +- tests/PythonQtTests.h | 795 ++- 147 files changed, 19193 insertions(+), 20382 deletions(-) diff --git a/examples/CPPPyWrapperExample/CPPPyWrapperExample.cpp b/examples/CPPPyWrapperExample/CPPPyWrapperExample.cpp index 5734b6540..6a5b67400 100644 --- a/examples/CPPPyWrapperExample/CPPPyWrapperExample.cpp +++ b/examples/CPPPyWrapperExample/CPPPyWrapperExample.cpp @@ -2,45 +2,46 @@ #include #include -int main (int argc, char* argv[]) { - QApplication app(argc, argv); - PythonQt::init(); - PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule(); - mainModule.evalScript(QString("import sys\n")); - Q_ASSERT(!mainModule.isNull()); - { - // evaluate a python file embedded in executable as resource: - mainModule.evalFile(":eyed3tagger.py"); - // create an object, hold onto its reference - PythonQtObjectPtr tag = mainModule.evalScript("EyeD3Tagger()\n", Py_eval_input); - Q_ASSERT(!tag.isNull()); - tag.call("setFileName", QVariantList() << "t.mp3"); - QVariant fn = tag.call("fileName", QVariantList()); - Q_ASSERT(fn.toString() == QString("t.mp3")); - // tag goes out of scope, reference count decremented. - } - { - // Allow the python system path to recognize QFile paths in the sys.path - PythonQt::self()->setImporter(NULL); - // append the Qt resource root directory to the sys.path - mainModule.evalScript("sys.path.append(':')\n"); - mainModule.evalScript("import eyed3tagger\n"); - PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input); - Q_ASSERT(!tag.isNull()); - tag.call("setFileName", QVariantList() << "t.mp3"); - QVariant fn = tag.call("fileName", QVariantList()); - Q_ASSERT(fn.toString() == QString("t.mp3")); - } - { // alternative using import and loading it as a real module from sys.path - // import sys first - mainModule.evalScript(QString("sys.path.append('%1')\n").arg(QDir::currentPath())); - mainModule.evalScript("import eyed3tagger\n"); - PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input); - Q_ASSERT(!tag.isNull()); - tag.call("setFileName", QVariantList() << "t.mp3"); - QVariant fn = tag.call("fileName", QVariantList()); - Q_ASSERT(fn.toString() == QString("t.mp3")); - } - qDebug() << "finished"; - return 0; +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv); + PythonQt::init(); + PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule(); + mainModule.evalScript(QString("import sys\n")); + Q_ASSERT(!mainModule.isNull()); + { + // evaluate a python file embedded in executable as resource: + mainModule.evalFile(":eyed3tagger.py"); + // create an object, hold onto its reference + PythonQtObjectPtr tag = mainModule.evalScript("EyeD3Tagger()\n", Py_eval_input); + Q_ASSERT(!tag.isNull()); + tag.call("setFileName", QVariantList() << "t.mp3"); + QVariant fn = tag.call("fileName", QVariantList()); + Q_ASSERT(fn.toString() == QString("t.mp3")); + // tag goes out of scope, reference count decremented. + } + { + // Allow the python system path to recognize QFile paths in the sys.path + PythonQt::self()->setImporter(NULL); + // append the Qt resource root directory to the sys.path + mainModule.evalScript("sys.path.append(':')\n"); + mainModule.evalScript("import eyed3tagger\n"); + PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input); + Q_ASSERT(!tag.isNull()); + tag.call("setFileName", QVariantList() << "t.mp3"); + QVariant fn = tag.call("fileName", QVariantList()); + Q_ASSERT(fn.toString() == QString("t.mp3")); + } + { // alternative using import and loading it as a real module from sys.path + // import sys first + mainModule.evalScript(QString("sys.path.append('%1')\n").arg(QDir::currentPath())); + mainModule.evalScript("import eyed3tagger\n"); + PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input); + Q_ASSERT(!tag.isNull()); + tag.call("setFileName", QVariantList() << "t.mp3"); + QVariant fn = tag.call("fileName", QVariantList()); + Q_ASSERT(fn.toString() == QString("t.mp3")); + } + qDebug() << "finished"; + return 0; } diff --git a/examples/PyCPPWrapperExample/CustomObjects.cpp b/examples/PyCPPWrapperExample/CustomObjects.cpp index 7fdff8de4..5b96e8212 100644 --- a/examples/PyCPPWrapperExample/CustomObjects.cpp +++ b/examples/PyCPPWrapperExample/CustomObjects.cpp @@ -40,4 +40,3 @@ //---------------------------------------------------------------------------------- #include "CustomObjects.h" - diff --git a/examples/PyCPPWrapperExample/CustomObjects.h b/examples/PyCPPWrapperExample/CustomObjects.h index 97701966a..e9ef406bf 100644 --- a/examples/PyCPPWrapperExample/CustomObjects.h +++ b/examples/PyCPPWrapperExample/CustomObjects.h @@ -46,21 +46,24 @@ #include "PythonQtCppWrapperFactory.h" #include - // declare our own custom object -class CustomObject { +class CustomObject +{ public: CustomObject() {} - CustomObject(const QString& first, const QString& last) { _firstName = first; _lastName = last; } + CustomObject(const QString& first, const QString& last) + { + _firstName = first; + _lastName = last; + } QString _firstName; QString _lastName; - }; - // add a decorator that allows to access the CustomObject from PythonQt -class CustomObjectWrapper : public QObject { +class CustomObjectWrapper : public QObject +{ Q_OBJECT @@ -79,7 +82,6 @@ public Q_SLOTS: void setFirstName(CustomObject* o, const QString& name) { o->_firstName = name; } void setLastName(CustomObject* o, const QString& name) { o->_lastName = name; } - }; #endif diff --git a/examples/PyCPPWrapperExample/main.cpp b/examples/PyCPPWrapperExample/main.cpp index 064f0dc7b..88ad1da69 100644 --- a/examples/PyCPPWrapperExample/main.cpp +++ b/examples/PyCPPWrapperExample/main.cpp @@ -45,17 +45,17 @@ #include -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { QApplication qapp(argc, argv); PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut); - PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); + PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); PythonQtScriptingConsole console(NULL, mainContext); // register the new object as a known classname and add it's wrapper object - PythonQt::self()->registerCPPClass("CustomObject", "","example", PythonQtCreateObject); + PythonQt::self()->registerCPPClass("CustomObject", "", "example", PythonQtCreateObject); mainContext.evalFile(":example.py"); @@ -64,4 +64,3 @@ int main(int argc, char *argv[]) return qapp.exec(); } - diff --git a/examples/PyCustomMetaTypeExample/CustomObject.cpp b/examples/PyCustomMetaTypeExample/CustomObject.cpp index 0f2d55e6d..8763b7dc7 100644 --- a/examples/PyCustomMetaTypeExample/CustomObject.cpp +++ b/examples/PyCustomMetaTypeExample/CustomObject.cpp @@ -40,4 +40,3 @@ //---------------------------------------------------------------------------------- #include "CustomObject.h" - diff --git a/examples/PyCustomMetaTypeExample/CustomObject.h b/examples/PyCustomMetaTypeExample/CustomObject.h index 841118cd0..db6a9d280 100644 --- a/examples/PyCustomMetaTypeExample/CustomObject.h +++ b/examples/PyCustomMetaTypeExample/CustomObject.h @@ -45,23 +45,27 @@ #include "PythonQt.h" #include - // declare our own copyable custom object -class CustomObject { +class CustomObject +{ public: CustomObject() {} - CustomObject(const QString& first, const QString& last) { _firstName = first; _lastName = last; } + CustomObject(const QString& first, const QString& last) + { + _firstName = first; + _lastName = last; + } QString _firstName; QString _lastName; - }; // register it to the meta type system Q_DECLARE_METATYPE(CustomObject) // add a wrapper that allows to access the CustomObject from PythonQt -class CustomObjectWrapper : public QObject { +class CustomObjectWrapper : public QObject +{ Q_OBJECT @@ -78,8 +82,6 @@ public Q_SLOTS: void setFirstName(CustomObject* o, const QString& name) { o->_firstName = name; } void setLastName(CustomObject* o, const QString& name) { o->_lastName = name; } - }; - #endif diff --git a/examples/PyCustomMetaTypeExample/main.cpp b/examples/PyCustomMetaTypeExample/main.cpp index 28813e31f..bb4819d73 100644 --- a/examples/PyCustomMetaTypeExample/main.cpp +++ b/examples/PyCustomMetaTypeExample/main.cpp @@ -45,19 +45,19 @@ #include -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { QApplication qapp(argc, argv); PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut); - PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); + PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); PythonQtScriptingConsole console(NULL, mainContext); // register the type with QMetaType qRegisterMetaType("CustomObject"); // add a wrapper object for the new variant type - PythonQt::self()->registerCPPClass("CustomObject","","example", PythonQtCreateObject); + PythonQt::self()->registerCPPClass("CustomObject", "", "example", PythonQtCreateObject); mainContext.evalFile(":example.py"); @@ -66,4 +66,3 @@ int main(int argc, char *argv[]) return qapp.exec(); } - diff --git a/examples/PyDecoratorsExample/PyExampleDecorators.cpp b/examples/PyDecoratorsExample/PyExampleDecorators.cpp index 442f69d53..f90010682 100644 --- a/examples/PyDecoratorsExample/PyExampleDecorators.cpp +++ b/examples/PyDecoratorsExample/PyExampleDecorators.cpp @@ -40,4 +40,3 @@ //---------------------------------------------------------------------------------- #include "PyExampleDecorators.h" - diff --git a/examples/PyDecoratorsExample/PyExampleDecorators.h b/examples/PyDecoratorsExample/PyExampleDecorators.h index fef3bc4bd..303140047 100644 --- a/examples/PyDecoratorsExample/PyExampleDecorators.h +++ b/examples/PyDecoratorsExample/PyExampleDecorators.h @@ -48,13 +48,18 @@ #include // an example CPP object -class YourCPPObject { +class YourCPPObject +{ public: - YourCPPObject(int arg1, float arg2) { a = arg1; b = arg2; } + YourCPPObject(int arg1, float arg2) + { + a = arg1; + b = arg2; + } - float doSomething(int arg1) { return arg1*a*b; }; + float doSomething(int arg1) { return arg1 * a * b; }; - private: +private: int a; float b; @@ -70,7 +75,7 @@ public Q_SLOTS: QSize* new_QSize(const QPoint& p) { return new QSize(p.x(), p.y()); } // add a constructor for QPushButton that takes a text and a parent widget - QPushButton* new_QPushButton(const QString& text, QWidget* parent=NULL) { return new QPushButton(text, parent); } + QPushButton* new_QPushButton(const QString& text, QWidget* parent = NULL) { return new QPushButton(text, parent); } // add a constructor for a CPP object YourCPPObject* new_YourCPPObject(int arg1, float arg2) { return new YourCPPObject(arg1, arg2); } @@ -85,11 +90,10 @@ public Q_SLOTS: void move(QWidget* w, const QPoint& p) { w->move(p); } // add an additional slot to QWidget, overloading the above move method - void move(QWidget* w, int x, int y) { w->move(x,y); } + void move(QWidget* w, int x, int y) { w->move(x, y); } // add a method to your own CPP object int doSomething(YourCPPObject* obj, int arg1) { return obj->doSomething(arg1); } }; - #endif diff --git a/examples/PyDecoratorsExample/main.cpp b/examples/PyDecoratorsExample/main.cpp index 336963653..e8e41f73e 100644 --- a/examples/PyDecoratorsExample/main.cpp +++ b/examples/PyDecoratorsExample/main.cpp @@ -45,18 +45,18 @@ #include -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { QApplication qapp(argc, argv); PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut); - PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); + PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); PythonQtScriptingConsole console(NULL, mainContext); - + PythonQt::self()->addDecorators(new PyExampleDecorators()); PythonQt::self()->registerClass(&QPushButton::staticMetaObject, "QtGui"); - PythonQt::self()->registerCPPClass("YourCPPObject","", "example"); + PythonQt::self()->registerCPPClass("YourCPPObject", "", "example"); mainContext.evalFile(":example.py"); @@ -65,4 +65,3 @@ int main(int argc, char *argv[]) return qapp.exec(); } - diff --git a/examples/PyGettingStarted/main.cpp b/examples/PyGettingStarted/main.cpp index dcc52ccea..4cdbdaf44 100644 --- a/examples/PyGettingStarted/main.cpp +++ b/examples/PyGettingStarted/main.cpp @@ -47,25 +47,25 @@ #include #include -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { QApplication qapp(argc, argv); - + // init PythonQt and Python PythonQt::init(); - + // get the __main__ python module PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule(); - + // evaluate a simple python script and receive the result a qvariant: QVariant result = mainModule.evalScript("19*2+4", Py_eval_input); - + // create a small Qt GUI - QVBoxLayout* vbox = new QVBoxLayout; - QGroupBox* box = new QGroupBox; + QVBoxLayout* vbox = new QVBoxLayout; + QGroupBox* box = new QGroupBox; QTextBrowser* browser = new QTextBrowser(box); - QLineEdit* edit = new QLineEdit(box); - QPushButton* button = new QPushButton(box); + QLineEdit* edit = new QLineEdit(box); + QPushButton* button = new QPushButton(box); button->setObjectName("button1"); edit->setObjectName("edit"); browser->setObjectName("browser"); @@ -73,20 +73,17 @@ int main(int argc, char *argv[]) vbox->addWidget(edit); vbox->addWidget(button); box->setLayout(vbox); - + // make the groupbox to the python under the name "box" mainModule.addObject("box", box); - + // evaluate the python script which is defined in the resources mainModule.evalFile(":GettingStarted.py"); - + // define a python method that appends the passed text to the browser mainModule.evalScript("def appendText(text):\n box.browser.append(text)"); // shows how to call the method with a text that will be append to the browser mainModule.call("appendText", QVariantList() << "The ultimate answer is "); - - return qapp.exec(); } - diff --git a/examples/PyGuiExample/main.cpp b/examples/PyGuiExample/main.cpp index 633f51f59..d8d7776c5 100644 --- a/examples/PyGuiExample/main.cpp +++ b/examples/PyGuiExample/main.cpp @@ -49,15 +49,14 @@ #include #include - -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { QApplication qapp(argc, argv); PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut); PythonQt_QtAll::init(); - PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); + PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); PythonQtScriptingConsole console(NULL, mainContext); mainContext.evalFile(":example.py"); @@ -65,4 +64,3 @@ int main(int argc, char *argv[]) console.show(); return qapp.exec(); } - diff --git a/examples/PyLauncher/main.cpp b/examples/PyLauncher/main.cpp index 33e340013..d13717804 100644 --- a/examples/PyLauncher/main.cpp +++ b/examples/PyLauncher/main.cpp @@ -47,15 +47,14 @@ #include #include - -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { QApplication qapp(argc, argv); PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut); PythonQt_QtAll::init(); - PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); + PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); bool showConsole = false; QStringList files; @@ -87,4 +86,3 @@ int main(int argc, char *argv[]) return qapp.exec(); } - diff --git a/examples/PyScriptingConsole/PyExampleObject.cpp b/examples/PyScriptingConsole/PyExampleObject.cpp index 37102cf8e..03eb59982 100644 --- a/examples/PyScriptingConsole/PyExampleObject.cpp +++ b/examples/PyScriptingConsole/PyExampleObject.cpp @@ -43,17 +43,19 @@ #include #include -PyExampleObject::PyExampleObject():QObject(NULL) +PyExampleObject::PyExampleObject() + : QObject(NULL) { } -PyObject* PyExampleObject::getMainModule() { +PyObject* PyExampleObject::getMainModule() +{ return PythonQt::self()->getMainModule(); } void PyExampleObject::showInformation(const QString& str) { - QMessageBox::information ( NULL, "Test", str); + QMessageBox::information(NULL, "Test", str); } QStringList PyExampleObject::readDirectory(const QString& dir) diff --git a/examples/PyScriptingConsole/PyExampleObject.h b/examples/PyScriptingConsole/PyExampleObject.h index b97b0795d..47b3adbee 100644 --- a/examples/PyScriptingConsole/PyExampleObject.h +++ b/examples/PyScriptingConsole/PyExampleObject.h @@ -51,8 +51,8 @@ #include #include - -class PyExampleObject : public QObject { +class PyExampleObject : public QObject +{ Q_OBJECT @@ -61,7 +61,7 @@ class PyExampleObject : public QObject { public Q_SLOTS: - //! example for passing a PyObject directly from Qt to Python (without extra mashalling) + //! example for passing a PyObject directly from Qt to Python (without extra mashalling) PyObject* getMainModule(); void showInformation(const QString& str); @@ -73,7 +73,6 @@ public Q_SLOTS: QObject* findChild(QObject* o, const QString& name); QVariantMap testMap(); - }; #endif diff --git a/examples/PyScriptingConsole/main.cpp b/examples/PyScriptingConsole/main.cpp index f094a6cc3..35e251b80 100644 --- a/examples/PyScriptingConsole/main.cpp +++ b/examples/PyScriptingConsole/main.cpp @@ -51,15 +51,14 @@ #include #include - -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { QApplication qapp(argc, argv); PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut); PythonQt_QtAll::init(); - PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); + PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule(); PythonQtScriptingConsole console(NULL, mainContext); // add a QObject to the namespace of the main python context @@ -71,4 +70,3 @@ int main(int argc, char *argv[]) console.show(); return qapp.exec(); } - diff --git a/extensions/PythonQt_QtAll/PythonQt_QtAll.cpp b/extensions/PythonQt_QtAll/PythonQt_QtAll.cpp index 50a0ccec1..b7c0b0cf0 100644 --- a/extensions/PythonQt_QtAll/PythonQt_QtAll.cpp +++ b/extensions/PythonQt_QtAll/PythonQt_QtAll.cpp @@ -75,47 +75,47 @@ void PythonQt_init_QtUiTools(PyObject*); void PythonQt_init_QtWebKit(PyObject*); #endif -namespace PythonQt_QtAll +namespace PythonQt_QtAll { +PYTHONQT_QTALL_EXPORT void init() { - PYTHONQT_QTALL_EXPORT void init() { #ifdef PYTHONQT_WITH_CORE - PythonQt_init_QtCore(0); + PythonQt_init_QtCore(0); #endif #ifdef PYTHONQT_WITH_NETWORK - PythonQt_init_QtNetwork(0); + PythonQt_init_QtNetwork(0); #endif #ifdef PYTHONQT_WITH_GUI - PythonQt_init_QtGui(0); + PythonQt_init_QtGui(0); #endif #ifdef PYTHONQT_WITH_XML - PythonQt_init_QtXml(0); + PythonQt_init_QtXml(0); #endif #ifdef PYTHONQT_WITH_SVG - PythonQt_init_QtSvg(0); + PythonQt_init_QtSvg(0); #endif #ifdef PYTHONQT_WITH_SQL - PythonQt_init_QtSql(0); + PythonQt_init_QtSql(0); #endif #ifdef PYTHONQT_WITH_WEBKIT - PythonQt_init_QtWebKit(0); + PythonQt_init_QtWebKit(0); #endif #ifdef PYTHONQT_WITH_OPENGL - PythonQt_init_QtOpenGL(0); + PythonQt_init_QtOpenGL(0); #endif #ifdef PYTHONQT_WITH_XMLPATTERNS - PythonQt_init_QtXmlPatterns(0); + PythonQt_init_QtXmlPatterns(0); #endif #ifdef PYTHONQT_WITH_MULTIMEDIA - PythonQt_init_QtMultimedia(0); + PythonQt_init_QtMultimedia(0); #endif #ifdef PYTHONQT_WITH_QML - PythonQt_init_QtQml(0); + PythonQt_init_QtQml(0); #endif #ifdef PYTHONQT_WITH_QUICK - PythonQt_init_QtQuick(0); + PythonQt_init_QtQuick(0); #endif #ifdef PYTHONQT_WITH_UITOOLS - PythonQt_init_QtUiTools(0); + PythonQt_init_QtUiTools(0); #endif - } +} } diff --git a/extensions/PythonQt_QtAll/PythonQt_QtAll.h b/extensions/PythonQt_QtAll/PythonQt_QtAll.h index 689e2e83c..381193960 100644 --- a/extensions/PythonQt_QtAll/PythonQt_QtAll.h +++ b/extensions/PythonQt_QtAll/PythonQt_QtAll.h @@ -34,19 +34,18 @@ */ #ifdef WIN32 -#ifdef PYTHONQT_QTALL_EXPORTS -#define PYTHONQT_QTALL_EXPORT __declspec(dllexport) + #ifdef PYTHONQT_QTALL_EXPORTS + #define PYTHONQT_QTALL_EXPORT __declspec(dllexport) + #else + #define PYTHONQT_QTALL_EXPORT __declspec(dllimport) + #endif #else -#define PYTHONQT_QTALL_EXPORT __declspec(dllimport) -#endif -#else -#define PYTHONQT_QTALL_EXPORT + #define PYTHONQT_QTALL_EXPORT #endif -namespace PythonQt_QtAll -{ - //! initialize the Qt binding - PYTHONQT_QTALL_EXPORT void init(); +namespace PythonQt_QtAll { +//! initialize the Qt binding +PYTHONQT_QTALL_EXPORT void init(); } #endif diff --git a/generator/abstractmetabuilder.cpp b/generator/abstractmetabuilder.cpp index c12ff1661..50370dd67 100644 --- a/generator/abstractmetabuilder.cpp +++ b/generator/abstractmetabuilder.cpp @@ -54,170 +54,168 @@ #include #include #include -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) -# include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + #include #endif #include #include #include #include -static QString strip_template_args(const QString &name) +static QString strip_template_args(const QString& name) { - int pos = name.indexOf('<'); - return pos < 0 ? name : name.left(pos); + int pos = name.indexOf('<'); + return pos < 0 ? name : name.left(pos); } -static QHash *operator_names; -QString rename_operator(const QString &oper) +static QHash* operator_names; +QString rename_operator(const QString& oper) { - QString op = oper.trimmed(); - if (!operator_names) { - operator_names = new QHash; - - operator_names->insert("+", "__add__"); - operator_names->insert("-", "__sub__"); - operator_names->insert("*", "__mul__"); - operator_names->insert("/", "__div__"); - operator_names->insert("%", "__mod__"); - operator_names->insert("&", "__and__"); - operator_names->insert("|", "__or__"); - operator_names->insert("^", "__xor__"); - operator_names->insert("~", "__invert__"); - operator_names->insert("<<", "__lshift__"); - operator_names->insert(">>", "__rshift__"); - - // assigments - operator_names->insert("=", "assign"); - operator_names->insert("+=", "__iadd__"); - operator_names->insert("-=", "__isub__"); - operator_names->insert("*=", "__imul__"); - operator_names->insert("/=", "__idiv__"); - operator_names->insert("%=", "__imod__"); - operator_names->insert("&=", "__iand__"); - operator_names->insert("|=", "__ior__"); - operator_names->insert("^=", "__ixor__"); - operator_names->insert("<<=", "__ilshift__"); - operator_names->insert(">>=", "__irshift__"); - - // Logical - operator_names->insert("&&", "logical_and"); - operator_names->insert("||", "logical_or"); - operator_names->insert("!", "not"); - - // incr/decr - operator_names->insert("++", "increment"); - operator_names->insert("--", "decrement"); - - // compare - operator_names->insert("<", "__lt__"); - operator_names->insert(">", "__gt__"); - operator_names->insert("<=", "__le__"); - operator_names->insert(">=", "__ge__"); - operator_names->insert("!=", "__ne__"); - operator_names->insert("==", "__eq__"); - - // other - operator_names->insert("[]", "subscript"); - operator_names->insert("->", "pointer"); - } - - if (!operator_names->contains(op)) { - TypeDatabase *tb = TypeDatabase::instance(); - - TypeParser::Info typeInfo = TypeParser::parse(op); - QString cast_to_name = typeInfo.qualified_name.join("::"); - TypeEntry *te = tb->findType(cast_to_name); - if ((te && te->codeGeneration() == TypeEntry::GenerateNothing) - || tb->isClassRejected(cast_to_name)) { - return QString(); - } else if (te) { - return "operator_cast_" + typeInfo.qualified_name.join("_"); - } else { - ReportHandler::warning(QString("unknown operator '%1'").arg(op)); - return "operator " + op; - } - } + QString op = oper.trimmed(); + if (!operator_names) { + operator_names = new QHash; + + operator_names->insert("+", "__add__"); + operator_names->insert("-", "__sub__"); + operator_names->insert("*", "__mul__"); + operator_names->insert("/", "__div__"); + operator_names->insert("%", "__mod__"); + operator_names->insert("&", "__and__"); + operator_names->insert("|", "__or__"); + operator_names->insert("^", "__xor__"); + operator_names->insert("~", "__invert__"); + operator_names->insert("<<", "__lshift__"); + operator_names->insert(">>", "__rshift__"); + + // assigments + operator_names->insert("=", "assign"); + operator_names->insert("+=", "__iadd__"); + operator_names->insert("-=", "__isub__"); + operator_names->insert("*=", "__imul__"); + operator_names->insert("/=", "__idiv__"); + operator_names->insert("%=", "__imod__"); + operator_names->insert("&=", "__iand__"); + operator_names->insert("|=", "__ior__"); + operator_names->insert("^=", "__ixor__"); + operator_names->insert("<<=", "__ilshift__"); + operator_names->insert(">>=", "__irshift__"); + + // Logical + operator_names->insert("&&", "logical_and"); + operator_names->insert("||", "logical_or"); + operator_names->insert("!", "not"); + + // incr/decr + operator_names->insert("++", "increment"); + operator_names->insert("--", "decrement"); + + // compare + operator_names->insert("<", "__lt__"); + operator_names->insert(">", "__gt__"); + operator_names->insert("<=", "__le__"); + operator_names->insert(">=", "__ge__"); + operator_names->insert("!=", "__ne__"); + operator_names->insert("==", "__eq__"); + + // other + operator_names->insert("[]", "subscript"); + operator_names->insert("->", "pointer"); + } + + if (!operator_names->contains(op)) { + TypeDatabase* tb = TypeDatabase::instance(); - QString r = operator_names->value(op); - if (r.startsWith("__")) { - return r; + TypeParser::Info typeInfo = TypeParser::parse(op); + QString cast_to_name = typeInfo.qualified_name.join("::"); + TypeEntry* te = tb->findType(cast_to_name); + if ((te && te->codeGeneration() == TypeEntry::GenerateNothing) || tb->isClassRejected(cast_to_name)) { + return QString(); + } else if (te) { + return "operator_cast_" + typeInfo.qualified_name.join("_"); } else { - return "operator_" + r; + ReportHandler::warning(QString("unknown operator '%1'").arg(op)); + return "operator " + op; } + } + + QString r = operator_names->value(op); + if (r.startsWith("__")) { + return r; + } else { + return "operator_" + r; + } } AbstractMetaBuilder::AbstractMetaBuilder() - : m_current_class(0) + : m_current_class(0) { } AbstractMetaBuilder::~AbstractMetaBuilder() { - qDeleteAll(m_meta_classes); - qDeleteAll(m_enums); + qDeleteAll(m_meta_classes); + qDeleteAll(m_enums); } void AbstractMetaBuilder::checkFunctionModifications() { - TypeDatabase *types = TypeDatabase::instance(); - SingleTypeEntryHash entryHash = types->entries(); - QList entries = entryHash.values(); - for (TypeEntry *entry : entries) { - if (entry == 0) - continue; - if (!entry->isComplex() || entry->codeGeneration() == TypeEntry::GenerateNothing) - continue; - - ComplexTypeEntry *centry = static_cast(entry); - FunctionModificationList modifications = centry->functionModifications(); - - for (FunctionModification modification : modifications) { - QString signature = modification.signature; - - QString name = signature.trimmed(); - name = name.mid(0, signature.indexOf("(")); - - AbstractMetaClass *clazz = m_meta_classes.findClass(centry->qualifiedCppName()); - if (clazz == 0) - continue; - - AbstractMetaFunctionList functions = clazz->functions(); - bool found = false; - QStringList possibleSignatures; - for (AbstractMetaFunction *function : functions) { - if (function->minimalSignature() == signature && function->implementingClass() == clazz) { - found = true; - break; - } - - if (function->originalName() == name) - possibleSignatures.append(function->minimalSignature() + " in " + function->implementingClass()->name()); - } + TypeDatabase* types = TypeDatabase::instance(); + SingleTypeEntryHash entryHash = types->entries(); + QList entries = entryHash.values(); + for (TypeEntry* entry : entries) { + if (entry == 0) + continue; + if (!entry->isComplex() || entry->codeGeneration() == TypeEntry::GenerateNothing) + continue; + + ComplexTypeEntry* centry = static_cast(entry); + FunctionModificationList modifications = centry->functionModifications(); + + for (FunctionModification modification : modifications) { + QString signature = modification.signature; + + QString name = signature.trimmed(); + name = name.mid(0, signature.indexOf("(")); + + AbstractMetaClass* clazz = m_meta_classes.findClass(centry->qualifiedCppName()); + if (clazz == 0) + continue; + + AbstractMetaFunctionList functions = clazz->functions(); + bool found = false; + QStringList possibleSignatures; + for (AbstractMetaFunction* function : functions) { + if (function->minimalSignature() == signature && function->implementingClass() == clazz) { + found = true; + break; + } + + if (function->originalName() == name) + possibleSignatures.append(function->minimalSignature() + " in " + function->implementingClass()->name()); + } - if (!found) { - QString warning - = QString("signature '%1' for function modification in '%2' not found. Possible candidates: %3") - .arg(signature) - .arg(clazz->qualifiedCppName()) - .arg(possibleSignatures.join(", ")); + if (!found) { + QString warning = QString("signature '%1' for function modification in '%2' not found. Possible candidates: %3") + .arg(signature) + .arg(clazz->qualifiedCppName()) + .arg(possibleSignatures.join(", ")); - ReportHandler::warning(warning); - } - } + ReportHandler::warning(warning); + } } + } } -AbstractMetaClass *AbstractMetaBuilder::argumentToClass(ArgumentModelItem argument) +AbstractMetaClass* AbstractMetaBuilder::argumentToClass(ArgumentModelItem argument) { - AbstractMetaClass *returned = 0; - bool ok = false; - AbstractMetaType::shared_pointer type = translateType(argument->type(), &ok); - if (ok && type != 0 && type->typeEntry() != 0 && type->typeEntry()->isComplex()) { - const TypeEntry *entry = type->typeEntry(); - returned = m_meta_classes.findClass(entry->name()); - } - return returned; + AbstractMetaClass* returned = 0; + bool ok = false; + AbstractMetaType::shared_pointer type = translateType(argument->type(), &ok); + if (ok && type != 0 && type->typeEntry() != 0 && type->typeEntry()->isComplex()) { + const TypeEntry* entry = type->typeEntry(); + returned = m_meta_classes.findClass(entry->name()); + } + return returned; } /** @@ -225,11 +223,11 @@ AbstractMetaClass *AbstractMetaBuilder::argumentToClass(ArgumentModelItem argume */ void AbstractMetaBuilder::registerHashFunction(FunctionModelItem function_item) { - ArgumentList arguments = function_item->arguments(); - if (arguments.size() == 1) { - if (AbstractMetaClass *cls = argumentToClass(arguments.at(0))) - cls->setHasHashFunction(true); - } + ArgumentList arguments = function_item->arguments(); + if (arguments.size() == 1) { + if (AbstractMetaClass* cls = argumentToClass(arguments.at(0))) + cls->setHasHashFunction(true); + } } /** @@ -238,109 +236,113 @@ void AbstractMetaBuilder::registerHashFunction(FunctionModelItem function_item) void AbstractMetaBuilder::registerToStringCapability(FunctionModelItem function_item) { - ArgumentList arguments = function_item->arguments(); - if (arguments.size() == 2) { - if (arguments.at(0)->type().toString() == "QDebug"){ - ArgumentModelItem arg = arguments.at(1); - if (AbstractMetaClass *cls = argumentToClass(arg)) { - if (arg->type().indirections() < 2 && cls->name()!="QObject") { - cls->setToStringCapability(function_item); - } - } + ArgumentList arguments = function_item->arguments(); + if (arguments.size() == 2) { + if (arguments.at(0)->type().toString() == "QDebug") { + ArgumentModelItem arg = arguments.at(1); + if (AbstractMetaClass* cls = argumentToClass(arg)) { + if (arg->type().indirections() < 2 && cls->name() != "QObject") { + cls->setToStringCapability(function_item); } + } } + } } -void AbstractMetaBuilder::traverseCompareOperator(FunctionModelItem item) { - ArgumentList arguments = item->arguments(); - if (arguments.size() == 2 && item->accessPolicy() == CodeModel::Public) { - AbstractMetaClass *comparer_class = argumentToClass(arguments.at(0)); - AbstractMetaClass *compared_class = argumentToClass(arguments.at(1)); - if (comparer_class != 0 && compared_class != 0) { - AbstractMetaClass *old_current_class = m_current_class; - m_current_class = comparer_class; - - AbstractMetaFunction *meta_function = traverseFunction(item); - if (meta_function != 0 && !meta_function->isInvalid()) { - // Strip away first argument, since that is the containing object - AbstractMetaArgumentList arguments = meta_function->arguments(); - arguments.pop_front(); - meta_function->setArguments(arguments); - - meta_function->setFunctionType(AbstractMetaFunction::GlobalScopeFunction); - - meta_function->setOriginalAttributes(meta_function->attributes()); - setupFunctionDefaults(meta_function, comparer_class); - - comparer_class->addFunction(meta_function, /*check_duplicates=*/true); - } else if (meta_function != 0) { - delete meta_function; - } +void AbstractMetaBuilder::traverseCompareOperator(FunctionModelItem item) +{ + ArgumentList arguments = item->arguments(); + if (arguments.size() == 2 && item->accessPolicy() == CodeModel::Public) { + AbstractMetaClass* comparer_class = argumentToClass(arguments.at(0)); + AbstractMetaClass* compared_class = argumentToClass(arguments.at(1)); + if (comparer_class != 0 && compared_class != 0) { + AbstractMetaClass* old_current_class = m_current_class; + m_current_class = comparer_class; + + AbstractMetaFunction* meta_function = traverseFunction(item); + if (meta_function != 0 && !meta_function->isInvalid()) { + // Strip away first argument, since that is the containing object + AbstractMetaArgumentList arguments = meta_function->arguments(); + arguments.pop_front(); + meta_function->setArguments(arguments); + + meta_function->setFunctionType(AbstractMetaFunction::GlobalScopeFunction); + + meta_function->setOriginalAttributes(meta_function->attributes()); + setupFunctionDefaults(meta_function, comparer_class); + + comparer_class->addFunction(meta_function, /*check_duplicates=*/true); + } else if (meta_function != 0) { + delete meta_function; + } - m_current_class = old_current_class; - } + m_current_class = old_current_class; } + } } void AbstractMetaBuilder::traverseStreamOperator(FunctionModelItem item) { - ArgumentList arguments = item->arguments(); - if (arguments.size() == 2 && item->accessPolicy() == CodeModel::Public) { - AbstractMetaClass *streamClass = argumentToClass(arguments.at(0)); - AbstractMetaClass *streamedClass = argumentToClass(arguments.at(1)); + ArgumentList arguments = item->arguments(); + if (arguments.size() == 2 && item->accessPolicy() == CodeModel::Public) { + AbstractMetaClass* streamClass = argumentToClass(arguments.at(0)); + AbstractMetaClass* streamedClass = argumentToClass(arguments.at(1)); - if (streamClass != 0 && streamedClass != 0 - && (streamClass->name() == "QDataStream" || streamClass->name() == "QTextStream")) { - AbstractMetaClass *old_current_class = m_current_class; - m_current_class = streamedClass; - AbstractMetaFunction *streamFunction = traverseFunction(item); + if (streamClass != 0 && streamedClass != 0 + && (streamClass->name() == "QDataStream" || streamClass->name() == "QTextStream")) + { + AbstractMetaClass* old_current_class = m_current_class; + m_current_class = streamedClass; + AbstractMetaFunction* streamFunction = traverseFunction(item); - if (streamFunction != 0 && !streamFunction->isInvalid()) { - QString name = item->name(); - streamFunction->setFunctionType(AbstractMetaFunction::GlobalScopeFunction); + if (streamFunction != 0 && !streamFunction->isInvalid()) { + QString name = item->name(); + streamFunction->setFunctionType(AbstractMetaFunction::GlobalScopeFunction); - if (name.endsWith("<<")) - streamFunction->setName("writeTo"); - else - streamFunction->setName("readFrom"); + if (name.endsWith("<<")) + streamFunction->setName("writeTo"); + else + streamFunction->setName("readFrom"); - // Strip away last argument, since that is the containing object - AbstractMetaArgumentList arguments = streamFunction->arguments(); - arguments.pop_back(); - streamFunction->setArguments(arguments); + // Strip away last argument, since that is the containing object + AbstractMetaArgumentList arguments = streamFunction->arguments(); + arguments.pop_back(); + streamFunction->setArguments(arguments); - *streamFunction += AbstractMetaAttributes::Final; - *streamFunction += AbstractMetaAttributes::Public; - streamFunction->setOriginalAttributes(streamFunction->attributes()); + *streamFunction += AbstractMetaAttributes::Final; + *streamFunction += AbstractMetaAttributes::Public; + streamFunction->setOriginalAttributes(streamFunction->attributes()); - streamFunction->setType(0); + streamFunction->setType(0); - setupFunctionDefaults(streamFunction, streamedClass); + setupFunctionDefaults(streamFunction, streamedClass); - streamedClass->addFunction(streamFunction, /*check_duplicates=*/true); - streamedClass->typeEntry()->addExtraInclude(streamClass->typeEntry()->include()); + streamedClass->addFunction(streamFunction, /*check_duplicates=*/true); + streamedClass->typeEntry()->addExtraInclude(streamClass->typeEntry()->include()); - m_current_class = old_current_class; - } - } + m_current_class = old_current_class; + } } + } } void AbstractMetaBuilder::traverseArithmeticOperator(FunctionModelItem item) { ArgumentList arguments = item->arguments(); if ((arguments.size() == 1 || arguments.size() == 2) && item->accessPolicy() == CodeModel::Public) { - AbstractMetaClass *aClass = argumentToClass(arguments.at(0)); - AbstractMetaClass *bClass = arguments.size() == 2 ? argumentToClass(arguments.at(1)) : nullptr; + AbstractMetaClass* aClass = argumentToClass(arguments.at(0)); + AbstractMetaClass* bClass = arguments.size() == 2 ? argumentToClass(arguments.at(1)) : nullptr; - if (!aClass) return; + if (!aClass) + return; - AbstractMetaClass *old_current_class = m_current_class; + AbstractMetaClass* old_current_class = m_current_class; m_current_class = aClass; - AbstractMetaFunction *streamFunction = traverseFunction(item); + AbstractMetaFunction* streamFunction = traverseFunction(item); if (streamFunction != 0 && !streamFunction->isInvalid()) { QString name = rename_operator(item->name().mid(8)); - if (name.isEmpty()) return; + if (name.isEmpty()) + return; streamFunction->setFunctionType(AbstractMetaFunction::GlobalScopeFunction); streamFunction->setName(name); @@ -366,31 +368,30 @@ void AbstractMetaBuilder::traverseArithmeticOperator(FunctionModelItem item) } } -void AbstractMetaBuilder::fixQObjectForScope(TypeDatabase *types, - NamespaceModelItem scope) +void AbstractMetaBuilder::fixQObjectForScope(TypeDatabase* types, NamespaceModelItem scope) { - for (const ClassModelItem& item : scope->classes()) { - QString qualified_name = item->qualifiedName().join("::"); - TypeEntry *entry = types->findType(qualified_name); - if (entry) { - if (isQObject(qualified_name) && entry->isComplex()) { - ((ComplexTypeEntry *) entry)->setQObject(true); - } - } + for (const ClassModelItem& item : scope->classes()) { + QString qualified_name = item->qualifiedName().join("::"); + TypeEntry* entry = types->findType(qualified_name); + if (entry) { + if (isQObject(qualified_name) && entry->isComplex()) { + ((ComplexTypeEntry*)entry)->setQObject(true); + } } + } - for (const NamespaceModelItem& item : scope->namespaceMap().values()) { - if (scope != item) - fixQObjectForScope(types, item); - } + for (const NamespaceModelItem& item : scope->namespaceMap().values()) { + if (scope != item) + fixQObjectForScope(types, item); + } } void AbstractMetaBuilder::sortLists() { - m_meta_classes.sort(); - for (AbstractMetaClass *cls : m_meta_classes) { - cls->sortFunctions(); - } + m_meta_classes.sort(); + for (AbstractMetaClass* cls : m_meta_classes) { + cls->sortFunctions(); + } } AbstractMetaClass* AbstractMetaBuilder::getGlobalNamespace(const TypeEntry* typeEntry) @@ -418,1713 +419,1650 @@ AbstractMetaClass* AbstractMetaBuilder::getGlobalNamespace(const TypeEntry* type Include AbstractMetaBuilder::getRelativeInclude(const QString& path) { #ifdef Q_OS_MACOS - // If the parsed header lives inside a macOS framework bundle, emit just the - // bare header name (e.g., "qbytearray.h") so generators will produce <...>. - // - // Match both: - // .../QtCore.framework/Headers/... - // .../QtCore.framework/Versions//Headers/... - static const QRegularExpression fwHeadersRe( - QStringLiteral(R"(\.framework/(Versions/[^/]+/)?Headers/)") - ); - if (fwHeadersRe.match(path).hasMatch()) { - const QString base = QFileInfo(path).fileName(); // e.g., "qbytearray.h" - return Include(Include::IncludePath, base); // choose <> style - } + // If the parsed header lives inside a macOS framework bundle, emit just the + // bare header name (e.g., "qbytearray.h") so generators will produce <...>. + // + // Match both: + // .../QtCore.framework/Headers/... + // .../QtCore.framework/Versions//Headers/... + static const QRegularExpression fwHeadersRe(QStringLiteral(R"(\.framework/(Versions/[^/]+/)?Headers/)")); + if (fwHeadersRe.match(path).hasMatch()) { + const QString base = QFileInfo(path).fileName(); // e.g., "qbytearray.h" + return Include(Include::IncludePath, base); // choose <> style + } #endif - QString bestRelativePath; - int bestNumDirectories = 0; - // find the shortest relative path relative to all given include directories - for (QString includePath : m_include_paths) { - QDir includeDir(includePath); - QString relativePath = includeDir.relativeFilePath(path); - QFileInfo info(relativePath); - if (!info.isRelative()) { - // not relative - different drives? - continue; - } - int numDirectories = relativePath.count('/'); - if (bestRelativePath.isEmpty() || numDirectories < bestNumDirectories) { - bestRelativePath = relativePath; - bestNumDirectories = numDirectories; - if (numDirectories == 0) { - // optimal relative path - break; - } - } - } - if (bestRelativePath.isEmpty()) { - // This shouldn't happen - QFileInfo info(path); - return Include(Include::IncludePath, info.fileName()); - } - else { - return Include(Include::IncludePath, bestRelativePath); + QString bestRelativePath; + int bestNumDirectories = 0; + // find the shortest relative path relative to all given include directories + for (QString includePath : m_include_paths) { + QDir includeDir(includePath); + QString relativePath = includeDir.relativeFilePath(path); + QFileInfo info(relativePath); + if (!info.isRelative()) { + // not relative - different drives? + continue; + } + int numDirectories = relativePath.count('/'); + if (bestRelativePath.isEmpty() || numDirectories < bestNumDirectories) { + bestRelativePath = relativePath; + bestNumDirectories = numDirectories; + if (numDirectories == 0) { + // optimal relative path + break; + } } + } + if (bestRelativePath.isEmpty()) { + // This shouldn't happen + QFileInfo info(path); + return Include(Include::IncludePath, info.fileName()); + } else { + return Include(Include::IncludePath, bestRelativePath); + } } bool AbstractMetaBuilder::build() { - Q_ASSERT(!m_file_name.isEmpty()); + Q_ASSERT(!m_file_name.isEmpty()); - QFile file(m_file_name); + QFile file(m_file_name); - if (!file.open(QFile::ReadOnly)) - return false; - - QTextStream stream(&file); -# if QT_VERSION < QT_VERSION_CHECK(6,0,0) - stream.setCodec(QTextCodec::codecForName("UTF-8")); - /* Note required in Qt6: see the same call in asttoxml.cpp */ -# endif - QByteArray contents = stream.readAll().toUtf8(); - file.close(); - - Control control; - control.setSkipFunctionBody(true); - Parser p(&control); - pool __pool; - - TranslationUnitAST *ast = p.parse(contents, contents.size(), &__pool); + if (!file.open(QFile::ReadOnly)) + return false; - CodeModel model; - Binder binder(&model, p.location()); - m_dom = binder.run(ast); + QTextStream stream(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + stream.setCodec(QTextCodec::codecForName("UTF-8")); + /* Note required in Qt6: see the same call in asttoxml.cpp */ +#endif + QByteArray contents = stream.readAll().toUtf8(); + file.close(); - pushScope(m_dom.dynamicCast<_ScopeModelItem>()); + Control control; + control.setSkipFunctionBody(true); + Parser p(&control); + pool __pool; - QHash typeMap = m_dom->classMap(); + TranslationUnitAST* ast = p.parse(contents, contents.size(), &__pool); + CodeModel model; + Binder binder(&model, p.location()); + m_dom = binder.run(ast); - // fix up QObject's in the type system.. - TypeDatabase *types = TypeDatabase::instance(); - fixQObjectForScope(types, m_dom.dynamicCast<_NamespaceModelItem>()); + pushScope(m_dom.dynamicCast<_ScopeModelItem>()); + QHash typeMap = m_dom->classMap(); - // Start the generation... + // fix up QObject's in the type system.. + TypeDatabase* types = TypeDatabase::instance(); + fixQObjectForScope(types, m_dom.dynamicCast<_NamespaceModelItem>()); - // First automatically add all enums marked as QEnum into the TypeDatabase - // (if they don't contain an entry already). If there is an QEnum entry, - // the enum is obviously meant for scripting. - for (const ClassModelItem& item : typeMap.values()) { - autoAddQEnumsForClassItem(item); - } + // Start the generation... - for (const ClassModelItem& item : typeMap.values()) { - AbstractMetaClass *cls = traverseClass(item); - addAbstractMetaClass(cls); - } + // First automatically add all enums marked as QEnum into the TypeDatabase + // (if they don't contain an entry already). If there is an QEnum entry, + // the enum is obviously meant for scripting. + for (const ClassModelItem& item : typeMap.values()) { + autoAddQEnumsForClassItem(item); + } - QHash namespaceMap = m_dom->namespaceMap(); - for (const NamespaceModelItem& item : namespaceMap.values()) { - AbstractMetaClass *meta_class = traverseNamespace(item); - if (meta_class) - m_meta_classes << meta_class; - } + for (const ClassModelItem& item : typeMap.values()) { + AbstractMetaClass* cls = traverseClass(item); + addAbstractMetaClass(cls); + } - // Some trickery to support global-namespace enums... - QHash enumMap = m_dom->enumMap(); - m_current_class = 0; - for (EnumModelItem item : enumMap) { - AbstractMetaEnum *meta_enum = traverseEnum(item, 0, QSet()); + QHash namespaceMap = m_dom->namespaceMap(); + for (const NamespaceModelItem& item : namespaceMap.values()) { + AbstractMetaClass* meta_class = traverseNamespace(item); + if (meta_class) + m_meta_classes << meta_class; + } - if (meta_enum) { - AbstractMetaClass* global = getGlobalNamespace(meta_enum->typeEntry()); + // Some trickery to support global-namespace enums... + QHash enumMap = m_dom->enumMap(); + m_current_class = 0; + for (EnumModelItem item : enumMap) { + AbstractMetaEnum* meta_enum = traverseEnum(item, 0, QSet()); - global->addEnum(meta_enum); + if (meta_enum) { + AbstractMetaClass* global = getGlobalNamespace(meta_enum->typeEntry()); - // Global enums should be public despite not having public - // identifiers so we'll fix the original attributes here. - meta_enum->setOriginalAttributes(meta_enum->attributes()); + global->addEnum(meta_enum); - // global enums have their own include - if (meta_enum->typeEntry()->include().isValid()) { - global->typeEntry()->addExtraInclude(meta_enum->typeEntry()->include()); - } - } - } + // Global enums should be public despite not having public + // identifiers so we'll fix the original attributes here. + meta_enum->setOriginalAttributes(meta_enum->attributes()); - // Go through all typedefs to see if we have defined any - // specific typedefs to be used as classes. - TypeAliasList typeAliases = m_dom->typeAliases(); - for (TypeAliasModelItem typeAlias : typeAliases) { - AbstractMetaClass *cls = traverseTypeAlias(typeAlias); - addAbstractMetaClass(cls); + // global enums have their own include + if (meta_enum->typeEntry()->include().isValid()) { + global->typeEntry()->addExtraInclude(meta_enum->typeEntry()->include()); + } } + } + // Go through all typedefs to see if we have defined any + // specific typedefs to be used as classes. + TypeAliasList typeAliases = m_dom->typeAliases(); + for (TypeAliasModelItem typeAlias : typeAliases) { + AbstractMetaClass* cls = traverseTypeAlias(typeAlias); + addAbstractMetaClass(cls); + } - - - for (AbstractMetaClass *cls : m_meta_classes) { - if (!cls->isInterface() && !cls->isNamespace()) { - setupInheritance(cls); - } + for (AbstractMetaClass* cls : m_meta_classes) { + if (!cls->isInterface() && !cls->isNamespace()) { + setupInheritance(cls); } + } + for (AbstractMetaClass* cls : m_meta_classes) { + cls->fixFunctions(); - for (AbstractMetaClass *cls : m_meta_classes) { - cls->fixFunctions(); - - if (cls->typeEntry() == 0) { - ReportHandler::warning(QString("class '%1' does not have an entry in the type system") - .arg(cls->name())); - } else { - if (!cls->hasConstructors() && !cls->isFinalInCpp() && !cls->isInterface() && !cls->isNamespace()) - cls->addDefaultConstructor(); - } + if (cls->typeEntry() == 0) { + ReportHandler::warning(QString("class '%1' does not have an entry in the type system").arg(cls->name())); + } else { + if (!cls->hasConstructors() && !cls->isFinalInCpp() && !cls->isInterface() && !cls->isNamespace()) + cls->addDefaultConstructor(); + } - if (cls->isAbstract() && !cls->isInterface()) { - cls->typeEntry()->setLookupName(cls->typeEntry()->targetLangName() + "$ConcreteWrapper"); - } + if (cls->isAbstract() && !cls->isInterface()) { + cls->typeEntry()->setLookupName(cls->typeEntry()->targetLangName() + "$ConcreteWrapper"); } + } - QList entries = TypeDatabase::instance()->entries().values(); - for (const TypeEntry *entry : entries) { - if (entry->isPrimitive()) - continue; - - if ((entry->isValue() || entry->isObject()) - && !entry->isString() - && !entry->isChar() - && !entry->isContainer() - && !entry->isCustom() - && !entry->isVariant() - && !m_meta_classes.findClass(entry->qualifiedCppName())) { - ReportHandler::warning(QString("type '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.") - .arg(entry->qualifiedCppName())); - } + QList entries = TypeDatabase::instance()->entries().values(); + for (const TypeEntry* entry : entries) { + if (entry->isPrimitive()) + continue; - if (entry->isEnum()) { - QString pkg = entry->javaPackage(); - QString name = (pkg.isEmpty() ? QString() : pkg + ".") - + ((EnumTypeEntry *) entry)->javaQualifier(); - AbstractMetaClass *cls = m_meta_classes.findClass(name); - - if (!cls) { - ReportHandler::warning(QString("namespace '%1' for enum '%2' is not declared") - .arg(name).arg(entry->targetLangName())); - } else { - AbstractMetaEnum *e = cls->findEnum(entry->targetLangName()); - if (!e) - ReportHandler::warning(QString("enum '%1' is specified in typesystem, " - "but not declared") - .arg(entry->qualifiedCppName())); - } - } + if ((entry->isValue() || entry->isObject()) && !entry->isString() && !entry->isChar() && !entry->isContainer() + && !entry->isCustom() && !entry->isVariant() && !m_meta_classes.findClass(entry->qualifiedCppName())) + { + ReportHandler::warning(QString( + "type '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.") + .arg(entry->qualifiedCppName())); + } + + if (entry->isEnum()) { + QString pkg = entry->javaPackage(); + QString name = (pkg.isEmpty() ? QString() : pkg + ".") + ((EnumTypeEntry*)entry)->javaQualifier(); + AbstractMetaClass* cls = m_meta_classes.findClass(name); + + if (!cls) { + ReportHandler::warning( + QString("namespace '%1' for enum '%2' is not declared").arg(name).arg(entry->targetLangName())); + } else { + AbstractMetaEnum* e = cls->findEnum(entry->targetLangName()); + if (!e) + ReportHandler::warning(QString("enum '%1' is specified in typesystem, " + "but not declared") + .arg(entry->qualifiedCppName())); + } } + } - { - FunctionList hash_functions = m_dom->findFunctions("qHash"); - for (FunctionModelItem item : hash_functions) { - registerHashFunction(item); - } + { + FunctionList hash_functions = m_dom->findFunctions("qHash"); + for (FunctionModelItem item : hash_functions) { + registerHashFunction(item); } + } - { - FunctionList hash_functions = m_dom->findFunctions("operator<<"); - for (FunctionModelItem item : hash_functions) { - registerToStringCapability(item); - } + { + FunctionList hash_functions = m_dom->findFunctions("operator<<"); + for (FunctionModelItem item : hash_functions) { + registerToStringCapability(item); } + } - { - FunctionList compare_operators = m_dom->findFunctions("operator==") - + m_dom->findFunctions("operator!=") - + m_dom->findFunctions("operator<=") - + m_dom->findFunctions("operator>=") - + m_dom->findFunctions("operator<") - + m_dom->findFunctions("operator>"); - for (FunctionModelItem item : compare_operators) { - traverseCompareOperator(item); - } + { + FunctionList compare_operators = m_dom->findFunctions("operator==") + m_dom->findFunctions("operator!=") + + m_dom->findFunctions("operator<=") + m_dom->findFunctions("operator>=") + + m_dom->findFunctions("operator<") + m_dom->findFunctions("operator>"); + for (FunctionModelItem item : compare_operators) { + traverseCompareOperator(item); } + } - { - FunctionList stream_operators = - m_dom->findFunctions("operator+") + m_dom->findFunctions("operator-") - + m_dom->findFunctions("operator/") + m_dom->findFunctions("operator*") - + m_dom->findFunctions("operator&") + m_dom->findFunctions("operator|") - + m_dom->findFunctions("operator%") + m_dom->findFunctions("operator^") - + m_dom->findFunctions("operator!") + m_dom->findFunctions("operator~"); - for (FunctionModelItem item : stream_operators) { - traverseArithmeticOperator(item); - } + { + FunctionList stream_operators = m_dom->findFunctions("operator+") + m_dom->findFunctions("operator-") + + m_dom->findFunctions("operator/") + m_dom->findFunctions("operator*") + + m_dom->findFunctions("operator&") + m_dom->findFunctions("operator|") + + m_dom->findFunctions("operator%") + m_dom->findFunctions("operator^") + + m_dom->findFunctions("operator!") + m_dom->findFunctions("operator~"); + for (FunctionModelItem item : stream_operators) { + traverseArithmeticOperator(item); } - { - FunctionList stream_operators = m_dom->findFunctions("operator<<") + m_dom->findFunctions("operator>>"); - for (FunctionModelItem item : stream_operators) { - traverseStreamOperator(item); - } + } + { + FunctionList stream_operators = m_dom->findFunctions("operator<<") + m_dom->findFunctions("operator>>"); + for (FunctionModelItem item : stream_operators) { + traverseStreamOperator(item); } + } - checkFunctionModifications(); + checkFunctionModifications(); - for (AbstractMetaClass *cls : m_meta_classes) { - setupEquals(cls); - setupComparable(cls); - setupClonable(cls); - } + for (AbstractMetaClass* cls : m_meta_classes) { + setupEquals(cls); + setupComparable(cls); + setupClonable(cls); + } - dumpLog(); + dumpLog(); - sortLists(); + sortLists(); - return true; + return true; } void AbstractMetaBuilder::autoAddQEnumsForClassItem(ClassModelItem class_item) { - // also do this for sub-classes: - for (ClassModelItem sub_class : class_item->classMap().values()) { - autoAddQEnumsForClassItem(sub_class); - } - - auto qEnumDeclarations = class_item->qEnumDeclarations(); - for (EnumModelItem enum_item : class_item->enumMap().values()) { - if (enum_item) { - const auto& names = enum_item->qualifiedName(); - QString qualified_name = names.join("::"); - QString enum_name = enum_item->name(); - - bool hasQEnumDeclaration = qEnumDeclarations.contains(qualified_name) - || qEnumDeclarations.contains(enum_name); - - TypeEntry* type_entry = TypeDatabase::instance()->findType(qualified_name); - if (hasQEnumDeclaration && !type_entry) { - // automatically add enum type declared as Q_ENUM - type_entry = new EnumTypeEntry(QStringList(names.mid(0, names.size() - 1)).join("::"), names.last()); - TypeDatabase::instance()->addType(type_entry); - } - } - } -} + // also do this for sub-classes: + for (ClassModelItem sub_class : class_item->classMap().values()) { + autoAddQEnumsForClassItem(sub_class); + } + auto qEnumDeclarations = class_item->qEnumDeclarations(); + for (EnumModelItem enum_item : class_item->enumMap().values()) { + if (enum_item) { + const auto& names = enum_item->qualifiedName(); + QString qualified_name = names.join("::"); + QString enum_name = enum_item->name(); -void AbstractMetaBuilder::addAbstractMetaClass(AbstractMetaClass *cls) -{ - if (!cls) - return; + bool hasQEnumDeclaration = qEnumDeclarations.contains(qualified_name) || qEnumDeclarations.contains(enum_name); - cls->setOriginalAttributes(cls->attributes()); - if (cls->typeEntry()->isContainer()) { - QString name = cls->typeEntry()->name(); - if (cls->functions().size() || cls->baseClassNames().size()) { - if (!m_templates.contains(name)) { - m_templates[name] = cls; - } - else { - ReportHandler::warning(QString("Duplicate container type template '%1'").arg(name)); - } - } - } else { - m_meta_classes << cls; - if (cls->typeEntry()->designatedInterface()) { - AbstractMetaClass *interface = cls->extractInterface(); - m_meta_classes << interface; - ReportHandler::debugSparse(QString(" -> interface '%1'").arg(interface->name())); - } + TypeEntry* type_entry = TypeDatabase::instance()->findType(qualified_name); + if (hasQEnumDeclaration && !type_entry) { + // automatically add enum type declared as Q_ENUM + type_entry = new EnumTypeEntry(QStringList(names.mid(0, names.size() - 1)).join("::"), names.last()); + TypeDatabase::instance()->addType(type_entry); + } } + } } - -AbstractMetaClass *AbstractMetaBuilder::traverseNamespace(NamespaceModelItem namespace_item) +void AbstractMetaBuilder::addAbstractMetaClass(AbstractMetaClass* cls) { - QString namespace_name = (!m_namespace_prefix.isEmpty() ? m_namespace_prefix + "::" : QString()) + namespace_item->name(); - NamespaceTypeEntry *type = TypeDatabase::instance()->findNamespaceType(namespace_name); - - if (TypeDatabase::instance()->isClassRejected(namespace_name)) { - m_rejected_classes.insert(namespace_name, GenerationDisabled); - return 0; + if (!cls) + return; + + cls->setOriginalAttributes(cls->attributes()); + if (cls->typeEntry()->isContainer()) { + QString name = cls->typeEntry()->name(); + if (cls->functions().size() || cls->baseClassNames().size()) { + if (!m_templates.contains(name)) { + m_templates[name] = cls; + } else { + ReportHandler::warning(QString("Duplicate container type template '%1'").arg(name)); + } } - - if (!type) { - ReportHandler::warning(QString("namespace '%1' does not have a type entry") - .arg(namespace_name)); - return 0; + } else { + m_meta_classes << cls; + if (cls->typeEntry()->designatedInterface()) { + AbstractMetaClass* interface = cls->extractInterface(); + m_meta_classes << interface; + ReportHandler::debugSparse(QString(" -> interface '%1'").arg(interface->name())); } + } +} - AbstractMetaClass *meta_class = createMetaClass(); - meta_class->setTypeEntry(type); - - *meta_class += AbstractMetaAttributes::Public; +AbstractMetaClass* AbstractMetaBuilder::traverseNamespace(NamespaceModelItem namespace_item) +{ + QString namespace_name = + (!m_namespace_prefix.isEmpty() ? m_namespace_prefix + "::" : QString()) + namespace_item->name(); + NamespaceTypeEntry* type = TypeDatabase::instance()->findNamespaceType(namespace_name); - m_current_class = meta_class; + if (TypeDatabase::instance()->isClassRejected(namespace_name)) { + m_rejected_classes.insert(namespace_name, GenerationDisabled); + return 0; + } - ReportHandler::debugSparse(QString("namespace '%1.%2'") - .arg(meta_class->package()) - .arg(namespace_item->name())); + if (!type) { + ReportHandler::warning(QString("namespace '%1' does not have a type entry").arg(namespace_name)); + return 0; + } - traverseEnums(namespace_item.dynamicCast<_ScopeModelItem>(), meta_class, namespace_item->qEnumDeclarations()); - traverseFunctions(namespace_item.dynamicCast<_ScopeModelItem>(), meta_class); -// traverseClasses(model_dynamic_cast(namespace_item)); + AbstractMetaClass* meta_class = createMetaClass(); + meta_class->setTypeEntry(type); - // collect all include files (since namespace items might come from different files) - QSet includeFiles; - for (const auto& item : namespace_item->enums()) { - includeFiles.insert(item->fileName()); - } - for (const auto& item : namespace_item->functions()) { - includeFiles.insert(item->fileName()); - } - // (should we do this for typeAliases and inner namespaces too?) + *meta_class += AbstractMetaAttributes::Public; - pushScope(namespace_item.dynamicCast<_ScopeModelItem>()); - m_namespace_prefix = currentScope()->qualifiedName().join("::"); + m_current_class = meta_class; + ReportHandler::debugSparse(QString("namespace '%1.%2'").arg(meta_class->package()).arg(namespace_item->name())); - ClassList classes = namespace_item->classes(); - for (ClassModelItem cls : classes) { - AbstractMetaClass *mjc = traverseClass(cls); - addAbstractMetaClass(mjc); - includeFiles.insert(cls->fileName()); - } + traverseEnums(namespace_item.dynamicCast<_ScopeModelItem>(), meta_class, namespace_item->qEnumDeclarations()); + traverseFunctions(namespace_item.dynamicCast<_ScopeModelItem>(), meta_class); + // traverseClasses(model_dynamic_cast(namespace_item)); - // Go through all typedefs to see if we have defined any - // specific typedefs to be used as classes. - TypeAliasList typeAliases = namespace_item->typeAliases(); - for (TypeAliasModelItem typeAlias : typeAliases) { - AbstractMetaClass *cls = traverseTypeAlias(typeAlias); - addAbstractMetaClass(cls); - } + // collect all include files (since namespace items might come from different files) + QSet includeFiles; + for (const auto& item : namespace_item->enums()) { + includeFiles.insert(item->fileName()); + } + for (const auto& item : namespace_item->functions()) { + includeFiles.insert(item->fileName()); + } + // (should we do this for typeAliases and inner namespaces too?) + pushScope(namespace_item.dynamicCast<_ScopeModelItem>()); + m_namespace_prefix = currentScope()->qualifiedName().join("::"); + ClassList classes = namespace_item->classes(); + for (ClassModelItem cls : classes) { + AbstractMetaClass* mjc = traverseClass(cls); + addAbstractMetaClass(mjc); + includeFiles.insert(cls->fileName()); + } - // Traverse namespaces recursively - QList inner_namespaces = namespace_item->namespaceMap().values(); - for (const NamespaceModelItem &ni : inner_namespaces) { - AbstractMetaClass *mjc = traverseNamespace(ni); - addAbstractMetaClass(mjc); - } + // Go through all typedefs to see if we have defined any + // specific typedefs to be used as classes. + TypeAliasList typeAliases = namespace_item->typeAliases(); + for (TypeAliasModelItem typeAlias : typeAliases) { + AbstractMetaClass* cls = traverseTypeAlias(typeAlias); + addAbstractMetaClass(cls); + } - m_current_class = 0; + // Traverse namespaces recursively + QList inner_namespaces = namespace_item->namespaceMap().values(); + for (const NamespaceModelItem& ni : inner_namespaces) { + AbstractMetaClass* mjc = traverseNamespace(ni); + addAbstractMetaClass(mjc); + } + m_current_class = 0; - popScope(); - m_namespace_prefix = currentScope()->qualifiedName().join("::"); + popScope(); + m_namespace_prefix = currentScope()->qualifiedName().join("::"); - if (!type->include().isValid()) { - type->setInclude(getRelativeInclude(namespace_item->fileName())); - } - // namespace items might come from different include files: - for (const QString& oneIncludeFile : includeFiles) { - type->addExtraInclude(getRelativeInclude(oneIncludeFile)); - } + if (!type->include().isValid()) { + type->setInclude(getRelativeInclude(namespace_item->fileName())); + } + // namespace items might come from different include files: + for (const QString& oneIncludeFile : includeFiles) { + type->addExtraInclude(getRelativeInclude(oneIncludeFile)); + } - return meta_class; + return meta_class; } - -AbstractMetaEnum *AbstractMetaBuilder::traverseEnum(EnumModelItem enum_item, AbstractMetaClass *enclosing, const QSet &enumsDeclarations) +AbstractMetaEnum* AbstractMetaBuilder::traverseEnum(EnumModelItem enum_item, AbstractMetaClass* enclosing, + const QSet& enumsDeclarations) { - // Skipping private enums. - if (enum_item->accessPolicy() == CodeModel::Private) { - return 0; - } + // Skipping private enums. + if (enum_item->accessPolicy() == CodeModel::Private) { + return 0; + } - QString qualified_name = enum_item->qualifiedName().join("::"); + QString qualified_name = enum_item->qualifiedName().join("::"); - TypeEntry *type_entry = TypeDatabase::instance()->findType(qualified_name); - QString enum_name = enum_item->name(); + TypeEntry* type_entry = TypeDatabase::instance()->findType(qualified_name); + QString enum_name = enum_item->name(); - QString class_name; - if (m_current_class) - class_name = m_current_class->typeEntry()->qualifiedCppName(); + QString class_name; + if (m_current_class) + class_name = m_current_class->typeEntry()->qualifiedCppName(); - if (TypeDatabase::instance()->isEnumRejected(class_name, enum_name)) { - m_rejected_enums.insert(qualified_name, GenerationDisabled); - return 0; - } + if (TypeDatabase::instance()->isEnumRejected(class_name, enum_name)) { + m_rejected_enums.insert(qualified_name, GenerationDisabled); + return 0; + } - if (!type_entry || !type_entry->isEnum()) { - QString context = m_current_class ? m_current_class->name() : QLatin1String(""); - ReportHandler::warning(QString("enum '%1' does not have a type entry or is not an enum") - .arg(qualified_name)); - m_rejected_enums.insert(qualified_name, NotInTypeSystem); - return 0; - } + if (!type_entry || !type_entry->isEnum()) { + QString context = m_current_class ? m_current_class->name() : QLatin1String(""); + ReportHandler::warning(QString("enum '%1' does not have a type entry or is not an enum").arg(qualified_name)); + m_rejected_enums.insert(qualified_name, NotInTypeSystem); + return 0; + } - static_cast(type_entry)->setEnumClass(enum_item->isEnumClass()); + static_cast(type_entry)->setEnumClass(enum_item->isEnumClass()); - AbstractMetaEnum *meta_enum = createMetaEnum(); - if ( enumsDeclarations.contains(qualified_name) - || enumsDeclarations.contains(enum_name)) { - meta_enum->setHasQEnumsDeclaration(true); - } + AbstractMetaEnum* meta_enum = createMetaEnum(); + if (enumsDeclarations.contains(qualified_name) || enumsDeclarations.contains(enum_name)) { + meta_enum->setHasQEnumsDeclaration(true); + } - meta_enum->setTypeEntry((EnumTypeEntry *) type_entry); - switch (enum_item->accessPolicy()) { - case CodeModel::Public: *meta_enum += AbstractMetaAttributes::Public; break; - case CodeModel::Protected: *meta_enum += AbstractMetaAttributes::Protected; break; -// case CodeModel::Private: *meta_enum += AbstractMetaAttributes::Private; break; - default: break; - } + meta_enum->setTypeEntry((EnumTypeEntry*)type_entry); + switch (enum_item->accessPolicy()) { + case CodeModel::Public: + *meta_enum += AbstractMetaAttributes::Public; + break; + case CodeModel::Protected: + *meta_enum += AbstractMetaAttributes::Protected; + break; + // case CodeModel::Private: *meta_enum += AbstractMetaAttributes::Private; break; + default: + break; + } - ReportHandler::debugMedium(QString(" - traversing enum %1").arg(meta_enum->fullName())); + ReportHandler::debugMedium(QString(" - traversing enum %1").arg(meta_enum->fullName())); - for (const EnumeratorModelItem& value : enum_item->enumerators()) { - if (meta_enum->typeEntry()->isEnumValueRejected(value->name())) { - continue; - } - AbstractMetaEnumValue *meta_enum_value = createMetaEnumValue(); - meta_enum_value->setName(value->name()); - // Deciding the enum value... + for (const EnumeratorModelItem& value : enum_item->enumerators()) { + if (meta_enum->typeEntry()->isEnumValueRejected(value->name())) { + continue; + } + AbstractMetaEnumValue* meta_enum_value = createMetaEnumValue(); + meta_enum_value->setName(value->name()); + // Deciding the enum value... - meta_enum_value->setStringValue(value->value()); - meta_enum->addEnumValue(meta_enum_value); + meta_enum_value->setStringValue(value->value()); + meta_enum->addEnumValue(meta_enum_value); - ReportHandler::debugFull(" - " + meta_enum_value->name() + " = " - + QString::number(meta_enum_value->value())); + ReportHandler::debugFull(" - " + meta_enum_value->name() + " = " + QString::number(meta_enum_value->value())); - // Add into global register... - if (enclosing) - m_enum_values[enclosing->name() + "::" + meta_enum_value->name()] = meta_enum_value; - else - m_enum_values[meta_enum_value->name()] = meta_enum_value; - } + // Add into global register... + if (enclosing) + m_enum_values[enclosing->name() + "::" + meta_enum_value->name()] = meta_enum_value; + else + m_enum_values[meta_enum_value->name()] = meta_enum_value; + } - meta_enum->typeEntry()->setInclude(getRelativeInclude(enum_item->fileName())); + meta_enum->typeEntry()->setInclude(getRelativeInclude(enum_item->fileName())); - m_enums << meta_enum; + m_enums << meta_enum; - return meta_enum; + return meta_enum; } -AbstractMetaClass *AbstractMetaBuilder::traverseTypeAlias(TypeAliasModelItem typeAlias) +AbstractMetaClass* AbstractMetaBuilder::traverseTypeAlias(TypeAliasModelItem typeAlias) { - QString class_name = strip_template_args(typeAlias->name()); + QString class_name = strip_template_args(typeAlias->name()); - QString full_class_name = class_name; - // we have an inner class - if (m_current_class) { - full_class_name = strip_template_args(m_current_class->typeEntry()->qualifiedCppName()) - + "::" + full_class_name; - } + QString full_class_name = class_name; + // we have an inner class + if (m_current_class) { + full_class_name = strip_template_args(m_current_class->typeEntry()->qualifiedCppName()) + "::" + full_class_name; + } - // If we haven't specified anything for the typedef, then we don't care - ComplexTypeEntry *type = TypeDatabase::instance()->findComplexType(full_class_name); - if (type == 0) - return 0; + // If we haven't specified anything for the typedef, then we don't care + ComplexTypeEntry* type = TypeDatabase::instance()->findComplexType(full_class_name); + if (type == 0) + return 0; - if (type->isObject()) - static_cast(type)->setQObject(isQObject(strip_template_args(typeAlias->type().qualifiedName().join("::")))); + if (type->isObject()) + static_cast(type)->setQObject( + isQObject(strip_template_args(typeAlias->type().qualifiedName().join("::")))); - AbstractMetaClass *meta_class = createMetaClass(); - meta_class->setTypeAlias(true); - meta_class->setTypeEntry(type); - meta_class->setBaseClassNames(QStringList() << typeAlias->type().qualifiedName().join("::")); - *meta_class += AbstractMetaAttributes::Public; + AbstractMetaClass* meta_class = createMetaClass(); + meta_class->setTypeAlias(true); + meta_class->setTypeEntry(type); + meta_class->setBaseClassNames(QStringList() << typeAlias->type().qualifiedName().join("::")); + *meta_class += AbstractMetaAttributes::Public; - // Set the default include file name - if (!type->include().isValid()) { - type->setInclude(getRelativeInclude(typeAlias->fileName())); - } + // Set the default include file name + if (!type->include().isValid()) { + type->setInclude(getRelativeInclude(typeAlias->fileName())); + } - return meta_class; + return meta_class; } -AbstractMetaClass *AbstractMetaBuilder::traverseClass(ClassModelItem class_item) +AbstractMetaClass* AbstractMetaBuilder::traverseClass(ClassModelItem class_item) { - QString class_name = strip_template_args(class_item->name()); - QString full_class_name = class_name; - - // we have inner an class - if (m_current_class) { - full_class_name = strip_template_args(m_current_class->typeEntry()->qualifiedCppName()) - + "::" + full_class_name; - } - - ComplexTypeEntry *type = TypeDatabase::instance()->findComplexType(full_class_name); - RejectReason reason = NoReason; - - if (full_class_name == "QMetaTypeId") { - // QtScript: record which types have been declared - int lpos = class_item->name().indexOf('<'); - int rpos = class_item->name().lastIndexOf('>'); - if ((lpos != -1) && (rpos != -1)) { - QString declared_typename = class_item->name().mid(lpos+1, rpos - lpos-1); - m_qmetatype_declared_typenames.insert(declared_typename); - } - } + QString class_name = strip_template_args(class_item->name()); + QString full_class_name = class_name; - if (TypeDatabase::instance()->isClassRejected(full_class_name)) { - reason = GenerationDisabled; - } else if (!type) { - TypeEntry *te = TypeDatabase::instance()->findType(full_class_name); - if (te && !te->isComplex()) - reason = RedefinedToNotClass; - else - reason = NotInTypeSystem; - } else if (type->codeGeneration() == TypeEntry::GenerateNothing) { - reason = GenerationDisabled; - } + // we have inner an class + if (m_current_class) { + full_class_name = strip_template_args(m_current_class->typeEntry()->qualifiedCppName()) + "::" + full_class_name; + } - if (reason != NoReason) { - m_rejected_classes.insert(full_class_name, reason); - return 0; - } + ComplexTypeEntry* type = TypeDatabase::instance()->findComplexType(full_class_name); + RejectReason reason = NoReason; - if (type->isObject()) { - ((ObjectTypeEntry *)type)->setQObject(isQObject(full_class_name)); + if (full_class_name == "QMetaTypeId") { + // QtScript: record which types have been declared + int lpos = class_item->name().indexOf('<'); + int rpos = class_item->name().lastIndexOf('>'); + if ((lpos != -1) && (rpos != -1)) { + QString declared_typename = class_item->name().mid(lpos + 1, rpos - lpos - 1); + m_qmetatype_declared_typenames.insert(declared_typename); } + } - AbstractMetaClass *meta_class = createMetaClass(); - meta_class->setTypeEntry(type); - meta_class->setBaseClassNames(class_item->baseClasses()); - *meta_class += AbstractMetaAttributes::Public; - - AbstractMetaClass *old_current_class = m_current_class; - m_current_class = meta_class; + if (TypeDatabase::instance()->isClassRejected(full_class_name)) { + reason = GenerationDisabled; + } else if (!type) { + TypeEntry* te = TypeDatabase::instance()->findType(full_class_name); + if (te && !te->isComplex()) + reason = RedefinedToNotClass; + else + reason = NotInTypeSystem; + } else if (type->codeGeneration() == TypeEntry::GenerateNothing) { + reason = GenerationDisabled; + } - if (type->isContainer()) { - ReportHandler::debugSparse(QString("container: '%1'").arg(full_class_name)); - } else { - ReportHandler::debugSparse(QString("class: '%1'").arg(meta_class->fullName())); - } + if (reason != NoReason) { + m_rejected_classes.insert(full_class_name, reason); + return 0; + } - TemplateParameterList template_parameters = class_item->templateParameters(); - QList template_args; - template_args.clear(); - for (int i=0; iname()); - param_type->setOrdinal(i); - template_args.append(param_type); - } - meta_class->setTemplateArguments(template_args); - meta_class->setHasActualDeclaration(class_item->hasActualDeclaration()); + if (type->isObject()) { + ((ObjectTypeEntry*)type)->setQObject(isQObject(full_class_name)); + } - traverseFunctions(class_item.dynamicCast<_ScopeModelItem>(), meta_class); - traverseEnums(class_item.dynamicCast<_ScopeModelItem>(), meta_class, class_item->qEnumDeclarations()); - traverseFields(class_item.dynamicCast<_ScopeModelItem>(), meta_class); + AbstractMetaClass* meta_class = createMetaClass(); + meta_class->setTypeEntry(type); + meta_class->setBaseClassNames(class_item->baseClasses()); + *meta_class += AbstractMetaAttributes::Public; - parseQ_Property(meta_class, class_item->propertyDeclarations()); + AbstractMetaClass* old_current_class = m_current_class; + m_current_class = meta_class; - // Inner classes - { - QList inner_classes = class_item->classMap().values(); - for (const ClassModelItem &ci : inner_classes) { - AbstractMetaClass *cl = traverseClass(ci); - if (cl) { - cl->setEnclosingClass(meta_class); - m_meta_classes << cl; - } - } + if (type->isContainer()) { + ReportHandler::debugSparse(QString("container: '%1'").arg(full_class_name)); + } else { + ReportHandler::debugSparse(QString("class: '%1'").arg(meta_class->fullName())); + } + TemplateParameterList template_parameters = class_item->templateParameters(); + QList template_args; + template_args.clear(); + for (int i = 0; i < template_parameters.size(); ++i) { + const TemplateParameterModelItem& param = template_parameters.at(i); + TemplateArgumentEntry* param_type = new TemplateArgumentEntry(param->name()); + param_type->setOrdinal(i); + template_args.append(param_type); + } + meta_class->setTemplateArguments(template_args); + meta_class->setHasActualDeclaration(class_item->hasActualDeclaration()); + + traverseFunctions(class_item.dynamicCast<_ScopeModelItem>(), meta_class); + traverseEnums(class_item.dynamicCast<_ScopeModelItem>(), meta_class, class_item->qEnumDeclarations()); + traverseFields(class_item.dynamicCast<_ScopeModelItem>(), meta_class); + + parseQ_Property(meta_class, class_item->propertyDeclarations()); + + // Inner classes + { + QList inner_classes = class_item->classMap().values(); + for (const ClassModelItem& ci : inner_classes) { + AbstractMetaClass* cl = traverseClass(ci); + if (cl) { + cl->setEnclosingClass(meta_class); + m_meta_classes << cl; + } } + } - // Go through all typedefs to see if we have defined any - // specific typedefs to be used as classes. - TypeAliasList typeAliases = class_item->typeAliases(); - for (TypeAliasModelItem typeAlias : typeAliases) { - AbstractMetaClass *cls = traverseTypeAlias(typeAlias); - if (cls != 0) { - cls->setEnclosingClass(meta_class); - addAbstractMetaClass(cls); - } + // Go through all typedefs to see if we have defined any + // specific typedefs to be used as classes. + TypeAliasList typeAliases = class_item->typeAliases(); + for (TypeAliasModelItem typeAlias : typeAliases) { + AbstractMetaClass* cls = traverseTypeAlias(typeAlias); + if (cls != 0) { + cls->setEnclosingClass(meta_class); + addAbstractMetaClass(cls); } + } + m_current_class = old_current_class; - m_current_class = old_current_class; - - // Set the default include file name. In case we saw an template instance earlier, - // overwrite the include file when we see the actual declaration. - if (!type->include().isValid() || class_item->hasActualDeclaration()) { - type->setInclude(getRelativeInclude(class_item->fileName())); - } + // Set the default include file name. In case we saw an template instance earlier, + // overwrite the include file when we see the actual declaration. + if (!type->include().isValid() || class_item->hasActualDeclaration()) { + type->setInclude(getRelativeInclude(class_item->fileName())); + } - return meta_class; + return meta_class; } -AbstractMetaField *AbstractMetaBuilder::traverseField(VariableModelItem field, const AbstractMetaClass *cls) +AbstractMetaField* AbstractMetaBuilder::traverseField(VariableModelItem field, const AbstractMetaClass* cls) { - QString field_name = field->name(); - QString class_name = m_current_class->typeEntry()->qualifiedCppName(); - - // Ignore friend decl. - if (field->isFriend()) - return 0; - - if (field->accessPolicy() == CodeModel::Private) - return 0; - - if (TypeDatabase::instance()->isFieldRejected(class_name, field_name)) { - m_rejected_fields.insert(class_name + "::" + field_name, GenerationDisabled); - return 0; - } + QString field_name = field->name(); + QString class_name = m_current_class->typeEntry()->qualifiedCppName(); + // Ignore friend decl. + if (field->isFriend()) + return 0; - AbstractMetaField *meta_field = createMetaField(); - meta_field->setName(field_name); - meta_field->setEnclosingClass(cls); + if (field->accessPolicy() == CodeModel::Private) + return 0; - bool ok; - TypeInfo field_type = field->type(); - AbstractMetaType::shared_pointer meta_type = translateType(field_type, &ok); + if (TypeDatabase::instance()->isFieldRejected(class_name, field_name)) { + m_rejected_fields.insert(class_name + "::" + field_name, GenerationDisabled); + return 0; + } - if (!meta_type || !ok) { - ReportHandler::warning(QString("skipping field '%1::%2' with unmatched type '%3'") - .arg(m_current_class->name()) - .arg(field_name) - .arg(TypeInfo::resolveType(field_type, currentScope()).qualifiedName().join("::"))); - delete meta_field; - return 0; - } + AbstractMetaField* meta_field = createMetaField(); + meta_field->setName(field_name); + meta_field->setEnclosingClass(cls); + + bool ok; + TypeInfo field_type = field->type(); + AbstractMetaType::shared_pointer meta_type = translateType(field_type, &ok); + + if (!meta_type || !ok) { + ReportHandler::warning(QString("skipping field '%1::%2' with unmatched type '%3'") + .arg(m_current_class->name()) + .arg(field_name) + .arg(TypeInfo::resolveType(field_type, currentScope()).qualifiedName().join("::"))); + delete meta_field; + return 0; + } - meta_field->setType(meta_type); + meta_field->setType(meta_type); - uint attr = 0; - if (field->isStatic()) - attr |= AbstractMetaAttributes::Static; + uint attr = 0; + if (field->isStatic()) + attr |= AbstractMetaAttributes::Static; - CodeModel::AccessPolicy policy = field->accessPolicy(); - if (policy == CodeModel::Public) - attr |= AbstractMetaAttributes::Public; - else if (policy == CodeModel::Protected) - attr |= AbstractMetaAttributes::Protected; - else - attr |= AbstractMetaAttributes::Private; - meta_field->setAttributes(attr); + CodeModel::AccessPolicy policy = field->accessPolicy(); + if (policy == CodeModel::Public) + attr |= AbstractMetaAttributes::Public; + else if (policy == CodeModel::Protected) + attr |= AbstractMetaAttributes::Protected; + else + attr |= AbstractMetaAttributes::Private; + meta_field->setAttributes(attr); - return meta_field; + return meta_field; } -void AbstractMetaBuilder::traverseFields(ScopeModelItem scope_item, AbstractMetaClass *meta_class) +void AbstractMetaBuilder::traverseFields(ScopeModelItem scope_item, AbstractMetaClass* meta_class) { - for (const VariableModelItem& field : scope_item->variables()) { - AbstractMetaField *meta_field = traverseField(field, meta_class); + for (const VariableModelItem& field : scope_item->variables()) { + AbstractMetaField* meta_field = traverseField(field, meta_class); - if (meta_field) { - meta_field->setOriginalAttributes(meta_field->attributes()); - meta_class->addField(meta_field); - } + if (meta_field) { + meta_field->setOriginalAttributes(meta_field->attributes()); + meta_class->addField(meta_field); } + } } -void AbstractMetaBuilder::setupFunctionDefaults(AbstractMetaFunction *meta_function, AbstractMetaClass *meta_class) +void AbstractMetaBuilder::setupFunctionDefaults(AbstractMetaFunction* meta_function, AbstractMetaClass* meta_class) { - // Set the default value of the declaring class. This may be changed - // in fixFunctions later on - meta_function->setDeclaringClass(meta_class); + // Set the default value of the declaring class. This may be changed + // in fixFunctions later on + meta_function->setDeclaringClass(meta_class); - // Some of the queries below depend on the implementing class being set - // to function properly. Such as function modifications - meta_function->setImplementingClass(meta_class); + // Some of the queries below depend on the implementing class being set + // to function properly. Such as function modifications + meta_function->setImplementingClass(meta_class); - if (meta_function->name() == "operator_equal") - meta_class->setHasEqualsOperator(true); + if (meta_function->name() == "operator_equal") + meta_class->setHasEqualsOperator(true); - if (!meta_function->isFinalInTargetLang() - && meta_function->isRemovedFrom(meta_class, TypeSystem::TargetLangCode)) { - *meta_function += AbstractMetaAttributes::FinalInCpp; - } + if (!meta_function->isFinalInTargetLang() && meta_function->isRemovedFrom(meta_class, TypeSystem::TargetLangCode)) { + *meta_function += AbstractMetaAttributes::FinalInCpp; + } } -void AbstractMetaBuilder::traverseFunctions(ScopeModelItem scope_item, AbstractMetaClass *meta_class) +void AbstractMetaBuilder::traverseFunctions(ScopeModelItem scope_item, AbstractMetaClass* meta_class) { - for (const FunctionModelItem& function : scope_item->functions()) { - AbstractMetaFunction *meta_function = traverseFunction(function); - - if (meta_function) { - meta_function->setOriginalAttributes(meta_function->attributes()); - if (meta_class->isNamespace()) - *meta_function += AbstractMetaAttributes::Static; - - if (QPropertySpec *read = meta_class->propertySpecForRead(meta_function->name())) { - if (read->type() == meta_function->type()->typeEntry()) { - *meta_function += AbstractMetaAttributes::PropertyReader; - meta_function->setPropertySpec(read); -// printf("%s is reader for %s\n", -// qPrintable(meta_function->name()), -// qPrintable(read->name())); - } - } else if (QPropertySpec *write = - meta_class->propertySpecForWrite(meta_function->name())) { - if (meta_function->arguments().size() == 1 && write->type() == meta_function->arguments().at(0)->type()->typeEntry()) { - *meta_function += AbstractMetaAttributes::PropertyWriter; - meta_function->setPropertySpec(write); -// printf("%s is writer for %s\n", -// qPrintable(meta_function->name()), -// qPrintable(write->name())); - } - } else if (QPropertySpec *reset = - meta_class->propertySpecForReset(meta_function->name())) { - *meta_function += AbstractMetaAttributes::PropertyResetter; - meta_function->setPropertySpec(reset); -// printf("%s is resetter for %s\n", -// qPrintable(meta_function->name()), -// qPrintable(reset->name())); - } + for (const FunctionModelItem& function : scope_item->functions()) { + AbstractMetaFunction* meta_function = traverseFunction(function); + if (meta_function) { + meta_function->setOriginalAttributes(meta_function->attributes()); + if (meta_class->isNamespace()) + *meta_function += AbstractMetaAttributes::Static; - bool isInvalidDestructor = meta_function->isDestructor() && meta_function->isPrivate(); - bool isInvalidConstructor = meta_function->isConstructor() - && (meta_function->isPrivate() || meta_function->isInvalid()); - if (isInvalidConstructor && meta_function->arguments().size() == 1 && - meta_class->qualifiedCppName() == meta_function->arguments().at(0)->type()->typeEntry()->qualifiedCppName()) - { - // deleted or private copy constructor, it seems copying is not allowed - meta_class->typeEntry()->setNoCopy(true); - } - if ((isInvalidDestructor || isInvalidConstructor) - && !meta_class->hasNonPrivateConstructor()) - { - *meta_class += AbstractMetaAttributes::Final; - } else if (meta_function->isConstructor() && !meta_function->isPrivate()) { - *meta_class -= AbstractMetaAttributes::Final; - meta_class->setHasNonPrivateConstructor(true); - } + if (QPropertySpec* read = meta_class->propertySpecForRead(meta_function->name())) { + if (read->type() == meta_function->type()->typeEntry()) { + *meta_function += AbstractMetaAttributes::PropertyReader; + meta_function->setPropertySpec(read); + // printf("%s is reader for %s\n", + // qPrintable(meta_function->name()), + // qPrintable(read->name())); + } + } else if (QPropertySpec* write = meta_class->propertySpecForWrite(meta_function->name())) { + if (meta_function->arguments().size() == 1 + && write->type() == meta_function->arguments().at(0)->type()->typeEntry()) + { + *meta_function += AbstractMetaAttributes::PropertyWriter; + meta_function->setPropertySpec(write); + // printf("%s is writer for %s\n", + // qPrintable(meta_function->name()), + // qPrintable(write->name())); + } + } else if (QPropertySpec* reset = meta_class->propertySpecForReset(meta_function->name())) { + *meta_function += AbstractMetaAttributes::PropertyResetter; + meta_function->setPropertySpec(reset); + // printf("%s is resetter for %s\n", + // qPrintable(meta_function->name()), + // qPrintable(reset->name())); + } - // Classes with virtual destructors should always have a shell class - // (since we aren't registering the destructors, we need this extra check) - if (meta_function->isDestructor() && !meta_function->isFinal()) - meta_class->setForceShellClass(true); + bool isInvalidDestructor = meta_function->isDestructor() && meta_function->isPrivate(); + bool isInvalidConstructor = + meta_function->isConstructor() && (meta_function->isPrivate() || meta_function->isInvalid()); + if (isInvalidConstructor && meta_function->arguments().size() == 1 + && meta_class->qualifiedCppName() + == meta_function->arguments().at(0)->type()->typeEntry()->qualifiedCppName()) + { + // deleted or private copy constructor, it seems copying is not allowed + meta_class->typeEntry()->setNoCopy(true); + } + if ((isInvalidDestructor || isInvalidConstructor) && !meta_class->hasNonPrivateConstructor()) { + *meta_class += AbstractMetaAttributes::Final; + } else if (meta_function->isConstructor() && !meta_function->isPrivate()) { + *meta_class -= AbstractMetaAttributes::Final; + meta_class->setHasNonPrivateConstructor(true); + } - if (meta_function->name().startsWith("__") && meta_function->isStatic()) { - // static operators are not supported by PythonQt - // (this only seems to happen for static operators in namespaces) - delete meta_function; - } - else if (!meta_function->isDestructor() - && !meta_function->isInvalid() - && (!meta_function->isConstructor() || !meta_function->isPrivate())) - { - if (meta_class->typeEntry()->designatedInterface() && !meta_function->isPublic() - && !meta_function->isPrivate()) { - QString warn = QString("non-public function '%1' in interface '%2'") - .arg(meta_function->name()).arg(meta_class->name()); - ReportHandler::warning(warn); - - meta_function->setVisibility(AbstractMetaClass::Public); - } + // Classes with virtual destructors should always have a shell class + // (since we aren't registering the destructors, we need this extra check) + if (meta_function->isDestructor() && !meta_function->isFinal()) + meta_class->setForceShellClass(true); - setupFunctionDefaults(meta_function, meta_class); + if (meta_function->name().startsWith("__") && meta_function->isStatic()) { + // static operators are not supported by PythonQt + // (this only seems to happen for static operators in namespaces) + delete meta_function; + } else if (!meta_function->isDestructor() && !meta_function->isInvalid() + && (!meta_function->isConstructor() || !meta_function->isPrivate())) + { + if (meta_class->typeEntry()->designatedInterface() && !meta_function->isPublic() && !meta_function->isPrivate()) + { + QString warn = + QString("non-public function '%1' in interface '%2'").arg(meta_function->name()).arg(meta_class->name()); + ReportHandler::warning(warn); - if (meta_function->isSignal() && meta_class->hasSignal(meta_function)) { -// QString warn = QString("signal '%1' in class '%2' is overloaded.") -// .arg(meta_function->name()).arg(meta_class->name()); -// ReportHandler::warning(warn); - } + meta_function->setVisibility(AbstractMetaClass::Public); + } - if (meta_function->isSignal() && !meta_class->isQObject()) { - QString warn = QString("signal '%1' in non-QObject class '%2'") - .arg(meta_function->name()).arg(meta_class->name()); - ReportHandler::warning(warn); - } + setupFunctionDefaults(meta_function, meta_class); - meta_class->addFunction(meta_function, /*check_duplicates=*/true); - } else if (meta_function->isDestructor()) { - meta_class->setDestructorException(meta_function->exception()); - if (!meta_function->isPublic()) { - meta_class->setHasPublicDestructor(false); - } - meta_class->setHasVirtualDestructor(meta_function->isVirtual()); - delete meta_function; - } else { - delete meta_function; - } + if (meta_function->isSignal() && meta_class->hasSignal(meta_function)) { + // QString warn = QString("signal '%1' in class '%2' is overloaded.") + // .arg(meta_function->name()).arg(meta_class->name()); + // ReportHandler::warning(warn); + } + + if (meta_function->isSignal() && !meta_class->isQObject()) { + QString warn = + QString("signal '%1' in non-QObject class '%2'").arg(meta_function->name()).arg(meta_class->name()); + ReportHandler::warning(warn); + } + + meta_class->addFunction(meta_function, /*check_duplicates=*/true); + } else if (meta_function->isDestructor()) { + meta_class->setDestructorException(meta_function->exception()); + if (!meta_function->isPublic()) { + meta_class->setHasPublicDestructor(false); } + meta_class->setHasVirtualDestructor(meta_function->isVirtual()); + delete meta_function; + } else { + delete meta_function; + } } - removeEquivalentFunctions(meta_class); + } + removeEquivalentFunctions(meta_class); } void AbstractMetaBuilder::removeEquivalentFunctions(AbstractMetaClass* parent) { - AbstractMetaFunctionList functions = parent->functions(); - for (AbstractMetaFunction* fun : functions) - { - AbstractMetaArgumentList args = fun->arguments(); - bool candidateToRemove = false; - for (AbstractMetaArgument* arg : args) { - const TypeEntry* argType = arg->type()->typeEntry(); - if (argType && argType->equivalentType()) { - candidateToRemove = true; - break; - } - } - if (!candidateToRemove) { - continue; - } - // check if there are other functions with the same name and equivalent parameters - AbstractMetaFunctionList overloadedFunctions = parent->queryFunctionsByName(fun->name()); - for (AbstractMetaFunction* overload : overloadedFunctions) { - if (overload != fun) { - AbstractMetaArgumentList overloadArgs = overload->arguments(); - if (overloadArgs.size() == args.size()) { - bool equivalentArgs = true; - for (int i = 0; i < args.size() && equivalentArgs; i++) { - const TypeEntry* argType = args[i]->type()->typeEntry(); - const TypeEntry* overloadArgType = overloadArgs[i]->type()->typeEntry(); - // This could have some more equivalency checks, but currently this seems to be sufficient - equivalentArgs = (argType && overloadArgType && - (argType == overloadArgType || argType->equivalentType() == overloadArgType)); - } - if (equivalentArgs) { - parent->removeFunction(fun); - break; - } - } - } + AbstractMetaFunctionList functions = parent->functions(); + for (AbstractMetaFunction* fun : functions) { + AbstractMetaArgumentList args = fun->arguments(); + bool candidateToRemove = false; + for (AbstractMetaArgument* arg : args) { + const TypeEntry* argType = arg->type()->typeEntry(); + if (argType && argType->equivalentType()) { + candidateToRemove = true; + break; + } + } + if (!candidateToRemove) { + continue; + } + // check if there are other functions with the same name and equivalent parameters + AbstractMetaFunctionList overloadedFunctions = parent->queryFunctionsByName(fun->name()); + for (AbstractMetaFunction* overload : overloadedFunctions) { + if (overload != fun) { + AbstractMetaArgumentList overloadArgs = overload->arguments(); + if (overloadArgs.size() == args.size()) { + bool equivalentArgs = true; + for (int i = 0; i < args.size() && equivalentArgs; i++) { + const TypeEntry* argType = args[i]->type()->typeEntry(); + const TypeEntry* overloadArgType = overloadArgs[i]->type()->typeEntry(); + // This could have some more equivalency checks, but currently this seems to be sufficient + equivalentArgs = (argType && overloadArgType + && (argType == overloadArgType || argType->equivalentType() == overloadArgType)); + } + if (equivalentArgs) { + parent->removeFunction(fun); + break; + } } + } } + } } -bool AbstractMetaBuilder::setupInheritance(AbstractMetaClass *meta_class) +bool AbstractMetaBuilder::setupInheritance(AbstractMetaClass* meta_class) { - Q_ASSERT(!meta_class->isInterface()); + Q_ASSERT(!meta_class->isInterface()); - if (m_setup_inheritance_done.contains(meta_class)) - return true; - m_setup_inheritance_done.insert(meta_class); + if (m_setup_inheritance_done.contains(meta_class)) + return true; + m_setup_inheritance_done.insert(meta_class); - QStringList base_classes = meta_class->baseClassNames(); + QStringList base_classes = meta_class->baseClassNames(); - TypeDatabase *types = TypeDatabase::instance(); + TypeDatabase* types = TypeDatabase::instance(); - // we only support our own containers and ONLY if there is only one baseclass - if (base_classes.size() == 1 && base_classes.first().count('<') == 1) { - QStringList scope = meta_class->typeEntry()->qualifiedCppName().split("::"); - scope.removeLast(); - for (int i=scope.size(); i>=0; --i) { - QString prefix = i > 0 ? QStringList(scope.mid(0, i)).join("::") + "::" : QString(); - QString complete_name = prefix + base_classes.first(); - TypeParser::Info info = TypeParser::parse(complete_name); - QString base_name = info.qualified_name.join("::"); + // we only support our own containers and ONLY if there is only one baseclass + if (base_classes.size() == 1 && base_classes.first().count('<') == 1) { + QStringList scope = meta_class->typeEntry()->qualifiedCppName().split("::"); + scope.removeLast(); + for (int i = scope.size(); i >= 0; --i) { + QString prefix = i > 0 ? QStringList(scope.mid(0, i)).join("::") + "::" : QString(); + QString complete_name = prefix + base_classes.first(); + TypeParser::Info info = TypeParser::parse(complete_name); + QString base_name = info.qualified_name.join("::"); - AbstractMetaClass *templ = m_templates.value(base_name); + AbstractMetaClass* templ = m_templates.value(base_name); - if (templ == 0) - templ = m_meta_classes.findClass(base_name); + if (templ == 0) + templ = m_meta_classes.findClass(base_name); - if (templ) { - setupInheritance(templ); - inheritTemplate(meta_class, templ, info); - return true; - } - } - - ReportHandler::warning(QString("template baseclass '%1' of '%2' is not known") - .arg(base_classes.first()) - .arg(meta_class->name())); - return false; + if (templ) { + setupInheritance(templ); + inheritTemplate(meta_class, templ, info); + return true; + } } - int primary = -1; - int primaries = 0; - for (int i=0; iname())); + return false; + } - if (types->isClassRejected(base_classes.at(i))) - continue; + int primary = -1; + int primaries = 0; + for (int i = 0; i < base_classes.size(); ++i) { - TypeEntry *base_class_entry = types->findType(base_classes.at(i)); - if (!base_class_entry) { - ReportHandler::warning(QString("class '%1' inherits from unknown base class '%2'") - .arg(meta_class->name()).arg(base_classes.at(i))); - } + if (types->isClassRejected(base_classes.at(i))) + continue; - // true for primary base class - else if (!base_class_entry->designatedInterface()) { - if (primaries > 0) { - ReportHandler::warning(QString("class '%1' has multiple primary base classes" - " '%2' and '%3'") - .arg(meta_class->name()) - .arg(base_classes.at(primary)) - .arg(base_class_entry->name())); - return false; - } - primaries++; - primary = i; - } + TypeEntry* base_class_entry = types->findType(base_classes.at(i)); + if (!base_class_entry) { + ReportHandler::warning( + QString("class '%1' inherits from unknown base class '%2'").arg(meta_class->name()).arg(base_classes.at(i))); } - if (primary >= 0) { - AbstractMetaClass *base_class = m_meta_classes.findClass(base_classes.at(primary)); - if (!base_class) { - ReportHandler::warning(QString("unknown baseclass for '%1': '%2'") - .arg(meta_class->name()) - .arg(base_classes.at(primary))); - return false; - } - meta_class->setBaseClass(base_class); - - if (meta_class->typeEntry()->designatedInterface() != 0 && meta_class->isQObject()) { - ReportHandler::warning(QString("QObject extended by interface type '%1'. This is not supported and the generated Java code will not compile.") - .arg(meta_class->name())); - } else if (meta_class->typeEntry()->designatedInterface() != 0 && base_class != 0 && !base_class->isInterface()) { - ReportHandler::warning(QString("object type '%1' extended by interface type '%2'. The resulting API will be less expressive than the original.") - .arg(base_class->name()) - .arg(meta_class->name())); - } + // true for primary base class + else if (!base_class_entry->designatedInterface()) + { + if (primaries > 0) { + ReportHandler::warning(QString("class '%1' has multiple primary base classes" + " '%2' and '%3'") + .arg(meta_class->name()) + .arg(base_classes.at(primary)) + .arg(base_class_entry->name())); + return false; + } + primaries++; + primary = i; + } + } + if (primary >= 0) { + AbstractMetaClass* base_class = m_meta_classes.findClass(base_classes.at(primary)); + if (!base_class) { + ReportHandler::warning( + QString("unknown baseclass for '%1': '%2'").arg(meta_class->name()).arg(base_classes.at(primary))); + return false; + } + meta_class->setBaseClass(base_class); + + if (meta_class->typeEntry()->designatedInterface() != 0 && meta_class->isQObject()) { + ReportHandler::warning(QString( + "QObject extended by interface type '%1'. This is not supported and the generated Java code will not compile.") + .arg(meta_class->name())); + } else if (meta_class->typeEntry()->designatedInterface() != 0 && base_class != 0 && !base_class->isInterface()) { + ReportHandler::warning(QString("object type '%1' extended by interface type '%2'. The resulting API will be less " + "expressive than the original.") + .arg(base_class->name()) + .arg(meta_class->name())); } + } - for (int i=0; iisClassRejected(base_classes.at(i))) - continue; + for (int i = 0; i < base_classes.size(); ++i) { + if (types->isClassRejected(base_classes.at(i))) + continue; - AbstractMetaClass *base_class = m_meta_classes.findClass(base_classes.at(i)); - if (base_class) { - meta_class->addSuperClass(base_class); - } - if (i != primary) { - if (base_class == 0) { - ReportHandler::warning(QString("class not found for setup inheritance '%1'").arg(base_classes.at(i))); - return false; - } + AbstractMetaClass* base_class = m_meta_classes.findClass(base_classes.at(i)); + if (base_class) { + meta_class->addSuperClass(base_class); + } + if (i != primary) { + if (base_class == 0) { + ReportHandler::warning(QString("class not found for setup inheritance '%1'").arg(base_classes.at(i))); + return false; + } - setupInheritance(base_class); + setupInheritance(base_class); - QString interface_name = InterfaceTypeEntry::interfaceName(base_class->name()); - AbstractMetaClass *iface = m_meta_classes.findClass(interface_name); - if (!iface) { - ReportHandler::warning(QString("unknown interface for '%1': '%2'") - .arg(meta_class->name()) - .arg(interface_name)); - return false; - } - meta_class->addInterface(iface); + QString interface_name = InterfaceTypeEntry::interfaceName(base_class->name()); + AbstractMetaClass* iface = m_meta_classes.findClass(interface_name); + if (!iface) { + ReportHandler::warning(QString("unknown interface for '%1': '%2'").arg(meta_class->name()).arg(interface_name)); + return false; + } + meta_class->addInterface(iface); - AbstractMetaClassList interfaces = iface->interfaces(); - for (AbstractMetaClass *iface : interfaces) - meta_class->addInterface(iface); - } + AbstractMetaClassList interfaces = iface->interfaces(); + for (AbstractMetaClass* iface : interfaces) + meta_class->addInterface(iface); } + } - return true; + return true; } -void AbstractMetaBuilder::traverseEnums(ScopeModelItem scope_item, AbstractMetaClass *meta_class, const QSet &qEnumDeclarations) +void AbstractMetaBuilder::traverseEnums(ScopeModelItem scope_item, AbstractMetaClass* meta_class, + const QSet& qEnumDeclarations) { - EnumList enums = scope_item->enums(); - for (EnumModelItem enum_item : enums) { - AbstractMetaEnum* meta_enum = traverseEnum(enum_item, meta_class, qEnumDeclarations); - if (meta_enum) { - meta_enum->setOriginalAttributes(meta_enum->attributes()); - meta_class->addEnum(meta_enum); - meta_enum->setEnclosingClass(meta_class); - } + EnumList enums = scope_item->enums(); + for (EnumModelItem enum_item : enums) { + AbstractMetaEnum* meta_enum = traverseEnum(enum_item, meta_class, qEnumDeclarations); + if (meta_enum) { + meta_enum->setOriginalAttributes(meta_enum->attributes()); + meta_class->addEnum(meta_enum); + meta_enum->setEnclosingClass(meta_class); } + } } -AbstractMetaFunction *AbstractMetaBuilder::traverseFunction(FunctionModelItem function_item) +AbstractMetaFunction* AbstractMetaBuilder::traverseFunction(FunctionModelItem function_item) { - QString function_name = function_item->name(); - QString class_name = m_current_class->typeEntry()->qualifiedCppName(); - - if (TypeDatabase::instance()->isFunctionRejected(class_name, function_name)) { - m_rejected_functions.insert(class_name + "::" + function_name, GenerationDisabled); - return 0; - } + QString function_name = function_item->name(); + QString class_name = m_current_class->typeEntry()->qualifiedCppName(); + if (TypeDatabase::instance()->isFunctionRejected(class_name, function_name)) { + m_rejected_functions.insert(class_name + "::" + function_name, GenerationDisabled); + return 0; + } - Q_ASSERT(function_item->functionType() == CodeModel::Normal - || function_item->functionType() == CodeModel::Signal - || function_item->functionType() == CodeModel::Slot); + Q_ASSERT(function_item->functionType() == CodeModel::Normal || function_item->functionType() == CodeModel::Signal + || function_item->functionType() == CodeModel::Slot); - if (function_item->isFriend()) - return 0; + if (function_item->isFriend()) + return 0; - // Filter out variadic functions (having ... arguments) - they are not currently handled - if (function_item->isVariadics()) { - return 0; - } + // Filter out variadic functions (having ... arguments) - they are not currently handled + if (function_item->isVariadics()) { + return 0; + } - // Also filter out functions with template parameters in classes without template arguments - // (we don't support templated classes directly, but derived classes might derive from template instantiations) - if (function_item->templateParameters().size() && m_current_class->templateArguments().empty()) { - return 0; - } + // Also filter out functions with template parameters in classes without template arguments + // (we don't support templated classes directly, but derived classes might derive from template instantiations) + if (function_item->templateParameters().size() && m_current_class->templateArguments().empty()) { + return 0; + } - if (function_item->isAuto()) { - /*TODO: it might work just to output 'auto', but this would require + if (function_item->isAuto()) { + /*TODO: it might work just to output 'auto', but this would require * understanding what AbstractMetabuild::translateType() does and * changing it. auto is only used once anyway. */ - ReportHandler::warning(QString("%1: skipping auto function type '%2'") - .arg(function_name) - .arg(function_item->type().toString())); - m_rejected_functions[class_name + "::" + function_name + " " + function_item->type().toString()] = - UnmatchedReturnType; - return 0; - } + ReportHandler::warning( + QString("%1: skipping auto function type '%2'").arg(function_name).arg(function_item->type().toString())); + m_rejected_functions[class_name + "::" + function_name + " " + function_item->type().toString()] = + UnmatchedReturnType; + return 0; + } - QString cast_type; + QString cast_type; - if (function_name.startsWith("operator")) { - function_name = rename_operator(function_name.mid(8)); - if (function_name.isEmpty()) { - m_rejected_functions.insert(class_name + "::" + function_name, - GenerationDisabled); - return 0; - } - if (function_name.contains("_cast_")) - cast_type = function_name.mid(14).trimmed(); + if (function_name.startsWith("operator")) { + function_name = rename_operator(function_name.mid(8)); + if (function_name.isEmpty()) { + m_rejected_functions.insert(class_name + "::" + function_name, GenerationDisabled); + return 0; } + if (function_name.contains("_cast_")) + cast_type = function_name.mid(14).trimmed(); + } - AbstractMetaFunction *meta_function = createMetaFunction(); - meta_function->setConstant(function_item->isConstant()); - meta_function->setConstexpr(function_item->isConstexpr()); - meta_function->setAuto(function_item->isAuto()); - meta_function->setException(function_item->exception()); - - ReportHandler::debugMedium(QString(" - %2()").arg(function_name)); - - meta_function->setName(function_name); - meta_function->setOriginalName(function_item->name()); + AbstractMetaFunction* meta_function = createMetaFunction(); + meta_function->setConstant(function_item->isConstant()); + meta_function->setConstexpr(function_item->isConstexpr()); + meta_function->setAuto(function_item->isAuto()); + meta_function->setException(function_item->exception()); - if (function_item->isAbstract()) - *meta_function += AbstractMetaAttributes::Abstract; + ReportHandler::debugMedium(QString(" - %2()").arg(function_name)); - if (!meta_function->isAbstract()) - *meta_function += AbstractMetaAttributes::Native; + meta_function->setName(function_name); + meta_function->setOriginalName(function_item->name()); - if (!function_item->isVirtual()) - *meta_function += AbstractMetaAttributes::Final; + if (function_item->isAbstract()) + *meta_function += AbstractMetaAttributes::Abstract; - if (function_item->isInvokable()) - *meta_function += AbstractMetaAttributes::Invokable; + if (!meta_function->isAbstract()) + *meta_function += AbstractMetaAttributes::Native; - if (function_item->isStatic()) { - *meta_function += AbstractMetaAttributes::Static; - *meta_function += AbstractMetaAttributes::Final; - } + if (!function_item->isVirtual()) + *meta_function += AbstractMetaAttributes::Final; - // Access rights - if (function_item->accessPolicy() == CodeModel::Public) - *meta_function += AbstractMetaAttributes::Public; - else if (function_item->accessPolicy() == CodeModel::Private) - *meta_function += AbstractMetaAttributes::Private; - else - *meta_function += AbstractMetaAttributes::Protected; + if (function_item->isInvokable()) + *meta_function += AbstractMetaAttributes::Invokable; + if (function_item->isStatic()) { + *meta_function += AbstractMetaAttributes::Static; + *meta_function += AbstractMetaAttributes::Final; + } - QString stripped_class_name = class_name; - int cc_pos = stripped_class_name.lastIndexOf("::"); - if (cc_pos > 0) - stripped_class_name = stripped_class_name.mid(cc_pos + 2); + // Access rights + if (function_item->accessPolicy() == CodeModel::Public) + *meta_function += AbstractMetaAttributes::Public; + else if (function_item->accessPolicy() == CodeModel::Private) + *meta_function += AbstractMetaAttributes::Private; + else + *meta_function += AbstractMetaAttributes::Protected; + + QString stripped_class_name = class_name; + int cc_pos = stripped_class_name.lastIndexOf("::"); + if (cc_pos > 0) + stripped_class_name = stripped_class_name.mid(cc_pos + 2); + + TypeInfo function_type = function_item->type(); + if (function_name.startsWith('~')) { + meta_function->setFunctionType(AbstractMetaFunction::DestructorFunction); + meta_function->setInvalid(true); + } else if (strip_template_args(function_name) == stripped_class_name) { + meta_function->setFunctionType(AbstractMetaFunction::ConstructorFunction); + meta_function->setName(m_current_class->name()); + } else { + bool ok; + AbstractMetaType::shared_pointer type = 0; - TypeInfo function_type = function_item->type(); - if (function_name.startsWith('~')) { - meta_function->setFunctionType(AbstractMetaFunction::DestructorFunction); - meta_function->setInvalid(true); - } else if (strip_template_args(function_name) == stripped_class_name) { - meta_function->setFunctionType(AbstractMetaFunction::ConstructorFunction); - meta_function->setName(m_current_class->name()); + if (!cast_type.isEmpty()) { + TypeInfo info; + info.setQualifiedName(QStringList(cast_type)); + type = translateType(info, &ok); } else { - bool ok; - AbstractMetaType::shared_pointer type = 0; - - if (!cast_type.isEmpty()) { - TypeInfo info; - info.setQualifiedName(QStringList(cast_type)); - type = translateType(info, &ok); - } else { - type = translateType(function_type, &ok); - } - - if (!ok) { - ReportHandler::warning(QString("skipping function '%1::%2', unmatched return type '%3'") - .arg(class_name) - .arg(function_item->name()) - .arg(function_item->type().toString())); - if (!function_item->type().toString().contains("Private")) { - m_rejected_functions[class_name + "::" + function_name + " " + function_item->type().toString()] = - UnmatchedReturnType; - } - meta_function->setInvalid(true); - return meta_function; - } - meta_function->setType(type); - - if (function_item->functionType() == CodeModel::Signal) - meta_function->setFunctionType(AbstractMetaFunction::SignalFunction); - else if (function_item->functionType() == CodeModel::Slot) - meta_function->setFunctionType(AbstractMetaFunction::SlotFunction); - } - - ArgumentList arguments = function_item->arguments(); - AbstractMetaArgumentList meta_arguments; - - int first_default_argument = 0; - for (int i=0; itype(), &ok); - if (!meta_type || !ok) { - ReportHandler::warning(QString("skipping function '%1::%2', " - "unmatched parameter type '%3'") - .arg(class_name) - .arg(function_item->name()) - .arg(arg->type().toString())); - if (!arg->type().toString().contains("Private")) { - m_rejected_functions[class_name + "::" + function_name + " " + arg->type().toString()] = - UnmatchedArgumentType; - } - meta_function->setInvalid(true); - qDeleteAll(meta_arguments); - return meta_function; - } - AbstractMetaArgument *meta_argument = createMetaArgument(); - meta_argument->setType(meta_type); - meta_argument->setName(arg->name()); - meta_argument->setArgumentIndex(i); - meta_arguments << meta_argument; - } - - meta_function->setArguments(meta_arguments); - - // Find the correct default values - for (int i=0; idefaultValue()) { - QString expr = arg->defaultValueExpression(); - if (!expr.isEmpty()) - meta_arg->setOriginalDefaultValueExpression(expr); - - expr = translateDefaultValue(arg, meta_arg->type(), meta_function, m_current_class, i); - if (expr.isEmpty()) { - first_default_argument = i; - } else { - meta_arg->setDefaultValueExpression(expr); - } - - if (meta_arg->type()->isEnum() || meta_arg->type()->isFlags()) { - m_enum_default_arguments - << QPair(meta_arg, meta_function); - } - - } + type = translateType(function_type, &ok); } - // If we were not able to translate the default argument make it - // reset all default arguments before this one too. - for (int i=0; isetDefaultValueExpression(QString()); + if (!ok) { + ReportHandler::warning(QString("skipping function '%1::%2', unmatched return type '%3'") + .arg(class_name) + .arg(function_item->name()) + .arg(function_item->type().toString())); + if (!function_item->type().toString().contains("Private")) { + m_rejected_functions[class_name + "::" + function_name + " " + function_item->type().toString()] = + UnmatchedReturnType; + } + meta_function->setInvalid(true); + return meta_function; } + meta_function->setType(type); - if (ReportHandler::debugLevel() == ReportHandler::FullDebug) { - for (AbstractMetaArgument *arg : meta_arguments) { - ReportHandler::debugFull(" - " + arg->toString()); - } - } + if (function_item->functionType() == CodeModel::Signal) + meta_function->setFunctionType(AbstractMetaFunction::SignalFunction); + else if (function_item->functionType() == CodeModel::Slot) + meta_function->setFunctionType(AbstractMetaFunction::SlotFunction); + } + + ArgumentList arguments = function_item->arguments(); + AbstractMetaArgumentList meta_arguments; - if (function_item->isDeleted()) { + int first_default_argument = 0; + for (int i = 0; i < arguments.size(); ++i) { + ArgumentModelItem arg = arguments.at(i); + + bool ok; + AbstractMetaType::shared_pointer meta_type = translateType(arg->type(), &ok); + if (!meta_type || !ok) { + ReportHandler::warning(QString("skipping function '%1::%2', " + "unmatched parameter type '%3'") + .arg(class_name) + .arg(function_item->name()) + .arg(arg->type().toString())); + if (!arg->type().toString().contains("Private")) { + m_rejected_functions[class_name + "::" + function_name + " " + arg->type().toString()] = UnmatchedArgumentType; + } meta_function->setInvalid(true); + qDeleteAll(meta_arguments); return meta_function; } + AbstractMetaArgument* meta_argument = createMetaArgument(); + meta_argument->setType(meta_type); + meta_argument->setName(arg->name()); + meta_argument->setArgumentIndex(i); + meta_arguments << meta_argument; + } - return meta_function; -} - + meta_function->setArguments(meta_arguments); + + // Find the correct default values + for (int i = 0; i < arguments.size(); ++i) { + ArgumentModelItem arg = arguments.at(i); + AbstractMetaArgument* meta_arg = meta_arguments.at(i); + if (arg->defaultValue()) { + QString expr = arg->defaultValueExpression(); + if (!expr.isEmpty()) + meta_arg->setOriginalDefaultValueExpression(expr); + + expr = translateDefaultValue(arg, meta_arg->type(), meta_function, m_current_class, i); + if (expr.isEmpty()) { + first_default_argument = i; + } else { + meta_arg->setDefaultValueExpression(expr); + } -AbstractMetaType::shared_pointer AbstractMetaBuilder::translateType(const TypeInfo &_typei, bool *ok, bool resolveType, bool resolveScope) -{ - Q_ASSERT(ok); - *ok = true; + if (meta_arg->type()->isEnum() || meta_arg->type()->isFlags()) { + m_enum_default_arguments << QPair(meta_arg, meta_function); + } + } + } - // 1. Test the type info without resolving typedefs in case this is present in the - // type system - TypeInfo typei; - if (resolveType) { - bool isok; - AbstractMetaType::shared_pointer t = translateType(_typei, &isok, false, resolveScope); - if (t != 0 && isok) - return t; - } - - if (!resolveType) - typei = _typei; - else { - // Go through all parts of the current scope (including global namespace) - // to resolve typedefs. The parser does not properly resolve typedefs in - // the global scope when they are referenced from inside a namespace. - // This is a work around to fix this bug since fixing it in resolveType - // seemed non-trivial - int i = m_scopes.size() - 1; - while (i >= 0) { - typei = TypeInfo::resolveType(_typei, m_scopes.at(i--)); - if (typei.qualifiedName().join("::") != _typei.qualifiedName().join("::")) - break; - } + // If we were not able to translate the default argument make it + // reset all default arguments before this one too. + for (int i = 0; i < first_default_argument; ++i) { + meta_arguments[i]->setDefaultValueExpression(QString()); + } + if (ReportHandler::debugLevel() == ReportHandler::FullDebug) { + for (AbstractMetaArgument* arg : meta_arguments) { + ReportHandler::debugFull(" - " + arg->toString()); } + } - if (typei.isFunctionPointer() || typei.isRvalueReference()) { // function pointers or r-value references are not supported - *ok = false; - return 0; - } + if (function_item->isDeleted()) { + meta_function->setInvalid(true); + return meta_function; + } - TypeParser::Info typeInfo = TypeParser::parse(typei.toString(/*parsable=*/true)); - if (typeInfo.is_busted) { - *ok = false; - return 0; - } + return meta_function; +} - // 2. Handle pointers specified as arrays with unspecified size - bool array_of_unspecified_size = false; - if (typeInfo.arrays.size() > 0) { - array_of_unspecified_size = true; - for (int i=0; i=0; --i) { - QString s = typeInfo.arrays.at(i); - bool isok; - - int elems = s.toInt(&isok); - if (!isok) - return 0; - - AbstractMetaType::shared_pointer arrayType = createMetaType(); - arrayType->setArrayElementCount(elems); - arrayType->setArrayElementType(elementType); - arrayType->setTypeEntry(new ArrayTypeEntry(elementType->typeEntry())); - decideUsagePattern(arrayType); - - elementType = arrayType; - } +AbstractMetaType::shared_pointer AbstractMetaBuilder::translateType(const TypeInfo& _typei, bool* ok, bool resolveType, + bool resolveScope) +{ + Q_ASSERT(ok); + *ok = true; + + // 1. Test the type info without resolving typedefs in case this is present in the + // type system + TypeInfo typei; + if (resolveType) { + bool isok; + AbstractMetaType::shared_pointer t = translateType(_typei, &isok, false, resolveScope); + if (t != 0 && isok) + return t; + } - return elementType; - } else { - typeInfo.indirections += typeInfo.arrays.size(); - } + if (!resolveType) + typei = _typei; + else { + // Go through all parts of the current scope (including global namespace) + // to resolve typedefs. The parser does not properly resolve typedefs in + // the global scope when they are referenced from inside a namespace. + // This is a work around to fix this bug since fixing it in resolveType + // seemed non-trivial + int i = m_scopes.size() - 1; + while (i >= 0) { + typei = TypeInfo::resolveType(_typei, m_scopes.at(i--)); + if (typei.qualifiedName().join("::") != _typei.qualifiedName().join("::")) + break; } + } - QStringList qualifier_list = typeInfo.qualified_name; - if (qualifier_list.isEmpty()) { - ReportHandler::warning(QString("horribly broken type '%1'").arg(_typei.toString())); - *ok = false; - return 0; - } + if (typei.isFunctionPointer() + || typei.isRvalueReference()) { // function pointers or r-value references are not supported + *ok = false; + return 0; + } - QString qualified_name = qualifier_list.join("::"); - QString name = qualifier_list.takeLast(); + TypeParser::Info typeInfo = TypeParser::parse(typei.toString(/*parsable=*/true)); + if (typeInfo.is_busted) { + *ok = false; + return 0; + } - // 3. Special case 'void' type - if (name == "void" && typeInfo.indirections == 0) { + // 2. Handle pointers specified as arrays with unspecified size + bool array_of_unspecified_size = false; + if (typeInfo.arrays.size() > 0) { + array_of_unspecified_size = true; + for (int i = 0; i < typeInfo.arrays.size(); ++i) + array_of_unspecified_size = array_of_unspecified_size && typeInfo.arrays.at(i).isEmpty(); + + if (!array_of_unspecified_size) { + TypeInfo newInfo; + //newInfo.setArguments(typei.arguments()); + newInfo.setIndirections(typei.indirections()); + newInfo.setConstant(typei.isConstant()); + newInfo.setFunctionPointer(typei.isFunctionPointer()); + newInfo.setQualifiedName(typei.qualifiedName()); + newInfo.setReference(typei.isReference()); + newInfo.setVolatile(typei.isVolatile()); + newInfo.setMutable(typei.isMutable()); + + AbstractMetaType::shared_pointer elementType = translateType(newInfo, ok); + if (!(*ok)) return 0; - } - // 4. Special case QFlags (include instantiation in name) - if (qualified_name == "QFlags") - qualified_name = typeInfo.toString(); + for (int i = typeInfo.arrays.size() - 1; i >= 0; --i) { + QString s = typeInfo.arrays.at(i); + bool isok; - // 5. Try to find the type - const TypeEntry *type = TypeDatabase::instance()->findType(qualified_name); + int elems = s.toInt(&isok); + if (!isok) + return 0; - // 6. No? Try looking it up as a flags type - if (!type) - type = TypeDatabase::instance()->findFlagsType(qualified_name); + AbstractMetaType::shared_pointer arrayType = createMetaType(); + arrayType->setArrayElementCount(elems); + arrayType->setArrayElementType(elementType); + arrayType->setTypeEntry(new ArrayTypeEntry(elementType->typeEntry())); + decideUsagePattern(arrayType); - // 7. No? Try looking it up as a container type - if (!type) - type = TypeDatabase::instance()->findContainerType(name); + elementType = arrayType; + } - // 8. No? Check if the current class is a template and this type is one - // of the parameters. - if (type == 0 && m_current_class != 0) { - QList template_args = m_current_class->templateArguments(); - for (TypeEntry *te : template_args) { - if (te->name() == qualified_name) - type = te; - } + return elementType; + } else { + typeInfo.indirections += typeInfo.arrays.size(); } + } + + QStringList qualifier_list = typeInfo.qualified_name; + if (qualifier_list.isEmpty()) { + ReportHandler::warning(QString("horribly broken type '%1'").arg(_typei.toString())); + *ok = false; + return 0; + } - // 9. Try finding the type by prefixing it with the current - // context and all baseclasses of the current context - if (!type && !TypeDatabase::instance()->isClassRejected(qualified_name) && m_current_class != 0 && resolveScope) { - QStringList contexts; - contexts.append(m_current_class->qualifiedCppName()); - contexts.append(currentScope()->qualifiedName().join("::")); + QString qualified_name = qualifier_list.join("::"); + QString name = qualifier_list.takeLast(); + // 3. Special case 'void' type + if (name == "void" && typeInfo.indirections == 0) { + return 0; + } - TypeInfo info = typei; - bool subclasses_done = false; - while (!contexts.isEmpty() && type == 0) { - //type = TypeDatabase::instance()->findType(contexts.at(0) + "::" + qualified_name); + // 4. Special case QFlags (include instantiation in name) + if (qualified_name == "QFlags") + qualified_name = typeInfo.toString(); - bool isok; - info.setQualifiedName(QStringList() << contexts.at(0) << qualified_name); - AbstractMetaType::shared_pointer t = translateType(info, &isok, true, false); - if (t != 0 && isok) - return t; + // 5. Try to find the type + const TypeEntry* type = TypeDatabase::instance()->findType(qualified_name); - ClassModelItem item = m_dom->findClass(contexts.at(0)); - if (item) - contexts += item->baseClasses(); - contexts.pop_front(); + // 6. No? Try looking it up as a flags type + if (!type) + type = TypeDatabase::instance()->findFlagsType(qualified_name); - // 10. Last resort: Special cased prefix of Qt namespace since the meta object implicitly inherits this, so - // enum types from there may be addressed without any scope resolution in properties. - if (contexts.size() == 0 && !subclasses_done) { - contexts << "Qt"; - subclasses_done = true; - } - } + // 7. No? Try looking it up as a container type + if (!type) + type = TypeDatabase::instance()->findContainerType(name); + // 8. No? Check if the current class is a template and this type is one + // of the parameters. + if (type == 0 && m_current_class != 0) { + QList template_args = m_current_class->templateArguments(); + for (TypeEntry* te : template_args) { + if (te->name() == qualified_name) + type = te; } + } - if (!type) { - *ok = false; - return 0; + // 9. Try finding the type by prefixing it with the current + // context and all baseclasses of the current context + if (!type && !TypeDatabase::instance()->isClassRejected(qualified_name) && m_current_class != 0 && resolveScope) { + QStringList contexts; + contexts.append(m_current_class->qualifiedCppName()); + contexts.append(currentScope()->qualifiedName().join("::")); + + TypeInfo info = typei; + bool subclasses_done = false; + while (!contexts.isEmpty() && type == 0) { + //type = TypeDatabase::instance()->findType(contexts.at(0) + "::" + qualified_name); + + bool isok; + info.setQualifiedName(QStringList() << contexts.at(0) << qualified_name); + AbstractMetaType::shared_pointer t = translateType(info, &isok, true, false); + if (t != 0 && isok) + return t; + + ClassModelItem item = m_dom->findClass(contexts.at(0)); + if (item) + contexts += item->baseClasses(); + contexts.pop_front(); + + // 10. Last resort: Special cased prefix of Qt namespace since the meta object implicitly inherits this, so + // enum types from there may be addressed without any scope resolution in properties. + if (contexts.size() == 0 && !subclasses_done) { + contexts << "Qt"; + subclasses_done = true; + } } + } - // Used to for diagnostics later... - m_used_types << type; + if (!type) { + *ok = false; + return 0; + } - // These are only implicit and should not appear in code... - Q_ASSERT(!type->isInterface()); + // Used to for diagnostics later... + m_used_types << type; - AbstractMetaType::shared_pointer meta_type = createMetaType(); - meta_type->setTypeEntry(type); - meta_type->setIndirections(typeInfo.indirections); - meta_type->setReference(typeInfo.is_reference); - meta_type->setConstant(typeInfo.is_constant); - meta_type->setOriginalTypeDescription(_typei.toString()); - decideUsagePattern(meta_type); + // These are only implicit and should not appear in code... + Q_ASSERT(!type->isInterface()); - if (meta_type->typeEntry()->isContainer()) { - ContainerTypeEntry::Type container_type = static_cast(type)->type(); + AbstractMetaType::shared_pointer meta_type = createMetaType(); + meta_type->setTypeEntry(type); + meta_type->setIndirections(typeInfo.indirections); + meta_type->setReference(typeInfo.is_reference); + meta_type->setConstant(typeInfo.is_constant); + meta_type->setOriginalTypeDescription(_typei.toString()); + decideUsagePattern(meta_type); - if (container_type == ContainerTypeEntry::StringListContainer) { - TypeInfo info; - info.setQualifiedName(QStringList() << "QString"); - AbstractMetaType::shared_pointer targ_type(translateType(info, ok)); + if (meta_type->typeEntry()->isContainer()) { + ContainerTypeEntry::Type container_type = static_cast(type)->type(); - Q_ASSERT(*ok); - Q_ASSERT(targ_type); + if (container_type == ContainerTypeEntry::StringListContainer) { + TypeInfo info; + info.setQualifiedName(QStringList() << "QString"); + AbstractMetaType::shared_pointer targ_type(translateType(info, ok)); - meta_type->addInstantiation(targ_type); - meta_type->setInstantiationInCpp(false); + Q_ASSERT(*ok); + Q_ASSERT(targ_type); - } else { - for (const TypeParser::Info &ta : typeInfo.template_instantiations) { - TypeInfo info; - info.setConstant(ta.is_constant); - info.setReference(ta.is_reference); - info.setIndirections(ta.indirections); + meta_type->addInstantiation(targ_type); + meta_type->setInstantiationInCpp(false); - info.setFunctionPointer(false); - info.setQualifiedName(ta.instantiationName().split("::")); + } else { + for (const TypeParser::Info& ta : typeInfo.template_instantiations) { + TypeInfo info; + info.setConstant(ta.is_constant); + info.setReference(ta.is_reference); + info.setIndirections(ta.indirections); - AbstractMetaType::shared_pointer targ_type (translateType(info, ok)); - if (!(*ok)) { - return 0; - } + info.setFunctionPointer(false); + info.setQualifiedName(ta.instantiationName().split("::")); - meta_type->addInstantiation(targ_type); - } + AbstractMetaType::shared_pointer targ_type(translateType(info, ok)); + if (!(*ok)) { + return 0; } - if (container_type == ContainerTypeEntry::ListContainer - || container_type == ContainerTypeEntry::VectorContainer - || container_type == ContainerTypeEntry::StringListContainer) { - //Q_ASSERT(meta_type->instantiations().size() == 1); - } + meta_type->addInstantiation(targ_type); + } } - return meta_type; + if (container_type == ContainerTypeEntry::ListContainer || container_type == ContainerTypeEntry::VectorContainer + || container_type == ContainerTypeEntry::StringListContainer) + { + //Q_ASSERT(meta_type->instantiations().size() == 1); + } + } + + return meta_type; } void AbstractMetaBuilder::decideUsagePattern(AbstractMetaType::shared_pointer meta_type) { - const TypeEntry *type = meta_type->typeEntry(); - - if (type->isPrimitive() && (meta_type->actualIndirections() == 0 - || (meta_type->isConstant() && meta_type->isReference() && meta_type->indirections() == 0))) { - meta_type->setTypeUsagePattern(AbstractMetaType::PrimitivePattern); - - } else if (type->isVoid()) { - meta_type->setTypeUsagePattern(AbstractMetaType::NativePointerPattern); - - } else if (type->isString() - && meta_type->indirections() == 0 - && (meta_type->isConstant() == meta_type->isReference() - || meta_type->isConstant())) { - meta_type->setTypeUsagePattern(AbstractMetaType::StringPattern); - - } else if (type->isChar() - && meta_type->indirections() == 0 - && meta_type->isConstant() == meta_type->isReference()) { - meta_type->setTypeUsagePattern(AbstractMetaType::CharPattern); - - } else if (type->isJObjectWrapper() - && meta_type->indirections() == 0 - && meta_type->isConstant() == meta_type->isReference()) { - meta_type->setTypeUsagePattern(AbstractMetaType::JObjectWrapperPattern); - - } else if (type->isVariant() - && meta_type->indirections() == 0 - && meta_type->isConstant() == meta_type->isReference()) { - meta_type->setTypeUsagePattern(AbstractMetaType::VariantPattern); - - } else if (type->isEnum() && meta_type->actualIndirections() == 0) { - meta_type->setTypeUsagePattern(AbstractMetaType::EnumPattern); - - } else if (type->isObject() - && meta_type->indirections() == 0 - && meta_type->isReference()) { - if (((ComplexTypeEntry *) type)->isQObject()) - meta_type->setTypeUsagePattern(AbstractMetaType::QObjectPattern); - else - meta_type->setTypeUsagePattern(AbstractMetaType::ObjectPattern); + const TypeEntry* type = meta_type->typeEntry(); - } else if (type->isObject() - && meta_type->indirections() == 1) { - if (((ComplexTypeEntry *) type)->isQObject()) - meta_type->setTypeUsagePattern(AbstractMetaType::QObjectPattern); - else - meta_type->setTypeUsagePattern(AbstractMetaType::ObjectPattern); + if (type->isPrimitive() + && (meta_type->actualIndirections() == 0 + || (meta_type->isConstant() && meta_type->isReference() && meta_type->indirections() == 0))) + { + meta_type->setTypeUsagePattern(AbstractMetaType::PrimitivePattern); - // const-references to pointers can be passed as pointers - if (meta_type->isReference() && meta_type->isConstant()) { - meta_type->setReference(false); - meta_type->setConstant(false); - } + } else if (type->isVoid()) { + meta_type->setTypeUsagePattern(AbstractMetaType::NativePointerPattern); - } else if (type->isContainer() && meta_type->indirections() == 0) { - meta_type->setTypeUsagePattern(AbstractMetaType::ContainerPattern); + } else if (type->isString() && meta_type->indirections() == 0 + && (meta_type->isConstant() == meta_type->isReference() || meta_type->isConstant())) + { + meta_type->setTypeUsagePattern(AbstractMetaType::StringPattern); - } else if (type->isTemplateArgument()) { + } else if (type->isChar() && meta_type->indirections() == 0 && meta_type->isConstant() == meta_type->isReference()) { + meta_type->setTypeUsagePattern(AbstractMetaType::CharPattern); - } else if (type->isFlags() - && meta_type->indirections() == 0 - && (meta_type->isConstant() == meta_type->isReference())) { - meta_type->setTypeUsagePattern(AbstractMetaType::FlagsPattern); + } else if (type->isJObjectWrapper() && meta_type->indirections() == 0 + && meta_type->isConstant() == meta_type->isReference()) + { + meta_type->setTypeUsagePattern(AbstractMetaType::JObjectWrapperPattern); - } else if (type->isArray()) { - meta_type->setTypeUsagePattern(AbstractMetaType::ArrayPattern); + } else if (type->isVariant() && meta_type->indirections() == 0 && meta_type->isConstant() == meta_type->isReference()) + { + meta_type->setTypeUsagePattern(AbstractMetaType::VariantPattern); - } else if (type->isThread()) { - Q_ASSERT(meta_type->indirections() == 1); - meta_type->setTypeUsagePattern(AbstractMetaType::ThreadPattern); + } else if (type->isEnum() && meta_type->actualIndirections() == 0) { + meta_type->setTypeUsagePattern(AbstractMetaType::EnumPattern); - } else if (type->isValue() - && meta_type->indirections() == 0 - && (meta_type->isConstant() == meta_type->isReference() - || !meta_type->isReference())) { - meta_type->setTypeUsagePattern(AbstractMetaType::ValuePattern); + } else if (type->isObject() && meta_type->indirections() == 0 && meta_type->isReference()) { + if (((ComplexTypeEntry*)type)->isQObject()) + meta_type->setTypeUsagePattern(AbstractMetaType::QObjectPattern); + else + meta_type->setTypeUsagePattern(AbstractMetaType::ObjectPattern); - } else { - meta_type->setTypeUsagePattern(AbstractMetaType::NativePointerPattern); - ReportHandler::debugFull(QString("native pointer pattern for '%1'") - .arg(meta_type->cppSignature())); + } else if (type->isObject() && meta_type->indirections() == 1) { + if (((ComplexTypeEntry*)type)->isQObject()) + meta_type->setTypeUsagePattern(AbstractMetaType::QObjectPattern); + else + meta_type->setTypeUsagePattern(AbstractMetaType::ObjectPattern); + + // const-references to pointers can be passed as pointers + if (meta_type->isReference() && meta_type->isConstant()) { + meta_type->setReference(false); + meta_type->setConstant(false); } + + } else if (type->isContainer() && meta_type->indirections() == 0) { + meta_type->setTypeUsagePattern(AbstractMetaType::ContainerPattern); + + } else if (type->isTemplateArgument()) { + + } else if (type->isFlags() && meta_type->indirections() == 0 && (meta_type->isConstant() == meta_type->isReference())) + { + meta_type->setTypeUsagePattern(AbstractMetaType::FlagsPattern); + + } else if (type->isArray()) { + meta_type->setTypeUsagePattern(AbstractMetaType::ArrayPattern); + + } else if (type->isThread()) { + Q_ASSERT(meta_type->indirections() == 1); + meta_type->setTypeUsagePattern(AbstractMetaType::ThreadPattern); + + } else if (type->isValue() && meta_type->indirections() == 0 + && (meta_type->isConstant() == meta_type->isReference() || !meta_type->isReference())) + { + meta_type->setTypeUsagePattern(AbstractMetaType::ValuePattern); + + } else { + meta_type->setTypeUsagePattern(AbstractMetaType::NativePointerPattern); + ReportHandler::debugFull(QString("native pointer pattern for '%1'").arg(meta_type->cppSignature())); + } } QString AbstractMetaBuilder::translateDefaultValue(ArgumentModelItem item, AbstractMetaType::shared_pointer type, - AbstractMetaFunction *fnc, AbstractMetaClass *implementing_class, - int argument_index) + AbstractMetaFunction* fnc, AbstractMetaClass* implementing_class, int argument_index) { - Q_UNUSED(type) - QString function_name = fnc->name(); - QString class_name = implementing_class->name(); + Q_UNUSED(type) + QString function_name = fnc->name(); + QString class_name = implementing_class->name(); - QString replaced_expression = fnc->replacedDefaultExpression(implementing_class, argument_index + 1); - if (fnc->removedDefaultExpression(implementing_class, argument_index +1)) - return ""; - if (!replaced_expression.isEmpty()) - return replaced_expression; + QString replaced_expression = fnc->replacedDefaultExpression(implementing_class, argument_index + 1); + if (fnc->removedDefaultExpression(implementing_class, argument_index + 1)) + return ""; + if (!replaced_expression.isEmpty()) + return replaced_expression; - return item->defaultValueExpression(); + return item->defaultValueExpression(); } - -bool AbstractMetaBuilder::isQObject(const QString &qualified_name) +bool AbstractMetaBuilder::isQObject(const QString& qualified_name) { - if (qualified_name == "QObject") - return true; + if (qualified_name == "QObject") + return true; - ClassModelItem class_item = m_dom->findClass(qualified_name); + ClassModelItem class_item = m_dom->findClass(qualified_name); - if (!class_item) { - QStringList names = qualified_name.split(QLatin1String("::")); - NamespaceModelItem ns = m_dom.dynamicCast<_NamespaceModelItem>(); - for (int i=0; inamespaceMap().value(names.at(i)); - if (ns && names.size() >= 2) - class_item = ns->findClass(names.at(names.size() - 1)); - } + if (!class_item) { + QStringList names = qualified_name.split(QLatin1String("::")); + NamespaceModelItem ns = m_dom.dynamicCast<_NamespaceModelItem>(); + for (int i = 0; i < names.size() - 1 && ns; ++i) + ns = ns->namespaceMap().value(names.at(i)); + if (ns && names.size() >= 2) + class_item = ns->findClass(names.at(names.size() - 1)); + } - bool isqobject = class_item && class_item->extendsClass("QObject"); + bool isqobject = class_item && class_item->extendsClass("QObject"); - if (class_item && !isqobject) { - QStringList baseClasses = class_item->baseClasses(); - for (int i=0; ibaseClasses(); + for (int i = 0; i < baseClasses.count(); ++i) { - isqobject = isQObject(baseClasses.at(i)); - if (isqobject) - break; - } + isqobject = isQObject(baseClasses.at(i)); + if (isqobject) + break; } + } - return isqobject; + return isqobject; } - -bool AbstractMetaBuilder::isEnum(const QStringList &qualified_name) +bool AbstractMetaBuilder::isEnum(const QStringList& qualified_name) { - CodeModelItem item = m_dom->model()->findItem(qualified_name, m_dom); - return item && item->kind() == _EnumModelItem::__node_kind; + CodeModelItem item = m_dom->model()->findItem(qualified_name, m_dom); + return item && item->kind() == _EnumModelItem::__node_kind; } AbstractMetaType::shared_pointer AbstractMetaBuilder::inheritTemplateType( - const QList &template_types, - AbstractMetaType::shared_pointer meta_type, bool *ok) + const QList& template_types, AbstractMetaType::shared_pointer meta_type, bool* ok) { - if (ok != 0) - *ok = true; - if (!meta_type || (!meta_type->typeEntry()->isTemplateArgument() && !meta_type->hasInstantiations())) - return meta_type ? meta_type->copy() : 0; - - AbstractMetaType::shared_pointer returned = meta_type->copy(); - returned->setOriginalTemplateType(meta_type); - - if (returned->typeEntry()->isTemplateArgument()) { - const TemplateArgumentEntry *tae = static_cast(returned->typeEntry()); - - // If the template is intantiated with void we special case this as rejecting the functions that use this - // parameter from the instantiation. - if (template_types.size() <= tae->ordinal() || template_types.at(tae->ordinal())->typeEntry()->name() == "void") { - if (ok != 0) - *ok = false; - return 0; - } + if (ok != 0) + *ok = true; + if (!meta_type || (!meta_type->typeEntry()->isTemplateArgument() && !meta_type->hasInstantiations())) + return meta_type ? meta_type->copy() : 0; - AbstractMetaType::shared_pointer t = returned->copy(); - t->setTypeEntry(template_types.at(tae->ordinal())->typeEntry()); - t->setIndirections(template_types.at(tae->ordinal())->indirections() + t->indirections() - ? 1 - : 0); - decideUsagePattern(t); + AbstractMetaType::shared_pointer returned = meta_type->copy(); + returned->setOriginalTemplateType(meta_type); - returned = inheritTemplateType(template_types, t, ok); - if (ok != 0 && !(*ok)) - return 0; + if (returned->typeEntry()->isTemplateArgument()) { + const TemplateArgumentEntry* tae = static_cast(returned->typeEntry()); + + // If the template is intantiated with void we special case this as rejecting the functions that use this + // parameter from the instantiation. + if (template_types.size() <= tae->ordinal() || template_types.at(tae->ordinal())->typeEntry()->name() == "void") { + if (ok != 0) + *ok = false; + return 0; } - if (returned->hasInstantiations()) { - auto instantiations = returned->instantiations(); - for (int i=0; isetInstantiations(instantiations); + AbstractMetaType::shared_pointer t = returned->copy(); + t->setTypeEntry(template_types.at(tae->ordinal())->typeEntry()); + t->setIndirections(template_types.at(tae->ordinal())->indirections() + t->indirections() ? 1 : 0); + decideUsagePattern(t); + + returned = inheritTemplateType(template_types, t, ok); + if (ok != 0 && !(*ok)) + return 0; + } + + if (returned->hasInstantiations()) { + auto instantiations = returned->instantiations(); + for (int i = 0; i < instantiations.count(); ++i) { + instantiations[i] = inheritTemplateType(template_types, instantiations[i], ok); + if (ok != 0 && !(*ok)) + return 0; } + returned->setInstantiations(instantiations); + } - return returned; + return returned; } -bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass *subclass, - const AbstractMetaClass *template_class, - const TypeParser::Info &info) +bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass* subclass, const AbstractMetaClass* template_class, + const TypeParser::Info& info) { - QList targs = info.template_instantiations; - - QList template_types; - for (const TypeParser::Info &i : targs) { - TypeEntry *t = TypeDatabase::instance()->findType(i.qualified_name.join("::")); - - if (t != 0) { - AbstractMetaType::shared_pointer temporary_type = createMetaType(); - temporary_type->setTypeEntry(t); - temporary_type->setConstant(i.is_constant); - temporary_type->setReference(i.is_reference); - temporary_type->setIndirections(i.indirections); - template_types << temporary_type; - } - } + QList targs = info.template_instantiations; - AbstractMetaFunctionList funcs = subclass->functions(); - for (const AbstractMetaFunction* function : template_class->functions()) { + QList template_types; + for (const TypeParser::Info& i : targs) { + TypeEntry* t = TypeDatabase::instance()->findType(i.qualified_name.join("::")); - if (function->isModifiedRemoved(TypeSystem::All)) - continue; + if (t != 0) { + AbstractMetaType::shared_pointer temporary_type = createMetaType(); + temporary_type->setTypeEntry(t); + temporary_type->setConstant(i.is_constant); + temporary_type->setReference(i.is_reference); + temporary_type->setIndirections(i.indirections); + template_types << temporary_type; + } + } - AbstractMetaFunction *f = function->copy(); - f->setArguments(AbstractMetaArgumentList()); + AbstractMetaFunctionList funcs = subclass->functions(); + for (const AbstractMetaFunction* function : template_class->functions()) { - bool ok = true; - AbstractMetaType::shared_pointer ftype = function->type(); - f->setType(inheritTemplateType(template_types, ftype, &ok)); - if (!ok) { - delete f; - continue; - } + if (function->isModifiedRemoved(TypeSystem::All)) + continue; - for (const AbstractMetaArgument* argument : function->arguments()) { - AbstractMetaType::shared_pointer atype = argument->type(); + AbstractMetaFunction* f = function->copy(); + f->setArguments(AbstractMetaArgumentList()); - AbstractMetaArgument *arg = argument->copy(); - arg->setType(inheritTemplateType(template_types, atype, &ok)); - if (!ok) - break; - f->addArgument(arg); - } + bool ok = true; + AbstractMetaType::shared_pointer ftype = function->type(); + f->setType(inheritTemplateType(template_types, ftype, &ok)); + if (!ok) { + delete f; + continue; + } - if (!ok) { - delete f; - continue ; - } + for (const AbstractMetaArgument* argument : function->arguments()) { + AbstractMetaType::shared_pointer atype = argument->type(); - // There is no base class in java to inherit from here, so the - // template instantiation is the class that implements the function.. - f->setImplementingClass(subclass); + AbstractMetaArgument* arg = argument->copy(); + arg->setType(inheritTemplateType(template_types, atype, &ok)); + if (!ok) + break; + f->addArgument(arg); + } - // We also set it as the declaring class, since the superclass is - // supposed to disappear. This allows us to make certain function modifications - // on the inherited functions. - f->setDeclaringClass(subclass); + if (!ok) { + delete f; + continue; + } + // There is no base class in java to inherit from here, so the + // template instantiation is the class that implements the function.. + f->setImplementingClass(subclass); - if (f->isConstructor() && subclass->isTypeAlias()) { - f->setName(subclass->name()); - } else if (f->isConstructor()) { - delete f; - continue; - } + // We also set it as the declaring class, since the superclass is + // supposed to disappear. This allows us to make certain function modifications + // on the inherited functions. + f->setDeclaringClass(subclass); - // if the instantiation has a function named the same as an existing - // function we have shadowing so we need to skip it. - bool found = false; - for (int i=0; iname() == f->name()) { - found = true; - continue; - } - } - if (found) { - delete f; - continue; - } + if (f->isConstructor() && subclass->isTypeAlias()) { + f->setName(subclass->name()); + } else if (f->isConstructor()) { + delete f; + continue; + } + + // if the instantiation has a function named the same as an existing + // function we have shadowing so we need to skip it. + bool found = false; + for (int i = 0; i < funcs.size(); ++i) { + if (funcs.at(i)->name() == f->name()) { + found = true; + continue; + } + } + if (found) { + delete f; + continue; + } - ComplexTypeEntry *te = subclass->typeEntry(); - FunctionModificationList mods = function->modifications(template_class); - for (int i=0; iminimalSignature(); + ComplexTypeEntry* te = subclass->typeEntry(); + FunctionModificationList mods = function->modifications(template_class); + for (int i = 0; i < mods.size(); ++i) { + FunctionModification mod = mods.at(i); + mod.signature = f->minimalSignature(); - // If we ever need it... Below is the code to do - // substitution of the template instantation type inside - // injected code.. + // If we ever need it... Below is the code to do + // substitution of the template instantation type inside + // injected code.. #if 0 if (mod.modifiers & Modification::CodeInjection) { for (int j=0; jaddFunctionModification(mod); - } - - subclass->addFunction(f); + te->addFunctionModification(mod); } - { - subclass->setTemplateBaseClass(template_class); + subclass->addFunction(f); + } - subclass->setInterfaces(template_class->interfaces()); - subclass->setBaseClass(template_class->baseClass()); - } + { + subclass->setTemplateBaseClass(template_class); - return true; + subclass->setInterfaces(template_class->interfaces()); + subclass->setBaseClass(template_class->baseClass()); + } + + return true; } -void AbstractMetaBuilder::parseQ_Property(AbstractMetaClass *meta_class, const QStringList &declarations) +void AbstractMetaBuilder::parseQ_Property(AbstractMetaClass* meta_class, const QStringList& declarations) { - for (int i=0; iqualifiedName(); - bool ok = false; - AbstractMetaType::shared_pointer type = 0; - int pIndex = 0; - QString typeName = l.value(pIndex++); - bool isConst = false; - if (typeName == "const") { - // use the next part as the type name - typeName = l.value(pIndex++); - isConst = true; - } - QString propertyName = l.value(pIndex++); - QString modifiers; - while (typeName.endsWith("*") || typeName.endsWith("&")) { - modifiers.insert(0, typeName.at(typeName.length() - 1)); - typeName.chop(1); - } - while (propertyName.startsWith("*") || propertyName.startsWith("&")) { - modifiers.append(propertyName.at(0)); - propertyName.remove(0, 1); - if (propertyName.isEmpty() && pIndex < l.size()) { - propertyName = l.value(pIndex++); - } - } - for (int j=qualifiedScopeName.size(); j>=0; --j) { - QStringList scope(qualifiedScopeName.mid(0, j)); - TypeInfo info; - info.setIndirections(modifiers.count('*')); - info.setReference(modifiers.contains('&')); // r-value reference seems improbable for a property... - info.setQualifiedName(scope + QStringList(typeName)); - - type = translateType(info, &ok); - if (type != 0 && ok) { - break; - } - } + for (int i = 0; i < declarations.size(); ++i) { + QString p = declarations.at(i); - if (type == 0 || !ok) { - ReportHandler::warning(QString("Unable to decide type '%1' of property '%2' in class '%3'") - .arg(typeName).arg(propertyName).arg(meta_class->name())); - continue; - } + QStringList l = p.split(QLatin1String(" ")); - QPropertySpec *spec = new QPropertySpec(type->typeEntry()); - spec->setName(propertyName); - spec->setIndex(i); - - for (int pos=pIndex; pos+1setRead(l.at(pos+1)); - else if (l.at(pos) == QLatin1String("WRITE")) - spec->setWrite(l.at(pos+1)); - else if (l.at(pos) == QLatin1String("DESIGNABLE")) - spec->setDesignable(l.at(pos+1)); - else if (l.at(pos) == QLatin1String("RESET")) - spec->setReset(l.at(pos+1)); - } + QStringList qualifiedScopeName = currentScope()->qualifiedName(); + bool ok = false; + AbstractMetaType::shared_pointer type = 0; + int pIndex = 0; + QString typeName = l.value(pIndex++); + bool isConst = false; + if (typeName == "const") { + // use the next part as the type name + typeName = l.value(pIndex++); + isConst = true; + } + QString propertyName = l.value(pIndex++); + QString modifiers; + while (typeName.endsWith("*") || typeName.endsWith("&")) { + modifiers.insert(0, typeName.at(typeName.length() - 1)); + typeName.chop(1); + } + while (propertyName.startsWith("*") || propertyName.startsWith("&")) { + modifiers.append(propertyName.at(0)); + propertyName.remove(0, 1); + if (propertyName.isEmpty() && pIndex < l.size()) { + propertyName = l.value(pIndex++); + } + } + for (int j = qualifiedScopeName.size(); j >= 0; --j) { + QStringList scope(qualifiedScopeName.mid(0, j)); + TypeInfo info; + info.setIndirections(modifiers.count('*')); + info.setReference(modifiers.contains('&')); // r-value reference seems improbable for a property... + info.setQualifiedName(scope + QStringList(typeName)); - meta_class->addPropertySpec(spec); + type = translateType(info, &ok); + if (type != 0 && ok) { + break; + } } -} -static void hide_functions(const AbstractMetaFunctionList &l) { - for (AbstractMetaFunction *f : l) { - FunctionModification mod; - mod.signature = f->minimalSignature(); - mod.modifiers = FunctionModification::Private; - ((ComplexTypeEntry *) f->implementingClass()->typeEntry())->addFunctionModification(mod); + if (type == 0 || !ok) { + ReportHandler::warning(QString("Unable to decide type '%1' of property '%2' in class '%3'") + .arg(typeName) + .arg(propertyName) + .arg(meta_class->name())); + continue; } + + QPropertySpec* spec = new QPropertySpec(type->typeEntry()); + spec->setName(propertyName); + spec->setIndex(i); + + for (int pos = pIndex; pos + 1 < l.size(); pos += 2) { + if (l.at(pos) == QLatin1String("READ")) + spec->setRead(l.at(pos + 1)); + else if (l.at(pos) == QLatin1String("WRITE")) + spec->setWrite(l.at(pos + 1)); + else if (l.at(pos) == QLatin1String("DESIGNABLE")) + spec->setDesignable(l.at(pos + 1)); + else if (l.at(pos) == QLatin1String("RESET")) + spec->setReset(l.at(pos + 1)); + } + + meta_class->addPropertySpec(spec); + } } -static void remove_function(AbstractMetaFunction *f) { +static void hide_functions(const AbstractMetaFunctionList& l) +{ + for (AbstractMetaFunction* f : l) { FunctionModification mod; - mod.removal = TypeSystem::All; mod.signature = f->minimalSignature(); - ((ComplexTypeEntry *) f->implementingClass()->typeEntry())->addFunctionModification(mod); + mod.modifiers = FunctionModification::Private; + ((ComplexTypeEntry*)f->implementingClass()->typeEntry())->addFunctionModification(mod); + } } -static AbstractMetaFunctionList filter_functions(const AbstractMetaFunctionList &lst, QSet *signatures) +static void remove_function(AbstractMetaFunction* f) { - AbstractMetaFunctionList functions; - for (AbstractMetaFunction *f : lst) { - QString signature = f->minimalSignature(); - int start = signature.indexOf(QLatin1Char('(')) + 1; - int end = signature.lastIndexOf(QLatin1Char(')')); - signature = signature.mid(start, end - start); - if (signatures->contains(signature)) { - remove_function(f); - continue; - } - (*signatures) << signature; - functions << f; - } - return functions; + FunctionModification mod; + mod.removal = TypeSystem::All; + mod.signature = f->minimalSignature(); + ((ComplexTypeEntry*)f->implementingClass()->typeEntry())->addFunctionModification(mod); } -void AbstractMetaBuilder::setupEquals(AbstractMetaClass *cls) +static AbstractMetaFunctionList filter_functions(const AbstractMetaFunctionList& lst, QSet* signatures) { - AbstractMetaFunctionList equals; - AbstractMetaFunctionList nequals; + AbstractMetaFunctionList functions; + for (AbstractMetaFunction* f : lst) { + QString signature = f->minimalSignature(); + int start = signature.indexOf(QLatin1Char('(')) + 1; + int end = signature.lastIndexOf(QLatin1Char(')')); + signature = signature.mid(start, end - start); + if (signatures->contains(signature)) { + remove_function(f); + continue; + } + (*signatures) << signature; + functions << f; + } + return functions; +} - QString op_equals = QLatin1String("operator_equal"); - QString op_nequals = QLatin1String("operator_not_equal"); +void AbstractMetaBuilder::setupEquals(AbstractMetaClass* cls) +{ + AbstractMetaFunctionList equals; + AbstractMetaFunctionList nequals; + + QString op_equals = QLatin1String("operator_equal"); + QString op_nequals = QLatin1String("operator_not_equal"); + + AbstractMetaFunctionList functions = + cls->queryFunctions(AbstractMetaClass::ClassImplements | AbstractMetaClass::NotRemovedFromTargetLang); + for (AbstractMetaFunction* f : functions) { + if (f->name() == op_equals) + equals << f; + else if (f->name() == op_nequals) + nequals << f; + } - AbstractMetaFunctionList functions = cls->queryFunctions(AbstractMetaClass::ClassImplements - | AbstractMetaClass::NotRemovedFromTargetLang); - for (AbstractMetaFunction *f : functions) { - if (f->name() == op_equals) - equals << f; - else if (f->name() == op_nequals) - nequals << f; + if (equals.size() || nequals.size()) { + if (!cls->hasHashFunction()) { + ReportHandler::warning( + QString::fromLatin1("Class '%1' has equals operators but no qHash() function").arg(cls->name())); } - if (equals.size() || nequals.size()) { - if (!cls->hasHashFunction()) { - ReportHandler::warning(QString::fromLatin1("Class '%1' has equals operators but no qHash() function") - .arg(cls->name())); - } - - hide_functions(equals); - hide_functions(nequals); + hide_functions(equals); + hide_functions(nequals); - // We only need == if we have both == and !=, and one == for - // each signature type, like QDateTime::==(QDate) and (QTime) - // if such a thing exists... - QSet func_signatures; - cls->setEqualsFunctions(filter_functions(equals, &func_signatures)); - cls->setNotEqualsFunctions(filter_functions(nequals, &func_signatures)); - } + // We only need == if we have both == and !=, and one == for + // each signature type, like QDateTime::==(QDate) and (QTime) + // if such a thing exists... + QSet func_signatures; + cls->setEqualsFunctions(filter_functions(equals, &func_signatures)); + cls->setNotEqualsFunctions(filter_functions(nequals, &func_signatures)); + } } -void AbstractMetaBuilder::setupComparable(AbstractMetaClass *cls) +void AbstractMetaBuilder::setupComparable(AbstractMetaClass* cls) { - AbstractMetaFunctionList greater; - AbstractMetaFunctionList greaterEquals; - AbstractMetaFunctionList less; - AbstractMetaFunctionList lessEquals; - - QString op_greater = QLatin1String("operator_greater"); - QString op_greater_eq = QLatin1String("operator_greater_or_equal"); - QString op_less = QLatin1String("operator_less"); - QString op_less_eq = QLatin1String("operator_less_or_equal"); - - AbstractMetaFunctionList functions = cls->queryFunctions(AbstractMetaClass::ClassImplements - | AbstractMetaClass::NotRemovedFromTargetLang); - for (AbstractMetaFunction *f : functions) { - if (f->name() == op_greater) - greater << f; - else if (f->name() == op_greater_eq) - greaterEquals << f; - else if (f->name() == op_less) - less << f; - else if (f->name() == op_less_eq) - lessEquals << f; - } - - bool hasEquals = cls->equalsFunctions().size() || cls->notEqualsFunctions().size(); - - // Conditions for comparable is: - // >, ==, < - The basic case - // >, == - Less than becomes else case - // <, == - Greater than becomes else case - // >=, <= - if (<= && >=) -> equal - bool mightBeComparable = greater.size() || greaterEquals.size() || less.size() || lessEquals.size() - || greaterEquals.size() == 1 || lessEquals.size() == 1; - - if (mightBeComparable) { - QSet signatures; - - // We only hide the original functions if we are able to make a compareTo() method - bool wasComparable = false; - - // The three upper cases, prefer the <, == approach - if (hasEquals && (greater.size() || less.size())) { - cls->setLessThanFunctions(filter_functions(less, &signatures)); - cls->setGreaterThanFunctions(filter_functions(greater, &signatures)); - filter_functions(greaterEquals, &signatures); - filter_functions(lessEquals, &signatures); - wasComparable = true; - } else if (hasEquals && (greaterEquals.size() || lessEquals.size())) { - cls->setLessThanEqFunctions(filter_functions(lessEquals, &signatures)); - cls->setGreaterThanEqFunctions(filter_functions(greaterEquals, &signatures)); - wasComparable = true; - } else if (greaterEquals.size() == 1 || lessEquals.size() == 1) { - cls->setGreaterThanEqFunctions(greaterEquals); - cls->setLessThanEqFunctions(lessEquals); - filter_functions(less, &signatures); - filter_functions(greater, &signatures); - wasComparable = true; - } + AbstractMetaFunctionList greater; + AbstractMetaFunctionList greaterEquals; + AbstractMetaFunctionList less; + AbstractMetaFunctionList lessEquals; + + QString op_greater = QLatin1String("operator_greater"); + QString op_greater_eq = QLatin1String("operator_greater_or_equal"); + QString op_less = QLatin1String("operator_less"); + QString op_less_eq = QLatin1String("operator_less_or_equal"); + + AbstractMetaFunctionList functions = + cls->queryFunctions(AbstractMetaClass::ClassImplements | AbstractMetaClass::NotRemovedFromTargetLang); + for (AbstractMetaFunction* f : functions) { + if (f->name() == op_greater) + greater << f; + else if (f->name() == op_greater_eq) + greaterEquals << f; + else if (f->name() == op_less) + less << f; + else if (f->name() == op_less_eq) + lessEquals << f; + } - if (wasComparable) { - hide_functions(greater); - hide_functions(greaterEquals); - hide_functions(less); - hide_functions(lessEquals); - } + bool hasEquals = cls->equalsFunctions().size() || cls->notEqualsFunctions().size(); + + // Conditions for comparable is: + // >, ==, < - The basic case + // >, == - Less than becomes else case + // <, == - Greater than becomes else case + // >=, <= - if (<= && >=) -> equal + bool mightBeComparable = greater.size() || greaterEquals.size() || less.size() || lessEquals.size() + || greaterEquals.size() == 1 || lessEquals.size() == 1; + + if (mightBeComparable) { + QSet signatures; + + // We only hide the original functions if we are able to make a compareTo() method + bool wasComparable = false; + + // The three upper cases, prefer the <, == approach + if (hasEquals && (greater.size() || less.size())) { + cls->setLessThanFunctions(filter_functions(less, &signatures)); + cls->setGreaterThanFunctions(filter_functions(greater, &signatures)); + filter_functions(greaterEquals, &signatures); + filter_functions(lessEquals, &signatures); + wasComparable = true; + } else if (hasEquals && (greaterEquals.size() || lessEquals.size())) { + cls->setLessThanEqFunctions(filter_functions(lessEquals, &signatures)); + cls->setGreaterThanEqFunctions(filter_functions(greaterEquals, &signatures)); + wasComparable = true; + } else if (greaterEquals.size() == 1 || lessEquals.size() == 1) { + cls->setGreaterThanEqFunctions(greaterEquals); + cls->setLessThanEqFunctions(lessEquals); + filter_functions(less, &signatures); + filter_functions(greater, &signatures); + wasComparable = true; + } + + if (wasComparable) { + hide_functions(greater); + hide_functions(greaterEquals); + hide_functions(less); + hide_functions(lessEquals); } - + } } -void AbstractMetaBuilder::setupClonable(AbstractMetaClass *cls) +void AbstractMetaBuilder::setupClonable(AbstractMetaClass* cls) { - QString op_assign = QLatin1String("operator_assign"); - - AbstractMetaFunctionList functions = cls->queryFunctions(AbstractMetaClass::ClassImplements); - for (AbstractMetaFunction *f : functions) { - if ((f->name() == op_assign || f->isConstructor()) && f->isPublic()) { - AbstractMetaArgumentList arguments = f->arguments(); - if (arguments.size() == 1) { - if (cls->typeEntry()->qualifiedCppName() == arguments.at(0)->type()->typeEntry()->qualifiedCppName()) { - if (cls->typeEntry()->isValue()) { - cls->setHasCloneOperator(true); - return; - } - } - } + QString op_assign = QLatin1String("operator_assign"); + + AbstractMetaFunctionList functions = cls->queryFunctions(AbstractMetaClass::ClassImplements); + for (AbstractMetaFunction* f : functions) { + if ((f->name() == op_assign || f->isConstructor()) && f->isPublic()) { + AbstractMetaArgumentList arguments = f->arguments(); + if (arguments.size() == 1) { + if (cls->typeEntry()->qualifiedCppName() == arguments.at(0)->type()->typeEntry()->qualifiedCppName()) { + if (cls->typeEntry()->isValue()) { + cls->setHasCloneOperator(true); + return; + } } + } } + } } -static void write_reject_log_file(const QString &name, const QString &tagName, - const QMap &rejects) +static void write_reject_log_file(const QString& name, const QString& tagName, + const QMap& rejects) { - QFile f(name); - if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { - ReportHandler::warning(QString("failed to write log file: '%1'") - .arg(f.fileName())); - return; - } - - QTextStream s(&f); + QFile f(name); + if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { + ReportHandler::warning(QString("failed to write log file: '%1'").arg(f.fileName())); + return; + } + QTextStream s(&f); - for (int reason=0; reason::const_iterator it = rejects.constBegin(); - it != rejects.constEnd(); ++it) { - if (it.value() != reason) - continue; - if (tagName.isEmpty()) { - s << it.key() << Qt::endl; - } else { - s << "<" << tagName << " name=\"" << it.key() << "\"/>" << Qt::endl; -// s << "" << Qt::endl; - } - } + s << Qt::endl; - s << QString(72, '*') << Qt::endl << Qt::endl; + for (QMap::const_iterator it = rejects.constBegin(); + it != rejects.constEnd(); ++it) + { + if (it.value() != reason) + continue; + if (tagName.isEmpty()) { + s << it.key() << Qt::endl; + } else { + s << "<" << tagName << " name=\"" << it.key() << "\"/>" << Qt::endl; + // s << "" << Qt::endl; + } } + s << QString(72, '*') << Qt::endl << Qt::endl; + } } - void AbstractMetaBuilder::dumpLog() { - write_reject_log_file("mjb_rejected_classes.log", "object-type", m_rejected_classes); - write_reject_log_file("mjb_rejected_enums.log", "enum-type", m_rejected_enums); - write_reject_log_file("mjb_rejected_functions.log","", m_rejected_functions); - write_reject_log_file("mjb_rejected_fields.log","", m_rejected_fields); + write_reject_log_file("mjb_rejected_classes.log", "object-type", m_rejected_classes); + write_reject_log_file("mjb_rejected_enums.log", "enum-type", m_rejected_enums); + write_reject_log_file("mjb_rejected_functions.log", "", m_rejected_functions); + write_reject_log_file("mjb_rejected_fields.log", "", m_rejected_fields); } AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted() const { - /* This function is the standard topological sort of a Directed Acyclic + /* This function is the standard topological sort of a Directed Acyclic * Graph (a DAG). It outputs a partially ordered list of the nodes in the * graph such that a node is output after all of its children. * @@ -2468,95 +2405,88 @@ AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted() const * comprehensions. */ - /* Build a hash list of QSet for each class. 'class' is represented + /* Build a hash list of QSet for each class. 'class' is represented * by a pointer to the AbstractMetaClass from m_meta_classes. */ - ReportHandler::debugSparse(QString("TSORT: %1 meta classes") - .arg(m_meta_classes.count())); - QHash> classes; - classes.reserve(m_meta_classes.count()); + ReportHandler::debugSparse(QString("TSORT: %1 meta classes").arg(m_meta_classes.count())); + QHash> classes; + classes.reserve(m_meta_classes.count()); - for (auto cls : m_meta_classes) { - /* Add the baseClass and the interfaces the class uses. The latter + for (auto cls : m_meta_classes) { + /* Add the baseClass and the interfaces the class uses. The latter * are stored in an AbstractMetaClassList which is uses a QList, so: */ - auto entry(classes.insert(cls, -# if QT_VERSION < QT_VERSION_CHECK(5,14,0) - QSet::fromList(cls->interfaces()) -# else - QSet(cls->interfaces().cbegin(), - cls->interfaces().cend()) -# endif + auto entry(classes.insert(cls, +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + QSet::fromList(cls->interfaces()) +#else + QSet(cls->interfaces().cbegin(), cls->interfaces().cend()) +#endif )); - if (cls->baseClass()) - entry.value().insert(cls->baseClass()); - entry.value().remove(cls); // may come from interfaces - } + if (cls->baseClass()) + entry.value().insert(cls->baseClass()); + entry.value().remove(cls); // may come from interfaces + } - /* This and the qFatals below are fatal internal errors in the code of + /* This and the qFatals below are fatal internal errors in the code of * pythonqt_generator. */ - if (m_meta_classes.count() != classes.count()) - qFatal("TOPO SORT: duplicate meta classes (%lld != %lld)", - static_cast(m_meta_classes.count()), - static_cast(classes.count())); + if (m_meta_classes.count() != classes.count()) + qFatal("TOPO SORT: duplicate meta classes (%lld != %lld)", static_cast(m_meta_classes.count()), + static_cast(classes.count())); - /* Loop: output all the classes with no remaining dependencies to the + /* Loop: output all the classes with no remaining dependencies to the * result and then also remove those now output classes from the remaining * classes in the hash table. */ - AbstractMetaClassList result; - result.reserve(classes.count()); - QSet handled; - handled.reserve(classes.count()); - int interfaceClasses(0), depthFromLeaf(0); + AbstractMetaClassList result; + result.reserve(classes.count()); + QSet handled; + handled.reserve(classes.count()); + int interfaceClasses(0), depthFromLeaf(0); - while (!classes.empty()) { - handled.clear(); - int iFCount(0); + while (!classes.empty()) { + handled.clear(); + int iFCount(0); - /* Output classes where all children have already been output (initially + /* Output classes where all children have already been output (initially * the leaf nodes): */ - for (auto i(classes.cbegin()); i != classes.cend(); ++i) - if (i.value().empty()) - handled.insert(i.key()); + for (auto i(classes.cbegin()); i != classes.cend(); ++i) + if (i.value().empty()) + handled.insert(i.key()); - /* Something must have been done; if not this is not a DAG because + /* Something must have been done; if not this is not a DAG because * there is a cycle. */ - if (handled.empty()) - qFatal("TOPOSORT: %lld cyclic meta classes @depth %d.", - static_cast(classes.count()), depthFromLeaf); - - /* Remove all 'handled' from the hash table. */ - for (auto cls : handled) - if (!classes.remove(cls)) - qFatal("TOPO SORT: class remove failed @depth %d.", - depthFromLeaf); - - /* Then remove the 'handled' set from the classes values: */ - for (QSet &set : classes) - set -= handled; - - /* Output only those handled classes there are not interfaces: */ - for (auto cls : handled) { - if (!cls->isInterface()) - result.append(cls); - else - ++iFCount; - } - - ReportHandler::debugSparse( - QString("TSORT: depth %1: %2 classes (%3 interface)") - .arg(depthFromLeaf).arg(handled.count()).arg(iFCount)); - interfaceClasses += iFCount; - ++depthFromLeaf; - } + if (handled.empty()) + qFatal("TOPOSORT: %lld cyclic meta classes @depth %d.", static_cast(classes.count()), depthFromLeaf); + + /* Remove all 'handled' from the hash table. */ + for (auto cls : handled) + if (!classes.remove(cls)) + qFatal("TOPO SORT: class remove failed @depth %d.", depthFromLeaf); + + /* Then remove the 'handled' set from the classes values: */ + for (QSet& set : classes) + set -= handled; + + /* Output only those handled classes there are not interfaces: */ + for (auto cls : handled) { + if (!cls->isInterface()) + result.append(cls); + else + ++iFCount; + } + + ReportHandler::debugSparse( + QString("TSORT: depth %1: %2 classes (%3 interface)").arg(depthFromLeaf).arg(handled.count()).arg(iFCount)); + interfaceClasses += iFCount; + ++depthFromLeaf; + } - ReportHandler::debugSparse(QString( - "TSORT: %1 result classes, %2 interface classes)") - .arg(result.count()).arg(interfaceClasses)); - return result; + ReportHandler::debugSparse( + QString("TSORT: %1 result classes, %2 interface classes)").arg(result.count()).arg(interfaceClasses)); + return result; } diff --git a/generator/abstractmetabuilder.h b/generator/abstractmetabuilder.h index ac8f87da4..5861900f1 100644 --- a/generator/abstractmetabuilder.h +++ b/generator/abstractmetabuilder.h @@ -52,141 +52,137 @@ class AbstractMetaBuilder { public: - enum RejectReason { - NotInTypeSystem, - GenerationDisabled, - RedefinedToNotClass, - UnmatchedArgumentType, - UnmatchedReturnType, - NoReason - }; - - AbstractMetaBuilder(); - virtual ~AbstractMetaBuilder(); - - AbstractMetaClassList classes() const { return m_meta_classes; } - AbstractMetaClassList classesTopologicalSorted() const; - - FileModelItem model() const { return m_dom; } - void setModel(FileModelItem item) { m_dom = item; } - - - ScopeModelItem popScope() { return m_scopes.takeLast(); } - void pushScope(ScopeModelItem item) { m_scopes << item; } - ScopeModelItem currentScope() const { return m_scopes.last(); } - - QString fileName() const { return m_file_name; } - void setFileName(const QString &fileName) { m_file_name = fileName; } - - //! Set list of include directories. This will be used to make absolute include paths relative. - void setIncludePaths(const QStringList& includePaths) { m_include_paths = includePaths; } - - void dumpLog(); - - bool build(); - - void autoAddQEnumsForClassItem(ClassModelItem item); - - void addAbstractMetaClass(AbstractMetaClass *cls); - AbstractMetaClass *traverseTypeAlias(TypeAliasModelItem item); - AbstractMetaClass *traverseClass(ClassModelItem item); - bool setupInheritance(AbstractMetaClass *meta_class); - AbstractMetaClass *traverseNamespace(NamespaceModelItem item); - AbstractMetaEnum *traverseEnum(EnumModelItem item, AbstractMetaClass *enclosing, const QSet &enumsDeclarations); - void traverseEnums(ScopeModelItem item, AbstractMetaClass *parent, const QSet &enumsDeclarations); - void traverseFunctions(ScopeModelItem item, AbstractMetaClass *parent); - void traverseFields(ScopeModelItem item, AbstractMetaClass *parent); - void traverseStreamOperator(FunctionModelItem function_item); - void traverseCompareOperator(FunctionModelItem item); - void traverseArithmeticOperator(FunctionModelItem item); - - //! remove functions/methods that are overloads with equivalent parameter types - //! when called from Python - void removeEquivalentFunctions(AbstractMetaClass* parent); - - AbstractMetaFunction *traverseFunction(FunctionModelItem function); - AbstractMetaField *traverseField(VariableModelItem field, const AbstractMetaClass *cls); - void checkFunctionModifications(); - void registerHashFunction(FunctionModelItem function_item); - void registerToStringCapability(FunctionModelItem function_item); - - void parseQ_Property(AbstractMetaClass *meta_class, const QStringList &declarations); - void setupEquals(AbstractMetaClass *meta_class); - void setupComparable(AbstractMetaClass *meta_class); - void setupClonable(AbstractMetaClass *cls); - void setupFunctionDefaults(AbstractMetaFunction *meta_function, AbstractMetaClass *meta_class); - - QString translateDefaultValue(ArgumentModelItem item, AbstractMetaType::shared_pointer type, - AbstractMetaFunction *fnc, AbstractMetaClass *, - int argument_index); - AbstractMetaType::shared_pointer translateType(const TypeInfo &type, bool *ok, bool resolveType = true, bool resolveScope = true); - - void decideUsagePattern(AbstractMetaType::shared_pointer type); - - bool inheritTemplate(AbstractMetaClass *subclass, - const AbstractMetaClass *template_class, - const TypeParser::Info &info); - AbstractMetaType::shared_pointer inheritTemplateType(const QList &template_types, - AbstractMetaType::shared_pointer meta_type, - bool *ok = 0); - - bool isQObject(const QString &qualified_name); - bool isEnum(const QStringList &qualified_name); - - void fixQObjectForScope (TypeDatabase *types, - NamespaceModelItem item); - - // QtScript - QSet qtMetaTypeDeclaredTypeNames() const - { return m_qmetatype_declared_typenames; } + enum RejectReason { + NotInTypeSystem, + GenerationDisabled, + RedefinedToNotClass, + UnmatchedArgumentType, + UnmatchedReturnType, + NoReason + }; + + AbstractMetaBuilder(); + virtual ~AbstractMetaBuilder(); + + AbstractMetaClassList classes() const { return m_meta_classes; } + AbstractMetaClassList classesTopologicalSorted() const; + + FileModelItem model() const { return m_dom; } + void setModel(FileModelItem item) { m_dom = item; } + + ScopeModelItem popScope() { return m_scopes.takeLast(); } + void pushScope(ScopeModelItem item) { m_scopes << item; } + ScopeModelItem currentScope() const { return m_scopes.last(); } + + QString fileName() const { return m_file_name; } + void setFileName(const QString& fileName) { m_file_name = fileName; } + + //! Set list of include directories. This will be used to make absolute include paths relative. + void setIncludePaths(const QStringList& includePaths) { m_include_paths = includePaths; } + + void dumpLog(); + + bool build(); + + void autoAddQEnumsForClassItem(ClassModelItem item); + + void addAbstractMetaClass(AbstractMetaClass* cls); + AbstractMetaClass* traverseTypeAlias(TypeAliasModelItem item); + AbstractMetaClass* traverseClass(ClassModelItem item); + bool setupInheritance(AbstractMetaClass* meta_class); + AbstractMetaClass* traverseNamespace(NamespaceModelItem item); + AbstractMetaEnum* traverseEnum(EnumModelItem item, AbstractMetaClass* enclosing, + const QSet& enumsDeclarations); + void traverseEnums(ScopeModelItem item, AbstractMetaClass* parent, const QSet& enumsDeclarations); + void traverseFunctions(ScopeModelItem item, AbstractMetaClass* parent); + void traverseFields(ScopeModelItem item, AbstractMetaClass* parent); + void traverseStreamOperator(FunctionModelItem function_item); + void traverseCompareOperator(FunctionModelItem item); + void traverseArithmeticOperator(FunctionModelItem item); + + //! remove functions/methods that are overloads with equivalent parameter types + //! when called from Python + void removeEquivalentFunctions(AbstractMetaClass* parent); + + AbstractMetaFunction* traverseFunction(FunctionModelItem function); + AbstractMetaField* traverseField(VariableModelItem field, const AbstractMetaClass* cls); + void checkFunctionModifications(); + void registerHashFunction(FunctionModelItem function_item); + void registerToStringCapability(FunctionModelItem function_item); + + void parseQ_Property(AbstractMetaClass* meta_class, const QStringList& declarations); + void setupEquals(AbstractMetaClass* meta_class); + void setupComparable(AbstractMetaClass* meta_class); + void setupClonable(AbstractMetaClass* cls); + void setupFunctionDefaults(AbstractMetaFunction* meta_function, AbstractMetaClass* meta_class); + + QString translateDefaultValue(ArgumentModelItem item, AbstractMetaType::shared_pointer type, + AbstractMetaFunction* fnc, AbstractMetaClass*, int argument_index); + AbstractMetaType::shared_pointer translateType(const TypeInfo& type, bool* ok, bool resolveType = true, + bool resolveScope = true); + + void decideUsagePattern(AbstractMetaType::shared_pointer type); + + bool inheritTemplate(AbstractMetaClass* subclass, const AbstractMetaClass* template_class, + const TypeParser::Info& info); + AbstractMetaType::shared_pointer inheritTemplateType(const QList& template_types, + AbstractMetaType::shared_pointer meta_type, bool* ok = 0); + + bool isQObject(const QString& qualified_name); + bool isEnum(const QStringList& qualified_name); + + void fixQObjectForScope(TypeDatabase* types, NamespaceModelItem item); + + // QtScript + QSet qtMetaTypeDeclaredTypeNames() const { return m_qmetatype_declared_typenames; } protected: - AbstractMetaClass *argumentToClass(ArgumentModelItem); + AbstractMetaClass* argumentToClass(ArgumentModelItem); - virtual AbstractMetaClass *createMetaClass() = 0; - virtual AbstractMetaEnum *createMetaEnum() = 0; - virtual AbstractMetaEnumValue *createMetaEnumValue() = 0; - virtual AbstractMetaField *createMetaField() = 0; - virtual AbstractMetaFunction *createMetaFunction() = 0; - virtual AbstractMetaArgument *createMetaArgument() = 0; - virtual AbstractMetaType::shared_pointer createMetaType() = 0; + virtual AbstractMetaClass* createMetaClass() = 0; + virtual AbstractMetaEnum* createMetaEnum() = 0; + virtual AbstractMetaEnumValue* createMetaEnumValue() = 0; + virtual AbstractMetaField* createMetaField() = 0; + virtual AbstractMetaFunction* createMetaFunction() = 0; + virtual AbstractMetaArgument* createMetaArgument() = 0; + virtual AbstractMetaType::shared_pointer createMetaType() = 0; private: - void sortLists(); + void sortLists(); - AbstractMetaClass* getGlobalNamespace(const TypeEntry* typeEntry); + AbstractMetaClass* getGlobalNamespace(const TypeEntry* typeEntry); - // turn absolute file path into a relative include - Include getRelativeInclude(const QString& path); + // turn absolute file path into a relative include + Include getRelativeInclude(const QString& path); - QString m_file_name; - QStringList m_include_paths; + QString m_file_name; + QStringList m_include_paths; - AbstractMetaClassList m_meta_classes; - QHash m_templates; - FileModelItem m_dom; - - QSet m_used_types; + AbstractMetaClassList m_meta_classes; + QHash m_templates; + FileModelItem m_dom; - QMap m_rejected_classes; - QMap m_rejected_enums; - QMap m_rejected_functions; - QMap m_rejected_fields; + QSet m_used_types; - QList m_enums; + QMap m_rejected_classes; + QMap m_rejected_enums; + QMap m_rejected_functions; + QMap m_rejected_fields; - QList > m_enum_default_arguments; + QList m_enums; - QHash m_enum_values; + QList> m_enum_default_arguments; - AbstractMetaClass *m_current_class; - QList m_scopes; - QString m_namespace_prefix; + QHash m_enum_values; - QSet m_setup_inheritance_done; + AbstractMetaClass* m_current_class; + QList m_scopes; + QString m_namespace_prefix; - // QtScript - QSet m_qmetatype_declared_typenames; + QSet m_setup_inheritance_done; + + // QtScript + QSet m_qmetatype_declared_typenames; }; #endif // ABSTRACTMETBUILDER_H diff --git a/generator/abstractmetalang.cpp b/generator/abstractmetalang.cpp index b3aafbde5..d565e7266 100644 --- a/generator/abstractmetalang.cpp +++ b/generator/abstractmetalang.cpp @@ -49,107 +49,102 @@ */ AbstractMetaType::shared_pointer AbstractMetaType::copy() const { - AbstractMetaType *cpy = new AbstractMetaType; + AbstractMetaType* cpy = new AbstractMetaType; - cpy->setTypeUsagePattern(typeUsagePattern()); - cpy->setConstant(isConstant()); - cpy->setReference(isReference()); - cpy->setIndirections(indirections()); - cpy->setInstantiations(instantiations()); - cpy->setArrayElementCount(arrayElementCount()); - cpy->setOriginalTypeDescription(originalTypeDescription()); - cpy->setOriginalTemplateType(originalTemplateType() ? originalTemplateType()->copy() : 0); + cpy->setTypeUsagePattern(typeUsagePattern()); + cpy->setConstant(isConstant()); + cpy->setReference(isReference()); + cpy->setIndirections(indirections()); + cpy->setInstantiations(instantiations()); + cpy->setArrayElementCount(arrayElementCount()); + cpy->setOriginalTypeDescription(originalTypeDescription()); + cpy->setOriginalTemplateType(originalTemplateType() ? originalTemplateType()->copy() : 0); - cpy->setArrayElementType(arrayElementType() ? arrayElementType()->copy() : 0); + cpy->setArrayElementType(arrayElementType() ? arrayElementType()->copy() : 0); - cpy->setTypeEntry(typeEntry()); + cpy->setTypeEntry(typeEntry()); - return AbstractMetaType::shared_pointer(cpy); + return AbstractMetaType::shared_pointer(cpy); } QString AbstractMetaType::cppSignature() const { - QString s; + QString s; - if (isConstant()) - s += "const "; + if (isConstant()) + s += "const "; - s += typeEntry()->qualifiedCppName(); + s += typeEntry()->qualifiedCppName(); - if (hasInstantiationInCpp()) { - auto &types = instantiations(); - s += "<"; - for (int i=0; i 0) - s += ", "; - s += types.at(i)->cppSignature(); - } - s += " >"; + if (hasInstantiationInCpp()) { + auto& types = instantiations(); + s += "<"; + for (int i = 0; i < types.count(); ++i) { + if (i > 0) + s += ", "; + s += types.at(i)->cppSignature(); } + s += " >"; + } - if (actualIndirections()) { - s += ' '; - if (indirections()) - s += QString(indirections(), '*'); - if (isReference()) - s += '&'; - } - return s; + if (actualIndirections()) { + s += ' '; + if (indirections()) + s += QString(indirections(), '*'); + if (isReference()) + s += '&'; + } + return s; } /******************************************************************************* * AbstractMetaVariable */ -AbstractMetaVariable::~AbstractMetaVariable() -{ -} +AbstractMetaVariable::~AbstractMetaVariable() {} /******************************************************************************* * AbstractMetaArgument */ -AbstractMetaArgument *AbstractMetaArgument::copy() const +AbstractMetaArgument* AbstractMetaArgument::copy() const { - AbstractMetaArgument *cpy = new AbstractMetaArgument; - cpy->setName(AbstractMetaVariable::name()); - cpy->setDefaultValueExpression(defaultValueExpression()); - cpy->setType(type()); - cpy->setArgumentIndex(argumentIndex()); + AbstractMetaArgument* cpy = new AbstractMetaArgument; + cpy->setName(AbstractMetaVariable::name()); + cpy->setDefaultValueExpression(defaultValueExpression()); + cpy->setType(type()); + cpy->setArgumentIndex(argumentIndex()); - return cpy; + return cpy; } - QString AbstractMetaArgument::argumentName() const { - QString n = AbstractMetaVariable::name(); - if (n.isEmpty()) { - return QString("arg__%2").arg(m_argument_index + 1); - } - return n; + QString n = AbstractMetaVariable::name(); + if (n.isEmpty()) { + return QString("arg__%2").arg(m_argument_index + 1); + } + return n; } - QString AbstractMetaArgument::indexedName() const { - QString n = AbstractMetaVariable::name(); - if (n.isEmpty()) - return argumentName(); - return QString("%1%2").arg(n).arg(m_argument_index); + QString n = AbstractMetaVariable::name(); + if (n.isEmpty()) + return argumentName(); + return QString("%1%2").arg(n).arg(m_argument_index); } QString AbstractMetaArgument::name() const { - Q_ASSERT_X(0, "AbstractMetaArgument::name()", "use argumentName() or indexedName() instead"); - return QString(); + Q_ASSERT_X(0, "AbstractMetaArgument::name()", "use argumentName() or indexedName() instead"); + return QString(); } - /******************************************************************************* * AbstractMetaFunction */ AbstractMetaFunction::~AbstractMetaFunction() { - qDeleteAll(m_arguments); + qDeleteAll(m_arguments); } /******************************************************************************* @@ -157,593 +152,588 @@ AbstractMetaFunction::~AbstractMetaFunction() */ bool AbstractMetaFunction::isModifiedRemoved(int types) const { - FunctionModificationList mods = modifications(implementingClass()); - for (FunctionModification mod : mods) { - if (!mod.isRemoveModifier()) - continue; + FunctionModificationList mods = modifications(implementingClass()); + for (FunctionModification mod : mods) { + if (!mod.isRemoveModifier()) + continue; - if ((mod.removal & types) == types) - return true; - } + if ((mod.removal & types) == types) + return true; + } - return false; + return false; } bool AbstractMetaFunction::needsCallThrough() const { - if (ownerClass()->isInterface()) - return false; - if (referenceCounts(implementingClass()).size() > 0) - return true; - if (argumentsHaveNativeId() || !isStatic()) - return true; + if (ownerClass()->isInterface()) + return false; + if (referenceCounts(implementingClass()).size() > 0) + return true; + if (argumentsHaveNativeId() || !isStatic()) + return true; + + for (const AbstractMetaArgument* arg : arguments()) { + if (arg->type()->isArray() || arg->type()->isTargetLangEnum() || arg->type()->isTargetLangFlags()) + return true; + } - for (const AbstractMetaArgument* arg : arguments()) { - if (arg->type()->isArray() || arg->type()->isTargetLangEnum() || arg->type()->isTargetLangFlags()) - return true; - } + if (type() && (type()->isArray() || type()->isTargetLangEnum() || type()->isTargetLangFlags())) + return true; - if (type() && (type()->isArray() || type()->isTargetLangEnum() || type()->isTargetLangFlags())) - return true; - - for (int i=-1; i <= arguments().size(); ++i) { - TypeSystem::Ownership owner = this->ownership(implementingClass(), TypeSystem::TargetLangCode, i); - if (owner != TypeSystem::InvalidOwnership) - return true; - } + for (int i = -1; i <= arguments().size(); ++i) { + TypeSystem::Ownership owner = this->ownership(implementingClass(), TypeSystem::TargetLangCode, i); + if (owner != TypeSystem::InvalidOwnership) + return true; + } - return false; + return false; } bool AbstractMetaFunction::needsSuppressUncheckedWarning() const { - for (int i=-1; i<=arguments().size(); ++i) { - const QList referenceCounts = this->referenceCounts(implementingClass(), i); - for (const ReferenceCount& referenceCount : referenceCounts) { - if (referenceCount.action != ReferenceCount::Set) - return true; - } + for (int i = -1; i <= arguments().size(); ++i) { + const QList referenceCounts = this->referenceCounts(implementingClass(), i); + for (const ReferenceCount& referenceCount : referenceCounts) { + if (referenceCount.action != ReferenceCount::Set) + return true; } - return false; + } + return false; } QString AbstractMetaFunction::marshalledName() const { - QString returned = "__qt_" + name(); - AbstractMetaArgumentList arguments = this->arguments(); - for (const AbstractMetaArgument* arg : arguments) { - returned += "_"; - if (arg->type()->isNativePointer()) { - returned += "nativepointer"; - } else if (arg->type()->isIntegerEnum() || arg->type()->isIntegerFlags()) { - returned += "int"; - } else { - returned += arg->type()->name().replace("[]", "_3").replace(".", "_"); - } + QString returned = "__qt_" + name(); + AbstractMetaArgumentList arguments = this->arguments(); + for (const AbstractMetaArgument* arg : arguments) { + returned += "_"; + if (arg->type()->isNativePointer()) { + returned += "nativepointer"; + } else if (arg->type()->isIntegerEnum() || arg->type()->isIntegerFlags()) { + returned += "int"; + } else { + returned += arg->type()->name().replace("[]", "_3").replace(".", "_"); } - return returned; + } + return returned; } -bool AbstractMetaFunction::operator<(const AbstractMetaFunction &other) const +bool AbstractMetaFunction::operator<(const AbstractMetaFunction& other) const { - uint result = compareTo(&other); - return result & NameLessThan; + uint result = compareTo(&other); + return result & NameLessThan; } - /*! Returns a mask of CompareResult describing how this function is compares to another function */ -uint AbstractMetaFunction::compareTo(const AbstractMetaFunction *other) const +uint AbstractMetaFunction::compareTo(const AbstractMetaFunction* other) const { - uint result = 0; + uint result = 0; - // Enclosing class... - if (ownerClass() == other->ownerClass()) { - result |= EqualImplementor; - } + // Enclosing class... + if (ownerClass() == other->ownerClass()) { + result |= EqualImplementor; + } - // Attributes - if (attributes() == other->attributes()) { - result |= EqualAttributes; - } + // Attributes + if (attributes() == other->attributes()) { + result |= EqualAttributes; + } - // Compare types - AbstractMetaType::shared_pointer t = type(); - AbstractMetaType::shared_pointer ot = other->type(); - if ((!t && !ot) || ((t && ot && t->name() == ot->name()))) { - result |= EqualReturnType; - } + // Compare types + AbstractMetaType::shared_pointer t = type(); + AbstractMetaType::shared_pointer ot = other->type(); + if ((!t && !ot) || ((t && ot && t->name() == ot->name()))) { + result |= EqualReturnType; + } - // Compare names - int cmp = originalName().compare(other->originalName()); + // Compare names + int cmp = originalName().compare(other->originalName()); - if (cmp < 0) { - result |= NameLessThan; - } else if (cmp == 0) { - result |= EqualName; - } + if (cmp < 0) { + result |= NameLessThan; + } else if (cmp == 0) { + result |= EqualName; + } - // compare name after modification... - cmp = modifiedName().compare(other->modifiedName()); - if (cmp == 0) - result |= EqualModifiedName; + // compare name after modification... + cmp = modifiedName().compare(other->modifiedName()); + if (cmp == 0) + result |= EqualModifiedName; + + // Compare arguments... + AbstractMetaArgumentList min_arguments; + AbstractMetaArgumentList max_arguments; + if (arguments().size() < other->arguments().size()) { + min_arguments = arguments(); + max_arguments = other->arguments(); + } else { + min_arguments = other->arguments(); + max_arguments = arguments(); + } - // Compare arguments... - AbstractMetaArgumentList min_arguments; - AbstractMetaArgumentList max_arguments; - if (arguments().size() < other->arguments().size()) { - min_arguments = arguments(); - max_arguments = other->arguments(); + int min_count = min_arguments.size(); + int max_count = max_arguments.size(); + bool same = true; + for (int i = 0; i < max_count; ++i) { + if (i < min_count) { + const AbstractMetaArgument* min_arg = min_arguments.at(i); + const AbstractMetaArgument* max_arg = max_arguments.at(i); + if (min_arg->type()->name() != max_arg->type()->name() + && (min_arg->defaultValueExpression().isEmpty() || max_arg->defaultValueExpression().isEmpty())) + { + same = false; + break; + } } else { - min_arguments = other->arguments(); - max_arguments = arguments(); - } - - int min_count = min_arguments.size(); - int max_count = max_arguments.size(); - bool same = true; - for (int i=0; itype()->name() != max_arg->type()->name() - && (min_arg->defaultValueExpression().isEmpty() || max_arg->defaultValueExpression().isEmpty())) { - same = false; - break; - } - } else { - if (max_arguments.at(i)->defaultValueExpression().isEmpty()) { - same = false; - break; - } - } + if (max_arguments.at(i)->defaultValueExpression().isEmpty()) { + same = false; + break; + } } + } - if (same) - result |= min_count == max_count ? EqualArguments : EqualDefaultValueOverload; + if (same) + result |= min_count == max_count ? EqualArguments : EqualDefaultValueOverload; - return result; + return result; } -AbstractMetaFunction *AbstractMetaFunction::copy() const +AbstractMetaFunction* AbstractMetaFunction::copy() const { - AbstractMetaFunction *cpy = new AbstractMetaFunction; - cpy->setName(name()); - cpy->setOriginalName(originalName()); - cpy->setOwnerClass(ownerClass()); - cpy->setImplementingClass(implementingClass()); - cpy->setInterfaceClass(interfaceClass()); - cpy->setFunctionType(functionType()); - cpy->setAttributes(attributes()); - cpy->setDeclaringClass(declaringClass()); - if (type()) - cpy->setType(type()); - cpy->setConstant(isConstant()); - cpy->setConstexpr(isConstexpr()); - cpy->setAuto(isAuto()); - cpy->setException(exception()); - cpy->setOriginalAttributes(originalAttributes()); - - for (AbstractMetaArgument* arg : arguments()) { - cpy->addArgument(arg->copy()); - } + AbstractMetaFunction* cpy = new AbstractMetaFunction; + cpy->setName(name()); + cpy->setOriginalName(originalName()); + cpy->setOwnerClass(ownerClass()); + cpy->setImplementingClass(implementingClass()); + cpy->setInterfaceClass(interfaceClass()); + cpy->setFunctionType(functionType()); + cpy->setAttributes(attributes()); + cpy->setDeclaringClass(declaringClass()); + if (type()) + cpy->setType(type()); + cpy->setConstant(isConstant()); + cpy->setConstexpr(isConstexpr()); + cpy->setAuto(isAuto()); + cpy->setException(exception()); + cpy->setOriginalAttributes(originalAttributes()); + + for (AbstractMetaArgument* arg : arguments()) { + cpy->addArgument(arg->copy()); + } - Q_ASSERT((!type() && !cpy->type()) - || (type()->instantiations() == cpy->type()->instantiations())); + Q_ASSERT((!type() && !cpy->type()) || (type()->instantiations() == cpy->type()->instantiations())); - return cpy; + return cpy; } -QStringList AbstractMetaFunction::introspectionCompatibleSignatures(const QStringList &resolvedArguments) const +QStringList AbstractMetaFunction::introspectionCompatibleSignatures(const QStringList& resolvedArguments) const { - AbstractMetaArgumentList arguments = this->arguments(); - if (arguments.size() == resolvedArguments.size()) { - return (QStringList() << TypeSystem::normalizedSignature((name() + "(" + resolvedArguments.join(",") + ")").toUtf8().constData())); - } else { - QStringList returned; - - AbstractMetaArgument *argument = arguments.at(resolvedArguments.size()); - QStringList minimalTypeSignature = argument->type()->minimalSignature().split("::"); - for (int i=0; iarguments(); + if (arguments.size() == resolvedArguments.size()) { + return (QStringList() << TypeSystem::normalizedSignature( + (name() + "(" + resolvedArguments.join(",") + ")").toUtf8().constData())); + } else { + QStringList returned; - return returned; + AbstractMetaArgument* argument = arguments.at(resolvedArguments.size()); + QStringList minimalTypeSignature = argument->type()->minimalSignature().split("::"); + for (int i = 0; i < minimalTypeSignature.size(); ++i) { + returned += introspectionCompatibleSignatures( + QStringList(resolvedArguments) + << QStringList(minimalTypeSignature.mid(minimalTypeSignature.size() - i - 1)).join("::")); } + + return returned; + } } QString AbstractMetaFunction::signature() const { - QString s(m_original_name); + QString s(m_original_name); - s += "("; + s += "("; - for (int i=0; i 0) - s += ", "; - AbstractMetaArgument *a = m_arguments.at(i); - s += a->type()->cppSignature(); + for (int i = 0; i < m_arguments.count(); ++i) { + if (i > 0) + s += ", "; + AbstractMetaArgument* a = m_arguments.at(i); + s += a->type()->cppSignature(); - // We need to have the argument names in the qdoc files - s += " "; - s += a->argumentName(); - } - s += ")"; + // We need to have the argument names in the qdoc files + s += " "; + s += a->argumentName(); + } + s += ")"; - if (isConstant()) - s += " const"; + if (isConstant()) + s += " const"; - return s; + return s; } int AbstractMetaFunction::actualMinimumArgumentCount() const { - AbstractMetaArgumentList arguments = this->arguments(); + AbstractMetaArgumentList arguments = this->arguments(); - int count = 0; - for (int i=0; idefaultValueExpression().isEmpty()) break; - } + int count = 0; + for (int i = 0; i < arguments.size(); ++i && ++count) { + if (argumentRemoved(i + 1)) + --count; + else if (!arguments.at(i)->defaultValueExpression().isEmpty()) + break; + } - return count; + return count; } // Returns reference counts for argument at idx, or all arguments if idx == -2 -QList AbstractMetaFunction::referenceCounts(const AbstractMetaClass *cls, int idx) const +QList AbstractMetaFunction::referenceCounts(const AbstractMetaClass* cls, int idx) const { - QList returned; + QList returned; - const FunctionModificationList mods = this->modifications(cls); - for (const FunctionModification& mod : mods) { - QList argument_mods = mod.argument_mods; - for (ArgumentModification argument_mod : argument_mods) { - if (argument_mod.index != idx && idx != -2) - continue; - returned += argument_mod.referenceCounts; - } + const FunctionModificationList mods = this->modifications(cls); + for (const FunctionModification& mod : mods) { + QList argument_mods = mod.argument_mods; + for (ArgumentModification argument_mod : argument_mods) { + if (argument_mod.index != idx && idx != -2) + continue; + returned += argument_mod.referenceCounts; } + } - return returned; + return returned; } -QString AbstractMetaFunction::replacedDefaultExpression(const AbstractMetaClass *cls, int key) const +QString AbstractMetaFunction::replacedDefaultExpression(const AbstractMetaClass* cls, int key) const { - const FunctionModificationList modifications = this->modifications(cls); - for (const FunctionModification& modification : modifications) { - const QList argument_modifications = modification.argument_mods; - for (const ArgumentModification& argument_modification : argument_modifications) { - if (argument_modification.index == key - && !argument_modification.replaced_default_expression.isEmpty()) { - return argument_modification.replaced_default_expression; - } - } + const FunctionModificationList modifications = this->modifications(cls); + for (const FunctionModification& modification : modifications) { + const QList argument_modifications = modification.argument_mods; + for (const ArgumentModification& argument_modification : argument_modifications) { + if (argument_modification.index == key && !argument_modification.replaced_default_expression.isEmpty()) { + return argument_modification.replaced_default_expression; + } } + } - return QString(); + return QString(); } -bool AbstractMetaFunction::removedDefaultExpression(const AbstractMetaClass *cls, int key) const +bool AbstractMetaFunction::removedDefaultExpression(const AbstractMetaClass* cls, int key) const { - const FunctionModificationList modifications = this->modifications(cls); - for (const FunctionModification& modification : modifications) { - const QList argument_modifications = modification.argument_mods; - for (const ArgumentModification& argument_modification : argument_modifications) { - if (argument_modification.index == key - && argument_modification.removed_default_expression) { - return true; - } - } + const FunctionModificationList modifications = this->modifications(cls); + for (const FunctionModification& modification : modifications) { + const QList argument_modifications = modification.argument_mods; + for (const ArgumentModification& argument_modification : argument_modifications) { + if (argument_modification.index == key && argument_modification.removed_default_expression) { + return true; + } } + } - return false; + return false; } bool AbstractMetaFunction::resetObjectAfterUse(int argument_idx) const { - const AbstractMetaClass *cls = declaringClass(); - const FunctionModificationList modifications = this->modifications(cls); - for (const FunctionModification& modification : modifications) { - const QList argumentModifications = modification.argument_mods; - for (const ArgumentModification& argumentModification : argumentModifications) { - if (argumentModification.index == argument_idx && argumentModification.reset_after_use) - return true; - } + const AbstractMetaClass* cls = declaringClass(); + const FunctionModificationList modifications = this->modifications(cls); + for (const FunctionModification& modification : modifications) { + const QList argumentModifications = modification.argument_mods; + for (const ArgumentModification& argumentModification : argumentModifications) { + if (argumentModification.index == argument_idx && argumentModification.reset_after_use) + return true; } + } - return false; + return false; } -QString AbstractMetaFunction::nullPointerDefaultValue(const AbstractMetaClass *mainClass, int argument_idx) const +QString AbstractMetaFunction::nullPointerDefaultValue(const AbstractMetaClass* mainClass, int argument_idx) const { - Q_ASSERT(nullPointersDisabled(mainClass, argument_idx)); + Q_ASSERT(nullPointersDisabled(mainClass, argument_idx)); - const AbstractMetaClass *cls = mainClass; - if (cls == 0) - cls = implementingClass(); + const AbstractMetaClass* cls = mainClass; + if (cls == 0) + cls = implementingClass(); - do { - const FunctionModificationList modifications = this->modifications(cls); - for (const FunctionModification& modification : modifications) { - const QList argument_modifications = modification.argument_mods; - for (const ArgumentModification& argument_modification : argument_modifications) { - if (argument_modification.index == argument_idx - && argument_modification.no_null_pointers) { - return argument_modification.null_pointer_default_value; - } - } + do { + const FunctionModificationList modifications = this->modifications(cls); + for (const FunctionModification& modification : modifications) { + const QList argument_modifications = modification.argument_mods; + for (const ArgumentModification& argument_modification : argument_modifications) { + if (argument_modification.index == argument_idx && argument_modification.no_null_pointers) { + return argument_modification.null_pointer_default_value; } + } + } - cls = cls->baseClass(); - } while (cls != 0 && mainClass == 0); // Once when mainClass != 0, or once for all base classes of implementing class - - return QString(); + cls = cls->baseClass(); + } while (cls != 0 && mainClass == 0); // Once when mainClass != 0, or once for all base classes of implementing class + return QString(); } -bool AbstractMetaFunction::nullPointersDisabled(const AbstractMetaClass *mainClass, int argument_idx) const +bool AbstractMetaFunction::nullPointersDisabled(const AbstractMetaClass* mainClass, int argument_idx) const { - const AbstractMetaClass *cls = mainClass; - if (cls == 0) - cls = implementingClass(); + const AbstractMetaClass* cls = mainClass; + if (cls == 0) + cls = implementingClass(); - do { - const FunctionModificationList& modifications = this->modifications(cls); - for (const FunctionModification& modification : modifications) { - const QList argument_modifications = modification.argument_mods; - for (const ArgumentModification& argument_modification : argument_modifications) { - if (argument_modification.index == argument_idx - && argument_modification.no_null_pointers) { - return true; - } - } + do { + const FunctionModificationList& modifications = this->modifications(cls); + for (const FunctionModification& modification : modifications) { + const QList argument_modifications = modification.argument_mods; + for (const ArgumentModification& argument_modification : argument_modifications) { + if (argument_modification.index == argument_idx && argument_modification.no_null_pointers) { + return true; } + } + } - cls = cls->baseClass(); - } while (cls != 0 && mainClass == 0); // Once when mainClass != 0, or once for all base classes of implementing class + cls = cls->baseClass(); + } while (cls != 0 && mainClass == 0); // Once when mainClass != 0, or once for all base classes of implementing class - return false; + return false; } QString AbstractMetaFunction::conversionRule(TypeSystem::Language language, int key) const { - const FunctionModificationList modifications = this->modifications(declaringClass()); - for (const FunctionModification& modification : modifications) { - const QList argument_modifications = modification.argument_mods; - for (const ArgumentModification& argument_modification : argument_modifications) { - if (argument_modification.index != key) - continue; - - for (CodeSnip snip : argument_modification.conversion_rules) { - if (snip.language == language && !snip.code().isEmpty()) - return snip.code(); - } - } + const FunctionModificationList modifications = this->modifications(declaringClass()); + for (const FunctionModification& modification : modifications) { + const QList argument_modifications = modification.argument_mods; + for (const ArgumentModification& argument_modification : argument_modifications) { + if (argument_modification.index != key) + continue; + + for (CodeSnip snip : argument_modification.conversion_rules) { + if (snip.language == language && !snip.code().isEmpty()) + return snip.code(); + } } + } - return QString(); + return QString(); } QString AbstractMetaFunction::argumentReplaced(int key) const { - const FunctionModificationList modifications = this->modifications(declaringClass()); - for (const FunctionModification& modification : modifications) { - const QList argument_modifications = modification.argument_mods; - for (const ArgumentModification& argument_modification : argument_modifications) { - if (argument_modification.index == key && !argument_modification.replace_value.isEmpty()) { - return argument_modification.replace_value; - } - } + const FunctionModificationList modifications = this->modifications(declaringClass()); + for (const FunctionModification& modification : modifications) { + const QList argument_modifications = modification.argument_mods; + for (const ArgumentModification& argument_modification : argument_modifications) { + if (argument_modification.index == key && !argument_modification.replace_value.isEmpty()) { + return argument_modification.replace_value; + } } + } - return ""; + return ""; } bool AbstractMetaFunction::argumentRemoved(int key) const { - const FunctionModificationList modifications = this->modifications(declaringClass()); - for (const FunctionModification& modification : modifications) { - const QList argument_modifications = modification.argument_mods; - for (const ArgumentModification& argument_modification : argument_modifications) { - if (argument_modification.index == key) { - if (argument_modification.removed) { - return true; - } - } + const FunctionModificationList modifications = this->modifications(declaringClass()); + for (const FunctionModification& modification : modifications) { + const QList argument_modifications = modification.argument_mods; + for (const ArgumentModification& argument_modification : argument_modifications) { + if (argument_modification.index == key) { + if (argument_modification.removed) { + return true; } + } } + } - return false; + return false; } bool AbstractMetaFunction::isVirtualSlot() const { - const FunctionModificationList modifications = this->modifications(declaringClass()); - for (const FunctionModification& modification : modifications) { - if (modification.isVirtualSlot()) - return true; - } + const FunctionModificationList modifications = this->modifications(declaringClass()); + for (const FunctionModification& modification : modifications) { + if (modification.isVirtualSlot()) + return true; + } - return false; + return false; } -bool AbstractMetaFunction::disabledGarbageCollection(const AbstractMetaClass *cls, int key) const +bool AbstractMetaFunction::disabledGarbageCollection(const AbstractMetaClass* cls, int key) const { - const FunctionModificationList modifications = this->modifications(cls); - for (const FunctionModification& modification : modifications) { - const QList argument_modifications = modification.argument_mods; - for (const ArgumentModification& argument_modification : argument_modifications) { - if (argument_modification.index != key) - continue; - - for (const TypeSystem::Ownership& ownership : argument_modification.ownerships.values()) { - if (ownership == TypeSystem::CppOwnership) - return true; - } + const FunctionModificationList modifications = this->modifications(cls); + for (const FunctionModification& modification : modifications) { + const QList argument_modifications = modification.argument_mods; + for (const ArgumentModification& argument_modification : argument_modifications) { + if (argument_modification.index != key) + continue; - } + for (const TypeSystem::Ownership& ownership : argument_modification.ownerships.values()) { + if (ownership == TypeSystem::CppOwnership) + return true; + } } + } - return false; + return false; } bool AbstractMetaFunction::isDeprecated() const { - const FunctionModificationList modifications = this->modifications(declaringClass()); - for (const FunctionModification& modification : modifications) { - if (modification.isDeprecated()) - return true; - } - return false; + const FunctionModificationList modifications = this->modifications(declaringClass()); + for (const FunctionModification& modification : modifications) { + if (modification.isDeprecated()) + return true; + } + return false; } -TypeSystem::Ownership AbstractMetaFunction::ownership(const AbstractMetaClass *cls, TypeSystem::Language language, int key) const +TypeSystem::Ownership AbstractMetaFunction::ownership(const AbstractMetaClass* cls, TypeSystem::Language language, + int key) const { - const FunctionModificationList modifications = this->modifications(cls); - for (const FunctionModification& modification : modifications) { - const QList argument_modifications = modification.argument_mods; - for (const ArgumentModification& argument_modification : argument_modifications) { - if (argument_modification.index == key) - return argument_modification.ownerships.value(language, TypeSystem::InvalidOwnership); - } + const FunctionModificationList modifications = this->modifications(cls); + for (const FunctionModification& modification : modifications) { + const QList argument_modifications = modification.argument_mods; + for (const ArgumentModification& argument_modification : argument_modifications) { + if (argument_modification.index == key) + return argument_modification.ownerships.value(language, TypeSystem::InvalidOwnership); } + } - return TypeSystem::InvalidOwnership; + return TypeSystem::InvalidOwnership; } -bool AbstractMetaFunction::isRemovedFromAllLanguages(const AbstractMetaClass *cls) const +bool AbstractMetaFunction::isRemovedFromAllLanguages(const AbstractMetaClass* cls) const { - return isRemovedFrom(cls, TypeSystem::All); + return isRemovedFrom(cls, TypeSystem::All); } -bool AbstractMetaFunction::isRemovedFrom(const AbstractMetaClass *cls, TypeSystem::Language language) const +bool AbstractMetaFunction::isRemovedFrom(const AbstractMetaClass* cls, TypeSystem::Language language) const { - const FunctionModificationList modifications = this->modifications(cls); - for (const FunctionModification& modification : modifications) { - if ((modification.removal & language) == language) - return true; - } - - return false; + const FunctionModificationList modifications = this->modifications(cls); + for (const FunctionModification& modification : modifications) { + if ((modification.removal & language) == language) + return true; + } + return false; } QString AbstractMetaFunction::typeReplaced(int key) const { - const FunctionModificationList modifications = this->modifications(declaringClass()); - for (const FunctionModification& modification : modifications) { - const QList argument_modifications = modification.argument_mods; - for (const ArgumentModification& argument_modification : argument_modifications) { - if (argument_modification.index == key - && !argument_modification.modified_type.isEmpty()) { - return argument_modification.modified_type; - } - } + const FunctionModificationList modifications = this->modifications(declaringClass()); + for (const FunctionModification& modification : modifications) { + const QList argument_modifications = modification.argument_mods; + for (const ArgumentModification& argument_modification : argument_modifications) { + if (argument_modification.index == key && !argument_modification.modified_type.isEmpty()) { + return argument_modification.modified_type; + } } + } - return QString(); + return QString(); } QString AbstractMetaFunction::minimalSignature() const { - if (!m_cached_minimal_signature.isEmpty()) - return m_cached_minimal_signature; + if (!m_cached_minimal_signature.isEmpty()) + return m_cached_minimal_signature; - QString minimalSignature = originalName() + "("; - AbstractMetaArgumentList arguments = this->arguments(); + QString minimalSignature = originalName() + "("; + AbstractMetaArgumentList arguments = this->arguments(); - for (int i=0; itype(); + for (int i = 0; i < arguments.count(); ++i) { + AbstractMetaType::shared_pointer t = arguments.at(i)->type(); - if (i > 0) - minimalSignature += ","; + if (i > 0) + minimalSignature += ","; - minimalSignature += t->minimalSignature(); - } - minimalSignature += ")"; - if (isConstant()) - minimalSignature += "const"; + minimalSignature += t->minimalSignature(); + } + minimalSignature += ")"; + if (isConstant()) + minimalSignature += "const"; - minimalSignature = TypeSystem::normalizedSignature(minimalSignature.toLocal8Bit().constData()); - m_cached_minimal_signature = minimalSignature; + minimalSignature = TypeSystem::normalizedSignature(minimalSignature.toLocal8Bit().constData()); + m_cached_minimal_signature = minimalSignature; - return minimalSignature; + return minimalSignature; } -FunctionModificationList AbstractMetaFunction::modifications(const AbstractMetaClass *implementor) const +FunctionModificationList AbstractMetaFunction::modifications(const AbstractMetaClass* implementor) const { - Q_ASSERT(implementor); - return implementor->typeEntry()->functionModifications(minimalSignature()); + Q_ASSERT(implementor); + return implementor->typeEntry()->functionModifications(minimalSignature()); } -bool AbstractMetaFunction::hasModifications(const AbstractMetaClass *implementor) const +bool AbstractMetaFunction::hasModifications(const AbstractMetaClass* implementor) const { - FunctionModificationList mods = modifications(implementor); - return mods.count() > 0; + FunctionModificationList mods = modifications(implementor); + return mods.count() > 0; } QString AbstractMetaFunction::modifiedName() const { - if (m_cached_modified_name.isEmpty()) { - const FunctionModificationList mods = modifications(implementingClass()); - for (const FunctionModification& mod : mods) { - if (mod.isRenameModifier()) { - m_cached_modified_name = mod.renamedToName; - break; - } - } - if (m_cached_modified_name.isEmpty()) - m_cached_modified_name = name(); + if (m_cached_modified_name.isEmpty()) { + const FunctionModificationList mods = modifications(implementingClass()); + for (const FunctionModification& mod : mods) { + if (mod.isRenameModifier()) { + m_cached_modified_name = mod.renamedToName; + break; + } } - return m_cached_modified_name; + if (m_cached_modified_name.isEmpty()) + m_cached_modified_name = name(); + } + return m_cached_modified_name; } QString AbstractMetaFunction::targetLangSignature(bool minimal) const { - QString s; + QString s; - // Attributes... - if (!minimal) { - // Return type - if (type()) - s += type()->name() + " "; - else - s += "void "; - } + // Attributes... + if (!minimal) { + // Return type + if (type()) + s += type()->name() + " "; + else + s += "void "; + } - s += modifiedName(); - s += "("; + s += modifiedName(); + s += "("; - int j = 0; - for (int i=0; itype()->name(); + int j = 0; + for (int i = 0; i < m_arguments.size(); ++i) { + if (argumentRemoved(i + 1)) + continue; + if (j != 0) { + s += ","; + if (!minimal) + s += QLatin1Char(' '); + } + s += m_arguments.at(i)->type()->name(); - if (!minimal) { - s += " "; - s += m_arguments.at(i)->argumentName(); - } - ++j; + if (!minimal) { + s += " "; + s += m_arguments.at(i)->argumentName(); } + ++j; + } - s += ")"; + s += ")"; - return s; + return s; } - -bool function_sorter(AbstractMetaFunction *a, AbstractMetaFunction *b) +bool function_sorter(AbstractMetaFunction* a, AbstractMetaFunction* b) { - return a->signature() < b->signature(); + return a->signature() < b->signature(); } /******************************************************************************* @@ -751,9 +741,9 @@ bool function_sorter(AbstractMetaFunction *a, AbstractMetaFunction *b) */ AbstractMetaClass::~AbstractMetaClass() { - qDeleteAll(m_functions); - qDeleteAll(m_fields); - qDeleteAll(m_property_specs); + qDeleteAll(m_functions); + qDeleteAll(m_fields); + qDeleteAll(m_property_specs); } /*AbstractMetaClass *AbstractMetaClass::copy() const @@ -781,88 +771,88 @@ AbstractMetaClass::~AbstractMetaClass() /******************************************************************************* * Returns true if this class is a subclass of the given class */ -bool AbstractMetaClass::inheritsFrom(const AbstractMetaClass *cls) const +bool AbstractMetaClass::inheritsFrom(const AbstractMetaClass* cls) const { - Q_ASSERT(cls != 0); + Q_ASSERT(cls != 0); - const AbstractMetaClass *clazz = this; - while (clazz != 0) { - if (clazz == cls) - return true; + const AbstractMetaClass* clazz = this; + while (clazz != 0) { + if (clazz == cls) + return true; - clazz = clazz->baseClass(); - } + clazz = clazz->baseClass(); + } - return false; + return false; } /******************************************************************************* * Constructs an interface based on the functions and enums in this * class and returns it... */ -AbstractMetaClass *AbstractMetaClass::extractInterface() +AbstractMetaClass* AbstractMetaClass::extractInterface() { - Q_ASSERT(typeEntry()->designatedInterface()); + Q_ASSERT(typeEntry()->designatedInterface()); - if (m_extracted_interface == 0) { - AbstractMetaClass *iface = new AbstractMetaClass; - iface->setAttributes(attributes()); - iface->setBaseClass(0); - iface->setPrimaryInterfaceImplementor(this); + if (m_extracted_interface == 0) { + AbstractMetaClass* iface = new AbstractMetaClass; + iface->setAttributes(attributes()); + iface->setBaseClass(0); + iface->setPrimaryInterfaceImplementor(this); - iface->setTypeEntry(typeEntry()->designatedInterface()); + iface->setTypeEntry(typeEntry()->designatedInterface()); - for (const AbstractMetaFunction* function : functions()) { - if (!function->isConstructor()) - iface->addFunction(function->copy()); - } - -// iface->setEnums(enums()); -// setEnums(AbstractMetaEnumList()); + for (const AbstractMetaFunction* function : functions()) { + if (!function->isConstructor()) + iface->addFunction(function->copy()); + } - for (const AbstractMetaField* field : fields()) { - if (field->isPublic()) { - AbstractMetaField *new_field = field->copy(); - new_field->setEnclosingClass(iface); - iface->addField(new_field); - } - } + // iface->setEnums(enums()); + // setEnums(AbstractMetaEnumList()); - m_extracted_interface = iface; - addInterface(iface); + for (const AbstractMetaField* field : fields()) { + if (field->isPublic()) { + AbstractMetaField* new_field = field->copy(); + new_field->setEnclosingClass(iface); + iface->addField(new_field); + } } - return m_extracted_interface; + m_extracted_interface = iface; + addInterface(iface); + } + + return m_extracted_interface; } /******************************************************************************* * Returns a list of all the functions with a given name */ -AbstractMetaFunctionList AbstractMetaClass::queryFunctionsByName(const QString &name) const +AbstractMetaFunctionList AbstractMetaClass::queryFunctionsByName(const QString& name) const { - AbstractMetaFunctionList returned; - AbstractMetaFunctionList functions = this->functions(); - for (AbstractMetaFunction* function : functions) { - if (function->name() == name) - returned.append(function); - } + AbstractMetaFunctionList returned; + AbstractMetaFunctionList functions = this->functions(); + for (AbstractMetaFunction* function : functions) { + if (function->name() == name) + returned.append(function); + } - return returned; + return returned; } QString AbstractMetaClass::getDefaultNonZeroFunction() const { - for (const AbstractMetaFunction* fun : queryFunctionsByName("isEmpty")) { - if (fun->actualMinimumArgumentCount()==0 && fun->isPublic()) { + for (const AbstractMetaFunction* fun : queryFunctionsByName("isEmpty")) { + if (fun->actualMinimumArgumentCount() == 0 && fun->isPublic()) { return "isEmpty"; } } - for (const AbstractMetaFunction* fun : queryFunctionsByName("isValid")) { + for (const AbstractMetaFunction* fun : queryFunctionsByName("isValid")) { if (fun->actualMinimumArgumentCount() == 0 && fun->isPublic()) { return "isValid"; } } - for (const AbstractMetaFunction* fun : queryFunctionsByName("isNull")) { + for (const AbstractMetaFunction* fun : queryFunctionsByName("isNull")) { if (fun->actualMinimumArgumentCount() == 0 && fun->isPublic()) { return "isNull"; } @@ -875,14 +865,14 @@ QString AbstractMetaClass::getDefaultNonZeroFunction() const */ QList AbstractMetaClass::referenceCounts() const { - QList returned; + QList returned; - AbstractMetaFunctionList functions = this->functions(); - for (const AbstractMetaFunction* function : functions) { - returned += function->referenceCounts(this); - } + AbstractMetaFunctionList functions = this->functions(); + for (const AbstractMetaFunction* function : functions) { + returned += function->referenceCounts(this); + } - return returned; + return returned; } /******************************************************************************* @@ -891,56 +881,56 @@ QList AbstractMetaClass::referenceCounts() const */ AbstractMetaFunctionList AbstractMetaClass::functionsInTargetLang() const { - int default_flags = NormalFunctions | Visible | NotRemovedFromTargetLang; + int default_flags = NormalFunctions | Visible | NotRemovedFromTargetLang; - // Interfaces don't implement functions - default_flags |= isInterface() ? 0 : ClassImplements; + // Interfaces don't implement functions + default_flags |= isInterface() ? 0 : ClassImplements; - // Only public functions in final classes - // default_flags |= isFinal() ? WasPublic : 0; - int public_flags = isFinal() ? WasPublic : 0; + // Only public functions in final classes + // default_flags |= isFinal() ? WasPublic : 0; + int public_flags = isFinal() ? WasPublic : 0; - // Constructors - AbstractMetaFunctionList returned = queryFunctions(Constructors | default_flags | public_flags); + // Constructors + AbstractMetaFunctionList returned = queryFunctions(Constructors | default_flags | public_flags); - // Final functions - returned += queryFunctions(FinalInTargetLangFunctions | NonStaticFunctions | default_flags | public_flags); + // Final functions + returned += queryFunctions(FinalInTargetLangFunctions | NonStaticFunctions | default_flags | public_flags); - // Virtual functions - returned += queryFunctions(VirtualInTargetLangFunctions | NonStaticFunctions | default_flags | public_flags); + // Virtual functions + returned += queryFunctions(VirtualInTargetLangFunctions | NonStaticFunctions | default_flags | public_flags); - // Static functions - returned += queryFunctions(StaticFunctions | default_flags | public_flags); + // Static functions + returned += queryFunctions(StaticFunctions | default_flags | public_flags); - // Empty, private functions, since they aren't caught by the other ones - returned += queryFunctions(Empty | Invisible); + // Empty, private functions, since they aren't caught by the other ones + returned += queryFunctions(Empty | Invisible); - return returned; + return returned; } AbstractMetaFunctionList AbstractMetaClass::virtualFunctions() const { - const AbstractMetaFunctionList list = functionsInShellClass(); + const AbstractMetaFunctionList list = functionsInShellClass(); - AbstractMetaFunctionList returned; - for (AbstractMetaFunction* f : list) { - if (!f->isFinalInCpp() || f->isVirtualSlot()) - returned += f; - } + AbstractMetaFunctionList returned; + for (AbstractMetaFunction* f : list) { + if (!f->isFinalInCpp() || f->isVirtualSlot()) + returned += f; + } - return returned; + return returned; } AbstractMetaFunctionList AbstractMetaClass::nonVirtualShellFunctions() const { - AbstractMetaFunctionList list = functionsInShellClass(); - AbstractMetaFunctionList returned; - for (AbstractMetaFunction* f : list) { - if (f->isFinalInCpp() && !f->isVirtualSlot()) - returned += f; - } + AbstractMetaFunctionList list = functionsInShellClass(); + AbstractMetaFunctionList returned; + for (AbstractMetaFunction* f : list) { + if (f->isFinalInCpp() && !f->isVirtualSlot()) + returned += f; + } - return returned; + return returned; } /******************************************************************************* @@ -949,20 +939,20 @@ AbstractMetaFunctionList AbstractMetaClass::nonVirtualShellFunctions() const */ AbstractMetaFunctionList AbstractMetaClass::functionsInShellClass() const { - // Only functions and only protected and public functions - int default_flags = NormalFunctions | Visible | WasVisible | NotRemovedFromShell; + // Only functions and only protected and public functions + int default_flags = NormalFunctions | Visible | WasVisible | NotRemovedFromShell; - // All virtual functions - AbstractMetaFunctionList returned = queryFunctions(VirtualFunctions | default_flags); + // All virtual functions + AbstractMetaFunctionList returned = queryFunctions(VirtualFunctions | default_flags); - // All functions explicitly set to be implemented by the shell class - // (mainly superclass functions that are hidden by other declarations) - returned += queryFunctions(ForcedShellFunctions | default_flags); + // All functions explicitly set to be implemented by the shell class + // (mainly superclass functions that are hidden by other declarations) + returned += queryFunctions(ForcedShellFunctions | default_flags); - // All functions explicitly set to be virtual slots - returned += queryFunctions(VirtualSlots | default_flags); + // All functions explicitly set to be virtual slots + returned += queryFunctions(VirtualSlots | default_flags); - return returned; + return returned; } /******************************************************************************* @@ -972,153 +962,148 @@ AbstractMetaFunctionList AbstractMetaClass::functionsInShellClass() const */ AbstractMetaFunctionList AbstractMetaClass::publicOverrideFunctions() const { - return queryFunctions(NormalFunctions | WasProtected | FinalInCppFunctions | NotRemovedFromTargetLang) + return queryFunctions(NormalFunctions | WasProtected | FinalInCppFunctions | NotRemovedFromTargetLang) + queryFunctions(Signals | WasProtected | FinalInCppFunctions | NotRemovedFromTargetLang); } AbstractMetaFunctionList AbstractMetaClass::virtualOverrideFunctions() const { - return queryFunctions(NormalFunctions | NonEmptyFunctions | Visible | VirtualInCppFunctions | NotRemovedFromShell) + - queryFunctions(Signals | NonEmptyFunctions | Visible | VirtualInCppFunctions | NotRemovedFromShell); + return queryFunctions(NormalFunctions | NonEmptyFunctions | Visible | VirtualInCppFunctions | NotRemovedFromShell) + + queryFunctions(Signals | NonEmptyFunctions | Visible | VirtualInCppFunctions | NotRemovedFromShell); } void AbstractMetaClass::sortFunctions() { - std::sort(m_functions.begin(), m_functions.end(), function_sorter); + std::sort(m_functions.begin(), m_functions.end(), function_sorter); } -void AbstractMetaClass::setFunctions(const AbstractMetaFunctionList &functions) +void AbstractMetaClass::setFunctions(const AbstractMetaFunctionList& functions) { - m_functions = functions; + m_functions = functions; - // Functions must be sorted by name before next loop - sortFunctions(); + // Functions must be sorted by name before next loop + sortFunctions(); - QString currentName; - bool hasVirtuals = false; - AbstractMetaFunctionList final_functions; - for (AbstractMetaFunction* f : m_functions) { - f->setOwnerClass(this); - - m_has_virtual_slots |= f->isVirtualSlot(); - m_has_virtuals |= !f->isFinal() || f->isVirtualSlot(); - m_has_nonpublic |= !f->isPublic(); + QString currentName; + bool hasVirtuals = false; + AbstractMetaFunctionList final_functions; + for (AbstractMetaFunction* f : m_functions) { + f->setOwnerClass(this); - // If we have non-virtual overloads of a virtual function, we have to implement - // all the overloads in the shell class to override the hiding rule - if (currentName == f->name()) { - hasVirtuals = hasVirtuals || !f->isFinal(); - if (f->isFinal()) - final_functions += f; - } else { - if (hasVirtuals && final_functions.size() > 0) { - for (AbstractMetaFunction* final_function : final_functions) { - *final_function += AbstractMetaAttributes::ForceShellImplementation; + m_has_virtual_slots |= f->isVirtualSlot(); + m_has_virtuals |= !f->isFinal() || f->isVirtualSlot(); + m_has_nonpublic |= !f->isPublic(); - QString warn = QString("hiding of function '%1' in class '%2'") - .arg(final_function->name()).arg(name()); - ReportHandler::warning(warn); - } - } + // If we have non-virtual overloads of a virtual function, we have to implement + // all the overloads in the shell class to override the hiding rule + if (currentName == f->name()) { + hasVirtuals = hasVirtuals || !f->isFinal(); + if (f->isFinal()) + final_functions += f; + } else { + if (hasVirtuals && final_functions.size() > 0) { + for (AbstractMetaFunction* final_function : final_functions) { + *final_function += AbstractMetaAttributes::ForceShellImplementation; - hasVirtuals = !f->isFinal(); - final_functions.clear(); - if (f->isFinal()) - final_functions += f; - currentName = f->name(); + QString warn = QString("hiding of function '%1' in class '%2'").arg(final_function->name()).arg(name()); + ReportHandler::warning(warn); } + } + + hasVirtuals = !f->isFinal(); + final_functions.clear(); + if (f->isFinal()) + final_functions += f; + currentName = f->name(); } + } #ifndef QT_NO_DEBUG - bool duplicate_function = false; - for (int j=0; jmodifications(m_functions.at(j)->implementingClass()); - - bool removed = false; - for (const FunctionModification& mod : mods) { - if (mod.isRemoveModifier()) { - removed = true; - break ; - } - } - if (removed) - continue ; - - for (int i=0; imodifications(m_functions.at(i)->implementingClass()); - bool removed = false; - for (const FunctionModification& mod : mods) { - if (mod.isRemoveModifier()) { - removed = true; - break ; - } - } - if (removed) - continue ; - - uint cmp = m_functions.at(i)->compareTo(m_functions.at(j)); - if ((cmp & AbstractMetaFunction::EqualName) && (cmp & AbstractMetaFunction::EqualArguments)) { - printf("%s.%s mostly equal to %s.%s\n", - qPrintable(m_functions.at(i)->implementingClass()->typeEntry()->qualifiedCppName()), - qPrintable(m_functions.at(i)->signature()), - qPrintable(m_functions.at(j)->implementingClass()->typeEntry()->qualifiedCppName()), - qPrintable(m_functions.at(j)->signature())); - duplicate_function = true; - } - } + bool duplicate_function = false; + for (int j = 0; j < m_functions.size(); ++j) { + FunctionModificationList mods = m_functions.at(j)->modifications(m_functions.at(j)->implementingClass()); + + bool removed = false; + for (const FunctionModification& mod : mods) { + if (mod.isRemoveModifier()) { + removed = true; + break; + } + } + if (removed) + continue; + + for (int i = 0; i < m_functions.size() - 1; ++i) { + if (j == i) + continue; + + mods = m_functions.at(i)->modifications(m_functions.at(i)->implementingClass()); + bool removed = false; + for (const FunctionModification& mod : mods) { + if (mod.isRemoveModifier()) { + removed = true; + break; + } + } + if (removed) + continue; + + uint cmp = m_functions.at(i)->compareTo(m_functions.at(j)); + if ((cmp & AbstractMetaFunction::EqualName) && (cmp & AbstractMetaFunction::EqualArguments)) { + printf("%s.%s mostly equal to %s.%s\n", + qPrintable(m_functions.at(i)->implementingClass()->typeEntry()->qualifiedCppName()), + qPrintable(m_functions.at(i)->signature()), + qPrintable(m_functions.at(j)->implementingClass()->typeEntry()->qualifiedCppName()), + qPrintable(m_functions.at(j)->signature())); + duplicate_function = true; + } } - //Q_ASSERT(!duplicate_function); + } + //Q_ASSERT(!duplicate_function); #endif } bool AbstractMetaClass::hasFieldAccessors() const { - for (const AbstractMetaField* field : fields()) { - if (field->getter() || field->setter()) - return true; - } + for (const AbstractMetaField* field : fields()) { + if (field->getter() || field->setter()) + return true; + } - return false; + return false; } bool AbstractMetaClass::hasDefaultToStringFunction() const { - for (AbstractMetaFunction* f : queryFunctionsByName("toString")) { - if (f->actualMinimumArgumentCount() == 0) { - return true; - } - + for (AbstractMetaFunction* f : queryFunctionsByName("toString")) { + if (f->actualMinimumArgumentCount() == 0) { + return true; } - return false; + } + return false; } -void AbstractMetaClass::addFunction(AbstractMetaFunction *function, bool check_duplicates) +void AbstractMetaClass::addFunction(AbstractMetaFunction* function, bool check_duplicates) { - function->setOwnerClass(this); - - if (check_duplicates) { - for (const auto f : m_functions) { - if (f->name() == function->name() && - f->minimalSignature() == function->minimalSignature()) - { - return; - } - } - } + function->setOwnerClass(this); - if (!function->isDestructor()) { - m_functions << function; - // seems like this is not needed and takes a lot of performance - //std::sort(m_functions.begin(), m_functions.end(), function_sorter); + if (check_duplicates) { + for (const auto f : m_functions) { + if (f->name() == function->name() && f->minimalSignature() == function->minimalSignature()) { + return; + } } + } + if (!function->isDestructor()) { + m_functions << function; + // seems like this is not needed and takes a lot of performance + //std::sort(m_functions.begin(), m_functions.end(), function_sorter); + } - m_has_virtual_slots |= function->isVirtualSlot(); - m_has_virtuals |= !function->isFinal() || function->isVirtualSlot(); - m_has_nonpublic |= !function->isPublic(); + m_has_virtual_slots |= function->isVirtualSlot(); + m_has_virtuals |= !function->isFinal() || function->isVirtualSlot(); + m_has_nonpublic |= !function->isPublic(); } void AbstractMetaClass::removeFunction(AbstractMetaFunction* function) @@ -1126,31 +1111,30 @@ void AbstractMetaClass::removeFunction(AbstractMetaFunction* function) m_functions.removeOne(function); } -bool AbstractMetaClass::hasSignal(const AbstractMetaFunction *other) const +bool AbstractMetaClass::hasSignal(const AbstractMetaFunction* other) const { - if (!other->isSignal()) - return false; + if (!other->isSignal()) + return false; - for (const AbstractMetaFunction* f : functions()) { - if (f->isSignal() && f->compareTo(other) & AbstractMetaFunction::EqualName) - return other->modifiedName() == f->modifiedName(); - } + for (const AbstractMetaFunction* f : functions()) { + if (f->isSignal() && f->compareTo(other) & AbstractMetaFunction::EqualName) + return other->modifiedName() == f->modifiedName(); + } - return false; + return false; } - QString AbstractMetaClass::name() const { - return QString(m_type_entry->targetLangName()).replace("::", "__"); + return QString(m_type_entry->targetLangName()).replace("::", "__"); } -bool AbstractMetaClass::hasFunction(const QString &str) const +bool AbstractMetaClass::hasFunction(const QString& str) const { - for (const AbstractMetaFunction* f : functions()) - if (f->name() == str) - return true; - return false; + for (const AbstractMetaFunction* f : functions()) + if (f->name() == str) + return true; + return false; } /* Returns true if this class has one or more functions that are @@ -1158,92 +1142,88 @@ bool AbstractMetaClass::hasFunction(const QString &str) const shell class with public accessors to the protected functions, so they can be called from the native functions. */ -bool AbstractMetaClass::hasProtectedFunctions() const { - for (AbstractMetaFunction* func : m_functions) { - if (func->isProtected()) - return true; - } - return false; +bool AbstractMetaClass::hasProtectedFunctions() const +{ + for (AbstractMetaFunction* func : m_functions) { + if (func->isProtected()) + return true; + } + return false; } bool AbstractMetaClass::generateShellClass() const { - return typeEntry()->shouldCreateShell() && ( m_force_shell_class || - (!isFinal() - && (hasVirtualFunctions() - || hasProtectedFunctions() - || hasFieldAccessors()))); + return typeEntry()->shouldCreateShell() + && (m_force_shell_class + || (!isFinal() && (hasVirtualFunctions() || hasProtectedFunctions() || hasFieldAccessors()))); } -QPropertySpec *AbstractMetaClass::propertySpecForRead(const QString &name) const +QPropertySpec* AbstractMetaClass::propertySpecForRead(const QString& name) const { - for (int i=0; iread()) - return m_property_specs.at(i); - return 0; + for (int i = 0; i < m_property_specs.size(); ++i) + if (name == m_property_specs.at(i)->read()) + return m_property_specs.at(i); + return 0; } -QPropertySpec *AbstractMetaClass::propertySpecForWrite(const QString &name) const +QPropertySpec* AbstractMetaClass::propertySpecForWrite(const QString& name) const { - for (int i=0; iwrite()) - return m_property_specs.at(i); - return 0; + for (int i = 0; i < m_property_specs.size(); ++i) + if (name == m_property_specs.at(i)->write()) + return m_property_specs.at(i); + return 0; } -QPropertySpec *AbstractMetaClass::propertySpecForReset(const QString &name) const +QPropertySpec* AbstractMetaClass::propertySpecForReset(const QString& name) const { - for (int i=0; ireset()) - return m_property_specs.at(i); - } - return 0; + for (int i = 0; i < m_property_specs.size(); ++i) { + if (name == m_property_specs.at(i)->reset()) + return m_property_specs.at(i); + } + return 0; } bool AbstractMetaClass::hasVirtualDestructor() const { - if (m_has_virtual_destructor) { + if (m_has_virtual_destructor) { + return true; + } else { + // check all super classes + for (int i = 0; i < m_super_classes.size(); ++i) { + AbstractMetaClass* super_class = m_super_classes.at(i); + if (super_class->hasVirtualDestructor()) { return true; + } } - else { - // check all super classes - for (int i = 0; i < m_super_classes.size(); ++i) { - AbstractMetaClass* super_class = m_super_classes.at(i); - if (super_class->hasVirtualDestructor()) { - return true; - } - } - } - return false; + } + return false; } - - -static bool functions_contains(const AbstractMetaFunctionList &l, const AbstractMetaFunction *func) +static bool functions_contains(const AbstractMetaFunctionList& l, const AbstractMetaFunction* func) { - for (const AbstractMetaFunction* f : l) { - if ((f->compareTo(func) & AbstractMetaFunction::PrettySimilar) == AbstractMetaFunction::PrettySimilar) - return true; - } - return false; + for (const AbstractMetaFunction* f : l) { + if ((f->compareTo(func) & AbstractMetaFunction::PrettySimilar) == AbstractMetaFunction::PrettySimilar) + return true; + } + return false; } AbstractMetaField::~AbstractMetaField() { - delete m_setter; - delete m_getter; + delete m_setter; + delete m_getter; } -ushort painters; // refcount -AbstractMetaField *AbstractMetaField::copy() const +ushort painters; // refcount +AbstractMetaField* AbstractMetaField::copy() const { - AbstractMetaField *returned = new AbstractMetaField; - returned->setEnclosingClass(0); - returned->setAttributes(attributes()); - returned->setName(name()); - returned->setType(type()); - returned->setOriginalAttributes(originalAttributes()); + AbstractMetaField* returned = new AbstractMetaField; + returned->setEnclosingClass(0); + returned->setAttributes(attributes()); + returned->setName(name()); + returned->setType(type()); + returned->setOriginalAttributes(originalAttributes()); - return returned; + return returned; } /* UNUSED static QString upCaseFirst(const QString &str) { @@ -1253,118 +1233,109 @@ static QString upCaseFirst(const QString &str) { return s; } */ -static AbstractMetaFunction *createXetter(const AbstractMetaField *g, const QString &name, uint type) { - AbstractMetaFunction *f = new AbstractMetaFunction; - - - - f->setName(name); - f->setOriginalName(name); - f->setOwnerClass(g->enclosingClass()); - f->setImplementingClass(g->enclosingClass()); - f->setDeclaringClass(g->enclosingClass()); +static AbstractMetaFunction* createXetter(const AbstractMetaField* g, const QString& name, uint type) +{ + AbstractMetaFunction* f = new AbstractMetaFunction; - uint attr = AbstractMetaAttributes::Native - | AbstractMetaAttributes::Final - | type; - if (g->isStatic()) - attr |= AbstractMetaAttributes::Static; - if (g->isPublic()) - attr |= AbstractMetaAttributes::Public; - else if (g->isProtected()) - attr |= AbstractMetaAttributes::Protected; - else - attr |= AbstractMetaAttributes::Private; - f->setAttributes(attr); - f->setOriginalAttributes(attr); - - const FieldModificationList mods = g->modifications(); - for (const FieldModification& mod : mods) { - if (mod.isRenameModifier()) - f->setName(mod.renamedTo()); - if (mod.isAccessModifier()) { - if (mod.isPrivate()) - f->setVisibility(AbstractMetaAttributes::Private); - else if (mod.isProtected()) - f->setVisibility(AbstractMetaAttributes::Protected); - else if (mod.isPublic()) - f->setVisibility(AbstractMetaAttributes::Public); - else if (mod.isFriendly()) - f->setVisibility(AbstractMetaAttributes::Friendly); - } + f->setName(name); + f->setOriginalName(name); + f->setOwnerClass(g->enclosingClass()); + f->setImplementingClass(g->enclosingClass()); + f->setDeclaringClass(g->enclosingClass()); + uint attr = AbstractMetaAttributes::Native | AbstractMetaAttributes::Final | type; + if (g->isStatic()) + attr |= AbstractMetaAttributes::Static; + if (g->isPublic()) + attr |= AbstractMetaAttributes::Public; + else if (g->isProtected()) + attr |= AbstractMetaAttributes::Protected; + else + attr |= AbstractMetaAttributes::Private; + f->setAttributes(attr); + f->setOriginalAttributes(attr); + + const FieldModificationList mods = g->modifications(); + for (const FieldModification& mod : mods) { + if (mod.isRenameModifier()) + f->setName(mod.renamedTo()); + if (mod.isAccessModifier()) { + if (mod.isPrivate()) + f->setVisibility(AbstractMetaAttributes::Private); + else if (mod.isProtected()) + f->setVisibility(AbstractMetaAttributes::Protected); + else if (mod.isPublic()) + f->setVisibility(AbstractMetaAttributes::Public); + else if (mod.isFriendly()) + f->setVisibility(AbstractMetaAttributes::Friendly); } - return f; + } + return f; } FieldModificationList AbstractMetaField::modifications() const { - FieldModificationList mods = enclosingClass()->typeEntry()->fieldModifications(); - FieldModificationList returned; + FieldModificationList mods = enclosingClass()->typeEntry()->fieldModifications(); + FieldModificationList returned; - for (FieldModification mod : mods) { - if (mod.name == name()) - returned += mod; - } + for (FieldModification mod : mods) { + if (mod.name == name()) + returned += mod; + } - return returned; + return returned; } -const AbstractMetaFunction *AbstractMetaField::setter() const +const AbstractMetaFunction* AbstractMetaField::setter() const { - if (m_setter == 0) { - m_setter = createXetter(this, - name(), - AbstractMetaAttributes::SetterFunction); - AbstractMetaArgumentList arguments; - AbstractMetaArgument *argument = new AbstractMetaArgument; - argument->setType(type()); - argument->setName(name()); - arguments.append(argument); - m_setter->setArguments(arguments); - } - return m_setter; + if (m_setter == 0) { + m_setter = createXetter(this, name(), AbstractMetaAttributes::SetterFunction); + AbstractMetaArgumentList arguments; + AbstractMetaArgument* argument = new AbstractMetaArgument; + argument->setType(type()); + argument->setName(name()); + arguments.append(argument); + m_setter->setArguments(arguments); + } + return m_setter; } -const AbstractMetaFunction *AbstractMetaField::getter() const +const AbstractMetaFunction* AbstractMetaField::getter() const { - if (m_getter == 0) { - m_getter = createXetter(this, - name(), - AbstractMetaAttributes::GetterFunction); - m_getter->setType(type()); - } + if (m_getter == 0) { + m_getter = createXetter(this, name(), AbstractMetaAttributes::GetterFunction); + m_getter->setType(type()); + } - return m_getter; + return m_getter; } - bool AbstractMetaClass::hasConstructors() const { - return queryFunctions(Constructors).size() != 0; + return queryFunctions(Constructors).size() != 0; } void AbstractMetaClass::addDefaultConstructor() { - AbstractMetaFunction *f = new AbstractMetaFunction; - f->setName(name()); - f->setOwnerClass(this); - f->setFunctionType(AbstractMetaFunction::ConstructorFunction); - f->setArguments(AbstractMetaArgumentList()); - f->setDeclaringClass(this); + AbstractMetaFunction* f = new AbstractMetaFunction; + f->setName(name()); + f->setOwnerClass(this); + f->setFunctionType(AbstractMetaFunction::ConstructorFunction); + f->setArguments(AbstractMetaArgumentList()); + f->setDeclaringClass(this); - uint attr = AbstractMetaAttributes::Native; - attr |= AbstractMetaAttributes::Public; - f->setAttributes(attr); - f->setImplementingClass(this); - f->setOriginalAttributes(f->attributes()); + uint attr = AbstractMetaAttributes::Native; + attr |= AbstractMetaAttributes::Public; + f->setAttributes(attr); + f->setImplementingClass(this); + f->setOriginalAttributes(f->attributes()); - addFunction(f); + addFunction(f); } -bool AbstractMetaClass::hasFunction(const AbstractMetaFunction *f) const +bool AbstractMetaClass::hasFunction(const AbstractMetaFunction* f) const { - return functions_contains(m_functions, f); + return functions_contains(m_functions, f); } /* Goes through the list of functions and returns a list of all @@ -1373,450 +1344,443 @@ bool AbstractMetaClass::hasFunction(const AbstractMetaFunction *f) const AbstractMetaFunctionList AbstractMetaClass::queryFunctions(uint query) const { - AbstractMetaFunctionList functions; + AbstractMetaFunctionList functions; - for (AbstractMetaFunction* f : m_functions) { + for (AbstractMetaFunction* f : m_functions) { - if ((query & VirtualSlots) && !f->isVirtualSlot()) - continue; + if ((query & VirtualSlots) && !f->isVirtualSlot()) + continue; - if ((query & NotRemovedFromTargetLang) && f->isRemovedFrom(f->implementingClass(), TypeSystem::TargetLangCode)) { - continue; - } + if ((query & NotRemovedFromTargetLang) && f->isRemovedFrom(f->implementingClass(), TypeSystem::TargetLangCode)) { + continue; + } - if ((query & NotRemovedFromTargetLang) && !f->isFinal() && f->isRemovedFrom(f->declaringClass(), TypeSystem::TargetLangCode)) { - continue; - } + if ((query & NotRemovedFromTargetLang) && !f->isFinal() + && f->isRemovedFrom(f->declaringClass(), TypeSystem::TargetLangCode)) + { + continue; + } - if ((query & NotRemovedFromShell) && f->isRemovedFrom(f->implementingClass(), TypeSystem::ShellCode)) { - continue; - } + if ((query & NotRemovedFromShell) && f->isRemovedFrom(f->implementingClass(), TypeSystem::ShellCode)) { + continue; + } - if ((query & NotRemovedFromShell) && !f->isFinal() && f->isRemovedFrom(f->declaringClass(), TypeSystem::ShellCode)) { - continue; - } + if ((query & NotRemovedFromShell) && !f->isFinal() && f->isRemovedFrom(f->declaringClass(), TypeSystem::ShellCode)) + { + continue; + } - if ((query & Visible) && f->isPrivate()) { - continue; - } + if ((query & Visible) && f->isPrivate()) { + continue; + } - if ((query & VirtualInTargetLangFunctions) && f->isFinalInTargetLang()) { - continue; - } + if ((query & VirtualInTargetLangFunctions) && f->isFinalInTargetLang()) { + continue; + } - if ((query & Invisible) && !f->isPrivate()) { - continue; - } + if ((query & Invisible) && !f->isPrivate()) { + continue; + } - if ((query & Empty) && !f->isEmptyFunction()) { - continue; - } + if ((query & Empty) && !f->isEmptyFunction()) { + continue; + } - if ((query & WasPublic) && !f->wasPublic()) { - continue; - } + if ((query & WasPublic) && !f->wasPublic()) { + continue; + } - if ((query & WasVisible) && f->wasPrivate()) { - continue; - } + if ((query & WasVisible) && f->wasPrivate()) { + continue; + } - if ((query & WasProtected) && !f->wasProtected()) { - continue; - } + if ((query & WasProtected) && !f->wasProtected()) { + continue; + } - if ((query & ClassImplements) && f->ownerClass() != f->implementingClass()) { - continue; - } + if ((query & ClassImplements) && f->ownerClass() != f->implementingClass()) { + continue; + } - if ((query & Inconsistent) && (f->isFinalInTargetLang() || !f->isFinalInCpp() || f->isStatic())) { - continue; - } + if ((query & Inconsistent) && (f->isFinalInTargetLang() || !f->isFinalInCpp() || f->isStatic())) { + continue; + } - if ((query & FinalInTargetLangFunctions) && !f->isFinalInTargetLang()) { - continue; - } + if ((query & FinalInTargetLangFunctions) && !f->isFinalInTargetLang()) { + continue; + } - if ((query & FinalInCppFunctions) && !f->isFinalInCpp()) { - continue; - } + if ((query & FinalInCppFunctions) && !f->isFinalInCpp()) { + continue; + } - if ((query & VirtualInCppFunctions) && f->isFinalInCpp()) { - continue; - } + if ((query & VirtualInCppFunctions) && f->isFinalInCpp()) { + continue; + } - if ((query & Signals) && (!f->isSignal())) { - continue; - } + if ((query & Signals) && (!f->isSignal())) { + continue; + } - if ((query & ForcedShellFunctions) - && (!f->isForcedShellImplementation() - || !f->isFinal())) { - continue; - } + if ((query & ForcedShellFunctions) && (!f->isForcedShellImplementation() || !f->isFinal())) { + continue; + } - if (((query & Constructors) && (!f->isConstructor() - || f->ownerClass() != f->implementingClass())) - || (f->isConstructor() && (query & Constructors) == 0)) { - continue; - } + if (((query & Constructors) && (!f->isConstructor() || f->ownerClass() != f->implementingClass())) + || (f->isConstructor() && (query & Constructors) == 0)) + { + continue; + } - // Destructors are never included in the functions of a class currently - /* + // Destructors are never included in the functions of a class currently + /* if ((query & Destructors) && (!f->isDestructor() || f->ownerClass() != f->implementingClass()) || f->isDestructor() && (query & Destructors) == 0) { continue; }*/ - if ((query & VirtualFunctions) && (f->isFinal() || f->isSignal() || f->isStatic())) { - continue; - } - - if ((query & StaticFunctions) && (!f->isStatic() || f->isSignal())) { - continue; - } + if ((query & VirtualFunctions) && (f->isFinal() || f->isSignal() || f->isStatic())) { + continue; + } - if ((query & NonStaticFunctions) && (f->isStatic())) { - continue; - } + if ((query & StaticFunctions) && (!f->isStatic() || f->isSignal())) { + continue; + } - if ((query & NonEmptyFunctions) && (f->isEmptyFunction())) { - continue; - } + if ((query & NonStaticFunctions) && (f->isStatic())) { + continue; + } - if ((query & NormalFunctions) && (f->isSignal())) { - continue; - } + if ((query & NonEmptyFunctions) && (f->isEmptyFunction())) { + continue; + } - if ((query & AbstractFunctions) && !f->isAbstract()) { - continue; - } + if ((query & NormalFunctions) && (f->isSignal())) { + continue; + } - functions << f; + if ((query & AbstractFunctions) && !f->isAbstract()) { + continue; } -// qDebug() << "queried" << m_type_entry->qualifiedCppName() << "got" << functions.size() << "out of" << m_functions.size(); + functions << f; + } + + // qDebug() << "queried" << m_type_entry->qualifiedCppName() << "got" << functions.size() << "out of" << m_functions.size(); - return functions; + return functions; } - bool AbstractMetaClass::hasInconsistentFunctions() const { - return cppInconsistentFunctions().size() > 0; + return cppInconsistentFunctions().size() > 0; } bool AbstractMetaClass::hasSignals() const { - return cppSignalFunctions().size() > 0; + return cppSignalFunctions().size() > 0; } - /** * Adds the specified interface to this class by adding all the * functions in the interface to this class. */ -void AbstractMetaClass::addInterface(AbstractMetaClass *interface) +void AbstractMetaClass::addInterface(AbstractMetaClass* interface) { - Q_ASSERT(!m_interfaces.contains(interface)); - m_interfaces << interface; + Q_ASSERT(!m_interfaces.contains(interface)); + m_interfaces << interface; - if (m_extracted_interface != 0 && m_extracted_interface != interface) - m_extracted_interface->addInterface(interface); + if (m_extracted_interface != 0 && m_extracted_interface != interface) + m_extracted_interface->addInterface(interface); - for (AbstractMetaFunction* function : interface->functions()) - if (!hasFunction(function) && !function->isConstructor()) { - AbstractMetaFunction *cpy = function->copy(); - // We do not want this in PythonQt: - //cpy->setImplementingClass(this); + for (AbstractMetaFunction* function : interface->functions()) + if (!hasFunction(function) && !function->isConstructor()) { + AbstractMetaFunction* cpy = function->copy(); + // We do not want this in PythonQt: + //cpy->setImplementingClass(this); - // Setup that this function is an interface class. - cpy->setInterfaceClass(interface); - *cpy += AbstractMetaAttributes::InterfaceFunction; + // Setup that this function is an interface class. + cpy->setInterfaceClass(interface); + *cpy += AbstractMetaAttributes::InterfaceFunction; - // Copy the modifications in interface into the implementing classes. - //FunctionModificationList mods = function->modifications(interface); - //for (const FunctionModification& mod : mods) { - // m_type_entry->addFunctionModification(mod); - //} + // Copy the modifications in interface into the implementing classes. + //FunctionModificationList mods = function->modifications(interface); + //for (const FunctionModification& mod : mods) { + // m_type_entry->addFunctionModification(mod); + //} - // It should be mostly safe to assume that when we implement an interface - // we don't "pass on" pure virtual functions to our sublcasses... -// *cpy -= AbstractMetaAttributes::Abstract; + // It should be mostly safe to assume that when we implement an interface + // we don't "pass on" pure virtual functions to our sublcasses... + // *cpy -= AbstractMetaAttributes::Abstract; - addFunction(cpy); - } + addFunction(cpy); + } } - -void AbstractMetaClass::setInterfaces(const AbstractMetaClassList &interfaces) +void AbstractMetaClass::setInterfaces(const AbstractMetaClassList& interfaces) { - m_interfaces = interfaces; + m_interfaces = interfaces; } - -AbstractMetaEnum *AbstractMetaClass::findEnum(const QString &enumName) +AbstractMetaEnum* AbstractMetaClass::findEnum(const QString& enumName) { - for (AbstractMetaEnum* e : m_enums) { - if (e->name() == enumName) - return e; - } + for (AbstractMetaEnum* e : m_enums) { + if (e->name() == enumName) + return e; + } - if (typeEntry()->designatedInterface()) - return extractInterface()->findEnum(enumName); + if (typeEntry()->designatedInterface()) + return extractInterface()->findEnum(enumName); - return 0; + return 0; } - - - /*! Recursivly searches for the enum value named \a enumValueName in this class and its superclasses and interfaces. Values belonging to \a meta_enum are excluded from the search. */ -AbstractMetaEnumValue *AbstractMetaClass::findEnumValue(const QString &enumValueName, AbstractMetaEnum *meta_enum) +AbstractMetaEnumValue* AbstractMetaClass::findEnumValue(const QString& enumValueName, AbstractMetaEnum* meta_enum) { - for (AbstractMetaEnum* e : m_enums) { - if (e == meta_enum) - continue; - for (AbstractMetaEnumValue* v : e->values()) { - if (v->name() == enumValueName) - return v; - } + for (AbstractMetaEnum* e : m_enums) { + if (e == meta_enum) + continue; + for (AbstractMetaEnumValue* v : e->values()) { + if (v->name() == enumValueName) + return v; } + } - if (typeEntry()->designatedInterface()) - return extractInterface()->findEnumValue(enumValueName, meta_enum); + if (typeEntry()->designatedInterface()) + return extractInterface()->findEnumValue(enumValueName, meta_enum); - if (baseClass() != 0) - return baseClass()->findEnumValue(enumValueName, meta_enum); + if (baseClass() != 0) + return baseClass()->findEnumValue(enumValueName, meta_enum); - return 0; + return 0; } - /*! * Searches through all of this class' enums for a value matching the * name \a enumValueName. The name is excluding the class/namespace * prefix. The function recursivly searches interfaces and baseclasses * of this class. */ -AbstractMetaEnum *AbstractMetaClass::findEnumForValue(const QString &enumValueName) +AbstractMetaEnum* AbstractMetaClass::findEnumForValue(const QString& enumValueName) { - for (AbstractMetaEnum* e : m_enums) { - for (AbstractMetaEnumValue* v : e->values()) { - if (v->name() == enumValueName) - return e; - } + for (AbstractMetaEnum* e : m_enums) { + for (AbstractMetaEnumValue* v : e->values()) { + if (v->name() == enumValueName) + return e; } + } - if (typeEntry()->designatedInterface()) - return extractInterface()->findEnumForValue(enumValueName); + if (typeEntry()->designatedInterface()) + return extractInterface()->findEnumForValue(enumValueName); - if (baseClass() != 0) - return baseClass()->findEnumForValue(enumValueName); + if (baseClass() != 0) + return baseClass()->findEnumForValue(enumValueName); - return 0; + return 0; } - -static void add_extra_include_for_type(AbstractMetaClass *meta_class, AbstractMetaType::const_shared_pointer type) +static void add_extra_include_for_type(AbstractMetaClass* meta_class, AbstractMetaType::const_shared_pointer type) { - if (type == 0) - return; + if (type == 0) + return; - Q_ASSERT(meta_class != 0); - const TypeEntry *entry = (type ? type->typeEntry() : 0); - if (entry != 0 && entry->isComplex()) { - const ComplexTypeEntry *centry = static_cast(entry); - ComplexTypeEntry *class_entry = meta_class->typeEntry(); - if (class_entry != 0 && centry->include().isValid()) - class_entry->addExtraInclude(centry->include()); - } + Q_ASSERT(meta_class != 0); + const TypeEntry* entry = (type ? type->typeEntry() : 0); + if (entry != 0 && entry->isComplex()) { + const ComplexTypeEntry* centry = static_cast(entry); + ComplexTypeEntry* class_entry = meta_class->typeEntry(); + if (class_entry != 0 && centry->include().isValid()) + class_entry->addExtraInclude(centry->include()); + } - if (type->hasInstantiations()) { - auto &instantiations = type->instantiations(); - for(auto &&instantiation: instantiations) - add_extra_include_for_type(meta_class, instantiation); - } + if (type->hasInstantiations()) { + auto& instantiations = type->instantiations(); + for (auto&& instantiation : instantiations) + add_extra_include_for_type(meta_class, instantiation); + } } -static void add_extra_includes_for_function(AbstractMetaClass *meta_class, const AbstractMetaFunction *meta_function) +static void add_extra_includes_for_function(AbstractMetaClass* meta_class, const AbstractMetaFunction* meta_function) { - Q_ASSERT(meta_class != 0); - Q_ASSERT(meta_function != 0); - add_extra_include_for_type(meta_class, meta_function->type()); + Q_ASSERT(meta_class != 0); + Q_ASSERT(meta_function != 0); + add_extra_include_for_type(meta_class, meta_function->type()); - AbstractMetaArgumentList arguments = meta_function->arguments(); - for (AbstractMetaArgument* argument : arguments) { - add_extra_include_for_type(meta_class, argument->type()); - } + AbstractMetaArgumentList arguments = meta_function->arguments(); + for (AbstractMetaArgument* argument : arguments) { + add_extra_include_for_type(meta_class, argument->type()); + } } void AbstractMetaClass::fixFunctions() { - if (m_functions_fixed) - return; - else - m_functions_fixed = true; - - AbstractMetaClass *super_class = baseClass(); - AbstractMetaFunctionList funcs = functions(); - AbstractMetaClassList interfaceClasses = interfaces(); - -// printf("fix functions for %s\n", qPrintable(name())); - - if (super_class != 0) - super_class->fixFunctions(); - int iface_idx = 0; - while (super_class || iface_idx < interfaceClasses.size()) { - - // Since we always traverse the complete hierarchy we are only - // interested in what each super class implements, not what - // we may have propagated from their base classes again. - AbstractMetaFunctionList super_funcs; - if (super_class) { -// printf(" - base: %s\n", qPrintable(super_class->name())); - - // Super classes can never be final - if (super_class->isFinalInTargetLang()) { - ReportHandler::warning("Final class '" + super_class->name() + "' set to non-final, as it is extended by other classes"); - *super_class -= AbstractMetaAttributes::FinalInTargetLang; + if (m_functions_fixed) + return; + else + m_functions_fixed = true; + + AbstractMetaClass* super_class = baseClass(); + AbstractMetaFunctionList funcs = functions(); + AbstractMetaClassList interfaceClasses = interfaces(); + + // printf("fix functions for %s\n", qPrintable(name())); + + if (super_class != 0) + super_class->fixFunctions(); + int iface_idx = 0; + while (super_class || iface_idx < interfaceClasses.size()) { + + // Since we always traverse the complete hierarchy we are only + // interested in what each super class implements, not what + // we may have propagated from their base classes again. + AbstractMetaFunctionList super_funcs; + if (super_class) { + // printf(" - base: %s\n", qPrintable(super_class->name())); + + // Super classes can never be final + if (super_class->isFinalInTargetLang()) { + ReportHandler::warning( + "Final class '" + super_class->name() + "' set to non-final, as it is extended by other classes"); + *super_class -= AbstractMetaAttributes::FinalInTargetLang; + } + super_funcs = super_class->queryFunctions(AbstractMetaClass::ClassImplements); + } else { + AbstractMetaClass* iface_class = interfaceClasses.at(iface_idx); + // printf(" - iface: %s\n", qPrintable(iface_class->name())); + iface_class->fixFunctions(); + super_funcs = iface_class->queryFunctions(AbstractMetaClass::NormalFunctions); + } + + QSet funcs_to_add; + for (int sfi = 0; sfi < super_funcs.size(); ++sfi) { + AbstractMetaFunction* sf = super_funcs.at(sfi); + + if (sf->isRemovedFromAllLanguages(sf->implementingClass())) + continue; + + // we generally don't care about private functions, but we have to get the ones that are + // virtual in case they override abstract functions. + bool add = (sf->isNormal() || sf->isSignal() || sf->isEmptyFunction()); + for (int fi = 0; fi < funcs.size(); ++fi) { + AbstractMetaFunction* f = funcs.at(fi); + if (f->isRemovedFromAllLanguages(f->implementingClass())) + continue; + + uint cmp = f->compareTo(sf); + + if (cmp & AbstractMetaFunction::EqualModifiedName) { + // printf(" - %s::%s similar to %s::%s %x vs %x\n", + // qPrintable(sf->implementingClass()->typeEntry()->qualifiedCppName()), + // qPrintable(sf->name()), + // qPrintable(f->implementingClass()->typeEntry()->qualifiedCppName()), + // qPrintable(f->name()), + // sf->attributes(), + // f->attributes()); + + add = false; + if (cmp & AbstractMetaFunction::EqualArguments) { + + // if (!(cmp & AbstractMetaFunction::EqualReturnType)) { + // ReportHandler::warning(QString("%1::%2 and %3::%4 differ in retur type") + // .arg(sf->implementingClass()->name()) + // .arg(sf->name()) + // .arg(f->implementingClass()->name()) + // .arg(f->name())); + // } + + // Same function, propagate virtual... + if (!(cmp & AbstractMetaFunction::EqualAttributes)) { + if (!f->isEmptyFunction()) { + if (!sf->isFinalInCpp() && f->isFinalInCpp()) { + *f -= AbstractMetaAttributes::FinalInCpp; + // printf(" --- inherit virtual\n"); + } + if (!sf->isFinalInTargetLang() && f->isFinalInTargetLang()) { + *f -= AbstractMetaAttributes::FinalInTargetLang; + // printf(" --- inherit virtual\n"); + } + if (!f->isFinalInTargetLang() && f->isPrivate()) { + f->setFunctionType(AbstractMetaFunction::EmptyFunction); + f->setVisibility(AbstractMetaAttributes::Protected); + *f += AbstractMetaAttributes::FinalInTargetLang; + ReportHandler::warning(QString("private virtual function '%1' in '%2'") + .arg(f->signature()) + .arg(f->implementingClass()->name())); + } + } } - super_funcs = super_class->queryFunctions(AbstractMetaClass::ClassImplements); - } else { - AbstractMetaClass *iface_class = interfaceClasses.at(iface_idx); -// printf(" - iface: %s\n", qPrintable(iface_class->name())); - iface_class->fixFunctions(); - super_funcs = iface_class->queryFunctions(AbstractMetaClass::NormalFunctions); - } - QSet funcs_to_add; - for (int sfi=0; sfiisRemovedFromAllLanguages(sf->implementingClass())) - continue; - - // we generally don't care about private functions, but we have to get the ones that are - // virtual in case they override abstract functions. - bool add = (sf->isNormal() || sf->isSignal() || sf->isEmptyFunction()); - for (int fi=0; fiisRemovedFromAllLanguages(f->implementingClass())) - continue; - - uint cmp = f->compareTo(sf); - - if (cmp & AbstractMetaFunction::EqualModifiedName) { -// printf(" - %s::%s similar to %s::%s %x vs %x\n", -// qPrintable(sf->implementingClass()->typeEntry()->qualifiedCppName()), -// qPrintable(sf->name()), -// qPrintable(f->implementingClass()->typeEntry()->qualifiedCppName()), -// qPrintable(f->name()), -// sf->attributes(), -// f->attributes()); - - add = false; - if (cmp & AbstractMetaFunction::EqualArguments) { - -// if (!(cmp & AbstractMetaFunction::EqualReturnType)) { -// ReportHandler::warning(QString("%1::%2 and %3::%4 differ in retur type") -// .arg(sf->implementingClass()->name()) -// .arg(sf->name()) -// .arg(f->implementingClass()->name()) -// .arg(f->name())); -// } - - // Same function, propagate virtual... - if (!(cmp & AbstractMetaFunction::EqualAttributes)) { - if (!f->isEmptyFunction()) { - if (!sf->isFinalInCpp() && f->isFinalInCpp()) { - *f -= AbstractMetaAttributes::FinalInCpp; - // printf(" --- inherit virtual\n"); - } - if (!sf->isFinalInTargetLang() && f->isFinalInTargetLang()) { - *f -= AbstractMetaAttributes::FinalInTargetLang; - // printf(" --- inherit virtual\n"); - } - if (!f->isFinalInTargetLang() && f->isPrivate()) { - f->setFunctionType(AbstractMetaFunction::EmptyFunction); - f->setVisibility(AbstractMetaAttributes::Protected); - *f += AbstractMetaAttributes::FinalInTargetLang; - ReportHandler::warning(QString("private virtual function '%1' in '%2'") - .arg(f->signature()) - .arg(f->implementingClass()->name())); - } - } - } - - if (f->visibility() != sf->visibility()) { - QString warn = QString("visibility of function '%1' modified in class '%2'") - .arg(f->name()).arg(name()); - ReportHandler::warning(warn); - - // If new visibility is private, we can't - // do anything. If it isn't, then we - // prefer the parent class's visibility - // setting for the function. - if (!f->isPrivate() && !sf->isPrivate()) - f->setVisibility(sf->visibility()); - - // Private overrides of abstract functions have to go into the class or - // the subclasses will not compile as non-abstract classes. - // But they don't need to be implemented, since they can never be called. - if (f->isPrivate() && sf->isAbstract()) { - f->setFunctionType(AbstractMetaFunction::EmptyFunction); - f->setVisibility(sf->visibility()); - *f += AbstractMetaAttributes::FinalInTargetLang; - *f += AbstractMetaAttributes::FinalInCpp; - } - } - - // Set the class which first declares this function, afawk - f->setDeclaringClass(sf->declaringClass()); - - if (sf->isFinalInTargetLang() && !sf->isPrivate() && !f->isPrivate() && !sf->isStatic() && !f->isStatic()) { - // Shadowed function, need to make base class - // function non-virtual - if (f->implementingClass() != sf->implementingClass() && f->implementingClass()->inheritsFrom(sf->implementingClass())) { - - // Check whether the superclass method has been redefined to non-final - - bool hasNonFinalModifier = false; - bool isBaseImplPrivate = false; - FunctionModificationList mods = sf->modifications(sf->implementingClass()); - for (FunctionModification mod : mods) { - if (mod.isNonFinal()) { - hasNonFinalModifier = true; - break; - } else if (mod.isPrivate()) { - isBaseImplPrivate = true; - break; - } - } - - if (!hasNonFinalModifier && !isBaseImplPrivate) { - ReportHandler::warning(QString::fromLatin1("Shadowing: %1::%2 and %3::%4; Java code will not compile") - .arg(sf->implementingClass()->name()) - .arg(sf->signature()) - .arg(f->implementingClass()->name()) - .arg(f->signature())); - } - } - } - - } - - /* I did not see a good reason for erasing the default arguments, + if (f->visibility() != sf->visibility()) { + QString warn = QString("visibility of function '%1' modified in class '%2'").arg(f->name()).arg(name()); + ReportHandler::warning(warn); + + // If new visibility is private, we can't + // do anything. If it isn't, then we + // prefer the parent class's visibility + // setting for the function. + if (!f->isPrivate() && !sf->isPrivate()) + f->setVisibility(sf->visibility()); + + // Private overrides of abstract functions have to go into the class or + // the subclasses will not compile as non-abstract classes. + // But they don't need to be implemented, since they can never be called. + if (f->isPrivate() && sf->isAbstract()) { + f->setFunctionType(AbstractMetaFunction::EmptyFunction); + f->setVisibility(sf->visibility()); + *f += AbstractMetaAttributes::FinalInTargetLang; + *f += AbstractMetaAttributes::FinalInCpp; + } + } + + // Set the class which first declares this function, afawk + f->setDeclaringClass(sf->declaringClass()); + + if (sf->isFinalInTargetLang() && !sf->isPrivate() && !f->isPrivate() && !sf->isStatic() && !f->isStatic()) { + // Shadowed function, need to make base class + // function non-virtual + if (f->implementingClass() != sf->implementingClass() + && f->implementingClass()->inheritsFrom(sf->implementingClass())) + { + + // Check whether the superclass method has been redefined to non-final + + bool hasNonFinalModifier = false; + bool isBaseImplPrivate = false; + FunctionModificationList mods = sf->modifications(sf->implementingClass()); + for (FunctionModification mod : mods) { + if (mod.isNonFinal()) { + hasNonFinalModifier = true; + break; + } else if (mod.isPrivate()) { + isBaseImplPrivate = true; + break; + } + } + + if (!hasNonFinalModifier && !isBaseImplPrivate) { + ReportHandler::warning(QString::fromLatin1("Shadowing: %1::%2 and %3::%4; Java code will not compile") + .arg(sf->implementingClass()->name()) + .arg(sf->signature()) + .arg(f->implementingClass()->name()) + .arg(f->signature())); + } + } + } + } + + /* I did not see a good reason for erasing the default arguments, maybe this was a java related problem? I uncommented this code, because it causes that the default arguments of QBoxLayout::addWidget(QWidget, stretch, alignment) are removed because of QLayout::addWidget(QWidget) */ - /* + /* if (cmp & AbstractMetaFunction::EqualDefaultValueOverload) { AbstractMetaArgumentList arguments; if (f->arguments().size() < sf->arguments().size()) @@ -1828,78 +1792,74 @@ void AbstractMetaClass::fixFunctions() arguments[i]->setDefaultValueExpression(QString()); }*/ + // Otherwise we have function shadowing and we can + // skip the thing... + } else if (cmp & AbstractMetaFunction::EqualName && !sf->isSignal()) { - // Otherwise we have function shadowing and we can - // skip the thing... - } else if (cmp & AbstractMetaFunction::EqualName && !sf->isSignal()) { - - // In the case of function shadowing where the function name has been altered to - // avoid conflict, we don't copy in the original. - add = false; - } - - } - - if (add) - funcs_to_add << sf; + // In the case of function shadowing where the function name has been altered to + // avoid conflict, we don't copy in the original. + add = false; } + } - for (AbstractMetaFunction* f : funcs_to_add) { - funcs << f->copy(); - } + if (add) + funcs_to_add << sf; + } - if (super_class) { - interfaceClasses += super_class->interfaces(); - super_class = super_class->baseClass(); - } else { - iface_idx++; - } + for (AbstractMetaFunction* f : funcs_to_add) { + funcs << f->copy(); } -// printf("end fix functions for %s\n", qPrintable(name())); + if (super_class) { + interfaceClasses += super_class->interfaces(); + super_class = super_class->baseClass(); + } else { + iface_idx++; + } + } - bool hasPrivateConstructors = false; - bool hasPublicConstructors = false; - for (AbstractMetaFunction* func : funcs) { - FunctionModificationList mods = func->modifications(this); - for (const FunctionModification& mod : mods) { - if (mod.isRenameModifier()) { -// qDebug() << name() << func->originalName() << func << " from " -// << func->implementingClass()->name() << "renamed to" << mod.renamedTo(); - func->setName(mod.renamedTo()); - } - } + // printf("end fix functions for %s\n", qPrintable(name())); - // Make sure class is abstract if one of the functions is - if (func->isAbstract()) { - (*this) += AbstractMetaAttributes::Abstract; - (*this) -= AbstractMetaAttributes::Final; - } + bool hasPrivateConstructors = false; + bool hasPublicConstructors = false; + for (AbstractMetaFunction* func : funcs) { + FunctionModificationList mods = func->modifications(this); + for (const FunctionModification& mod : mods) { + if (mod.isRenameModifier()) { + // qDebug() << name() << func->originalName() << func << " from " + // << func->implementingClass()->name() << "renamed to" << mod.renamedTo(); + func->setName(mod.renamedTo()); + } + } - if (func->isConstructor()) { - if (func->isPrivate()) - hasPrivateConstructors = true; - else - hasPublicConstructors = true; - } + // Make sure class is abstract if one of the functions is + if (func->isAbstract()) { + (*this) += AbstractMetaAttributes::Abstract; + (*this) -= AbstractMetaAttributes::Final; + } + if (func->isConstructor()) { + if (func->isPrivate()) + hasPrivateConstructors = true; + else + hasPublicConstructors = true; + } + // Make sure that we include files for all classes that are in use - // Make sure that we include files for all classes that are in use + if (!func->isRemovedFrom(this, TypeSystem::ShellCode)) + add_extra_includes_for_function(this, func); + } - if (!func->isRemovedFrom(this, TypeSystem::ShellCode)) - add_extra_includes_for_function(this, func); - } + if (hasPrivateConstructors && !hasPublicConstructors) { + (*this) += AbstractMetaAttributes::Abstract; + (*this) -= AbstractMetaAttributes::Final; + } - if (hasPrivateConstructors && !hasPublicConstructors) { - (*this) += AbstractMetaAttributes::Abstract; - (*this) -= AbstractMetaAttributes::Final; - } + // we don't care about FinalOverload for PythonQt, so we + // can remove this compare orgy... - // we don't care about FinalOverload for PythonQt, so we - // can remove this compare orgy... - - /*for (AbstractMetaFunction* f1 : funcs) { + /*for (AbstractMetaFunction* f1 : funcs) { for (AbstractMetaFunction* f2 : funcs) { if (f1 != f2) { uint cmp = f1->compareTo(f2); @@ -1922,99 +1882,95 @@ void AbstractMetaClass::fixFunctions() } }*/ - setFunctions(funcs); + setFunctions(funcs); } - QString AbstractMetaType::minimalSignature() const { - QString minimalSignature; - if (isConstant()) - minimalSignature += "const "; - minimalSignature += typeEntry()->qualifiedCppName(); - if (hasInstantiations()) { - auto &instantiations = this->instantiations(); - minimalSignature += "<"; - for (int i=0;i 0) - minimalSignature += ","; - minimalSignature += instantiations.at(i)->minimalSignature(); - } - minimalSignature += ">"; - } + QString minimalSignature; + if (isConstant()) + minimalSignature += "const "; + minimalSignature += typeEntry()->qualifiedCppName(); + if (hasInstantiations()) { + auto& instantiations = this->instantiations(); + minimalSignature += "<"; + for (int i = 0; i < instantiations.size(); ++i) { + if (i > 0) + minimalSignature += ","; + minimalSignature += instantiations.at(i)->minimalSignature(); + } + minimalSignature += ">"; + } - if (isReference()) - minimalSignature += "&"; - for (int j=0; jisNativeIdBased(); + return (isQObject() || isValue() || isObject()) && typeEntry()->isNativeIdBased(); } - /******************************************************************************* * Other stuff... */ - -AbstractMetaEnum *AbstractMetaClassList::findEnum(const EnumTypeEntry *entry) const +AbstractMetaEnum* AbstractMetaClassList::findEnum(const EnumTypeEntry* entry) const { - Q_ASSERT(entry->isEnum()); + Q_ASSERT(entry->isEnum()); - QString qualified_name = entry->qualifiedCppName(); - int pos = qualified_name.lastIndexOf("::"); + QString qualified_name = entry->qualifiedCppName(); + int pos = qualified_name.lastIndexOf("::"); - QString enum_name; - QString class_name; + QString enum_name; + QString class_name; - if (pos > 0) { - enum_name = qualified_name.mid(pos + 2); - class_name = qualified_name.mid(0, pos); - } else { - enum_name = qualified_name; - class_name = TypeDatabase::globalNamespaceClassName(entry); - } + if (pos > 0) { + enum_name = qualified_name.mid(pos + 2); + class_name = qualified_name.mid(0, pos); + } else { + enum_name = qualified_name; + class_name = TypeDatabase::globalNamespaceClassName(entry); + } - AbstractMetaClass *meta_class = findClass(class_name); - if (!meta_class) { - ReportHandler::warning(QString("AbstractMeta::findEnum(), unknown class '%1' in '%2'") - .arg(class_name).arg(entry->qualifiedCppName())); - return 0; - } + AbstractMetaClass* meta_class = findClass(class_name); + if (!meta_class) { + ReportHandler::warning( + QString("AbstractMeta::findEnum(), unknown class '%1' in '%2'").arg(class_name).arg(entry->qualifiedCppName())); + return 0; + } - return meta_class->findEnum(enum_name); + return meta_class->findEnum(enum_name); } -AbstractMetaEnumValue *AbstractMetaEnumValueList::find(const QString &name) const +AbstractMetaEnumValue* AbstractMetaEnumValueList::find(const QString& name) const { - for (int i=0; iname()) - return at(i); - } - return 0; + for (int i = 0; i < size(); ++i) { + if (name == at(i)->name()) + return at(i); + } + return 0; } -AbstractMetaEnumValue *AbstractMetaClassList::findEnumValue(const QString &name) const +AbstractMetaEnumValue* AbstractMetaClassList::findEnumValue(const QString& name) const { - QStringList lst = name.split(QLatin1String("::")); + QStringList lst = name.split(QLatin1String("::")); - Q_ASSERT_X(lst.size() == 2, "AbstractMetaClassList::findEnumValue()", "Expected qualified enum"); + Q_ASSERT_X(lst.size() == 2, "AbstractMetaClassList::findEnumValue()", "Expected qualified enum"); + QString prefixName = lst.at(0); + QString enumName = lst.at(1); - QString prefixName = lst.at(0); - QString enumName = lst.at(1); + AbstractMetaClass* cl = findClass(prefixName); + if (cl) + return cl->findEnumValue(enumName, 0); - AbstractMetaClass *cl = findClass(prefixName); - if (cl) - return cl->findEnumValue(enumName, 0); - - ReportHandler::warning(QString("no matching enum '%1'").arg(name)); - return 0; + ReportHandler::warning(QString("no matching enum '%1'").arg(name)); + return 0; } /*! @@ -2022,31 +1978,30 @@ AbstractMetaEnumValue *AbstractMetaClassList::findEnumValue(const QString &name) * C++, Java base name or complete Java package.class name. */ -AbstractMetaClass *AbstractMetaClassList::findClass(const QString &name) const +AbstractMetaClass* AbstractMetaClassList::findClass(const QString& name) const { - if (name.isEmpty()) - return 0; + if (name.isEmpty()) + return 0; - for (AbstractMetaClass* c : *this) { - if (c->qualifiedCppName() == name) - return c; - } + for (AbstractMetaClass* c : *this) { + if (c->qualifiedCppName() == name) + return c; + } - for (AbstractMetaClass* c : *this) { - if (c->fullName() == name) - return c; - } + for (AbstractMetaClass* c : *this) { + if (c->fullName() == name) + return c; + } - for (AbstractMetaClass* c : *this) { - if (c->name() == name) - return c; - } + for (AbstractMetaClass* c : *this) { + if (c->name() == name) + return c; + } - return 0; + return 0; } - void AbstractMetaClassList::sort(void) { - std::stable_sort(begin(), end(), AbstractMetaClass::less_than); + std::stable_sort(begin(), end(), AbstractMetaClass::less_than); } diff --git a/generator/abstractmetalang.h b/generator/abstractmetalang.h index 75c3d1b25..6e62499b7 100644 --- a/generator/abstractmetalang.h +++ b/generator/abstractmetalang.h @@ -62,907 +62,893 @@ class AbstractMetaEnumValue; class AbstractMetaEnum; class QPropertySpec; -typedef QList AbstractMetaFieldList; -typedef QList AbstractMetaArgumentList; -typedef QList AbstractMetaFunctionList; -class AbstractMetaClassList : public QList +typedef QList AbstractMetaFieldList; +typedef QList AbstractMetaArgumentList; +typedef QList AbstractMetaFunctionList; +class AbstractMetaClassList : public QList { public: - AbstractMetaClass *findClass(const QString &name) const; - AbstractMetaEnumValue *findEnumValue(const QString &string) const; - AbstractMetaEnum *findEnum(const EnumTypeEntry *entry) const; - void sort(); - + AbstractMetaClass* findClass(const QString& name) const; + AbstractMetaEnumValue* findEnumValue(const QString& string) const; + AbstractMetaEnum* findEnum(const EnumTypeEntry* entry) const; + void sort(); }; - - class AbstractMetaAttributes { public: - AbstractMetaAttributes() = default; + AbstractMetaAttributes() = default; - enum Attribute { - None = 0x00000000, + enum Attribute { + None = 0x00000000, - Private = 0x00000001, - Protected = 0x00000002, - Public = 0x00000004, - Friendly = 0x00000008, - Visibility = 0x0000000f, + Private = 0x00000001, + Protected = 0x00000002, + Public = 0x00000004, + Friendly = 0x00000008, + Visibility = 0x0000000f, - Native = 0x00000010, - Abstract = 0x00000020, - Static = 0x00000040, + Native = 0x00000010, + Abstract = 0x00000020, + Static = 0x00000040, - FinalInTargetLang = 0x00000080, - FinalInCpp = 0x00000100, - ForceShellImplementation = 0x00000200, + FinalInTargetLang = 0x00000080, + FinalInCpp = 0x00000100, + ForceShellImplementation = 0x00000200, - GetterFunction = 0x00000400, - SetterFunction = 0x00000800, + GetterFunction = 0x00000400, + SetterFunction = 0x00000800, - FinalOverload = 0x00001000, - InterfaceFunction = 0x00002000, + FinalOverload = 0x00001000, + InterfaceFunction = 0x00002000, - PropertyReader = 0x00004000, - PropertyWriter = 0x00008000, - PropertyResetter = 0x00010000, + PropertyReader = 0x00004000, + PropertyWriter = 0x00008000, + PropertyResetter = 0x00010000, - Fake = 0x00020000, + Fake = 0x00020000, - Invokable = 0x00040000, + Invokable = 0x00040000, - Final = FinalInTargetLang | FinalInCpp - }; + Final = FinalInTargetLang | FinalInCpp + }; - uint attributes() const { return m_attributes; } - void setAttributes(uint attributes) { m_attributes = attributes; } + uint attributes() const { return m_attributes; } + void setAttributes(uint attributes) { m_attributes = attributes; } - uint originalAttributes() const { return m_originalAttributes; } - void setOriginalAttributes(uint attributes) { m_originalAttributes = attributes; } + uint originalAttributes() const { return m_originalAttributes; } + void setOriginalAttributes(uint attributes) { m_originalAttributes = attributes; } - uint visibility() const { return m_attributes & Visibility; } - void setVisibility(uint visi) { m_attributes = (m_attributes & ~Visibility) | visi; } + uint visibility() const { return m_attributes & Visibility; } + void setVisibility(uint visi) { m_attributes = (m_attributes & ~Visibility) | visi; } - void operator+=(Attribute attribute) { m_attributes |= attribute; } - void operator-=(Attribute attribute) { m_attributes &= ~attribute; } + void operator+=(Attribute attribute) { m_attributes |= attribute; } + void operator-=(Attribute attribute) { m_attributes &= ~attribute; } - bool isNative() const { return m_attributes & Native; } - bool isFinal() const { return (m_attributes & Final) == Final; } - bool isFinalInTargetLang() const { return m_attributes & FinalInTargetLang; } - bool isFinalInCpp() const { return m_attributes & FinalInCpp; } - bool isAbstract() const { return m_attributes & Abstract; } - bool isStatic() const { return m_attributes & Static; } - bool isForcedShellImplementation() const { return m_attributes & ForceShellImplementation; } - bool isInterfaceFunction() const { return m_attributes & InterfaceFunction; } - bool isFinalOverload() const { return m_attributes & FinalOverload; } - bool isInvokable() const { return m_attributes & Invokable; } + bool isNative() const { return m_attributes & Native; } + bool isFinal() const { return (m_attributes & Final) == Final; } + bool isFinalInTargetLang() const { return m_attributes & FinalInTargetLang; } + bool isFinalInCpp() const { return m_attributes & FinalInCpp; } + bool isAbstract() const { return m_attributes & Abstract; } + bool isStatic() const { return m_attributes & Static; } + bool isForcedShellImplementation() const { return m_attributes & ForceShellImplementation; } + bool isInterfaceFunction() const { return m_attributes & InterfaceFunction; } + bool isFinalOverload() const { return m_attributes & FinalOverload; } + bool isInvokable() const { return m_attributes & Invokable; } - bool isPropertyReader() const { return m_attributes & PropertyReader; } - bool isPropertyWriter() const { return m_attributes & PropertyWriter; } - bool isPropertyResetter() const { return m_attributes & PropertyResetter; } + bool isPropertyReader() const { return m_attributes & PropertyReader; } + bool isPropertyWriter() const { return m_attributes & PropertyWriter; } + bool isPropertyResetter() const { return m_attributes & PropertyResetter; } - bool isPrivate() const { return m_attributes & Private; } - bool isProtected() const { return m_attributes & Protected; } - bool isPublic() const { return m_attributes & Public; } - bool isFriendly() const { return m_attributes & Friendly; } + bool isPrivate() const { return m_attributes & Private; } + bool isProtected() const { return m_attributes & Protected; } + bool isPublic() const { return m_attributes & Public; } + bool isFriendly() const { return m_attributes & Friendly; } - bool wasPrivate() const { return m_originalAttributes & Private; } - bool wasProtected() const { return m_originalAttributes & Protected; } - bool wasPublic() const { return m_originalAttributes & Public; } - bool wasFriendly() const { return m_originalAttributes & Friendly; } + bool wasPrivate() const { return m_originalAttributes & Private; } + bool wasProtected() const { return m_originalAttributes & Protected; } + bool wasPublic() const { return m_originalAttributes & Public; } + bool wasFriendly() const { return m_originalAttributes & Friendly; } private: - uint m_attributes{}; - uint m_originalAttributes{}; + uint m_attributes {}; + uint m_originalAttributes {}; }; - class AbstractMetaType { public: - typedef QSharedPointer shared_pointer; - typedef QSharedPointer const_shared_pointer; - enum TypeUsagePattern { - InvalidPattern, - PrimitivePattern, - FlagsPattern, - EnumPattern, - ValuePattern, - StringPattern, - CharPattern, - ObjectPattern, - QObjectPattern, - NativePointerPattern, - ContainerPattern, - VariantPattern, - JObjectWrapperPattern, - ArrayPattern, - ThreadPattern - }; - - AbstractMetaType() : - m_constant(false), - m_reference(false), - m_cpp_instantiation(true), - m_indirections(0), - m_reserved(0) - { - } + typedef QSharedPointer shared_pointer; + typedef QSharedPointer const_shared_pointer; + enum TypeUsagePattern { + InvalidPattern, + PrimitivePattern, + FlagsPattern, + EnumPattern, + ValuePattern, + StringPattern, + CharPattern, + ObjectPattern, + QObjectPattern, + NativePointerPattern, + ContainerPattern, + VariantPattern, + JObjectWrapperPattern, + ArrayPattern, + ThreadPattern + }; + + AbstractMetaType() + : m_constant(false) + , m_reference(false) + , m_cpp_instantiation(true) + , m_indirections(0) + , m_reserved(0) + { + } - QString package() const { return m_type_entry->javaPackage(); } - QString name() const { return m_type_entry->targetLangName(); } - QString fullName() const { return m_type_entry->qualifiedTargetLangName(); } + QString package() const { return m_type_entry->javaPackage(); } + QString name() const { return m_type_entry->targetLangName(); } + QString fullName() const { return m_type_entry->qualifiedTargetLangName(); } - void setTypeUsagePattern(TypeUsagePattern pattern) { m_pattern = pattern; } - TypeUsagePattern typeUsagePattern() const { return m_pattern; } + void setTypeUsagePattern(TypeUsagePattern pattern) { m_pattern = pattern; } + TypeUsagePattern typeUsagePattern() const { return m_pattern; } - // true when use pattern is container - bool hasInstantiations() const { return !m_instantiations.isEmpty(); } - void addInstantiation(AbstractMetaType::shared_pointer inst) { m_instantiations << inst; } - void setInstantiations(const QList &insts) { m_instantiations = insts; } - const QList &instantiations() const { return m_instantiations; } - void setInstantiationInCpp(bool incpp) { m_cpp_instantiation = incpp; } - bool hasInstantiationInCpp() const { return hasInstantiations() && m_cpp_instantiation; } + // true when use pattern is container + bool hasInstantiations() const { return !m_instantiations.isEmpty(); } + void addInstantiation(AbstractMetaType::shared_pointer inst) { m_instantiations << inst; } + void setInstantiations(const QList& insts) { m_instantiations = insts; } + const QList& instantiations() const { return m_instantiations; } + void setInstantiationInCpp(bool incpp) { m_cpp_instantiation = incpp; } + bool hasInstantiationInCpp() const { return hasInstantiations() && m_cpp_instantiation; } - QString minimalSignature() const; + QString minimalSignature() const; - // true when the type is a QtJambiObject subclass - bool hasNativeId() const; + // true when the type is a QtJambiObject subclass + bool hasNativeId() const; - // returns true if the typs is used as a non complex primitive, no & or *'s - bool isPrimitive() const { return m_pattern == PrimitivePattern; } + // returns true if the typs is used as a non complex primitive, no & or *'s + bool isPrimitive() const { return m_pattern == PrimitivePattern; } - // returns true if the type is used as an enum - bool isEnum() const { return m_pattern == EnumPattern; } + // returns true if the type is used as an enum + bool isEnum() const { return m_pattern == EnumPattern; } - // returns true if the type is used as a QObject * - bool isQObject() const { return m_pattern == QObjectPattern; } + // returns true if the type is used as a QObject * + bool isQObject() const { return m_pattern == QObjectPattern; } - // returns true if the type is used as an object, e.g. Xxx * - bool isObject() const { return m_pattern == ObjectPattern; } + // returns true if the type is used as an object, e.g. Xxx * + bool isObject() const { return m_pattern == ObjectPattern; } - // returns true if the type is used as an array, e.g. Xxx[42] - bool isArray() const { return m_pattern == ArrayPattern; } + // returns true if the type is used as an array, e.g. Xxx[42] + bool isArray() const { return m_pattern == ArrayPattern; } - // returns true if the type is used as a value type (X or const X &) - bool isValue() const { return m_pattern == ValuePattern; } + // returns true if the type is used as a value type (X or const X &) + bool isValue() const { return m_pattern == ValuePattern; } - // returns true for more complex types... - bool isNativePointer() const { return m_pattern == NativePointerPattern; } + // returns true for more complex types... + bool isNativePointer() const { return m_pattern == NativePointerPattern; } - // returns true if the type was originally a QString or const QString & or equivalent for QLatin1String - bool isTargetLangString() const { return m_pattern == StringPattern; } + // returns true if the type was originally a QString or const QString & or equivalent for QLatin1String + bool isTargetLangString() const { return m_pattern == StringPattern; } - // returns true if the type was originally a QChar or const QChar & - bool isTargetLangChar() const { return m_pattern == CharPattern; } + // returns true if the type was originally a QChar or const QChar & + bool isTargetLangChar() const { return m_pattern == CharPattern; } - // return true if the type was originally a QVariant or const QVariant & - bool isVariant() const { return m_pattern == VariantPattern; } + // return true if the type was originally a QVariant or const QVariant & + bool isVariant() const { return m_pattern == VariantPattern; } - // return true if the type was originally a JObjectWrapper or const JObjectWrapper & - bool isJObjectWrapper() const { return m_pattern == JObjectWrapperPattern; } + // return true if the type was originally a JObjectWrapper or const JObjectWrapper & + bool isJObjectWrapper() const { return m_pattern == JObjectWrapperPattern; } - // returns true if the type was used as a container - bool isContainer() const { return m_pattern == ContainerPattern; } + // returns true if the type was used as a container + bool isContainer() const { return m_pattern == ContainerPattern; } - // returns true if the type was used as a flag - bool isFlags() const { return m_pattern == FlagsPattern; } + // returns true if the type was used as a flag + bool isFlags() const { return m_pattern == FlagsPattern; } - // returns true if the type was used as a thread - bool isThread() const { return m_pattern == ThreadPattern; } + // returns true if the type was used as a thread + bool isThread() const { return m_pattern == ThreadPattern; } - bool isConstant() const { return m_constant; } - void setConstant(bool constant) { m_constant = constant; } + bool isConstant() const { return m_constant; } + void setConstant(bool constant) { m_constant = constant; } - bool isReference() const { return m_reference; } - void setReference(bool ref) { m_reference = ref; } + bool isReference() const { return m_reference; } + void setReference(bool ref) { m_reference = ref; } - // Returns true if the type is to be implemented using Java enums, e.g. not plain ints. - bool isTargetLangEnum() const { return isEnum() && !((EnumTypeEntry *) typeEntry())->forceInteger(); } - bool isIntegerEnum() const { return isEnum() && !isTargetLangEnum(); } + // Returns true if the type is to be implemented using Java enums, e.g. not plain ints. + bool isTargetLangEnum() const { return isEnum() && !((EnumTypeEntry*)typeEntry())->forceInteger(); } + bool isIntegerEnum() const { return isEnum() && !isTargetLangEnum(); } - // Returns true if the type is to be implemented using Java QFlags, e.g. not plain ints. - bool isTargetLangFlags() const { - return isFlags() && !((FlagsTypeEntry *) typeEntry())->forceInteger(); } - bool isIntegerFlags() const { return isFlags() && !isTargetLangFlags(); } + // Returns true if the type is to be implemented using Java QFlags, e.g. not plain ints. + bool isTargetLangFlags() const { return isFlags() && !((FlagsTypeEntry*)typeEntry())->forceInteger(); } + bool isIntegerFlags() const { return isFlags() && !isTargetLangFlags(); } - int actualIndirections() const { return m_indirections + (isReference() ? 1 : 0); } - int indirections() const { return m_indirections; } - void setIndirections(int indirections) { m_indirections = indirections; } + int actualIndirections() const { return m_indirections + (isReference() ? 1 : 0); } + int indirections() const { return m_indirections; } + void setIndirections(int indirections) { m_indirections = indirections; } - void setArrayElementCount(int n) { m_array_element_count = n; } - int arrayElementCount() const { return m_array_element_count; } + void setArrayElementCount(int n) { m_array_element_count = n; } + int arrayElementCount() const { return m_array_element_count; } - AbstractMetaType::shared_pointer arrayElementType() const { return m_array_element_type; } - void setArrayElementType(AbstractMetaType::shared_pointer t) { m_array_element_type = t; } + AbstractMetaType::shared_pointer arrayElementType() const { return m_array_element_type; } + void setArrayElementType(AbstractMetaType::shared_pointer t) { m_array_element_type = t; } - QString cppSignature() const; + QString cppSignature() const; - AbstractMetaType::shared_pointer copy() const; + AbstractMetaType::shared_pointer copy() const; - const TypeEntry *typeEntry() const { return m_type_entry; } - void setTypeEntry(const TypeEntry *type) { m_type_entry = type; } + const TypeEntry* typeEntry() const { return m_type_entry; } + void setTypeEntry(const TypeEntry* type) { m_type_entry = type; } - void setOriginalTypeDescription(const QString &otd) { m_original_type_description = otd; } - QString originalTypeDescription() const { return m_original_type_description; } + void setOriginalTypeDescription(const QString& otd) { m_original_type_description = otd; } + QString originalTypeDescription() const { return m_original_type_description; } - void setOriginalTemplateType(AbstractMetaType::const_shared_pointer type) { m_original_template_type = type; } - AbstractMetaType::const_shared_pointer originalTemplateType() const { return m_original_template_type; } + void setOriginalTemplateType(AbstractMetaType::const_shared_pointer type) { m_original_template_type = type; } + AbstractMetaType::const_shared_pointer originalTemplateType() const { return m_original_template_type; } private: - const TypeEntry *m_type_entry{}; - QList m_instantiations; - QString m_package; - QString m_original_type_description; - - int m_array_element_count{}; - AbstractMetaType::shared_pointer m_array_element_type{}; - AbstractMetaType::const_shared_pointer m_original_template_type{}; - - TypeUsagePattern m_pattern{InvalidPattern}; - uint m_constant : 1; - uint m_reference : 1; - uint m_cpp_instantiation : 1; - int m_indirections : 4; - uint m_reserved : 25; // unused + const TypeEntry* m_type_entry {}; + QList m_instantiations; + QString m_package; + QString m_original_type_description; + + int m_array_element_count {}; + AbstractMetaType::shared_pointer m_array_element_type {}; + AbstractMetaType::const_shared_pointer m_original_template_type {}; + + TypeUsagePattern m_pattern {InvalidPattern}; + uint m_constant: 1; + uint m_reference: 1; + uint m_cpp_instantiation: 1; + int m_indirections: 4; + uint m_reserved: 25; // unused }; class AbstractMetaVariable { public: - AbstractMetaVariable() = default; - virtual ~AbstractMetaVariable(); + AbstractMetaVariable() = default; + virtual ~AbstractMetaVariable(); - AbstractMetaType::shared_pointer type() const { return m_type; } - void setType(AbstractMetaType::shared_pointer type) { m_type = type; } + AbstractMetaType::shared_pointer type() const { return m_type; } + void setType(AbstractMetaType::shared_pointer type) { m_type = type; } - QString name() const { return m_name; } - void setName(const QString &name) { m_name = name; } + QString name() const { return m_name; } + void setName(const QString& name) { m_name = name; } private: - QString m_name; - AbstractMetaType::shared_pointer m_type{}; + QString m_name; + AbstractMetaType::shared_pointer m_type {}; }; - - class AbstractMetaArgument : public AbstractMetaVariable { public: - AbstractMetaArgument() = default; + AbstractMetaArgument() = default; - QString defaultValueExpression() const { return m_expression; } - void setDefaultValueExpression(const QString &expr) { m_expression = expr; } + QString defaultValueExpression() const { return m_expression; } + void setDefaultValueExpression(const QString& expr) { m_expression = expr; } - QString originalDefaultValueExpression() const { return m_original_expression; } - void setOriginalDefaultValueExpression(const QString &expr) { m_original_expression = expr; } + QString originalDefaultValueExpression() const { return m_original_expression; } + void setOriginalDefaultValueExpression(const QString& expr) { m_original_expression = expr; } - QString toString() const { return type()->name() + " " + AbstractMetaVariable::name() + - (m_expression.isEmpty() ? "" : " = " + m_expression); } + QString toString() const + { + return type()->name() + " " + AbstractMetaVariable::name() + (m_expression.isEmpty() ? "" : " = " + m_expression); + } - int argumentIndex() const { return m_argument_index; } - void setArgumentIndex(int argIndex) { m_argument_index = argIndex; } + int argumentIndex() const { return m_argument_index; } + void setArgumentIndex(int argIndex) { m_argument_index = argIndex; } - QString argumentName() const; - QString indexedName() const; + QString argumentName() const; + QString indexedName() const; - AbstractMetaArgument *copy() const; + AbstractMetaArgument* copy() const; private: - // Just to force people to call argumentName() And indexedName(); - QString name() const; + // Just to force people to call argumentName() And indexedName(); + QString name() const; - QString m_expression; - QString m_original_expression; - int m_argument_index{}; + QString m_expression; + QString m_original_expression; + int m_argument_index {}; }; - class AbstractMetaField : public AbstractMetaVariable, public AbstractMetaAttributes { public: - AbstractMetaField() = default; - ~AbstractMetaField(); + AbstractMetaField() = default; + ~AbstractMetaField(); - const AbstractMetaClass *enclosingClass() const { return m_class; } - void setEnclosingClass(const AbstractMetaClass *cls) { m_class = cls; } + const AbstractMetaClass* enclosingClass() const { return m_class; } + void setEnclosingClass(const AbstractMetaClass* cls) { m_class = cls; } - const AbstractMetaFunction *getter() const; - const AbstractMetaFunction *setter() const; + const AbstractMetaFunction* getter() const; + const AbstractMetaFunction* setter() const; - FieldModificationList modifications() const; + FieldModificationList modifications() const; - AbstractMetaField *copy() const; + AbstractMetaField* copy() const; private: - mutable AbstractMetaFunction *m_getter{}; - mutable AbstractMetaFunction *m_setter{}; - const AbstractMetaClass *m_class{}; + mutable AbstractMetaFunction* m_getter {}; + mutable AbstractMetaFunction* m_setter {}; + const AbstractMetaClass* m_class {}; }; - class AbstractMetaFunction : public AbstractMetaAttributes { public: - enum FunctionType { - ConstructorFunction, - DestructorFunction, - NormalFunction, - SignalFunction, - EmptyFunction, - SlotFunction, - GlobalScopeFunction - }; - - enum CompareResult { - EqualName = 0x00000001, - EqualArguments = 0x00000002, - EqualAttributes = 0x00000004, - EqualImplementor = 0x00000008, - EqualReturnType = 0x00000010, - EqualDefaultValueOverload = 0x00000020, - EqualModifiedName = 0x00000040, - - NameLessThan = 0x00001000, - - PrettySimilar = EqualName | EqualArguments, - Equal = 0x0000001f, - NotEqual = 0x00001000 - }; - - AbstractMetaFunction() : - m_constant(false), - m_constexpr(false), - m_invalid(false) - { + enum FunctionType { + ConstructorFunction, + DestructorFunction, + NormalFunction, + SignalFunction, + EmptyFunction, + SlotFunction, + GlobalScopeFunction + }; + + enum CompareResult { + EqualName = 0x00000001, + EqualArguments = 0x00000002, + EqualAttributes = 0x00000004, + EqualImplementor = 0x00000008, + EqualReturnType = 0x00000010, + EqualDefaultValueOverload = 0x00000020, + EqualModifiedName = 0x00000040, + + NameLessThan = 0x00001000, + + PrettySimilar = EqualName | EqualArguments, + Equal = 0x0000001f, + NotEqual = 0x00001000 + }; + + AbstractMetaFunction() + : m_constant(false) + , m_constexpr(false) + , m_invalid(false) + { + } + + ~AbstractMetaFunction(); + + QString name() const { return m_name; } + void setName(const QString& name) { m_name = name; } + + QString originalName() const { return m_original_name.isEmpty() ? name() : m_original_name; } + void setOriginalName(const QString& name) { m_original_name = name; } + + QString modifiedName() const; + + QString minimalSignature() const; + QStringList possibleIntrospectionCompatibleSignatures() const; + + QString marshalledName() const; + + // true if one or more of the arguments are of QtJambiObject subclasses + bool argumentsHaveNativeId() const + { + for (const AbstractMetaArgument* arg : m_arguments) { + if (arg->type()->hasNativeId()) + return true; } - ~AbstractMetaFunction(); + return false; + } - QString name() const { return m_name; } - void setName(const QString &name) { m_name = name; } + bool isModifiedRemoved(int types = TypeSystem::All) const; - QString originalName() const { return m_original_name.isEmpty() ? name() : m_original_name; } - void setOriginalName(const QString &name) { m_original_name = name; } + AbstractMetaType::shared_pointer type() const { return m_type; } + void setType(AbstractMetaType::shared_pointer type) { m_type = type; } - QString modifiedName() const; + // The class that has this function as a member. + const AbstractMetaClass* ownerClass() const { return m_class; } + void setOwnerClass(const AbstractMetaClass* cls) { m_class = cls; } - QString minimalSignature() const; - QStringList possibleIntrospectionCompatibleSignatures() const; + // The first class in a hierarchy that declares the function + const AbstractMetaClass* declaringClass() const { return m_declaring_class; } + void setDeclaringClass(const AbstractMetaClass* cls) { m_declaring_class = cls; } - QString marshalledName() const; + // The class that actually implements this function + const AbstractMetaClass* implementingClass() const { return m_implementing_class; } + void setImplementingClass(const AbstractMetaClass* cls) { m_implementing_class = cls; } - // true if one or more of the arguments are of QtJambiObject subclasses - bool argumentsHaveNativeId() const - { - for (const AbstractMetaArgument* arg : m_arguments) { - if (arg->type()->hasNativeId()) - return true; - } + bool needsCallThrough() const; - return false; - } + AbstractMetaArgumentList arguments() const { return m_arguments; } + void setArguments(const AbstractMetaArgumentList& arguments) { m_arguments = arguments; } + void addArgument(AbstractMetaArgument* argument) { m_arguments << argument; } + int actualMinimumArgumentCount() const; - bool isModifiedRemoved(int types = TypeSystem::All) const; + void setInvalid(bool on) { m_invalid = on; } + bool isInvalid() const { return m_invalid; } + bool isDeprecated() const; + bool isDestructor() const { return functionType() == DestructorFunction; } + bool isConstructor() const { return functionType() == ConstructorFunction; } + bool isNormal() const { return functionType() == NormalFunction || isSlot() || isInGlobalScope(); } + bool isInGlobalScope() const { return functionType() == GlobalScopeFunction; } + bool isSignal() const { return functionType() == SignalFunction; } + bool isSlot() const { return functionType() == SlotFunction; } + bool isEmptyFunction() const { return functionType() == EmptyFunction; } + FunctionType functionType() const { return m_function_type; } + void setFunctionType(FunctionType type) { m_function_type = type; } - AbstractMetaType::shared_pointer type() const { return m_type; } - void setType(AbstractMetaType::shared_pointer type) { m_type = type; } + bool isVirtual() const { return !(isFinal() || isSignal() || isStatic()); } + QStringList introspectionCompatibleSignatures(const QStringList& resolvedArguments = QStringList()) const; + QString signature() const; + QString targetLangSignature(bool minimal = false) const; + bool shouldReturnThisObject() const { return QLatin1String("this") == argumentReplaced(0); } + bool shouldIgnoreReturnValue() const { return QLatin1String("void") == argumentReplaced(0); } - // The class that has this function as a member. - const AbstractMetaClass *ownerClass() const { return m_class; } - void setOwnerClass(const AbstractMetaClass *cls) { m_class = cls; } + bool isConstant() const { return m_constant; } + void setConstant(bool constant) { m_constant = constant; } - // The first class in a hierarchy that declares the function - const AbstractMetaClass *declaringClass() const { return m_declaring_class; } - void setDeclaringClass(const AbstractMetaClass *cls) { m_declaring_class = cls; } + bool isConstexpr() const { return m_constexpr; } + void setConstexpr(bool constant) { m_constexpr = constant; } - // The class that actually implements this function - const AbstractMetaClass *implementingClass() const { return m_implementing_class; } - void setImplementingClass(const AbstractMetaClass *cls) { m_implementing_class = cls; } + bool isAuto() const { return m_auto; } + void setAuto(bool isAuto) { m_auto = isAuto; } - bool needsCallThrough() const; + QString exception() const { return m_exception; } + void setException(const QString& exception) { m_exception = exception; } + QString toString() const { return m_name; } - AbstractMetaArgumentList arguments() const { return m_arguments; } - void setArguments(const AbstractMetaArgumentList &arguments) { m_arguments = arguments; } - void addArgument(AbstractMetaArgument *argument) { m_arguments << argument; } - int actualMinimumArgumentCount() const; + uint compareTo(const AbstractMetaFunction* other) const; - void setInvalid(bool on) { m_invalid = on; } - bool isInvalid() const { return m_invalid; } - bool isDeprecated() const; - bool isDestructor() const { return functionType() == DestructorFunction; } - bool isConstructor() const { return functionType() == ConstructorFunction; } - bool isNormal() const { return functionType() == NormalFunction || isSlot() || isInGlobalScope(); } - bool isInGlobalScope() const { return functionType() == GlobalScopeFunction; } - bool isSignal() const { return functionType() == SignalFunction; } - bool isSlot() const { return functionType() == SlotFunction; } - bool isEmptyFunction() const { return functionType() == EmptyFunction; } - FunctionType functionType() const { return m_function_type; } - void setFunctionType(FunctionType type) { m_function_type = type; } + bool operator<(const AbstractMetaFunction& a) const; - bool isVirtual() const { return !(isFinal() || isSignal() || isStatic()); } - QStringList introspectionCompatibleSignatures(const QStringList &resolvedArguments = QStringList()) const; - QString signature() const; - QString targetLangSignature(bool minimal = false) const; - bool shouldReturnThisObject() const { return QLatin1String("this") == argumentReplaced(0); } - bool shouldIgnoreReturnValue() const { return QLatin1String("void") == argumentReplaced(0); } + AbstractMetaFunction* copy() const; - bool isConstant() const { return m_constant; } - void setConstant(bool constant) { m_constant = constant; } + QString replacedDefaultExpression(const AbstractMetaClass* cls, int idx) const; + bool removedDefaultExpression(const AbstractMetaClass* cls, int idx) const; + QString conversionRule(TypeSystem::Language language, int idx) const; + QList referenceCounts(const AbstractMetaClass* cls, int idx = -2) const; - bool isConstexpr() const { return m_constexpr; } - void setConstexpr(bool constant) { m_constexpr = constant; } + bool nullPointersDisabled(const AbstractMetaClass* cls = 0, int argument_idx = 0) const; + QString nullPointerDefaultValue(const AbstractMetaClass* cls = 0, int argument_idx = 0) const; - bool isAuto() const { return m_auto; } - void setAuto(bool isAuto) { m_auto = isAuto; } + bool resetObjectAfterUse(int argument_idx) const; - QString exception() const { return m_exception; } - void setException(const QString &exception) { m_exception = exception; } - QString toString() const { return m_name; } + // Returns whether garbage collection is disabled for the argument in any context + bool disabledGarbageCollection(const AbstractMetaClass* cls, int key) const; - uint compareTo(const AbstractMetaFunction *other) const; + // Returns the ownership rules for the given argument in the given context + TypeSystem::Ownership ownership(const AbstractMetaClass* cls, TypeSystem::Language language, int idx) const; - bool operator <(const AbstractMetaFunction &a) const; + bool isVirtualSlot() const; - AbstractMetaFunction *copy() const; + QString typeReplaced(int argument_index) const; + bool isRemovedFromAllLanguages(const AbstractMetaClass*) const; + bool isRemovedFrom(const AbstractMetaClass*, TypeSystem::Language language) const; + bool argumentRemoved(int) const; - QString replacedDefaultExpression(const AbstractMetaClass *cls, int idx) const; - bool removedDefaultExpression(const AbstractMetaClass *cls, int idx) const; - QString conversionRule(TypeSystem::Language language, int idx) const; - QList referenceCounts(const AbstractMetaClass *cls, int idx = -2) const; + QString argumentReplaced(int key) const; + bool needsSuppressUncheckedWarning() const; - bool nullPointersDisabled(const AbstractMetaClass *cls = 0, int argument_idx = 0) const; - QString nullPointerDefaultValue(const AbstractMetaClass *cls = 0, int argument_idx = 0) const; + bool hasModifications(const AbstractMetaClass* implementor) const; + FunctionModificationList modifications(const AbstractMetaClass* implementor) const; - bool resetObjectAfterUse(int argument_idx) const; + // If this function stems from an interface, this returns the + // interface that declares it. + const AbstractMetaClass* interfaceClass() const { return m_interface_class; } + void setInterfaceClass(const AbstractMetaClass* cl) { m_interface_class = cl; } - // Returns whether garbage collection is disabled for the argument in any context - bool disabledGarbageCollection(const AbstractMetaClass *cls, int key) const; - - // Returns the ownership rules for the given argument in the given context - TypeSystem::Ownership ownership(const AbstractMetaClass *cls, TypeSystem::Language language, int idx) const; - - bool isVirtualSlot() const; - - QString typeReplaced(int argument_index) const; - bool isRemovedFromAllLanguages(const AbstractMetaClass *) const; - bool isRemovedFrom(const AbstractMetaClass *, TypeSystem::Language language) const; - bool argumentRemoved(int) const; - - QString argumentReplaced(int key) const; - bool needsSuppressUncheckedWarning() const; - - bool hasModifications(const AbstractMetaClass *implementor) const; - FunctionModificationList modifications(const AbstractMetaClass *implementor) const; - - // If this function stems from an interface, this returns the - // interface that declares it. - const AbstractMetaClass *interfaceClass() const { return m_interface_class; } - void setInterfaceClass(const AbstractMetaClass *cl) { m_interface_class = cl; } - - void setPropertySpec(QPropertySpec *spec) { m_property_spec = spec; } - QPropertySpec *propertySpec() const { return m_property_spec; } + void setPropertySpec(QPropertySpec* spec) { m_property_spec = spec; } + QPropertySpec* propertySpec() const { return m_property_spec; } private: - QString m_name; - QString m_original_name; - mutable QString m_cached_minimal_signature; - mutable QString m_cached_modified_name; - - FunctionType m_function_type{NormalFunction}; - AbstractMetaType::shared_pointer m_type{}; - const AbstractMetaClass *m_class{}; - const AbstractMetaClass *m_implementing_class{}; - const AbstractMetaClass *m_declaring_class{}; - const AbstractMetaClass *m_interface_class{}; - QPropertySpec *m_property_spec{}; - AbstractMetaArgumentList m_arguments; - QString m_exception; - uint m_constant : 1; - uint m_constexpr : 1; - uint m_auto : 1; - uint m_invalid : 1; + QString m_name; + QString m_original_name; + mutable QString m_cached_minimal_signature; + mutable QString m_cached_modified_name; + + FunctionType m_function_type {NormalFunction}; + AbstractMetaType::shared_pointer m_type {}; + const AbstractMetaClass* m_class {}; + const AbstractMetaClass* m_implementing_class {}; + const AbstractMetaClass* m_declaring_class {}; + const AbstractMetaClass* m_interface_class {}; + QPropertySpec* m_property_spec {}; + AbstractMetaArgumentList m_arguments; + QString m_exception; + uint m_constant: 1; + uint m_constexpr: 1; + uint m_auto: 1; + uint m_invalid: 1; }; - class AbstractMetaEnumValue { public: - AbstractMetaEnumValue() = default; + AbstractMetaEnumValue() = default; - int value() const { return m_value; } - void setValue(int value) { m_value_set = true; m_value = value; } + int value() const { return m_value; } + void setValue(int value) + { + m_value_set = true; + m_value = value; + } - QString stringValue() const { return m_string_value; } - void setStringValue(const QString &v) { m_string_value = v; } + QString stringValue() const { return m_string_value; } + void setStringValue(const QString& v) { m_string_value = v; } - QString name() const { return m_name; } - void setName(const QString &name) { m_name = name; } + QString name() const { return m_name; } + void setName(const QString& name) { m_name = name; } - bool isValueSet() const { return m_value_set; } + bool isValueSet() const { return m_value_set; } private: - QString m_name; - QString m_string_value; + QString m_name; + QString m_string_value; - bool m_value_set{}; - int m_value{}; + bool m_value_set {}; + int m_value {}; }; - -class AbstractMetaEnumValueList : public QList +class AbstractMetaEnumValueList : public QList { public: - AbstractMetaEnumValue *find(const QString &name) const; + AbstractMetaEnumValue* find(const QString& name) const; }; class AbstractMetaEnum : public AbstractMetaAttributes { public: - AbstractMetaEnum() : m_has_qenums_declaration(false) {} - ~AbstractMetaEnum() { qDeleteAll(m_enum_values); } + AbstractMetaEnum() + : m_has_qenums_declaration(false) + { + } + ~AbstractMetaEnum() { qDeleteAll(m_enum_values); } - AbstractMetaEnumValueList values() const { return m_enum_values; } - void addEnumValue(AbstractMetaEnumValue *enumValue) { m_enum_values << enumValue; } + AbstractMetaEnumValueList values() const { return m_enum_values; } + void addEnumValue(AbstractMetaEnumValue* enumValue) { m_enum_values << enumValue; } - QString name() const { return m_type_entry->targetLangName(); } - QString qualifier() const { return m_type_entry->javaQualifier(); } - QString package() const { return m_type_entry->javaPackage(); } - QString fullName() const { return package() + "." + qualifier() + "." + name(); } + QString name() const { return m_type_entry->targetLangName(); } + QString qualifier() const { return m_type_entry->javaQualifier(); } + QString package() const { return m_type_entry->javaPackage(); } + QString fullName() const { return package() + "." + qualifier() + "." + name(); } - // Has the enum been declared inside a Q_ENUMS() macro in its enclosing class? - void setHasQEnumsDeclaration(bool on) { m_has_qenums_declaration = on; } - bool hasQEnumsDeclaration() const { return m_has_qenums_declaration; } + // Has the enum been declared inside a Q_ENUMS() macro in its enclosing class? + void setHasQEnumsDeclaration(bool on) { m_has_qenums_declaration = on; } + bool hasQEnumsDeclaration() const { return m_has_qenums_declaration; } - EnumTypeEntry *typeEntry() const { return m_type_entry; } - void setTypeEntry(EnumTypeEntry *entry) { m_type_entry = entry; } + EnumTypeEntry* typeEntry() const { return m_type_entry; } + void setTypeEntry(EnumTypeEntry* entry) { m_type_entry = entry; } - AbstractMetaClass *enclosingClass() const { return m_class; } - void setEnclosingClass(AbstractMetaClass *c) { m_class = c; } + AbstractMetaClass* enclosingClass() const { return m_class; } + void setEnclosingClass(AbstractMetaClass* c) { m_class = c; } private: - AbstractMetaEnumValueList m_enum_values; - EnumTypeEntry *m_type_entry{}; - AbstractMetaClass *m_class{}; + AbstractMetaEnumValueList m_enum_values; + EnumTypeEntry* m_type_entry {}; + AbstractMetaClass* m_class {}; - uint m_has_qenums_declaration : 1; - uint m_reserved : 31; + uint m_has_qenums_declaration: 1; + uint m_reserved: 31; }; -typedef QList AbstractMetaEnumList; +typedef QList AbstractMetaEnumList; class AbstractMetaClass : public AbstractMetaAttributes { public: - enum FunctionQueryOption { - Constructors = 0x000001, // Only constructors - //Destructors = 0x000002, // Only destructors. Not included in class. - VirtualFunctions = 0x000004, // Only virtual functions (virtual in both TargetLang and C++) - FinalInTargetLangFunctions = 0x000008, // Only functions that are non-virtual in TargetLang - FinalInCppFunctions = 0x000010, // Only functions that are non-virtual in C++ - ClassImplements = 0x000020, // Only functions implemented by the current class - Inconsistent = 0x000040, // Only inconsistent functions (inconsistent virtualness in TargetLang/C++) - StaticFunctions = 0x000080, // Only static functions - Signals = 0x000100, // Only signals - NormalFunctions = 0x000200, // Only functions that aren't signals - Visible = 0x000400, // Only public and protected functions - ForcedShellFunctions = 0x000800, // Only functions that are overridden to be implemented in the shell class - WasPublic = 0x001000, // Only functions that were originally public - WasProtected = 0x002000, // Only functions that were originally protected - NonStaticFunctions = 0x004000, // No static functions - Empty = 0x008000, // Empty overrides of abstract functions - Invisible = 0x010000, // Only private functions - VirtualInCppFunctions = 0x020000, // Only functions that are virtual in C++ - NonEmptyFunctions = 0x040000, // Only functions with JNI implementations - VirtualInTargetLangFunctions = 0x080000, // Only functions which are virtual in TargetLang - AbstractFunctions = 0x100000, // Only abstract functions - WasVisible = 0x200000, // Only functions that were public or protected in the original code - NotRemovedFromTargetLang = 0x400000, // Only functions that have not been removed from TargetLang - NotRemovedFromShell = 0x800000, // Only functions that have not been removed from the shell class - VirtualSlots = 0x1000000 // Only functions that are set as virtual slots in the type system - }; - - AbstractMetaClass() - : m_namespace(false), - m_qobject(false), - m_has_virtuals(false), - m_has_nonpublic(false), - m_has_virtual_slots(false), - m_has_nonprivateconstructor(false), - m_functions_fixed(false), - m_has_public_destructor(true), - m_has_virtual_destructor(false), - m_force_shell_class(false), - m_has_hash_function(false), - m_has_equals_operator(false), - m_has_clone_operator(false), - m_is_type_alias(false), - m_has_actual_declaration(false), - m_is_global_namespace(false), - m_qDebug_stream_function(0) - { - } + enum FunctionQueryOption { + Constructors = 0x000001, // Only constructors + //Destructors = 0x000002, // Only destructors. Not included in class. + VirtualFunctions = 0x000004, // Only virtual functions (virtual in both TargetLang and C++) + FinalInTargetLangFunctions = 0x000008, // Only functions that are non-virtual in TargetLang + FinalInCppFunctions = 0x000010, // Only functions that are non-virtual in C++ + ClassImplements = 0x000020, // Only functions implemented by the current class + Inconsistent = 0x000040, // Only inconsistent functions (inconsistent virtualness in TargetLang/C++) + StaticFunctions = 0x000080, // Only static functions + Signals = 0x000100, // Only signals + NormalFunctions = 0x000200, // Only functions that aren't signals + Visible = 0x000400, // Only public and protected functions + ForcedShellFunctions = 0x000800, // Only functions that are overridden to be implemented in the shell class + WasPublic = 0x001000, // Only functions that were originally public + WasProtected = 0x002000, // Only functions that were originally protected + NonStaticFunctions = 0x004000, // No static functions + Empty = 0x008000, // Empty overrides of abstract functions + Invisible = 0x010000, // Only private functions + VirtualInCppFunctions = 0x020000, // Only functions that are virtual in C++ + NonEmptyFunctions = 0x040000, // Only functions with JNI implementations + VirtualInTargetLangFunctions = 0x080000, // Only functions which are virtual in TargetLang + AbstractFunctions = 0x100000, // Only abstract functions + WasVisible = 0x200000, // Only functions that were public or protected in the original code + NotRemovedFromTargetLang = 0x400000, // Only functions that have not been removed from TargetLang + NotRemovedFromShell = 0x800000, // Only functions that have not been removed from the shell class + VirtualSlots = 0x1000000 // Only functions that are set as virtual slots in the type system + }; + + AbstractMetaClass() + : m_namespace(false) + , m_qobject(false) + , m_has_virtuals(false) + , m_has_nonpublic(false) + , m_has_virtual_slots(false) + , m_has_nonprivateconstructor(false) + , m_functions_fixed(false) + , m_has_public_destructor(true) + , m_has_virtual_destructor(false) + , m_force_shell_class(false) + , m_has_hash_function(false) + , m_has_equals_operator(false) + , m_has_clone_operator(false) + , m_is_type_alias(false) + , m_has_actual_declaration(false) + , m_is_global_namespace(false) + , m_qDebug_stream_function(0) + { + } + + virtual ~AbstractMetaClass(); + + AbstractMetaClass* extractInterface(); + void fixFunctions(); + + AbstractMetaFunctionList functions() const { return m_functions; } + void setFunctions(const AbstractMetaFunctionList& functions); + void addFunction(AbstractMetaFunction* function, bool check_duplicates = false); + void removeFunction(AbstractMetaFunction* function); + bool hasFunction(const AbstractMetaFunction* f) const; + bool hasFunction(const QString& str) const; + bool hasSignal(const AbstractMetaFunction* f) const; + + bool hasConstructors() const; + + void addDefaultConstructor(); + + bool hasNonPrivateConstructor() const { return m_has_nonprivateconstructor; } + void setHasNonPrivateConstructor(bool on) { m_has_nonprivateconstructor = on; } + bool hasPublicDestructor() const { return m_has_public_destructor; } + void setHasPublicDestructor(bool on) { m_has_public_destructor = on; } + bool hasVirtualDestructor() const; + void setHasVirtualDestructor(bool on) { m_has_virtual_destructor = on; } + + QString destructorException() const { return m_destructor_exception; } + void setDestructorException(const QString& exception) { m_destructor_exception = exception; } + AbstractMetaFunctionList queryFunctionsByName(const QString& name) const; + AbstractMetaFunctionList queryFunctions(uint query) const; + inline AbstractMetaFunctionList allVirtualFunctions() const; + inline AbstractMetaFunctionList allFinalFunctions() const; + AbstractMetaFunctionList functionsInTargetLang() const; + AbstractMetaFunctionList functionsInShellClass() const; + inline AbstractMetaFunctionList cppInconsistentFunctions() const; + inline AbstractMetaFunctionList cppSignalFunctions() const; + AbstractMetaFunctionList publicOverrideFunctions() const; + AbstractMetaFunctionList virtualOverrideFunctions() const; + AbstractMetaFunctionList virtualFunctions() const; + AbstractMetaFunctionList nonVirtualShellFunctions() const; + + AbstractMetaFieldList fields() const { return m_fields; } + void setFields(const AbstractMetaFieldList& fields) { m_fields = fields; } + void addField(AbstractMetaField* field) { m_fields << field; } + + AbstractMetaEnumList enums() const { return m_enums; } + void setEnums(const AbstractMetaEnumList& enums) { m_enums = enums; } + void addEnum(AbstractMetaEnum* e) { m_enums << e; } + + AbstractMetaEnum* findEnum(const QString& enumName); + AbstractMetaEnum* findEnumForValue(const QString& enumName); + AbstractMetaEnumValue* findEnumValue(const QString& enumName, AbstractMetaEnum* meta_enum); + + AbstractMetaClassList interfaces() const { return m_interfaces; } + void addInterface(AbstractMetaClass* interface); + void setInterfaces(const AbstractMetaClassList& interface); + + QString fullName() const { return package() + "." + name(); } + QString name() const; + + QString baseClassName() const { return m_base_class ? m_base_class->name() : QString(); } + + AbstractMetaClass* baseClass() const { return m_base_class; } + void setBaseClass(AbstractMetaClass* base_class) { m_base_class = base_class; } + + // this lists _all_ super classes of this class + QList superClasses() const { return m_super_classes; } + void addSuperClass(AbstractMetaClass* super_class) { m_super_classes.append(super_class); } + + const AbstractMetaClass* enclosingClass() const { return m_enclosing_class; } + void setEnclosingClass(AbstractMetaClass* cl) { m_enclosing_class = cl; } - virtual ~AbstractMetaClass(); + QString package() const { return m_type_entry->javaPackage(); } + bool isInterface() const { return m_type_entry->isInterface(); } + bool isNamespace() const { return m_type_entry->isNamespace(); } + bool isQObject() const { return m_type_entry->isQObject(); } + bool isQtNamespace() const { return isNamespace() && name() == "Qt"; } + QString qualifiedCppName() const { return m_type_entry->qualifiedCppName(); } - AbstractMetaClass *extractInterface(); - void fixFunctions(); + bool hasInconsistentFunctions() const; + bool hasSignals() const; + bool inheritsFrom(const AbstractMetaClass* other) const; - AbstractMetaFunctionList functions() const { return m_functions; } - void setFunctions(const AbstractMetaFunctionList &functions); - void addFunction(AbstractMetaFunction *function, bool check_duplicates = false); - void removeFunction(AbstractMetaFunction* function); - bool hasFunction(const AbstractMetaFunction *f) const; - bool hasFunction(const QString &str) const; - bool hasSignal(const AbstractMetaFunction *f) const; + void setForceShellClass(bool on) { m_force_shell_class = on; } + bool generateShellClass() const; - bool hasConstructors() const; + bool hasVirtualSlots() const { return m_has_virtual_slots; } + bool hasVirtualFunctions() const { return !isFinal() && m_has_virtuals; } + bool hasProtectedFunctions() const; - void addDefaultConstructor(); + QList templateArguments() const { return m_template_args; } + void setTemplateArguments(const QList& args) { m_template_args = args; } - bool hasNonPrivateConstructor() const { return m_has_nonprivateconstructor; } - void setHasNonPrivateConstructor(bool on) { m_has_nonprivateconstructor = on; } - bool hasPublicDestructor() const { return m_has_public_destructor; } - void setHasPublicDestructor(bool on) { m_has_public_destructor = on; } - bool hasVirtualDestructor() const; - void setHasVirtualDestructor(bool on) { m_has_virtual_destructor = on; } + bool hasFieldAccessors() const; - QString destructorException() const { return m_destructor_exception; } - void setDestructorException(const QString &exception) { m_destructor_exception = exception; } - AbstractMetaFunctionList queryFunctionsByName(const QString &name) const; - AbstractMetaFunctionList queryFunctions(uint query) const; - inline AbstractMetaFunctionList allVirtualFunctions() const; - inline AbstractMetaFunctionList allFinalFunctions() const; - AbstractMetaFunctionList functionsInTargetLang() const; - AbstractMetaFunctionList functionsInShellClass() const; - inline AbstractMetaFunctionList cppInconsistentFunctions() const; - inline AbstractMetaFunctionList cppSignalFunctions() const; - AbstractMetaFunctionList publicOverrideFunctions() const; - AbstractMetaFunctionList virtualOverrideFunctions() const; - AbstractMetaFunctionList virtualFunctions() const; - AbstractMetaFunctionList nonVirtualShellFunctions() const; + // only valid during metajavabuilder's run + QStringList baseClassNames() const { return m_base_class_names; } + void setBaseClassNames(const QStringList& names) { m_base_class_names = names; } - AbstractMetaFieldList fields() const { return m_fields; } - void setFields(const AbstractMetaFieldList &fields) { m_fields = fields; } - void addField(AbstractMetaField *field) { m_fields << field; } + AbstractMetaClass* primaryInterfaceImplementor() const { return m_primary_interface_implementor; } + void setPrimaryInterfaceImplementor(AbstractMetaClass* cl) { m_primary_interface_implementor = cl; } - AbstractMetaEnumList enums() const { return m_enums; } - void setEnums(const AbstractMetaEnumList &enums) { m_enums = enums; } - void addEnum(AbstractMetaEnum *e) { m_enums << e; } + const ComplexTypeEntry* typeEntry() const { return m_type_entry; } + ComplexTypeEntry* typeEntry() { return m_type_entry; } + void setTypeEntry(ComplexTypeEntry* type) { m_type_entry = type; } - AbstractMetaEnum *findEnum(const QString &enumName); - AbstractMetaEnum *findEnumForValue(const QString &enumName); - AbstractMetaEnumValue *findEnumValue(const QString &enumName, AbstractMetaEnum *meta_enum); + void setHasHashFunction(bool on) { m_has_hash_function = on; } + bool hasHashFunction() const { return m_has_hash_function; } - AbstractMetaClassList interfaces() const { return m_interfaces; } - void addInterface(AbstractMetaClass *interface); - void setInterfaces(const AbstractMetaClassList &interface); + void setToStringCapability(FunctionModelItem fun) { m_qDebug_stream_function = fun; } + FunctionModelItem hasToStringCapability() const { return m_qDebug_stream_function; } - QString fullName() const { return package() + "." + name(); } - QString name() const; + virtual bool hasDefaultToStringFunction() const; - QString baseClassName() const { return m_base_class ? m_base_class->name() : QString(); } + void setHasEqualsOperator(bool on) { m_has_equals_operator = on; } + bool hasEqualsOperator() const { return m_has_equals_operator; } - AbstractMetaClass *baseClass() const { return m_base_class; } - void setBaseClass(AbstractMetaClass *base_class) { m_base_class = base_class; } + void setHasCloneOperator(bool on) { m_has_clone_operator = on; } + bool hasCloneOperator() const { return m_has_clone_operator; } - // this lists _all_ super classes of this class - QList superClasses() const { return m_super_classes; } - void addSuperClass(AbstractMetaClass *super_class) { m_super_classes.append(super_class); } + void setHasActualDeclaration(bool on) { m_has_actual_declaration = on; } + bool hasActualDeclaration() const { return m_has_actual_declaration; } - const AbstractMetaClass *enclosingClass() const { return m_enclosing_class; } - void setEnclosingClass(AbstractMetaClass *cl) { m_enclosing_class = cl; } + void setIsGlobalNamespace(bool on) { m_is_global_namespace = on; } + bool isGlobalNamespace() const { return m_is_global_namespace; } - QString package() const { return m_type_entry->javaPackage(); } - bool isInterface() const { return m_type_entry->isInterface(); } - bool isNamespace() const { return m_type_entry->isNamespace(); } - bool isQObject() const { return m_type_entry->isQObject(); } - bool isQtNamespace() const { return isNamespace() && name() == "Qt"; } - QString qualifiedCppName() const { return m_type_entry->qualifiedCppName(); } + QString getDefaultNonZeroFunction() const; - bool hasInconsistentFunctions() const; - bool hasSignals() const; - bool inheritsFrom(const AbstractMetaClass *other) const; + void addPropertySpec(QPropertySpec* spec) { m_property_specs << spec; } + QList propertySpecs() const { return m_property_specs; } - void setForceShellClass(bool on) { m_force_shell_class = on; } - bool generateShellClass() const; + QPropertySpec* propertySpecForRead(const QString& name) const; + QPropertySpec* propertySpecForWrite(const QString& name) const; + QPropertySpec* propertySpecForReset(const QString& name) const; - bool hasVirtualSlots() const { return m_has_virtual_slots; } - bool hasVirtualFunctions() const { return !isFinal() && m_has_virtuals; } - bool hasProtectedFunctions() const; + QList referenceCounts() const; - QList templateArguments() const { return m_template_args; } - void setTemplateArguments(const QList &args) { m_template_args = args; } + void setEqualsFunctions(const AbstractMetaFunctionList& lst) { m_equals_functions = lst; } + AbstractMetaFunctionList equalsFunctions() const { return m_equals_functions; } - bool hasFieldAccessors() const; + void setNotEqualsFunctions(const AbstractMetaFunctionList& lst) { m_nequals_functions = lst; } + AbstractMetaFunctionList notEqualsFunctions() const { return m_nequals_functions; } - // only valid during metajavabuilder's run - QStringList baseClassNames() const { return m_base_class_names; } - void setBaseClassNames(const QStringList &names) { m_base_class_names = names; } + void setLessThanFunctions(const AbstractMetaFunctionList& lst) { m_less_than_functions = lst; } + AbstractMetaFunctionList lessThanFunctions() const { return m_less_than_functions; } - AbstractMetaClass *primaryInterfaceImplementor() const { return m_primary_interface_implementor; } - void setPrimaryInterfaceImplementor(AbstractMetaClass *cl) { m_primary_interface_implementor = cl; } + void setGreaterThanFunctions(const AbstractMetaFunctionList& lst) { m_greater_than_functions = lst; } + AbstractMetaFunctionList greaterThanFunctions() const { return m_greater_than_functions; } - const ComplexTypeEntry *typeEntry() const { return m_type_entry; } - ComplexTypeEntry *typeEntry() { return m_type_entry; } - void setTypeEntry(ComplexTypeEntry *type) { m_type_entry = type; } + void setLessThanEqFunctions(const AbstractMetaFunctionList& lst) { m_less_than_eq_functions = lst; } + AbstractMetaFunctionList lessThanEqFunctions() const { return m_less_than_eq_functions; } - void setHasHashFunction(bool on) { m_has_hash_function = on; } - bool hasHashFunction() const { return m_has_hash_function; } + void setGreaterThanEqFunctions(const AbstractMetaFunctionList& lst) { m_greater_than_eq_functions = lst; } + AbstractMetaFunctionList greaterThanEqFunctions() const { return m_greater_than_eq_functions; } - void setToStringCapability(FunctionModelItem fun) { m_qDebug_stream_function= fun; } - FunctionModelItem hasToStringCapability() const { return m_qDebug_stream_function; } + void sortFunctions(); - virtual bool hasDefaultToStringFunction() const; + const AbstractMetaClass* templateBaseClass() const { return m_template_base_class; } + void setTemplateBaseClass(const AbstractMetaClass* cls) { m_template_base_class = cls; } - void setHasEqualsOperator(bool on) { m_has_equals_operator = on; } - bool hasEqualsOperator() const { return m_has_equals_operator; } + void setTypeAlias(bool typeAlias) { m_is_type_alias = typeAlias; } + bool isTypeAlias() const { return m_is_type_alias; } + bool operator<(const AbstractMetaClass& a) const { return qualifiedCppName() < a.qualifiedCppName(); } - void setHasCloneOperator(bool on) { m_has_clone_operator = on; } - bool hasCloneOperator() const { return m_has_clone_operator; } - - void setHasActualDeclaration(bool on) { m_has_actual_declaration = on; } - bool hasActualDeclaration() const { return m_has_actual_declaration; } - - void setIsGlobalNamespace(bool on) { m_is_global_namespace = on; } - bool isGlobalNamespace() const { return m_is_global_namespace; } - - QString getDefaultNonZeroFunction() const; - - void addPropertySpec(QPropertySpec *spec) { m_property_specs << spec; } - QList propertySpecs() const { return m_property_specs; } - - QPropertySpec *propertySpecForRead(const QString &name) const; - QPropertySpec *propertySpecForWrite(const QString &name) const; - QPropertySpec *propertySpecForReset(const QString &name) const; - - QList referenceCounts() const; - - void setEqualsFunctions(const AbstractMetaFunctionList &lst) { m_equals_functions = lst; } - AbstractMetaFunctionList equalsFunctions() const { return m_equals_functions; } - - void setNotEqualsFunctions(const AbstractMetaFunctionList &lst) { m_nequals_functions = lst; } - AbstractMetaFunctionList notEqualsFunctions() const { return m_nequals_functions; } - - void setLessThanFunctions(const AbstractMetaFunctionList &lst) { m_less_than_functions = lst; } - AbstractMetaFunctionList lessThanFunctions() const { return m_less_than_functions; } - - void setGreaterThanFunctions(const AbstractMetaFunctionList &lst) { m_greater_than_functions = lst; } - AbstractMetaFunctionList greaterThanFunctions() const { return m_greater_than_functions; } - - void setLessThanEqFunctions(const AbstractMetaFunctionList &lst) { m_less_than_eq_functions = lst; } - AbstractMetaFunctionList lessThanEqFunctions() const { return m_less_than_eq_functions; } - - void setGreaterThanEqFunctions(const AbstractMetaFunctionList &lst) { m_greater_than_eq_functions = lst; } - AbstractMetaFunctionList greaterThanEqFunctions() const { return m_greater_than_eq_functions; } - - void sortFunctions(); - - const AbstractMetaClass *templateBaseClass() const { return m_template_base_class; } - void setTemplateBaseClass(const AbstractMetaClass *cls) { m_template_base_class = cls; } - - void setTypeAlias(bool typeAlias) { m_is_type_alias = typeAlias; } - bool isTypeAlias() const { return m_is_type_alias; } - bool operator <(const AbstractMetaClass &a) const { - return qualifiedCppName() < a.qualifiedCppName(); - } - - static bool less_than(const AbstractMetaClass *cl, - const AbstractMetaClass *cr) { - return cl->name() < cr->name(); - } + static bool less_than(const AbstractMetaClass* cl, const AbstractMetaClass* cr) { return cl->name() < cr->name(); } private: - uint m_namespace : 1; - uint m_qobject : 1; - uint m_has_virtuals : 1; - uint m_has_nonpublic : 1; - uint m_has_virtual_slots : 1; - uint m_has_nonprivateconstructor : 1; - uint m_functions_fixed : 1; - uint m_has_public_destructor : 1; - uint m_has_virtual_destructor : 1; - uint m_force_shell_class : 1; - uint m_has_hash_function : 1; - uint m_has_equals_operator : 1; - uint m_has_clone_operator :1; - uint m_is_type_alias : 1; - uint m_has_actual_declaration : 1; - uint m_is_global_namespace : 1; - uint m_reserved : 16; - QString m_destructor_exception; - - const AbstractMetaClass *m_enclosing_class{}; - AbstractMetaClass *m_base_class{}; - QList m_super_classes; - const AbstractMetaClass *m_template_base_class{}; - AbstractMetaFunctionList m_functions; - AbstractMetaFieldList m_fields; - AbstractMetaEnumList m_enums; - AbstractMetaClassList m_interfaces; - AbstractMetaClass *m_extracted_interface{}; - AbstractMetaClass *m_primary_interface_implementor{}; - QList m_property_specs; - AbstractMetaFunctionList m_equals_functions; - AbstractMetaFunctionList m_nequals_functions; - - AbstractMetaFunctionList m_less_than_functions; - AbstractMetaFunctionList m_greater_than_functions; - AbstractMetaFunctionList m_less_than_eq_functions; - AbstractMetaFunctionList m_greater_than_eq_functions; - - QStringList m_base_class_names; - QList m_template_args; - ComplexTypeEntry *m_type_entry{}; - FunctionModelItem m_qDebug_stream_function; + uint m_namespace: 1; + uint m_qobject: 1; + uint m_has_virtuals: 1; + uint m_has_nonpublic: 1; + uint m_has_virtual_slots: 1; + uint m_has_nonprivateconstructor: 1; + uint m_functions_fixed: 1; + uint m_has_public_destructor: 1; + uint m_has_virtual_destructor: 1; + uint m_force_shell_class: 1; + uint m_has_hash_function: 1; + uint m_has_equals_operator: 1; + uint m_has_clone_operator: 1; + uint m_is_type_alias: 1; + uint m_has_actual_declaration: 1; + uint m_is_global_namespace: 1; + uint m_reserved: 16; + QString m_destructor_exception; + + const AbstractMetaClass* m_enclosing_class {}; + AbstractMetaClass* m_base_class {}; + QList m_super_classes; + const AbstractMetaClass* m_template_base_class {}; + AbstractMetaFunctionList m_functions; + AbstractMetaFieldList m_fields; + AbstractMetaEnumList m_enums; + AbstractMetaClassList m_interfaces; + AbstractMetaClass* m_extracted_interface {}; + AbstractMetaClass* m_primary_interface_implementor {}; + QList m_property_specs; + AbstractMetaFunctionList m_equals_functions; + AbstractMetaFunctionList m_nequals_functions; + + AbstractMetaFunctionList m_less_than_functions; + AbstractMetaFunctionList m_greater_than_functions; + AbstractMetaFunctionList m_less_than_eq_functions; + AbstractMetaFunctionList m_greater_than_eq_functions; + + QStringList m_base_class_names; + QList m_template_args; + ComplexTypeEntry* m_type_entry {}; + FunctionModelItem m_qDebug_stream_function; }; -class QPropertySpec { +class QPropertySpec +{ public: - QPropertySpec(const TypeEntry *type) - : m_type(type), - m_index(-1) - { - } + QPropertySpec(const TypeEntry* type) + : m_type(type) + , m_index(-1) + { + } - const TypeEntry *type() const { return m_type; } + const TypeEntry* type() const { return m_type; } - QString name() const { return m_name; } - void setName(const QString &name) { m_name = name; } + QString name() const { return m_name; } + void setName(const QString& name) { m_name = name; } - QString read() const { return m_read; } - void setRead(const QString &read) { m_read = read; } + QString read() const { return m_read; } + void setRead(const QString& read) { m_read = read; } - QString write() const { return m_write; } - void setWrite(const QString &write) { m_write = write; } + QString write() const { return m_write; } + void setWrite(const QString& write) { m_write = write; } - QString designable() const { return m_designable; } - void setDesignable(const QString &designable) { m_designable = designable; } + QString designable() const { return m_designable; } + void setDesignable(const QString& designable) { m_designable = designable; } - QString reset() const { return m_reset; } - void setReset(const QString &reset) { m_reset = reset; } + QString reset() const { return m_reset; } + void setReset(const QString& reset) { m_reset = reset; } - int index() const { return m_index; } - void setIndex(int index) { m_index = index; } + int index() const { return m_index; } + void setIndex(int index) { m_index = index; } private: - QString m_name; - QString m_read; - QString m_write; - QString m_designable; - QString m_reset; - const TypeEntry *m_type{}; - int m_index{-1}; + QString m_name; + QString m_read; + QString m_write; + QString m_designable; + QString m_reset; + const TypeEntry* m_type {}; + int m_index {-1}; }; inline AbstractMetaFunctionList AbstractMetaClass::allVirtualFunctions() const { - return queryFunctions(VirtualFunctions - | NotRemovedFromTargetLang); + return queryFunctions(VirtualFunctions | NotRemovedFromTargetLang); } inline AbstractMetaFunctionList AbstractMetaClass::allFinalFunctions() const { - return queryFunctions(FinalInTargetLangFunctions - | FinalInCppFunctions - | NotRemovedFromTargetLang); + return queryFunctions(FinalInTargetLangFunctions | FinalInCppFunctions | NotRemovedFromTargetLang); } inline AbstractMetaFunctionList AbstractMetaClass::cppInconsistentFunctions() const { - return queryFunctions(Inconsistent - | NormalFunctions - | Visible - | NotRemovedFromTargetLang); + return queryFunctions(Inconsistent | NormalFunctions | Visible | NotRemovedFromTargetLang); } inline AbstractMetaFunctionList AbstractMetaClass::cppSignalFunctions() const { - return queryFunctions(Signals - | Visible - | NotRemovedFromTargetLang); + return queryFunctions(Signals | Visible | NotRemovedFromTargetLang); } #endif // ABSTRACTMETALANG_H diff --git a/generator/asttoxml.cpp b/generator/asttoxml.cpp index eb3913b8c..d48868ae5 100644 --- a/generator/asttoxml.cpp +++ b/generator/asttoxml.cpp @@ -44,25 +44,25 @@ #include "parser.h" #include "binder.h" - #include #include -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) -# include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + #include #endif #include -void astToXML(QString name) { - QFile file(name); +void astToXML(QString name) +{ + QFile file(name); - if (!file.open(QFile::ReadOnly)) - return; + if (!file.open(QFile::ReadOnly)) + return; - QTextStream stream(&file); -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) - stream.setCodec(QTextCodec::codecForName("UTF-8")); + QTextStream stream(&file); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + stream.setCodec(QTextCodec::codecForName("UTF-8")); #else - /* NOTE, for Qt6: + /* NOTE, for Qt6: * * stream.setEncoding(QStringConverter::Utf8) * @@ -71,120 +71,122 @@ void astToXML(QString name) { * a text stream otherwise. */ #endif - QByteArray contents = stream.readAll().toUtf8(); - file.close(); + QByteArray contents = stream.readAll().toUtf8(); + file.close(); - Control control; - Parser p(&control); - pool __pool; + Control control; + Parser p(&control); + pool __pool; - TranslationUnitAST *ast = p.parse(contents, contents.size(), &__pool); + TranslationUnitAST* ast = p.parse(contents, contents.size(), &__pool); - CodeModel model; - Binder binder(&model, p.location()); - FileModelItem dom = binder.run(ast); + CodeModel model; + Binder binder(&model, p.location()); + FileModelItem dom = binder.run(ast); - QFile outputFile; - if (!outputFile.open(stdout, QIODevice::WriteOnly)) - { - return; - } + QFile outputFile; + if (!outputFile.open(stdout, QIODevice::WriteOnly)) { + return; + } - QXmlStreamWriter s( &outputFile); - s.setAutoFormatting( true ); + QXmlStreamWriter s(&outputFile); + s.setAutoFormatting(true); - s.writeStartElement("code"); + s.writeStartElement("code"); - QHash namespaceMap = dom->namespaceMap(); - for (NamespaceModelItem item : namespaceMap.values()) { - writeOutNamespace(s, item); - } + QHash namespaceMap = dom->namespaceMap(); + for (NamespaceModelItem item : namespaceMap.values()) { + writeOutNamespace(s, item); + } - QHash typeMap = dom->classMap(); - for (ClassModelItem item : typeMap.values()) { - writeOutClass(s, item); - } - s.writeEndElement(); + QHash typeMap = dom->classMap(); + for (ClassModelItem item : typeMap.values()) { + writeOutClass(s, item); + } + s.writeEndElement(); } +void writeOutNamespace(QXmlStreamWriter& s, NamespaceModelItem& item) +{ + s.writeStartElement("namespace"); + s.writeAttribute("name", item->name()); -void writeOutNamespace(QXmlStreamWriter &s, NamespaceModelItem &item) { - s.writeStartElement("namespace"); - s.writeAttribute("name", item->name()); + QHash namespaceMap = item->namespaceMap(); + for (NamespaceModelItem namespaceItem : namespaceMap.values()) { + writeOutNamespace(s, namespaceItem); + } - QHash namespaceMap = item->namespaceMap(); - for (NamespaceModelItem namespaceItem : namespaceMap.values()) { - writeOutNamespace(s, namespaceItem); - } + QHash typeMap = item->classMap(); + for (ClassModelItem classItem : typeMap.values()) { + writeOutClass(s, classItem); + } - QHash typeMap = item->classMap(); - for (ClassModelItem classItem : typeMap.values()) { - writeOutClass(s, classItem); - } + QHash enumMap = item->enumMap(); + for (EnumModelItem enumItem : enumMap.values()) { + writeOutEnum(s, enumItem); + } - QHash enumMap = item->enumMap(); - for (EnumModelItem enumItem : enumMap.values()) { - writeOutEnum(s, enumItem); - } - - s.writeEndElement(); + s.writeEndElement(); } -void writeOutEnum(QXmlStreamWriter &s, EnumModelItem &item) { - QString qualified_name = item->qualifiedName().join("::"); - s.writeStartElement("enum"); - s.writeAttribute("name", qualified_name); +void writeOutEnum(QXmlStreamWriter& s, EnumModelItem& item) +{ + QString qualified_name = item->qualifiedName().join("::"); + s.writeStartElement("enum"); + s.writeAttribute("name", qualified_name); - EnumeratorList enumList = item->enumerators(); - for(int i=0; i < enumList.size() ; i++) { - s.writeStartElement("enumerator"); - if( !enumList[i]->value().isEmpty() ) - s.writeAttribute("value", enumList[i]->value()); - s.writeCharacters(enumList[i]->name()); + EnumeratorList enumList = item->enumerators(); + for (int i = 0; i < enumList.size(); i++) { + s.writeStartElement("enumerator"); + if (!enumList[i]->value().isEmpty()) + s.writeAttribute("value", enumList[i]->value()); + s.writeCharacters(enumList[i]->name()); - s.writeEndElement(); - } s.writeEndElement(); + } + s.writeEndElement(); } -void writeOutFunction(QXmlStreamWriter &s, FunctionModelItem &item) { - QString qualified_name = item->qualifiedName().join("::"); - s.writeStartElement("function"); - s.writeAttribute("name", qualified_name); - - if (!item->exception().isEmpty()) { - s.writeStartElement("exception"); - s.writeAttribute("throw", item->exception()); - s.writeEndElement(); - } - - ArgumentList arguments = item->arguments(); - for(int i=0; i < arguments.size() ; i++) { - s.writeStartElement("argument"); - s.writeAttribute("type", arguments[i]->type().qualifiedName().join("::")); - s.writeEndElement(); - } +void writeOutFunction(QXmlStreamWriter& s, FunctionModelItem& item) +{ + QString qualified_name = item->qualifiedName().join("::"); + s.writeStartElement("function"); + s.writeAttribute("name", qualified_name); + + if (!item->exception().isEmpty()) { + s.writeStartElement("exception"); + s.writeAttribute("throw", item->exception()); s.writeEndElement(); -} + } -void writeOutClass(QXmlStreamWriter &s, ClassModelItem &item) { - QString qualified_name = item->qualifiedName().join("::"); - s.writeStartElement("class"); - s.writeAttribute("name", qualified_name); - - QHash enumMap = item->enumMap(); - for (EnumModelItem enumItem : enumMap.values()) { - writeOutEnum(s, enumItem); - } - - QMultiHash functionMap = item->functionMap(); - for (FunctionModelItem funcItem : functionMap.values()) { - writeOutFunction(s, funcItem); - } - - QHash typeMap = item->classMap(); - for (ClassModelItem classItem : typeMap.values()) { - writeOutClass(s, classItem); - } + ArgumentList arguments = item->arguments(); + for (int i = 0; i < arguments.size(); i++) { + s.writeStartElement("argument"); + s.writeAttribute("type", arguments[i]->type().qualifiedName().join("::")); s.writeEndElement(); + } + s.writeEndElement(); +} + +void writeOutClass(QXmlStreamWriter& s, ClassModelItem& item) +{ + QString qualified_name = item->qualifiedName().join("::"); + s.writeStartElement("class"); + s.writeAttribute("name", qualified_name); + + QHash enumMap = item->enumMap(); + for (EnumModelItem enumItem : enumMap.values()) { + writeOutEnum(s, enumItem); + } + + QMultiHash functionMap = item->functionMap(); + for (FunctionModelItem funcItem : functionMap.values()) { + writeOutFunction(s, funcItem); + } + + QHash typeMap = item->classMap(); + for (ClassModelItem classItem : typeMap.values()) { + writeOutClass(s, classItem); + } + s.writeEndElement(); } diff --git a/generator/asttoxml.h b/generator/asttoxml.h index 7b3e3fcf7..94a75e44f 100644 --- a/generator/asttoxml.h +++ b/generator/asttoxml.h @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #ifndef ASTTOXML #define ASTTOXML @@ -49,10 +48,9 @@ #include void astToXML(const QString name); -void writeOutNamespace(QXmlStreamWriter &s, NamespaceModelItem &item); -void writeOutEnum(QXmlStreamWriter &s, EnumModelItem &item); -void writeOutFunction(QXmlStreamWriter &s, FunctionModelItem &item); -void writeOutClass(QXmlStreamWriter &s, ClassModelItem &item); - +void writeOutNamespace(QXmlStreamWriter& s, NamespaceModelItem& item); +void writeOutEnum(QXmlStreamWriter& s, EnumModelItem& item); +void writeOutFunction(QXmlStreamWriter& s, FunctionModelItem& item); +void writeOutClass(QXmlStreamWriter& s, ClassModelItem& item); #endif // ASTTOXML diff --git a/generator/fileout.cpp b/generator/fileout.cpp index c0f78c50c..0b38b1bcb 100644 --- a/generator/fileout.cpp +++ b/generator/fileout.cpp @@ -58,181 +58,175 @@ const char* colorReset = "\033[0m"; const char* colorDelete = ""; const char* colorAdd = ""; const char* colorInfo = ""; -const char* colorReset = ""; +const char* colorReset = ""; #endif -FileOut::FileOut(QString n): - name(n), - stream(&tmp), - isDone(false) -{} +FileOut::FileOut(QString n) + : name(n) + , stream(&tmp) + , isDone(false) +{ +} -static int* lcsLength(QList a, QList b) { - const int height = a.size() + 1; - const int width = b.size() + 1; +static int* lcsLength(QList a, QList b) +{ + const int height = a.size() + 1; + const int width = b.size() + 1; - int *res = new int[width * height]; + int* res = new int[width * height]; - for (int row=0; row a, QList b){ - { - if (type == Unchanged) { - if ((end - start) > 9) { - for (int i = start; i <= start+2; i++) - printf(" %s\n", a[i].data()); - printf("%s=\n= %d more lines\n=%s\n", colorInfo, end - start - 6, colorReset); - for (int i = end-2; i <= end; i++) - printf(" %s\n", a[i].data()); - } - else - for (int i = start; i <= end; i++) - printf(" %s\n", a[i].data()); - } - else if(type == Add) { - printf("%s", colorAdd); - for (int i = start; i <= end; i++){ - printf("+ %s\n", b[i].data()); - } - printf("%s", colorReset); - } - else if (type == Delete) { - printf("%s", colorDelete); - for (int i = start; i <= end; i++) { - printf("- %s\n", a[i].data()); - } - printf("%s", colorReset); - } +enum Type { Add, Delete, Unchanged }; + +struct Unit { + Unit(Type type, int pos) + : type(type) + , start(pos) + , end(pos) + { + } + + Type type; + int start; + int end; + + void print(QList a, QList b) + { + { + if (type == Unchanged) { + if ((end - start) > 9) { + for (int i = start; i <= start + 2; i++) + printf(" %s\n", a[i].data()); + printf("%s=\n= %d more lines\n=%s\n", colorInfo, end - start - 6, colorReset); + for (int i = end - 2; i <= end; i++) + printf(" %s\n", a[i].data()); + } else + for (int i = start; i <= end; i++) + printf(" %s\n", a[i].data()); + } else if (type == Add) { + printf("%s", colorAdd); + for (int i = start; i <= end; i++) { + printf("+ %s\n", b[i].data()); } + printf("%s", colorReset); + } else if (type == Delete) { + printf("%s", colorDelete); + for (int i = start; i <= end; i++) { + printf("- %s\n", a[i].data()); + } + printf("%s", colorReset); + } } + } }; -static QList *unitAppend(QList *res, Type type, int pos) +static QList* unitAppend(QList* res, Type type, int pos) { - if (res == 0) { - res = new QList; - res->append(new Unit(type, pos)); - return res; - } - - Unit *last = res->last(); - if (last->type == type) { - last->end = pos; - } else { - res->append(new Unit(type, pos)); - } + if (res == 0) { + res = new QList; + res->append(new Unit(type, pos)); return res; + } + + Unit* last = res->last(); + if (last->type == type) { + last->end = pos; + } else { + res->append(new Unit(type, pos)); + } + return res; } -static QList *diffHelper(int *lcs, QList a, QList b, int row, int col) { - if (row>0 && col>0 && (a[row-1] == b[col-1])) { - return unitAppend(diffHelper(lcs, a, b, row-1, col-1), Unchanged, row-1); - } - else { - int width = b.size()+1; - if ((col > 0) && ((row==0) || - lcs[width * row + col-1] >= lcs[width * (row-1) + col])) - { - return unitAppend(diffHelper(lcs, a, b, row, col-1), Add, col-1); - } - else if((row > 0) && ((col==0) || - lcs[width * row + col-1] < lcs[width * (row-1) + col])){ - return unitAppend(diffHelper(lcs, a, b, row-1, col), Delete, row-1);; - } +static QList* diffHelper(int* lcs, QList a, QList b, int row, int col) +{ + if (row > 0 && col > 0 && (a[row - 1] == b[col - 1])) { + return unitAppend(diffHelper(lcs, a, b, row - 1, col - 1), Unchanged, row - 1); + } else { + int width = b.size() + 1; + if ((col > 0) && ((row == 0) || lcs[width * row + col - 1] >= lcs[width * (row - 1) + col])) { + return unitAppend(diffHelper(lcs, a, b, row, col - 1), Add, col - 1); + } else if ((row > 0) && ((col == 0) || lcs[width * row + col - 1] < lcs[width * (row - 1) + col])) { + return unitAppend(diffHelper(lcs, a, b, row - 1, col), Delete, row - 1); + ; } - delete lcs; - return 0; + } + delete lcs; + return 0; } -static void diff(QList a, QList b) { - QList *res = diffHelper(lcsLength(a, b), a, b, a.size(), b.size()); - for (int i=0; i < res->size(); i++) { - Unit *unit = res->at(i); - unit->print(a, b); - delete(unit); - } - delete(res); +static void diff(QList a, QList b) +{ + QList* res = diffHelper(lcsLength(a, b), a, b, a.size(), b.size()); + for (int i = 0; i < res->size(); i++) { + Unit* unit = res->at(i); + unit->print(a, b); + delete (unit); + } + delete (res); } +bool FileOut::done() +{ + Q_ASSERT(!isDone); + isDone = true; + bool fileEqual = false; + QFile fileRead(name); + QFileInfo info(fileRead); + stream.flush(); + QByteArray original; + if (info.exists() && (diff || (info.size() == tmp.size()))) { + if (!fileRead.open(QIODevice::ReadOnly)) { + ReportHandler::warning(QString("failed to open file '%1' for reading").arg(fileRead.fileName())); + return false; + } -bool FileOut::done() { - Q_ASSERT( !isDone ); - isDone = true; - bool fileEqual = false; - QFile fileRead(name); - QFileInfo info(fileRead); - stream.flush(); - QByteArray original; - if (info.exists() && (diff || (info.size() == tmp.size()))) { - if ( !fileRead.open(QIODevice::ReadOnly) ) { - ReportHandler::warning(QString("failed to open file '%1' for reading") - .arg(fileRead.fileName())); - return false; - } - - original = fileRead.readAll(); - fileRead.close(); - fileEqual = (original == tmp); + original = fileRead.readAll(); + fileRead.close(); + fileEqual = (original == tmp); + } + + if (!fileEqual) { + if (!FileOut::dummy) { + QDir dir(info.absolutePath()); + if (!dir.mkpath(dir.absolutePath())) { + ReportHandler::warning(QString("unable to create directory '%1'").arg(dir.absolutePath())); + return false; + } + + QFile fileWrite(name); + if (!fileWrite.open(QIODevice::WriteOnly)) { + ReportHandler::warning(QString("failed to open file '%1' for writing").arg(fileWrite.fileName())); + return false; + } + stream.setDevice(&fileWrite); + stream << tmp; } - - if( !fileEqual ) { - if( !FileOut::dummy ) { - QDir dir(info.absolutePath()); - if (!dir.mkpath(dir.absolutePath())) { - ReportHandler::warning(QString("unable to create directory '%1'") - .arg(dir.absolutePath())); - return false; - } - - QFile fileWrite(name); - if (!fileWrite.open(QIODevice::WriteOnly)) { - ReportHandler::warning(QString("failed to open file '%1' for writing") - .arg(fileWrite.fileName())); - return false; - } - stream.setDevice(&fileWrite); - stream << tmp; - } - if (diff) { - printf("%sFile: %s%s\n", colorInfo, qPrintable(name), colorReset); - - ::diff(original.split('\n'), tmp.split('\n')); - - printf("\n"); - } - return true; + if (diff) { + printf("%sFile: %s%s\n", colorInfo, qPrintable(name), colorReset); + + ::diff(original.split('\n'), tmp.split('\n')); + + printf("\n"); } - return false; + return true; + } + return false; } diff --git a/generator/fileout.h b/generator/fileout.h index cec3fade3..6b7a2b362 100644 --- a/generator/fileout.h +++ b/generator/fileout.h @@ -48,30 +48,30 @@ class FileOut : public QObject { - Q_OBJECT + Q_OBJECT private: - QByteArray tmp; - QString name; + QByteArray tmp; + QString name; public: - FileOut(QString name); - ~FileOut() - { - if( !isDone ) - done(); - } + FileOut(QString name); + ~FileOut() + { + if (!isDone) + done(); + } - bool done(); - - QTextStream stream; + bool done(); - static bool dummy; - static bool diff; - static bool license; + QTextStream stream; - private: - bool isDone; + static bool dummy; + static bool diff; + static bool license; + +private: + bool isDone; }; #endif // FILEOUT_H diff --git a/generator/generator.cpp b/generator/generator.cpp index e87b43986..a5d7a6d55 100644 --- a/generator/generator.cpp +++ b/generator/generator.cpp @@ -48,94 +48,91 @@ Generator::Generator() { - m_num_generated = 0; - m_num_generated_written = 0; - m_out_dir = "."; + m_num_generated = 0; + m_num_generated_written = 0; + m_out_dir = "."; } void Generator::generate() { - if (m_classes.size() == 0) { - ReportHandler::warning(QString("%1: no java classes, skipping") - .arg(metaObject()->className())); - return; - } + if (m_classes.size() == 0) { + ReportHandler::warning(QString("%1: no java classes, skipping").arg(metaObject()->className())); + return; + } - m_classes.sort(); + m_classes.sort(); - for (AbstractMetaClass* cls : m_classes) { - if (!shouldGenerate(cls)) - continue; + for (AbstractMetaClass* cls : m_classes) { + if (!shouldGenerate(cls)) + continue; - QString fileName = fileNameForClass(cls); - ReportHandler::debugSparse(QString("generating: %1").arg(fileName)); + QString fileName = fileNameForClass(cls); + ReportHandler::debugSparse(QString("generating: %1").arg(fileName)); - FileOut fileOut(outputDirectory() + "/" + subDirectoryForClass(cls) + "/" + fileName); - write(fileOut.stream, cls); + FileOut fileOut(outputDirectory() + "/" + subDirectoryForClass(cls) + "/" + fileName); + write(fileOut.stream, cls); - if( fileOut.done() ) - ++m_num_generated_written; - ++m_num_generated; - } + if (fileOut.done()) + ++m_num_generated_written; + ++m_num_generated; + } } - void Generator::printClasses() { - QTextStream s(stdout); + QTextStream s(stdout); - AbstractMetaClassList classes = m_classes; - classes.sort(); + AbstractMetaClassList classes = m_classes; + classes.sort(); - for (AbstractMetaClass* cls : classes) { - if (!shouldGenerate(cls)) - continue; - write(s, cls); - s << Qt::endl << Qt::endl; - } + for (AbstractMetaClass* cls : classes) { + if (!shouldGenerate(cls)) + continue; + write(s, cls); + s << Qt::endl << Qt::endl; + } } -void Generator::verifyDirectoryFor(const QFile &file) +void Generator::verifyDirectoryFor(const QFile& file) { - QDir dir = QFileInfo(file).dir(); - if (!dir.exists()) { - if (!dir.mkpath(dir.absolutePath())) - ReportHandler::warning(QString("unable to create directory '%1'") - .arg(dir.absolutePath())); - } + QDir dir = QFileInfo(file).dir(); + if (!dir.exists()) { + if (!dir.mkpath(dir.absolutePath())) + ReportHandler::warning(QString("unable to create directory '%1'").arg(dir.absolutePath())); + } } -QString Generator::subDirectoryForClass(const AbstractMetaClass *) const +QString Generator::subDirectoryForClass(const AbstractMetaClass*) const { - Q_ASSERT(false); - return QString(); + Q_ASSERT(false); + return QString(); } -QString Generator::fileNameForClass(const AbstractMetaClass *) const +QString Generator::fileNameForClass(const AbstractMetaClass*) const { - Q_ASSERT(false); - return QString(); + Q_ASSERT(false); + return QString(); } -void Generator::write(QTextStream &, const AbstractMetaClass *) +void Generator::write(QTextStream&, const AbstractMetaClass*) { - Q_ASSERT(false); + Q_ASSERT(false); } -bool Generator::hasDefaultConstructor(const AbstractMetaType *type) +bool Generator::hasDefaultConstructor(const AbstractMetaType* type) { - QString full_name = type->typeEntry()->qualifiedTargetLangName(); - QString class_name = type->typeEntry()->targetLangName(); - - for (const AbstractMetaClass* java_class : m_classes) { - if (java_class->typeEntry()->qualifiedTargetLangName() == full_name) { - AbstractMetaFunctionList functions = java_class->functions(); - for (const AbstractMetaFunction* function : functions) { - if (function->arguments().size() == 0 && function->name() == class_name) - return true; - } - return false; - } + QString full_name = type->typeEntry()->qualifiedTargetLangName(); + QString class_name = type->typeEntry()->targetLangName(); + + for (const AbstractMetaClass* java_class : m_classes) { + if (java_class->typeEntry()->qualifiedTargetLangName() == full_name) { + AbstractMetaFunctionList functions = java_class->functions(); + for (const AbstractMetaFunction* function : functions) { + if (function->arguments().size() == 0 && function->name() == class_name) + return true; + } + return false; } - return false; + } + return false; } diff --git a/generator/generator.h b/generator/generator.h index 84205b178..7f8adcafa 100644 --- a/generator/generator.h +++ b/generator/generator.h @@ -49,117 +49,113 @@ class Generator : public QObject { - Q_OBJECT + Q_OBJECT - Q_PROPERTY(QString outputDirectory READ outputDirectory WRITE setOutputDirectory) + Q_PROPERTY(QString outputDirectory READ outputDirectory WRITE setOutputDirectory) public: - enum Option:uint32_t { - NoOption = 0x00000000, - BoxedPrimitive = 0x00000001, - ExcludeConst = 0x00000002, - ExcludeReference = 0x00000004, - UseNativeIds = 0x00000008, - - EnumAsInts = 0x00000010, - SkipName = 0x00000020, - NoCasts = 0x00000040, - SkipReturnType = 0x00000080, - OriginalName = 0x00000100, - ShowStatic = 0x00000200, - UnderscoreSpaces = 0x00000400, - ForceEnumCast = 0x00000800, - ArrayAsPointer = 0x00001000, - VirtualCall = 0x00002000, - SkipTemplateParameters = 0x00004000, - SkipAttributes = 0x00008000, - OriginalTypeDescription = 0x00010000, - SkipRemovedArguments = 0x00020000, - IncludeDefaultExpression = 0x00040000, - NoReturnStatement = 0x00080000, - NoBlockedSlot = 0x00100000, - - SuperCall = 0x00200000, - // The following options have been added for PythonQt: - FirstArgIsWrappedObject = 0x00400000, - ConvertReferenceToPtr = 0x00800000, - UseIndexedName = 0x01000000, - ProtectedEnumAsInts = 0x02000000, - AddOwnershipTemplates = 0x04000000, - - ForceValueType = ExcludeReference | ExcludeConst - }; - - Generator(); - - void setClasses(const AbstractMetaClassList &classes) { m_classes = classes; } - AbstractMetaClassList classes() const { return m_classes; } - - QString outputDirectory() const { return m_out_dir; } - void setOutputDirectory(const QString &outDir) { m_out_dir = outDir; } - virtual void generate(); - void printClasses(); - - int numGenerated() { return m_num_generated; } - int numGeneratedAndWritten() { return m_num_generated_written; } - - virtual bool shouldGenerate(const AbstractMetaClass *) const { return true; } - virtual QString subDirectoryForClass(const AbstractMetaClass *java_class) const; - virtual QString fileNameForClass(const AbstractMetaClass *java_class) const; - virtual void write(QTextStream &s, const AbstractMetaClass *java_class); - - bool hasDefaultConstructor(const AbstractMetaType *type); - - // QtScript - void setQtMetaTypeDeclaredTypeNames(const QSet &names) - { m_qmetatype_declared_typenames = names; } - QSet qtMetaTypeDeclaredTypeNames() const - { return m_qmetatype_declared_typenames; } + enum Option : uint32_t { + NoOption = 0x00000000, + BoxedPrimitive = 0x00000001, + ExcludeConst = 0x00000002, + ExcludeReference = 0x00000004, + UseNativeIds = 0x00000008, + + EnumAsInts = 0x00000010, + SkipName = 0x00000020, + NoCasts = 0x00000040, + SkipReturnType = 0x00000080, + OriginalName = 0x00000100, + ShowStatic = 0x00000200, + UnderscoreSpaces = 0x00000400, + ForceEnumCast = 0x00000800, + ArrayAsPointer = 0x00001000, + VirtualCall = 0x00002000, + SkipTemplateParameters = 0x00004000, + SkipAttributes = 0x00008000, + OriginalTypeDescription = 0x00010000, + SkipRemovedArguments = 0x00020000, + IncludeDefaultExpression = 0x00040000, + NoReturnStatement = 0x00080000, + NoBlockedSlot = 0x00100000, + + SuperCall = 0x00200000, + // The following options have been added for PythonQt: + FirstArgIsWrappedObject = 0x00400000, + ConvertReferenceToPtr = 0x00800000, + UseIndexedName = 0x01000000, + ProtectedEnumAsInts = 0x02000000, + AddOwnershipTemplates = 0x04000000, + + ForceValueType = ExcludeReference | ExcludeConst + }; + + Generator(); + + void setClasses(const AbstractMetaClassList& classes) { m_classes = classes; } + AbstractMetaClassList classes() const { return m_classes; } + + QString outputDirectory() const { return m_out_dir; } + void setOutputDirectory(const QString& outDir) { m_out_dir = outDir; } + virtual void generate(); + void printClasses(); + + int numGenerated() { return m_num_generated; } + int numGeneratedAndWritten() { return m_num_generated_written; } + + virtual bool shouldGenerate(const AbstractMetaClass*) const { return true; } + virtual QString subDirectoryForClass(const AbstractMetaClass* java_class) const; + virtual QString fileNameForClass(const AbstractMetaClass* java_class) const; + virtual void write(QTextStream& s, const AbstractMetaClass* java_class); + + bool hasDefaultConstructor(const AbstractMetaType* type); + + // QtScript + void setQtMetaTypeDeclaredTypeNames(const QSet& names) { m_qmetatype_declared_typenames = names; } + QSet qtMetaTypeDeclaredTypeNames() const { return m_qmetatype_declared_typenames; } protected: - - void verifyDirectoryFor(const QFile &file); + void verifyDirectoryFor(const QFile& file); - AbstractMetaClassList m_classes; - int m_num_generated; - int m_num_generated_written; - QString m_out_dir; + AbstractMetaClassList m_classes; + int m_num_generated; + int m_num_generated_written; + QString m_out_dir; - // QtScript - QSet m_qmetatype_declared_typenames; + // QtScript + QSet m_qmetatype_declared_typenames; }; -class Indentor { +class Indentor +{ public: - Indentor(): - indent(0) - {} - int indent; + Indentor() + : indent(0) + { + } + int indent; }; -class Indentation { +class Indentation +{ public: - Indentation(Indentor &indentor): - indentor(indentor) - { - indentor.indent++; - } - ~Indentation() - { - indentor.indent--; - } + Indentation(Indentor& indentor) + : indentor(indentor) + { + indentor.indent++; + } + ~Indentation() { indentor.indent--; } private: - Indentor &indentor; + Indentor& indentor; }; -inline QTextStream &operator <<(QTextStream &s, const Indentor &indentor) +inline QTextStream& operator<<(QTextStream& s, const Indentor& indentor) { - for (int i=0; i args) { - if (args.contains("output-directory")) { - outDir = args.value("output-directory"); - } +bool GeneratorSet::readParameters(const QMap args) +{ + if (args.contains("output-directory")) { + outDir = args.value("output-directory"); + } - printStdout = args.contains("print-stdout"); + printStdout = args.contains("print-stdout"); - return !(args.contains("help") || args.contains("h") || args.contains("?")); + return !(args.contains("help") || args.contains("h") || args.contains("?")); } diff --git a/generator/generatorset.h b/generator/generatorset.h index d0a125256..f062ec88b 100644 --- a/generator/generatorset.h +++ b/generator/generatorset.h @@ -49,21 +49,21 @@ class GeneratorSet : public QObject { - Q_OBJECT + Q_OBJECT - public: - GeneratorSet(); +public: + GeneratorSet(); - virtual QString usage() = 0; - virtual bool readParameters(const QMap args) = 0; - virtual void buildModel(const QString pp_file) = 0; - virtual void dumpObjectTree() = 0; - virtual void setIncludePaths(const QStringList& includePaths) = 0; - virtual QString generate() = 0; + virtual QString usage() = 0; + virtual bool readParameters(const QMap args) = 0; + virtual void buildModel(const QString pp_file) = 0; + virtual void dumpObjectTree() = 0; + virtual void setIncludePaths(const QStringList& includePaths) = 0; + virtual QString generate() = 0; - static GeneratorSet *getInstance(); - QString outDir; - bool printStdout; + static GeneratorSet* getInstance(); + QString outDir; + bool printStdout; }; #endif // GENERATOR_SET_H diff --git a/generator/generatorsetqtscript.cpp b/generator/generatorsetqtscript.cpp index 404c491f1..5c41abbe6 100644 --- a/generator/generatorsetqtscript.cpp +++ b/generator/generatorsetqtscript.cpp @@ -44,96 +44,95 @@ #include "shellheadergenerator.h" #include "shellimplgenerator.h" -GeneratorSet *GeneratorSet::getInstance() { - return new GeneratorSetQtScript(); +GeneratorSet* GeneratorSet::getInstance() +{ + return new GeneratorSetQtScript(); } -GeneratorSetQtScript::GeneratorSetQtScript() -{} +GeneratorSetQtScript::GeneratorSetQtScript() {} -QString GeneratorSetQtScript::usage() { - QString usage = - "QtScript:\n" - " --nothing-to-report-yet \n" - " --max-classes-per-file= \n"; +QString GeneratorSetQtScript::usage() +{ + QString usage = "QtScript:\n" + " --nothing-to-report-yet \n" + " --max-classes-per-file= \n"; - return usage; + return usage; } -bool GeneratorSetQtScript::readParameters(const QMap args) { - if (args.contains("max-classes-per-file")) { - bool ok; - int n = args.value("max-classes-per-file").toInt(&ok); - if (ok && n > 0) { - maxClassesPerFile = n; - } - else { - printf("Invalid value for option --max-classes-per-file (must be number > 0)\n"); - } +bool GeneratorSetQtScript::readParameters(const QMap args) +{ + if (args.contains("max-classes-per-file")) { + bool ok; + int n = args.value("max-classes-per-file").toInt(&ok); + if (ok && n > 0) { + maxClassesPerFile = n; + } else { + printf("Invalid value for option --max-classes-per-file (must be number > 0)\n"); } - return GeneratorSet::readParameters(args); + } + return GeneratorSet::readParameters(args); } -void GeneratorSetQtScript::buildModel(const QString pp_file) { - // Building the code inforamation... - ReportHandler::setContext("MetaJavaBuilder"); - builder.setFileName(pp_file); - builder.build(); +void GeneratorSetQtScript::buildModel(const QString pp_file) +{ + // Building the code inforamation... + ReportHandler::setContext("MetaJavaBuilder"); + builder.setFileName(pp_file); + builder.build(); } -void GeneratorSetQtScript::dumpObjectTree() { - -} +void GeneratorSetQtScript::dumpObjectTree() {} void GeneratorSetQtScript::setIncludePaths(const QStringList& includePaths) { - builder.setIncludePaths(includePaths); + builder.setIncludePaths(includePaths); } -QString GeneratorSetQtScript::generate() { - AbstractMetaClassList classes = builder.classesTopologicalSorted(); - QSet declaredTypeNames = builder.qtMetaTypeDeclaredTypeNames(); - - PriGenerator priGenerator(maxClassesPerFile); - priGenerator.setOutputDirectory(outDir); - - SetupGenerator setupGenerator(maxClassesPerFile); - setupGenerator.setOutputDirectory(outDir); - setupGenerator.setQtMetaTypeDeclaredTypeNames(declaredTypeNames); - setupGenerator.setClasses(classes); - - ShellImplGenerator shellImplGenerator(&priGenerator); - shellImplGenerator.setOutputDirectory(outDir); - shellImplGenerator.setClasses(classes); - shellImplGenerator.setQtMetaTypeDeclaredTypeNames(declaredTypeNames); - shellImplGenerator.generate(); - - ShellHeaderGenerator shellHeaderGenerator(&priGenerator, &setupGenerator); - shellHeaderGenerator.setOutputDirectory(outDir); - shellHeaderGenerator.setClasses(classes); - shellHeaderGenerator.generate(); - - priGenerator.generate(); - setupGenerator.generate(); - - return QString("Classes in typesystem: %1\n" - "Generated:\n" - " - header....: %2 (%3)\n" - " - impl......: %4 (%5)\n" - " - modules...: %6 (%7)\n" - " - pri.......: %8 (%9)\n" - ) - .arg(builder.classes().size()) - - .arg(shellHeaderGenerator.numGenerated()) - .arg(shellHeaderGenerator.numGeneratedAndWritten()) - - .arg(shellImplGenerator.numGenerated()) - .arg(shellImplGenerator.numGeneratedAndWritten()) - - .arg(setupGenerator.numGenerated()) - .arg(setupGenerator.numGeneratedAndWritten()) - - .arg(priGenerator.numGenerated()) - .arg(priGenerator.numGeneratedAndWritten()); +QString GeneratorSetQtScript::generate() +{ + AbstractMetaClassList classes = builder.classesTopologicalSorted(); + QSet declaredTypeNames = builder.qtMetaTypeDeclaredTypeNames(); + + PriGenerator priGenerator(maxClassesPerFile); + priGenerator.setOutputDirectory(outDir); + + SetupGenerator setupGenerator(maxClassesPerFile); + setupGenerator.setOutputDirectory(outDir); + setupGenerator.setQtMetaTypeDeclaredTypeNames(declaredTypeNames); + setupGenerator.setClasses(classes); + + ShellImplGenerator shellImplGenerator(&priGenerator); + shellImplGenerator.setOutputDirectory(outDir); + shellImplGenerator.setClasses(classes); + shellImplGenerator.setQtMetaTypeDeclaredTypeNames(declaredTypeNames); + shellImplGenerator.generate(); + + ShellHeaderGenerator shellHeaderGenerator(&priGenerator, &setupGenerator); + shellHeaderGenerator.setOutputDirectory(outDir); + shellHeaderGenerator.setClasses(classes); + shellHeaderGenerator.generate(); + + priGenerator.generate(); + setupGenerator.generate(); + + return QString("Classes in typesystem: %1\n" + "Generated:\n" + " - header....: %2 (%3)\n" + " - impl......: %4 (%5)\n" + " - modules...: %6 (%7)\n" + " - pri.......: %8 (%9)\n") + .arg(builder.classes().size()) + + .arg(shellHeaderGenerator.numGenerated()) + .arg(shellHeaderGenerator.numGeneratedAndWritten()) + + .arg(shellImplGenerator.numGenerated()) + .arg(shellImplGenerator.numGeneratedAndWritten()) + + .arg(setupGenerator.numGenerated()) + .arg(setupGenerator.numGeneratedAndWritten()) + + .arg(priGenerator.numGenerated()) + .arg(priGenerator.numGeneratedAndWritten()); } diff --git a/generator/generatorsetqtscript.h b/generator/generatorsetqtscript.h index 8209bd2e4..f60f4cfdd 100644 --- a/generator/generatorsetqtscript.h +++ b/generator/generatorsetqtscript.h @@ -47,24 +47,23 @@ class GeneratorSetQtScript : public GeneratorSet { - Q_OBJECT + Q_OBJECT public: - GeneratorSetQtScript(); + GeneratorSetQtScript(); - QString usage() override; - bool readParameters(const QMap args) override; + QString usage() override; + bool readParameters(const QMap args) override; - void buildModel(const QString pp_file) override; - void dumpObjectTree() override; - void setIncludePaths(const QStringList& includePaths) override; + void buildModel(const QString pp_file) override; + void dumpObjectTree() override; + void setIncludePaths(const QStringList& includePaths) override; - QString generate() override; + QString generate() override; private: - MetaQtScriptBuilder builder; - int maxClassesPerFile{30}; - + MetaQtScriptBuilder builder; + int maxClassesPerFile {30}; }; #endif // GENERATOR_SET_QT_SCRIPT_H diff --git a/generator/main.cpp b/generator/main.cpp index 54009f0c8..251e41043 100644 --- a/generator/main.cpp +++ b/generator/main.cpp @@ -64,496 +64,483 @@ #include -void displayHelp(GeneratorSet *generatorSet); +void displayHelp(GeneratorSet* generatorSet); + +namespace { +static const QStringList candidatesQtModules { + QStringLiteral("QtCore"), + QStringLiteral("QtGui"), + QStringLiteral("QtNetwork"), + QStringLiteral("QtOpenGL"), + QStringLiteral("QtXml"), +}; -namespace +static bool isDir(const QString& p) { - static const QStringList candidatesQtModules { - QStringLiteral("QtCore"), - QStringLiteral("QtGui"), - QStringLiteral("QtNetwork"), - QStringLiteral("QtOpenGL"), - QStringLiteral("QtXml"), - }; - - static bool isDir(const QString& p) { return QFileInfo(p).isDir(); } - static QString joinPath(const QString& base, const QString& child) { - return QDir(base).filePath(child); - } -#if QT_VERSION < QT_VERSION_CHECK(5,10,0) - QString qEnvironmentVariable(const char *varName){ - return QString::fromLocal8Bit(qgetenv(varName)); - } + return QFileInfo(p).isDir(); +} +static QString joinPath(const QString& base, const QString& child) +{ + return QDir(base).filePath(child); +} +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) +QString qEnvironmentVariable(const char* varName) +{ + return QString::fromLocal8Bit(qgetenv(varName)); +} #endif - QStringList getIncludeDirectories(const QString &commandLineIncludes) - { - QStringList includes; - includes << QStringLiteral("."); - - const QChar pathSplitter = QDir::listSeparator(); - - // From env var PYTHONQT_INCLUDE - const QString envInclude = qEnvironmentVariable("PYTHONQT_INCLUDE"); - if (!envInclude.isEmpty()) { - QStringList envIncludes = envInclude.split(pathSplitter, Qt::SkipEmptyParts); - for(const QString& include: qAsConst(envIncludes)) { - if (isDir(include)) { - includes << include; - } - else { - qWarning() << "Include path" << include << "does not exist, ignoring."; - } - } - } - - // CLI-provided include paths - if (!commandLineIncludes.isEmpty()) { - const QStringList cliIncludes = commandLineIncludes.split(QDir::listSeparator(), Qt::SkipEmptyParts); - for (const QString& include : cliIncludes) { - if (isDir(include)) { - includes << QDir::cleanPath(include); - } - else { - qWarning() << "Include path" << include << "does not exist, ignoring."; - } - } - } - - // Prefer QTDIR first (allows targeting a different Qt). - // If QTDIR/include exists use it, otherwise treat QTDIR as the include root - QString qtInclude; - const QString qtDir = qEnvironmentVariable("QTDIR"); - if (!qtDir.isEmpty() && isDir(qtDir)) { - const QString qtIncludeUnder = joinPath(qtDir, QStringLiteral("include")); - qtInclude = isDir(qtIncludeUnder) ? qtIncludeUnder : qtDir; +QStringList getIncludeDirectories(const QString& commandLineIncludes) +{ + QStringList includes; + includes << QStringLiteral("."); + + const QChar pathSplitter = QDir::listSeparator(); + + // From env var PYTHONQT_INCLUDE + const QString envInclude = qEnvironmentVariable("PYTHONQT_INCLUDE"); + if (!envInclude.isEmpty()) { + QStringList envIncludes = envInclude.split(pathSplitter, Qt::SkipEmptyParts); + for (const QString& include : qAsConst(envIncludes)) { + if (isDir(include)) { + includes << include; } else { - const QString reason = QStringLiteral("The QTDIR environment variable ") - + (qtDir.isEmpty() - ? "is not set." - : "points to a non-existing directory."); - qWarning().noquote() << reason << "Falling back to QLibraryInfo includes path."; + qWarning() << "Include path" << include << "does not exist, ignoring."; } - // Fallback to QLibraryInfo (works without QTDIR or when QTDIR unusable) - if (qtInclude.isEmpty()) { - qtInclude = QLibraryInfo::location(QLibraryInfo::HeadersPath); - } - if (!qtInclude.isEmpty() && isDir(qtInclude)) { - qInfo() << "Using Qt headers at:" << qtInclude; - // Check for / - for (const QString& qtModule : qAsConst(candidatesQtModules)) { - const QString qtModuleInclude = joinPath(qtInclude, qtModule); - if (isDir(qtModuleInclude)) { - includes << qtModuleInclude; - } - } - includes << qtInclude; + } + } + + // CLI-provided include paths + if (!commandLineIncludes.isEmpty()) { + const QStringList cliIncludes = commandLineIncludes.split(QDir::listSeparator(), Qt::SkipEmptyParts); + for (const QString& include : cliIncludes) { + if (isDir(include)) { + includes << QDir::cleanPath(include); + } else { + qWarning() << "Include path" << include << "does not exist, ignoring."; } - - return includes; } - - QStringList getFrameworkDirectories(const QString &commandLineFrameworks) - { - QStringList frameworks; - frameworks << QStringLiteral("."); - - const QChar pathSplitter = QDir::listSeparator(); - - // From env var PYTHONQT_FRAMEWORK - const QString envFramework = qEnvironmentVariable("PYTHONQT_FRAMEWORK"); - if (!envFramework.isEmpty()) { - QStringList envFrameworks = envFramework.split(pathSplitter, Qt::SkipEmptyParts); - for(const QString& framework: qAsConst(envFrameworks)) { - if (isDir(framework)) { - frameworks << framework; - } - else { - qWarning() << "Framework path" << framework << "does not exist, ignoring."; - } - } + } + + // Prefer QTDIR first (allows targeting a different Qt). + // If QTDIR/include exists use it, otherwise treat QTDIR as the include root + QString qtInclude; + const QString qtDir = qEnvironmentVariable("QTDIR"); + if (!qtDir.isEmpty() && isDir(qtDir)) { + const QString qtIncludeUnder = joinPath(qtDir, QStringLiteral("include")); + qtInclude = isDir(qtIncludeUnder) ? qtIncludeUnder : qtDir; + } else { + const QString reason = QStringLiteral("The QTDIR environment variable ") + + (qtDir.isEmpty() ? "is not set." : "points to a non-existing directory."); + qWarning().noquote() << reason << "Falling back to QLibraryInfo includes path."; + } + // Fallback to QLibraryInfo (works without QTDIR or when QTDIR unusable) + if (qtInclude.isEmpty()) { + qtInclude = QLibraryInfo::location(QLibraryInfo::HeadersPath); + } + if (!qtInclude.isEmpty() && isDir(qtInclude)) { + qInfo() << "Using Qt headers at:" << qtInclude; + // Check for / + for (const QString& qtModule : qAsConst(candidatesQtModules)) { + const QString qtModuleInclude = joinPath(qtInclude, qtModule); + if (isDir(qtModuleInclude)) { + includes << qtModuleInclude; } + } + includes << qtInclude; + } - // CLI-provided framework paths - if (!commandLineFrameworks.isEmpty()) { - const QStringList cliFrameworks = commandLineFrameworks.split(QDir::listSeparator(), Qt::SkipEmptyParts); - for (const QString& framework : cliFrameworks) { - if (isDir(framework)) { - frameworks << QDir::cleanPath(framework); - } - else { - qWarning() << "Framework path" << framework << "does not exist, ignoring."; - } - } - } + return includes; +} - // Prefer QTDIR/lib first (allows targeting a different Qt) - QString qtLib; - const QString qtDir = qEnvironmentVariable("QTDIR"); - if (!qtDir.isEmpty() && isDir(qtDir)) { - qtLib = joinPath(qtDir, QStringLiteral("lib")); +QStringList getFrameworkDirectories(const QString& commandLineFrameworks) +{ + QStringList frameworks; + frameworks << QStringLiteral("."); + + const QChar pathSplitter = QDir::listSeparator(); + + // From env var PYTHONQT_FRAMEWORK + const QString envFramework = qEnvironmentVariable("PYTHONQT_FRAMEWORK"); + if (!envFramework.isEmpty()) { + QStringList envFrameworks = envFramework.split(pathSplitter, Qt::SkipEmptyParts); + for (const QString& framework : qAsConst(envFrameworks)) { + if (isDir(framework)) { + frameworks << framework; } else { - const QString reason = QStringLiteral("The QTDIR environment variable ") - + (qtDir.isEmpty() - ? "is not set." - : "points to a non-existing directory."); - qWarning().noquote() << reason << "Falling back to QLibraryInfo libraries path."; + qWarning() << "Framework path" << framework << "does not exist, ignoring."; } - // Fallback to QLibraryInfo (works without QTDIR or when QTDIR unusable) - if(qtLib.isEmpty()) { - qtLib = QLibraryInfo::location(QLibraryInfo::LibrariesPath); + } + } + + // CLI-provided framework paths + if (!commandLineFrameworks.isEmpty()) { + const QStringList cliFrameworks = commandLineFrameworks.split(QDir::listSeparator(), Qt::SkipEmptyParts); + for (const QString& framework : cliFrameworks) { + if (isDir(framework)) { + frameworks << QDir::cleanPath(framework); + } else { + qWarning() << "Framework path" << framework << "does not exist, ignoring."; } - if (!qtLib.isEmpty() && isDir(qtLib)) { - qInfo() << "Using Qt frameworks at:" << qtLib; - // Check for /.framework bundles - for (const QString& qtModule : qAsConst(candidatesQtModules)) { - const QString qtModuleFramework = QDir(qtLib).filePath(qtModule + ".framework"); - if (QDir(qtModuleFramework).exists()) { - frameworks << qtModuleFramework; - } - } - frameworks << qtLib; + } + } + + // Prefer QTDIR/lib first (allows targeting a different Qt) + QString qtLib; + const QString qtDir = qEnvironmentVariable("QTDIR"); + if (!qtDir.isEmpty() && isDir(qtDir)) { + qtLib = joinPath(qtDir, QStringLiteral("lib")); + } else { + const QString reason = QStringLiteral("The QTDIR environment variable ") + + (qtDir.isEmpty() ? "is not set." : "points to a non-existing directory."); + qWarning().noquote() << reason << "Falling back to QLibraryInfo libraries path."; + } + // Fallback to QLibraryInfo (works without QTDIR or when QTDIR unusable) + if (qtLib.isEmpty()) { + qtLib = QLibraryInfo::location(QLibraryInfo::LibrariesPath); + } + if (!qtLib.isEmpty() && isDir(qtLib)) { + qInfo() << "Using Qt frameworks at:" << qtLib; + // Check for /.framework bundles + for (const QString& qtModule : qAsConst(candidatesQtModules)) { + const QString qtModuleFramework = QDir(qtLib).filePath(qtModule + ".framework"); + if (QDir(qtModuleFramework).exists()) { + frameworks << qtModuleFramework; } - - return frameworks; } + frameworks << qtLib; + } - bool - preprocess(const QString& sourceFile, const QString& targetFile, const QStringList& includePaths, const QStringList& frameworkPaths) - { - simplecpp::DUI dui; // settings + return frameworks; +} - for(const QString& include : includePaths) { - dui.addIncludePath(QDir::toNativeSeparators(include).toStdString()); - } - for(const QString& framework : frameworkPaths) { - dui.addFrameworkPath(QDir::toNativeSeparators(framework).toStdString()); - } - dui.defines.push_back("__cplusplus=1"); - dui.defines.push_back("__STDC__"); +bool preprocess(const QString& sourceFile, const QString& targetFile, const QStringList& includePaths, + const QStringList& frameworkPaths) +{ + simplecpp::DUI dui; // settings + + for (const QString& include : includePaths) { + dui.addIncludePath(QDir::toNativeSeparators(include).toStdString()); + } + for (const QString& framework : frameworkPaths) { + dui.addFrameworkPath(QDir::toNativeSeparators(framework).toStdString()); + } + dui.defines.push_back("__cplusplus=1"); + dui.defines.push_back("__STDC__"); #ifdef Q_PROCESSOR_X86_64 - dui.defines.push_back("__x86_64__"); + dui.defines.push_back("__x86_64__"); #endif - dui.std = "c++20"; - dui.removeComments = true; - - QFile file(sourceFile); - if (!file.open(QFile::ReadOnly)) - { - std::cerr << "Main file not found:" << sourceFile.toUtf8().constData() << std::endl; - return false; - } - - QByteArray ba = file.readAll(); - file.close(); - - // Perform preprocessing (code originally taken from simplecpp/main.cpp and modified) - simplecpp::OutputList outputList; - std::vector files; - std::unique_ptr rawtokens(new simplecpp::TokenList(ba.constData(), ba.size(), files, {}, &outputList)); - rawtokens->removeComments(); - simplecpp::TokenList outputTokens(files); - simplecpp::FileDataCache filedata; - simplecpp::preprocess(outputTokens, *rawtokens, files, filedata, dui, &outputList); - simplecpp::cleanup(filedata); - rawtokens.reset(); - - for (const simplecpp::Output& output : outputList) { - if (output.type == simplecpp::Output::MISSING_HEADER) { - // do not print these messages for now, we are not interested - continue; - } - std::cerr << output.location.file() << ':' << output.location.line << ": "; - switch (output.type) { - case simplecpp::Output::ERROR: - std::cerr << "#error: "; - break; - case simplecpp::Output::WARNING: - std::cerr << "#warning: "; - break; - case simplecpp::Output::MISSING_HEADER: - std::cerr << "missing header: "; - break; - case simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY: - std::cerr << "include nested too deeply: "; - break; - case simplecpp::Output::SYNTAX_ERROR: - std::cerr << "syntax error: "; - break; - case simplecpp::Output::PORTABILITY_BACKSLASH: - std::cerr << "portability: "; - break; - case simplecpp::Output::UNHANDLED_CHAR_ERROR: - std::cerr << "unhandled char error: "; - break; - case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND: - std::cerr << "explicit include not found: "; - break; - case simplecpp::Output::FILE_NOT_FOUND: - std::cerr << "file not found: "; - break; - case simplecpp::Output::DUI_ERROR: - std::cerr << "dui error: "; - break; - } - std::cerr << output.msg << std::endl; - } + dui.std = "c++20"; + dui.removeComments = true; + + QFile file(sourceFile); + if (!file.open(QFile::ReadOnly)) { + std::cerr << "Main file not found:" << sourceFile.toUtf8().constData() << std::endl; + return false; + } + + QByteArray ba = file.readAll(); + file.close(); + + // Perform preprocessing (code originally taken from simplecpp/main.cpp and modified) + simplecpp::OutputList outputList; + std::vector files; + std::unique_ptr rawtokens( + new simplecpp::TokenList(ba.constData(), ba.size(), files, {}, &outputList)); + rawtokens->removeComments(); + simplecpp::TokenList outputTokens(files); + simplecpp::FileDataCache filedata; + simplecpp::preprocess(outputTokens, *rawtokens, files, filedata, dui, &outputList); + simplecpp::cleanup(filedata); + rawtokens.reset(); + + for (const simplecpp::Output& output : outputList) { + if (output.type == simplecpp::Output::MISSING_HEADER) { + // do not print these messages for now, we are not interested + continue; + } + std::cerr << output.location.file() << ':' << output.location.line << ": "; + switch (output.type) { + case simplecpp::Output::ERROR: + std::cerr << "#error: "; + break; + case simplecpp::Output::WARNING: + std::cerr << "#warning: "; + break; + case simplecpp::Output::MISSING_HEADER: + std::cerr << "missing header: "; + break; + case simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY: + std::cerr << "include nested too deeply: "; + break; + case simplecpp::Output::SYNTAX_ERROR: + std::cerr << "syntax error: "; + break; + case simplecpp::Output::PORTABILITY_BACKSLASH: + std::cerr << "portability: "; + break; + case simplecpp::Output::UNHANDLED_CHAR_ERROR: + std::cerr << "unhandled char error: "; + break; + case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND: + std::cerr << "explicit include not found: "; + break; + case simplecpp::Output::FILE_NOT_FOUND: + std::cerr << "file not found: "; + break; + case simplecpp::Output::DUI_ERROR: + std::cerr << "dui error: "; + break; + } + std::cerr << output.msg << std::endl; + } - QFile f(targetFile); - if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) - { - fprintf(stderr, "Failed to write preprocessed file: %s\n", qPrintable(targetFile)); - } - std::string result = outputTokens.stringify(); - f.write(result.c_str(), result.length()); + QFile f(targetFile); + if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { + fprintf(stderr, "Failed to write preprocessed file: %s\n", qPrintable(targetFile)); + } + std::string result = outputTokens.stringify(); + f.write(result.c_str(), result.length()); - return true; - } + return true; +} - unsigned int getQtVersion(const QStringList& paths) - { - QRegularExpression re("#define\\s+QTCORE_VERSION\\s+0x([0-9a-f]+)", QRegularExpression::CaseInsensitiveOption); +unsigned int getQtVersion(const QStringList& paths) +{ + QRegularExpression re("#define\\s+QTCORE_VERSION\\s+0x([0-9a-f]+)", QRegularExpression::CaseInsensitiveOption); - // Iterate through provided paths to find the qtcoreversion.h header file - for (const QString &path: paths) - { + // Iterate through provided paths to find the qtcoreversion.h header file + for (const QString& path : paths) { #ifdef Q_OS_MACOS - // Define potential locations for the header file on macOS - const QStringList candidates = { - joinPath(path, "Versions/A/Headers/qtcoreversion.h"), - joinPath(path, "Versions/5/Headers/qtcoreversion.h"), - joinPath(path, "Headers/qtcoreversion.h"), // top-level Headers (often a symlink into Versions) - }; + // Define potential locations for the header file on macOS + const QStringList candidates = { + joinPath(path, "Versions/A/Headers/qtcoreversion.h"), + joinPath(path, "Versions/5/Headers/qtcoreversion.h"), + joinPath(path, "Headers/qtcoreversion.h"), // top-level Headers (often a symlink into Versions) + }; #else - // Define the location for other platforms - const QStringList candidates = { joinPath(path, "qtcoreversion.h") }; + // Define the location for other platforms + const QStringList candidates = {joinPath(path, "qtcoreversion.h")}; #endif - // Pick the first existing candidate - QString qtCoreVersionHeader; - for (const QString& candidate : candidates) { - if (QFile::exists(candidate)) { - qtCoreVersionHeader = candidate; - break; - } - } + // Pick the first existing candidate + QString qtCoreVersionHeader; + for (const QString& candidate : candidates) { + if (QFile::exists(candidate)) { + qtCoreVersionHeader = candidate; + break; + } + } - if (QFile::exists(qtCoreVersionHeader)) - { - QString filePath = QFileInfo(qtCoreVersionHeader).absoluteFilePath(); - QFile f(filePath); - if (f.open(QIODevice::ReadOnly)) - { - QTextStream ts(&f); - QString content = ts.readAll(); - f.close(); - auto match = re.match(content); - if (match.isValid()) - { - unsigned int result; - bool ok; - result = match.captured(1).toUInt(&ok, 16); - if (!ok) - { - printf("Could not parse Qt version in file [%s] (looked for #define QTCORE_VERSION)\n", - qPrintable(filePath)); - } - return result; - } + if (QFile::exists(qtCoreVersionHeader)) { + QString filePath = QFileInfo(qtCoreVersionHeader).absoluteFilePath(); + QFile f(filePath); + if (f.open(QIODevice::ReadOnly)) { + QTextStream ts(&f); + QString content = ts.readAll(); + f.close(); + auto match = re.match(content); + if (match.isValid()) { + unsigned int result; + bool ok; + result = match.captured(1).toUInt(&ok, 16); + if (!ok) { + printf("Could not parse Qt version in file [%s] (looked for #define QTCORE_VERSION)\n", + qPrintable(filePath)); } + return result; } } - printf("Error: Could not find Qt version (looked for qtcoreversion.h in %s)\n", - qPrintable(paths.join(QDir::listSeparator()))); - return 0; } + } + printf("Error: Could not find Qt version (looked for qtcoreversion.h in %s)\n", + qPrintable(paths.join(QDir::listSeparator()))); + return 0; +} }; - -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - ReportHandler::setContext("Arguments"); - - QScopedPointer gs(GeneratorSet::getInstance()); - - QString default_file = ":/trolltech/generator/qtscript_masterinclude.h"; - QString default_system = ":/trolltech/generator/build_all.txt"; - - QString fileName; - QString typesystemFileName; - QString pp_file = ".preprocessed.tmp"; - - QMap args; - unsigned int qtVersion{}; - - int argNum = 0; - for (int i=1; i 0 ) - args[arg.mid(2).left(split-2)] = arg.mid(split + 1).trimmed(); - else - args[arg.mid(2)] = QString(); - } else if( arg.startsWith("-")) { - args[arg.mid(1)] = QString(); - } else { - argNum++; - args[QString("arg-%1").arg(argNum)] = arg; - } + ReportHandler::setContext("Arguments"); + + QScopedPointer gs(GeneratorSet::getInstance()); + + QString default_file = ":/trolltech/generator/qtscript_masterinclude.h"; + QString default_system = ":/trolltech/generator/build_all.txt"; + + QString fileName; + QString typesystemFileName; + QString pp_file = ".preprocessed.tmp"; + + QMap args; + unsigned int qtVersion {}; + + int argNum = 0; + for (int i = 1; i < argc; ++i) { + QString arg(argv[i]); + arg = arg.trimmed(); + if (arg.startsWith("--")) { + int split = arg.indexOf("="); + if (split > 0) + args[arg.mid(2).left(split - 2)] = arg.mid(split + 1).trimmed(); + else + args[arg.mid(2)] = QString(); + } else if (arg.startsWith("-")) { + args[arg.mid(1)] = QString(); + } else { + argNum++; + args[QString("arg-%1").arg(argNum)] = arg; } - - if (args.contains("no-suppress-warnings")) { - TypeDatabase *db = TypeDatabase::instance(); - db->setSuppressWarnings(false); + } + + if (args.contains("no-suppress-warnings")) { + TypeDatabase* db = TypeDatabase::instance(); + db->setSuppressWarnings(false); + } + + if (args.contains("debug-level")) { + QString level = args.value("debug-level"); + if (level == "sparse") + ReportHandler::setDebugLevel(ReportHandler::SparseDebug); + else if (level == "medium") + ReportHandler::setDebugLevel(ReportHandler::MediumDebug); + else if (level == "full") + ReportHandler::setDebugLevel(ReportHandler::FullDebug); + } + + if (args.contains("print-parser-errors")) { + Control::setPrintErrors(true); + } + + if (args.contains("dummy")) { + FileOut::dummy = true; + } + + if (args.contains("diff")) { + FileOut::diff = true; + } + + if (args.contains("license")) + FileOut::license = true; + + if (args.contains("rebuild-only")) { + QStringList classes = args.value("rebuild-only").split(",", Qt::SkipEmptyParts); + TypeDatabase::instance()->setRebuildClasses(classes); + } + + if (args.contains("qt-version")) { + bool ok; + qtVersion = TypeSystem::qtVersionFromString(args.value("qt-version"), ok); + if (!ok || qtVersion < 0x050000) { + printf("Invalid Qt version specified, will look into header files for version...\n"); + qtVersion = 0; } + } - if (args.contains("debug-level")) { - QString level = args.value("debug-level"); - if (level == "sparse") - ReportHandler::setDebugLevel(ReportHandler::SparseDebug); - else if (level == "medium") - ReportHandler::setDebugLevel(ReportHandler::MediumDebug); - else if (level == "full") - ReportHandler::setDebugLevel(ReportHandler::FullDebug); - } + fileName = args.value("arg-1"); - if (args.contains("print-parser-errors")) { - Control::setPrintErrors(true); - } + typesystemFileName = args.value("arg-2"); + if (args.contains("arg-3")) + displayHelp(&*gs); - if (args.contains("dummy")) { - FileOut::dummy = true; - } + if (fileName.isEmpty()) + fileName = default_file; - if (args.contains("diff")) { - FileOut::diff = true; - } + if (typesystemFileName.isEmpty()) + typesystemFileName = default_system; - if (args.contains("license")) - FileOut::license = true; + if (fileName.isEmpty() || typesystemFileName.isEmpty()) + displayHelp(&*gs); - if (args.contains("rebuild-only")) { - QStringList classes = args.value("rebuild-only").split(",", Qt::SkipEmptyParts); - TypeDatabase::instance()->setRebuildClasses(classes); - } + if (!gs->readParameters(args)) + displayHelp(&*gs); - if (args.contains("qt-version")) { - bool ok; - qtVersion = TypeSystem::qtVersionFromString(args.value("qt-version"), ok); - if (!ok || qtVersion < 0x050000) { - printf("Invalid Qt version specified, will look into header files for version...\n"); - qtVersion = 0; - } - } - - fileName = args.value("arg-1"); - - typesystemFileName = args.value("arg-2"); - if (args.contains("arg-3")) - displayHelp(&*gs); - - if (fileName.isEmpty()) - fileName = default_file; - - if (typesystemFileName.isEmpty()) - typesystemFileName = default_system; - - if (fileName.isEmpty() || typesystemFileName.isEmpty() ) - displayHelp(&*gs); + printf("Please wait while source files are being generated...\n"); - if (!gs->readParameters(args)) - displayHelp(&*gs); - - printf("Please wait while source files are being generated...\n"); - - QStringList includePaths = getIncludeDirectories(args.value("include-paths")); - if (!qtVersion && !includePaths.empty()) { - printf("Trying to determine Qt version...\n"); - qtVersion = getQtVersion(includePaths); - } + QStringList includePaths = getIncludeDirectories(args.value("include-paths")); + if (!qtVersion && !includePaths.empty()) { + printf("Trying to determine Qt version...\n"); + qtVersion = getQtVersion(includePaths); + } #ifdef Q_OS_MACOS - QStringList frameworkPaths = getFrameworkDirectories(args.value("framework-paths")); - if (!qtVersion && !frameworkPaths.empty()) { - printf("Trying to determine Qt version...\n"); - qtVersion = getQtVersion(frameworkPaths); - } - if (!qtVersion) { - fprintf(stderr, "Aborting. Could not determine Qt version from include or framework paths.\n"); - return 1; - } + QStringList frameworkPaths = getFrameworkDirectories(args.value("framework-paths")); + if (!qtVersion && !frameworkPaths.empty()) { + printf("Trying to determine Qt version...\n"); + qtVersion = getQtVersion(frameworkPaths); + } + if (!qtVersion) { + fprintf(stderr, "Aborting. Could not determine Qt version from include or framework paths.\n"); + return 1; + } #else - Q_UNUSED(getFrameworkDirectories); - QStringList frameworkPaths; - if (!qtVersion) { - fprintf(stderr, "Aborting. Could not determine Qt version from include paths.\n"); - return 1; - } + Q_UNUSED(getFrameworkDirectories); + QStringList frameworkPaths; + if (!qtVersion) { + fprintf(stderr, "Aborting. Could not determine Qt version from include paths.\n"); + return 1; + } #endif - printf("Determined Qt version is %d.%d.%d\n", qtVersion >> 16, (qtVersion >> 8) & 0xFF, qtVersion & 0xFF); - - printf("Parsing typesystem file [%s]\n", qPrintable(typesystemFileName)); - fflush(stdout); - ReportHandler::setContext("Typesystem"); - if (TypeDatabase::instance()->parseFile(typesystemFileName, qtVersion)) { - TypeDatabase::instance()->finalSetup(); - } - else { - qFatal("Cannot parse file: '%s'", qPrintable(typesystemFileName)); - } - - printf("PreProcessing - Generate [%s] using [%s] and include-paths [%s]\n", - qPrintable(pp_file), qPrintable(fileName), qPrintable(args.value("include-paths"))); - ReportHandler::setContext("Preprocess"); - - if (!preprocess(fileName, pp_file, includePaths, frameworkPaths)) { - fprintf(stderr, "Preprocessor failed on file: '%s'\n", qPrintable(fileName)); - return 1; - } - - if (args.contains("ast-to-xml")) { - printf("Running ast-to-xml on file [%s] using pp_file [%s] and include-paths [%s]\n", - qPrintable(fileName), qPrintable(pp_file), qPrintable(args.value("include-paths"))); - ReportHandler::setContext(QString("AST-to-XML")); - astToXML(pp_file); - return 0; - } - - printf("Building model using [%s]\n", qPrintable(pp_file)); - ReportHandler::setContext("Build"); - gs->setIncludePaths(includePaths); - gs->buildModel(pp_file); - if (args.contains("dump-object-tree")) { - gs->dumpObjectTree(); - return 0; - } - ReportHandler::setContext("Generate"); - printf("%s\n", qPrintable(gs->generate())); - - printf("Done, %d warnings (%d known issues)\n", ReportHandler::warningCount(), - ReportHandler::suppressedCount()); + printf("Determined Qt version is %d.%d.%d\n", qtVersion >> 16, (qtVersion >> 8) & 0xFF, qtVersion & 0xFF); + + printf("Parsing typesystem file [%s]\n", qPrintable(typesystemFileName)); + fflush(stdout); + ReportHandler::setContext("Typesystem"); + if (TypeDatabase::instance()->parseFile(typesystemFileName, qtVersion)) { + TypeDatabase::instance()->finalSetup(); + } else { + qFatal("Cannot parse file: '%s'", qPrintable(typesystemFileName)); + } + + printf("PreProcessing - Generate [%s] using [%s] and include-paths [%s]\n", qPrintable(pp_file), qPrintable(fileName), + qPrintable(args.value("include-paths"))); + ReportHandler::setContext("Preprocess"); + + if (!preprocess(fileName, pp_file, includePaths, frameworkPaths)) { + fprintf(stderr, "Preprocessor failed on file: '%s'\n", qPrintable(fileName)); + return 1; + } + + if (args.contains("ast-to-xml")) { + printf("Running ast-to-xml on file [%s] using pp_file [%s] and include-paths [%s]\n", qPrintable(fileName), + qPrintable(pp_file), qPrintable(args.value("include-paths"))); + ReportHandler::setContext(QString("AST-to-XML")); + astToXML(pp_file); + return 0; + } + + printf("Building model using [%s]\n", qPrintable(pp_file)); + ReportHandler::setContext("Build"); + gs->setIncludePaths(includePaths); + gs->buildModel(pp_file); + if (args.contains("dump-object-tree")) { + gs->dumpObjectTree(); + return 0; + } + ReportHandler::setContext("Generate"); + printf("%s\n", qPrintable(gs->generate())); + + printf("Done, %d warnings (%d known issues)\n", ReportHandler::warningCount(), ReportHandler::suppressedCount()); } - -void displayHelp(GeneratorSet* generatorSet) { - const auto path_splitter = QDir::listSeparator().toLatin1(); - printf("Usage:\n generator [options] header-file typesystem-file\n\n"); - printf("Available options:\n\n"); - printf("General:\n"); - printf(" --debug-level=[sparse|medium|full] \n" - " --print-parser-errors \n" - " --dump-object-tree \n" - " --help, -h or -? \n" - " --no-suppress-warnings \n" - " --output-directory=[dir] \n" - " --include-paths=[%c%c...] \n" +void displayHelp(GeneratorSet* generatorSet) +{ + const auto path_splitter = QDir::listSeparator().toLatin1(); + printf("Usage:\n generator [options] header-file typesystem-file\n\n"); + printf("Available options:\n\n"); + printf("General:\n"); + printf(" --debug-level=[sparse|medium|full] \n" + " --print-parser-errors \n" + " --dump-object-tree \n" + " --help, -h or -? \n" + " --no-suppress-warnings \n" + " --output-directory=[dir] \n" + " --include-paths=[%c%c...] \n" #ifdef Q_OS_MACOS - " --framework-paths=[%c%c...] \n" + " --framework-paths=[%c%c...] \n" #endif - " --qt-version=x.y.z \n" - " --print-stdout \n", - path_splitter, path_splitter); + " --qt-version=x.y.z \n" + " --print-stdout \n", + path_splitter, path_splitter); - printf("%s", qPrintable( generatorSet->usage())); - exit(0); + printf("%s", qPrintable(generatorSet->usage())); + exit(0); } diff --git a/generator/metajava.h b/generator/metajava.h index 6fb8e47a2..4472668b2 100644 --- a/generator/metajava.h +++ b/generator/metajava.h @@ -53,8 +53,6 @@ class MetaJavaArgument; class MetaJavaEnumValue; class MetaJavaEnum; - - class MetaJavaType : public AbstractMetaType {}; diff --git a/generator/metaqtscript.cpp b/generator/metaqtscript.cpp index 6d9b6a653..71405d896 100644 --- a/generator/metaqtscript.cpp +++ b/generator/metaqtscript.cpp @@ -41,7 +41,6 @@ #include "metaqtscript.h" - bool MetaQtScriptClass::hasDefaultToStringFunction() const { return AbstractMetaClass::hasDefaultToStringFunction(); diff --git a/generator/metaqtscript.h b/generator/metaqtscript.h index c1e93fe93..43839ac33 100644 --- a/generator/metaqtscript.h +++ b/generator/metaqtscript.h @@ -53,8 +53,6 @@ class MetaQtScriptArgument; class MetaQtScriptEnumValue; class MetaQtScriptEnum; - - class MetaQtScriptType : public AbstractMetaType {}; @@ -75,7 +73,7 @@ class MetaQtScriptEnum : public AbstractMetaEnum class MetaQtScriptClass : public AbstractMetaClass { - virtual bool hasDefaultToStringFunction() const; + virtual bool hasDefaultToStringFunction() const; }; #endif // METAQTSCRIPT_H diff --git a/generator/metaqtscriptbuilder.cpp b/generator/metaqtscriptbuilder.cpp index 7c9e107b5..b875e2976 100644 --- a/generator/metaqtscriptbuilder.cpp +++ b/generator/metaqtscriptbuilder.cpp @@ -40,4 +40,3 @@ ****************************************************************************/ #include "metaqtscriptbuilder.h" - diff --git a/generator/metaqtscriptbuilder.h b/generator/metaqtscriptbuilder.h index 5a4a48e08..85f069387 100644 --- a/generator/metaqtscriptbuilder.h +++ b/generator/metaqtscriptbuilder.h @@ -48,42 +48,23 @@ class MetaQtScriptBuilder : public AbstractMetaBuilder { - protected: - virtual MetaQtScriptClass *createMetaClass() - { - return new MetaQtScriptClass(); - }; +protected: + virtual MetaQtScriptClass* createMetaClass() { return new MetaQtScriptClass(); }; - virtual MetaQtScriptEnum *createMetaEnum() - { - return new MetaQtScriptEnum(); - }; + virtual MetaQtScriptEnum* createMetaEnum() { return new MetaQtScriptEnum(); }; - virtual MetaQtScriptEnumValue *createMetaEnumValue() - { - return new MetaQtScriptEnumValue(); - }; - - virtual MetaQtScriptField *createMetaField() - { - return new MetaQtScriptField(); - }; + virtual MetaQtScriptEnumValue* createMetaEnumValue() { return new MetaQtScriptEnumValue(); }; - virtual MetaQtScriptFunction *createMetaFunction() - { - return new MetaQtScriptFunction(); - }; + virtual MetaQtScriptField* createMetaField() { return new MetaQtScriptField(); }; - virtual MetaQtScriptArgument *createMetaArgument() - { - return new MetaQtScriptArgument(); - }; + virtual MetaQtScriptFunction* createMetaFunction() { return new MetaQtScriptFunction(); }; - virtual AbstractMetaType::shared_pointer createMetaType() - { - return AbstractMetaType::shared_pointer(new MetaQtScriptType()); - }; + virtual MetaQtScriptArgument* createMetaArgument() { return new MetaQtScriptArgument(); }; + virtual AbstractMetaType::shared_pointer createMetaType() + { + return AbstractMetaType::shared_pointer(new MetaQtScriptType()); + }; }; #endif // METAQTSCRIPTBUILDER_H diff --git a/generator/parser/ast.cpp b/generator/parser/ast.cpp index 6e89ab0a8..cc7bfd33b 100644 --- a/generator/parser/ast.cpp +++ b/generator/parser/ast.cpp @@ -44,9 +44,9 @@ // kate: space-indent on; indent-width 2; replace-tabs on; -QString AST::toString(TokenStream *stream) const +QString AST::toString(TokenStream* stream) const { - const Token &tk = stream->token((int) start_token); - const Token &end_tk = stream->token ((int) end_token); - return QString::fromLatin1(tk.text + tk.position, static_cast(end_tk.position - tk.position)); + const Token& tk = stream->token((int)start_token); + const Token& end_tk = stream->token((int)end_token); + return QString::fromLatin1(tk.text + tk.position, static_cast(end_tk.position - tk.position)); } diff --git a/generator/parser/ast.h b/generator/parser/ast.h index 6afcbf924..9fd069ae5 100644 --- a/generator/parser/ast.h +++ b/generator/parser/ast.h @@ -39,17 +39,15 @@ ** ****************************************************************************/ - #ifndef AST_H -#define AST_H + #define AST_H -#include "smallobject.h" -#include "list.h" + #include "smallobject.h" + #include "list.h" class QString; -#define DECLARE_AST_NODE(k) \ - enum { __node_kind = Kind_##k }; + #define DECLARE_AST_NODE(k) enum { __node_kind = Kind_##k }; class TokenStream; @@ -133,772 +131,688 @@ struct WinDeclSpecAST; struct QPropertyAST; struct QEnumsAST; -struct AST -{ - enum NODE_KIND - { - Kind_UNKNOWN = 0, - - Kind_AccessSpecifier, - Kind_AsmDefinition, - Kind_BaseClause, - Kind_BaseSpecifier, - Kind_BinaryExpression, - Kind_CastExpression, - Kind_ClassMemberAccess, - Kind_ClassSpecifier, - Kind_CompoundStatement, - Kind_Condition, - Kind_ConditionalExpression, - Kind_CppCastExpression, - Kind_CtorInitializer, - Kind_DeclarationStatement, - Kind_Declarator, - Kind_DeleteExpression, - Kind_DoStatement, - Kind_ElaboratedTypeSpecifier, - Kind_EnumSpecifier, - Kind_Enumerator, - Kind_ExceptionSpecification, - Kind_ExpressionOrDeclarationStatement, - Kind_ExpressionStatement, - Kind_ForStatement, - Kind_FunctionCall, - Kind_FunctionDefinition, - Kind_IfStatement, - Kind_IncrDecrExpression, - Kind_InitDeclarator, - Kind_Initializer, - Kind_InitializerClause, - Kind_LabeledStatement, - Kind_LinkageBody, - Kind_LinkageSpecification, - Kind_MemInitializer, - Kind_Name, - Kind_Namespace, - Kind_NamespaceAliasDefinition, - Kind_NewDeclarator, - Kind_NewExpression, - Kind_NewInitializer, - Kind_NewTypeId, - Kind_Operator, - Kind_OperatorFunctionId, - Kind_ParameterDeclaration, - Kind_ParameterDeclarationClause, - Kind_PostfixExpression, - Kind_PrimaryExpression, - Kind_PtrOperator, - Kind_PtrToMember, - Kind_ReturnStatement, - Kind_SimpleDeclaration, - Kind_SimpleTypeSpecifier, - Kind_SizeofExpression, - Kind_StringLiteral, - Kind_SubscriptExpression, - Kind_SwitchStatement, - Kind_TemplateArgument, - Kind_TemplateDeclaration, - Kind_TemplateParameter, - Kind_ThrowExpression, - Kind_TranslationUnit, - Kind_TryBlockStatement, - Kind_TypeId, - Kind_TypeIdentification, - Kind_TypeParameter, - Kind_Typedef, - Kind_UnaryExpression, - Kind_UnqualifiedName, - Kind_Using, - Kind_UsingDirective, - Kind_WhileStatement, - Kind_WinDeclSpec, - Kind_QPropertyAST, - Kind_ForwardDeclarationSpecifier, - Kind_QEnumsAST, - - NODE_KIND_COUNT - }; - - QString toString(TokenStream *stream) const; - - int kind{}; - - std::size_t start_token{}; - std::size_t end_token{}; -}; - -struct TypeSpecifierAST: public AST -{ - const ListNode *cv{}; -}; - -struct StatementAST: public AST -{ -}; - -struct ExpressionAST: public AST -{ -}; - -struct DeclarationAST: public AST -{ -}; - -struct AccessSpecifierAST: public DeclarationAST -{ +struct AST { + enum NODE_KIND { + Kind_UNKNOWN = 0, + + Kind_AccessSpecifier, + Kind_AsmDefinition, + Kind_BaseClause, + Kind_BaseSpecifier, + Kind_BinaryExpression, + Kind_CastExpression, + Kind_ClassMemberAccess, + Kind_ClassSpecifier, + Kind_CompoundStatement, + Kind_Condition, + Kind_ConditionalExpression, + Kind_CppCastExpression, + Kind_CtorInitializer, + Kind_DeclarationStatement, + Kind_Declarator, + Kind_DeleteExpression, + Kind_DoStatement, + Kind_ElaboratedTypeSpecifier, + Kind_EnumSpecifier, + Kind_Enumerator, + Kind_ExceptionSpecification, + Kind_ExpressionOrDeclarationStatement, + Kind_ExpressionStatement, + Kind_ForStatement, + Kind_FunctionCall, + Kind_FunctionDefinition, + Kind_IfStatement, + Kind_IncrDecrExpression, + Kind_InitDeclarator, + Kind_Initializer, + Kind_InitializerClause, + Kind_LabeledStatement, + Kind_LinkageBody, + Kind_LinkageSpecification, + Kind_MemInitializer, + Kind_Name, + Kind_Namespace, + Kind_NamespaceAliasDefinition, + Kind_NewDeclarator, + Kind_NewExpression, + Kind_NewInitializer, + Kind_NewTypeId, + Kind_Operator, + Kind_OperatorFunctionId, + Kind_ParameterDeclaration, + Kind_ParameterDeclarationClause, + Kind_PostfixExpression, + Kind_PrimaryExpression, + Kind_PtrOperator, + Kind_PtrToMember, + Kind_ReturnStatement, + Kind_SimpleDeclaration, + Kind_SimpleTypeSpecifier, + Kind_SizeofExpression, + Kind_StringLiteral, + Kind_SubscriptExpression, + Kind_SwitchStatement, + Kind_TemplateArgument, + Kind_TemplateDeclaration, + Kind_TemplateParameter, + Kind_ThrowExpression, + Kind_TranslationUnit, + Kind_TryBlockStatement, + Kind_TypeId, + Kind_TypeIdentification, + Kind_TypeParameter, + Kind_Typedef, + Kind_UnaryExpression, + Kind_UnqualifiedName, + Kind_Using, + Kind_UsingDirective, + Kind_WhileStatement, + Kind_WinDeclSpec, + Kind_QPropertyAST, + Kind_ForwardDeclarationSpecifier, + Kind_QEnumsAST, + + NODE_KIND_COUNT + }; + + QString toString(TokenStream* stream) const; + + int kind {}; + + std::size_t start_token {}; + std::size_t end_token {}; +}; + +struct TypeSpecifierAST : public AST { + const ListNode* cv {}; +}; + +struct StatementAST : public AST {}; + +struct ExpressionAST : public AST {}; + +struct DeclarationAST : public AST {}; + +struct AccessSpecifierAST : public DeclarationAST { DECLARE_AST_NODE(AccessSpecifier) - const ListNode *specs{}; + const ListNode* specs {}; }; -struct AsmDefinitionAST: public DeclarationAST -{ +struct AsmDefinitionAST : public DeclarationAST { DECLARE_AST_NODE(AsmDefinition) - const ListNode *cv{}; + const ListNode* cv {}; }; -struct BaseClauseAST: public AST // ### kill me +struct BaseClauseAST : public AST // ### kill me { DECLARE_AST_NODE(BaseClause) - const ListNode *base_specifiers{}; + const ListNode* base_specifiers {}; }; -struct BaseSpecifierAST: public AST -{ +struct BaseSpecifierAST : public AST { DECLARE_AST_NODE(BaseSpecifier) - std::size_t virt{}; - std::size_t access_specifier{}; - NameAST *name{}; + std::size_t virt {}; + std::size_t access_specifier {}; + NameAST* name {}; }; -struct BinaryExpressionAST: public ExpressionAST -{ +struct BinaryExpressionAST : public ExpressionAST { DECLARE_AST_NODE(BinaryExpression) - std::size_t op{}; - ExpressionAST *left_expression{}; - ExpressionAST *right_expression{}; + std::size_t op {}; + ExpressionAST* left_expression {}; + ExpressionAST* right_expression {}; }; -struct CastExpressionAST: public ExpressionAST -{ +struct CastExpressionAST : public ExpressionAST { DECLARE_AST_NODE(CastExpression) - TypeIdAST *type_id{}; - ExpressionAST *expression{}; + TypeIdAST* type_id {}; + ExpressionAST* expression {}; }; -struct ClassMemberAccessAST: public ExpressionAST -{ +struct ClassMemberAccessAST : public ExpressionAST { DECLARE_AST_NODE(ClassMemberAccess) - std::size_t op{}; - NameAST *name{}; + std::size_t op {}; + NameAST* name {}; }; -struct ClassSpecifierAST: public TypeSpecifierAST -{ +struct ClassSpecifierAST : public TypeSpecifierAST { DECLARE_AST_NODE(ClassSpecifier) - WinDeclSpecAST *win_decl_specifiers{}; - std::size_t class_key{}; - NameAST *name{}; - BaseClauseAST *base_clause{}; - const ListNode *member_specs{}; + WinDeclSpecAST* win_decl_specifiers {}; + std::size_t class_key {}; + NameAST* name {}; + BaseClauseAST* base_clause {}; + const ListNode* member_specs {}; }; -struct ForwardDeclarationSpecifierAST: public TypeSpecifierAST -{ - DECLARE_AST_NODE(ForwardDeclarationSpecifier) +struct ForwardDeclarationSpecifierAST : public TypeSpecifierAST { + DECLARE_AST_NODE(ForwardDeclarationSpecifier) - std::size_t class_key{}; - NameAST *name{}; - BaseClauseAST *base_clause{}; + std::size_t class_key {}; + NameAST* name {}; + BaseClauseAST* base_clause {}; }; -struct CompoundStatementAST: public StatementAST -{ +struct CompoundStatementAST : public StatementAST { DECLARE_AST_NODE(CompoundStatement) - const ListNode *statements{}; + const ListNode* statements {}; }; -struct ConditionAST: public AST -{ +struct ConditionAST : public AST { DECLARE_AST_NODE(Condition) - TypeSpecifierAST *type_specifier{}; - DeclaratorAST *declarator{}; - ExpressionAST *expression{}; + TypeSpecifierAST* type_specifier {}; + DeclaratorAST* declarator {}; + ExpressionAST* expression {}; }; -struct ConditionalExpressionAST: public ExpressionAST -{ +struct ConditionalExpressionAST : public ExpressionAST { DECLARE_AST_NODE(ConditionalExpression) - ExpressionAST *condition{}; - ExpressionAST *left_expression{}; - ExpressionAST *right_expression{}; + ExpressionAST* condition {}; + ExpressionAST* left_expression {}; + ExpressionAST* right_expression {}; }; -struct CppCastExpressionAST: public ExpressionAST -{ +struct CppCastExpressionAST : public ExpressionAST { DECLARE_AST_NODE(CppCastExpression) - std::size_t op{}; - TypeIdAST *type_id{}; - ExpressionAST *expression{}; - const ListNode *sub_expressions{}; + std::size_t op {}; + TypeIdAST* type_id {}; + ExpressionAST* expression {}; + const ListNode* sub_expressions {}; }; -struct CtorInitializerAST: public AST -{ +struct CtorInitializerAST : public AST { DECLARE_AST_NODE(CtorInitializer) - std::size_t colon{}; - const ListNode *member_initializers{}; + std::size_t colon {}; + const ListNode* member_initializers {}; }; -struct DeclarationStatementAST: public StatementAST -{ +struct DeclarationStatementAST : public StatementAST { DECLARE_AST_NODE(DeclarationStatement) - DeclarationAST *declaration{}; + DeclarationAST* declaration {}; }; -struct DeclaratorAST: public AST -{ +struct DeclaratorAST : public AST { DECLARE_AST_NODE(Declarator) enum ValueReferenceEnum { UnspecifiedRef, Lvalue, Rvalue }; // "&" or "&&" after member function - + DeclaratorAST() = default; - const ListNode *ptr_ops{}; - DeclaratorAST *sub_declarator{}; - NameAST *id{}; - ExpressionAST *bit_expression{}; - const ListNode *array_dimensions{}; - ParameterDeclarationClauseAST *parameter_declaration_clause{}; - const ListNode *fun_cv{}; - ExceptionSpecificationAST *exception_spec{}; - bool _override{}; - bool packedParameter{}; - ValueReferenceEnum valueRef{ UnspecifiedRef }; -}; - -struct DeleteExpressionAST: public ExpressionAST -{ + const ListNode* ptr_ops {}; + DeclaratorAST* sub_declarator {}; + NameAST* id {}; + ExpressionAST* bit_expression {}; + const ListNode* array_dimensions {}; + ParameterDeclarationClauseAST* parameter_declaration_clause {}; + const ListNode* fun_cv {}; + ExceptionSpecificationAST* exception_spec {}; + bool _override {}; + bool packedParameter {}; + ValueReferenceEnum valueRef {UnspecifiedRef}; +}; + +struct DeleteExpressionAST : public ExpressionAST { DECLARE_AST_NODE(DeleteExpression) - std::size_t scope_token{}; - std::size_t delete_token{}; - std::size_t lbracket_token{}; - std::size_t rbracket_token{}; - ExpressionAST *expression{}; + std::size_t scope_token {}; + std::size_t delete_token {}; + std::size_t lbracket_token {}; + std::size_t rbracket_token {}; + ExpressionAST* expression {}; }; -struct DoStatementAST: public StatementAST -{ +struct DoStatementAST : public StatementAST { DECLARE_AST_NODE(DoStatement) - StatementAST *statement{}; - ExpressionAST *expression{}; + StatementAST* statement {}; + ExpressionAST* expression {}; }; -struct ElaboratedTypeSpecifierAST: public TypeSpecifierAST -{ +struct ElaboratedTypeSpecifierAST : public TypeSpecifierAST { DECLARE_AST_NODE(ElaboratedTypeSpecifier) - std::size_t type{}; - NameAST *name{}; + std::size_t type {}; + NameAST* name {}; }; -struct EnumSpecifierAST: public TypeSpecifierAST -{ +struct EnumSpecifierAST : public TypeSpecifierAST { DECLARE_AST_NODE(EnumSpecifier) - NameAST *name{}; - const ListNode *enumerators{}; - bool is_enum_class{}; + NameAST* name {}; + const ListNode* enumerators {}; + bool is_enum_class {}; }; -struct EnumeratorAST: public AST -{ +struct EnumeratorAST : public AST { DECLARE_AST_NODE(Enumerator) - std::size_t id{}; - ExpressionAST *expression{}; + std::size_t id {}; + ExpressionAST* expression {}; }; -struct ExceptionSpecificationAST: public AST -{ +struct ExceptionSpecificationAST : public AST { DECLARE_AST_NODE(ExceptionSpecification) - std::size_t ellipsis{}; - const ListNode *type_ids{}; + std::size_t ellipsis {}; + const ListNode* type_ids {}; }; -struct ExpressionOrDeclarationStatementAST: public StatementAST -{ +struct ExpressionOrDeclarationStatementAST : public StatementAST { DECLARE_AST_NODE(ExpressionOrDeclarationStatement) - StatementAST *expression{}; - StatementAST *declaration{}; + StatementAST* expression {}; + StatementAST* declaration {}; }; -struct ExpressionStatementAST: public StatementAST -{ +struct ExpressionStatementAST : public StatementAST { DECLARE_AST_NODE(ExpressionStatement) - ExpressionAST *expression{}; + ExpressionAST* expression {}; }; -struct FunctionCallAST: public ExpressionAST -{ +struct FunctionCallAST : public ExpressionAST { DECLARE_AST_NODE(FunctionCall) - ExpressionAST *arguments{}; + ExpressionAST* arguments {}; }; -struct FunctionDefinitionAST: public DeclarationAST -{ +struct FunctionDefinitionAST : public DeclarationAST { DECLARE_AST_NODE(FunctionDefinition) - const ListNode *storage_specifiers{}; - const ListNode *function_specifiers{}; - TypeSpecifierAST *type_specifier{}; - InitDeclaratorAST *init_declarator{}; - StatementAST *function_body{}; - WinDeclSpecAST *win_decl_specifiers{}; + const ListNode* storage_specifiers {}; + const ListNode* function_specifiers {}; + TypeSpecifierAST* type_specifier {}; + InitDeclaratorAST* init_declarator {}; + StatementAST* function_body {}; + WinDeclSpecAST* win_decl_specifiers {}; }; -struct ForStatementAST: public StatementAST -{ +struct ForStatementAST : public StatementAST { DECLARE_AST_NODE(ForStatement) - StatementAST *init_statement{}; - ConditionAST *condition{}; - ExpressionAST *expression{}; - StatementAST *statement{}; + StatementAST* init_statement {}; + ConditionAST* condition {}; + ExpressionAST* expression {}; + StatementAST* statement {}; }; -struct IfStatementAST: public StatementAST -{ +struct IfStatementAST : public StatementAST { DECLARE_AST_NODE(IfStatement) - ConditionAST *condition{}; - StatementAST *statement{}; - StatementAST *else_statement{}; + ConditionAST* condition {}; + StatementAST* statement {}; + StatementAST* else_statement {}; }; -struct IncrDecrExpressionAST: public ExpressionAST -{ +struct IncrDecrExpressionAST : public ExpressionAST { DECLARE_AST_NODE(IncrDecrExpression) - std::size_t op{}; + std::size_t op {}; }; -struct InitDeclaratorAST: public AST -{ +struct InitDeclaratorAST : public AST { DECLARE_AST_NODE(InitDeclarator) - DeclaratorAST *declarator{}; - InitializerAST *initializer{}; + DeclaratorAST* declarator {}; + InitializerAST* initializer {}; }; -struct InitializerAST: public AST -{ +struct InitializerAST : public AST { DECLARE_AST_NODE(Initializer) - InitializerClauseAST *initializer_clause{}; - ExpressionAST *expression{}; - bool isDefault{}; - bool isDeleted{}; + InitializerClauseAST* initializer_clause {}; + ExpressionAST* expression {}; + bool isDefault {}; + bool isDeleted {}; }; -struct InitializerClauseAST: public AST -{ +struct InitializerClauseAST : public AST { DECLARE_AST_NODE(InitializerClause) - ExpressionAST *expression{}; + ExpressionAST* expression {}; }; -struct LabeledStatementAST: public StatementAST -{ +struct LabeledStatementAST : public StatementAST { DECLARE_AST_NODE(LabeledStatement) }; -struct LinkageBodyAST: public AST -{ +struct LinkageBodyAST : public AST { DECLARE_AST_NODE(LinkageBody) - const ListNode *declarations{}; + const ListNode* declarations {}; }; -struct LinkageSpecificationAST: public DeclarationAST -{ +struct LinkageSpecificationAST : public DeclarationAST { DECLARE_AST_NODE(LinkageSpecification) - std::size_t extern_type{}; - LinkageBodyAST *linkage_body{}; - DeclarationAST *declaration{}; + std::size_t extern_type {}; + LinkageBodyAST* linkage_body {}; + DeclarationAST* declaration {}; }; -struct MemInitializerAST: public AST -{ +struct MemInitializerAST : public AST { DECLARE_AST_NODE(MemInitializer) - NameAST *initializer_id{}; - ExpressionAST *expression{}; + NameAST* initializer_id {}; + ExpressionAST* expression {}; }; -struct NameAST: public AST -{ +struct NameAST : public AST { DECLARE_AST_NODE(Name) - bool global{}; - const ListNode *qualified_names{}; - UnqualifiedNameAST *unqualified_name{}; + bool global {}; + const ListNode* qualified_names {}; + UnqualifiedNameAST* unqualified_name {}; }; -struct NamespaceAST: public DeclarationAST -{ +struct NamespaceAST : public DeclarationAST { DECLARE_AST_NODE(Namespace) - std::size_t namespace_name{}; - LinkageBodyAST *linkage_body{}; + std::size_t namespace_name {}; + LinkageBodyAST* linkage_body {}; }; -struct NamespaceAliasDefinitionAST: public DeclarationAST -{ +struct NamespaceAliasDefinitionAST : public DeclarationAST { DECLARE_AST_NODE(NamespaceAliasDefinition) - std::size_t namespace_name{}; - NameAST *alias_name{}; + std::size_t namespace_name {}; + NameAST* alias_name {}; }; -struct NewDeclaratorAST: public AST -{ +struct NewDeclaratorAST : public AST { DECLARE_AST_NODE(NewDeclarator) - PtrOperatorAST *ptr_op{}; - NewDeclaratorAST *sub_declarator{}; - const ListNode *expressions{}; + PtrOperatorAST* ptr_op {}; + NewDeclaratorAST* sub_declarator {}; + const ListNode* expressions {}; }; -struct NewExpressionAST: public ExpressionAST -{ +struct NewExpressionAST : public ExpressionAST { DECLARE_AST_NODE(NewExpression) - std::size_t scope_token{}; - std::size_t new_token{}; - ExpressionAST *expression{}; - TypeIdAST *type_id{}; - NewTypeIdAST *new_type_id{}; - NewInitializerAST *new_initializer{}; + std::size_t scope_token {}; + std::size_t new_token {}; + ExpressionAST* expression {}; + TypeIdAST* type_id {}; + NewTypeIdAST* new_type_id {}; + NewInitializerAST* new_initializer {}; }; -struct NewInitializerAST: public AST -{ +struct NewInitializerAST : public AST { DECLARE_AST_NODE(NewInitializer) - ExpressionAST *expression{}; + ExpressionAST* expression {}; }; -struct NewTypeIdAST: public AST -{ +struct NewTypeIdAST : public AST { DECLARE_AST_NODE(NewTypeId) - TypeSpecifierAST *type_specifier{}; - NewInitializerAST *new_initializer{}; - NewDeclaratorAST *new_declarator{}; + TypeSpecifierAST* type_specifier {}; + NewInitializerAST* new_initializer {}; + NewDeclaratorAST* new_declarator {}; }; -struct OperatorAST: public AST -{ +struct OperatorAST : public AST { DECLARE_AST_NODE(Operator) - std::size_t op{}; - std::size_t open{}; - std::size_t close{}; + std::size_t op {}; + std::size_t open {}; + std::size_t close {}; }; -struct OperatorFunctionIdAST: public AST -{ +struct OperatorFunctionIdAST : public AST { DECLARE_AST_NODE(OperatorFunctionId) - OperatorAST *op{}; - TypeSpecifierAST *type_specifier{}; - const ListNode *ptr_ops{}; + OperatorAST* op {}; + TypeSpecifierAST* type_specifier {}; + const ListNode* ptr_ops {}; }; -struct ParameterDeclarationAST: public AST -{ +struct ParameterDeclarationAST : public AST { DECLARE_AST_NODE(ParameterDeclaration) - TypeSpecifierAST *type_specifier{}; - DeclaratorAST *declarator{}; - ExpressionAST *expression{}; + TypeSpecifierAST* type_specifier {}; + DeclaratorAST* declarator {}; + ExpressionAST* expression {}; }; -struct ParameterDeclarationClauseAST: public AST -{ +struct ParameterDeclarationClauseAST : public AST { DECLARE_AST_NODE(ParameterDeclarationClause) - const ListNode *parameter_declarations{}; - std::size_t ellipsis{}; + const ListNode* parameter_declarations {}; + std::size_t ellipsis {}; }; -struct PostfixExpressionAST: public ExpressionAST -{ +struct PostfixExpressionAST : public ExpressionAST { DECLARE_AST_NODE(PostfixExpression) - TypeSpecifierAST *type_specifier{}; - ExpressionAST *expression{}; - const ListNode *sub_expressions{}; + TypeSpecifierAST* type_specifier {}; + ExpressionAST* expression {}; + const ListNode* sub_expressions {}; }; -struct PrimaryExpressionAST: public ExpressionAST -{ +struct PrimaryExpressionAST : public ExpressionAST { DECLARE_AST_NODE(PrimaryExpression) - StringLiteralAST *literal{}; - std::size_t token{}; - StatementAST *expression_statement{}; - ExpressionAST *sub_expression{}; - NameAST *name{}; + StringLiteralAST* literal {}; + std::size_t token {}; + StatementAST* expression_statement {}; + ExpressionAST* sub_expression {}; + NameAST* name {}; }; -struct PtrOperatorAST: public AST -{ +struct PtrOperatorAST : public AST { DECLARE_AST_NODE(PtrOperator) - const ListNode *cv{}; - std::size_t op{}; - PtrToMemberAST *mem_ptr{}; + const ListNode* cv {}; + std::size_t op {}; + PtrToMemberAST* mem_ptr {}; }; -struct PtrToMemberAST: public AST -{ +struct PtrToMemberAST : public AST { DECLARE_AST_NODE(PtrToMember) }; -struct ReturnStatementAST: public StatementAST -{ +struct ReturnStatementAST : public StatementAST { DECLARE_AST_NODE(ReturnStatement) - ExpressionAST *expression{}; + ExpressionAST* expression {}; }; -struct SimpleDeclarationAST: public DeclarationAST -{ +struct SimpleDeclarationAST : public DeclarationAST { DECLARE_AST_NODE(SimpleDeclaration) - const ListNode *storage_specifiers{}; - const ListNode *function_specifiers{}; - TypeSpecifierAST *type_specifier{}; - const ListNode *init_declarators{}; - WinDeclSpecAST *win_decl_specifiers{}; + const ListNode* storage_specifiers {}; + const ListNode* function_specifiers {}; + TypeSpecifierAST* type_specifier {}; + const ListNode* init_declarators {}; + WinDeclSpecAST* win_decl_specifiers {}; }; -struct SimpleTypeSpecifierAST: public TypeSpecifierAST -{ +struct SimpleTypeSpecifierAST : public TypeSpecifierAST { DECLARE_AST_NODE(SimpleTypeSpecifier) - const ListNode *integrals{}; - std::size_t type_of{}; - TypeIdAST *type_id{}; - ExpressionAST *expression{}; - NameAST *name{}; - bool is_auto{}; + const ListNode* integrals {}; + std::size_t type_of {}; + TypeIdAST* type_id {}; + ExpressionAST* expression {}; + NameAST* name {}; + bool is_auto {}; }; -struct SizeofExpressionAST: public ExpressionAST -{ +struct SizeofExpressionAST : public ExpressionAST { DECLARE_AST_NODE(SizeofExpression) - std::size_t sizeof_token{}; - TypeIdAST *type_id{}; - ExpressionAST *expression{}; + std::size_t sizeof_token {}; + TypeIdAST* type_id {}; + ExpressionAST* expression {}; }; -struct StringLiteralAST: public AST -{ +struct StringLiteralAST : public AST { DECLARE_AST_NODE(StringLiteral) - const ListNode *literals{}; + const ListNode* literals {}; }; -struct SubscriptExpressionAST: public ExpressionAST -{ +struct SubscriptExpressionAST : public ExpressionAST { DECLARE_AST_NODE(SubscriptExpression) - ExpressionAST *subscript{}; + ExpressionAST* subscript {}; }; -struct SwitchStatementAST: public StatementAST -{ +struct SwitchStatementAST : public StatementAST { DECLARE_AST_NODE(SwitchStatement) - ConditionAST *condition{}; - StatementAST *statement{}; + ConditionAST* condition {}; + StatementAST* statement {}; }; -struct TemplateArgumentAST: public AST -{ +struct TemplateArgumentAST : public AST { DECLARE_AST_NODE(TemplateArgument) - TypeIdAST *type_id{}; - ExpressionAST *expression{}; - bool variadic{}; + TypeIdAST* type_id {}; + ExpressionAST* expression {}; + bool variadic {}; }; -struct TemplateDeclarationAST: public DeclarationAST -{ +struct TemplateDeclarationAST : public DeclarationAST { DECLARE_AST_NODE(TemplateDeclaration) - std::size_t exported{}; - const ListNode *template_parameters{}; - DeclarationAST* declaration{}; + std::size_t exported {}; + const ListNode* template_parameters {}; + DeclarationAST* declaration {}; }; -struct TemplateParameterAST: public AST -{ +struct TemplateParameterAST : public AST { DECLARE_AST_NODE(TemplateParameter) - TypeParameterAST *type_parameter{}; - ParameterDeclarationAST *parameter_declaration{}; + TypeParameterAST* type_parameter {}; + ParameterDeclarationAST* parameter_declaration {}; }; -struct ThrowExpressionAST: public ExpressionAST -{ +struct ThrowExpressionAST : public ExpressionAST { DECLARE_AST_NODE(ThrowExpression) - std::size_t throw_token{}; - ExpressionAST *expression{}; + std::size_t throw_token {}; + ExpressionAST* expression {}; }; -struct TranslationUnitAST: public AST -{ +struct TranslationUnitAST : public AST { DECLARE_AST_NODE(TranslationUnit) - const ListNode *declarations{}; + const ListNode* declarations {}; }; -struct TryBlockStatementAST: public StatementAST -{ +struct TryBlockStatementAST : public StatementAST { DECLARE_AST_NODE(TryBlockStatement) }; -struct TypeIdAST: public AST -{ +struct TypeIdAST : public AST { DECLARE_AST_NODE(TypeId) - TypeSpecifierAST *type_specifier{}; - DeclaratorAST *declarator{}; + TypeSpecifierAST* type_specifier {}; + DeclaratorAST* declarator {}; }; -struct TypeIdentificationAST: public ExpressionAST -{ +struct TypeIdentificationAST : public ExpressionAST { DECLARE_AST_NODE(TypeIdentification) - std::size_t typename_token{}; - NameAST *name{}; - ExpressionAST *expression{}; + std::size_t typename_token {}; + NameAST* name {}; + ExpressionAST* expression {}; }; -struct TypeParameterAST: public AST -{ +struct TypeParameterAST : public AST { DECLARE_AST_NODE(TypeParameter) - std::size_t type{}; - NameAST *name{}; - TypeIdAST *type_id{}; - const ListNode *template_parameters{}; - NameAST *template_name{}; + std::size_t type {}; + NameAST* name {}; + TypeIdAST* type_id {}; + const ListNode* template_parameters {}; + NameAST* template_name {}; }; -struct TypedefAST: public DeclarationAST -{ +struct TypedefAST : public DeclarationAST { DECLARE_AST_NODE(Typedef) - TypeSpecifierAST *type_specifier{}; - const ListNode *init_declarators{}; + TypeSpecifierAST* type_specifier {}; + const ListNode* init_declarators {}; }; -struct UnaryExpressionAST: public ExpressionAST -{ +struct UnaryExpressionAST : public ExpressionAST { DECLARE_AST_NODE(UnaryExpression) - std::size_t op{}; - ExpressionAST *expression{}; + std::size_t op {}; + ExpressionAST* expression {}; }; -struct UnqualifiedNameAST: public AST -{ +struct UnqualifiedNameAST : public AST { DECLARE_AST_NODE(UnqualifiedName) - std::size_t tilde{}; - std::size_t id{}; - OperatorFunctionIdAST *operator_id{}; - const ListNode *template_arguments{}; + std::size_t tilde {}; + std::size_t id {}; + OperatorFunctionIdAST* operator_id {}; + const ListNode* template_arguments {}; }; -struct UsingAST: public DeclarationAST -{ +struct UsingAST : public DeclarationAST { DECLARE_AST_NODE(Using) - std::size_t type_name{}; - NameAST *name{}; + std::size_t type_name {}; + NameAST* name {}; }; -struct UsingDirectiveAST: public DeclarationAST -{ +struct UsingDirectiveAST : public DeclarationAST { DECLARE_AST_NODE(UsingDirective) - NameAST *name{}; + NameAST* name {}; }; -struct WhileStatementAST: public StatementAST -{ +struct WhileStatementAST : public StatementAST { DECLARE_AST_NODE(WhileStatement) - ConditionAST *condition{}; - StatementAST *statement{}; + ConditionAST* condition {}; + StatementAST* statement {}; }; -struct WinDeclSpecAST: public AST -{ +struct WinDeclSpecAST : public AST { DECLARE_AST_NODE(WinDeclSpec) - std::size_t specifier{}; - std::size_t modifier{}; + std::size_t specifier {}; + std::size_t modifier {}; }; -struct QPropertyAST : public DeclarationAST -{ +struct QPropertyAST : public DeclarationAST { DECLARE_AST_NODE(QPropertyAST) }; -struct QEnumsAST : public DeclarationAST -{ +struct QEnumsAST : public DeclarationAST { DECLARE_AST_NODE(QEnumsAST) - bool isQEnum{}; + bool isQEnum {}; }; -template -_Tp *CreateNode(pool *memory_pool) +template +_Tp* CreateNode(pool* memory_pool) { - _Tp *node = reinterpret_cast<_Tp*>(memory_pool->allocate(sizeof(_Tp))); + _Tp* node = reinterpret_cast<_Tp*>(memory_pool->allocate(sizeof(_Tp))); node->kind = _Tp::__node_kind; return node; } -template -_Tp ast_cast(AST *item) +template +_Tp ast_cast(AST* item) { if (item && static_cast<_Tp>(0)->__node_kind == item->kind) return static_cast<_Tp>(item); diff --git a/generator/parser/binder.cpp b/generator/parser/binder.cpp index a93bac2c5..3e2a25962 100644 --- a/generator/parser/binder.cpp +++ b/generator/parser/binder.cpp @@ -53,15 +53,15 @@ #include -Binder::Binder(CodeModel *__model, LocationManager &__location, Control *__control) - : _M_model(__model), - _M_location(__location), - _M_token_stream(&_M_location.token_stream), - _M_control(__control), - _M_current_function_type(CodeModel::Normal), - type_cc(this), - name_cc(this), - decl_cc(this) +Binder::Binder(CodeModel* __model, LocationManager& __location, Control* __control) + : _M_model(__model) + , _M_location(__location) + , _M_token_stream(&_M_location.token_stream) + , _M_control(__control) + , _M_current_function_type(CodeModel::Normal) + , type_cc(this) + , name_cc(this) + , decl_cc(this) { _M_qualified_types["char"] = QString(); _M_qualified_types["double"] = QString(); @@ -72,17 +72,15 @@ Binder::Binder(CodeModel *__model, LocationManager &__location, Control *__contr _M_qualified_types["void"] = QString(); } -Binder::~Binder() -{ -} +Binder::~Binder() {} -FileModelItem Binder::run(AST *node) +FileModelItem Binder::run(AST* node) { FileModelItem old = _M_current_file; _M_current_access = CodeModel::Public; _M_current_file = model()->create(); - updateItemPosition (_M_current_file, node); + updateItemPosition(_M_current_file, node); visit(node); FileModelItem result = _M_current_file; @@ -150,283 +148,251 @@ int Binder::decode_token(std::size_t index) const CodeModel::AccessPolicy Binder::decode_access_policy(std::size_t index) const { - switch (decode_token(index)) - { - case Token_class: - return CodeModel::Private; + switch (decode_token(index)) { + case Token_class: + return CodeModel::Private; - case Token_struct: - case Token_union: - return CodeModel::Public; + case Token_struct: + case Token_union: + return CodeModel::Public; - default: - return CodeModel::Public; - } + default: + return CodeModel::Public; + } } CodeModel::ClassType Binder::decode_class_type(std::size_t index) const { - switch (decode_token(index)) - { - case Token_class: - return CodeModel::Class; - case Token_struct: - return CodeModel::Struct; - case Token_union: - return CodeModel::Union; - default: - warnHere(); - std::cerr << "** WARNING unrecognized class type" << std::endl; - } + switch (decode_token(index)) { + case Token_class: return CodeModel::Class; + case Token_struct: + return CodeModel::Struct; + case Token_union: + return CodeModel::Union; + default: + warnHere(); + std::cerr << "** WARNING unrecognized class type" << std::endl; + } + return CodeModel::Class; } -const NameSymbol *Binder::decode_symbol(std::size_t index) const +const NameSymbol* Binder::decode_symbol(std::size_t index) const { return _M_token_stream->symbol(index); } -void Binder::visitAccessSpecifier(AccessSpecifierAST *node) +void Binder::visitAccessSpecifier(AccessSpecifierAST* node) { - const ListNode *it = node->specs; + const ListNode* it = node->specs; if (it == 0) return; it = it->toFront(); - const ListNode *end = it; - - do - { - switch (decode_token(it->element)) - { - default: - break; - - case Token_public: - changeCurrentAccess(CodeModel::Public); - changeCurrentFunctionType(CodeModel::Normal); - break; - case Token_protected: - changeCurrentAccess(CodeModel::Protected); - changeCurrentFunctionType(CodeModel::Normal); - break; - case Token_private: - changeCurrentAccess(CodeModel::Private); - changeCurrentFunctionType(CodeModel::Normal); - break; - case Token_signals: - changeCurrentAccess(CodeModel::Protected); - changeCurrentFunctionType(CodeModel::Signal); - break; - case Token_slots: - changeCurrentFunctionType(CodeModel::Slot); - break; - } - it = it->next; + const ListNode* end = it; + + do { + switch (decode_token(it->element)) { + default: + break; + + case Token_public: + changeCurrentAccess(CodeModel::Public); + changeCurrentFunctionType(CodeModel::Normal); + break; + case Token_protected: + changeCurrentAccess(CodeModel::Protected); + changeCurrentFunctionType(CodeModel::Normal); + break; + case Token_private: + changeCurrentAccess(CodeModel::Private); + changeCurrentFunctionType(CodeModel::Normal); + break; + case Token_signals: + changeCurrentAccess(CodeModel::Protected); + changeCurrentFunctionType(CodeModel::Signal); + break; + case Token_slots: + changeCurrentFunctionType(CodeModel::Slot); + break; } - while (it != end); + it = it->next; + } while (it != end); } -void Binder::visitSimpleDeclaration(SimpleDeclarationAST *node) +void Binder::visitSimpleDeclaration(SimpleDeclarationAST* node) { visit(node->type_specifier); - if (const ListNode *it = node->init_declarators) - { - it = it->toFront(); - const ListNode *end = it; - do - { - InitDeclaratorAST *init_declarator = it->element; - declare_symbol(node, init_declarator); - it = it->next; - } - while (it != end); - } + if (const ListNode* it = node->init_declarators) { + it = it->toFront(); + const ListNode* end = it; + do { + InitDeclaratorAST* init_declarator = it->element; + declare_symbol(node, init_declarator); + it = it->next; + } while (it != end); + } } -void Binder::declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_declarator) +void Binder::declare_symbol(SimpleDeclarationAST* node, InitDeclaratorAST* init_declarator) { - DeclaratorAST *declarator = init_declarator->declarator; + DeclaratorAST* declarator = init_declarator->declarator; while (declarator && declarator->sub_declarator) declarator = declarator->sub_declarator; - NameAST *id = declarator->id; - if (! declarator->id) - { - warnHere(); - std::cerr << "** WARNING expected a declarator id" << std::endl; - return; - } + NameAST* id = declarator->id; + if (!declarator->id) { + warnHere(); + std::cerr << "** WARNING expected a declarator id" << std::endl; + return; + } CodeModelFinder finder(model(), this); ScopeModelItem symbolScope = finder.resolveScope(id, currentScope()); - if (! symbolScope) - { - name_cc.run(id); - warnHere(); - std::cerr << "** WARNING scope not found for symbol: " - << qPrintable(name_cc.name()) << std::endl; - return; - } + if (!symbolScope) { + name_cc.run(id); + warnHere(); + std::cerr << "** WARNING scope not found for symbol: " << qPrintable(name_cc.name()) << std::endl; + return; + } decl_cc.run(declarator); - if (decl_cc.isFunction()) - { - name_cc.run(id->unqualified_name); - - FunctionModelItem fun = model()->create(); - updateItemPosition (fun, node); - fun->setAccessPolicy(_M_current_access); - fun->setFunctionType(_M_current_function_type); - fun->setName(name_cc.name()); - InitializerAST* initializer = init_declarator->initializer; - fun->setDeleted(initializer && initializer->isDeleted); - fun->setAbstract(initializer && !initializer->isDefault && !initializer->isDeleted); // must be "= 0" - fun->setConstant(declarator->fun_cv != 0); - fun->setException(exceptionSpecToString(declarator->exception_spec)); - - fun->setTemplateParameters(_M_current_template_parameters); - applyStorageSpecifiers(node->storage_specifiers, fun.staticCast<_MemberModelItem>()); - applyFunctionSpecifiers(node->function_specifiers, fun); - - if (hasFriendSpecifier(node->storage_specifiers)) - { - // check if this function declaration is a "friend" function. - // In this case we modify the scope, and remove the "friend" flag. - // This is for functions/operators that are only defined as friend - // inside of classes. - symbolScope = _M_current_file.staticCast<_ScopeModelItem>(); - // unset the friend flag, as we treat this like a stand-alone function definition - fun->setFriend(false); - // also set the access policy to public, just in case - fun->setAccessPolicy(CodeModel::Public); - } + if (decl_cc.isFunction()) { + name_cc.run(id->unqualified_name); + + FunctionModelItem fun = model()->create(); + updateItemPosition(fun, node); + fun->setAccessPolicy(_M_current_access); + fun->setFunctionType(_M_current_function_type); + fun->setName(name_cc.name()); + InitializerAST* initializer = init_declarator->initializer; + fun->setDeleted(initializer && initializer->isDeleted); + fun->setAbstract(initializer && !initializer->isDefault && !initializer->isDeleted); // must be "= 0" + fun->setConstant(declarator->fun_cv != 0); + fun->setException(exceptionSpecToString(declarator->exception_spec)); + + fun->setTemplateParameters(_M_current_template_parameters); + applyStorageSpecifiers(node->storage_specifiers, fun.staticCast<_MemberModelItem>()); + applyFunctionSpecifiers(node->function_specifiers, fun); + + if (hasFriendSpecifier(node->storage_specifiers)) { + // check if this function declaration is a "friend" function. + // In this case we modify the scope, and remove the "friend" flag. + // This is for functions/operators that are only defined as friend + // inside of classes. + symbolScope = _M_current_file.staticCast<_ScopeModelItem>(); + // unset the friend flag, as we treat this like a stand-alone function definition + fun->setFriend(false); + // also set the access policy to public, just in case + fun->setAccessPolicy(CodeModel::Public); + } - if (const ListNode *it = node->init_declarators) - { - it = it->toFront(); - const ListNode *end = it; - do - { - InitDeclaratorAST *init_declarator = it->element; - if (init_declarator->declarator && init_declarator->declarator->_override) { - //std::cout << name_cc.name().toLatin1().constData() << std::endl; - fun->setVirtual(true); - } - it = it->next; - } while (it != end); - } + if (const ListNode* it = node->init_declarators) { + it = it->toFront(); + const ListNode* end = it; + do { + InitDeclaratorAST* init_declarator = it->element; + if (init_declarator->declarator && init_declarator->declarator->_override) { + //std::cout << name_cc.name().toLatin1().constData() << std::endl; + fun->setVirtual(true); + } + it = it->next; + } while (it != end); + } - // build the type - TypeInfo typeInfo = CompilerUtils::typeDescription(node->type_specifier, - declarator, - this); + // build the type + TypeInfo typeInfo = CompilerUtils::typeDescription(node->type_specifier, declarator, this); - fun->setType(qualifyType(typeInfo, symbolScope->qualifiedName())); + fun->setType(qualifyType(typeInfo, symbolScope->qualifiedName())); + fun->setVariadics(decl_cc.isVariadics()); - fun->setVariadics (decl_cc.isVariadics ()); + // ... and the signature + const QList parameters = decl_cc.parameters(); + for (const DeclaratorCompiler::Parameter& p : parameters) { + ArgumentModelItem arg = model()->create(); + arg->setType(qualifyType(p.type, _M_context)); + arg->setName(p.name); + arg->setDefaultValue(p.defaultValue); + if (p.defaultValue) + arg->setDefaultValueExpression(p.defaultValueExpression); + fun->addArgument(arg); + } - // ... and the signature + fun->setScope(symbolScope->qualifiedName()); + symbolScope->addFunction(fun); + } else { + VariableModelItem var = model()->create(); + updateItemPosition(var, node); + var->setTemplateParameters(_M_current_template_parameters); + var->setAccessPolicy(_M_current_access); + name_cc.run(id->unqualified_name); + var->setName(name_cc.name()); + TypeInfo typeInfo = CompilerUtils::typeDescription(node->type_specifier, declarator, this); + if (declarator != init_declarator->declarator && init_declarator->declarator->parameter_declaration_clause != 0) { + typeInfo.setFunctionPointer(true); + decl_cc.run(init_declarator->declarator); const QList parameters = decl_cc.parameters(); - for (const DeclaratorCompiler::Parameter& p : parameters) - { - ArgumentModelItem arg = model()->create(); - arg->setType(qualifyType(p.type, _M_context)); - arg->setName(p.name); - arg->setDefaultValue(p.defaultValue); - if (p.defaultValue) - arg->setDefaultValueExpression(p.defaultValueExpression); - fun->addArgument(arg); - } - - fun->setScope(symbolScope->qualifiedName()); - symbolScope->addFunction(fun); + for (const DeclaratorCompiler::Parameter& p : parameters) { + typeInfo.addArgument(p.type); + } } - else - { - VariableModelItem var = model()->create(); - updateItemPosition (var, node); - var->setTemplateParameters(_M_current_template_parameters); - var->setAccessPolicy(_M_current_access); - name_cc.run(id->unqualified_name); - var->setName(name_cc.name()); - TypeInfo typeInfo = CompilerUtils::typeDescription(node->type_specifier, - declarator, - this); - if (declarator != init_declarator->declarator - && init_declarator->declarator->parameter_declaration_clause != 0) - { - typeInfo.setFunctionPointer (true); - decl_cc.run (init_declarator->declarator); - const QList parameters = decl_cc.parameters(); - for (const DeclaratorCompiler::Parameter& p : parameters) { - typeInfo.addArgument(p.type); - } - } - var->setType(qualifyType(typeInfo, _M_context)); - applyStorageSpecifiers(node->storage_specifiers, var.staticCast<_MemberModelItem>()); + var->setType(qualifyType(typeInfo, _M_context)); + applyStorageSpecifiers(node->storage_specifiers, var.staticCast<_MemberModelItem>()); - var->setScope(symbolScope->qualifiedName()); - symbolScope->addVariable(var); - } + var->setScope(symbolScope->qualifiedName()); + symbolScope->addVariable(var); + } } -void Binder::visitFunctionDefinition(FunctionDefinitionAST *node) +void Binder::visitFunctionDefinition(FunctionDefinitionAST* node) { Q_ASSERT(node->init_declarator != 0); ScopeModelItem scope = currentScope(); bool friendWithDefinition = false; - if (hasFriendSpecifier(node->storage_specifiers)) - { - // check if this function declaration is a "friend" function. - // In this case we modify the scope, and remove the "friend" flag later on. - friendWithDefinition = true; - scope = _M_current_file.staticCast<_ScopeModelItem>(); - } + if (hasFriendSpecifier(node->storage_specifiers)) { + // check if this function declaration is a "friend" function. + // In this case we modify the scope, and remove the "friend" flag later on. + friendWithDefinition = true; + scope = _M_current_file.staticCast<_ScopeModelItem>(); + } - InitDeclaratorAST *init_declarator = node->init_declarator; - DeclaratorAST *declarator = init_declarator->declarator; + InitDeclaratorAST* init_declarator = node->init_declarator; + DeclaratorAST* declarator = init_declarator->declarator; // in the case of "void (func)()" or "void ((func))()" we need to // skip to the inner most. This is in line with how the declarator // node is generated in 'parser.cpp' while (declarator && declarator->sub_declarator) - declarator = declarator->sub_declarator; + declarator = declarator->sub_declarator; //Q_ASSERT(declarator->id); if (!declarator->id) { warnHere(); - std::cerr << "** SHIT " << qPrintable(name_cc.name()) << std::endl - << "\tdefinition *ignored*" - << std::endl; + std::cerr << "** SHIT " << qPrintable(name_cc.name()) << std::endl << "\tdefinition *ignored*" << std::endl; return; } CodeModelFinder finder(model(), this); - if (declarator->valueRef == DeclaratorAST::Rvalue) - { + if (declarator->valueRef == DeclaratorAST::Rvalue) { // rvalue reference methods are ignored, since we can't use them for the wrappers // (there is usually also a method with lvalue reference binding) return; } ScopeModelItem functionScope = finder.resolveScope(declarator->id, scope); - if (! functionScope) - { - warnHere(); - name_cc.run(declarator->id); - std::cerr << "** WARNING scope not found for function definition: " - << qPrintable(name_cc.name()) << std::endl - << "\tdefinition *ignored*" - << std::endl; - return; - } + if (!functionScope) { + warnHere(); + name_cc.run(declarator->id); + std::cerr << "** WARNING scope not found for function definition: " << qPrintable(name_cc.name()) << std::endl + << "\tdefinition *ignored*" << std::endl; + return; + } decl_cc.run(declarator); const QList parameters = decl_cc.parameters(); @@ -445,20 +411,18 @@ void Binder::visitFunctionDefinition(FunctionDefinitionAST *node) } } - Q_ASSERT(! decl_cc.id().isEmpty()); + Q_ASSERT(!decl_cc.id().isEmpty()); - FunctionDefinitionModelItem - old = changeCurrentFunction(_M_model->create()); + FunctionDefinitionModelItem old = changeCurrentFunction(_M_model->create()); _M_current_function->setScope(functionScope->qualifiedName()); - updateItemPosition (_M_current_function, node); + updateItemPosition(_M_current_function, node); Q_ASSERT(declarator->id->unqualified_name != 0); name_cc.run(declarator->id->unqualified_name); QString unqualified_name = name_cc.name(); _M_current_function->setName(unqualified_name); - TypeInfo tmp_type = CompilerUtils::typeDescription(node->type_specifier, - declarator, this); + TypeInfo tmp_type = CompilerUtils::typeDescription(node->type_specifier, declarator, this); _M_current_function->setType(qualifyType(tmp_type, _M_context)); _M_current_function->setAccessPolicy(_M_current_access); @@ -467,49 +431,44 @@ void Binder::visitFunctionDefinition(FunctionDefinitionAST *node) _M_current_function->setTemplateParameters(_M_current_template_parameters); _M_current_function->setException(exceptionSpecToString(declarator->exception_spec)); - applyStorageSpecifiers(node->storage_specifiers, - _M_current_function.staticCast<_MemberModelItem>()); - applyFunctionSpecifiers(node->function_specifiers, - _M_current_function.staticCast<_FunctionModelItem>()); + applyStorageSpecifiers(node->storage_specifiers, _M_current_function.staticCast<_MemberModelItem>()); + applyFunctionSpecifiers(node->function_specifiers, _M_current_function.staticCast<_FunctionModelItem>()); if (node->init_declarator->declarator && node->init_declarator->declarator->_override) { //std::cout << unqualified_name.toLatin1().constData() << std::endl; _M_current_function.staticCast<_FunctionModelItem>()->setVirtual(true); } - if (friendWithDefinition) - { + if (friendWithDefinition) { // unset the friend flag, as we treat this like a stand-alone function definition _M_current_function->setFriend(false); // also set the access policy to public, just in case _M_current_function->setAccessPolicy(CodeModel::Public); } - _M_current_function->setVariadics (decl_cc.isVariadics ()); + _M_current_function->setVariadics(decl_cc.isVariadics()); - for (const DeclaratorCompiler::Parameter& p : parameters) - { - ArgumentModelItem arg = model()->create(); + for (const DeclaratorCompiler::Parameter& p : parameters) { + ArgumentModelItem arg = model()->create(); - // Work on a local copy of the type only - TypeInfo parameter_type = p.type; - - if (_M_current_class && _M_current_class->isTemplateClass()) - { - QStringList qualifiedName = parameter_type.qualifiedName(); - if (qualifiedName.size() == 1 && !qualifiedName.last().contains('<') && - qualifiedName.last() == _M_current_class->name().split('<').first()) - { - // Fix: add template arguments if the argument type is the current class - // name without template arguments - parameter_type.setQualifiedName(QStringList(_M_current_class->name())); - } - } - arg->setType(qualifyType(parameter_type, functionScope->qualifiedName())); - arg->setName(p.name); - arg->setDefaultValue(p.defaultValue); - if (p.defaultValue) - arg->setDefaultValueExpression(p.defaultValueExpression); - _M_current_function->addArgument(arg); + // Work on a local copy of the type only + TypeInfo parameter_type = p.type; + + if (_M_current_class && _M_current_class->isTemplateClass()) { + QStringList qualifiedName = parameter_type.qualifiedName(); + if (qualifiedName.size() == 1 && !qualifiedName.last().contains('<') + && qualifiedName.last() == _M_current_class->name().split('<').first()) + { + // Fix: add template arguments if the argument type is the current class + // name without template arguments + parameter_type.setQualifiedName(QStringList(_M_current_class->name())); + } } + arg->setType(qualifyType(parameter_type, functionScope->qualifiedName())); + arg->setName(p.name); + arg->setDefaultValue(p.defaultValue); + if (p.defaultValue) + arg->setDefaultValueExpression(p.defaultValueExpression); + _M_current_function->addArgument(arg); + } functionScope->addFunctionDefinition(_M_current_function); @@ -517,269 +476,247 @@ void Binder::visitFunctionDefinition(FunctionDefinitionAST *node) FunctionModelItem declared = functionScope->declaredFunction(prototype); // try to find a function declaration for this definition.. - if (! declared) - { - functionScope->addFunction(prototype); + if (!declared) { + functionScope->addFunction(prototype); + } else { + applyFunctionSpecifiers(node->function_specifiers, declared); + if (node->init_declarator->declarator && node->init_declarator->declarator->_override) { + //std::cout << unqualified_name.toLatin1().constData() << std::endl; + _M_current_function.staticCast<_FunctionModelItem>()->setVirtual(true); } - else - { - applyFunctionSpecifiers(node->function_specifiers, declared); - if (node->init_declarator->declarator && node->init_declarator->declarator->_override) { - //std::cout << unqualified_name.toLatin1().constData() << std::endl; - _M_current_function.staticCast<_FunctionModelItem>()->setVirtual(true); - } - // fix the function type and the access policy - _M_current_function->setAccessPolicy(declared->accessPolicy()); - _M_current_function->setFunctionType(declared->functionType()); - } + // fix the function type and the access policy + _M_current_function->setAccessPolicy(declared->accessPolicy()); + _M_current_function->setFunctionType(declared->functionType()); + } changeCurrentFunction(old); } -void Binder::visitTemplateDeclaration(TemplateDeclarationAST *node) +void Binder::visitTemplateDeclaration(TemplateDeclarationAST* node) { - const ListNode *it = node->template_parameters; - if (it == 0) { - // QtScript: we want to visit the declaration still, so that - // e.g. QMetaTypeId is added to the code model - visit(node->declaration); - return; - } + const ListNode* it = node->template_parameters; + if (it == 0) { + // QtScript: we want to visit the declaration still, so that + // e.g. QMetaTypeId is added to the code model + visit(node->declaration); + return; + } - TemplateParameterList savedTemplateParameters = changeTemplateParameters(TemplateParameterList()); + TemplateParameterList savedTemplateParameters = changeTemplateParameters(TemplateParameterList()); - it = it->toFront(); - const ListNode *end = it; + it = it->toFront(); + const ListNode* end = it; + + TemplateParameterList templateParameters; + do { + TemplateParameterAST* parameter = it->element; + TypeParameterAST* type_parameter = parameter->type_parameter; + + NameAST* name; + if (!type_parameter) { + // A hacky hack to work around missing support for parameter declarations in + // templates. We just need the to get the name of the variable, since we + // aren't actually compiling these anyway. We are still not supporting much + // more, but we are refusing to fail for a few more declarations + if (parameter->parameter_declaration == 0 || parameter->parameter_declaration->declarator == 0 + || parameter->parameter_declaration->declarator->id == 0) + { - TemplateParameterList templateParameters; - do { - TemplateParameterAST *parameter = it->element; - TypeParameterAST *type_parameter = parameter->type_parameter; - - NameAST *name; - if (!type_parameter) { - // A hacky hack to work around missing support for parameter declarations in - // templates. We just need the to get the name of the variable, since we - // aren't actually compiling these anyway. We are still not supporting much - // more, but we are refusing to fail for a few more declarations - if (parameter->parameter_declaration == 0 || - parameter->parameter_declaration->declarator == 0 || - parameter->parameter_declaration->declarator->id == 0) { - - /*std::cerr << "** WARNING template declaration not supported ``"; + /*std::cerr << "** WARNING template declaration not supported ``"; Token const &tk = _M_token_stream->token ((int) node->start_token); Token const &end_tk = _M_token_stream->token ((int) node->declaration->start_token); std::cerr << std::string (&tk.text[tk.position], (end_tk.position) - tk.position) << "''" << std::endl << std::endl;*/ - changeTemplateParameters(savedTemplateParameters); - return; - - } + changeTemplateParameters(savedTemplateParameters); + return; + } - name = parameter->parameter_declaration->declarator->id; - } else { - int tk = decode_token(type_parameter->type); - if (tk != Token_typename && tk != Token_class) - { - /*std::cerr << "** WARNING template declaration not supported ``"; + name = parameter->parameter_declaration->declarator->id; + } else { + int tk = decode_token(type_parameter->type); + if (tk != Token_typename && tk != Token_class) { + /*std::cerr << "** WARNING template declaration not supported ``"; Token const &tk = _M_token_stream->token ((int) node->start_token); Token const &end_tk = _M_token_stream->token ((int) node->declaration->start_token); std::cerr << std::string (&tk.text[tk.position], (end_tk.position) - tk.position) << "''" << std::endl << std::endl;*/ - changeTemplateParameters(savedTemplateParameters); - return; - } - assert(tk == Token_typename || tk == Token_class); + changeTemplateParameters(savedTemplateParameters); + return; + } + assert(tk == Token_typename || tk == Token_class); - name = type_parameter->name; - } + name = type_parameter->name; + } - TemplateParameterModelItem p = model()->create(); - name_cc.run(name); - p->setName(name_cc.name()); + TemplateParameterModelItem p = model()->create(); + name_cc.run(name); + p->setName(name_cc.name()); - _M_current_template_parameters.append(p); - it = it->next; - } while (it != end); + _M_current_template_parameters.append(p); + it = it->next; + } while (it != end); - visit(node->declaration); + visit(node->declaration); - changeTemplateParameters(savedTemplateParameters); + changeTemplateParameters(savedTemplateParameters); } -void Binder::visitTypedef(TypedefAST *node) +void Binder::visitTypedef(TypedefAST* node) { - const ListNode *it = node->init_declarators; + const ListNode* it = node->init_declarators; if (it == 0) return; it = it->toFront(); - const ListNode *end = it; + const ListNode* end = it; - do - { - InitDeclaratorAST *init_declarator = it->element; - it = it->next; + do { + InitDeclaratorAST* init_declarator = it->element; + it = it->next; - Q_ASSERT(init_declarator->declarator != 0); + Q_ASSERT(init_declarator->declarator != 0); - // the name - decl_cc.run (init_declarator->declarator); - QString alias_name = decl_cc.id (); + // the name + decl_cc.run(init_declarator->declarator); + QString alias_name = decl_cc.id(); - if (alias_name.isEmpty ()) - { - warnHere(); - std::cerr << "** WARNING anonymous typedef not supported! ``"; - Token const &tk = _M_token_stream->token ((int) node->start_token); - Token const &end_tk = _M_token_stream->token ((int) node->end_token); + if (alias_name.isEmpty()) { + warnHere(); + std::cerr << "** WARNING anonymous typedef not supported! ``"; + Token const& tk = _M_token_stream->token((int)node->start_token); + Token const& end_tk = _M_token_stream->token((int)node->end_token); - std::cerr << std::string (&tk.text[tk.position], end_tk.position - tk.position) << "''" - << std::endl << std::endl; - continue; - } + std::cerr << std::string(&tk.text[tk.position], end_tk.position - tk.position) << "''" << std::endl << std::endl; + continue; + } - // build the type - TypeInfo typeInfo = CompilerUtils::typeDescription (node->type_specifier, - init_declarator->declarator, - this); - DeclaratorAST *decl = init_declarator->declarator; - while (decl && decl->sub_declarator) - decl = decl->sub_declarator; - - if (decl != init_declarator->declarator - && init_declarator->declarator->parameter_declaration_clause != 0) - { - typeInfo.setFunctionPointer (true); - decl_cc.run (init_declarator->declarator); - const QList parameters = decl_cc.parameters(); - for (const DeclaratorCompiler::Parameter& p : parameters) { - typeInfo.addArgument(p.type); - } - } + // build the type + TypeInfo typeInfo = CompilerUtils::typeDescription(node->type_specifier, init_declarator->declarator, this); + DeclaratorAST* decl = init_declarator->declarator; + while (decl && decl->sub_declarator) + decl = decl->sub_declarator; - ScopeModelItem scope = currentScope(); - DeclaratorAST *declarator = init_declarator->declarator; - CodeModelFinder finder(model(), this); - ScopeModelItem typedefScope = finder.resolveScope(declarator->id, scope); - - TypeAliasModelItem typeAlias = model ()->create (); - updateItemPosition (typeAlias, node); - typeAlias->setName (alias_name); - typeAlias->setType (qualifyType (typeInfo, currentScope ()->qualifiedName ())); - typeAlias->setScope (typedefScope->qualifiedName()); - _M_qualified_types[typeAlias->qualifiedName().join(".")] = QString(); - currentScope ()->addTypeAlias (typeAlias); + if (decl != init_declarator->declarator && init_declarator->declarator->parameter_declaration_clause != 0) { + typeInfo.setFunctionPointer(true); + decl_cc.run(init_declarator->declarator); + const QList parameters = decl_cc.parameters(); + for (const DeclaratorCompiler::Parameter& p : parameters) { + typeInfo.addArgument(p.type); + } } - while (it != end); + + ScopeModelItem scope = currentScope(); + DeclaratorAST* declarator = init_declarator->declarator; + CodeModelFinder finder(model(), this); + ScopeModelItem typedefScope = finder.resolveScope(declarator->id, scope); + + TypeAliasModelItem typeAlias = model()->create(); + updateItemPosition(typeAlias, node); + typeAlias->setName(alias_name); + typeAlias->setType(qualifyType(typeInfo, currentScope()->qualifiedName())); + typeAlias->setScope(typedefScope->qualifiedName()); + _M_qualified_types[typeAlias->qualifiedName().join(".")] = QString(); + currentScope()->addTypeAlias(typeAlias); + } while (it != end); } -void Binder::visitNamespace(NamespaceAST *node) +void Binder::visitNamespace(NamespaceAST* node) { bool anonymous = (node->namespace_name == 0); ScopeModelItem scope = currentScope(); NamespaceModelItem old; - if (! anonymous) - { - QString name = decode_symbol(node->namespace_name)->as_string(); - - QStringList qualified_name = scope->qualifiedName(); - qualified_name += name; - NamespaceModelItem ns = (_M_model->findItem(qualified_name,_M_current_file)) - .dynamicCast<_NamespaceModelItem>(); - if (!ns) - { - ns = _M_model->create(); - updateItemPosition (ns, node); - ns->setName(name); - ns->setScope(scope->qualifiedName()); - } - old = changeCurrentNamespace(ns); - - _M_context.append(name); + if (!anonymous) { + QString name = decode_symbol(node->namespace_name)->as_string(); + + QStringList qualified_name = scope->qualifiedName(); + qualified_name += name; + NamespaceModelItem ns = (_M_model->findItem(qualified_name, _M_current_file)).dynamicCast<_NamespaceModelItem>(); + if (!ns) { + ns = _M_model->create(); + updateItemPosition(ns, node); + ns->setName(name); + ns->setScope(scope->qualifiedName()); } + old = changeCurrentNamespace(ns); - DefaultVisitor::visitNamespace(node); + _M_context.append(name); + } - if (! anonymous) - { - Q_ASSERT(scope->kind() == _CodeModelItem::Kind_Namespace - || scope->kind() == _CodeModelItem::Kind_File); + DefaultVisitor::visitNamespace(node); - _M_context.removeLast(); + if (!anonymous) { + Q_ASSERT(scope->kind() == _CodeModelItem::Kind_Namespace || scope->kind() == _CodeModelItem::Kind_File); - if (NamespaceModelItem ns = scope.staticCast<_NamespaceModelItem>()) - { - ns->addNamespace(_M_current_namespace); - } + _M_context.removeLast(); - changeCurrentNamespace(old); + if (NamespaceModelItem ns = scope.staticCast<_NamespaceModelItem>()) { + ns->addNamespace(_M_current_namespace); } + + changeCurrentNamespace(old); + } } -void Binder::visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST *node) +void Binder::visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST* node) { - name_cc.run(node->name); - if (name_cc.name().isEmpty()) - return; + name_cc.run(node->name); + if (name_cc.name().isEmpty()) + return; - ScopeModelItem scope = currentScope(); - _M_qualified_types[(scope->qualifiedName() + name_cc.qualifiedName()).join(".") ] = QString(); + ScopeModelItem scope = currentScope(); + _M_qualified_types[(scope->qualifiedName() + name_cc.qualifiedName()).join(".")] = QString(); } -void Binder::visitClassSpecifier(ClassSpecifierAST *node) +void Binder::visitClassSpecifier(ClassSpecifierAST* node) { ClassCompiler class_cc(this); class_cc.run(node); - if (class_cc.name().isEmpty()) - { - // anonymous not supported - return; - } + if (class_cc.name().isEmpty()) { + // anonymous not supported + return; + } Q_ASSERT(node->name != 0 && node->name->unqualified_name != 0); ScopeModelItem scope = currentScope(); ClassModelItem old = changeCurrentClass(_M_model->create()); - updateItemPosition (_M_current_class, node); + updateItemPosition(_M_current_class, node); _M_current_class->setName(class_cc.name()); - QStringList baseClasses = class_cc.baseClasses(); TypeInfo info; - for (int i=0; iqualifiedName()).qualifiedName().join("::"); - } + QStringList baseClasses = class_cc.baseClasses(); + TypeInfo info; + for (int i = 0; i < baseClasses.size(); ++i) { + info.setQualifiedName(baseClasses.at(i).split("::")); + baseClasses[i] = qualifyType(info, scope->qualifiedName()).qualifiedName().join("::"); + } _M_current_class->setBaseClasses(baseClasses); _M_current_class->setClassType(decode_class_type(node->class_key)); _M_current_class->setTemplateParameters(_M_current_template_parameters); - if (! _M_current_template_parameters.isEmpty()) - { - QString name = _M_current_class->name(); - name += "<"; - for (int i = 0; i<_M_current_template_parameters.size(); ++i) - { - if (i != 0) - name += ","; + if (!_M_current_template_parameters.isEmpty()) { + QString name = _M_current_class->name(); + name += "<"; + for (int i = 0; i < _M_current_template_parameters.size(); ++i) { + if (i != 0) + name += ","; - name += _M_current_template_parameters.at(i)->name(); - } - - name += ">"; - _M_current_class->setName(name); + name += _M_current_template_parameters.at(i)->name(); } + name += ">"; + _M_current_class->setName(name); + } + CodeModel::AccessPolicy oldAccessPolicy = changeCurrentAccess(decode_access_policy(node->class_key)); CodeModel::FunctionType oldFunctionType = changeCurrentFunctionType(CodeModel::Normal); @@ -799,17 +736,17 @@ void Binder::visitClassSpecifier(ClassSpecifierAST *node) changeCurrentFunctionType(oldFunctionType); } -void Binder::visitLinkageSpecification(LinkageSpecificationAST *node) +void Binder::visitLinkageSpecification(LinkageSpecificationAST* node) { DefaultVisitor::visitLinkageSpecification(node); } -void Binder::visitUsing(UsingAST *node) +void Binder::visitUsing(UsingAST* node) { DefaultVisitor::visitUsing(node); } -void Binder::visitEnumSpecifier(EnumSpecifierAST *node) +void Binder::visitEnumSpecifier(EnumSpecifierAST* node) { CodeModelFinder finder(model(), this); ScopeModelItem scope = currentScope(); @@ -818,19 +755,18 @@ void Binder::visitEnumSpecifier(EnumSpecifierAST *node) name_cc.run(node->name); QString name = name_cc.name(); - if (name.isEmpty()) - { - // anonymous enum - QString key = _M_context.join("::"); - int current = ++_M_anonymous_enums[key]; - name += QLatin1String("enum_"); - name += QString::number(current); - } + if (name.isEmpty()) { + // anonymous enum + QString key = _M_context.join("::"); + int current = ++_M_anonymous_enums[key]; + name += QLatin1String("enum_"); + name += QString::number(current); + } _M_current_enum = model()->create(); _M_current_enum->setAccessPolicy(_M_current_access); _M_current_enum->setEnumClass(node->is_enum_class); - updateItemPosition (_M_current_enum, node); + updateItemPosition(_M_current_enum, node); _M_current_enum->setName(name); _M_current_enum->setScope(enumScope->qualifiedName()); @@ -843,47 +779,48 @@ void Binder::visitEnumSpecifier(EnumSpecifierAST *node) _M_current_enum = 0; } -static QString strip_preprocessor_lines(const QString &name) +static QString strip_preprocessor_lines(const QString& name) { - QStringList lst = name.split("\n"); - QString s; - for (int i=0; icreate(); - updateItemPosition (e, node); + updateItemPosition(e, node); e->setName(decode_symbol(node->id)->as_string()); - if (ExpressionAST *expr = node->expression) - { - const Token &start_token = _M_token_stream->token((int) expr->start_token); - const Token &end_token = _M_token_stream->token((int) expr->end_token); + if (ExpressionAST* expr = node->expression) { + const Token& start_token = _M_token_stream->token((int)expr->start_token); + const Token& end_token = _M_token_stream->token((int)expr->end_token); - e->setValue(strip_preprocessor_lines(QString::fromUtf8(&start_token.text[start_token.position], - (int) (end_token.position - start_token.position)).trimmed()).remove(' ')); - } + e->setValue(strip_preprocessor_lines( + QString::fromUtf8(&start_token.text[start_token.position], (int)(end_token.position - start_token.position)) + .trimmed()) + .remove(' ')); + } _M_current_enum->addEnumerator(e); } -void Binder::visitUsingDirective(UsingDirectiveAST *node) +void Binder::visitUsingDirective(UsingDirectiveAST* node) { DefaultVisitor::visitUsingDirective(node); } -void Binder::visitQEnums(QEnumsAST *node) +void Binder::visitQEnums(QEnumsAST* node) { - const Token &start = _M_token_stream->token((int) node->start_token); - const Token &end = _M_token_stream->token((int) node->end_token); - QStringList enum_list = QString::fromLatin1(start.text + start.position, - static_cast(end.position - start.position)).split(' '); + const Token& start = _M_token_stream->token((int)node->start_token); + const Token& end = _M_token_stream->token((int)node->end_token); + QStringList enum_list = + QString::fromLatin1(start.text + start.position, static_cast(end.position - start.position)).split(' '); ScopeModelItem scope = currentScope(); for (int i = 0; i < enum_list.size(); ++i) { @@ -894,13 +831,12 @@ void Binder::visitQEnums(QEnumsAST *node) } } -void Binder::visitQProperty(QPropertyAST *node) +void Binder::visitQProperty(QPropertyAST* node) { - const Token &start = _M_token_stream->token((int) node->start_token); - const Token &end = _M_token_stream->token((int) node->end_token); - QString property = QString::fromLatin1(start.text + start.position, - static_cast(end.position - start.position)); - _M_current_class->addPropertyDeclaration(property); + const Token& start = _M_token_stream->token((int)node->start_token); + const Token& end = _M_token_stream->token((int)node->end_token); + QString property = QString::fromLatin1(start.text + start.position, static_cast(end.position - start.position)); + _M_current_class->addPropertyDeclaration(property); } void Binder::warnHere() const @@ -921,8 +857,7 @@ bool Binder::hasFriendSpecifier(const ListNode* it) it = it->toFront(); const ListNode* end = it; - do - { + do { if (decode_token(it->element) == Token_friend) { return true; } @@ -931,152 +866,136 @@ bool Binder::hasFriendSpecifier(const ListNode* it) return false; } -void Binder::applyStorageSpecifiers(const ListNode *it, MemberModelItem item) +void Binder::applyStorageSpecifiers(const ListNode* it, MemberModelItem item) { if (it == 0) return; it = it->toFront(); - const ListNode *end = it; - - do - { - switch (decode_token(it->element)) - { - default: - break; - - case Token_friend: - item->setFriend(true); - break; - case Token_auto: - item->setAuto(true); - break; - case Token_register: - item->setRegister(true); - break; - case Token_static: - item->setStatic(true); - break; - case Token_extern: - item->setExtern(true); - break; - case Token_mutable: - item->setMutable(true); - break; - } - it = it->next; + const ListNode* end = it; + + do { + switch (decode_token(it->element)) { + default: + break; + + case Token_friend: + item->setFriend(true); + break; + case Token_auto: + item->setAuto(true); + break; + case Token_register: + item->setRegister(true); + break; + case Token_static: + item->setStatic(true); + break; + case Token_extern: + item->setExtern(true); + break; + case Token_mutable: + item->setMutable(true); + break; } - while (it != end); + it = it->next; + } while (it != end); } -void Binder::applyFunctionSpecifiers(const ListNode *it, FunctionModelItem item) +void Binder::applyFunctionSpecifiers(const ListNode* it, FunctionModelItem item) { if (it == 0) return; it = it->toFront(); - const ListNode *end = it; - - do - { - switch (decode_token(it->element)) - { - default: - break; - - case Token_constexpr: - item->setConstexpr(true); - break; - - case Token_inline: - item->setInline(true); - break; - - case Token_virtual: - item->setVirtual(true); - break; - - case Token_explicit: - item->setExplicit(true); - break; - - case Token_Q_INVOKABLE: - item->setInvokable(true); - break; - } - it = it->next; + const ListNode* end = it; + + do { + switch (decode_token(it->element)) { + default: + break; + + case Token_constexpr: + item->setConstexpr(true); + break; + + case Token_inline: + item->setInline(true); + break; + + case Token_virtual: + item->setVirtual(true); + break; + + case Token_explicit: + item->setExplicit(true); + break; + + case Token_Q_INVOKABLE: + item->setInvokable(true); + break; } - while (it != end); + it = it->next; + } while (it != end); } -TypeInfo Binder::qualifyType(const TypeInfo &type, const QStringList &context) const +TypeInfo Binder::qualifyType(const TypeInfo& type, const QStringList& context) const { // ### Potentially improve to use string list in the name table to - if (context.size() == 0) - { - // ### We can assume that this means global namespace for now... - return type; - } - else if (_M_qualified_types.contains(type.qualifiedName().join("."))) - { - return type; - } - else - { - QStringList expanded = context; - expanded << type.qualifiedName(); - if (_M_qualified_types.contains(expanded.join("."))) - { - TypeInfo modified_type = type; - modified_type.setQualifiedName(expanded); - return modified_type; - } - else - { - CodeModelItem scope = model ()->findItem (context, _M_current_file); - - if (ClassModelItem klass = scope.dynamicCast<_ClassModelItem> ()) - { - const QStringList baseClasses = klass->baseClasses(); - for (const QString& base : baseClasses) - { - QStringList ctx = context; - ctx.removeLast(); - ctx.append (base); - - TypeInfo qualified = qualifyType (type, ctx); - if (qualified != type) - return qualified; - } - } - - QStringList copy = context; - copy.removeLast(); - return qualifyType(type, copy); + if (context.size() == 0) { + // ### We can assume that this means global namespace for now... + return type; + } else if (_M_qualified_types.contains(type.qualifiedName().join("."))) { + return type; + } else { + QStringList expanded = context; + expanded << type.qualifiedName(); + if (_M_qualified_types.contains(expanded.join("."))) { + TypeInfo modified_type = type; + modified_type.setQualifiedName(expanded); + return modified_type; + } else { + CodeModelItem scope = model()->findItem(context, _M_current_file); + + if (ClassModelItem klass = scope.dynamicCast<_ClassModelItem>()) { + const QStringList baseClasses = klass->baseClasses(); + for (const QString& base : baseClasses) { + QStringList ctx = context; + ctx.removeLast(); + ctx.append(base); + + TypeInfo qualified = qualifyType(type, ctx); + if (qualified != type) + return qualified; } + } + + QStringList copy = context; + copy.removeLast(); + return qualifyType(type, copy); } + } } -void Binder::updateItemPosition(CodeModelItem item, AST *node) +void Binder::updateItemPosition(CodeModelItem item, AST* node) { QString filename; int line, column; - assert (node != 0); - _M_location.positionAt (_M_token_stream->position(node->start_token), &line, &column, &filename); - item->setFileName (filename); + assert(node != 0); + _M_location.positionAt(_M_token_stream->position(node->start_token), &line, &column, &filename); + item->setFileName(filename); } QString Binder::exceptionSpecToString(ExceptionSpecificationAST* exception_spec) { QString exception; if (exception_spec) { - const Token &start_token = _M_token_stream->token((int) exception_spec->start_token); - const Token &end_token = _M_token_stream->token((int) exception_spec->end_token); + const Token& start_token = _M_token_stream->token((int)exception_spec->start_token); + const Token& end_token = _M_token_stream->token((int)exception_spec->end_token); - exception = QString::fromUtf8(&start_token.text[start_token.position], - (int)(end_token.position - start_token.position)); + exception = + QString::fromUtf8(&start_token.text[start_token.position], (int)(end_token.position - start_token.position)); } return exception; } diff --git a/generator/parser/binder.h b/generator/parser/binder.h index 922092395..f09d502eb 100644 --- a/generator/parser/binder.h +++ b/generator/parser/binder.h @@ -39,59 +39,58 @@ ** ****************************************************************************/ - #ifndef BINDER_H -#define BINDER_H + #define BINDER_H -#include "default_visitor.h" -#include "codemodel.h" -#include "type_compiler.h" -#include "name_compiler.h" -#include "declarator_compiler.h" + #include "default_visitor.h" + #include "codemodel.h" + #include "type_compiler.h" + #include "name_compiler.h" + #include "declarator_compiler.h" class TokenStream; class LocationManager; class Control; struct NameSymbol; -class Binder: protected DefaultVisitor +class Binder : protected DefaultVisitor { public: - Binder(CodeModel *__model, LocationManager &__location, Control *__control = 0); + Binder(CodeModel* __model, LocationManager& __location, Control* __control = 0); virtual ~Binder(); - inline TokenStream *tokenStream() const { return _M_token_stream; } - inline CodeModel *model() const { return _M_model; } + inline TokenStream* tokenStream() const { return _M_token_stream; } + inline CodeModel* model() const { return _M_model; } ScopeModelItem currentScope() const; - FileModelItem run(AST *node); + FileModelItem run(AST* node); -// utils - TypeInfo qualifyType(const TypeInfo &type, const QStringList &context) const; + // utils + TypeInfo qualifyType(const TypeInfo& type, const QStringList& context) const; protected: - virtual void visitAccessSpecifier(AccessSpecifierAST *); - virtual void visitClassSpecifier(ClassSpecifierAST *); - virtual void visitEnumSpecifier(EnumSpecifierAST *); - virtual void visitEnumerator(EnumeratorAST *); - virtual void visitFunctionDefinition(FunctionDefinitionAST *); - virtual void visitLinkageSpecification(LinkageSpecificationAST *); - virtual void visitNamespace(NamespaceAST *); - virtual void visitSimpleDeclaration(SimpleDeclarationAST *); - virtual void visitTemplateDeclaration(TemplateDeclarationAST *); - virtual void visitTypedef(TypedefAST *); - virtual void visitUsing(UsingAST *); - virtual void visitUsingDirective(UsingDirectiveAST *); - virtual void visitQProperty(QPropertyAST *); - virtual void visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST *); - virtual void visitQEnums(QEnumsAST *); + virtual void visitAccessSpecifier(AccessSpecifierAST*); + virtual void visitClassSpecifier(ClassSpecifierAST*); + virtual void visitEnumSpecifier(EnumSpecifierAST*); + virtual void visitEnumerator(EnumeratorAST*); + virtual void visitFunctionDefinition(FunctionDefinitionAST*); + virtual void visitLinkageSpecification(LinkageSpecificationAST*); + virtual void visitNamespace(NamespaceAST*); + virtual void visitSimpleDeclaration(SimpleDeclarationAST*); + virtual void visitTemplateDeclaration(TemplateDeclarationAST*); + virtual void visitTypedef(TypedefAST*); + virtual void visitUsing(UsingAST*); + virtual void visitUsingDirective(UsingDirectiveAST*); + virtual void visitQProperty(QPropertyAST*); + virtual void visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST*); + virtual void visitQEnums(QEnumsAST*); void warnHere() const; private: int decode_token(std::size_t index) const; - const NameSymbol *decode_symbol(std::size_t index) const; + const NameSymbol* decode_symbol(std::size_t index) const; CodeModel::AccessPolicy decode_access_policy(std::size_t index) const; CodeModel::ClassType decode_class_type(std::size_t index) const; @@ -102,21 +101,21 @@ class Binder: protected DefaultVisitor FunctionDefinitionModelItem changeCurrentFunction(FunctionDefinitionModelItem item); TemplateParameterList changeTemplateParameters(TemplateParameterList templateParameters); - void declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_declarator); + void declare_symbol(SimpleDeclarationAST* node, InitDeclaratorAST* init_declarator); bool hasFriendSpecifier(const ListNode* it); - void applyStorageSpecifiers(const ListNode *storage_specifiers, MemberModelItem item); - void applyFunctionSpecifiers(const ListNode *it, FunctionModelItem item); + void applyStorageSpecifiers(const ListNode* storage_specifiers, MemberModelItem item); + void applyFunctionSpecifiers(const ListNode* it, FunctionModelItem item); - void updateItemPosition(CodeModelItem item, AST *node); + void updateItemPosition(CodeModelItem item, AST* node); - QString exceptionSpecToString(ExceptionSpecificationAST *exception_spec); + QString exceptionSpecToString(ExceptionSpecificationAST* exception_spec); private: - CodeModel *_M_model; - LocationManager &_M_location; - TokenStream *_M_token_stream; - Control *_M_control; + CodeModel* _M_model; + LocationManager& _M_location; + TokenStream* _M_token_stream; + Control* _M_control; CodeModel::FunctionType _M_current_function_type; CodeModel::AccessPolicy _M_current_access; diff --git a/generator/parser/class_compiler.cpp b/generator/parser/class_compiler.cpp index 27a9755bc..912cc176c 100644 --- a/generator/parser/class_compiler.cpp +++ b/generator/parser/class_compiler.cpp @@ -39,24 +39,21 @@ ** ****************************************************************************/ - #include "class_compiler.h" #include "lexer.h" #include "binder.h" -ClassCompiler::ClassCompiler(Binder *binder) - : _M_binder (binder), - _M_token_stream(binder->tokenStream ()), - name_cc(_M_binder), - type_cc(_M_binder) +ClassCompiler::ClassCompiler(Binder* binder) + : _M_binder(binder) + , _M_token_stream(binder->tokenStream()) + , name_cc(_M_binder) + , type_cc(_M_binder) { } -ClassCompiler::~ClassCompiler() -{ -} +ClassCompiler::~ClassCompiler() {} -void ClassCompiler::run(ClassSpecifierAST *node) +void ClassCompiler::run(ClassSpecifierAST* node) { name_cc.run(node->name); _M_name = name_cc.name(); @@ -65,19 +62,18 @@ void ClassCompiler::run(ClassSpecifierAST *node) visit(node); } -void ClassCompiler::visitClassSpecifier(ClassSpecifierAST *node) +void ClassCompiler::visitClassSpecifier(ClassSpecifierAST* node) { visit(node->base_clause); } -void ClassCompiler::visitBaseSpecifier(BaseSpecifierAST *node) +void ClassCompiler::visitBaseSpecifier(BaseSpecifierAST* node) { name_cc.run(node->name); QString name = name_cc.name(); - if (! name.isEmpty()) + if (!name.isEmpty()) _M_base_classes.append(name); } - // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/generator/parser/class_compiler.h b/generator/parser/class_compiler.h index 6c2b67c83..4fb64e0d0 100644 --- a/generator/parser/class_compiler.h +++ b/generator/parser/class_compiler.h @@ -39,38 +39,37 @@ ** ****************************************************************************/ - #ifndef CLASS_COMPILER_H -#define CLASS_COMPILER_H + #define CLASS_COMPILER_H -#include -#include + #include + #include -#include "default_visitor.h" -#include "name_compiler.h" -#include "type_compiler.h" + #include "default_visitor.h" + #include "name_compiler.h" + #include "type_compiler.h" class TokenStream; class Binder; -class ClassCompiler: protected DefaultVisitor +class ClassCompiler : protected DefaultVisitor { public: - ClassCompiler(Binder *binder); + ClassCompiler(Binder* binder); virtual ~ClassCompiler(); inline QString name() const { return _M_name; } inline QStringList baseClasses() const { return _M_base_classes; } - void run(ClassSpecifierAST *node); + void run(ClassSpecifierAST* node); protected: - virtual void visitClassSpecifier(ClassSpecifierAST *node); - virtual void visitBaseSpecifier(BaseSpecifierAST *node); + virtual void visitClassSpecifier(ClassSpecifierAST* node); + virtual void visitBaseSpecifier(BaseSpecifierAST* node); private: - Binder *_M_binder; - TokenStream *_M_token_stream; + Binder* _M_binder; + TokenStream* _M_token_stream; QString _M_name; QStringList _M_base_classes; NameCompiler name_cc; diff --git a/generator/parser/codemodel.cpp b/generator/parser/codemodel.cpp index 933282560..ec2ecd979 100644 --- a/generator/parser/codemodel.cpp +++ b/generator/parser/codemodel.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include "codemodel.h" // --------------------------------------------------------------------------- @@ -49,9 +48,7 @@ CodeModel::CodeModel() _M_globalNamespace = create(); } -CodeModel::~CodeModel() -{ -} +CodeModel::~CodeModel() {} void CodeModel::wipeout() { @@ -83,7 +80,7 @@ void CodeModel::removeFile(FileModelItem item) _M_files.erase(it); } -FileModelItem CodeModel::findFile(const QString &name) const +FileModelItem CodeModel::findFile(const QString& name) const { return _M_files.value(name); } @@ -93,86 +90,76 @@ QHash CodeModel::fileMap() const return _M_files; } -CodeModelItem CodeModel::findItem(const QStringList &qualifiedName, CodeModelItem scope) const +CodeModelItem CodeModel::findItem(const QStringList& qualifiedName, CodeModelItem scope) const { - for (int i=0; i()) - { - if (NamespaceModelItem tmp_ns = ns->findNamespace(name)) { - scope = tmp_ns; - continue; - } + const QString& name = qualifiedName.at(i); + + if (NamespaceModelItem ns = scope.dynamicCast<_NamespaceModelItem>()) { + if (NamespaceModelItem tmp_ns = ns->findNamespace(name)) { + scope = tmp_ns; + continue; } + } - if (ScopeModelItem ss = scope.dynamicCast<_ScopeModelItem>()) - { - if (ClassModelItem cs = ss->findClass(name)) - { - scope = cs; - } - else if (EnumModelItem es = ss->findEnum(name)) - { - if (i == qualifiedName.size () - 1) - return es; - } - else if (TypeAliasModelItem tp = ss->findTypeAlias(name)) - { - if (i == qualifiedName.size () - 1) - return tp; - } - else - { - // If we don't find the name in the scope chain we - // need to return an empty item to indicate failure... - return CodeModelItem(); - } + if (ScopeModelItem ss = scope.dynamicCast<_ScopeModelItem>()) { + if (ClassModelItem cs = ss->findClass(name)) { + scope = cs; + } else if (EnumModelItem es = ss->findEnum(name)) { + if (i == qualifiedName.size() - 1) + return es; + } else if (TypeAliasModelItem tp = ss->findTypeAlias(name)) { + if (i == qualifiedName.size() - 1) + return tp; + } else { + // If we don't find the name in the scope chain we + // need to return an empty item to indicate failure... + return CodeModelItem(); } + } } return scope; } - // --------------------------------------------------------------------------- -TypeInfo TypeInfo::combine (const TypeInfo &__lhs, const TypeInfo &__rhs) +TypeInfo TypeInfo::combine(const TypeInfo& __lhs, const TypeInfo& __rhs) { TypeInfo __result = __lhs; - __result.setConstant (__result.isConstant () || __rhs.isConstant ()); - __result.setVolatile (__result.isVolatile () || __rhs.isVolatile ()); - __result.setMutable (__result.isMutable () || __rhs.isMutable ()); - __result.setReference (__result.isReference () || __rhs.isReference ()); - __result.setRvalueReference (__result.isRvalueReference () || __rhs.isRvalueReference ()); - __result.setIndirections (__result.indirections () + __rhs.indirections ()); - __result.setArrayElements (__result.arrayElements () + __rhs.arrayElements ()); + __result.setConstant(__result.isConstant() || __rhs.isConstant()); + __result.setVolatile(__result.isVolatile() || __rhs.isVolatile()); + __result.setMutable(__result.isMutable() || __rhs.isMutable()); + __result.setReference(__result.isReference() || __rhs.isReference()); + __result.setRvalueReference(__result.isRvalueReference() || __rhs.isRvalueReference()); + __result.setIndirections(__result.indirections() + __rhs.indirections()); + __result.setArrayElements(__result.arrayElements() + __rhs.arrayElements()); return __result; } -TypeInfo TypeInfo::resolveType (TypeInfo const &__type, CodeModelItem __scope) +TypeInfo TypeInfo::resolveType(TypeInfo const& __type, CodeModelItem __scope) { - CodeModel *__model = __scope->model (); - Q_ASSERT (__model != 0); + CodeModel* __model = __scope->model(); + Q_ASSERT(__model != 0); - CodeModelItem __item = __model->findItem (__type.qualifiedName (), __scope); + CodeModelItem __item = __model->findItem(__type.qualifiedName(), __scope); - // Copy the type and replace with the proper qualified name. This - // only makes sence to do if we're actually getting a resolved - // type with a namespace. We only get this if the returned type - // has more than 2 entries in the qualified name... This test - // could be improved by returning if the type was found or not. - TypeInfo otherType(__type); - if (__item && __item->qualifiedName().size() > 1) { - otherType.setQualifiedName(__item->qualifiedName()); - } + // Copy the type and replace with the proper qualified name. This + // only makes sence to do if we're actually getting a resolved + // type with a namespace. We only get this if the returned type + // has more than 2 entries in the qualified name... This test + // could be improved by returning if the type was found or not. + TypeInfo otherType(__type); + if (__item && __item->qualifiedName().size() > 1) { + otherType.setQualifiedName(__item->qualifiedName()); + } - if (TypeAliasModelItem __alias = __item.dynamicCast<_TypeAliasModelItem>()) - return resolveType (TypeInfo::combine (__alias->type (), otherType), __scope); + if (TypeAliasModelItem __alias = __item.dynamicCast<_TypeAliasModelItem>()) + return resolveType(TypeInfo::combine(__alias->type(), otherType), __scope); - return otherType; + return otherType; } QString TypeInfo::toString(bool parsable) const @@ -199,66 +186,59 @@ QString TypeInfo::toString(bool parsable) const else if (isReference()) tmp += QLatin1Char('&'); - if (isFunctionPointer()) - { - tmp += QLatin1String(" (*)("); - for (int i=0; iarrayElements(); - for (const QString& elt : arrayElements) - { - tmp += QLatin1String ("["); - tmp += elt; - tmp += QLatin1String ("]"); - } + for (const QString& elt : arrayElements) { + tmp += QLatin1String("["); + tmp += elt; + tmp += QLatin1String("]"); + } return tmp; } -bool TypeInfo::operator==(const TypeInfo &other) const +bool TypeInfo::operator==(const TypeInfo& other) const { if (arrayElements().count() != other.arrayElements().count()) return false; -#if defined (RXX_CHECK_ARRAY_ELEMENTS) // ### it'll break - for (int i=0; ifindFile(fileName()); } -void _CodeModelItem::getStartPosition(int *line, int *column) const +void _CodeModelItem::getStartPosition(int* line, int* column) const { *line = _M_startLine; *column = _M_startColumn; @@ -332,7 +312,7 @@ void _CodeModelItem::setStartPosition(int line, int column) _M_startColumn = column; } -void _CodeModelItem::getEndPosition(int *line, int *column) const +void _CodeModelItem::getEndPosition(int* line, int* column) const { *line = _M_endLine; *column = _M_endColumn; @@ -350,7 +330,7 @@ QStringList _ClassModelItem::baseClasses() const return _M_baseClasses; } -void _ClassModelItem::setBaseClasses(const QStringList &baseClasses) +void _ClassModelItem::setBaseClasses(const QStringList& baseClasses) { _M_baseClasses = baseClasses; } @@ -360,22 +340,22 @@ TemplateParameterList _ClassModelItem::templateParameters() const return _M_templateParameters; } -void _ClassModelItem::setTemplateParameters(const TemplateParameterList &templateParameters) +void _ClassModelItem::setTemplateParameters(const TemplateParameterList& templateParameters) { _M_templateParameters = templateParameters; } -void _ClassModelItem::addBaseClass(const QString &baseClass) +void _ClassModelItem::addBaseClass(const QString& baseClass) { _M_baseClasses.append(baseClass); } -void _ClassModelItem::removeBaseClass(const QString &baseClass) +void _ClassModelItem::removeBaseClass(const QString& baseClass) { _M_baseClasses.removeAt(_M_baseClasses.indexOf(baseClass)); } -bool _ClassModelItem::extendsClass(const QString &name) const +bool _ClassModelItem::extendsClass(const QString& name) const { return _M_baseClasses.contains(name); } @@ -390,22 +370,20 @@ CodeModel::ClassType _ClassModelItem::classType() const return _M_classType; } -void _ClassModelItem::addPropertyDeclaration(const QString &propertyDeclaration) +void _ClassModelItem::addPropertyDeclaration(const QString& propertyDeclaration) { - _M_propertyDeclarations << propertyDeclaration; + _M_propertyDeclarations << propertyDeclaration; } - // --------------------------------------------------------------------------- FunctionModelItem _ScopeModelItem::declaredFunction(FunctionModelItem item) { const FunctionList function_list = findFunctions(item->name()); - for (const FunctionModelItem& fun : function_list) - { - if (fun->isSimilar(item)) - return fun; - } + for (const FunctionModelItem& fun : function_list) { + if (fun->isSimilar(item)) + return fun; + } return FunctionModelItem(); } @@ -430,7 +408,7 @@ FunctionList _ScopeModelItem::functions() const return _M_functions.values(); } -void _ScopeModelItem::addQEnumDeclaration(const QString &qEnumDeclaration) +void _ScopeModelItem::addQEnumDeclaration(const QString& qEnumDeclaration) { _M_qEnumDeclarations.insert(qEnumDeclaration); } @@ -447,10 +425,10 @@ EnumList _ScopeModelItem::enums() const void _ScopeModelItem::addClass(ClassModelItem item) { - QString name = item->name(); - int idx = name.indexOf("<"); - if (idx > 0) - _M_classes.insert(name.left(idx), item); + QString name = item->name(); + int idx = name.indexOf("<"); + if (idx > 0) + _M_classes.insert(name.left(idx), item); _M_classes.insert(name, item); } @@ -491,32 +469,26 @@ void _ScopeModelItem::removeFunction(FunctionModelItem item) { QMultiHash::Iterator it = _M_functions.find(item->name()); - while (it != _M_functions.end() && it.key() == item->name() - && it.value() != item) - { - ++it; - } + while (it != _M_functions.end() && it.key() == item->name() && it.value() != item) { + ++it; + } - if (it != _M_functions.end() && it.value() == item) - { - _M_functions.erase(it); - } + if (it != _M_functions.end() && it.value() == item) { + _M_functions.erase(it); + } } void _ScopeModelItem::removeFunctionDefinition(FunctionDefinitionModelItem item) { QMultiHash::Iterator it = _M_functionDefinitions.find(item->name()); - while (it != _M_functionDefinitions.end() && it.key() == item->name() - && it.value() != item) - { - ++it; - } + while (it != _M_functionDefinitions.end() && it.key() == item->name() && it.value() != item) { + ++it; + } - if (it != _M_functionDefinitions.end() && it.value() == item) - { - _M_functionDefinitions.erase(it); - } + if (it != _M_functionDefinitions.end() && it.value() == item) { + _M_functionDefinitions.erase(it); + } } void _ScopeModelItem::removeVariable(VariableModelItem item) @@ -543,32 +515,32 @@ void _ScopeModelItem::removeEnum(EnumModelItem item) _M_enums.erase(it); } -ClassModelItem _ScopeModelItem::findClass(const QString &name) const +ClassModelItem _ScopeModelItem::findClass(const QString& name) const { return _M_classes.value(name); } -VariableModelItem _ScopeModelItem::findVariable(const QString &name) const +VariableModelItem _ScopeModelItem::findVariable(const QString& name) const { return _M_variables.value(name); } -TypeAliasModelItem _ScopeModelItem::findTypeAlias(const QString &name) const +TypeAliasModelItem _ScopeModelItem::findTypeAlias(const QString& name) const { return _M_typeAliases.value(name); } -EnumModelItem _ScopeModelItem::findEnum(const QString &name) const +EnumModelItem _ScopeModelItem::findEnum(const QString& name) const { return _M_enums.value(name); } -FunctionList _ScopeModelItem::findFunctions(const QString &name) const +FunctionList _ScopeModelItem::findFunctions(const QString& name) const { return _M_functions.values(name); } -FunctionDefinitionList _ScopeModelItem::findFunctionDefinitions(const QString &name) const +FunctionDefinitionList _ScopeModelItem::findFunctionDefinitions(const QString& name) const { return _M_functionDefinitions.values(name); } @@ -590,7 +562,7 @@ void _NamespaceModelItem::removeNamespace(NamespaceModelItem item) _M_namespaces.erase(it); } -NamespaceModelItem _NamespaceModelItem::findNamespace(const QString &name) const +NamespaceModelItem _NamespaceModelItem::findNamespace(const QString& name) const { return _M_namespaces.value(name); } @@ -601,7 +573,7 @@ TypeInfo _ArgumentModelItem::type() const return _M_type; } -void _ArgumentModelItem::setType(const TypeInfo &type) +void _ArgumentModelItem::setType(const TypeInfo& type) { _M_type = type; } @@ -633,14 +605,13 @@ bool _FunctionModelItem::isSimilar(FunctionModelItem other) const // ### check the template parameters - for (int i=0; iarguments().at(i); + for (int i = 0; i < arguments().count(); ++i) { + ArgumentModelItem arg1 = arguments().at(i); + ArgumentModelItem arg2 = other->arguments().at(i); - if (arg1->type() != arg2->type()) - return false; - } + if (arg1->type() != arg2->type()) + return false; + } return true; } @@ -675,7 +646,7 @@ QString _FunctionModelItem::exception() const return _M_exception; } -void _FunctionModelItem::setException(const QString &exception) +void _FunctionModelItem::setException(const QString& exception) { _M_exception = exception; } @@ -743,12 +714,12 @@ void _FunctionModelItem::setDeleted(bool isDeleted) // Qt bool _FunctionModelItem::isInvokable() const { - return _M.isInvokable; + return _M.isInvokable; } void _FunctionModelItem::setInvokable(bool isInvokable) { - _M.isInvokable = isInvokable; + _M.isInvokable = isInvokable; } // --------------------------------------------------------------------------- @@ -757,7 +728,7 @@ TypeInfo _TypeAliasModelItem::type() const return _M_type; } -void _TypeAliasModelItem::setType(const TypeInfo &type) +void _TypeAliasModelItem::setType(const TypeInfo& type) { _M_type = type; } @@ -794,7 +765,7 @@ QString _EnumeratorModelItem::value() const return _M_value; } -void _EnumeratorModelItem::setValue(const QString &value) +void _EnumeratorModelItem::setValue(const QString& value) { _M_value = value; } @@ -805,7 +776,7 @@ TypeInfo _TemplateParameterModelItem::type() const return _M_type; } -void _TemplateParameterModelItem::setType(const TypeInfo &type) +void _TemplateParameterModelItem::setType(const TypeInfo& type) { _M_type = type; } @@ -821,73 +792,73 @@ void _TemplateParameterModelItem::setDefaultValue(bool defaultValue) } // --------------------------------------------------------------------------- -ScopeModelItem _ScopeModelItem::create(CodeModel *model) +ScopeModelItem _ScopeModelItem::create(CodeModel* model) { ScopeModelItem item(new _ScopeModelItem(model)); return item; } -ClassModelItem _ClassModelItem::create(CodeModel *model) +ClassModelItem _ClassModelItem::create(CodeModel* model) { ClassModelItem item(new _ClassModelItem(model)); return item; } -NamespaceModelItem _NamespaceModelItem::create(CodeModel *model) +NamespaceModelItem _NamespaceModelItem::create(CodeModel* model) { NamespaceModelItem item(new _NamespaceModelItem(model)); return item; } -FileModelItem _FileModelItem::create(CodeModel *model) +FileModelItem _FileModelItem::create(CodeModel* model) { FileModelItem item(new _FileModelItem(model)); return item; } -ArgumentModelItem _ArgumentModelItem::create(CodeModel *model) +ArgumentModelItem _ArgumentModelItem::create(CodeModel* model) { ArgumentModelItem item(new _ArgumentModelItem(model)); return item; } -FunctionModelItem _FunctionModelItem::create(CodeModel *model) +FunctionModelItem _FunctionModelItem::create(CodeModel* model) { FunctionModelItem item(new _FunctionModelItem(model)); return item; } -FunctionDefinitionModelItem _FunctionDefinitionModelItem::create(CodeModel *model) +FunctionDefinitionModelItem _FunctionDefinitionModelItem::create(CodeModel* model) { FunctionDefinitionModelItem item(new _FunctionDefinitionModelItem(model)); return item; } -VariableModelItem _VariableModelItem::create(CodeModel *model) +VariableModelItem _VariableModelItem::create(CodeModel* model) { VariableModelItem item(new _VariableModelItem(model)); return item; } -TypeAliasModelItem _TypeAliasModelItem::create(CodeModel *model) +TypeAliasModelItem _TypeAliasModelItem::create(CodeModel* model) { TypeAliasModelItem item(new _TypeAliasModelItem(model)); return item; } -EnumModelItem _EnumModelItem::create(CodeModel *model) +EnumModelItem _EnumModelItem::create(CodeModel* model) { EnumModelItem item(new _EnumModelItem(model)); return item; } -EnumeratorModelItem _EnumeratorModelItem::create(CodeModel *model) +EnumeratorModelItem _EnumeratorModelItem::create(CodeModel* model) { EnumeratorModelItem item(new _EnumeratorModelItem(model)); return item; } -TemplateParameterModelItem _TemplateParameterModelItem::create(CodeModel *model) +TemplateParameterModelItem _TemplateParameterModelItem::create(CodeModel* model) { TemplateParameterModelItem item(new _TemplateParameterModelItem(model)); return item; @@ -899,7 +870,7 @@ TypeInfo _MemberModelItem::type() const return _M_type; } -void _MemberModelItem::setType(const TypeInfo &type) +void _MemberModelItem::setType(const TypeInfo& type) { _M_type = type; } @@ -1005,4 +976,3 @@ void _MemberModelItem::setMutable(bool isMutable) } // kate: space-indent on; indent-width 2; replace-tabs on; - diff --git a/generator/parser/codemodel.h b/generator/parser/codemodel.h index b6ef2ac3e..98c21ec47 100644 --- a/generator/parser/codemodel.h +++ b/generator/parser/codemodel.h @@ -39,52 +39,36 @@ ** ****************************************************************************/ - #ifndef CODEMODEL_H -#define CODEMODEL_H + #define CODEMODEL_H -#include "codemodel_fwd.h" + #include "codemodel_fwd.h" -#include -#include -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include + #include + #include -#define DECLARE_MODEL_NODE(k) \ - enum { __node_kind = Kind_##k }; \ + #define DECLARE_MODEL_NODE(k) enum { __node_kind = Kind_##k }; class CodeModel { public: - enum AccessPolicy - { - Public, - Protected, - Private - }; + enum AccessPolicy { Public, Protected, Private }; - enum FunctionType - { - Normal, - Signal, - Slot - }; + enum FunctionType { Normal, Signal, Slot }; - enum ClassType - { - Class, - Struct, - Union - }; + enum ClassType { Class, Struct, Union }; public: CodeModel(); virtual ~CodeModel(); - template _Target create() + template + _Target create() { typedef typename _Target::Type _Target_type; @@ -98,10 +82,10 @@ class CodeModel void addFile(FileModelItem item); void removeFile(FileModelItem item); - FileModelItem findFile(const QString &name) const; + FileModelItem findFile(const QString& name) const; QHash fileMap() const; - CodeModelItem findItem(const QStringList &qualifiedName, CodeModelItem scope) const; + CodeModelItem findItem(const QStringList& qualifiedName, CodeModelItem scope) const; void wipeout(); @@ -111,14 +95,13 @@ class CodeModel std::size_t _M_creation_id; private: - CodeModel(const CodeModel &other); - void operator = (const CodeModel &other); + CodeModel(const CodeModel& other); + void operator=(const CodeModel& other); }; -struct TypeInfo -{ +struct TypeInfo { QStringList qualifiedName() const { return m_qualifiedName; } - void setQualifiedName(const QStringList &qualified_name) { m_qualifiedName = qualified_name; } + void setQualifiedName(const QStringList& qualified_name) { m_qualifiedName = qualified_name; } bool isConstant() const { return m_flags.m_constant; } void setConstant(bool is) { m_flags.m_constant = is; } @@ -142,54 +125,50 @@ struct TypeInfo void setFunctionPointer(bool is) { m_flags.m_functionPointer = is; } QStringList arrayElements() const { return m_arrayElements; } - void setArrayElements(const QStringList &arrayElements) { m_arrayElements = arrayElements; } + void setArrayElements(const QStringList& arrayElements) { m_arrayElements = arrayElements; } QList arguments() const { return m_arguments; } - void setArguments(const QList &arguments); - void addArgument(const TypeInfo &arg) { m_arguments.append(arg); } + void setArguments(const QList& arguments); + void addArgument(const TypeInfo& arg) { m_arguments.append(arg); } - bool operator==(const TypeInfo &other) const; - bool operator!=(const TypeInfo &other) const { return !(*this==other); } + bool operator==(const TypeInfo& other) const; + bool operator!=(const TypeInfo& other) const { return !(*this == other); } // ### arrays and templates?? QString toString(bool parsable = false) const; - static TypeInfo combine (const TypeInfo &__lhs, const TypeInfo &__rhs); - static TypeInfo resolveType (TypeInfo const &__type, CodeModelItem __scope); + static TypeInfo combine(const TypeInfo& __lhs, const TypeInfo& __rhs); + static TypeInfo resolveType(TypeInfo const& __type, CodeModelItem __scope); private: struct TypeInfo_flags { - uint m_constant: 1; - uint m_constexpr: 1; - uint m_volatile: 1; - uint m_mutable: 1; - uint m_reference: 1; - uint m_functionPointer: 1; - uint m_indirections: 6; - inline bool equals(TypeInfo_flags other) const { - /* m_auto and m_friend don't matter here */ - return m_constant == other.m_constant - && m_constexpr == other.m_constexpr - && m_volatile == other.m_volatile - && m_mutable == other.m_mutable - && m_reference == other.m_reference - && m_functionPointer == other.m_functionPointer - && m_indirections == other.m_indirections; - } + uint m_constant: 1; + uint m_constexpr: 1; + uint m_volatile: 1; + uint m_mutable: 1; + uint m_reference: 1; + uint m_functionPointer: 1; + uint m_indirections: 6; + inline bool equals(TypeInfo_flags other) const + { + /* m_auto and m_friend don't matter here */ + return m_constant == other.m_constant && m_constexpr == other.m_constexpr && m_volatile == other.m_volatile + && m_mutable == other.m_mutable && m_reference == other.m_reference + && m_functionPointer == other.m_functionPointer && m_indirections == other.m_indirections; + } } m_flags {0, 0, 0, 0, 0, 0, 0}; QStringList m_qualifiedName; QStringList m_arrayElements; QList m_arguments; - bool m_rvalue_reference { false }; + bool m_rvalue_reference {false}; }; class _CodeModelItem { public: - enum Kind - { + enum Kind { /* These are bit-flags resembling inheritance */ Kind_Scope = 0x1, Kind_Namespace = 0x2 | Kind_Scope, @@ -218,35 +197,35 @@ class _CodeModelItem QStringList qualifiedName() const; QString name() const; - void setName(const QString &name); + void setName(const QString& name); QStringList scope() const; - void setScope(const QStringList &scope); + void setScope(const QStringList& scope); QString fileName() const; - void setFileName(const QString &fileName); + void setFileName(const QString& fileName); FileModelItem file() const; - void getStartPosition(int *line, int *column) const; + void getStartPosition(int* line, int* column) const; void setStartPosition(int line, int column); - void getEndPosition(int *line, int *column) const; + void getEndPosition(int* line, int* column) const; void setEndPosition(int line, int column); inline std::size_t creationId() const { return _M_creation_id; } inline void setCreationId(std::size_t creation_id) { _M_creation_id = creation_id; } - inline CodeModel *model() const { return _M_model; } + inline CodeModel* model() const { return _M_model; } CodeModelItem toItem() const; protected: - _CodeModelItem(CodeModel *model, int kind); + _CodeModelItem(CodeModel* model, int kind); void setKind(int kind); private: - CodeModel *_M_model; + CodeModel* _M_model; int _M_kind; int _M_startLine; int _M_startColumn; @@ -258,16 +237,16 @@ class _CodeModelItem QStringList _M_scope; private: - _CodeModelItem(const _CodeModelItem &other); - void operator = (const _CodeModelItem &other); + _CodeModelItem(const _CodeModelItem& other); + void operator=(const _CodeModelItem& other); }; -class _ScopeModelItem: public _CodeModelItem +class _ScopeModelItem : public _CodeModelItem { public: DECLARE_MODEL_NODE(Scope) - static ScopeModelItem create(CodeModel *model); + static ScopeModelItem create(CodeModel* model); public: ClassList classes() const; @@ -291,28 +270,33 @@ class _ScopeModelItem: public _CodeModelItem void removeTypeAlias(TypeAliasModelItem item); void removeVariable(VariableModelItem item); - ClassModelItem findClass(const QString &name) const; - EnumModelItem findEnum(const QString &name) const; - FunctionDefinitionList findFunctionDefinitions(const QString &name) const; - FunctionList findFunctions(const QString &name) const; - TypeAliasModelItem findTypeAlias(const QString &name) const; - VariableModelItem findVariable(const QString &name) const; + ClassModelItem findClass(const QString& name) const; + EnumModelItem findEnum(const QString& name) const; + FunctionDefinitionList findFunctionDefinitions(const QString& name) const; + FunctionList findFunctions(const QString& name) const; + TypeAliasModelItem findTypeAlias(const QString& name) const; + VariableModelItem findVariable(const QString& name) const; - void addQEnumDeclaration(const QString &qEnumDeclaration); + void addQEnumDeclaration(const QString& qEnumDeclaration); QSet qEnumDeclarations() const { return _M_qEnumDeclarations; } inline QHash classMap() const { return _M_classes; } inline QHash enumMap() const { return _M_enums; } inline QHash typeAliasMap() const { return _M_typeAliases; } inline QHash variableMap() const { return _M_variables; } - inline QMultiHash functionDefinitionMap() const { return _M_functionDefinitions; } + inline QMultiHash functionDefinitionMap() const + { + return _M_functionDefinitions; + } inline QMultiHash functionMap() const { return _M_functions; } FunctionModelItem declaredFunction(FunctionModelItem item); protected: - _ScopeModelItem(CodeModel *model, int kind = __node_kind) - : _CodeModelItem(model, kind) {} + _ScopeModelItem(CodeModel* model, int kind = __node_kind) + : _CodeModelItem(model, kind) + { + } private: QHash _M_classes; @@ -323,45 +307,47 @@ class _ScopeModelItem: public _CodeModelItem QMultiHash _M_functions; private: - _ScopeModelItem(const _ScopeModelItem &other); - void operator = (const _ScopeModelItem &other); + _ScopeModelItem(const _ScopeModelItem& other); + void operator=(const _ScopeModelItem& other); QSet _M_qEnumDeclarations; }; -class _ClassModelItem: public _ScopeModelItem +class _ClassModelItem : public _ScopeModelItem { public: DECLARE_MODEL_NODE(Class) - static ClassModelItem create(CodeModel *model); + static ClassModelItem create(CodeModel* model); public: QStringList baseClasses() const; - void setBaseClasses(const QStringList &baseClasses); - void addBaseClass(const QString &baseClass); - void removeBaseClass(const QString &baseClass); + void setBaseClasses(const QStringList& baseClasses); + void addBaseClass(const QString& baseClass); + void removeBaseClass(const QString& baseClass); TemplateParameterList templateParameters() const; - void setTemplateParameters(const TemplateParameterList &templateParameters); + void setTemplateParameters(const TemplateParameterList& templateParameters); bool isTemplateClass() const { return _M_templateParameters.size(); } - bool extendsClass(const QString &name) const; + bool extendsClass(const QString& name) const; void setClassType(CodeModel::ClassType type); CodeModel::ClassType classType() const; - void addPropertyDeclaration(const QString &propertyDeclaration); + void addPropertyDeclaration(const QString& propertyDeclaration); QStringList propertyDeclarations() const { return _M_propertyDeclarations; } void setHasActualDeclaration(bool flag) { _M_hasActualDeclaration = flag; } bool hasActualDeclaration() const { return _M_hasActualDeclaration; } - protected: - _ClassModelItem(CodeModel *model, int kind = __node_kind) - : _ScopeModelItem(model, kind), _M_classType(CodeModel::Class) {} + _ClassModelItem(CodeModel* model, int kind = __node_kind) + : _ScopeModelItem(model, kind) + , _M_classType(CodeModel::Class) + { + } private: QStringList _M_baseClasses; @@ -370,19 +356,19 @@ class _ClassModelItem: public _ScopeModelItem QStringList _M_propertyDeclarations; - bool _M_hasActualDeclaration{}; + bool _M_hasActualDeclaration {}; private: - _ClassModelItem(const _ClassModelItem &other); - void operator = (const _ClassModelItem &other); + _ClassModelItem(const _ClassModelItem& other); + void operator=(const _ClassModelItem& other); }; -class _NamespaceModelItem: public _ScopeModelItem +class _NamespaceModelItem : public _ScopeModelItem { public: DECLARE_MODEL_NODE(Namespace) - static NamespaceModelItem create(CodeModel *model); + static NamespaceModelItem create(CodeModel* model); public: NamespaceList namespaces() const; @@ -390,58 +376,65 @@ class _NamespaceModelItem: public _ScopeModelItem void addNamespace(NamespaceModelItem item); void removeNamespace(NamespaceModelItem item); - NamespaceModelItem findNamespace(const QString &name) const; + NamespaceModelItem findNamespace(const QString& name) const; inline QHash namespaceMap() const { return _M_namespaces; } protected: - _NamespaceModelItem(CodeModel *model, int kind = __node_kind) - : _ScopeModelItem(model, kind) {} + _NamespaceModelItem(CodeModel* model, int kind = __node_kind) + : _ScopeModelItem(model, kind) + { + } private: QHash _M_namespaces; private: - _NamespaceModelItem(const _NamespaceModelItem &other); - void operator = (const _NamespaceModelItem &other); + _NamespaceModelItem(const _NamespaceModelItem& other); + void operator=(const _NamespaceModelItem& other); }; -class _FileModelItem: public _NamespaceModelItem +class _FileModelItem : public _NamespaceModelItem { public: DECLARE_MODEL_NODE(File) - static FileModelItem create(CodeModel *model); + static FileModelItem create(CodeModel* model); protected: - _FileModelItem(CodeModel *model, int kind = __node_kind) - : _NamespaceModelItem(model, kind) {} + _FileModelItem(CodeModel* model, int kind = __node_kind) + : _NamespaceModelItem(model, kind) + { + } private: - _FileModelItem(const _FileModelItem &other); - void operator = (const _FileModelItem &other); + _FileModelItem(const _FileModelItem& other); + void operator=(const _FileModelItem& other); }; -class _ArgumentModelItem: public _CodeModelItem +class _ArgumentModelItem : public _CodeModelItem { public: DECLARE_MODEL_NODE(Argument) - static ArgumentModelItem create(CodeModel *model); + static ArgumentModelItem create(CodeModel* model); public: TypeInfo type() const; - void setType(const TypeInfo &type); + void setType(const TypeInfo& type); bool defaultValue() const; void setDefaultValue(bool defaultValue); QString defaultValueExpression() const { return _M_defaultValueExpression; } - void setDefaultValueExpression(const QString &expr) { _M_defaultValueExpression = expr; } + void setDefaultValueExpression(const QString& expr) { _M_defaultValueExpression = expr; } protected: - _ArgumentModelItem(CodeModel *model, int kind = __node_kind) - : _CodeModelItem(model, kind), _M_defaultValue(false) {} + _ArgumentModelItem(CodeModel* model, int kind = __node_kind) + : _CodeModelItem(model, kind) + , _M_defaultValue(false) + { + } private: TypeInfo _M_type; @@ -449,11 +442,11 @@ class _ArgumentModelItem: public _CodeModelItem bool _M_defaultValue; private: - _ArgumentModelItem(const _ArgumentModelItem &other); - void operator = (const _ArgumentModelItem &other); + _ArgumentModelItem(const _ArgumentModelItem& other); + void operator=(const _ArgumentModelItem& other); }; -class _MemberModelItem: public _CodeModelItem +class _MemberModelItem : public _CodeModelItem { public: DECLARE_MODEL_NODE(Member) @@ -488,30 +481,30 @@ class _MemberModelItem: public _CodeModelItem CodeModel::AccessPolicy accessPolicy() const; void setAccessPolicy(CodeModel::AccessPolicy accessPolicy); - TemplateParameterList templateParameters() const - { return _M_templateParameters; } + TemplateParameterList templateParameters() const { return _M_templateParameters; } - void setTemplateParameters(const TemplateParameterList &templateParameters) - { _M_templateParameters = templateParameters; } + void setTemplateParameters(const TemplateParameterList& templateParameters) + { + _M_templateParameters = templateParameters; + } TypeInfo type() const; - void setType(const TypeInfo &type); + void setType(const TypeInfo& type); protected: - _MemberModelItem(CodeModel *model, int kind) - : _CodeModelItem(model, kind), - _M_accessPolicy(CodeModel::Public), - _M_flags(0) - {} + _MemberModelItem(CodeModel* model, int kind) + : _CodeModelItem(model, kind) + , _M_accessPolicy(CodeModel::Public) + , _M_flags(0) + { + } private: TemplateParameterList _M_templateParameters; TypeInfo _M_type; CodeModel::AccessPolicy _M_accessPolicy; - union - { - struct - { + union { + struct { uint isConstant: 1; uint isConstexpr: 1; uint isVolatile: 1; @@ -524,15 +517,14 @@ class _MemberModelItem: public _CodeModelItem } _M; uint _M_flags; }; - }; -class _FunctionModelItem: public _MemberModelItem +class _FunctionModelItem : public _MemberModelItem { public: DECLARE_MODEL_NODE(Function) - static FunctionModelItem create(CodeModel *model); + static FunctionModelItem create(CodeModel* model); public: ArgumentList arguments() const; @@ -544,7 +536,7 @@ class _FunctionModelItem: public _MemberModelItem void setFunctionType(CodeModel::FunctionType functionType); QString exception() const; - void setException(const QString &exception); + void setException(const QString& exception); bool isVirtual() const; void setVirtual(bool isVirtual); @@ -555,7 +547,7 @@ class _FunctionModelItem: public _MemberModelItem bool isExplicit() const; void setExplicit(bool isExplicit); - bool isInvokable() const; // Qt + bool isInvokable() const; // Qt void setInvokable(bool isInvokable); // Qt bool isAbstract() const; @@ -570,98 +562,102 @@ class _FunctionModelItem: public _MemberModelItem bool isSimilar(FunctionModelItem other) const; protected: - _FunctionModelItem(CodeModel *model, int kind = __node_kind) - : _MemberModelItem(model, kind), - _M_functionType(CodeModel::Normal), - _M_flags(0) - {} + _FunctionModelItem(CodeModel* model, int kind = __node_kind) + : _MemberModelItem(model, kind) + , _M_functionType(CodeModel::Normal) + , _M_flags(0) + { + } private: ArgumentList _M_arguments; CodeModel::FunctionType _M_functionType; QString _M_exception; - union - { - struct - { + union { + struct { uint isVirtual: 1; uint isInline: 1; uint isAbstract: 1; uint isDeleted: 1; uint isExplicit: 1; uint isVariadics: 1; - uint isInvokable : 1; // Qt + uint isInvokable: 1; // Qt } _M; uint _M_flags; }; private: - _FunctionModelItem(const _FunctionModelItem &other); - void operator = (const _FunctionModelItem &other); + _FunctionModelItem(const _FunctionModelItem& other); + void operator=(const _FunctionModelItem& other); }; -class _FunctionDefinitionModelItem: public _FunctionModelItem +class _FunctionDefinitionModelItem : public _FunctionModelItem { public: DECLARE_MODEL_NODE(FunctionDefinition) - static FunctionDefinitionModelItem create(CodeModel *model); + static FunctionDefinitionModelItem create(CodeModel* model); protected: - _FunctionDefinitionModelItem(CodeModel *model, int kind = __node_kind) - : _FunctionModelItem(model, kind) {} + _FunctionDefinitionModelItem(CodeModel* model, int kind = __node_kind) + : _FunctionModelItem(model, kind) + { + } private: - _FunctionDefinitionModelItem(const _FunctionDefinitionModelItem &other); - void operator = (const _FunctionDefinitionModelItem &other); + _FunctionDefinitionModelItem(const _FunctionDefinitionModelItem& other); + void operator=(const _FunctionDefinitionModelItem& other); }; -class _VariableModelItem: public _MemberModelItem +class _VariableModelItem : public _MemberModelItem { public: DECLARE_MODEL_NODE(Variable) - static VariableModelItem create(CodeModel *model); + static VariableModelItem create(CodeModel* model); protected: - _VariableModelItem(CodeModel *model, int kind = __node_kind) + _VariableModelItem(CodeModel* model, int kind = __node_kind) : _MemberModelItem(model, kind) - {} + { + } private: - _VariableModelItem(const _VariableModelItem &other); - void operator = (const _VariableModelItem &other); + _VariableModelItem(const _VariableModelItem& other); + void operator=(const _VariableModelItem& other); }; -class _TypeAliasModelItem: public _CodeModelItem +class _TypeAliasModelItem : public _CodeModelItem { public: DECLARE_MODEL_NODE(TypeAlias) - static TypeAliasModelItem create(CodeModel *model); + static TypeAliasModelItem create(CodeModel* model); public: TypeInfo type() const; - void setType(const TypeInfo &type); + void setType(const TypeInfo& type); protected: - _TypeAliasModelItem(CodeModel *model, int kind = __node_kind) - : _CodeModelItem(model, kind) {} + _TypeAliasModelItem(CodeModel* model, int kind = __node_kind) + : _CodeModelItem(model, kind) + { + } private: TypeInfo _M_type; private: - _TypeAliasModelItem(const _TypeAliasModelItem &other); - void operator = (const _TypeAliasModelItem &other); + _TypeAliasModelItem(const _TypeAliasModelItem& other); + void operator=(const _TypeAliasModelItem& other); }; -class _EnumModelItem: public _CodeModelItem +class _EnumModelItem : public _CodeModelItem { public: DECLARE_MODEL_NODE(Enum) - static EnumModelItem create(CodeModel *model); + static EnumModelItem create(CodeModel* model); public: CodeModel::AccessPolicy accessPolicy() const; @@ -675,69 +671,75 @@ class _EnumModelItem: public _CodeModelItem void removeEnumerator(EnumeratorModelItem item); protected: - _EnumModelItem(CodeModel *model, int kind = __node_kind) - : _CodeModelItem(model, kind), - _M_accessPolicy(CodeModel::Public) - {} + _EnumModelItem(CodeModel* model, int kind = __node_kind) + : _CodeModelItem(model, kind) + , _M_accessPolicy(CodeModel::Public) + { + } private: CodeModel::AccessPolicy _M_accessPolicy; EnumeratorList _M_enumerators; - bool _M_isEnumClass{}; + bool _M_isEnumClass {}; private: - _EnumModelItem(const _EnumModelItem &other); - void operator = (const _EnumModelItem &other); + _EnumModelItem(const _EnumModelItem& other); + void operator=(const _EnumModelItem& other); }; -class _EnumeratorModelItem: public _CodeModelItem +class _EnumeratorModelItem : public _CodeModelItem { public: DECLARE_MODEL_NODE(Enumerator) - static EnumeratorModelItem create(CodeModel *model); + static EnumeratorModelItem create(CodeModel* model); public: QString value() const; - void setValue(const QString &value); + void setValue(const QString& value); protected: - _EnumeratorModelItem(CodeModel *model, int kind = __node_kind) - : _CodeModelItem(model, kind) {} + _EnumeratorModelItem(CodeModel* model, int kind = __node_kind) + : _CodeModelItem(model, kind) + { + } private: QString _M_value; private: - _EnumeratorModelItem(const _EnumeratorModelItem &other); - void operator = (const _EnumeratorModelItem &other); + _EnumeratorModelItem(const _EnumeratorModelItem& other); + void operator=(const _EnumeratorModelItem& other); }; -class _TemplateParameterModelItem: public _CodeModelItem +class _TemplateParameterModelItem : public _CodeModelItem { public: DECLARE_MODEL_NODE(TemplateParameter) - static TemplateParameterModelItem create(CodeModel *model); + static TemplateParameterModelItem create(CodeModel* model); public: TypeInfo type() const; - void setType(const TypeInfo &type); + void setType(const TypeInfo& type); bool defaultValue() const; void setDefaultValue(bool defaultValue); protected: - _TemplateParameterModelItem(CodeModel *model, int kind = __node_kind) - : _CodeModelItem(model, kind), _M_defaultValue(false) {} + _TemplateParameterModelItem(CodeModel* model, int kind = __node_kind) + : _CodeModelItem(model, kind) + , _M_defaultValue(false) + { + } private: TypeInfo _M_type; bool _M_defaultValue; private: - _TemplateParameterModelItem(const _TemplateParameterModelItem &other); - void operator = (const _TemplateParameterModelItem &other); + _TemplateParameterModelItem(const _TemplateParameterModelItem& other); + void operator=(const _TemplateParameterModelItem& other); }; #endif // CODEMODEL_H diff --git a/generator/parser/codemodel_finder.cpp b/generator/parser/codemodel_finder.cpp index 6b26aef3e..ab7934af2 100644 --- a/generator/parser/codemodel_finder.cpp +++ b/generator/parser/codemodel_finder.cpp @@ -39,25 +39,22 @@ ** ****************************************************************************/ - #include "codemodel_finder.h" #include "codemodel.h" #include "binder.h" -CodeModelFinder::CodeModelFinder(CodeModel *model, Binder *binder) - : _M_model(model), - _M_binder (binder), - _M_token_stream(binder->tokenStream ()), - name_cc(_M_binder), - _M_resolve_policy(ResolveItem) +CodeModelFinder::CodeModelFinder(CodeModel* model, Binder* binder) + : _M_model(model) + , _M_binder(binder) + , _M_token_stream(binder->tokenStream()) + , name_cc(_M_binder) + , _M_resolve_policy(ResolveItem) { } -CodeModelFinder::~CodeModelFinder() -{ -} +CodeModelFinder::~CodeModelFinder() {} -ScopeModelItem CodeModelFinder::resolveScope(NameAST *name, ScopeModelItem scope) +ScopeModelItem CodeModelFinder::resolveScope(NameAST* name, ScopeModelItem scope) { Q_ASSERT(scope.data() != 0); @@ -83,7 +80,7 @@ ScopeModelItem CodeModelFinder::changeCurrentScope(ScopeModelItem scope) return old; } -void CodeModelFinder::visitName(NameAST *node) +void CodeModelFinder::visitName(NameAST* node) { visitNodes(this, node->qualified_names); @@ -91,32 +88,25 @@ void CodeModelFinder::visitName(NameAST *node) visit(node->unqualified_name); } -void CodeModelFinder::visitUnqualifiedName(UnqualifiedNameAST *node) +void CodeModelFinder::visitUnqualifiedName(UnqualifiedNameAST* node) { - if (!_M_current_scope) - { - // nothing to do - return; - } + if (!_M_current_scope) { + // nothing to do + return; + } name_cc.run(node); QString id = name_cc.name(); - if (ClassModelItem klass = _M_current_scope->findClass(id)) - { - _M_current_scope = klass; - } - else if (NamespaceModelItem parentNamespace = _M_current_scope.dynamicCast<_NamespaceModelItem>()) - { - NamespaceModelItem ns = parentNamespace->findNamespace(id); - _M_current_scope = ns.staticCast<_ScopeModelItem>(); - } - else if (FileModelItem file = _M_current_scope.dynamicCast<_FileModelItem>()) - { - NamespaceModelItem ns = file->findNamespace(id); - _M_current_scope = ns.staticCast<_ScopeModelItem>(); - } + if (ClassModelItem klass = _M_current_scope->findClass(id)) { + _M_current_scope = klass; + } else if (NamespaceModelItem parentNamespace = _M_current_scope.dynamicCast<_NamespaceModelItem>()) { + NamespaceModelItem ns = parentNamespace->findNamespace(id); + _M_current_scope = ns.staticCast<_ScopeModelItem>(); + } else if (FileModelItem file = _M_current_scope.dynamicCast<_FileModelItem>()) { + NamespaceModelItem ns = file->findNamespace(id); + _M_current_scope = ns.staticCast<_ScopeModelItem>(); } +} // kate: space-indent on; indent-width 2; replace-tabs on; - diff --git a/generator/parser/codemodel_finder.h b/generator/parser/codemodel_finder.h index 79af1f9bf..ccba226a6 100644 --- a/generator/parser/codemodel_finder.h +++ b/generator/parser/codemodel_finder.h @@ -39,43 +39,38 @@ ** ****************************************************************************/ - #ifndef CODEMODEL_FINDER_H -#define CODEMODEL_FINDER_H + #define CODEMODEL_FINDER_H -#include "default_visitor.h" -#include "codemodel_fwd.h" -#include "name_compiler.h" + #include "default_visitor.h" + #include "codemodel_fwd.h" + #include "name_compiler.h" class TokenStream; class Binder; -class CodeModelFinder: protected DefaultVisitor +class CodeModelFinder : protected DefaultVisitor { - enum ResolvePolicy - { - ResolveScope, - ResolveItem - }; + enum ResolvePolicy { ResolveScope, ResolveItem }; public: - CodeModelFinder(CodeModel *model, Binder *binder); + CodeModelFinder(CodeModel* model, Binder* binder); virtual ~CodeModelFinder(); - ScopeModelItem resolveScope(NameAST *name, ScopeModelItem scope); + ScopeModelItem resolveScope(NameAST* name, ScopeModelItem scope); - inline CodeModel *model() const { return _M_model; } + inline CodeModel* model() const { return _M_model; } protected: - virtual void visitName(NameAST *node); - virtual void visitUnqualifiedName(UnqualifiedNameAST *node); + virtual void visitName(NameAST* node); + virtual void visitUnqualifiedName(UnqualifiedNameAST* node); ScopeModelItem changeCurrentScope(ScopeModelItem scope); private: - CodeModel *_M_model; - Binder *_M_binder; - TokenStream *_M_token_stream; + CodeModel* _M_model; + Binder* _M_binder; + TokenStream* _M_token_stream; NameCompiler name_cc; ScopeModelItem _M_current_scope; diff --git a/generator/parser/codemodel_fwd.h b/generator/parser/codemodel_fwd.h index cdbcafbfe..76e2686ee 100644 --- a/generator/parser/codemodel_fwd.h +++ b/generator/parser/codemodel_fwd.h @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #ifndef CODEMODEL_FWD_H #define CODEMODEL_FWD_H diff --git a/generator/parser/compiler_utils.cpp b/generator/parser/compiler_utils.cpp index d924f26c6..a1d7fa802 100644 --- a/generator/parser/compiler_utils.cpp +++ b/generator/parser/compiler_utils.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include "compiler_utils.h" #include "type_compiler.h" #include "name_compiler.h" @@ -47,23 +46,23 @@ #include "ast.h" #include "binder.h" -TypeInfo CompilerUtils::typeDescription(TypeSpecifierAST *type_specifier, DeclaratorAST *declarator, Binder *binder) +TypeInfo CompilerUtils::typeDescription(TypeSpecifierAST* type_specifier, DeclaratorAST* declarator, Binder* binder) { - TypeCompiler type_cc (binder); - DeclaratorCompiler decl_cc (binder); + TypeCompiler type_cc(binder); + DeclaratorCompiler decl_cc(binder); - type_cc.run (type_specifier); - decl_cc.run (declarator); + type_cc.run(type_specifier); + decl_cc.run(declarator); TypeInfo typeInfo; - typeInfo.setQualifiedName (type_cc.qualifiedName ()); - typeInfo.setConstant (type_cc.isConstant ()); - typeInfo.setVolatile (type_cc.isVolatile ()); - typeInfo.setMutable (type_cc.isMutable ()); - typeInfo.setReference (decl_cc.isReference ()); - typeInfo.setRvalueReference (decl_cc.isRvalueReference ()); - typeInfo.setIndirections (decl_cc.indirection ()); - typeInfo.setArrayElements (decl_cc.arrayElements ()); + typeInfo.setQualifiedName(type_cc.qualifiedName()); + typeInfo.setConstant(type_cc.isConstant()); + typeInfo.setVolatile(type_cc.isVolatile()); + typeInfo.setMutable(type_cc.isMutable()); + typeInfo.setReference(decl_cc.isReference()); + typeInfo.setRvalueReference(decl_cc.isRvalueReference()); + typeInfo.setIndirections(decl_cc.indirection()); + typeInfo.setArrayElements(decl_cc.arrayElements()); return typeInfo; } diff --git a/generator/parser/compiler_utils.h b/generator/parser/compiler_utils.h index 01c6f9133..0c9460229 100644 --- a/generator/parser/compiler_utils.h +++ b/generator/parser/compiler_utils.h @@ -39,13 +39,12 @@ ** ****************************************************************************/ - #ifndef COMPILER_UTILS_H -#define COMPILER_UTILS_H + #define COMPILER_UTILS_H -#include + #include -#include "codemodel.h" + #include "codemodel.h" class QString; struct TypeSpecifierAST; @@ -53,10 +52,9 @@ struct DeclaratorAST; class TokenStream; class Binder; -namespace CompilerUtils -{ +namespace CompilerUtils { -TypeInfo typeDescription(TypeSpecifierAST *type_specifier, DeclaratorAST *declarator, Binder *binder); +TypeInfo typeDescription(TypeSpecifierAST* type_specifier, DeclaratorAST* declarator, Binder* binder); } // namespace CompilerUtils diff --git a/generator/parser/control.cpp b/generator/parser/control.cpp index f76cc4e66..9a53491c7 100644 --- a/generator/parser/control.cpp +++ b/generator/parser/control.cpp @@ -39,22 +39,20 @@ ** ****************************************************************************/ - #include "control.h" #include "lexer.h" bool Control::_M_printErrors = false; Control::Control() - : current_context(0), - _M_skipFunctionBody(false), - _M_lexer(0), - _M_parser(0) + : current_context(0) + , _M_skipFunctionBody(false) + , _M_lexer(0) + , _M_parser(0) { pushContext(); - declareTypedef(findOrInsertName("__builtin_va_list", - strlen("__builtin_va_list")), 0); + declareTypedef(findOrInsertName("__builtin_va_list", strlen("__builtin_va_list")), 0); } Control::~Control() @@ -64,28 +62,28 @@ Control::~Control() Q_ASSERT(current_context == 0); } -Lexer *Control::changeLexer(Lexer *lexer) +Lexer* Control::changeLexer(Lexer* lexer) { - Lexer *old = _M_lexer; + Lexer* old = _M_lexer; _M_lexer = lexer; return old; } -Parser *Control::changeParser(Parser *parser) +Parser* Control::changeParser(Parser* parser) { - Parser *old = _M_parser; + Parser* old = _M_parser; _M_parser = parser; return old; } -Type *Control::lookupType(const NameSymbol *name) const +Type* Control::lookupType(const NameSymbol* name) const { Q_ASSERT(current_context != 0); return current_context->resolve(name); } -void Control::declare(const NameSymbol *name, Type *type) +void Control::declare(const NameSymbol* name, Type* type) { //printf("*** Declare:"); //printSymbol(name); @@ -98,7 +96,7 @@ void Control::declare(const NameSymbol *name, Type *type) void Control::pushContext() { // printf("+Context\n"); - Context *new_context = new Context; + Context* new_context = new Context; new_context->parent = current_context; current_context = new_context; } @@ -108,13 +106,13 @@ void Control::popContext() // printf("-Context\n"); Q_ASSERT(current_context != 0); - Context *old_context = current_context; + Context* old_context = current_context; current_context = current_context->parent; delete old_context; } -void Control::declareTypedef(const NameSymbol *name, Declarator *d) +void Control::declareTypedef(const NameSymbol* name, Declarator* d) { // printf("declared typedef:"); // printSymbol(name); @@ -122,7 +120,7 @@ void Control::declareTypedef(const NameSymbol *name, Declarator *d) stl_typedef_table.insert(name, d); } -bool Control::isTypedef(const NameSymbol *name) const +bool Control::isTypedef(const NameSymbol* name) const { // printf("is typedef:"); // printSymbol(name); @@ -131,21 +129,22 @@ bool Control::isTypedef(const NameSymbol *name) const return stl_typedef_table.contains(name); } -QList Control::errorMessages () const +QList Control::errorMessages() const { return _M_error_messages; } -void Control::clearErrorMessages () +void Control::clearErrorMessages() { - _M_error_messages.clear (); + _M_error_messages.clear(); } -void Control::reportError (const ErrorMessage &errmsg) +void Control::reportError(const ErrorMessage& errmsg) { _M_error_messages.append(errmsg); if (_M_printErrors) { - printf("%s (%s:%d:%d)\n", qPrintable(errmsg.message()), qPrintable(errmsg.fileName()), errmsg.line(), errmsg.column()); + printf("%s (%s:%d:%d)\n", qPrintable(errmsg.message()), qPrintable(errmsg.fileName()), errmsg.line(), + errmsg.column()); } } diff --git a/generator/parser/control.h b/generator/parser/control.h index a52747488..64e834b6c 100644 --- a/generator/parser/control.h +++ b/generator/parser/control.h @@ -39,30 +39,27 @@ ** ****************************************************************************/ - #ifndef CONTROL_H -#define CONTROL_H + #define CONTROL_H -#include "symbol.h" -#include "smallobject.h" + #include "symbol.h" + #include "smallobject.h" -#include + #include struct Declarator; struct Type; class Lexer; class Parser; -struct Context -{ - Context *parent; +struct Context { + Context* parent; - inline void bind(const NameSymbol *name, Type *type) - { symbol_table.insert(name, type); } + inline void bind(const NameSymbol* name, Type* type) { symbol_table.insert(name, type); } - inline Type *resolve(const NameSymbol *name) const + inline Type* resolve(const NameSymbol* name) const { - if (Type *type = symbol_table.value(name)) + if (Type* type = symbol_table.value(name)) return type; else if (parent) return parent->resolve(name); @@ -81,21 +78,23 @@ class Control class ErrorMessage { public: - ErrorMessage (): - _M_line (0), - _M_column (0) {} + ErrorMessage() + : _M_line(0) + , _M_column(0) + { + } - inline int line () const { return _M_line; } - inline void setLine (int line) { _M_line = line; } + inline int line() const { return _M_line; } + inline void setLine(int line) { _M_line = line; } - inline int column () const { return _M_column; } - inline void setColumn (int column) { _M_column = column; } + inline int column() const { return _M_column; } + inline void setColumn(int column) { _M_column = column; } - inline QString fileName () const { return _M_fileName; } - inline void setFileName (const QString &fileName) { _M_fileName = fileName; } + inline QString fileName() const { return _M_fileName; } + inline void setFileName(const QString& fileName) { _M_fileName = fileName; } - inline QString message () const { return _M_message; } - inline void setMessage (const QString &message) { _M_message = message; } + inline QString message() const { return _M_message; } + inline void setMessage(const QString& message) { _M_message = message; } private: int _M_line; @@ -110,43 +109,44 @@ class Control inline bool skipFunctionBody() const { return _M_skipFunctionBody; } inline void setSkipFunctionBody(bool skip) { _M_skipFunctionBody = skip; } - Lexer *changeLexer(Lexer *lexer); - Parser *changeParser(Parser *parser); + Lexer* changeLexer(Lexer* lexer); + Parser* changeParser(Parser* parser); - Lexer *currentLexer() const { return _M_lexer; } - Parser *currentParser() const { return _M_parser; } + Lexer* currentLexer() const { return _M_lexer; } + Parser* currentParser() const { return _M_parser; } - Context *current_context; + Context* current_context; - inline Context *currentContext() const - { return current_context; } + inline Context* currentContext() const { return current_context; } void pushContext(); void popContext(); - Type *lookupType(const NameSymbol *name) const; - void declare(const NameSymbol *name, Type *type); + Type* lookupType(const NameSymbol* name) const; + void declare(const NameSymbol* name, Type* type); - inline const NameSymbol *findOrInsertName(const char *data, size_t count) - { return name_table.findOrInsert(data, count); } + inline const NameSymbol* findOrInsertName(const char* data, size_t count) + { + return name_table.findOrInsert(data, count); + } - void declareTypedef(const NameSymbol *name, Declarator *d); - bool isTypedef(const NameSymbol *name) const; + void declareTypedef(const NameSymbol* name, Declarator* d); + bool isTypedef(const NameSymbol* name) const; static bool printErrors() { return _M_printErrors; } static void setPrintErrors(bool on) { _M_printErrors = on; } - void reportError (const ErrorMessage &errmsg); - QList errorMessages () const; - void clearErrorMessages (); + void reportError(const ErrorMessage& errmsg); + QList errorMessages() const; + void clearErrorMessages(); private: NameTable name_table; QHash stl_typedef_table; bool _M_skipFunctionBody; static bool _M_printErrors; - Lexer *_M_lexer; - Parser *_M_parser; + Lexer* _M_lexer; + Parser* _M_parser; QList _M_error_messages; }; diff --git a/generator/parser/declarator_compiler.cpp b/generator/parser/declarator_compiler.cpp index 4aaafeefc..5f2e3c3ea 100644 --- a/generator/parser/declarator_compiler.cpp +++ b/generator/parser/declarator_compiler.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include "declarator_compiler.h" #include "name_compiler.h" #include "type_compiler.h" @@ -50,12 +49,13 @@ #include -DeclaratorCompiler::DeclaratorCompiler(Binder *binder) - : _M_binder (binder), _M_token_stream (binder->tokenStream ()) +DeclaratorCompiler::DeclaratorCompiler(Binder* binder) + : _M_binder(binder) + , _M_token_stream(binder->tokenStream()) { } -void DeclaratorCompiler::run(DeclaratorAST *node) +void DeclaratorCompiler::run(DeclaratorAST* node) { _M_id.clear(); _M_parameters.clear(); @@ -67,82 +67,76 @@ void DeclaratorCompiler::run(DeclaratorAST *node) _M_packed_parameter = false; _M_indirection = 0; - if (node) - { - NameCompiler name_cc(_M_binder); + if (node) { + NameCompiler name_cc(_M_binder); - DeclaratorAST *decl = node; - while (decl && decl->sub_declarator) - decl = decl->sub_declarator; + DeclaratorAST* decl = node; + while (decl && decl->sub_declarator) + decl = decl->sub_declarator; - Q_ASSERT (decl != 0); + Q_ASSERT(decl != 0); - name_cc.run(decl->id); - _M_id = name_cc.name(); - _M_function = (node->parameter_declaration_clause != 0); - if (node->parameter_declaration_clause && node->parameter_declaration_clause->ellipsis) - _M_variadics = true; - _M_packed_parameter = node->packedParameter; + name_cc.run(decl->id); + _M_id = name_cc.name(); + _M_function = (node->parameter_declaration_clause != 0); + if (node->parameter_declaration_clause && node->parameter_declaration_clause->ellipsis) + _M_variadics = true; + _M_packed_parameter = node->packedParameter; - visitNodes(this, node->ptr_ops); - visit(node->parameter_declaration_clause); + visitNodes(this, node->ptr_ops); + visit(node->parameter_declaration_clause); - if (const ListNode *it = node->array_dimensions) - { - it->toFront(); - const ListNode *end = it; + if (const ListNode* it = node->array_dimensions) { + it->toFront(); + const ListNode* end = it; - do - { - QString elt; - if (ExpressionAST *expr = it->element) - { - const Token &start_token = _M_token_stream->token((int) expr->start_token); - const Token &end_token = _M_token_stream->token((int) expr->end_token); + do { + QString elt; + if (ExpressionAST* expr = it->element) { + const Token& start_token = _M_token_stream->token((int)expr->start_token); + const Token& end_token = _M_token_stream->token((int)expr->end_token); - elt += QString::fromUtf8(&start_token.text[start_token.position], - (int) (end_token.position - start_token.position)).trimmed(); - } + elt += + QString::fromUtf8(&start_token.text[start_token.position], (int)(end_token.position - start_token.position)) + .trimmed(); + } - _M_array.append (elt); + _M_array.append(elt); - it = it->next; - } - while (it != end); - } + it = it->next; + } while (it != end); } + } } -void DeclaratorCompiler::visitPtrOperator(PtrOperatorAST *node) +void DeclaratorCompiler::visitPtrOperator(PtrOperatorAST* node) { - std::size_t op = _M_token_stream->kind(node->op); - - switch (op) - { - case Token_and: - _M_rvalue_reference = true; - _M_reference = false; - break; - case '&': - _M_reference = true; - break; - case '*': - ++_M_indirection; - break; - - default: - break; - } + std::size_t op = _M_token_stream->kind(node->op); + + switch (op) { + case Token_and: + _M_rvalue_reference = true; + _M_reference = false; + break; + case '&': + _M_reference = true; + break; + case '*': + ++_M_indirection; + break; + + default: + break; + } - if (node->mem_ptr) - { + if (node->mem_ptr) { #if defined(__GNUC__) -#pragma GCC warning "ptr to mem -- not implemented" + #pragma GCC warning "ptr to mem -- not implemented" #endif - } + } } -void DeclaratorCompiler::visitParameterDeclaration(ParameterDeclarationAST *node) +void DeclaratorCompiler::visitParameterDeclaration(ParameterDeclarationAST* node) { Parameter p; @@ -156,31 +150,27 @@ void DeclaratorCompiler::visitParameterDeclaration(ParameterDeclarationAST *node p.packedParameter = decl_cc.isPackedParameter(); // ignore case a single void parameter - if (_M_parameters.isEmpty() && p.name.isEmpty() && p.type.toString() == "void") - { + if (_M_parameters.isEmpty() && p.name.isEmpty() && p.type.toString() == "void") { return; } - if (node->expression != 0) - { - const Token &start = _M_token_stream->token((int) node->expression->start_token); - const Token &end = _M_token_stream->token((int) node->expression->end_token); - int length = (int) (end.position - start.position); - - p.defaultValueExpression = QString(); - QString source = QString::fromUtf8(&start.text[start.position], length).trimmed(); - QStringList list = source.split("\n"); - + if (node->expression != 0) { + const Token& start = _M_token_stream->token((int)node->expression->start_token); + const Token& end = _M_token_stream->token((int)node->expression->end_token); + int length = (int)(end.position - start.position); - for (int i=0; i 0; + p.defaultValueExpression = QString(); + QString source = QString::fromUtf8(&start.text[start.position], length).trimmed(); + QStringList list = source.split("\n"); + for (int i = 0; i < list.size(); ++i) { + if (!list.at(i).startsWith("#")) + p.defaultValueExpression += list.at(i).trimmed(); } + p.defaultValue = p.defaultValueExpression.size() > 0; + } + _M_parameters.append(p); } diff --git a/generator/parser/declarator_compiler.h b/generator/parser/declarator_compiler.h index 6337e1aee..92379cb52 100644 --- a/generator/parser/declarator_compiler.h +++ b/generator/parser/declarator_compiler.h @@ -39,37 +39,35 @@ ** ****************************************************************************/ - #ifndef DECLARATOR_COMPILER_H -#define DECLARATOR_COMPILER_H + #define DECLARATOR_COMPILER_H -#include "default_visitor.h" -#include "codemodel.h" + #include "default_visitor.h" + #include "codemodel.h" -#include -#include + #include + #include class TokenStream; class Binder; -class DeclaratorCompiler: protected DefaultVisitor +class DeclaratorCompiler : protected DefaultVisitor { public: - struct Parameter - { + struct Parameter { TypeInfo type; QString name; QString defaultValueExpression; - bool defaultValue{}; - bool packedParameter{}; + bool defaultValue {}; + bool packedParameter {}; Parameter() {} }; public: - DeclaratorCompiler(Binder *binder); + DeclaratorCompiler(Binder* binder); - void run(DeclaratorAST *node); + void run(DeclaratorAST* node); inline QString id() const { return _M_id; } inline QStringList arrayElements() const { return _M_array; } @@ -82,12 +80,12 @@ class DeclaratorCompiler: protected DefaultVisitor inline QList parameters() const { return _M_parameters; } protected: - virtual void visitPtrOperator(PtrOperatorAST *node); - virtual void visitParameterDeclaration(ParameterDeclarationAST *node); + virtual void visitPtrOperator(PtrOperatorAST* node); + virtual void visitParameterDeclaration(ParameterDeclarationAST* node); private: - Binder *_M_binder; - TokenStream *_M_token_stream; + Binder* _M_binder; + TokenStream* _M_token_stream; bool _M_function; bool _M_reference; diff --git a/generator/parser/default_visitor.cpp b/generator/parser/default_visitor.cpp index 1932fdc71..cdd3b1525 100644 --- a/generator/parser/default_visitor.cpp +++ b/generator/parser/default_visitor.cpp @@ -39,47 +39,46 @@ ** ****************************************************************************/ - #include "default_visitor.h" -void DefaultVisitor::visitAccessSpecifier(AccessSpecifierAST *) +void DefaultVisitor::visitAccessSpecifier(AccessSpecifierAST*) { // nothing to do } -void DefaultVisitor::visitAsmDefinition(AsmDefinitionAST *) +void DefaultVisitor::visitAsmDefinition(AsmDefinitionAST*) { // nothing to do } -void DefaultVisitor::visitBaseClause(BaseClauseAST *node) +void DefaultVisitor::visitBaseClause(BaseClauseAST* node) { visitNodes(this, node->base_specifiers); } -void DefaultVisitor::visitBaseSpecifier(BaseSpecifierAST *node) +void DefaultVisitor::visitBaseSpecifier(BaseSpecifierAST* node) { visit(node->name); } -void DefaultVisitor::visitBinaryExpression(BinaryExpressionAST *node) +void DefaultVisitor::visitBinaryExpression(BinaryExpressionAST* node) { visit(node->left_expression); visit(node->right_expression); } -void DefaultVisitor::visitCastExpression(CastExpressionAST *node) +void DefaultVisitor::visitCastExpression(CastExpressionAST* node) { visit(node->type_id); visit(node->expression); } -void DefaultVisitor::visitClassMemberAccess(ClassMemberAccessAST *node) +void DefaultVisitor::visitClassMemberAccess(ClassMemberAccessAST* node) { visit(node->name); } -void DefaultVisitor::visitClassSpecifier(ClassSpecifierAST *node) +void DefaultVisitor::visitClassSpecifier(ClassSpecifierAST* node) { visit(node->win_decl_specifiers); visit(node->name); @@ -87,43 +86,43 @@ void DefaultVisitor::visitClassSpecifier(ClassSpecifierAST *node) visitNodes(this, node->member_specs); } -void DefaultVisitor::visitCompoundStatement(CompoundStatementAST *node) +void DefaultVisitor::visitCompoundStatement(CompoundStatementAST* node) { visitNodes(this, node->statements); } -void DefaultVisitor::visitCondition(ConditionAST *node) +void DefaultVisitor::visitCondition(ConditionAST* node) { visit(node->type_specifier); visit(node->declarator); visit(node->expression); } -void DefaultVisitor::visitConditionalExpression(ConditionalExpressionAST *node) +void DefaultVisitor::visitConditionalExpression(ConditionalExpressionAST* node) { visit(node->condition); visit(node->left_expression); visit(node->right_expression); } -void DefaultVisitor::visitCppCastExpression(CppCastExpressionAST *node) +void DefaultVisitor::visitCppCastExpression(CppCastExpressionAST* node) { visit(node->type_id); visit(node->expression); visitNodes(this, node->sub_expressions); } -void DefaultVisitor::visitCtorInitializer(CtorInitializerAST *node) +void DefaultVisitor::visitCtorInitializer(CtorInitializerAST* node) { visitNodes(this, node->member_initializers); } -void DefaultVisitor::visitDeclarationStatement(DeclarationStatementAST *node) +void DefaultVisitor::visitDeclarationStatement(DeclarationStatementAST* node) { visit(node->declaration); } -void DefaultVisitor::visitDeclarator(DeclaratorAST *node) +void DefaultVisitor::visitDeclarator(DeclaratorAST* node) { visit(node->sub_declarator); visitNodes(this, node->ptr_ops); @@ -134,50 +133,50 @@ void DefaultVisitor::visitDeclarator(DeclaratorAST *node) visit(node->exception_spec); } -void DefaultVisitor::visitDeleteExpression(DeleteExpressionAST *node) +void DefaultVisitor::visitDeleteExpression(DeleteExpressionAST* node) { visit(node->expression); } -void DefaultVisitor::visitDoStatement(DoStatementAST *node) +void DefaultVisitor::visitDoStatement(DoStatementAST* node) { visit(node->statement); visit(node->expression); } -void DefaultVisitor::visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *node) +void DefaultVisitor::visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST* node) { visit(node->name); } -void DefaultVisitor::visitEnumSpecifier(EnumSpecifierAST *node) +void DefaultVisitor::visitEnumSpecifier(EnumSpecifierAST* node) { visit(node->name); visitNodes(this, node->enumerators); } -void DefaultVisitor::visitEnumerator(EnumeratorAST *node) +void DefaultVisitor::visitEnumerator(EnumeratorAST* node) { visit(node->expression); } -void DefaultVisitor::visitExceptionSpecification(ExceptionSpecificationAST *node) +void DefaultVisitor::visitExceptionSpecification(ExceptionSpecificationAST* node) { visitNodes(this, node->type_ids); } -void DefaultVisitor::visitExpressionOrDeclarationStatement(ExpressionOrDeclarationStatementAST *node) +void DefaultVisitor::visitExpressionOrDeclarationStatement(ExpressionOrDeclarationStatementAST* node) { visit(node->expression); visit(node->declaration); } -void DefaultVisitor::visitExpressionStatement(ExpressionStatementAST *node) +void DefaultVisitor::visitExpressionStatement(ExpressionStatementAST* node) { visit(node->expression); } -void DefaultVisitor::visitForStatement(ForStatementAST *node) +void DefaultVisitor::visitForStatement(ForStatementAST* node) { visit(node->init_statement); visit(node->condition); @@ -185,12 +184,12 @@ void DefaultVisitor::visitForStatement(ForStatementAST *node) visit(node->statement); } -void DefaultVisitor::visitFunctionCall(FunctionCallAST *node) +void DefaultVisitor::visitFunctionCall(FunctionCallAST* node) { visit(node->arguments); } -void DefaultVisitor::visitFunctionDefinition(FunctionDefinitionAST *node) +void DefaultVisitor::visitFunctionDefinition(FunctionDefinitionAST* node) { visit(node->type_specifier); visit(node->init_declarator); @@ -198,81 +197,81 @@ void DefaultVisitor::visitFunctionDefinition(FunctionDefinitionAST *node) visit(node->win_decl_specifiers); } -void DefaultVisitor::visitIfStatement(IfStatementAST *node) +void DefaultVisitor::visitIfStatement(IfStatementAST* node) { visit(node->condition); visit(node->statement); visit(node->else_statement); } -void DefaultVisitor::visitIncrDecrExpression(IncrDecrExpressionAST *) +void DefaultVisitor::visitIncrDecrExpression(IncrDecrExpressionAST*) { // nothing to do } -void DefaultVisitor::visitInitDeclarator(InitDeclaratorAST *node) +void DefaultVisitor::visitInitDeclarator(InitDeclaratorAST* node) { visit(node->declarator); visit(node->initializer); } -void DefaultVisitor::visitInitializer(InitializerAST *node) +void DefaultVisitor::visitInitializer(InitializerAST* node) { visit(node->initializer_clause); visit(node->expression); } -void DefaultVisitor::visitInitializerClause(InitializerClauseAST *node) +void DefaultVisitor::visitInitializerClause(InitializerClauseAST* node) { visit(node->expression); } -void DefaultVisitor::visitLabeledStatement(LabeledStatementAST *) +void DefaultVisitor::visitLabeledStatement(LabeledStatementAST*) { // nothing to do } -void DefaultVisitor::visitLinkageBody(LinkageBodyAST *node) +void DefaultVisitor::visitLinkageBody(LinkageBodyAST* node) { visitNodes(this, node->declarations); } -void DefaultVisitor::visitLinkageSpecification(LinkageSpecificationAST *node) +void DefaultVisitor::visitLinkageSpecification(LinkageSpecificationAST* node) { visit(node->linkage_body); visit(node->declaration); } -void DefaultVisitor::visitMemInitializer(MemInitializerAST *node) +void DefaultVisitor::visitMemInitializer(MemInitializerAST* node) { visit(node->initializer_id); visit(node->expression); } -void DefaultVisitor::visitName(NameAST *node) +void DefaultVisitor::visitName(NameAST* node) { visitNodes(this, node->qualified_names); visit(node->unqualified_name); } -void DefaultVisitor::visitNamespace(NamespaceAST *node) +void DefaultVisitor::visitNamespace(NamespaceAST* node) { visit(node->linkage_body); } -void DefaultVisitor::visitNamespaceAliasDefinition(NamespaceAliasDefinitionAST *node) +void DefaultVisitor::visitNamespaceAliasDefinition(NamespaceAliasDefinitionAST* node) { visit(node->alias_name); } -void DefaultVisitor::visitNewDeclarator(NewDeclaratorAST *node) +void DefaultVisitor::visitNewDeclarator(NewDeclaratorAST* node) { visit(node->ptr_op); visit(node->sub_declarator); visitNodes(this, node->expressions); } -void DefaultVisitor::visitNewExpression(NewExpressionAST *node) +void DefaultVisitor::visitNewExpression(NewExpressionAST* node) { visit(node->expression); visit(node->type_id); @@ -280,50 +279,50 @@ void DefaultVisitor::visitNewExpression(NewExpressionAST *node) visit(node->new_initializer); } -void DefaultVisitor::visitNewInitializer(NewInitializerAST *node) +void DefaultVisitor::visitNewInitializer(NewInitializerAST* node) { visit(node->expression); } -void DefaultVisitor::visitNewTypeId(NewTypeIdAST *node) +void DefaultVisitor::visitNewTypeId(NewTypeIdAST* node) { visit(node->type_specifier); visit(node->new_initializer); visit(node->new_declarator); } -void DefaultVisitor::visitOperator(OperatorAST *) +void DefaultVisitor::visitOperator(OperatorAST*) { // nothing to do } -void DefaultVisitor::visitOperatorFunctionId(OperatorFunctionIdAST *node) +void DefaultVisitor::visitOperatorFunctionId(OperatorFunctionIdAST* node) { visit(node->op); visit(node->type_specifier); visitNodes(this, node->ptr_ops); } -void DefaultVisitor::visitParameterDeclaration(ParameterDeclarationAST *node) +void DefaultVisitor::visitParameterDeclaration(ParameterDeclarationAST* node) { visit(node->type_specifier); visit(node->declarator); visit(node->expression); } -void DefaultVisitor::visitParameterDeclarationClause(ParameterDeclarationClauseAST *node) +void DefaultVisitor::visitParameterDeclarationClause(ParameterDeclarationClauseAST* node) { visitNodes(this, node->parameter_declarations); } -void DefaultVisitor::visitPostfixExpression(PostfixExpressionAST *node) +void DefaultVisitor::visitPostfixExpression(PostfixExpressionAST* node) { visit(node->type_specifier); visit(node->expression); visitNodes(this, node->sub_expressions); } -void DefaultVisitor::visitPrimaryExpression(PrimaryExpressionAST *node) +void DefaultVisitor::visitPrimaryExpression(PrimaryExpressionAST* node) { visit(node->literal); visit(node->expression_statement); @@ -331,103 +330,103 @@ void DefaultVisitor::visitPrimaryExpression(PrimaryExpressionAST *node) visit(node->name); } -void DefaultVisitor::visitPtrOperator(PtrOperatorAST *node) +void DefaultVisitor::visitPtrOperator(PtrOperatorAST* node) { visit(node->mem_ptr); } -void DefaultVisitor::visitPtrToMember(PtrToMemberAST *) +void DefaultVisitor::visitPtrToMember(PtrToMemberAST*) { // nothing to do } -void DefaultVisitor::visitReturnStatement(ReturnStatementAST *node) +void DefaultVisitor::visitReturnStatement(ReturnStatementAST* node) { visit(node->expression); } -void DefaultVisitor::visitSimpleDeclaration(SimpleDeclarationAST *node) +void DefaultVisitor::visitSimpleDeclaration(SimpleDeclarationAST* node) { visit(node->type_specifier); visitNodes(this, node->init_declarators); visit(node->win_decl_specifiers); } -void DefaultVisitor::visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *node) +void DefaultVisitor::visitSimpleTypeSpecifier(SimpleTypeSpecifierAST* node) { visit(node->name); visit(node->type_id); visit(node->expression); } -void DefaultVisitor::visitSizeofExpression(SizeofExpressionAST *node) +void DefaultVisitor::visitSizeofExpression(SizeofExpressionAST* node) { visit(node->type_id); visit(node->expression); } -void DefaultVisitor::visitStringLiteral(StringLiteralAST *) +void DefaultVisitor::visitStringLiteral(StringLiteralAST*) { // nothing to do } -void DefaultVisitor::visitSubscriptExpression(SubscriptExpressionAST *node) +void DefaultVisitor::visitSubscriptExpression(SubscriptExpressionAST* node) { visit(node->subscript); } -void DefaultVisitor::visitSwitchStatement(SwitchStatementAST *node) +void DefaultVisitor::visitSwitchStatement(SwitchStatementAST* node) { visit(node->condition); visit(node->statement); } -void DefaultVisitor::visitTemplateArgument(TemplateArgumentAST *node) +void DefaultVisitor::visitTemplateArgument(TemplateArgumentAST* node) { visit(node->type_id); visit(node->expression); } -void DefaultVisitor::visitTemplateDeclaration(TemplateDeclarationAST *node) +void DefaultVisitor::visitTemplateDeclaration(TemplateDeclarationAST* node) { visitNodes(this, node->template_parameters); visit(node->declaration); } -void DefaultVisitor::visitTemplateParameter(TemplateParameterAST *node) +void DefaultVisitor::visitTemplateParameter(TemplateParameterAST* node) { visit(node->type_parameter); visit(node->parameter_declaration); } -void DefaultVisitor::visitThrowExpression(ThrowExpressionAST *node) +void DefaultVisitor::visitThrowExpression(ThrowExpressionAST* node) { visit(node->expression); } -void DefaultVisitor::visitTranslationUnit(TranslationUnitAST *node) +void DefaultVisitor::visitTranslationUnit(TranslationUnitAST* node) { visitNodes(this, node->declarations); } -void DefaultVisitor::visitTryBlockStatement(TryBlockStatementAST *) +void DefaultVisitor::visitTryBlockStatement(TryBlockStatementAST*) { // nothing to do } -void DefaultVisitor::visitTypeId(TypeIdAST *node) +void DefaultVisitor::visitTypeId(TypeIdAST* node) { visit(node->type_specifier); visit(node->declarator); } -void DefaultVisitor::visitTypeIdentification(TypeIdentificationAST *node) +void DefaultVisitor::visitTypeIdentification(TypeIdentificationAST* node) { visit(node->name); visit(node->expression); } -void DefaultVisitor::visitTypeParameter(TypeParameterAST *node) +void DefaultVisitor::visitTypeParameter(TypeParameterAST* node) { visit(node->name); visit(node->type_id); @@ -435,40 +434,40 @@ void DefaultVisitor::visitTypeParameter(TypeParameterAST *node) visit(node->template_name); } -void DefaultVisitor::visitTypedef(TypedefAST *node) +void DefaultVisitor::visitTypedef(TypedefAST* node) { visit(node->type_specifier); visitNodes(this, node->init_declarators); } -void DefaultVisitor::visitUnaryExpression(UnaryExpressionAST *node) +void DefaultVisitor::visitUnaryExpression(UnaryExpressionAST* node) { visit(node->expression); } -void DefaultVisitor::visitUnqualifiedName(UnqualifiedNameAST *node) +void DefaultVisitor::visitUnqualifiedName(UnqualifiedNameAST* node) { visit(node->operator_id); visitNodes(this, node->template_arguments); } -void DefaultVisitor::visitUsing(UsingAST *node) +void DefaultVisitor::visitUsing(UsingAST* node) { visit(node->name); } -void DefaultVisitor::visitUsingDirective(UsingDirectiveAST *node) +void DefaultVisitor::visitUsingDirective(UsingDirectiveAST* node) { visit(node->name); } -void DefaultVisitor::visitWhileStatement(WhileStatementAST *node) +void DefaultVisitor::visitWhileStatement(WhileStatementAST* node) { visit(node->condition); visit(node->statement); } -void DefaultVisitor::visitWinDeclSpec(WinDeclSpecAST *) +void DefaultVisitor::visitWinDeclSpec(WinDeclSpecAST*) { // nothing to do } diff --git a/generator/parser/default_visitor.h b/generator/parser/default_visitor.h index 1c6388aa2..59e8fd8c7 100644 --- a/generator/parser/default_visitor.h +++ b/generator/parser/default_visitor.h @@ -39,94 +39,93 @@ ** ****************************************************************************/ - #ifndef DEFAULT_VISITOR_H -#define DEFAULT_VISITOR_H + #define DEFAULT_VISITOR_H -#include "visitor.h" + #include "visitor.h" -class DefaultVisitor: public Visitor +class DefaultVisitor : public Visitor { public: DefaultVisitor() {} protected: - virtual void visitAccessSpecifier(AccessSpecifierAST *); - virtual void visitAsmDefinition(AsmDefinitionAST *); - virtual void visitBaseClause(BaseClauseAST *); - virtual void visitBaseSpecifier(BaseSpecifierAST *); - virtual void visitBinaryExpression(BinaryExpressionAST *); - virtual void visitCastExpression(CastExpressionAST *); - virtual void visitClassMemberAccess(ClassMemberAccessAST *); - virtual void visitClassSpecifier(ClassSpecifierAST *); - virtual void visitCompoundStatement(CompoundStatementAST *); - virtual void visitCondition(ConditionAST *); - virtual void visitConditionalExpression(ConditionalExpressionAST *); - virtual void visitCppCastExpression(CppCastExpressionAST *); - virtual void visitCtorInitializer(CtorInitializerAST *); - virtual void visitDeclarationStatement(DeclarationStatementAST *); - virtual void visitDeclarator(DeclaratorAST *); - virtual void visitDeleteExpression(DeleteExpressionAST *); - virtual void visitDoStatement(DoStatementAST *); - virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *); - virtual void visitEnumSpecifier(EnumSpecifierAST *); - virtual void visitEnumerator(EnumeratorAST *); - virtual void visitExceptionSpecification(ExceptionSpecificationAST *); - virtual void visitExpressionOrDeclarationStatement(ExpressionOrDeclarationStatementAST *); - virtual void visitExpressionStatement(ExpressionStatementAST *); - virtual void visitForStatement(ForStatementAST *); - virtual void visitFunctionCall(FunctionCallAST *); - virtual void visitFunctionDefinition(FunctionDefinitionAST *); - virtual void visitIfStatement(IfStatementAST *); - virtual void visitIncrDecrExpression(IncrDecrExpressionAST *); - virtual void visitInitDeclarator(InitDeclaratorAST *); - virtual void visitInitializer(InitializerAST *); - virtual void visitInitializerClause(InitializerClauseAST *); - virtual void visitLabeledStatement(LabeledStatementAST *); - virtual void visitLinkageBody(LinkageBodyAST *); - virtual void visitLinkageSpecification(LinkageSpecificationAST *); - virtual void visitMemInitializer(MemInitializerAST *); - virtual void visitName(NameAST *); - virtual void visitNamespace(NamespaceAST *); - virtual void visitNamespaceAliasDefinition(NamespaceAliasDefinitionAST *); - virtual void visitNewDeclarator(NewDeclaratorAST *); - virtual void visitNewExpression(NewExpressionAST *); - virtual void visitNewInitializer(NewInitializerAST *); - virtual void visitNewTypeId(NewTypeIdAST *); - virtual void visitOperator(OperatorAST *); - virtual void visitOperatorFunctionId(OperatorFunctionIdAST *); - virtual void visitParameterDeclaration(ParameterDeclarationAST *); - virtual void visitParameterDeclarationClause(ParameterDeclarationClauseAST *); - virtual void visitPostfixExpression(PostfixExpressionAST *); - virtual void visitPrimaryExpression(PrimaryExpressionAST *); - virtual void visitPtrOperator(PtrOperatorAST *); - virtual void visitPtrToMember(PtrToMemberAST *); - virtual void visitReturnStatement(ReturnStatementAST *); - virtual void visitSimpleDeclaration(SimpleDeclarationAST *); - virtual void visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *); - virtual void visitSizeofExpression(SizeofExpressionAST *); - virtual void visitStringLiteral(StringLiteralAST *); - virtual void visitSubscriptExpression(SubscriptExpressionAST *); - virtual void visitSwitchStatement(SwitchStatementAST *); - virtual void visitTemplateArgument(TemplateArgumentAST *); - virtual void visitTemplateDeclaration(TemplateDeclarationAST *); - virtual void visitTemplateParameter(TemplateParameterAST *); - virtual void visitThrowExpression(ThrowExpressionAST *); - virtual void visitTranslationUnit(TranslationUnitAST *); - virtual void visitTryBlockStatement(TryBlockStatementAST *); - virtual void visitTypeId(TypeIdAST *); - virtual void visitTypeIdentification(TypeIdentificationAST *); - virtual void visitTypeParameter(TypeParameterAST *); - virtual void visitTypedef(TypedefAST *); - virtual void visitUnaryExpression(UnaryExpressionAST *); - virtual void visitUnqualifiedName(UnqualifiedNameAST *); - virtual void visitUsing(UsingAST *); - virtual void visitUsingDirective(UsingDirectiveAST *); - virtual void visitWhileStatement(WhileStatementAST *); - virtual void visitWinDeclSpec(WinDeclSpecAST *); + virtual void visitAccessSpecifier(AccessSpecifierAST*); + virtual void visitAsmDefinition(AsmDefinitionAST*); + virtual void visitBaseClause(BaseClauseAST*); + virtual void visitBaseSpecifier(BaseSpecifierAST*); + virtual void visitBinaryExpression(BinaryExpressionAST*); + virtual void visitCastExpression(CastExpressionAST*); + virtual void visitClassMemberAccess(ClassMemberAccessAST*); + virtual void visitClassSpecifier(ClassSpecifierAST*); + virtual void visitCompoundStatement(CompoundStatementAST*); + virtual void visitCondition(ConditionAST*); + virtual void visitConditionalExpression(ConditionalExpressionAST*); + virtual void visitCppCastExpression(CppCastExpressionAST*); + virtual void visitCtorInitializer(CtorInitializerAST*); + virtual void visitDeclarationStatement(DeclarationStatementAST*); + virtual void visitDeclarator(DeclaratorAST*); + virtual void visitDeleteExpression(DeleteExpressionAST*); + virtual void visitDoStatement(DoStatementAST*); + virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST*); + virtual void visitEnumSpecifier(EnumSpecifierAST*); + virtual void visitEnumerator(EnumeratorAST*); + virtual void visitExceptionSpecification(ExceptionSpecificationAST*); + virtual void visitExpressionOrDeclarationStatement(ExpressionOrDeclarationStatementAST*); + virtual void visitExpressionStatement(ExpressionStatementAST*); + virtual void visitForStatement(ForStatementAST*); + virtual void visitFunctionCall(FunctionCallAST*); + virtual void visitFunctionDefinition(FunctionDefinitionAST*); + virtual void visitIfStatement(IfStatementAST*); + virtual void visitIncrDecrExpression(IncrDecrExpressionAST*); + virtual void visitInitDeclarator(InitDeclaratorAST*); + virtual void visitInitializer(InitializerAST*); + virtual void visitInitializerClause(InitializerClauseAST*); + virtual void visitLabeledStatement(LabeledStatementAST*); + virtual void visitLinkageBody(LinkageBodyAST*); + virtual void visitLinkageSpecification(LinkageSpecificationAST*); + virtual void visitMemInitializer(MemInitializerAST*); + virtual void visitName(NameAST*); + virtual void visitNamespace(NamespaceAST*); + virtual void visitNamespaceAliasDefinition(NamespaceAliasDefinitionAST*); + virtual void visitNewDeclarator(NewDeclaratorAST*); + virtual void visitNewExpression(NewExpressionAST*); + virtual void visitNewInitializer(NewInitializerAST*); + virtual void visitNewTypeId(NewTypeIdAST*); + virtual void visitOperator(OperatorAST*); + virtual void visitOperatorFunctionId(OperatorFunctionIdAST*); + virtual void visitParameterDeclaration(ParameterDeclarationAST*); + virtual void visitParameterDeclarationClause(ParameterDeclarationClauseAST*); + virtual void visitPostfixExpression(PostfixExpressionAST*); + virtual void visitPrimaryExpression(PrimaryExpressionAST*); + virtual void visitPtrOperator(PtrOperatorAST*); + virtual void visitPtrToMember(PtrToMemberAST*); + virtual void visitReturnStatement(ReturnStatementAST*); + virtual void visitSimpleDeclaration(SimpleDeclarationAST*); + virtual void visitSimpleTypeSpecifier(SimpleTypeSpecifierAST*); + virtual void visitSizeofExpression(SizeofExpressionAST*); + virtual void visitStringLiteral(StringLiteralAST*); + virtual void visitSubscriptExpression(SubscriptExpressionAST*); + virtual void visitSwitchStatement(SwitchStatementAST*); + virtual void visitTemplateArgument(TemplateArgumentAST*); + virtual void visitTemplateDeclaration(TemplateDeclarationAST*); + virtual void visitTemplateParameter(TemplateParameterAST*); + virtual void visitThrowExpression(ThrowExpressionAST*); + virtual void visitTranslationUnit(TranslationUnitAST*); + virtual void visitTryBlockStatement(TryBlockStatementAST*); + virtual void visitTypeId(TypeIdAST*); + virtual void visitTypeIdentification(TypeIdentificationAST*); + virtual void visitTypeParameter(TypeParameterAST*); + virtual void visitTypedef(TypedefAST*); + virtual void visitUnaryExpression(UnaryExpressionAST*); + virtual void visitUnqualifiedName(UnqualifiedNameAST*); + virtual void visitUsing(UsingAST*); + virtual void visitUsingDirective(UsingDirectiveAST*); + virtual void visitWhileStatement(WhileStatementAST*); + virtual void visitWinDeclSpec(WinDeclSpecAST*); private: - typedef void (Visitor::*visitor_fun_ptr)(AST *); + typedef void (Visitor::*visitor_fun_ptr)(AST*); static visitor_fun_ptr _S_table[]; }; diff --git a/generator/parser/dumptree.cpp b/generator/parser/dumptree.cpp index 21d11f979..9a13135fa 100644 --- a/generator/parser/dumptree.cpp +++ b/generator/parser/dumptree.cpp @@ -39,100 +39,34 @@ ** ****************************************************************************/ - #include "dumptree.h" #include #include -static char const * const names[] = { - 0, - "AccessSpecifier", - "AsmDefinition", - "BaseClause", - "BaseSpecifier", - "BinaryExpression", - "CastExpression", - "ClassMemberAccess", - "ClassSpecifier", - "CompoundStatement", - "Condition", - "ConditionalExpression", - "CppCastExpression", - "CtorInitializer", - "DeclarationStatement", - "Declarator", - "DeleteExpression", - "DoStatement", - "ElaboratedTypeSpecifier", - "EnumSpecifier", - "Enumerator", - "ExceptionSpecification", - "ExpressionOrDeclarationStatement", - "ExpressionStatement", - "ForStatement", - "FunctionCall", - "FunctionDefinition", - "IfStatement", - "IncrDecrExpression", - "InitDeclarator", - "Initializer", - "InitializerClause", - "LabeledStatement", - "LinkageBody", - "LinkageSpecification", - "MemInitializer", - "Name", - "Namespace", - "NamespaceAliasDefinition", - "NewDeclarator", - "NewExpression", - "NewInitializer", - "NewTypeId", - "Operator", - "OperatorFunctionId", - "ParameterDeclaration", - "ParameterDeclarationClause", - "PostfixExpression", - "PrimaryExpression", - "PtrOperator", - "PtrToMember", - "ReturnStatement", - "SimpleDeclaration", - "SimpleTypeSpecifier", - "SizeofExpression", - "StringLiteral", - "SubscriptExpression", - "SwitchStatement", - "TemplateArgument", - "TemplateDeclaration", - "TemplateParameter", - "ThrowExpression", - "TranslationUnit", - "TryBlockStatement", - "TypeId", - "TypeIdentification", - "TypeParameter", - "Typedef", - "UnaryExpression", - "UnqualifiedName", - "Using", - "UsingDirective", - "WhileStatement", - "WinDeclSpec" -}; +static char const* const names[] = {0, "AccessSpecifier", "AsmDefinition", "BaseClause", "BaseSpecifier", + "BinaryExpression", "CastExpression", "ClassMemberAccess", "ClassSpecifier", "CompoundStatement", "Condition", + "ConditionalExpression", "CppCastExpression", "CtorInitializer", "DeclarationStatement", "Declarator", + "DeleteExpression", "DoStatement", "ElaboratedTypeSpecifier", "EnumSpecifier", "Enumerator", "ExceptionSpecification", + "ExpressionOrDeclarationStatement", "ExpressionStatement", "ForStatement", "FunctionCall", "FunctionDefinition", + "IfStatement", "IncrDecrExpression", "InitDeclarator", "Initializer", "InitializerClause", "LabeledStatement", + "LinkageBody", "LinkageSpecification", "MemInitializer", "Name", "Namespace", "NamespaceAliasDefinition", + "NewDeclarator", "NewExpression", "NewInitializer", "NewTypeId", "Operator", "OperatorFunctionId", + "ParameterDeclaration", "ParameterDeclarationClause", "PostfixExpression", "PrimaryExpression", "PtrOperator", + "PtrToMember", "ReturnStatement", "SimpleDeclaration", "SimpleTypeSpecifier", "SizeofExpression", "StringLiteral", + "SubscriptExpression", "SwitchStatement", "TemplateArgument", "TemplateDeclaration", "TemplateParameter", + "ThrowExpression", "TranslationUnit", "TryBlockStatement", "TypeId", "TypeIdentification", "TypeParameter", "Typedef", + "UnaryExpression", "UnqualifiedName", "Using", "UsingDirective", "WhileStatement", "WinDeclSpec"}; -DumpTree::DumpTree() -{ -} +DumpTree::DumpTree() {} -void DumpTree::visit(AST *node) +void DumpTree::visit(AST* node) { static int indent = 0; if (node) - qDebug() << QString(indent * 2, ' ').toLatin1().constData() << names[node->kind] - << '[' << node->start_token << ", " << node->end_token << ']'; + qDebug() << QString(indent * 2, ' ').toLatin1().constData() << names[node->kind] << '[' << node->start_token << ", " + << node->end_token << ']'; ++indent; DefaultVisitor::visit(node); diff --git a/generator/parser/dumptree.h b/generator/parser/dumptree.h index 2778c93a0..fd55c039d 100644 --- a/generator/parser/dumptree.h +++ b/generator/parser/dumptree.h @@ -39,21 +39,20 @@ ** ****************************************************************************/ - #ifndef DUMPTREE_H -#define DUMPTREE_H + #define DUMPTREE_H -#include "default_visitor.h" + #include "default_visitor.h" -class DumpTree: protected DefaultVisitor +class DumpTree : protected DefaultVisitor { public: DumpTree(); - void dump(AST *node) { visit(node); } + void dump(AST* node) { visit(node); } protected: - virtual void visit(AST *node); + virtual void visit(AST* node); }; #endif // DUMPTREE_H diff --git a/generator/parser/include/stdarg.h b/generator/parser/include/stdarg.h index 677c27a2a..a1ce6a60f 100644 --- a/generator/parser/include/stdarg.h +++ b/generator/parser/include/stdarg.h @@ -39,26 +39,25 @@ ** ****************************************************************************/ - #ifndef __STDARG #define __STDARG #if !defined(_VA_LIST) && !defined(__VA_LIST_DEFINED) -#define _VA_LIST -#define _VA_LIST_DEFINED + #define _VA_LIST + #define _VA_LIST_DEFINED -typedef char *__va_list; +typedef char* __va_list; #endif static float __va_arg_tmp; typedef __va_list va_list; -#define va_start(list, start) ((void)0) -#define __va_arg(list, mode, n) ((void)0) -#define _bigendian_va_arg(list, mode, n) ((void)0) +#define va_start(list, start) ((void)0) +#define __va_arg(list, mode, n) ((void)0) +#define _bigendian_va_arg(list, mode, n) ((void)0) #define _littleendian_va_arg(list, mode, n) ((void)0) -#define va_end(list) ((void)0) -#define va_arg(list, mode) ((void)0) +#define va_end(list) ((void)0) +#define va_arg(list, mode) ((void)0) -typedef void *__gnuc_va_list; +typedef void* __gnuc_va_list; #endif diff --git a/generator/parser/lexer.cpp b/generator/parser/lexer.cpp index 2ea0bcf59..74aea7d2f 100644 --- a/generator/parser/lexer.cpp +++ b/generator/parser/lexer.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include "lexer.h" #include "tokens.h" #include "control.h" @@ -47,81 +46,72 @@ #include #include -scan_fun_ptr Lexer::s_scan_keyword_table[] = { - &Lexer::scanKeyword0, &Lexer::scanKeyword0, - &Lexer::scanKeyword2, &Lexer::scanKeyword3, - &Lexer::scanKeyword4, &Lexer::scanKeyword5, - &Lexer::scanKeyword6, &Lexer::scanKeyword7, - &Lexer::scanKeyword8, &Lexer::scanKeyword9, - &Lexer::scanKeyword10, &Lexer::scanKeyword11, - &Lexer::scanKeyword12, &Lexer::scanKeyword13, - &Lexer::scanKeyword14, &Lexer::scanKeyword0, - &Lexer::scanKeyword16 -}; - -void LocationManager::extract_line(int offset, int *line, QString *filename) const +scan_fun_ptr Lexer::s_scan_keyword_table[] = {&Lexer::scanKeyword0, &Lexer::scanKeyword0, &Lexer::scanKeyword2, + &Lexer::scanKeyword3, &Lexer::scanKeyword4, &Lexer::scanKeyword5, &Lexer::scanKeyword6, &Lexer::scanKeyword7, + &Lexer::scanKeyword8, &Lexer::scanKeyword9, &Lexer::scanKeyword10, &Lexer::scanKeyword11, &Lexer::scanKeyword12, + &Lexer::scanKeyword13, &Lexer::scanKeyword14, &Lexer::scanKeyword0, &Lexer::scanKeyword16}; + +void LocationManager::extract_line(int offset, int* line, QString* filename) const { *line = 0; - if (token_stream.size () < 1) + if (token_stream.size() < 1) return; - const unsigned char *begin_buffer = reinterpret_cast(token_stream[0].text); - const unsigned char *cursor = begin_buffer + offset; + const unsigned char* begin_buffer = reinterpret_cast(token_stream[0].text); + const unsigned char* cursor = begin_buffer + offset; ++cursor; // skip '#' if (cursor[0] == 'l' && cursor[1] == 'i' && cursor[2] == 'n' && cursor[3] == 'e') { cursor += 4; } - if (std::isspace(*cursor) && std::isdigit(*(cursor + 1))) - { - ++cursor; - char buffer[1024], *cp = buffer; - do { - *cp++ = *cursor++; - } while (std::isdigit(*cursor)); - *cp = '\0'; - int l = strtol(buffer, 0, 0); - - Q_ASSERT(std::isspace(*cursor)); - ++cursor; - - Q_ASSERT(*cursor == '"'); - ++cursor; + if (std::isspace(*cursor) && std::isdigit(*(cursor + 1))) { + ++cursor; + char buffer[1024], *cp = buffer; + do { + *cp++ = *cursor++; + } while (std::isdigit(*cursor)); + *cp = '\0'; + int l = strtol(buffer, 0, 0); + + Q_ASSERT(std::isspace(*cursor)); + ++cursor; - cp = buffer; - while (*cursor && *cursor != '"') { - *cp++ = *cursor++; - } - *cp = '\0'; - Q_ASSERT(*cursor == '"'); - ++cursor; + Q_ASSERT(*cursor == '"'); + ++cursor; - *filename = buffer; - *line = l; - // printf("filename: %s line: %d\n", buffer, line); + cp = buffer; + while (*cursor && *cursor != '"') { + *cp++ = *cursor++; } + *cp = '\0'; + Q_ASSERT(*cursor == '"'); + ++cursor; + + *filename = buffer; + *line = l; + // printf("filename: %s line: %d\n", buffer, line); + } } -void LocationManager::positionAt(std::size_t offset, int *line, int *column, - QString *filename) const +void LocationManager::positionAt(std::size_t offset, int* line, int* column, QString* filename) const { int ppline, ppcolumn; line_table.positionAt(offset, &ppline, &ppcolumn); int base_line; - extract_line((int) line_table[ppline-1], &base_line, filename); + extract_line((int)line_table[ppline - 1], &base_line, filename); int line2, column2; - location_table.positionAt((int) line_table[ppline-1], &line2, &column2); + location_table.positionAt((int)line_table[ppline - 1], &line2, &column2); location_table.positionAt(offset, line, column); - *line = base_line + *line - line2 - 1; + *line = base_line + *line - line2 - 1; } scan_fun_ptr Lexer::s_scan_table[256]; bool Lexer::s_initialized = false; -void Lexer::tokenize(const char *contents, std::size_t size) +void Lexer::tokenize(const char* contents, std::size_t size) { if (!s_initialized) initialize_scan_table(); @@ -132,8 +122,8 @@ void Lexer::tokenize(const char *contents, std::size_t size) index = 1; - cursor = (const unsigned char *) contents; - begin_buffer = (const unsigned char *) contents; + cursor = (const unsigned char*)contents; + begin_buffer = (const unsigned char*)contents; end_buffer = cursor + size; location_table.resize(1024); @@ -145,10 +135,11 @@ void Lexer::tokenize(const char *contents, std::size_t size) line_table.current_line = 1; do { - if (index >= token_stream.size()-4) // increase size of token_stream early, in case more than one token is written in one go + if (index >= token_stream.size() + - 4) // increase size of token_stream early, in case more than one token is written in one go token_stream.resize(token_stream.size() * 2); - Token *current_token = &token_stream[(int) index]; + Token* current_token = &token_stream[(int)index]; current_token->text = reinterpret_cast(begin_buffer); current_token->position = cursor - begin_buffer; (this->*s_scan_table[*cursor])(); @@ -156,52 +147,50 @@ void Lexer::tokenize(const char *contents, std::size_t size) } while (cursor < end_buffer); if (index == token_stream.size()) - token_stream.resize(token_stream.size() * 2); + token_stream.resize(token_stream.size() * 2); Q_ASSERT(index < token_stream.size()); - token_stream[(int) index].position = cursor - begin_buffer; - token_stream[(int) index].kind = Token_EOF; + token_stream[(int)index].position = cursor - begin_buffer; + token_stream[(int)index].kind = Token_EOF; } void Lexer::reportError(const QString& msg) { - int line, column; - QString fileName; - - std::size_t tok = token_stream.cursor(); - _M_location.positionAt(token_stream.position(tok), - &line, &column, &fileName); - - Control::ErrorMessage errmsg; - errmsg.setLine(line + 1); - errmsg.setColumn(column); - errmsg.setFileName(fileName); - errmsg.setMessage(QLatin1String("** LEXER ERROR ") + msg); - control->reportError(errmsg); + int line, column; + QString fileName; + + std::size_t tok = token_stream.cursor(); + _M_location.positionAt(token_stream.position(tok), &line, &column, &fileName); + + Control::ErrorMessage errmsg; + errmsg.setLine(line + 1); + errmsg.setColumn(column); + errmsg.setFileName(fileName); + errmsg.setMessage(QLatin1String("** LEXER ERROR ") + msg); + control->reportError(errmsg); } void Lexer::initialize_scan_table() { s_initialized = true; - for (int i=0; i<256; ++i) - { - if (isspace(i)) - s_scan_table[i] = &Lexer::scan_white_spaces; - else if (isalpha(i) || i == '_') - s_scan_table[i] = &Lexer::scan_identifier_or_keyword; - else if (isdigit(i)) - s_scan_table[i] = &Lexer::scan_int_constant; - else - s_scan_table[i] = &Lexer::scan_invalid_input; - } + for (int i = 0; i < 256; ++i) { + if (isspace(i)) + s_scan_table[i] = &Lexer::scan_white_spaces; + else if (isalpha(i) || i == '_') + s_scan_table[i] = &Lexer::scan_identifier_or_keyword; + else if (isdigit(i)) + s_scan_table[i] = &Lexer::scan_int_constant; + else + s_scan_table[i] = &Lexer::scan_invalid_input; + } s_scan_table[int('L')] = &Lexer::scan_identifier_or_literal; s_scan_table[int('\n')] = &Lexer::scan_newline; s_scan_table[int('#')] = &Lexer::scan_preprocessor; s_scan_table[int('\'')] = &Lexer::scan_char_constant; - s_scan_table[int('"')] = &Lexer::scan_string_constant; + s_scan_table[int('"')] = &Lexer::scan_string_constant; s_scan_table[int('.')] = &Lexer::scan_int_constant; @@ -237,65 +226,61 @@ void Lexer::scan_preprocessor() if (line_table.current_line == line_table.size()) line_table.resize(line_table.current_line * 2); - line_table[(int) line_table.current_line++] = (cursor - begin_buffer); + line_table[(int)line_table.current_line++] = (cursor - begin_buffer); while (*cursor && *cursor != '\n') ++cursor; if (*cursor != '\n') - reportError("expected newline"); + reportError("expected newline"); } void Lexer::scan_char_constant_with_prefix(const unsigned char* prefix) { - const unsigned char *begin = prefix ? prefix : cursor; + const unsigned char* begin = prefix ? prefix : cursor; ++cursor; - while (*cursor && *cursor != '\'') - { - if (*cursor == '\n') - reportError("did not expect newline"); + while (*cursor && *cursor != '\'') { + if (*cursor == '\n') + reportError("did not expect newline"); - if (*cursor == '\\') - ++cursor; + if (*cursor == '\\') ++cursor; - } + ++cursor; + } - if (*cursor != '\'') - reportError("expected \'"); + if (*cursor != '\'') + reportError("expected \'"); ++cursor; - token_stream[(int) index].extra.symbol = - control->findOrInsertName((const char*) begin, cursor - begin); + token_stream[(int)index].extra.symbol = control->findOrInsertName((const char*)begin, cursor - begin); - token_stream[(int) index++].kind = Token_char_literal; + token_stream[(int)index++].kind = Token_char_literal; } void Lexer::scan_string_constant_with_prefix(const unsigned char* prefix) { - const unsigned char *begin = prefix ? prefix : cursor; + const unsigned char* begin = prefix ? prefix : cursor; ++cursor; - while (*cursor && *cursor != '"') - { - if (*cursor == '\n') - reportError("did not expect newline"); + while (*cursor && *cursor != '"') { + if (*cursor == '\n') + reportError("did not expect newline"); - if (*cursor == '\\') - ++cursor; + if (*cursor == '\\') ++cursor; - } + ++cursor; + } if (*cursor != '"') reportError("expected \""); ++cursor; - token_stream[(int) index].extra.symbol = - control->findOrInsertName((const char*) begin, cursor - begin); + token_stream[(int)index].extra.symbol = control->findOrInsertName((const char*)begin, cursor - begin); - token_stream[(int) index++].kind = Token_string_literal; + token_stream[(int)index++].kind = Token_string_literal; } void Lexer::scan_raw_string_constant_with_prefix(const unsigned char* prefix) @@ -306,46 +291,30 @@ void Lexer::scan_raw_string_constant_with_prefix(const unsigned char* prefix) int endSequenceLength = 0; bool stillValidDelimiter = true; ++cursor; - while (*cursor) - { - if (!delimiterLength) - { - if (*cursor == '"') - { + while (*cursor) { + if (!delimiterLength) { + if (*cursor == '"') { break; - } - else if (*cursor == '\n') - { + } else if (*cursor == '\n') { // this would probably not be a valid delimiter stillValidDelimiter = false; - } - else if (stillValidDelimiter && *cursor == '(' && (cursor - begin) < 16) - { + } else if (stillValidDelimiter && *cursor == '(' && (cursor - begin) < 16) { // delimiter sequence identified (see https://en.cppreference.com/w/cpp/language/string_literal) delimiterLength = cursor - begin; } - } - else if (endSequenceLength) - { + } else if (endSequenceLength) { // possible end delimiter sequence - if (endSequenceLength == delimiterLength && *cursor == '"') - { + if (endSequenceLength == delimiterLength && *cursor == '"') { break; - } - else if (endSequenceLength < delimiterLength && *cursor == begin[endSequenceLength]) - { + } else if (endSequenceLength < delimiterLength && *cursor == begin[endSequenceLength]) { endSequenceLength++; - } - else - { + } else { // this is not the end of the string, go back to // after the starting ')' and try again cursor -= endSequenceLength; endSequenceLength = 0; } - } - else if (*cursor == ')') - { + } else if (*cursor == ')') { // this might be the start of the end delimiter sequence endSequenceLength = 1; } @@ -357,8 +326,7 @@ void Lexer::scan_raw_string_constant_with_prefix(const unsigned char* prefix) ++cursor; - token_stream[(int)index].extra.symbol = - control->findOrInsertName((const char*)begin, cursor - begin); + token_stream[(int)index].extra.symbol = control->findOrInsertName((const char*)begin, cursor - begin); token_stream[(int)index++].kind = Token_string_literal; } @@ -368,78 +336,66 @@ void Lexer::scan_newline() if (location_table.current_line == location_table.size()) location_table.resize(location_table.current_line * 2); - location_table[(int) location_table.current_line++] = (cursor - begin_buffer); + location_table[(int)location_table.current_line++] = (cursor - begin_buffer); ++cursor; } void Lexer::scan_white_spaces() { - while (isspace(*cursor)) - { - if (*cursor == '\n') - scan_newline(); - else - ++cursor; - } + while (isspace(*cursor)) { + if (*cursor == '\n') + scan_newline(); + else + ++cursor; + } } void Lexer::scan_identifier_or_literal() { - switch (*(cursor + 1)) - { - case '\'': - ++cursor; - scan_char_constant(); - break; + switch (*(cursor + 1)) { + case '\'': + ++cursor; + scan_char_constant(); + break; - case '\"': - ++cursor; - scan_string_constant(); - break; + case '\"': + ++cursor; + scan_string_constant(); + break; - default: - scan_identifier_or_keyword(); - break; - } + default: + scan_identifier_or_keyword(); + break; + } } void Lexer::scan_identifier_or_keyword() { - const unsigned char *skip = cursor; + const unsigned char* skip = cursor; const unsigned char* start = cursor; - while (isalnum(*skip) || *skip== '_') + while (isalnum(*skip) || *skip == '_') ++skip; int n = skip - cursor; - if (*skip == '"' && n <= 3) - { + if (*skip == '"' && n <= 3) { cursor = skip; // this should be a unicode and/or raw string - // we pass through anything that does not follow the standard, though - if (skip[-1] == 'R') - { + if (skip[-1] == 'R') { scan_raw_string_constant_with_prefix(start); - } - else - { + } else { scan_string_constant_with_prefix(start); } - } - else if (*skip == '\'' && n <= 2) - { + } else if (*skip == '\'' && n <= 2) { // probably some special encoding cursor = skip; scan_char_constant_with_prefix(start); - } - else - { + } else { Token* current_token = &token_stream[(int)index]; (this->*s_scan_keyword_table[n < 17 ? n : 0])(); - if (current_token->kind == Token_identifier) - { - current_token->extra.symbol = - control->findOrInsertName((const char*)cursor, n); + if (current_token->kind == Token_identifier) { + current_token->extra.symbol = control->findOrInsertName((const char*)cursor, n); } cursor = skip; @@ -448,21 +404,19 @@ void Lexer::scan_identifier_or_keyword() void Lexer::scan_int_constant() { - if (*cursor == '.' && !std::isdigit(*(cursor + 1))) - { - scan_dot(); - return; - } + if (*cursor == '.' && !std::isdigit(*(cursor + 1))) { + scan_dot(); + return; + } - const unsigned char *begin = cursor; + const unsigned char* begin = cursor; while (isalnum(*cursor) || *cursor == '.') ++cursor; - token_stream[(int) index].extra.symbol = - control->findOrInsertName((const char*) begin, cursor - begin); + token_stream[(int)index].extra.symbol = control->findOrInsertName((const char*)begin, cursor - begin); - token_stream[(int) index++].kind = Token_number_literal; + token_stream[(int)index++].kind = Token_number_literal; } void Lexer::scan_not() @@ -474,15 +428,12 @@ void Lexer::scan_not() ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_not_eq; - } - else - { - token_stream[(int) index++].kind = '!'; - } + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_not_eq; + } else { + token_stream[(int)index++].kind = '!'; + } } void Lexer::scan_remainder() @@ -494,15 +445,12 @@ void Lexer::scan_remainder() ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_assign; - } - else - { - token_stream[(int) index++].kind = '%'; - } + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_assign; + } else { + token_stream[(int)index++].kind = '%'; + } } void Lexer::scan_and() @@ -514,32 +462,27 @@ void Lexer::scan_and() */ ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_assign; - } - else if (*cursor == '&') - { - ++cursor; - token_stream[(int) index++].kind = Token_and; - } - else - { - token_stream[(int) index++].kind = '&'; - } + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_assign; + } else if (*cursor == '&') { + ++cursor; + token_stream[(int)index++].kind = Token_and; + } else { + token_stream[(int)index++].kind = '&'; + } } void Lexer::scan_left_paren() { ++cursor; - token_stream[(int) index++].kind = '('; + token_stream[(int)index++].kind = '('; } void Lexer::scan_right_paren() { ++cursor; - token_stream[(int) index++].kind = ')'; + token_stream[(int)index++].kind = ')'; } void Lexer::scan_star() @@ -551,15 +494,12 @@ void Lexer::scan_star() ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_assign; - } - else - { - token_stream[(int) index++].kind = '*'; - } + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_assign; + } else { + token_stream[(int)index++].kind = '*'; + } } void Lexer::scan_plus() @@ -571,26 +511,21 @@ void Lexer::scan_plus() */ ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_assign; - } - else if (*cursor == '+') - { - ++cursor; - token_stream[(int) index++].kind = Token_incr; - } - else - { - token_stream[(int) index++].kind = '+'; - } + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_assign; + } else if (*cursor == '+') { + ++cursor; + token_stream[(int)index++].kind = Token_incr; + } else { + token_stream[(int)index++].kind = '+'; + } } void Lexer::scan_comma() { ++cursor; - token_stream[(int) index++].kind = ','; + token_stream[(int)index++].kind = ','; } void Lexer::scan_minus() @@ -603,30 +538,22 @@ void Lexer::scan_minus() */ ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_assign; - } - else if (*cursor == '-') - { - ++cursor; - token_stream[(int) index++].kind = Token_decr; - } - else if (*cursor == '>') - { + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_assign; + } else if (*cursor == '-') { + ++cursor; + token_stream[(int)index++].kind = Token_decr; + } else if (*cursor == '>') { + ++cursor; + token_stream[(int)index++].kind = Token_arrow; + if (*cursor == '*') { ++cursor; - token_stream[(int) index++].kind = Token_arrow; - if (*cursor == '*') - { - ++cursor; - token_stream[(int) index++].kind = Token_ptrmem; - } - } - else - { - token_stream[(int) index++].kind = '-'; + token_stream[(int)index++].kind = Token_ptrmem; } + } else { + token_stream[(int)index++].kind = '-'; + } } void Lexer::scan_dot() @@ -637,18 +564,14 @@ void Lexer::scan_dot() */ ++cursor; - if (*cursor == '.' && *(cursor + 1) == '.') - { - cursor += 2; - token_stream[(int) index++].kind = Token_ellipsis; - } - else if (*cursor == '.' && *(cursor + 1) == '*') - { - cursor += 2; - token_stream[(int) index++].kind = Token_ptrmem; - } - else - token_stream[(int) index++].kind = '.'; + if (*cursor == '.' && *(cursor + 1) == '.') { + cursor += 2; + token_stream[(int)index++].kind = Token_ellipsis; + } else if (*cursor == '.' && *(cursor + 1) == '*') { + cursor += 2; + token_stream[(int)index++].kind = Token_ptrmem; + } else + token_stream[(int)index++].kind = '.'; } void Lexer::scan_divide() @@ -660,35 +583,29 @@ void Lexer::scan_divide() ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_assign; - } - else - { - token_stream[(int) index++].kind = '/'; - } + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_assign; + } else { + token_stream[(int)index++].kind = '/'; + } } void Lexer::scan_colon() { ++cursor; - if (*cursor == ':') - { - ++cursor; - token_stream[(int) index++].kind = Token_scope; - } - else - { - token_stream[(int) index++].kind = ':'; - } + if (*cursor == ':') { + ++cursor; + token_stream[(int)index++].kind = Token_scope; + } else { + token_stream[(int)index++].kind = ':'; + } } void Lexer::scan_semicolon() { ++cursor; - token_stream[(int) index++].kind = ';'; + token_stream[(int)index++].kind = ';'; } void Lexer::scan_less() @@ -701,28 +618,20 @@ void Lexer::scan_less() */ ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_leq; - } - else if (*cursor == '<') - { + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_leq; + } else if (*cursor == '<') { + ++cursor; + if (*cursor == '=') { ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_assign; - } - else - { - token_stream[(int) index++].kind = Token_shift_left; - } - } - else - { - token_stream[(int) index++].kind = '<'; + token_stream[(int)index++].kind = Token_assign; + } else { + token_stream[(int)index++].kind = Token_shift_left; } + } else { + token_stream[(int)index++].kind = '<'; + } } void Lexer::scan_equal() @@ -733,15 +642,12 @@ void Lexer::scan_equal() */ ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_eq; - } - else - { - token_stream[(int) index++].kind = '='; - } + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_eq; + } else { + token_stream[(int)index++].kind = '='; + } } void Lexer::scan_greater() @@ -754,48 +660,40 @@ void Lexer::scan_greater() */ ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_geq; - } - else if (*cursor == '>') - { + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_geq; + } else if (*cursor == '>') { + ++cursor; + if (*cursor == '=') { ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_assign; - } - else - { - // may be replaced by two ">" during parsing - token_stream[(int) index++].kind = Token_shift_right; - token_stream[(int) index++].kind = Token_placeholder; - } - } - else - { - token_stream[(int) index++].kind = '>'; + token_stream[(int)index++].kind = Token_assign; + } else { + // may be replaced by two ">" during parsing + token_stream[(int)index++].kind = Token_shift_right; + token_stream[(int)index++].kind = Token_placeholder; } + } else { + token_stream[(int)index++].kind = '>'; + } } void Lexer::scan_question() { ++cursor; - token_stream[(int) index++].kind = '?'; + token_stream[(int)index++].kind = '?'; } void Lexer::scan_left_bracket() { ++cursor; - token_stream[(int) index++].kind = '['; + token_stream[(int)index++].kind = '['; } void Lexer::scan_right_bracket() { ++cursor; - token_stream[(int) index++].kind = ']'; + token_stream[(int)index++].kind = ']'; } void Lexer::scan_xor() @@ -806,21 +704,18 @@ void Lexer::scan_xor() */ ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_assign; - } - else - { - token_stream[(int) index++].kind = '^'; - } + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_assign; + } else { + token_stream[(int)index++].kind = '^'; + } } void Lexer::scan_left_brace() { ++cursor; - token_stream[(int) index++].kind = '{'; + token_stream[(int)index++].kind = '{'; } void Lexer::scan_or() @@ -831,38 +726,33 @@ void Lexer::scan_or() '||' ::= or_or */ ++cursor; - if (*cursor == '=') - { - ++cursor; - token_stream[(int) index++].kind = Token_assign; - } - else if (*cursor == '|') - { - ++cursor; - token_stream[(int) index++].kind = Token_or; - } - else - { - token_stream[(int) index++].kind = '|'; + if (*cursor == '=') { + ++cursor; + token_stream[(int)index++].kind = Token_assign; + } else if (*cursor == '|') { + ++cursor; + token_stream[(int)index++].kind = Token_or; + } else { + token_stream[(int)index++].kind = '|'; } } void Lexer::scan_right_brace() { ++cursor; - token_stream[(int) index++].kind = '}'; + token_stream[(int)index++].kind = '}'; } void Lexer::scan_tilde() { ++cursor; - token_stream[(int) index++].kind = '~'; + token_stream[(int)index++].kind = '~'; } void Lexer::scan_EOF() { ++cursor; - token_stream[(int) index++].kind = Token_EOF; + token_stream[(int)index++].kind = Token_EOF; } void Lexer::scan_invalid_input() @@ -872,8 +762,7 @@ void Lexer::scan_invalid_input() ++cursor; } -void LocationTable::positionAt(std::size_t offset, int max_line, - int *line, int *column) const +void LocationTable::positionAt(std::size_t offset, int max_line, int* line, int* column) const { if (!(line && column && max_line != 0)) return; @@ -883,1162 +772,790 @@ void LocationTable::positionAt(std::size_t offset, int max_line, int half; int middle; - while (len > 0) - { - half = len >> 1; - middle = first; + while (len > 0) { + half = len >> 1; + middle = first; - middle += half; + middle += half; - if (lines[middle] < offset) - { - first = middle; - ++first; - len = len - half - 1; - } - else - len = half; - } + if (lines[middle] < offset) { + first = middle; + ++first; + len = len - half - 1; + } else + len = half; + } *line = std::max(first, 1); - *column = (int) (offset - lines[*line - 1] - 1); + *column = (int)(offset - lines[*line - 1] - 1); - if (*column < 0) - { - *column = 0; - } + if (*column < 0) { + *column = 0; + } } void Lexer::scanKeyword0() { - token_stream[(int) index++].kind = Token_identifier; + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword2() { - switch (*cursor) - { - case 'i': - if (*(cursor + 1) == 'f') - { - token_stream[(int) index++].kind = Token_if; - return; - } - break; - - case 'd': - if (*(cursor + 1) == 'o') - { - token_stream[(int) index++].kind = Token_do; - return; - } - break; - - case 'o': - if (*(cursor + 1) == 'r') - { - token_stream[(int) index++].kind = Token_or; - return; - } - break; - - } - token_stream[(int) index++].kind = Token_identifier; + switch (*cursor) { + case 'i': + if (*(cursor + 1) == 'f') { + token_stream[(int)index++].kind = Token_if; + return; + } + break; + + case 'd': + if (*(cursor + 1) == 'o') { + token_stream[(int)index++].kind = Token_do; + return; + } + break; + + case 'o': + if (*(cursor + 1) == 'r') { + token_stream[(int)index++].kind = Token_or; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword3() { - switch (*cursor) - { - case 'a': - if (*(cursor + 1) == 'n' && - *(cursor + 2) == 'd') - { - token_stream[(int) index++].kind = Token_and; - return; - } - if (*(cursor + 1) == 's' && - *(cursor + 2) == 'm') - { - token_stream[(int) index++].kind = Token_asm; - return; - } - break; - - case 'f': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'r') - { - token_stream[(int) index++].kind = Token_for; - return; - } - break; - - case 'i': - if (*(cursor + 1) == 'n' && - *(cursor + 2) == 't') - { - token_stream[(int) index++].kind = Token_int; - return; - } - break; - - case 'n': - if (*(cursor + 1) == 'e' && - *(cursor + 2) == 'w') - { - token_stream[(int) index++].kind = Token_new; - return; - } - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 't') - { - token_stream[(int) index++].kind = Token_not; - return; - } - break; - - case 't': - if (*(cursor + 1) == 'r' && - *(cursor + 2) == 'y') - { - token_stream[(int) index++].kind = Token_try; - return; - } - break; - - case 'x': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'r') - { - token_stream[(int) index++].kind = Token_xor; - return; - } - break; - - } - token_stream[(int) index++].kind = Token_identifier; + switch (*cursor) { + case 'a': + if (*(cursor + 1) == 'n' && *(cursor + 2) == 'd') { + token_stream[(int)index++].kind = Token_and; + return; + } + if (*(cursor + 1) == 's' && *(cursor + 2) == 'm') { + token_stream[(int)index++].kind = Token_asm; + return; + } + break; + + case 'f': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'r') { + token_stream[(int)index++].kind = Token_for; + return; + } + break; + + case 'i': + if (*(cursor + 1) == 'n' && *(cursor + 2) == 't') { + token_stream[(int)index++].kind = Token_int; + return; + } + break; + + case 'n': + if (*(cursor + 1) == 'e' && *(cursor + 2) == 'w') { + token_stream[(int)index++].kind = Token_new; + return; + } + if (*(cursor + 1) == 'o' && *(cursor + 2) == 't') { + token_stream[(int)index++].kind = Token_not; + return; + } + break; + + case 't': + if (*(cursor + 1) == 'r' && *(cursor + 2) == 'y') { + token_stream[(int)index++].kind = Token_try; + return; + } + break; + + case 'x': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'r') { + token_stream[(int)index++].kind = Token_xor; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword4() { - switch (*cursor) - { - case 'a': - if (*(cursor + 1) == 'u' && - *(cursor + 2) == 't' && - *(cursor + 3) == 'o') - { - token_stream[(int) index++].kind = Token_auto; - return; - } - break; - - case 'c': - if (*(cursor + 1) == 'a' && - *(cursor + 2) == 's' && - *(cursor + 3) == 'e') - { - token_stream[(int) index++].kind = Token_case; - return; - } - if (*(cursor + 1) == 'h' && - *(cursor + 2) == 'a' && - *(cursor + 3) == 'r') - { - token_stream[(int) index++].kind = Token_char; - return; - } - break; - - case 'b': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'o' && - *(cursor + 3) == 'l') - { - token_stream[(int) index++].kind = Token_bool; - return; - } - break; - - case 'e': - if (*(cursor + 1) == 'l' && - *(cursor + 2) == 's' && - *(cursor + 3) == 'e') - { - token_stream[(int) index++].kind = Token_else; - return; - } - if (*(cursor + 1) == 'm' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 't') - { - token_stream[(int) index++].kind = Token_emit; - return; - } - if (*(cursor + 1) == 'n' && - *(cursor + 2) == 'u' && - *(cursor + 3) == 'm') - { - token_stream[(int) index++].kind = Token_enum; - return; - } - break; - - case 'g': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 't' && - *(cursor + 3) == 'o') - { - token_stream[(int) index++].kind = Token_goto; - return; - } - break; - - case 'l': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'n' && - *(cursor + 3) == 'g') - { - token_stream[(int) index++].kind = Token_long; - return; - } - break; - - case 't': - if (*(cursor + 1) == 'h' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 's') - { - token_stream[(int) index++].kind = Token_this; - return; - } - break; - - case 'v': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 'd') - { - token_stream[(int) index++].kind = Token_void; - return; - } - break; - - } - token_stream[(int) index++].kind = Token_identifier; + switch (*cursor) { + case 'a': + if (*(cursor + 1) == 'u' && *(cursor + 2) == 't' && *(cursor + 3) == 'o') { + token_stream[(int)index++].kind = Token_auto; + return; + } + break; + + case 'c': + if (*(cursor + 1) == 'a' && *(cursor + 2) == 's' && *(cursor + 3) == 'e') { + token_stream[(int)index++].kind = Token_case; + return; + } + if (*(cursor + 1) == 'h' && *(cursor + 2) == 'a' && *(cursor + 3) == 'r') { + token_stream[(int)index++].kind = Token_char; + return; + } + break; + + case 'b': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'o' && *(cursor + 3) == 'l') { + token_stream[(int)index++].kind = Token_bool; + return; + } + break; + + case 'e': + if (*(cursor + 1) == 'l' && *(cursor + 2) == 's' && *(cursor + 3) == 'e') { + token_stream[(int)index++].kind = Token_else; + return; + } + if (*(cursor + 1) == 'm' && *(cursor + 2) == 'i' && *(cursor + 3) == 't') { + token_stream[(int)index++].kind = Token_emit; + return; + } + if (*(cursor + 1) == 'n' && *(cursor + 2) == 'u' && *(cursor + 3) == 'm') { + token_stream[(int)index++].kind = Token_enum; + return; + } + break; + + case 'g': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 't' && *(cursor + 3) == 'o') { + token_stream[(int)index++].kind = Token_goto; + return; + } + break; + + case 'l': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'n' && *(cursor + 3) == 'g') { + token_stream[(int)index++].kind = Token_long; + return; + } + break; + + case 't': + if (*(cursor + 1) == 'h' && *(cursor + 2) == 'i' && *(cursor + 3) == 's') { + token_stream[(int)index++].kind = Token_this; + return; + } + break; + + case 'v': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'i' && *(cursor + 3) == 'd') { + token_stream[(int)index++].kind = Token_void; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword5() { - switch (*cursor) - { - case 'c': - if (*(cursor + 1) == 'a' && - *(cursor + 2) == 't' && - *(cursor + 3) == 'c' && - *(cursor + 4) == 'h') - { - token_stream[(int) index++].kind = Token_catch; - return; - } - if (*(cursor + 1) == 'l' && - *(cursor + 2) == 'a' && - *(cursor + 3) == 's' && - *(cursor + 4) == 's') - { - token_stream[(int) index++].kind = Token_class; - return; - } - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'm' && - *(cursor + 3) == 'p' && - *(cursor + 4) == 'l') - { - token_stream[(int) index++].kind = Token_compl; - return; - } - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'n' && - *(cursor + 3) == 's' && - *(cursor + 4) == 't') - { - token_stream[(int) index++].kind = Token_const; - return; - } - break; - - case 'b': - if (*(cursor + 1) == 'i' && - *(cursor + 2) == 't' && - *(cursor + 3) == 'o' && - *(cursor + 4) == 'r') - { - token_stream[(int) index++].kind = Token_bitor; - return; - } - if (*(cursor + 1) == 'r' && - *(cursor + 2) == 'e' && - *(cursor + 3) == 'a' && - *(cursor + 4) == 'k') - { - token_stream[(int) index++].kind = Token_break; - return; - } - break; - - case 'f': - if (*(cursor + 1) == 'l' && - *(cursor + 2) == 'o' && - *(cursor + 3) == 'a' && - *(cursor + 4) == 't') - { - token_stream[(int) index++].kind = Token_float; - return; - } - break; - - case 'o': - if (*(cursor + 1) == 'r' && - *(cursor + 2) == '_' && - *(cursor + 3) == 'e' && - *(cursor + 4) == 'q') - { - token_stream[(int) index++].kind = Token_or_eq; - return; - } - break; - - case 's': - if (*(cursor + 1) == 'h' && - *(cursor + 2) == 'o' && - *(cursor + 3) == 'r' && - *(cursor + 4) == 't') - { - token_stream[(int) index++].kind = Token_short; - return; - } - if (*(cursor + 1) == 'l' && - *(cursor + 2) == 'o' && - *(cursor + 3) == 't' && - *(cursor + 4) == 's') - { - token_stream[(int) index++].kind = Token_slots; - return; - } - break; - - case 'u': - if (*(cursor + 1) == 'n' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 'o' && - *(cursor + 4) == 'n') - { - token_stream[(int) index++].kind = Token_union; - return; - } - if (*(cursor + 1) == 's' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 'n' && - *(cursor + 4) == 'g') - { - token_stream[(int) index++].kind = Token_using; - return; - } - break; - - case 't': - if (*(cursor + 1) == 'h' && - *(cursor + 2) == 'r' && - *(cursor + 3) == 'o' && - *(cursor + 4) == 'w') - { - token_stream[(int) index++].kind = Token_throw; - return; - } - break; - - case 'w': - if (*(cursor + 1) == 'h' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 'l' && - *(cursor + 4) == 'e') - { - token_stream[(int) index++].kind = Token_while; - return; - } - break; - - } - token_stream[(int) index++].kind = Token_identifier; + switch (*cursor) { + case 'c': + if (*(cursor + 1) == 'a' && *(cursor + 2) == 't' && *(cursor + 3) == 'c' && *(cursor + 4) == 'h') { + token_stream[(int)index++].kind = Token_catch; + return; + } + if (*(cursor + 1) == 'l' && *(cursor + 2) == 'a' && *(cursor + 3) == 's' && *(cursor + 4) == 's') { + token_stream[(int)index++].kind = Token_class; + return; + } + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'm' && *(cursor + 3) == 'p' && *(cursor + 4) == 'l') { + token_stream[(int)index++].kind = Token_compl; + return; + } + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'n' && *(cursor + 3) == 's' && *(cursor + 4) == 't') { + token_stream[(int)index++].kind = Token_const; + return; + } + break; + + case 'b': + if (*(cursor + 1) == 'i' && *(cursor + 2) == 't' && *(cursor + 3) == 'o' && *(cursor + 4) == 'r') { + token_stream[(int)index++].kind = Token_bitor; + return; + } + if (*(cursor + 1) == 'r' && *(cursor + 2) == 'e' && *(cursor + 3) == 'a' && *(cursor + 4) == 'k') { + token_stream[(int)index++].kind = Token_break; + return; + } + break; + + case 'f': + if (*(cursor + 1) == 'l' && *(cursor + 2) == 'o' && *(cursor + 3) == 'a' && *(cursor + 4) == 't') { + token_stream[(int)index++].kind = Token_float; + return; + } + break; + + case 'o': + if (*(cursor + 1) == 'r' && *(cursor + 2) == '_' && *(cursor + 3) == 'e' && *(cursor + 4) == 'q') { + token_stream[(int)index++].kind = Token_or_eq; + return; + } + break; + + case 's': + if (*(cursor + 1) == 'h' && *(cursor + 2) == 'o' && *(cursor + 3) == 'r' && *(cursor + 4) == 't') { + token_stream[(int)index++].kind = Token_short; + return; + } + if (*(cursor + 1) == 'l' && *(cursor + 2) == 'o' && *(cursor + 3) == 't' && *(cursor + 4) == 's') { + token_stream[(int)index++].kind = Token_slots; + return; + } + break; + + case 'u': + if (*(cursor + 1) == 'n' && *(cursor + 2) == 'i' && *(cursor + 3) == 'o' && *(cursor + 4) == 'n') { + token_stream[(int)index++].kind = Token_union; + return; + } + if (*(cursor + 1) == 's' && *(cursor + 2) == 'i' && *(cursor + 3) == 'n' && *(cursor + 4) == 'g') { + token_stream[(int)index++].kind = Token_using; + return; + } + break; + + case 't': + if (*(cursor + 1) == 'h' && *(cursor + 2) == 'r' && *(cursor + 3) == 'o' && *(cursor + 4) == 'w') { + token_stream[(int)index++].kind = Token_throw; + return; + } + break; + + case 'w': + if (*(cursor + 1) == 'h' && *(cursor + 2) == 'i' && *(cursor + 3) == 'l' && *(cursor + 4) == 'e') { + token_stream[(int)index++].kind = Token_while; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword6() { - switch (*cursor) + switch (*cursor) { + case 'a': + if (*(cursor + 1) == 'n' && *(cursor + 2) == 'd' && *(cursor + 3) == '_' && *(cursor + 4) == 'e' + && *(cursor + 5) == 'q') { - case 'a': - if (*(cursor + 1) == 'n' && - *(cursor + 2) == 'd' && - *(cursor + 3) == '_' && - *(cursor + 4) == 'e' && - *(cursor + 5) == 'q') - { - token_stream[(int) index++].kind = Token_and_eq; - return; - } - break; - - case 'b': - if (*(cursor + 1) == 'i' && - *(cursor + 2) == 't' && - *(cursor + 3) == 'a' && - *(cursor + 4) == 'n' && - *(cursor + 5) == 'd') - { - token_stream[(int) index++].kind = Token_bitand; - return; - } - break; - - case 'e': - if (*(cursor + 1) == 'x' && - *(cursor + 2) == 'p' && - *(cursor + 3) == 'o' && - *(cursor + 4) == 'r' && - *(cursor + 5) == 't') - { - token_stream[(int) index++].kind = Token_export; - return; - } - if (*(cursor + 1) == 'x' && - *(cursor + 2) == 't' && - *(cursor + 3) == 'e' && - *(cursor + 4) == 'r' && - *(cursor + 5) == 'n') - { - token_stream[(int) index++].kind = Token_extern; - return; - } - break; - - case 'd': - if (*(cursor + 1) == 'e' && - *(cursor + 2) == 'l' && - *(cursor + 3) == 'e' && - *(cursor + 4) == 't' && - *(cursor + 5) == 'e') - { - token_stream[(int) index++].kind = Token_delete; - return; - } - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'u' && - *(cursor + 3) == 'b' && - *(cursor + 4) == 'l' && - *(cursor + 5) == 'e') - { - token_stream[(int) index++].kind = Token_double; - return; - } - break; - - case 'f': - if (*(cursor + 1) == 'r' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 'e' && - *(cursor + 4) == 'n' && - *(cursor + 5) == 'd') - { - token_stream[(int) index++].kind = Token_friend; - return; - } - break; - - case 'i': - if (*(cursor + 1) == 'n' && - *(cursor + 2) == 'l' && - *(cursor + 3) == 'i' && - *(cursor + 4) == 'n' && - *(cursor + 5) == 'e') - { - token_stream[(int) index++].kind = Token_inline; - return; - } - break; - - case 'K': - if (*(cursor + 1) == '_' && - *(cursor + 2) == 'D' && - *(cursor + 3) == 'C' && - *(cursor + 4) == 'O' && - *(cursor + 5) == 'P') - { - token_stream[(int) index++].kind = Token_K_DCOP; - return; - } - break; - - case 'n': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 't' && - *(cursor + 3) == '_' && - *(cursor + 4) == 'e' && - *(cursor + 5) == 'q') - { - token_stream[(int) index++].kind = Token_not_eq; - return; - } - break; - - case 'p': - if (*(cursor + 1) == 'u' && - *(cursor + 2) == 'b' && - *(cursor + 3) == 'l' && - *(cursor + 4) == 'i' && - *(cursor + 5) == 'c') - { - token_stream[(int) index++].kind = Token_public; - return; - } - break; - - case 's': - if (*(cursor + 1) == 'i' && - *(cursor + 2) == 'g' && - *(cursor + 3) == 'n' && - *(cursor + 4) == 'e' && - *(cursor + 5) == 'd') - { - token_stream[(int) index++].kind = Token_signed; - return; - } - if (*(cursor + 1) == 'i' && - *(cursor + 2) == 'z' && - *(cursor + 3) == 'e' && - *(cursor + 4) == 'o' && - *(cursor + 5) == 'f') - { - token_stream[(int) index++].kind = Token_sizeof; - return; - } - if (*(cursor + 1) == 't' && - *(cursor + 2) == 'a' && - *(cursor + 3) == 't' && - *(cursor + 4) == 'i' && - *(cursor + 5) == 'c') - { - token_stream[(int) index++].kind = Token_static; - return; - } - if (*(cursor + 1) == 't' && - *(cursor + 2) == 'r' && - *(cursor + 3) == 'u' && - *(cursor + 4) == 'c' && - *(cursor + 5) == 't') - { - token_stream[(int) index++].kind = Token_struct; - return; - } - if (*(cursor + 1) == 'w' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 't' && - *(cursor + 4) == 'c' && - *(cursor + 5) == 'h') - { - token_stream[(int) index++].kind = Token_switch; - return; - } - break; - - case 'r': - if (*(cursor + 1) == 'e' && - *(cursor + 2) == 't' && - *(cursor + 3) == 'u' && - *(cursor + 4) == 'r' && - *(cursor + 5) == 'n') - { - token_stream[(int) index++].kind = Token_return; - return; - } - break; - - case 't': - if (*(cursor + 1) == 'y' && - *(cursor + 2) == 'p' && - *(cursor + 3) == 'e' && - *(cursor + 4) == 'i' && - *(cursor + 5) == 'd') - { - token_stream[(int) index++].kind = Token_typeid; - return; - } - break; - - case 'x': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'r' && - *(cursor + 3) == '_' && - *(cursor + 4) == 'e' && - *(cursor + 5) == 'q') - { - token_stream[(int) index++].kind = Token_xor_eq; - return; - } - break; - - case 'k': - if (*(cursor + 1) == '_' && - *(cursor + 2) == 'd' && - *(cursor + 3) == 'c' && - *(cursor + 4) == 'o' && - *(cursor + 5) == 'p') - { - token_stream[(int) index++].kind = Token_k_dcop; - return; - } - break; - case 'Q': - if (*(cursor + 1) == '_' && - *(cursor + 2) == 'E' && - *(cursor + 3) == 'N' && - *(cursor + 4) == 'U' && - *(cursor + 5) == 'M') - { - token_stream[(int)index++].kind = Token_Q_ENUM; - return; - } - break; + token_stream[(int)index++].kind = Token_and_eq; + return; + } + break; + + case 'b': + if (*(cursor + 1) == 'i' && *(cursor + 2) == 't' && *(cursor + 3) == 'a' && *(cursor + 4) == 'n' + && *(cursor + 5) == 'd') + { + token_stream[(int)index++].kind = Token_bitand; + return; + } + break; + + case 'e': + if (*(cursor + 1) == 'x' && *(cursor + 2) == 'p' && *(cursor + 3) == 'o' && *(cursor + 4) == 'r' + && *(cursor + 5) == 't') + { + token_stream[(int)index++].kind = Token_export; + return; + } + if (*(cursor + 1) == 'x' && *(cursor + 2) == 't' && *(cursor + 3) == 'e' && *(cursor + 4) == 'r' + && *(cursor + 5) == 'n') + { + token_stream[(int)index++].kind = Token_extern; + return; + } + break; + + case 'd': + if (*(cursor + 1) == 'e' && *(cursor + 2) == 'l' && *(cursor + 3) == 'e' && *(cursor + 4) == 't' + && *(cursor + 5) == 'e') + { + token_stream[(int)index++].kind = Token_delete; + return; + } + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'u' && *(cursor + 3) == 'b' && *(cursor + 4) == 'l' + && *(cursor + 5) == 'e') + { + token_stream[(int)index++].kind = Token_double; + return; + } + break; + + case 'f': + if (*(cursor + 1) == 'r' && *(cursor + 2) == 'i' && *(cursor + 3) == 'e' && *(cursor + 4) == 'n' + && *(cursor + 5) == 'd') + { + token_stream[(int)index++].kind = Token_friend; + return; + } + break; + + case 'i': + if (*(cursor + 1) == 'n' && *(cursor + 2) == 'l' && *(cursor + 3) == 'i' && *(cursor + 4) == 'n' + && *(cursor + 5) == 'e') + { + token_stream[(int)index++].kind = Token_inline; + return; + } + break; + + case 'K': + if (*(cursor + 1) == '_' && *(cursor + 2) == 'D' && *(cursor + 3) == 'C' && *(cursor + 4) == 'O' + && *(cursor + 5) == 'P') + { + token_stream[(int)index++].kind = Token_K_DCOP; + return; + } + break; + case 'n': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 't' && *(cursor + 3) == '_' && *(cursor + 4) == 'e' + && *(cursor + 5) == 'q') + { + token_stream[(int)index++].kind = Token_not_eq; + return; + } + break; + + case 'p': + if (*(cursor + 1) == 'u' && *(cursor + 2) == 'b' && *(cursor + 3) == 'l' && *(cursor + 4) == 'i' + && *(cursor + 5) == 'c') + { + token_stream[(int)index++].kind = Token_public; + return; + } + break; + + case 's': + if (*(cursor + 1) == 'i' && *(cursor + 2) == 'g' && *(cursor + 3) == 'n' && *(cursor + 4) == 'e' + && *(cursor + 5) == 'd') + { + token_stream[(int)index++].kind = Token_signed; + return; + } + if (*(cursor + 1) == 'i' && *(cursor + 2) == 'z' && *(cursor + 3) == 'e' && *(cursor + 4) == 'o' + && *(cursor + 5) == 'f') + { + token_stream[(int)index++].kind = Token_sizeof; + return; + } + if (*(cursor + 1) == 't' && *(cursor + 2) == 'a' && *(cursor + 3) == 't' && *(cursor + 4) == 'i' + && *(cursor + 5) == 'c') + { + token_stream[(int)index++].kind = Token_static; + return; + } + if (*(cursor + 1) == 't' && *(cursor + 2) == 'r' && *(cursor + 3) == 'u' && *(cursor + 4) == 'c' + && *(cursor + 5) == 't') + { + token_stream[(int)index++].kind = Token_struct; + return; + } + if (*(cursor + 1) == 'w' && *(cursor + 2) == 'i' && *(cursor + 3) == 't' && *(cursor + 4) == 'c' + && *(cursor + 5) == 'h') + { + token_stream[(int)index++].kind = Token_switch; + return; + } + break; + + case 'r': + if (*(cursor + 1) == 'e' && *(cursor + 2) == 't' && *(cursor + 3) == 'u' && *(cursor + 4) == 'r' + && *(cursor + 5) == 'n') + { + token_stream[(int)index++].kind = Token_return; + return; + } + break; + + case 't': + if (*(cursor + 1) == 'y' && *(cursor + 2) == 'p' && *(cursor + 3) == 'e' && *(cursor + 4) == 'i' + && *(cursor + 5) == 'd') + { + token_stream[(int)index++].kind = Token_typeid; + return; + } + break; + + case 'x': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'r' && *(cursor + 3) == '_' && *(cursor + 4) == 'e' + && *(cursor + 5) == 'q') + { + token_stream[(int)index++].kind = Token_xor_eq; + return; + } + break; + + case 'k': + if (*(cursor + 1) == '_' && *(cursor + 2) == 'd' && *(cursor + 3) == 'c' && *(cursor + 4) == 'o' + && *(cursor + 5) == 'p') + { + token_stream[(int)index++].kind = Token_k_dcop; + return; } - token_stream[(int) index++].kind = Token_identifier; + break; + case 'Q': + if (*(cursor + 1) == '_' && *(cursor + 2) == 'E' && *(cursor + 3) == 'N' && *(cursor + 4) == 'U' + && *(cursor + 5) == 'M') + { + token_stream[(int)index++].kind = Token_Q_ENUM; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword7() { - switch (*cursor) + switch (*cursor) { + case 'a': + if (*(cursor + 1) == 'l' && *(cursor + 2) == 'i' && *(cursor + 3) == 'g' && *(cursor + 4) == 'n' + && *(cursor + 5) == 'a' && *(cursor + 6) == 's') { - case 'a': - if (*(cursor + 1) == 'l' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 'g' && - *(cursor + 4) == 'n' && - *(cursor + 5) == 'a' && - *(cursor + 6) == 's') - { - token_stream[(int)index++].kind = Token_alignas; - return; - } - break; - case 'd': - if (*(cursor + 1) == 'e' && - *(cursor + 2) == 'f' && - *(cursor + 3) == 'a' && - *(cursor + 4) == 'u' && - *(cursor + 5) == 'l' && - *(cursor + 6) == 't') - { - token_stream[(int) index++].kind = Token_default; - return; - } - break; - - case 'm': - if (*(cursor + 1) == 'u' && - *(cursor + 2) == 't' && - *(cursor + 3) == 'a' && - *(cursor + 4) == 'b' && - *(cursor + 5) == 'l' && - *(cursor + 6) == 'e') - { - token_stream[(int) index++].kind = Token_mutable; - return; - } - break; - - case 'p': - if (*(cursor + 1) == 'r' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 'v' && - *(cursor + 4) == 'a' && - *(cursor + 5) == 't' && - *(cursor + 6) == 'e') - { - token_stream[(int) index++].kind = Token_private; - return; - } - break; - case 's': - if (*(cursor + 1) == 'i' && - *(cursor + 2) == 'g' && - *(cursor + 3) == 'n' && - *(cursor + 4) == 'a' && - *(cursor + 5) == 'l' && - *(cursor + 6) == 's') - { - token_stream[(int) index++].kind = Token_signals; - return; - } - break; - case 't': - if (*(cursor + 1) == 'y' && - *(cursor + 2) == 'p' && - *(cursor + 3) == 'e' && - *(cursor + 4) == 'd' && - *(cursor + 5) == 'e' && - *(cursor + 6) == 'f') - { - token_stream[(int) index++].kind = Token_typedef; - return; - } - break; - - case 'v': - if (*(cursor + 1) == 'i' && - *(cursor + 2) == 'r' && - *(cursor + 3) == 't' && - *(cursor + 4) == 'u' && - *(cursor + 5) == 'a' && - *(cursor + 6) == 'l') - { - token_stream[(int) index++].kind = Token_virtual; - return; - } - break; - - case 'Q': - if (*(cursor + 1) == '_' && - *(cursor + 2) == 'E' && - *(cursor + 3) == 'N' && - *(cursor + 4) == 'U' && - *(cursor + 5) == 'M' && - *(cursor + 6) == 'S') - { - token_stream[(int) index++].kind = Token_Q_ENUMS; - return; - } - break; + token_stream[(int)index++].kind = Token_alignas; + return; + } + break; + case 'd': + if (*(cursor + 1) == 'e' && *(cursor + 2) == 'f' && *(cursor + 3) == 'a' && *(cursor + 4) == 'u' + && *(cursor + 5) == 'l' && *(cursor + 6) == 't') + { + token_stream[(int)index++].kind = Token_default; + return; + } + break; + + case 'm': + if (*(cursor + 1) == 'u' && *(cursor + 2) == 't' && *(cursor + 3) == 'a' && *(cursor + 4) == 'b' + && *(cursor + 5) == 'l' && *(cursor + 6) == 'e') + { + token_stream[(int)index++].kind = Token_mutable; + return; + } + break; + case 'p': + if (*(cursor + 1) == 'r' && *(cursor + 2) == 'i' && *(cursor + 3) == 'v' && *(cursor + 4) == 'a' + && *(cursor + 5) == 't' && *(cursor + 6) == 'e') + { + token_stream[(int)index++].kind = Token_private; + return; + } + break; + case 's': + if (*(cursor + 1) == 'i' && *(cursor + 2) == 'g' && *(cursor + 3) == 'n' && *(cursor + 4) == 'a' + && *(cursor + 5) == 'l' && *(cursor + 6) == 's') + { + token_stream[(int)index++].kind = Token_signals; + return; + } + break; + case 't': + if (*(cursor + 1) == 'y' && *(cursor + 2) == 'p' && *(cursor + 3) == 'e' && *(cursor + 4) == 'd' + && *(cursor + 5) == 'e' && *(cursor + 6) == 'f') + { + token_stream[(int)index++].kind = Token_typedef; + return; } - token_stream[(int) index++].kind = Token_identifier; + break; + + case 'v': + if (*(cursor + 1) == 'i' && *(cursor + 2) == 'r' && *(cursor + 3) == 't' && *(cursor + 4) == 'u' + && *(cursor + 5) == 'a' && *(cursor + 6) == 'l') + { + token_stream[(int)index++].kind = Token_virtual; + return; + } + break; + + case 'Q': + if (*(cursor + 1) == '_' && *(cursor + 2) == 'E' && *(cursor + 3) == 'N' && *(cursor + 4) == 'U' + && *(cursor + 5) == 'M' && *(cursor + 6) == 'S') + { + token_stream[(int)index++].kind = Token_Q_ENUMS; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword8() { - switch (*cursor) + switch (*cursor) { + case '_': + if (*(cursor + 1) == '_' && *(cursor + 2) == 't' && *(cursor + 3) == 'y' && *(cursor + 4) == 'p' + && *(cursor + 5) == 'e' && *(cursor + 6) == 'o' && *(cursor + 7) == 'f') + { + token_stream[(int)index++].kind = Token___typeof; + return; + } + break; + + case 'c': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'n' && *(cursor + 3) == 't' && *(cursor + 4) == 'i' + && *(cursor + 5) == 'n' && *(cursor + 6) == 'u' && *(cursor + 7) == 'e') + { + token_stream[(int)index++].kind = Token_continue; + return; + } + break; + + case 'd': + if (*(cursor + 1) == 'e' && *(cursor + 2) == 'c' && *(cursor + 3) == 'l' && *(cursor + 4) == 't' + && *(cursor + 5) == 'y' && *(cursor + 6) == 'p' && *(cursor + 7) == 'e') + { + token_stream[(int)index++].kind = Token_decltype; + return; + } + break; + + case 'e': + if (*(cursor + 1) == 'x' && *(cursor + 2) == 'p' && *(cursor + 3) == 'l' && *(cursor + 4) == 'i' + && *(cursor + 5) == 'c' && *(cursor + 6) == 'i' && *(cursor + 7) == 't') + { + token_stream[(int)index++].kind = Token_explicit; + return; + } + break; + + case 'n': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'e' && *(cursor + 3) == 'x' && *(cursor + 4) == 'c' + && *(cursor + 5) == 'e' && *(cursor + 6) == 'p' && *(cursor + 7) == 't') + { + token_stream[(int)index++].kind = Token_noexcept; + return; + } + break; + + case 'o': + if (*(cursor + 1) == 'p' && *(cursor + 2) == 'e' && *(cursor + 3) == 'r' && *(cursor + 4) == 'a' + && *(cursor + 5) == 't' && *(cursor + 6) == 'o' && *(cursor + 7) == 'r') + { + token_stream[(int)index++].kind = Token_operator; + return; + } + break; + + case 'Q': + if (*(cursor + 1) == '_' && *(cursor + 2) == 'O' && *(cursor + 3) == 'B' && *(cursor + 4) == 'J' + && *(cursor + 5) == 'E' && *(cursor + 6) == 'C' && *(cursor + 7) == 'T') + { + token_stream[(int)index++].kind = Token_Q_OBJECT; + return; + } + break; + + case 'r': + if (*(cursor + 1) == 'e' && *(cursor + 2) == 'g' && *(cursor + 3) == 'i' && *(cursor + 4) == 's' + && *(cursor + 5) == 't' && *(cursor + 6) == 'e' && *(cursor + 7) == 'r') + { + token_stream[(int)index++].kind = Token_register; + return; + } + break; + + case 'u': + if (*(cursor + 1) == 'n' && *(cursor + 2) == 's' && *(cursor + 3) == 'i' && *(cursor + 4) == 'g' + && *(cursor + 5) == 'n' && *(cursor + 6) == 'e' && *(cursor + 7) == 'd') + { + token_stream[(int)index++].kind = Token_unsigned; + return; + } + break; + + case 't': + if (*(cursor + 1) == 'e' && *(cursor + 2) == 'm' && *(cursor + 3) == 'p' && *(cursor + 4) == 'l' + && *(cursor + 5) == 'a' && *(cursor + 6) == 't' && *(cursor + 7) == 'e') + { + token_stream[(int)index++].kind = Token_template; + return; + } + if (*(cursor + 1) == 'y' && *(cursor + 2) == 'p' && *(cursor + 3) == 'e' && *(cursor + 4) == 'n' + && *(cursor + 5) == 'a' && *(cursor + 6) == 'm' && *(cursor + 7) == 'e') + { + token_stream[(int)index++].kind = Token_typename; + return; + } + break; + + case 'v': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'l' && *(cursor + 3) == 'a' && *(cursor + 4) == 't' + && *(cursor + 5) == 'i' && *(cursor + 6) == 'l' && *(cursor + 7) == 'e') { - case '_': - if (*(cursor + 1) == '_' && - *(cursor + 2) == 't' && - *(cursor + 3) == 'y' && - *(cursor + 4) == 'p' && - *(cursor + 5) == 'e' && - *(cursor + 6) == 'o' && - *(cursor + 7) == 'f') - { - token_stream[(int) index++].kind = Token___typeof; - return; - } - break; - - case 'c': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'n' && - *(cursor + 3) == 't' && - *(cursor + 4) == 'i' && - *(cursor + 5) == 'n' && - *(cursor + 6) == 'u' && - *(cursor + 7) == 'e') - { - token_stream[(int) index++].kind = Token_continue; - return; - } - break; - - case 'd': - if (*(cursor + 1) == 'e' && - *(cursor + 2) == 'c' && - *(cursor + 3) == 'l' && - *(cursor + 4) == 't' && - *(cursor + 5) == 'y' && - *(cursor + 6) == 'p' && - *(cursor + 7) == 'e') - { - token_stream[(int) index++].kind = Token_decltype; - return; - } - break; - - case 'e': - if (*(cursor + 1) == 'x' && - *(cursor + 2) == 'p' && - *(cursor + 3) == 'l' && - *(cursor + 4) == 'i' && - *(cursor + 5) == 'c' && - *(cursor + 6) == 'i' && - *(cursor + 7) == 't') - { - token_stream[(int) index++].kind = Token_explicit; - return; - } - break; - - case 'n': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'e' && - *(cursor + 3) == 'x' && - *(cursor + 4) == 'c' && - *(cursor + 5) == 'e' && - *(cursor + 6) == 'p' && - *(cursor + 7) == 't') - { - token_stream[(int) index++].kind = Token_noexcept; - return; - } - break; - - case 'o': - if (*(cursor + 1) == 'p' && - *(cursor + 2) == 'e' && - *(cursor + 3) == 'r' && - *(cursor + 4) == 'a' && - *(cursor + 5) == 't' && - *(cursor + 6) == 'o' && - *(cursor + 7) == 'r') - { - token_stream[(int) index++].kind = Token_operator; - return; - } - break; - - case 'Q': - if (*(cursor + 1) == '_' && - *(cursor + 2) == 'O' && - *(cursor + 3) == 'B' && - *(cursor + 4) == 'J' && - *(cursor + 5) == 'E' && - *(cursor + 6) == 'C' && - *(cursor + 7) == 'T') - { - token_stream[(int) index++].kind = Token_Q_OBJECT; - return; - } - break; - - case 'r': - if (*(cursor + 1) == 'e' && - *(cursor + 2) == 'g' && - *(cursor + 3) == 'i' && - *(cursor + 4) == 's' && - *(cursor + 5) == 't' && - *(cursor + 6) == 'e' && - *(cursor + 7) == 'r') - { - token_stream[(int) index++].kind = Token_register; - return; - } - break; - - case 'u': - if (*(cursor + 1) == 'n' && - *(cursor + 2) == 's' && - *(cursor + 3) == 'i' && - *(cursor + 4) == 'g' && - *(cursor + 5) == 'n' && - *(cursor + 6) == 'e' && - *(cursor + 7) == 'd') - { - token_stream[(int) index++].kind = Token_unsigned; - return; - } - break; - - case 't': - if (*(cursor + 1) == 'e' && - *(cursor + 2) == 'm' && - *(cursor + 3) == 'p' && - *(cursor + 4) == 'l' && - *(cursor + 5) == 'a' && - *(cursor + 6) == 't' && - *(cursor + 7) == 'e') - { - token_stream[(int) index++].kind = Token_template; - return; - } - if (*(cursor + 1) == 'y' && - *(cursor + 2) == 'p' && - *(cursor + 3) == 'e' && - *(cursor + 4) == 'n' && - *(cursor + 5) == 'a' && - *(cursor + 6) == 'm' && - *(cursor + 7) == 'e') - { - token_stream[(int) index++].kind = Token_typename; - return; - } - break; - - case 'v': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'l' && - *(cursor + 3) == 'a' && - *(cursor + 4) == 't' && - *(cursor + 5) == 'i' && - *(cursor + 6) == 'l' && - *(cursor + 7) == 'e') - { - token_stream[(int) index++].kind = Token_volatile; - return; - } - break; - - } - token_stream[(int) index++].kind = Token_identifier; + token_stream[(int)index++].kind = Token_volatile; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword9() { - switch (*cursor) + switch (*cursor) { + case 'c': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'n' && *(cursor + 3) == 's' && *(cursor + 4) == 't' + && *(cursor + 5) == 'e' && *(cursor + 6) == 'x' && *(cursor + 7) == 'p' && *(cursor + 8) == 'r') + { + token_stream[(int)index++].kind = Token_constexpr; + return; + } + break; + + case 'p': + if (*(cursor + 1) == 'r' && *(cursor + 2) == 'o' && *(cursor + 3) == 't' && *(cursor + 4) == 'e' + && *(cursor + 5) == 'c' && *(cursor + 6) == 't' && *(cursor + 7) == 'e' && *(cursor + 8) == 'd') { - case 'c': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'n' && - *(cursor + 3) == 's' && - *(cursor + 4) == 't' && - *(cursor + 5) == 'e' && - *(cursor + 6) == 'x' && - *(cursor + 7) == 'p' && - *(cursor + 8) == 'r') - { - token_stream[(int) index++].kind = Token_constexpr; - return; - } - break; - - case 'p': - if (*(cursor + 1) == 'r' && - *(cursor + 2) == 'o' && - *(cursor + 3) == 't' && - *(cursor + 4) == 'e' && - *(cursor + 5) == 'c' && - *(cursor + 6) == 't' && - *(cursor + 7) == 'e' && - *(cursor + 8) == 'd') - { - token_stream[(int) index++].kind = Token_protected; - return; - } - break; - - case 'n': - if (*(cursor + 1) == 'a' && - *(cursor + 2) == 'm' && - *(cursor + 3) == 'e' && - *(cursor + 4) == 's' && - *(cursor + 5) == 'p' && - *(cursor + 6) == 'a' && - *(cursor + 7) == 'c' && - *(cursor + 8) == 'e') - { - token_stream[(int) index++].kind = Token_namespace; - return; - } - break; - - } - token_stream[(int) index++].kind = Token_identifier; + token_stream[(int)index++].kind = Token_protected; + return; + } + break; + + case 'n': + if (*(cursor + 1) == 'a' && *(cursor + 2) == 'm' && *(cursor + 3) == 'e' && *(cursor + 4) == 's' + && *(cursor + 5) == 'p' && *(cursor + 6) == 'a' && *(cursor + 7) == 'c' && *(cursor + 8) == 'e') + { + token_stream[(int)index++].kind = Token_namespace; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword10() { - switch (*cursor) + switch (*cursor) { + case 'c': + if (*(cursor + 1) == 'o' && *(cursor + 2) == 'n' && *(cursor + 3) == 's' && *(cursor + 4) == 't' + && *(cursor + 5) == '_' && *(cursor + 6) == 'c' && *(cursor + 7) == 'a' && *(cursor + 8) == 's' + && *(cursor + 9) == 't') { - case 'c': - if (*(cursor + 1) == 'o' && - *(cursor + 2) == 'n' && - *(cursor + 3) == 's' && - *(cursor + 4) == 't' && - *(cursor + 5) == '_' && - *(cursor + 6) == 'c' && - *(cursor + 7) == 'a' && - *(cursor + 8) == 's' && - *(cursor + 9) == 't') - { - token_stream[(int) index++].kind = Token_const_cast; - return; - } - break; - - case 'Q': - if (*(cursor + 1) == '_' && - *(cursor + 2) == 'P' && - *(cursor + 3) == 'R' && - *(cursor + 4) == 'O' && - *(cursor + 5) == 'P' && - *(cursor + 6) == 'E' && - *(cursor + 7) == 'R' && - *(cursor + 8) == 'T' && - *(cursor + 9) == 'Y') - { - token_stream[(int) index++].kind = Token_Q_PROPERTY; - return; - } + token_stream[(int)index++].kind = Token_const_cast; + return; + } + break; - break; + case 'Q': + if (*(cursor + 1) == '_' && *(cursor + 2) == 'P' && *(cursor + 3) == 'R' && *(cursor + 4) == 'O' + && *(cursor + 5) == 'P' && *(cursor + 6) == 'E' && *(cursor + 7) == 'R' && *(cursor + 8) == 'T' + && *(cursor + 9) == 'Y') + { + token_stream[(int)index++].kind = Token_Q_PROPERTY; + return; } - token_stream[(int) index++].kind = Token_identifier; + break; + } + + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword11() { - switch (*cursor) + switch (*cursor) { + case 'Q': + if (*(cursor + 1) == '_' && *(cursor + 2) == 'I' && *(cursor + 3) == 'N' && *(cursor + 4) == 'V' + && *(cursor + 5) == 'O' && *(cursor + 6) == 'K' && *(cursor + 7) == 'A' && *(cursor + 8) == 'B' + && *(cursor + 9) == 'L' && *(cursor + 10) == 'E') { - case 'Q': - if (*(cursor + 1) == '_' && - *(cursor + 2) == 'I' && - *(cursor + 3) == 'N' && - *(cursor + 4) == 'V' && - *(cursor + 5) == 'O' && - *(cursor + 6) == 'K' && - *(cursor + 7) == 'A' && - *(cursor + 8) == 'B' && - *(cursor + 9) == 'L' && - *(cursor + 10) == 'E') - { - token_stream[(int) index++].kind = Token_Q_INVOKABLE; - return; - } - break; - - case 's': - if (*(cursor + 1) == 't' && - *(cursor + 2) == 'a' && - *(cursor + 3) == 't' && - *(cursor + 4) == 'i' && - *(cursor + 5) == 'c' && - *(cursor + 6) == '_' && - *(cursor + 7) == 'c' && - *(cursor + 8) == 'a' && - *(cursor + 9) == 's' && - *(cursor + 10) == 't') - { - token_stream[(int) index++].kind = Token_static_cast; - return; - } - break; - - } - token_stream[(int) index++].kind = Token_identifier; + token_stream[(int)index++].kind = Token_Q_INVOKABLE; + return; + } + break; + + case 's': + if (*(cursor + 1) == 't' && *(cursor + 2) == 'a' && *(cursor + 3) == 't' && *(cursor + 4) == 'i' + && *(cursor + 5) == 'c' && *(cursor + 6) == '_' && *(cursor + 7) == 'c' && *(cursor + 8) == 'a' + && *(cursor + 9) == 's' && *(cursor + 10) == 't') + { + token_stream[(int)index++].kind = Token_static_cast; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword12() { - switch (*cursor) + switch (*cursor) { + case 'd': + if (*(cursor + 1) == 'y' && *(cursor + 2) == 'n' && *(cursor + 3) == 'a' && *(cursor + 4) == 'm' + && *(cursor + 5) == 'i' && *(cursor + 6) == 'c' && *(cursor + 7) == '_' && *(cursor + 8) == 'c' + && *(cursor + 9) == 'a' && *(cursor + 10) == 's' && *(cursor + 11) == 't') { - case 'd': - if (*(cursor + 1) == 'y' && - *(cursor + 2) == 'n' && - *(cursor + 3) == 'a' && - *(cursor + 4) == 'm' && - *(cursor + 5) == 'i' && - *(cursor + 6) == 'c' && - *(cursor + 7) == '_' && - *(cursor + 8) == 'c' && - *(cursor + 9) == 'a' && - *(cursor + 10) == 's' && - *(cursor + 11) == 't') - { - token_stream[(int) index++].kind = Token_dynamic_cast; - return; - } - break; - - } - token_stream[(int) index++].kind = Token_identifier; + token_stream[(int)index++].kind = Token_dynamic_cast; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword13() { - switch (*cursor) + switch (*cursor) { + case '_': + if (*(cursor + 1) == '_' && *(cursor + 2) == 'a' && *(cursor + 3) == 't' && *(cursor + 4) == 't' + && *(cursor + 5) == 'r' && *(cursor + 6) == 'i' && *(cursor + 7) == 'b' && *(cursor + 8) == 'u' + && *(cursor + 9) == 't' && *(cursor + 10) == 'e' && *(cursor + 11) == '_' && *(cursor + 12) == '_') { - case '_': - if (*(cursor + 1) == '_' && - *(cursor + 2) == 'a' && - *(cursor + 3) == 't' && - *(cursor + 4) == 't' && - *(cursor + 5) == 'r' && - *(cursor + 6) == 'i' && - *(cursor + 7) == 'b' && - *(cursor + 8) == 'u' && - *(cursor + 9) == 't' && - *(cursor + 10) == 'e' && - *(cursor + 11) == '_' && - *(cursor + 12) == '_') - { - token_stream[(int) index++].kind = Token___attribute__; - return; - } - break; - } - token_stream[(int) index++].kind = Token_identifier; + token_stream[(int)index++].kind = Token___attribute__; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword14() { - switch (*cursor) - { - case 'k': - if (*(cursor + 1) == '_' && - *(cursor + 2) == 'd' && - *(cursor + 3) == 'c' && - *(cursor + 4) == 'o' && - *(cursor + 5) == 'p' && - *(cursor + 6) == '_' && - *(cursor + 7) == 's' && - *(cursor + 8) == 'i' && - *(cursor + 9) == 'g' && - *(cursor + 10) == 'n' && - *(cursor + 11) == 'a' && - *(cursor + 12) == 'l' && - *(cursor + 13) == 's') - { - token_stream[(int) index++].kind = Token_k_dcop_signals; - return; - } - break; - } - token_stream[(int) index++].kind = Token_identifier; + switch (*cursor) { + case 'k': + if (*(cursor + 1) == '_' && *(cursor + 2) == 'd' && *(cursor + 3) == 'c' && *(cursor + 4) == 'o' + && *(cursor + 5) == 'p' && *(cursor + 6) == '_' && *(cursor + 7) == 's' && *(cursor + 8) == 'i' + && *(cursor + 9) == 'g' && *(cursor + 10) == 'n' && *(cursor + 11) == 'a' && *(cursor + 12) == 'l' + && *(cursor + 13) == 's') + { + token_stream[(int)index++].kind = Token_k_dcop_signals; + return; + } + break; + } + token_stream[(int)index++].kind = Token_identifier; } void Lexer::scanKeyword16() { - switch (*cursor) - { - case 'r': - if (*(cursor + 1) == 'e' && - *(cursor + 2) == 'i' && - *(cursor + 3) == 'n' && - *(cursor + 4) == 't' && - *(cursor + 5) == 'e' && - *(cursor + 6) == 'r' && - *(cursor + 7) == 'p' && - *(cursor + 8) == 'r' && - *(cursor + 9) == 'e' && - *(cursor + 10) == 't' && - *(cursor + 11) == '_' && - *(cursor + 12) == 'c' && - *(cursor + 13) == 'a' && - *(cursor + 14) == 's' && - *(cursor + 15) == 't') - { - token_stream[(int) index++].kind = Token_reinterpret_cast; - return; - } - break; - } - - token_stream[(int) index++].kind = Token_identifier; + switch (*cursor) { + case 'r': + if (*(cursor + 1) == 'e' && *(cursor + 2) == 'i' && *(cursor + 3) == 'n' && *(cursor + 4) == 't' + && *(cursor + 5) == 'e' && *(cursor + 6) == 'r' && *(cursor + 7) == 'p' && *(cursor + 8) == 'r' + && *(cursor + 9) == 'e' && *(cursor + 10) == 't' && *(cursor + 11) == '_' && *(cursor + 12) == 'c' + && *(cursor + 13) == 'a' && *(cursor + 14) == 's' && *(cursor + 15) == 't') + { + token_stream[(int)index++].kind = Token_reinterpret_cast; + return; + } + break; + } + + token_stream[(int)index++].kind = Token_identifier; } // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/generator/parser/lexer.h b/generator/parser/lexer.h index 1166609e7..33cfe6b41 100644 --- a/generator/parser/lexer.h +++ b/generator/parser/lexer.h @@ -39,15 +39,14 @@ ** ****************************************************************************/ - #ifndef LEXER_H -#define LEXER_H + #define LEXER_H -#include "symbol.h" + #include "symbol.h" -#include -#include -#include + #include + #include + #include struct NameSymbol; class Lexer; @@ -61,11 +60,10 @@ class Token int kind; std::size_t position; std::size_t size; - char const *text; + char const* text; - union - { - const NameSymbol *symbol; + union { + const NameSymbol* symbol; std::size_t right_brace; } extra; }; @@ -73,43 +71,40 @@ class Token class LocationTable { private: - LocationTable(const LocationTable &source); - void operator = (const LocationTable &source); + LocationTable(const LocationTable& source); + void operator=(const LocationTable& source); public: inline LocationTable(std::size_t size = 1024) - : lines(0), - line_count(0), - current_line(0) + : lines(0) + , line_count(0) + , current_line(0) { resize(size); } - inline ~LocationTable() - { - free(lines); - } + inline ~LocationTable() { free(lines); } - inline std::size_t size() const - { return line_count; } + inline std::size_t size() const { return line_count; } void resize(std::size_t size) { Q_ASSERT(size > 0); - lines = (std::size_t*) ::realloc(lines, sizeof(std::size_t) * size); + lines = (std::size_t*)::realloc(lines, sizeof(std::size_t) * size); line_count = size; } - void positionAt(std::size_t offset, int *line, int *column) const - { positionAt(offset, (int) current_line, line, column); } + void positionAt(std::size_t offset, int* line, int* column) const + { + positionAt(offset, (int)current_line, line, column); + } - void positionAt(std::size_t offset, int max_line, int *line, int *column) const; + void positionAt(std::size_t offset, int max_line, int* line, int* column) const; - inline std::size_t &operator[](int index) - { return lines[index]; } + inline std::size_t& operator[](int index) { return lines[index]; } private: - std::size_t *lines; + std::size_t* lines; std::size_t line_count; std::size_t current_line; @@ -119,63 +114,51 @@ class LocationTable class TokenStream { private: - TokenStream(const TokenStream &); - void operator = (const TokenStream &); + TokenStream(const TokenStream&); + void operator=(const TokenStream&); public: inline TokenStream(std::size_t size = 1024) - : tokens(0), - index(0), - token_count(0) + : tokens(0) + , index(0) + , token_count(0) { resize(size); } - inline ~TokenStream() - { ::free(tokens); } + inline ~TokenStream() { ::free(tokens); } - inline std::size_t size() const - { return token_count; } + inline std::size_t size() const { return token_count; } - inline std::size_t cursor() const - { return index; } + inline std::size_t cursor() const { return index; } - inline void rewind(std::size_t i) - { index = i; } + inline void rewind(std::size_t i) { index = i; } void resize(std::size_t size) { Q_ASSERT(size > 0); - tokens = (Token*) ::realloc(tokens, sizeof(Token) * size); + tokens = (Token*)::realloc(tokens, sizeof(Token) * size); token_count = size; } - inline std::size_t nextToken() - { return index++; } + inline std::size_t nextToken() { return index++; } - inline int lookAhead(std::size_t i = 0) const - { return tokens[index + i].kind; } + inline int lookAhead(std::size_t i = 0) const { return tokens[index + i].kind; } - inline int kind(std::size_t i) const - { return tokens[i].kind; } + inline int kind(std::size_t i) const { return tokens[i].kind; } - inline std::size_t position(std::size_t i) const - { return tokens[i].position; } + inline std::size_t position(std::size_t i) const { return tokens[i].position; } - inline const NameSymbol *symbol(std::size_t i) const - { return tokens[i].extra.symbol; } + inline const NameSymbol* symbol(std::size_t i) const { return tokens[i].extra.symbol; } - inline std::size_t matchingBrace(std::size_t i) const - { return tokens[i].extra.right_brace; } + inline std::size_t matchingBrace(std::size_t i) const { return tokens[i].extra.right_brace; } - inline Token &operator[](std::size_t i) - { return tokens[i]; } + inline Token& operator[](std::size_t i) { return tokens[i]; } - inline const Token &token(std::size_t i) const - { return tokens[i]; } + inline const Token& token(std::size_t i) const { return tokens[i]; } private: - Token *tokens; + Token* tokens; std::size_t index; std::size_t token_count; @@ -185,43 +168,44 @@ class TokenStream class LocationManager { - LocationManager(LocationManager const &__other); - void operator = (LocationManager const &__other); + LocationManager(LocationManager const& __other); + void operator=(LocationManager const& __other); public: - LocationManager (TokenStream &__token_stream, - LocationTable &__location_table, - LocationTable &__line_table): - token_stream (__token_stream), - location_table (__location_table), - line_table (__line_table) {} + LocationManager(TokenStream& __token_stream, LocationTable& __location_table, LocationTable& __line_table) + : token_stream(__token_stream) + , location_table(__location_table) + , line_table(__line_table) + { + } - void positionAt(std::size_t offset, int *line, int *column, - QString *filename) const; + void positionAt(std::size_t offset, int* line, int* column, QString* filename) const; - void extract_line(int offset, int *line, QString *filename) const; + void extract_line(int offset, int* line, QString* filename) const; - TokenStream &token_stream; - LocationTable &location_table; - LocationTable &line_table; + TokenStream& token_stream; + LocationTable& location_table; + LocationTable& line_table; }; class Lexer { public: - Lexer(LocationManager &__location, Control *__control): - _M_location(__location), - token_stream(_M_location.token_stream), - location_table(_M_location.location_table), - line_table(_M_location.line_table), - control(__control) {} + Lexer(LocationManager& __location, Control* __control) + : _M_location(__location) + , token_stream(_M_location.token_stream) + , location_table(_M_location.location_table) + , line_table(_M_location.line_table) + , control(__control) + { + } - void tokenize(const char *contents, std::size_t size); + void tokenize(const char* contents, std::size_t size); - LocationManager &_M_location; - TokenStream &token_stream; - LocationTable &location_table; - LocationTable &line_table; + LocationManager& _M_location; + TokenStream& token_stream; + LocationTable& location_table; + LocationTable& line_table; private: void reportError(const QString& msg); @@ -286,10 +270,10 @@ class Lexer void scan_EOF(); private: - Control *control; - const unsigned char *cursor; - const unsigned char *begin_buffer; - const unsigned char *end_buffer; + Control* control; + const unsigned char* cursor; + const unsigned char* begin_buffer; + const unsigned char* end_buffer; std::size_t index; static scan_fun_ptr s_scan_table[]; diff --git a/generator/parser/list.cpp b/generator/parser/list.cpp index 59d316054..86bbb62ec 100644 --- a/generator/parser/list.cpp +++ b/generator/parser/list.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include "list.h" // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/generator/parser/list.h b/generator/parser/list.h index c7ef9e285..a70cd2f21 100644 --- a/generator/parser/list.h +++ b/generator/parser/list.h @@ -39,22 +39,20 @@ ** ****************************************************************************/ - #ifndef FASTLIST_H -#define FASTLIST_H + #define FASTLIST_H -#include "smallobject.h" + #include "smallobject.h" -template -struct ListNode -{ +template +struct ListNode { Tp element; int index; - mutable const ListNode *next; + mutable const ListNode* next; - static ListNode *create(const Tp &element, pool *p) + static ListNode* create(const Tp& element, pool* p) { - ListNode *node = new (p->allocate(sizeof(ListNode))) ListNode(); + ListNode* node = new (p->allocate(sizeof(ListNode))) ListNode(); node->element = element; node->index = 0; node->next = node; @@ -62,9 +60,9 @@ struct ListNode return node; } - static ListNode *create(const ListNode *n1, const Tp &element, pool *p) + static ListNode* create(const ListNode* n1, const Tp& element, pool* p) { - ListNode *n2 = ListNode::create(element, p); + ListNode* n2 = ListNode::create(element, p); n2->index = n1->index + 1; n2->next = n1->next; @@ -73,29 +71,26 @@ struct ListNode return n2; } - inline ListNode() { } + inline ListNode() {} - inline const ListNode *at(int index) const + inline const ListNode* at(int index) const { - const ListNode *node = this; + const ListNode* node = this; while (index != node->index) node = node->next; return node; } - inline bool hasNext() const - { return index < next->index; } + inline bool hasNext() const { return index < next->index; } - inline int count() const - { return 1 + toBack()->index; } + inline int count() const { return 1 + toBack()->index; } - inline const ListNode *toFront() const - { return toBack()->next; } + inline const ListNode* toFront() const { return toBack()->next; } - inline const ListNode *toBack() const + inline const ListNode* toBack() const { - const ListNode *node = this; + const ListNode* node = this; while (node->hasNext()) node = node->next; @@ -103,9 +98,8 @@ struct ListNode } }; -template -inline const ListNode *snoc(const ListNode *list, - const Tp &element, pool *p) +template +inline const ListNode* snoc(const ListNode* list, const Tp& element, pool* p) { if (!list) return ListNode::create(element, p); @@ -116,4 +110,3 @@ inline const ListNode *snoc(const ListNode *list, #endif // FASTLIST_H // kate: space-indent on; indent-width 2; replace-tabs on; - diff --git a/generator/parser/name_compiler.cpp b/generator/parser/name_compiler.cpp index ba5fbcd21..42bdccde0 100644 --- a/generator/parser/name_compiler.cpp +++ b/generator/parser/name_compiler.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include "name_compiler.h" #include "type_compiler.h" #include "declarator_compiler.h" @@ -49,25 +48,26 @@ #include -NameCompiler::NameCompiler(Binder *binder) - : _M_binder (binder), _M_token_stream (binder->tokenStream ()) +NameCompiler::NameCompiler(Binder* binder) + : _M_binder(binder) + , _M_token_stream(binder->tokenStream()) { } QString NameCompiler::decode_operator(std::size_t index) const { - const Token &tk = _M_token_stream->token((int) index); - return QString::fromUtf8(&tk.text[tk.position], (int) tk.size); + const Token& tk = _M_token_stream->token((int)index); + return QString::fromUtf8(&tk.text[tk.position], (int)tk.size); } -QString NameCompiler::internal_run(AST *node) +QString NameCompiler::internal_run(AST* node) { _M_name.clear(); visit(node); return name(); } -void NameCompiler::visitUnqualifiedName(UnqualifiedNameAST *node) +void NameCompiler::visitUnqualifiedName(UnqualifiedNameAST* node) { QString tmp_name; @@ -77,85 +77,75 @@ void NameCompiler::visitUnqualifiedName(UnqualifiedNameAST *node) if (node->id) tmp_name += _M_token_stream->symbol(node->id)->as_string(); - if (OperatorFunctionIdAST *op_id = node->operator_id) - { + if (OperatorFunctionIdAST* op_id = node->operator_id) { #if defined(__GNUC__) -#pragma GCC warning "NameCompiler::visitUnqualifiedName() -- implement me" + #pragma GCC warning "NameCompiler::visitUnqualifiedName() -- implement me" #endif - if (op_id->op && op_id->op->op) - { - tmp_name += QLatin1String("operator"); - tmp_name += decode_operator(op_id->op->op); - if (op_id->op->close) - tmp_name += decode_operator(op_id->op->close); - } - else if (op_id->type_specifier) - { + if (op_id->op && op_id->op->op) { + tmp_name += QLatin1String("operator"); + tmp_name += decode_operator(op_id->op->op); + if (op_id->op->close) + tmp_name += decode_operator(op_id->op->close); + } else if (op_id->type_specifier) { #if defined(__GNUC__) -#pragma GCC warning "don't use an hardcoded string as cast' name" + #pragma GCC warning "don't use an hardcoded string as cast' name" #endif - Token const &tk = _M_token_stream->token ((int) op_id->start_token); - Token const &end_tk = _M_token_stream->token ((int) op_id->end_token); - tmp_name += QString::fromLatin1 (&tk.text[tk.position], - (int) (end_tk.position - tk.position)).trimmed (); - } + Token const& tk = _M_token_stream->token((int)op_id->start_token); + Token const& end_tk = _M_token_stream->token((int)op_id->end_token); + tmp_name += QString::fromLatin1(&tk.text[tk.position], (int)(end_tk.position - tk.position)).trimmed(); } + } _M_name += tmp_name; - if (node->template_arguments) - { - // ### cleanup - _M_name.last() += QLatin1String("<"); - visitNodes(this, node->template_arguments); - _M_name.last().truncate(_M_name.last().length() - 1); // remove the last ',' - _M_name.last() += QLatin1String(">"); - } - + if (node->template_arguments) { + // ### cleanup + _M_name.last() += QLatin1String("<"); + visitNodes(this, node->template_arguments); + _M_name.last().truncate(_M_name.last().length() - 1); // remove the last ',' + _M_name.last() += QLatin1String(">"); + } } -void NameCompiler::visitTemplateArgument(TemplateArgumentAST *node) +void NameCompiler::visitTemplateArgument(TemplateArgumentAST* node) { - if (node->type_id && node->type_id->type_specifier) - { - TypeCompiler type_cc(_M_binder); - type_cc.run(node->type_id->type_specifier); - - DeclaratorCompiler decl_cc(_M_binder); - decl_cc.run(node->type_id->declarator); - - if (type_cc.isConstant()) - _M_name.last() += "const "; - - QStringList q = type_cc.qualifiedName (); - - if (q.count () == 1) - { -#if defined (RXX_RESOLVE_TYPEDEF) // ### it'll break :( - TypeInfo tp; - tp.setQualifiedName (q); - tp = TypeInfo::resolveType (tp, _M_binder->currentScope ()->toItem ()); - q = tp.qualifiedName (); -#endif + if (node->type_id && node->type_id->type_specifier) { + TypeCompiler type_cc(_M_binder); + type_cc.run(node->type_id->type_specifier); - if (CodeModelItem item = _M_binder->model ()->findItem (q, _M_binder->currentScope ())) - { - if (item->name () == q.last ()) - q = item->qualifiedName (); - } - } + DeclaratorCompiler decl_cc(_M_binder); + decl_cc.run(node->type_id->declarator); - _M_name.last() += q.join("::"); + if (type_cc.isConstant()) + _M_name.last() += "const "; - if (decl_cc.isRvalueReference()) - _M_name.last() += "&&"; - else if (decl_cc.isReference()) - _M_name.last() += "&"; - if (decl_cc.indirection()) - _M_name.last() += QString(decl_cc.indirection(), '*'); + QStringList q = type_cc.qualifiedName(); - _M_name.last() += QLatin1String(","); + if (q.count() == 1) { +#if defined(RXX_RESOLVE_TYPEDEF) // ### it'll break :( + TypeInfo tp; + tp.setQualifiedName(q); + tp = TypeInfo::resolveType(tp, _M_binder->currentScope()->toItem()); + q = tp.qualifiedName(); +#endif + + if (CodeModelItem item = _M_binder->model()->findItem(q, _M_binder->currentScope())) { + if (item->name() == q.last()) + q = item->qualifiedName(); + } } + + _M_name.last() += q.join("::"); + + if (decl_cc.isRvalueReference()) + _M_name.last() += "&&"; + else if (decl_cc.isReference()) + _M_name.last() += "&"; + if (decl_cc.indirection()) + _M_name.last() += QString(decl_cc.indirection(), '*'); + + _M_name.last() += QLatin1String(","); + } } // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/generator/parser/name_compiler.h b/generator/parser/name_compiler.h index 5eb8507d4..5c847c4eb 100644 --- a/generator/parser/name_compiler.h +++ b/generator/parser/name_compiler.h @@ -39,37 +39,36 @@ ** ****************************************************************************/ - #ifndef NAME_COMPILER_H -#define NAME_COMPILER_H + #define NAME_COMPILER_H -#include "default_visitor.h" -#include + #include "default_visitor.h" + #include class TokenStream; class Binder; -class NameCompiler: protected DefaultVisitor +class NameCompiler : protected DefaultVisitor { public: - NameCompiler(Binder *binder); + NameCompiler(Binder* binder); - void run(NameAST *node) { internal_run(node); } - void run(UnqualifiedNameAST *node) { internal_run(node); } + void run(NameAST* node) { internal_run(node); } + void run(UnqualifiedNameAST* node) { internal_run(node); } QString name() const { return _M_name.join("::"); } QStringList qualifiedName() const { return _M_name; } protected: - virtual void visitUnqualifiedName(UnqualifiedNameAST *node); - virtual void visitTemplateArgument(TemplateArgumentAST *node); + virtual void visitUnqualifiedName(UnqualifiedNameAST* node); + virtual void visitTemplateArgument(TemplateArgumentAST* node); - QString internal_run(AST *node); + QString internal_run(AST* node); QString decode_operator(std::size_t index) const; private: - Binder *_M_binder; - TokenStream *_M_token_stream; + Binder* _M_binder; + TokenStream* _M_token_stream; QStringList _M_name; }; diff --git a/generator/parser/parser.cpp b/generator/parser/parser.cpp index ed9bd48cc..9924649e6 100644 --- a/generator/parser/parser.cpp +++ b/generator/parser/parser.cpp @@ -41,7 +41,6 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ - // c++ support #include "parser.h" #include "tokens.h" @@ -53,7 +52,7 @@ #include #if defined(_MSC_VER) || defined(__GNUC__) -#include + #include std::string _joinLocation(const char* name, int line) { @@ -62,57 +61,53 @@ std::string _joinLocation(const char* name, int line) return ss.str(); } -#define PARSER_METHOD_NAME _joinLocation(__FUNCTION__, __LINE__).c_str() -#else -#define PARSER_METHOD_NAME "" -#endif - + #define PARSER_METHOD_NAME _joinLocation(__FUNCTION__, __LINE__).c_str() +#else + #define PARSER_METHOD_NAME "" +#endif #define SYNTAX_ERROR() syntaxError(PARSER_METHOD_NAME) #define ADVANCE(tk, descr) \ -{ \ - if (token_stream.lookAhead() != tk) { \ + { \ + if (token_stream.lookAhead() != tk) { \ tokenRequiredError(tk, PARSER_METHOD_NAME); \ return false; \ - } \ - nextToken(); \ -} + } \ + nextToken(); \ + } #define ADVANCE_NR(tk, descr) \ do { \ if (token_stream.lookAhead() != tk) { \ tokenRequiredError(tk, PARSER_METHOD_NAME); \ - } \ - else \ - nextToken(); \ + } else \ + nextToken(); \ } while (0) #define CHECK(tk) \ do { \ if (token_stream.lookAhead() != tk) { \ - return false; \ + return false; \ } \ nextToken(); \ } while (0) #define UPDATE_POS(_node, start, end) \ do { \ - (_node)->start_token = start; \ - (_node)->end_token = end; \ + (_node)->start_token = start; \ + (_node)->end_token = end; \ } while (0) -Parser::Parser(Control *c) - : _M_location(token_stream, location_table, line_table), - control(c), - lexer(_M_location, control) +Parser::Parser(Control* c) + : _M_location(token_stream, location_table, line_table) + , control(c) + , lexer(_M_location, control) { _M_block_errors = false; } -Parser::~Parser() -{ -} +Parser::~Parser() {} void Parser::nextToken() { @@ -126,34 +121,33 @@ void Parser::rewind(std::size_t pos) keepTrackDebug(); } -TranslationUnitAST *Parser::parse(const char *contents, - std::size_t size, pool *p) +TranslationUnitAST* Parser::parse(const char* contents, std::size_t size, pool* p) { _M_block_errors = false; _M_pool = p; lexer.tokenize(contents, size); nextToken(); // skip the first token - Lexer *oldLexer = control->changeLexer (&lexer); - Parser *oldParser = control->changeParser (this); + Lexer* oldLexer = control->changeLexer(&lexer); + Parser* oldParser = control->changeParser(this); - TranslationUnitAST *ast = 0; + TranslationUnitAST* ast = 0; parseTranslationUnit(ast); - control->changeLexer (oldLexer); - control->changeParser (oldParser); + control->changeLexer(oldLexer); + control->changeParser(oldParser); return ast; } -bool Parser::parseWinDeclSpec(WinDeclSpecAST *&node) +bool Parser::parseWinDeclSpec(WinDeclSpecAST*& node) { if (token_stream.lookAhead() != Token_identifier) return false; std::size_t start = token_stream.cursor(); - const NameSymbol *name_symbol = token_stream.symbol(token_stream.cursor()); + const NameSymbol* name_symbol = token_stream.symbol(token_stream.cursor()); QString name = name_symbol->as_string(); if (name != QLatin1String("__declspec")) return false; @@ -211,41 +205,35 @@ void Parser::syntaxError(const char* functionName) void Parser::reportError(const QString& msg, const char* functionName) { - if (!_M_block_errors) - { - int line, column; - QString fileName; - - std::size_t tok = token_stream.cursor(); - location().positionAt(token_stream.position(tok), - &line, &column, &fileName); - - Control::ErrorMessage errmsg; - errmsg.setLine(line + 1); - errmsg.setColumn(column); - errmsg.setFileName(fileName); - errmsg.setMessage(QLatin1String("** PARSER ERROR ") + msg); - if (functionName && *functionName) { - errmsg.setMessage(errmsg.message() + " in " + functionName); - } + if (!_M_block_errors) { + int line, column; + QString fileName; - control->reportError(errmsg); + std::size_t tok = token_stream.cursor(); + location().positionAt(token_stream.position(tok), &line, &column, &fileName); + + Control::ErrorMessage errmsg; + errmsg.setLine(line + 1); + errmsg.setColumn(column); + errmsg.setFileName(fileName); + errmsg.setMessage(QLatin1String("** PARSER ERROR ") + msg); + if (functionName && *functionName) { + errmsg.setMessage(errmsg.message() + " in " + functionName); } + + control->reportError(errmsg); + } } void Parser::keepTrackDebug() { #ifndef NDEBUG std::size_t tok = token_stream.cursor(); - location().positionAt(token_stream.position(tok), - &_currentLine, &_currentColumn, &_currentFile); + location().positionAt(token_stream.position(tok), &_currentLine, &_currentColumn, &_currentFile); _currentToken = token_name(token_stream.lookAhead()); - if (token_stream.lookAhead() == Token_identifier) - { + if (token_stream.lookAhead() == Token_identifier) { _currentSymbol = token_stream.symbol(tok)->as_string(); - } - else - { + } else { _currentSymbol = ""; } #endif @@ -254,13 +242,10 @@ void Parser::keepTrackDebug() bool Parser::skipAlignas() { // we are currently not interested in alignas, so we just skip it - if (token_stream.lookAhead() == Token_alignas) - { + if (token_stream.lookAhead() == Token_alignas) { nextToken(); - if (token_stream.lookAhead() == '(') - { - if (skip('(', ')')) - { + if (token_stream.lookAhead() == '(') { + if (skip('(', ')')) { nextToken(); } } @@ -273,23 +258,19 @@ bool Parser::skipAttributes() { bool any = false; while (true) { - if (token_stream.lookAhead() == Token___attribute__) - { + if (token_stream.lookAhead() == Token___attribute__) { parse_Attribute__(); any = true; - } - else if (token_stream.lookAhead() == '[' && token_stream.lookAhead(1) == '[') - { + } else if (token_stream.lookAhead() == '[' && token_stream.lookAhead(1) == '[') { nextToken(); - while (true) - { + while (true) { nextToken(); int tk = token_stream.lookAhead(); - if (tk == Token_EOF) - { + if (tk == Token_EOF) { break; - } - else if (tk == ']' && token_stream.lookAhead(1) == ']') // this has no separate token because "]]" can occur in other contexts + } else if (tk == ']' + && token_stream.lookAhead(1) + == ']') // this has no separate token because "]]" can occur in other contexts { nextToken(); nextToken(); @@ -297,9 +278,7 @@ bool Parser::skipAttributes() } } any = true; - } - else - { + } else { break; } } @@ -308,127 +287,122 @@ bool Parser::skipAttributes() bool Parser::skipUntil(int token) { - while (token_stream.lookAhead()) - { - if (token_stream.lookAhead() == token) - return true; + while (token_stream.lookAhead()) { + if (token_stream.lookAhead() == token) + return true; - nextToken(); - } + nextToken(); + } return false; } bool Parser::skipUntilDeclaration() { - while (token_stream.lookAhead()) - { + while (token_stream.lookAhead()) { - switch(token_stream.lookAhead()) - { - case ';': - case '~': - case Token_scope: - case Token_identifier: - case Token_operator: - case Token_char: - case Token_wchar_t: - case Token_bool: - case Token_short: - case Token_int: - case Token_long: - case Token_signed: - case Token_unsigned: - case Token_float: - case Token_double: - case Token_void: - case Token_extern: - case Token_namespace: - case Token_using: - case Token_typedef: - case Token_asm: - case Token_template: - case Token_export: - - case Token_const: // cv - case Token_constexpr: // cv - case Token_volatile: // cv - case Token_mutable: // cv - - case Token_public: - case Token_protected: - case Token_private: - case Token_signals: // Qt - case Token_slots: // Qt - return true; + switch (token_stream.lookAhead()) { + case ';': + case '~': + case Token_scope: + case Token_identifier: + case Token_operator: + case Token_char: + case Token_wchar_t: + case Token_bool: + case Token_short: + case Token_int: + case Token_long: + case Token_signed: + case Token_unsigned: + case Token_float: + case Token_double: + case Token_void: + case Token_extern: + case Token_namespace: + case Token_using: + case Token_typedef: + case Token_asm: + case Token_template: + case Token_export: - case Token_decltype: - case Token___typeof: - reportError("C++11 decltype/__typeof(id|expression) not handled"); - return true; + case Token_const: // cv + case Token_constexpr: // cv + case Token_volatile: // cv + case Token_mutable: // cv - default: - nextToken(); - } + case Token_public: + case Token_protected: + case Token_private: + case Token_signals: // Qt + case Token_slots: // Qt + return true; + + case Token_decltype: + case Token___typeof: + reportError("C++11 decltype/__typeof(id|expression) not handled"); + return true; + + default: + nextToken(); } + } return false; } bool Parser::skipUntilStatement() { - while (token_stream.lookAhead()) - { - switch(token_stream.lookAhead()) - { - case ';': - case '{': - case '}': - case Token_const: - case Token_constexpr: - case Token_decltype: - case Token___typeof: - case Token_volatile: - case Token_mutable: - case Token_identifier: - case Token_case: - case Token_default: - case Token_if: - case Token_switch: - case Token_while: - case Token_do: - case Token_for: - case Token_break: - case Token_continue: - case Token_return: - case Token_goto: - case Token_try: - case Token_catch: - case Token_throw: - case Token_char: - case Token_wchar_t: - case Token_bool: - case Token_short: - case Token_int: - case Token_long: - case Token_signed: - case Token_unsigned: - case Token_float: - case Token_double: - case Token_void: - case Token_class: - case Token_struct: - case Token_union: - case Token_enum: - case Token_scope: - case Token_template: - case Token_using: - return true; + while (token_stream.lookAhead()) { + switch (token_stream.lookAhead()) { + case ';': + case '{': + case '}': + case Token_const: + case Token_constexpr: + case Token_decltype: + case Token___typeof: + case Token_volatile: + case Token_mutable: + case Token_identifier: + case Token_case: + case Token_default: + case Token_if: + case Token_switch: + case Token_while: + case Token_do: + case Token_for: + case Token_break: + case Token_continue: + case Token_return: + case Token_goto: + case Token_try: + case Token_catch: + case Token_throw: + case Token_char: + case Token_wchar_t: + case Token_bool: + case Token_short: + case Token_int: + case Token_long: + case Token_signed: + case Token_unsigned: + case Token_float: + case Token_double: + case Token_void: + case Token_class: + case Token_struct: + case Token_union: + case Token_enum: + case Token_scope: + case Token_template: + case Token_using: + return true; - default: - nextToken(); - } + default: + nextToken(); } + } return false; } @@ -436,72 +410,63 @@ bool Parser::skipUntilStatement() bool Parser::skip(int l, int r) { int count = 0; - while (token_stream.lookAhead()) - { - int tk = token_stream.lookAhead(); - - if (tk == l) - ++count; - else if (tk == r) - --count; - else if (l != '{' && (tk == '{' || tk == '}' || tk == ';')) - return false; + while (token_stream.lookAhead()) { + int tk = token_stream.lookAhead(); + + if (tk == l) + ++count; + else if (tk == r) + --count; + else if (l != '{' && (tk == '{' || tk == '}' || tk == ';')) + return false; - if (count == 0) - return true; + if (count == 0) + return true; - nextToken(); - } + nextToken(); + } return false; } -bool Parser::parseName(NameAST *&node, bool acceptTemplateId) +bool Parser::parseName(NameAST*& node, bool acceptTemplateId) { std::size_t start = token_stream.cursor(); - WinDeclSpecAST *winDeclSpec = 0; - while (skipAlignas() || (!winDeclSpec && parseWinDeclSpec(winDeclSpec))) - { + WinDeclSpecAST* winDeclSpec = 0; + while (skipAlignas() || (!winDeclSpec && parseWinDeclSpec(winDeclSpec))) { ; } - NameAST *ast = CreateNode(_M_pool); + NameAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == Token_scope) - { - ast->global = true; - nextToken(); - } + if (token_stream.lookAhead() == Token_scope) { + ast->global = true; + nextToken(); + } std::size_t idx = token_stream.cursor(); - while (true) - { - UnqualifiedNameAST *n = 0; - if (!parseUnqualifiedName(n, acceptTemplateId)) - return false; + while (true) { + UnqualifiedNameAST* n = 0; + if (!parseUnqualifiedName(n, acceptTemplateId)) + return false; - if (token_stream.lookAhead() == Token_scope) - { - nextToken(); + if (token_stream.lookAhead() == Token_scope) { + nextToken(); - ast->qualified_names - = snoc(ast->qualified_names, n, _M_pool); + ast->qualified_names = snoc(ast->qualified_names, n, _M_pool); - if (token_stream.lookAhead() == Token_template) - { - /// skip optional template #### @todo CHECK - nextToken(); - } - } - else - { - Q_ASSERT(n != 0); - ast->unqualified_name = n; - break; - } + if (token_stream.lookAhead() == Token_template) { + /// skip optional template #### @todo CHECK + nextToken(); + } + } else { + Q_ASSERT(n != 0); + ast->unqualified_name = n; + break; } + } if (idx == token_stream.cursor()) return false; @@ -512,33 +477,27 @@ bool Parser::parseName(NameAST *&node, bool acceptTemplateId) return true; } -bool Parser::parseTranslationUnit(TranslationUnitAST *&node) +bool Parser::parseTranslationUnit(TranslationUnitAST*& node) { std::size_t start = token_stream.cursor(); - TranslationUnitAST *ast = CreateNode(_M_pool); - - while (token_stream.lookAhead()) - { - std::size_t startDecl = token_stream.cursor(); + TranslationUnitAST* ast = CreateNode(_M_pool); + + while (token_stream.lookAhead()) { + std::size_t startDecl = token_stream.cursor(); + + DeclarationAST* declaration = 0; + if (parseDeclaration(declaration)) { + ast->declarations = snoc(ast->declarations, declaration, _M_pool); + } else { + // error recovery + if (startDecl == token_stream.cursor()) { + // skip at least one token + nextToken(); + } - DeclarationAST *declaration = 0; - if (parseDeclaration(declaration)) - { - ast->declarations = - snoc(ast->declarations, declaration, _M_pool); - } - else - { - // error recovery - if (startDecl == token_stream.cursor()) - { - // skip at least one token - nextToken(); - } - - skipUntilDeclaration(); - } + skipUntilDeclaration(); } + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -546,117 +505,106 @@ bool Parser::parseTranslationUnit(TranslationUnitAST *&node) return true; } -bool Parser::parseDeclaration(DeclarationAST *&node) +bool Parser::parseDeclaration(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); - switch(token_stream.lookAhead()) - { - case ';': - // ignore ellipse in constructs like - // using T1 = T2...>; - case Token_ellipsis: - nextToken(); - return true; + switch (token_stream.lookAhead()) { + case ';': + // ignore ellipse in constructs like + // using T1 = T2...>; + case Token_ellipsis: + nextToken(); + return true; - case Token_extern: - return parseLinkageSpecification(node); + case Token_extern: + return parseLinkageSpecification(node); - case Token_namespace: - return parseNamespace(node); + case Token_namespace: + return parseNamespace(node); - case Token_using: - return parseUsing(node); + case Token_using: + return parseUsing(node); - case Token_typedef: - return parseTypedef(node); + case Token_typedef: + return parseTypedef(node); - case Token_asm: - return parseAsmDefinition(node); + case Token_asm: + return parseAsmDefinition(node); - case Token_Q_ENUMS: - return parseQ_ENUMS(node); + case Token_Q_ENUMS: + return parseQ_ENUMS(node); - case Token_Q_ENUM: - return parseQ_ENUM(node); + case Token_Q_ENUM: + return parseQ_ENUM(node); - case Token_template: - case Token_export: - return parseTemplateDeclaration(node); + case Token_template: + case Token_export: + return parseTemplateDeclaration(node); - case Token_inline: - if (token_stream.lookAhead(1) == Token_namespace) - { - nextToken(); - // handle like a normal namespace for now - return parseNamespace(node); - } - // else fallthrough - default: - { - skipAttributes(); + case Token_inline: + if (token_stream.lookAhead(1) == Token_namespace) { + nextToken(); + // handle like a normal namespace for now + return parseNamespace(node); + } + // else fallthrough + default: + { + skipAttributes(); - const ListNode *cv = 0; - const ListNode* storageSpec = 0; - // consume all qualifiers/specifiers - while (parseCvQualify(cv) || parseStorageClassSpecifier(storageSpec)) - { - ; - } + const ListNode* cv = 0; + const ListNode* storageSpec = 0; + // consume all qualifiers/specifiers + while (parseCvQualify(cv) || parseStorageClassSpecifier(storageSpec)) { + ; + } - TypeSpecifierAST *spec = 0; - if (parseEnumSpecifier(spec) - || parseClassSpecifier(spec) - || parseForwardDeclarationSpecifier(spec)) - { - parseCvQualify(cv); + TypeSpecifierAST* spec = 0; + if (parseEnumSpecifier(spec) || parseClassSpecifier(spec) || parseForwardDeclarationSpecifier(spec)) { + parseCvQualify(cv); - spec->cv = cv; + spec->cv = cv; - const ListNode *declarators = 0; - parseInitDeclaratorList(declarators); - ADVANCE(';', ";"); + const ListNode* declarators = 0; + parseInitDeclaratorList(declarators); + ADVANCE(';', ";"); - SimpleDeclarationAST *ast = - CreateNode(_M_pool); + SimpleDeclarationAST* ast = CreateNode(_M_pool); - ast->storage_specifiers = storageSpec; - ast->type_specifier = spec; - ast->init_declarators = declarators; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; + ast->storage_specifiers = storageSpec; + ast->type_specifier = spec; + ast->init_declarators = declarators; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; - return true; - } - } - } // end switch + return true; + } + } + } // end switch rewind(start); return parseDeclarationInternal(node); } -bool Parser::parseLinkageSpecification(DeclarationAST *&node) +bool Parser::parseLinkageSpecification(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); CHECK(Token_extern); - LinkageSpecificationAST *ast = CreateNode(_M_pool); + LinkageSpecificationAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == Token_string_literal) - { - ast->extern_type = token_stream.cursor(); - nextToken(); - } + if (token_stream.lookAhead() == Token_string_literal) { + ast->extern_type = token_stream.cursor(); + nextToken(); + } - if (token_stream.lookAhead() == '{') - { - parseLinkageBody(ast->linkage_body); - } - else if (!parseDeclaration(ast->declaration)) - { - reportError(("Declaration syntax error")); - } + if (token_stream.lookAhead() == '{') { + parseLinkageBody(ast->linkage_body); + } else if (!parseDeclaration(ast->declaration)) { + reportError(("Declaration syntax error")); + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -664,40 +612,35 @@ bool Parser::parseLinkageSpecification(DeclarationAST *&node) return true; } -bool Parser::parseLinkageBody(LinkageBodyAST *&node) +bool Parser::parseLinkageBody(LinkageBodyAST*& node) { std::size_t start = token_stream.cursor(); CHECK('{'); - LinkageBodyAST *ast = CreateNode(_M_pool); + LinkageBodyAST* ast = CreateNode(_M_pool); - while (token_stream.lookAhead()) - { - int tk = token_stream.lookAhead(); + while (token_stream.lookAhead()) { + int tk = token_stream.lookAhead(); - if (tk == '}') - break; + if (tk == '}') + break; - std::size_t startDecl = token_stream.cursor(); + std::size_t startDecl = token_stream.cursor(); - DeclarationAST *declaration = 0; - if (parseDeclaration(declaration)) - { - ast->declarations = snoc(ast->declarations, declaration, _M_pool); - } - else - { - // error recovery - if (startDecl == token_stream.cursor()) - { - // skip at least one token - nextToken(); - } - - skipUntilDeclaration(); - } + DeclarationAST* declaration = 0; + if (parseDeclaration(declaration)) { + ast->declarations = snoc(ast->declarations, declaration, _M_pool); + } else { + // error recovery + if (startDecl == token_stream.cursor()) { + // skip at least one token + nextToken(); + } + + skipUntilDeclaration(); } + } if (token_stream.lookAhead() != '}') reportError(("} expected")); @@ -710,50 +653,42 @@ bool Parser::parseLinkageBody(LinkageBodyAST *&node) return true; } -bool Parser::parseNamespace(DeclarationAST *&node) +bool Parser::parseNamespace(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); CHECK(Token_namespace); std::size_t namespace_name = 0; - if (token_stream.lookAhead() == Token_identifier) - { - namespace_name = token_stream.cursor(); - nextToken(); - } + if (token_stream.lookAhead() == Token_identifier) { + namespace_name = token_stream.cursor(); + nextToken(); + } - if (token_stream.lookAhead() == '=') - { - // namespace alias - nextToken(); + if (token_stream.lookAhead() == '=') { + // namespace alias + nextToken(); - NameAST *name = 0; - if (parseName(name)) - { - ADVANCE(';', ";"); + NameAST* name = 0; + if (parseName(name)) { + ADVANCE(';', ";"); - NamespaceAliasDefinitionAST *ast - = CreateNode(_M_pool); - ast->namespace_name = namespace_name; - ast->alias_name = name; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - return true; - } - else - { - reportError(("namespace expected")); - return false; - } - } - else if (token_stream.lookAhead() != '{') - { - reportError(("{ expected")); + NamespaceAliasDefinitionAST* ast = CreateNode(_M_pool); + ast->namespace_name = namespace_name; + ast->alias_name = name; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + return true; + } else { + reportError(("namespace expected")); return false; } + } else if (token_stream.lookAhead() != '{') { + reportError(("{ expected")); + return false; + } - NamespaceAST *ast = CreateNode(_M_pool); + NamespaceAST* ast = CreateNode(_M_pool); ast->namespace_name = namespace_name; parseLinkageBody(ast->linkage_body); @@ -763,27 +698,25 @@ bool Parser::parseNamespace(DeclarationAST *&node) return true; } -bool Parser::parseUsing(DeclarationAST *&node) +bool Parser::parseUsing(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); CHECK(Token_using); - if (token_stream.lookAhead(1) == '=') - { - return parseUsingTypedef(node); + if (token_stream.lookAhead(1) == '=') { + return parseUsingTypedef(node); } if (token_stream.lookAhead() == Token_namespace) return parseUsingDirective(node); - UsingAST *ast = CreateNode(_M_pool); + UsingAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == Token_typename) - { - ast->type_name = token_stream.cursor(); - nextToken(); - } + if (token_stream.lookAhead() == Token_typename) { + ast->type_name = token_stream.cursor(); + nextToken(); + } if (!parseName(ast->name, /*acceptTemplateId=*/true)) return false; @@ -798,55 +731,52 @@ bool Parser::parseUsing(DeclarationAST *&node) bool Parser::parseUsingTypedef(DeclarationAST*& node) { - std::size_t start = token_stream.cursor(); + std::size_t start = token_stream.cursor(); - DeclaratorAST* decl = 0; - if (!parseDeclarator(decl)) - { - return false; - } + DeclaratorAST* decl = 0; + if (!parseDeclarator(decl)) { + return false; + } - InitDeclaratorAST* init_decl = CreateNode(_M_pool); - init_decl->declarator = decl; - init_decl->initializer = 0; - const ListNode* declarators = 0; - declarators = snoc(declarators, init_decl, _M_pool); + InitDeclaratorAST* init_decl = CreateNode(_M_pool); + init_decl->declarator = decl; + init_decl->initializer = 0; + const ListNode* declarators = 0; + declarators = snoc(declarators, init_decl, _M_pool); - ADVANCE('=', "="); + ADVANCE('=', "="); - TypeSpecifierAST* spec = 0; - if (!parseTypeSpecifierOrClassSpec(spec)) - { - reportError(("Need a type specifier to declare")); - return false; - } + TypeSpecifierAST* spec = 0; + if (!parseTypeSpecifierOrClassSpec(spec)) { + reportError(("Need a type specifier to declare")); + return false; + } - TypedefAST* ast = CreateNode(_M_pool); - ast->type_specifier = spec; - ast->init_declarators = declarators; + TypedefAST* ast = CreateNode(_M_pool); + ast->type_specifier = spec; + ast->init_declarators = declarators; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; - return true; + return true; } - -bool Parser::parseUsingDirective(DeclarationAST *&node) + +bool Parser::parseUsingDirective(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); CHECK(Token_namespace); - NameAST *name = 0; - if (!parseName(name)) - { - reportError(("Namespace name expected")); - return false; - } + NameAST* name = 0; + if (!parseName(name)) { + reportError(("Namespace name expected")); + return false; + } ADVANCE(';', ";"); - UsingDirectiveAST *ast = CreateNode(_M_pool); + UsingDirectiveAST* ast = CreateNode(_M_pool); ast->name = name; UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -854,96 +784,87 @@ bool Parser::parseUsingDirective(DeclarationAST *&node) return true; } - -bool Parser::parseOperatorFunctionId(OperatorFunctionIdAST *&node) +bool Parser::parseOperatorFunctionId(OperatorFunctionIdAST*& node) { std::size_t start = token_stream.cursor(); CHECK(Token_operator); - OperatorFunctionIdAST *ast = CreateNode(_M_pool); + OperatorFunctionIdAST* ast = CreateNode(_M_pool); - if (!parseOperator(ast->op)) - { - ast->op = 0; + if (!parseOperator(ast->op)) { + ast->op = 0; - // parse cast operator - const ListNode *cv = 0; - parseCvQualify(cv); + // parse cast operator + const ListNode* cv = 0; + parseCvQualify(cv); - if (!parseSimpleTypeSpecifier(ast->type_specifier)) - { - SYNTAX_ERROR(); - return false; - } + if (!parseSimpleTypeSpecifier(ast->type_specifier)) { + SYNTAX_ERROR(); + return false; + } - parseCvQualify(cv); - ast->type_specifier->cv = cv; + parseCvQualify(cv); + ast->type_specifier->cv = cv; - PtrOperatorAST *ptr_op = 0; - while (parsePtrOperator(ptr_op)) - ast->ptr_ops = snoc(ast->ptr_ops, ptr_op, _M_pool); - } + PtrOperatorAST* ptr_op = 0; + while (parsePtrOperator(ptr_op)) + ast->ptr_ops = snoc(ast->ptr_ops, ptr_op, _M_pool); + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; return true; } -bool Parser::parseTemplateArgumentList(const ListNode *&node, - bool reportError) +bool Parser::parseTemplateArgumentList(const ListNode*& node, bool reportError) { - TemplateArgumentAST *templArg = 0; + TemplateArgumentAST* templArg = 0; if (!parseTemplateArgument(templArg)) return false; node = snoc(node, templArg, _M_pool); - while (token_stream.lookAhead() == ',') - { - nextToken(); - - if (!parseTemplateArgument(templArg)) - { - if (reportError) - { - SYNTAX_ERROR(); - break; - } + while (token_stream.lookAhead() == ',') { + nextToken(); - node = 0; - return false; - } + if (!parseTemplateArgument(templArg)) { + if (reportError) { + SYNTAX_ERROR(); + break; + } - node = snoc(node, templArg, _M_pool); + node = 0; + return false; } + node = snoc(node, templArg, _M_pool); + } + return true; } -bool Parser::parseTypedef(DeclarationAST *&node) +bool Parser::parseTypedef(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); CHECK(Token_typedef); - TypeSpecifierAST *spec = 0; - if (!parseTypeSpecifierOrClassSpec(spec)) - { - reportError(("Need a type specifier to declare")); - return false; - } + TypeSpecifierAST* spec = 0; + if (!parseTypeSpecifierOrClassSpec(spec)) { + reportError(("Need a type specifier to declare")); + return false; + } - const ListNode *declarators = 0; - if (!parseInitDeclaratorList(declarators)) - { - //reportError(("Need an identifier to declare")); - //return false; - } + const ListNode* declarators = 0; + if (!parseInitDeclaratorList(declarators)) { + //reportError(("Need an identifier to declare")); + //return false; + } ADVANCE(';', ";"); - TypedefAST *ast = CreateNode(_M_pool); + TypedefAST* ast = CreateNode(_M_pool); ast->type_specifier = spec; ast->init_declarators = declarators; @@ -953,23 +874,23 @@ bool Parser::parseTypedef(DeclarationAST *&node) return true; } -bool Parser::parseAsmDefinition(DeclarationAST *&node) +bool Parser::parseAsmDefinition(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); ADVANCE(Token_asm, "asm"); - const ListNode *cv = 0; + const ListNode* cv = 0; parseCvQualify(cv); #if defined(__GNUC__) -#pragma GCC warning "implement me" + #pragma GCC warning "implement me" #endif skip('(', ')'); nextToken(); ADVANCE(';', ";"); - AsmDefinitionAST *ast = CreateNode(_M_pool); + AsmDefinitionAST* ast = CreateNode(_M_pool); ast->cv = cv; UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -977,36 +898,33 @@ bool Parser::parseAsmDefinition(DeclarationAST *&node) return true; } -bool Parser::parseTemplateDeclaration(DeclarationAST *&node) +bool Parser::parseTemplateDeclaration(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); std::size_t exported = 0; - if (token_stream.lookAhead() == Token_export) - { - exported = token_stream.cursor(); - nextToken(); - } + if (token_stream.lookAhead() == Token_export) { + exported = token_stream.cursor(); + nextToken(); + } CHECK(Token_template); - const ListNode *params = 0; - if (token_stream.lookAhead() == '<') - { - nextToken(); - parseTemplateParameterList(params); + const ListNode* params = 0; + if (token_stream.lookAhead() == '<') { + nextToken(); + parseTemplateParameterList(params); - resolveRightShift(); - ADVANCE('>', ">"); - } + resolveRightShift(); + ADVANCE('>', ">"); + } - DeclarationAST *declaration = 0; - if (!parseDeclaration(declaration)) - { - reportError(("expected a declaration")); - } + DeclarationAST* declaration = 0; + if (!parseDeclaration(declaration)) { + reportError(("expected a declaration")); + } - TemplateDeclarationAST *ast = CreateNode(_M_pool); + TemplateDeclarationAST* ast = CreateNode(_M_pool); ast->exported = exported; ast->template_parameters = params; ast->declaration = declaration; @@ -1017,100 +935,86 @@ bool Parser::parseTemplateDeclaration(DeclarationAST *&node) return true; } -bool Parser::parseOperator(OperatorAST *&node) +bool Parser::parseOperator(OperatorAST*& node) { std::size_t start = token_stream.cursor(); - OperatorAST *ast = CreateNode(_M_pool); - - switch(token_stream.lookAhead()) - { - case Token_new: - case Token_delete: - { - ast->op = token_stream.cursor(); - nextToken(); + OperatorAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == '[' - && token_stream.lookAhead(1) == ']') - { - ast->open = token_stream.cursor(); - nextToken(); + switch (token_stream.lookAhead()) { + case Token_new: + case Token_delete: + { + ast->op = token_stream.cursor(); + nextToken(); - ast->close = token_stream.cursor(); - nextToken(); - } - } - break; + if (token_stream.lookAhead() == '[' && token_stream.lookAhead(1) == ']') { + ast->open = token_stream.cursor(); + nextToken(); - case '+': - case '-': - case '*': - case '/': - case '%': - case '^': - case '&': - case '|': - case '~': - case '!': - case '=': - case '<': - case '>': - case ',': - case Token_assign: - case Token_shift_left: - case Token_eq: - case Token_not_eq: - case Token_leq: - case Token_geq: - case Token_and: - case Token_or: - case Token_incr: - case Token_decr: - case Token_ptrmem: - case Token_arrow: - ast->op = token_stream.cursor(); + ast->close = token_stream.cursor(); nextToken(); - break; + } + } break; + + case '+': + case '-': + case '*': + case '/': + case '%': + case '^': + case '&': + case '|': + case '~': + case '!': + case '=': + case '<': + case '>': + case ',': + case Token_assign: + case Token_shift_left: + case Token_eq: + case Token_not_eq: + case Token_leq: + case Token_geq: + case Token_and: + case Token_or: + case Token_incr: + case Token_decr: + case Token_ptrmem: + case Token_arrow: + ast->op = token_stream.cursor(); + nextToken(); + break; + + case Token_shift_right: + ast->op = token_stream.cursor(); + nextToken(); + // skip placeholder + nextToken(); + break; - case Token_shift_right: + default: + if (token_stream.lookAhead() == '(' && token_stream.lookAhead(1) == ')') { + ast->op = ast->open = token_stream.cursor(); + nextToken(); + ast->close = token_stream.cursor(); + nextToken(); + } else if (token_stream.lookAhead() == '[' && token_stream.lookAhead(1) == ']') { + ast->op = ast->open = token_stream.cursor(); + nextToken(); + ast->close = token_stream.cursor(); + nextToken(); + } else if (token_stream.lookAhead() == Token_string_literal && token_stream.lookAhead(1) == Token_identifier) { + // string literal operator ast->op = token_stream.cursor(); nextToken(); - // skip placeholder + // skip string literal suffix for now nextToken(); - break; - - default: - if (token_stream.lookAhead() == '(' - && token_stream.lookAhead(1) == ')') - { - ast->op = ast->open = token_stream.cursor(); - nextToken(); - ast->close = token_stream.cursor(); - nextToken(); - } - else if (token_stream.lookAhead() == '[' - && token_stream.lookAhead(1) == ']') - { - ast->op = ast->open = token_stream.cursor(); - nextToken(); - ast->close = token_stream.cursor(); - nextToken(); - } - else if (token_stream.lookAhead() == Token_string_literal - && token_stream.lookAhead(1) == Token_identifier) - { - // string literal operator - ast->op = token_stream.cursor(); - nextToken(); - // skip string literal suffix for now - nextToken(); - } - else - { - return false; - } + } else { + return false; } + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -1118,109 +1022,87 @@ bool Parser::parseOperator(OperatorAST *&node) return true; } -bool Parser::parseCvQualify(const ListNode *&node) +bool Parser::parseCvQualify(const ListNode*& node) { std::size_t start = token_stream.cursor(); int tk; - while (0 != (tk = token_stream.lookAhead()) - && (tk == Token_const || - tk == Token_volatile || tk == Token_mutable)) - { - node = snoc(node, token_stream.cursor(), _M_pool); - nextToken(); - } + while (0 != (tk = token_stream.lookAhead()) && (tk == Token_const || tk == Token_volatile || tk == Token_mutable)) { + node = snoc(node, token_stream.cursor(), _M_pool); + nextToken(); + } return start != token_stream.cursor(); } -bool Parser::parseSimpleTypeSpecifier(TypeSpecifierAST *&node, - bool onlyIntegral) +bool Parser::parseSimpleTypeSpecifier(TypeSpecifierAST*& node, bool onlyIntegral) { std::size_t start = token_stream.cursor(); bool isIntegral = false; bool done = false; - const ListNode *integrals = 0; - - while (!done) - { - switch(token_stream.lookAhead()) - { - case Token_char: - case Token_wchar_t: - case Token_bool: - case Token_short: - case Token_int: - case Token_long: - case Token_signed: - case Token_unsigned: - case Token_float: - case Token_double: - case Token_void: - integrals = snoc(integrals, token_stream.cursor(), _M_pool); - isIntegral = true; - nextToken(); - break; + const ListNode* integrals = 0; + + while (!done) { + switch (token_stream.lookAhead()) { + case Token_char: + case Token_wchar_t: + case Token_bool: + case Token_short: + case Token_int: + case Token_long: + case Token_signed: + case Token_unsigned: + case Token_float: + case Token_double: + case Token_void: + integrals = snoc(integrals, token_stream.cursor(), _M_pool); + isIntegral = true; + nextToken(); + break; - default: - done = true; - } + default: + done = true; } + } - SimpleTypeSpecifierAST *ast = CreateNode(_M_pool); - if (isIntegral) - { - ast->integrals = integrals; - } - else if (token_stream.lookAhead() == Token_auto) - { - nextToken(); - ast->is_auto = true; - } - else if (token_stream.lookAhead() == Token___typeof || - token_stream.lookAhead() == Token_decltype) - { - ast->type_of = token_stream.cursor(); - nextToken(); + SimpleTypeSpecifierAST* ast = CreateNode(_M_pool); + if (isIntegral) { + ast->integrals = integrals; + } else if (token_stream.lookAhead() == Token_auto) { + nextToken(); + ast->is_auto = true; + } else if (token_stream.lookAhead() == Token___typeof || token_stream.lookAhead() == Token_decltype) { + ast->type_of = token_stream.cursor(); + nextToken(); - if (token_stream.lookAhead() == '(') - { - nextToken(); + if (token_stream.lookAhead() == '(') { + nextToken(); - std::size_t saved = token_stream.cursor(); - parseTypeId(ast->type_id); - if (token_stream.lookAhead() != ')') - { - ast->type_id = 0; - rewind(saved); - parseCommaExpression(ast->expression); - } - ADVANCE(')', ")"); - } - else - { - parseUnaryExpression(ast->expression); - } + std::size_t saved = token_stream.cursor(); + parseTypeId(ast->type_id); + if (token_stream.lookAhead() != ')') { + ast->type_id = 0; + rewind(saved); + parseCommaExpression(ast->expression); + } + ADVANCE(')', ")"); + } else { + parseUnaryExpression(ast->expression); } - else if (onlyIntegral) - { + } else if (onlyIntegral) { + rewind(start); + return false; + } else { + if (token_stream.lookAhead() == Token_typename) { + nextToken(); // simply skip for now + } + if (!parseName(ast->name, true)) { + ast->name = 0; rewind(start); return false; } - else - { - if (token_stream.lookAhead() == Token_typename) - { - nextToken(); // simply skip for now - } - if (!parseName(ast->name, true)) - { - ast->name = 0; - rewind(start); - return false; - } - } + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -1228,44 +1110,39 @@ bool Parser::parseSimpleTypeSpecifier(TypeSpecifierAST *&node, return true; } -bool Parser::parsePtrOperator(PtrOperatorAST *&node) +bool Parser::parsePtrOperator(PtrOperatorAST*& node) { int tk = token_stream.lookAhead(); - if (tk != '&' && tk != Token_and && tk != '*' - && tk != Token_scope && tk != Token_identifier) - { - return false; - } + if (tk != '&' && tk != Token_and && tk != '*' && tk != Token_scope && tk != Token_identifier) { + return false; + } std::size_t start = token_stream.cursor(); - PtrOperatorAST *ast = CreateNode(_M_pool); - - switch (token_stream.lookAhead()) - { - case '&': - case '*': - case Token_and: - ast->op = token_stream.cursor(); - nextToken(); - break; + PtrOperatorAST* ast = CreateNode(_M_pool); - case Token_scope: - case Token_identifier: - { - if (!parsePtrToMember(ast->mem_ptr)) - { - rewind(start); - return false; - } - } - break; + switch (token_stream.lookAhead()) { + case '&': + case '*': + case Token_and: + ast->op = token_stream.cursor(); + nextToken(); + break; - default: - Q_ASSERT(0); - break; + case Token_scope: + case Token_identifier: + { + if (!parsePtrToMember(ast->mem_ptr)) { + rewind(start); + return false; } + } break; + + default: + Q_ASSERT(0); + break; + } parseCvQualify(ast->cv); @@ -1275,25 +1152,24 @@ bool Parser::parsePtrOperator(PtrOperatorAST *&node) return true; } -bool Parser::parseTemplateArgument(TemplateArgumentAST *&node) +bool Parser::parseTemplateArgument(TemplateArgumentAST*& node) { std::size_t start = token_stream.cursor(); - TypeIdAST *typeId = 0; - ExpressionAST *expr = 0; + TypeIdAST* typeId = 0; + ExpressionAST* expr = 0; - if (!parseTypeId(typeId) || (token_stream.lookAhead() != ',' - && token_stream.lookAhead() != Token_ellipsis - && token_stream.lookAhead() != '>' - && token_stream.lookAhead() != Token_shift_right)) - { - rewind(start); + if (!parseTypeId(typeId) + || (token_stream.lookAhead() != ',' && token_stream.lookAhead() != Token_ellipsis + && token_stream.lookAhead() != '>' && token_stream.lookAhead() != Token_shift_right)) + { + rewind(start); - if (!parseLogicalOrExpression(expr, true)) - return false; - } + if (!parseLogicalOrExpression(expr, true)) + return false; + } - TemplateArgumentAST *ast = CreateNode(_M_pool); + TemplateArgumentAST* ast = CreateNode(_M_pool); ast->type_id = typeId; ast->expression = expr; @@ -1308,21 +1184,20 @@ bool Parser::parseTemplateArgument(TemplateArgumentAST *&node) return true; } -bool Parser::parseTypeSpecifier(TypeSpecifierAST *&node) +bool Parser::parseTypeSpecifier(TypeSpecifierAST*& node) { std::size_t start = token_stream.cursor(); skipAttributes(); - const ListNode *cv = 0; + const ListNode* cv = 0; parseCvQualify(cv); - TypeSpecifierAST *ast = 0; - if (!parseElaboratedTypeSpecifier(ast) && !parseSimpleTypeSpecifier(ast)) - { - rewind(start); - return false; - } + TypeSpecifierAST* ast = 0; + if (!parseElaboratedTypeSpecifier(ast) && !parseSimpleTypeSpecifier(ast)) { + rewind(start); + return false; + } parseCvQualify(cv); ast->cv = cv; @@ -1332,208 +1207,175 @@ bool Parser::parseTypeSpecifier(TypeSpecifierAST *&node) return true; } -bool Parser::parseDeclarator(DeclaratorAST *&node, bool asParameter) +bool Parser::parseDeclarator(DeclaratorAST*& node, bool asParameter) { std::size_t start = token_stream.cursor(); - DeclaratorAST *ast = CreateNode(_M_pool); + DeclaratorAST* ast = CreateNode(_M_pool); - DeclaratorAST *decl = 0; - NameAST *declId = 0; + DeclaratorAST* decl = 0; + NameAST* declId = 0; - PtrOperatorAST *ptrOp = 0; - while (parsePtrOperator(ptrOp)) - { - ast->ptr_ops = snoc(ast->ptr_ops, ptrOp, _M_pool); - } + PtrOperatorAST* ptrOp = 0; + while (parsePtrOperator(ptrOp)) { + ast->ptr_ops = snoc(ast->ptr_ops, ptrOp, _M_pool); + } - if (token_stream.lookAhead() == '(') - { - nextToken(); + if (token_stream.lookAhead() == '(') { + nextToken(); - if (!parseDeclarator(decl)) - return false; + if (!parseDeclarator(decl)) + return false; - ast->sub_declarator = decl; + ast->sub_declarator = decl; - CHECK(')'); + CHECK(')'); + } else { + if (token_stream.lookAhead() == ':') { + // unnamed bitfield + } else { + if (asParameter && token_stream.lookAhead() == Token_ellipsis) { + // parameter pack + nextToken(); + ast->packedParameter = true; + } + if (parseName(declId, true)) { + ast->id = declId; + } else { + rewind(start); + return false; + } } - else - { - if (token_stream.lookAhead() == ':') - { - // unnamed bitfield - } - else - { - if (asParameter && token_stream.lookAhead() == Token_ellipsis) - { - // parameter pack - nextToken(); - ast->packedParameter = true; - } - if (parseName(declId, true)) - { - ast->id = declId; - } - else - { - rewind(start); - return false; - } - } - if (token_stream.lookAhead() == ':') - { - nextToken(); + if (token_stream.lookAhead() == ':') { + nextToken(); - if (!parseConstantExpression(ast->bit_expression)) - { - reportError(("Constant expression expected")); - } - goto update_pos; - } + if (!parseConstantExpression(ast->bit_expression)) { + reportError(("Constant expression expected")); + } + goto update_pos; } + } { bool isVector = true; - while (token_stream.lookAhead() == '[') - { - nextToken(); + while (token_stream.lookAhead() == '[') { + nextToken(); - ExpressionAST *expr = 0; - parseCommaExpression(expr); + ExpressionAST* expr = 0; + parseCommaExpression(expr); - ADVANCE(']', "]"); + ADVANCE(']', "]"); - ast->array_dimensions = snoc(ast->array_dimensions, expr, _M_pool); - isVector = true; - } + ast->array_dimensions = snoc(ast->array_dimensions, expr, _M_pool); + isVector = true; + } bool skipParen = false; - if (token_stream.lookAhead() == Token_identifier - && token_stream.lookAhead(1) == '(' + if (token_stream.lookAhead() == Token_identifier && token_stream.lookAhead(1) == '(' && token_stream.lookAhead(2) == '(') - { - nextToken(); - nextToken(); - skipParen = true; - } + { + nextToken(); + nextToken(); + skipParen = true; + } int tok = token_stream.lookAhead(); - if (ast->sub_declarator - && !(isVector || tok == '(' || tok == ',' - || tok == ';' || tok == '=')) - { - rewind(start); - return false; - } + if (ast->sub_declarator && !(isVector || tok == '(' || tok == ',' || tok == ';' || tok == '=')) { + rewind(start); + return false; + } if (parseDeclaratorParametersAndSuffix(ast)) { - if (token_stream.lookAhead() == Token_identifier && - token_stream.symbol(token_stream.cursor())->as_string() == "override") + if (token_stream.lookAhead() == Token_identifier + && token_stream.symbol(token_stream.cursor())->as_string() == "override") { nextToken(); ast->_override = true; } skipAttributes(); - if (skipParen) - { - if (token_stream.lookAhead() != ')') - { + if (skipParen) { + if (token_stream.lookAhead() != ')') { reportError(("')' expected")); - } - else + } else nextToken(); } - } } - update_pos: +update_pos: UPDATE_POS(ast, start, token_stream.cursor()); node = ast; return true; } -bool Parser::parseAbstractDeclarator(DeclaratorAST *&node) +bool Parser::parseAbstractDeclarator(DeclaratorAST*& node) { std::size_t start = token_stream.cursor(); - DeclaratorAST *ast = CreateNode(_M_pool); - DeclaratorAST *decl = 0; + DeclaratorAST* ast = CreateNode(_M_pool); + DeclaratorAST* decl = 0; - PtrOperatorAST *ptrOp = 0; - while (parsePtrOperator(ptrOp)) - { - ast->ptr_ops = snoc(ast->ptr_ops, ptrOp, _M_pool); - } + PtrOperatorAST* ptrOp = 0; + while (parsePtrOperator(ptrOp)) { + ast->ptr_ops = snoc(ast->ptr_ops, ptrOp, _M_pool); + } - int index = (int) token_stream.cursor(); - if (token_stream.lookAhead() == '(') - { - nextToken(); + int index = (int)token_stream.cursor(); + if (token_stream.lookAhead() == '(') { + nextToken(); - if (!parseAbstractDeclarator(decl)) - { - rewind(index); - goto label1; - } + if (!parseAbstractDeclarator(decl)) { + rewind(index); + goto label1; + } - ast->sub_declarator = decl; + ast->sub_declarator = decl; - if (token_stream.lookAhead() != ')') - { - rewind(start); - return false; - } - nextToken(); + if (token_stream.lookAhead() != ')') { + rewind(start); + return false; } - else if (token_stream.lookAhead() == ':') - { - nextToken(); - if (!parseConstantExpression(ast->bit_expression)) - { - ast->bit_expression = 0; - reportError(("Constant expression expected")); - } - goto update_pos; + nextToken(); + } else if (token_stream.lookAhead() == ':') { + nextToken(); + if (!parseConstantExpression(ast->bit_expression)) { + ast->bit_expression = 0; + reportError(("Constant expression expected")); } + goto update_pos; + } - label1: - { - bool isVector = true; +label1: +{ + bool isVector = true; - while (token_stream.lookAhead() == '[') - { - nextToken(); - - ExpressionAST *expr = 0; - parseCommaExpression(expr); + while (token_stream.lookAhead() == '[') { + nextToken(); - ADVANCE(']', "]"); + ExpressionAST* expr = 0; + parseCommaExpression(expr); - ast->array_dimensions = snoc(ast->array_dimensions, expr, _M_pool); - isVector = true; - } + ADVANCE(']', "]"); - int tok = token_stream.lookAhead(); - if (ast->sub_declarator - && !(isVector || tok == '(' || tok == ',' - || tok == ';' || tok == '=')) - { - rewind(start); - return false; - } + ast->array_dimensions = snoc(ast->array_dimensions, expr, _M_pool); + isVector = true; + } - parseDeclaratorParametersAndSuffix(ast); + int tok = token_stream.lookAhead(); + if (ast->sub_declarator && !(isVector || tok == '(' || tok == ',' || tok == ';' || tok == '=')) { + rewind(start); + return false; } - update_pos: + parseDeclaratorParametersAndSuffix(ast); +} + +update_pos: if (token_stream.cursor() == start) return false; @@ -1546,35 +1388,29 @@ bool Parser::parseAbstractDeclarator(DeclaratorAST *&node) bool Parser::parseDeclaratorParametersAndSuffix(DeclaratorAST* ast) { std::size_t index = token_stream.cursor(); - if (token_stream.lookAhead() == '(') - { + if (token_stream.lookAhead() == '(') { nextToken(); ParameterDeclarationClauseAST* params = 0; - if (!parseParameterDeclarationClause(params)) - { + if (!parseParameterDeclarationClause(params)) { rewind(index); return false; } ast->parameter_declaration_clause = params; - if (token_stream.lookAhead() != ')') - { + if (token_stream.lookAhead() != ')') { rewind(index); return false; } - nextToken(); // skip ')' + nextToken(); // skip ')' parseCvQualify(ast->fun_cv); - if (token_stream.lookAhead() == '&') - { + if (token_stream.lookAhead() == '&') { ast->valueRef = DeclaratorAST::Lvalue; nextToken(); - } - else if (token_stream.lookAhead() == Token_and) - { + } else if (token_stream.lookAhead() == Token_and) { ast->valueRef = DeclaratorAST::Rvalue; nextToken(); } @@ -1584,62 +1420,55 @@ bool Parser::parseDeclaratorParametersAndSuffix(DeclaratorAST* ast) return false; } -bool Parser::parseEnumSpecifier(TypeSpecifierAST *&node) +bool Parser::parseEnumSpecifier(TypeSpecifierAST*& node) { std::size_t start = token_stream.cursor(); CHECK(Token_enum); - bool enum_class{}; - if (token_stream.lookAhead() == Token_class) - { - enum_class = true; - nextToken(); - } + bool enum_class {}; + if (token_stream.lookAhead() == Token_class) { + enum_class = true; + nextToken(); + } - NameAST *name = 0; + NameAST* name = 0; parseName(name); - if(token_stream.lookAhead() == ':') - { - nextToken(); - TypeSpecifierAST *ast = 0; - if (!parseSimpleTypeSpecifier(ast)) - { - rewind(start); - return false; - } - } - - if (token_stream.lookAhead() != '{') - { + if (token_stream.lookAhead() == ':') { + nextToken(); + TypeSpecifierAST* ast = 0; + if (!parseSimpleTypeSpecifier(ast)) { rewind(start); return false; } + } + + if (token_stream.lookAhead() != '{') { + rewind(start); + return false; + } nextToken(); - EnumSpecifierAST *ast = CreateNode(_M_pool); + EnumSpecifierAST* ast = CreateNode(_M_pool); ast->name = name; ast->is_enum_class = enum_class; - EnumeratorAST *enumerator = 0; - if (parseEnumerator(enumerator)) - { - ast->enumerators = snoc(ast->enumerators, enumerator, _M_pool); + EnumeratorAST* enumerator = 0; + if (parseEnumerator(enumerator)) { + ast->enumerators = snoc(ast->enumerators, enumerator, _M_pool); - while (token_stream.lookAhead() == ',') - { - nextToken(); + while (token_stream.lookAhead() == ',') { + nextToken(); - if (!parseEnumerator(enumerator)) - { - //reportError(("Enumerator expected")); - break; - } + if (!parseEnumerator(enumerator)) { + //reportError(("Enumerator expected")); + break; + } - ast->enumerators = snoc(ast->enumerators, enumerator, _M_pool); - } + ast->enumerators = snoc(ast->enumerators, enumerator, _M_pool); } + } ADVANCE_NR('}', "}"); @@ -1649,62 +1478,52 @@ bool Parser::parseEnumSpecifier(TypeSpecifierAST *&node) return true; } -bool Parser::parseTemplateParameterList(const ListNode *&node) +bool Parser::parseTemplateParameterList(const ListNode*& node) { - TemplateParameterAST *param = 0; + TemplateParameterAST* param = 0; if (!parseTemplateParameter(param)) return false; node = snoc(node, param, _M_pool); - while (token_stream.lookAhead() == ',') - { - nextToken(); + while (token_stream.lookAhead() == ',') { + nextToken(); - if (!parseTemplateParameter(param)) - { - SYNTAX_ERROR(); - break; - } - else - { - node = snoc(node, param, _M_pool); - } + if (!parseTemplateParameter(param)) { + SYNTAX_ERROR(); + break; + } else { + node = snoc(node, param, _M_pool); } + } - if (token_stream.lookAhead() == Token_ellipsis) - { - // ignore variadic template parameters as in - // template + if (token_stream.lookAhead() == Token_ellipsis) { + // ignore variadic template parameters as in + // template + token_stream.nextToken(); + if (token_stream.lookAhead() == Token_identifier) { token_stream.nextToken(); - if (token_stream.lookAhead() == Token_identifier) - { - token_stream.nextToken(); - } } + } return true; } -bool Parser::parseTemplateParameter(TemplateParameterAST *&node) +bool Parser::parseTemplateParameter(TemplateParameterAST*& node) { std::size_t start = token_stream.cursor(); - TemplateParameterAST *ast = CreateNode(_M_pool); + TemplateParameterAST* ast = CreateNode(_M_pool); int tk = token_stream.lookAhead(); - if ((tk == Token_class || tk == Token_typename || tk == Token_template) - && parseTypeParameter(ast->type_parameter)) - { - if (token_stream.lookAhead() == '=' || token_stream.lookAhead() == Token_assign) - { - // default template parameter - token_stream.nextToken(); - TypeSpecifierAST* typeNode = 0; - parseTypeSpecifier(typeNode); - } + if ((tk == Token_class || tk == Token_typename || tk == Token_template) && parseTypeParameter(ast->type_parameter)) { + if (token_stream.lookAhead() == '=' || token_stream.lookAhead() == Token_assign) { + // default template parameter + token_stream.nextToken(); + TypeSpecifierAST* typeNode = 0; + parseTypeSpecifier(typeNode); } - else if (!parseParameterDeclaration(ast->parameter_declaration)) + } else if (!parseParameterDeclaration(ast->parameter_declaration)) return false; UPDATE_POS(ast, start, token_stream.cursor()); @@ -1713,148 +1532,132 @@ bool Parser::parseTemplateParameter(TemplateParameterAST *&node) return true; } -bool Parser::parseTypeParameter(TypeParameterAST *&node) +bool Parser::parseTypeParameter(TypeParameterAST*& node) { std::size_t start = token_stream.cursor(); - TypeParameterAST *ast = CreateNode(_M_pool); + TypeParameterAST* ast = CreateNode(_M_pool); ast->type = start; - switch(token_stream.lookAhead()) - { - case Token_class: - case Token_typename: - { - nextToken(); // skip class + switch (token_stream.lookAhead()) { + case Token_class: + case Token_typename: + { + nextToken(); // skip class - if (token_stream.lookAhead() == Token_ellipsis) - { - // skip variadic parameters in template parameter list - nextToken(); - } + if (token_stream.lookAhead() == Token_ellipsis) { + // skip variadic parameters in template parameter list + nextToken(); + } - // parse optional name - if(parseName(ast->name, true)) - { - if (token_stream.lookAhead() == '=') - { - nextToken(); - - if(!parseTypeId(ast->type_id)) - { - //SYNTAX_ERROR(); - rewind(start); - return false; - } - } - else if (token_stream.lookAhead() != ',' - && token_stream.lookAhead() != '>') - { - rewind(start); - return false; - } - } + // parse optional name + if (parseName(ast->name, true)) { + if (token_stream.lookAhead() == '=') { + nextToken(); + + if (!parseTypeId(ast->type_id)) { + //SYNTAX_ERROR(); + rewind(start); + return false; + } + } else if (token_stream.lookAhead() != ',' && token_stream.lookAhead() != '>') { + rewind(start); + return false; } - break; + } + } break; - case Token_template: - { - nextToken(); // skip template - ADVANCE('<', "<"); + case Token_template: + { + nextToken(); // skip template + ADVANCE('<', "<"); - if (!parseTemplateParameterList(ast->template_parameters)) - return false; + if (!parseTemplateParameterList(ast->template_parameters)) + return false; - ADVANCE('>', ">"); + ADVANCE('>', ">"); - if (token_stream.lookAhead() == Token_class) - nextToken(); + if (token_stream.lookAhead() == Token_class) + nextToken(); - // parse optional name - if (parseName(ast->name, true)) - { - if (token_stream.lookAhead() == '=') - { - nextToken(); - - if (!parseTypeId(ast->type_id)) - { - SYNTAX_ERROR(); - return false; - } - } - } - - if (token_stream.lookAhead() == '=') - { - nextToken(); - - parseName(ast->template_name, true); - } + // parse optional name + if (parseName(ast->name, true)) { + if (token_stream.lookAhead() == '=') { + nextToken(); + + if (!parseTypeId(ast->type_id)) { + SYNTAX_ERROR(); + return false; + } } - break; + } - default: - return false; + if (token_stream.lookAhead() == '=') { + nextToken(); - } // end switch + parseName(ast->template_name, true); + } + } break; + default: + return false; + + } // end switch UPDATE_POS(ast, start, token_stream.cursor()); node = ast; return true; } -bool Parser::parseStorageClassSpecifier(const ListNode *&node) +bool Parser::parseStorageClassSpecifier(const ListNode*& node) { std::size_t start = token_stream.cursor(); int tk; - while (0 != (tk = token_stream.lookAhead()) - && (tk == Token_friend - // || tk == Token_auto // I believe "auto" isn't used as storage class specifier in Qt, and it collides with the type-specifier of the same name - || tk == Token_register || tk == Token_static - || tk == Token_extern)) - { - node = snoc(node, token_stream.cursor(), _M_pool); - nextToken(); - } + while ( + 0 != (tk = token_stream.lookAhead()) + && (tk == Token_friend + // || tk == Token_auto // I believe "auto" isn't used as storage class specifier in Qt, and it collides with the type-specifier of the same name + || tk == Token_register || tk == Token_static || tk == Token_extern)) + { + node = snoc(node, token_stream.cursor(), _M_pool); + nextToken(); + } return start != token_stream.cursor(); } -bool Parser::parseFunctionSpecifier(const ListNode *&node) +bool Parser::parseFunctionSpecifier(const ListNode*& node) { std::size_t start = token_stream.cursor(); int tk; while (0 != (tk = token_stream.lookAhead()) - && (tk == Token_constexpr || tk == Token_inline || tk == Token_virtual - || tk == Token_explicit || tk == Token_Q_INVOKABLE)) - { - node = snoc(node, token_stream.cursor(), _M_pool); - nextToken(); - } + && (tk == Token_constexpr || tk == Token_inline || tk == Token_virtual || tk == Token_explicit + || tk == Token_Q_INVOKABLE)) + { + node = snoc(node, token_stream.cursor(), _M_pool); + nextToken(); + } return start != token_stream.cursor(); } -bool Parser::parseTypeId(TypeIdAST *&node) +bool Parser::parseTypeId(TypeIdAST*& node) { /// @todo implement the AST for typeId std::size_t start = token_stream.cursor(); - TypeSpecifierAST *spec = 0; - if (!parseTypeSpecifier(spec)) - { - rewind(start); - return false; - } + TypeSpecifierAST* spec = 0; + if (!parseTypeSpecifier(spec)) { + rewind(start); + return false; + } - DeclaratorAST *decl = 0; + DeclaratorAST* decl = 0; parseAbstractDeclarator(decl); - TypeIdAST *ast = CreateNode(_M_pool); + TypeIdAST* ast = CreateNode(_M_pool); ast->type_specifier = spec; ast->declarator = decl; @@ -1864,58 +1667,51 @@ bool Parser::parseTypeId(TypeIdAST *&node) return true; } -bool Parser::parseInitDeclaratorList(const ListNode *&node) +bool Parser::parseInitDeclaratorList(const ListNode*& node) { - InitDeclaratorAST *decl = 0; + InitDeclaratorAST* decl = 0; if (!parseInitDeclarator(decl)) return false; node = snoc(node, decl, _M_pool); - while (token_stream.lookAhead() == ',') - { - nextToken(); + while (token_stream.lookAhead() == ',') { + nextToken(); - if (!parseInitDeclarator(decl)) - { - SYNTAX_ERROR(); - break; - } - node = snoc(node, decl, _M_pool); + if (!parseInitDeclarator(decl)) { + SYNTAX_ERROR(); + break; } + node = snoc(node, decl, _M_pool); + } return true; } -bool Parser::parseParameterDeclarationClause(ParameterDeclarationClauseAST *&node) +bool Parser::parseParameterDeclarationClause(ParameterDeclarationClauseAST*& node) { std::size_t start = token_stream.cursor(); - ParameterDeclarationClauseAST *ast - = CreateNode(_M_pool); - - if (!parseParameterDeclarationList(ast->parameter_declarations)) - { - if (token_stream.lookAhead() == ')') - goto good; + ParameterDeclarationClauseAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == Token_ellipsis - && token_stream.lookAhead(1) == ')') - { - ast->ellipsis = token_stream.cursor(); - goto good; - } + if (!parseParameterDeclarationList(ast->parameter_declarations)) { + if (token_stream.lookAhead() == ')') + goto good; - return false; + if (token_stream.lookAhead() == Token_ellipsis && token_stream.lookAhead(1) == ')') { + ast->ellipsis = token_stream.cursor(); + goto good; } - good: + return false; + } - if (token_stream.lookAhead() == Token_ellipsis) - { - ast->ellipsis = token_stream.cursor(); - nextToken(); - } +good: + + if (token_stream.lookAhead() == Token_ellipsis) { + ast->ellipsis = token_stream.cursor(); + nextToken(); + } /// @todo add ellipsis UPDATE_POS(ast, start, token_stream.cursor()); @@ -1924,74 +1720,67 @@ bool Parser::parseParameterDeclarationClause(ParameterDeclarationClauseAST *&nod return true; } -bool Parser::parseParameterDeclarationList(const ListNode *&node) +bool Parser::parseParameterDeclarationList(const ListNode*& node) { std::size_t start = token_stream.cursor(); - ParameterDeclarationAST *param = 0; - if (!parseParameterDeclaration(param)) - { - rewind(start); - return false; - } + ParameterDeclarationAST* param = 0; + if (!parseParameterDeclaration(param)) { + rewind(start); + return false; + } node = snoc(node, param, _M_pool); - while (token_stream.lookAhead() == ',') - { - nextToken(); + while (token_stream.lookAhead() == ',') { + nextToken(); - if (token_stream.lookAhead() == Token_ellipsis) - break; + if (token_stream.lookAhead() == Token_ellipsis) + break; - if (!parseParameterDeclaration(param)) - { - rewind(start); - return false; - } - node = snoc(node, param, _M_pool); + if (!parseParameterDeclaration(param)) { + rewind(start); + return false; } + node = snoc(node, param, _M_pool); + } return true; } -bool Parser::parseParameterDeclaration(ParameterDeclarationAST *&node) +bool Parser::parseParameterDeclaration(ParameterDeclarationAST*& node) { std::size_t start = token_stream.cursor(); - const ListNode *storage = 0; + const ListNode* storage = 0; parseStorageClassSpecifier(storage); // parse decl spec - TypeSpecifierAST *spec = 0; - if (!parseTypeSpecifier(spec)) - { - rewind(start); - return false; - } + TypeSpecifierAST* spec = 0; + if (!parseTypeSpecifier(spec)) { + rewind(start); + return false; + } - int index = (int) token_stream.cursor(); + int index = (int)token_stream.cursor(); - DeclaratorAST *decl = 0; - if (!parseDeclarator(decl, /*asParameter=*/true)) - { - rewind(index); + DeclaratorAST* decl = 0; + if (!parseDeclarator(decl, /*asParameter=*/true)) { + rewind(index); - // try with abstract declarator - parseAbstractDeclarator(decl); - } + // try with abstract declarator + parseAbstractDeclarator(decl); + } - ExpressionAST *expr = 0; - if (token_stream.lookAhead() == '=') - { - nextToken(); - if (!parseLogicalOrExpression(expr,true)) - { - //reportError(("Expression expected")); - } + ExpressionAST* expr = 0; + if (token_stream.lookAhead() == '=') { + nextToken(); + if (!parseLogicalOrExpression(expr, true)) { + //reportError(("Expression expected")); } + } - ParameterDeclarationAST *ast = CreateNode(_M_pool); + ParameterDeclarationAST* ast = CreateNode(_M_pool); ast->type_specifier = spec; ast->declarator = decl; ast->expression = expr; @@ -2002,40 +1791,39 @@ bool Parser::parseParameterDeclaration(ParameterDeclarationAST *&node) return true; } -bool Parser::parse_Attribute__() { - nextToken(); +bool Parser::parse_Attribute__() +{ + nextToken(); - ADVANCE('(', "("); + ADVANCE('(', "("); - ExpressionAST *expr = 0; - parseExpression(expr); + ExpressionAST* expr = 0; + parseExpression(expr); - if (token_stream.lookAhead() != ')') - { - reportError(("')' expected")); - return false; - } - else - { - nextToken(); - } - return true; + if (token_stream.lookAhead() != ')') { + reportError(("')' expected")); + return false; + } else { + nextToken(); + } + return true; } -QString Parser::tokenText(AST *ast) const +QString Parser::tokenText(AST* ast) const { - if (ast == 0) return QString(); + if (ast == 0) + return QString(); - size_t start_token = ast->start_token; - size_t end_token = ast->end_token; + size_t start_token = ast->start_token; + size_t end_token = ast->end_token; - Token const &tk = token_stream.token (start_token); - Token const &end_tk = token_stream.token(end_token); + Token const& tk = token_stream.token(start_token); + Token const& end_tk = token_stream.token(end_token); - return QString::fromLatin1 (&tk.text[tk.position],(int) (end_tk.position - tk.position)).trimmed(); + return QString::fromLatin1(&tk.text[tk.position], (int)(end_tk.position - tk.position)).trimmed(); } -bool Parser::parseForwardDeclarationSpecifier(TypeSpecifierAST *&node) +bool Parser::parseForwardDeclarationSpecifier(TypeSpecifierAST*& node) { std::size_t start = token_stream.cursor(); @@ -2046,34 +1834,30 @@ bool Parser::parseForwardDeclarationSpecifier(TypeSpecifierAST *&node) std::size_t class_key = token_stream.cursor(); nextToken(); - if (kind == Token_enum && token_stream.lookAhead() == Token_class) - { - nextToken(); - } + if (kind == Token_enum && token_stream.lookAhead() == Token_class) { + nextToken(); + } - NameAST *name = 0; + NameAST* name = 0; if (!parseName(name, false)) { - rewind(start); - return false; + rewind(start); + return false; } - BaseClauseAST *bases = 0; - if (token_stream.lookAhead() == ':') - { - if (!parseBaseClause(bases)) - { - rewind(start); - return false; - } + BaseClauseAST* bases = 0; + if (token_stream.lookAhead() == ':') { + if (!parseBaseClause(bases)) { + rewind(start); + return false; } + } - if (token_stream.lookAhead() != ';') - { - rewind(start); - return false; - } + if (token_stream.lookAhead() != ';') { + rewind(start); + return false; + } - ForwardDeclarationSpecifierAST *ast = CreateNode(_M_pool); + ForwardDeclarationSpecifierAST* ast = CreateNode(_M_pool); ast->class_key = class_key; ast->name = name; ast->base_clause = bases; @@ -2084,7 +1868,7 @@ bool Parser::parseForwardDeclarationSpecifier(TypeSpecifierAST *&node) return true; } -bool Parser::parseClassSpecifier(TypeSpecifierAST *&node) +bool Parser::parseClassSpecifier(TypeSpecifierAST*& node) { std::size_t start = token_stream.cursor(); @@ -2095,63 +1879,54 @@ bool Parser::parseClassSpecifier(TypeSpecifierAST *&node) std::size_t class_key = token_stream.cursor(); nextToken(); - WinDeclSpecAST *winDeclSpec = 0; - while (skipAttributes() || skipAlignas() || (!winDeclSpec && parseWinDeclSpec(winDeclSpec))) - { + WinDeclSpecAST* winDeclSpec = 0; + while (skipAttributes() || skipAlignas() || (!winDeclSpec && parseWinDeclSpec(winDeclSpec))) { ; } - while (token_stream.lookAhead() == Token_identifier - && token_stream.lookAhead(1) == Token_identifier) - { - nextToken(); - } + while (token_stream.lookAhead() == Token_identifier && token_stream.lookAhead(1) == Token_identifier) { + nextToken(); + } - NameAST *name = 0; + NameAST* name = 0; parseName(name, true); - - BaseClauseAST *bases = 0; - if (token_stream.lookAhead() == ':') - { - if (!parseBaseClause(bases)) - { - skipUntil('{'); - } + BaseClauseAST* bases = 0; + + if (token_stream.lookAhead() == ':') { + if (!parseBaseClause(bases)) { + skipUntil('{'); } + } - if (token_stream.lookAhead() != '{') - { + if (token_stream.lookAhead() != '{') { - rewind(start); - return false; - } + rewind(start); + return false; + } ADVANCE('{', "{"); - ClassSpecifierAST *ast = CreateNode(_M_pool); + ClassSpecifierAST* ast = CreateNode(_M_pool); ast->win_decl_specifiers = winDeclSpec; ast->class_key = class_key; ast->name = name; ast->base_clause = bases; - while (token_stream.lookAhead()) - { - if (token_stream.lookAhead() == '}') - break; + while (token_stream.lookAhead()) { + if (token_stream.lookAhead() == '}') + break; - std::size_t startDecl = token_stream.cursor(); + std::size_t startDecl = token_stream.cursor(); - DeclarationAST *memSpec = 0; - if (!parseMemberSpecification(memSpec)) - { - if (startDecl == token_stream.cursor()) - nextToken(); // skip at least one token - skipUntilDeclaration(); - } - else - ast->member_specs = snoc(ast->member_specs, memSpec, _M_pool); - } + DeclarationAST* memSpec = 0; + if (!parseMemberSpecification(memSpec)) { + if (startDecl == token_stream.cursor()) + nextToken(); // skip at least one token + skipUntilDeclaration(); + } else + ast->member_specs = snoc(ast->member_specs, memSpec, _M_pool); + } ADVANCE_NR('}', "}"); @@ -2161,40 +1936,38 @@ bool Parser::parseClassSpecifier(TypeSpecifierAST *&node) return true; } -bool Parser::parseAccessSpecifier(DeclarationAST *&node) +bool Parser::parseAccessSpecifier(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); - const ListNode *specs = 0; + const ListNode* specs = 0; bool done = false; - while (!done) - { - switch(token_stream.lookAhead()) - { - case Token_signals: - case Token_slots: - case Token_k_dcop: - case Token_k_dcop_signals: - case Token_public: - case Token_protected: - case Token_private: - specs = snoc(specs, token_stream.cursor(), _M_pool); - nextToken(); - break; + while (!done) { + switch (token_stream.lookAhead()) { + case Token_signals: + case Token_slots: + case Token_k_dcop: + case Token_k_dcop_signals: + case Token_public: + case Token_protected: + case Token_private: + specs = snoc(specs, token_stream.cursor(), _M_pool); + nextToken(); + break; - default: - done = true; - break; - } + default: + done = true; + break; } + } if (!specs) return false; ADVANCE(':', ":"); - AccessSpecifierAST *ast = CreateNode(_M_pool); + AccessSpecifierAST* ast = CreateNode(_M_pool); ast->specs = specs; UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -2202,95 +1975,75 @@ bool Parser::parseAccessSpecifier(DeclarationAST *&node) return true; } -bool Parser::parseMemberSpecification(DeclarationAST *&node) +bool Parser::parseMemberSpecification(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); - if (token_stream.lookAhead() == ';') - { - nextToken(); - return true; - } - else if (token_stream.lookAhead() == Token_Q_OBJECT || token_stream.lookAhead() == Token_K_DCOP) - { - nextToken(); - return true; - } - else if (parseTypedef(node)) - { - return true; - } - else if (parseUsing(node)) - { - return true; - } - else if (parseTemplateDeclaration(node)) - { - return true; - } - else if (parseAccessSpecifier(node)) - { - return true; - } - else if (parseQ_PROPERTY(node)) - { - return true; - } - else if (parseQ_ENUMS(node)) - { - return true; - } - else if (parseQ_ENUM(node)) - { + if (token_stream.lookAhead() == ';') { + nextToken(); + return true; + } else if (token_stream.lookAhead() == Token_Q_OBJECT || token_stream.lookAhead() == Token_K_DCOP) { + nextToken(); + return true; + } else if (parseTypedef(node)) { + return true; + } else if (parseUsing(node)) { + return true; + } else if (parseTemplateDeclaration(node)) { + return true; + } else if (parseAccessSpecifier(node)) { + return true; + } else if (parseQ_PROPERTY(node)) { + return true; + } else if (parseQ_ENUMS(node)) { + return true; + } else if (parseQ_ENUM(node)) { return true; } rewind(start); - const ListNode *cv = 0; + const ListNode* cv = 0; const ListNode* storageSpec = 0; // consume all qualifiers/specifiers - while (parseCvQualify(cv) || parseStorageClassSpecifier(storageSpec)) - { + while (parseCvQualify(cv) || parseStorageClassSpecifier(storageSpec)) { ; } - TypeSpecifierAST *spec = 0; - if (parseEnumSpecifier(spec) || parseClassSpecifier(spec)) - { - parseCvQualify(cv); - spec->cv = cv; + TypeSpecifierAST* spec = 0; + if (parseEnumSpecifier(spec) || parseClassSpecifier(spec)) { + parseCvQualify(cv); + spec->cv = cv; - const ListNode *declarators = 0; - parseInitDeclaratorList(declarators); - ADVANCE(';', ";"); + const ListNode* declarators = 0; + parseInitDeclaratorList(declarators); + ADVANCE(';', ";"); - SimpleDeclarationAST *ast = CreateNode(_M_pool); - ast->type_specifier = spec; - ast->init_declarators = declarators; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; + SimpleDeclarationAST* ast = CreateNode(_M_pool); + ast->type_specifier = spec; + ast->init_declarators = declarators; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; - return true; - } + return true; + } rewind(start); return parseDeclarationInternal(node); } -bool Parser::parseCtorInitializer(CtorInitializerAST *&node) +bool Parser::parseCtorInitializer(CtorInitializerAST*& node) { std::size_t start = token_stream.cursor(); CHECK(':'); - CtorInitializerAST *ast = CreateNode(_M_pool); + CtorInitializerAST* ast = CreateNode(_M_pool); ast->colon = start; - if (!parseMemInitializerList(ast->member_initializers)) - { - reportError(("Member initializers expected")); - } + if (!parseMemInitializerList(ast->member_initializers)) { + reportError(("Member initializers expected")); + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -2298,50 +2051,41 @@ bool Parser::parseCtorInitializer(CtorInitializerAST *&node) return true; } -bool Parser::parseElaboratedTypeSpecifier(TypeSpecifierAST *&node) +bool Parser::parseElaboratedTypeSpecifier(TypeSpecifierAST*& node) { std::size_t start = token_stream.cursor(); int tk = token_stream.lookAhead(); - if (tk == Token_class || - tk == Token_struct || - tk == Token_union || - tk == Token_enum || - tk == Token_typename) - { - std::size_t type = token_stream.cursor(); - nextToken(); + if (tk == Token_class || tk == Token_struct || tk == Token_union || tk == Token_enum || tk == Token_typename) { + std::size_t type = token_stream.cursor(); + nextToken(); - NameAST *name = 0; - if (parseName(name, true)) - { - ElaboratedTypeSpecifierAST *ast - = CreateNode(_M_pool); + NameAST* name = 0; + if (parseName(name, true)) { + ElaboratedTypeSpecifierAST* ast = CreateNode(_M_pool); - ast->type = type; - ast->name = name; + ast->type = type; + ast->name = name; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; - return true; - } + return true; } + } rewind(start); return false; } -bool Parser::parseExceptionSpecification(ExceptionSpecificationAST *&node) +bool Parser::parseExceptionSpecification(ExceptionSpecificationAST*& node) { std::size_t start = token_stream.cursor(); - if (token_stream.lookAhead() == Token_noexcept) - { + if (token_stream.lookAhead() == Token_noexcept) { // ignore noexcept nextToken(); - if (token_stream.lookAhead() == '(') - { + if (token_stream.lookAhead() == '(') { nextToken(); ExpressionAST* node; parseCommaExpression(node); @@ -2353,18 +2097,14 @@ bool Parser::parseExceptionSpecification(ExceptionSpecificationAST *&node) CHECK(Token_throw); ADVANCE('(', "("); - ExceptionSpecificationAST *ast - = CreateNode(_M_pool); + ExceptionSpecificationAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == Token_ellipsis) - { - ast->ellipsis = token_stream.cursor(); - nextToken(); - } - else - { - parseTypeIdList(ast->type_ids); - } + if (token_stream.lookAhead() == Token_ellipsis) { + ast->ellipsis = token_stream.cursor(); + nextToken(); + } else { + parseTypeIdList(ast->type_ids); + } ADVANCE(')', ")"); @@ -2374,27 +2114,25 @@ bool Parser::parseExceptionSpecification(ExceptionSpecificationAST *&node) return true; } -bool Parser::parseEnumerator(EnumeratorAST *&node) +bool Parser::parseEnumerator(EnumeratorAST*& node) { std::size_t start = token_stream.cursor(); CHECK(Token_identifier); std::size_t id = token_stream.cursor() - 1; - EnumeratorAST *ast = CreateNode(_M_pool); + EnumeratorAST* ast = CreateNode(_M_pool); ast->id = id; skipAttributes(); - if (token_stream.lookAhead() == '=') - { - nextToken(); + if (token_stream.lookAhead() == '=') { + nextToken(); - if (!parseConstantExpression(ast->expression)) - { - reportError(("Constant expression expected")); - } + if (!parseConstantExpression(ast->expression)) { + reportError(("Constant expression expected")); } + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -2402,34 +2140,31 @@ bool Parser::parseEnumerator(EnumeratorAST *&node) return true; } -bool Parser::parseInitDeclarator(InitDeclaratorAST *&node) +bool Parser::parseInitDeclarator(InitDeclaratorAST*& node) { std::size_t start = token_stream.cursor(); - if (token_stream.lookAhead(0) == Token_ellipsis) - { - // for now just ignore variadic parameters - token_stream.nextToken(); - return true; - } - - DeclaratorAST *decl = 0; - if (!parseDeclarator(decl)) - { - return false; - } + if (token_stream.lookAhead(0) == Token_ellipsis) { + // for now just ignore variadic parameters + token_stream.nextToken(); + return true; + } - if (token_stream.lookAhead(0) == Token_asm) - { - nextToken(); - skip('(', ')'); - nextToken(); - } + DeclaratorAST* decl = 0; + if (!parseDeclarator(decl)) { + return false; + } + + if (token_stream.lookAhead(0) == Token_asm) { + nextToken(); + skip('(', ')'); + nextToken(); + } - InitializerAST *init = 0; + InitializerAST* init = 0; parseInitializer(init, !decl->parameter_declaration_clause); - InitDeclaratorAST *ast = CreateNode(_M_pool); + InitDeclaratorAST* ast = CreateNode(_M_pool); ast->declarator = decl; ast->initializer = init; @@ -2439,30 +2174,28 @@ bool Parser::parseInitDeclarator(InitDeclaratorAST *&node) return true; } -bool Parser::parseBaseClause(BaseClauseAST *&node) +bool Parser::parseBaseClause(BaseClauseAST*& node) { std::size_t start = token_stream.cursor(); CHECK(':'); - BaseSpecifierAST *baseSpec = 0; + BaseSpecifierAST* baseSpec = 0; if (!parseBaseSpecifier(baseSpec)) return false; - BaseClauseAST *ast = CreateNode(_M_pool); + BaseClauseAST* ast = CreateNode(_M_pool); ast->base_specifiers = snoc(ast->base_specifiers, baseSpec, _M_pool); - while (token_stream.lookAhead() == ',') - { - nextToken(); + while (token_stream.lookAhead() == ',') { + nextToken(); - if (!parseBaseSpecifier(baseSpec)) - { - reportError(("Base class specifier expected")); - break; - } - ast->base_specifiers = snoc(ast->base_specifiers, baseSpec, _M_pool); + if (!parseBaseSpecifier(baseSpec)) { + reportError(("Base class specifier expected")); + break; } + ast->base_specifiers = snoc(ast->base_specifiers, baseSpec, _M_pool); + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -2470,7 +2203,7 @@ bool Parser::parseBaseClause(BaseClauseAST *&node) return true; } -bool Parser::parseInitializer(InitializerAST *&node, bool allowNewStyle) +bool Parser::parseInitializer(InitializerAST*& node, bool allowNewStyle) { std::size_t start = token_stream.cursor(); @@ -2478,36 +2211,26 @@ bool Parser::parseInitializer(InitializerAST *&node, bool allowNewStyle) if (tk != '=' && tk != '(' && !(allowNewStyle && tk == '{')) return false; - InitializerAST *ast = CreateNode(_M_pool); + InitializerAST* ast = CreateNode(_M_pool); - if (tk == '=') - { + if (tk == '=') { + nextToken(); + tk = token_stream.lookAhead(); + // this is also used for methods: + if (tk == Token_delete) { + ast->isDeleted = true; nextToken(); - tk = token_stream.lookAhead(); - // this is also used for methods: - if (tk == Token_delete) - { - ast->isDeleted = true; - nextToken(); - } - else if (tk == Token_default) - { - ast->isDefault = true; - nextToken(); - } - else if (!parseInitializerClause(ast->initializer_clause)) - { - reportError(("Initializer clause expected")); - } - } - else if (tk == '(') - { + } else if (tk == Token_default) { + ast->isDefault = true; nextToken(); - parseCommaExpression(ast->expression); - CHECK(')'); + } else if (!parseInitializerClause(ast->initializer_clause)) { + reportError(("Initializer clause expected")); } - else if (tk == '{') - { + } else if (tk == '(') { + nextToken(); + parseCommaExpression(ast->expression); + CHECK(')'); + } else if (tk == '{') { nextToken(); if (token_stream.lookAhead() != '}') { parseCommaExpression(ast->expression); @@ -2522,42 +2245,39 @@ bool Parser::parseInitializer(InitializerAST *&node, bool allowNewStyle) return true; } -bool Parser::parseMemInitializerList(const ListNode *&node) +bool Parser::parseMemInitializerList(const ListNode*& node) { - MemInitializerAST *init = 0; + MemInitializerAST* init = 0; if (!parseMemInitializer(init)) return false; node = snoc(node, init, _M_pool); - while (token_stream.lookAhead() == ',') - { - nextToken(); + while (token_stream.lookAhead() == ',') { + nextToken(); - if (!parseMemInitializer(init)) - break; + if (!parseMemInitializer(init)) + break; - node = snoc(node, init, _M_pool); - } + node = snoc(node, init, _M_pool); + } return true; } -bool Parser::parseMemInitializer(MemInitializerAST *&node) +bool Parser::parseMemInitializer(MemInitializerAST*& node) { std::size_t start = token_stream.cursor(); - NameAST *initId = 0; - if (!parseName(initId, true)) - { - reportError(("Identifier expected")); - return false; - } + NameAST* initId = 0; + if (!parseName(initId, true)) { + reportError(("Identifier expected")); + return false; + } ExpressionAST* expr = 0; - if (token_stream.lookAhead() == '{') - { + if (token_stream.lookAhead() == '{') { // new style initializers ADVANCE('{', "{"); if (token_stream.lookAhead() != '}') { @@ -2565,15 +2285,13 @@ bool Parser::parseMemInitializer(MemInitializerAST *&node) } // new-style initializers may be empty (default value) ADVANCE('}', "}"); - } - else - { + } else { ADVANCE('(', "("); parseCommaExpression(expr); ADVANCE(')', ")"); } - MemInitializerAST *ast = CreateNode(_M_pool); + MemInitializerAST* ast = CreateNode(_M_pool); ast->initializer_id = initId; ast->expression = expr; @@ -2583,66 +2301,54 @@ bool Parser::parseMemInitializer(MemInitializerAST *&node) return true; } -bool Parser::parseTypeIdList(const ListNode *&node) +bool Parser::parseTypeIdList(const ListNode*& node) { - TypeIdAST *typeId = 0; + TypeIdAST* typeId = 0; if (!parseTypeId(typeId)) return false; node = snoc(node, typeId, _M_pool); - while (token_stream.lookAhead() == ',') - { - nextToken(); - if (parseTypeId(typeId)) - { - node = snoc(node, typeId, _M_pool); - } - else - { - reportError(("Type id expected")); - break; - } + while (token_stream.lookAhead() == ',') { + nextToken(); + if (parseTypeId(typeId)) { + node = snoc(node, typeId, _M_pool); + } else { + reportError(("Type id expected")); + break; } + } return true; } -bool Parser::parseBaseSpecifier(BaseSpecifierAST *&node) +bool Parser::parseBaseSpecifier(BaseSpecifierAST*& node) { std::size_t start = token_stream.cursor(); - BaseSpecifierAST *ast = CreateNode(_M_pool); + BaseSpecifierAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == Token_virtual) - { - ast->virt = token_stream.cursor(); - nextToken(); + if (token_stream.lookAhead() == Token_virtual) { + ast->virt = token_stream.cursor(); + nextToken(); - int tk = token_stream.lookAhead(); - if (tk == Token_public || tk == Token_protected - || tk == Token_private) - { - ast->access_specifier = token_stream.cursor(); - nextToken(); - } + int tk = token_stream.lookAhead(); + if (tk == Token_public || tk == Token_protected || tk == Token_private) { + ast->access_specifier = token_stream.cursor(); + nextToken(); + } + } else { + int tk = token_stream.lookAhead(); + if (tk == Token_public || tk == Token_protected || tk == Token_private) { + ast->access_specifier = token_stream.cursor(); + nextToken(); } - else - { - int tk = token_stream.lookAhead(); - if (tk == Token_public || tk == Token_protected - || tk == Token_private) - { - ast->access_specifier = token_stream.cursor(); - nextToken(); - } - if (token_stream.lookAhead() == Token_virtual) - { - ast->virt = token_stream.cursor(); - nextToken(); - } + if (token_stream.lookAhead() == Token_virtual) { + ast->virt = token_stream.cursor(); + nextToken(); } + } if (!parseName(ast->name, true)) reportError(("Class name expected")); @@ -2653,29 +2359,25 @@ bool Parser::parseBaseSpecifier(BaseSpecifierAST *&node) return true; } -bool Parser::parseInitializerClause(InitializerClauseAST *&node) +bool Parser::parseInitializerClause(InitializerClauseAST*& node) { std::size_t start = token_stream.cursor(); - InitializerClauseAST *ast = CreateNode(_M_pool); + InitializerClauseAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == '{') - { + if (token_stream.lookAhead() == '{') { #if defined(__GNUC__) -#pragma GCC warning "implement me" + #pragma GCC warning "implement me" #endif - if (skip('{','}')) - nextToken(); - else - reportError(("} missing")); - } - else - { - if (!parseAssignmentExpression(ast->expression)) - { - //reportError(("Expression expected")); - } + if (skip('{', '}')) + nextToken(); + else + reportError(("} missing")); + } else { + if (!parseAssignmentExpression(ast->expression)) { + //reportError(("Expression expected")); } + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -2683,117 +2385,98 @@ bool Parser::parseInitializerClause(InitializerClauseAST *&node) return true; } -bool Parser::parsePtrToMember(PtrToMemberAST *&node) +bool Parser::parsePtrToMember(PtrToMemberAST*& node) { #if defined(__GNUC__) -#pragma GCC warning "implemente me (AST)" + #pragma GCC warning "implemente me (AST)" #endif std::size_t start = token_stream.cursor(); - if (token_stream.lookAhead() == Token_scope) - { - nextToken(); - } - - UnqualifiedNameAST *name = 0; - while (token_stream.lookAhead() == Token_identifier) - { - if (!parseUnqualifiedName(name)) - break; + if (token_stream.lookAhead() == Token_scope) { + nextToken(); + } - if (token_stream.lookAhead() == Token_scope - && token_stream.lookAhead(1) == '*') - { - nextToken(); - nextToken(); + UnqualifiedNameAST* name = 0; + while (token_stream.lookAhead() == Token_identifier) { + if (!parseUnqualifiedName(name)) + break; - PtrToMemberAST *ast = CreateNode(_M_pool); - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; + if (token_stream.lookAhead() == Token_scope && token_stream.lookAhead(1) == '*') { + nextToken(); + nextToken(); - return true; - } + PtrToMemberAST* ast = CreateNode(_M_pool); + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; - if (token_stream.lookAhead() == Token_scope) - nextToken(); + return true; } + if (token_stream.lookAhead() == Token_scope) + nextToken(); + } + rewind(start); return false; } void Parser::resolveRightShift() { - if (token_stream.lookAhead() == Token_shift_right) - { - std::size_t index = token_stream.cursor(); - token_stream[index].kind = '>'; - token_stream[index + 1].kind = '>'; - } + if (token_stream.lookAhead() == Token_shift_right) { + std::size_t index = token_stream.cursor(); + token_stream[index].kind = '>'; + token_stream[index + 1].kind = '>'; + } } -bool Parser::parseUnqualifiedName(UnqualifiedNameAST *&node, - bool parseTemplateId) +bool Parser::parseUnqualifiedName(UnqualifiedNameAST*& node, bool parseTemplateId) { std::size_t start = token_stream.cursor(); std::size_t tilde = 0; std::size_t id = 0; - OperatorFunctionIdAST *operator_id = 0; - - if (token_stream.lookAhead() == Token_identifier) - { - id = token_stream.cursor(); - nextToken(); - } - else if (token_stream.lookAhead() == '~' - && token_stream.lookAhead(1) == Token_identifier) - { - tilde = token_stream.cursor(); - nextToken(); // skip ~ + OperatorFunctionIdAST* operator_id = 0; - id = token_stream.cursor(); - nextToken(); // skip classname - } - else if (token_stream.lookAhead() == Token_operator) - { - if (!parseOperatorFunctionId(operator_id)) - return false; - } - else - { + if (token_stream.lookAhead() == Token_identifier) { + id = token_stream.cursor(); + nextToken(); + } else if (token_stream.lookAhead() == '~' && token_stream.lookAhead(1) == Token_identifier) { + tilde = token_stream.cursor(); + nextToken(); // skip ~ + + id = token_stream.cursor(); + nextToken(); // skip classname + } else if (token_stream.lookAhead() == Token_operator) { + if (!parseOperatorFunctionId(operator_id)) return false; - } + } else { + return false; + } - UnqualifiedNameAST *ast = CreateNode(_M_pool); + UnqualifiedNameAST* ast = CreateNode(_M_pool); ast->tilde = tilde; ast->id = id; ast->operator_id = operator_id; - if (parseTemplateId && !tilde) - { - std::size_t index = token_stream.cursor(); + if (parseTemplateId && !tilde) { + std::size_t index = token_stream.cursor(); - if (token_stream.lookAhead() == '<') - { - nextToken(); + if (token_stream.lookAhead() == '<') { + nextToken(); - // optional template arguments - parseTemplateArgumentList(ast->template_arguments); - - resolveRightShift(); - if (token_stream.lookAhead() == '>') - { - nextToken(); - } - else - { - ast->template_arguments = 0; - rewind(index); - } - } + // optional template arguments + parseTemplateArgumentList(ast->template_arguments); + + resolveRightShift(); + if (token_stream.lookAhead() == '>') { + nextToken(); + } else { + ast->template_arguments = 0; + rewind(index); + } } + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -2801,20 +2484,19 @@ bool Parser::parseUnqualifiedName(UnqualifiedNameAST *&node, return true; } -bool Parser::parseStringLiteral(StringLiteralAST *&node) +bool Parser::parseStringLiteral(StringLiteralAST*& node) { std::size_t start = token_stream.cursor(); if (token_stream.lookAhead() != Token_string_literal) return false; - StringLiteralAST *ast = CreateNode(_M_pool); - - while (token_stream.lookAhead() == Token_string_literal) - { - ast->literals = snoc(ast->literals, token_stream.cursor(), _M_pool); - nextToken(); - } + StringLiteralAST* ast = CreateNode(_M_pool); + + while (token_stream.lookAhead() == Token_string_literal) { + ast->literals = snoc(ast->literals, token_stream.cursor(), _M_pool); + nextToken(); + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -2822,16 +2504,16 @@ bool Parser::parseStringLiteral(StringLiteralAST *&node) return true; } -bool Parser::parseExpressionStatement(StatementAST *&node) +bool Parser::parseExpressionStatement(StatementAST*& node) { std::size_t start = token_stream.cursor(); - ExpressionAST *expr = 0; + ExpressionAST* expr = 0; parseCommaExpression(expr); ADVANCE(';', ";"); - ExpressionStatementAST *ast = CreateNode(_M_pool); + ExpressionStatementAST* ast = CreateNode(_M_pool); ast->expression = expr; UPDATE_POS(ast, start, token_stream.cursor()); @@ -2840,116 +2522,111 @@ bool Parser::parseExpressionStatement(StatementAST *&node) return true; } -bool Parser::parseStatement(StatementAST *&node) +bool Parser::parseStatement(StatementAST*& node) { std::size_t start = token_stream.cursor(); - switch(token_stream.lookAhead()) - { - case Token_while: - return parseWhileStatement(node); + switch (token_stream.lookAhead()) { + case Token_while: + return parseWhileStatement(node); - case Token_do: - return parseDoStatement(node); + case Token_do: + return parseDoStatement(node); - case Token_for: - return parseForStatement(node); + case Token_for: + return parseForStatement(node); - case Token_if: - return parseIfStatement(node); + case Token_if: + return parseIfStatement(node); - case Token_switch: - return parseSwitchStatement(node); + case Token_switch: + return parseSwitchStatement(node); - case Token_try: - return parseTryBlockStatement(node); + case Token_try: + return parseTryBlockStatement(node); - case Token_case: - case Token_default: - return parseLabeledStatement(node); + case Token_case: + case Token_default: + return parseLabeledStatement(node); - case Token_break: - case Token_continue: + case Token_break: + case Token_continue: #if defined(__GNUC__) -#pragma GCC warning "implement me" + #pragma GCC warning "implement me" #endif - nextToken(); - ADVANCE(';', ";"); - return true; + nextToken(); + ADVANCE(';', ";"); + return true; - case Token_goto: + case Token_goto: #if defined(__GNUC__) -#pragma GCC warning "implement me" + #pragma GCC warning "implement me" #endif - nextToken(); - ADVANCE(Token_identifier, "identifier"); - ADVANCE(';', ";"); - return true; + nextToken(); + ADVANCE(Token_identifier, "identifier"); + ADVANCE(';', ";"); + return true; - case Token_return: - { - nextToken(); - ExpressionAST *expr = 0; - parseCommaExpression(expr); + case Token_return: + { + nextToken(); + ExpressionAST* expr = 0; + parseCommaExpression(expr); - ADVANCE(';', ";"); + ADVANCE(';', ";"); - ReturnStatementAST *ast = CreateNode(_M_pool); - ast->expression = expr; + ReturnStatementAST* ast = CreateNode(_M_pool); + ast->expression = expr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; - case '{': - return parseCompoundStatement(node); + case '{': + return parseCompoundStatement(node); - case Token_identifier: - if (parseLabeledStatement(node)) - return true; - break; - } + case Token_identifier: + if (parseLabeledStatement(node)) + return true; + break; + } return parseExpressionOrDeclarationStatement(node); } -bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node) +bool Parser::parseExpressionOrDeclarationStatement(StatementAST*& node) { bool blocked = block_errors(true); std::size_t start = token_stream.cursor(); - StatementAST *decl_ast = 0; + StatementAST* decl_ast = 0; bool maybe_amb = parseDeclarationStatement(decl_ast); maybe_amb &= token_stream.kind(token_stream.cursor() - 1) == ';'; std::size_t end = token_stream.cursor(); rewind(start); - StatementAST *expr_ast = 0; + StatementAST* expr_ast = 0; maybe_amb &= parseExpressionStatement(expr_ast); maybe_amb &= token_stream.kind(token_stream.cursor() - 1) == ';'; - if (maybe_amb) - { - Q_ASSERT(decl_ast != 0 && expr_ast != 0); - ExpressionOrDeclarationStatementAST *ast - = CreateNode(_M_pool); - ast->declaration = decl_ast; - ast->expression = expr_ast; + if (maybe_amb) { + Q_ASSERT(decl_ast != 0 && expr_ast != 0); + ExpressionOrDeclarationStatementAST* ast = CreateNode(_M_pool); + ast->declaration = decl_ast; + ast->expression = expr_ast; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - else - { - rewind(std::max(end, token_stream.cursor())); + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } else { + rewind(std::max(end, token_stream.cursor())); - node = decl_ast; - if (!node) - node = expr_ast; - } + node = decl_ast; + if (!node) + node = expr_ast; + } block_errors(blocked); @@ -2959,44 +2636,40 @@ bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node) return node != 0; } -bool Parser::parseCondition(ConditionAST *&node, bool initRequired) +bool Parser::parseCondition(ConditionAST*& node, bool initRequired) { std::size_t start = token_stream.cursor(); - ConditionAST *ast = CreateNode(_M_pool); - TypeSpecifierAST *spec = 0; + ConditionAST* ast = CreateNode(_M_pool); + TypeSpecifierAST* spec = 0; - if (parseTypeSpecifier(spec)) - { - ast->type_specifier = spec; + if (parseTypeSpecifier(spec)) { + ast->type_specifier = spec; - std::size_t declarator_start = token_stream.cursor(); + std::size_t declarator_start = token_stream.cursor(); - DeclaratorAST *decl = 0; - if (!parseDeclarator(decl)) - { - rewind(declarator_start); - if (!initRequired && !parseAbstractDeclarator(decl)) - decl = 0; - } + DeclaratorAST* decl = 0; + if (!parseDeclarator(decl)) { + rewind(declarator_start); + if (!initRequired && !parseAbstractDeclarator(decl)) + decl = 0; + } - if (decl && (!initRequired || token_stream.lookAhead() == '=')) - { - ast->declarator = decl; + if (decl && (!initRequired || token_stream.lookAhead() == '=')) { + ast->declarator = decl; - if (token_stream.lookAhead() == '=') - { - nextToken(); + if (token_stream.lookAhead() == '=') { + nextToken(); - parseExpression(ast->expression); - } + parseExpression(ast->expression); + } - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; - return true; - } + return true; } + } rewind(start); @@ -3009,30 +2682,27 @@ bool Parser::parseCondition(ConditionAST *&node, bool initRequired) return true; } - -bool Parser::parseWhileStatement(StatementAST *&node) +bool Parser::parseWhileStatement(StatementAST*& node) { std::size_t start = token_stream.cursor(); ADVANCE(Token_while, "while"); - ADVANCE('(' , "("); + ADVANCE('(', "("); - ConditionAST *cond = 0; - if (!parseCondition(cond)) - { - reportError(("condition expected")); - return false; - } + ConditionAST* cond = 0; + if (!parseCondition(cond)) { + reportError(("condition expected")); + return false; + } ADVANCE(')', ")"); - StatementAST *body = 0; - if (!parseStatement(body)) - { - reportError(("statement expected")); - return false; - } + StatementAST* body = 0; + if (!parseStatement(body)) { + reportError(("statement expected")); + return false; + } - WhileStatementAST *ast = CreateNode(_M_pool); + WhileStatementAST* ast = CreateNode(_M_pool); ast->condition = cond; ast->statement = body; @@ -3042,33 +2712,31 @@ bool Parser::parseWhileStatement(StatementAST *&node) return true; } -bool Parser::parseDoStatement(StatementAST *&node) +bool Parser::parseDoStatement(StatementAST*& node) { std::size_t start = token_stream.cursor(); ADVANCE(Token_do, "do"); - StatementAST *body = 0; - if (!parseStatement(body)) - { - reportError(("statement expected")); - //return false; - } + StatementAST* body = 0; + if (!parseStatement(body)) { + reportError(("statement expected")); + //return false; + } ADVANCE_NR(Token_while, "while"); - ADVANCE_NR('(' , "("); + ADVANCE_NR('(', "("); - ExpressionAST *expr = 0; - if (!parseCommaExpression(expr)) - { - reportError(("expression expected")); - //return false; - } + ExpressionAST* expr = 0; + if (!parseCommaExpression(expr)) { + reportError(("expression expected")); + //return false; + } ADVANCE_NR(')', ")"); ADVANCE_NR(';', ";"); - DoStatementAST *ast = CreateNode(_M_pool); + DoStatementAST* ast = CreateNode(_M_pool); ast->statement = body; ast->expression = expr; @@ -3078,33 +2746,32 @@ bool Parser::parseDoStatement(StatementAST *&node) return true; } -bool Parser::parseForStatement(StatementAST *&node) +bool Parser::parseForStatement(StatementAST*& node) { std::size_t start = token_stream.cursor(); ADVANCE(Token_for, "for"); ADVANCE('(', "("); - StatementAST *init = 0; - if (!parseForInitStatement(init)) - { - reportError(("for initialization expected")); - return false; - } + StatementAST* init = 0; + if (!parseForInitStatement(init)) { + reportError(("for initialization expected")); + return false; + } - ConditionAST *cond = 0; + ConditionAST* cond = 0; parseCondition(cond); ADVANCE(';', ";"); - ExpressionAST *expr = 0; + ExpressionAST* expr = 0; parseCommaExpression(expr); ADVANCE(')', ")"); - StatementAST *body = 0; + StatementAST* body = 0; if (!parseStatement(body)) return false; - ForStatementAST *ast = CreateNode(_M_pool); + ForStatementAST* ast = CreateNode(_M_pool); ast->init_statement = init; ast->condition = cond; ast->expression = expr; @@ -3116,7 +2783,7 @@ bool Parser::parseForStatement(StatementAST *&node) return true; } -bool Parser::parseForInitStatement(StatementAST *&node) +bool Parser::parseForInitStatement(StatementAST*& node) { if (parseDeclarationStatement(node)) return true; @@ -3124,34 +2791,30 @@ bool Parser::parseForInitStatement(StatementAST *&node) return parseExpressionStatement(node); } -bool Parser::parseCompoundStatement(StatementAST *&node) +bool Parser::parseCompoundStatement(StatementAST*& node) { std::size_t start = token_stream.cursor(); CHECK('{'); - CompoundStatementAST *ast = CreateNode(_M_pool); + CompoundStatementAST* ast = CreateNode(_M_pool); - while (token_stream.lookAhead()) - { - if (token_stream.lookAhead() == '}') - break; + while (token_stream.lookAhead()) { + if (token_stream.lookAhead() == '}') + break; - std::size_t startStmt = token_stream.cursor(); + std::size_t startStmt = token_stream.cursor(); - StatementAST *stmt = 0; - if (!parseStatement(stmt)) - { - if (startStmt == token_stream.cursor()) - nextToken(); + StatementAST* stmt = 0; + if (!parseStatement(stmt)) { + if (startStmt == token_stream.cursor()) + nextToken(); - skipUntilStatement(); - } - else - { - ast->statements = snoc(ast->statements, stmt, _M_pool); - } + skipUntilStatement(); + } else { + ast->statements = snoc(ast->statements, stmt, _M_pool); } + } ADVANCE_NR('}', "}"); @@ -3161,44 +2824,40 @@ bool Parser::parseCompoundStatement(StatementAST *&node) return true; } -bool Parser::parseIfStatement(StatementAST *&node) +bool Parser::parseIfStatement(StatementAST*& node) { std::size_t start = token_stream.cursor(); ADVANCE(Token_if, "if"); - ADVANCE('(' , "("); + ADVANCE('(', "("); - IfStatementAST *ast = CreateNode(_M_pool); + IfStatementAST* ast = CreateNode(_M_pool); - ConditionAST *cond = 0; - if (!parseCondition(cond)) - { - reportError(("condition expected")); - return false; - } + ConditionAST* cond = 0; + if (!parseCondition(cond)) { + reportError(("condition expected")); + return false; + } ADVANCE(')', ")"); - StatementAST *stmt = 0; - if (!parseStatement(stmt)) - { - reportError(("statement expected")); - return false; - } + StatementAST* stmt = 0; + if (!parseStatement(stmt)) { + reportError(("statement expected")); + return false; + } ast->condition = cond; ast->statement = stmt; - if (token_stream.lookAhead() == Token_else) - { - nextToken(); + if (token_stream.lookAhead() == Token_else) { + nextToken(); - if (!parseStatement(ast->else_statement)) - { - reportError(("statement expected")); - return false; - } + if (!parseStatement(ast->else_statement)) { + reportError(("statement expected")); + return false; } + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -3206,29 +2865,27 @@ bool Parser::parseIfStatement(StatementAST *&node) return true; } -bool Parser::parseSwitchStatement(StatementAST *&node) +bool Parser::parseSwitchStatement(StatementAST*& node) { std::size_t start = token_stream.cursor(); ADVANCE(Token_switch, "switch"); - ADVANCE('(' , "("); + ADVANCE('(', "("); - ConditionAST *cond = 0; - if (!parseCondition(cond)) - { - reportError(("condition expected")); - return false; - } + ConditionAST* cond = 0; + if (!parseCondition(cond)) { + reportError(("condition expected")); + return false; + } ADVANCE(')', ")"); - StatementAST *stmt = 0; - if (!parseCompoundStatement(stmt)) - { - SYNTAX_ERROR(); - return false; - } + StatementAST* stmt = 0; + if (!parseCompoundStatement(stmt)) { + SYNTAX_ERROR(); + return false; + } - SwitchStatementAST *ast = CreateNode(_M_pool); + SwitchStatementAST* ast = CreateNode(_M_pool); ast->condition = cond; ast->statement = stmt; @@ -3238,105 +2895,91 @@ bool Parser::parseSwitchStatement(StatementAST *&node) return true; } -bool Parser::parseLabeledStatement(StatementAST *&node) +bool Parser::parseLabeledStatement(StatementAST*& node) { - switch(token_stream.lookAhead()) - { - case Token_identifier: - case Token_default: - if (token_stream.lookAhead(1) == ':') - { - nextToken(); - nextToken(); + switch (token_stream.lookAhead()) { + case Token_identifier: + case Token_default: + if (token_stream.lookAhead(1) == ':') { + nextToken(); + nextToken(); - StatementAST *stmt = 0; - if (parseStatement(stmt)) - { - node = stmt; - return true; - } - } - break; + StatementAST* stmt = 0; + if (parseStatement(stmt)) { + node = stmt; + return true; + } + } + break; - case Token_case: - { - nextToken(); - ExpressionAST *expr = 0; - if (!parseConstantExpression(expr)) - { - reportError(("expression expected")); - } - else if (token_stream.lookAhead() == Token_ellipsis) - { - nextToken(); - - ExpressionAST *expr2 = 0; - if (!parseConstantExpression(expr2)) - { - reportError(("expression expected")); - } - } - ADVANCE(':', ":"); - - StatementAST *stmt = 0; - if (parseStatement(stmt)) - { - node = stmt; - return true; - } + case Token_case: + { + nextToken(); + ExpressionAST* expr = 0; + if (!parseConstantExpression(expr)) { + reportError(("expression expected")); + } else if (token_stream.lookAhead() == Token_ellipsis) { + nextToken(); + + ExpressionAST* expr2 = 0; + if (!parseConstantExpression(expr2)) { + reportError(("expression expected")); } - break; + } + ADVANCE(':', ":"); + StatementAST* stmt = 0; + if (parseStatement(stmt)) { + node = stmt; + return true; } + } break; + } return false; } -bool Parser::parseBlockDeclaration(DeclarationAST *&node) +bool Parser::parseBlockDeclaration(DeclarationAST*& node) { - switch(token_stream.lookAhead()) - { - case Token_typedef: - return parseTypedef(node); - case Token_using: - return parseUsing(node); - case Token_asm: - return parseAsmDefinition(node); - case Token_namespace: - return parseNamespaceAliasDefinition(node); - } + switch (token_stream.lookAhead()) { + case Token_typedef: + return parseTypedef(node); + case Token_using: + return parseUsing(node); + case Token_asm: + return parseAsmDefinition(node); + case Token_namespace: + return parseNamespaceAliasDefinition(node); + } std::size_t start = token_stream.cursor(); - const ListNode *cv = 0; - const ListNode *storageSpec = 0; + const ListNode* cv = 0; + const ListNode* storageSpec = 0; // consume all qualifiers/specifiers - while (parseCvQualify(cv) || parseStorageClassSpecifier(storageSpec)) - { + while (parseCvQualify(cv) || parseStorageClassSpecifier(storageSpec)) { ; } - TypeSpecifierAST *spec = 0; - if (!parseTypeSpecifierOrClassSpec(spec)) - { // replace with simpleTypeSpecifier?!?! - rewind(start); - return false; - } + TypeSpecifierAST* spec = 0; + if (!parseTypeSpecifierOrClassSpec(spec)) { // replace with simpleTypeSpecifier?!?! + rewind(start); + return false; + } parseCvQualify(cv); spec->cv = cv; - const ListNode *declarators = 0; + const ListNode* declarators = 0; parseInitDeclaratorList(declarators); - if (token_stream.lookAhead() != ';') - { - rewind(start); - return false; - } + if (token_stream.lookAhead() != ';') { + rewind(start); + return false; + } nextToken(); - SimpleDeclarationAST *ast = CreateNode(_M_pool); + SimpleDeclarationAST* ast = CreateNode(_M_pool); ast->type_specifier = spec; ast->init_declarators = declarators; @@ -3346,24 +2989,22 @@ bool Parser::parseBlockDeclaration(DeclarationAST *&node) return true; } -bool Parser::parseNamespaceAliasDefinition(DeclarationAST *&node) +bool Parser::parseNamespaceAliasDefinition(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); CHECK(Token_namespace); - NamespaceAliasDefinitionAST *ast - = CreateNode(_M_pool); + NamespaceAliasDefinitionAST* ast = CreateNode(_M_pool); - ADVANCE(Token_identifier, "identifier"); + ADVANCE(Token_identifier, "identifier"); ast->namespace_name = token_stream.cursor() - 1; ADVANCE('=', "="); - if (!parseName(ast->alias_name)) - { - reportError(("Namespace name expected")); - } + if (!parseName(ast->alias_name)) { + reportError(("Namespace name expected")); + } ADVANCE(';', ";"); @@ -3373,15 +3014,15 @@ bool Parser::parseNamespaceAliasDefinition(DeclarationAST *&node) return true; } -bool Parser::parseDeclarationStatement(StatementAST *&node) +bool Parser::parseDeclarationStatement(StatementAST*& node) { std::size_t start = token_stream.cursor(); - DeclarationAST *decl = 0; + DeclarationAST* decl = 0; if (!parseBlockDeclaration(decl)) return false; - DeclarationStatementAST *ast = CreateNode(_M_pool); + DeclarationStatementAST* ast = CreateNode(_M_pool); ast->declaration = decl; UPDATE_POS(ast, start, token_stream.cursor()); @@ -3390,278 +3031,245 @@ bool Parser::parseDeclarationStatement(StatementAST *&node) return true; } -bool Parser::parseDeclarationInternal(DeclarationAST *&node) +bool Parser::parseDeclarationInternal(DeclarationAST*& node) { std::size_t start = token_stream.cursor(); // that is for the case '__declspec(dllexport) int ...' or // '__declspec(dllexport) inline int ...', etc. - WinDeclSpecAST *winDeclSpec = 0; + WinDeclSpecAST* winDeclSpec = 0; const ListNode* cv = 0; const ListNode* funSpec = 0; const ListNode* storageSpec = 0; // since it seems that the various specifiers can come in almost any order, // so just consume then until no specifiers are left. // Luckily the parse methods can be called multiple times, they just add to existing nodes. - while (skipAttributes() || - skipAlignas() || - (!winDeclSpec && parseWinDeclSpec(winDeclSpec)) || - parseCvQualify(cv) || - parseFunctionSpecifier(funSpec) || - parseStorageClassSpecifier(storageSpec)) + while (skipAttributes() || skipAlignas() || (!winDeclSpec && parseWinDeclSpec(winDeclSpec)) || parseCvQualify(cv) + || parseFunctionSpecifier(funSpec) || parseStorageClassSpecifier(storageSpec)) { ; } - int index = (int) token_stream.cursor(); - NameAST *name = 0; - if (parseName(name, true) && token_stream.lookAhead() == '(') - { - // no type specifier, maybe a constructor or a cast operator?? - - rewind(index); + int index = (int)token_stream.cursor(); + NameAST* name = 0; + if (parseName(name, true) && token_stream.lookAhead() == '(') { + // no type specifier, maybe a constructor or a cast operator?? - InitDeclaratorAST *declarator = 0; - if (parseInitDeclarator(declarator)) - { - switch(token_stream.lookAhead()) - { - case ';': - { - nextToken(); - - SimpleDeclarationAST *ast - = CreateNode(_M_pool); - - ast->storage_specifiers = storageSpec; - ast->function_specifiers = funSpec; - ast->init_declarators = snoc(ast->init_declarators, - declarator, _M_pool); - - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; - - case ':': - { - CtorInitializerAST *ctorInit = 0; - StatementAST *funBody = 0; - - if (parseCtorInitializer(ctorInit) - && parseFunctionBody(funBody)) - { - FunctionDefinitionAST *ast - = CreateNode(_M_pool); - - ast->storage_specifiers = storageSpec; - ast->function_specifiers = funSpec; - ast->init_declarator = declarator; - ast->function_body = funBody; - - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - - return true; - } - } - break; - - case '{': - { - StatementAST *funBody = 0; - if (parseFunctionBody(funBody)) - { - FunctionDefinitionAST *ast - = CreateNode(_M_pool); - - ast->storage_specifiers = storageSpec; - ast->function_specifiers = funSpec; - ast->init_declarator = declarator; - ast->function_body = funBody; - - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - - return true; - } - } - break; - - case '(': - case '[': - // ops!! it seems a declarator - goto start_decl; - break; - } + rewind(index); - } - } + InitDeclaratorAST* declarator = 0; + if (parseInitDeclarator(declarator)) { + switch (token_stream.lookAhead()) { + case ';': + { + nextToken(); - start_decl: - rewind(index); + SimpleDeclarationAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == Token_const - && token_stream.lookAhead(1) == Token_identifier - && token_stream.lookAhead(2) == '=') - { - // constant definition - nextToken(); // skip const + ast->storage_specifiers = storageSpec; + ast->function_specifiers = funSpec; + ast->init_declarators = snoc(ast->init_declarators, declarator, _M_pool); - const ListNode *declarators = 0; - if (!parseInitDeclaratorList(declarators)) - { - SYNTAX_ERROR(); - return false; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; - ADVANCE(';', ";"); + case ':': + { + CtorInitializerAST* ctorInit = 0; + StatementAST* funBody = 0; -#if defined(__GNUC__) -#pragma GCC warning "mark the ast as constant" -#endif - SimpleDeclarationAST *ast = CreateNode(_M_pool); - ast->init_declarators = declarators; + if (parseCtorInitializer(ctorInit) && parseFunctionBody(funBody)) { + FunctionDefinitionAST* ast = CreateNode(_M_pool); - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; + ast->storage_specifiers = storageSpec; + ast->function_specifiers = funSpec; + ast->init_declarator = declarator; + ast->function_body = funBody; - return true; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; - TypeSpecifierAST *spec = 0; - if (parseTypeSpecifier(spec)) - { - Q_ASSERT(spec != 0); + return true; + } + } break; - parseFunctionSpecifier(funSpec); // e.g. "void inline" + case '{': + { + StatementAST* funBody = 0; + if (parseFunctionBody(funBody)) { + FunctionDefinitionAST* ast = CreateNode(_M_pool); - spec->cv = cv; + ast->storage_specifiers = storageSpec; + ast->function_specifiers = funSpec; + ast->init_declarator = declarator; + ast->function_body = funBody; - const ListNode *declarators = 0; - InitDeclaratorAST *decl = 0; - int startDeclarator = (int) token_stream.cursor(); - bool maybeFunctionDefinition = false; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; - if (token_stream.lookAhead() != ';') - { - if (parseInitDeclarator(decl) && (token_stream.lookAhead() == '{' || token_stream.lookAhead() == Token_arrow)) - { - // function definition - maybeFunctionDefinition = true; - } - else - { - rewind(startDeclarator); - if (!parseInitDeclaratorList(declarators)) - { - SYNTAX_ERROR(); - return false; - } - } + return true; } + } break; - if (token_stream.lookAhead() == Token_arrow) { - // trailing return type, used in conjuction with "auto" return type - nextToken(); - TypeSpecifierAST* trailingReturnTypeSpec = 0; - if (!parseTypeSpecifier(trailingReturnTypeSpec)) { - // todo: replace "auto" return type? But I doubt we can handle these return types anyway. - SYNTAX_ERROR(); - return false; - } - maybeFunctionDefinition = true; + case '(': + case '[': + // ops!! it seems a declarator + goto start_decl; + break; } - - switch(token_stream.lookAhead()) - { - case ';': - { - nextToken(); - SimpleDeclarationAST *ast - = CreateNode(_M_pool); - - ast->storage_specifiers = storageSpec; - ast->function_specifiers = funSpec; - ast->type_specifier = spec; - ast->win_decl_specifiers = winDeclSpec; - ast->init_declarators = declarators; - - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; - - case '{': - { - if (!maybeFunctionDefinition) - { - SYNTAX_ERROR(); - return false; - } - - StatementAST *funBody = 0; - if (parseFunctionBody(funBody)) - { - FunctionDefinitionAST *ast - = CreateNode(_M_pool); - - ast->win_decl_specifiers = winDeclSpec; - ast->storage_specifiers = storageSpec; - ast->function_specifiers = funSpec; - ast->type_specifier = spec; - ast->init_declarator = decl; - ast->function_body = funBody; - - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - - return true; - } - } - break; - } // end switch } + } - SYNTAX_ERROR(); - return false; -} +start_decl: + rewind(index); -bool Parser::skipFunctionBody(StatementAST *& node) + if (token_stream.lookAhead() == Token_const && token_stream.lookAhead(1) == Token_identifier + && token_stream.lookAhead(2) == '=') + { + // constant definition + nextToken(); // skip const + + const ListNode* declarators = 0; + if (!parseInitDeclaratorList(declarators)) { + SYNTAX_ERROR(); + return false; + } + + ADVANCE(';', ";"); + +#if defined(__GNUC__) + #pragma GCC warning "mark the ast as constant" +#endif + SimpleDeclarationAST* ast = CreateNode(_M_pool); + ast->init_declarators = declarators; + + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + + return true; + } + + TypeSpecifierAST* spec = 0; + if (parseTypeSpecifier(spec)) { + Q_ASSERT(spec != 0); + + parseFunctionSpecifier(funSpec); // e.g. "void inline" + + spec->cv = cv; + + const ListNode* declarators = 0; + InitDeclaratorAST* decl = 0; + int startDeclarator = (int)token_stream.cursor(); + bool maybeFunctionDefinition = false; + + if (token_stream.lookAhead() != ';') { + if (parseInitDeclarator(decl) && (token_stream.lookAhead() == '{' || token_stream.lookAhead() == Token_arrow)) { + // function definition + maybeFunctionDefinition = true; + } else { + rewind(startDeclarator); + if (!parseInitDeclaratorList(declarators)) { + SYNTAX_ERROR(); + return false; + } + } + } + + if (token_stream.lookAhead() == Token_arrow) { + // trailing return type, used in conjuction with "auto" return type + nextToken(); + TypeSpecifierAST* trailingReturnTypeSpec = 0; + if (!parseTypeSpecifier(trailingReturnTypeSpec)) { + // todo: replace "auto" return type? But I doubt we can handle these return types anyway. + SYNTAX_ERROR(); + return false; + } + maybeFunctionDefinition = true; + } + + switch (token_stream.lookAhead()) { + case ';': + { + nextToken(); + SimpleDeclarationAST* ast = CreateNode(_M_pool); + + ast->storage_specifiers = storageSpec; + ast->function_specifiers = funSpec; + ast->type_specifier = spec; + ast->win_decl_specifiers = winDeclSpec; + ast->init_declarators = declarators; + + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; + + case '{': + { + if (!maybeFunctionDefinition) { + SYNTAX_ERROR(); + return false; + } + + StatementAST* funBody = 0; + if (parseFunctionBody(funBody)) { + FunctionDefinitionAST* ast = CreateNode(_M_pool); + + ast->win_decl_specifiers = winDeclSpec; + ast->storage_specifiers = storageSpec; + ast->function_specifiers = funSpec; + ast->type_specifier = spec; + ast->init_declarator = decl; + ast->function_body = funBody; + + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + + return true; + } + } break; + } // end switch + } + + SYNTAX_ERROR(); + return false; +} + +bool Parser::skipFunctionBody(StatementAST*& node) { std::size_t start = token_stream.cursor(); ADVANCE('{', "{"); int braceCount = 1; - while (braceCount) - { - int tk = token_stream.lookAhead(); - switch (tk) - { - // handle opening braces: - case '{': - braceCount++; - break; - // handle closing braces: - case '}': - braceCount--; - break; - case Token_EOF: - reportError("unexpected EOF while skipping block"); - braceCount = 0; - break; - default: - // skip everything else - ; - } - nextToken(); + while (braceCount) { + int tk = token_stream.lookAhead(); + switch (tk) { + // handle opening braces: + case '{': + braceCount++; + break; + // handle closing braces: + case '}': + braceCount--; + break; + case Token_EOF: + reportError("unexpected EOF while skipping block"); + braceCount = 0; + break; + default: + // skip everything else + ; } + nextToken(); + } CompoundStatementAST* ast = CreateNode(_M_pool); UPDATE_POS(ast, start, token_stream.cursor()); node = ast; return true; } -bool Parser::parseFunctionBody(StatementAST *&node) +bool Parser::parseFunctionBody(StatementAST*& node) { if (control->skipFunctionBody()) return skipFunctionBody(node); @@ -3669,7 +3277,7 @@ bool Parser::parseFunctionBody(StatementAST *&node) return parseCompoundStatement(node); } -bool Parser::parseTypeSpecifierOrClassSpec(TypeSpecifierAST *&node) +bool Parser::parseTypeSpecifierOrClassSpec(TypeSpecifierAST*& node) { if (parseClassSpecifier(node)) return true; @@ -3681,112 +3289,101 @@ bool Parser::parseTypeSpecifierOrClassSpec(TypeSpecifierAST *&node) return false; } -bool Parser::parseTryBlockStatement(StatementAST *&node) +bool Parser::parseTryBlockStatement(StatementAST*& node) { #if defined(__GNUC__) -#pragma GCC warning "implement me" + #pragma GCC warning "implement me" #endif CHECK(Token_try); - StatementAST *stmt = 0; - if (!parseCompoundStatement(stmt)) - { - SYNTAX_ERROR(); - return false; - } + StatementAST* stmt = 0; + if (!parseCompoundStatement(stmt)) { + SYNTAX_ERROR(); + return false; + } - if (token_stream.lookAhead() != Token_catch) - { - reportError(("catch expected")); - return false; - } + if (token_stream.lookAhead() != Token_catch) { + reportError(("catch expected")); + return false; + } - while (token_stream.lookAhead() == Token_catch) - { + while (token_stream.lookAhead() == Token_catch) { + nextToken(); + ADVANCE('(', "("); + ConditionAST* cond = 0; + if (token_stream.lookAhead() == Token_ellipsis) { nextToken(); - ADVANCE('(', "("); - ConditionAST *cond = 0; - if (token_stream.lookAhead() == Token_ellipsis) - { - nextToken(); - } - else if (!parseCondition(cond, false)) - { - reportError(("condition expected")); - return false; - } - ADVANCE(')', ")"); + } else if (!parseCondition(cond, false)) { + reportError(("condition expected")); + return false; + } + ADVANCE(')', ")"); - StatementAST *body = 0; - if (!parseCompoundStatement(body)) - { - SYNTAX_ERROR(); - return false; - } + StatementAST* body = 0; + if (!parseCompoundStatement(body)) { + SYNTAX_ERROR(); + return false; } + } node = stmt; return true; } -bool Parser::parsePrimaryExpression(ExpressionAST *&node) +bool Parser::parsePrimaryExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); - PrimaryExpressionAST *ast = CreateNode(_M_pool); + PrimaryExpressionAST* ast = CreateNode(_M_pool); - switch(token_stream.lookAhead()) - { - case Token_string_literal: - parseStringLiteral(ast->literal); - break; + switch (token_stream.lookAhead()) { + case Token_string_literal: + parseStringLiteral(ast->literal); + break; - case Token_ellipsis: // "..." can occur in constexpr of variadic templates - case Token_number_literal: - case Token_char_literal: - case Token_true: - case Token_false: - case Token_this: - ast->token = token_stream.cursor(); - nextToken(); - break; + case Token_ellipsis: // "..." can occur in constexpr of variadic templates + case Token_number_literal: + case Token_char_literal: + case Token_true: + case Token_false: + case Token_this: + ast->token = token_stream.cursor(); + nextToken(); + break; - case '(': - nextToken(); + case '(': + nextToken(); - if (token_stream.lookAhead() == '{') - { - if (!parseCompoundStatement(ast->expression_statement)) - return false; - } - else - { - if (!parseExpression(ast->sub_expression)) - return false; - } + if (token_stream.lookAhead() == '{') { + if (!parseCompoundStatement(ast->expression_statement)) + return false; + } else { + if (!parseExpression(ast->sub_expression)) + return false; + } - CHECK(')'); - break; + CHECK(')'); + break; - case '{': - nextToken(); + case '{': + nextToken(); - // support for new-style initializers - if (token_stream.lookAhead() != '}' && !parseExpression(ast->sub_expression)) { - return false; - } + // support for new-style initializers + if (token_stream.lookAhead() != '}' && !parseExpression(ast->sub_expression)) { + return false; + } - CHECK('}'); - break; + CHECK('}'); + break; // case '[': // TODO: parse lambda expression - default: - if (!parseName(ast->name, true)) // this can also be a template - return false; + default: + if (!parseName(ast->name, true)) // this can also be a template + return false; - break; - } + break; + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -3794,7 +3391,6 @@ bool Parser::parsePrimaryExpression(ExpressionAST *&node) return true; } - /* postfix-expression-internal: [ expression ] @@ -3804,99 +3400,96 @@ bool Parser::parsePrimaryExpression(ExpressionAST *&node) ++ -- */ -bool Parser::parsePostfixExpressionInternal(ExpressionAST *&node) +bool Parser::parsePostfixExpressionInternal(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); - switch (token_stream.lookAhead()) - { - case '[': - { - nextToken(); - ExpressionAST *expr = 0; - parseExpression(expr); - CHECK(']'); + switch (token_stream.lookAhead()) { + case '[': + { + nextToken(); + ExpressionAST* expr = 0; + parseExpression(expr); + CHECK(']'); - SubscriptExpressionAST *ast - = CreateNode(_M_pool); + SubscriptExpressionAST* ast = CreateNode(_M_pool); - ast->subscript = expr; + ast->subscript = expr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; - case '(': - { - nextToken(); - ExpressionAST *expr = 0; - parseExpression(expr); - CHECK(')'); + case '(': + { + nextToken(); + ExpressionAST* expr = 0; + parseExpression(expr); + CHECK(')'); - FunctionCallAST *ast = CreateNode(_M_pool); - ast->arguments = expr; + FunctionCallAST* ast = CreateNode(_M_pool); + ast->arguments = expr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; - case '.': - case Token_arrow: - { - std::size_t op = token_stream.cursor(); - nextToken(); + case '.': + case Token_arrow: + { + std::size_t op = token_stream.cursor(); + nextToken(); - std::size_t templ = 0; - if (token_stream.lookAhead() == Token_template) - { - templ = token_stream.cursor(); - nextToken(); - } - - std::size_t saved = token_stream.cursor(); - NameAST *name = 0; - - if (parseName(name, true) && name->unqualified_name - && name->unqualified_name->template_arguments != 0 - && token_stream.lookAhead() == '(') { - // a template method call - // ### reverse the logic - } else { - rewind(saved); - name = 0; - - if (! parseName (name, templ != 0)) - return false; - } + std::size_t templ = 0; + if (token_stream.lookAhead() == Token_template) { + templ = token_stream.cursor(); + nextToken(); + } - ClassMemberAccessAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->name = name; + std::size_t saved = token_stream.cursor(); + NameAST* name = 0; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; + if (parseName(name, true) && name->unqualified_name && name->unqualified_name->template_arguments != 0 + && token_stream.lookAhead() == '(') + { + // a template method call + // ### reverse the logic + } else { + rewind(saved); + name = 0; - case Token_incr: - case Token_decr: - { - std::size_t op = token_stream.cursor(); - nextToken(); + if (!parseName(name, templ != 0)) + return false; + } - IncrDecrExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; + ClassMemberAccessAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->name = name; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; - default: - return false; - } + case Token_incr: + case Token_decr: + { + std::size_t op = token_stream.cursor(); + nextToken(); + + IncrDecrExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; + + default: + return false; + } } /* @@ -3904,312 +3497,282 @@ bool Parser::parsePostfixExpressionInternal(ExpressionAST *&node) simple-type-specifier ( expression-list [opt] ) primary-expression postfix-expression-internal* */ -bool Parser::parsePostfixExpression(ExpressionAST *&node) +bool Parser::parsePostfixExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); - switch (token_stream.lookAhead()) - { - case Token_dynamic_cast: - case Token_static_cast: - case Token_reinterpret_cast: - case Token_const_cast: - { - std::size_t castOp = token_stream.cursor(); - nextToken(); + switch (token_stream.lookAhead()) { + case Token_dynamic_cast: + case Token_static_cast: + case Token_reinterpret_cast: + case Token_const_cast: + { + std::size_t castOp = token_stream.cursor(); + nextToken(); - CHECK('<'); - TypeIdAST *typeId = 0; - parseTypeId(typeId); - CHECK('>'); + CHECK('<'); + TypeIdAST* typeId = 0; + parseTypeId(typeId); + CHECK('>'); - CHECK('('); - ExpressionAST *expr = 0; - parseCommaExpression(expr); - CHECK(')'); + CHECK('('); + ExpressionAST* expr = 0; + parseCommaExpression(expr); + CHECK(')'); - CppCastExpressionAST *ast = CreateNode(_M_pool); - ast->op = castOp; - ast->type_id = typeId; - ast->expression = expr; + CppCastExpressionAST* ast = CreateNode(_M_pool); + ast->op = castOp; + ast->type_id = typeId; + ast->expression = expr; - ExpressionAST *e = 0; - while (parsePostfixExpressionInternal(e)) - { - ast->sub_expressions = snoc(ast->sub_expressions, e, _M_pool); - } + ExpressionAST* e = 0; + while (parsePostfixExpressionInternal(e)) { + ast->sub_expressions = snoc(ast->sub_expressions, e, _M_pool); + } - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; - case Token_typename: - { - std::size_t token = token_stream.cursor(); - nextToken(); + case Token_typename: + { + std::size_t token = token_stream.cursor(); + nextToken(); - NameAST* name = 0; - if (!parseName(name, true)) - return false; + NameAST* name = 0; + if (!parseName(name, true)) + return false; - CHECK('('); - ExpressionAST *expr = 0; - parseCommaExpression(expr); - CHECK(')'); + CHECK('('); + ExpressionAST* expr = 0; + parseCommaExpression(expr); + CHECK(')'); - TypeIdentificationAST *ast = CreateNode(_M_pool); - ast->typename_token = token; - ast->name = name; - ast->expression = expr; + TypeIdentificationAST* ast = CreateNode(_M_pool); + ast->typename_token = token; + ast->name = name; + ast->expression = expr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; - case Token_typeid: - { - nextToken(); + case Token_typeid: + { + nextToken(); - CHECK('('); - TypeIdAST *typeId = 0; - parseTypeId(typeId); - CHECK(')'); + CHECK('('); + TypeIdAST* typeId = 0; + parseTypeId(typeId); + CHECK(')'); - TypeIdentificationAST *ast = CreateNode(_M_pool); - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; + TypeIdentificationAST* ast = CreateNode(_M_pool); + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; - default: - break; - } + default: + break; + } std::size_t saved_pos = token_stream.cursor(); - TypeSpecifierAST *typeSpec = 0; - ExpressionAST *expr = 0; + TypeSpecifierAST* typeSpec = 0; + ExpressionAST* expr = 0; // let's try to parse a type - NameAST *name = 0; - if (parseName(name, true)) - { - Q_ASSERT(name->unqualified_name != 0); - - bool has_template_args - = name->unqualified_name->template_arguments != 0; - - if (has_template_args && token_stream.lookAhead() == '(') - { - ExpressionAST *cast_expr = 0; - if (parseCastExpression(cast_expr) - && cast_expr->kind == AST::Kind_CastExpression) - { - rewind(saved_pos); - parsePrimaryExpression(expr); - goto L_no_rewind; - } - } + NameAST* name = 0; + if (parseName(name, true)) { + Q_ASSERT(name->unqualified_name != 0); + + bool has_template_args = name->unqualified_name->template_arguments != 0; + + if (has_template_args && token_stream.lookAhead() == '(') { + ExpressionAST* cast_expr = 0; + if (parseCastExpression(cast_expr) && cast_expr->kind == AST::Kind_CastExpression) { + rewind(saved_pos); + parsePrimaryExpression(expr); + goto L_no_rewind; + } } + } rewind(saved_pos); - L_no_rewind: +L_no_rewind: if (!expr && parseSimpleTypeSpecifier(typeSpec) && (token_stream.lookAhead() == '(' || token_stream.lookAhead() == '{')) - { - int tk = token_stream.lookAhead(); - nextToken(); // skip '(' or '{' - parseCommaExpression(expr); - if (tk == '(') - { - CHECK(')'); - } - else - { - CHECK('}'); - } - } - else if (expr) - { - typeSpec = 0; + { + int tk = token_stream.lookAhead(); + nextToken(); // skip '(' or '{' + parseCommaExpression(expr); + if (tk == '(') { + CHECK(')'); + } else { + CHECK('}'); } - else - { - typeSpec = 0; - rewind(start); - - if (token_stream.lookAhead() == Token_noexcept) - { - nextToken(); - CHECK('('); - ExpressionAST* arg_expr = 0; - if (!parseExpression(arg_expr)) - { - return false; - } - CHECK(')'); + } else if (expr) { + typeSpec = 0; + } else { + typeSpec = 0; + rewind(start); - // make noexcept() in expressions an unary expression - UnaryExpressionAST* ast = CreateNode(_M_pool); - ast->op = start; - ast->expression = arg_expr; - expr = ast; - } - else if (!parsePrimaryExpression(expr)) + if (token_stream.lookAhead() == Token_noexcept) { + nextToken(); + CHECK('('); + ExpressionAST* arg_expr = 0; + if (!parseExpression(arg_expr)) { return false; - } + } + CHECK(')'); + + // make noexcept() in expressions an unary expression + UnaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = start; + ast->expression = arg_expr; + expr = ast; + } else if (!parsePrimaryExpression(expr)) + return false; + } - const ListNode *sub_expressions = 0; - ExpressionAST *sub_expression = 0; + const ListNode* sub_expressions = 0; + ExpressionAST* sub_expression = 0; while (parsePostfixExpressionInternal(sub_expression)) sub_expressions = snoc(sub_expressions, sub_expression, _M_pool); - if (sub_expressions || ! expr || (typeSpec && expr)) - { - PostfixExpressionAST *ast = CreateNode(_M_pool); - ast->type_specifier = typeSpec; - ast->expression = expr; - ast->sub_expressions = sub_expressions; + if (sub_expressions || !expr || (typeSpec && expr)) { + PostfixExpressionAST* ast = CreateNode(_M_pool); + ast->type_specifier = typeSpec; + ast->expression = expr; + ast->sub_expressions = sub_expressions; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - else + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } else node = expr; if (token_stream.lookAhead() == Token_ellipsis) { // ignore ellipsis, it might be something like "Pair...", which might appear // in template arguments of variadic templates nextToken(); - } - - return true; -} - -bool Parser::parseUnaryExpression(ExpressionAST *&node) -{ - std::size_t start = token_stream.cursor(); - - switch(token_stream.lookAhead()) - { - case Token_incr: - case Token_decr: - case '*': - case '&': - case '+': - case '-': - case '!': - case '~': - { - std::size_t op = token_stream.cursor(); - nextToken(); + } - ExpressionAST *expr = 0; - if (!parseCastExpression(expr)) - return false; + return true; +} - UnaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->expression = expr; +bool Parser::parseUnaryExpression(ExpressionAST*& node) +{ + std::size_t start = token_stream.cursor(); - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } - return true; + switch (token_stream.lookAhead()) { + case Token_incr: + case Token_decr: + case '*': + case '&': + case '+': + case '-': + case '!': + case '~': + { + std::size_t op = token_stream.cursor(); + nextToken(); - case Token_sizeof: - { - std::size_t sizeof_token = token_stream.cursor(); - nextToken(); + ExpressionAST* expr = 0; + if (!parseCastExpression(expr)) + return false; - if (token_stream.lookAhead() == Token_ellipsis) { - // sizeof... is used on parameter packs - currently we ignore this - // todo: handle this - nextToken(); - } + UnaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->expression = expr; - SizeofExpressionAST *ast = CreateNode(_M_pool); - ast->sizeof_token = sizeof_token; + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } + return true; - std::size_t index = token_stream.cursor(); - if (token_stream.lookAhead() == '(') - { - nextToken(); - if (parseTypeId(ast->type_id) && token_stream.lookAhead() == ')') - { - nextToken(); // skip ) + case Token_sizeof: + { + std::size_t sizeof_token = token_stream.cursor(); + nextToken(); - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - return true; - } + if (token_stream.lookAhead() == Token_ellipsis) { + // sizeof... is used on parameter packs - currently we ignore this + // todo: handle this + nextToken(); + } - ast->type_id = 0; - rewind(index); - } + SizeofExpressionAST* ast = CreateNode(_M_pool); + ast->sizeof_token = sizeof_token; - if (!parseUnaryExpression(ast->expression)) - return false; + std::size_t index = token_stream.cursor(); + if (token_stream.lookAhead() == '(') { + nextToken(); + if (parseTypeId(ast->type_id) && token_stream.lookAhead() == ')') { + nextToken(); // skip ) UPDATE_POS(ast, start, token_stream.cursor()); node = ast; return true; } - default: - break; + ast->type_id = 0; + rewind(index); } + if (!parseUnaryExpression(ast->expression)) + return false; + + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + return true; + } + + default: + break; + } + int token = token_stream.lookAhead(); - if (token == Token_new - || (token == Token_scope && token_stream.lookAhead(1) == Token_new)) + if (token == Token_new || (token == Token_scope && token_stream.lookAhead(1) == Token_new)) return parseNewExpression(node); - if (token == Token_delete - || (token == Token_scope && token_stream.lookAhead(1) == Token_delete)) + if (token == Token_delete || (token == Token_scope && token_stream.lookAhead(1) == Token_delete)) return parseDeleteExpression(node); return parsePostfixExpression(node); } -bool Parser::parseNewExpression(ExpressionAST *&node) +bool Parser::parseNewExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); - NewExpressionAST *ast = CreateNode(_M_pool); + NewExpressionAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == Token_scope - && token_stream.lookAhead(1) == Token_new) - { - ast->scope_token = token_stream.cursor(); - nextToken(); - } + if (token_stream.lookAhead() == Token_scope && token_stream.lookAhead(1) == Token_new) { + ast->scope_token = token_stream.cursor(); + nextToken(); + } CHECK(Token_new); ast->new_token = token_stream.cursor() - 1; - if (token_stream.lookAhead() == '(') - { - nextToken(); - parseCommaExpression(ast->expression); - CHECK(')'); - } + if (token_stream.lookAhead() == '(') { + nextToken(); + parseCommaExpression(ast->expression); + CHECK(')'); + } - if (token_stream.lookAhead() == '(') - { - nextToken(); - parseTypeId(ast->type_id); - CHECK(')'); - } - else - { - parseNewTypeId(ast->new_type_id); - } + if (token_stream.lookAhead() == '(') { + nextToken(); + parseTypeId(ast->type_id); + CHECK(')'); + } else { + parseNewTypeId(ast->new_type_id); + } parseNewInitializer(ast->new_initializer); @@ -4219,15 +3782,15 @@ bool Parser::parseNewExpression(ExpressionAST *&node) return true; } -bool Parser::parseNewTypeId(NewTypeIdAST *&node) +bool Parser::parseNewTypeId(NewTypeIdAST*& node) { std::size_t start = token_stream.cursor(); - TypeSpecifierAST *typeSpec = 0; + TypeSpecifierAST* typeSpec = 0; if (!parseTypeSpecifier(typeSpec)) return false; - NewTypeIdAST *ast = CreateNode(_M_pool); + NewTypeIdAST* ast = CreateNode(_M_pool); ast->type_specifier = typeSpec; parseNewDeclarator(ast->new_declarator); @@ -4238,27 +3801,25 @@ bool Parser::parseNewTypeId(NewTypeIdAST *&node) return true; } -bool Parser::parseNewDeclarator(NewDeclaratorAST *&node) +bool Parser::parseNewDeclarator(NewDeclaratorAST*& node) { std::size_t start = token_stream.cursor(); - NewDeclaratorAST *ast = CreateNode(_M_pool); + NewDeclaratorAST* ast = CreateNode(_M_pool); - PtrOperatorAST *ptrOp = 0; - if (parsePtrOperator(ptrOp)) - { - ast->ptr_op = ptrOp; - parseNewDeclarator(ast->sub_declarator); - } + PtrOperatorAST* ptrOp = 0; + if (parsePtrOperator(ptrOp)) { + ast->ptr_op = ptrOp; + parseNewDeclarator(ast->sub_declarator); + } - while (token_stream.lookAhead() == '[') - { - nextToken(); - ExpressionAST *expr = 0; - parseExpression(expr); - ast->expressions = snoc(ast->expressions, expr, _M_pool); - ADVANCE(']', "]"); - } + while (token_stream.lookAhead() == '[') { + nextToken(); + ExpressionAST* expr = 0; + parseExpression(expr); + ast->expressions = snoc(ast->expressions, expr, _M_pool); + ADVANCE(']', "]"); + } UPDATE_POS(ast, start, token_stream.cursor()); node = ast; @@ -4266,13 +3827,13 @@ bool Parser::parseNewDeclarator(NewDeclaratorAST *&node) return true; } -bool Parser::parseNewInitializer(NewInitializerAST *&node) +bool Parser::parseNewInitializer(NewInitializerAST*& node) { std::size_t start = token_stream.cursor(); CHECK('('); - NewInitializerAST *ast = CreateNode(_M_pool); + NewInitializerAST* ast = CreateNode(_M_pool); parseCommaExpression(ast->expression); @@ -4284,29 +3845,26 @@ bool Parser::parseNewInitializer(NewInitializerAST *&node) return true; } -bool Parser::parseDeleteExpression(ExpressionAST *&node) +bool Parser::parseDeleteExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); - DeleteExpressionAST *ast = CreateNode(_M_pool); + DeleteExpressionAST* ast = CreateNode(_M_pool); - if (token_stream.lookAhead() == Token_scope - && token_stream.lookAhead(1) == Token_delete) - { - ast->scope_token = token_stream.cursor(); - nextToken(); - } + if (token_stream.lookAhead() == Token_scope && token_stream.lookAhead(1) == Token_delete) { + ast->scope_token = token_stream.cursor(); + nextToken(); + } CHECK(Token_delete); ast->delete_token = token_stream.cursor() - 1; - if (token_stream.lookAhead() == '[') - { - ast->lbracket_token = token_stream.cursor(); - nextToken(); - CHECK(']'); - ast->rbracket_token = token_stream.cursor() - 1; - } + if (token_stream.lookAhead() == '[') { + ast->lbracket_token = token_stream.cursor(); + nextToken(); + CHECK(']'); + ast->rbracket_token = token_stream.cursor() - 1; + } if (!parseCastExpression(ast->expression)) return false; @@ -4317,393 +3875,370 @@ bool Parser::parseDeleteExpression(ExpressionAST *&node) return true; } -bool Parser::parseCastExpression(ExpressionAST *&node) +bool Parser::parseCastExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); - if (token_stream.lookAhead() == '(') - { - nextToken(); + if (token_stream.lookAhead() == '(') { + nextToken(); - CastExpressionAST *ast = CreateNode(_M_pool); + CastExpressionAST* ast = CreateNode(_M_pool); - if (parseTypeId(ast->type_id)) - { - if (token_stream.lookAhead() == ')') - { - nextToken(); - - if (parseCastExpression(ast->expression)) - { - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - - return true; - } - } + if (parseTypeId(ast->type_id)) { + if (token_stream.lookAhead() == ')') { + nextToken(); + + if (parseCastExpression(ast->expression)) { + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + + return true; } + } } + } rewind(start); return parseUnaryExpression(node); } -bool Parser::parsePmExpression(ExpressionAST *&node) +bool Parser::parsePmExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); if (!parseCastExpression(node) || !node) // ### fixme return false; - while (token_stream.lookAhead() == Token_ptrmem) - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == Token_ptrmem) { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseCastExpression(rightExpr)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseCastExpression(rightExpr)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseMultiplicativeExpression(ExpressionAST *&node) +bool Parser::parseMultiplicativeExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); if (!parsePmExpression(node)) return false; - while (token_stream.lookAhead() == '*' - || token_stream.lookAhead() == '/' - || token_stream.lookAhead() == '%') - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == '*' || token_stream.lookAhead() == '/' || token_stream.lookAhead() == '%') { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parsePmExpression(rightExpr)) - return false; + ExpressionAST* rightExpr = 0; + if (!parsePmExpression(rightExpr)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } - -bool Parser::parseAdditiveExpression(ExpressionAST *&node) +bool Parser::parseAdditiveExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); if (!parseMultiplicativeExpression(node)) return false; - while (token_stream.lookAhead() == '+' || token_stream.lookAhead() == '-') - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == '+' || token_stream.lookAhead() == '-') { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseMultiplicativeExpression(rightExpr)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseMultiplicativeExpression(rightExpr)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseShiftExpression(ExpressionAST *&node) +bool Parser::parseShiftExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); if (!parseAdditiveExpression(node)) return false; - while (token_stream.lookAhead() == Token_shift_left || token_stream.lookAhead() == Token_shift_right) - { - std::size_t op = token_stream.cursor(); - if (token_stream.lookAhead() == Token_shift_right) - { - // skip placeholder - nextToken(); - } + while (token_stream.lookAhead() == Token_shift_left || token_stream.lookAhead() == Token_shift_right) { + std::size_t op = token_stream.cursor(); + if (token_stream.lookAhead() == Token_shift_right) { + // skip placeholder nextToken(); + } + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseAdditiveExpression(rightExpr)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseAdditiveExpression(rightExpr)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseRelationalExpression(ExpressionAST *&node, bool templArgs) +bool Parser::parseRelationalExpression(ExpressionAST*& node, bool templArgs) { std::size_t start = token_stream.cursor(); if (!parseShiftExpression(node)) return false; - while (token_stream.lookAhead() == '<' - || (token_stream.lookAhead() == '>' && !templArgs) - || token_stream.lookAhead() == Token_leq - || token_stream.lookAhead() == Token_geq) - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == '<' || (token_stream.lookAhead() == '>' && !templArgs) + || token_stream.lookAhead() == Token_leq || token_stream.lookAhead() == Token_geq) + { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseShiftExpression(rightExpr)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseShiftExpression(rightExpr)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseEqualityExpression(ExpressionAST *&node, bool templArgs) +bool Parser::parseEqualityExpression(ExpressionAST*& node, bool templArgs) { std::size_t start = token_stream.cursor(); if (!parseRelationalExpression(node, templArgs)) return false; - while (token_stream.lookAhead() == Token_eq - || token_stream.lookAhead() == Token_not_eq) - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == Token_eq || token_stream.lookAhead() == Token_not_eq) { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseRelationalExpression(rightExpr, templArgs)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseRelationalExpression(rightExpr, templArgs)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseAndExpression(ExpressionAST *&node, bool templArgs) +bool Parser::parseAndExpression(ExpressionAST*& node, bool templArgs) { std::size_t start = token_stream.cursor(); if (!parseEqualityExpression(node, templArgs)) return false; - while (token_stream.lookAhead() == '&') - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == '&') { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseEqualityExpression(rightExpr, templArgs)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseEqualityExpression(rightExpr, templArgs)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseExclusiveOrExpression(ExpressionAST *&node, bool templArgs) +bool Parser::parseExclusiveOrExpression(ExpressionAST*& node, bool templArgs) { std::size_t start = token_stream.cursor(); if (!parseAndExpression(node, templArgs)) return false; - while (token_stream.lookAhead() == '^') - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == '^') { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseAndExpression(rightExpr, templArgs)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseAndExpression(rightExpr, templArgs)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseInclusiveOrExpression(ExpressionAST *&node, bool templArgs) +bool Parser::parseInclusiveOrExpression(ExpressionAST*& node, bool templArgs) { std::size_t start = token_stream.cursor(); if (!parseExclusiveOrExpression(node, templArgs)) return false; - while (token_stream.lookAhead() == '|') - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == '|') { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseExclusiveOrExpression(rightExpr, templArgs)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseExclusiveOrExpression(rightExpr, templArgs)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseLogicalAndExpression(ExpressionAST *&node, bool templArgs) +bool Parser::parseLogicalAndExpression(ExpressionAST*& node, bool templArgs) { std::size_t start = token_stream.cursor(); if (!parseInclusiveOrExpression(node, templArgs)) return false; - while (token_stream.lookAhead() == Token_and) - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == Token_and) { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseInclusiveOrExpression(rightExpr, templArgs)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseInclusiveOrExpression(rightExpr, templArgs)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseLogicalOrExpression(ExpressionAST *&node, bool templArgs) +bool Parser::parseLogicalOrExpression(ExpressionAST*& node, bool templArgs) { std::size_t start = token_stream.cursor(); if (!parseLogicalAndExpression(node, templArgs)) return false; - while (token_stream.lookAhead() == Token_or) - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == Token_or) { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseLogicalAndExpression(rightExpr, templArgs)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseLogicalAndExpression(rightExpr, templArgs)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseConditionalExpression(ExpressionAST *&node) +bool Parser::parseConditionalExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); if (!parseLogicalOrExpression(node)) return false; - if (token_stream.lookAhead() == '?') - { - nextToken(); + if (token_stream.lookAhead() == '?') { + nextToken(); - ExpressionAST *leftExpr = 0; - if (!parseExpression(leftExpr)) - return false; + ExpressionAST* leftExpr = 0; + if (!parseExpression(leftExpr)) + return false; - CHECK(':'); + CHECK(':'); - ExpressionAST *rightExpr = 0; - if (!parseAssignmentExpression(rightExpr)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseAssignmentExpression(rightExpr)) + return false; - ConditionalExpressionAST *ast - = CreateNode(_M_pool); + ConditionalExpressionAST* ast = CreateNode(_M_pool); - ast->condition = node; - ast->left_expression = leftExpr; - ast->right_expression = rightExpr; + ast->condition = node; + ast->left_expression = leftExpr; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseAssignmentExpression(ExpressionAST *&node) +bool Parser::parseAssignmentExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); @@ -4712,73 +4247,70 @@ bool Parser::parseAssignmentExpression(ExpressionAST *&node) else if (!parseConditionalExpression(node)) return false; - while (token_stream.lookAhead() == Token_assign - || token_stream.lookAhead() == '=') - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == Token_assign || token_stream.lookAhead() == '=') { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseConditionalExpression(rightExpr)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseConditionalExpression(rightExpr)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseConstantExpression(ExpressionAST *&node) +bool Parser::parseConstantExpression(ExpressionAST*& node) { return parseConditionalExpression(node); } -bool Parser::parseExpression(ExpressionAST *&node) +bool Parser::parseExpression(ExpressionAST*& node) { return parseCommaExpression(node); } -bool Parser::parseCommaExpression(ExpressionAST *&node) +bool Parser::parseCommaExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); if (!parseAssignmentExpression(node)) return false; - while (token_stream.lookAhead() == ',') - { - std::size_t op = token_stream.cursor(); - nextToken(); + while (token_stream.lookAhead() == ',') { + std::size_t op = token_stream.cursor(); + nextToken(); - ExpressionAST *rightExpr = 0; - if (!parseAssignmentExpression(rightExpr)) - return false; + ExpressionAST* rightExpr = 0; + if (!parseAssignmentExpression(rightExpr)) + return false; - BinaryExpressionAST *ast = CreateNode(_M_pool); - ast->op = op; - ast->left_expression = node; - ast->right_expression = rightExpr; + BinaryExpressionAST* ast = CreateNode(_M_pool); + ast->op = op; + ast->left_expression = node; + ast->right_expression = rightExpr; - UPDATE_POS(ast, start, token_stream.cursor()); - node = ast; - } + UPDATE_POS(ast, start, token_stream.cursor()); + node = ast; + } return true; } -bool Parser::parseThrowExpression(ExpressionAST *&node) +bool Parser::parseThrowExpression(ExpressionAST*& node) { std::size_t start = token_stream.cursor(); CHECK(Token_throw); - ThrowExpressionAST *ast = CreateNode(_M_pool); + ThrowExpressionAST* ast = CreateNode(_M_pool); ast->throw_token = token_stream.cursor() - 1; parseAssignmentExpression(ast->expression); @@ -4789,7 +4321,7 @@ bool Parser::parseThrowExpression(ExpressionAST *&node) return true; } -bool Parser::parseQ_ENUMS(DeclarationAST *&node) +bool Parser::parseQ_ENUMS(DeclarationAST*& node) { if (token_stream.lookAhead() != Token_Q_ENUMS) return false; @@ -4804,7 +4336,7 @@ bool Parser::parseQ_ENUMS(DeclarationAST *&node) while (token_stream.lookAhead() != ')') { nextToken(); } - QEnumsAST *ast = CreateNode(_M_pool); + QEnumsAST* ast = CreateNode(_M_pool); UPDATE_POS(ast, firstToken, token_stream.cursor()); ast->isQEnum = false; node = ast; @@ -4814,7 +4346,7 @@ bool Parser::parseQ_ENUMS(DeclarationAST *&node) return true; } -bool Parser::parseQ_ENUM(DeclarationAST *&node) +bool Parser::parseQ_ENUM(DeclarationAST*& node) { if (token_stream.lookAhead() != Token_Q_ENUM) return false; @@ -4829,7 +4361,7 @@ bool Parser::parseQ_ENUM(DeclarationAST *&node) while (token_stream.lookAhead() != ')') { nextToken(); } - QEnumsAST *ast = CreateNode(_M_pool); + QEnumsAST* ast = CreateNode(_M_pool); UPDATE_POS(ast, firstToken, token_stream.cursor()); node = ast; ast->isQEnum = true; @@ -4839,25 +4371,25 @@ bool Parser::parseQ_ENUM(DeclarationAST *&node) return true; } -bool Parser::parseQ_PROPERTY(DeclarationAST *&node) +bool Parser::parseQ_PROPERTY(DeclarationAST*& node) { if (token_stream.lookAhead() != Token_Q_PROPERTY || token_stream.lookAhead(1) != '(') return false; nextToken(); - size_t firstToken = token_stream.cursor()+1; + size_t firstToken = token_stream.cursor() + 1; if (!skip('(', ')')) { return false; } - QPropertyAST *ast = CreateNode(_M_pool); + QPropertyAST* ast = CreateNode(_M_pool); UPDATE_POS(ast, firstToken, token_stream.cursor()); node = ast; -// const Token &t1 = token_stream[firstToken]; -// const Token &t2 = token_stream[token_stream.cursor()]; -// printf("property: %s\n", -// qPrintable(QString::fromLatin1(t1.text + t1.position, t2.position - t1.position))); + // const Token &t1 = token_stream[firstToken]; + // const Token &t2 = token_stream[token_stream.cursor()]; + // printf("property: %s\n", + // qPrintable(QString::fromLatin1(t1.text + t1.position, t2.position - t1.position))); nextToken(); @@ -4871,5 +4403,4 @@ bool Parser::block_errors(bool block) return current; } - // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/generator/parser/parser.h b/generator/parser/parser.h index 4843ff7cb..287a3780b 100644 --- a/generator/parser/parser.h +++ b/generator/parser/parser.h @@ -39,14 +39,13 @@ ** ****************************************************************************/ - #ifndef PARSER_H -#define PARSER_H + #define PARSER_H -#include "ast.h" -#include "lexer.h" + #include "ast.h" + #include "lexer.h" -#include + #include class FileSymbol; class Control; @@ -54,12 +53,12 @@ class Control; class Parser { public: - Parser(Control *control); + Parser(Control* control); ~Parser(); - LocationManager &location() { return _M_location; } + LocationManager& location() { return _M_location; } - TranslationUnitAST *parse(const char *contents, std::size_t size, pool *p); + TranslationUnitAST* parse(const char* contents, std::size_t size, pool* p); private: void reportError(const QString& msg, const char* functionName = nullptr); @@ -67,124 +66,115 @@ class Parser void tokenRequiredError(int expected, const char* functionName = nullptr); public: - bool skipFunctionBody(StatementAST *&node); + bool skipFunctionBody(StatementAST*& node); public: bool parse_Attribute__(); - bool parseAbstractDeclarator(DeclaratorAST *&node); - bool parseAccessSpecifier(DeclarationAST *&node); - bool parseAdditiveExpression(ExpressionAST *&node); - bool parseAndExpression(ExpressionAST *&node, bool templArgs = false); - bool parseAsmDefinition(DeclarationAST *&node); - bool parseAssignmentExpression(ExpressionAST *&node); - bool parseBaseClause(BaseClauseAST *&node); - bool parseBaseSpecifier(BaseSpecifierAST *&node); - bool parseBlockDeclaration(DeclarationAST *&node); - bool parseCastExpression(ExpressionAST *&node); - bool parseClassSpecifier(TypeSpecifierAST *&node); - bool parseForwardDeclarationSpecifier(TypeSpecifierAST *&node); - bool parseCommaExpression(ExpressionAST *&node); - bool parseCompoundStatement(StatementAST *&node); - bool parseCondition(ConditionAST *&node, bool initRequired = true); - bool parseConditionalExpression(ExpressionAST *&node); - bool parseConstantExpression(ExpressionAST *&node); - bool parseCtorInitializer(CtorInitializerAST *&node); - bool parseCvQualify(const ListNode *&node); - bool parseDeclaration(DeclarationAST *&node); - bool parseDeclarationInternal(DeclarationAST *&node); - bool parseDeclarationStatement(StatementAST *&node); - bool parseDeclarator(DeclaratorAST *&node, bool asParameter = false); + bool parseAbstractDeclarator(DeclaratorAST*& node); + bool parseAccessSpecifier(DeclarationAST*& node); + bool parseAdditiveExpression(ExpressionAST*& node); + bool parseAndExpression(ExpressionAST*& node, bool templArgs = false); + bool parseAsmDefinition(DeclarationAST*& node); + bool parseAssignmentExpression(ExpressionAST*& node); + bool parseBaseClause(BaseClauseAST*& node); + bool parseBaseSpecifier(BaseSpecifierAST*& node); + bool parseBlockDeclaration(DeclarationAST*& node); + bool parseCastExpression(ExpressionAST*& node); + bool parseClassSpecifier(TypeSpecifierAST*& node); + bool parseForwardDeclarationSpecifier(TypeSpecifierAST*& node); + bool parseCommaExpression(ExpressionAST*& node); + bool parseCompoundStatement(StatementAST*& node); + bool parseCondition(ConditionAST*& node, bool initRequired = true); + bool parseConditionalExpression(ExpressionAST*& node); + bool parseConstantExpression(ExpressionAST*& node); + bool parseCtorInitializer(CtorInitializerAST*& node); + bool parseCvQualify(const ListNode*& node); + bool parseDeclaration(DeclarationAST*& node); + bool parseDeclarationInternal(DeclarationAST*& node); + bool parseDeclarationStatement(StatementAST*& node); + bool parseDeclarator(DeclaratorAST*& node, bool asParameter = false); bool parseDeclaratorParametersAndSuffix(DeclaratorAST* node); - bool parseDeleteExpression(ExpressionAST *&node); - bool parseDoStatement(StatementAST *&node); - bool parseElaboratedTypeSpecifier(TypeSpecifierAST *&node); - bool parseEnumSpecifier(TypeSpecifierAST *&node); - bool parseEnumerator(EnumeratorAST *&node); - bool parseEqualityExpression(ExpressionAST *&node, - bool templArgs = false); - bool parseExceptionSpecification(ExceptionSpecificationAST *&node); - bool parseExclusiveOrExpression(ExpressionAST *&node, - bool templArgs = false); - bool parseExpression(ExpressionAST *&node); - bool parseExpressionOrDeclarationStatement(StatementAST *&node); - bool parseExpressionStatement(StatementAST *&node); - bool parseForInitStatement(StatementAST *&node); - bool parseForStatement(StatementAST *&node); - bool parseFunctionBody(StatementAST *&node); - bool parseFunctionSpecifier(const ListNode *&node); - bool parseIfStatement(StatementAST *&node); - bool parseInclusiveOrExpression(ExpressionAST *&node, - bool templArgs = false); - bool parseInitDeclarator(InitDeclaratorAST *&node); - bool parseInitDeclaratorList(const ListNode *&node); - bool parseInitializer(InitializerAST *&node, bool allowNewStyle); - bool parseInitializerClause(InitializerClauseAST *&node); - bool parseLabeledStatement(StatementAST *&node); - bool parseLinkageBody(LinkageBodyAST *&node); - bool parseLinkageSpecification(DeclarationAST *&node); - bool parseLogicalAndExpression(ExpressionAST *&node, - bool templArgs = false); - bool parseLogicalOrExpression(ExpressionAST *&node, - bool templArgs = false); - bool parseMemInitializer(MemInitializerAST *&node); - bool parseMemInitializerList(const ListNode *&node); - bool parseMemberSpecification(DeclarationAST *&node); - bool parseMultiplicativeExpression(ExpressionAST *&node); - bool parseName(NameAST *&node, bool acceptTemplateId = false); - bool parseNamespace(DeclarationAST *&node); - bool parseNamespaceAliasDefinition(DeclarationAST *&node); - bool parseNewDeclarator(NewDeclaratorAST *&node); - bool parseNewExpression(ExpressionAST *&node); - bool parseNewInitializer(NewInitializerAST *&node); - bool parseNewTypeId(NewTypeIdAST *&node); - bool parseOperator(OperatorAST *&node); - bool parseOperatorFunctionId(OperatorFunctionIdAST *&node); - bool parseParameterDeclaration(ParameterDeclarationAST *&node); - bool parseParameterDeclarationClause(ParameterDeclarationClauseAST *&node); - bool parseParameterDeclarationList(const ListNode *&node); - bool parsePmExpression(ExpressionAST *&node); - bool parsePostfixExpression(ExpressionAST *&node); - bool parsePostfixExpressionInternal(ExpressionAST *&node); - bool parsePrimaryExpression(ExpressionAST *&node); - bool parsePtrOperator(PtrOperatorAST *&node); - bool parsePtrToMember(PtrToMemberAST *&node); + bool parseDeleteExpression(ExpressionAST*& node); + bool parseDoStatement(StatementAST*& node); + bool parseElaboratedTypeSpecifier(TypeSpecifierAST*& node); + bool parseEnumSpecifier(TypeSpecifierAST*& node); + bool parseEnumerator(EnumeratorAST*& node); + bool parseEqualityExpression(ExpressionAST*& node, bool templArgs = false); + bool parseExceptionSpecification(ExceptionSpecificationAST*& node); + bool parseExclusiveOrExpression(ExpressionAST*& node, bool templArgs = false); + bool parseExpression(ExpressionAST*& node); + bool parseExpressionOrDeclarationStatement(StatementAST*& node); + bool parseExpressionStatement(StatementAST*& node); + bool parseForInitStatement(StatementAST*& node); + bool parseForStatement(StatementAST*& node); + bool parseFunctionBody(StatementAST*& node); + bool parseFunctionSpecifier(const ListNode*& node); + bool parseIfStatement(StatementAST*& node); + bool parseInclusiveOrExpression(ExpressionAST*& node, bool templArgs = false); + bool parseInitDeclarator(InitDeclaratorAST*& node); + bool parseInitDeclaratorList(const ListNode*& node); + bool parseInitializer(InitializerAST*& node, bool allowNewStyle); + bool parseInitializerClause(InitializerClauseAST*& node); + bool parseLabeledStatement(StatementAST*& node); + bool parseLinkageBody(LinkageBodyAST*& node); + bool parseLinkageSpecification(DeclarationAST*& node); + bool parseLogicalAndExpression(ExpressionAST*& node, bool templArgs = false); + bool parseLogicalOrExpression(ExpressionAST*& node, bool templArgs = false); + bool parseMemInitializer(MemInitializerAST*& node); + bool parseMemInitializerList(const ListNode*& node); + bool parseMemberSpecification(DeclarationAST*& node); + bool parseMultiplicativeExpression(ExpressionAST*& node); + bool parseName(NameAST*& node, bool acceptTemplateId = false); + bool parseNamespace(DeclarationAST*& node); + bool parseNamespaceAliasDefinition(DeclarationAST*& node); + bool parseNewDeclarator(NewDeclaratorAST*& node); + bool parseNewExpression(ExpressionAST*& node); + bool parseNewInitializer(NewInitializerAST*& node); + bool parseNewTypeId(NewTypeIdAST*& node); + bool parseOperator(OperatorAST*& node); + bool parseOperatorFunctionId(OperatorFunctionIdAST*& node); + bool parseParameterDeclaration(ParameterDeclarationAST*& node); + bool parseParameterDeclarationClause(ParameterDeclarationClauseAST*& node); + bool parseParameterDeclarationList(const ListNode*& node); + bool parsePmExpression(ExpressionAST*& node); + bool parsePostfixExpression(ExpressionAST*& node); + bool parsePostfixExpressionInternal(ExpressionAST*& node); + bool parsePrimaryExpression(ExpressionAST*& node); + bool parsePtrOperator(PtrOperatorAST*& node); + bool parsePtrToMember(PtrToMemberAST*& node); void resolveRightShift(); - bool parseRelationalExpression(ExpressionAST *&node, - bool templArgs = false); - bool parseShiftExpression(ExpressionAST *&node); - bool parseSimpleTypeSpecifier(TypeSpecifierAST *&node, - bool onlyIntegral = false); - bool parseStatement(StatementAST *&node); - bool parseStorageClassSpecifier(const ListNode *&node); - bool parseStringLiteral(StringLiteralAST *&node); - bool parseSwitchStatement(StatementAST *&node); - bool parseTemplateArgument(TemplateArgumentAST *&node); - bool parseTemplateArgumentList(const ListNode *&node, - bool reportError = true); - bool parseTemplateDeclaration(DeclarationAST *&node); - bool parseTemplateParameter(TemplateParameterAST *&node); - bool parseTemplateParameterList(const ListNode *&node); - bool parseThrowExpression(ExpressionAST *&node); - bool parseTranslationUnit(TranslationUnitAST *&node); - bool parseTryBlockStatement(StatementAST *&node); - bool parseTypeId(TypeIdAST *&node); - bool parseTypeIdList(const ListNode *&node); - bool parseTypeParameter(TypeParameterAST *&node); - bool parseTypeSpecifier(TypeSpecifierAST *&node); - bool parseTypeSpecifierOrClassSpec(TypeSpecifierAST *&node); - bool parseTypedef(DeclarationAST *&node); - bool parseUnaryExpression(ExpressionAST *&node); - bool parseUnqualifiedName(UnqualifiedNameAST *&node, - bool parseTemplateId = true); - bool parseUsing(DeclarationAST *&node); + bool parseRelationalExpression(ExpressionAST*& node, bool templArgs = false); + bool parseShiftExpression(ExpressionAST*& node); + bool parseSimpleTypeSpecifier(TypeSpecifierAST*& node, bool onlyIntegral = false); + bool parseStatement(StatementAST*& node); + bool parseStorageClassSpecifier(const ListNode*& node); + bool parseStringLiteral(StringLiteralAST*& node); + bool parseSwitchStatement(StatementAST*& node); + bool parseTemplateArgument(TemplateArgumentAST*& node); + bool parseTemplateArgumentList(const ListNode*& node, bool reportError = true); + bool parseTemplateDeclaration(DeclarationAST*& node); + bool parseTemplateParameter(TemplateParameterAST*& node); + bool parseTemplateParameterList(const ListNode*& node); + bool parseThrowExpression(ExpressionAST*& node); + bool parseTranslationUnit(TranslationUnitAST*& node); + bool parseTryBlockStatement(StatementAST*& node); + bool parseTypeId(TypeIdAST*& node); + bool parseTypeIdList(const ListNode*& node); + bool parseTypeParameter(TypeParameterAST*& node); + bool parseTypeSpecifier(TypeSpecifierAST*& node); + bool parseTypeSpecifierOrClassSpec(TypeSpecifierAST*& node); + bool parseTypedef(DeclarationAST*& node); + bool parseUnaryExpression(ExpressionAST*& node); + bool parseUnqualifiedName(UnqualifiedNameAST*& node, bool parseTemplateId = true); + bool parseUsing(DeclarationAST*& node); bool parseUsingTypedef(DeclarationAST*& node); - bool parseUsingDirective(DeclarationAST *&node); - bool parseWhileStatement(StatementAST *&node); - bool parseWinDeclSpec(WinDeclSpecAST *&node); + bool parseUsingDirective(DeclarationAST*& node); + bool parseWhileStatement(StatementAST*& node); + bool parseWinDeclSpec(WinDeclSpecAST*& node); - bool parseQ_PROPERTY(DeclarationAST *&node); - bool parseQ_ENUMS(DeclarationAST *&node); - bool parseQ_ENUM(DeclarationAST *&node); + bool parseQ_PROPERTY(DeclarationAST*& node); + bool parseQ_ENUMS(DeclarationAST*& node); + bool parseQ_ENUM(DeclarationAST*& node); bool skipAlignas(); bool skipAttributes(); @@ -204,24 +194,24 @@ class Parser bool block_errors(bool block); private: - QString tokenText(AST *) const; + QString tokenText(AST*) const; void keepTrackDebug(); LocationManager _M_location; - Control *control; + Control* control; Lexer lexer; - pool *_M_pool; + pool* _M_pool; bool _M_block_errors; QString _currentFile; - int _currentLine{}; - int _currentColumn{}; - const char* _currentToken{}; + int _currentLine {}; + int _currentColumn {}; + const char* _currentToken {}; QString _currentSymbol; private: Parser(const Parser& source); - void operator = (const Parser& source); + void operator=(const Parser& source); }; #endif diff --git a/generator/parser/rxx_allocator.h b/generator/parser/rxx_allocator.h index 88d8f7858..d46e19d3b 100644 --- a/generator/parser/rxx_allocator.h +++ b/generator/parser/rxx_allocator.h @@ -39,16 +39,17 @@ ** ****************************************************************************/ - #ifndef RXX_ALLOCATOR_H -#define RXX_ALLOCATOR_H + #define RXX_ALLOCATOR_H -#include -#include -#include -#include + #include + #include + #include + #include -template class rxx_allocator { +template +class rxx_allocator +{ public: typedef _Tp value_type; typedef _Tp* pointer; @@ -61,14 +62,16 @@ template class rxx_allocator { static const size_type max_block_count = size_type(-1); static const size_type _S_block_size = 1 << 16; // 64K - rxx_allocator() { + rxx_allocator() + { _M_block_index = max_block_count; _M_current_index = 0; _M_storage = 0; _M_current_block = 0; } - ~rxx_allocator() { + ~rxx_allocator() + { for (size_type index = 0; index < _M_block_index + 1; ++index) delete[] _M_storage[index]; @@ -78,28 +81,24 @@ template class rxx_allocator { pointer address(reference __val) { return &__val; } const_pointer address(const_reference __val) const { return &__val; } - pointer allocate(size_type __n, const void* = 0) { + pointer allocate(size_type __n, const void* = 0) + { const size_type bytes = __n * sizeof(_Tp); - if (_M_current_block == 0 - || _S_block_size < _M_current_index + bytes) - { - ++_M_block_index; + if (_M_current_block == 0 || _S_block_size < _M_current_index + bytes) { + ++_M_block_index; - _M_storage = reinterpret_cast - (::realloc(_M_storage, sizeof(char*) * (1 + _M_block_index))); + _M_storage = reinterpret_cast(::realloc(_M_storage, sizeof(char*) * (1 + _M_block_index))); - _M_current_block = _M_storage[_M_block_index] = reinterpret_cast - (new char[_S_block_size]); + _M_current_block = _M_storage[_M_block_index] = reinterpret_cast(new char[_S_block_size]); -#if defined(RXX_ALLOCATOR_INIT_0) // ### make it a policy - ::memset(_M_current_block, 0, _S_block_size); -#endif - _M_current_index = 0; - } + #if defined(RXX_ALLOCATOR_INIT_0) // ### make it a policy + ::memset(_M_current_block, 0, _S_block_size); + #endif + _M_current_index = 0; + } - pointer p = reinterpret_cast - (_M_current_block + _M_current_index); + pointer p = reinterpret_cast(_M_current_block + _M_current_index); _M_current_index += bytes; // Hack for modern C++ to get aligned allocations @@ -117,17 +116,21 @@ template class rxx_allocator { void destruct(pointer __p) { __p->~_Tp(); } private: - template struct rebind { + template + struct rebind { typedef rxx_allocator<_Tp1> other; }; - template rxx_allocator(const rxx_allocator<_Tp1> &/*__o*/) {} + template + rxx_allocator(const rxx_allocator<_Tp1>& /*__o*/) + { + } private: size_type _M_block_index; size_type _M_current_index; - char *_M_current_block; - char **_M_storage; + char* _M_current_block; + char** _M_storage; }; #endif // RXX_ALLOCATOR_H diff --git a/generator/parser/smallobject.cpp b/generator/parser/smallobject.cpp index 4e511be47..9040e5596 100644 --- a/generator/parser/smallobject.cpp +++ b/generator/parser/smallobject.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include "smallobject.h" // kate: space-indent on; indent-width 2; replace-tabs on; diff --git a/generator/parser/smallobject.h b/generator/parser/smallobject.h index 1295c304f..29cd4bddc 100644 --- a/generator/parser/smallobject.h +++ b/generator/parser/smallobject.h @@ -39,22 +39,21 @@ ** ****************************************************************************/ - #ifndef SMALLOBJECT_H -#define SMALLOBJECT_H + #define SMALLOBJECT_H -#include "rxx_allocator.h" -#include + #include "rxx_allocator.h" + #include class pool { rxx_allocator __alloc; public: - inline void *allocate(std::size_t __size); + inline void* allocate(std::size_t __size); }; -inline void *pool::allocate(std::size_t __size) +inline void* pool::allocate(std::size_t __size) { return __alloc.allocate(__size); } diff --git a/generator/parser/symbol.h b/generator/parser/symbol.h index d711e0d3a..902542994 100644 --- a/generator/parser/symbol.h +++ b/generator/parser/symbol.h @@ -39,58 +39,55 @@ ** ****************************************************************************/ - #ifndef SYMBOL_H -#define SYMBOL_H + #define SYMBOL_H -#include -#include + #include + #include -#include -#include + #include + #include -struct NameSymbol -{ - const char *data; +struct NameSymbol { + const char* data; std::size_t count; - inline QString as_string() const - { - return QString::fromUtf8(data, (int) count); - } + inline QString as_string() const { return QString::fromUtf8(data, (int)count); } - inline bool operator == (const NameSymbol &other) const + inline bool operator==(const NameSymbol& other) const { - return count == other.count - && std::strncmp(data, other.data, count) == 0; + return count == other.count && std::strncmp(data, other.data, count) == 0; } protected: inline NameSymbol() {} - inline NameSymbol(const char *d, std::size_t c) - : data(d), count(c) {} + inline NameSymbol(const char* d, std::size_t c) + : data(d) + , count(c) + { + } private: - void operator = (const NameSymbol &); + void operator=(const NameSymbol&); friend class NameTable; }; -inline uint qHash(const NameSymbol &r) +inline uint qHash(const NameSymbol& r) { uint hash_value = 0; - for (std::size_t i=0; i &r) +inline uint qHash(const QPair& r) { uint hash_value = 0; - for (std::size_t i=0; i &r) class NameTable { public: - typedef QPair KeyType; + typedef QPair KeyType; typedef QHash ContainerType; public: NameTable() {} - ~NameTable() - { - qDeleteAll(_M_storage); - } + ~NameTable() { qDeleteAll(_M_storage); } - inline const NameSymbol *findOrInsert(const char *str, std::size_t len) + inline const NameSymbol* findOrInsert(const char* str, std::size_t len) { KeyType key(str, len); - NameSymbol *name = _M_storage.value(key); - if (!name) - { - name = new NameSymbol(str, len); - _M_storage.insert(key, name); - } + NameSymbol* name = _M_storage.value(key); + if (!name) { + name = new NameSymbol(str, len); + _M_storage.insert(key, name); + } return name; } - inline std::size_t count() const - { - return _M_storage.size(); - } + inline std::size_t count() const { return _M_storage.size(); } private: ContainerType _M_storage; private: - NameTable(const NameTable &other); - void operator = (const NameTable &other); + NameTable(const NameTable& other); + void operator=(const NameTable& other); }; #endif // SYMBOL_H diff --git a/generator/parser/tokens.cpp b/generator/parser/tokens.cpp index 02e02fc7d..6880e8d3b 100644 --- a/generator/parser/tokens.cpp +++ b/generator/parser/tokens.cpp @@ -39,252 +39,142 @@ ** ****************************************************************************/ - #include #include #include "tokens.h" -static char const * const _S_token_names[] = { - "K_DCOP", - "Q_OBJECT", - "Q_PROPERTY", - "__attribute__", - "__typeof", - "alignas", - "and", - "and_eq", - "arrow", - "asm", - "assign", - "auto", - "bitand", - "bitor", - "bool", - "break", - "case", - "catch", - "char", - "char_literal", - "class", - "comment", - "compl", - "concat", - "const", - "constexpr", - "const_cast", - "continue", - "decltype", - "decr", - "default", - "delete", - "do", - "double", - "dynamic_cast", - "ellipsis", - "else", - "emit", - "enum", - "eq", - "explicit", - "export", - "extern", - "false", - "float", - "for", - "friend", - "geq", - "goto", - "identifier", - "if", - "incr", - "inline", - "int", - "k_dcop", - "k_dcop_signals", - "leq", - "long", - "mutable", - "namespace", - "new", - "noexcept", - "not", - "not_eq", - "number_literal", - "operator", - "or", - "or_eq", - "placeholder", - "preproc", - "private", - "protected", - "ptrmem", - "public", - "register", - "reinterpret_cast", - "return", - "scope", - "shift_left", - "shift_right", - "short", - "signals", - "signed", - "sizeof", - "slots", - "static", - "static_cast", - "string_literal", - "struct", - "switch", - "template", - "this", - "throw", - "true", - "try", - "typedef", - "typeid", - "typename", - "union", - "unsigned", - "using", - "virtual", - "void", - "volatile", - "wchar_t", - "while", - "whitespaces", - "xor", - "xor_eq", - "Q_ENUMS", - "Q_ENUM", - "Q_INVOKABLE" -}; +static char const* const _S_token_names[] = {"K_DCOP", "Q_OBJECT", "Q_PROPERTY", "__attribute__", "__typeof", "alignas", + "and", "and_eq", "arrow", "asm", "assign", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", + "char_literal", "class", "comment", "compl", "concat", "const", "constexpr", "const_cast", "continue", "decltype", + "decr", "default", "delete", "do", "double", "dynamic_cast", "ellipsis", "else", "emit", "enum", "eq", "explicit", + "export", "extern", "false", "float", "for", "friend", "geq", "goto", "identifier", "if", "incr", "inline", "int", + "k_dcop", "k_dcop_signals", "leq", "long", "mutable", "namespace", "new", "noexcept", "not", "not_eq", + "number_literal", "operator", "or", "or_eq", "placeholder", "preproc", "private", "protected", "ptrmem", "public", + "register", "reinterpret_cast", "return", "scope", "shift_left", "shift_right", "short", "signals", "signed", + "sizeof", "slots", "static", "static_cast", "string_literal", "struct", "switch", "template", "this", "throw", "true", + "try", "typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", "void", "volatile", "wchar_t", + "while", "whitespaces", "xor", "xor_eq", "Q_ENUMS", "Q_ENUM", "Q_INVOKABLE"}; static char _S_printable[][2] = { - { char(32), '\0' }, - { char(33), '\0' }, - { char(34), '\0' }, - { char(35), '\0' }, - { char(36), '\0' }, - { char(37), '\0' }, - { char(38), '\0' }, - { char(39), '\0' }, - { char(40), '\0' }, - { char(41), '\0' }, - { char(42), '\0' }, - { char(43), '\0' }, - { char(44), '\0' }, - { char(45), '\0' }, - { char(46), '\0' }, - { char(47), '\0' }, - { char(48), '\0' }, - { char(49), '\0' }, - { char(50), '\0' }, - { char(51), '\0' }, - { char(52), '\0' }, - { char(53), '\0' }, - { char(54), '\0' }, - { char(55), '\0' }, - { char(56), '\0' }, - { char(57), '\0' }, - { char(58), '\0' }, - { char(59), '\0' }, - { char(60), '\0' }, - { char(61), '\0' }, - { char(62), '\0' }, - { char(63), '\0' }, - { char(64), '\0' }, - { char(65), '\0' }, - { char(66), '\0' }, - { char(67), '\0' }, - { char(68), '\0' }, - { char(69), '\0' }, - { char(70), '\0' }, - { char(71), '\0' }, - { char(72), '\0' }, - { char(73), '\0' }, - { char(74), '\0' }, - { char(75), '\0' }, - { char(76), '\0' }, - { char(77), '\0' }, - { char(78), '\0' }, - { char(79), '\0' }, - { char(80), '\0' }, - { char(81), '\0' }, - { char(82), '\0' }, - { char(83), '\0' }, - { char(84), '\0' }, - { char(85), '\0' }, - { char(86), '\0' }, - { char(87), '\0' }, - { char(88), '\0' }, - { char(89), '\0' }, - { char(90), '\0' }, - { char(91), '\0' }, - { char(92), '\0' }, - { char(93), '\0' }, - { char(94), '\0' }, - { char(95), '\0' }, - { char(96), '\0' }, - { char(97), '\0' }, - { char(98), '\0' }, - { char(99), '\0' }, - { char(100), '\0' }, - { char(101), '\0' }, - { char(102), '\0' }, - { char(103), '\0' }, - { char(104), '\0' }, - { char(105), '\0' }, - { char(106), '\0' }, - { char(107), '\0' }, - { char(108), '\0' }, - { char(109), '\0' }, - { char(110), '\0' }, - { char(111), '\0' }, - { char(112), '\0' }, - { char(113), '\0' }, - { char(114), '\0' }, - { char(115), '\0' }, - { char(116), '\0' }, - { char(117), '\0' }, - { char(118), '\0' }, - { char(119), '\0' }, - { char(120), '\0' }, - { char(121), '\0' }, - { char(122), '\0' }, - { char(123), '\0' }, - { char(124), '\0' }, - { char(125), '\0' }, - { char(126), '\0' }, - { char(127), '\0' }, + {char(32), '\0'}, + {char(33), '\0'}, + {char(34), '\0'}, + {char(35), '\0'}, + {char(36), '\0'}, + {char(37), '\0'}, + {char(38), '\0'}, + {char(39), '\0'}, + {char(40), '\0'}, + {char(41), '\0'}, + {char(42), '\0'}, + {char(43), '\0'}, + {char(44), '\0'}, + {char(45), '\0'}, + {char(46), '\0'}, + {char(47), '\0'}, + {char(48), '\0'}, + {char(49), '\0'}, + {char(50), '\0'}, + {char(51), '\0'}, + {char(52), '\0'}, + {char(53), '\0'}, + {char(54), '\0'}, + {char(55), '\0'}, + {char(56), '\0'}, + {char(57), '\0'}, + {char(58), '\0'}, + {char(59), '\0'}, + {char(60), '\0'}, + {char(61), '\0'}, + {char(62), '\0'}, + {char(63), '\0'}, + {char(64), '\0'}, + {char(65), '\0'}, + {char(66), '\0'}, + {char(67), '\0'}, + {char(68), '\0'}, + {char(69), '\0'}, + {char(70), '\0'}, + {char(71), '\0'}, + {char(72), '\0'}, + {char(73), '\0'}, + {char(74), '\0'}, + {char(75), '\0'}, + {char(76), '\0'}, + {char(77), '\0'}, + {char(78), '\0'}, + {char(79), '\0'}, + {char(80), '\0'}, + {char(81), '\0'}, + {char(82), '\0'}, + {char(83), '\0'}, + {char(84), '\0'}, + {char(85), '\0'}, + {char(86), '\0'}, + {char(87), '\0'}, + {char(88), '\0'}, + {char(89), '\0'}, + {char(90), '\0'}, + {char(91), '\0'}, + {char(92), '\0'}, + {char(93), '\0'}, + {char(94), '\0'}, + {char(95), '\0'}, + {char(96), '\0'}, + {char(97), '\0'}, + {char(98), '\0'}, + {char(99), '\0'}, + {char(100), '\0'}, + {char(101), '\0'}, + {char(102), '\0'}, + {char(103), '\0'}, + {char(104), '\0'}, + {char(105), '\0'}, + {char(106), '\0'}, + {char(107), '\0'}, + {char(108), '\0'}, + {char(109), '\0'}, + {char(110), '\0'}, + {char(111), '\0'}, + {char(112), '\0'}, + {char(113), '\0'}, + {char(114), '\0'}, + {char(115), '\0'}, + {char(116), '\0'}, + {char(117), '\0'}, + {char(118), '\0'}, + {char(119), '\0'}, + {char(120), '\0'}, + {char(121), '\0'}, + {char(122), '\0'}, + {char(123), '\0'}, + {char(124), '\0'}, + {char(125), '\0'}, + {char(126), '\0'}, + {char(127), '\0'}, }; int check_tokens_consistency() { - if (sizeof(_S_token_names) / sizeof(_S_token_names[0]) != TOKEN_KIND_COUNT - Token_K_DCOP) - { - std::cerr << "** ERROR enum TOKEN_KIND and _S_token_names are not consistent" << std::endl; - abort(); - } + if (sizeof(_S_token_names) / sizeof(_S_token_names[0]) != TOKEN_KIND_COUNT - Token_K_DCOP) { + std::cerr << "** ERROR enum TOKEN_KIND and _S_token_names are not consistent" << std::endl; + abort(); + } return 0; } static int tokens_consistency = check_tokens_consistency(); -char const *token_name(int token) +char const* token_name(int token) { - if (token == 0) - { - return "eof"; - } - else if (token >= 32 && token <= 127) - { - return _S_printable[token - 32]; - } - else if (token >= Token_K_DCOP) - { - return _S_token_names[token - Token_K_DCOP]; - } + if (token == 0) { + return "eof"; + } else if (token >= 32 && token <= 127) { + return _S_printable[token - 32]; + } else if (token >= Token_K_DCOP) { + return _S_token_names[token - Token_K_DCOP]; + } Q_ASSERT(0); return 0; diff --git a/generator/parser/tokens.h b/generator/parser/tokens.h index edc6221f0..c7b31867d 100644 --- a/generator/parser/tokens.h +++ b/generator/parser/tokens.h @@ -39,131 +39,129 @@ ** ****************************************************************************/ - #ifndef TOKENS_H -#define TOKENS_H + #define TOKENS_H -enum TOKEN_KIND -{ - Token_EOF = 0, +enum TOKEN_KIND { + Token_EOF = 0, - Token_K_DCOP = 1000, - Token_Q_OBJECT, - Token_Q_PROPERTY, - Token___attribute__, - Token___typeof, - Token_alignas, - Token_and, - Token_and_eq, - Token_arrow, - Token_asm, - Token_assign, - Token_auto, - Token_bitand, - Token_bitor, - Token_bool, - Token_break, - Token_case, - Token_catch, - Token_char, - Token_char_literal, - Token_class, - Token_comment, - Token_compl, - Token_concat, - Token_const, - Token_constexpr, - Token_const_cast, - Token_continue, - Token_decltype, - Token_decr, - Token_default, - Token_delete, - Token_do, - Token_double, - Token_dynamic_cast, - Token_ellipsis, - Token_else, - Token_emit, - Token_enum, - Token_eq, - Token_explicit, - Token_export, - Token_extern, - Token_false, - Token_float, - Token_for, - Token_friend, - Token_geq, - Token_goto, - Token_identifier, - Token_if, - Token_incr, - Token_inline, - Token_int, - Token_k_dcop, - Token_k_dcop_signals, - Token_leq, - Token_long, - Token_mutable, - Token_namespace, - Token_new, - Token_noexcept, - Token_not, - Token_not_eq, - Token_number_literal, - Token_operator, - Token_or, - Token_or_eq, - Token_placeholder, - Token_preproc, - Token_private, - Token_protected, - Token_ptrmem, - Token_public, - Token_register, - Token_reinterpret_cast, - Token_return, - Token_scope, - Token_shift_left, - Token_shift_right, - Token_short, - Token_signals, - Token_signed, - Token_sizeof, - Token_slots, - Token_static, - Token_static_cast, - Token_string_literal, - Token_struct, - Token_switch, - Token_template, - Token_this, - Token_throw, - Token_true, - Token_try, - Token_typedef, - Token_typeid, - Token_typename, - Token_union, - Token_unsigned, - Token_using, - Token_virtual, - Token_void, - Token_volatile, - Token_wchar_t, - Token_while, - Token_whitespaces, - Token_xor, - Token_xor_eq, - Token_Q_ENUMS, - Token_Q_ENUM, - Token_Q_INVOKABLE, + Token_K_DCOP = 1000, + Token_Q_OBJECT, + Token_Q_PROPERTY, + Token___attribute__, + Token___typeof, + Token_alignas, + Token_and, + Token_and_eq, + Token_arrow, + Token_asm, + Token_assign, + Token_auto, + Token_bitand, + Token_bitor, + Token_bool, + Token_break, + Token_case, + Token_catch, + Token_char, + Token_char_literal, + Token_class, + Token_comment, + Token_compl, + Token_concat, + Token_const, + Token_constexpr, + Token_const_cast, + Token_continue, + Token_decltype, + Token_decr, + Token_default, + Token_delete, + Token_do, + Token_double, + Token_dynamic_cast, + Token_ellipsis, + Token_else, + Token_emit, + Token_enum, + Token_eq, + Token_explicit, + Token_export, + Token_extern, + Token_false, + Token_float, + Token_for, + Token_friend, + Token_geq, + Token_goto, + Token_identifier, + Token_if, + Token_incr, + Token_inline, + Token_int, + Token_k_dcop, + Token_k_dcop_signals, + Token_leq, + Token_long, + Token_mutable, + Token_namespace, + Token_new, + Token_noexcept, + Token_not, + Token_not_eq, + Token_number_literal, + Token_operator, + Token_or, + Token_or_eq, + Token_placeholder, + Token_preproc, + Token_private, + Token_protected, + Token_ptrmem, + Token_public, + Token_register, + Token_reinterpret_cast, + Token_return, + Token_scope, + Token_shift_left, + Token_shift_right, + Token_short, + Token_signals, + Token_signed, + Token_sizeof, + Token_slots, + Token_static, + Token_static_cast, + Token_string_literal, + Token_struct, + Token_switch, + Token_template, + Token_this, + Token_throw, + Token_true, + Token_try, + Token_typedef, + Token_typeid, + Token_typename, + Token_union, + Token_unsigned, + Token_using, + Token_virtual, + Token_void, + Token_volatile, + Token_wchar_t, + Token_while, + Token_whitespaces, + Token_xor, + Token_xor_eq, + Token_Q_ENUMS, + Token_Q_ENUM, + Token_Q_INVOKABLE, - TOKEN_KIND_COUNT + TOKEN_KIND_COUNT }; -char const *token_name(int token); +char const* token_name(int token); #endif diff --git a/generator/parser/type_compiler.cpp b/generator/parser/type_compiler.cpp index a03ef9793..6405c4b29 100644 --- a/generator/parser/type_compiler.cpp +++ b/generator/parser/type_compiler.cpp @@ -41,7 +41,6 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ - #include "type_compiler.h" #include "name_compiler.h" #include "lexer.h" @@ -51,76 +50,69 @@ #include -TypeCompiler::TypeCompiler(Binder *binder) - : _M_binder (binder), _M_token_stream(binder->tokenStream ()) +TypeCompiler::TypeCompiler(Binder* binder) + : _M_binder(binder) + , _M_token_stream(binder->tokenStream()) { } -void TypeCompiler::run(TypeSpecifierAST *node) +void TypeCompiler::run(TypeSpecifierAST* node) { _M_type.clear(); _M_cv.clear(); visit(node); - if (node && node->cv) - { - const ListNode *it = node->cv->toFront(); - const ListNode *end = it; - do - { - int kind = _M_token_stream->kind(it->element); - if (! _M_cv.contains(kind)) - _M_cv.append(kind); - - it = it->next; - } - while (it != end); - } + if (node && node->cv) { + const ListNode* it = node->cv->toFront(); + const ListNode* end = it; + do { + int kind = _M_token_stream->kind(it->element); + if (!_M_cv.contains(kind)) + _M_cv.append(kind); + + it = it->next; + } while (it != end); + } } -void TypeCompiler::visitClassSpecifier(ClassSpecifierAST *node) +void TypeCompiler::visitClassSpecifier(ClassSpecifierAST* node) { visit(node->name); } -void TypeCompiler::visitEnumSpecifier(EnumSpecifierAST *node) +void TypeCompiler::visitEnumSpecifier(EnumSpecifierAST* node) { visit(node->name); } -void TypeCompiler::visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *node) +void TypeCompiler::visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST* node) { visit(node->name); } -void TypeCompiler::visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *node) +void TypeCompiler::visitSimpleTypeSpecifier(SimpleTypeSpecifierAST* node) { - if (const ListNode *it = node->integrals) - { - it = it->toFront(); - const ListNode *end = it; - QString current_item; - do - { - std::size_t token = it->element; - current_item += token_name(_M_token_stream->kind(token)); - current_item += " "; - it = it->next; - } - while (it != end); - _M_type += current_item.trimmed(); - } - else if (node->type_of) - { - // ### implement me - _M_type += QLatin1String("typeof<...>"); - } + if (const ListNode* it = node->integrals) { + it = it->toFront(); + const ListNode* end = it; + QString current_item; + do { + std::size_t token = it->element; + current_item += token_name(_M_token_stream->kind(token)); + current_item += " "; + it = it->next; + } while (it != end); + _M_type += current_item.trimmed(); + } else if (node->type_of) { + // ### implement me + _M_type += QLatin1String("typeof<...>"); + } visit(node->name); } -void TypeCompiler::visitName(NameAST *node) +void TypeCompiler::visitName(NameAST* node) { NameCompiler name_cc(_M_binder); name_cc.run(node); diff --git a/generator/parser/type_compiler.h b/generator/parser/type_compiler.h index b6ea6915e..b2549ef8f 100644 --- a/generator/parser/type_compiler.h +++ b/generator/parser/type_compiler.h @@ -39,23 +39,22 @@ ** ****************************************************************************/ - #ifndef TYPE_COMPILER_H -#define TYPE_COMPILER_H + #define TYPE_COMPILER_H -#include "default_visitor.h" + #include "default_visitor.h" -#include -#include -#include + #include + #include + #include class TokenStream; class Binder; -class TypeCompiler: protected DefaultVisitor +class TypeCompiler : protected DefaultVisitor { public: - TypeCompiler(Binder *binder); + TypeCompiler(Binder* binder); inline QStringList qualifiedName() const { return _M_type; } inline QList cv() const { return _M_cv; } @@ -64,19 +63,19 @@ class TypeCompiler: protected DefaultVisitor bool isVolatile() const; bool isMutable() const; - void run(TypeSpecifierAST *node); + void run(TypeSpecifierAST* node); protected: - virtual void visitClassSpecifier(ClassSpecifierAST *node); - virtual void visitEnumSpecifier(EnumSpecifierAST *node); - virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *node); - virtual void visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *node); + virtual void visitClassSpecifier(ClassSpecifierAST* node); + virtual void visitEnumSpecifier(EnumSpecifierAST* node); + virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST* node); + virtual void visitSimpleTypeSpecifier(SimpleTypeSpecifierAST* node); - virtual void visitName(NameAST *node); + virtual void visitName(NameAST* node); private: - Binder *_M_binder; - TokenStream *_M_token_stream; + Binder* _M_binder; + TokenStream* _M_token_stream; QStringList _M_type; QList _M_cv; }; diff --git a/generator/parser/visitor.cpp b/generator/parser/visitor.cpp index be88d8352..77b16d849 100644 --- a/generator/parser/visitor.cpp +++ b/generator/parser/visitor.cpp @@ -39,11 +39,9 @@ ** ****************************************************************************/ - #include "visitor.h" -Visitor::visitor_fun_ptr Visitor::_S_table[AST::NODE_KIND_COUNT] = { - 0, +Visitor::visitor_fun_ptr Visitor::_S_table[AST::NODE_KIND_COUNT] = {0, reinterpret_cast(&Visitor::visitAccessSpecifier), reinterpret_cast(&Visitor::visitAsmDefinition), reinterpret_cast(&Visitor::visitBaseClause), @@ -119,18 +117,13 @@ Visitor::visitor_fun_ptr Visitor::_S_table[AST::NODE_KIND_COUNT] = { reinterpret_cast(&Visitor::visitWinDeclSpec), reinterpret_cast(&Visitor::visitQProperty), reinterpret_cast(&Visitor::visitForwardDeclarationSpecifier), - reinterpret_cast(&Visitor::visitQEnums) -}; + reinterpret_cast(&Visitor::visitQEnums)}; -Visitor::Visitor() -{ -} +Visitor::Visitor() {} -Visitor::~Visitor() -{ -} +Visitor::~Visitor() {} -void Visitor::visit(AST *node) +void Visitor::visit(AST* node) { if (node) (this->*_S_table[node->kind])(node); diff --git a/generator/parser/visitor.h b/generator/parser/visitor.h index 01f5898d6..c5f751036 100644 --- a/generator/parser/visitor.h +++ b/generator/parser/visitor.h @@ -39,11 +39,10 @@ ** ****************************************************************************/ - #ifndef VISITOR_H -#define VISITOR_H + #define VISITOR_H -#include "ast.h" + #include "ast.h" class Visitor { @@ -51,108 +50,104 @@ class Visitor Visitor(); virtual ~Visitor(); - virtual void visit(AST *node); + virtual void visit(AST* node); protected: - virtual void visitAccessSpecifier(AccessSpecifierAST *) {} - virtual void visitAsmDefinition(AsmDefinitionAST *) {} - virtual void visitBaseClause(BaseClauseAST *) {} - virtual void visitBaseSpecifier(BaseSpecifierAST *) {} - virtual void visitBinaryExpression(BinaryExpressionAST *) {} - virtual void visitCastExpression(CastExpressionAST *) {} - virtual void visitClassMemberAccess(ClassMemberAccessAST *) {} - virtual void visitClassSpecifier(ClassSpecifierAST *) {} - virtual void visitCompoundStatement(CompoundStatementAST *) {} - virtual void visitCondition(ConditionAST *) {} - virtual void visitConditionalExpression(ConditionalExpressionAST *) {} - virtual void visitCppCastExpression(CppCastExpressionAST *) {} - virtual void visitCtorInitializer(CtorInitializerAST *) {} - virtual void visitDeclarationStatement(DeclarationStatementAST *) {} - virtual void visitDeclarator(DeclaratorAST *) {} - virtual void visitDeleteExpression(DeleteExpressionAST *) {} - virtual void visitDoStatement(DoStatementAST *) {} - virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST *) {} - virtual void visitEnumSpecifier(EnumSpecifierAST *) {} - virtual void visitEnumerator(EnumeratorAST *) {} - virtual void visitExceptionSpecification(ExceptionSpecificationAST *) {} - virtual void visitExpressionOrDeclarationStatement(ExpressionOrDeclarationStatementAST *) {} - virtual void visitExpressionStatement(ExpressionStatementAST *) {} - virtual void visitForStatement(ForStatementAST *) {} - virtual void visitFunctionCall(FunctionCallAST *) {} - virtual void visitFunctionDefinition(FunctionDefinitionAST *) {} - virtual void visitIfStatement(IfStatementAST *) {} - virtual void visitIncrDecrExpression(IncrDecrExpressionAST *) {} - virtual void visitInitDeclarator(InitDeclaratorAST *) {} - virtual void visitInitializer(InitializerAST *) {} - virtual void visitInitializerClause(InitializerClauseAST *) {} - virtual void visitLabeledStatement(LabeledStatementAST *) {} - virtual void visitLinkageBody(LinkageBodyAST *) {} - virtual void visitLinkageSpecification(LinkageSpecificationAST *) {} - virtual void visitMemInitializer(MemInitializerAST *) {} - virtual void visitName(NameAST *) {} - virtual void visitNamespace(NamespaceAST *) {} - virtual void visitNamespaceAliasDefinition(NamespaceAliasDefinitionAST *) {} - virtual void visitNewDeclarator(NewDeclaratorAST *) {} - virtual void visitNewExpression(NewExpressionAST *) {} - virtual void visitNewInitializer(NewInitializerAST *) {} - virtual void visitNewTypeId(NewTypeIdAST *) {} - virtual void visitOperator(OperatorAST *) {} - virtual void visitOperatorFunctionId(OperatorFunctionIdAST *) {} - virtual void visitParameterDeclaration(ParameterDeclarationAST *) {} - virtual void visitParameterDeclarationClause(ParameterDeclarationClauseAST *) {} - virtual void visitPostfixExpression(PostfixExpressionAST *) {} - virtual void visitPrimaryExpression(PrimaryExpressionAST *) {} - virtual void visitPtrOperator(PtrOperatorAST *) {} - virtual void visitPtrToMember(PtrToMemberAST *) {} - virtual void visitReturnStatement(ReturnStatementAST *) {} - virtual void visitSimpleDeclaration(SimpleDeclarationAST *) {} - virtual void visitSimpleTypeSpecifier(SimpleTypeSpecifierAST *) {} - virtual void visitSizeofExpression(SizeofExpressionAST *) {} - virtual void visitStringLiteral(StringLiteralAST *) {} - virtual void visitSubscriptExpression(SubscriptExpressionAST *) {} - virtual void visitSwitchStatement(SwitchStatementAST *) {} - virtual void visitTemplateArgument(TemplateArgumentAST *) {} - virtual void visitTemplateDeclaration(TemplateDeclarationAST *) {} - virtual void visitTemplateParameter(TemplateParameterAST *) {} - virtual void visitThrowExpression(ThrowExpressionAST *) {} - virtual void visitTranslationUnit(TranslationUnitAST *) {} - virtual void visitTryBlockStatement(TryBlockStatementAST *) {} - virtual void visitTypeId(TypeIdAST *) {} - virtual void visitTypeIdentification(TypeIdentificationAST *) {} - virtual void visitTypeParameter(TypeParameterAST *) {} - virtual void visitTypedef(TypedefAST *) {} - virtual void visitUnaryExpression(UnaryExpressionAST *) {} - virtual void visitUnqualifiedName(UnqualifiedNameAST *) {} - virtual void visitUsing(UsingAST *) {} - virtual void visitUsingDirective(UsingDirectiveAST *) {} - virtual void visitWhileStatement(WhileStatementAST *) {} - virtual void visitWinDeclSpec(WinDeclSpecAST *) {} - virtual void visitQProperty(QPropertyAST *) {} - virtual void visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST *) {} - virtual void visitQEnums(QEnumsAST *) {} + virtual void visitAccessSpecifier(AccessSpecifierAST*) {} + virtual void visitAsmDefinition(AsmDefinitionAST*) {} + virtual void visitBaseClause(BaseClauseAST*) {} + virtual void visitBaseSpecifier(BaseSpecifierAST*) {} + virtual void visitBinaryExpression(BinaryExpressionAST*) {} + virtual void visitCastExpression(CastExpressionAST*) {} + virtual void visitClassMemberAccess(ClassMemberAccessAST*) {} + virtual void visitClassSpecifier(ClassSpecifierAST*) {} + virtual void visitCompoundStatement(CompoundStatementAST*) {} + virtual void visitCondition(ConditionAST*) {} + virtual void visitConditionalExpression(ConditionalExpressionAST*) {} + virtual void visitCppCastExpression(CppCastExpressionAST*) {} + virtual void visitCtorInitializer(CtorInitializerAST*) {} + virtual void visitDeclarationStatement(DeclarationStatementAST*) {} + virtual void visitDeclarator(DeclaratorAST*) {} + virtual void visitDeleteExpression(DeleteExpressionAST*) {} + virtual void visitDoStatement(DoStatementAST*) {} + virtual void visitElaboratedTypeSpecifier(ElaboratedTypeSpecifierAST*) {} + virtual void visitEnumSpecifier(EnumSpecifierAST*) {} + virtual void visitEnumerator(EnumeratorAST*) {} + virtual void visitExceptionSpecification(ExceptionSpecificationAST*) {} + virtual void visitExpressionOrDeclarationStatement(ExpressionOrDeclarationStatementAST*) {} + virtual void visitExpressionStatement(ExpressionStatementAST*) {} + virtual void visitForStatement(ForStatementAST*) {} + virtual void visitFunctionCall(FunctionCallAST*) {} + virtual void visitFunctionDefinition(FunctionDefinitionAST*) {} + virtual void visitIfStatement(IfStatementAST*) {} + virtual void visitIncrDecrExpression(IncrDecrExpressionAST*) {} + virtual void visitInitDeclarator(InitDeclaratorAST*) {} + virtual void visitInitializer(InitializerAST*) {} + virtual void visitInitializerClause(InitializerClauseAST*) {} + virtual void visitLabeledStatement(LabeledStatementAST*) {} + virtual void visitLinkageBody(LinkageBodyAST*) {} + virtual void visitLinkageSpecification(LinkageSpecificationAST*) {} + virtual void visitMemInitializer(MemInitializerAST*) {} + virtual void visitName(NameAST*) {} + virtual void visitNamespace(NamespaceAST*) {} + virtual void visitNamespaceAliasDefinition(NamespaceAliasDefinitionAST*) {} + virtual void visitNewDeclarator(NewDeclaratorAST*) {} + virtual void visitNewExpression(NewExpressionAST*) {} + virtual void visitNewInitializer(NewInitializerAST*) {} + virtual void visitNewTypeId(NewTypeIdAST*) {} + virtual void visitOperator(OperatorAST*) {} + virtual void visitOperatorFunctionId(OperatorFunctionIdAST*) {} + virtual void visitParameterDeclaration(ParameterDeclarationAST*) {} + virtual void visitParameterDeclarationClause(ParameterDeclarationClauseAST*) {} + virtual void visitPostfixExpression(PostfixExpressionAST*) {} + virtual void visitPrimaryExpression(PrimaryExpressionAST*) {} + virtual void visitPtrOperator(PtrOperatorAST*) {} + virtual void visitPtrToMember(PtrToMemberAST*) {} + virtual void visitReturnStatement(ReturnStatementAST*) {} + virtual void visitSimpleDeclaration(SimpleDeclarationAST*) {} + virtual void visitSimpleTypeSpecifier(SimpleTypeSpecifierAST*) {} + virtual void visitSizeofExpression(SizeofExpressionAST*) {} + virtual void visitStringLiteral(StringLiteralAST*) {} + virtual void visitSubscriptExpression(SubscriptExpressionAST*) {} + virtual void visitSwitchStatement(SwitchStatementAST*) {} + virtual void visitTemplateArgument(TemplateArgumentAST*) {} + virtual void visitTemplateDeclaration(TemplateDeclarationAST*) {} + virtual void visitTemplateParameter(TemplateParameterAST*) {} + virtual void visitThrowExpression(ThrowExpressionAST*) {} + virtual void visitTranslationUnit(TranslationUnitAST*) {} + virtual void visitTryBlockStatement(TryBlockStatementAST*) {} + virtual void visitTypeId(TypeIdAST*) {} + virtual void visitTypeIdentification(TypeIdentificationAST*) {} + virtual void visitTypeParameter(TypeParameterAST*) {} + virtual void visitTypedef(TypedefAST*) {} + virtual void visitUnaryExpression(UnaryExpressionAST*) {} + virtual void visitUnqualifiedName(UnqualifiedNameAST*) {} + virtual void visitUsing(UsingAST*) {} + virtual void visitUsingDirective(UsingDirectiveAST*) {} + virtual void visitWhileStatement(WhileStatementAST*) {} + virtual void visitWinDeclSpec(WinDeclSpecAST*) {} + virtual void visitQProperty(QPropertyAST*) {} + virtual void visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST*) {} + virtual void visitQEnums(QEnumsAST*) {} private: - typedef void (Visitor::*visitor_fun_ptr)(AST *); + typedef void (Visitor::*visitor_fun_ptr)(AST*); static visitor_fun_ptr _S_table[]; }; -template - void visitNodes(Visitor *v, const ListNode<_Tp> *nodes) - { - if (!nodes) - return; +template +void visitNodes(Visitor* v, const ListNode<_Tp>* nodes) +{ + if (!nodes) + return; - const ListNode<_Tp> - *it = nodes->toFront(), - *end = it; + const ListNode<_Tp>*it = nodes->toFront(), *end = it; - do - { - v->visit(it->element); - it = it->next; - } - while (it != end); - } + do { + v->visit(it->element); + it = it->next; + } while (it != end); +} #endif // VISITOR_H diff --git a/generator/prigenerator.cpp b/generator/prigenerator.cpp index 7dfdda896..8dc6aa301 100644 --- a/generator/prigenerator.cpp +++ b/generator/prigenerator.cpp @@ -46,35 +46,37 @@ #include "reporthandler.h" #include "fileout.h" -void PriGenerator::addHeader(const QString &folder, const QString &header) +void PriGenerator::addHeader(const QString& folder, const QString& header) { - priHash[folder].headers << header; + priHash[folder].headers << header; } -void PriGenerator::addSource(const QString &folder, const QString &source) +void PriGenerator::addSource(const QString& folder, const QString& source) { - priHash[folder].sources << source; + priHash[folder].sources << source; } -static void collectAndRemoveFile(QTextStream& stream, const QString& file) { +static void collectAndRemoveFile(QTextStream& stream, const QString& file) +{ QFile f(file); if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { QString s = QString::fromLatin1(f.readAll()); if (file.endsWith(".cpp")) { // remove first line include - s = s.mid(s.indexOf('\n')+1); + s = s.mid(s.indexOf('\n') + 1); } stream << s; f.close(); QFile::remove(file); } } - -static QString combineIncludes(const QString& text) { + +static QString combineIncludes(const QString& text) +{ QStringList lines = text.split('\n'); QSet includes; QString result; - for (QString line : lines) { + for (QString line : lines) { if (line.startsWith("#include")) { includes.insert(line); } else if (line.startsWith("#") && line.contains("PYTHONQTWRAPPER_")) { @@ -83,25 +85,27 @@ static QString combineIncludes(const QString& text) { result += line + "\n"; } } -#if QT_VERSION < QT_VERSION_CHECK(5,14,0) - QStringList includeList = includes.toList(); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + QStringList includeList = includes.toList(); #else - QStringList includeList(includes.begin(), includes.end()); + QStringList includeList(includes.begin(), includes.end()); #endif std::sort(includeList.begin(), includeList.end()); result = includeList.join("\n") + result; return result; } -QStringList PriGenerator::compactFiles(const QStringList& list, const QString& ext, const QString& dir, const QString& prefix) { +QStringList PriGenerator::compactFiles(const QStringList& list, const QString& ext, const QString& dir, + const QString& prefix) +{ QStringList outList; int count = list.count(); int fileNum = 0; QString srcDir = dir; if (dir.endsWith("_builtin")) { - srcDir = dir.left(dir.length()-strlen("_builtin")); + srcDir = dir.left(dir.length() - strlen("_builtin")); } - while (count>0) { + while (count > 0) { QString outFileName = prefix + QString::number(fileNum) + ext; FileOut file(dir + "/" + outFileName); if (ext == ".cpp") { @@ -110,8 +114,8 @@ QStringList PriGenerator::compactFiles(const QStringList& list, const QString& e outList << outFileName; QString allText; QTextStream ts(&allText); - for (int i = 0; i< maxClassesPerFile && count>0; i++) { - collectAndRemoveFile(ts, srcDir + "/" + list.at(list.count()-count)); + for (int i = 0; i < maxClassesPerFile && count > 0; i++) { + collectAndRemoveFile(ts, srcDir + "/" + list.at(list.count() - count)); count--; } allText = combineIncludes(allText); @@ -123,46 +127,46 @@ QStringList PriGenerator::compactFiles(const QStringList& list, const QString& e void PriGenerator::generate() { - QHashIterator pri(priHash); - while (pri.hasNext()) { - pri.next(); - QStringList list = pri.value().headers; - if (list.isEmpty()) - continue; + QHashIterator pri(priHash); + while (pri.hasNext()) { + pri.next(); + QStringList list = pri.value().headers; + if (list.isEmpty()) + continue; + + QString folder = pri.key(); + folder.replace('\\', '/'); + int idx = folder.indexOf('/'); + folder = folder.left(idx); - QString folder = pri.key(); - folder.replace('\\','/'); - int idx = folder.indexOf('/'); - folder = folder.left(idx); + std::sort(list.begin(), list.end()); + FileOut file(m_out_dir + "/generated_cpp/" + pri.key()); - std::sort(list.begin(), list.end()); - FileOut file(m_out_dir + "/generated_cpp/" + pri.key()); - - // strange idea to do the file compacting so late, but it is the most effective way without patching the generator a lot - bool compact = true; - if (compact) { - list = compactFiles(list, ".h", m_out_dir + "/generated_cpp/" + folder, folder); - } - - file.stream << "HEADERS += \\\n"; - for (const QString& entry : list) { - file.stream << " $$PWD/" << entry << " \\\n"; - } + // strange idea to do the file compacting so late, but it is the most effective way without patching the generator a lot + bool compact = true; + if (compact) { + list = compactFiles(list, ".h", m_out_dir + "/generated_cpp/" + folder, folder); + } - file.stream << "\n"; - file.stream << "SOURCES += \\\n"; - list = pri.value().sources; - std::sort(list.begin(), list.end()); - if (compact) { - list = compactFiles(list, ".cpp", m_out_dir + "/generated_cpp/" + folder, folder); - } - for (const QString& entry : list) { - file.stream << " $$PWD/" << entry << " \\\n"; - } - file.stream << " $$PWD/" << folder << "_init.cpp\n"; + file.stream << "HEADERS += \\\n"; + for (const QString& entry : list) { + file.stream << " $$PWD/" << entry << " \\\n"; + } - if (file.done()) - ++m_num_generated_written; - ++m_num_generated; + file.stream << "\n"; + file.stream << "SOURCES += \\\n"; + list = pri.value().sources; + std::sort(list.begin(), list.end()); + if (compact) { + list = compactFiles(list, ".cpp", m_out_dir + "/generated_cpp/" + folder, folder); + } + for (const QString& entry : list) { + file.stream << " $$PWD/" << entry << " \\\n"; } + file.stream << " $$PWD/" << folder << "_init.cpp\n"; + + if (file.done()) + ++m_num_generated_written; + ++m_num_generated; + } } diff --git a/generator/prigenerator.h b/generator/prigenerator.h index 853ea6b7f..11afcf42f 100644 --- a/generator/prigenerator.h +++ b/generator/prigenerator.h @@ -47,29 +47,29 @@ #include #include -struct Pri -{ - QStringList headers; - QStringList sources; +struct Pri { + QStringList headers; + QStringList sources; }; class PriGenerator : public Generator { - Q_OBJECT - - public: - PriGenerator(int classesPerFile) : maxClassesPerFile(classesPerFile) {} - virtual void generate(); + Q_OBJECT - void addHeader(const QString &folder, const QString &header); - void addSource(const QString &folder, const QString &source); +public: + PriGenerator(int classesPerFile) + : maxClassesPerFile(classesPerFile) + { + } + virtual void generate(); - private: - QStringList compactFiles(const QStringList& list, const QString& ext, const QString& dir, const QString& prefix); + void addHeader(const QString& folder, const QString& header); + void addSource(const QString& folder, const QString& source); - QHash priHash; - int maxClassesPerFile; +private: + QStringList compactFiles(const QStringList& list, const QString& ext, const QString& dir, const QString& prefix); + QHash priHash; + int maxClassesPerFile; }; #endif // PRIGENERATOR_H - diff --git a/generator/qtscript_masterinclude.h b/generator/qtscript_masterinclude.h index 0d4c47597..ee2e60f26 100644 --- a/generator/qtscript_masterinclude.h +++ b/generator/qtscript_masterinclude.h @@ -39,7 +39,6 @@ ** ****************************************************************************/ - // Qt #define QOBJECTDEFS_H #define QTMETAMACROS_H @@ -50,7 +49,7 @@ #define Q_FLAGS(a) #define Q_FLAG(a) #define Q_PRIVATE_SLOT(a, b) -#define Q_DECLARE_INTERFACE(a,b) +#define Q_DECLARE_INTERFACE(a, b) #define Q_INTERFACES(a) #define Q_GADGET #define Q_OVERRIDE(a) @@ -73,9 +72,6 @@ // ignore static_assert #define static_assert(...) - - - // We need to force the endianess in Qt5 #define Q_BYTE_ORDER Q_LITTLE_ENDIAN @@ -105,18 +101,17 @@ * needs other fixes. */ #if QT_VERSION_MAJOR == 5 && QT_VERSION_MINOR > 11 -# include // included by QtCore/QTimer -# define Q_CLANG_QDOC -# include -# undef Q_CLANG_QDOC + #include // included by QtCore/QTimer + #define Q_CLANG_QDOC + #include + #undef Q_CLANG_QDOC #endif - #if QT_VERSION >= 0x060700 -// adjust macro to work with simplecpp -#define QT_OVERLOADED_MACRO(MACRO, ...) QT_OVERLOADED_MACRO_IMP(MACRO, QT_VA_ARGS_COUNT(__VA_ARGS__))(__VA_ARGS__) - + // adjust macro to work with simplecpp + #define QT_OVERLOADED_MACRO(MACRO, ...) QT_OVERLOADED_MACRO_IMP(MACRO, QT_VA_ARGS_COUNT(__VA_ARGS__))(__VA_ARGS__) + #endif // Workaround: Modify definition of QT_DEFINE_TAG to not include type definition in variable definition, @@ -162,1134 +157,1132 @@ #include #if QT_VERSION >= 0x060000 -#include + #include #endif #include #if QT_VERSION >= 0x050000 -#include -#include + #include + #include #endif #include #if QT_VERSION >= 0x050000 -#include -#include -#include -#include + #include + #include + #include + #include #endif #if QT_VERSION < 0x060000 -#ifndef QT_NO_XMLPATTERNS -# include -#endif + #ifndef QT_NO_XMLPATTERNS + #include + #endif #endif #ifndef QT_NO_WEBKIT -# include -#if QT_VERSION >= 0x050000 -# include -#endif + #include + #if QT_VERSION >= 0x050000 + #include + #endif #endif #include #ifndef QT_NO_PHONON -# include + #include #endif //#include "../qtbindings/qtscript_core/qtscriptconcurrent.h" #ifndef QT_NO_OPENGL -#define GL_ACCUM 0x0100 -#define GL_LOAD 0x0101 -#define GL_RETURN 0x0102 -#define GL_MULT 0x0103 -#define GL_ADD 0x0104 - -/* AlphaFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* AttribMask */ -#define GL_CURRENT_BIT 0x00000001 -#define GL_POINT_BIT 0x00000002 -#define GL_LINE_BIT 0x00000004 -#define GL_POLYGON_BIT 0x00000008 -#define GL_POLYGON_STIPPLE_BIT 0x00000010 -#define GL_PIXEL_MODE_BIT 0x00000020 -#define GL_LIGHTING_BIT 0x00000040 -#define GL_FOG_BIT 0x00000080 -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_ACCUM_BUFFER_BIT 0x00000200 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_VIEWPORT_BIT 0x00000800 -#define GL_TRANSFORM_BIT 0x00001000 -#define GL_ENABLE_BIT 0x00002000 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_HINT_BIT 0x00008000 -#define GL_EVAL_BIT 0x00010000 -#define GL_LIST_BIT 0x00020000 -#define GL_TEXTURE_BIT 0x00040000 -#define GL_SCISSOR_BIT 0x00080000 -#define GL_ALL_ATTRIB_BITS 0x000fffff - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_QUADS 0x0007 -#define GL_QUAD_STRIP 0x0008 -#define GL_POLYGON 0x0009 - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* Boolean */ -#define GL_TRUE 1 -#define GL_FALSE 0 - -/* ClearBufferMask */ -/* GL_COLOR_BUFFER_BIT */ -/* GL_ACCUM_BUFFER_BIT */ -/* GL_STENCIL_BUFFER_BIT */ -/* GL_DEPTH_BUFFER_BIT */ - -/* ClientArrayType */ -/* GL_VERTEX_ARRAY */ -/* GL_NORMAL_ARRAY */ -/* GL_COLOR_ARRAY */ -/* GL_INDEX_ARRAY */ -/* GL_TEXTURE_COORD_ARRAY */ -/* GL_EDGE_FLAG_ARRAY */ - -/* ClipPlaneName */ -#define GL_CLIP_PLANE0 0x3000 -#define GL_CLIP_PLANE1 0x3001 -#define GL_CLIP_PLANE2 0x3002 -#define GL_CLIP_PLANE3 0x3003 -#define GL_CLIP_PLANE4 0x3004 -#define GL_CLIP_PLANE5 0x3005 - -/* ColorMaterialFace */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ - -/* ColorMaterialParameter */ -/* GL_AMBIENT */ -/* GL_DIFFUSE */ -/* GL_SPECULAR */ -/* GL_EMISSION */ -/* GL_AMBIENT_AND_DIFFUSE */ - -/* ColorPointerType */ -/* GL_BYTE */ -/* GL_UNSIGNED_BYTE */ -/* GL_SHORT */ -/* GL_UNSIGNED_SHORT */ -/* GL_INT */ -/* GL_UNSIGNED_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* CullFaceMode */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_2_BYTES 0x1407 -#define GL_3_BYTES 0x1408 -#define GL_4_BYTES 0x1409 -#define GL_DOUBLE 0x140A - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* DrawBufferMode */ -#define GL_NONE 0 -#define GL_FRONT_LEFT 0x0400 -#define GL_FRONT_RIGHT 0x0401 -#define GL_BACK_LEFT 0x0402 -#define GL_BACK_RIGHT 0x0403 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_LEFT 0x0406 -#define GL_RIGHT 0x0407 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_AUX0 0x0409 -#define GL_AUX1 0x040A -#define GL_AUX2 0x040B -#define GL_AUX3 0x040C - -/* Enable */ -/* GL_FOG */ -/* GL_LIGHTING */ -/* GL_TEXTURE_1D */ -/* GL_TEXTURE_2D */ -/* GL_LINE_STIPPLE */ -/* GL_POLYGON_STIPPLE */ -/* GL_CULL_FACE */ -/* GL_ALPHA_TEST */ -/* GL_BLEND */ -/* GL_INDEX_LOGIC_OP */ -/* GL_COLOR_LOGIC_OP */ -/* GL_DITHER */ -/* GL_STENCIL_TEST */ -/* GL_DEPTH_TEST */ -/* GL_CLIP_PLANE0 */ -/* GL_CLIP_PLANE1 */ -/* GL_CLIP_PLANE2 */ -/* GL_CLIP_PLANE3 */ -/* GL_CLIP_PLANE4 */ -/* GL_CLIP_PLANE5 */ -/* GL_LIGHT0 */ -/* GL_LIGHT1 */ -/* GL_LIGHT2 */ -/* GL_LIGHT3 */ -/* GL_LIGHT4 */ -/* GL_LIGHT5 */ -/* GL_LIGHT6 */ -/* GL_LIGHT7 */ -/* GL_TEXTURE_GEN_S */ -/* GL_TEXTURE_GEN_T */ -/* GL_TEXTURE_GEN_R */ -/* GL_TEXTURE_GEN_Q */ -/* GL_MAP1_VERTEX_3 */ -/* GL_MAP1_VERTEX_4 */ -/* GL_MAP1_COLOR_4 */ -/* GL_MAP1_INDEX */ -/* GL_MAP1_NORMAL */ -/* GL_MAP1_TEXTURE_COORD_1 */ -/* GL_MAP1_TEXTURE_COORD_2 */ -/* GL_MAP1_TEXTURE_COORD_3 */ -/* GL_MAP1_TEXTURE_COORD_4 */ -/* GL_MAP2_VERTEX_3 */ -/* GL_MAP2_VERTEX_4 */ -/* GL_MAP2_COLOR_4 */ -/* GL_MAP2_INDEX */ -/* GL_MAP2_NORMAL */ -/* GL_MAP2_TEXTURE_COORD_1 */ -/* GL_MAP2_TEXTURE_COORD_2 */ -/* GL_MAP2_TEXTURE_COORD_3 */ -/* GL_MAP2_TEXTURE_COORD_4 */ -/* GL_POINT_SMOOTH */ -/* GL_LINE_SMOOTH */ -/* GL_POLYGON_SMOOTH */ -/* GL_SCISSOR_TEST */ -/* GL_COLOR_MATERIAL */ -/* GL_NORMALIZE */ -/* GL_AUTO_NORMAL */ -/* GL_VERTEX_ARRAY */ -/* GL_NORMAL_ARRAY */ -/* GL_COLOR_ARRAY */ -/* GL_INDEX_ARRAY */ -/* GL_TEXTURE_COORD_ARRAY */ -/* GL_EDGE_FLAG_ARRAY */ -/* GL_POLYGON_OFFSET_POINT */ -/* GL_POLYGON_OFFSET_LINE */ -/* GL_POLYGON_OFFSET_FILL */ - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FeedBackMode */ -#define GL_2D 0x0600 -#define GL_3D 0x0601 -#define GL_3D_COLOR 0x0602 -#define GL_3D_COLOR_TEXTURE 0x0603 -#define GL_4D_COLOR_TEXTURE 0x0604 - -/* FeedBackToken */ -#define GL_PASS_THROUGH_TOKEN 0x0700 -#define GL_POINT_TOKEN 0x0701 -#define GL_LINE_TOKEN 0x0702 -#define GL_POLYGON_TOKEN 0x0703 -#define GL_BITMAP_TOKEN 0x0704 -#define GL_DRAW_PIXEL_TOKEN 0x0705 -#define GL_COPY_PIXEL_TOKEN 0x0706 -#define GL_LINE_RESET_TOKEN 0x0707 - -/* FogMode */ -/* GL_LINEAR */ -#define GL_EXP 0x0800 -#define GL_EXP2 0x0801 - - -/* FogParameter */ -/* GL_FOG_COLOR */ -/* GL_FOG_DENSITY */ -/* GL_FOG_END */ -/* GL_FOG_INDEX */ -/* GL_FOG_MODE */ -/* GL_FOG_START */ - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetMapTarget */ -#define GL_COEFF 0x0A00 -#define GL_ORDER 0x0A01 -#define GL_DOMAIN 0x0A02 - -/* GetPixelMap */ -/* GL_PIXEL_MAP_I_TO_I */ -/* GL_PIXEL_MAP_S_TO_S */ -/* GL_PIXEL_MAP_I_TO_R */ -/* GL_PIXEL_MAP_I_TO_G */ -/* GL_PIXEL_MAP_I_TO_B */ -/* GL_PIXEL_MAP_I_TO_A */ -/* GL_PIXEL_MAP_R_TO_R */ -/* GL_PIXEL_MAP_G_TO_G */ -/* GL_PIXEL_MAP_B_TO_B */ -/* GL_PIXEL_MAP_A_TO_A */ - -/* GetPointerTarget */ -/* GL_VERTEX_ARRAY_POINTER */ -/* GL_NORMAL_ARRAY_POINTER */ -/* GL_COLOR_ARRAY_POINTER */ -/* GL_INDEX_ARRAY_POINTER */ -/* GL_TEXTURE_COORD_ARRAY_POINTER */ -/* GL_EDGE_FLAG_ARRAY_POINTER */ - -/* GetTarget */ -#define GL_CURRENT_COLOR 0x0B00 -#define GL_CURRENT_INDEX 0x0B01 -#define GL_CURRENT_NORMAL 0x0B02 -#define GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define GL_CURRENT_RASTER_COLOR 0x0B04 -#define GL_CURRENT_RASTER_INDEX 0x0B05 -#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 -#define GL_CURRENT_RASTER_POSITION 0x0B07 -#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 -#define GL_CURRENT_RASTER_DISTANCE 0x0B09 -#define GL_POINT_SMOOTH 0x0B10 -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_RANGE 0x0B12 -#define GL_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_LINE_SMOOTH 0x0B20 -#define GL_LINE_WIDTH 0x0B21 -#define GL_LINE_WIDTH_RANGE 0x0B22 -#define GL_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_LINE_STIPPLE 0x0B24 -#define GL_LINE_STIPPLE_PATTERN 0x0B25 -#define GL_LINE_STIPPLE_REPEAT 0x0B26 -#define GL_LIST_MODE 0x0B30 -#define GL_MAX_LIST_NESTING 0x0B31 -#define GL_LIST_BASE 0x0B32 -#define GL_LIST_INDEX 0x0B33 -#define GL_POLYGON_MODE 0x0B40 -#define GL_POLYGON_SMOOTH 0x0B41 -#define GL_POLYGON_STIPPLE 0x0B42 -#define GL_EDGE_FLAG 0x0B43 -#define GL_CULL_FACE 0x0B44 -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_LIGHTING 0x0B50 -#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 -#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 -#define GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define GL_SHADE_MODEL 0x0B54 -#define GL_COLOR_MATERIAL_FACE 0x0B55 -#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 -#define GL_COLOR_MATERIAL 0x0B57 -#define GL_FOG 0x0B60 -#define GL_FOG_INDEX 0x0B61 -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_COLOR 0x0B66 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_TEST 0x0B71 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_ACCUM_CLEAR_VALUE 0x0B80 -#define GL_STENCIL_TEST 0x0B90 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_MATRIX_MODE 0x0BA0 -#define GL_NORMALIZE 0x0BA1 -#define GL_VIEWPORT 0x0BA2 -#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_PROJECTION_MATRIX 0x0BA7 -#define GL_TEXTURE_MATRIX 0x0BA8 -#define GL_ATTRIB_STACK_DEPTH 0x0BB0 -#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 -#define GL_ALPHA_TEST 0x0BC0 -#define GL_ALPHA_TEST_FUNC 0x0BC1 -#define GL_ALPHA_TEST_REF 0x0BC2 -#define GL_DITHER 0x0BD0 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_BLEND 0x0BE2 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_INDEX_LOGIC_OP 0x0BF1 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_AUX_BUFFERS 0x0C00 -#define GL_DRAW_BUFFER 0x0C01 -#define GL_READ_BUFFER 0x0C02 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_INDEX_CLEAR_VALUE 0x0C20 -#define GL_INDEX_WRITEMASK 0x0C21 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_INDEX_MODE 0x0C30 -#define GL_RGBA_MODE 0x0C31 -#define GL_DOUBLEBUFFER 0x0C32 -#define GL_STEREO 0x0C33 -#define GL_RENDER_MODE 0x0C40 -#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define GL_POINT_SMOOTH_HINT 0x0C51 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_POLYGON_SMOOTH_HINT 0x0C53 -#define GL_FOG_HINT 0x0C54 -#define GL_TEXTURE_GEN_S 0x0C60 -#define GL_TEXTURE_GEN_T 0x0C61 -#define GL_TEXTURE_GEN_R 0x0C62 -#define GL_TEXTURE_GEN_Q 0x0C63 -#define GL_PIXEL_MAP_I_TO_I 0x0C70 -#define GL_PIXEL_MAP_S_TO_S 0x0C71 -#define GL_PIXEL_MAP_I_TO_R 0x0C72 -#define GL_PIXEL_MAP_I_TO_G 0x0C73 -#define GL_PIXEL_MAP_I_TO_B 0x0C74 -#define GL_PIXEL_MAP_I_TO_A 0x0C75 -#define GL_PIXEL_MAP_R_TO_R 0x0C76 -#define GL_PIXEL_MAP_G_TO_G 0x0C77 -#define GL_PIXEL_MAP_B_TO_B 0x0C78 -#define GL_PIXEL_MAP_A_TO_A 0x0C79 -#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 -#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 -#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 -#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 -#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 -#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 -#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 -#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 -#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 -#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 -#define GL_UNPACK_SWAP_BYTES 0x0CF0 -#define GL_UNPACK_LSB_FIRST 0x0CF1 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_SWAP_BYTES 0x0D00 -#define GL_PACK_LSB_FIRST 0x0D01 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAP_COLOR 0x0D10 -#define GL_MAP_STENCIL 0x0D11 -#define GL_INDEX_SHIFT 0x0D12 -#define GL_INDEX_OFFSET 0x0D13 -#define GL_RED_SCALE 0x0D14 -#define GL_RED_BIAS 0x0D15 -#define GL_ZOOM_X 0x0D16 -#define GL_ZOOM_Y 0x0D17 -#define GL_GREEN_SCALE 0x0D18 -#define GL_GREEN_BIAS 0x0D19 -#define GL_BLUE_SCALE 0x0D1A -#define GL_BLUE_BIAS 0x0D1B -#define GL_ALPHA_SCALE 0x0D1C -#define GL_ALPHA_BIAS 0x0D1D -#define GL_DEPTH_SCALE 0x0D1E -#define GL_DEPTH_BIAS 0x0D1F -#define GL_MAX_EVAL_ORDER 0x0D30 -#define GL_MAX_LIGHTS 0x0D31 -#define GL_MAX_CLIP_PLANES 0x0D32 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 -#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_NAME_STACK_DEPTH 0x0D37 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_INDEX_BITS 0x0D51 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_ACCUM_RED_BITS 0x0D58 -#define GL_ACCUM_GREEN_BITS 0x0D59 -#define GL_ACCUM_BLUE_BITS 0x0D5A -#define GL_ACCUM_ALPHA_BITS 0x0D5B -#define GL_NAME_STACK_DEPTH 0x0D70 -#define GL_AUTO_NORMAL 0x0D80 -#define GL_MAP1_COLOR_4 0x0D90 -#define GL_MAP1_INDEX 0x0D91 -#define GL_MAP1_NORMAL 0x0D92 -#define GL_MAP1_TEXTURE_COORD_1 0x0D93 -#define GL_MAP1_TEXTURE_COORD_2 0x0D94 -#define GL_MAP1_TEXTURE_COORD_3 0x0D95 -#define GL_MAP1_TEXTURE_COORD_4 0x0D96 -#define GL_MAP1_VERTEX_3 0x0D97 -#define GL_MAP1_VERTEX_4 0x0D98 -#define GL_MAP2_COLOR_4 0x0DB0 -#define GL_MAP2_INDEX 0x0DB1 -#define GL_MAP2_NORMAL 0x0DB2 -#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 -#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 -#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 -#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 -#define GL_MAP2_VERTEX_3 0x0DB7 -#define GL_MAP2_VERTEX_4 0x0DB8 -#define GL_MAP1_GRID_DOMAIN 0x0DD0 -#define GL_MAP1_GRID_SEGMENTS 0x0DD1 -#define GL_MAP2_GRID_DOMAIN 0x0DD2 -#define GL_MAP2_GRID_SEGMENTS 0x0DD3 -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 -#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 -#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 -#define GL_SELECTION_BUFFER_POINTER 0x0DF3 -#define GL_SELECTION_BUFFER_SIZE 0x0DF4 -/* GL_TEXTURE_BINDING_1D */ -/* GL_TEXTURE_BINDING_2D */ -/* GL_VERTEX_ARRAY */ -/* GL_NORMAL_ARRAY */ -/* GL_COLOR_ARRAY */ -/* GL_INDEX_ARRAY */ -/* GL_TEXTURE_COORD_ARRAY */ -/* GL_EDGE_FLAG_ARRAY */ -/* GL_VERTEX_ARRAY_SIZE */ -/* GL_VERTEX_ARRAY_TYPE */ -/* GL_VERTEX_ARRAY_STRIDE */ -/* GL_NORMAL_ARRAY_TYPE */ -/* GL_NORMAL_ARRAY_STRIDE */ -/* GL_COLOR_ARRAY_SIZE */ -/* GL_COLOR_ARRAY_TYPE */ -/* GL_COLOR_ARRAY_STRIDE */ -/* GL_INDEX_ARRAY_TYPE */ -/* GL_INDEX_ARRAY_STRIDE */ -/* GL_TEXTURE_COORD_ARRAY_SIZE */ -/* GL_TEXTURE_COORD_ARRAY_TYPE */ -/* GL_TEXTURE_COORD_ARRAY_STRIDE */ -/* GL_EDGE_FLAG_ARRAY_STRIDE */ -/* GL_POLYGON_OFFSET_FACTOR */ -/* GL_POLYGON_OFFSET_UNITS */ - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_TEXTURE_BORDER 0x1005 -/* GL_TEXTURE_RED_SIZE */ -/* GL_TEXTURE_GREEN_SIZE */ -/* GL_TEXTURE_BLUE_SIZE */ -/* GL_TEXTURE_ALPHA_SIZE */ -/* GL_TEXTURE_LUMINANCE_SIZE */ -/* GL_TEXTURE_INTENSITY_SIZE */ -/* GL_TEXTURE_PRIORITY */ -/* GL_TEXTURE_RESIDENT */ - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -/* GL_PERSPECTIVE_CORRECTION_HINT */ -/* GL_POINT_SMOOTH_HINT */ -/* GL_LINE_SMOOTH_HINT */ -/* GL_POLYGON_SMOOTH_HINT */ -/* GL_FOG_HINT */ -/* GL_PHONG_HINT */ - -/* IndexPointerType */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* LightModelParameter */ -/* GL_LIGHT_MODEL_AMBIENT */ -/* GL_LIGHT_MODEL_LOCAL_VIEWER */ -/* GL_LIGHT_MODEL_TWO_SIDE */ - -/* LightName */ -#define GL_LIGHT0 0x4000 -#define GL_LIGHT1 0x4001 -#define GL_LIGHT2 0x4002 -#define GL_LIGHT3 0x4003 -#define GL_LIGHT4 0x4004 -#define GL_LIGHT5 0x4005 -#define GL_LIGHT6 0x4006 -#define GL_LIGHT7 0x4007 - -/* LightParameter */ -#define GL_AMBIENT 0x1200 -#define GL_DIFFUSE 0x1201 -#define GL_SPECULAR 0x1202 -#define GL_POSITION 0x1203 -#define GL_SPOT_DIRECTION 0x1204 -#define GL_SPOT_EXPONENT 0x1205 -#define GL_SPOT_CUTOFF 0x1206 -#define GL_CONSTANT_ATTENUATION 0x1207 -#define GL_LINEAR_ATTENUATION 0x1208 -#define GL_QUADRATIC_ATTENUATION 0x1209 - -/* InterleavedArrays */ -/* GL_V2F */ -/* GL_V3F */ -/* GL_C4UB_V2F */ -/* GL_C4UB_V3F */ -/* GL_C3F_V3F */ -/* GL_N3F_V3F */ -/* GL_C4F_N3F_V3F */ -/* GL_T2F_V3F */ -/* GL_T4F_V4F */ -/* GL_T2F_C4UB_V3F */ -/* GL_T2F_C3F_V3F */ -/* GL_T2F_N3F_V3F */ -/* GL_T2F_C4F_N3F_V3F */ -/* GL_T4F_C4F_N3F_V4F */ - -/* ListMode */ -#define GL_COMPILE 0x1300 -#define GL_COMPILE_AND_EXECUTE 0x1301 - -/* ListNameType */ -/* GL_BYTE */ -/* GL_UNSIGNED_BYTE */ -/* GL_SHORT */ -/* GL_UNSIGNED_SHORT */ -/* GL_INT */ -/* GL_UNSIGNED_INT */ -/* GL_FLOAT */ -/* GL_2_BYTES */ -/* GL_3_BYTES */ -/* GL_4_BYTES */ - -/* LogicOp */ -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F - -/* MapTarget */ -/* GL_MAP1_COLOR_4 */ -/* GL_MAP1_INDEX */ -/* GL_MAP1_NORMAL */ -/* GL_MAP1_TEXTURE_COORD_1 */ -/* GL_MAP1_TEXTURE_COORD_2 */ -/* GL_MAP1_TEXTURE_COORD_3 */ -/* GL_MAP1_TEXTURE_COORD_4 */ -/* GL_MAP1_VERTEX_3 */ -/* GL_MAP1_VERTEX_4 */ -/* GL_MAP2_COLOR_4 */ -/* GL_MAP2_INDEX */ -/* GL_MAP2_NORMAL */ -/* GL_MAP2_TEXTURE_COORD_1 */ -/* GL_MAP2_TEXTURE_COORD_2 */ -/* GL_MAP2_TEXTURE_COORD_3 */ -/* GL_MAP2_TEXTURE_COORD_4 */ -/* GL_MAP2_VERTEX_3 */ -/* GL_MAP2_VERTEX_4 */ - -/* MaterialFace */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ - -/* MaterialParameter */ -#define GL_EMISSION 0x1600 -#define GL_SHININESS 0x1601 -#define GL_AMBIENT_AND_DIFFUSE 0x1602 -#define GL_COLOR_INDEXES 0x1603 -/* GL_AMBIENT */ -/* GL_DIFFUSE */ -/* GL_SPECULAR */ - -/* MatrixMode */ -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_TEXTURE 0x1702 - -/* MeshMode1 */ -/* GL_POINT */ -/* GL_LINE */ - -/* MeshMode2 */ -/* GL_POINT */ -/* GL_LINE */ -/* GL_FILL */ - -/* NormalPointerType */ -/* GL_BYTE */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* PixelCopyType */ -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 - -/* PixelFormat */ -#define GL_COLOR_INDEX 0x1900 -#define GL_STENCIL_INDEX 0x1901 -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelMap */ -/* GL_PIXEL_MAP_I_TO_I */ -/* GL_PIXEL_MAP_S_TO_S */ -/* GL_PIXEL_MAP_I_TO_R */ -/* GL_PIXEL_MAP_I_TO_G */ -/* GL_PIXEL_MAP_I_TO_B */ -/* GL_PIXEL_MAP_I_TO_A */ -/* GL_PIXEL_MAP_R_TO_R */ -/* GL_PIXEL_MAP_G_TO_G */ -/* GL_PIXEL_MAP_B_TO_B */ -/* GL_PIXEL_MAP_A_TO_A */ - -/* PixelStore */ -/* GL_UNPACK_SWAP_BYTES */ -/* GL_UNPACK_LSB_FIRST */ -/* GL_UNPACK_ROW_LENGTH */ -/* GL_UNPACK_SKIP_ROWS */ -/* GL_UNPACK_SKIP_PIXELS */ -/* GL_UNPACK_ALIGNMENT */ -/* GL_PACK_SWAP_BYTES */ -/* GL_PACK_LSB_FIRST */ -/* GL_PACK_ROW_LENGTH */ -/* GL_PACK_SKIP_ROWS */ -/* GL_PACK_SKIP_PIXELS */ -/* GL_PACK_ALIGNMENT */ - -/* PixelTransfer */ -/* GL_MAP_COLOR */ -/* GL_MAP_STENCIL */ -/* GL_INDEX_SHIFT */ -/* GL_INDEX_OFFSET */ -/* GL_RED_SCALE */ -/* GL_RED_BIAS */ -/* GL_GREEN_SCALE */ -/* GL_GREEN_BIAS */ -/* GL_BLUE_SCALE */ -/* GL_BLUE_BIAS */ -/* GL_ALPHA_SCALE */ -/* GL_ALPHA_BIAS */ -/* GL_DEPTH_SCALE */ -/* GL_DEPTH_BIAS */ - -/* PixelType */ -#define GL_BITMAP 0x1A00 -/* GL_BYTE */ -/* GL_UNSIGNED_BYTE */ -/* GL_SHORT */ -/* GL_UNSIGNED_SHORT */ -/* GL_INT */ -/* GL_UNSIGNED_INT */ -/* GL_FLOAT */ - -/* PolygonMode */ -#define GL_POINT 0x1B00 -#define GL_LINE 0x1B01 -#define GL_FILL 0x1B02 - -/* ReadBufferMode */ -/* GL_FRONT_LEFT */ -/* GL_FRONT_RIGHT */ -/* GL_BACK_LEFT */ -/* GL_BACK_RIGHT */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_LEFT */ -/* GL_RIGHT */ -/* GL_AUX0 */ -/* GL_AUX1 */ -/* GL_AUX2 */ -/* GL_AUX3 */ - -/* RenderingMode */ -#define GL_RENDER 0x1C00 -#define GL_FEEDBACK 0x1C01 -#define GL_SELECT 0x1C02 - -/* ShadingModel */ -#define GL_FLAT 0x1D00 -#define GL_SMOOTH 0x1D01 - - -/* StencilFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -/* GL_INVERT */ - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TextureCoordName */ -#define GL_S 0x2000 -#define GL_T 0x2001 -#define GL_R 0x2002 -#define GL_Q 0x2003 - -/* TexCoordPointerType */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* TextureEnvMode */ -#define GL_MODULATE 0x2100 -#define GL_DECAL 0x2101 -/* GL_BLEND */ -/* GL_REPLACE */ - -/* TextureEnvParameter */ -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_ENV_COLOR 0x2201 - -/* TextureEnvTarget */ -#define GL_TEXTURE_ENV 0x2300 - -/* TextureGenMode */ -#define GL_EYE_LINEAR 0x2400 -#define GL_OBJECT_LINEAR 0x2401 -#define GL_SPHERE_MAP 0x2402 - -/* TextureGenParameter */ -#define GL_TEXTURE_GEN_MODE 0x2500 -#define GL_OBJECT_PLANE 0x2501 -#define GL_EYE_PLANE 0x2502 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -/* GL_TEXTURE_BORDER_COLOR */ -/* GL_TEXTURE_PRIORITY */ - -/* TextureTarget */ -/* GL_TEXTURE_1D */ -/* GL_TEXTURE_2D */ -/* GL_PROXY_TEXTURE_1D */ -/* GL_PROXY_TEXTURE_2D */ - -/* TextureWrapMode */ -#define GL_CLAMP 0x2900 -#define GL_REPEAT 0x2901 - -/* VertexPointerType */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* ClientAttribMask */ -#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 -#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 -#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff - -/* polygon_offset */ -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_POLYGON_OFFSET_FILL 0x8037 - -/* texture */ -#define GL_ALPHA4 0x803B -#define GL_ALPHA8 0x803C -#define GL_ALPHA12 0x803D -#define GL_ALPHA16 0x803E -#define GL_LUMINANCE4 0x803F -#define GL_LUMINANCE8 0x8040 -#define GL_LUMINANCE12 0x8041 -#define GL_LUMINANCE16 0x8042 -#define GL_LUMINANCE4_ALPHA4 0x8043 -#define GL_LUMINANCE6_ALPHA2 0x8044 -#define GL_LUMINANCE8_ALPHA8 0x8045 -#define GL_LUMINANCE12_ALPHA4 0x8046 -#define GL_LUMINANCE12_ALPHA12 0x8047 -#define GL_LUMINANCE16_ALPHA16 0x8048 -#define GL_INTENSITY 0x8049 -#define GL_INTENSITY4 0x804A -#define GL_INTENSITY8 0x804B -#define GL_INTENSITY12 0x804C -#define GL_INTENSITY16 0x804D -#define GL_R3_G3_B2 0x2A10 -#define GL_RGB4 0x804F -#define GL_RGB5 0x8050 -#define GL_RGB8 0x8051 -#define GL_RGB10 0x8052 -#define GL_RGB12 0x8053 -#define GL_RGB16 0x8054 -#define GL_RGBA2 0x8055 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_RGBA12 0x805A -#define GL_RGBA16 0x805B -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE 0x8061 -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 - -/* texture_object */ -#define GL_TEXTURE_PRIORITY 0x8066 -#define GL_TEXTURE_RESIDENT 0x8067 -#define GL_TEXTURE_BINDING_1D 0x8068 -#define GL_TEXTURE_BINDING_2D 0x8069 - -/* vertex_array */ -#define GL_VERTEX_ARRAY 0x8074 -#define GL_NORMAL_ARRAY 0x8075 -#define GL_COLOR_ARRAY 0x8076 -#define GL_INDEX_ARRAY 0x8077 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_EDGE_FLAG_ARRAY 0x8079 -#define GL_VERTEX_ARRAY_SIZE 0x807A -#define GL_VERTEX_ARRAY_TYPE 0x807B -#define GL_VERTEX_ARRAY_STRIDE 0x807C -#define GL_NORMAL_ARRAY_TYPE 0x807E -#define GL_NORMAL_ARRAY_STRIDE 0x807F -#define GL_COLOR_ARRAY_SIZE 0x8081 -#define GL_COLOR_ARRAY_TYPE 0x8082 -#define GL_COLOR_ARRAY_STRIDE 0x8083 -#define GL_INDEX_ARRAY_TYPE 0x8085 -#define GL_INDEX_ARRAY_STRIDE 0x8086 -#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C -#define GL_VERTEX_ARRAY_POINTER 0x808E -#define GL_NORMAL_ARRAY_POINTER 0x808F -#define GL_COLOR_ARRAY_POINTER 0x8090 -#define GL_INDEX_ARRAY_POINTER 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 -#define GL_V2F 0x2A20 -#define GL_V3F 0x2A21 -#define GL_C4UB_V2F 0x2A22 -#define GL_C4UB_V3F 0x2A23 -#define GL_C3F_V3F 0x2A24 -#define GL_N3F_V3F 0x2A25 -#define GL_C4F_N3F_V3F 0x2A26 -#define GL_T2F_V3F 0x2A27 -#define GL_T4F_V4F 0x2A28 -#define GL_T2F_C4UB_V3F 0x2A29 -#define GL_T2F_C3F_V3F 0x2A2A -#define GL_T2F_N3F_V3F 0x2A2B -#define GL_T2F_C4F_N3F_V3F 0x2A2C -#define GL_T4F_C4F_N3F_V4F 0x2A2D - -/* Extensions */ -#define GL_EXT_vertex_array 1 -#define GL_EXT_bgra 1 -#define GL_EXT_paletted_texture 1 -#define GL_WIN_swap_hint 1 -#define GL_WIN_draw_range_elements 1 -// #define GL_WIN_phong_shading 1 -// #define GL_WIN_specular_fog 1 - -/* EXT_vertex_array */ -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#define GL_DOUBLE_EXT GL_DOUBLE - -/* EXT_bgra */ -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 - -/* EXT_paletted_texture */ - -/* These must match the GL_COLOR_TABLE_*_SGI enumerants */ -#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 -#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF - -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 - -/* WIN_draw_range_elements */ -#define GL_MAX_ELEMENTS_VERTICES_WIN 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_WIN 0x80E9 - -/* WIN_phong_shading */ -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB - -/* WIN_specular_fog */ -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC - -/* For compatibility with OpenGL v1.0 */ -#define GL_LOGIC_OP GL_INDEX_LOGIC_OP -#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT -#include -#if QT_VERSION >= 0x060000 -#include -#endif + #define GL_ACCUM 0x0100 + #define GL_LOAD 0x0101 + #define GL_RETURN 0x0102 + #define GL_MULT 0x0103 + #define GL_ADD 0x0104 + + /* AlphaFunction */ + #define GL_NEVER 0x0200 + #define GL_LESS 0x0201 + #define GL_EQUAL 0x0202 + #define GL_LEQUAL 0x0203 + #define GL_GREATER 0x0204 + #define GL_NOTEQUAL 0x0205 + #define GL_GEQUAL 0x0206 + #define GL_ALWAYS 0x0207 + + /* AttribMask */ + #define GL_CURRENT_BIT 0x00000001 + #define GL_POINT_BIT 0x00000002 + #define GL_LINE_BIT 0x00000004 + #define GL_POLYGON_BIT 0x00000008 + #define GL_POLYGON_STIPPLE_BIT 0x00000010 + #define GL_PIXEL_MODE_BIT 0x00000020 + #define GL_LIGHTING_BIT 0x00000040 + #define GL_FOG_BIT 0x00000080 + #define GL_DEPTH_BUFFER_BIT 0x00000100 + #define GL_ACCUM_BUFFER_BIT 0x00000200 + #define GL_STENCIL_BUFFER_BIT 0x00000400 + #define GL_VIEWPORT_BIT 0x00000800 + #define GL_TRANSFORM_BIT 0x00001000 + #define GL_ENABLE_BIT 0x00002000 + #define GL_COLOR_BUFFER_BIT 0x00004000 + #define GL_HINT_BIT 0x00008000 + #define GL_EVAL_BIT 0x00010000 + #define GL_LIST_BIT 0x00020000 + #define GL_TEXTURE_BIT 0x00040000 + #define GL_SCISSOR_BIT 0x00080000 + #define GL_ALL_ATTRIB_BITS 0x000fffff + + /* BeginMode */ + #define GL_POINTS 0x0000 + #define GL_LINES 0x0001 + #define GL_LINE_LOOP 0x0002 + #define GL_LINE_STRIP 0x0003 + #define GL_TRIANGLES 0x0004 + #define GL_TRIANGLE_STRIP 0x0005 + #define GL_TRIANGLE_FAN 0x0006 + #define GL_QUADS 0x0007 + #define GL_QUAD_STRIP 0x0008 + #define GL_POLYGON 0x0009 + + /* BlendingFactorDest */ + #define GL_ZERO 0 + #define GL_ONE 1 + #define GL_SRC_COLOR 0x0300 + #define GL_ONE_MINUS_SRC_COLOR 0x0301 + #define GL_SRC_ALPHA 0x0302 + #define GL_ONE_MINUS_SRC_ALPHA 0x0303 + #define GL_DST_ALPHA 0x0304 + #define GL_ONE_MINUS_DST_ALPHA 0x0305 + + /* BlendingFactorSrc */ + /* GL_ZERO */ + /* GL_ONE */ + #define GL_DST_COLOR 0x0306 + #define GL_ONE_MINUS_DST_COLOR 0x0307 + #define GL_SRC_ALPHA_SATURATE 0x0308 + /* GL_SRC_ALPHA */ + /* GL_ONE_MINUS_SRC_ALPHA */ + /* GL_DST_ALPHA */ + /* GL_ONE_MINUS_DST_ALPHA */ + + /* Boolean */ + #define GL_TRUE 1 + #define GL_FALSE 0 + + /* ClearBufferMask */ + /* GL_COLOR_BUFFER_BIT */ + /* GL_ACCUM_BUFFER_BIT */ + /* GL_STENCIL_BUFFER_BIT */ + /* GL_DEPTH_BUFFER_BIT */ + + /* ClientArrayType */ + /* GL_VERTEX_ARRAY */ + /* GL_NORMAL_ARRAY */ + /* GL_COLOR_ARRAY */ + /* GL_INDEX_ARRAY */ + /* GL_TEXTURE_COORD_ARRAY */ + /* GL_EDGE_FLAG_ARRAY */ + + /* ClipPlaneName */ + #define GL_CLIP_PLANE0 0x3000 + #define GL_CLIP_PLANE1 0x3001 + #define GL_CLIP_PLANE2 0x3002 + #define GL_CLIP_PLANE3 0x3003 + #define GL_CLIP_PLANE4 0x3004 + #define GL_CLIP_PLANE5 0x3005 + + /* ColorMaterialFace */ + /* GL_FRONT */ + /* GL_BACK */ + /* GL_FRONT_AND_BACK */ + + /* ColorMaterialParameter */ + /* GL_AMBIENT */ + /* GL_DIFFUSE */ + /* GL_SPECULAR */ + /* GL_EMISSION */ + /* GL_AMBIENT_AND_DIFFUSE */ + + /* ColorPointerType */ + /* GL_BYTE */ + /* GL_UNSIGNED_BYTE */ + /* GL_SHORT */ + /* GL_UNSIGNED_SHORT */ + /* GL_INT */ + /* GL_UNSIGNED_INT */ + /* GL_FLOAT */ + /* GL_DOUBLE */ + + /* CullFaceMode */ + /* GL_FRONT */ + /* GL_BACK */ + /* GL_FRONT_AND_BACK */ + + /* DataType */ + #define GL_BYTE 0x1400 + #define GL_UNSIGNED_BYTE 0x1401 + #define GL_SHORT 0x1402 + #define GL_UNSIGNED_SHORT 0x1403 + #define GL_INT 0x1404 + #define GL_UNSIGNED_INT 0x1405 + #define GL_FLOAT 0x1406 + #define GL_2_BYTES 0x1407 + #define GL_3_BYTES 0x1408 + #define GL_4_BYTES 0x1409 + #define GL_DOUBLE 0x140A + + /* DepthFunction */ + /* GL_NEVER */ + /* GL_LESS */ + /* GL_EQUAL */ + /* GL_LEQUAL */ + /* GL_GREATER */ + /* GL_NOTEQUAL */ + /* GL_GEQUAL */ + /* GL_ALWAYS */ + + /* DrawBufferMode */ + #define GL_NONE 0 + #define GL_FRONT_LEFT 0x0400 + #define GL_FRONT_RIGHT 0x0401 + #define GL_BACK_LEFT 0x0402 + #define GL_BACK_RIGHT 0x0403 + #define GL_FRONT 0x0404 + #define GL_BACK 0x0405 + #define GL_LEFT 0x0406 + #define GL_RIGHT 0x0407 + #define GL_FRONT_AND_BACK 0x0408 + #define GL_AUX0 0x0409 + #define GL_AUX1 0x040A + #define GL_AUX2 0x040B + #define GL_AUX3 0x040C + + /* Enable */ + /* GL_FOG */ + /* GL_LIGHTING */ + /* GL_TEXTURE_1D */ + /* GL_TEXTURE_2D */ + /* GL_LINE_STIPPLE */ + /* GL_POLYGON_STIPPLE */ + /* GL_CULL_FACE */ + /* GL_ALPHA_TEST */ + /* GL_BLEND */ + /* GL_INDEX_LOGIC_OP */ + /* GL_COLOR_LOGIC_OP */ + /* GL_DITHER */ + /* GL_STENCIL_TEST */ + /* GL_DEPTH_TEST */ + /* GL_CLIP_PLANE0 */ + /* GL_CLIP_PLANE1 */ + /* GL_CLIP_PLANE2 */ + /* GL_CLIP_PLANE3 */ + /* GL_CLIP_PLANE4 */ + /* GL_CLIP_PLANE5 */ + /* GL_LIGHT0 */ + /* GL_LIGHT1 */ + /* GL_LIGHT2 */ + /* GL_LIGHT3 */ + /* GL_LIGHT4 */ + /* GL_LIGHT5 */ + /* GL_LIGHT6 */ + /* GL_LIGHT7 */ + /* GL_TEXTURE_GEN_S */ + /* GL_TEXTURE_GEN_T */ + /* GL_TEXTURE_GEN_R */ + /* GL_TEXTURE_GEN_Q */ + /* GL_MAP1_VERTEX_3 */ + /* GL_MAP1_VERTEX_4 */ + /* GL_MAP1_COLOR_4 */ + /* GL_MAP1_INDEX */ + /* GL_MAP1_NORMAL */ + /* GL_MAP1_TEXTURE_COORD_1 */ + /* GL_MAP1_TEXTURE_COORD_2 */ + /* GL_MAP1_TEXTURE_COORD_3 */ + /* GL_MAP1_TEXTURE_COORD_4 */ + /* GL_MAP2_VERTEX_3 */ + /* GL_MAP2_VERTEX_4 */ + /* GL_MAP2_COLOR_4 */ + /* GL_MAP2_INDEX */ + /* GL_MAP2_NORMAL */ + /* GL_MAP2_TEXTURE_COORD_1 */ + /* GL_MAP2_TEXTURE_COORD_2 */ + /* GL_MAP2_TEXTURE_COORD_3 */ + /* GL_MAP2_TEXTURE_COORD_4 */ + /* GL_POINT_SMOOTH */ + /* GL_LINE_SMOOTH */ + /* GL_POLYGON_SMOOTH */ + /* GL_SCISSOR_TEST */ + /* GL_COLOR_MATERIAL */ + /* GL_NORMALIZE */ + /* GL_AUTO_NORMAL */ + /* GL_VERTEX_ARRAY */ + /* GL_NORMAL_ARRAY */ + /* GL_COLOR_ARRAY */ + /* GL_INDEX_ARRAY */ + /* GL_TEXTURE_COORD_ARRAY */ + /* GL_EDGE_FLAG_ARRAY */ + /* GL_POLYGON_OFFSET_POINT */ + /* GL_POLYGON_OFFSET_LINE */ + /* GL_POLYGON_OFFSET_FILL */ + + /* ErrorCode */ + #define GL_NO_ERROR 0 + #define GL_INVALID_ENUM 0x0500 + #define GL_INVALID_VALUE 0x0501 + #define GL_INVALID_OPERATION 0x0502 + #define GL_STACK_OVERFLOW 0x0503 + #define GL_STACK_UNDERFLOW 0x0504 + #define GL_OUT_OF_MEMORY 0x0505 + + /* FeedBackMode */ + #define GL_2D 0x0600 + #define GL_3D 0x0601 + #define GL_3D_COLOR 0x0602 + #define GL_3D_COLOR_TEXTURE 0x0603 + #define GL_4D_COLOR_TEXTURE 0x0604 + + /* FeedBackToken */ + #define GL_PASS_THROUGH_TOKEN 0x0700 + #define GL_POINT_TOKEN 0x0701 + #define GL_LINE_TOKEN 0x0702 + #define GL_POLYGON_TOKEN 0x0703 + #define GL_BITMAP_TOKEN 0x0704 + #define GL_DRAW_PIXEL_TOKEN 0x0705 + #define GL_COPY_PIXEL_TOKEN 0x0706 + #define GL_LINE_RESET_TOKEN 0x0707 + + /* FogMode */ + /* GL_LINEAR */ + #define GL_EXP 0x0800 + #define GL_EXP2 0x0801 + + /* FogParameter */ + /* GL_FOG_COLOR */ + /* GL_FOG_DENSITY */ + /* GL_FOG_END */ + /* GL_FOG_INDEX */ + /* GL_FOG_MODE */ + /* GL_FOG_START */ + + /* FrontFaceDirection */ + #define GL_CW 0x0900 + #define GL_CCW 0x0901 + + /* GetMapTarget */ + #define GL_COEFF 0x0A00 + #define GL_ORDER 0x0A01 + #define GL_DOMAIN 0x0A02 + + /* GetPixelMap */ + /* GL_PIXEL_MAP_I_TO_I */ + /* GL_PIXEL_MAP_S_TO_S */ + /* GL_PIXEL_MAP_I_TO_R */ + /* GL_PIXEL_MAP_I_TO_G */ + /* GL_PIXEL_MAP_I_TO_B */ + /* GL_PIXEL_MAP_I_TO_A */ + /* GL_PIXEL_MAP_R_TO_R */ + /* GL_PIXEL_MAP_G_TO_G */ + /* GL_PIXEL_MAP_B_TO_B */ + /* GL_PIXEL_MAP_A_TO_A */ + + /* GetPointerTarget */ + /* GL_VERTEX_ARRAY_POINTER */ + /* GL_NORMAL_ARRAY_POINTER */ + /* GL_COLOR_ARRAY_POINTER */ + /* GL_INDEX_ARRAY_POINTER */ + /* GL_TEXTURE_COORD_ARRAY_POINTER */ + /* GL_EDGE_FLAG_ARRAY_POINTER */ + + /* GetTarget */ + #define GL_CURRENT_COLOR 0x0B00 + #define GL_CURRENT_INDEX 0x0B01 + #define GL_CURRENT_NORMAL 0x0B02 + #define GL_CURRENT_TEXTURE_COORDS 0x0B03 + #define GL_CURRENT_RASTER_COLOR 0x0B04 + #define GL_CURRENT_RASTER_INDEX 0x0B05 + #define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 + #define GL_CURRENT_RASTER_POSITION 0x0B07 + #define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 + #define GL_CURRENT_RASTER_DISTANCE 0x0B09 + #define GL_POINT_SMOOTH 0x0B10 + #define GL_POINT_SIZE 0x0B11 + #define GL_POINT_SIZE_RANGE 0x0B12 + #define GL_POINT_SIZE_GRANULARITY 0x0B13 + #define GL_LINE_SMOOTH 0x0B20 + #define GL_LINE_WIDTH 0x0B21 + #define GL_LINE_WIDTH_RANGE 0x0B22 + #define GL_LINE_WIDTH_GRANULARITY 0x0B23 + #define GL_LINE_STIPPLE 0x0B24 + #define GL_LINE_STIPPLE_PATTERN 0x0B25 + #define GL_LINE_STIPPLE_REPEAT 0x0B26 + #define GL_LIST_MODE 0x0B30 + #define GL_MAX_LIST_NESTING 0x0B31 + #define GL_LIST_BASE 0x0B32 + #define GL_LIST_INDEX 0x0B33 + #define GL_POLYGON_MODE 0x0B40 + #define GL_POLYGON_SMOOTH 0x0B41 + #define GL_POLYGON_STIPPLE 0x0B42 + #define GL_EDGE_FLAG 0x0B43 + #define GL_CULL_FACE 0x0B44 + #define GL_CULL_FACE_MODE 0x0B45 + #define GL_FRONT_FACE 0x0B46 + #define GL_LIGHTING 0x0B50 + #define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 + #define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 + #define GL_LIGHT_MODEL_AMBIENT 0x0B53 + #define GL_SHADE_MODEL 0x0B54 + #define GL_COLOR_MATERIAL_FACE 0x0B55 + #define GL_COLOR_MATERIAL_PARAMETER 0x0B56 + #define GL_COLOR_MATERIAL 0x0B57 + #define GL_FOG 0x0B60 + #define GL_FOG_INDEX 0x0B61 + #define GL_FOG_DENSITY 0x0B62 + #define GL_FOG_START 0x0B63 + #define GL_FOG_END 0x0B64 + #define GL_FOG_MODE 0x0B65 + #define GL_FOG_COLOR 0x0B66 + #define GL_DEPTH_RANGE 0x0B70 + #define GL_DEPTH_TEST 0x0B71 + #define GL_DEPTH_WRITEMASK 0x0B72 + #define GL_DEPTH_CLEAR_VALUE 0x0B73 + #define GL_DEPTH_FUNC 0x0B74 + #define GL_ACCUM_CLEAR_VALUE 0x0B80 + #define GL_STENCIL_TEST 0x0B90 + #define GL_STENCIL_CLEAR_VALUE 0x0B91 + #define GL_STENCIL_FUNC 0x0B92 + #define GL_STENCIL_VALUE_MASK 0x0B93 + #define GL_STENCIL_FAIL 0x0B94 + #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 + #define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 + #define GL_STENCIL_REF 0x0B97 + #define GL_STENCIL_WRITEMASK 0x0B98 + #define GL_MATRIX_MODE 0x0BA0 + #define GL_NORMALIZE 0x0BA1 + #define GL_VIEWPORT 0x0BA2 + #define GL_MODELVIEW_STACK_DEPTH 0x0BA3 + #define GL_PROJECTION_STACK_DEPTH 0x0BA4 + #define GL_TEXTURE_STACK_DEPTH 0x0BA5 + #define GL_MODELVIEW_MATRIX 0x0BA6 + #define GL_PROJECTION_MATRIX 0x0BA7 + #define GL_TEXTURE_MATRIX 0x0BA8 + #define GL_ATTRIB_STACK_DEPTH 0x0BB0 + #define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 + #define GL_ALPHA_TEST 0x0BC0 + #define GL_ALPHA_TEST_FUNC 0x0BC1 + #define GL_ALPHA_TEST_REF 0x0BC2 + #define GL_DITHER 0x0BD0 + #define GL_BLEND_DST 0x0BE0 + #define GL_BLEND_SRC 0x0BE1 + #define GL_BLEND 0x0BE2 + #define GL_LOGIC_OP_MODE 0x0BF0 + #define GL_INDEX_LOGIC_OP 0x0BF1 + #define GL_COLOR_LOGIC_OP 0x0BF2 + #define GL_AUX_BUFFERS 0x0C00 + #define GL_DRAW_BUFFER 0x0C01 + #define GL_READ_BUFFER 0x0C02 + #define GL_SCISSOR_BOX 0x0C10 + #define GL_SCISSOR_TEST 0x0C11 + #define GL_INDEX_CLEAR_VALUE 0x0C20 + #define GL_INDEX_WRITEMASK 0x0C21 + #define GL_COLOR_CLEAR_VALUE 0x0C22 + #define GL_COLOR_WRITEMASK 0x0C23 + #define GL_INDEX_MODE 0x0C30 + #define GL_RGBA_MODE 0x0C31 + #define GL_DOUBLEBUFFER 0x0C32 + #define GL_STEREO 0x0C33 + #define GL_RENDER_MODE 0x0C40 + #define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 + #define GL_POINT_SMOOTH_HINT 0x0C51 + #define GL_LINE_SMOOTH_HINT 0x0C52 + #define GL_POLYGON_SMOOTH_HINT 0x0C53 + #define GL_FOG_HINT 0x0C54 + #define GL_TEXTURE_GEN_S 0x0C60 + #define GL_TEXTURE_GEN_T 0x0C61 + #define GL_TEXTURE_GEN_R 0x0C62 + #define GL_TEXTURE_GEN_Q 0x0C63 + #define GL_PIXEL_MAP_I_TO_I 0x0C70 + #define GL_PIXEL_MAP_S_TO_S 0x0C71 + #define GL_PIXEL_MAP_I_TO_R 0x0C72 + #define GL_PIXEL_MAP_I_TO_G 0x0C73 + #define GL_PIXEL_MAP_I_TO_B 0x0C74 + #define GL_PIXEL_MAP_I_TO_A 0x0C75 + #define GL_PIXEL_MAP_R_TO_R 0x0C76 + #define GL_PIXEL_MAP_G_TO_G 0x0C77 + #define GL_PIXEL_MAP_B_TO_B 0x0C78 + #define GL_PIXEL_MAP_A_TO_A 0x0C79 + #define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 + #define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 + #define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 + #define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 + #define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 + #define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 + #define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 + #define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 + #define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 + #define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 + #define GL_UNPACK_SWAP_BYTES 0x0CF0 + #define GL_UNPACK_LSB_FIRST 0x0CF1 + #define GL_UNPACK_ROW_LENGTH 0x0CF2 + #define GL_UNPACK_SKIP_ROWS 0x0CF3 + #define GL_UNPACK_SKIP_PIXELS 0x0CF4 + #define GL_UNPACK_ALIGNMENT 0x0CF5 + #define GL_PACK_SWAP_BYTES 0x0D00 + #define GL_PACK_LSB_FIRST 0x0D01 + #define GL_PACK_ROW_LENGTH 0x0D02 + #define GL_PACK_SKIP_ROWS 0x0D03 + #define GL_PACK_SKIP_PIXELS 0x0D04 + #define GL_PACK_ALIGNMENT 0x0D05 + #define GL_MAP_COLOR 0x0D10 + #define GL_MAP_STENCIL 0x0D11 + #define GL_INDEX_SHIFT 0x0D12 + #define GL_INDEX_OFFSET 0x0D13 + #define GL_RED_SCALE 0x0D14 + #define GL_RED_BIAS 0x0D15 + #define GL_ZOOM_X 0x0D16 + #define GL_ZOOM_Y 0x0D17 + #define GL_GREEN_SCALE 0x0D18 + #define GL_GREEN_BIAS 0x0D19 + #define GL_BLUE_SCALE 0x0D1A + #define GL_BLUE_BIAS 0x0D1B + #define GL_ALPHA_SCALE 0x0D1C + #define GL_ALPHA_BIAS 0x0D1D + #define GL_DEPTH_SCALE 0x0D1E + #define GL_DEPTH_BIAS 0x0D1F + #define GL_MAX_EVAL_ORDER 0x0D30 + #define GL_MAX_LIGHTS 0x0D31 + #define GL_MAX_CLIP_PLANES 0x0D32 + #define GL_MAX_TEXTURE_SIZE 0x0D33 + #define GL_MAX_PIXEL_MAP_TABLE 0x0D34 + #define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 + #define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 + #define GL_MAX_NAME_STACK_DEPTH 0x0D37 + #define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 + #define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 + #define GL_MAX_VIEWPORT_DIMS 0x0D3A + #define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B + #define GL_SUBPIXEL_BITS 0x0D50 + #define GL_INDEX_BITS 0x0D51 + #define GL_RED_BITS 0x0D52 + #define GL_GREEN_BITS 0x0D53 + #define GL_BLUE_BITS 0x0D54 + #define GL_ALPHA_BITS 0x0D55 + #define GL_DEPTH_BITS 0x0D56 + #define GL_STENCIL_BITS 0x0D57 + #define GL_ACCUM_RED_BITS 0x0D58 + #define GL_ACCUM_GREEN_BITS 0x0D59 + #define GL_ACCUM_BLUE_BITS 0x0D5A + #define GL_ACCUM_ALPHA_BITS 0x0D5B + #define GL_NAME_STACK_DEPTH 0x0D70 + #define GL_AUTO_NORMAL 0x0D80 + #define GL_MAP1_COLOR_4 0x0D90 + #define GL_MAP1_INDEX 0x0D91 + #define GL_MAP1_NORMAL 0x0D92 + #define GL_MAP1_TEXTURE_COORD_1 0x0D93 + #define GL_MAP1_TEXTURE_COORD_2 0x0D94 + #define GL_MAP1_TEXTURE_COORD_3 0x0D95 + #define GL_MAP1_TEXTURE_COORD_4 0x0D96 + #define GL_MAP1_VERTEX_3 0x0D97 + #define GL_MAP1_VERTEX_4 0x0D98 + #define GL_MAP2_COLOR_4 0x0DB0 + #define GL_MAP2_INDEX 0x0DB1 + #define GL_MAP2_NORMAL 0x0DB2 + #define GL_MAP2_TEXTURE_COORD_1 0x0DB3 + #define GL_MAP2_TEXTURE_COORD_2 0x0DB4 + #define GL_MAP2_TEXTURE_COORD_3 0x0DB5 + #define GL_MAP2_TEXTURE_COORD_4 0x0DB6 + #define GL_MAP2_VERTEX_3 0x0DB7 + #define GL_MAP2_VERTEX_4 0x0DB8 + #define GL_MAP1_GRID_DOMAIN 0x0DD0 + #define GL_MAP1_GRID_SEGMENTS 0x0DD1 + #define GL_MAP2_GRID_DOMAIN 0x0DD2 + #define GL_MAP2_GRID_SEGMENTS 0x0DD3 + #define GL_TEXTURE_1D 0x0DE0 + #define GL_TEXTURE_2D 0x0DE1 + #define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 + #define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 + #define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 + #define GL_SELECTION_BUFFER_POINTER 0x0DF3 + #define GL_SELECTION_BUFFER_SIZE 0x0DF4 + /* GL_TEXTURE_BINDING_1D */ + /* GL_TEXTURE_BINDING_2D */ + /* GL_VERTEX_ARRAY */ + /* GL_NORMAL_ARRAY */ + /* GL_COLOR_ARRAY */ + /* GL_INDEX_ARRAY */ + /* GL_TEXTURE_COORD_ARRAY */ + /* GL_EDGE_FLAG_ARRAY */ + /* GL_VERTEX_ARRAY_SIZE */ + /* GL_VERTEX_ARRAY_TYPE */ + /* GL_VERTEX_ARRAY_STRIDE */ + /* GL_NORMAL_ARRAY_TYPE */ + /* GL_NORMAL_ARRAY_STRIDE */ + /* GL_COLOR_ARRAY_SIZE */ + /* GL_COLOR_ARRAY_TYPE */ + /* GL_COLOR_ARRAY_STRIDE */ + /* GL_INDEX_ARRAY_TYPE */ + /* GL_INDEX_ARRAY_STRIDE */ + /* GL_TEXTURE_COORD_ARRAY_SIZE */ + /* GL_TEXTURE_COORD_ARRAY_TYPE */ + /* GL_TEXTURE_COORD_ARRAY_STRIDE */ + /* GL_EDGE_FLAG_ARRAY_STRIDE */ + /* GL_POLYGON_OFFSET_FACTOR */ + /* GL_POLYGON_OFFSET_UNITS */ + + /* GetTextureParameter */ + /* GL_TEXTURE_MAG_FILTER */ + /* GL_TEXTURE_MIN_FILTER */ + /* GL_TEXTURE_WRAP_S */ + /* GL_TEXTURE_WRAP_T */ + #define GL_TEXTURE_WIDTH 0x1000 + #define GL_TEXTURE_HEIGHT 0x1001 + #define GL_TEXTURE_INTERNAL_FORMAT 0x1003 + #define GL_TEXTURE_BORDER_COLOR 0x1004 + #define GL_TEXTURE_BORDER 0x1005 + /* GL_TEXTURE_RED_SIZE */ + /* GL_TEXTURE_GREEN_SIZE */ + /* GL_TEXTURE_BLUE_SIZE */ + /* GL_TEXTURE_ALPHA_SIZE */ + /* GL_TEXTURE_LUMINANCE_SIZE */ + /* GL_TEXTURE_INTENSITY_SIZE */ + /* GL_TEXTURE_PRIORITY */ + /* GL_TEXTURE_RESIDENT */ + + /* HintMode */ + #define GL_DONT_CARE 0x1100 + #define GL_FASTEST 0x1101 + #define GL_NICEST 0x1102 + + /* HintTarget */ + /* GL_PERSPECTIVE_CORRECTION_HINT */ + /* GL_POINT_SMOOTH_HINT */ + /* GL_LINE_SMOOTH_HINT */ + /* GL_POLYGON_SMOOTH_HINT */ + /* GL_FOG_HINT */ + /* GL_PHONG_HINT */ + + /* IndexPointerType */ + /* GL_SHORT */ + /* GL_INT */ + /* GL_FLOAT */ + /* GL_DOUBLE */ + + /* LightModelParameter */ + /* GL_LIGHT_MODEL_AMBIENT */ + /* GL_LIGHT_MODEL_LOCAL_VIEWER */ + /* GL_LIGHT_MODEL_TWO_SIDE */ + + /* LightName */ + #define GL_LIGHT0 0x4000 + #define GL_LIGHT1 0x4001 + #define GL_LIGHT2 0x4002 + #define GL_LIGHT3 0x4003 + #define GL_LIGHT4 0x4004 + #define GL_LIGHT5 0x4005 + #define GL_LIGHT6 0x4006 + #define GL_LIGHT7 0x4007 + + /* LightParameter */ + #define GL_AMBIENT 0x1200 + #define GL_DIFFUSE 0x1201 + #define GL_SPECULAR 0x1202 + #define GL_POSITION 0x1203 + #define GL_SPOT_DIRECTION 0x1204 + #define GL_SPOT_EXPONENT 0x1205 + #define GL_SPOT_CUTOFF 0x1206 + #define GL_CONSTANT_ATTENUATION 0x1207 + #define GL_LINEAR_ATTENUATION 0x1208 + #define GL_QUADRATIC_ATTENUATION 0x1209 + + /* InterleavedArrays */ + /* GL_V2F */ + /* GL_V3F */ + /* GL_C4UB_V2F */ + /* GL_C4UB_V3F */ + /* GL_C3F_V3F */ + /* GL_N3F_V3F */ + /* GL_C4F_N3F_V3F */ + /* GL_T2F_V3F */ + /* GL_T4F_V4F */ + /* GL_T2F_C4UB_V3F */ + /* GL_T2F_C3F_V3F */ + /* GL_T2F_N3F_V3F */ + /* GL_T2F_C4F_N3F_V3F */ + /* GL_T4F_C4F_N3F_V4F */ + + /* ListMode */ + #define GL_COMPILE 0x1300 + #define GL_COMPILE_AND_EXECUTE 0x1301 + + /* ListNameType */ + /* GL_BYTE */ + /* GL_UNSIGNED_BYTE */ + /* GL_SHORT */ + /* GL_UNSIGNED_SHORT */ + /* GL_INT */ + /* GL_UNSIGNED_INT */ + /* GL_FLOAT */ + /* GL_2_BYTES */ + /* GL_3_BYTES */ + /* GL_4_BYTES */ + + /* LogicOp */ + #define GL_CLEAR 0x1500 + #define GL_AND 0x1501 + #define GL_AND_REVERSE 0x1502 + #define GL_COPY 0x1503 + #define GL_AND_INVERTED 0x1504 + #define GL_NOOP 0x1505 + #define GL_XOR 0x1506 + #define GL_OR 0x1507 + #define GL_NOR 0x1508 + #define GL_EQUIV 0x1509 + #define GL_INVERT 0x150A + #define GL_OR_REVERSE 0x150B + #define GL_COPY_INVERTED 0x150C + #define GL_OR_INVERTED 0x150D + #define GL_NAND 0x150E + #define GL_SET 0x150F + + /* MapTarget */ + /* GL_MAP1_COLOR_4 */ + /* GL_MAP1_INDEX */ + /* GL_MAP1_NORMAL */ + /* GL_MAP1_TEXTURE_COORD_1 */ + /* GL_MAP1_TEXTURE_COORD_2 */ + /* GL_MAP1_TEXTURE_COORD_3 */ + /* GL_MAP1_TEXTURE_COORD_4 */ + /* GL_MAP1_VERTEX_3 */ + /* GL_MAP1_VERTEX_4 */ + /* GL_MAP2_COLOR_4 */ + /* GL_MAP2_INDEX */ + /* GL_MAP2_NORMAL */ + /* GL_MAP2_TEXTURE_COORD_1 */ + /* GL_MAP2_TEXTURE_COORD_2 */ + /* GL_MAP2_TEXTURE_COORD_3 */ + /* GL_MAP2_TEXTURE_COORD_4 */ + /* GL_MAP2_VERTEX_3 */ + /* GL_MAP2_VERTEX_4 */ + + /* MaterialFace */ + /* GL_FRONT */ + /* GL_BACK */ + /* GL_FRONT_AND_BACK */ + + /* MaterialParameter */ + #define GL_EMISSION 0x1600 + #define GL_SHININESS 0x1601 + #define GL_AMBIENT_AND_DIFFUSE 0x1602 + #define GL_COLOR_INDEXES 0x1603 + /* GL_AMBIENT */ + /* GL_DIFFUSE */ + /* GL_SPECULAR */ + + /* MatrixMode */ + #define GL_MODELVIEW 0x1700 + #define GL_PROJECTION 0x1701 + #define GL_TEXTURE 0x1702 + + /* MeshMode1 */ + /* GL_POINT */ + /* GL_LINE */ + + /* MeshMode2 */ + /* GL_POINT */ + /* GL_LINE */ + /* GL_FILL */ + + /* NormalPointerType */ + /* GL_BYTE */ + /* GL_SHORT */ + /* GL_INT */ + /* GL_FLOAT */ + /* GL_DOUBLE */ + + /* PixelCopyType */ + #define GL_COLOR 0x1800 + #define GL_DEPTH 0x1801 + #define GL_STENCIL 0x1802 + + /* PixelFormat */ + #define GL_COLOR_INDEX 0x1900 + #define GL_STENCIL_INDEX 0x1901 + #define GL_DEPTH_COMPONENT 0x1902 + #define GL_RED 0x1903 + #define GL_GREEN 0x1904 + #define GL_BLUE 0x1905 + #define GL_ALPHA 0x1906 + #define GL_RGB 0x1907 + #define GL_RGBA 0x1908 + #define GL_LUMINANCE 0x1909 + #define GL_LUMINANCE_ALPHA 0x190A + + /* PixelMap */ + /* GL_PIXEL_MAP_I_TO_I */ + /* GL_PIXEL_MAP_S_TO_S */ + /* GL_PIXEL_MAP_I_TO_R */ + /* GL_PIXEL_MAP_I_TO_G */ + /* GL_PIXEL_MAP_I_TO_B */ + /* GL_PIXEL_MAP_I_TO_A */ + /* GL_PIXEL_MAP_R_TO_R */ + /* GL_PIXEL_MAP_G_TO_G */ + /* GL_PIXEL_MAP_B_TO_B */ + /* GL_PIXEL_MAP_A_TO_A */ + + /* PixelStore */ + /* GL_UNPACK_SWAP_BYTES */ + /* GL_UNPACK_LSB_FIRST */ + /* GL_UNPACK_ROW_LENGTH */ + /* GL_UNPACK_SKIP_ROWS */ + /* GL_UNPACK_SKIP_PIXELS */ + /* GL_UNPACK_ALIGNMENT */ + /* GL_PACK_SWAP_BYTES */ + /* GL_PACK_LSB_FIRST */ + /* GL_PACK_ROW_LENGTH */ + /* GL_PACK_SKIP_ROWS */ + /* GL_PACK_SKIP_PIXELS */ + /* GL_PACK_ALIGNMENT */ + + /* PixelTransfer */ + /* GL_MAP_COLOR */ + /* GL_MAP_STENCIL */ + /* GL_INDEX_SHIFT */ + /* GL_INDEX_OFFSET */ + /* GL_RED_SCALE */ + /* GL_RED_BIAS */ + /* GL_GREEN_SCALE */ + /* GL_GREEN_BIAS */ + /* GL_BLUE_SCALE */ + /* GL_BLUE_BIAS */ + /* GL_ALPHA_SCALE */ + /* GL_ALPHA_BIAS */ + /* GL_DEPTH_SCALE */ + /* GL_DEPTH_BIAS */ + + /* PixelType */ + #define GL_BITMAP 0x1A00 + /* GL_BYTE */ + /* GL_UNSIGNED_BYTE */ + /* GL_SHORT */ + /* GL_UNSIGNED_SHORT */ + /* GL_INT */ + /* GL_UNSIGNED_INT */ + /* GL_FLOAT */ + + /* PolygonMode */ + #define GL_POINT 0x1B00 + #define GL_LINE 0x1B01 + #define GL_FILL 0x1B02 + + /* ReadBufferMode */ + /* GL_FRONT_LEFT */ + /* GL_FRONT_RIGHT */ + /* GL_BACK_LEFT */ + /* GL_BACK_RIGHT */ + /* GL_FRONT */ + /* GL_BACK */ + /* GL_LEFT */ + /* GL_RIGHT */ + /* GL_AUX0 */ + /* GL_AUX1 */ + /* GL_AUX2 */ + /* GL_AUX3 */ + + /* RenderingMode */ + #define GL_RENDER 0x1C00 + #define GL_FEEDBACK 0x1C01 + #define GL_SELECT 0x1C02 + + /* ShadingModel */ + #define GL_FLAT 0x1D00 + #define GL_SMOOTH 0x1D01 + + /* StencilFunction */ + /* GL_NEVER */ + /* GL_LESS */ + /* GL_EQUAL */ + /* GL_LEQUAL */ + /* GL_GREATER */ + /* GL_NOTEQUAL */ + /* GL_GEQUAL */ + /* GL_ALWAYS */ + + /* StencilOp */ + /* GL_ZERO */ + #define GL_KEEP 0x1E00 + #define GL_REPLACE 0x1E01 + #define GL_INCR 0x1E02 + #define GL_DECR 0x1E03 + /* GL_INVERT */ + + /* StringName */ + #define GL_VENDOR 0x1F00 + #define GL_RENDERER 0x1F01 + #define GL_VERSION 0x1F02 + #define GL_EXTENSIONS 0x1F03 + + /* TextureCoordName */ + #define GL_S 0x2000 + #define GL_T 0x2001 + #define GL_R 0x2002 + #define GL_Q 0x2003 + + /* TexCoordPointerType */ + /* GL_SHORT */ + /* GL_INT */ + /* GL_FLOAT */ + /* GL_DOUBLE */ + + /* TextureEnvMode */ + #define GL_MODULATE 0x2100 + #define GL_DECAL 0x2101 + /* GL_BLEND */ + /* GL_REPLACE */ + + /* TextureEnvParameter */ + #define GL_TEXTURE_ENV_MODE 0x2200 + #define GL_TEXTURE_ENV_COLOR 0x2201 + + /* TextureEnvTarget */ + #define GL_TEXTURE_ENV 0x2300 + + /* TextureGenMode */ + #define GL_EYE_LINEAR 0x2400 + #define GL_OBJECT_LINEAR 0x2401 + #define GL_SPHERE_MAP 0x2402 + + /* TextureGenParameter */ + #define GL_TEXTURE_GEN_MODE 0x2500 + #define GL_OBJECT_PLANE 0x2501 + #define GL_EYE_PLANE 0x2502 + + /* TextureMagFilter */ + #define GL_NEAREST 0x2600 + #define GL_LINEAR 0x2601 + + /* TextureMinFilter */ + /* GL_NEAREST */ + /* GL_LINEAR */ + #define GL_NEAREST_MIPMAP_NEAREST 0x2700 + #define GL_LINEAR_MIPMAP_NEAREST 0x2701 + #define GL_NEAREST_MIPMAP_LINEAR 0x2702 + #define GL_LINEAR_MIPMAP_LINEAR 0x2703 + + /* TextureParameterName */ + #define GL_TEXTURE_MAG_FILTER 0x2800 + #define GL_TEXTURE_MIN_FILTER 0x2801 + #define GL_TEXTURE_WRAP_S 0x2802 + #define GL_TEXTURE_WRAP_T 0x2803 + /* GL_TEXTURE_BORDER_COLOR */ + /* GL_TEXTURE_PRIORITY */ + + /* TextureTarget */ + /* GL_TEXTURE_1D */ + /* GL_TEXTURE_2D */ + /* GL_PROXY_TEXTURE_1D */ + /* GL_PROXY_TEXTURE_2D */ + + /* TextureWrapMode */ + #define GL_CLAMP 0x2900 + #define GL_REPEAT 0x2901 + + /* VertexPointerType */ + /* GL_SHORT */ + /* GL_INT */ + /* GL_FLOAT */ + /* GL_DOUBLE */ + + /* ClientAttribMask */ + #define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 + #define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 + #define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff + + /* polygon_offset */ + #define GL_POLYGON_OFFSET_FACTOR 0x8038 + #define GL_POLYGON_OFFSET_UNITS 0x2A00 + #define GL_POLYGON_OFFSET_POINT 0x2A01 + #define GL_POLYGON_OFFSET_LINE 0x2A02 + #define GL_POLYGON_OFFSET_FILL 0x8037 + + /* texture */ + #define GL_ALPHA4 0x803B + #define GL_ALPHA8 0x803C + #define GL_ALPHA12 0x803D + #define GL_ALPHA16 0x803E + #define GL_LUMINANCE4 0x803F + #define GL_LUMINANCE8 0x8040 + #define GL_LUMINANCE12 0x8041 + #define GL_LUMINANCE16 0x8042 + #define GL_LUMINANCE4_ALPHA4 0x8043 + #define GL_LUMINANCE6_ALPHA2 0x8044 + #define GL_LUMINANCE8_ALPHA8 0x8045 + #define GL_LUMINANCE12_ALPHA4 0x8046 + #define GL_LUMINANCE12_ALPHA12 0x8047 + #define GL_LUMINANCE16_ALPHA16 0x8048 + #define GL_INTENSITY 0x8049 + #define GL_INTENSITY4 0x804A + #define GL_INTENSITY8 0x804B + #define GL_INTENSITY12 0x804C + #define GL_INTENSITY16 0x804D + #define GL_R3_G3_B2 0x2A10 + #define GL_RGB4 0x804F + #define GL_RGB5 0x8050 + #define GL_RGB8 0x8051 + #define GL_RGB10 0x8052 + #define GL_RGB12 0x8053 + #define GL_RGB16 0x8054 + #define GL_RGBA2 0x8055 + #define GL_RGBA4 0x8056 + #define GL_RGB5_A1 0x8057 + #define GL_RGBA8 0x8058 + #define GL_RGB10_A2 0x8059 + #define GL_RGBA12 0x805A + #define GL_RGBA16 0x805B + #define GL_TEXTURE_RED_SIZE 0x805C + #define GL_TEXTURE_GREEN_SIZE 0x805D + #define GL_TEXTURE_BLUE_SIZE 0x805E + #define GL_TEXTURE_ALPHA_SIZE 0x805F + #define GL_TEXTURE_LUMINANCE_SIZE 0x8060 + #define GL_TEXTURE_INTENSITY_SIZE 0x8061 + #define GL_PROXY_TEXTURE_1D 0x8063 + #define GL_PROXY_TEXTURE_2D 0x8064 + + /* texture_object */ + #define GL_TEXTURE_PRIORITY 0x8066 + #define GL_TEXTURE_RESIDENT 0x8067 + #define GL_TEXTURE_BINDING_1D 0x8068 + #define GL_TEXTURE_BINDING_2D 0x8069 + + /* vertex_array */ + #define GL_VERTEX_ARRAY 0x8074 + #define GL_NORMAL_ARRAY 0x8075 + #define GL_COLOR_ARRAY 0x8076 + #define GL_INDEX_ARRAY 0x8077 + #define GL_TEXTURE_COORD_ARRAY 0x8078 + #define GL_EDGE_FLAG_ARRAY 0x8079 + #define GL_VERTEX_ARRAY_SIZE 0x807A + #define GL_VERTEX_ARRAY_TYPE 0x807B + #define GL_VERTEX_ARRAY_STRIDE 0x807C + #define GL_NORMAL_ARRAY_TYPE 0x807E + #define GL_NORMAL_ARRAY_STRIDE 0x807F + #define GL_COLOR_ARRAY_SIZE 0x8081 + #define GL_COLOR_ARRAY_TYPE 0x8082 + #define GL_COLOR_ARRAY_STRIDE 0x8083 + #define GL_INDEX_ARRAY_TYPE 0x8085 + #define GL_INDEX_ARRAY_STRIDE 0x8086 + #define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 + #define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 + #define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A + #define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C + #define GL_VERTEX_ARRAY_POINTER 0x808E + #define GL_NORMAL_ARRAY_POINTER 0x808F + #define GL_COLOR_ARRAY_POINTER 0x8090 + #define GL_INDEX_ARRAY_POINTER 0x8091 + #define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 + #define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 + #define GL_V2F 0x2A20 + #define GL_V3F 0x2A21 + #define GL_C4UB_V2F 0x2A22 + #define GL_C4UB_V3F 0x2A23 + #define GL_C3F_V3F 0x2A24 + #define GL_N3F_V3F 0x2A25 + #define GL_C4F_N3F_V3F 0x2A26 + #define GL_T2F_V3F 0x2A27 + #define GL_T4F_V4F 0x2A28 + #define GL_T2F_C4UB_V3F 0x2A29 + #define GL_T2F_C3F_V3F 0x2A2A + #define GL_T2F_N3F_V3F 0x2A2B + #define GL_T2F_C4F_N3F_V3F 0x2A2C + #define GL_T4F_C4F_N3F_V4F 0x2A2D + + /* Extensions */ + #define GL_EXT_vertex_array 1 + #define GL_EXT_bgra 1 + #define GL_EXT_paletted_texture 1 + #define GL_WIN_swap_hint 1 + #define GL_WIN_draw_range_elements 1 + // #define GL_WIN_phong_shading 1 + // #define GL_WIN_specular_fog 1 + + /* EXT_vertex_array */ + #define GL_VERTEX_ARRAY_EXT 0x8074 + #define GL_NORMAL_ARRAY_EXT 0x8075 + #define GL_COLOR_ARRAY_EXT 0x8076 + #define GL_INDEX_ARRAY_EXT 0x8077 + #define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 + #define GL_EDGE_FLAG_ARRAY_EXT 0x8079 + #define GL_VERTEX_ARRAY_SIZE_EXT 0x807A + #define GL_VERTEX_ARRAY_TYPE_EXT 0x807B + #define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C + #define GL_VERTEX_ARRAY_COUNT_EXT 0x807D + #define GL_NORMAL_ARRAY_TYPE_EXT 0x807E + #define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F + #define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 + #define GL_COLOR_ARRAY_SIZE_EXT 0x8081 + #define GL_COLOR_ARRAY_TYPE_EXT 0x8082 + #define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 + #define GL_COLOR_ARRAY_COUNT_EXT 0x8084 + #define GL_INDEX_ARRAY_TYPE_EXT 0x8085 + #define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 + #define GL_INDEX_ARRAY_COUNT_EXT 0x8087 + #define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 + #define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 + #define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A + #define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B + #define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C + #define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D + #define GL_VERTEX_ARRAY_POINTER_EXT 0x808E + #define GL_NORMAL_ARRAY_POINTER_EXT 0x808F + #define GL_COLOR_ARRAY_POINTER_EXT 0x8090 + #define GL_INDEX_ARRAY_POINTER_EXT 0x8091 + #define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 + #define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 + #define GL_DOUBLE_EXT GL_DOUBLE + + /* EXT_bgra */ + #define GL_BGR_EXT 0x80E0 + #define GL_BGRA_EXT 0x80E1 + + /* EXT_paletted_texture */ + + /* These must match the GL_COLOR_TABLE_*_SGI enumerants */ + #define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 + #define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 + #define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA + #define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB + #define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC + #define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD + #define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE + #define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF + + #define GL_COLOR_INDEX1_EXT 0x80E2 + #define GL_COLOR_INDEX2_EXT 0x80E3 + #define GL_COLOR_INDEX4_EXT 0x80E4 + #define GL_COLOR_INDEX8_EXT 0x80E5 + #define GL_COLOR_INDEX12_EXT 0x80E6 + #define GL_COLOR_INDEX16_EXT 0x80E7 + + /* WIN_draw_range_elements */ + #define GL_MAX_ELEMENTS_VERTICES_WIN 0x80E8 + #define GL_MAX_ELEMENTS_INDICES_WIN 0x80E9 + + /* WIN_phong_shading */ + #define GL_PHONG_WIN 0x80EA + #define GL_PHONG_HINT_WIN 0x80EB + + /* WIN_specular_fog */ + #define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC + + /* For compatibility with OpenGL v1.0 */ + #define GL_LOGIC_OP GL_INDEX_LOGIC_OP + #define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT + #include + #if QT_VERSION >= 0x060000 + #include + #endif #endif // QT_NO_OPENGL diff --git a/generator/reporthandler.cpp b/generator/reporthandler.cpp index 8dc368a91..b6f9eac6e 100644 --- a/generator/reporthandler.cpp +++ b/generator/reporthandler.cpp @@ -48,27 +48,26 @@ QString ReportHandler::m_context; ReportHandler::DebugLevel ReportHandler::m_debug_level = NoDebug; QSet ReportHandler::m_reported_warnings; - -void ReportHandler::warning(const QString &text) +void ReportHandler::warning(const QString& text) { - QString warningText = QString("WARNING(%1) :: %2").arg(m_context).arg(text); + QString warningText = QString("WARNING(%1) :: %2").arg(m_context).arg(text); - TypeDatabase *db = TypeDatabase::instance(); - if (db && db->isSuppressedWarning(warningText)) { - ++m_suppressed_count; - } else if (!m_reported_warnings.contains(warningText)) { - qDebug("%s", qPrintable(warningText)); - ++m_warning_count; + TypeDatabase* db = TypeDatabase::instance(); + if (db && db->isSuppressedWarning(warningText)) { + ++m_suppressed_count; + } else if (!m_reported_warnings.contains(warningText)) { + qDebug("%s", qPrintable(warningText)); + ++m_warning_count; - m_reported_warnings.insert(warningText); - } + m_reported_warnings.insert(warningText); + } } -void ReportHandler::debug(DebugLevel level, const QString &text) +void ReportHandler::debug(DebugLevel level, const QString& text) { - if (m_debug_level == NoDebug) - return; + if (m_debug_level == NoDebug) + return; - if (level <= m_debug_level) - qDebug(" - DEBUG(%s) :: %s", qPrintable(m_context), qPrintable(text)); + if (level <= m_debug_level) + qDebug(" - DEBUG(%s) :: %s", qPrintable(m_context), qPrintable(text)); } diff --git a/generator/reporthandler.h b/generator/reporthandler.h index 030764b8c..d188d4336 100644 --- a/generator/reporthandler.h +++ b/generator/reporthandler.h @@ -48,36 +48,30 @@ class ReportHandler { public: - enum DebugLevel { NoDebug, SparseDebug, MediumDebug, FullDebug }; + enum DebugLevel { NoDebug, SparseDebug, MediumDebug, FullDebug }; - static void setContext(const QString &context) { m_context = context; } + static void setContext(const QString& context) { m_context = context; } - static DebugLevel debugLevel() { return m_debug_level; } - static void setDebugLevel(DebugLevel level) { m_debug_level = level; } + static DebugLevel debugLevel() { return m_debug_level; } + static void setDebugLevel(DebugLevel level) { m_debug_level = level; } - static int warningCount() { return m_warning_count; } + static int warningCount() { return m_warning_count; } - static int suppressedCount() { return m_suppressed_count; } + static int suppressedCount() { return m_suppressed_count; } - static void warning(const QString &str); + static void warning(const QString& str); - static void debugSparse(const QString &str) { - debug(SparseDebug, str); - } - static void debugMedium(const QString &str) { - debug(MediumDebug, str); - } - static void debugFull(const QString &str) { - debug(FullDebug, str); - } - static void debug(DebugLevel level, const QString &str); + static void debugSparse(const QString& str) { debug(SparseDebug, str); } + static void debugMedium(const QString& str) { debug(MediumDebug, str); } + static void debugFull(const QString& str) { debug(FullDebug, str); } + static void debug(DebugLevel level, const QString& str); private: - static int m_warning_count; - static int m_suppressed_count; - static DebugLevel m_debug_level; - static QString m_context; - static QSet m_reported_warnings; + static int m_warning_count; + static int m_suppressed_count; + static DebugLevel m_debug_level; + static QString m_context; + static QSet m_reported_warnings; }; #endif // REPORTHANDLER_H diff --git a/generator/setupgenerator.cpp b/generator/setupgenerator.cpp index df7d79e08..c20edea3f 100644 --- a/generator/setupgenerator.cpp +++ b/generator/setupgenerator.cpp @@ -46,13 +46,13 @@ #include "reporthandler.h" #include "fileout.h" - -void SetupGenerator::addClass(const QString& package, const AbstractMetaClass *cls) +void SetupGenerator::addClass(const QString& package, const AbstractMetaClass* cls) { packHash[package].append(cls); } -static QStringList getOperatorCodes(const AbstractMetaClass* cls) { +static QStringList getOperatorCodes(const AbstractMetaClass* cls) +{ QSet operatorCodes; AbstractMetaFunctionList returned; AbstractMetaFunctionList functions = cls->functions(); @@ -64,12 +64,13 @@ static QStringList getOperatorCodes(const AbstractMetaClass* cls) { } QSet r; for (const QString& op : -# if QT_VERSION < QT_VERSION_CHECK(5,14,0) - operatorCodes.toList() -# else - QStringList(operatorCodes.begin(), operatorCodes.end()) -# endif - ) { +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + operatorCodes.toList() +#else + QStringList(operatorCodes.begin(), operatorCodes.end()) +#endif + ) + { if (op == ">" || op == "<" || op == ">=" || op == "<=" || op == "==" || op == "!=") { r.insert("PythonQt::Type_RichCompare"); } else if (op == "+") { @@ -90,7 +91,7 @@ static QStringList getOperatorCodes(const AbstractMetaClass* cls) { r.insert("PythonQt::Type_Xor"); } else if (op == "~") { r.insert("PythonQt::Type_Invert"); - + } else if (op == "+=") { r.insert("PythonQt::Type_InplaceAdd"); } else if (op == "-=") { @@ -115,71 +116,71 @@ static QStringList getOperatorCodes(const AbstractMetaClass* cls) { { CodeSnipList code_snips = cls->typeEntry()->codeSnips(); - for (const CodeSnip &cs : code_snips) { + for (const CodeSnip& cs : code_snips) { if (cs.language == TypeSystem::PyWrapperOperators) { QStringList values = cs.code().split(" ", Qt::SkipEmptyParts); - for (QString value : values) { + for (QString value : values) { r.insert(value); } } } } - -#if QT_VERSION < QT_VERSION_CHECK(5,14,0) - QStringList result = r.toList(); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + QStringList result = r.toList(); #else - QStringList result(r.begin(), r.end()); + QStringList result(r.begin(), r.end()); #endif std::sort(result.begin(), result.end()); return result; } static QSet _builtinListTypes = QSet() << "QByteArray" -<< "QDate" -<< "QTime" -<< "QDateTime" -<< "QUrl" -<< "QLocale" -<< "QRect" -<< "QRectF" -<< "QSize" -<< "QSizeF" -<< "QLine" -<< "QLineF" -<< "QPoint" -<< "QPointF" -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) -<< "QRegExp" + << "QDate" + << "QTime" + << "QDateTime" + << "QUrl" + << "QLocale" + << "QRect" + << "QRectF" + << "QSize" + << "QSizeF" + << "QLine" + << "QLineF" + << "QPoint" + << "QPointF" +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + << "QRegExp" #endif -<< "QRegularExpression" -<< "QFont" -<< "QPixmap" -<< "QBrush" -<< "QColor" -<< "QPalette" -<< "QIcon" -<< "QImage" -<< "QPolygon" -<< "QRegion" -<< "QBitmap" -<< "QCursor" -<< "QSizePolicy" -<< "QKeySequence" -<< "QPen" -<< "QTextLength" -<< "QTextFormat" -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) -<< "QMatrix" + << "QRegularExpression" + << "QFont" + << "QPixmap" + << "QBrush" + << "QColor" + << "QPalette" + << "QIcon" + << "QImage" + << "QPolygon" + << "QRegion" + << "QBitmap" + << "QCursor" + << "QSizePolicy" + << "QKeySequence" + << "QPen" + << "QTextLength" + << "QTextFormat" +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + << "QMatrix" #endif -<< "QTransform" -<< "QMatrix4x4" -<< "QVariant"; + << "QTransform" + << "QMatrix4x4" + << "QVariant"; -static void addListRegistration(AbstractMetaType::shared_pointer type, QSet& output) { +static void addListRegistration(AbstractMetaType::shared_pointer type, QSet& output) +{ if (type->instantiations().size() > 0) { - auto &args = type->instantiations(); - + auto& args = type->instantiations(); + /* QString debugStr; for (AbstractMetaType* arg : args) { @@ -204,8 +205,11 @@ static void addListRegistration(AbstractMetaType::shared_pointer type, QSetisEnum()) { - output.insert(QString("PythonQtMethodInfo::addParameterTypeAlias(\"") + typeName + "<" + innerName + ">\", \"" + typeName + "\");"); - } else if (args.at(0)->instantiations().isEmpty() && innerName.startsWith("Q") && !_builtinListTypes.contains(innerName)) { + output.insert(QString("PythonQtMethodInfo::addParameterTypeAlias(\"") + typeName + "<" + innerName + ">\", \"" + + typeName + "\");"); + } else if (args.at(0)->instantiations().isEmpty() && innerName.startsWith("Q") + && !_builtinListTypes.contains(innerName)) + { QString result = "PythonQtRegisterListTemplateConverterForKnownClass(" + typeName + ", " + innerName + ");"; output.insert(result); } @@ -219,22 +223,22 @@ static void addListRegistration(AbstractMetaType::shared_pointer type, QSet 0) { - p[0] = p[0].toUpper(); - } +QStringList capitalize(QStringList parts) +{ + for (QString& p : parts) { + if (p.length() > 0) { + p[0] = p[0].toUpper(); } - return parts; } + return parts; +} } void SetupGenerator::generate() { AbstractMetaClassList classes_with_polymorphic_id; { - QHashIterator > pack(packHash); + QHashIterator> pack(packHash); while (pack.hasNext()) { pack.next(); QList list = pack.value(); @@ -247,7 +251,7 @@ void SetupGenerator::generate() } classes_with_polymorphic_id.sort(); - QHashIterator > pack(packHash); + QHashIterator> pack(packHash); while (pack.hasNext()) { pack.next(); QList list = pack.value(); @@ -275,12 +279,12 @@ void SetupGenerator::generate() QString fileName(packName + "/" + packKey + "_init.cpp"); FileOut initFile(m_out_dir + "/generated_cpp/" + fileName); ReportHandler::debugSparse(QString("generating: %1").arg(fileName)); - QTextStream &s = initFile.stream; + QTextStream& s = initFile.stream; s << "#include " << Qt::endl; s << "#include " << Qt::endl; - for (int i=0; i<(list.count()+ maxClassesPerFile -1) / maxClassesPerFile; i++) { + for (int i = 0; i < (list.count() + maxClassesPerFile - 1) / maxClassesPerFile; i++) { s << "#include \"" << packKey << QString::number(i) << ".h\"" << Qt::endl; } s << Qt::endl; @@ -293,12 +297,12 @@ void SetupGenerator::generate() QSet listRegistration; QSet snips; - for (auto cls: list) { - for(auto &&func: cls->functions()) { + for (auto cls : list) { + for (auto&& func : cls->functions()) { if (func->type() && func->type()->isContainer()) { addListRegistration(func->type(), listRegistration); } - for(auto &&arg: func->arguments()) { + for (auto&& arg : func->arguments()) { if (arg->type() && arg->type()->isContainer()) { addListRegistration(arg->type(), listRegistration); } @@ -307,7 +311,7 @@ void SetupGenerator::generate() { while (cls) { CodeSnipList code_snips = cls->typeEntry()->codeSnips(); - for (const CodeSnip &cs : code_snips) { + for (const CodeSnip& cs : code_snips) { if (cs.language == TypeSystem::PyInitSource) { snips.insert(cs.code()); } @@ -317,7 +321,7 @@ void SetupGenerator::generate() } } - for (QString snip : snips) { + for (QString snip : snips) { s << snip; } s << Qt::endl; @@ -327,11 +331,11 @@ void SetupGenerator::generate() for (const AbstractMetaClass* cls : list) { if (cls->qualifiedCppName().contains("Ssl")) { - s << "#ifndef QT_NO_SSL" << Qt::endl; + s << "#ifndef QT_NO_SSL" << Qt::endl; } - AbstractMetaFunctionList ctors = cls->queryFunctions(AbstractMetaClass::Constructors - | AbstractMetaClass::WasVisible - | AbstractMetaClass::NotRemovedFromTargetLang); + AbstractMetaFunctionList ctors = + cls->queryFunctions(AbstractMetaClass::Constructors | AbstractMetaClass::WasVisible + | AbstractMetaClass::NotRemovedFromTargetLang); QString shellCreator; if (cls->generateShellClass() && !ctors.isEmpty()) { @@ -340,7 +344,7 @@ void SetupGenerator::generate() const AbstractMetaClass* theclass = cls; while (theclass) { CodeSnipList code_snips = theclass->typeEntry()->codeSnips(); - for (const CodeSnip &cs : code_snips) { + for (const CodeSnip& cs : code_snips) { if (cs.language == TypeSystem::PySetWrapperFunc) { setInstanceFunc = cs.code(); break; @@ -358,36 +362,45 @@ void SetupGenerator::generate() operatorCodes = "0"; } if (cls->isQObject()) { - s << "PythonQt::priv()->registerClass(&" << cls->qualifiedCppName() << "::staticMetaObject, \"" << packageName <<"\", PythonQtCreateObjectname() << ">" << shellCreator << ", module, " << operatorCodes <<");" << Qt::endl; + s << "PythonQt::priv()->registerClass(&" << cls->qualifiedCppName() << "::staticMetaObject, \"" << packageName + << "\", PythonQtCreateObjectname() << ">" << shellCreator << ", module, " + << operatorCodes << ");" << Qt::endl; } else if (cls->isGlobalNamespace()) { - s << "PythonQt::priv()->registerGlobalNamespace(\"" << cls->qualifiedCppName() << "\", \"" << packageName << "\", PythonQtCreateObjectname() << ">, PythonQtWrapper_" << cls->name() << "::staticMetaObject, module); " << Qt::endl; + s << "PythonQt::priv()->registerGlobalNamespace(\"" << cls->qualifiedCppName() << "\", \"" << packageName + << "\", PythonQtCreateObjectname() << ">, PythonQtWrapper_" << cls->name() + << "::staticMetaObject, module); " << Qt::endl; } else { - QString baseName = cls->baseClass()?cls->baseClass()->qualifiedCppName():""; - s << "PythonQt::priv()->registerCPPClass(\""<< cls->qualifiedCppName() << "\", \"" << baseName << "\", \"" << packageName <<"\", PythonQtCreateObjectname() << ">" << shellCreator << ", module, " << operatorCodes <<");" << Qt::endl; + QString baseName = cls->baseClass() ? cls->baseClass()->qualifiedCppName() : ""; + s << "PythonQt::priv()->registerCPPClass(\"" << cls->qualifiedCppName() << "\", \"" << baseName << "\", \"" + << packageName << "\", PythonQtCreateObjectname() << ">" << shellCreator + << ", module, " << operatorCodes << ");" << Qt::endl; } - for (AbstractMetaClass* interface : cls->interfaces()) { + for (AbstractMetaClass* interface : cls->interfaces()) { // the interface might be our own class... (e.g. QPaintDevice) if (interface->qualifiedCppName() != cls->qualifiedCppName()) { - s << "PythonQt::self()->addParentClass(\""<< cls->qualifiedCppName() << "\", \"" << interface->qualifiedCppName() << "\",PythonQtUpcastingOffset<" << cls->qualifiedCppName() <<","<qualifiedCppName()<<">());" << Qt::endl; + s << "PythonQt::self()->addParentClass(\"" << cls->qualifiedCppName() << "\", \"" + << interface->qualifiedCppName() << "\",PythonQtUpcastingOffset<" << cls->qualifiedCppName() << "," + << interface->qualifiedCppName() << ">());" << Qt::endl; } } if (cls->qualifiedCppName().contains("Ssl")) { - s << "#endif" << Qt::endl; + s << "#endif" << Qt::endl; } } s << Qt::endl; for (QString handler : polymorphicHandlers) { - s << "PythonQt::self()->addPolymorphicHandler(\""<< handler << "\", polymorphichandler_" << handler << ");" << Qt::endl; + s << "PythonQt::self()->addPolymorphicHandler(\"" << handler << "\", polymorphichandler_" << handler << ");" + << Qt::endl; } s << Qt::endl; -#if QT_VERSION < QT_VERSION_CHECK(5,14,0) +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QStringList list = listRegistration.toList(); #else QStringList list(listRegistration.begin(), listRegistration.end()); #endif list.sort(); - for(auto &&name: list) { + for (auto&& name : list) { if (name.contains("Ssl")) { s << "#ifndef QT_NO_SSL" << Qt::endl; } @@ -403,24 +416,24 @@ void SetupGenerator::generate() } } -QStringList SetupGenerator::writePolymorphicHandler(QTextStream &s, const QString &package, - const AbstractMetaClassList &polybase, QList& allClasses) +QStringList SetupGenerator::writePolymorphicHandler(QTextStream& s, const QString& package, + const AbstractMetaClassList& polybase, QList& allClasses) { QStringList handlers; for (AbstractMetaClass* cls : polybase) { - const ComplexTypeEntry *centry = cls->typeEntry(); + const ComplexTypeEntry* centry = cls->typeEntry(); if (!centry->isPolymorphicBase()) continue; - bool isGraphicsItem = (cls->qualifiedCppName()=="QGraphicsItem"); + bool isGraphicsItem = (cls->qualifiedCppName() == "QGraphicsItem"); bool first = true; for (const AbstractMetaClass* clazz : allClasses) { bool inherits = false; if (isGraphicsItem) { - const AbstractMetaClass *currentClazz = clazz; + const AbstractMetaClass* currentClazz = clazz; while (!inherits && currentClazz) { - for (AbstractMetaClass* interfaze : currentClazz->interfaces()) { - if (interfaze->qualifiedCppName()=="QGraphicsItem") { + for (AbstractMetaClass* interfaze : currentClazz->interfaces()) { + if (interfaze->qualifiedCppName() == "QGraphicsItem") { inherits = true; break; } @@ -439,26 +452,24 @@ QStringList SetupGenerator::writePolymorphicHandler(QTextStream &s, const QStrin QString handler = cls->name(); handlers.append(handler); - s << "static void* polymorphichandler_" << handler - << "(const void *ptr, const char **class_name)" << Qt::endl + s << "static void* polymorphichandler_" << handler << "(const void *ptr, const char **class_name)" + << Qt::endl << "{" << Qt::endl << " Q_ASSERT(ptr != nullptr);" << Qt::endl - << " " << cls->qualifiedCppName() << " *object = (" - << cls->qualifiedCppName() << " *)ptr;" << Qt::endl; + << " " << cls->qualifiedCppName() << " *object = (" << cls->qualifiedCppName() << " *)ptr;" + << Qt::endl; } // For each, add case label QString polyId = clazz->typeEntry()->polymorphicIdValue(); - s << " if (" - << polyId.replace("%1", "object") - << ") {" << Qt::endl + s << " if (" << polyId.replace("%1", "object") << ") {" << Qt::endl << " *class_name = \"" << clazz->name() << "\";" << Qt::endl << " return (" << clazz->qualifiedCppName() << "*)object;" << Qt::endl << " }" << Qt::endl; } else { QString warning = QString("class '%1' inherits from polymorphic class '%2', but has no polymorphic id set") - .arg(clazz->name()) - .arg(cls->name()); + .arg(clazz->name()) + .arg(cls->name()); ReportHandler::warning(warning); } @@ -467,8 +478,7 @@ QStringList SetupGenerator::writePolymorphicHandler(QTextStream &s, const QStrin // Close the function if it has been opened if (!first) { - s << " return nullptr;" << Qt::endl - << "}" << Qt::endl; + s << " return nullptr;" << Qt::endl << "}" << Qt::endl; } } diff --git a/generator/setupgenerator.h b/generator/setupgenerator.h index fb5985d2b..ade85b1ca 100644 --- a/generator/setupgenerator.h +++ b/generator/setupgenerator.h @@ -47,26 +47,28 @@ class SetupGenerator : public Generator { - Q_OBJECT + Q_OBJECT - public: - SetupGenerator(int classesPerFile) : maxClassesPerFile(classesPerFile) {} +public: + SetupGenerator(int classesPerFile) + : maxClassesPerFile(classesPerFile) + { + } - virtual void generate(); + virtual void generate(); - void addClass(const QString& package, const AbstractMetaClass *cls); + void addClass(const QString& package, const AbstractMetaClass* cls); - static void writeInclude(QTextStream &stream, const Include &inc); - - static bool isSpecialStreamingOperator(const AbstractMetaFunction *fun); - - private: - QStringList writePolymorphicHandler(QTextStream &s, const QString &package, - const AbstractMetaClassList &polyBaseClasses, QList& allClasses); + static void writeInclude(QTextStream& stream, const Include& inc); - QHash > packHash; + static bool isSpecialStreamingOperator(const AbstractMetaFunction* fun); - int maxClassesPerFile; +private: + QStringList writePolymorphicHandler(QTextStream& s, const QString& package, + const AbstractMetaClassList& polyBaseClasses, QList& allClasses); + + QHash> packHash; + + int maxClassesPerFile; }; #endif // SETUPGENERATOR_H - diff --git a/generator/shellgenerator.cpp b/generator/shellgenerator.cpp index c3877ec9b..6a8529ac8 100644 --- a/generator/shellgenerator.cpp +++ b/generator/shellgenerator.cpp @@ -47,174 +47,173 @@ #include "metaqtscript.h" #include -bool ShellGenerator::shouldGenerate(const AbstractMetaClass *meta_class) const +bool ShellGenerator::shouldGenerate(const AbstractMetaClass* meta_class) const { - uint cg = meta_class->typeEntry()->codeGeneration(); - return ((cg & TypeEntry::GenerateCode) != 0); + uint cg = meta_class->typeEntry()->codeGeneration(); + return ((cg & TypeEntry::GenerateCode) != 0); } -void ShellGenerator::writeTypeInfo(QTextStream &s, AbstractMetaType::const_shared_pointer type, Option options, TypeSystem::Ownership ownership) +void ShellGenerator::writeTypeInfo(QTextStream& s, AbstractMetaType::const_shared_pointer type, Option options, + TypeSystem::Ownership ownership) { - if ((options & OriginalTypeDescription) && !type->originalTypeDescription().isEmpty()) { - s << type->originalTypeDescription(); - return; - } + if ((options & OriginalTypeDescription) && !type->originalTypeDescription().isEmpty()) { + s << type->originalTypeDescription(); + return; + } - if (type->isArray()) { - writeTypeInfo(s, type->arrayElementType(), options, ownership); - if (options & ArrayAsPointer) { - s << "*"; - } else { - s << "[" << type->arrayElementCount() << "]"; - } - return; + if (type->isArray()) { + writeTypeInfo(s, type->arrayElementType(), options, ownership); + if (options & ArrayAsPointer) { + s << "*"; + } else { + s << "[" << type->arrayElementCount() << "]"; } + return; + } - const TypeEntry *te = type->typeEntry(); + const TypeEntry* te = type->typeEntry(); - if (type->isConstant() && !(options & ExcludeConst) && !(ownership!=TypeSystem::InvalidOwnership && type->isReference()) ) - s << "const "; + if (type->isConstant() && !(options & ExcludeConst) + && !(ownership != TypeSystem::InvalidOwnership && type->isReference())) + s << "const "; - if ((options & EnumAsInts) && (te->isEnum() || te->isFlags())) { + if ((options & EnumAsInts) && (te->isEnum() || te->isFlags())) { + s << "int"; + } else if (te->isFlags()) { + s << ((FlagsTypeEntry*)te)->originalName(); + } else { + if (type->isEnum() && (options & ProtectedEnumAsInts)) { + AbstractMetaEnum* enumType = m_classes.findEnum((EnumTypeEntry*)te); + if (enumType && enumType->wasProtected()) { s << "int"; - } else if (te->isFlags()) { - s << ((FlagsTypeEntry *) te)->originalName(); - } else { - if (type->isEnum() && (options & ProtectedEnumAsInts)) { - AbstractMetaEnum* enumType = m_classes.findEnum((EnumTypeEntry *)te); - if (enumType && enumType->wasProtected()) { - s << "int"; - } else { - s << fixCppTypeName(te->qualifiedCppName()); - } } else { s << fixCppTypeName(te->qualifiedCppName()); } + } else { + s << fixCppTypeName(te->qualifiedCppName()); } + } - if (type->instantiations().size() > 0 - && (!te->isContainer() - || (static_cast(te))->type() != ContainerTypeEntry::StringListContainer)) { - s << '<'; - auto &args = type->instantiations(); - bool nested_template = false; - for (int i=0; iisContainer(); - writeTypeInfo(s, args.at(i)); - } - if (nested_template) - s << ' '; - s << '>'; + if (type->instantiations().size() > 0 + && (!te->isContainer() + || (static_cast(te))->type() != ContainerTypeEntry::StringListContainer)) + { + s << '<'; + auto& args = type->instantiations(); + bool nested_template = false; + for (int i = 0; i < args.size(); ++i) { + if (i != 0) + s << ", "; + nested_template |= args.at(i)->isContainer(); + writeTypeInfo(s, args.at(i)); } + if (nested_template) + s << ' '; + s << '>'; + } - s << QString(type->indirections(), '*'); + s << QString(type->indirections(), '*'); - if (type->isReference() && !(options & ExcludeReference) && !(options & ConvertReferenceToPtr) && !(ownership != TypeSystem::InvalidOwnership && type->isReference())) - s << "&"; + if (type->isReference() && !(options & ExcludeReference) && !(options & ConvertReferenceToPtr) + && !(ownership != TypeSystem::InvalidOwnership && type->isReference())) + s << "&"; - if (type->isReference() && (options & ConvertReferenceToPtr)) { - s << "*"; - } - + if (type->isReference() && (options & ConvertReferenceToPtr)) { + s << "*"; + } - if (!(options & SkipName)) - s << ' '; + if (!(options & SkipName)) + s << ' '; } namespace { - AbstractMetaEnum* findEnumTypeOfClass(const AbstractMetaClass* implementor, const QString& enumName) - { - for (AbstractMetaEnum* enumType : implementor->enums()) { - if (enumType->name() == enumName) { - return enumType; - } +AbstractMetaEnum* findEnumTypeOfClass(const AbstractMetaClass* implementor, const QString& enumName) +{ + for (AbstractMetaEnum* enumType : implementor->enums()) { + if (enumType->name() == enumName) { + return enumType; } - return nullptr; } + return nullptr; +} } namespace { - QString trimSpaces(const QString& expr) - { - QString result = expr; - if (!result.contains("\"") && !result.contains("'")) { - // assume all spaces are expendable (some new spaces were introduced by the new simplecpp preprocessor) - result.replace(" ", ""); - } - return result; +QString trimSpaces(const QString& expr) +{ + QString result = expr; + if (!result.contains("\"") && !result.contains("'")) { + // assume all spaces are expendable (some new spaces were introduced by the new simplecpp preprocessor) + result.replace(" ", ""); } + return result; +} }; - -void ShellGenerator::writeFunctionArguments(QTextStream &s, - const AbstractMetaFunction *meta_function, - Option option, - int numArguments) +void ShellGenerator::writeFunctionArguments(QTextStream& s, const AbstractMetaFunction* meta_function, Option option, + int numArguments) { - const AbstractMetaArgumentList &arguments = meta_function->arguments(); + const AbstractMetaArgumentList& arguments = meta_function->arguments(); - if (numArguments < 0) numArguments = arguments.size(); - - for (int i=0; itype(), option, ownership); - if (ownership != TypeSystem::InvalidOwnership) { - s << "> "; - } + if (numArguments < 0) + numArguments = arguments.size(); - if (!(option & SkipName)) { - if (option & UseIndexedName) { - s << " " << arg->indexedName(); - } - else { - s << " " << arg->argumentName(); - } - } - if ((option & IncludeDefaultExpression) && !arg->defaultValueExpression().isEmpty()) { - s << " = "; + for (int i = 0; i < numArguments; ++i) { + if (i != 0) + s << ", "; + AbstractMetaArgument* arg = arguments.at(i); + TypeSystem::Ownership ownership = TypeSystem::InvalidOwnership; + if (option & AddOwnershipTemplates) { + ownership = writeOwnershipTemplate(s, meta_function, i + 1); + } + writeTypeInfo(s, arg->type(), option, ownership); + if (ownership != TypeSystem::InvalidOwnership) { + s << "> "; + } - QString expr = trimSpaces(arg->defaultValueExpression()); - if (expr == "NULL") - { - expr = "nullptr"; - } - if (expr != "0") { - QString qualifier; - if (arg->type()->typeEntry()->isEnum() && expr.indexOf("::") < 0) { - qualifier = ((EnumTypeEntry *)arg->type()->typeEntry())->qualifier(); - } else if (arg->type()->typeEntry()->isFlags() && expr.indexOf("::") < 0) { - qualifier = ((FlagsTypeEntry *)arg->type()->typeEntry())->originator()->qualifier(); - } else if (_currentScope) { - int pos = expr.indexOf("::"); - if (pos > 0) { - QString typeName = expr.left(pos); - AbstractMetaEnum* enumType = findEnumTypeOfClass(_currentScope, typeName); - if (enumType) { - // prepend original class name, otherwise the new enum type from the wrapper will be used, - // which is not compatible - qualifier = _currentScope->name(); - } - } - } + if (!(option & SkipName)) { + if (option & UseIndexedName) { + s << " " << arg->indexedName(); + } else { + s << " " << arg->argumentName(); + } + } + if ((option & IncludeDefaultExpression) && !arg->defaultValueExpression().isEmpty()) { + s << " = "; - if (!qualifier.isEmpty() && !expr.startsWith("{")) { - s << qualifier << "::"; + QString expr = trimSpaces(arg->defaultValueExpression()); + if (expr == "NULL") { + expr = "nullptr"; + } + if (expr != "0") { + QString qualifier; + if (arg->type()->typeEntry()->isEnum() && expr.indexOf("::") < 0) { + qualifier = ((EnumTypeEntry*)arg->type()->typeEntry())->qualifier(); + } else if (arg->type()->typeEntry()->isFlags() && expr.indexOf("::") < 0) { + qualifier = ((FlagsTypeEntry*)arg->type()->typeEntry())->originator()->qualifier(); + } else if (_currentScope) { + int pos = expr.indexOf("::"); + if (pos > 0) { + QString typeName = expr.left(pos); + AbstractMetaEnum* enumType = findEnumTypeOfClass(_currentScope, typeName); + if (enumType) { + // prepend original class name, otherwise the new enum type from the wrapper will be used, + // which is not compatible + qualifier = _currentScope->name(); } } - - s << expr; } + + if (!qualifier.isEmpty() && !expr.startsWith("{")) { + s << qualifier << "::"; + } + } + + s << expr; } + } } /*! @@ -231,106 +230,101 @@ void ShellGenerator::writeFunctionArguments(QTextStream &s, * form "bool static_call". */ -void ShellGenerator::writeFunctionSignature(QTextStream &s, - const AbstractMetaFunction *meta_function, - const AbstractMetaClass *implementor, - const QString &name_prefix, - Option option, - const QString &classname_prefix, - const QStringList &extra_arguments, - int numArguments) +void ShellGenerator::writeFunctionSignature(QTextStream& s, const AbstractMetaFunction* meta_function, + const AbstractMetaClass* implementor, const QString& name_prefix, Option option, const QString& classname_prefix, + const QStringList& extra_arguments, int numArguments) { -// ### remove the implementor - AbstractMetaType::shared_pointer function_type = meta_function->type(); - - - if ((option & SkipReturnType) == 0) { - if (function_type) { - TypeSystem::Ownership ownership = TypeSystem::InvalidOwnership; - if (option & AddOwnershipTemplates) { - ownership = writeOwnershipTemplate(s, meta_function, 0); - } - writeTypeInfo(s, function_type, option, ownership); - s << " "; - if (ownership != TypeSystem::InvalidOwnership) { - s << "> "; - } - } else if (!meta_function->isConstructor()) { - s << "void "; - } + // ### remove the implementor + AbstractMetaType::shared_pointer function_type = meta_function->type(); + + if ((option & SkipReturnType) == 0) { + if (function_type) { + TypeSystem::Ownership ownership = TypeSystem::InvalidOwnership; + if (option & AddOwnershipTemplates) { + ownership = writeOwnershipTemplate(s, meta_function, 0); + } + writeTypeInfo(s, function_type, option, ownership); + s << " "; + if (ownership != TypeSystem::InvalidOwnership) { + s << "> "; + } + } else if (!meta_function->isConstructor()) { + s << "void "; } + } - if (implementor) { - if (classname_prefix.isEmpty()) - s << wrapperClassName(implementor) << "::"; - else - s << classname_prefix << implementor->name() << "::"; - } + if (implementor) { + if (classname_prefix.isEmpty()) + s << wrapperClassName(implementor) << "::"; + else + s << classname_prefix << implementor->name() << "::"; + } + QString function_name; + if (option & OriginalName) + function_name = meta_function->originalName(); + else + function_name = meta_function->name(); - QString function_name; - if (option & OriginalName) - function_name = meta_function->originalName(); - else - function_name = meta_function->name(); + if (option & UnderscoreSpaces) + function_name = function_name.replace(' ', '_'); - if (option & UnderscoreSpaces) - function_name = function_name.replace(' ', '_'); + if (meta_function->isConstructor()) + function_name = meta_function->ownerClass()->name(); - if (meta_function->isConstructor()) - function_name = meta_function->ownerClass()->name(); + if (meta_function->isStatic() && (option & ShowStatic)) { + function_name = "static_" + meta_function->ownerClass()->name() + "_" + function_name; + } - if (meta_function->isStatic() && (option & ShowStatic)) { - function_name = "static_" + meta_function->ownerClass()->name() + "_" + function_name; - } - - if (function_name.startsWith("operator")) { - function_name = meta_function->name(); - } + if (function_name.startsWith("operator")) { + function_name = meta_function->name(); + } - if (meta_function->attributes() & AbstractMetaAttributes::SetterFunction) + if (meta_function->attributes() & AbstractMetaAttributes::SetterFunction) s << "py_set_"; - else if (meta_function->attributes() & AbstractMetaAttributes::GetterFunction) + else if (meta_function->attributes() & AbstractMetaAttributes::GetterFunction) s << "py_get_"; s << name_prefix << function_name; - s << "("; + s << "("; - if ((option & FirstArgIsWrappedObject) && meta_function->ownerClass() && !meta_function->isConstructor() && !meta_function->isStatic()) { - s << meta_function->ownerClass()->qualifiedCppName() << "* theWrappedObject"; + if ((option & FirstArgIsWrappedObject) && meta_function->ownerClass() && !meta_function->isConstructor() + && !meta_function->isStatic()) + { + s << meta_function->ownerClass()->qualifiedCppName() << "* theWrappedObject"; if (meta_function->arguments().size() != 0) { s << ", "; } } - - writeFunctionArguments(s, meta_function, Option(option & Option(~ConvertReferenceToPtr)), numArguments); - - // The extra arguments... - for (int i=0; i 0 || meta_function->arguments().size() != 0) - s << ", "; - s << extra_arguments.at(i); - } - s << ")"; - if (meta_function->isConstant()) - s << " const"; - if (!meta_function->exception().isEmpty()) - s << " " << meta_function->exception(); + writeFunctionArguments(s, meta_function, Option(option & Option(~ConvertReferenceToPtr)), numArguments); + + // The extra arguments... + for (int i = 0; i < extra_arguments.size(); ++i) { + if (i > 0 || meta_function->arguments().size() != 0) + s << ", "; + s << extra_arguments.at(i); + } + + s << ")"; + if (meta_function->isConstant()) + s << " const"; + if (!meta_function->exception().isEmpty()) + s << " " << meta_function->exception(); } -bool function_sorter(AbstractMetaFunction *a, AbstractMetaFunction *b); +bool function_sorter(AbstractMetaFunction* a, AbstractMetaFunction* b); bool ShellGenerator::functionHasNonConstReferences(const AbstractMetaFunction* function) { - for (const AbstractMetaArgument* arg : function->arguments()) - { + for (const AbstractMetaArgument* arg : function->arguments()) { if (!arg->type()->isConstant() && arg->type()->isReference()) { QString s; QTextStream t(&s); t << function->implementingClass()->qualifiedCppName() << "::"; writeFunctionSignature(t, function, 0, "", - Option(ConvertReferenceToPtr | FirstArgIsWrappedObject | IncludeDefaultExpression | ShowStatic | UnderscoreSpaces | ProtectedEnumAsInts)); + Option(ConvertReferenceToPtr | FirstArgIsWrappedObject | IncludeDefaultExpression | ShowStatic + | UnderscoreSpaces | ProtectedEnumAsInts)); std::cout << s.toLatin1().constData() << std::endl; return true; } @@ -338,12 +332,12 @@ bool ShellGenerator::functionHasNonConstReferences(const AbstractMetaFunction* f return false; } -bool ShellGenerator::functionNeedsNormalWrapperSlot(const AbstractMetaFunction* func, const AbstractMetaClass* currentClass) +bool ShellGenerator::functionNeedsNormalWrapperSlot(const AbstractMetaFunction* func, + const AbstractMetaClass* currentClass) { if (func->isSlot()) { return false; - } - else if (func->isVirtual()) { + } else if (func->isVirtual()) { return func->declaringClass() == currentClass; } else { return true; @@ -352,20 +346,18 @@ bool ShellGenerator::functionNeedsNormalWrapperSlot(const AbstractMetaFunction* AbstractMetaFunctionList ShellGenerator::getFunctionsToWrap(const AbstractMetaClass* meta_class) { - AbstractMetaFunctionList functions = meta_class->queryFunctions( - AbstractMetaClass::NormalFunctions | AbstractMetaClass::WasVisible - | AbstractMetaClass::NotRemovedFromTargetLang | AbstractMetaClass::ClassImplements - ); - AbstractMetaFunctionList functions2 = meta_class->queryFunctions( - AbstractMetaClass::VirtualFunctions | AbstractMetaClass::WasVisible - | AbstractMetaClass::NotRemovedFromTargetLang | AbstractMetaClass::ClassImplements - ); -#if QT_VERSION < QT_VERSION_CHECK(5,14,0) + AbstractMetaFunctionList functions = + meta_class->queryFunctions(AbstractMetaClass::NormalFunctions | AbstractMetaClass::WasVisible + | AbstractMetaClass::NotRemovedFromTargetLang | AbstractMetaClass::ClassImplements); + AbstractMetaFunctionList functions2 = + meta_class->queryFunctions(AbstractMetaClass::VirtualFunctions | AbstractMetaClass::WasVisible + | AbstractMetaClass::NotRemovedFromTargetLang | AbstractMetaClass::ClassImplements); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) QSet set1 = QSet::fromList(functions); #else QSet set1(functions.begin(), functions.end()); #endif - for (AbstractMetaFunction* func : functions2) { + for (AbstractMetaFunction* func : functions2) { set1.insert(func); } @@ -374,13 +366,14 @@ AbstractMetaFunctionList ShellGenerator::getFunctionsToWrap(const AbstractMetaCl bool hasPromoter = meta_class->typeEntry()->shouldCreatePromoter(); for (AbstractMetaFunction* func : -# if QT_VERSION < QT_VERSION_CHECK(5,14,0) - set1.toList() -# else - QList(set1.begin(), set1.end()) -# endif - ) { - if (func->implementingClass()==meta_class) { +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) + set1.toList() +#else + QList(set1.begin(), set1.end()) +#endif + ) + { + if (func->implementingClass() == meta_class) { if (hasPromoter || func->wasPublic()) { resultFunctions << func; } @@ -392,19 +385,17 @@ AbstractMetaFunctionList ShellGenerator::getFunctionsToWrap(const AbstractMetaCl AbstractMetaFunctionList ShellGenerator::getVirtualFunctionsForShell(const AbstractMetaClass* meta_class) { - AbstractMetaFunctionList functions = meta_class->queryFunctions( - AbstractMetaClass::VirtualFunctions | AbstractMetaClass::WasVisible - | AbstractMetaClass::NotRemovedFromTargetLang - ); + AbstractMetaFunctionList functions = meta_class->queryFunctions( + AbstractMetaClass::VirtualFunctions | AbstractMetaClass::WasVisible | AbstractMetaClass::NotRemovedFromTargetLang); std::sort(functions.begin(), functions.end(), function_sorter); return functions; } AbstractMetaFunctionList ShellGenerator::getProtectedFunctionsThatNeedPromotion(const AbstractMetaClass* meta_class) { - AbstractMetaFunctionList functions; - AbstractMetaFunctionList functions1 = getFunctionsToWrap(meta_class); - for (AbstractMetaFunction* func : functions1) { + AbstractMetaFunctionList functions; + AbstractMetaFunctionList functions1 = getFunctionsToWrap(meta_class); + for (AbstractMetaFunction* func : functions1) { if (func->wasProtected() || func->isVirtual()) { functions << func; } @@ -416,7 +407,7 @@ AbstractMetaFunctionList ShellGenerator::getProtectedFunctionsThatNeedPromotion( /*! Writes the include defined by \a inc to \a stream. */ -void ShellGenerator::writeInclude(QTextStream &stream, const Include &inc) +void ShellGenerator::writeInclude(QTextStream& stream, const Include& inc) { if (inc.name.isEmpty()) return; @@ -447,15 +438,15 @@ Returns true if the given function \a fun is operator>>() or operator<<() that streams from/to a Q{Data,Text}Stream, false otherwise. */ -bool ShellGenerator::isSpecialStreamingOperator(const AbstractMetaFunction *fun) +bool ShellGenerator::isSpecialStreamingOperator(const AbstractMetaFunction* fun) { - return ((fun->functionType() == AbstractMetaFunction::GlobalScopeFunction) - && (fun->arguments().size() == 1) - && (((fun->originalName() == "operator>>") && (fun->modifiedName() == "readFrom")) - || ((fun->originalName() == "operator<<") && (fun->modifiedName() == "writeTo")))); + return ((fun->functionType() == AbstractMetaFunction::GlobalScopeFunction) && (fun->arguments().size() == 1) + && (((fun->originalName() == "operator>>") && (fun->modifiedName() == "readFrom")) + || ((fun->originalName() == "operator<<") && (fun->modifiedName() == "writeTo")))); } -bool ShellGenerator::isBuiltIn(const QString& name) { +bool ShellGenerator::isBuiltIn(const QString& name) +{ static QSet builtIn; if (builtIn.isEmpty()) { @@ -478,7 +469,7 @@ bool ShellGenerator::isBuiltIn(const QString& name) { builtIn.insert("QKeySequence"); builtIn.insert("QTextLength"); builtIn.insert("QTextFormat"); -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) builtIn.insert("QMatrix"); #endif builtIn.insert("QTransform"); @@ -496,7 +487,7 @@ bool ShellGenerator::isBuiltIn(const QString& name) { builtIn.insert("QLineF"); builtIn.insert("QPoint"); builtIn.insert("QPointF"); -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) builtIn.insert("QRegExp"); #endif builtIn.insert("QRegularExpression"); @@ -504,16 +495,16 @@ bool ShellGenerator::isBuiltIn(const QString& name) { return builtIn.contains(name); } -TypeSystem::Ownership ShellGenerator::writeOwnershipTemplate(QTextStream & s, const AbstractMetaFunction * meta_function, int argumentIndex) +TypeSystem::Ownership ShellGenerator::writeOwnershipTemplate(QTextStream& s, const AbstractMetaFunction* meta_function, + int argumentIndex) { - TypeSystem::Ownership ownership = meta_function->ownership(meta_function->ownerClass(), TypeSystem::TargetLangCode, argumentIndex); + TypeSystem::Ownership ownership = + meta_function->ownership(meta_function->ownerClass(), TypeSystem::TargetLangCode, argumentIndex); if (ownership == TypeSystem::CppOwnership) { s << "PythonQtPassOwnershipToCPP<"; - } - else if (ownership == TypeSystem::TargetLangOwnership) { + } else if (ownership == TypeSystem::TargetLangOwnership) { s << "PythonQtPassOwnershipToPython<"; - } - else if (ownership == TypeSystem::TargetLangThisOwnership) { + } else if (ownership == TypeSystem::TargetLangThisOwnership) { s << "PythonQtNewOwnerOfThis<"; } return ownership; diff --git a/generator/shellgenerator.h b/generator/shellgenerator.h index c082a3d0a..3cabbdd3c 100644 --- a/generator/shellgenerator.h +++ b/generator/shellgenerator.h @@ -48,68 +48,64 @@ class ShellGenerator : public Generator { - Q_OBJECT + Q_OBJECT public: - virtual QString subDirectoryForClass(const AbstractMetaClass *cls) const - { - return "generated_cpp/" + toFileNameBase(cls->package()) + "/"; - } + virtual QString subDirectoryForClass(const AbstractMetaClass* cls) const + { + return "generated_cpp/" + toFileNameBase(cls->package()) + "/"; + } - void writeTypeInfo(QTextStream &s, AbstractMetaType::const_shared_pointer type, Option option = NoOption, TypeSystem::Ownership ownership = TypeSystem::InvalidOwnership); - void writeFunctionSignature(QTextStream &s, const AbstractMetaFunction *meta_function, - const AbstractMetaClass *implementor = 0, - const QString &name_prefix = QString(), - Option option = NoOption, - const QString &classname_prefix = QString(), - const QStringList &extra_arguments = QStringList(), - int numArguments = -1); + void writeTypeInfo(QTextStream& s, AbstractMetaType::const_shared_pointer type, Option option = NoOption, + TypeSystem::Ownership ownership = TypeSystem::InvalidOwnership); + void writeFunctionSignature(QTextStream& s, const AbstractMetaFunction* meta_function, + const AbstractMetaClass* implementor = 0, const QString& name_prefix = QString(), Option option = NoOption, + const QString& classname_prefix = QString(), const QStringList& extra_arguments = QStringList(), + int numArguments = -1); - TypeSystem::Ownership writeOwnershipTemplate(QTextStream & s, const AbstractMetaFunction * meta_function, int argumentIndex); + TypeSystem::Ownership writeOwnershipTemplate(QTextStream& s, const AbstractMetaFunction* meta_function, + int argumentIndex); - void writeFunctionArguments(QTextStream &s, const AbstractMetaFunction *meta_function, - Option option = NoOption, - int numArguments = -1); + void writeFunctionArguments(QTextStream& s, const AbstractMetaFunction* meta_function, Option option = NoOption, + int numArguments = -1); - bool shouldGenerate(const AbstractMetaClass *meta_class) const; + bool shouldGenerate(const AbstractMetaClass* meta_class) const; - bool functionHasNonConstReferences(const AbstractMetaFunction* func); + bool functionHasNonConstReferences(const AbstractMetaFunction* func); - bool functionNeedsNormalWrapperSlot(const AbstractMetaFunction* func, const AbstractMetaClass* currentClass); + bool functionNeedsNormalWrapperSlot(const AbstractMetaFunction* func, const AbstractMetaClass* currentClass); - static QString shellClassName(const AbstractMetaClass *meta_class) { - return "PythonQtShell_" + meta_class->name(); - } - static QString wrapperClassName(const AbstractMetaClass *meta_class) { - return "PythonQtWrapper_" + meta_class->name(); - } - static QString promoterClassName(const AbstractMetaClass *meta_class) { - return "PythonQtPublicPromoter_" + meta_class->name(); - } + static QString shellClassName(const AbstractMetaClass* meta_class) { return "PythonQtShell_" + meta_class->name(); } + static QString wrapperClassName(const AbstractMetaClass* meta_class) + { + return "PythonQtWrapper_" + meta_class->name(); + } + static QString promoterClassName(const AbstractMetaClass* meta_class) + { + return "PythonQtPublicPromoter_" + meta_class->name(); + } - AbstractMetaFunctionList getFunctionsToWrap(const AbstractMetaClass* cls); - AbstractMetaFunctionList getVirtualFunctionsForShell(const AbstractMetaClass* cls); - AbstractMetaFunctionList getProtectedFunctionsThatNeedPromotion(const AbstractMetaClass* cls); + AbstractMetaFunctionList getFunctionsToWrap(const AbstractMetaClass* cls); + AbstractMetaFunctionList getVirtualFunctionsForShell(const AbstractMetaClass* cls); + AbstractMetaFunctionList getProtectedFunctionsThatNeedPromotion(const AbstractMetaClass* cls); - // PythonQt builtins..., dont put them in pri files and dont register them, but generate the code - static bool isBuiltIn(const QString& name); + // PythonQt builtins..., dont put them in pri files and dont register them, but generate the code + static bool isBuiltIn(const QString& name); - static bool isSpecialStreamingOperator(const AbstractMetaFunction *fun); + static bool isSpecialStreamingOperator(const AbstractMetaFunction* fun); - static QString toFileNameBase(QString packageName) { return packageName.replace('.', '_').toLower(); } + static QString toFileNameBase(QString packageName) { return packageName.replace('.', '_').toLower(); } - static void writeInclude(QTextStream &stream, const Include &inc); - - // this scope is used in writeFunctionArguments - const AbstractMetaClass* setCurrentScope(const AbstractMetaClass* scope); - const AbstractMetaClass* currentScope() const { return _currentScope; } + static void writeInclude(QTextStream& stream, const Include& inc); - protected: - PriGenerator* priGenerator{}; + // this scope is used in writeFunctionArguments + const AbstractMetaClass* setCurrentScope(const AbstractMetaClass* scope); + const AbstractMetaClass* currentScope() const { return _currentScope; } - const AbstractMetaClass* _currentScope{}; +protected: + PriGenerator* priGenerator {}; + const AbstractMetaClass* _currentScope {}; }; - #endif // SHELLGENERATOR_H diff --git a/generator/shellheadergenerator.cpp b/generator/shellheadergenerator.cpp index 1ebaf273e..ce8fb6448 100644 --- a/generator/shellheadergenerator.cpp +++ b/generator/shellheadergenerator.cpp @@ -52,24 +52,27 @@ QString ShellHeaderGenerator::fileNameForClass(const AbstractMetaClass* meta_cla return QString("PythonQtWrapper_%1.h").arg(meta_class->name()); } - void ShellHeaderGenerator::writeFieldAccessors(QTextStream& s, const AbstractMetaField* field) { const AbstractMetaFunction* setter = field->setter(); const AbstractMetaFunction* getter = field->getter(); // static fields are not supported (yet?) - if (setter->isStatic()) return; + if (setter->isStatic()) + return; // Uuid data4 did not work (TODO: move to typesystem...( - if (field->enclosingClass()->name() == "QUuid" && setter->name() == "data4") return; - if (field->enclosingClass()->name() == "QIPv6Address") return; + if (field->enclosingClass()->name() == "QUuid" && setter->name() == "data4") + return; + if (field->enclosingClass()->name() == "QIPv6Address") + return; bool isInventorField = field->type()->name().startsWith("So"); if (!isInventorField && !field->type()->isConstant()) { writeFunctionSignature(s, setter, 0, QString(), - Option(ConvertReferenceToPtr | FirstArgIsWrappedObject | IncludeDefaultExpression | ShowStatic | UnderscoreSpaces)); + Option( + ConvertReferenceToPtr | FirstArgIsWrappedObject | IncludeDefaultExpression | ShowStatic | UnderscoreSpaces)); s << "{ theWrappedObject->" << field->name() << " = " << setter->arguments()[0]->argumentName() << "; }\n"; } @@ -109,8 +112,7 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c QString include_block = "PYTHONQTWRAPPER_" + meta_class->name().toUpper() + "_H"; - s << "#ifndef " << include_block << Qt::endl - << "#define " << include_block << Qt::endl << Qt::endl; + s << "#ifndef " << include_block << Qt::endl << "#define " << include_block << Qt::endl << Qt::endl; Include inc = meta_class->typeEntry()->include(); ShellGenerator::writeInclude(s, inc); @@ -120,15 +122,13 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c IncludeList list = meta_class->typeEntry()->extraIncludes(); std::sort(list.begin(), list.end()); - for (const Include & inc : list) { + for (const Include& inc : list) { ShellGenerator::writeInclude(s, inc); } s << Qt::endl; - - AbstractMetaFunctionList ctors = meta_class->queryFunctions(AbstractMetaClass::Constructors - | AbstractMetaClass::WasVisible - | AbstractMetaClass::NotRemovedFromTargetLang); + AbstractMetaFunctionList ctors = meta_class->queryFunctions( + AbstractMetaClass::Constructors | AbstractMetaClass::WasVisible | AbstractMetaClass::NotRemovedFromTargetLang); if (meta_class->qualifiedCppName().contains("Ssl")) { s << "#ifndef QT_NO_SSL" << Qt::endl; @@ -139,10 +139,10 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c AbstractMetaFunctionList virtualsForShell = getVirtualFunctionsForShell(meta_class); - s << "class " << shellClassName(meta_class) - << " : public " << meta_class->qualifiedCppName() << Qt::endl << "{" << Qt::endl; + s << "class " << shellClassName(meta_class) << " : public " << meta_class->qualifiedCppName() << Qt::endl + << "{" << Qt::endl; s << "public:" << Qt::endl; - for (AbstractMetaFunction * fun : ctors) { + for (AbstractMetaFunction* fun : ctors) { s << " "; writeFunctionSignature(s, fun, 0, "PythonQtShell_", Option(IncludeDefaultExpression | ShowStatic | UnderscoreSpaces)); @@ -159,12 +159,12 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c s << "};" << Qt::endl; } s << Qt::endl; - s << " ~" << shellClassName(meta_class) << "()" << (meta_class->hasVirtualDestructor() ? " override" : "") << ";" << Qt::endl; + s << " ~" << shellClassName(meta_class) << "()" << (meta_class->hasVirtualDestructor() ? " override" : "") << ";" + << Qt::endl; s << Qt::endl; - for (AbstractMetaFunction * fun : virtualsForShell) { - writeFunctionSignature(s, fun, 0, QString(), - Option(IncludeDefaultExpression | ShowStatic | UnderscoreSpaces)); + for (AbstractMetaFunction* fun : virtualsForShell) { + writeFunctionSignature(s, fun, 0, QString(), Option(IncludeDefaultExpression | ShowStatic | UnderscoreSpaces)); s << " override;" << Qt::endl; } s << Qt::endl; @@ -185,26 +185,29 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c promoteFunctions = getProtectedFunctionsThatNeedPromotion(meta_class); } if (!promoteFunctions.isEmpty()) { - s << "class " << promoterClassName(meta_class) - << " : public " << meta_class->qualifiedCppName() << Qt::endl << "{ public:" << Qt::endl; + s << "class " << promoterClassName(meta_class) << " : public " << meta_class->qualifiedCppName() << Qt::endl + << "{ public:" << Qt::endl; AbstractMetaEnumList enums1 = meta_class->enums(); std::sort(enums1.begin(), enums1.end(), enum_lessThan); - for (AbstractMetaEnum * enum1 : enums1) { + for (AbstractMetaEnum* enum1 : enums1) { if (enum1->wasProtected()) { s << "enum " << enum1->name() << "{" << Qt::endl; bool first = true; QString scope = meta_class->qualifiedCppName(); - for (AbstractMetaEnumValue * value : enum1->values()) { - if (first) { first = false; } - else { s << ", "; } + for (AbstractMetaEnumValue* value : enum1->values()) { + if (first) { + first = false; + } else { + s << ", "; + } s << " " << value->name() << " = " << scope << "::" << value->name(); } s << "};" << Qt::endl; } } - for (AbstractMetaFunction * fun : promoteFunctions) { + for (AbstractMetaFunction* fun : promoteFunctions) { // normal promoter if (fun->wasProtected()) { if (fun->isStatic()) { @@ -234,7 +237,7 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c } } - for (AbstractMetaFunction * fun : promoteFunctions) { + for (AbstractMetaFunction* fun : promoteFunctions) { // qualified promoter for virtual functions if (fun->isVirtual()) { s << "inline "; @@ -249,8 +252,7 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c if (!fun->isAbstract()) { // call the qualified version, we don't want the virtual function s << meta_class->qualifiedCppName() << "::"; - } - else { + } else { // TODO: this would better be empty and do no call at all... s << "this->"; } @@ -265,9 +267,7 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c // Wrapper------------------------------------------------------------------- - s << "class " << wrapperClassName(meta_class) - << " : public QObject" << Qt::endl - << "{ Q_OBJECT" << Qt::endl; + s << "class " << wrapperClassName(meta_class) << " : public QObject" << Qt::endl << "{ Q_OBJECT" << Qt::endl; s << "public:" << Qt::endl; @@ -275,12 +275,12 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c std::sort(enums1.begin(), enums1.end(), enum_lessThan); AbstractMetaEnumList enums; QList flags; - for (AbstractMetaEnum * enum1 : enums1) { + for (AbstractMetaEnum* enum1 : enums1) { // catch gadgets and enums that are not exported on QObjects... // since we don't parse Q_FLAG(S), we also need to generate for Q_ENUM which might // have a missing Q_FLAG(S) declaration. - if ((enum1->wasProtected() || enum1->wasPublic()) && - (!meta_class->isQObject() || !enum1->hasQEnumsDeclaration() || enum1->typeEntry()->flags())) + if ((enum1->wasProtected() || enum1->wasPublic()) + && (!meta_class->isQObject() || !enum1->hasQEnumsDeclaration() || enum1->typeEntry()->flags())) { enums << enum1; if (enum1->typeEntry()->flags()) { @@ -290,14 +290,14 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c } if (enums.count()) { s << "Q_ENUMS("; - for (AbstractMetaEnum * enum1 : enums) { + for (AbstractMetaEnum* enum1 : enums) { s << enum1->name() << " "; } s << ")" << Qt::endl; if (flags.count()) { s << "Q_FLAGS("; - for (FlagsTypeEntry * flag1 : flags) { + for (FlagsTypeEntry* flag1 : flags) { QString origName = flag1->originalName(); int idx = origName.lastIndexOf("::"); if (idx != -1) { @@ -308,32 +308,34 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c s << ")" << Qt::endl; } - for (AbstractMetaEnum * enum1 : enums) { + for (AbstractMetaEnum* enum1 : enums) { bool isEnumClass = enum1->typeEntry()->isEnumClass(); s << "enum " << (isEnumClass ? "class " : "") << enum1->name() << "{" << Qt::endl; bool first = true; - QString scope = meta_class->isGlobalNamespace() ? QString() : - (enum1->wasProtected() ? promoterClassName(meta_class) : meta_class->qualifiedCppName()); + QString scope = meta_class->isGlobalNamespace() + ? QString() + : (enum1->wasProtected() ? promoterClassName(meta_class) : meta_class->qualifiedCppName()); if (isEnumClass) { scope += "::" + enum1->name(); } - for (AbstractMetaEnumValue * value : enum1->values()) { - if (first) { first = false; } - else { s << ", "; } + for (AbstractMetaEnumValue* value : enum1->values()) { + if (first) { + first = false; + } else { + s << ", "; + } QString assignedValue = scope + "::" + value->name(); if (isEnumClass) { s << " " << value->name() << " = " << "static_cast(" << scope << "::" << value->name() << ")"; - } - else { + } else { s << " " << value->name() << " = " << scope << "::" << value->name(); - } } s << "};" << Qt::endl; } if (flags.count()) { - for (AbstractMetaEnum * enum1 : enums) { + for (AbstractMetaEnum* enum1 : enums) { if (enum1->typeEntry()->flags()) { QString origName = enum1->typeEntry()->flags()->originalName(); int idx = origName.lastIndexOf("::"); @@ -350,14 +352,17 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c bool copyConstructorSeen = false; bool defaultConstructorSeen = false; - for (const AbstractMetaFunction * fun : ctors) { - if (fun->isAbstract() || (!meta_class->generateShellClass() && !fun->isPublic())) { continue; } + for (const AbstractMetaFunction* fun : ctors) { + if (fun->isAbstract() || (!meta_class->generateShellClass() && !fun->isPublic())) { + continue; + } s << meta_class->qualifiedCppName() << "* "; - writeFunctionSignature(s, fun, 0, "new_", - Option(IncludeDefaultExpression | ShowStatic | AddOwnershipTemplates)); + writeFunctionSignature(s, fun, 0, "new_", Option(IncludeDefaultExpression | ShowStatic | AddOwnershipTemplates)); s << ";" << Qt::endl; - if (fun->arguments().size() == 1 && meta_class->qualifiedCppName() == fun->arguments().at(0)->type()->typeEntry()->qualifiedCppName()) { + if (fun->arguments().size() == 1 + && meta_class->qualifiedCppName() == fun->arguments().at(0)->type()->typeEntry()->qualifiedCppName()) + { copyConstructorSeen = true; } if (fun->arguments().size() == 0) { @@ -365,36 +370,41 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c } } - if (meta_class->typeEntry()->isValue() - && !copyConstructorSeen && defaultConstructorSeen && !meta_class->typeEntry()->hasNoCopy()) + if (meta_class->typeEntry()->isValue() && !copyConstructorSeen && defaultConstructorSeen + && !meta_class->typeEntry()->hasNoCopy()) { - QString className = meta_class->generateShellClass() ? shellClassName(meta_class) : meta_class->qualifiedCppName(); - s << meta_class->qualifiedCppName() << "* new_" << meta_class->name() << "(const " << meta_class->qualifiedCppName() << "& other) {" << Qt::endl; + QString className = + meta_class->generateShellClass() ? shellClassName(meta_class) : meta_class->qualifiedCppName(); + s << meta_class->qualifiedCppName() << "* new_" << meta_class->name() << "(const " + << meta_class->qualifiedCppName() << "& other) {" << Qt::endl; s << className << "* a = new " << className << "();" << Qt::endl; s << "*((" << meta_class->qualifiedCppName() << "*)a) = other;" << Qt::endl; s << "return a; }" << Qt::endl; } } if (meta_class->hasPublicDestructor() && !meta_class->isNamespace()) { - s << "void delete_" << meta_class->name() << "(" << meta_class->qualifiedCppName() << "* obj) { delete obj; }" << Qt::endl; + s << "void delete_" << meta_class->name() << "(" << meta_class->qualifiedCppName() << "* obj) { delete obj; }" + << Qt::endl; } AbstractMetaFunctionList functions = getFunctionsToWrap(meta_class); - for (const AbstractMetaFunction * function : functions) { + for (const AbstractMetaFunction* function : functions) { if (functionNeedsNormalWrapperSlot(function, meta_class)) { // for debugging: //functionHasNonConstReferences(function); s << " "; writeFunctionSignature(s, function, 0, QString(), - Option(AddOwnershipTemplates | ConvertReferenceToPtr | FirstArgIsWrappedObject | IncludeDefaultExpression | ShowStatic | UnderscoreSpaces | ProtectedEnumAsInts)); + Option(AddOwnershipTemplates | ConvertReferenceToPtr | FirstArgIsWrappedObject | IncludeDefaultExpression + | ShowStatic | UnderscoreSpaces | ProtectedEnumAsInts)); s << ";" << Qt::endl; } if (function->isVirtual() && meta_class->typeEntry()->shouldCreatePromoter()) { // qualified version that calls the promoter/the qualified version s << " "; writeFunctionSignature(s, function, 0, "py_q_", - Option(AddOwnershipTemplates | ConvertReferenceToPtr | FirstArgIsWrappedObject | IncludeDefaultExpression | ShowStatic | UnderscoreSpaces | ProtectedEnumAsInts)); + Option(AddOwnershipTemplates | ConvertReferenceToPtr | FirstArgIsWrappedObject | IncludeDefaultExpression + | ShowStatic | UnderscoreSpaces | ProtectedEnumAsInts)); s << "{ "; QString scriptFunctionName = function->originalName(); @@ -435,7 +445,7 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c // TODO: move "So" check to typesystem, e.g. allow star in rejection... // Field accessors - for (const AbstractMetaField * field : fields) { + for (const AbstractMetaField* field : fields) { if (field->isPublic()) { writeFieldAccessors(s, field); } @@ -443,7 +453,6 @@ void ShellHeaderGenerator::write(QTextStream& s, const AbstractMetaClass* meta_c writeInjectedCode(s, meta_class, TypeSystem::PyWrapperDeclaration); - s << "};" << Qt::endl << Qt::endl; if (meta_class->qualifiedCppName().contains("Ssl")) { s << "#endif" << Qt::endl << Qt::endl; @@ -470,12 +479,13 @@ void ShellHeaderGenerator::writePromoterArgs(AbstractMetaArgumentList& args, QTe } } -void ShellHeaderGenerator::writeInjectedCode(QTextStream& s, const AbstractMetaClass* meta_class, int type, bool recursive) +void ShellHeaderGenerator::writeInjectedCode(QTextStream& s, const AbstractMetaClass* meta_class, int type, + bool recursive) { const AbstractMetaClass* cls = meta_class; do { CodeSnipList code_snips = cls->typeEntry()->codeSnips(); - for (const CodeSnip & cs : code_snips) { + for (const CodeSnip& cs : code_snips) { if (cs.language == type) { s << cs.code() << Qt::endl; } diff --git a/generator/shellheadergenerator.h b/generator/shellheadergenerator.h index a6590f583..3fea369d2 100644 --- a/generator/shellheadergenerator.h +++ b/generator/shellheadergenerator.h @@ -48,24 +48,24 @@ class ShellHeaderGenerator : public ShellGenerator { - Q_OBJECT + Q_OBJECT public: - ShellHeaderGenerator(PriGenerator *pri, SetupGenerator *setup) - { - priGenerator = pri; - setupGenerator = setup; - } + ShellHeaderGenerator(PriGenerator* pri, SetupGenerator* setup) + { + priGenerator = pri; + setupGenerator = setup; + } - virtual QString fileNameForClass(const AbstractMetaClass *cls) const; + virtual QString fileNameForClass(const AbstractMetaClass* cls) const; - void write(QTextStream &s, const AbstractMetaClass *meta_class); + void write(QTextStream& s, const AbstractMetaClass* meta_class); - void writePromoterArgs(AbstractMetaArgumentList &args, QTextStream & s); + void writePromoterArgs(AbstractMetaArgumentList& args, QTextStream& s); - void writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class, int type, bool recursive = false); + void writeInjectedCode(QTextStream& s, const AbstractMetaClass* meta_class, int type, bool recursive = false); - void writeFieldAccessors(QTextStream &s, const AbstractMetaField *field); + void writeFieldAccessors(QTextStream& s, const AbstractMetaField* field); SetupGenerator* setupGenerator; }; diff --git a/generator/shellimplgenerator.cpp b/generator/shellimplgenerator.cpp index c3272a3c0..2302d650d 100644 --- a/generator/shellimplgenerator.cpp +++ b/generator/shellimplgenerator.cpp @@ -46,11 +46,10 @@ #include "fileout.h" #include -extern void declareFunctionMetaTypes(QTextStream &stream, - const AbstractMetaFunctionList &functions, - QSet ®isteredTypeNames); +extern void declareFunctionMetaTypes(QTextStream& stream, const AbstractMetaFunctionList& functions, + QSet& registeredTypeNames); -QString ShellImplGenerator::fileNameForClass(const AbstractMetaClass *meta_class) const +QString ShellImplGenerator::fileNameForClass(const AbstractMetaClass* meta_class) const { return QString("PythonQtWrapper_%1.cpp").arg(meta_class->name()); } @@ -62,21 +61,17 @@ static bool include_less_than(const Include &a, const Include &b) } */ -static void writeHelperCode(QTextStream &, const AbstractMetaClass *) -{ -} - - +static void writeHelperCode(QTextStream&, const AbstractMetaClass*) {} -void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_class) +void ShellImplGenerator::write(QTextStream& s, const AbstractMetaClass* meta_class) { setCurrentScope(meta_class); - QString builtIn = ShellGenerator::isBuiltIn(meta_class->name())?"_builtin":""; + QString builtIn = ShellGenerator::isBuiltIn(meta_class->name()) ? "_builtin" : ""; QString fileBaseName = toFileNameBase(meta_class->package() + builtIn); QString pro_file_name = fileBaseName + "/" + fileBaseName + ".pri"; priGenerator->addSource(pro_file_name, fileNameForClass(meta_class)); - + s << "#include \"PythonQtWrapper_" << meta_class->name() << ".h\"" << Qt::endl << Qt::endl; s << "#include " << Qt::endl; @@ -90,16 +85,15 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla std::sort(list.begin(), list.end()); for (const Include& inc : list) { ShellGenerator::writeInclude(s, inc); - } + } s << Qt::endl; writeHelperCode(s, meta_class); // find constructors AbstractMetaFunctionList ctors; - ctors = meta_class->queryFunctions(AbstractMetaClass::Constructors - | AbstractMetaClass::WasVisible - | AbstractMetaClass::NotRemovedFromTargetLang); + ctors = meta_class->queryFunctions( + AbstractMetaClass::Constructors | AbstractMetaClass::WasVisible | AbstractMetaClass::NotRemovedFromTargetLang); // find member functions AbstractMetaFunctionList functions = getFunctionsToWrap(meta_class); @@ -110,7 +104,7 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla // s << Qt::endl; } if (meta_class->qualifiedCppName().contains("Ssl")) { - s << "#ifndef QT_NO_SSL" << Qt::endl; + s << "#ifndef QT_NO_SSL" << Qt::endl; } bool generateShell = meta_class->generateShellClass() && !ctors.isEmpty(); @@ -124,8 +118,7 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla AbstractMetaFunctionList virtualsForShell = getVirtualFunctionsForShell(meta_class); for (const AbstractMetaFunction* fun : virtualsForShell) { bool hasReturnValue = !fun->type().isNull(); - writeFunctionSignature(s, fun, meta_class, QString(), - Option(ShowStatic | UnderscoreSpaces | UseIndexedName), + writeFunctionSignature(s, fun, meta_class, QString(), Option(ShowStatic | UnderscoreSpaces | UseIndexedName), "PythonQtShell_"); s << Qt::endl << "{" << Qt::endl; @@ -153,7 +146,9 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla s << "\""; } s << "};" << Qt::endl; - s << " static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(" << QString::number(args.size() + 1) << ", argumentList);" << Qt::endl; + s << " static const PythonQtMethodInfo* methodInfo = " + "PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(" + << QString::number(args.size() + 1) << ", argumentList);" << Qt::endl; if (hasReturnValue) { s << " "; @@ -169,10 +164,13 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla s << " PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);" << Qt::endl; if (hasReturnValue) { s << " if (result) {" << Qt::endl; - s << " args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, nullptr, &returnValue);" << Qt::endl; + s << " args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, " + "nullptr, &returnValue);" + << Qt::endl; s << " if (args[0]!=&returnValue) {" << Qt::endl; s << " if (args[0]==nullptr) {" << Qt::endl; - s << " PythonQt::priv()->handleVirtualOverloadReturnError(\"" << fun->name() << "\", methodInfo, result);" << Qt::endl; + s << " PythonQt::priv()->handleVirtualOverloadReturnError(\"" << fun->name() + << "\", methodInfo, result);" << Qt::endl; s << " } else {" << Qt::endl; s << " returnValue = *(("; writeTypeInfo(s, fun->type(), typeOptions); @@ -185,14 +183,13 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla s << " Py_DECREF(obj);" << Qt::endl; // ugly hack, we don't support QGraphicsScene* nor QGraphicsItem* QVariants in PythonQt... if (fun->name() == "itemChange" && fun->type() && fun->type()->isVariant()) { - s << " if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) {\n"; - s << " returnValue = value1;\n"; - s << " } \n"; + s << " if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) {\n"; + s << " returnValue = value1;\n"; + s << " } \n"; } if (hasReturnValue) { s << " return returnValue;" << Qt::endl; - } - else { + } else { s << " return;" << Qt::endl; } s << " } else {" << Qt::endl; @@ -206,7 +203,7 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla if (fun->type()) { // return empty default object s << "return "; - if (fun->type()->indirections()>0) { + if (fun->type()->indirections() > 0) { s << "nullptr;"; } else { writeTypeInfo(s, fun->type(), typeOptions); @@ -235,14 +232,17 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla // write constructors for (const AbstractMetaFunction* ctor : ctors) { - if (ctor->isAbstract() || (!meta_class->generateShellClass() && !ctor->isPublic())) { continue; } + if (ctor->isAbstract() || (!meta_class->generateShellClass() && !ctor->isPublic())) { + continue; + } s << meta_class->qualifiedCppName() << "* "; s << "PythonQtWrapper_" << meta_class->name() << "::"; writeFunctionSignature(s, ctor, 0, "new_", Option(AddOwnershipTemplates | ShowStatic)); s << Qt::endl; s << "{ " << Qt::endl; - s << "return new " << (meta_class->generateShellClass()?shellClassName(meta_class):meta_class->qualifiedCppName()) << "("; + s << "return new " + << (meta_class->generateShellClass() ? shellClassName(meta_class) : meta_class->qualifiedCppName()) << "("; AbstractMetaArgumentList args = ctor->arguments(); for (int i = 0; i < args.size(); ++i) { if (i > 0) @@ -258,30 +258,33 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla s << " if (QObject::d_ptr->metaObject) {" << Qt::endl; s << " return QObject::d_ptr->dynamicMetaObject();" << Qt::endl; s << " } else if (_wrapper) {" << Qt::endl; - s << " return PythonQt::priv()->getDynamicMetaObject(_wrapper, &" << meta_class->qualifiedCppName() << "::staticMetaObject);" << Qt::endl; + s << " return PythonQt::priv()->getDynamicMetaObject(_wrapper, &" << meta_class->qualifiedCppName() + << "::staticMetaObject);" << Qt::endl; s << " } else {" << Qt::endl; s << " return &" << meta_class->qualifiedCppName() << "::staticMetaObject;" << Qt::endl; s << " }" << Qt::endl; s << "}" << Qt::endl; - s << "int " << shellClassName(meta_class) << "::qt_metacall(QMetaObject::Call call, int id, void** args) {" << Qt::endl; + s << "int " << shellClassName(meta_class) << "::qt_metacall(QMetaObject::Call call, int id, void** args) {" + << Qt::endl; s << " int result = " << meta_class->qualifiedCppName() << "::qt_metacall(call, id, args);" << Qt::endl; - s << " return result >= 0 ? PythonQt::priv()->handleMetaCall(this, _wrapper, call, id, args) : result;" << Qt::endl; + s << " return result >= 0 ? PythonQt::priv()->handleMetaCall(this, _wrapper, call, id, args) : result;" + << Qt::endl; s << "}" << Qt::endl; - } QString wrappedObject = " (*theWrappedObject)"; // write member functions for (int i = 0; i < functions.size(); ++i) { - AbstractMetaFunction *fun = functions.at(i); + AbstractMetaFunction* fun = functions.at(i); bool needsWrapping = functionNeedsNormalWrapperSlot(fun, meta_class); if (!needsWrapping) { continue; } writeFunctionSignature(s, fun, meta_class, QString(), - Option(AddOwnershipTemplates | ConvertReferenceToPtr | FirstArgIsWrappedObject | ShowStatic | UnderscoreSpaces | ProtectedEnumAsInts), + Option(AddOwnershipTemplates | ConvertReferenceToPtr | FirstArgIsWrappedObject | ShowStatic | UnderscoreSpaces + | ProtectedEnumAsInts), "PythonQtWrapper_"); s << Qt::endl << "{" << Qt::endl; s << " "; @@ -311,11 +314,12 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla s << wrappedObject << " <<" << args.at(0)->argumentName(); } else if (scriptFunctionName.startsWith("operator[]") && !fun->wasProtected()) { s << wrappedObject << "[" << args.at(0)->argumentName() << "]"; - } else if (scriptFunctionName.startsWith("operator") && args.size()==1 && !fun->wasProtected()) { + } else if (scriptFunctionName.startsWith("operator") && args.size() == 1 && !fun->wasProtected()) { QString op = scriptFunctionName.mid(8); s << wrappedObject << op << " " << args.at(0)->argumentName(); - } - else if (scriptFunctionName.startsWith("operator") && args.size() == 0 && scriptFunctionName.length() == 9 && !fun->wasProtected()) { + } else if (scriptFunctionName.startsWith("operator") && args.size() == 0 && scriptFunctionName.length() == 9 + && !fun->wasProtected()) + { // only the unary operators consisting of one char can be applied by prepending the operator... QString op = scriptFunctionName.mid(8); // unary operator @@ -330,7 +334,7 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla } else { if (fun->wasProtected()) { //|| (fun->isVirtual() && meta_class->typeEntry()->shouldCreatePromoter())) { - s << " ((" << promoterClassName(meta_class) << "*)theWrappedObject)->promoted_"; + s << " ((" << promoterClassName(meta_class) << "*)theWrappedObject)->promoted_"; } else { s << " theWrappedObject->"; } @@ -338,8 +342,7 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla if (fun->wasProtected()) { // this is different e.g. for operators s << fun->name() << "("; - } - else { + } else { s << fun->originalName() << "("; } for (int i = 0; i < args.size(); ++i) { @@ -357,15 +360,17 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla } if (meta_class->hasDefaultToStringFunction()) { - s << "QString PythonQtWrapper_" << meta_class->name() << "::py_toString(" << meta_class->qualifiedCppName() << "* obj) { return obj->toString(); }" << Qt::endl; + s << "QString PythonQtWrapper_" << meta_class->name() << "::py_toString(" << meta_class->qualifiedCppName() + << "* obj) { return obj->toString(); }" << Qt::endl; } else if (meta_class->hasToStringCapability()) { FunctionModelItem fun = meta_class->hasToStringCapability(); int indirections = fun->arguments().at(1)->type().indirections(); QString deref = QLatin1String(indirections == 0 ? "*" : ""); - s << "QString PythonQtWrapper_" << meta_class->name() << "::py_toString(" << meta_class->qualifiedCppName() << "* obj) {" << Qt::endl; + s << "QString PythonQtWrapper_" << meta_class->name() << "::py_toString(" << meta_class->qualifiedCppName() + << "* obj) {" << Qt::endl; s << " QString result;" << Qt::endl; s << " QDebug d(&result);" << Qt::endl; - s << " d << " << deref << "obj;" << Qt::endl; + s << " d << " << deref << "obj;" << Qt::endl; s << " return result;" << Qt::endl; s << "}" << Qt::endl << Qt::endl; } @@ -373,13 +378,13 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla writeInjectedCode(s, meta_class); if (meta_class->qualifiedCppName().contains("Ssl")) { - s << "#endif" << Qt::endl; + s << "#endif" << Qt::endl; } setCurrentScope(nullptr); } -void ShellImplGenerator::writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class) +void ShellImplGenerator::writeInjectedCode(QTextStream& s, const AbstractMetaClass* meta_class) { CodeSnipList code_snips = meta_class->typeEntry()->codeSnips(); for (const CodeSnip& cs : code_snips) { diff --git a/generator/shellimplgenerator.h b/generator/shellimplgenerator.h index c2fc7c60f..67b4ce352 100644 --- a/generator/shellimplgenerator.h +++ b/generator/shellimplgenerator.h @@ -47,19 +47,15 @@ class ShellImplGenerator : public ShellGenerator { - Q_OBJECT + Q_OBJECT public: - ShellImplGenerator(PriGenerator *pri) - { - priGenerator = pri; - } + ShellImplGenerator(PriGenerator* pri) { priGenerator = pri; } - virtual QString fileNameForClass(const AbstractMetaClass *cls) const; - - void write(QTextStream &s, const AbstractMetaClass *meta_class); - void writeInjectedCode(QTextStream &s, const AbstractMetaClass *meta_class); + virtual QString fileNameForClass(const AbstractMetaClass* cls) const; + void write(QTextStream& s, const AbstractMetaClass* meta_class); + void writeInjectedCode(QTextStream& s, const AbstractMetaClass* meta_class); }; #endif // SHELLIMPLGENERATOR_H diff --git a/generator/typeparser.cpp b/generator/typeparser.cpp index 5d70cc1bb..859c04f61 100644 --- a/generator/typeparser.cpp +++ b/generator/typeparser.cpp @@ -47,248 +47,264 @@ class Scanner { public: - enum Token { - StarToken, - AmpersandToken, - LessThanToken, - ColonToken, - CommaToken, - EllipsisToken, - OpenParenToken, - CloseParenToken, - SquareBegin, - SquareEnd, - GreaterThanToken, - - ConstToken, - Identifier, - NoToken - }; - - Scanner(const QString &s) - : m_pos(0), m_length(s.length()), m_chars(s.constData()) - { - } - - Token nextToken(); - QString identifier() const; + enum Token { + StarToken, + AmpersandToken, + LessThanToken, + ColonToken, + CommaToken, + EllipsisToken, + OpenParenToken, + CloseParenToken, + SquareBegin, + SquareEnd, + GreaterThanToken, + + ConstToken, + Identifier, + NoToken + }; + + Scanner(const QString& s) + : m_pos(0) + , m_length(s.length()) + , m_chars(s.constData()) + { + } + + Token nextToken(); + QString identifier() const; private: - int m_pos; - int m_length; - int m_token_start; - const QChar *m_chars; + int m_pos; + int m_length; + int m_token_start; + const QChar* m_chars; }; QString Scanner::identifier() const { - return QString(m_chars + m_token_start, m_pos - m_token_start); + return QString(m_chars + m_token_start, m_pos - m_token_start); } Scanner::Token Scanner::nextToken() { - Token tok = NoToken; - - // remove whitespace - while (m_pos < m_length && m_chars[m_pos] == ' ') { + Token tok = NoToken; + + // remove whitespace + while (m_pos < m_length && m_chars[m_pos] == ' ') { + ++m_pos; + } + + m_token_start = m_pos; + + while (m_pos < m_length) { + + const QChar& c = m_chars[m_pos]; + + if (tok == NoToken) { + switch (c.toLatin1()) { + case '*': + tok = StarToken; + break; + case '&': + tok = AmpersandToken; + break; + case '<': + tok = LessThanToken; + break; + case '>': + tok = GreaterThanToken; + break; + case ',': + tok = CommaToken; + break; + case '(': + tok = OpenParenToken; + break; + case ')': + tok = CloseParenToken; + break; + case '[': + tok = SquareBegin; + break; + case ']': + tok = SquareEnd; + break; + case ':': + tok = ColonToken; + Q_ASSERT(m_pos + 1 < m_length); ++m_pos; - } - - m_token_start = m_pos; - - while (m_pos < m_length) { - - const QChar &c = m_chars[m_pos]; - - if (tok == NoToken) { - switch (c.toLatin1()) { - case '*': tok = StarToken; break; - case '&': tok = AmpersandToken; break; - case '<': tok = LessThanToken; break; - case '>': tok = GreaterThanToken; break; - case ',': tok = CommaToken; break; - case '(': tok = OpenParenToken; break; - case ')': tok = CloseParenToken; break; - case '[': tok = SquareBegin; break; - case ']' : tok = SquareEnd; break; - case ':': - tok = ColonToken; - Q_ASSERT(m_pos + 1 < m_length); - ++m_pos; - break; - case '.': - if (m_pos + 2 < m_length && c == m_chars[m_pos + 1] && c == m_chars[m_pos + 2]) { - tok = EllipsisToken; - m_pos += 2; - break; - } - Q_FALLTHROUGH(); - default: - if (c.isLetterOrNumber() || c == '_') - tok = Identifier; - else - qFatal("Unrecognized character in lexer: %c", c.toLatin1()); - break; - } - } - - if (tok <= GreaterThanToken) { - ++m_pos; - break; + break; + case '.': + if (m_pos + 2 < m_length && c == m_chars[m_pos + 1] && c == m_chars[m_pos + 2]) { + tok = EllipsisToken; + m_pos += 2; + break; } + Q_FALLTHROUGH(); + default: + if (c.isLetterOrNumber() || c == '_') + tok = Identifier; + else + qFatal("Unrecognized character in lexer: %c", c.toLatin1()); + break; + } + } - if (tok == Identifier) { - if (c.isLetterOrNumber() || c == '_') - ++m_pos; - else - break; - } + if (tok <= GreaterThanToken) { + ++m_pos; + break; } - if (tok == Identifier && m_pos - m_token_start == 5) { - if (m_chars[m_token_start] == 'c' - && m_chars[m_token_start + 1] == 'o' - && m_chars[m_token_start + 2] == 'n' - && m_chars[m_token_start + 3] == 's' - && m_chars[m_token_start + 4] == 't') - tok = ConstToken; + if (tok == Identifier) { + if (c.isLetterOrNumber() || c == '_') + ++m_pos; + else + break; } + } - return tok; + if (tok == Identifier && m_pos - m_token_start == 5) { + if (m_chars[m_token_start] == 'c' && m_chars[m_token_start + 1] == 'o' && m_chars[m_token_start + 2] == 'n' + && m_chars[m_token_start + 3] == 's' && m_chars[m_token_start + 4] == 't') + tok = ConstToken; + } + return tok; } -TypeParser::Info TypeParser::parse(const QString &str) +TypeParser::Info TypeParser::parse(const QString& str) { - Scanner scanner(str); - - Info info; - QStack stack; - stack.push(&info); - - bool colon_prefix = false; - bool in_array = false; - QString array; - - Scanner::Token tok = scanner.nextToken(); - while (tok != Scanner::NoToken) { - -// switch (tok) { -// case Scanner::StarToken: printf(" - *\n"); break; -// case Scanner::AmpersandToken: printf(" - &\n"); break; -// case Scanner::EllipsisToken: printf(" - ...\n"); break; -// case Scanner::LessThanToken: printf(" - <\n"); break; -// case Scanner::GreaterThanToken: printf(" - >\n"); break; -// case Scanner::ColonToken: printf(" - ::\n"); break; -// case Scanner::CommaToken: printf(" - ,\n"); break; -// case Scanner::ConstToken: printf(" - const\n"); break; -// case Scanner::SquareBegin: printf(" - [\n"); break; -// case Scanner::SquareEnd: printf(" - ]\n"); break; -// case Scanner::Identifier: printf(" - '%s'\n", qPrintable(scanner.identifier())); break; -// default: -// break; -// } - - switch (tok) { - - case Scanner::StarToken: - ++stack.top()->indirections; - break; - - case Scanner::AmpersandToken: - stack.top()->is_reference = true; - break; - - case Scanner::LessThanToken: - stack.top()->template_instantiations << Info(); - stack.push(&stack.top()->template_instantiations.last()); - break; - - case Scanner::CommaToken: - stack.pop(); - stack.top()->template_instantiations << Info(); - stack.push(&stack.top()->template_instantiations.last()); - break; - - case Scanner::GreaterThanToken: - stack.pop(); - break; - - case Scanner::ColonToken: - colon_prefix = true; - break; - - case Scanner::ConstToken: - stack.top()->is_constant = true; - break; - - case Scanner::OpenParenToken: // function pointers not supported - case Scanner::CloseParenToken: - case Scanner::EllipsisToken: // variadic templates not supported - { - Info i; - i.is_busted = true; - return i; - } - - - case Scanner::Identifier: - if (in_array) { - array = scanner.identifier(); - } else if (colon_prefix || stack.top()->qualified_name.isEmpty()) { - stack.top()->qualified_name << scanner.identifier(); - colon_prefix = false; - } else { - stack.top()->qualified_name.last().append(" " + scanner.identifier()); - } - break; - - case Scanner::SquareBegin: - in_array = true; - break; - - case Scanner::SquareEnd: - in_array = false; - stack.top()->arrays += array; - break; - - - default: - break; - } + Scanner scanner(str); + + Info info; + QStack stack; + stack.push(&info); + + bool colon_prefix = false; + bool in_array = false; + QString array; + + Scanner::Token tok = scanner.nextToken(); + while (tok != Scanner::NoToken) { + + // switch (tok) { + // case Scanner::StarToken: printf(" - *\n"); break; + // case Scanner::AmpersandToken: printf(" - &\n"); break; + // case Scanner::EllipsisToken: printf(" - ...\n"); break; + // case Scanner::LessThanToken: printf(" - <\n"); break; + // case Scanner::GreaterThanToken: printf(" - >\n"); break; + // case Scanner::ColonToken: printf(" - ::\n"); break; + // case Scanner::CommaToken: printf(" - ,\n"); break; + // case Scanner::ConstToken: printf(" - const\n"); break; + // case Scanner::SquareBegin: printf(" - [\n"); break; + // case Scanner::SquareEnd: printf(" - ]\n"); break; + // case Scanner::Identifier: printf(" - '%s'\n", qPrintable(scanner.identifier())); break; + // default: + // break; + // } + + switch (tok) { + + case Scanner::StarToken: + ++stack.top()->indirections; + break; + + case Scanner::AmpersandToken: + stack.top()->is_reference = true; + break; + + case Scanner::LessThanToken: + stack.top()->template_instantiations << Info(); + stack.push(&stack.top()->template_instantiations.last()); + break; + + case Scanner::CommaToken: + stack.pop(); + stack.top()->template_instantiations << Info(); + stack.push(&stack.top()->template_instantiations.last()); + break; + + case Scanner::GreaterThanToken: + stack.pop(); + break; + + case Scanner::ColonToken: + colon_prefix = true; + break; + + case Scanner::ConstToken: + stack.top()->is_constant = true; + break; + + case Scanner::OpenParenToken: // function pointers not supported + case Scanner::CloseParenToken: + case Scanner::EllipsisToken: // variadic templates not supported + { + Info i; + i.is_busted = true; + return i; + } - tok = scanner.nextToken(); + case Scanner::Identifier: + if (in_array) { + array = scanner.identifier(); + } else if (colon_prefix || stack.top()->qualified_name.isEmpty()) { + stack.top()->qualified_name << scanner.identifier(); + colon_prefix = false; + } else { + stack.top()->qualified_name.last().append(" " + scanner.identifier()); + } + break; + + case Scanner::SquareBegin: + in_array = true; + break; + + case Scanner::SquareEnd: + in_array = false; + stack.top()->arrays += array; + break; + + default: + break; } - return info; + tok = scanner.nextToken(); + } + + return info; } QString TypeParser::Info::instantiationName() const { - QString s(qualified_name.join("::")); - if (!template_instantiations.isEmpty()) { - s += '<'; - for (int i=0; i template_instantiations; // I believe template_argument_types would be a better name - uint is_reference : 1; - uint is_constant : 1; - uint is_busted : 1; - uint indirections : 5; + } + QStringList qualified_name; + QStringList arrays; + QList template_instantiations; // I believe template_argument_types would be a better name + uint is_reference: 1; + uint is_constant: 1; + uint is_busted: 1; + uint indirections: 5; - QString toString() const; - QString instantiationName() const; - }; + QString toString() const; + QString instantiationName() const; + }; - static Info parse(const QString &str); + static Info parse(const QString& str); }; #endif // TYPEPARSER_H diff --git a/generator/typesystem.cpp b/generator/typesystem.cpp index 11b82f666..a1f7f756d 100644 --- a/generator/typesystem.cpp +++ b/generator/typesystem.cpp @@ -61,460 +61,461 @@ QString strings_java_lang = QLatin1String("java.lang"); QString strings_jchar = QLatin1String("jchar"); QString strings_jobject = QLatin1String("jobject"); -static void addRemoveFunctionToTemplates(TypeDatabase *db); +static void addRemoveFunctionToTemplates(TypeDatabase* db); class StackElement { - public: - enum ElementType { - None = 0x0, - - // Type tags (0x1, ... , 0xff) - ObjectTypeEntry = 0x1, - ValueTypeEntry = 0x2, - InterfaceTypeEntry = 0x3, - NamespaceTypeEntry = 0x4, - ComplexTypeEntryMask = 0xf, - - // Non-complex type tags (0x10, 0x20, ... , 0xf0) - PrimitiveTypeEntry = 0x10, - EnumTypeEntry = 0x20, - TypeEntryMask = 0xff, - - // Simple tags (0x100, 0x200, ... , 0xf00) - ExtraIncludes = 0x100, - Include = 0x200, - ModifyFunction = 0x300, - ModifyField = 0x400, - Root = 0x500, - CustomMetaConstructor = 0x600, - CustomMetaDestructor = 0x700, - ArgumentMap = 0x800, - SuppressedWarning = 0x900, - Rejection = 0xa00, - LoadTypesystem = 0xb00, - RejectEnumValue = 0xc00, - Template = 0xd00, - TemplateInstanceEnum = 0xe00, - Replace = 0xf00, - SimpleMask = 0xf00, - - // Code snip tags (0x1000, 0x2000, ... , 0xf000) - InjectCode = 0x1000, - InjectCodeInFunction = 0x2000, - CodeSnipMask = 0xf000, - - // Function modifier tags (0x010000, 0x020000, ... , 0xf00000) - Access = 0x010000, - Removal = 0x020000, - Rename = 0x040000, - ModifyArgument = 0x080000, - FunctionModifiers = 0xff0000, - - // Argument modifier tags (0x01000000 ... 0xf0000000) - ConversionRule = 0x01000000, - ReplaceType = 0x02000000, - ReplaceDefaultExpression = 0x04000000, - RemoveArgument = 0x08000000, - DefineOwnership = 0x10000000, - RemoveDefaultExpression = 0x20000000, - NoNullPointers = 0x40000000, - ReferenceCount = 0x80000000, - ArgumentModifiers = 0xff000000 - }; - - StackElement(StackElement *p) : entry(0), type(None), parent(p){ } +public: + enum ElementType { + None = 0x0, + + // Type tags (0x1, ... , 0xff) + ObjectTypeEntry = 0x1, + ValueTypeEntry = 0x2, + InterfaceTypeEntry = 0x3, + NamespaceTypeEntry = 0x4, + ComplexTypeEntryMask = 0xf, + + // Non-complex type tags (0x10, 0x20, ... , 0xf0) + PrimitiveTypeEntry = 0x10, + EnumTypeEntry = 0x20, + TypeEntryMask = 0xff, + + // Simple tags (0x100, 0x200, ... , 0xf00) + ExtraIncludes = 0x100, + Include = 0x200, + ModifyFunction = 0x300, + ModifyField = 0x400, + Root = 0x500, + CustomMetaConstructor = 0x600, + CustomMetaDestructor = 0x700, + ArgumentMap = 0x800, + SuppressedWarning = 0x900, + Rejection = 0xa00, + LoadTypesystem = 0xb00, + RejectEnumValue = 0xc00, + Template = 0xd00, + TemplateInstanceEnum = 0xe00, + Replace = 0xf00, + SimpleMask = 0xf00, + + // Code snip tags (0x1000, 0x2000, ... , 0xf000) + InjectCode = 0x1000, + InjectCodeInFunction = 0x2000, + CodeSnipMask = 0xf000, + + // Function modifier tags (0x010000, 0x020000, ... , 0xf00000) + Access = 0x010000, + Removal = 0x020000, + Rename = 0x040000, + ModifyArgument = 0x080000, + FunctionModifiers = 0xff0000, + + // Argument modifier tags (0x01000000 ... 0xf0000000) + ConversionRule = 0x01000000, + ReplaceType = 0x02000000, + ReplaceDefaultExpression = 0x04000000, + RemoveArgument = 0x08000000, + DefineOwnership = 0x10000000, + RemoveDefaultExpression = 0x20000000, + NoNullPointers = 0x40000000, + ReferenceCount = 0x80000000, + ArgumentModifiers = 0xff000000 + }; + + StackElement(StackElement* p) + : entry(0) + , type(None) + , parent(p) + { + } - TypeEntry *entry; - ElementType type; - StackElement *parent; + TypeEntry* entry; + ElementType type; + StackElement* parent; - union { - TemplateInstance *templateInstance; - TemplateEntry *templateEntry; - CustomFunction *customFunction; - } value; + union { + TemplateInstance* templateInstance; + TemplateEntry* templateEntry; + CustomFunction* customFunction; + } value; }; class Handler { public: - class Attributes + class Attributes + { + public: + Attributes() = default; + explicit Attributes(const QXmlStreamAttributes& attributes) + : m_attributes(attributes) { - public: - Attributes() = default; - explicit Attributes(const QXmlStreamAttributes &attributes) - : m_attributes(attributes) {} - - int length() const { return m_attributes.size(); } - - QString localName(int index) const - { - return m_attributes.at(index).name().toString(); - } + } - QString value(int index) const - { - return m_attributes.at(index).value().toString(); - } + int length() const { return m_attributes.size(); } - QString value(const QString &qualifiedName) const - { - return m_attributes.hasAttribute(qualifiedName) - ? m_attributes.value(qualifiedName).toString() - : QString(); - } + QString localName(int index) const { return m_attributes.at(index).name().toString(); } - int index(const QString &qualifiedName) const - { - for (int i = 0; i < m_attributes.size(); ++i) { - if (m_attributes.at(i).name().toString() == qualifiedName) - return i; - } - return -1; - } + QString value(int index) const { return m_attributes.at(index).value().toString(); } - private: - QXmlStreamAttributes m_attributes; - }; + QString value(const QString& qualifiedName) const + { + return m_attributes.hasAttribute(qualifiedName) ? m_attributes.value(qualifiedName).toString() : QString(); + } - Handler(TypeDatabase *database, unsigned int qtVersion, bool generate) - : m_database(database) - , m_generate(generate ? TypeEntry::GenerateAll : TypeEntry::GenerateForSubclass) - , m_qtVersion(qtVersion) + int index(const QString& qualifiedName) const { - m_current_enum = 0; - current = 0; - - tagNames["rejection"] = StackElement::Rejection; - tagNames["primitive-type"] = StackElement::PrimitiveTypeEntry; - tagNames["object-type"] = StackElement::ObjectTypeEntry; - tagNames["value-type"] = StackElement::ValueTypeEntry; - tagNames["interface-type"] = StackElement::InterfaceTypeEntry; - tagNames["namespace-type"] = StackElement::NamespaceTypeEntry; - tagNames["enum-type"] = StackElement::EnumTypeEntry; - tagNames["extra-includes"] = StackElement::ExtraIncludes; - tagNames["include"] = StackElement::Include; - tagNames["inject-code"] = StackElement::InjectCode; - tagNames["modify-function"] = StackElement::ModifyFunction; - tagNames["modify-field"] = StackElement::ModifyField; - tagNames["access"] = StackElement::Access; - tagNames["remove"] = StackElement::Removal; - tagNames["rename"] = StackElement::Rename; - tagNames["typesystem"] = StackElement::Root; - tagNames["custom-constructor"] = StackElement::CustomMetaConstructor; - tagNames["custom-destructor"] = StackElement::CustomMetaDestructor; - tagNames["argument-map"] = StackElement::ArgumentMap; - tagNames["suppress-warning"] = StackElement::SuppressedWarning; - tagNames["load-typesystem"] = StackElement::LoadTypesystem; - tagNames["define-ownership"] = StackElement::DefineOwnership; - tagNames["replace-default-expression"] = StackElement::ReplaceDefaultExpression; - tagNames["reject-enum-value"] = StackElement::RejectEnumValue; - tagNames["replace-type"] = StackElement::ReplaceType; - tagNames["conversion-rule"] = StackElement::ConversionRule; - tagNames["modify-argument"] = StackElement::ModifyArgument; - tagNames["remove-argument"] = StackElement::RemoveArgument; - tagNames["remove-default-expression"] = StackElement::RemoveDefaultExpression; - tagNames["template"] = StackElement::Template; - tagNames["insert-template"] = StackElement::TemplateInstanceEnum; - tagNames["replace"] = StackElement::Replace; - tagNames["no-null-pointer"] = StackElement::NoNullPointers; - tagNames["reference-count"] = StackElement::ReferenceCount; + for (int i = 0; i < m_attributes.size(); ++i) { + if (m_attributes.at(i).name().toString() == qualifiedName) + return i; + } + return -1; } - bool parse(QXmlStreamReader &reader); - bool startDocument() { m_nestingLevel = 0; m_disabledLevel = -1; return true; } - bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const Attributes &atts); - bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName); + private: + QXmlStreamAttributes m_attributes; + }; + + Handler(TypeDatabase* database, unsigned int qtVersion, bool generate) + : m_database(database) + , m_generate(generate ? TypeEntry::GenerateAll : TypeEntry::GenerateForSubclass) + , m_qtVersion(qtVersion) + { + m_current_enum = 0; + current = 0; + + tagNames["rejection"] = StackElement::Rejection; + tagNames["primitive-type"] = StackElement::PrimitiveTypeEntry; + tagNames["object-type"] = StackElement::ObjectTypeEntry; + tagNames["value-type"] = StackElement::ValueTypeEntry; + tagNames["interface-type"] = StackElement::InterfaceTypeEntry; + tagNames["namespace-type"] = StackElement::NamespaceTypeEntry; + tagNames["enum-type"] = StackElement::EnumTypeEntry; + tagNames["extra-includes"] = StackElement::ExtraIncludes; + tagNames["include"] = StackElement::Include; + tagNames["inject-code"] = StackElement::InjectCode; + tagNames["modify-function"] = StackElement::ModifyFunction; + tagNames["modify-field"] = StackElement::ModifyField; + tagNames["access"] = StackElement::Access; + tagNames["remove"] = StackElement::Removal; + tagNames["rename"] = StackElement::Rename; + tagNames["typesystem"] = StackElement::Root; + tagNames["custom-constructor"] = StackElement::CustomMetaConstructor; + tagNames["custom-destructor"] = StackElement::CustomMetaDestructor; + tagNames["argument-map"] = StackElement::ArgumentMap; + tagNames["suppress-warning"] = StackElement::SuppressedWarning; + tagNames["load-typesystem"] = StackElement::LoadTypesystem; + tagNames["define-ownership"] = StackElement::DefineOwnership; + tagNames["replace-default-expression"] = StackElement::ReplaceDefaultExpression; + tagNames["reject-enum-value"] = StackElement::RejectEnumValue; + tagNames["replace-type"] = StackElement::ReplaceType; + tagNames["conversion-rule"] = StackElement::ConversionRule; + tagNames["modify-argument"] = StackElement::ModifyArgument; + tagNames["remove-argument"] = StackElement::RemoveArgument; + tagNames["remove-default-expression"] = StackElement::RemoveDefaultExpression; + tagNames["template"] = StackElement::Template; + tagNames["insert-template"] = StackElement::TemplateInstanceEnum; + tagNames["replace"] = StackElement::Replace; + tagNames["no-null-pointer"] = StackElement::NoNullPointers; + tagNames["reference-count"] = StackElement::ReferenceCount; + } - QString errorString() const { return m_error; } + bool parse(QXmlStreamReader& reader); + bool startDocument() + { + m_nestingLevel = 0; + m_disabledLevel = -1; + return true; + } + bool startElement(const QString& namespaceURI, const QString& localName, const QString& qName, + const Attributes& atts); + bool endElement(const QString& namespaceURI, const QString& localName, const QString& qName); - bool characters(const QString &ch); + QString errorString() const { return m_error; } + + bool characters(const QString& ch); private: - void fetchAttributeValues(const QString &name, const Attributes &atts, - QHash *acceptedAttributes); + void fetchAttributeValues(const QString& name, const Attributes& atts, QHash* acceptedAttributes); - bool importFileElement(const Attributes &atts); - bool convertBoolean(const QString &, const QString &, bool); - bool qtVersionMatches(const Attributes& atts, bool& ok); + bool importFileElement(const Attributes& atts); + bool convertBoolean(const QString&, const QString&, bool); + bool qtVersionMatches(const Attributes& atts, bool& ok); - TypeDatabase *m_database; - StackElement* current; - QString m_defaultPackage; - QString m_defaultSuperclass; - QString m_error; - TypeEntry::CodeGeneration m_generate; + TypeDatabase* m_database; + StackElement* current; + QString m_defaultPackage; + QString m_defaultSuperclass; + QString m_error; + TypeEntry::CodeGeneration m_generate; - EnumTypeEntry *m_current_enum; + EnumTypeEntry* m_current_enum; - CodeSnipList m_code_snips; - FunctionModificationList m_function_mods; - FieldModificationList m_field_mods; + CodeSnipList m_code_snips; + FunctionModificationList m_function_mods; + FieldModificationList m_field_mods; - QHash tagNames; + QHash tagNames; - unsigned int m_qtVersion{}; - int m_nestingLevel{}; // current nesting level, needed to reset m_disabledLevel if leaving element - int m_disabledLevel{}; // if this is != 0, elements should be ignored + unsigned int m_qtVersion {}; + int m_nestingLevel {}; // current nesting level, needed to reset m_disabledLevel if leaving element + int m_disabledLevel {}; // if this is != 0, elements should be ignored }; -bool Handler::parse(QXmlStreamReader &reader) +bool Handler::parse(QXmlStreamReader& reader) { - if (!startDocument()) - return false; + if (!startDocument()) + return false; - while (!reader.atEnd()) { - const auto token = reader.readNext(); - switch (token) { - case QXmlStreamReader::StartElement: { - Attributes attributes(reader.attributes()); - if (!startElement(reader.namespaceUri().toString(), - reader.name().toString(), - reader.qualifiedName().toString(), - attributes)) { - return false; - } - break; - } - case QXmlStreamReader::EndElement: - if (!endElement(reader.namespaceUri().toString(), - reader.name().toString(), - reader.qualifiedName().toString())) { - return false; - } - break; - case QXmlStreamReader::Characters: - case QXmlStreamReader::EntityReference: - if (!characters(reader.text().toString())) { - return false; - } - break; - default: - break; - } + while (!reader.atEnd()) { + const auto token = reader.readNext(); + switch (token) { + case QXmlStreamReader::StartElement: + { + Attributes attributes(reader.attributes()); + if (!startElement(reader.namespaceUri().toString(), reader.name().toString(), reader.qualifiedName().toString(), + attributes)) + { + return false; + } + break; } - - if (reader.hasError()) { - m_error = QStringLiteral("Parse error at line %1, column %2: %3") - .arg(reader.lineNumber()) - .arg(reader.columnNumber()) - .arg(reader.errorString()); - qWarning() << m_error; + case QXmlStreamReader::EndElement: + if (!endElement(reader.namespaceUri().toString(), reader.name().toString(), reader.qualifiedName().toString())) { + return false; + } + break; + case QXmlStreamReader::Characters: + case QXmlStreamReader::EntityReference: + if (!characters(reader.text().toString())) { return false; + } + break; + default: + break; } + } - return true; + if (reader.hasError()) { + m_error = QStringLiteral("Parse error at line %1, column %2: %3") + .arg(reader.lineNumber()) + .arg(reader.columnNumber()) + .arg(reader.errorString()); + qWarning() << m_error; + return false; + } + + return true; } -void Handler::fetchAttributeValues(const QString &name, const Attributes &atts, - QHash *acceptedAttributes) +void Handler::fetchAttributeValues(const QString& name, const Attributes& atts, + QHash* acceptedAttributes) { - Q_ASSERT(acceptedAttributes != 0); + Q_ASSERT(acceptedAttributes != 0); - for (int i=0; icontains(key) && key != "since-version" && key != "before-version") { - ReportHandler::warning(QString("Unknown attribute for '%1': '%2'").arg(name).arg(key)); - } else { - (*acceptedAttributes)[key] = val; - } + if (!acceptedAttributes->contains(key) && key != "since-version" && key != "before-version") { + ReportHandler::warning(QString("Unknown attribute for '%1': '%2'").arg(name).arg(key)); + } else { + (*acceptedAttributes)[key] = val; } + } } -bool Handler::endElement(const QString &, const QString &localName, const QString &) +bool Handler::endElement(const QString&, const QString& localName, const QString&) { - QString tagName = localName.toLower(); - int oldNestingLevel = m_nestingLevel--; - if (m_disabledLevel >= 0) { - if (m_disabledLevel == oldNestingLevel) { - m_disabledLevel = -1; - } - return true; + QString tagName = localName.toLower(); + int oldNestingLevel = m_nestingLevel--; + if (m_disabledLevel >= 0) { + if (m_disabledLevel == oldNestingLevel) { + m_disabledLevel = -1; } - if(tagName == "import-file" || tagName == "group") - return true; + return true; + } + if (tagName == "import-file" || tagName == "group") + return true; - if (!current) - return true; + if (!current) + return true; - switch (current->type) { - case StackElement::ObjectTypeEntry: - case StackElement::ValueTypeEntry: - case StackElement::InterfaceTypeEntry: - case StackElement::NamespaceTypeEntry: - { - ComplexTypeEntry *centry = static_cast(current->entry); - centry->setFunctionModifications(m_function_mods); - centry->setFieldModifications(m_field_mods); - centry->setCodeSnips(m_code_snips); - - if (centry->designatedInterface()) { - centry->designatedInterface()->setCodeSnips(m_code_snips); - centry->designatedInterface()->setFunctionModifications(m_function_mods); - } - m_code_snips = CodeSnipList(); - m_function_mods = FunctionModificationList(); - m_field_mods = FieldModificationList(); - } - break; - case StackElement::CustomMetaConstructor: - { - current->entry->setCustomConstructor(*current->value.customFunction); - delete current->value.customFunction; - } - break; - case StackElement::CustomMetaDestructor: - { - current->entry->setCustomDestructor(*current->value.customFunction); - delete current->value.customFunction; - } - break; - case StackElement::EnumTypeEntry: - m_current_enum = 0; - break; - case StackElement::Template: - m_database->addTemplate(current->value.templateEntry); - break; - case StackElement::TemplateInstanceEnum: - if(current->parent->type == StackElement::InjectCode){ - m_code_snips.last().addTemplateInstance(current->value.templateInstance); - }else if(current->parent->type == StackElement::Template){ - current->parent->value.templateEntry->addTemplateInstance(current->value.templateInstance); - }else if(current->parent->type == StackElement::CustomMetaConstructor){ - current->parent->value.customFunction->addTemplateInstance(current->value.templateInstance); - }else if(current->parent->type == StackElement::ConversionRule){ - m_function_mods.last().argument_mods.last().conversion_rules.last().addTemplateInstance(current->value.templateInstance); - }else if(current->parent->type == StackElement::InjectCodeInFunction){ - m_function_mods.last().snips.last().addTemplateInstance(current->value.templateInstance); - } - break; - default: - break; + switch (current->type) { + case StackElement::ObjectTypeEntry: + case StackElement::ValueTypeEntry: + case StackElement::InterfaceTypeEntry: + case StackElement::NamespaceTypeEntry: + { + ComplexTypeEntry* centry = static_cast(current->entry); + centry->setFunctionModifications(m_function_mods); + centry->setFieldModifications(m_field_mods); + centry->setCodeSnips(m_code_snips); + + if (centry->designatedInterface()) { + centry->designatedInterface()->setCodeSnips(m_code_snips); + centry->designatedInterface()->setFunctionModifications(m_function_mods); + } + m_code_snips = CodeSnipList(); + m_function_mods = FunctionModificationList(); + m_field_mods = FieldModificationList(); + } break; + case StackElement::CustomMetaConstructor: + { + current->entry->setCustomConstructor(*current->value.customFunction); + delete current->value.customFunction; + } break; + case StackElement::CustomMetaDestructor: + { + current->entry->setCustomDestructor(*current->value.customFunction); + delete current->value.customFunction; + } break; + case StackElement::EnumTypeEntry: + m_current_enum = 0; + break; + case StackElement::Template: + m_database->addTemplate(current->value.templateEntry); + break; + case StackElement::TemplateInstanceEnum: + if (current->parent->type == StackElement::InjectCode) { + m_code_snips.last().addTemplateInstance(current->value.templateInstance); + } else if (current->parent->type == StackElement::Template) { + current->parent->value.templateEntry->addTemplateInstance(current->value.templateInstance); + } else if (current->parent->type == StackElement::CustomMetaConstructor) { + current->parent->value.customFunction->addTemplateInstance(current->value.templateInstance); + } else if (current->parent->type == StackElement::ConversionRule) { + m_function_mods.last().argument_mods.last().conversion_rules.last().addTemplateInstance( + current->value.templateInstance); + } else if (current->parent->type == StackElement::InjectCodeInFunction) { + m_function_mods.last().snips.last().addTemplateInstance(current->value.templateInstance); } + break; + default: + break; + } - StackElement *child = current; - current=current->parent; - delete(child); + StackElement* child = current; + current = current->parent; + delete (child); - return true; + return true; } -bool Handler::characters(const QString &ch) +bool Handler::characters(const QString& ch) { - if(current->type == StackElement::Template){ - current->value.templateEntry->addCode(ch); - return true; - } + if (current->type == StackElement::Template) { + current->value.templateEntry->addCode(ch); + return true; + } - if (current->type == StackElement::CustomMetaConstructor || current->type == StackElement::CustomMetaDestructor){ - current->value.customFunction->addCode(ch); - return true; - } + if (current->type == StackElement::CustomMetaConstructor || current->type == StackElement::CustomMetaDestructor) { + current->value.customFunction->addCode(ch); + return true; + } - if (current->type == StackElement::ConversionRule){ - m_function_mods.last().argument_mods.last().conversion_rules.last().addCode(ch); - return true; - } + if (current->type == StackElement::ConversionRule) { + m_function_mods.last().argument_mods.last().conversion_rules.last().addCode(ch); + return true; + } - if (current->parent){ - if ((current->type & StackElement::CodeSnipMask) != 0) { - switch (current->parent->type) { - case StackElement::Root: - ((TypeSystemTypeEntry *) current->parent->entry)->snips.last().addCode(ch); - break; - case StackElement::ModifyFunction: - m_function_mods.last().snips.last().addCode(ch); - break; - case StackElement::NamespaceTypeEntry: - case StackElement::ObjectTypeEntry: - case StackElement::ValueTypeEntry: - case StackElement::InterfaceTypeEntry: - m_code_snips.last().addCode(ch); - break; - default: - Q_ASSERT(false); - }; - return true; - } + if (current->parent) { + if ((current->type & StackElement::CodeSnipMask) != 0) { + switch (current->parent->type) { + case StackElement::Root: + ((TypeSystemTypeEntry*)current->parent->entry)->snips.last().addCode(ch); + break; + case StackElement::ModifyFunction: + m_function_mods.last().snips.last().addCode(ch); + break; + case StackElement::NamespaceTypeEntry: + case StackElement::ObjectTypeEntry: + case StackElement::ValueTypeEntry: + case StackElement::InterfaceTypeEntry: + m_code_snips.last().addCode(ch); + break; + default: + Q_ASSERT(false); + }; + return true; } + } - return true; + return true; } -bool Handler::importFileElement(const Attributes &atts) +bool Handler::importFileElement(const Attributes& atts) { - QString fileName = atts.value("name"); - if(fileName.isEmpty()){ - m_error = "Required attribute 'name' missing for include-file tag."; - return false; - } + QString fileName = atts.value("name"); + if (fileName.isEmpty()) { + m_error = "Required attribute 'name' missing for include-file tag."; + return false; + } - QFile file(fileName); + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + file.setFileName(":/trolltech/generator/" + fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - file.setFileName(":/trolltech/generator/" + fileName); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - m_error = QString("Could not open file: '%1'").arg(fileName); - return false; - } + m_error = QString("Could not open file: '%1'").arg(fileName); + return false; } + } - QString quoteFrom = atts.value("quote-after-line"); - bool foundFromOk = quoteFrom.isEmpty(); - bool from = quoteFrom.isEmpty(); - - QString quoteTo = atts.value("quote-before-line"); - bool foundToOk = quoteTo.isEmpty(); - bool to = true; - - QTextStream in(&file); - while (!in.atEnd()) { - QString line = in.readLine(); - if(from && to && line.contains(quoteTo)) { - to = false; - foundToOk = true; - break; - } - if(from && to) - characters(line + "\n"); - if(!from && line.contains(quoteFrom)) { - from = true; - foundFromOk = true; - } + QString quoteFrom = atts.value("quote-after-line"); + bool foundFromOk = quoteFrom.isEmpty(); + bool from = quoteFrom.isEmpty(); + + QString quoteTo = atts.value("quote-before-line"); + bool foundToOk = quoteTo.isEmpty(); + bool to = true; + + QTextStream in(&file); + while (!in.atEnd()) { + QString line = in.readLine(); + if (from && to && line.contains(quoteTo)) { + to = false; + foundToOk = true; + break; } - if(!foundFromOk || !foundToOk){ - QString fromError = QString("Could not find quote-after-line='%1' in file '%2'.").arg(quoteFrom).arg(fileName); - QString toError = QString("Could not find quote-before-line='%1' in file '%2'.").arg(quoteTo).arg(fileName); - - if(!foundToOk) - m_error = toError; - if(!foundFromOk) - m_error = fromError; - if(!foundFromOk && !foundToOk) - m_error = fromError + " " + toError; - return false; + if (from && to) + characters(line + "\n"); + if (!from && line.contains(quoteFrom)) { + from = true; + foundFromOk = true; } + } + if (!foundFromOk || !foundToOk) { + QString fromError = QString("Could not find quote-after-line='%1' in file '%2'.").arg(quoteFrom).arg(fileName); + QString toError = QString("Could not find quote-before-line='%1' in file '%2'.").arg(quoteTo).arg(fileName); + + if (!foundToOk) + m_error = toError; + if (!foundFromOk) + m_error = fromError; + if (!foundFromOk && !foundToOk) + m_error = fromError + " " + toError; + return false; + } - return true; + return true; } -bool Handler::convertBoolean(const QString &_value, const QString &attributeName, bool defaultValue) +bool Handler::convertBoolean(const QString& _value, const QString& attributeName, bool defaultValue) { - QString value = _value.toLower(); - if (value == "true" || value == "yes") { - return true; - } else if (value == "false" || value == "no") { - return false; - } else { - QString warn = QString("Boolean value '%1' not supported in attribute '%2'. Use 'yes' or 'no'. Defaulting to '%3'.") - .arg(value).arg(attributeName).arg(defaultValue ? "yes" : "no"); - - ReportHandler::warning(warn); - return defaultValue; - } + QString value = _value.toLower(); + if (value == "true" || value == "yes") { + return true; + } else if (value == "false" || value == "no") { + return false; + } else { + QString warn = QString("Boolean value '%1' not supported in attribute '%2'. Use 'yes' or 'no'. Defaulting to '%3'.") + .arg(value) + .arg(attributeName) + .arg(defaultValue ? "yes" : "no"); + + ReportHandler::warning(warn); + return defaultValue; + } } bool Handler::qtVersionMatches(const Attributes& atts, bool& ok) @@ -527,8 +528,7 @@ bool Handler::qtVersionMatches(const Attributes& atts, bool& ok) if (m_qtVersion >= beforeVersion) { return false; } - } - else { + } else { m_error = "Invalid 'before-version' version string: " + atts.value(beforeIndex); } } @@ -539,1646 +539,1629 @@ bool Handler::qtVersionMatches(const Attributes& atts, bool& ok) if (m_qtVersion < sinceVersion) { return false; } - } - else { + } else { m_error = "Invalid 'since-version' version string: " + atts.value(sinceIndex); } } return true; } -bool Handler::startElement(const QString &, const QString &n, - const QString &, const Attributes &atts) +bool Handler::startElement(const QString&, const QString& n, const QString&, const Attributes& atts) { - QString tagName = n.toLower(); - m_nestingLevel++; - if (m_disabledLevel >= 0 && m_disabledLevel < m_nestingLevel) { - return true; + QString tagName = n.toLower(); + m_nestingLevel++; + if (m_disabledLevel >= 0 && m_disabledLevel < m_nestingLevel) { + return true; + } + bool ok; + bool versionMatches = qtVersionMatches(atts, ok); + if (!ok) { + return false; // abort + } else if (!versionMatches) { + m_disabledLevel = m_nestingLevel; + return true; + } + + if (tagName == "import-file") { + return importFileElement(atts); + } else if (tagName == "group") { // non-functional element to handle version ranges + return true; + } + + std::unique_ptr element(new StackElement(current)); + + if (!tagNames.contains(tagName)) { + m_error = QString("Unknown tag name: '%1'").arg(tagName); + return false; + } + + element->type = tagNames[tagName]; + if (element->type & StackElement::TypeEntryMask) { + if (current->type != StackElement::Root) { + m_error = "Nested types not supported"; + return false; } - bool ok; - bool versionMatches = qtVersionMatches(atts, ok); - if (!ok) { - return false; // abort - } else if (!versionMatches) { - m_disabledLevel = m_nestingLevel; - return true; + + QHash attributes; + attributes["name"] = QString(); + attributes["aliases"] = QString(); + + switch (element->type) { + case StackElement::PrimitiveTypeEntry: + attributes["java-name"] = QString(); + attributes["jni-name"] = QString(); + attributes["preferred-conversion"] = "yes"; + attributes["preferred-java-type"] = "yes"; + break; + case StackElement::EnumTypeEntry: + attributes["flags"] = "no"; + attributes["upper-bound"] = QString(); + attributes["lower-bound"] = QString(); + attributes["force-integer"] = "no"; + attributes["extensible"] = "no"; + + break; + + case StackElement::ObjectTypeEntry: + case StackElement::ValueTypeEntry: + attributes["force-abstract"] = QString("no"); + attributes["deprecated"] = QString("no"); + Q_FALLTHROUGH(); + case StackElement::InterfaceTypeEntry: + attributes["default-superclass"] = m_defaultSuperclass; + attributes["polymorphic-id-expression"] = QString(); + attributes["delete-in-main-thread"] = QString("no"); + Q_FALLTHROUGH(); + case StackElement::NamespaceTypeEntry: + attributes["java-name"] = QString(); + attributes["package"] = m_defaultPackage; + attributes["expense-cost"] = "1"; + attributes["expense-limit"] = "none"; + attributes["polymorphic-base"] = QString("no"); + attributes["create-shell"] = QString("yes"); + attributes["create-promoter"] = QString("yes"); + attributes["generate"] = QString("yes"); + attributes["target-type"] = QString(); + attributes["generic-class"] = QString("no"); + break; + default:; // nada + }; + + fetchAttributeValues(tagName, atts, &attributes); + + QString name = attributes["name"]; + QStringList aliases = attributes["aliases"].split(',', Qt::SkipEmptyParts); + + // We need to be able to have duplicate primitive type entries, or it's not possible to + // cover all primitive java types (which we need to do in order to support fake + // meta objects) + if (element->type != StackElement::PrimitiveTypeEntry) { + if (m_database->findType(name)) { + ReportHandler::warning(QString("Duplicate type entry: '%1'").arg(name)); + } + for (const QString& alias : aliases) { + if (m_database->findType(alias)) { + ReportHandler::warning(QString("Duplicate alias type entry: '%1'").arg(alias)); + } + } } - if (tagName == "import-file") { - return importFileElement(atts); + if (name.isEmpty()) { + m_error = "no 'name' attribute specified"; + return false; } - else if (tagName == "group") { // non-functional element to handle version ranges - return true; + switch (element->type) { + case StackElement::PrimitiveTypeEntry: + { + QString java_name = attributes["java-name"]; + QString jni_name = attributes["jni-name"]; + QString preferred_conversion = attributes["preferred-conversion"].toLower(); + QString preferred_java_type = attributes["preferred-java-type"].toLower(); + + if (java_name.isEmpty()) + java_name = name; + if (jni_name.isEmpty()) + jni_name = name; + + PrimitiveTypeEntry* type = new PrimitiveTypeEntry(name); + type->setCodeGeneration(m_generate); + type->setTargetLangName(java_name); + type->setJniName(jni_name); + + type->setPreferredConversion(convertBoolean(preferred_conversion, "preferred-conversion", true)); + type->setPreferredTargetLangType(convertBoolean(preferred_java_type, "preferred-java-type", true)); + + element->entry = type; + } break; + case StackElement::EnumTypeEntry: + { + QStringList names = name.split(QLatin1String("::")); + + if (names.size() == 1) { + m_current_enum = new EnumTypeEntry(QString(), name); + } else + m_current_enum = new EnumTypeEntry(QStringList(names.mid(0, names.size() - 1)).join("::"), names.last()); + element->entry = m_current_enum; + m_current_enum->setCodeGeneration(m_generate); + m_current_enum->setTargetLangPackage(m_defaultPackage); + m_current_enum->setUpperBound(attributes["upper-bound"]); + m_current_enum->setLowerBound(attributes["lower-bound"]); + m_current_enum->setForceInteger(convertBoolean(attributes["force-integer"], "force-integer", false)); + m_current_enum->setExtensible(convertBoolean(attributes["extensible"], "extensible", false)); + + // put in the flags parallel... + if (!attributes["flags"].isEmpty() && attributes["flags"].toLower() != "no") { + FlagsTypeEntry* ftype = new FlagsTypeEntry("QFlags<" + name + ">"); + ftype->setOriginator(m_current_enum); + ftype->setOriginalName(attributes["flags"]); + ftype->setCodeGeneration(m_generate); + QString origname = ftype->originalName(); + + QStringList lst = origname.split("::"); + if (QStringList(lst.mid(0, lst.size() - 1)).join("::") != m_current_enum->javaQualifier()) { + ReportHandler::warning( + QString("enum %1 and flags %2 differ in qualifiers").arg(m_current_enum->javaQualifier()).arg(lst.at(0))); + } + + ftype->setFlagsName(lst.last()); + m_current_enum->setFlags(ftype); + + m_database->addFlagsType(ftype); + m_database->addType(ftype); + } + } break; + + case StackElement::InterfaceTypeEntry: + { + ObjectTypeEntry* otype = new ObjectTypeEntry(name); + QString javaName = attributes["java-name"]; + if (javaName.isEmpty()) + javaName = name; + InterfaceTypeEntry* itype = new InterfaceTypeEntry(InterfaceTypeEntry::interfaceName(javaName)); + + if (!convertBoolean(attributes["generate"], "generate", true)) + itype->setCodeGeneration(TypeEntry::GenerateForSubclass); + else + itype->setCodeGeneration(m_generate); + otype->setDesignatedInterface(itype); + itype->setOrigin(otype); + element->entry = otype; + } + // fall through + case StackElement::NamespaceTypeEntry: + if (element->entry == 0) { + element->entry = new NamespaceTypeEntry(name); + } + // fall through + case StackElement::ObjectTypeEntry: + if (element->entry == 0) { + element->entry = new ObjectTypeEntry(name); + } + // fall through + case StackElement::ValueTypeEntry: + { + if (element->entry == 0) { + element->entry = new ValueTypeEntry(name); + } + + ComplexTypeEntry* ctype = static_cast(element->entry); + ctype->setTargetLangPackage(attributes["package"]); + ctype->setDefaultSuperclass(attributes["default-superclass"]); + ctype->setGenericClass(convertBoolean(attributes["generic-class"], "generic-class", false)); + + if (!convertBoolean(attributes["generate"], "generate", true)) + element->entry->setCodeGeneration(TypeEntry::GenerateForSubclass); + else + element->entry->setCodeGeneration(m_generate); + + QString javaName = attributes["java-name"]; + if (!javaName.isEmpty()) + ctype->setTargetLangName(javaName); + + // The expense policy + QString limit = attributes["expense-limit"]; + if (!limit.isEmpty() && limit != "none") { + ExpensePolicy ep; + ep.limit = limit.toInt(); + ep.cost = attributes["expense-cost"]; + ctype->setExpensePolicy(ep); + } + ctype->setCreateShell(convertBoolean(attributes["create-shell"], "create-shell", false)); + ctype->setCreatePromoter(convertBoolean(attributes["create-promoter"], "create-promoter", false)); + + ctype->setIsPolymorphicBase(convertBoolean(attributes["polymorphic-base"], "polymorphic-base", false)); + ctype->setPolymorphicIdValue(attributes["polymorphic-id-expression"]); + + if (element->type == StackElement::ObjectTypeEntry || element->type == StackElement::ValueTypeEntry) { + if (convertBoolean(attributes["force-abstract"], "force-abstract", false)) + ctype->setTypeFlags(ctype->typeFlags() | ComplexTypeEntry::ForceAbstract); + if (convertBoolean(attributes["deprecated"], "deprecated", false)) + ctype->setTypeFlags(ctype->typeFlags() | ComplexTypeEntry::Deprecated); + } + + if (element->type == StackElement::InterfaceTypeEntry || element->type == StackElement::ValueTypeEntry + || element->type == StackElement::ObjectTypeEntry) + { + if (convertBoolean(attributes["delete-in-main-thread"], "delete-in-main-thread", false)) + ctype->setTypeFlags(ctype->typeFlags() | ComplexTypeEntry::DeleteInMainThread); + } + + QString targetType = attributes["target-type"]; + if (!targetType.isEmpty() && element->entry->isComplex()) + static_cast(element->entry)->setTargetType(targetType); + + // ctype->setInclude(Include(Include::IncludePath, ctype->name())); + ctype = ctype->designatedInterface(); + if (ctype != 0) + ctype->setTargetLangPackage(attributes["package"]); + + } break; + default: + Q_ASSERT(false); + }; + + element->entry->setAliases(aliases); // also add type under given aliases into type database + if (element->entry) + m_database->addType(element->entry); + else + ReportHandler::warning(QString("Type: %1 was rejected by typesystem").arg(name)); + + } else if (element->type != StackElement::None) { + bool topLevel = element->type == StackElement::Root || element->type == StackElement::SuppressedWarning + || element->type == StackElement::Rejection || element->type == StackElement::LoadTypesystem + || element->type == StackElement::InjectCode || element->type == StackElement::Template; + + if (!topLevel && current->type == StackElement::Root) { + m_error = QString("Tag requires parent: '%1'").arg(tagName); + return false; } - std::unique_ptr element(new StackElement(current)); + StackElement topElement = current == 0 ? StackElement(0) : *current; + element->entry = topElement.entry; + + QHash attributes; + switch (element->type) { + case StackElement::Root: + attributes["package"] = QString(); + attributes["default-superclass"] = QString(); + break; + case StackElement::LoadTypesystem: + attributes["name"] = QString(); + attributes["generate"] = "yes"; + break; + case StackElement::NoNullPointers: + attributes["default-value"] = QString(); + break; + case StackElement::SuppressedWarning: + attributes["text"] = QString(); + break; + case StackElement::ReplaceDefaultExpression: + attributes["with"] = QString(); + break; + case StackElement::DefineOwnership: + attributes["class"] = "java"; + attributes["owner"] = ""; + break; + case StackElement::ModifyFunction: + attributes["signature"] = QString(); + attributes["access"] = QString(); + attributes["remove"] = QString(); + attributes["rename"] = QString(); + attributes["deprecated"] = QString("no"); + attributes["associated-to"] = QString(); + attributes["virtual-slot"] = QString("no"); + break; + case StackElement::ModifyArgument: + attributes["index"] = QString(); + attributes["replace-value"] = QString(); + attributes["invalidate-after-use"] = QString("no"); + break; + case StackElement::ModifyField: + attributes["name"] = QString(); + attributes["write"] = "true"; + attributes["read"] = "true"; + break; + case StackElement::Access: + attributes["modifier"] = QString(); + break; + case StackElement::Include: + attributes["file-name"] = QString(); + attributes["location"] = QString(); + break; + case StackElement::CustomMetaConstructor: + attributes["name"] = topElement.entry->name().toLower() + "_create"; + attributes["param-name"] = "copy"; + break; + case StackElement::CustomMetaDestructor: + attributes["name"] = topElement.entry->name().toLower() + "_delete"; + attributes["param-name"] = "copy"; + break; + case StackElement::ReplaceType: + attributes["modified-type"] = QString(); + break; + case StackElement::InjectCode: + attributes["class"] = "java"; + attributes["position"] = "beginning"; + break; + case StackElement::ConversionRule: + attributes["class"] = ""; + break; + case StackElement::RejectEnumValue: + attributes["name"] = ""; + break; + case StackElement::ArgumentMap: + attributes["index"] = "1"; + attributes["meta-name"] = QString(); + break; + case StackElement::Rename: + attributes["to"] = QString(); + break; + case StackElement::Rejection: + attributes["class"] = "*"; + attributes["function-name"] = "*"; + attributes["field-name"] = "*"; + attributes["enum-name"] = "*"; + break; + case StackElement::Removal: + attributes["class"] = "all"; + break; + case StackElement::Template: + attributes["name"] = QString(); + break; + case StackElement::TemplateInstanceEnum: + attributes["name"] = QString(); + break; + case StackElement::Replace: + attributes["from"] = QString(); + attributes["to"] = QString(); + break; + case StackElement::ReferenceCount: + attributes["action"] = QString(); + attributes["variable-name"] = QString(); + attributes["thread-safe"] = QString("no"); + attributes["declare-variable"] = QString(); + attributes["access"] = QString("private"); + attributes["conditional"] = QString(""); + break; + default:; // nada + }; + + if (attributes.count() > 0) + fetchAttributeValues(tagName, atts, &attributes); + + switch (element->type) { + case StackElement::Root: + m_defaultPackage = attributes["package"]; + m_defaultSuperclass = attributes["default-superclass"]; + element->type = StackElement::Root; + element->entry = new TypeSystemTypeEntry(m_defaultPackage); + TypeDatabase::instance()->addType(element->entry); + break; + case StackElement::LoadTypesystem: + { + QString name = attributes["name"]; + if (name.isEmpty()) { + m_error = "No typesystem name specified"; + return false; + } + + if (!m_database->parseFile(name, m_qtVersion, convertBoolean(attributes["generate"], "generate", true))) { + m_error = QString("Failed to parse: '%1'").arg(name); + return false; + } + } break; + case StackElement::RejectEnumValue: + { + if (!m_current_enum) { + m_error = " node must be used inside a node"; + return false; + } + QString name = attributes["name"]; + + if (!name.isEmpty()) { + m_current_enum->addEnumValueRejection(name); + } - if (!tagNames.contains(tagName)) { - m_error = QString("Unknown tag name: '%1'").arg(tagName); + } break; + case StackElement::ReplaceType: + { + if (topElement.type != StackElement::ModifyArgument) { + m_error = "Type replacement can only be specified for argument modifications"; return false; + } + + if (attributes["modified-type"].isEmpty()) { + m_error = "Type replacement requires 'modified-type' attribute"; + return false; + } + + m_function_mods.last().argument_mods.last().modified_type = attributes["modified-type"]; + } break; + case StackElement::ConversionRule: + { + if (topElement.type != StackElement::ModifyArgument) { + m_error = "Conversion rules can only be specified for argument modification"; + return false; + } + + static QHash languageNames; + if (languageNames.isEmpty()) { + languageNames["native"] = TypeSystem::NativeCode; + languageNames["shell"] = TypeSystem::ShellCode; + } + + CodeSnip snip; + QString languageAttribute = attributes["class"].toLower(); + TypeSystem::Language lang = languageNames.value(languageAttribute, TypeSystem::NoLanguage); + if (lang == TypeSystem::NoLanguage) { + m_error = QString("unsupported class attribute: '%1'").arg(languageAttribute); + return false; + } + + snip.language = lang; + m_function_mods.last().argument_mods.last().conversion_rules.append(snip); } - element->type = tagNames[tagName]; - if (element->type & StackElement::TypeEntryMask) { - if (current->type != StackElement::Root) { - m_error = "Nested types not supported"; - return false; + break; + case StackElement::ModifyArgument: + { + if (topElement.type != StackElement::ModifyFunction) { + m_error = QString::fromLatin1("argument modification requires function" + " modification as parent, was %1") + .arg(topElement.type, 0, 16); + return false; + } + + QString index = attributes["index"]; + if (index == "return") + index = "0"; + else if (index == "this") + index = "-1"; + + bool ok = false; + int idx = index.toInt(&ok); + if (!ok) { + m_error = QString("Cannot convert '%1' to integer").arg(index); + return false; + } + + QString replace_value = attributes["replace-value"]; + + if (!replace_value.isEmpty() && idx != 0) { + m_error = QString("replace-value is only supported for return values (index=0)."); + return false; + } + + ArgumentModification argumentModification = ArgumentModification(idx); + argumentModification.replace_value = replace_value; + argumentModification.reset_after_use = + convertBoolean(attributes["invalidate-after-use"], "invalidate-after-use", false); + m_function_mods.last().argument_mods.append(argumentModification); + } break; + case StackElement::NoNullPointers: + { + if (topElement.type != StackElement::ModifyArgument) { + m_error = "no-null-pointer requires argument modification as parent"; + return false; + } + + m_function_mods.last().argument_mods.last().no_null_pointers = true; + if (m_function_mods.last().argument_mods.last().index == 0) { + m_function_mods.last().argument_mods.last().null_pointer_default_value = attributes["default-value"]; + } else if (!attributes["default-value"].isEmpty()) { + ReportHandler::warning("default values for null pointer guards are only effective for return values"); + } + } break; + case StackElement::DefineOwnership: + { + if (topElement.type != StackElement::ModifyArgument) { + m_error = "define-ownership requires argument modification as parent"; + return false; + } + + static QHash languageNames; + if (languageNames.isEmpty()) { + languageNames["java"] = TypeSystem::TargetLangCode; + languageNames["shell"] = TypeSystem::ShellCode; + } + + QString classAttribute = attributes["class"].toLower(); + TypeSystem::Language lang = languageNames.value(classAttribute, TypeSystem::NoLanguage); + if (lang == TypeSystem::NoLanguage) { + m_error = QString("unsupported class attribute: '%1'").arg(classAttribute); + return false; + } + + static QHash ownershipNames; + if (ownershipNames.isEmpty()) { + ownershipNames["python"] = TypeSystem::TargetLangOwnership; + ownershipNames["c++"] = TypeSystem::CppOwnership; + ownershipNames["default"] = TypeSystem::DefaultOwnership; + ownershipNames["new-owner-of-this"] = TypeSystem::TargetLangThisOwnership; + } + + QString ownershipAttribute = attributes["owner"].toLower(); + TypeSystem::Ownership owner = ownershipNames.value(ownershipAttribute, TypeSystem::InvalidOwnership); + if (owner == TypeSystem::InvalidOwnership) { + m_error = QString("unsupported owner attribute: '%1'").arg(ownershipAttribute); + return false; + } + + m_function_mods.last().argument_mods.last().ownerships[lang] = owner; + } break; + case StackElement::SuppressedWarning: + if (attributes["text"].isEmpty()) + ReportHandler::warning("Suppressed warning with no text specified"); + else + m_database->addSuppressedWarning(attributes["text"]); + break; + case StackElement::ArgumentMap: + { + if (!(topElement.type & StackElement::CodeSnipMask)) { + m_error = "Argument maps requires code injection as parent"; + return false; + } + + bool ok; + int pos = attributes["index"].toInt(&ok); + if (!ok) { + m_error = QString("Can't convert position '%1' to integer").arg(attributes["position"]); + return false; + } + + if (pos <= 0) { + m_error = QString("Argument position %1 must be a positive number").arg(pos); + return false; + } + + QString meta_name = attributes["meta-name"]; + if (meta_name.isEmpty()) { + ReportHandler::warning("Empty meta name in argument map"); + } + + if (topElement.type == StackElement::InjectCodeInFunction) { + m_function_mods.last().snips.last().argumentMap[pos] = meta_name; + } else { + ReportHandler::warning("Argument maps are only useful for injection of code " + "into functions."); + } + } break; + case StackElement::Removal: + { + if (topElement.type != StackElement::ModifyFunction) { + m_error = "Function modification parent required"; + return false; + } + + static QHash languageNames; + if (languageNames.isEmpty()) { + languageNames["java"] = TypeSystem::TargetLangAndNativeCode; + languageNames["all"] = TypeSystem::All; + } + + QString languageAttribute = attributes["class"].toLower(); + TypeSystem::Language lang = languageNames.value(languageAttribute, TypeSystem::NoLanguage); + if (lang == TypeSystem::NoLanguage) { + m_error = QString("unsupported class attribute: '%1'").arg(languageAttribute); + return false; + } + + m_function_mods.last().removal = lang; + } break; + case StackElement::Rename: + case StackElement::Access: + { + if (topElement.type != StackElement::ModifyField && topElement.type != StackElement::ModifyFunction) { + m_error = "Function or field modification parent required"; + return false; + } + + Modification* mod = 0; + if (topElement.type == StackElement::ModifyFunction) + mod = &m_function_mods.last(); + else + mod = &m_field_mods.last(); + + QString modifier; + if (element->type == StackElement::Rename) { + modifier = "rename"; + QString renamed_to = attributes["to"]; + if (renamed_to.isEmpty()) { + m_error = "Rename modifier requires 'to' attribute"; + return false; } - QHash attributes; - attributes["name"] = QString(); - attributes["aliases"] = QString(); - - switch (element->type) { - case StackElement::PrimitiveTypeEntry: - attributes["java-name"] = QString(); - attributes["jni-name"] = QString(); - attributes["preferred-conversion"] = "yes"; - attributes["preferred-java-type"] = "yes"; - break; - case StackElement::EnumTypeEntry: - attributes["flags"] = "no"; - attributes["upper-bound"] = QString(); - attributes["lower-bound"] = QString(); - attributes["force-integer"] = "no"; - attributes["extensible"] = "no"; - - break; - - case StackElement::ObjectTypeEntry: - case StackElement::ValueTypeEntry: - attributes["force-abstract"] = QString("no"); - attributes["deprecated"] = QString("no"); - Q_FALLTHROUGH(); - case StackElement::InterfaceTypeEntry: - attributes["default-superclass"] = m_defaultSuperclass; - attributes["polymorphic-id-expression"] = QString(); - attributes["delete-in-main-thread"] = QString("no"); - Q_FALLTHROUGH(); - case StackElement::NamespaceTypeEntry: - attributes["java-name"] = QString(); - attributes["package"] = m_defaultPackage; - attributes["expense-cost"] = "1"; - attributes["expense-limit"] = "none"; - attributes["polymorphic-base"] = QString("no"); - attributes["create-shell"] = QString("yes"); - attributes["create-promoter"] = QString("yes"); - attributes["generate"] = QString("yes"); - attributes["target-type"] = QString(); - attributes["generic-class"] = QString("no"); - break; - default: - ; // nada - }; - - fetchAttributeValues(tagName, atts, &attributes); - - QString name = attributes["name"]; - QStringList aliases = attributes["aliases"].split(',', Qt::SkipEmptyParts); - - // We need to be able to have duplicate primitive type entries, or it's not possible to - // cover all primitive java types (which we need to do in order to support fake - // meta objects) - if (element->type != StackElement::PrimitiveTypeEntry) { - if (m_database->findType(name)) { - ReportHandler::warning(QString("Duplicate type entry: '%1'").arg(name)); - } - for (const QString& alias : aliases) { - if (m_database->findType(alias)) { - ReportHandler::warning(QString("Duplicate alias type entry: '%1'").arg(alias)); - } - } + if (topElement.type == StackElement::ModifyFunction) + mod->setRenamedTo(renamed_to); + else + mod->setRenamedTo(renamed_to); + } else { + modifier = attributes["modifier"].toLower(); + } + + if (modifier.isEmpty()) { + m_error = "No access modification specified"; + return false; + } + + static QHash modifierNames; + if (modifierNames.isEmpty()) { + modifierNames["private"] = Modification::Private; + modifierNames["public"] = Modification::Public; + modifierNames["protected"] = Modification::Protected; + modifierNames["friendly"] = Modification::Friendly; + modifierNames["rename"] = Modification::Rename; + modifierNames["final"] = Modification::Final; + modifierNames["non-final"] = Modification::NonFinal; + } + + if (!modifierNames.contains(modifier)) { + m_error = QString("Unknown access modifier: '%1'").arg(modifier); + return false; + } + + mod->modifiers |= modifierNames[modifier]; + } break; + case StackElement::RemoveArgument: + if (topElement.type != StackElement::ModifyArgument) { + m_error = "Removing argument requires argument modification as parent"; + return false; + } + + m_function_mods.last().argument_mods.last().removed = true; + + break; + + case StackElement::ModifyField: + { + QString name = attributes["name"]; + if (name.isEmpty()) + break; + FieldModification fm; + fm.name = name; + fm.modifiers = 0; + + QString read = attributes["read"]; + QString write = attributes["write"]; + + if (read == "true") + fm.modifiers |= FieldModification::Readable; + if (write == "true") + fm.modifiers |= FieldModification::Writable; + + m_field_mods << fm; + } break; + case StackElement::ModifyFunction: + { + if (!(topElement.type & StackElement::ComplexTypeEntryMask)) { + m_error = QString::fromLatin1("Modify function requires complex type as parent" + ", was=%1") + .arg(topElement.type, 0, 16); + return false; + } + QString signature = attributes["signature"]; + + signature = TypeSystem::normalizedSignature(signature.toLocal8Bit().constData()); + if (signature.isEmpty()) { + m_error = "No signature for modified function"; + return false; + } + + FunctionModification mod; + mod.signature = signature; + + QString access = attributes["access"].toLower(); + if (!access.isEmpty()) { + if (access == QLatin1String("private")) + mod.modifiers |= Modification::Private; + else if (access == QLatin1String("protected")) + mod.modifiers |= Modification::Protected; + else if (access == QLatin1String("public")) + mod.modifiers |= Modification::Public; + else if (access == QLatin1String("final")) + mod.modifiers |= Modification::Final; + else if (access == QLatin1String("non-final")) + mod.modifiers |= Modification::NonFinal; + else { + m_error = QString::fromLatin1("Bad access type '%1'").arg(access); + return false; } + } - if (name.isEmpty()) { - m_error = "no 'name' attribute specified"; - return false; + if (convertBoolean(attributes["deprecated"], "deprecated", false)) { + mod.modifiers |= Modification::Deprecated; + } + + QString remove = attributes["remove"].toLower(); + if (!remove.isEmpty()) { + if (remove == QLatin1String("all")) + mod.removal = TypeSystem::All; + else if (remove == QLatin1String("java")) + mod.removal = TypeSystem::TargetLangAndNativeCode; + else { + m_error = QString::fromLatin1("Bad removal type '%1'").arg(remove); + return false; } - switch (element->type) { - case StackElement::PrimitiveTypeEntry: - { - QString java_name = attributes["java-name"]; - QString jni_name = attributes["jni-name"]; - QString preferred_conversion = attributes["preferred-conversion"].toLower(); - QString preferred_java_type = attributes["preferred-java-type"].toLower(); - - if (java_name.isEmpty()) - java_name = name; - if (jni_name.isEmpty()) - jni_name = name; - - PrimitiveTypeEntry *type = new PrimitiveTypeEntry(name); - type->setCodeGeneration(m_generate); - type->setTargetLangName(java_name); - type->setJniName(jni_name); - - type->setPreferredConversion(convertBoolean(preferred_conversion, "preferred-conversion", true)); - type->setPreferredTargetLangType(convertBoolean(preferred_java_type, "preferred-java-type", true)); - - element->entry = type; - } - break; - case StackElement::EnumTypeEntry: { - QStringList names = name.split(QLatin1String("::")); - - if (names.size() == 1) { - m_current_enum = new EnumTypeEntry(QString(), name); - } - else - m_current_enum = - new EnumTypeEntry(QStringList(names.mid(0, names.size() - 1)).join("::"), - names.last()); - element->entry = m_current_enum; - m_current_enum->setCodeGeneration(m_generate); - m_current_enum->setTargetLangPackage(m_defaultPackage); - m_current_enum->setUpperBound(attributes["upper-bound"]); - m_current_enum->setLowerBound(attributes["lower-bound"]); - m_current_enum->setForceInteger(convertBoolean(attributes["force-integer"], "force-integer", false)); - m_current_enum->setExtensible(convertBoolean(attributes["extensible"], "extensible", false)); - - // put in the flags parallel... - if (!attributes["flags"].isEmpty() && attributes["flags"].toLower() != "no") { - FlagsTypeEntry *ftype = new FlagsTypeEntry("QFlags<" + name + ">"); - ftype->setOriginator(m_current_enum); - ftype->setOriginalName(attributes["flags"]); - ftype->setCodeGeneration(m_generate); - QString origname = ftype->originalName(); - - QStringList lst = origname.split("::"); - if (QStringList(lst.mid(0, lst.size() - 1)).join("::") != m_current_enum->javaQualifier()) { - ReportHandler::warning(QString("enum %1 and flags %2 differ in qualifiers") - .arg(m_current_enum->javaQualifier()) - .arg(lst.at(0))); - } - - ftype->setFlagsName(lst.last()); - m_current_enum->setFlags(ftype); - - m_database->addFlagsType(ftype); - m_database->addType(ftype); - } - } - break; - - case StackElement::InterfaceTypeEntry: - { - ObjectTypeEntry *otype = new ObjectTypeEntry(name); - QString javaName = attributes["java-name"]; - if (javaName.isEmpty()) - javaName = name; - InterfaceTypeEntry *itype = - new InterfaceTypeEntry(InterfaceTypeEntry::interfaceName(javaName)); - - if (!convertBoolean(attributes["generate"], "generate", true)) - itype->setCodeGeneration(TypeEntry::GenerateForSubclass); - else - itype->setCodeGeneration(m_generate); - otype->setDesignatedInterface(itype); - itype->setOrigin(otype); - element->entry = otype; - } - // fall through - case StackElement::NamespaceTypeEntry: - if (element->entry == 0) { - element->entry = new NamespaceTypeEntry(name); - } - // fall through - case StackElement::ObjectTypeEntry: - if (element->entry == 0) { - element->entry = new ObjectTypeEntry(name); - } - // fall through - case StackElement::ValueTypeEntry: - { - if (element->entry == 0) { - element->entry = new ValueTypeEntry(name); - } - - ComplexTypeEntry *ctype = static_cast(element->entry); - ctype->setTargetLangPackage(attributes["package"]); - ctype->setDefaultSuperclass(attributes["default-superclass"]); - ctype->setGenericClass(convertBoolean(attributes["generic-class"], "generic-class", false)); - - if (!convertBoolean(attributes["generate"], "generate", true)) - element->entry->setCodeGeneration(TypeEntry::GenerateForSubclass); - else - element->entry->setCodeGeneration(m_generate); - - QString javaName = attributes["java-name"]; - if (!javaName.isEmpty()) - ctype->setTargetLangName(javaName); - - // The expense policy - QString limit = attributes["expense-limit"]; - if (!limit.isEmpty() && limit != "none") { - ExpensePolicy ep; - ep.limit = limit.toInt(); - ep.cost = attributes["expense-cost"]; - ctype->setExpensePolicy(ep); - } - ctype->setCreateShell(convertBoolean(attributes["create-shell"], "create-shell", false)); - ctype->setCreatePromoter(convertBoolean(attributes["create-promoter"], "create-promoter", false)); - - ctype->setIsPolymorphicBase(convertBoolean(attributes["polymorphic-base"], "polymorphic-base", false)); - ctype->setPolymorphicIdValue(attributes["polymorphic-id-expression"]); - - if (element->type == StackElement::ObjectTypeEntry || element->type == StackElement::ValueTypeEntry) { - if (convertBoolean(attributes["force-abstract"], "force-abstract", false)) - ctype->setTypeFlags(ctype->typeFlags() | ComplexTypeEntry::ForceAbstract); - if (convertBoolean(attributes["deprecated"], "deprecated", false)) - ctype->setTypeFlags(ctype->typeFlags() | ComplexTypeEntry::Deprecated); - } - - if (element->type == StackElement::InterfaceTypeEntry || - element->type == StackElement::ValueTypeEntry || - element->type == StackElement::ObjectTypeEntry) { - if (convertBoolean(attributes["delete-in-main-thread"], "delete-in-main-thread", false)) - ctype->setTypeFlags(ctype->typeFlags() | ComplexTypeEntry::DeleteInMainThread); - } - - QString targetType = attributes["target-type"]; - if (!targetType.isEmpty() && element->entry->isComplex()) - static_cast(element->entry)->setTargetType(targetType); - - // ctype->setInclude(Include(Include::IncludePath, ctype->name())); - ctype = ctype->designatedInterface(); - if (ctype != 0) - ctype->setTargetLangPackage(attributes["package"]); - - } - break; - default: - Q_ASSERT(false); - }; - - element->entry->setAliases(aliases); // also add type under given aliases into type database - if (element->entry) - m_database->addType(element->entry); - else - ReportHandler::warning(QString("Type: %1 was rejected by typesystem").arg(name)); - - } else if (element->type != StackElement::None) { - bool topLevel = element->type == StackElement::Root - || element->type == StackElement::SuppressedWarning - || element->type == StackElement::Rejection - || element->type == StackElement::LoadTypesystem - || element->type == StackElement::InjectCode - || element->type == StackElement::Template; - - if (!topLevel && current->type == StackElement::Root) { - m_error = QString("Tag requires parent: '%1'").arg(tagName); - return false; + } + + QString rename = attributes["rename"]; + if (!rename.isEmpty()) { + mod.renamedToName = rename; + mod.modifiers |= Modification::Rename; + } + + QString association = attributes["associated-to"]; + if (!association.isEmpty()) + mod.association = association; + + mod.modifiers |= + (convertBoolean(attributes["virtual-slot"], "virtual-slot", false) ? Modification::VirtualSlot : 0); + + m_function_mods << mod; + } break; + case StackElement::ReplaceDefaultExpression: + if (!(topElement.type & StackElement::ModifyArgument)) { + m_error = "Replace default expression only allowed as child of argument modification"; + return false; + } + + if (attributes["with"].isEmpty()) { + m_error = "Default expression replaced with empty string. Use remove-default-expression instead."; + return false; + } + + m_function_mods.last().argument_mods.last().replaced_default_expression = attributes["with"]; + break; + case StackElement::RemoveDefaultExpression: + m_function_mods.last().argument_mods.last().removed_default_expression = true; + break; + case StackElement::CustomMetaConstructor: + case StackElement::CustomMetaDestructor: + { + CustomFunction* func = new CustomFunction(attributes["name"]); + func->param_name = attributes["param-name"]; + element->value.customFunction = func; + } break; + case StackElement::ReferenceCount: + { + if (topElement.type != StackElement::ModifyArgument) { + m_error = "reference-count must be child of modify-argument"; + return false; + } + + ReferenceCount rc; + rc.threadSafe = convertBoolean(attributes["thread-safe"], "thread-safe", false); + + static QHash actions; + if (actions.isEmpty()) { + actions["add"] = ReferenceCount::Add; + actions["add-all"] = ReferenceCount::AddAll; + actions["remove"] = ReferenceCount::Remove; + actions["set"] = ReferenceCount::Set; + actions["ignore"] = ReferenceCount::Ignore; + } + rc.action = actions.value(attributes["action"].toLower(), ReferenceCount::Invalid); + + rc.variableName = attributes["variable-name"]; + if (rc.action != ReferenceCount::Ignore && rc.variableName.isEmpty()) { + m_error = "variable-name attribute must be specified"; + return false; + } + + rc.declareVariable = attributes["declare-variable"]; + rc.conditional = attributes["conditional"]; + + static QHash accessRights; + if (accessRights.isEmpty()) { + accessRights["private"] = ReferenceCount::Private; + accessRights["public"] = ReferenceCount::Public; + accessRights["protected"] = ReferenceCount::Protected; + accessRights["friendly"] = ReferenceCount::Friendly; + } + rc.access = accessRights.value(attributes["access"].toLower(), 0); + if (rc.access == 0) { + m_error = "unrecognized access value: " + attributes["access"]; + return false; + } + + if (rc.action == ReferenceCount::Invalid) { + m_error = "unrecognized value for action attribute. supported actions:"; + QStringList actionKeys = actions.keys(); + for (QString action : actionKeys) + m_error += " " + action; + } + + m_function_mods.last().argument_mods.last().referenceCounts.append(rc); + } break; + case StackElement::InjectCode: + { + if (((topElement.type & StackElement::ComplexTypeEntryMask) == 0) + && (topElement.type != StackElement::ModifyFunction) && (topElement.type != StackElement::Root)) + { + m_error = "wrong parent type for code injection"; + return false; + } + + static QHash languageNames; + if (languageNames.isEmpty()) { + languageNames["java"] = TypeSystem::TargetLangCode; + languageNames["native"] = TypeSystem::NativeCode; + languageNames["shell"] = TypeSystem::ShellCode; + languageNames["shell-declaration"] = TypeSystem::ShellDeclaration; + languageNames["library-initializer"] = TypeSystem::PackageInitializer; + languageNames["destructor-function"] = TypeSystem::DestructorFunction; + languageNames["constructors"] = TypeSystem::Constructors; + languageNames["interface"] = TypeSystem::Interface; + languageNames["pywrap-cpp"] = TypeSystem::PyWrapperCode; + languageNames["pywrap-h"] = TypeSystem::PyWrapperDeclaration; + languageNames["pywrap-operators"] = TypeSystem::PyWrapperOperators; + languageNames["pyshell-h"] = TypeSystem::PyShellDeclaration; + languageNames["pyinheritshell-h"] = TypeSystem::PyInheritShellDeclaration; + languageNames["pyinheritshell-constructor-code"] = TypeSystem::PyInheritShellConstructorCode; + languageNames["pyinit-cpp"] = TypeSystem::PyInitSource; + languageNames["pysetwrapperfunc"] = TypeSystem::PySetWrapperFunc; + } + + QString className = attributes["class"].toLower(); + if (!languageNames.contains(className)) { + m_error = QString("Invalid class specifier: '%1'").arg(className); + return false; + } + + static QHash positionNames; + if (positionNames.isEmpty()) { + positionNames["beginning"] = CodeSnip::Beginning; + positionNames["end"] = CodeSnip::End; + // QtScript + positionNames["prototype-initialization"] = CodeSnip::PrototypeInitialization; + positionNames["constructor-initialization"] = CodeSnip::ConstructorInitialization; + positionNames["constructor"] = CodeSnip::Constructor; + } + + QString position = attributes["position"].toLower(); + if (!positionNames.contains(position)) { + m_error = QString("Invalid position: '%1'").arg(position); + return false; + } + + CodeSnip snip; + snip.language = languageNames[className]; + snip.position = positionNames[position]; + + if (snip.language == TypeSystem::Interface && topElement.type != StackElement::InterfaceTypeEntry) { + m_error = "Interface code injections must be direct child of an interface type entry"; + return false; + } + + if (topElement.type == StackElement::ModifyFunction) { + FunctionModification mod = m_function_mods.last(); + if (snip.language == TypeSystem::ShellDeclaration) { + m_error = "no function implementation in shell declaration in which to inject code"; + return false; } - StackElement topElement = current==0 ? StackElement(0) : *current; - element->entry = topElement.entry; - - QHash attributes; - switch (element->type) { - case StackElement::Root: - attributes["package"] = QString(); - attributes["default-superclass"] = QString(); - break; - case StackElement::LoadTypesystem: - attributes["name"] = QString(); - attributes["generate"] = "yes"; - break; - case StackElement::NoNullPointers: - attributes["default-value"] = QString(); - break; - case StackElement::SuppressedWarning: - attributes["text"] = QString(); - break; - case StackElement::ReplaceDefaultExpression: - attributes["with"] = QString(); - break; - case StackElement::DefineOwnership: - attributes["class"] = "java"; - attributes["owner"] = ""; - break; - case StackElement::ModifyFunction: - attributes["signature"] = QString(); - attributes["access"] = QString(); - attributes["remove"] = QString(); - attributes["rename"] = QString(); - attributes["deprecated"] = QString("no"); - attributes["associated-to"] = QString(); - attributes["virtual-slot"] = QString("no"); - break; - case StackElement::ModifyArgument: - attributes["index"] = QString(); - attributes["replace-value"] = QString(); - attributes["invalidate-after-use"] = QString("no"); - break; - case StackElement::ModifyField: - attributes["name"] = QString(); - attributes["write"] = "true"; - attributes["read"] = "true"; - break; - case StackElement::Access: - attributes["modifier"] = QString(); - break; - case StackElement::Include: - attributes["file-name"] = QString(); - attributes["location"] = QString(); - break; - case StackElement::CustomMetaConstructor: - attributes["name"] = topElement.entry->name().toLower() + "_create"; - attributes["param-name"] = "copy"; - break; - case StackElement::CustomMetaDestructor: - attributes["name"] = topElement.entry->name().toLower() + "_delete"; - attributes["param-name"] = "copy"; - break; - case StackElement::ReplaceType: - attributes["modified-type"] = QString(); - break; - case StackElement::InjectCode: - attributes["class"] = "java"; - attributes["position"] = "beginning"; - break; - case StackElement::ConversionRule: - attributes["class"] = ""; - break; - case StackElement::RejectEnumValue: - attributes["name"] = ""; - break; - case StackElement::ArgumentMap: - attributes["index"] = "1"; - attributes["meta-name"] = QString(); - break; - case StackElement::Rename: - attributes["to"] = QString(); - break; - case StackElement::Rejection: - attributes["class"] = "*"; - attributes["function-name"] = "*"; - attributes["field-name"] = "*"; - attributes["enum-name"] = "*"; - break; - case StackElement::Removal: - attributes["class"] = "all"; - break; - case StackElement::Template: - attributes["name"] = QString(); - break; - case StackElement::TemplateInstanceEnum: - attributes["name"] = QString(); - break; - case StackElement::Replace: - attributes["from"] = QString(); - attributes["to"] = QString(); - break; - case StackElement::ReferenceCount: - attributes["action"] = QString(); - attributes["variable-name"] = QString(); - attributes["thread-safe"] = QString("no"); - attributes["declare-variable"] = QString(); - attributes["access"] = QString("private"); - attributes["conditional"] = QString(""); - break; - default: - ; // nada - }; - - if (attributes.count() > 0) - fetchAttributeValues(tagName, atts, &attributes); - - switch (element->type) { - case StackElement::Root: - m_defaultPackage = attributes["package"]; - m_defaultSuperclass = attributes["default-superclass"]; - element->type = StackElement::Root; - element->entry = new TypeSystemTypeEntry(m_defaultPackage); - TypeDatabase::instance()->addType(element->entry); - break; - case StackElement::LoadTypesystem: - { - QString name = attributes["name"]; - if (name.isEmpty()) { - m_error = "No typesystem name specified"; - return false; - } - - if (!m_database->parseFile(name, m_qtVersion, convertBoolean(attributes["generate"], "generate", true))) { - m_error = QString("Failed to parse: '%1'").arg(name); - return false; - } - } - break; - case StackElement::RejectEnumValue: { - if (!m_current_enum) { - m_error = " node must be used inside a node"; - return false; - } - QString name = attributes["name"]; - - if (!name.isEmpty()) { - m_current_enum->addEnumValueRejection(name); - } - - } break; - case StackElement::ReplaceType: - { - if (topElement.type != StackElement::ModifyArgument) { - m_error = "Type replacement can only be specified for argument modifications"; - return false; - } - - if (attributes["modified-type"].isEmpty()) { - m_error = "Type replacement requires 'modified-type' attribute"; - return false; - } - - m_function_mods.last().argument_mods.last().modified_type = attributes["modified-type"]; - } - break; - case StackElement::ConversionRule: - { - if (topElement.type != StackElement::ModifyArgument) { - m_error = "Conversion rules can only be specified for argument modification"; - return false; - } - - static QHash languageNames; - if (languageNames.isEmpty()) { - languageNames["native"] = TypeSystem::NativeCode; - languageNames["shell"] = TypeSystem::ShellCode; - } - - CodeSnip snip; - QString languageAttribute = attributes["class"].toLower(); - TypeSystem::Language lang = languageNames.value(languageAttribute, TypeSystem::NoLanguage); - if (lang == TypeSystem::NoLanguage) { - m_error = QString("unsupported class attribute: '%1'").arg(languageAttribute); - return false; - } - - snip.language = lang; - m_function_mods.last().argument_mods.last().conversion_rules.append(snip); - } - - break; - case StackElement::ModifyArgument: - { - if (topElement.type != StackElement::ModifyFunction) { - m_error = QString::fromLatin1("argument modification requires function" - " modification as parent, was %1") - .arg(topElement.type, 0, 16); - return false; - } - - QString index = attributes["index"]; - if (index == "return") - index = "0"; - else if (index == "this") - index = "-1"; - - bool ok = false; - int idx = index.toInt(&ok); - if (!ok) { - m_error = QString("Cannot convert '%1' to integer").arg(index); - return false; - } - - QString replace_value = attributes["replace-value"]; - - if (!replace_value.isEmpty() && idx != 0) { - m_error = QString("replace-value is only supported for return values (index=0)."); - return false; - } - - ArgumentModification argumentModification = ArgumentModification(idx); - argumentModification.replace_value = replace_value; - argumentModification.reset_after_use = convertBoolean(attributes["invalidate-after-use"], "invalidate-after-use", false); - m_function_mods.last().argument_mods.append(argumentModification); - } - break; - case StackElement::NoNullPointers: - { - if (topElement.type != StackElement::ModifyArgument) { - m_error = "no-null-pointer requires argument modification as parent"; - return false; - } - - m_function_mods.last().argument_mods.last().no_null_pointers = true; - if (m_function_mods.last().argument_mods.last().index == 0) { - m_function_mods.last().argument_mods.last().null_pointer_default_value = attributes["default-value"]; - } else if (!attributes["default-value"].isEmpty()) { - ReportHandler::warning("default values for null pointer guards are only effective for return values"); - } - } - break; - case StackElement::DefineOwnership: - { - if (topElement.type != StackElement::ModifyArgument) { - m_error = "define-ownership requires argument modification as parent"; - return false; - } - - static QHash languageNames; - if (languageNames.isEmpty()) { - languageNames["java"] = TypeSystem::TargetLangCode; - languageNames["shell"] = TypeSystem::ShellCode; - } - - QString classAttribute = attributes["class"].toLower(); - TypeSystem::Language lang = languageNames.value(classAttribute, TypeSystem::NoLanguage); - if (lang == TypeSystem::NoLanguage) { - m_error = QString("unsupported class attribute: '%1'").arg(classAttribute); - return false; - } - - static QHash ownershipNames; - if (ownershipNames.isEmpty()) { - ownershipNames["python"] = TypeSystem::TargetLangOwnership; - ownershipNames["c++"] = TypeSystem::CppOwnership; - ownershipNames["default"] = TypeSystem::DefaultOwnership; - ownershipNames["new-owner-of-this"] = TypeSystem::TargetLangThisOwnership; - } - - QString ownershipAttribute = attributes["owner"].toLower(); - TypeSystem::Ownership owner = ownershipNames.value(ownershipAttribute, TypeSystem::InvalidOwnership); - if (owner == TypeSystem::InvalidOwnership) { - m_error = QString("unsupported owner attribute: '%1'").arg(ownershipAttribute); - return false; - } - - m_function_mods.last().argument_mods.last().ownerships[lang] = owner; - } - break; - case StackElement::SuppressedWarning: - if (attributes["text"].isEmpty()) - ReportHandler::warning("Suppressed warning with no text specified"); - else - m_database->addSuppressedWarning(attributes["text"]); - break; - case StackElement::ArgumentMap: - { - if (!(topElement.type & StackElement::CodeSnipMask)) { - m_error = "Argument maps requires code injection as parent"; - return false; - } - - bool ok; - int pos = attributes["index"].toInt(&ok); - if (!ok) { - m_error = QString("Can't convert position '%1' to integer") - .arg(attributes["position"]); - return false; - } - - if (pos <= 0) { - m_error = QString("Argument position %1 must be a positive number").arg(pos); - return false; - } - - QString meta_name = attributes["meta-name"]; - if (meta_name.isEmpty()) { - ReportHandler::warning("Empty meta name in argument map"); - } - - if (topElement.type == StackElement::InjectCodeInFunction) { - m_function_mods.last().snips.last().argumentMap[pos] = meta_name; - } else { - ReportHandler::warning("Argument maps are only useful for injection of code " - "into functions."); - } - } - break; - case StackElement::Removal: - { - if (topElement.type != StackElement::ModifyFunction) { - m_error = "Function modification parent required"; - return false; - } - - static QHash languageNames; - if (languageNames.isEmpty()) { - languageNames["java"] = TypeSystem::TargetLangAndNativeCode; - languageNames["all"] = TypeSystem::All; - } - - QString languageAttribute = attributes["class"].toLower(); - TypeSystem::Language lang = languageNames.value(languageAttribute, TypeSystem::NoLanguage); - if (lang == TypeSystem::NoLanguage) { - m_error = QString("unsupported class attribute: '%1'").arg(languageAttribute); - return false; - } - - m_function_mods.last().removal = lang; - } - break; - case StackElement::Rename: - case StackElement::Access: - { - if (topElement.type != StackElement::ModifyField - && topElement.type != StackElement::ModifyFunction) { - m_error = "Function or field modification parent required"; - return false; - } - - Modification *mod = 0; - if (topElement.type == StackElement::ModifyFunction) - mod = &m_function_mods.last(); - else - mod = &m_field_mods.last(); - - QString modifier; - if (element->type == StackElement::Rename) { - modifier = "rename"; - QString renamed_to = attributes["to"]; - if (renamed_to.isEmpty()) { - m_error = "Rename modifier requires 'to' attribute"; - return false; - } - - if (topElement.type == StackElement::ModifyFunction) - mod->setRenamedTo(renamed_to); - else - mod->setRenamedTo(renamed_to); - } else { - modifier = attributes["modifier"].toLower(); - } - - if (modifier.isEmpty()) { - m_error = "No access modification specified"; - return false; - } - - static QHash modifierNames; - if (modifierNames.isEmpty()) { - modifierNames["private"] = Modification::Private; - modifierNames["public"] = Modification::Public; - modifierNames["protected"] = Modification::Protected; - modifierNames["friendly"] = Modification::Friendly; - modifierNames["rename"] = Modification::Rename; - modifierNames["final"] = Modification::Final; - modifierNames["non-final"] = Modification::NonFinal; - } - - if (!modifierNames.contains(modifier)) { - m_error = QString("Unknown access modifier: '%1'").arg(modifier); - return false; - } - - mod->modifiers |= modifierNames[modifier]; - } - break; - case StackElement::RemoveArgument: - if (topElement.type != StackElement::ModifyArgument) { - m_error = "Removing argument requires argument modification as parent"; - return false; - } - - m_function_mods.last().argument_mods.last().removed = true; - - break; - - case StackElement::ModifyField: - { - QString name = attributes["name"]; - if (name.isEmpty()) - break; - FieldModification fm; - fm.name = name; - fm.modifiers = 0; - - QString read = attributes["read"]; - QString write = attributes["write"]; - - if (read == "true") fm.modifiers |= FieldModification::Readable; - if (write == "true") fm.modifiers |= FieldModification::Writable; - - m_field_mods << fm; - } - break; - case StackElement::ModifyFunction: - { - if (!(topElement.type & StackElement::ComplexTypeEntryMask)) { - m_error = QString::fromLatin1("Modify function requires complex type as parent" - ", was=%1").arg(topElement.type, 0, 16); - return false; - } - QString signature = attributes["signature"]; - - signature = TypeSystem::normalizedSignature(signature.toLocal8Bit().constData()); - if (signature.isEmpty()) { - m_error = "No signature for modified function"; - return false; - } - - FunctionModification mod; - mod.signature = signature; - - QString access = attributes["access"].toLower(); - if (!access.isEmpty()) { - if (access == QLatin1String("private")) - mod.modifiers |= Modification::Private; - else if (access == QLatin1String("protected")) - mod.modifiers |= Modification::Protected; - else if (access == QLatin1String("public")) - mod.modifiers |= Modification::Public; - else if (access == QLatin1String("final")) - mod.modifiers |= Modification::Final; - else if (access == QLatin1String("non-final")) - mod.modifiers |= Modification::NonFinal; - else { - m_error = QString::fromLatin1("Bad access type '%1'").arg(access); - return false; - } - } - - if (convertBoolean(attributes["deprecated"], "deprecated", false)) { - mod.modifiers |= Modification::Deprecated; - } - - QString remove = attributes["remove"].toLower(); - if (!remove.isEmpty()) { - if (remove == QLatin1String("all")) - mod.removal = TypeSystem::All; - else if (remove == QLatin1String("java")) - mod.removal = TypeSystem::TargetLangAndNativeCode; - else { - m_error = QString::fromLatin1("Bad removal type '%1'").arg(remove); - return false; - } - } - - QString rename = attributes["rename"]; - if (!rename.isEmpty()) { - mod.renamedToName = rename; - mod.modifiers |= Modification::Rename; - } - - QString association = attributes["associated-to"]; - if (!association.isEmpty()) - mod.association = association; - - mod.modifiers |= (convertBoolean(attributes["virtual-slot"], "virtual-slot", false) ? Modification::VirtualSlot : 0); - - m_function_mods << mod; - } - break; - case StackElement::ReplaceDefaultExpression: - if (!(topElement.type & StackElement::ModifyArgument)) { - m_error = "Replace default expression only allowed as child of argument modification"; - return false; - } - - if (attributes["with"].isEmpty()) { - m_error = "Default expression replaced with empty string. Use remove-default-expression instead."; - return false; - } - - m_function_mods.last().argument_mods.last().replaced_default_expression = attributes["with"]; - break; - case StackElement::RemoveDefaultExpression: - m_function_mods.last().argument_mods.last().removed_default_expression = true; - break; - case StackElement::CustomMetaConstructor: - case StackElement::CustomMetaDestructor: - { - CustomFunction *func = new CustomFunction(attributes["name"]); - func->param_name = attributes["param-name"]; - element->value.customFunction = func; - } - break; - case StackElement::ReferenceCount: - { - if (topElement.type != StackElement::ModifyArgument) { - m_error = "reference-count must be child of modify-argument"; - return false; - } - - ReferenceCount rc; - rc.threadSafe = convertBoolean(attributes["thread-safe"], "thread-safe", false); - - static QHash actions; - if (actions.isEmpty()) { - actions["add"] = ReferenceCount::Add; - actions["add-all"] = ReferenceCount::AddAll; - actions["remove"] = ReferenceCount::Remove; - actions["set"] = ReferenceCount::Set; - actions["ignore"] = ReferenceCount::Ignore; - } - rc.action = actions.value(attributes["action"].toLower(), ReferenceCount::Invalid); - - rc.variableName = attributes["variable-name"]; - if (rc.action != ReferenceCount::Ignore && rc.variableName.isEmpty()) { - m_error = "variable-name attribute must be specified"; - return false; - } - - rc.declareVariable = attributes["declare-variable"]; - rc.conditional = attributes["conditional"]; - - static QHash accessRights; - if (accessRights.isEmpty()) { - accessRights["private"] = ReferenceCount::Private; - accessRights["public"] = ReferenceCount::Public; - accessRights["protected"] = ReferenceCount::Protected; - accessRights["friendly"] = ReferenceCount::Friendly; - } - rc.access = accessRights.value(attributes["access"].toLower(), 0); - if (rc.access == 0) { - m_error = "unrecognized access value: " + attributes["access"]; - return false; - } - - if (rc.action == ReferenceCount::Invalid) { - m_error = "unrecognized value for action attribute. supported actions:"; - QStringList actionKeys = actions.keys(); - for (QString action : actionKeys) - m_error += " " + action; - } - - m_function_mods.last().argument_mods.last().referenceCounts.append(rc); - } - break; - case StackElement::InjectCode: - { - if (((topElement.type & StackElement::ComplexTypeEntryMask) == 0) - && (topElement.type != StackElement::ModifyFunction) - && (topElement.type != StackElement::Root)) { - m_error = "wrong parent type for code injection"; - return false; - } - - static QHash languageNames; - if (languageNames.isEmpty()) { - languageNames["java"] = TypeSystem::TargetLangCode; - languageNames["native"] = TypeSystem::NativeCode; - languageNames["shell"] = TypeSystem::ShellCode; - languageNames["shell-declaration"] = TypeSystem::ShellDeclaration; - languageNames["library-initializer"] = TypeSystem::PackageInitializer; - languageNames["destructor-function"] = TypeSystem::DestructorFunction; - languageNames["constructors"] = TypeSystem::Constructors; - languageNames["interface"] = TypeSystem::Interface; - languageNames["pywrap-cpp"] = TypeSystem::PyWrapperCode; - languageNames["pywrap-h"] = TypeSystem::PyWrapperDeclaration; - languageNames["pywrap-operators"] = TypeSystem::PyWrapperOperators; - languageNames["pyshell-h"] = TypeSystem::PyShellDeclaration; - languageNames["pyinheritshell-h"] = TypeSystem::PyInheritShellDeclaration; - languageNames["pyinheritshell-constructor-code"] = TypeSystem::PyInheritShellConstructorCode; - languageNames["pyinit-cpp"] = TypeSystem::PyInitSource; - languageNames["pysetwrapperfunc"] = TypeSystem::PySetWrapperFunc; - } - - QString className = attributes["class"].toLower(); - if (!languageNames.contains(className)) { - m_error = QString("Invalid class specifier: '%1'").arg(className); - return false; - } - - - static QHash positionNames; - if (positionNames.isEmpty()) { - positionNames["beginning"] = CodeSnip::Beginning; - positionNames["end"] = CodeSnip::End; - // QtScript - positionNames["prototype-initialization"] = CodeSnip::PrototypeInitialization; - positionNames["constructor-initialization"] = CodeSnip::ConstructorInitialization; - positionNames["constructor"] = CodeSnip::Constructor; - } - - QString position = attributes["position"].toLower(); - if (!positionNames.contains(position)) { - m_error = QString("Invalid position: '%1'").arg(position); - return false; - } - - CodeSnip snip; - snip.language = languageNames[className]; - snip.position = positionNames[position]; - - if (snip.language == TypeSystem::Interface && topElement.type != StackElement::InterfaceTypeEntry) { - m_error = "Interface code injections must be direct child of an interface type entry"; - return false; - } - - if (topElement.type == StackElement::ModifyFunction) { - FunctionModification mod = m_function_mods.last(); - if (snip.language == TypeSystem::ShellDeclaration) { - m_error = "no function implementation in shell declaration in which to inject code"; - return false; - } - - m_function_mods.last().snips << snip; - element->type = StackElement::InjectCodeInFunction; - } else if (topElement.type == StackElement::Root) { - ((TypeSystemTypeEntry *) element->entry)->snips << snip; - - } else if (topElement.type != StackElement::Root) { - m_code_snips << snip; - } - } - break; - case StackElement::Include: - { - QString location = attributes["location"].toLower(); - - static QHash locationNames; - if (locationNames.isEmpty()) { - locationNames["global"] = Include::IncludePath; - locationNames["local"] = Include::LocalPath; - locationNames["java"] = Include::TargetLangImport; - } - - if (!locationNames.contains(location)) { - m_error = QString("Location not recognized: '%1'").arg(location); - return false; - } - - Include::IncludeType loc = locationNames[location]; - Include inc(loc, attributes["file-name"]); - - ComplexTypeEntry *ctype = static_cast(element->entry); - if (topElement.type & StackElement::ComplexTypeEntryMask) { - ctype->setInclude(inc); - } else if (topElement.type == StackElement::ExtraIncludes) { - ctype->addExtraInclude(inc); - } else { - m_error = "Only supported parents are complex types and extra-includes"; - return false; - } - - inc = ctype->include(); - IncludeList lst = ctype->extraIncludes(); - ctype = ctype->designatedInterface(); - if (ctype != 0) { - ctype->setExtraIncludes(lst); - ctype->setInclude(inc); - } - } - break; - case StackElement::Rejection: - { - QString cls = attributes["class"]; - QString function = attributes["function-name"]; - QString field = attributes["field-name"]; - QString enum_ = attributes["enum-name"]; - if (cls == "*" && function == "*" && field == "*" && enum_ == "*") { - m_error = "bad reject entry, neither 'class', 'function-name' nor " - "'field' specified"; - return false; - } - m_database->addRejection(cls, function, field, enum_); - } - break; - case StackElement::Template: - element->value.templateEntry = new TemplateEntry(attributes["name"]); - break; - case StackElement::TemplateInstanceEnum: - if (!(topElement.type & StackElement::CodeSnipMask) && - (topElement.type != StackElement::Template) && - (topElement.type != StackElement::CustomMetaConstructor) && - (topElement.type != StackElement::CustomMetaDestructor) && - (topElement.type != StackElement::ConversionRule)) - { - m_error = "Can only insert templates into code snippets, templates, custom-constructors, custom-destructors or conversion-rule."; - return false; - } - element->value.templateInstance = new TemplateInstance(attributes["name"]); - break; - case StackElement::Replace: - if (topElement.type != StackElement::TemplateInstanceEnum) { - m_error = "Can only insert replace rules into insert-template."; - return false; - } - element->parent->value.templateInstance->addReplaceRule(attributes["from"],attributes["to"]); - break; - default: - break; // nada - }; - } + m_function_mods.last().snips << snip; + element->type = StackElement::InjectCodeInFunction; + } else if (topElement.type == StackElement::Root) { + ((TypeSystemTypeEntry*)element->entry)->snips << snip; - current = element.release(); - return true; + } else if (topElement.type != StackElement::Root) { + m_code_snips << snip; + } + } break; + case StackElement::Include: + { + QString location = attributes["location"].toLower(); + + static QHash locationNames; + if (locationNames.isEmpty()) { + locationNames["global"] = Include::IncludePath; + locationNames["local"] = Include::LocalPath; + locationNames["java"] = Include::TargetLangImport; + } + + if (!locationNames.contains(location)) { + m_error = QString("Location not recognized: '%1'").arg(location); + return false; + } + + Include::IncludeType loc = locationNames[location]; + Include inc(loc, attributes["file-name"]); + + ComplexTypeEntry* ctype = static_cast(element->entry); + if (topElement.type & StackElement::ComplexTypeEntryMask) { + ctype->setInclude(inc); + } else if (topElement.type == StackElement::ExtraIncludes) { + ctype->addExtraInclude(inc); + } else { + m_error = "Only supported parents are complex types and extra-includes"; + return false; + } + + inc = ctype->include(); + IncludeList lst = ctype->extraIncludes(); + ctype = ctype->designatedInterface(); + if (ctype != 0) { + ctype->setExtraIncludes(lst); + ctype->setInclude(inc); + } + } break; + case StackElement::Rejection: + { + QString cls = attributes["class"]; + QString function = attributes["function-name"]; + QString field = attributes["field-name"]; + QString enum_ = attributes["enum-name"]; + if (cls == "*" && function == "*" && field == "*" && enum_ == "*") { + m_error = "bad reject entry, neither 'class', 'function-name' nor " + "'field' specified"; + return false; + } + m_database->addRejection(cls, function, field, enum_); + } break; + case StackElement::Template: + element->value.templateEntry = new TemplateEntry(attributes["name"]); + break; + case StackElement::TemplateInstanceEnum: + if (!(topElement.type & StackElement::CodeSnipMask) && (topElement.type != StackElement::Template) + && (topElement.type != StackElement::CustomMetaConstructor) + && (topElement.type != StackElement::CustomMetaDestructor) + && (topElement.type != StackElement::ConversionRule)) + { + m_error = "Can only insert templates into code snippets, templates, custom-constructors, custom-destructors or " + "conversion-rule."; + return false; + } + element->value.templateInstance = new TemplateInstance(attributes["name"]); + break; + case StackElement::Replace: + if (topElement.type != StackElement::TemplateInstanceEnum) { + m_error = "Can only insert replace rules into insert-template."; + return false; + } + element->parent->value.templateInstance->addReplaceRule(attributes["from"], attributes["to"]); + break; + default: + break; // nada + }; + } + + current = element.release(); + return true; } -TypeDatabase *TypeDatabase::instance() +TypeDatabase* TypeDatabase::instance() { - static TypeDatabase *db = new TypeDatabase(); - return db; + static TypeDatabase* db = new TypeDatabase(); + return db; } -TypeDatabase::TypeDatabase() : m_suppressWarnings(true) +TypeDatabase::TypeDatabase() + : m_suppressWarnings(true) { - StringTypeEntry* mainStringType = new StringTypeEntry("QString"); - addType(mainStringType); + StringTypeEntry* mainStringType = new StringTypeEntry("QString"); + addType(mainStringType); - StringTypeEntry *e = new StringTypeEntry("QLatin1String"); - e->setPreferredConversion(false); - e->setEquivalentType(mainStringType); - addType(e); + StringTypeEntry* e = new StringTypeEntry("QLatin1String"); + e->setPreferredConversion(false); + e->setEquivalentType(mainStringType); + addType(e); - e = new StringTypeEntry("QStringRef"); - e->setPreferredConversion(false); - e->setEquivalentType(mainStringType); - addType(e); + e = new StringTypeEntry("QStringRef"); + e->setPreferredConversion(false); + e->setEquivalentType(mainStringType); + addType(e); - e = new StringTypeEntry("QStringView"); - e->setPreferredConversion(false); - e->setEquivalentType(mainStringType); - addType(e); + e = new StringTypeEntry("QStringView"); + e->setPreferredConversion(false); + e->setEquivalentType(mainStringType); + addType(e); - e = new StringTypeEntry("QAnyStringView"); - e->setPreferredConversion(false); - e->setEquivalentType(mainStringType); - addType(e); + e = new StringTypeEntry("QAnyStringView"); + e->setPreferredConversion(false); + e->setEquivalentType(mainStringType); + addType(e); - e = new StringTypeEntry("QXmlStreamStringRef"); - e->setPreferredConversion(false); - addType(e); + e = new StringTypeEntry("QXmlStreamStringRef"); + e->setPreferredConversion(false); + addType(e); - addType(new CharTypeEntry("QChar")); + addType(new CharTypeEntry("QChar")); - CharTypeEntry *c = new CharTypeEntry("QLatin1Char"); - c->setPreferredConversion(false); - addType(c); + CharTypeEntry* c = new CharTypeEntry("QLatin1Char"); + c->setPreferredConversion(false); + addType(c); - { - VariantTypeEntry *qvariant = new VariantTypeEntry("QVariant"); - qvariant->setCodeGeneration(TypeEntry::GenerateNothing); - addType(qvariant); - } + { + VariantTypeEntry* qvariant = new VariantTypeEntry("QVariant"); + qvariant->setCodeGeneration(TypeEntry::GenerateNothing); + addType(qvariant); + } - { - JObjectWrapperTypeEntry *wrapper = new JObjectWrapperTypeEntry("JObjectWrapper"); - wrapper->setCodeGeneration(TypeEntry::GenerateNothing); - addType(wrapper); - } + { + JObjectWrapperTypeEntry* wrapper = new JObjectWrapperTypeEntry("JObjectWrapper"); + wrapper->setCodeGeneration(TypeEntry::GenerateNothing); + addType(wrapper); + } - //addType(new ThreadTypeEntry()); - addType(new VoidTypeEntry()); - - // Predefined containers... - addType(new ContainerTypeEntry("QList", ContainerTypeEntry::ListContainer)); - addType(new ContainerTypeEntry("QStringList", ContainerTypeEntry::StringListContainer)); - addType(new ContainerTypeEntry("QLinkedList", ContainerTypeEntry::LinkedListContainer)); - addType(new ContainerTypeEntry("QVector", ContainerTypeEntry::VectorContainer)); - addType(new ContainerTypeEntry("QStack", ContainerTypeEntry::StackContainer)); - addType(new ContainerTypeEntry("QSet", ContainerTypeEntry::SetContainer)); - addType(new ContainerTypeEntry("QMap", ContainerTypeEntry::MapContainer)); - addType(new ContainerTypeEntry("QHash", ContainerTypeEntry::HashContainer)); - addType(new ContainerTypeEntry("QPair", ContainerTypeEntry::PairContainer)); - addType(new ContainerTypeEntry("std::pair", ContainerTypeEntry::PairContainer)); - addType(new ContainerTypeEntry("QQueue", ContainerTypeEntry::QueueContainer)); - addType(new ContainerTypeEntry("QMultiMap", ContainerTypeEntry::MultiMapContainer)); - - addRemoveFunctionToTemplates(this); + //addType(new ThreadTypeEntry()); + addType(new VoidTypeEntry()); + + // Predefined containers... + addType(new ContainerTypeEntry("QList", ContainerTypeEntry::ListContainer)); + addType(new ContainerTypeEntry("QStringList", ContainerTypeEntry::StringListContainer)); + addType(new ContainerTypeEntry("QLinkedList", ContainerTypeEntry::LinkedListContainer)); + addType(new ContainerTypeEntry("QVector", ContainerTypeEntry::VectorContainer)); + addType(new ContainerTypeEntry("QStack", ContainerTypeEntry::StackContainer)); + addType(new ContainerTypeEntry("QSet", ContainerTypeEntry::SetContainer)); + addType(new ContainerTypeEntry("QMap", ContainerTypeEntry::MapContainer)); + addType(new ContainerTypeEntry("QHash", ContainerTypeEntry::HashContainer)); + addType(new ContainerTypeEntry("QPair", ContainerTypeEntry::PairContainer)); + addType(new ContainerTypeEntry("std::pair", ContainerTypeEntry::PairContainer)); + addType(new ContainerTypeEntry("QQueue", ContainerTypeEntry::QueueContainer)); + addType(new ContainerTypeEntry("QMultiMap", ContainerTypeEntry::MultiMapContainer)); + + addRemoveFunctionToTemplates(this); } void TypeDatabase::finalSetup() { TypeEntry* byteArrayType = findType("QByteArray"); if (byteArrayType) { - // Support QByteArrayView as alternative parameter type. - // Using StringTypeEntry for it, because no wrappers are generated for those types - StringTypeEntry* e = new StringTypeEntry("QByteArrayView"); - e->setPreferredConversion(false); - e->setEquivalentType(byteArrayType); - addType(e); + // Support QByteArrayView as alternative parameter type. + // Using StringTypeEntry for it, because no wrappers are generated for those types + StringTypeEntry* e = new StringTypeEntry("QByteArrayView"); + e->setPreferredConversion(false); + e->setEquivalentType(byteArrayType); + addType(e); } } -bool TypeDatabase::parseFile(const QString &filename, unsigned int qtVersion, bool generate) +bool TypeDatabase::parseFile(const QString& filename, unsigned int qtVersion, bool generate) { - QFile file(filename); + QFile file(filename); - // Attempt to open the file from the specified path + // Attempt to open the file from the specified path + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + // If opening fails, attempt to load from Qt resources + file.setFileName(":/trolltech/generator/" + filename); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - // If opening fails, attempt to load from Qt resources - file.setFileName(":/trolltech/generator/" + filename); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - ReportHandler::warning(QString::fromLatin1("Could not open typesystem file: '%1'").arg(filename)); - return false; - } + ReportHandler::warning(QString::fromLatin1("Could not open typesystem file: '%1'").arg(filename)); + return false; } + } - int count = m_entries.size(); + int count = m_entries.size(); - Handler handler(this, qtVersion, generate); - QXmlStreamReader reader(&file); + Handler handler(this, qtVersion, generate); + QXmlStreamReader reader(&file); - bool ok = handler.parse(reader); - if (!ok && !handler.errorString().isEmpty()) - ReportHandler::warning(handler.errorString()); + bool ok = handler.parse(reader); + if (!ok && !handler.errorString().isEmpty()) + ReportHandler::warning(handler.errorString()); - int newCount = m_entries.size(); + int newCount = m_entries.size(); - ReportHandler::debugSparse(QString::fromLatin1("Parsed: '%1', %2 new entries") - .arg(filename) - .arg(newCount - count)); + ReportHandler::debugSparse(QString::fromLatin1("Parsed: '%1', %2 new entries").arg(filename).arg(newCount - count)); - return ok; + return ok; } QString PrimitiveTypeEntry::javaObjectName() const { - static QHash table; - if (table.isEmpty()) { - table["boolean"] = "Boolean"; - table["byte"] = "Byte"; - table["char"] = "Character"; - table["short"] = "Short"; - table["int"] = "Integer"; - table["long"] = "Long"; - table["float"] = "Float"; - table["double"] = "Double"; - } - Q_ASSERT(table.contains(targetLangName())); - return table[targetLangName()]; + static QHash table; + if (table.isEmpty()) { + table["boolean"] = "Boolean"; + table["byte"] = "Byte"; + table["char"] = "Character"; + table["short"] = "Short"; + table["int"] = "Integer"; + table["long"] = "Long"; + table["float"] = "Float"; + table["double"] = "Double"; + } + Q_ASSERT(table.contains(targetLangName())); + return table[targetLangName()]; } -ContainerTypeEntry *TypeDatabase::findContainerType(const QString &name) +ContainerTypeEntry* TypeDatabase::findContainerType(const QString& name) { - QString template_name = name; + QString template_name = name; - int pos = name.indexOf('<'); - if (pos > 0) - template_name = name.left(pos); + int pos = name.indexOf('<'); + if (pos > 0) + template_name = name.left(pos); - TypeEntry *type_entry = findType(template_name); - if (type_entry && type_entry->isContainer()) - return static_cast(type_entry); - return 0; + TypeEntry* type_entry = findType(template_name); + if (type_entry && type_entry->isContainer()) + return static_cast(type_entry); + return 0; } -PrimitiveTypeEntry *TypeDatabase::findTargetLangPrimitiveType(const QString &java_name) +PrimitiveTypeEntry* TypeDatabase::findTargetLangPrimitiveType(const QString& java_name) { - for (QList entries : m_entries.values()) { - for (TypeEntry* e : entries) { - if (e && e->isPrimitive()) { - PrimitiveTypeEntry *pe = static_cast(e); - if (pe->targetLangName() == java_name && pe->preferredConversion()) - return pe; - } - } + for (QList entries : m_entries.values()) { + for (TypeEntry* e : entries) { + if (e && e->isPrimitive()) { + PrimitiveTypeEntry* pe = static_cast(e); + if (pe->targetLangName() == java_name && pe->preferredConversion()) + return pe; + } } + } - return 0; + return 0; } -IncludeList TypeDatabase::extraIncludes(const QString &className) +IncludeList TypeDatabase::extraIncludes(const QString& className) { - ComplexTypeEntry *typeEntry = findComplexType(className); - if (typeEntry != 0) - return typeEntry->extraIncludes(); - else - return IncludeList(); + ComplexTypeEntry* typeEntry = findComplexType(className); + if (typeEntry != 0) + return typeEntry->extraIncludes(); + else + return IncludeList(); } - - QString Include::toString() const { - if (type == IncludePath) - return "#include <" + name + '>'; - else if (type == LocalPath) - return "#include \"" + name + "\""; - else - return "import " + name + ";"; + if (type == IncludePath) + return "#include <" + name + '>'; + else if (type == LocalPath) + return "#include \"" + name + "\""; + else + return "import " + name + ";"; } QString Modification::accessModifierString() const { - if (isPrivate()) return "private"; - if (isProtected()) return "protected"; - if (isPublic()) return "public"; - if (isFriendly()) return "friendly"; - return QString(); + if (isPrivate()) + return "private"; + if (isProtected()) + return "protected"; + if (isPublic()) + return "public"; + if (isFriendly()) + return "friendly"; + return QString(); } -FunctionModificationList ComplexTypeEntry::functionModifications(const QString &signature) const +FunctionModificationList ComplexTypeEntry::functionModifications(const QString& signature) const { - FunctionModificationList lst; - for (int i=0; ifindType(m_qualifier); - if (te != 0) - return te->targetLangName(); - else - return m_qualifier; + TypeEntry* te = TypeDatabase::instance()->findType(m_qualifier); + if (te != 0) + return te->targetLangName(); + else + return m_qualifier; } QString EnumTypeEntry::jniName() const { - return "jint"; + return "jint"; } QString FlagsTypeEntry::jniName() const { - return "jint"; + return "jint"; } QString FlagsTypeEntry::qualifiedTargetLangName() const { - return javaPackage() + "." + m_enum->javaQualifier() + "." + targetLangName(); + return javaPackage() + "." + m_enum->javaQualifier() + "." + targetLangName(); } - -void TypeDatabase::addRejection(const QString &class_name, const QString &function_name, - const QString &field_name, const QString &enum_name) +void TypeDatabase::addRejection(const QString& class_name, const QString& function_name, const QString& field_name, + const QString& enum_name) { - TypeRejection r; - r.class_name = class_name; - r.function_name = function_name; - r.field_name = field_name; - r.enum_name = enum_name; + TypeRejection r; + r.class_name = class_name; + r.function_name = function_name; + r.field_name = field_name; + r.enum_name = enum_name; - m_rejections << r; + m_rejections << r; } -bool TypeDatabase::isClassRejected(const QString &class_name) +bool TypeDatabase::isClassRejected(const QString& class_name) { - if (!m_rebuild_classes.isEmpty()) - return !m_rebuild_classes.contains(class_name); + if (!m_rebuild_classes.isEmpty()) + return !m_rebuild_classes.contains(class_name); - for (const TypeRejection& r : m_rejections) - if (r.class_name == class_name && r.function_name == "*" && r.field_name == "*" && r.enum_name == "*") { - return true; - } - return false; + for (const TypeRejection& r : m_rejections) + if (r.class_name == class_name && r.function_name == "*" && r.field_name == "*" && r.enum_name == "*") { + return true; + } + return false; } -bool TypeDatabase::isEnumRejected(const QString &class_name, const QString &enum_name) +bool TypeDatabase::isEnumRejected(const QString& class_name, const QString& enum_name) { - for (const TypeRejection& r : m_rejections) { - if (r.enum_name == enum_name - && (r.class_name == class_name || r.class_name == "*")) { - return true; - } + for (const TypeRejection& r : m_rejections) { + if (r.enum_name == enum_name && (r.class_name == class_name || r.class_name == "*")) { + return true; } + } - return false; + return false; } -bool TypeDatabase::isFunctionRejected(const QString &class_name, const QString &function_name) +bool TypeDatabase::isFunctionRejected(const QString& class_name, const QString& function_name) { - for (const TypeRejection& r : m_rejections) - if (r.function_name == function_name && - (r.class_name == class_name || r.class_name == "*")) - return true; - return false; + for (const TypeRejection& r : m_rejections) + if (r.function_name == function_name && (r.class_name == class_name || r.class_name == "*")) + return true; + return false; } - -bool TypeDatabase::isFieldRejected(const QString &class_name, const QString &field_name) +bool TypeDatabase::isFieldRejected(const QString& class_name, const QString& field_name) { - for (const TypeRejection& r : m_rejections) - if (r.field_name == field_name && - (r.class_name == class_name || r.class_name == "*")) - return true; - return false; + for (const TypeRejection& r : m_rejections) + if (r.field_name == field_name && (r.class_name == class_name || r.class_name == "*")) + return true; + return false; } void TypeDatabase::addType(TypeEntry* e) { - m_entries[e->qualifiedCppName()].append(e); - for (const QString& alias : e->aliases()) { - m_entries[alias].append(e); - } + m_entries[e->qualifiedCppName()].append(e); + for (const QString& alias : e->aliases()) { + m_entries[alias].append(e); + } } -FlagsTypeEntry *TypeDatabase::findFlagsType(const QString &name) const +FlagsTypeEntry* TypeDatabase::findFlagsType(const QString& name) const { - FlagsTypeEntry *fte = (FlagsTypeEntry *) findType(name); - return fte ? fte : (FlagsTypeEntry *) m_flags_entries.value(name); + FlagsTypeEntry* fte = (FlagsTypeEntry*)findType(name); + return fte ? fte : (FlagsTypeEntry*)m_flags_entries.value(name); } -QString TypeDatabase::globalNamespaceClassName(const TypeEntry * entry) +QString TypeDatabase::globalNamespaceClassName(const TypeEntry* entry) { - return "Qt" + entry->javaPackage().split('.').back(); + return "Qt" + entry->javaPackage().split('.').back(); } - /*! * The Visual Studio 2002 compiler doesn't support these symbols, * which our typedefs unforntuatly expand to. */ -QString fixCppTypeName(const QString &name) +QString fixCppTypeName(const QString& name) { - if (name == "long long") return "qint64"; - else if (name == "unsigned long long") return "quint64"; - return name; + if (name == "long long") + return "qint64"; + else if (name == "unsigned long long") + return "quint64"; + return name; } -QString formattedCodeHelper(QTextStream &s, Indentor &indentor, QStringList &lines) { - bool multilineComment = false; - bool lastEmpty = true; - QString lastLine; - while (!lines.isEmpty()) { - const QString line = lines.takeFirst().trimmed(); - if (line.isEmpty()) { - if (!lastEmpty) - s << Qt::endl; - lastEmpty = true; - continue; - } else { - lastEmpty = false; - } - if (line.startsWith("/*")) - multilineComment = true; - - if (multilineComment) { - s << indentor; - if (line.startsWith("*")) - s << " "; - s << line << Qt::endl; - if (line.endsWith("*/")) - multilineComment = false; - } else if (line.startsWith("}")) { - return line; - } else if (line.endsWith("}")) { - s << indentor << line << Qt::endl; - return 0; - } else if(line.endsWith("{")) { - s << indentor << line << Qt::endl; - QString tmp; - { - Indentation indent(indentor); - tmp = formattedCodeHelper(s, indentor, lines); - } - if (!tmp.isNull()) { - s << indentor << tmp << Qt::endl; - } - lastLine = tmp; - continue; - } else { - s << indentor; - if (!lastLine.isEmpty() && - !lastLine.endsWith(";") && - !line.startsWith("@") && - !line.startsWith("//") && - !lastLine.startsWith("//") && - !lastLine.endsWith("}") && - !line.startsWith("{")) - s << " "; - s << line << Qt::endl; - } - lastLine = line; +QString formattedCodeHelper(QTextStream& s, Indentor& indentor, QStringList& lines) +{ + bool multilineComment = false; + bool lastEmpty = true; + QString lastLine; + while (!lines.isEmpty()) { + const QString line = lines.takeFirst().trimmed(); + if (line.isEmpty()) { + if (!lastEmpty) + s << Qt::endl; + lastEmpty = true; + continue; + } else { + lastEmpty = false; } - return 0; + if (line.startsWith("/*")) + multilineComment = true; + + if (multilineComment) { + s << indentor; + if (line.startsWith("*")) + s << " "; + s << line << Qt::endl; + if (line.endsWith("*/")) + multilineComment = false; + } else if (line.startsWith("}")) { + return line; + } else if (line.endsWith("}")) { + s << indentor << line << Qt::endl; + return 0; + } else if (line.endsWith("{")) { + s << indentor << line << Qt::endl; + QString tmp; + { + Indentation indent(indentor); + tmp = formattedCodeHelper(s, indentor, lines); + } + if (!tmp.isNull()) { + s << indentor << tmp << Qt::endl; + } + lastLine = tmp; + continue; + } else { + s << indentor; + if (!lastLine.isEmpty() && !lastLine.endsWith(";") && !line.startsWith("@") && !line.startsWith("//") + && !lastLine.startsWith("//") && !lastLine.endsWith("}") && !line.startsWith("{")) + s << " "; + s << line << Qt::endl; + } + lastLine = line; + } + return 0; } - -QTextStream &CodeSnip::formattedCode(QTextStream &s, Indentor &indentor) const +QTextStream& CodeSnip::formattedCode(QTextStream& s, Indentor& indentor) const { - QStringList lst(code().split("\n")); - while (!lst.isEmpty()) { - QString tmp = formattedCodeHelper(s, indentor, lst); - if (!tmp.isNull()) { - s << indentor << tmp << Qt::endl; - } + QStringList lst(code().split("\n")); + while (!lst.isEmpty()) { + QString tmp = formattedCodeHelper(s, indentor, lst); + if (!tmp.isNull()) { + s << indentor << tmp << Qt::endl; } - s.flush(); - return s; + } + s.flush(); + return s; } -QString TemplateInstance::expandCode() const{ - TemplateEntry *templateEntry = TypeDatabase::instance()->findTemplate(m_name); - if(templateEntry){ - QString res = templateEntry->code(); - for (QString key : replaceRules.keys()){ - res.replace(key, replaceRules[key]); - } - return "// TEMPLATE - " + m_name + " - START" + res + "// TEMPLATE - " + m_name + " - END"; - } - else{ - ReportHandler::warning("insert-template referring to non-existing template '" + m_name + "'"); +QString TemplateInstance::expandCode() const +{ + TemplateEntry* templateEntry = TypeDatabase::instance()->findTemplate(m_name); + if (templateEntry) { + QString res = templateEntry->code(); + for (QString key : replaceRules.keys()) { + res.replace(key, replaceRules[key]); } - return QString(); + return "// TEMPLATE - " + m_name + " - START" + res + "// TEMPLATE - " + m_name + " - END"; + } else { + ReportHandler::warning("insert-template referring to non-existing template '" + m_name + "'"); + } + return QString(); } - -QString CodeSnipAbstract::code() const{ - QString res; - for (CodeSnipFragment *codeFrag : codeList){ - res.append(codeFrag->code()); - } - return res; +QString CodeSnipAbstract::code() const +{ + QString res; + for (CodeSnipFragment* codeFrag : codeList) { + res.append(codeFrag->code()); + } + return res; } -QString CodeSnipFragment::code() const{ - if(m_instance) - return m_instance->expandCode(); - else - return m_code; +QString CodeSnipFragment::code() const +{ + if (m_instance) + return m_instance->expandCode(); + else + return m_code; } QString FunctionModification::toString() const { - QString str = signature + QLatin1String("->"); - if (modifiers & AccessModifierMask) { - switch (modifiers & AccessModifierMask) { - case Private: str += QLatin1String("private"); break; - case Protected: str += QLatin1String("protected"); break; - case Public: str += QLatin1String("public"); break; - case Friendly: str += QLatin1String("friendly"); break; - } + QString str = signature + QLatin1String("->"); + if (modifiers & AccessModifierMask) { + switch (modifiers & AccessModifierMask) { + case Private: + str += QLatin1String("private"); + break; + case Protected: + str += QLatin1String("protected"); + break; + case Public: + str += QLatin1String("public"); + break; + case Friendly: + str += QLatin1String("friendly"); + break; } + } - if (modifiers & Final) str += QLatin1String("final"); - if (modifiers & NonFinal) str += QLatin1String("non-final"); + if (modifiers & Final) + str += QLatin1String("final"); + if (modifiers & NonFinal) + str += QLatin1String("non-final"); - if (modifiers & Readable) str += QLatin1String("readable"); - if (modifiers & Writable) str += QLatin1String("writable"); + if (modifiers & Readable) + str += QLatin1String("readable"); + if (modifiers & Writable) + str += QLatin1String("writable"); - if (modifiers & CodeInjection) { - for (CodeSnip s : snips) { - str += QLatin1String("\n//code injection:\n"); - str += s.code(); - } + if (modifiers & CodeInjection) { + for (CodeSnip s : snips) { + str += QLatin1String("\n//code injection:\n"); + str += s.code(); } + } - if (modifiers & Rename) str += QLatin1String("renamed:") + renamedToName; + if (modifiers & Rename) + str += QLatin1String("renamed:") + renamedToName; - if (modifiers & Deprecated) str += QLatin1String("deprecate"); + if (modifiers & Deprecated) + str += QLatin1String("deprecate"); - if (modifiers & ReplaceExpression) str += QLatin1String("replace-expression"); + if (modifiers & ReplaceExpression) + str += QLatin1String("replace-expression"); - return str; + return str; } -static void removeFunction(ComplexTypeEntry *e, const char *signature) +static void removeFunction(ComplexTypeEntry* e, const char* signature) { - FunctionModification mod; - mod.signature = TypeSystem::normalizedSignature(signature); - mod.removal = TypeSystem::All; + FunctionModification mod; + mod.signature = TypeSystem::normalizedSignature(signature); + mod.removal = TypeSystem::All; - e->addFunctionModification(mod); + e->addFunctionModification(mod); } - - - -static void injectCode(ComplexTypeEntry *e, - const char *signature, - const QByteArray &code, - const ArgumentMap &args) +static void injectCode(ComplexTypeEntry* e, const char* signature, const QByteArray& code, const ArgumentMap& args) { - CodeSnip snip; - snip.language = TypeSystem::NativeCode; - snip.position = CodeSnip::Beginning; - snip.addCode(QString::fromLatin1(code)); - snip.argumentMap = args; - - FunctionModification mod; - mod.signature = TypeSystem::normalizedSignature(signature); - mod.snips << snip; - mod.modifiers = Modification::CodeInjection; - e->addFunctionModification(mod); + CodeSnip snip; + snip.language = TypeSystem::NativeCode; + snip.position = CodeSnip::Beginning; + snip.addCode(QString::fromLatin1(code)); + snip.argumentMap = args; + + FunctionModification mod; + mod.signature = TypeSystem::normalizedSignature(signature); + mod.snips << snip; + mod.modifiers = Modification::CodeInjection; + e->addFunctionModification(mod); } - -static void addRemoveFunctionToTemplates(TypeDatabase *db) +static void addRemoveFunctionToTemplates(TypeDatabase* db) { - ContainerTypeEntry *qvector = db->findContainerType(QLatin1String("QVector")); - removeFunction(qvector, "constData() const"); - removeFunction(qvector, "data() const"); - removeFunction(qvector, "data()"); - removeFunction(qvector, "first()"); - removeFunction(qvector, "last()"); - removeFunction(qvector, "operator[](int)"); - removeFunction(qvector, "operator[](int) const"); - removeFunction(qvector, "operator=(QVector)"); - - ContainerTypeEntry *qlist = db->findContainerType(QLatin1String("QList")); - removeFunction(qlist, "constData() const"); - removeFunction(qlist, "data() const"); - removeFunction(qlist, "data()"); - removeFunction(qlist, "back()"); - removeFunction(qlist, "front()"); - removeFunction(qlist, "first()"); - removeFunction(qlist, "last()"); - removeFunction(qlist, "operator[](int)"); - removeFunction(qlist, "operator[](int) const"); - removeFunction(qlist, "operator=(QList)"); - - ContainerTypeEntry *qqueue = db->findContainerType(QLatin1String("QQueue")); - removeFunction(qqueue, "head() const"); - - // QtScript: The next part is Java-specific, skip it for now... - return; - - ArgumentMap args1; - args1[1] = QLatin1String("$1"); - ArgumentMap args2 = args1; - args2[2] = QLatin1String("$2"); - - QByteArray code = - "\nif ($1 >= __qt_this->size() || $1 < 0) {" - "\n __jni_env->ThrowNew(__jni_env->FindClass(\"java/lang/IndexOutOfBoundsException\")," - "\n QString::fromLatin1(\"Accessing container of size %3 at %4\")" - "\n .arg(__qt_this->size()).arg($1).toLatin1());" - "\n return;" - "\n}"; - - QByteArray code_with_return = QByteArray(code).replace("return;", "return 0;"); - - QByteArray code_index_length = - "\nif ($1 < 0 || $2 < 0 || ($1 + $2) >= __qt_this->size()) {" - "\n __jni_env->ThrowNew(__jni_env->FindClass(\"java/lang/IndexOutOfBoundsException\")," - "\n QString::fromLatin1(\"Accessing container of size %3 from %4 to %5\")" - "\n .arg(__qt_this->size()).arg($1).arg($1+$2).toLatin1());" - "\n return;" - "\n}"; - - QByteArray code_non_empty = - "\nif (__qt_this->isEmpty()) {" - "\n __jni_env->ThrowNew(__jni_env->FindClass(\"java/lang/IndexOutOfBoundsException\")," - "\n QString::fromLatin1(\"Accessing empty container...\").toLatin1());" - "\n return;" - "\n}"; - - QByteArray code_two_indices = - "\nif ($1 < 0 || $2 < 0 || $1 >= __qt_this->size() || $2 >= __qt_this->size()) {" - "\n __jni_env->ThrowNew(__jni_env->FindClass(\"java/lang/IndexOutOfBoundsException\")," - "\n QString::fromLatin1(\"Accessing container of size %3 from %4 to %5\")" - "\n .arg(__qt_this->size()).arg($1).arg($1+$2).toLatin1());" - "\n return;" - "\n}"; - - { // QVector safty... - injectCode(qvector, "at(int) const", code_with_return, args1); - injectCode(qvector, "replace(int,T)", code, args1); - injectCode(qvector, "remove(int)", code, args1); - injectCode(qvector, "remove(int, int)", code_index_length, args2); - injectCode(qvector, "pop_back()", code_non_empty, ArgumentMap()); - injectCode(qvector, "pop_front()", code_non_empty, ArgumentMap()); - } - - { // QList safty... - injectCode(qlist, "at(int) const", code_with_return, args1); - injectCode(qlist, "replace(int, T)", code, args1); - injectCode(qlist, "pop_back()", code_non_empty, ArgumentMap()); - injectCode(qlist, "pop_front()", code_non_empty, ArgumentMap()); - injectCode(qlist, "swap(int, int)", code_two_indices, args2); - injectCode(qlist, "move(int, int)", code_two_indices, args2); - injectCode(qlist, "removeAt(int)", code, args1); - injectCode(qlist, "takeAt(int)", code_with_return, args1); - } + ContainerTypeEntry* qvector = db->findContainerType(QLatin1String("QVector")); + removeFunction(qvector, "constData() const"); + removeFunction(qvector, "data() const"); + removeFunction(qvector, "data()"); + removeFunction(qvector, "first()"); + removeFunction(qvector, "last()"); + removeFunction(qvector, "operator[](int)"); + removeFunction(qvector, "operator[](int) const"); + removeFunction(qvector, "operator=(QVector)"); + + ContainerTypeEntry* qlist = db->findContainerType(QLatin1String("QList")); + removeFunction(qlist, "constData() const"); + removeFunction(qlist, "data() const"); + removeFunction(qlist, "data()"); + removeFunction(qlist, "back()"); + removeFunction(qlist, "front()"); + removeFunction(qlist, "first()"); + removeFunction(qlist, "last()"); + removeFunction(qlist, "operator[](int)"); + removeFunction(qlist, "operator[](int) const"); + removeFunction(qlist, "operator=(QList)"); + + ContainerTypeEntry* qqueue = db->findContainerType(QLatin1String("QQueue")); + removeFunction(qqueue, "head() const"); + + // QtScript: The next part is Java-specific, skip it for now... + return; + + ArgumentMap args1; + args1[1] = QLatin1String("$1"); + ArgumentMap args2 = args1; + args2[2] = QLatin1String("$2"); + + QByteArray code = "\nif ($1 >= __qt_this->size() || $1 < 0) {" + "\n __jni_env->ThrowNew(__jni_env->FindClass(\"java/lang/IndexOutOfBoundsException\")," + "\n QString::fromLatin1(\"Accessing container of size %3 at %4\")" + "\n .arg(__qt_this->size()).arg($1).toLatin1());" + "\n return;" + "\n}"; + + QByteArray code_with_return = QByteArray(code).replace("return;", "return 0;"); + + QByteArray code_index_length = + "\nif ($1 < 0 || $2 < 0 || ($1 + $2) >= __qt_this->size()) {" + "\n __jni_env->ThrowNew(__jni_env->FindClass(\"java/lang/IndexOutOfBoundsException\")," + "\n QString::fromLatin1(\"Accessing container of size %3 from %4 to %5\")" + "\n .arg(__qt_this->size()).arg($1).arg($1+$2).toLatin1());" + "\n return;" + "\n}"; + + QByteArray code_non_empty = + "\nif (__qt_this->isEmpty()) {" + "\n __jni_env->ThrowNew(__jni_env->FindClass(\"java/lang/IndexOutOfBoundsException\")," + "\n QString::fromLatin1(\"Accessing empty container...\").toLatin1());" + "\n return;" + "\n}"; + + QByteArray code_two_indices = + "\nif ($1 < 0 || $2 < 0 || $1 >= __qt_this->size() || $2 >= __qt_this->size()) {" + "\n __jni_env->ThrowNew(__jni_env->FindClass(\"java/lang/IndexOutOfBoundsException\")," + "\n QString::fromLatin1(\"Accessing container of size %3 from %4 to %5\")" + "\n .arg(__qt_this->size()).arg($1).arg($1+$2).toLatin1());" + "\n return;" + "\n}"; + + { // QVector safty... + injectCode(qvector, "at(int) const", code_with_return, args1); + injectCode(qvector, "replace(int,T)", code, args1); + injectCode(qvector, "remove(int)", code, args1); + injectCode(qvector, "remove(int, int)", code_index_length, args2); + injectCode(qvector, "pop_back()", code_non_empty, ArgumentMap()); + injectCode(qvector, "pop_front()", code_non_empty, ArgumentMap()); + } + { // QList safty... + injectCode(qlist, "at(int) const", code_with_return, args1); + injectCode(qlist, "replace(int, T)", code, args1); + injectCode(qlist, "pop_back()", code_non_empty, ArgumentMap()); + injectCode(qlist, "pop_front()", code_non_empty, ArgumentMap()); + injectCode(qlist, "swap(int, int)", code_two_indices, args2); + injectCode(qlist, "move(int, int)", code_two_indices, args2); + injectCode(qlist, "removeAt(int)", code, args1); + injectCode(qlist, "takeAt(int)", code_with_return, args1); + } } QByteArray TypeSystem::normalizedSignature(const char* signature) @@ -2199,8 +2182,7 @@ unsigned int TypeSystem::qtVersionFromString(const QString& value, bool& ok) { ok = true; QList values; - for (QString dotValue : value.split('.')) - { + for (QString dotValue : value.split('.')) { dotValue = dotValue.trimmed(); bool ok2; values.append(dotValue.toUInt(&ok2)); diff --git a/generator/typesystem.h b/generator/typesystem.h index bc1788d4b..1fce0f489 100644 --- a/generator/typesystem.h +++ b/generator/typesystem.h @@ -55,20 +55,20 @@ * QString original deprecated then it was removed in Qt6. This provides * forward compatibility with Qt6 for versions of Qt prior to 15.4: */ -#if QT_VERSION < QT_VERSION_CHECK(5,14,0) - namespace Qt { - const QString::SplitBehavior SkipEmptyParts = QString::SkipEmptyParts; - }; +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) +namespace Qt { +const QString::SplitBehavior SkipEmptyParts = QString::SkipEmptyParts; +}; #endif /* Qt < 5.14 only provided ::endl (global). Create a namespaced alias so code * can uniformly use Qt::endl across Qt versions. */ #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - namespace Qt { - using qt_endl_t = QTextStream& (*)(QTextStream&); - static constexpr qt_endl_t endl = ::endl; - } +namespace Qt { +using qt_endl_t = QTextStream& (*)(QTextStream&); +static constexpr qt_endl_t endl = ::endl; +} #endif /* END: Qt compatibility. */ @@ -88,25 +88,25 @@ extern QString strings_java_lang; extern QString strings_jchar; extern QString strings_jobject; -struct Include -{ - enum IncludeType { - IncludePath, - LocalPath, - TargetLangImport - }; +struct Include { + enum IncludeType { IncludePath, LocalPath, TargetLangImport }; - Include() : type(IncludePath) { } - Include(IncludeType t, const QString &nam) : type(t), name(nam) { }; + Include() + : type(IncludePath) + { + } + Include(IncludeType t, const QString& nam) + : type(t) + , name(nam) {}; - bool isValid() { return !name.isEmpty(); } + bool isValid() { return !name.isEmpty(); } - IncludeType type; - QString name; + IncludeType type; + QString name; - QString toString() const; + QString toString() const; - bool operator<(const Include &other) const { return name < other.name; } + bool operator<(const Include& other) const { return name < other.name; } }; typedef QList IncludeList; @@ -115,319 +115,322 @@ typedef QMap ArgumentMap; class TemplateInstance; namespace TypeSystem { - enum Language { - NoLanguage = 0x0000, - TargetLangCode = 0x0001, - NativeCode = 0x0002, - ShellCode = 0x0004, - ShellDeclaration = 0x0008, - PackageInitializer = 0x0010, - DestructorFunction = 0x0020, - Constructors = 0x0040, - Interface = 0x0080, - PyWrapperCode = 0x0100, - PyWrapperDeclaration = 0x0200, - PyWrapperOperators = 0x0400, - PyShellDeclaration = 0x0800, - PyInheritShellDeclaration = 0x1000, - PyInitSource = 0x2000, - PySetWrapperFunc = 0x4000, - PyInheritShellConstructorCode = 0x8000, - // masks - All = TargetLangCode - | NativeCode - | ShellCode - | ShellDeclaration - | PackageInitializer - | Constructors - | Interface - | DestructorFunction, - - JavaAndNativeCode = TargetLangCode | NativeCode, - TargetLangAndNativeCode = TargetLangCode | NativeCode - }; - - enum Ownership { - InvalidOwnership, - DefaultOwnership, - TargetLangOwnership, - CppOwnership, - TargetLangThisOwnership - }; - - //! A better normalized signature, which takes care of PODs with the same name - QByteArray normalizedSignature(const char* signature); - - //! Determine version ID from version string - unsigned int qtVersionFromString(const QString& value, bool& ok); -} - -struct ReferenceCount -{ - ReferenceCount() : threadSafe(false), access(Public) { } - enum Action { // 0x01 - 0xff - Invalid = 0x00, - Add = 0x01, - AddAll = 0x02, - Remove = 0x04, - Set = 0x08, - Ignore = 0x10, - - ActionsMask = 0xff, - - Padding = 0xffffffff - }; - - enum Flag { // 0x100 - 0xf00 - ThreadSafe = 0x100, - Static = 0x200, - DeclareVariable = 0x400, - - FlagsMask = 0xf00 - }; - - enum Access { // 0x1000 - 0xf000 - Private = 0x1000, - Protected = 0x2000, - Friendly = 0x3000, - Public = 0x4000, +enum Language { + NoLanguage = 0x0000, + TargetLangCode = 0x0001, + NativeCode = 0x0002, + ShellCode = 0x0004, + ShellDeclaration = 0x0008, + PackageInitializer = 0x0010, + DestructorFunction = 0x0020, + Constructors = 0x0040, + Interface = 0x0080, + PyWrapperCode = 0x0100, + PyWrapperDeclaration = 0x0200, + PyWrapperOperators = 0x0400, + PyShellDeclaration = 0x0800, + PyInheritShellDeclaration = 0x1000, + PyInitSource = 0x2000, + PySetWrapperFunc = 0x4000, + PyInheritShellConstructorCode = 0x8000, + // masks + All = TargetLangCode | NativeCode | ShellCode | ShellDeclaration | PackageInitializer | Constructors | Interface + | DestructorFunction, + + JavaAndNativeCode = TargetLangCode | NativeCode, + TargetLangAndNativeCode = TargetLangCode | NativeCode +}; - AccessMask = 0xf000 - }; +enum Ownership { InvalidOwnership, DefaultOwnership, TargetLangOwnership, CppOwnership, TargetLangThisOwnership }; - Action action; - QString variableName; - QString conditional; - QString declareVariable; +//! A better normalized signature, which takes care of PODs with the same name +QByteArray normalizedSignature(const char* signature); - uint threadSafe : 1; +//! Determine version ID from version string +unsigned int qtVersionFromString(const QString& value, bool& ok); +} - uint access; +struct ReferenceCount { + ReferenceCount() + : threadSafe(false) + , access(Public) + { + } + enum Action { // 0x01 - 0xff + Invalid = 0x00, + Add = 0x01, + AddAll = 0x02, + Remove = 0x04, + Set = 0x08, + Ignore = 0x10, + + ActionsMask = 0xff, + + Padding = 0xffffffff + }; + + enum Flag { // 0x100 - 0xf00 + ThreadSafe = 0x100, + Static = 0x200, + DeclareVariable = 0x400, + + FlagsMask = 0xf00 + }; + + enum Access { // 0x1000 - 0xf000 + Private = 0x1000, + Protected = 0x2000, + Friendly = 0x3000, + Public = 0x4000, + + AccessMask = 0xf000 + }; + + Action action; + QString variableName; + QString conditional; + QString declareVariable; + + uint threadSafe: 1; + + uint access; }; -class CodeSnipFragment{ - private: - const QString m_code; - TemplateInstance *m_instance; +class CodeSnipFragment +{ +private: + const QString m_code; + TemplateInstance* m_instance; - public: - CodeSnipFragment(const QString &code) - : m_code(code), - m_instance(0) - {} +public: + CodeSnipFragment(const QString& code) + : m_code(code) + , m_instance(0) + { + } - CodeSnipFragment(TemplateInstance *instance) + CodeSnipFragment(TemplateInstance* instance) : m_instance(instance) - {} + { + } - QString code() const; + QString code() const; }; -class CodeSnipAbstract{ +class CodeSnipAbstract +{ public: - QString code() const; + QString code() const; - void addCode(const QString &code){ - codeList.append(new CodeSnipFragment(code)); - } + void addCode(const QString& code) { codeList.append(new CodeSnipFragment(code)); } - void addTemplateInstance(TemplateInstance *ti){ - codeList.append(new CodeSnipFragment(ti)); - } + void addTemplateInstance(TemplateInstance* ti) { codeList.append(new CodeSnipFragment(ti)); } - QList codeList; + QList codeList; }; class CustomFunction : public CodeSnipAbstract { - public: - CustomFunction(const QString &n = QString()) : name(n) { } +public: + CustomFunction(const QString& n = QString()) + : name(n) + { + } - QString name; - QString param_name; + QString name; + QString param_name; }; class TemplateEntry : public CodeSnipAbstract { public: - TemplateEntry(const QString &name) - : m_name(name) - { - }; + TemplateEntry(const QString& name) + : m_name(name) {}; - QString name() const { - return m_name; - }; + QString name() const { return m_name; }; private: - QString m_name; + QString m_name; }; -typedef QHash TemplateEntryHash; +typedef QHash TemplateEntryHash; class TemplateInstance { - public: - TemplateInstance(const QString &name) - : m_name(name) - {} +public: + TemplateInstance(const QString& name) + : m_name(name) + { + } - void addReplaceRule(const QString &name, const QString &value){ - replaceRules[name]=value; - } + void addReplaceRule(const QString& name, const QString& value) { replaceRules[name] = value; } - QString expandCode() const; + QString expandCode() const; - QString name() const { - return m_name; - } + QString name() const { return m_name; } - private: - const QString m_name; - QHash replaceRules; +private: + const QString m_name; + QHash replaceRules; }; - class CodeSnip : public CodeSnipAbstract { - public: - enum Position { - Beginning, - End, - AfterThis, - // QtScript - PrototypeInitialization, - ConstructorInitialization, - Constructor - }; - - CodeSnip() : language(TypeSystem::TargetLangCode) { } - CodeSnip(TypeSystem::Language lang) : language(lang) { } - - // Very simple, easy to make code ugly if you try - QTextStream &formattedCode(QTextStream &s, Indentor &indentor) const; - - TypeSystem::Language language; - Position position; - ArgumentMap argumentMap; +public: + enum Position { + Beginning, + End, + AfterThis, + // QtScript + PrototypeInitialization, + ConstructorInitialization, + Constructor + }; + + CodeSnip() + : language(TypeSystem::TargetLangCode) + { + } + CodeSnip(TypeSystem::Language lang) + : language(lang) + { + } + + // Very simple, easy to make code ugly if you try + QTextStream& formattedCode(QTextStream& s, Indentor& indentor) const; + + TypeSystem::Language language; + Position position; + ArgumentMap argumentMap; }; typedef QList CodeSnipList; -struct ArgumentModification -{ - ArgumentModification(int idx) : removed_default_expression(false), removed(false), no_null_pointers(false), index(idx) - {} +struct ArgumentModification { + ArgumentModification(int idx) + : removed_default_expression(false) + , removed(false) + , no_null_pointers(false) + , index(idx) + { + } - // Should the default expression be removed? - uint removed_default_expression : 1; - uint removed : 1; - uint no_null_pointers : 1; - uint reset_after_use : 1; + // Should the default expression be removed? + uint removed_default_expression: 1; + uint removed: 1; + uint no_null_pointers: 1; + uint reset_after_use: 1; - // The index of this argument - int index; + // The index of this argument + int index; - // Reference count flags for this argument - QList referenceCounts; + // Reference count flags for this argument + QList referenceCounts; - // The text given for the new type of the argument - QString modified_type; + // The text given for the new type of the argument + QString modified_type; - QString replace_value; + QString replace_value; - // The code to be used to construct a return value when no_null_pointers is true and - // the returned value is null. If no_null_pointers is true and this string is - // empty, then the base class implementation will be used (or a default construction - // if there is no implementation) - QString null_pointer_default_value; + // The code to be used to construct a return value when no_null_pointers is true and + // the returned value is null. If no_null_pointers is true and this string is + // empty, then the base class implementation will be used (or a default construction + // if there is no implementation) + QString null_pointer_default_value; - // The text of the new default expression of the argument - QString replaced_default_expression; + // The text of the new default expression of the argument + QString replaced_default_expression; - // The new definition of ownership for a specific argument - QHash ownerships; + // The new definition of ownership for a specific argument + QHash ownerships; - // Different conversion rules - CodeSnipList conversion_rules; + // Different conversion rules + CodeSnipList conversion_rules; }; struct Modification { - enum Modifiers { - Private = 0x0001, - Protected = 0x0002, - Public = 0x0003, - Friendly = 0x0004, - AccessModifierMask = 0x000f, - - Final = 0x0010, - NonFinal = 0x0020, - FinalMask = Final | NonFinal, - - Readable = 0x0100, - Writable = 0x0200, - - CodeInjection = 0x1000, - Rename = 0x2000, - Deprecated = 0x4000, - ReplaceExpression = 0x8000, - VirtualSlot = 0x10000 | NonFinal - }; - - Modification() : modifiers(0) { } - - bool isAccessModifier() const { return modifiers & AccessModifierMask; } - Modifiers accessModifier() const { return Modifiers(modifiers & AccessModifierMask); } - bool isPrivate() const { return accessModifier() == Private; } - bool isProtected() const { return accessModifier() == Protected; } - bool isPublic() const { return accessModifier() == Public; } - bool isFriendly() const { return accessModifier() == Friendly; } - bool isFinal() const { return modifiers & Final; } - bool isNonFinal() const { return modifiers & NonFinal; } - bool isVirtualSlot() const { return (modifiers & VirtualSlot) == VirtualSlot; } - QString accessModifierString() const; - - bool isDeprecated() const { return modifiers & Deprecated; } - - void setRenamedTo(const QString &name) { renamedToName = name; } - QString renamedTo() const { return renamedToName; } - bool isRenameModifier() const { return modifiers & Rename; } - - uint modifiers; - QString renamedToName; + enum Modifiers { + Private = 0x0001, + Protected = 0x0002, + Public = 0x0003, + Friendly = 0x0004, + AccessModifierMask = 0x000f, + + Final = 0x0010, + NonFinal = 0x0020, + FinalMask = Final | NonFinal, + + Readable = 0x0100, + Writable = 0x0200, + + CodeInjection = 0x1000, + Rename = 0x2000, + Deprecated = 0x4000, + ReplaceExpression = 0x8000, + VirtualSlot = 0x10000 | NonFinal + }; + + Modification() + : modifiers(0) + { + } + + bool isAccessModifier() const { return modifiers & AccessModifierMask; } + Modifiers accessModifier() const { return Modifiers(modifiers & AccessModifierMask); } + bool isPrivate() const { return accessModifier() == Private; } + bool isProtected() const { return accessModifier() == Protected; } + bool isPublic() const { return accessModifier() == Public; } + bool isFriendly() const { return accessModifier() == Friendly; } + bool isFinal() const { return modifiers & Final; } + bool isNonFinal() const { return modifiers & NonFinal; } + bool isVirtualSlot() const { return (modifiers & VirtualSlot) == VirtualSlot; } + QString accessModifierString() const; + + bool isDeprecated() const { return modifiers & Deprecated; } + + void setRenamedTo(const QString& name) { renamedToName = name; } + QString renamedTo() const { return renamedToName; } + bool isRenameModifier() const { return modifiers & Rename; } + + uint modifiers; + QString renamedToName; }; -struct FunctionModification: public Modification -{ - FunctionModification() : removal(TypeSystem::NoLanguage) { } +struct FunctionModification : public Modification { + FunctionModification() + : removal(TypeSystem::NoLanguage) + { + } - bool isCodeInjection() const { return modifiers & CodeInjection; } - bool isRemoveModifier() const { return removal != TypeSystem::NoLanguage; } + bool isCodeInjection() const { return modifiers & CodeInjection; } + bool isRemoveModifier() const { return removal != TypeSystem::NoLanguage; } - QString toString() const; + QString toString() const; - QString signature; - QString association; - CodeSnipList snips; - TypeSystem::Language removal; + QString signature; + QString association; + CodeSnipList snips; + TypeSystem::Language removal; - QList argument_mods; + QList argument_mods; }; typedef QList FunctionModificationList; -struct FieldModification: public Modification -{ - bool isReadable() const { return modifiers & Readable; } - bool isWritable() const { return modifiers & Writable; } +struct FieldModification : public Modification { + bool isReadable() const { return modifiers & Readable; } + bool isWritable() const { return modifiers & Writable; } - QString name; + QString name; }; typedef QList FieldModificationList; struct ExpensePolicy { - ExpensePolicy() : limit(-1) { } - int limit; - QString cost; - bool isValid() const { return limit >= 0; } + ExpensePolicy() + : limit(-1) + { + } + int limit; + QString cost; + bool isValid() const { return limit >= 0; } }; class InterfaceTypeEntry; @@ -436,852 +439,837 @@ class ObjectTypeEntry; class TypeEntry { public: - enum Type { - PrimitiveType, - VoidType, - FlagsType, - EnumType, - TemplateArgumentType, - ThreadType, - BasicValueType, - StringType, - ContainerType, - InterfaceType, - ObjectType, - NamespaceType, - VariantType, - JObjectWrapperType, - CharType, - ArrayType, - TypeSystemType, - CustomType, - }; - - enum CodeGeneration { - GenerateTargetLang = 0x0001, - GenerateCpp = 0x0002, - GenerateForSubclass = 0x0004, - - GenerateNothing = 0, - GenerateAll = 0xffff, - GenerateCode = GenerateTargetLang | GenerateCpp - }; - - TypeEntry(const QString &name, Type t) - : m_name(name), - m_type(t), - m_code_generation(GenerateAll), - m_preferred_conversion(true) - { - }; - - virtual ~TypeEntry() { } - - Type type() const { return m_type; } - bool isPrimitive() const { return m_type == PrimitiveType; } - bool isEnum() const { return m_type == EnumType; } - bool isFlags() const { return m_type == FlagsType; } - bool isInterface() const { return m_type == InterfaceType; } - bool isObject() const { return m_type == ObjectType; } - bool isString() const { return m_type == StringType; } - bool isChar() const { return m_type == CharType; } - bool isNamespace() const { return m_type == NamespaceType; } - bool isContainer() const { return m_type == ContainerType; } - bool isVariant() const { return m_type == VariantType; } - bool isJObjectWrapper() const { return m_type == JObjectWrapperType; } - bool isArray() const { return m_type == ArrayType; } - bool isTemplateArgument() const { return m_type == TemplateArgumentType; } - bool isVoid() const { return m_type == VoidType; } - bool isThread() const { return m_type == ThreadType; } - bool isCustom() const { return m_type == CustomType; } - bool isBasicValue() const { return m_type == BasicValueType; } - bool isTypeSystem() const { return m_type == TypeSystemType; } - - virtual bool preferredConversion() const { return m_preferred_conversion; } - virtual void setPreferredConversion(bool b) { m_preferred_conversion = b; } - - // The type's name in C++, fully qualified - QString name() const { return m_name; } - - //! Alias names for this type (need to be fully qualified) - QStringList aliases() const { return m_aliases; } - void setAliases(const QStringList& aliases) { m_aliases = aliases; } - - uint codeGeneration() const { return m_code_generation; } - void setCodeGeneration(uint cg) { m_code_generation = cg; } - - virtual QString qualifiedCppName() const { return m_name; } - - // Its type's name in JNI - virtual QString jniName() const { return m_name; } - - // The type's name in TargetLang - virtual QString targetLangName() const { return m_name; } - - // The type to lookup when converting to TargetLang - virtual QString lookupName() const { return targetLangName(); } - - // The package - virtual QString javaPackage() const { return QString(); } - - virtual QString qualifiedTargetLangName() const { - QString pkg = javaPackage(); - if (pkg.isEmpty()) return targetLangName(); - return pkg + '.' + targetLangName(); - } - - virtual InterfaceTypeEntry *designatedInterface() const { return 0; } - - void setCustomConstructor(const CustomFunction &func) { m_customConstructor = func; } - CustomFunction customConstructor() const { return m_customConstructor; } - - void setCustomDestructor(const CustomFunction &func) { m_customDestructor = func; } - CustomFunction customDestructor() const { return m_customDestructor; } - - virtual bool isValue() const { return false; } - virtual bool isComplex() const { return false; } - - virtual bool isNativeIdBased() const { return false; } - - virtual TypeEntry* equivalentType() const { return nullptr; } + enum Type { + PrimitiveType, + VoidType, + FlagsType, + EnumType, + TemplateArgumentType, + ThreadType, + BasicValueType, + StringType, + ContainerType, + InterfaceType, + ObjectType, + NamespaceType, + VariantType, + JObjectWrapperType, + CharType, + ArrayType, + TypeSystemType, + CustomType, + }; + + enum CodeGeneration { + GenerateTargetLang = 0x0001, + GenerateCpp = 0x0002, + GenerateForSubclass = 0x0004, + + GenerateNothing = 0, + GenerateAll = 0xffff, + GenerateCode = GenerateTargetLang | GenerateCpp + }; + + TypeEntry(const QString& name, Type t) + : m_name(name) + , m_type(t) + , m_code_generation(GenerateAll) + , m_preferred_conversion(true) {}; + + virtual ~TypeEntry() {} + + Type type() const { return m_type; } + bool isPrimitive() const { return m_type == PrimitiveType; } + bool isEnum() const { return m_type == EnumType; } + bool isFlags() const { return m_type == FlagsType; } + bool isInterface() const { return m_type == InterfaceType; } + bool isObject() const { return m_type == ObjectType; } + bool isString() const { return m_type == StringType; } + bool isChar() const { return m_type == CharType; } + bool isNamespace() const { return m_type == NamespaceType; } + bool isContainer() const { return m_type == ContainerType; } + bool isVariant() const { return m_type == VariantType; } + bool isJObjectWrapper() const { return m_type == JObjectWrapperType; } + bool isArray() const { return m_type == ArrayType; } + bool isTemplateArgument() const { return m_type == TemplateArgumentType; } + bool isVoid() const { return m_type == VoidType; } + bool isThread() const { return m_type == ThreadType; } + bool isCustom() const { return m_type == CustomType; } + bool isBasicValue() const { return m_type == BasicValueType; } + bool isTypeSystem() const { return m_type == TypeSystemType; } + + virtual bool preferredConversion() const { return m_preferred_conversion; } + virtual void setPreferredConversion(bool b) { m_preferred_conversion = b; } + + // The type's name in C++, fully qualified + QString name() const { return m_name; } + + //! Alias names for this type (need to be fully qualified) + QStringList aliases() const { return m_aliases; } + void setAliases(const QStringList& aliases) { m_aliases = aliases; } + + uint codeGeneration() const { return m_code_generation; } + void setCodeGeneration(uint cg) { m_code_generation = cg; } + + virtual QString qualifiedCppName() const { return m_name; } + + // Its type's name in JNI + virtual QString jniName() const { return m_name; } + + // The type's name in TargetLang + virtual QString targetLangName() const { return m_name; } + + // The type to lookup when converting to TargetLang + virtual QString lookupName() const { return targetLangName(); } + + // The package + virtual QString javaPackage() const { return QString(); } + + virtual QString qualifiedTargetLangName() const + { + QString pkg = javaPackage(); + if (pkg.isEmpty()) + return targetLangName(); + return pkg + '.' + targetLangName(); + } + + virtual InterfaceTypeEntry* designatedInterface() const { return 0; } + + void setCustomConstructor(const CustomFunction& func) { m_customConstructor = func; } + CustomFunction customConstructor() const { return m_customConstructor; } + + void setCustomDestructor(const CustomFunction& func) { m_customDestructor = func; } + CustomFunction customDestructor() const { return m_customDestructor; } + + virtual bool isValue() const { return false; } + virtual bool isComplex() const { return false; } + + virtual bool isNativeIdBased() const { return false; } + + virtual TypeEntry* equivalentType() const { return nullptr; } private: - QString m_name; - QStringList m_aliases; - Type m_type; - uint m_code_generation; - CustomFunction m_customConstructor; - CustomFunction m_customDestructor; - bool m_preferred_conversion; + QString m_name; + QStringList m_aliases; + Type m_type; + uint m_code_generation; + CustomFunction m_customConstructor; + CustomFunction m_customDestructor; + bool m_preferred_conversion; }; -typedef QHash > TypeEntryHash; -typedef QHash SingleTypeEntryHash; - +typedef QHash> TypeEntryHash; +typedef QHash SingleTypeEntryHash; class TypeSystemTypeEntry : public TypeEntry { public: - TypeSystemTypeEntry(const QString &name) - : TypeEntry(name, TypeSystemType) - { - }; + TypeSystemTypeEntry(const QString& name) + : TypeEntry(name, TypeSystemType) {}; - QList snips; + QList snips; }; - class ThreadTypeEntry : public TypeEntry { public: - ThreadTypeEntry() : TypeEntry("QThread", ThreadType) { setCodeGeneration(GenerateNothing); } - - QString jniName() const { return strings_jobject; } - QString targetLangName() const { return strings_Thread; } - QString javaPackage() const { return strings_java_lang; } + ThreadTypeEntry() + : TypeEntry("QThread", ThreadType) + { + setCodeGeneration(GenerateNothing); + } + + QString jniName() const { return strings_jobject; } + QString targetLangName() const { return strings_Thread; } + QString javaPackage() const { return strings_java_lang; } }; class VoidTypeEntry : public TypeEntry { public: - VoidTypeEntry() : TypeEntry("void", VoidType) { } + VoidTypeEntry() + : TypeEntry("void", VoidType) + { + } }; class TemplateArgumentEntry : public TypeEntry { public: - TemplateArgumentEntry(const QString &name) - : TypeEntry(name, TemplateArgumentType), m_ordinal(0) - { - } + TemplateArgumentEntry(const QString& name) + : TypeEntry(name, TemplateArgumentType) + , m_ordinal(0) + { + } - int ordinal() const { return m_ordinal; } - void setOrdinal(int o) { m_ordinal = o; } + int ordinal() const { return m_ordinal; } + void setOrdinal(int o) { m_ordinal = o; } private: - int m_ordinal; + int m_ordinal; }; class ArrayTypeEntry : public TypeEntry { public: - ArrayTypeEntry(const TypeEntry *nested_type) : TypeEntry("Array", ArrayType), m_nested_type(nested_type) - { - Q_ASSERT(m_nested_type); - } - - void setNestedTypeEntry(TypeEntry *nested) { m_nested_type = nested; } - const TypeEntry *nestedTypeEntry() const { return m_nested_type; } - - QString targetLangName() const { return m_nested_type->targetLangName() + "[]"; } - QString jniName() const - { - if (m_nested_type->isPrimitive()) - return m_nested_type->jniName() + "Array"; - else - return "jobjectArray"; - } + ArrayTypeEntry(const TypeEntry* nested_type) + : TypeEntry("Array", ArrayType) + , m_nested_type(nested_type) + { + Q_ASSERT(m_nested_type); + } + + void setNestedTypeEntry(TypeEntry* nested) { m_nested_type = nested; } + const TypeEntry* nestedTypeEntry() const { return m_nested_type; } + + QString targetLangName() const { return m_nested_type->targetLangName() + "[]"; } + QString jniName() const + { + if (m_nested_type->isPrimitive()) + return m_nested_type->jniName() + "Array"; + else + return "jobjectArray"; + } private: - const TypeEntry *m_nested_type; + const TypeEntry* m_nested_type; }; - class PrimitiveTypeEntry : public TypeEntry { public: - PrimitiveTypeEntry(const QString &name) - : TypeEntry(name, PrimitiveType), m_preferred_conversion(true), m_preferred_java_type(true) - { - } + PrimitiveTypeEntry(const QString& name) + : TypeEntry(name, PrimitiveType) + , m_preferred_conversion(true) + , m_preferred_java_type(true) + { + } - QString targetLangName() const { return m_java_name; } - void setTargetLangName(const QString &targetLangName) { m_java_name = targetLangName; } + QString targetLangName() const { return m_java_name; } + void setTargetLangName(const QString& targetLangName) { m_java_name = targetLangName; } - QString jniName() const { return m_jni_name; } - void setJniName(const QString &jniName) { m_jni_name = jniName; } + QString jniName() const { return m_jni_name; } + void setJniName(const QString& jniName) { m_jni_name = jniName; } - QString javaObjectFullName() const { return javaObjectPackage() + "." + javaObjectName(); } - QString javaObjectName() const; - QString javaObjectPackage() const { return strings_java_lang; } + QString javaObjectFullName() const { return javaObjectPackage() + "." + javaObjectName(); } + QString javaObjectName() const; + QString javaObjectPackage() const { return strings_java_lang; } - virtual bool preferredConversion() const { return m_preferred_conversion; } - virtual void setPreferredConversion(bool b) { m_preferred_conversion = b; } + virtual bool preferredConversion() const { return m_preferred_conversion; } + virtual void setPreferredConversion(bool b) { m_preferred_conversion = b; } - virtual bool preferredTargetLangType() const { return m_preferred_java_type; } - virtual void setPreferredTargetLangType(bool b) { m_preferred_java_type = b; } + virtual bool preferredTargetLangType() const { return m_preferred_java_type; } + virtual void setPreferredTargetLangType(bool b) { m_preferred_java_type = b; } private: - QString m_java_name; - QString m_jni_name; - uint m_preferred_conversion : 1; - uint m_preferred_java_type : 1; + QString m_java_name; + QString m_jni_name; + uint m_preferred_conversion: 1; + uint m_preferred_java_type: 1; }; - - - -struct EnumValueRedirection -{ - EnumValueRedirection(const QString &rej, const QString &us) - : rejected(rej), - used(us) - { - } - QString rejected; - QString used; +struct EnumValueRedirection { + EnumValueRedirection(const QString& rej, const QString& us) + : rejected(rej) + , used(us) + { + } + QString rejected; + QString used; }; class EnumTypeEntry : public TypeEntry { public: - EnumTypeEntry(const QString &nspace, const QString &enumName) - : TypeEntry(nspace.isEmpty() ? enumName : nspace + QLatin1String("::") + enumName, - EnumType), - m_flags(0), - m_extensible(false), - m_force_integer(false) - { - m_qualifier = nspace; - m_java_name = enumName; - } + EnumTypeEntry(const QString& nspace, const QString& enumName) + : TypeEntry(nspace.isEmpty() ? enumName : nspace + QLatin1String("::") + enumName, EnumType) + , m_flags(0) + , m_extensible(false) + , m_force_integer(false) + { + m_qualifier = nspace; + m_java_name = enumName; + } - QString javaPackage() const { return m_package_name; } - void setTargetLangPackage(const QString &package) { m_package_name = package; } + QString javaPackage() const { return m_package_name; } + void setTargetLangPackage(const QString& package) { m_package_name = package; } - QString targetLangName() const { return m_java_name; } - QString javaQualifier() const; - QString qualifiedTargetLangName() const { - QString pkg = javaPackage(); - if (pkg.isEmpty()) return javaQualifier() + '.' + targetLangName(); - return pkg + '.' + javaQualifier() + '.' + targetLangName(); - } + QString targetLangName() const { return m_java_name; } + QString javaQualifier() const; + QString qualifiedTargetLangName() const + { + QString pkg = javaPackage(); + if (pkg.isEmpty()) + return javaQualifier() + '.' + targetLangName(); + return pkg + '.' + javaQualifier() + '.' + targetLangName(); + } - QString jniName() const; + QString jniName() const; - Include include() const { return m_include; } - void setInclude(const Include &inc) { m_include = inc; } + Include include() const { return m_include; } + void setInclude(const Include& inc) { m_include = inc; } - QString qualifier() const { return m_qualifier; } - void setQualifier(const QString &q) { m_qualifier = q; } + QString qualifier() const { return m_qualifier; } + void setQualifier(const QString& q) { m_qualifier = q; } - virtual bool preferredConversion() const { return false; } + virtual bool preferredConversion() const { return false; } - bool isBoundsChecked() const { return m_lower_bound.isEmpty() && m_upper_bound.isEmpty(); } + bool isBoundsChecked() const { return m_lower_bound.isEmpty() && m_upper_bound.isEmpty(); } - QString upperBound() const { return m_upper_bound; } - void setUpperBound(const QString &bound) { m_upper_bound = bound; } + QString upperBound() const { return m_upper_bound; } + void setUpperBound(const QString& bound) { m_upper_bound = bound; } - QString lowerBound() const { return m_lower_bound; } - void setLowerBound(const QString &bound) { m_lower_bound = bound; } + QString lowerBound() const { return m_lower_bound; } + void setLowerBound(const QString& bound) { m_lower_bound = bound; } - void setFlags(FlagsTypeEntry *flags) { m_flags = flags; } - FlagsTypeEntry *flags() const { return m_flags; } + void setFlags(FlagsTypeEntry* flags) { m_flags = flags; } + FlagsTypeEntry* flags() const { return m_flags; } - bool isExtensible() const { return m_extensible; } - void setExtensible(bool is) { m_extensible = is; } + bool isExtensible() const { return m_extensible; } + void setExtensible(bool is) { m_extensible = is; } - bool isEnumValueRejected(const QString &name) { return m_rejected_enums.contains(name); } - void addEnumValueRejection(const QString &name) { m_rejected_enums << name; } - QStringList enumValueRejections() const { return m_rejected_enums; } + bool isEnumValueRejected(const QString& name) { return m_rejected_enums.contains(name); } + void addEnumValueRejection(const QString& name) { m_rejected_enums << name; } + QStringList enumValueRejections() const { return m_rejected_enums; } - bool isEnumClass() const { return m_enum_class; } - void setEnumClass(bool enum_class) { m_enum_class = enum_class; } + bool isEnumClass() const { return m_enum_class; } + void setEnumClass(bool enum_class) { m_enum_class = enum_class; } - bool forceInteger() const { return m_force_integer; } - void setForceInteger(bool force) { m_force_integer = force; } + bool forceInteger() const { return m_force_integer; } + void setForceInteger(bool force) { m_force_integer = force; } private: - Include m_include; - QString m_package_name; - QString m_qualifier; - QString m_java_name; + Include m_include; + QString m_package_name; + QString m_qualifier; + QString m_java_name; - QString m_lower_bound; - QString m_upper_bound; + QString m_lower_bound; + QString m_upper_bound; - QStringList m_rejected_enums; + QStringList m_rejected_enums; - FlagsTypeEntry *m_flags; + FlagsTypeEntry* m_flags; - bool m_extensible; - bool m_enum_class; - bool m_force_integer; + bool m_extensible; + bool m_enum_class; + bool m_force_integer; }; class FlagsTypeEntry : public TypeEntry { public: - FlagsTypeEntry(const QString &name) : TypeEntry(name, FlagsType), m_enum(0) - { - } + FlagsTypeEntry(const QString& name) + : TypeEntry(name, FlagsType) + , m_enum(0) + { + } - QString qualifiedTargetLangName() const; - QString targetLangName() const { return m_java_name; } - QString jniName() const; - virtual bool preferredConversion() const { return false; } + QString qualifiedTargetLangName() const; + QString targetLangName() const { return m_java_name; } + QString jniName() const; + virtual bool preferredConversion() const { return false; } - QString originalName() const { return m_original_name; } - void setOriginalName(const QString &s) { m_original_name = s; } + QString originalName() const { return m_original_name; } + void setOriginalName(const QString& s) { m_original_name = s; } - QString flagsName() const { return m_java_name; } - void setFlagsName(const QString &name) { m_java_name = name; } + QString flagsName() const { return m_java_name; } + void setFlagsName(const QString& name) { m_java_name = name; } - bool forceInteger() const { return m_enum->forceInteger(); } + bool forceInteger() const { return m_enum->forceInteger(); } - EnumTypeEntry *originator() const { return m_enum; } - void setOriginator(EnumTypeEntry *e) { m_enum = e; } + EnumTypeEntry* originator() const { return m_enum; } + void setOriginator(EnumTypeEntry* e) { m_enum = e; } - QString javaPackage() const { return m_enum->javaPackage(); } + QString javaPackage() const { return m_enum->javaPackage(); } private: - QString m_original_name; - QString m_java_name; - EnumTypeEntry *m_enum; + QString m_original_name; + QString m_java_name; + EnumTypeEntry* m_enum; }; - class ComplexTypeEntry : public TypeEntry { public: - enum TypeFlag { - NoTypeFlags = 0x0, - ForceAbstract = 0x1, - DeleteInMainThread = 0x2, - Deprecated = 0x4 - }; - typedef QFlags TypeFlags; - - ComplexTypeEntry(const QString &name, Type t) - : TypeEntry(QString(name).replace("::", "__"), t), - m_qualified_cpp_name(name), - m_qobject(false), - m_polymorphic_base(false), - m_generic_class(false), - m_createShell(false), - m_createPromoter(false), - m_noCopy(false), - m_type_flags(TypeFlag::NoTypeFlags) - { - Include inc; - inc.name = "QVariant"; - inc.type = Include::IncludePath; - - addExtraInclude(inc); + enum TypeFlag { NoTypeFlags = 0x0, ForceAbstract = 0x1, DeleteInMainThread = 0x2, Deprecated = 0x4 }; + typedef QFlags TypeFlags; + + ComplexTypeEntry(const QString& name, Type t) + : TypeEntry(QString(name).replace("::", "__"), t) + , m_qualified_cpp_name(name) + , m_qobject(false) + , m_polymorphic_base(false) + , m_generic_class(false) + , m_createShell(false) + , m_createPromoter(false) + , m_noCopy(false) + , m_type_flags(TypeFlag::NoTypeFlags) + { + Include inc; + inc.name = "QVariant"; + inc.type = Include::IncludePath; + + addExtraInclude(inc); + } + + bool isComplex() const { return true; } + + IncludeList extraIncludes() const { return m_extra_includes; } + void setExtraIncludes(const IncludeList& includes) { m_extra_includes = includes; } + void addExtraInclude(const Include& include) + { + if (!m_includes_used.value(include.name, false)) { + m_extra_includes << include; + m_includes_used[include.name] = true; } + } - bool isComplex() const { return true; } + ComplexTypeEntry* copy() const + { + ComplexTypeEntry* centry = new ComplexTypeEntry(name(), type()); + centry->setInclude(include()); + centry->setExtraIncludes(extraIncludes()); + centry->setFunctionModifications(functionModifications()); + centry->setFieldModifications(fieldModifications()); + centry->setQObject(isQObject()); + centry->setDefaultSuperclass(defaultSuperclass()); + centry->setCodeSnips(codeSnips()); + centry->setTargetLangPackage(javaPackage()); - IncludeList extraIncludes() const { return m_extra_includes; } - void setExtraIncludes(const IncludeList &includes) { m_extra_includes = includes; } - void addExtraInclude(const Include &include) - { - if (!m_includes_used.value(include.name, false)) { - m_extra_includes << include; - m_includes_used[include.name] = true; - } - } + return centry; + } - ComplexTypeEntry *copy() const - { - ComplexTypeEntry *centry = new ComplexTypeEntry(name(), type()); - centry->setInclude(include()); - centry->setExtraIncludes(extraIncludes()); - centry->setFunctionModifications(functionModifications()); - centry->setFieldModifications(fieldModifications()); - centry->setQObject(isQObject()); - centry->setDefaultSuperclass(defaultSuperclass()); - centry->setCodeSnips(codeSnips()); - centry->setTargetLangPackage(javaPackage()); - - return centry; - } + void setLookupName(const QString& name) { m_lookup_name = name; } - void setLookupName(const QString &name) - { - m_lookup_name = name; - } - - virtual QString lookupName() const - { - return m_lookup_name.isEmpty() ? targetLangName() : m_lookup_name; - } + virtual QString lookupName() const { return m_lookup_name.isEmpty() ? targetLangName() : m_lookup_name; } - QString jniName() const { return strings_jobject; } + QString jniName() const { return strings_jobject; } + Include include() const { return m_include; } + void setInclude(const Include& inc) { m_include = inc; } - Include include() const { return m_include; } - void setInclude(const Include &inc) { m_include = inc; } - - void setTypeFlags(TypeFlags flags) - { - m_type_flags = flags; - } - - TypeFlags typeFlags() const - { - return m_type_flags; - } + void setTypeFlags(TypeFlags flags) { m_type_flags = flags; } - CodeSnipList codeSnips() const { return m_code_snips; } - void setCodeSnips(const CodeSnipList &codeSnips) { m_code_snips = codeSnips; } - void addCodeSnip(const CodeSnip &codeSnip) { m_code_snips << codeSnip; } + TypeFlags typeFlags() const { return m_type_flags; } - FunctionModificationList functionModifications() const { return m_function_mods; } - void setFunctionModifications(const FunctionModificationList &functionModifications) { - m_function_mods = functionModifications; - } - void addFunctionModification(const FunctionModification &functionModification) { - m_function_mods << functionModification; - } - FunctionModificationList functionModifications(const QString &signature) const; + CodeSnipList codeSnips() const { return m_code_snips; } + void setCodeSnips(const CodeSnipList& codeSnips) { m_code_snips = codeSnips; } + void addCodeSnip(const CodeSnip& codeSnip) { m_code_snips << codeSnip; } - FieldModification fieldModification(const QString &name) const; - void setFieldModifications(const FieldModificationList &mods) { m_field_mods = mods; } - FieldModificationList fieldModifications() const { return m_field_mods; } + FunctionModificationList functionModifications() const { return m_function_mods; } + void setFunctionModifications(const FunctionModificationList& functionModifications) + { + m_function_mods = functionModifications; + } + void addFunctionModification(const FunctionModification& functionModification) + { + m_function_mods << functionModification; + } + FunctionModificationList functionModifications(const QString& signature) const; - QString javaPackage() const { return m_package; } - void setTargetLangPackage(const QString &package) { m_package = package; } + FieldModification fieldModification(const QString& name) const; + void setFieldModifications(const FieldModificationList& mods) { m_field_mods = mods; } + FieldModificationList fieldModifications() const { return m_field_mods; } - bool isQObject() const { return m_qobject; } - void setQObject(bool qobject) { m_qobject = qobject; } + QString javaPackage() const { return m_package; } + void setTargetLangPackage(const QString& package) { m_package = package; } - QString defaultSuperclass() const { return m_default_superclass; } - void setDefaultSuperclass(const QString &sc) { m_default_superclass = sc; } + bool isQObject() const { return m_qobject; } + void setQObject(bool qobject) { m_qobject = qobject; } - virtual QString qualifiedCppName() const { return m_qualified_cpp_name; } + QString defaultSuperclass() const { return m_default_superclass; } + void setDefaultSuperclass(const QString& sc) { m_default_superclass = sc; } + virtual QString qualifiedCppName() const { return m_qualified_cpp_name; } - void setIsPolymorphicBase(bool on) - { - m_polymorphic_base = on; - } - bool isPolymorphicBase() const { return m_polymorphic_base; } + void setIsPolymorphicBase(bool on) { m_polymorphic_base = on; } + bool isPolymorphicBase() const { return m_polymorphic_base; } - void setCreateShell(bool on) - { - m_createShell = on; - } - bool shouldCreateShell() const { return m_createShell; } + void setCreateShell(bool on) { m_createShell = on; } + bool shouldCreateShell() const { return m_createShell; } - void setCreatePromoter(bool on) - { - m_createPromoter = on; - } - bool shouldCreatePromoter() const { return m_createPromoter; } + void setCreatePromoter(bool on) { m_createPromoter = on; } + bool shouldCreatePromoter() const { return m_createPromoter; } - void setPolymorphicIdValue(const QString &value) - { - m_polymorphic_id_value = value; - } - QString polymorphicIdValue() const { return m_polymorphic_id_value; } + void setPolymorphicIdValue(const QString& value) { m_polymorphic_id_value = value; } + QString polymorphicIdValue() const { return m_polymorphic_id_value; } - void setExpensePolicy(const ExpensePolicy &policy) { m_expense_policy = policy; } - const ExpensePolicy &expensePolicy() const { return m_expense_policy; } + void setExpensePolicy(const ExpensePolicy& policy) { m_expense_policy = policy; } + const ExpensePolicy& expensePolicy() const { return m_expense_policy; } - QString targetType() const { return m_target_type; } - void setTargetType(const QString &code) { m_target_type = code; } + QString targetType() const { return m_target_type; } + void setTargetType(const QString& code) { m_target_type = code; } - QString targetLangName() const { return m_java_name.isEmpty() - ? TypeEntry::targetLangName() - : m_java_name; - } - void setTargetLangName(const QString &name) { m_java_name = name; } + QString targetLangName() const { return m_java_name.isEmpty() ? TypeEntry::targetLangName() : m_java_name; } + void setTargetLangName(const QString& name) { m_java_name = name; } - bool isGenericClass() const { return m_generic_class; } - void setGenericClass(bool isGeneric) { m_generic_class = isGeneric; } + bool isGenericClass() const { return m_generic_class; } + void setGenericClass(bool isGeneric) { m_generic_class = isGeneric; } - bool hasNoCopy() const { return m_noCopy; } - void setNoCopy(bool noCopy) { m_noCopy = noCopy; } + bool hasNoCopy() const { return m_noCopy; } + void setNoCopy(bool noCopy) { m_noCopy = noCopy; } private: - IncludeList m_extra_includes; - Include m_include; - QHash m_includes_used; - FunctionModificationList m_function_mods; - FieldModificationList m_field_mods; - CodeSnipList m_code_snips; - QString m_package; - QString m_default_superclass; - QString m_qualified_cpp_name; - QString m_java_name; - - uint m_qobject : 1; - uint m_polymorphic_base : 1; - uint m_generic_class : 1; - uint m_createShell : 1; - uint m_createPromoter : 1; - uint m_noCopy : 1; - - QString m_polymorphic_id_value; - QString m_lookup_name; - QString m_target_type; - ExpensePolicy m_expense_policy; - TypeFlags m_type_flags; + IncludeList m_extra_includes; + Include m_include; + QHash m_includes_used; + FunctionModificationList m_function_mods; + FieldModificationList m_field_mods; + CodeSnipList m_code_snips; + QString m_package; + QString m_default_superclass; + QString m_qualified_cpp_name; + QString m_java_name; + + uint m_qobject: 1; + uint m_polymorphic_base: 1; + uint m_generic_class: 1; + uint m_createShell: 1; + uint m_createPromoter: 1; + uint m_noCopy: 1; + + QString m_polymorphic_id_value; + QString m_lookup_name; + QString m_target_type; + ExpensePolicy m_expense_policy; + TypeFlags m_type_flags; }; class ContainerTypeEntry : public ComplexTypeEntry { public: - enum Type { - NoContainer, - ListContainer, - StringListContainer, - LinkedListContainer, - VectorContainer, - StackContainer, - QueueContainer, - SetContainer, - MapContainer, - MultiMapContainer, - HashContainer, - MultiHashContainer, - PairContainer, - }; - - ContainerTypeEntry(const QString &name, Type type) - : ComplexTypeEntry(name, ContainerType) - { - m_type = type; - setCodeGeneration(GenerateForSubclass); - } - - Type type() const { return m_type; } - QString targetLangName() const; - QString javaPackage() const; - QString qualifiedCppName() const; + enum Type { + NoContainer, + ListContainer, + StringListContainer, + LinkedListContainer, + VectorContainer, + StackContainer, + QueueContainer, + SetContainer, + MapContainer, + MultiMapContainer, + HashContainer, + MultiHashContainer, + PairContainer, + }; + + ContainerTypeEntry(const QString& name, Type type) + : ComplexTypeEntry(name, ContainerType) + { + m_type = type; + setCodeGeneration(GenerateForSubclass); + } + + Type type() const { return m_type; } + QString targetLangName() const; + QString javaPackage() const; + QString qualifiedCppName() const; private: - Type m_type; + Type m_type; }; - class NamespaceTypeEntry : public ComplexTypeEntry { public: - NamespaceTypeEntry(const QString &name) : ComplexTypeEntry(name, NamespaceType) { } + NamespaceTypeEntry(const QString& name) + : ComplexTypeEntry(name, NamespaceType) + { + } }; - class ValueTypeEntry : public ComplexTypeEntry { public: - ValueTypeEntry(const QString &name) : ComplexTypeEntry(name, BasicValueType) { } + ValueTypeEntry(const QString& name) + : ComplexTypeEntry(name, BasicValueType) + { + } - bool isValue() const { return true; } + bool isValue() const { return true; } - virtual bool isNativeIdBased() const { return true; } + virtual bool isNativeIdBased() const { return true; } - virtual TypeEntry* equivalentType() const { return _equivalentType; } - void setEquivalentType(TypeEntry* typeEntry) { _equivalentType = typeEntry; } + virtual TypeEntry* equivalentType() const { return _equivalentType; } + void setEquivalentType(TypeEntry* typeEntry) { _equivalentType = typeEntry; } protected: - ValueTypeEntry(const QString &name, Type t) : ComplexTypeEntry(name, t) { } + ValueTypeEntry(const QString& name, Type t) + : ComplexTypeEntry(name, t) + { + } private: - TypeEntry* _equivalentType{}; + TypeEntry* _equivalentType {}; }; - class StringTypeEntry : public ValueTypeEntry { public: - StringTypeEntry(const QString &name) - : ValueTypeEntry(name, StringType) - { - setCodeGeneration(GenerateNothing); - } + StringTypeEntry(const QString& name) + : ValueTypeEntry(name, StringType) + { + setCodeGeneration(GenerateNothing); + } - QString jniName() const { return strings_jobject; } - QString targetLangName() const { return strings_String; } - QString javaPackage() const { return strings_java_lang; } + QString jniName() const { return strings_jobject; } + QString targetLangName() const { return strings_String; } + QString javaPackage() const { return strings_java_lang; } - virtual bool isNativeIdBased() const { return false; } + virtual bool isNativeIdBased() const { return false; } }; class CharTypeEntry : public ValueTypeEntry { public: - CharTypeEntry(const QString &name) : ValueTypeEntry(name, CharType) - { - setCodeGeneration(GenerateNothing); - } + CharTypeEntry(const QString& name) + : ValueTypeEntry(name, CharType) + { + setCodeGeneration(GenerateNothing); + } - QString jniName() const { return strings_jchar; } - QString targetLangName() const { return strings_char; } - QString javaPackage() const { return QString(); } + QString jniName() const { return strings_jchar; } + QString targetLangName() const { return strings_char; } + QString javaPackage() const { return QString(); } - virtual bool isNativeIdBased() const { return false; } + virtual bool isNativeIdBased() const { return false; } }; -class JObjectWrapperTypeEntry: public ValueTypeEntry +class JObjectWrapperTypeEntry : public ValueTypeEntry { public: - JObjectWrapperTypeEntry(const QString &name) : ValueTypeEntry(name, JObjectWrapperType) { } + JObjectWrapperTypeEntry(const QString& name) + : ValueTypeEntry(name, JObjectWrapperType) + { + } - QString jniName() const { return strings_jobject; } - QString targetLangName() const { return strings_Object; } - QString javaPackage() const { return strings_java_lang; } + QString jniName() const { return strings_jobject; } + QString targetLangName() const { return strings_Object; } + QString javaPackage() const { return strings_java_lang; } - bool isNativeIdBased() const { return false; } + bool isNativeIdBased() const { return false; } }; -class VariantTypeEntry: public ValueTypeEntry +class VariantTypeEntry : public ValueTypeEntry { public: - VariantTypeEntry(const QString &name) : ValueTypeEntry(name, VariantType) { } + VariantTypeEntry(const QString& name) + : ValueTypeEntry(name, VariantType) + { + } - QString jniName() const { return strings_jobject; } - QString targetLangName() const { return strings_Object; } - QString javaPackage() const { return strings_java_lang; } + QString jniName() const { return strings_jobject; } + QString targetLangName() const { return strings_Object; } + QString javaPackage() const { return strings_java_lang; } - virtual bool isNativeIdBased() const { return false; } + virtual bool isNativeIdBased() const { return false; } }; - class InterfaceTypeEntry : public ComplexTypeEntry { public: - InterfaceTypeEntry(const QString &name) - : ComplexTypeEntry(name, InterfaceType) - { - } + InterfaceTypeEntry(const QString& name) + : ComplexTypeEntry(name, InterfaceType) + { + } - static QString interfaceName(const QString &name) { - return name + "Interface"; - } + static QString interfaceName(const QString& name) { return name + "Interface"; } - ObjectTypeEntry *origin() const { return m_origin; } - void setOrigin(ObjectTypeEntry *origin) { m_origin = origin; } + ObjectTypeEntry* origin() const { return m_origin; } + void setOrigin(ObjectTypeEntry* origin) { m_origin = origin; } - virtual bool isNativeIdBased() const { return true; } - virtual QString qualifiedCppName() const { - return ComplexTypeEntry::qualifiedCppName().left(ComplexTypeEntry::qualifiedCppName().length() - interfaceName("").length()); - } + virtual bool isNativeIdBased() const { return true; } + virtual QString qualifiedCppName() const + { + return ComplexTypeEntry::qualifiedCppName().left( + ComplexTypeEntry::qualifiedCppName().length() - interfaceName("").length()); + } private: - ObjectTypeEntry *m_origin{}; + ObjectTypeEntry* m_origin {}; }; - class ObjectTypeEntry : public ComplexTypeEntry { public: - ObjectTypeEntry(const QString &name) - : ComplexTypeEntry(name, ObjectType), m_interface(0) - { - } + ObjectTypeEntry(const QString& name) + : ComplexTypeEntry(name, ObjectType) + , m_interface(0) + { + } - InterfaceTypeEntry *designatedInterface() const { return m_interface; } - void setDesignatedInterface(InterfaceTypeEntry *entry) { m_interface = entry; } + InterfaceTypeEntry* designatedInterface() const { return m_interface; } + void setDesignatedInterface(InterfaceTypeEntry* entry) { m_interface = entry; } - virtual bool isNativeIdBased() const { return true; } + virtual bool isNativeIdBased() const { return true; } private: - InterfaceTypeEntry *m_interface; + InterfaceTypeEntry* m_interface; }; class CustomTypeEntry : public ComplexTypeEntry { public: - CustomTypeEntry(const QString &name) : ComplexTypeEntry(name, CustomType) { } + CustomTypeEntry(const QString& name) + : ComplexTypeEntry(name, CustomType) + { + } }; -struct TypeRejection -{ - QString class_name; - QString function_name; - QString field_name; - QString enum_name; +struct TypeRejection { + QString class_name; + QString function_name; + QString field_name; + QString enum_name; }; class TypeDatabase { public: - TypeDatabase(); - - static TypeDatabase *instance(); - - QList extraIncludes(const QString &className); - - inline PrimitiveTypeEntry *findPrimitiveType(const QString &name); - inline ComplexTypeEntry *findComplexType(const QString &name); - inline ObjectTypeEntry *findObjectType(const QString &name); - inline NamespaceTypeEntry *findNamespaceType(const QString &name); - ContainerTypeEntry *findContainerType(const QString &name); - - TypeEntry *findType(const QString &name) const { - QList entries = findTypes(name); - for (TypeEntry* entry : entries) { - if (entry != 0 && - (!entry->isPrimitive() || static_cast(entry)->preferredTargetLangType())) { - return entry; - } - } - return 0; - } - QList findTypes(const QString &name) const { return m_entries.value(name); } - TypeEntryHash allEntries() { return m_entries; } - SingleTypeEntryHash entries() { - TypeEntryHash entries = allEntries(); + TypeDatabase(); - SingleTypeEntryHash returned; - QList keys = entries.keys(); + static TypeDatabase* instance(); - for (QString key : keys) { - returned[key] = findType(key); - } + QList extraIncludes(const QString& className); - return returned; + inline PrimitiveTypeEntry* findPrimitiveType(const QString& name); + inline ComplexTypeEntry* findComplexType(const QString& name); + inline ObjectTypeEntry* findObjectType(const QString& name); + inline NamespaceTypeEntry* findNamespaceType(const QString& name); + ContainerTypeEntry* findContainerType(const QString& name); + + TypeEntry* findType(const QString& name) const + { + QList entries = findTypes(name); + for (TypeEntry* entry : entries) { + if (entry != 0 && (!entry->isPrimitive() || static_cast(entry)->preferredTargetLangType())) { + return entry; + } + } + return 0; + } + QList findTypes(const QString& name) const { return m_entries.value(name); } + TypeEntryHash allEntries() { return m_entries; } + SingleTypeEntryHash entries() + { + TypeEntryHash entries = allEntries(); + + SingleTypeEntryHash returned; + QList keys = entries.keys(); + + for (QString key : keys) { + returned[key] = findType(key); } - PrimitiveTypeEntry *findTargetLangPrimitiveType(const QString &java_name); + return returned; + } - void addRejection(const QString &class_name, const QString &function_name, - const QString &field_name, const QString &enum_name); - bool isClassRejected(const QString &class_name); - bool isFunctionRejected(const QString &class_name, const QString &function_name); - bool isFieldRejected(const QString &class_name, const QString &field_name); - bool isEnumRejected(const QString &class_name, const QString &enum_name); + PrimitiveTypeEntry* findTargetLangPrimitiveType(const QString& java_name); - void addType(TypeEntry* e); + void addRejection(const QString& class_name, const QString& function_name, const QString& field_name, + const QString& enum_name); + bool isClassRejected(const QString& class_name); + bool isFunctionRejected(const QString& class_name, const QString& function_name); + bool isFieldRejected(const QString& class_name, const QString& field_name); + bool isEnumRejected(const QString& class_name, const QString& enum_name); - SingleTypeEntryHash flagsEntries() const { return m_flags_entries; } - FlagsTypeEntry *findFlagsType(const QString &name) const; - void addFlagsType(FlagsTypeEntry *fte) { m_flags_entries[fte->originalName()] = fte; } + void addType(TypeEntry* e); - TemplateEntry *findTemplate(const QString &name) { return m_templates[name]; } - void addTemplate(TemplateEntry *t) { m_templates[t->name()] = t; } + SingleTypeEntryHash flagsEntries() const { return m_flags_entries; } + FlagsTypeEntry* findFlagsType(const QString& name) const; + void addFlagsType(FlagsTypeEntry* fte) { m_flags_entries[fte->originalName()] = fte; } - void setSuppressWarnings(bool on) { m_suppressWarnings = on; } - void addSuppressedWarning(const QString &s) - { - m_suppressedWarnings.append(s); - } + TemplateEntry* findTemplate(const QString& name) { return m_templates[name]; } + void addTemplate(TemplateEntry* t) { m_templates[t->name()] = t; } - bool isSuppressedWarning(const QString &s) - { - if (!m_suppressWarnings) - return false; + void setSuppressWarnings(bool on) { m_suppressWarnings = on; } + void addSuppressedWarning(const QString& s) { m_suppressedWarnings.append(s); } - for (const QString& _warning : m_suppressedWarnings) { - QString warning(QString(_warning).replace("\\*", "&place_holder_for_asterisk;")); + bool isSuppressedWarning(const QString& s) + { + if (!m_suppressWarnings) + return false; - QStringList segs = warning.split("*", Qt::SkipEmptyParts); + for (const QString& _warning : m_suppressedWarnings) { + QString warning(QString(_warning).replace("\\*", "&place_holder_for_asterisk;")); - if (segs.size() == 0) - continue ; + QStringList segs = warning.split("*", Qt::SkipEmptyParts); - int i = 0; - int pos = s.indexOf(QString(segs.at(i++)).replace("&place_holder_for_asterisk;", "*")); - //qDebug() << "s == " << s << ", warning == " << segs; - while (pos != -1) { - if (i == segs.size()) - return true; - pos = s.indexOf(QString(segs.at(i++)).replace("&place_holder_for_asterisk;", "*"), pos); - } - } + if (segs.size() == 0) + continue; - return false; + int i = 0; + int pos = s.indexOf(QString(segs.at(i++)).replace("&place_holder_for_asterisk;", "*")); + //qDebug() << "s == " << s << ", warning == " << segs; + while (pos != -1) { + if (i == segs.size()) + return true; + pos = s.indexOf(QString(segs.at(i++)).replace("&place_holder_for_asterisk;", "*"), pos); + } } - void setRebuildClasses(const QStringList &cls) { m_rebuild_classes = cls; } + return false; + } + + void setRebuildClasses(const QStringList& cls) { m_rebuild_classes = cls; } - static QString globalNamespaceClassName(const TypeEntry *te); - QString filename() const { return "typesystem.txt"; } + static QString globalNamespaceClassName(const TypeEntry* te); + QString filename() const { return "typesystem.txt"; } - bool parseFile(const QString &filename, unsigned int qtVersion, bool generate = true); - void finalSetup(); + bool parseFile(const QString& filename, unsigned int qtVersion, bool generate = true); + void finalSetup(); private: - bool m_suppressWarnings; - TypeEntryHash m_entries; - SingleTypeEntryHash m_flags_entries; - TemplateEntryHash m_templates; - QStringList m_suppressedWarnings; - - QList m_rejections; - QStringList m_rebuild_classes; + bool m_suppressWarnings; + TypeEntryHash m_entries; + SingleTypeEntryHash m_flags_entries; + TemplateEntryHash m_templates; + QStringList m_suppressedWarnings; + + QList m_rejections; + QStringList m_rebuild_classes; }; -inline PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString &name) +inline PrimitiveTypeEntry* TypeDatabase::findPrimitiveType(const QString& name) { - QList entries = findTypes(name); + QList entries = findTypes(name); - for (TypeEntry* entry : entries) { - if (entry != 0 && entry->isPrimitive() && static_cast(entry)->preferredTargetLangType()) - return static_cast(entry); - } + for (TypeEntry* entry : entries) { + if (entry != 0 && entry->isPrimitive() && static_cast(entry)->preferredTargetLangType()) + return static_cast(entry); + } - return 0; + return 0; } -inline ComplexTypeEntry *TypeDatabase::findComplexType(const QString &name) +inline ComplexTypeEntry* TypeDatabase::findComplexType(const QString& name) { - TypeEntry *entry = findType(name); - if (entry != 0 && entry->isComplex()) - return static_cast(entry); - else - return 0; + TypeEntry* entry = findType(name); + if (entry != 0 && entry->isComplex()) + return static_cast(entry); + else + return 0; } -inline ObjectTypeEntry *TypeDatabase::findObjectType(const QString &name) +inline ObjectTypeEntry* TypeDatabase::findObjectType(const QString& name) { - TypeEntry *entry = findType(name); - if (entry != 0 && entry->isObject()) - return static_cast(entry); - else - return 0; + TypeEntry* entry = findType(name); + if (entry != 0 && entry->isObject()) + return static_cast(entry); + else + return 0; } -inline NamespaceTypeEntry *TypeDatabase::findNamespaceType(const QString &name) +inline NamespaceTypeEntry* TypeDatabase::findNamespaceType(const QString& name) { - TypeEntry *entry = findType(name); - if (entry != 0 && entry->isNamespace()) - return static_cast(entry); - else - return 0; + TypeEntry* entry = findType(name); + if (entry != 0 && entry->isNamespace()) + return static_cast(entry); + else + return 0; } -QString fixCppTypeName(const QString &name); +QString fixCppTypeName(const QString& name); #endif // TYPESYSTEM_H diff --git a/src/PythonQt.cpp b/src/PythonQt.cpp index c75b92c41..2b016ec83 100644 --- a/src/PythonQt.cpp +++ b/src/PythonQt.cpp @@ -59,14 +59,15 @@ #include #if PY_VERSION_HEX >= 0x030A0000 -#include + #include #else -#include + #include #endif // .co_varnames was removed in 3.11, but the helper function was added #if PY_VERSION_HEX < 0x030B0000 -static inline PyObject *PyCode_GetVarnames(PyCodeObject *o) { +static inline PyObject* PyCode_GetVarnames(PyCodeObject* o) +{ Py_XINCREF(o->co_varnames); return o->co_varnames; } @@ -75,23 +76,26 @@ static inline PyObject *PyCode_GetVarnames(PyCodeObject *o) { #include PythonQt* PythonQt::_self = nullptr; -int PythonQt::_uniqueModuleCount = 0; +int PythonQt::_uniqueModuleCount = 0; void PythonQt_init_QtGuiBuiltin(PyObject*); void PythonQt_init_QtCoreBuiltin(PyObject*); - void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) { if (!_self) { _self = new PythonQt(flags, pythonQtModuleName); _self->_p->_PythonQtObjectPtr_metaId = qRegisterMetaType("PythonQtObjectPtr"); - PythonQtConv::registerMetaTypeToPythonConverter(_self->_p->_PythonQtObjectPtr_metaId, PythonQtConv::convertFromPythonQtObjectPtr); - PythonQtConv::registerPythonToMetaTypeConverter(_self->_p->_PythonQtObjectPtr_metaId, PythonQtConv::convertToPythonQtObjectPtr); + PythonQtConv::registerMetaTypeToPythonConverter(_self->_p->_PythonQtObjectPtr_metaId, + PythonQtConv::convertFromPythonQtObjectPtr); + PythonQtConv::registerPythonToMetaTypeConverter(_self->_p->_PythonQtObjectPtr_metaId, + PythonQtConv::convertToPythonQtObjectPtr); _self->_p->_PythonQtSafeObjectPtr_metaId = qRegisterMetaType("PythonQtSafeObjectPtr"); - PythonQtConv::registerMetaTypeToPythonConverter(_self->_p->_PythonQtSafeObjectPtr_metaId, PythonQtConv::convertFromPythonQtSafeObjectPtr); - PythonQtConv::registerPythonToMetaTypeConverter(_self->_p->_PythonQtSafeObjectPtr_metaId, PythonQtConv::convertToPythonQtSafeObjectPtr); + PythonQtConv::registerMetaTypeToPythonConverter(_self->_p->_PythonQtSafeObjectPtr_metaId, + PythonQtConv::convertFromPythonQtSafeObjectPtr); + PythonQtConv::registerPythonToMetaTypeConverter(_self->_p->_PythonQtSafeObjectPtr_metaId, + PythonQtConv::convertToPythonQtSafeObjectPtr); PythonQtObjectPtr importlib; importlib.setNewRef(PyImport_ImportModule("importlib.machinery")); @@ -105,21 +109,20 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) // Importing asyncio on Py3.12+ pulls in ssl/_ssl; some environments/tests // want to avoid that during early embedded init. if (!qEnvironmentVariableIsSet("PYTHONQT_DISABLE_ASYNCIO")) { - PythonQtObjectPtr asyncio; - asyncio.setNewRef(PyImport_ImportModule("asyncio")); - if (asyncio) - { - _self->_p->_pyEnsureFuture = asyncio.getVariable("ensure_future"); - _self->_p->_pyFutureClass = asyncio.getVariable("Future"); - } + PythonQtObjectPtr asyncio; + asyncio.setNewRef(PyImport_ImportModule("asyncio")); + if (asyncio) { + _self->_p->_pyEnsureFuture = asyncio.getVariable("ensure_future"); + _self->_p->_pyFutureClass = asyncio.getVariable("Future"); + } } PythonQt::priv()->setupSharedLibrarySuffixes(); PythonQtMethodInfo::addParameterTypeAlias("QObjectList", "QList"); - qRegisterMetaType >("QList"); + qRegisterMetaType>("QList"); qRegisterMetaType("QObjectList"); - qRegisterMetaType >("QList"); + qRegisterMetaType>("QList"); if (QT_POINTER_SIZE == 8) { qRegisterMetaType("size_t"); } else { @@ -127,7 +130,7 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) } PythonQtConv::registerStringViewTypes(); - int objectPtrListId = qRegisterMetaType >("QList"); + int objectPtrListId = qRegisterMetaType>("QList"); PythonQtConv::registerMetaTypeToPythonConverter(objectPtrListId, PythonQtConv::convertFromQListOfPythonQtObjectPtr); PythonQtConv::registerPythonToMetaTypeConverter(objectPtrListId, PythonQtConv::convertToQListOfPythonQtObjectPtr); @@ -139,7 +142,7 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) PythonQtRegisterToolClassesTemplateConverter(quint32); PythonQtRegisterToolClassesTemplateConverter(qint64); PythonQtRegisterToolClassesTemplateConverter(quint64); - + #ifdef PYTHONQT_SUPPORT_ML_TYPES PythonQtMethodInfo::addParameterTypeAlias("QList", "QList"); PythonQtMethodInfo::addParameterTypeAlias("QVector", "QVector"); @@ -226,7 +229,8 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) PythonQt_init_QtGuiBuiltin(nullptr); PythonQt::self()->addDecorators(new PythonQtStdDecorators()); - PythonQt::self()->registerCPPClass("QMetaObject",nullptr, "QtCore", PythonQtCreateObject); + PythonQt::self()->registerCPPClass("QMetaObject", nullptr, "QtCore", + PythonQtCreateObject); PythonQtRegisterToolClassesTemplateConverterForKnownClass(QByteArray); PythonQtRegisterToolClassesTemplateConverterForKnownClass(QDate); @@ -270,8 +274,8 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) PyObject* pack = PythonQt::priv()->packageByName("QtCore"); PyObject* pack2 = PythonQt::priv()->packageByName("Qt"); PyObject* qtNamespace = PythonQt::priv()->getClassInfo("Qt")->pythonQtClassWrapper(); - const char* names[16] = {"SIGNAL", "SLOT", "qAbs", "qBound","qDebug","qWarning","qCritical","qFatal" - ,"qFuzzyCompare", "qMax","qMin","qRound","qRound64","qVersion","qrand","qsrand"}; + const char* names[16] = {"SIGNAL", "SLOT", "qAbs", "qBound", "qDebug", "qWarning", "qCritical", "qFatal", + "qFuzzyCompare", "qMax", "qMin", "qRound", "qRound64", "qVersion", "qrand", "qsrand"}; for (unsigned int i = 0; i < sizeof(names) / sizeof(names[0]); i++) { PyObject* obj = PyObject_GetAttrString(qtNamespace, names[i]); if (obj) { @@ -280,7 +284,7 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) } else { Py_INCREF(obj); } - if(PyModule_AddObject(pack2, names[i], obj) < 0) { + if (PyModule_AddObject(pack2, names[i], obj) < 0) { Py_DECREF(obj); std::cerr << "failed to add " << names[i] << " to Qt\n"; } @@ -288,22 +292,10 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) std::cerr << "method not found " << names[i] << std::endl; } } - int enumValues[] = { - QtDebugMsg, - QtWarningMsg, - QtCriticalMsg, - QtFatalMsg, - QtSystemMsg - }; - const char* enumNames[] = { - "QtDebugMsg", - "QtWarningMsg", - "QtCriticalMsg", - "QtFatalMsg", - "QtSystemMsg" - }; - - for (auto i = 0u; i < sizeof(enumValues)/sizeof(int); i++) { + int enumValues[] = {QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg}; + const char* enumNames[] = {"QtDebugMsg", "QtWarningMsg", "QtCriticalMsg", "QtFatalMsg", "QtSystemMsg"}; + + for (auto i = 0u; i < sizeof(enumValues) / sizeof(int); i++) { PyObject* obj = PyLong_FromLong(enumValues[i]); if (PyModule_AddObject(pack, enumNames[i], obj) == 0) { Py_INCREF(obj); @@ -322,7 +314,6 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) PyModule_AddObject(pack, "Slot", (PyObject*)&PythonQtSlotDecorator_Type); PyModule_AddObject(pack, "Signal", (PyObject*)&PythonQtSignalFunction_Type); PyModule_AddObject(pack, "Property", (PyObject*)&PythonQtProperty_Type); - } } @@ -338,7 +329,10 @@ void PythonQt::cleanup() } } -PythonQt* PythonQt::self() { return _self; } +PythonQt* PythonQt::self() +{ + return _self; +} PythonQt::PythonQt(int flags, const QByteArray& pythonQtModuleName) { @@ -356,17 +350,20 @@ PythonQt::PythonQt(int flags, const QByteArray& pythonQtModuleName) // add our own python object types for qt object slots if (PyType_Ready(&PythonQtSlotFunction_Type) < 0) { - std::cerr << "could not initialize PythonQtSlotFunction_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + std::cerr << "could not initialize PythonQtSlotFunction_Type" << ", in " << __FILE__ << ":" << __LINE__ + << std::endl; } Py_INCREF(&PythonQtSlotFunction_Type); if (PyType_Ready(&PythonQtSignalFunction_Type) < 0) { - std::cerr << "could not initialize PythonQtSignalFunction_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + std::cerr << "could not initialize PythonQtSignalFunction_Type" << ", in " << __FILE__ << ":" << __LINE__ + << std::endl; } Py_INCREF(&PythonQtSignalFunction_Type); if (PyType_Ready(&PythonQtSlotDecorator_Type) < 0) { - std::cerr << "could not initialize PythonQtSlotDecorator_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + std::cerr << "could not initialize PythonQtSlotDecorator_Type" << ", in " << __FILE__ << ":" << __LINE__ + << std::endl; } Py_INCREF(&PythonQtSlotDecorator_Type); @@ -385,38 +382,44 @@ PythonQt::PythonQt(int flags, const QByteArray& pythonQtModuleName) PythonQtClassWrapper_Type.tp_base = &PyType_Type; // add our own python object types for classes if (PyType_Ready(&PythonQtClassWrapper_Type) < 0) { - std::cerr << "could not initialize PythonQtClassWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + std::cerr << "could not initialize PythonQtClassWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ + << std::endl; } Py_INCREF(&PythonQtClassWrapper_Type); // add our own python object types for CPP instances if (PyType_Ready(&PythonQtInstanceWrapper_Type) < 0) { PythonQt::handleError(); - std::cerr << "could not initialize PythonQtInstanceWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + std::cerr << "could not initialize PythonQtInstanceWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ + << std::endl; } Py_INCREF(&PythonQtInstanceWrapper_Type); // add our own python object types for redirection of stdout if (PyType_Ready(&PythonQtStdOutRedirectType) < 0) { - std::cerr << "could not initialize PythonQtStdOutRedirectType" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + std::cerr << "could not initialize PythonQtStdOutRedirectType" << ", in " << __FILE__ << ":" << __LINE__ + << std::endl; } Py_INCREF(&PythonQtStdOutRedirectType); // add our own python object types for redirection of stdin if (PyType_Ready(&PythonQtStdInRedirectType) < 0) { - std::cerr << "could not initialize PythonQtStdInRedirectType" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + std::cerr << "could not initialize PythonQtStdInRedirectType" << ", in " << __FILE__ << ":" << __LINE__ + << std::endl; } Py_INCREF(&PythonQtStdInRedirectType); initPythonQtModule(flags & RedirectStdOut, pythonQtModuleName); } -PythonQt::~PythonQt() { +PythonQt::~PythonQt() +{ delete _p; _p = nullptr; } -PythonQtPrivate::~PythonQtPrivate() { +PythonQtPrivate::~PythonQtPrivate() +{ delete _defaultImporter; _defaultImporter = nullptr; @@ -429,7 +432,7 @@ PythonQtPrivate::~PythonQtPrivate() { PythonQtArgumentFrame::cleanupFreeList(); } -void PythonQtPrivate::setTaskDoneCallback(const PythonQtObjectPtr & callable) +void PythonQtPrivate::setTaskDoneCallback(const PythonQtObjectPtr& callable) { _pyTaskDoneCallback = callable; } @@ -437,13 +440,11 @@ void PythonQtPrivate::setTaskDoneCallback(const PythonQtObjectPtr & callable) PythonQtObjectPtr PythonQtPrivate::checkAndRunCoroutine(const PythonQtObjectPtr& object) { PythonQtObjectPtr result; - if (!PyCoro_CheckExact(object)) - { + if (!PyCoro_CheckExact(object)) { return result; } - if (!_pyEnsureFuture) - { + if (!_pyEnsureFuture) { std::cerr << "PythonQt: ensure_future not initialized" << std::endl; return PythonQtObjectPtr(); } @@ -464,15 +465,14 @@ PythonQtObjectPtr PythonQtPrivate::checkAndRunCoroutine(const PythonQtObjectPtr& PythonQtObjectPtr PythonQtPrivate::createAsyncioFuture() { - if (!_pyFutureClass) - { + if (!_pyFutureClass) { std::cerr << "PythonQt: _pyFutureClass not initialized" << std::endl; return nullptr; } return _pyFutureClass.call(); } -void PythonQt::setRedirectStdInCallback(PythonQtInputChangedCB* callback, void * callbackData) +void PythonQt::setRedirectStdInCallback(PythonQtInputChangedCB* callback, void* callbackData) { if (!callback) { std::cerr << "PythonQt::setRedirectStdInCallback - callback parameter is NULL !" << std::endl; @@ -484,7 +484,7 @@ void PythonQt::setRedirectStdInCallback(PythonQtInputChangedCB* callback, void * sys.setNewRef(PyImport_ImportModule("sys")); // Backup original 'sys.stdin' if not yet done - if( !PyObject_HasAttrString(sys.object(), "pythonqt_original_stdin") ) { + if (!PyObject_HasAttrString(sys.object(), "pythonqt_original_stdin")) { PyObject_SetAttrString(sys.object(), "pythonqt_original_stdin", PyObject_GetAttrString(sys.object(), "stdin")); } @@ -505,11 +505,11 @@ void PythonQt::setRedirectStdInCallbackEnabled(bool enabled) sys.setNewRef(PyImport_ImportModule("sys")); if (enabled) { - if( PyObject_HasAttrString(sys.object(), "pythonqt_stdin") ) { + if (PyObject_HasAttrString(sys.object(), "pythonqt_stdin")) { PyObject_SetAttrString(sys.object(), "stdin", PyObject_GetAttrString(sys.object(), "pythonqt_stdin")); } } else { - if( PyObject_HasAttrString(sys.object(), "pythonqt_original_stdin") ) { + if (PyObject_HasAttrString(sys.object(), "pythonqt_original_stdin")) { PyObject_SetAttrString(sys.object(), "stdin", PyObject_GetAttrString(sys.object(), "pythonqt_original_stdin")); } } @@ -517,7 +517,7 @@ void PythonQt::setRedirectStdInCallbackEnabled(bool enabled) PythonQtImportFileInterface* PythonQt::importInterface() { - return _self->_p->_importInterface?_self->_p->_importInterface:_self->_p->_defaultImporter; + return _self->_p->_importInterface ? _self->_p->_importInterface : _self->_p->_defaultImporter; } void PythonQt::qObjectNoLongerWrappedCB(QObject* o) @@ -541,12 +541,15 @@ QString PythonQt::qObjectMissingAttributeCallback(QObject* o, const QString& att } } -void PythonQt::registerClass(const QMetaObject* metaobject, const char* package, PythonQtQObjectCreatorFunctionCB* wrapperCreator, PythonQtShellSetInstanceWrapperCB* shell) +void PythonQt::registerClass(const QMetaObject* metaobject, const char* package, + PythonQtQObjectCreatorFunctionCB* wrapperCreator, PythonQtShellSetInstanceWrapperCB* shell) { _p->registerClass(metaobject, package, wrapperCreator, shell); } -void PythonQtPrivate::registerClass(const QMetaObject* metaobject, const char* package, PythonQtQObjectCreatorFunctionCB* wrapperCreator, PythonQtShellSetInstanceWrapperCB* shell, PyObject* module, int typeSlots) +void PythonQtPrivate::registerClass(const QMetaObject* metaobject, const char* package, + PythonQtQObjectCreatorFunctionCB* wrapperCreator, PythonQtShellSetInstanceWrapperCB* shell, PyObject* module, + int typeSlots) { // we register all classes in the hierarchy const QMetaObject* m = metaobject; @@ -570,7 +573,7 @@ void PythonQtPrivate::registerClass(const QMetaObject* metaobject, const char* p Py_INCREF(classWrapper); PyObject* pack = module ? module : packageByName(package); // same logic like in createPythonQtClassWrapper if (PyModule_AddObject(pack, info->className(), classWrapper) < 0) { - Py_DECREF(classWrapper); + Py_DECREF(classWrapper); } } if (first) { @@ -591,12 +594,12 @@ void PythonQtPrivate::createPythonQtClassWrapper(PythonQtClassInfo* info, const QByteArray pythonClassName = info->className(); int nestedClassIndex = pythonClassName.indexOf("::"); bool isNested = false; - if (nestedClassIndex>0) { + if (nestedClassIndex > 0) { pythonClassName = pythonClassName.mid(nestedClassIndex + 2); isNested = true; } - PyObject* pack = module?module:packageByName(package); + PyObject* pack = module ? module : packageByName(package); PyObject* pyobj = (PyObject*)createNewPythonQtClassWrapper(info, pack, pythonClassName); if (isNested) { @@ -635,7 +638,7 @@ PyObject* PythonQtPrivate::wrapQObject(QObject* obj) if (!wrap) { // smuggling it in... PythonQtClassInfo* classInfo = _knownClassInfos.value(obj->metaObject()->className()); - if (!classInfo || classInfo->pythonQtClassWrapper()==nullptr) { + if (!classInfo || classInfo->pythonQtClassWrapper() == nullptr) { registerClass(obj->metaObject()); classInfo = _knownClassInfos.value(obj->metaObject()->className()); } @@ -676,7 +679,7 @@ PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name, bool passO } // we do not know the metaobject yet, but we might know it by its name: - if (_knownQObjectClassNames.find(name)!=_knownQObjectClassNames.end()) { + if (_knownQObjectClassNames.find(name) != _knownQObjectClassNames.end()) { // yes, we know it, so we can convert to QObject QObject* qptr = (QObject*)ptr; registerClass(qptr->metaObject()); @@ -686,7 +689,7 @@ PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name, bool passO if (info && info->isQObject()) { QObject* qptr = (QObject*)ptr; // if the object is a derived object, we want to switch the class info to the one of the derived class: - if (name!=(qptr->metaObject()->className())) { + if (name != (qptr->metaObject()->className())) { info = _knownClassInfos.value(qptr->metaObject()->className()); if (!info || (info->pythonQtClassWrapper() == nullptr)) { registerClass(qptr->metaObject()); @@ -699,9 +702,9 @@ PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name, bool passO return (PyObject*)wrap; } - // not a known QObject, try to wrap via foreign wrapper factories + // not a known QObject, try to wrap via foreign wrapper factories PyObject* foreignWrapper = nullptr; - for (int i=0; i<_foreignWrapperFactories.size(); i++) { + for (int i = 0; i < _foreignWrapperFactories.size(); i++) { foreignWrapper = _foreignWrapperFactories.at(i)->wrap(name, ptr); if (foreignWrapper) { return foreignWrapper; @@ -710,7 +713,7 @@ PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name, bool passO // not a known QObject, so try our wrapper factory: QObject* wrapper = nullptr; - for (int i=0; i<_cppWrapperFactories.size(); i++) { + for (int i = 0; i < _cppWrapperFactories.size(); i++) { wrapper = _cppWrapperFactories.at(i)->create(name, ptr); if (wrapper) { break; @@ -719,14 +722,14 @@ PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name, bool passO if (info) { // try to downcast in the class hierarchy, which will modify info and ptr if it is successfull - ptr = info->castDownIfPossible(ptr, &info); + ptr = info->castDownIfPossible(ptr, &info); // if downcasting found out that the object is a QObject, // handle it like one: if (info && info->isQObject()) { QObject* qptr = (QObject*)ptr; // if the object is a derived object, we want to switch the class info to the one of the derived class: - if (name!=(qptr->metaObject()->className())) { + if (name != (qptr->metaObject()->className())) { registerClass(qptr->metaObject()); info = _knownClassInfos.value(qptr->metaObject()->className()); } @@ -737,7 +740,7 @@ PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name, bool passO } } - if (!info || info->pythonQtClassWrapper()==nullptr) { + if (!info || info->pythonQtClassWrapper() == nullptr) { // still unknown, register as CPP class registerCPPClass(name.constData()); info = _knownClassInfos.value(name); @@ -762,19 +765,22 @@ PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name, bool passO return (PyObject*)wrap; } -PyObject* PythonQtPrivate::dummyTuple() { +PyObject* PythonQtPrivate::dummyTuple() +{ static PyObject* dummyTuple = nullptr; - if (dummyTuple==nullptr) { + if (dummyTuple == nullptr) { dummyTuple = PyTuple_New(1); - PyTuple_SET_ITEM(dummyTuple, 0 , PyUnicode_FromString("dummy")); + PyTuple_SET_ITEM(dummyTuple, 0, PyUnicode_FromString("dummy")); } return dummyTuple; } - -PythonQtInstanceWrapper* PythonQtPrivate::createNewPythonQtInstanceWrapper(QObject* obj, PythonQtClassInfo* info, void* wrappedPtr) { +PythonQtInstanceWrapper* PythonQtPrivate::createNewPythonQtInstanceWrapper(QObject* obj, PythonQtClassInfo* info, + void* wrappedPtr) +{ // call the associated class type to create a new instance... - PythonQtInstanceWrapper* result = (PythonQtInstanceWrapper*)PyObject_Call(info->pythonQtClassWrapper(), dummyTuple(), nullptr); + PythonQtInstanceWrapper* result = + (PythonQtInstanceWrapper*)PyObject_Call(info->pythonQtClassWrapper(), dummyTuple(), nullptr); result->setQObject(obj); result->_wrappedPtr = wrappedPtr; @@ -793,7 +799,7 @@ PythonQtInstanceWrapper* PythonQtPrivate::createNewPythonQtInstanceWrapper(QObje _wrappedObjects.insert(wrappedPtr, result); } else { _wrappedObjects.insert(obj, result); - if (obj->parent()== nullptr && _wrappedCB) { + if (obj->parent() == nullptr && _wrappedCB) { // tell someone who is interested that the qobject is wrapped the first time, if it has no parent (*_wrappedCB)(obj); } @@ -802,7 +808,9 @@ PythonQtInstanceWrapper* PythonQtPrivate::createNewPythonQtInstanceWrapper(QObje return result; } -PythonQtClassWrapper* PythonQtPrivate::createNewPythonQtClassWrapper(PythonQtClassInfo* info, PyObject* parentModule, const QByteArray& pythonClassName) { +PythonQtClassWrapper* PythonQtPrivate::createNewPythonQtClassWrapper(PythonQtClassInfo* info, PyObject* parentModule, + const QByteArray& pythonClassName) +{ PythonQtClassWrapper* result; PyObject* className = PyUnicode_FromString(pythonClassName.constData()); @@ -815,12 +823,12 @@ PythonQtClassWrapper* PythonQtPrivate::createNewPythonQtClassWrapper(PythonQtCla PyObject* moduleName = PyObject_GetAttrString(parentModule, "__name__"); PyDict_SetItemString(typeDict, "__module__", moduleName); - PyObject* args = Py_BuildValue("OOO", className, baseClasses, typeDict); + PyObject* args = Py_BuildValue("OOO", className, baseClasses, typeDict); // set the class info so that PythonQtClassWrapper_new can read it _currentClassInfoForClassWrapperCreation = info; // create the new type object by calling the type - result = (PythonQtClassWrapper *)PyObject_Call((PyObject *)&PythonQtClassWrapper_Type, args, nullptr); + result = (PythonQtClassWrapper*)PyObject_Call((PyObject*)&PythonQtClassWrapper_Type, args, nullptr); Py_DECREF(baseClasses); Py_DECREF(typeDict); @@ -831,7 +839,7 @@ PythonQtClassWrapper* PythonQtPrivate::createNewPythonQtClassWrapper(PythonQtCla return result; } -PyObject* PythonQtPrivate::createEnumValueInstance(PyObject* enumType, unsigned int enumValue) +PyObject* PythonQtPrivate::createEnumValueInstance(PyObject* enumType, unsigned int enumValue) { PyObject* args = Py_BuildValue("(i)", enumValue); PyObject* result = PyObject_Call(enumType, args, nullptr); @@ -839,7 +847,8 @@ PyObject* PythonQtPrivate::createEnumValueInstance(PyObject* enumType, unsigned return result; } -PyObject* PythonQtPrivate::createNewPythonQtEnumWrapper(const char* enumName, PyObject* parentObject) { +PyObject* PythonQtPrivate::createNewPythonQtEnumWrapper(const char* enumName, PyObject* parentObject) +{ PyObject* result; PyObject* className = PyUnicode_FromString(enumName); @@ -852,10 +861,10 @@ PyObject* PythonQtPrivate::createNewPythonQtEnumWrapper(const char* enumName, Py PyObject* typeDict = PyDict_New(); PyDict_SetItemString(typeDict, "__module__", module); - PyObject* args = Py_BuildValue("OOO", className, baseClasses, typeDict); + PyObject* args = Py_BuildValue("OOO", className, baseClasses, typeDict); // create the new int derived type object by calling the core type - result = PyObject_Call((PyObject *)&PyType_Type, args, nullptr); + result = PyObject_Call((PyObject*)&PyType_Type, args, nullptr); Py_DECREF(baseClasses); Py_DECREF(module); @@ -945,7 +954,7 @@ PythonQtObjectPtr PythonQt::lookupObject(PyObject* module, const QString& name) PythonQtObjectPtr p = module; PythonQtObjectPtr prev; QByteArray b; - for (QStringList::ConstIterator i = l.begin(); i!=l.end() && p; ++i) { + for (QStringList::ConstIterator i = l.begin(); i != l.end() && p; ++i) { prev = p; b = QStringToPythonEncoding(*i); if (PyDict_Check(p)) { @@ -958,7 +967,8 @@ PythonQtObjectPtr PythonQt::lookupObject(PyObject* module, const QString& name) return p; } -PythonQtObjectPtr PythonQt::getMainModule() { +PythonQtObjectPtr PythonQt::getMainModule() +{ //both borrowed PythonQtObjectPtr dict = PyImport_GetModuleDict(); return PyDict_GetItemString(dict, "__main__"); @@ -971,8 +981,8 @@ PythonQtObjectPtr PythonQt::importModule(const QString& name) return mod; } - -QVariant PythonQt::evalCode(PyObject* object, PyObject* pycode) { +QVariant PythonQt::evalCode(PyObject* object, PyObject* pycode) +{ QVariant result; clearError(); if (pycode) { @@ -986,7 +996,8 @@ QVariant PythonQt::evalCode(PyObject* object, PyObject* pycode) { globals = dict; } else { dict = PyObject_GetAttrString(object, "__dict__"); - globals = PyObject_GetAttrString(PyImport_ImportModule(PyUnicode_AsUTF8(PyObject_GetAttrString(object, "__module__"))),"__dict__"); + globals = PyObject_GetAttrString( + PyImport_ImportModule(PyUnicode_AsUTF8(PyObject_GetAttrString(object, "__module__"))), "__dict__"); } PyObject* r = nullptr; if (dict) { @@ -1026,7 +1037,6 @@ QVariant PythonQt::evalScript(PyObject* object, const QString& script, int start return result; } - QVariant PythonQt::evalScript(const QString& script, PyObject* globals, PyObject* locals, int start) { QVariant result; @@ -1043,7 +1053,6 @@ QVariant PythonQt::evalScript(const QString& script, PyObject* globals, PyObject return result; } - void PythonQt::evalFile(PyObject* module, const QString& filename) { // NOTE: error checking is done by parseFile and evalCode @@ -1086,7 +1095,7 @@ PythonQtObjectPtr PythonQt::parseFileWithPythonLoaders(const QString& file) loader.setNewRef(callAndReturnPyObject(loaderClass, args)); QVariantList args2; args2 << dummy; - PythonQtObjectPtr getCode; + PythonQtObjectPtr getCode; getCode.setNewRef(PyObject_GetAttrString(loader, "get_code")); result.setNewRef(callAndReturnPyObject(getCode, args2)); if (!result) { @@ -1113,7 +1122,7 @@ PythonQtObjectPtr PythonQt::createModuleFromScript(const QString& name, const QS scriptCode = "\n"; } PythonQtObjectPtr pycode; - pycode.setNewRef(Py_CompileString(QStringToPythonCharPointer(scriptCode), "", Py_file_input)); + pycode.setNewRef(Py_CompileString(QStringToPythonCharPointer(scriptCode), "", Py_file_input)); PythonQtObjectPtr module = _p->createModule(name, pycode); return module; } @@ -1121,7 +1130,7 @@ PythonQtObjectPtr PythonQt::createModuleFromScript(const QString& name, const QS PythonQtObjectPtr PythonQt::createUniqueModule() { static QString pyQtStr("PythonQt_module"); - QString moduleName = pyQtStr+QString::number(_uniqueModuleCount++); + QString moduleName = pyQtStr + QString::number(_uniqueModuleCount++); return createModuleFromScript(moduleName); } @@ -1257,15 +1266,16 @@ QStringList PythonQt::introspectObject(PyObject* object, ObjectType type) PyObject* key; PyObject* value; QString keystr; - for (int i = 0;iob_type != &PyCFunction_Type - && value->ob_type != &PyFunction_Type - && value->ob_type != &PyMethod_Type - && value->ob_type != &PyModule_Type - && value->ob_type != &PyType_Type - && value->ob_type != &PythonQtSlotFunction_Type - ) { + if (value->ob_type != &PyCFunction_Type && value->ob_type != &PyFunction_Type + && value->ob_type != &PyMethod_Type && value->ob_type != &PyModule_Type + && value->ob_type != &PyType_Type && value->ob_type != &PythonQtSlotFunction_Type) + { results << keystr; } break; case Function: - if (value->ob_type == &PyCFunction_Type || - value->ob_type == &PyFunction_Type || - value->ob_type == &PyMethod_Type || - value->ob_type == &PythonQtSlotFunction_Type - ) { + if (value->ob_type == &PyCFunction_Type || value->ob_type == &PyFunction_Type + || value->ob_type == &PyMethod_Type || value->ob_type == &PythonQtSlotFunction_Type) + { results << keystr; } break; @@ -1323,28 +1327,28 @@ PyObject* PythonQt::getObjectByType(const QString& typeName) sys.setNewRef(PyImport_ImportModule("sys")); PythonQtObjectPtr modules = lookupObject(sys, "modules"); Q_ASSERT(PyDict_Check(modules)); - + QStringList tmp = typeName.split("."); QString simpleTypeName = tmp.takeLast(); QString moduleName = tmp.join("."); - + PyObject* object = nullptr; PyObject* moduleObject = PyDict_GetItemString(modules, QStringToPythonCharPointer(moduleName)); if (moduleObject) { object = PyObject_GetAttrString(moduleObject, QStringToPythonCharPointer(simpleTypeName)); } - + if (!object) { moduleObject = PyDict_GetItemString(modules, "__builtin__"); if (moduleObject) { object = PyObject_GetAttrString(moduleObject, QStringToPythonCharPointer(simpleTypeName)); } } - + PyErr_Clear(); return object; } - + QStringList PythonQt::introspectType(const QString& typeName, ObjectType type) { QStringList results; @@ -1412,7 +1416,7 @@ PyObject* PythonQt::callAndReturnPyObject(PyObject* callable, const QVariantList PyObject* arg = PythonQtConv::QVariantToPyObject(args.at(i)); if (arg) { // steals reference, no unref - PyTuple_SetItem(pargs, i,arg); + PyTuple_SetItem(pargs, i, arg); } else { err = true; break; @@ -1457,7 +1461,8 @@ void PythonQt::addInstanceDecorators(QObject* o) void PythonQt::addClassDecorators(QObject* o) { - _p->addDecorators(o, PythonQtPrivate::StaticDecorator | PythonQtPrivate::ConstructorDecorator | PythonQtPrivate::DestructorDecorator); + _p->addDecorators(o, + PythonQtPrivate::StaticDecorator | PythonQtPrivate::ConstructorDecorator | PythonQtPrivate::DestructorDecorator); } void PythonQt::addDecorators(QObject* o) @@ -1491,7 +1496,7 @@ void PythonQt::addWrapperFactory(PythonQtCppWrapperFactory* factory) _p->_cppWrapperFactories.append(factory); } -void PythonQt::addWrapperFactory( PythonQtForeignWrapperFactory* factory ) +void PythonQt::addWrapperFactory(PythonQtForeignWrapperFactory* factory) { _p->_foreignWrapperFactories.append(factory); } @@ -1530,7 +1535,7 @@ void PythonQtPrivate::setupSharedLibrarySuffixes() const QVariantList entries = result.toList(); for (const QVariant& entry : entries) { QVariantList suffixEntry = entry.toList(); - if (suffixEntry.count()==3) { + if (suffixEntry.count() == 3) { int code = suffixEntry.at(2).toInt(); if (code == cExtensionCode) { _sharedLibrarySuffixes << suffixEntry.at(0).toString(); @@ -1548,19 +1553,20 @@ PythonQtClassInfo* PythonQtPrivate::currentClassInfoForClassWrapperCreation() void PythonQtPrivate::addDecorators(QObject* o, int decoTypes) { - if (o == nullptr) - { + if (o == nullptr) { return; - } + } o->setParent(this); int numMethods = o->metaObject()->methodCount(); for (int i = 0; i < numMethods; i++) { QMetaMethod m = o->metaObject()->method(i); QByteArray signature = PythonQtUtils::methodName(m); - if ((m.methodType() == QMetaMethod::Method || - m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) { + if ((m.methodType() == QMetaMethod::Method || m.methodType() == QMetaMethod::Slot) + && m.access() == QMetaMethod::Public) + { if (signature.startsWith("new_")) { - if ((decoTypes & ConstructorDecorator) == 0) continue; + if ((decoTypes & ConstructorDecorator) == 0) + continue; const PythonQtMethodInfo* info = PythonQtMethodInfo::getCachedMethodInfo(m, nullptr); if (info->parameters().at(0).pointerCount == 1) { QByteArray nameOfClass = signature.mid(4); @@ -1570,25 +1576,28 @@ void PythonQtPrivate::addDecorators(QObject* o, int decoTypes) classInfo->addConstructor(newSlot); } } else if (signature.startsWith("delete_")) { - if ((decoTypes & DestructorDecorator) == 0) continue; + if ((decoTypes & DestructorDecorator) == 0) + continue; QByteArray nameOfClass = signature.mid(7); nameOfClass.replace("__", "::"); PythonQtClassInfo* classInfo = lookupClassInfoAndCreateIfNotPresent(nameOfClass); PythonQtSlotInfo* newSlot = new PythonQtSlotInfo(nullptr, m, i, o, PythonQtSlotInfo::ClassDecorator); classInfo->setDestructor(newSlot); } else if (signature.startsWith("static_")) { - if ((decoTypes & StaticDecorator) == 0) continue; + if ((decoTypes & StaticDecorator) == 0) + continue; QByteArray nameOfClass = signature.mid(7); nameOfClass = nameOfClass.mid(0, nameOfClass.indexOf('_')); PythonQtClassInfo* classInfo = lookupClassInfoAndCreateIfNotPresent(nameOfClass); PythonQtSlotInfo* newSlot = new PythonQtSlotInfo(nullptr, m, i, o, PythonQtSlotInfo::ClassDecorator); classInfo->addDecoratorSlot(newSlot); } else { - if ((decoTypes & InstanceDecorator) == 0) continue; + if ((decoTypes & InstanceDecorator) == 0) + continue; const PythonQtMethodInfo* info = PythonQtMethodInfo::getCachedMethodInfo(m, nullptr); - if (info->parameters().count()>1) { + if (info->parameters().count() > 1) { PythonQtMethodInfo::ParameterInfo p = info->parameters().at(1); - if (p.pointerCount==1) { + if (p.pointerCount == 1) { PythonQtClassInfo* classInfo = lookupClassInfoAndCreateIfNotPresent(p.name); PythonQtSlotInfo* newSlot = new PythonQtSlotInfo(nullptr, m, i, o, PythonQtSlotInfo::InstanceDecorator); classInfo->addDecoratorSlot(newSlot); @@ -1623,8 +1632,7 @@ void PythonQt::removeSignalHandlers() _p->_signalReceivers.clear(); } -namespace -{ +namespace { //! adapted from python source file "pythonrun.c", function "handle_system_exit" //! return the exitcode instead of calling "Py_Exit". //! it gives the application an opportunity to properly terminate. @@ -1633,10 +1641,10 @@ int custom_system_exit_exception_handler() PyObject *exception, *value, *tb; int exitcode = 0; -// if (Py_InspectFlag) -// /* Don't exit if -i flag was given. This flag is set to 0 -// * when entering interactive mode for inspecting. */ -// return exitcode; + // if (Py_InspectFlag) + // /* Don't exit if -i flag was given. This flag is set to 0 + // * when entering interactive mode for inspecting. */ + // return exitcode; PyErr_Fetch(&exception, &value, &tb); @@ -1646,7 +1654,7 @@ int custom_system_exit_exception_handler() goto done; if (PyExceptionInstance_Check(value)) { /* The error code should be in the `code' attribute. */ - PyObject *code = PyObject_GetAttrString(value, "code"); + PyObject* code = PyObject_GetAttrString(value, "code"); if (code) { Py_DECREF(value); value = code; @@ -1659,7 +1667,7 @@ int custom_system_exit_exception_handler() if (PyLong_Check(value)) exitcode = (int)PyLong_AsLong(value); else { - PyObject *sys_stderr = PySys_GetObject(const_cast("stderr")); + PyObject* sys_stderr = PySys_GetObject(const_cast("stderr")); if (sys_stderr != nullptr && sys_stderr != Py_None) { PyFile_WriteObject(value, sys_stderr, Py_PRINT_RAW); } else { @@ -1669,16 +1677,16 @@ int custom_system_exit_exception_handler() PySys_WriteStderr("\n"); exitcode = 1; } - done: - /* Restore and clear the exception info, in order to properly decref +done: + /* Restore and clear the exception info, in order to properly decref * the exception, value, and traceback. If we just exit instead, * these leak, which confuses PYTHONDUMPREFS output, and may prevent * some finalizers from running. */ - PyErr_Restore(exception, value, tb); - PyErr_Clear(); - return exitcode; - //Py_Exit(exitcode); + PyErr_Restore(exception, value, tb); + PyErr_Clear(); + return exitcode; + //Py_Exit(exitcode); } } @@ -1687,13 +1695,10 @@ bool PythonQt::handleError(bool printStack) bool flag = false; if (PyErr_Occurred()) { - if (_p->_systemExitExceptionHandlerEnabled && - PyErr_ExceptionMatches(PyExc_SystemExit)) { + if (_p->_systemExitExceptionHandlerEnabled && PyErr_ExceptionMatches(PyExc_SystemExit)) { int exitcode = custom_system_exit_exception_handler(); Q_EMIT PythonQt::self()->systemExitExceptionRaised(exitcode); - } - else - { + } else { if (printStack) { PyErr_Print(); } else { @@ -1712,7 +1717,7 @@ bool PythonQt::handleError(bool printStack) return flag; } -bool PythonQt::hadError()const +bool PythonQt::hadError() const { return _p->_hadError; } @@ -1805,7 +1810,6 @@ void PythonQt::setProfilingCallback(ProfilingCB* cb) _p->_profilingCB = cb; } - void PythonQt::setEnableThreadSupport(bool flag) { #ifdef PYTHONQT_FULL_THREAD_SUPPORT @@ -1814,20 +1818,18 @@ void PythonQt::setEnableThreadSupport(bool flag) #endif } -static PyMethodDef PythonQtMethods[] = { - {nullptr, nullptr, 0, nullptr} -}; +static PyMethodDef PythonQtMethods[] = {{nullptr, nullptr, 0, nullptr}}; static PyModuleDef PythonQtModuleDef = { PyModuleDef_HEAD_INIT, /* m_base */ - "", /* m_name */ - nullptr, /* m_doc */ - -1, /* m_size */ - PythonQtMethods, /* m_methods */ - nullptr, /* m_slots */ - nullptr, /* m_traverse */ - nullptr, /* m_clear */ - nullptr /* m_free */ + "", /* m_name */ + nullptr, /* m_doc */ + -1, /* m_size */ + PythonQtMethods, /* m_methods */ + nullptr, /* m_slots */ + nullptr, /* m_traverse */ + nullptr, /* m_clear */ + nullptr /* m_free */ }; void PythonQt::initPythonQtModule(bool redirectStdOut, const QByteArray& pythonQtModuleName) @@ -1852,9 +1854,9 @@ void PythonQt::initPythonQtModule(bool redirectStdOut, const QByteArray& pythonQ // Create a redirection object for stdout and stderr PythonQtObjectPtr out; PythonQtObjectPtr err; - out = PythonQtStdOutRedirectType.tp_new(&PythonQtStdOutRedirectType,NULL, NULL); + out = PythonQtStdOutRedirectType.tp_new(&PythonQtStdOutRedirectType, NULL, NULL); ((PythonQtStdOutRedirect*)out.object())->_cb = stdOutRedirectCB; - err = PythonQtStdOutRedirectType.tp_new(&PythonQtStdOutRedirectType,NULL, NULL); + err = PythonQtStdOutRedirectType.tp_new(&PythonQtStdOutRedirectType, NULL, NULL); ((PythonQtStdOutRedirect*)err.object())->_cb = stdErrRedirectCB; // replace the built in file objects with our own objects PyModule_AddObject(sys, "pythonqt_stdout", out); @@ -1863,10 +1865,10 @@ void PythonQt::initPythonQtModule(bool redirectStdOut, const QByteArray& pythonQ setRedirectStdOutCallbackEnabled(redirectStdOut); // add PythonQt to the list of builtin module names - PyObject *old_module_names = PyObject_GetAttrString(sys.object(),"builtin_module_names"); + PyObject* old_module_names = PyObject_GetAttrString(sys.object(), "builtin_module_names"); if (old_module_names && PyTuple_Check(old_module_names)) { Py_ssize_t old_size = PyTuple_Size(old_module_names); - PyObject *module_names = PyTuple_New(old_size + 1); + PyObject* module_names = PyTuple_New(old_size + 1); for (Py_ssize_t i = 0; i < old_size; i++) { PyObject* val = PyTuple_GetItem(old_module_names, i); Py_INCREF(val); @@ -1904,17 +1906,17 @@ void PythonQt::setRedirectStdOutCallbackEnabled(bool enabled) sys.setNewRef(PyImport_ImportModule("sys")); if (enabled) { - if( PyObject_HasAttrString(sys.object(), "pythonqt_stdout") ) { + if (PyObject_HasAttrString(sys.object(), "pythonqt_stdout")) { PyModule_AddObject(sys.object(), "stdout", PyObject_GetAttrString(sys.object(), "pythonqt_stdout")); } - if( PyObject_HasAttrString(sys.object(), "pythonqt_stderr") ) { + if (PyObject_HasAttrString(sys.object(), "pythonqt_stderr")) { PyModule_AddObject(sys.object(), "stderr", PyObject_GetAttrString(sys.object(), "pythonqt_stderr")); } } else { - if( PyObject_HasAttrString(sys.object(), "pythonqt_original_stdout") ) { + if (PyObject_HasAttrString(sys.object(), "pythonqt_original_stdout")) { PyModule_AddObject(sys.object(), "stdout", PyObject_GetAttrString(sys.object(), "pythonqt_original_stdout")); } - if( PyObject_HasAttrString(sys.object(), "pythonqt_original_stderr") ) { + if (PyObject_HasAttrString(sys.object(), "pythonqt_original_stderr")) { PyModule_AddObject(sys.object(), "stderr", PyObject_GetAttrString(sys.object(), "pythonqt_original_stderr")); } } @@ -1925,7 +1927,7 @@ QString PythonQt::getReturnTypeOfWrappedMethod(PyObject* module, const QString& QStringList tmp = name.split("."); QString methodName = tmp.takeLast(); QString variableName = tmp.join("."); - PythonQtObjectPtr variableObject = lookupObject(module, variableName); + PythonQtObjectPtr variableObject = lookupObject(module, variableName); if (variableObject.isNull()) { // try lookup by interpreting the variableName as a type QString type = getReturnTypeOfWrappedMethod(variableName, methodName); @@ -1943,7 +1945,8 @@ QString PythonQt::getReturnTypeOfWrappedMethod(const QString& typeName, const QS return getReturnTypeOfWrappedMethodHelper(typeObject, methodName, typeName + "." + methodName); } -QString PythonQt::getReturnTypeOfWrappedMethodHelper(const PythonQtObjectPtr& variableObject, const QString& methodName, const QString& context) +QString PythonQt::getReturnTypeOfWrappedMethodHelper(const PythonQtObjectPtr& variableObject, const QString& methodName, + const QString& context) { PythonQtObjectPtr methodObject; if (PyDict_Check(variableObject)) { @@ -1954,9 +1957,9 @@ QString PythonQt::getReturnTypeOfWrappedMethodHelper(const PythonQtObjectPtr& va if (methodObject.isNull()) { return ""; } - + QString type; - + if (PythonQtUtils::isPythonClassType(methodObject)) { // the methodObject is not a method, but the name of a type/class. This means // a constructor is called. Return the context. @@ -1964,7 +1967,7 @@ QString PythonQt::getReturnTypeOfWrappedMethodHelper(const PythonQtObjectPtr& va } else if (methodObject->ob_type == &PythonQtSlotFunction_Type) { PythonQtSlotInfo* slotInfo = ((PythonQtSlotFunctionObject*)methodObject.object())->m_ml; if (slotInfo) { - if (slotInfo->parameterCount()>0) { + if (slotInfo->parameterCount() > 0) { type = slotInfo->parameters().at(0).name; if (type.contains("<")) { // can't handle templates @@ -1988,12 +1991,12 @@ QString PythonQt::getReturnTypeOfWrappedMethodHelper(const PythonQtObjectPtr& va return type; } -void PythonQt::registerCPPClass(const char* typeName, const char* parentTypeName, const char* package, PythonQtQObjectCreatorFunctionCB* wrapperCreator, PythonQtShellSetInstanceWrapperCB* shell) +void PythonQt::registerCPPClass(const char* typeName, const char* parentTypeName, const char* package, + PythonQtQObjectCreatorFunctionCB* wrapperCreator, PythonQtShellSetInstanceWrapperCB* shell) { _p->registerCPPClass(typeName, parentTypeName, package, wrapperCreator, shell); } - PythonQtClassInfo* PythonQtPrivate::lookupClassInfoAndCreateIfNotPresent(const char* typeName) { PythonQtClassInfo* info = _knownClassInfos.value(typeName); @@ -2033,7 +2036,9 @@ bool PythonQtPrivate::addParentClass(const char* typeName, const char* parentTyp } } -void PythonQtPrivate::registerCPPClass(const char* typeName, const char* parentTypeName, const char* package, PythonQtQObjectCreatorFunctionCB* wrapperCreator, PythonQtShellSetInstanceWrapperCB* shell, PyObject* module, int typeSlots) +void PythonQtPrivate::registerCPPClass(const char* typeName, const char* parentTypeName, const char* package, + PythonQtQObjectCreatorFunctionCB* wrapperCreator, PythonQtShellSetInstanceWrapperCB* shell, PyObject* module, + int typeSlots) { PythonQtClassInfo* info = lookupClassInfoAndCreateIfNotPresent(typeName); if (!info->pythonQtClassWrapper()) { @@ -2041,7 +2046,7 @@ void PythonQtPrivate::registerCPPClass(const char* typeName, const char* parentT info->setupCPPObject(typeName); createPythonQtClassWrapper(info, package, module); } - if (parentTypeName && strcmp(parentTypeName,"")!=0) { + if (parentTypeName && strcmp(parentTypeName, "") != 0) { addParentClass(typeName, parentTypeName, 0); } if (wrapperCreator) { @@ -2080,17 +2085,18 @@ void PythonQtPrivate::registerCPPClass(const char* typeName, const char* parentT namespace { - void addObjectToPackage(PyObject* obj, const char* name, const char* packageName, PyObject* package) - { - if (PyModule_AddObject(package, name, obj) < 0) { - Py_DECREF(obj); - std::cerr << "failed to add " << name << " to " << packageName << "\n"; - } +void addObjectToPackage(PyObject* obj, const char* name, const char* packageName, PyObject* package) +{ + if (PyModule_AddObject(package, name, obj) < 0) { + Py_DECREF(obj); + std::cerr << "failed to add " << name << " to " << packageName << "\n"; } +} }; -void PythonQtPrivate::registerGlobalNamespace(const char* typeName, const char* packageName, PythonQtQObjectCreatorFunctionCB* wrapperCreator, const QMetaObject& metaObject, PyObject* module) +void PythonQtPrivate::registerGlobalNamespace(const char* typeName, const char* packageName, + PythonQtQObjectCreatorFunctionCB* wrapperCreator, const QMetaObject& metaObject, PyObject* module) { registerCPPClass(typeName, "", packageName, wrapperCreator, nullptr, module, 0); @@ -2104,14 +2110,13 @@ void PythonQtPrivate::registerGlobalNamespace(const char* typeName, const char* methodNames.insert(metaObject.method(i).name()); } QByteArray staticPrefix = "static_" + QByteArray(typeName) + "_"; // every static method starts with this string - for (auto name: methodNames) { - if (name.startsWith(staticPrefix)) { // non-static methods wouldn't work (and should not exists) + for (auto name : methodNames) { + if (name.startsWith(staticPrefix)) { // non-static methods wouldn't work (and should not exists) name = name.mid(staticPrefix.length()); PyObject* obj = PyObject_GetAttrString(globalNamespace, name.constData()); if (obj) { addObjectToPackage(obj, name, packageName, package); - } - else { + } else { std::cerr << "method not found " << name.constData() << " in " << typeName << std::endl; } } @@ -2123,8 +2128,7 @@ void PythonQtPrivate::registerGlobalNamespace(const char* typeName, const char* PyObject* obj = PyObject_GetAttrString(globalNamespace, metaEnum.name()); if (obj) { addObjectToPackage(obj, metaEnum.name(), packageName, package); - } - else { + } else { std::cerr << "enum type not found " << metaEnum.name() << " in " << typeName << std::endl; } #if QT_VERSION > 0x050800 @@ -2147,7 +2151,7 @@ void PythonQtPrivate::registerGlobalNamespace(const char* typeName, const char* PyObject* PythonQtPrivate::packageByName(const char* name) { - if (name==nullptr || name[0]==0) { + if (name == nullptr || name[0] == 0) { name = "private"; } PyObject* v = _packages.value(name); @@ -2162,9 +2166,12 @@ PyObject* PythonQtPrivate::packageByName(const char* name) return v; } -void PythonQtPrivate::handleVirtualOverloadReturnError(const char* signature, const PythonQtMethodInfo* methodInfo, PyObject* result) +void PythonQtPrivate::handleVirtualOverloadReturnError(const char* signature, const PythonQtMethodInfo* methodInfo, + PyObject* result) { - QString error = "Return value '" + PythonQtConv::PyObjGetString(result) + "' can not be converted to expected C++ type '" + methodInfo->parameters().at(0).name + "' as return value of virtual method " + signature; + QString error = "Return value '" + PythonQtConv::PyObjGetString(result) + + "' can not be converted to expected C++ type '" + methodInfo->parameters().at(0).name + + "' as return value of virtual method " + signature; PyErr_SetString(PyExc_AttributeError, QStringToPythonCharPointer(error)); PythonQt::self()->handleError(); } @@ -2186,12 +2193,12 @@ void PythonQt::clearNotFoundCachedMembers() } } -void PythonQt::removeWrapperFactory( PythonQtCppWrapperFactory* factory ) +void PythonQt::removeWrapperFactory(PythonQtCppWrapperFactory* factory) { _p->_cppWrapperFactories.removeAll(factory); } -void PythonQt::removeWrapperFactory( PythonQtForeignWrapperFactory* factory ) +void PythonQt::removeWrapperFactory(PythonQtForeignWrapperFactory* factory) { _p->_foreignWrapperFactories.removeAll(factory); } @@ -2232,10 +2239,10 @@ PythonQtObjectPtr PythonQtPrivate::createModule(const QString& name, PyObject* p return result; } -void* PythonQtPrivate::unwrapForeignWrapper( const QByteArray& classname, PyObject* obj ) +void* PythonQtPrivate::unwrapForeignWrapper(const QByteArray& classname, PyObject* obj) { void* foreignObject = nullptr; - for (int i=0; i<_foreignWrapperFactories.size(); i++) { + for (int i = 0; i < _foreignWrapperFactories.size(); i++) { foreignObject = _foreignWrapperFactories.at(i)->unwrap(classname, obj); if (foreignObject) { return foreignObject; @@ -2247,11 +2254,9 @@ void* PythonQtPrivate::unwrapForeignWrapper( const QByteArray& classname, PyObje bool PythonQtPrivate::isMethodDescriptor(PyObject* object) const { // This implementation is the same as in inspect.ismethoddescriptor(), inspect.py. - if (PyObject_HasAttrString(object, "__get__") && - !PyObject_HasAttrString(object, "__set__") && - !PyMethod_Check(object) && - !PyFunction_Check(object) - ) { + if (PyObject_HasAttrString(object, "__get__") && !PyObject_HasAttrString(object, "__set__") && !PyMethod_Check(object) + && !PyFunction_Check(object)) + { return true; } return false; @@ -2260,7 +2265,8 @@ bool PythonQtPrivate::isMethodDescriptor(PyObject* object) const // We need this for the dynamic meta object building: #include -const QMetaObject* PythonQtPrivate::getDynamicMetaObject(PythonQtInstanceWrapper* wrapper, const QMetaObject* prototypeMetaObject) +const QMetaObject* PythonQtPrivate::getDynamicMetaObject(PythonQtInstanceWrapper* wrapper, + const QMetaObject* prototypeMetaObject) { PYTHONQT_GIL_SCOPE; PythonQtDynamicClassInfo* info = wrapper->dynamicClassInfo(); @@ -2273,10 +2279,11 @@ const QMetaObject* PythonQtPrivate::getDynamicMetaObject(PythonQtInstanceWrapper return prototypeMetaObject; } -const QMetaObject* PythonQtPrivate::setupDynamicMetaObjectChain(PythonQtClassWrapper* type, const QMetaObject* prototypeMetaObject) +const QMetaObject* PythonQtPrivate::setupDynamicMetaObjectChain(PythonQtClassWrapper* type, + const QMetaObject* prototypeMetaObject) { if (!type->_dynamicClassInfo->_dynamicMetaObject) { - PyTypeObject* superType = ((PyTypeObject *)type)->tp_base; + PyTypeObject* superType = ((PyTypeObject*)type)->tp_base; const QMetaObject* metaObjectOfParent = prototypeMetaObject; if (((PythonQtClassWrapper*)superType)->_dynamicClassInfo) { metaObjectOfParent = setupDynamicMetaObjectChain((PythonQtClassWrapper*)superType, prototypeMetaObject); @@ -2287,7 +2294,8 @@ const QMetaObject* PythonQtPrivate::setupDynamicMetaObjectChain(PythonQtClassWra } } -const QMetaObject* PythonQtPrivate::buildDynamicMetaObject(PythonQtClassWrapper* type, const QMetaObject* prototypeMetaObject) +const QMetaObject* PythonQtPrivate::buildDynamicMetaObject(PythonQtClassWrapper* type, + const QMetaObject* prototypeMetaObject) { //std::cout << "creating " << ((PyTypeObject*)type)->tp_name << " derived from " << prototypeMetaObject->className() << std::endl; @@ -2378,8 +2386,8 @@ const QMetaObject* PythonQtPrivate::buildDynamicMetaObject(PythonQtClassWrapper* return type->_dynamicClassInfo->_dynamicMetaObject; } - -int PythonQtPrivate::handleMetaCall(QObject* object, PythonQtInstanceWrapper* wrapper, QMetaObject::Call call, int id, void** args) +int PythonQtPrivate::handleMetaCall(QObject* object, PythonQtInstanceWrapper* wrapper, QMetaObject::Call call, int id, + void** args) { const QMetaObject* meta = object->metaObject(); int methodCount = meta->methodCount(); @@ -2406,7 +2414,8 @@ int PythonQtPrivate::handleMetaCall(QObject* object, PythonQtInstanceWrapper* wr } else { return id - methodCount; } - const PythonQtMethodInfo::ParameterInfo& info = PythonQtMethodInfo::getParameterInfoForMetaType(metaProp.userType()); + const PythonQtMethodInfo::ParameterInfo& info = + PythonQtMethodInfo::getParameterInfoForMetaType(metaProp.userType()); if (call == QMetaObject::WriteProperty) { PyObject* value = PythonQtConv::ConvertQtValueToPython(info, args[0]); @@ -2433,7 +2442,7 @@ int PythonQtPrivate::handleMetaCall(QObject* object, PythonQtInstanceWrapper* wr return id - methodCount; } -void PythonQtPrivate::callMethodInPython(QMetaMethod &method, PythonQtInstanceWrapper* wrapper, void** args) +void PythonQtPrivate::callMethodInPython(QMetaMethod& method, PythonQtInstanceWrapper* wrapper, void** args) { PyObject* func = PyObject_GetAttrString((PyObject*)wrapper, method.name()); if (func) { @@ -2442,7 +2451,7 @@ void PythonQtPrivate::callMethodInPython(QMetaMethod &method, PythonQtInstanceWr if (result) { PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, nullptr, args[0]); // TODO: handle error? - //PythonQt::priv()->handleVirtualOverloadReturnError("devType", methodInfo, result); + //PythonQt::priv()->handleVirtualOverloadReturnError("devType", methodInfo, result); } Py_XDECREF(result); Py_DECREF(func); @@ -2452,13 +2461,13 @@ void PythonQtPrivate::callMethodInPython(QMetaMethod &method, PythonQtInstanceWr QString PythonQtPrivate::getSignature(PyObject* object) { QString signature; - + if (object) { PyMethodObject* method = nullptr; PyFunctionObject* func = nullptr; - + bool decrefMethod = false; - + if (PythonQtUtils::isPythonClassType(object)) { method = (PyMethodObject*)PyObject_GetAttrString(object, "__init__"); decrefMethod = true; @@ -2467,7 +2476,7 @@ QString PythonQtPrivate::getSignature(PyObject* object) } else if (object->ob_type == &PyMethod_Type) { method = (PyMethodObject*)object; } - if (method) { + if (method) { if (PyFunction_Check(method->im_func)) { func = (PyFunctionObject*)method->im_func; } else if (isMethodDescriptor((PyObject*)method)) { @@ -2494,7 +2503,7 @@ QString PythonQtPrivate::getSignature(PyObject* object) } } } - + if (func) { QString funcName; PyObject* s = PyObject_GetAttrString((PyObject*)func, "__name__"); @@ -2511,7 +2520,7 @@ QString PythonQtPrivate::getSignature(PyObject* object) Py_DECREF(s); } } - + QStringList arguments; QStringList defaults; QString varargs; @@ -2523,7 +2532,7 @@ QString PythonQtPrivate::getSignature(PyObject* object) if (auto co_varnames = PyCode_GetVarnames(code)) { int nargs = code->co_argcount; Q_ASSERT(PyTuple_Check(co_varnames)); - for (int i=0; ifunc_defaults; if (defaultsTuple) { Q_ASSERT(PyTuple_Check(defaultsTuple)); - for (Py_ssize_t i=0; i0 || arguments[i] != "self") { + for (int i = 0; i < arguments.size(); i++) { + if (!signature.isEmpty()) { + signature += ", "; + } + if (!method || i > 0 || arguments[i] != "self") { signature += arguments[i]; if (i >= firstdefault) { - signature += "=" + defaults[i-firstdefault]; + signature += "=" + defaults[i - firstdefault]; } } } if (!varargs.isEmpty()) { - if (!signature.isEmpty()) { signature += ", "; } + if (!signature.isEmpty()) { + signature += ", "; + } signature += "*" + varargs; } if (!varkeywords.isEmpty()) { - if (!signature.isEmpty()) { signature += ", "; } + if (!signature.isEmpty()) { + signature += ", "; + } signature += "**" + varkeywords; } signature = funcName + "(" + signature + ")"; } - + if (method && decrefMethod) { Py_DECREF(method); } } - + return signature; } -void PythonQtPrivate::shellClassDeleted( void* shellClass ) +void PythonQtPrivate::shellClassDeleted(void* shellClass) { PYTHONQT_GIL_SCOPE @@ -2610,22 +2625,22 @@ void PythonQtPrivate::shellClassDeleted( void* shellClass ) } } -PyObject* PythonQtPrivate::wrapMemoryAsBuffer( const void* data, Py_ssize_t size ) +PyObject* PythonQtPrivate::wrapMemoryAsBuffer(const void* data, Py_ssize_t size) { return PyMemoryView_FromMemory((char*)data, size, PyBUF_READ); } -PyObject* PythonQtPrivate::wrapMemoryAsBuffer( void* data, Py_ssize_t size ) +PyObject* PythonQtPrivate::wrapMemoryAsBuffer(void* data, Py_ssize_t size) { return PyMemoryView_FromMemory((char*)data, size, PyBUF_WRITE); } -PythonQtClassInfo* PythonQtPrivate::getClassInfo( const QMetaObject* meta ) +PythonQtClassInfo* PythonQtPrivate::getClassInfo(const QMetaObject* meta) { return getClassInfo(QByteArray(meta->className())); } -PythonQtClassInfo* PythonQtPrivate::getClassInfo( const QByteArray& className ) +PythonQtClassInfo* PythonQtPrivate::getClassInfo(const QByteArray& className) { PythonQtClassInfo* result = _knownClassInfos.value(className); if (!result) { @@ -2638,7 +2653,8 @@ PythonQtClassInfo* PythonQtPrivate::getClassInfo( const QByteArray& className ) recursion = false; result = _knownClassInfos.value(className); if (!result) { - std::cerr << "PythonQt lazy import " << module.constData() << " did not resolve " << className.constData() < #include - class PythonQtClassInfo; class PythonQtPrivate; class PythonQtMethodInfo; @@ -70,15 +69,17 @@ class PythonQtCppWrapperFactory; class PythonQtForeignWrapperFactory; class PythonQtQFileImporter; -typedef void PythonQtVoidPtrCB(void* object); -typedef void PythonQtQObjectWrappedCB(QObject* object); -typedef void PythonQtQObjectNoLongerWrappedCB(QObject* object); -typedef void* PythonQtPolymorphicHandlerCB(const void *ptr, const char **class_name); +typedef void PythonQtVoidPtrCB(void* object); +typedef void PythonQtQObjectWrappedCB(QObject* object); +typedef void PythonQtQObjectNoLongerWrappedCB(QObject* object); +typedef void* PythonQtPolymorphicHandlerCB(const void* ptr, const char** class_name); typedef QString PythonQtQObjectMissingAttributeCB(QObject* object, const QString& attribute); typedef void PythonQtShellSetInstanceWrapperCB(void* object, PythonQtInstanceWrapper* wrapper); -template void PythonQtSetInstanceWrapperOnShell(void* object, PythonQtInstanceWrapper* wrapper) { +template +void PythonQtSetInstanceWrapperOnShell(void* object, PythonQtInstanceWrapper* wrapper) +{ (reinterpret_cast(object))->_wrapper = wrapper; } @@ -88,15 +89,18 @@ template void PythonQtSetInstanceWrapperOnShell(void* object, PythonQtI template class PythonQtPassOwnershipToCPP { - public: - //! Allow conversion from T to PythonQtPassOwnershipToCPP - PythonQtPassOwnershipToCPP(const T& t):_t(t) {} - //! Allow conversion from PythonQtPassOwnershipToCPP to T - operator T() const { return _t; } - - //! Stored value. This is important so that it has the same memory layout - //! as a pointer if T is a pointer type (which is the typical use case for this class). - T _t; +public: + //! Allow conversion from T to PythonQtPassOwnershipToCPP + PythonQtPassOwnershipToCPP(const T& t) + : _t(t) + { + } + //! Allow conversion from PythonQtPassOwnershipToCPP to T + operator T() const { return _t; } + + //! Stored value. This is important so that it has the same memory layout + //! as a pointer if T is a pointer type (which is the typical use case for this class). + T _t; }; //! Helper template that allows to pass the ownership of a C++ instance between C++ and Python @@ -107,7 +111,10 @@ class PythonQtPassOwnershipToPython { public: //! Allow conversion from T to PythonQtPassOwnershipToPython - PythonQtPassOwnershipToPython(const T& t):_t(t) {} + PythonQtPassOwnershipToPython(const T& t) + : _t(t) + { + } //! Allow conversion from PythonQtPassOwnershipToPython to T operator T() const { return _t; } @@ -124,7 +131,10 @@ class PythonQtNewOwnerOfThis { public: //! Allow conversion from T to PythonQtNewOwnerOfThis - PythonQtNewOwnerOfThis(const T& t):_t(t) {} + PythonQtNewOwnerOfThis(const T& t) + : _t(t) + { + } //! Allow conversion from PythonQtNewOwnerOfThis to T operator T() const { return _t; } @@ -133,9 +143,10 @@ class PythonQtNewOwnerOfThis T _t; }; - //! returns the offset that needs to be added to upcast an object of type T1 to T2 -template int PythonQtUpcastingOffset() { +template +int PythonQtUpcastingOffset() +{ return ((reinterpret_cast(static_cast(reinterpret_cast(0x100)))) - (reinterpret_cast(reinterpret_cast(0x100)))); } @@ -144,7 +155,11 @@ template int PythonQtUpcastingOffset() { typedef QObject* PythonQtQObjectCreatorFunctionCB(); //! helper template to create a derived QObject class -template QObject* PythonQtCreateObject() { return new T(); } +template +QObject* PythonQtCreateObject() +{ + return new T(); +} //! Helper define to convert from QString to Python C-API #define QStringToPythonConstCharPointer(arg) ((arg).toUtf8().constData()) @@ -160,7 +175,8 @@ template QObject* PythonQtCreateObject() { return new T(); } but you will need to populate the dict with the __builtins__ instance to have all Pythons available when running code in the scope of a dict. */ -class PYTHONQT_EXPORT PythonQt : public QObject { +class PYTHONQT_EXPORT PythonQt : public QObject +{ Q_OBJECT @@ -206,15 +222,12 @@ class PYTHONQT_EXPORT PythonQt : public QObject { Type_Invert = 1 << 29, Type_RichCompare = 1 << 30, - Type_NonZero = 1 << 31, + Type_NonZero = 1 << 31, }; //! enum for profiling callback - enum ProfilingCallbackState { - Enter = 1, - Leave = 2 - }; + enum ProfilingCallbackState { Enter = 1, Leave = 2 }; //! callback for profiling. className and methodName are only passed when state == Enter, otherwise //! they are NULL. @@ -238,15 +251,7 @@ class PYTHONQT_EXPORT PythonQt : public QObject { //@} //! defines the object types for introspection - enum ObjectType { - Class, - Function, - Variable, - Module, - Anything, - CallOverloads - }; - + enum ObjectType { Class, Function, Variable, Module, Anything, CallOverloads }; //--------------------------------------------------------------------------- //! \name Standard input handling @@ -254,7 +259,7 @@ class PYTHONQT_EXPORT PythonQt : public QObject { //! Overwrite default handling of stdin using a custom callback. It internally backup //! the original 'sys.stdin' into 'sys.pythonqt_original_stdin' - void setRedirectStdInCallback(PythonQtInputChangedCB* callback, void * callbackData = nullptr); + void setRedirectStdInCallback(PythonQtInputChangedCB* callback, void* callbackData = nullptr); //! Enable or disable stdin custom callback. It resets 'sys.stdin' using either 'sys.pythonqt_stdin' //! or 'sys.pythonqt_original_stdin' @@ -325,7 +330,8 @@ class PYTHONQT_EXPORT PythonQt : public QObject { //! registers a QObject derived class to PythonQt (this is implicitly called by addObject as well) /* Since Qt4 does not offer a way to detect if a given classname is derived from QObject and thus has a QMetaObject, you MUST register all your QObject derived classes here when you want them to be detected in signal and slot calls */ - void registerClass(const QMetaObject* metaobject, const char* package = nullptr, PythonQtQObjectCreatorFunctionCB* wrapperCreator = nullptr, PythonQtShellSetInstanceWrapperCB* shell = nullptr); + void registerClass(const QMetaObject* metaobject, const char* package = nullptr, + PythonQtQObjectCreatorFunctionCB* wrapperCreator = nullptr, PythonQtShellSetInstanceWrapperCB* shell = nullptr); //! add a wrapper object for the given QMetaType typeName, also does an addClassDecorators() to add constructors for variants //! (ownership of wrapper is passed to PythonQt) @@ -335,7 +341,8 @@ class PYTHONQT_EXPORT PythonQt : public QObject { All slots that take a pointer to typeName as the first argument will be callable from Python on a variant object that contains such a type. */ - void registerCPPClass(const char* typeName, const char* parentTypeName = nullptr, const char* package = nullptr, PythonQtQObjectCreatorFunctionCB* wrapperCreator = nullptr, PythonQtShellSetInstanceWrapperCB* shell = nullptr); + void registerCPPClass(const char* typeName, const char* parentTypeName = nullptr, const char* package = nullptr, + PythonQtQObjectCreatorFunctionCB* wrapperCreator = nullptr, PythonQtShellSetInstanceWrapperCB* shell = nullptr); //! as an alternative to registerClass, you can tell PythonQt the names of QObject derived classes //! and it will register the classes when it first sees a pointer to such a derived class @@ -345,7 +352,7 @@ class PYTHONQT_EXPORT PythonQt : public QObject { //! and can be calculated using PythonQtUpcastingOffset(), which also verifies that //! type is really derived from parentType. //! Returns false if the typeName was not yet registered. - bool addParentClass(const char* typeName, const char* parentTypeName, int upcastingOffset=0); + bool addParentClass(const char* typeName, const char* parentTypeName, int upcastingOffset = 0); //! add a handler for polymorphic downcasting void addPolymorphicHandler(const char* typeName, PythonQtPolymorphicHandlerCB* cb); @@ -444,13 +451,16 @@ class PYTHONQT_EXPORT PythonQt : public QObject { //@{ //! call the given python \c callable in the scope of object, returns the result converted to a QVariant - QVariant call(PyObject* object, const QString& callable, const QVariantList& args = QVariantList(), const QVariantMap& kwargs = QVariantMap()); + QVariant call(PyObject* object, const QString& callable, const QVariantList& args = QVariantList(), + const QVariantMap& kwargs = QVariantMap()); //! call the given python object, returns the result converted to a QVariant - QVariant call(PyObject* callable, const QVariantList& args = QVariantList(), const QVariantMap& kwargs = QVariantMap()); + QVariant call(PyObject* callable, const QVariantList& args = QVariantList(), + const QVariantMap& kwargs = QVariantMap()); //! call the given python object, returns the result as new PyObject - PyObject* callAndReturnPyObject(PyObject* callable, const QVariantList& args = QVariantList(), const QVariantMap& kwargs = QVariantMap()); + PyObject* callAndReturnPyObject(PyObject* callable, const QVariantList& args = QVariantList(), + const QVariantMap& kwargs = QVariantMap()); //@} @@ -570,7 +580,7 @@ class PYTHONQT_EXPORT PythonQt : public QObject { bool handleError(bool printStack = true); //! return \a true if \a handleError() has been called and an error occurred. - bool hadError()const; + bool hadError() const; //! reset error flag. After calling this, hadError() will return false. //! \sa hadError() @@ -634,7 +644,8 @@ class PYTHONQT_EXPORT PythonQt : public QObject { private: void initPythonQtModule(bool redirectStdOut, const QByteArray& pythonQtModuleName); - QString getReturnTypeOfWrappedMethodHelper(const PythonQtObjectPtr& variableObject, const QString& methodName, const QString& context); + QString getReturnTypeOfWrappedMethodHelper(const PythonQtObjectPtr& variableObject, const QString& methodName, + const QString& context); PyObject* getObjectByType(const QString& typeName); @@ -652,14 +663,14 @@ class PYTHONQT_EXPORT PythonQt : public QObject { static int _uniqueModuleCount; PythonQtPrivate* _p; - }; class PythonQtDebugAPI; class PythonQtConfigAPI; //! internal PythonQt details -class PYTHONQT_EXPORT PythonQtPrivate : public QObject { +class PYTHONQT_EXPORT PythonQtPrivate : public QObject +{ Q_OBJECT @@ -693,7 +704,10 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject { //! returns if the id is the id for PythonQtSafeObjectPtr bool isPythonQtSafeObjectPtrMetaId(int id) { return _PythonQtSafeObjectPtr_metaId == id; } //! returns if the id is either PythonQtObjectPtr or PythonQtSafeObjectPtr - bool isPythonQtAnyObjectPtrMetaId(int id) { return _PythonQtObjectPtr_metaId == id || _PythonQtSafeObjectPtr_metaId == id; } + bool isPythonQtAnyObjectPtrMetaId(int id) + { + return _PythonQtObjectPtr_metaId == id || _PythonQtSafeObjectPtr_metaId == id; + } //! add the wrapper pointer (for reuse if the same obj appears while wrapper still exists) void addWrapperPointer(void* obj, PythonQtInstanceWrapper* wrapper); @@ -735,7 +749,9 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject { //! registers a QObject derived class to PythonQt (this is implicitly called by addObject as well) /* Since Qt4 does not offer a way to detect if a given classname is derived from QObject and thus has a QMetaObject, you MUST register all your QObject derived classes here when you want them to be detected in signal and slot calls */ - void registerClass(const QMetaObject* metaobject, const char* package = nullptr, PythonQtQObjectCreatorFunctionCB* wrapperCreator = nullptr, PythonQtShellSetInstanceWrapperCB* shell = nullptr, PyObject* module = nullptr, int typeSlots = 0); + void registerClass(const QMetaObject* metaobject, const char* package = nullptr, + PythonQtQObjectCreatorFunctionCB* wrapperCreator = nullptr, PythonQtShellSetInstanceWrapperCB* shell = nullptr, + PyObject* module = nullptr, int typeSlots = 0); //! add a wrapper object for the given QMetaType typeName, also does an addClassDecorators() to add constructors for variants //! (ownership of wrapper is passed to PythonQt) @@ -745,10 +761,13 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject { All slots that take a pointer to typeName as the first argument will be callable from Python on a variant object that contains such a type. */ - void registerCPPClass(const char* typeName, const char* parentTypeName = nullptr, const char* package = nullptr, PythonQtQObjectCreatorFunctionCB* wrapperCreator = nullptr, PythonQtShellSetInstanceWrapperCB* shell = nullptr, PyObject* module = nullptr, int typeSlots = 0); + void registerCPPClass(const char* typeName, const char* parentTypeName = nullptr, const char* package = nullptr, + PythonQtQObjectCreatorFunctionCB* wrapperCreator = nullptr, PythonQtShellSetInstanceWrapperCB* shell = nullptr, + PyObject* module = nullptr, int typeSlots = 0); //! Same as above, but all enums of the created wrapper will also be added to the given package and to the "Qt" package - void registerGlobalNamespace(const char* typeName, const char* package, PythonQtQObjectCreatorFunctionCB* wrapperCreator, const QMetaObject& metaObject, PyObject* module = nullptr); + void registerGlobalNamespace(const char* typeName, const char* package, + PythonQtQObjectCreatorFunctionCB* wrapperCreator, const QMetaObject& metaObject, PyObject* module = nullptr); //! as an alternative to registerClass, you can tell PythonQt the names of QObject derived classes //! and it will register the classes when it first sees a pointer to such a derived class @@ -758,16 +777,18 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject { void addDecorators(QObject* o, int decoTypes); //! helper method that creates a PythonQtClassWrapper object (returns a new reference) - PythonQtClassWrapper* createNewPythonQtClassWrapper(PythonQtClassInfo* info, PyObject* module, const QByteArray& pythonClassName); + PythonQtClassWrapper* createNewPythonQtClassWrapper(PythonQtClassInfo* info, PyObject* module, + const QByteArray& pythonClassName); //! create a new instance of the given enum type with given value (returns a new reference) - static PyObject* createEnumValueInstance(PyObject* enumType, unsigned int enumValue); + static PyObject* createEnumValueInstance(PyObject* enumType, unsigned int enumValue); //! helper that creates a new int derived class that represents the enum of the given name (returns a new reference) static PyObject* createNewPythonQtEnumWrapper(const char* enumName, PyObject* parentObject); //! helper method that creates a PythonQtInstanceWrapper object and registers it in the object map - PythonQtInstanceWrapper* createNewPythonQtInstanceWrapper(QObject* obj, PythonQtClassInfo* info, void* wrappedPtr = nullptr); + PythonQtInstanceWrapper* createNewPythonQtInstanceWrapper(QObject* obj, PythonQtClassInfo* info, + void* wrappedPtr = nullptr); //! get the class info for a meta object (if available) PythonQtClassInfo* getClassInfo(const QMetaObject* meta); @@ -816,7 +837,7 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject { int handleMetaCall(QObject* object, PythonQtInstanceWrapper* wrapper, QMetaObject::Call call, int id, void** args); //! calls the given method on Python function with same name. - void callMethodInPython(QMetaMethod &method, PythonQtInstanceWrapper* wrapper, void** args); + void callMethodInPython(QMetaMethod& method, PythonQtInstanceWrapper* wrapper, void** args); private: //! Setup the shared library suffixes by getting them from the "imp" module. @@ -832,10 +853,10 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject { PythonQtInstanceWrapper* findWrapperAndRemoveUnused(void* obj); //! stores pointer to PyObject mapping of wrapped QObjects AND C++ objects - QHash _wrappedObjects; + QHash _wrappedObjects; //! stores the meta info of known Qt classes - QHash _knownClassInfos; + QHash _knownClassInfos; //! names of qobject derived classes that can be casted to qobject savely QHash _knownQObjectClassNames; @@ -844,7 +865,7 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject { QHash _knownLazyClasses; //! stores signal receivers for QObjects - QHash _signalReceivers; + QHash _signalReceivers; //! the PythonQt python module PythonQtObjectPtr _pythonQtModule; diff --git a/src/PythonQtBoolResult.cpp b/src/PythonQtBoolResult.cpp index 09d685a64..3c9a4610c 100644 --- a/src/PythonQtBoolResult.cpp +++ b/src/PythonQtBoolResult.cpp @@ -42,9 +42,9 @@ #include "PythonQt.h" #include "PythonQtBoolResult.h" -static int PythonQtBoolResult_init(PythonQtBoolResultObject *self, PyObject* args, PyObject*) +static int PythonQtBoolResult_init(PythonQtBoolResultObject* self, PyObject* args, PyObject*) { - if (args && PyTuple_Size(args)>0) { + if (args && PyTuple_Size(args) > 0) { PyErr_SetString(PyExc_ValueError, "No arguments supported for BoolResult!"); return -1; } @@ -52,13 +52,13 @@ static int PythonQtBoolResult_init(PythonQtBoolResultObject *self, PyObject* arg return 0; } -static PyObject *PythonQtBoolResult_repr(PythonQtBoolResultObject *obj) +static PyObject* PythonQtBoolResult_repr(PythonQtBoolResultObject* obj) { PythonQtBoolResultObject* wrapper = (PythonQtBoolResultObject*)obj; - return PyUnicode_FromString(wrapper->_value?"BoolResult(True)":"BoolResult(False)"); + return PyUnicode_FromString(wrapper->_value ? "BoolResult(True)" : "BoolResult(False)"); } -static int PythonQtBoolResult_bool(PyObject *obj) +static int PythonQtBoolResult_bool(PyObject* obj) { PythonQtBoolResultObject* wrapper = (PythonQtBoolResultObject*)obj; return wrapper->_value; @@ -66,77 +66,77 @@ static int PythonQtBoolResult_bool(PyObject *obj) // we override nb_nonzero, so that one can do 'if' expressions to test for a NULL ptr static PyNumberMethods PythonQtBoolResult_as_number = { - nullptr, /* nb_add */ - nullptr, /* nb_subtract */ - nullptr, /* nb_multiply */ - nullptr, /* nb_remainder */ - nullptr, /* nb_divmod */ - nullptr, /* nb_power */ - nullptr, /* nb_negative */ - nullptr, /* nb_positive */ - nullptr, /* nb_absolute */ + nullptr, /* nb_add */ + nullptr, /* nb_subtract */ + nullptr, /* nb_multiply */ + nullptr, /* nb_remainder */ + nullptr, /* nb_divmod */ + nullptr, /* nb_power */ + nullptr, /* nb_negative */ + nullptr, /* nb_positive */ + nullptr, /* nb_absolute */ PythonQtBoolResult_bool, /* nb_bool */ - nullptr, /* nb_invert */ - nullptr, /* nb_lshift */ - nullptr, /* nb_rshift */ - nullptr, /* nb_and */ - nullptr, /* nb_xor */ - nullptr, /* nb_or */ - nullptr, /* nb_int */ - nullptr, /* nb_reserved */ - nullptr, /* nb_float */ - nullptr, /* nb_inplace_add */ - nullptr, /* nb_inplace_subtract */ - nullptr, /* nb_inplace_multiply */ - nullptr, /* nb_inplace_remainder */ - nullptr, /* nb_inplace_power */ - nullptr, /* nb_inplace_lshift */ - nullptr, /* nb_inplace_rshift */ - nullptr, /* nb_inplace_and */ - nullptr, /* nb_inplace_xor */ - nullptr, /* nb_inplace_or */ - nullptr, /* nb_floor_divide */ - nullptr, /* nb_true_divide */ - nullptr, /* nb_inplace_floor_divide */ - nullptr, /* nb_inplace_true_divide */ - nullptr, /* nb_index */ + nullptr, /* nb_invert */ + nullptr, /* nb_lshift */ + nullptr, /* nb_rshift */ + nullptr, /* nb_and */ + nullptr, /* nb_xor */ + nullptr, /* nb_or */ + nullptr, /* nb_int */ + nullptr, /* nb_reserved */ + nullptr, /* nb_float */ + nullptr, /* nb_inplace_add */ + nullptr, /* nb_inplace_subtract */ + nullptr, /* nb_inplace_multiply */ + nullptr, /* nb_inplace_remainder */ + nullptr, /* nb_inplace_power */ + nullptr, /* nb_inplace_lshift */ + nullptr, /* nb_inplace_rshift */ + nullptr, /* nb_inplace_and */ + nullptr, /* nb_inplace_xor */ + nullptr, /* nb_inplace_or */ + nullptr, /* nb_floor_divide */ + nullptr, /* nb_true_divide */ + nullptr, /* nb_inplace_floor_divide */ + nullptr, /* nb_inplace_true_divide */ + nullptr, /* nb_index */ }; PyTypeObject PythonQtBoolResult_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) /*tp_base*/ - "BoolResult", /* tp_name */ - sizeof(PythonQtBoolResultObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - nullptr, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ - nullptr, /* tp_getattr */ - nullptr, /* tp_setattr */ - nullptr, /* tp_as_async */ - (reprfunc)PythonQtBoolResult_repr, /* tp_repr */ - &PythonQtBoolResult_as_number, /* tp_as_number */ - nullptr, /* tp_as_sequence */ - nullptr, /* tp_as_mapping */ - nullptr, /* tp_hash */ - nullptr, /* tp_call */ - nullptr, /* tp_str */ - nullptr, /* tp_getattro */ - nullptr, /* tp_setattro */ - nullptr, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT,/* tp_flags */ - "Result object that is useful for bool* arguments", /* tp_doc */ - nullptr, /* tp_traverse */ - nullptr, /* tp_clear */ - nullptr, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - nullptr, /* tp_iter */ - nullptr, /* tp_iternext */ - nullptr, /* tp_methods */ - nullptr, /* tp_members */ - nullptr, /* tp_getset */ - nullptr, /* tp_base */ - nullptr, /* tp_dict */ - nullptr, /* tp_descr_get */ - nullptr, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)&PythonQtBoolResult_init, /* tp_init */ + PyVarObject_HEAD_INIT(&PyType_Type, 0) /*tp_base*/ + "BoolResult", /* tp_name */ + sizeof(PythonQtBoolResultObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + nullptr, /* tp_dealloc */ + 0, /* tp_vectorcall_offset */ + nullptr, /* tp_getattr */ + nullptr, /* tp_setattr */ + nullptr, /* tp_as_async */ + (reprfunc)PythonQtBoolResult_repr, /* tp_repr */ + &PythonQtBoolResult_as_number, /* tp_as_number */ + nullptr, /* tp_as_sequence */ + nullptr, /* tp_as_mapping */ + nullptr, /* tp_hash */ + nullptr, /* tp_call */ + nullptr, /* tp_str */ + nullptr, /* tp_getattro */ + nullptr, /* tp_setattro */ + nullptr, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "Result object that is useful for bool* arguments", /* tp_doc */ + nullptr, /* tp_traverse */ + nullptr, /* tp_clear */ + nullptr, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + nullptr, /* tp_iter */ + nullptr, /* tp_iternext */ + nullptr, /* tp_methods */ + nullptr, /* tp_members */ + nullptr, /* tp_getset */ + nullptr, /* tp_base */ + nullptr, /* tp_dict */ + nullptr, /* tp_descr_get */ + nullptr, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)&PythonQtBoolResult_init, /* tp_init */ }; diff --git a/src/PythonQtBoolResult.h b/src/PythonQtBoolResult.h index d459d6d73..e3cd12834 100644 --- a/src/PythonQtBoolResult.h +++ b/src/PythonQtBoolResult.h @@ -52,9 +52,8 @@ extern PYTHONQT_EXPORT PyTypeObject PythonQtBoolResult_Type; //! defines a python object that stores a single bool struct PythonQtBoolResultObject { - PyObject_HEAD - bool _value; + PyObject_HEAD + bool _value; }; - #endif diff --git a/src/PythonQtClassInfo.cpp b/src/PythonQtClassInfo.cpp index d4d9b44fa..68799e33f 100644 --- a/src/PythonQtClassInfo.cpp +++ b/src/PythonQtClassInfo.cpp @@ -53,11 +53,10 @@ QHash PythonQtMethodInfo::_parameterTypeDict; QList PythonQtClassInfo::_globalNamespaceWrappers; // List of words that are reserved in Python, but not in C++, so they need escaping -QSet PythonQtClassInfo::_reservedNames{ - "None", "True", "False" -}; +QSet PythonQtClassInfo::_reservedNames {"None", "True", "False"}; -PythonQtClassInfo::PythonQtClassInfo() { +PythonQtClassInfo::PythonQtClassInfo() +{ _meta = nullptr; _constructors = nullptr; _destructor = nullptr; @@ -79,7 +78,7 @@ PythonQtClassInfo::PythonQtClassInfo() { PythonQtClassInfo::~PythonQtClassInfo() { clearCachedMembers(); - + if (_constructors) { _constructors->deleteOverloadsAndThis(); } @@ -113,7 +112,7 @@ void PythonQtClassInfo::clearCachedMembers() QHashIterator i(_cachedMembers); while (i.hasNext()) { PythonQtMemberInfo member = i.next().value(); - if (member._type== PythonQtMemberInfo::Slot || member._type== PythonQtMemberInfo::Signal) { + if (member._type == PythonQtMemberInfo::Slot || member._type == PythonQtMemberInfo::Signal) { PythonQtSlotInfo* info = member._slot; while (info) { PythonQtSlotInfo* next = info->nextInfo(); @@ -130,36 +129,36 @@ int PythonQtClassInfo::findCharOffset(const char* sigStart, char someChar) char c; do { c = *sigEnd++; - } while (c!=someChar && c!=0); - return sigEnd-sigStart-1; + } while (c != someChar && c != 0); + return sigEnd - sigStart - 1; } - + bool PythonQtClassInfo::lookForPropertyAndCache(const char* memberName) { - if (!_meta) return false; - + if (!_meta) + return false; + bool found = false; const char* attributeName = memberName; // look for properties int i = _meta->indexOfProperty(attributeName); #ifdef PYTHONQT_SUPPORT_NAME_PROPERTY bool nameMapped = false; - if (i==-1) { + if (i == -1) { // try to map name to objectName - if (qstrcmp(attributeName, "name")==0) { + if (qstrcmp(attributeName, "name") == 0) { attributeName = "objectName"; nameMapped = true; i = _meta->indexOfProperty(attributeName); } } #endif - if (qstrcmp(attributeName, "singleShot") == 0 && - className() == "QTimer") { + if (qstrcmp(attributeName, "singleShot") == 0 && className() == "QTimer") { // ignore singleShot property, users need to use setSingleShot and isSingleShot instead... i = -1; } - if (i!=-1) { + if (i != -1) { PythonQtMemberInfo newInfo(_meta->property(i)); _cachedMembers.insert(attributeName, newInfo); #ifdef PYTHONQT_SUPPORT_NAME_PROPERTY @@ -167,24 +166,28 @@ bool PythonQtClassInfo::lookForPropertyAndCache(const char* memberName) _cachedMembers.insert(memberName, newInfo); } #endif - #ifdef PYTHONQT_DEBUG +#ifdef PYTHONQT_DEBUG std::cout << "caching property " << memberName << " on " << _meta->className() << std::endl; - #endif +#endif found = true; } return found; } -PythonQtSlotInfo* PythonQtClassInfo::recursiveFindDecoratorSlotsFromDecoratorProvider(const char* memberName, PythonQtSlotInfo* inputInfo, bool &found, QHash& memberCache, int upcastingOffset) +PythonQtSlotInfo* PythonQtClassInfo::recursiveFindDecoratorSlotsFromDecoratorProvider(const char* memberName, + PythonQtSlotInfo* inputInfo, bool& found, QHash& memberCache, int upcastingOffset) { inputInfo = findDecoratorSlotsFromDecoratorProvider(memberName, inputInfo, found, memberCache, upcastingOffset); for (const ParentClassInfo& info : _parentClasses) { - inputInfo = info._parent->recursiveFindDecoratorSlotsFromDecoratorProvider(memberName, inputInfo, found, memberCache, upcastingOffset+info._upcastingOffset); + inputInfo = info._parent->recursiveFindDecoratorSlotsFromDecoratorProvider(memberName, inputInfo, found, + memberCache, upcastingOffset + info._upcastingOffset); } return inputInfo; } -PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(const char* memberName, PythonQtSlotInfo* tail, bool &found, QHash& memberCache, int upcastingOffset) { +PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(const char* memberName, + PythonQtSlotInfo* tail, bool& found, QHash& memberCache, int upcastingOffset) +{ QObject* decoratorProvider = decorator(); if (decoratorProvider) { //qDebug()<< "looking " << decoratorProvider->metaObject()->className() << " " << memberName << " " << upcastingOffset; @@ -193,9 +196,10 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(con int startFrom = QObject::staticMetaObject.methodCount(); for (int i = startFrom; i < numMethods; i++) { QMetaMethod m = meta->method(i); - if ((m.methodType() == QMetaMethod::Method || - m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) { - + if ((m.methodType() == QMetaMethod::Method || m.methodType() == QMetaMethod::Slot) + && m.access() == QMetaMethod::Public) + { + QByteArray signature = PythonQtUtils::methodName(m); bool isClassDeco = false; if (signature.startsWith("static_")) { @@ -208,11 +212,12 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(con isClassDeco = true; } // XXX no checking is currently done if the slots have correct first argument or not... - + // check if same length and same name if (signature == memberName) { found = true; - PythonQtSlotInfo* info = new PythonQtSlotInfo(this, m, i, decoratorProvider, isClassDeco?PythonQtSlotInfo::ClassDecorator:PythonQtSlotInfo::InstanceDecorator); + PythonQtSlotInfo* info = new PythonQtSlotInfo(this, m, i, decoratorProvider, + isClassDeco ? PythonQtSlotInfo::ClassDecorator : PythonQtSlotInfo::InstanceDecorator); info->setUpcastingOffset(upcastingOffset); //qDebug()<< "adding " << decoratorProvider->metaObject()->className() << " " << memberName << " " << upcastingOffset; if (tail) { @@ -236,27 +241,28 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlotsFromDecoratorProvider(con // and not in the parent class, which is traversed recursively later on. // (if the class in not a QObject, we are working with a script wrapper QObject // and need to read all slots/signals starting from 0). - int methodOffset = _isQObject?_meta->methodOffset():0; + int methodOffset = _isQObject ? _meta->methodOffset() : 0; for (int i = methodOffset; i < numMethods; i++) { QMetaMethod m = _meta->method(i); - if (((m.methodType() == QMetaMethod::Method || - m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) - || m.methodType()==QMetaMethod::Signal) { + if (((m.methodType() == QMetaMethod::Method || m.methodType() == QMetaMethod::Slot) + && m.access() == QMetaMethod::Public) + || m.methodType() == QMetaMethod::Signal) + { - QByteArray signature = PythonQtUtils::methodName(m); + QByteArray signature = PythonQtUtils::methodName(m); - // check if same length and same name - if (signature == memberName) { - found = true; - PythonQtSlotInfo* info = new PythonQtSlotInfo(this, m, i); - if (tail) { - tail->setNextInfo(info); - } else { - PythonQtMemberInfo newInfo(info); - memberCache.insert(signature, newInfo); - } - tail = info; + // check if same length and same name + if (signature == memberName) { + found = true; + PythonQtSlotInfo* info = new PythonQtSlotInfo(this, m, i); + if (tail) { + tail->setNextInfo(info); + } else { + PythonQtMemberInfo newInfo(info); + memberCache.insert(signature, newInfo); } + tail = info; + } } } } @@ -267,12 +273,12 @@ bool PythonQtClassInfo::lookForMethodAndCache(const char* memberName) { bool found = false; PythonQtSlotInfo* tail = nullptr; - + // look for dynamic decorators in this class and in derived classes // (do this first to allow overloading of existing slots with generated wrappers, // e.g. QDialog::accept is overloaded with PythonQtWrapper_QDialog::accept decorator) tail = recursiveFindDecoratorSlotsFromDecoratorProvider(memberName, tail, found, _cachedMembers, 0); - + return found; } @@ -281,12 +287,13 @@ bool PythonQtClassInfo::lookForEnumAndCache(const QMetaObject* meta, const char* bool found = false; // look for enum values int enumCount = meta->enumeratorCount(); - for (int i=0;ienumerator(i); // we do not want flags, they will cause our values to appear two times - if (e.isFlag()) continue; - - for (int j=0; j < e.keyCount(); j++) { + if (e.isFlag()) + continue; + + for (int j = 0; j < e.keyCount(); j++) { if (escapeReservedNames(e.key(j)) == memberName) { PyObject* enumType = findEnumWrapper(e.name()); if (enumType) { @@ -294,9 +301,9 @@ bool PythonQtClassInfo::lookForEnumAndCache(const QMetaObject* meta, const char* enumValuePtr.setNewRef(PythonQtPrivate::createEnumValueInstance(enumType, e.value(j))); PythonQtMemberInfo newInfo(enumValuePtr); _cachedMembers.insert(memberName, newInfo); - #ifdef PYTHONQT_DEBUG +#ifdef PYTHONQT_DEBUG std::cout << "caching enum " << memberName << " on " << meta->className() << std::endl; - #endif +#endif found = true; break; } else { @@ -315,7 +322,7 @@ PythonQtMemberInfo PythonQtClassInfo::member(const char* memberName) return info; } else { bool found = false; - + found = lookForPropertyAndCache(memberName); if (!found) { found = lookForMethodAndCache(memberName); @@ -366,10 +373,10 @@ PythonQtMemberInfo PythonQtClassInfo::member(const char* memberName) // since python keywords can not be looked up, we check if the name contains a single trailing _ // and remove that and look again, so that we e.g. find exec on an exec_ lookup QByteArray mbrName(memberName); - if ((mbrName.length()>2) && - (mbrName.at(mbrName.length()-1) == '_') && - (mbrName.at(mbrName.length()-2) != '_')) { - mbrName = mbrName.mid(0,mbrName.length()-1); + if ((mbrName.length() > 2) && (mbrName.at(mbrName.length() - 1) == '_') + && (mbrName.at(mbrName.length() - 2) != '_')) + { + mbrName = mbrName.mid(0, mbrName.length() - 1); found = lookForMethodAndCache(mbrName.constData()); if (found) { return _cachedMembers.value(mbrName); @@ -386,7 +393,8 @@ PythonQtMemberInfo PythonQtClassInfo::member(const char* memberName) return _cachedMembers.value(memberName); } -void PythonQtClassInfo::recursiveCollectDecoratorObjects(QList& decoratorObjects) { +void PythonQtClassInfo::recursiveCollectDecoratorObjects(QList& decoratorObjects) +{ QObject* deco = decorator(); if (deco) { decoratorObjects.append(deco); @@ -396,14 +404,16 @@ void PythonQtClassInfo::recursiveCollectDecoratorObjects(QList& decora } } -void PythonQtClassInfo::recursiveCollectClassInfos(QList& classInfoObjects) { +void PythonQtClassInfo::recursiveCollectClassInfos(QList& classInfoObjects) +{ classInfoObjects.append(this); for (const ParentClassInfo& info : _parentClasses) { info._parent->recursiveCollectClassInfos(classInfoObjects); } } -PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlots(const char* memberName, PythonQtSlotInfo* tail, bool &found, QHash& memberCache, int upcastingOffset) +PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlots(const char* memberName, PythonQtSlotInfo* tail, bool& found, + QHash& memberCache, int upcastingOffset) { QListIterator it(_decoratorSlots); while (it.hasNext()) { @@ -412,7 +422,7 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlots(const char* memberName, QByteArray signature = PythonQtUtils::methodName(*infoOrig->metaMethod()); if (signature.startsWith("static_")) { int offset = signature.indexOf('_', 7); - signature = signature.mid(offset+1); + signature = signature.mid(offset + 1); } if (signature == memberName) { //make a copy, otherwise we will have trouble on overloads! @@ -431,7 +441,8 @@ PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlots(const char* memberName, return tail; } -void PythonQtClassInfo::listDecoratorSlotsFromDecoratorProvider(QStringList& list, bool metaOnly) { +void PythonQtClassInfo::listDecoratorSlotsFromDecoratorProvider(QStringList& list, bool metaOnly) +{ QObject* decoratorProvider = decorator(); if (decoratorProvider) { const QMetaObject* meta = decoratorProvider->metaObject(); @@ -439,9 +450,10 @@ void PythonQtClassInfo::listDecoratorSlotsFromDecoratorProvider(QStringList& lis int startFrom = QObject::staticMetaObject.methodCount(); for (int i = startFrom; i < numMethods; i++) { QMetaMethod m = meta->method(i); - if ((m.methodType() == QMetaMethod::Method || - m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) { - + if ((m.methodType() == QMetaMethod::Method || m.methodType() == QMetaMethod::Slot) + && m.access() == QMetaMethod::Public) + { + QByteArray signature = PythonQtUtils::methodName(m); bool isClassDeco = false; if (signature.startsWith("static_")) { @@ -455,7 +467,7 @@ void PythonQtClassInfo::listDecoratorSlotsFromDecoratorProvider(QStringList& lis } // XXX no checking is currently done if the slots have correct first argument or not... if (!metaOnly || isClassDeco) { - list << QString::fromLatin1(signature.constData()); + list << QString::fromLatin1(signature.constData()); } } } @@ -468,8 +480,8 @@ void PythonQtClassInfo::listDecoratorSlotsFromDecoratorProvider(QStringList& lis QByteArray name = slot->slotName(); if (name.startsWith("static_")) { int idx = name.indexOf('_'); - idx = name.indexOf('_', idx+1); - name = name.mid(idx+1); + idx = name.indexOf('_', idx + 1); + name = name.mid(idx + 1); } else if (name.startsWith("new_")) { continue; } else if (name.startsWith("delete_")) { @@ -510,11 +522,12 @@ QStringList PythonQtClassInfo::memberList() if (_meta) { int numMethods = _meta->methodCount(); bool skipQObj = !_isQObject; - for (int i = skipQObj?QObject::staticMetaObject.methodCount():0; i < numMethods; i++) { + for (int i = skipQObj ? QObject::staticMetaObject.methodCount() : 0; i < numMethods; i++) { QMetaMethod m = _meta->method(i); - if (((m.methodType() == QMetaMethod::Method || - m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) - || m.methodType()==QMetaMethod::Signal) { + if (((m.methodType() == QMetaMethod::Method || m.methodType() == QMetaMethod::Slot) + && m.access() == QMetaMethod::Public) + || m.methodType() == QMetaMethod::Signal) + { l << PythonQtUtils::methodName(m); } } @@ -528,7 +541,7 @@ QStringList PythonQtClassInfo::memberList() info->listDecoratorSlotsFromDecoratorProvider(l, false); } } - + // List enumerator keys... QList enumMetaObjects; if (_meta) { @@ -540,15 +553,16 @@ QStringList PythonQtClassInfo::memberList() for (QObject* deco : decoObjects) { enumMetaObjects << deco->metaObject(); } - + for (const QMetaObject* meta : enumMetaObjects) { - for (int i = 0; ienumeratorCount(); i++) { + for (int i = 0; i < meta->enumeratorCount(); i++) { QMetaEnum e = meta->enumerator(i); l << e.name(); // we do not want flags, they will cause our values to appear two times - if (e.isFlag()) continue; + if (e.isFlag()) + continue; - for (int j=0; j < e.keyCount(); j++) { + for (int j = 0; j < e.keyCount(); j++) { l << QString(e.key(j)); } } @@ -577,7 +591,7 @@ const QByteArray& PythonQtClassInfo::className() const void* PythonQtClassInfo::castTo(void* ptr, const char* classname) { - if (ptr==nullptr) { + if (ptr == nullptr) { return nullptr; } if (_wrappedClassName == classname) { @@ -623,10 +637,10 @@ QString PythonQtClassInfo::help() decorator(); QString h; h += QString("--- ") + QString(className()) + QString(" ---\n"); - + if (_isQObject) { h += "Properties:\n"; - + int i; int numProperties = _meta->propertyCount(); for (i = 0; i < numProperties; i++) { @@ -634,7 +648,7 @@ QString PythonQtClassInfo::help() h += QString(p.name()) + " (" + QString(p.typeName()) + " )\n"; } } - + if (constructors()) { h += "Constructors:\n"; PythonQtSlotInfo* constr = constructors(); @@ -652,24 +666,27 @@ QString PythonQtClassInfo::help() int numMethods = _meta->methodCount(); for (int i = 0; i < numMethods; i++) { QMetaMethod m = _meta->method(i); - if ((m.methodType() == QMetaMethod::Method || - m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) { + if ((m.methodType() == QMetaMethod::Method || m.methodType() == QMetaMethod::Slot) + && m.access() == QMetaMethod::Public) + { PythonQtSlotInfo slot(this, m, i); - h += slot.fullSignature()+ "\n"; + h += slot.fullSignature() + "\n"; } } } - + // TODO xxx : decorators and enums from decorator() are missing... // maybe we can reuse memberlist()? - + if (_meta && _meta->enumeratorCount()) { h += "Enums:\n"; - for (int i = 0; i<_meta->enumeratorCount(); i++) { + for (int i = 0; i < _meta->enumeratorCount(); i++) { QMetaEnum e = _meta->enumerator(i); h += QString(e.name()) + " {"; - for (int j=0; j < e.keyCount(); j++) { - if (j) { h+= ", "; } + for (int j = 0; j < e.keyCount(); j++) { + if (j) { + h += ", "; + } h += e.key(j); } h += " }\n"; @@ -678,7 +695,7 @@ QString PythonQtClassInfo::help() if (_isQObject && _meta) { int numMethods = _meta->methodCount(); - if (numMethods>0) { + if (numMethods > 0) { h += "Signals:\n"; for (int i = 0; i < numMethods; i++) { QMetaMethod m = _meta->method(i); @@ -754,7 +771,8 @@ QObject* PythonQtClassInfo::decorator() if (!_enumsCreated) { createEnumWrappers(_decoratorProvider); } - PythonQt::priv()->addDecorators(_decoratorProvider, PythonQtPrivate::ConstructorDecorator | PythonQtPrivate::DestructorDecorator); + PythonQt::priv()->addDecorators(_decoratorProvider, + PythonQtPrivate::ConstructorDecorator | PythonQtPrivate::DestructorDecorator); } } // check if enums need to be created and create them if they are not yet created @@ -798,15 +816,15 @@ void* PythonQtClassInfo::castDownIfPossible(void* ptr, PythonQtClassInfo** resul // (for speed reasons and because of casting offsets...) // Only do this once... _searchPolymorphicHandlerOnParent = false; - if (_parentClasses.count()>0) { + if (_parentClasses.count() > 0) { PythonQtClassInfo* parent = _parentClasses[0]._parent; while (parent) { - if (parent->_polymorphicHandlers.count()>0) { + if (parent->_polymorphicHandlers.count() > 0) { // copy handlers from parent class, to speedup next lookup _polymorphicHandlers = parent->_polymorphicHandlers; break; } - if (parent->_parentClasses.count()>0) { + if (parent->_parentClasses.count() > 0) { parent = parent->_parentClasses[0]._parent; } else { parent = nullptr; @@ -845,19 +863,19 @@ PyObject* PythonQtClassInfo::findEnumWrapper(const QByteArray& name, PythonQtCla *isLocalEnum = false; } // split into scope and enum name - QByteArray enumScope = name.mid(0,scopePos); - QByteArray enumName = name.mid(scopePos+2); + QByteArray enumScope = name.mid(0, scopePos); + QByteArray enumName = name.mid(scopePos + 2); PythonQtClassInfo* info = PythonQt::priv()->getClassInfo(enumScope); if (info) { return info->findEnumWrapper(enumName); - } else{ + } else { return nullptr; } } PyObject* enumWrapper = nullptr; if (localScope) { enumWrapper = localScope->findEnumWrapper(name); - } + } if (!enumWrapper) { // it might be a top-level enum - search in all currently registered global namespace wrappers for (PythonQtClassInfo* globalWrapper : _globalNamespaceWrappers) { @@ -872,7 +890,7 @@ PyObject* PythonQtClassInfo::findEnumWrapper(const QByteArray& name, PythonQtCla void PythonQtClassInfo::createEnumWrappers(const QMetaObject* meta) { - for (int i = meta->enumeratorOffset();ienumeratorCount();i++) { + for (int i = meta->enumeratorOffset(); i < meta->enumeratorCount(); i++) { QMetaEnum e = meta->enumerator(i); PythonQtObjectPtr p; p.setNewRef(PythonQtPrivate::createNewPythonQtEnumWrapper(e.name(), _pythonQtClassWrapper)); @@ -905,7 +923,8 @@ void PythonQtClassInfo::createEnumWrappers(const QObject* decoratorProvider) } } -PyObject* PythonQtClassInfo::findEnumWrapper(const char* name) { +PyObject* PythonQtClassInfo::findEnumWrapper(const char* name) +{ // force enum creation if (!_enumsCreated) { // trigger decorator() instead of createEnumWrappers(), @@ -914,18 +933,19 @@ PyObject* PythonQtClassInfo::findEnumWrapper(const char* name) { } for (const PythonQtObjectPtr& p : _enumWrappers) { const char* className = ((PyTypeObject*)p.object())->tp_name; - if (qstrcmp(className, name)==0) { + if (qstrcmp(className, name) == 0) { return p.object(); } } for (const ParentClassInfo& info : _parentClasses) { PyObject* p = info._parent->findEnumWrapper(name); - if (p) return p; + if (p) + return p; } return nullptr; } -void PythonQtClassInfo::setDecoratorProvider( PythonQtQObjectCreatorFunctionCB* cb ) +void PythonQtClassInfo::setDecoratorProvider(PythonQtQObjectCreatorFunctionCB* cb) { _decoratorProviderCB = cb; _decoratorProvider = nullptr; @@ -960,7 +980,7 @@ QByteArray PythonQtClassInfo::unscopedClassName() const } } -PyObject* PythonQtClassInfo::copyObject( void* cppObject ) +PyObject* PythonQtClassInfo::copyObject(void* cppObject) { PythonQtClassInfo* info; cppObject = castDownIfPossible(cppObject, &info); @@ -979,14 +999,16 @@ PyObject* PythonQtClassInfo::copyObject( void* cppObject ) PythonQtSlotInfo::invokeQtMethod(slot->decorator(), slot, args); } if (result) { - PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(result, info->className()); + PythonQtInstanceWrapper* wrapper = + (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(result, info->className()); if (wrapper) { wrapper->_ownedByPythonQt = true; } return (PyObject*)wrapper; } } else { - std::cerr << "PythonQt: Can't create a copy of '" << info->_wrappedClassName.constData() << "', either use qRegisterMetaType() or add a copy constructor to the decorator/wrapper." << std::endl; + std::cerr << "PythonQt: Can't create a copy of '" << info->_wrappedClassName.constData() + << "', either use qRegisterMetaType() or add a copy constructor to the decorator/wrapper." << std::endl; } } return nullptr; @@ -996,9 +1018,9 @@ PythonQtSlotInfo* PythonQtClassInfo::getCopyConstructor() { PythonQtSlotInfo* construc = constructors(); while (construc) { - if ((construc->parameterCount() == 2) && - (construc->parameters().at(1).name == _wrappedClassName) && - (construc->parameters().at(1).pointerCount == 0)) { + if ((construc->parameterCount() == 2) && (construc->parameters().at(1).name == _wrappedClassName) + && (construc->parameters().at(1).pointerCount == 0)) + { return construc; } construc = construc->nextInfo(); @@ -1006,7 +1028,7 @@ PythonQtSlotInfo* PythonQtClassInfo::getCopyConstructor() return nullptr; } -void PythonQtClassInfo::setReferenceCounting( PythonQtVoidPtrCB* refCB, PythonQtVoidPtrCB* unrefCB ) +void PythonQtClassInfo::setReferenceCounting(PythonQtVoidPtrCB* refCB, PythonQtVoidPtrCB* unrefCB) { _refCallback = refCB; _unrefCallback = unrefCB; @@ -1032,8 +1054,7 @@ QByteArray PythonQtClassInfo::escapeReservedNames(const QByteArray& name) { if (_reservedNames.contains(name)) { return name + "_"; - } - else { + } else { return name; } } @@ -1056,14 +1077,14 @@ void PythonQtClassInfo::updateRefCountingCBs() PythonQtClassInfo* parent = _parentClasses.at(0)._parent; parent->updateRefCountingCBs(); // propagate to ourself - _refCallback = parent->_refCallback; - _unrefCallback = parent->_unrefCallback; + _refCallback = parent->_refCallback; + _unrefCallback = parent->_unrefCallback; } } _searchRefCountCB = false; } -PyObject* PythonQtClassInfo::getPythonTypeForProperty( const QString& name ) +PyObject* PythonQtClassInfo::getPythonTypeForProperty(const QString& name) { PythonQtClassInfo* classInfo = getClassInfoForProperty(name); if (classInfo) { @@ -1073,7 +1094,7 @@ PyObject* PythonQtClassInfo::getPythonTypeForProperty( const QString& name ) } } -PythonQtClassInfo* PythonQtClassInfo::getClassInfoForProperty( const QString& name ) +PythonQtClassInfo* PythonQtClassInfo::getClassInfoForProperty(const QString& name) { QByteArray typeName; PythonQtMemberInfo info = member(QStringToPythonConstCharPointer(name)); @@ -1124,7 +1145,8 @@ bool PythonQtClassInfo::supportsRichCompare() //------------------------------------------------------------------------- -PythonQtMemberInfo::PythonQtMemberInfo( PythonQtSlotInfo* info ) : _slot(info) +PythonQtMemberInfo::PythonQtMemberInfo(PythonQtSlotInfo* info) + : _slot(info) { if (info->metaMethod()->methodType() == QMetaMethod::Signal) { _type = Signal; @@ -1135,7 +1157,7 @@ PythonQtMemberInfo::PythonQtMemberInfo( PythonQtSlotInfo* info ) : _slot(info) _pythonType = nullptr; } -PythonQtMemberInfo::PythonQtMemberInfo( const PythonQtObjectPtr& enumValue ) +PythonQtMemberInfo::PythonQtMemberInfo(const PythonQtObjectPtr& enumValue) { _type = EnumValue; _slot = nullptr; @@ -1143,7 +1165,7 @@ PythonQtMemberInfo::PythonQtMemberInfo( const PythonQtObjectPtr& enumValue ) _pythonType = nullptr; } -PythonQtMemberInfo::PythonQtMemberInfo( const QMetaProperty& prop ) +PythonQtMemberInfo::PythonQtMemberInfo(const QMetaProperty& prop) { _type = Property; _slot = nullptr; diff --git a/src/PythonQtClassInfo.h b/src/PythonQtClassInfo.h index 04f1d46b4..b6be43046 100644 --- a/src/PythonQtClassInfo.h +++ b/src/PythonQtClassInfo.h @@ -44,9 +44,12 @@ class PythonQtSlotInfo; class PythonQtClassInfo; -struct PythonQtDynamicClassInfo -{ - PythonQtDynamicClassInfo() { _dynamicMetaObject = nullptr; _classInfo = nullptr; } +struct PythonQtDynamicClassInfo { + PythonQtDynamicClassInfo() + { + _dynamicMetaObject = nullptr; + _classInfo = nullptr; + } ~PythonQtDynamicClassInfo(); const QMetaObject* _dynamicMetaObject; @@ -54,11 +57,15 @@ struct PythonQtDynamicClassInfo }; struct PythonQtMemberInfo { - enum Type { - Invalid, Slot, Signal, EnumValue, EnumWrapper, Property, NestedClass, NotFound - }; - - PythonQtMemberInfo():_type(Invalid),_slot(nullptr),_pythonType(nullptr),_enumValue(nullptr) { } + enum Type { Invalid, Slot, Signal, EnumValue, EnumWrapper, Property, NestedClass, NotFound }; + + PythonQtMemberInfo() + : _type(Invalid) + , _slot(nullptr) + , _pythonType(nullptr) + , _enumValue(nullptr) + { + } PythonQtMemberInfo(PythonQtSlotInfo* info); @@ -66,19 +73,20 @@ struct PythonQtMemberInfo { PythonQtMemberInfo(const QMetaProperty& prop); - Type _type; + Type _type; // TODO: this could be a union... PythonQtSlotInfo* _slot; - PyObject* _pythonType; + PyObject* _pythonType; PythonQtObjectPtr _enumValue; - QMetaProperty _property; + QMetaProperty _property; }; //! a class that stores all required information about a Qt object (and an optional associated C++ class name) /*! for fast lookup of slots when calling the object from Python */ -class PYTHONQT_EXPORT PythonQtClassInfo { +class PYTHONQT_EXPORT PythonQtClassInfo +{ public: PythonQtClassInfo(); @@ -86,14 +94,14 @@ class PYTHONQT_EXPORT PythonQtClassInfo { //! store information about parent classes struct ParentClassInfo { - ParentClassInfo(PythonQtClassInfo* parent, int upcastingOffset=0):_parent(parent),_upcastingOffset(upcastingOffset) - {}; + ParentClassInfo(PythonQtClassInfo* parent, int upcastingOffset = 0) + : _parent(parent) + , _upcastingOffset(upcastingOffset) {}; PythonQtClassInfo* _parent; - int _upcastingOffset; + int _upcastingOffset; }; - //! setup as a QObject, taking the meta object as meta information about the QObject void setupQObject(const QMetaObject* meta); @@ -183,14 +191,10 @@ class PYTHONQT_EXPORT PythonQtClassInfo { PyObject* pythonQtClassWrapper() { return _pythonQtClassWrapper; } //! set the shell set instance wrapper cb - void setShellSetInstanceWrapperCB(PythonQtShellSetInstanceWrapperCB* cb) { - _shellSetInstanceWrapperCB = cb; - } + void setShellSetInstanceWrapperCB(PythonQtShellSetInstanceWrapperCB* cb) { _shellSetInstanceWrapperCB = cb; } //! get the shell set instance wrapper cb - PythonQtShellSetInstanceWrapperCB* shellSetInstanceWrapperCB() { - return _shellSetInstanceWrapperCB; - } + PythonQtShellSetInstanceWrapperCB* shellSetInstanceWrapperCB() { return _shellSetInstanceWrapperCB; } //! add a handler for polymorphic downcasting void addPolymorphicHandler(PythonQtPolymorphicHandlerCB* cb) { _polymorphicHandlers.append(cb); } @@ -229,7 +233,7 @@ class PYTHONQT_EXPORT PythonQtClassInfo { PyObject* getPythonTypeForProperty(const QString& name); //! Returns the class info for given property, if available. - PythonQtClassInfo* getClassInfoForProperty( const QString& name ); + PythonQtClassInfo* getClassInfoForProperty(const QString& name); //! Returns if the class supports rich compare. This tests for //! __eq__, __ne__, __lt__, __le__, __gt__, __ge__ slots and if @@ -260,9 +264,11 @@ class PYTHONQT_EXPORT PythonQtClassInfo { void* recursiveCastDownIfPossible(void* ptr, const char** resultClassName); - PythonQtSlotInfo* findDecoratorSlotsFromDecoratorProvider(const char* memberName, PythonQtSlotInfo* inputInfo, bool &found, QHash& memberCache, int upcastingOffset); + PythonQtSlotInfo* findDecoratorSlotsFromDecoratorProvider(const char* memberName, PythonQtSlotInfo* inputInfo, + bool& found, QHash& memberCache, int upcastingOffset); void listDecoratorSlotsFromDecoratorProvider(QStringList& list, bool metaOnly); - PythonQtSlotInfo* recursiveFindDecoratorSlotsFromDecoratorProvider(const char* memberName, PythonQtSlotInfo* inputInfo, bool &found, QHash& memberCache, int upcastingOffset); + PythonQtSlotInfo* recursiveFindDecoratorSlotsFromDecoratorProvider(const char* memberName, + PythonQtSlotInfo* inputInfo, bool& found, QHash& memberCache, int upcastingOffset); void recursiveCollectClassInfos(QList& classInfoObjects); void recursiveCollectDecoratorObjects(QList& decoratorObjects); @@ -271,39 +277,40 @@ class PYTHONQT_EXPORT PythonQtClassInfo { bool lookForMethodAndCache(const char* memberName); bool lookForEnumAndCache(const QMetaObject* m, const char* memberName); - PythonQtSlotInfo* findDecoratorSlots(const char* memberName, PythonQtSlotInfo* tail, bool &found, QHash& memberCache, int upcastingOffset); + PythonQtSlotInfo* findDecoratorSlots(const char* memberName, PythonQtSlotInfo* tail, bool& found, + QHash& memberCache, int upcastingOffset); int findCharOffset(const char* sigStart, char someChar); QHash _cachedMembers; - PythonQtSlotInfo* _constructors; - PythonQtSlotInfo* _destructor; + PythonQtSlotInfo* _constructors; + PythonQtSlotInfo* _destructor; - PythonQtVoidPtrCB* _refCallback; - PythonQtVoidPtrCB* _unrefCallback; + PythonQtVoidPtrCB* _refCallback; + PythonQtVoidPtrCB* _unrefCallback; - QList _decoratorSlots; + QList _decoratorSlots; - QList _enumWrappers; + QList _enumWrappers; - const QMetaObject* _meta; + const QMetaObject* _meta; - QByteArray _wrappedClassName; - QList _parentClasses; + QByteArray _wrappedClassName; + QList _parentClasses; QList _polymorphicHandlers; - QList _nestedClasses; + QList _nestedClasses; - QObject* _decoratorProvider; - PythonQtQObjectCreatorFunctionCB* _decoratorProviderCB; + QObject* _decoratorProvider; + PythonQtQObjectCreatorFunctionCB* _decoratorProviderCB; - PyObject* _pythonQtClassWrapper; + PyObject* _pythonQtClassWrapper; - PythonQtShellSetInstanceWrapperCB* _shellSetInstanceWrapperCB; + PythonQtShellSetInstanceWrapperCB* _shellSetInstanceWrapperCB; - int _metaTypeId; - int _typeSlots; + int _metaTypeId; + int _typeSlots; bool _isQObject; bool _enumsCreated; @@ -311,12 +318,11 @@ class PYTHONQT_EXPORT PythonQtClassInfo { bool _searchPolymorphicHandlerOnParent; bool _searchRefCountCB; - static QList _globalNamespaceWrappers; + static QList _globalNamespaceWrappers; - static QSet _reservedNames; + static QSet _reservedNames; }; //--------------------------------------------------------------- - #endif diff --git a/src/PythonQtClassWrapper.cpp b/src/PythonQtClassWrapper.cpp index c5ffde6e4..4c84f61a4 100644 --- a/src/PythonQtClassWrapper.cpp +++ b/src/PythonQtClassWrapper.cpp @@ -55,7 +55,8 @@ static PyObject* PythonQtInstanceWrapper_invert(PythonQtInstanceWrapper* wrapper static QByteArray memberName = "__invert__"; PythonQtMemberInfo opSlot = wrapper->classInfo()->member(memberName); if (opSlot._type == PythonQtMemberInfo::Slot) { - result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, nullptr, wrapper->_wrappedPtr); + result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, nullptr, + wrapper->_wrappedPtr); } return result; } @@ -66,7 +67,8 @@ static PyObject* PythonQtInstanceWrapper_negative(PythonQtInstanceWrapper* wrapp static QByteArray memberName = "__sub__"; PythonQtMemberInfo opSlot = wrapper->classInfo()->member(memberName); if (opSlot._type == PythonQtMemberInfo::Slot) { - result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, nullptr, wrapper->_wrappedPtr); + result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, nullptr, + wrapper->_wrappedPtr); } return result; } @@ -77,19 +79,21 @@ static PyObject* PythonQtInstanceWrapper_positive(PythonQtInstanceWrapper* wrapp static QByteArray memberName = "__add__"; PythonQtMemberInfo opSlot = wrapper->classInfo()->member(memberName); if (opSlot._type == PythonQtMemberInfo::Slot) { - result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, nullptr, wrapper->_wrappedPtr); + result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, nullptr, + wrapper->_wrappedPtr); } return result; } static int PythonQtInstanceWrapper_nonzero(PythonQtInstanceWrapper* wrapper) { - int result = (wrapper->_wrappedPtr == nullptr && wrapper->_obj == nullptr)?0:1; + int result = (wrapper->_wrappedPtr == nullptr && wrapper->_obj == nullptr) ? 0 : 1; if (result) { static QByteArray memberName = "__nonzero__"; PythonQtMemberInfo opSlot = wrapper->classInfo()->member(memberName); if (opSlot._type == PythonQtMemberInfo::Slot) { - PyObject* resultObj = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, nullptr, wrapper->_wrappedPtr); + PyObject* resultObj = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, + nullptr, wrapper->_wrappedPtr); if (resultObj == Py_False) { result = 0; } @@ -106,7 +110,8 @@ static Py_ssize_t PythonQtInstanceWrapper_length(PythonQtInstanceWrapper* wrappe static QByteArray memberName = "__len__"; PythonQtMemberInfo opSlot = wrapper->classInfo()->member(memberName); if (opSlot._type == PythonQtMemberInfo::Slot) { - PyObject* resultObj = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, nullptr, wrapper->_wrappedPtr); + PyObject* resultObj = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, nullptr, + nullptr, wrapper->_wrappedPtr); bool ok; result = PythonQtConv::PyObjGetLongLong(resultObj, false, ok); if (!ok) { @@ -126,19 +131,20 @@ static int PythonQtInstanceWrapper_setitem(PyObject* self, PyObject* index, PyOb PythonQtMemberInfo opSlot = wrapper->classInfo()->member(methodName); if (opSlot._type == PythonQtMemberInfo::Slot) { - PyObject* args = PyTuple_New(isSetItem?2:1); + PyObject* args = PyTuple_New(isSetItem ? 2 : 1); Py_INCREF(index); PyTuple_SET_ITEM(args, 0, index); if (isSetItem) { Py_INCREF(value); PyTuple_SET_ITEM(args, 1, value); } - PyObject* result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, args, nullptr, wrapper->_wrappedPtr); + PyObject* result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, args, nullptr, + wrapper->_wrappedPtr); if (result) { Py_DECREF(result); } Py_DECREF(args); - return PyErr_Occurred()?-1:0; + return PyErr_Occurred() ? -1 : 0; } else { QString e = QString("No method '%1' on class '%2'").arg(methodName).arg(QString(wrapper->classInfo()->className())); PyErr_SetString(PyExc_AttributeError, QStringToPythonConstCharPointer(e)); @@ -146,12 +152,14 @@ static int PythonQtInstanceWrapper_setitem(PyObject* self, PyObject* index, PyOb } } -static PyObject* PythonQtInstanceWrapper_binaryfunc(PyObject* self, PyObject* other, const QByteArray& opName, const QByteArray& fallbackOpName = QByteArray()) +static PyObject* PythonQtInstanceWrapper_binaryfunc(PyObject* self, PyObject* other, const QByteArray& opName, + const QByteArray& fallbackOpName = QByteArray()) { // since we disabled type checking, we can receive any object as self, but we currently only support // different objects on the right. Otherwise we would need to generate __radd__ etc. methods. if (!PyObject_TypeCheck(self, &PythonQtInstanceWrapper_Type)) { - QString error = "Unsupported operation " + opName + "(" + self->ob_type->tp_name + ", " + other->ob_type->tp_name + ")"; + QString error = + "Unsupported operation " + opName + "(" + self->ob_type->tp_name + ", " + other->ob_type->tp_name + ")"; PyErr_SetString(PyExc_ArithmeticError, QStringToPythonCharPointer(error)); return nullptr; } @@ -162,7 +170,8 @@ static PyObject* PythonQtInstanceWrapper_binaryfunc(PyObject* self, PyObject* ot PyObject* args = PyTuple_New(1); Py_INCREF(other); PyTuple_SET_ITEM(args, 0, other); - result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, args, nullptr, wrapper->_wrappedPtr); + result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, args, nullptr, + wrapper->_wrappedPtr); Py_DECREF(args); if (!result && !fallbackOpName.isEmpty()) { // try fallback if we did not get a result @@ -189,26 +198,27 @@ static PyObject* PythonQtInstanceWrapper_mul(PyObject* self, PyObject* other) PyObject* args = PyTuple_New(1); Py_INCREF(other); PyTuple_SET_ITEM(args, 0, other); - result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, args, nullptr, wrapper->_wrappedPtr); + result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, args, nullptr, + wrapper->_wrappedPtr); Py_DECREF(args); } return result; } #define BINARY_OP(NAME) \ -static PyObject* PythonQtInstanceWrapper_ ## NAME(PyObject* self, PyObject* other) \ -{ \ - static const QByteArray opName("__" #NAME "__"); \ - return PythonQtInstanceWrapper_binaryfunc(self, other, opName); \ -} + static PyObject* PythonQtInstanceWrapper_##NAME(PyObject* self, PyObject* other) \ + { \ + static const QByteArray opName("__" #NAME "__"); \ + return PythonQtInstanceWrapper_binaryfunc(self, other, opName); \ + } #define BINARY_OP_INPLACE(NAME) \ - static PyObject* PythonQtInstanceWrapper_i ## NAME(PyObject* self, PyObject* other) \ -{ \ - static const QByteArray opName("__i" #NAME "__"); \ - static const QByteArray fallbackName("__" #NAME "__"); \ - return PythonQtInstanceWrapper_binaryfunc(self, other, opName, fallbackName); \ -} + static PyObject* PythonQtInstanceWrapper_i##NAME(PyObject* self, PyObject* other) \ + { \ + static const QByteArray opName("__i" #NAME "__"); \ + static const QByteArray fallbackName("__" #NAME "__"); \ + return PythonQtInstanceWrapper_binaryfunc(self, other, opName, fallbackName); \ + } BINARY_OP(add) BINARY_OP(sub) @@ -321,7 +331,7 @@ static void initializeSlots(PythonQtClassWrapper* wrap) } } -static PyObject* PythonQtClassWrapper_alloc(PyTypeObject *self, Py_ssize_t nitems) +static PyObject* PythonQtClassWrapper_alloc(PyTypeObject* self, Py_ssize_t nitems) { // call the default type alloc PyObject* obj = PyType_Type.tp_alloc(self, nitems); @@ -336,18 +346,17 @@ static PyObject* PythonQtClassWrapper_alloc(PyTypeObject *self, Py_ssize_t nitem return obj; } - static int PythonQtClassWrapper_init(PythonQtClassWrapper* self, PyObject* args, PyObject* kwds) { // call the default type init - if (PyType_Type.tp_init((PyObject *)self, args, kwds) < 0) { + if (PyType_Type.tp_init((PyObject*)self, args, kwds) < 0) { return -1; } self->_dynamicClassInfo = nullptr; // if we have no CPP class information, try our base class if (!self->classInfo()) { - PyTypeObject* superType = ((PyTypeObject *)self)->tp_base; + PyTypeObject* superType = ((PyTypeObject*)self)->tp_base; // recursively search for PythonQtClassWrapper superclass, // this is needed for multiple levels of inheritance in python, // e.g. @@ -369,7 +378,7 @@ static int PythonQtClassWrapper_init(PythonQtClassWrapper* self, PyObject* args, self->_dynamicClassInfo = new PythonQtDynamicClassInfo(); // take the class info from the superType and fill the whole chain - PyTypeObject* typeChain = (PyTypeObject *)self; + PyTypeObject* typeChain = (PyTypeObject*)self; while (typeChain && Py_TYPE(typeChain) != &PythonQtClassWrapper_Type) { ((PythonQtClassWrapper*)typeChain)->_classInfo = ((PythonQtClassWrapper*)superType)->classInfo(); @@ -382,22 +391,22 @@ static int PythonQtClassWrapper_init(PythonQtClassWrapper* self, PyObject* args, return 0; } -static PyObject *PythonQtClassWrapper_classname(PythonQtClassWrapper* type) +static PyObject* PythonQtClassWrapper_classname(PythonQtClassWrapper* type) { return PyUnicode_FromString((QByteArray("Class_") + type->classInfo()->className()).constData()); } -static PyObject *PythonQtClassWrapper_help(PythonQtClassWrapper* type) +static PyObject* PythonQtClassWrapper_help(PythonQtClassWrapper* type) { return PythonQt::self()->helpCalled(type->classInfo()); } -PyObject *PythonQtClassWrapper_delete(PythonQtClassWrapper *type, PyObject *args) +PyObject* PythonQtClassWrapper_delete(PythonQtClassWrapper* type, PyObject* args) { Q_UNUSED(type) Py_ssize_t argc = PyTuple_Size(args); - if (argc>0) { + if (argc > 0) { PyObject* self = PyTuple_GET_ITEM(args, 0); if (PyObject_TypeCheck(self, &PythonQtInstanceWrapper_Type)) { return PythonQtInstanceWrapper_delete((PythonQtInstanceWrapper*)self); @@ -406,35 +415,31 @@ PyObject *PythonQtClassWrapper_delete(PythonQtClassWrapper *type, PyObject *args return nullptr; } -PyObject *PythonQtClassWrapper_inherits(PythonQtClassWrapper *type, PyObject *args) +PyObject* PythonQtClassWrapper_inherits(PythonQtClassWrapper* type, PyObject* args) { Q_UNUSED(type) PythonQtInstanceWrapper* wrapper = nullptr; - char *name = nullptr; - if (!PyArg_ParseTuple(args, "O!s:PythonQtClassWrapper.inherits",&PythonQtInstanceWrapper_Type, &wrapper, &name)) { + char* name = nullptr; + if (!PyArg_ParseTuple(args, "O!s:PythonQtClassWrapper.inherits", &PythonQtInstanceWrapper_Type, &wrapper, &name)) { return nullptr; } return PythonQtConv::GetPyBool(wrapper->classInfo()->inherits(name)); } - static PyMethodDef PythonQtClassWrapper_methods[] = { - {"className", reinterpret_cast(reinterpret_cast(PythonQtClassWrapper_classname)), METH_NOARGS, - "Return the classname of the object" - }, - {"inherits", reinterpret_cast(reinterpret_cast(PythonQtClassWrapper_inherits)), METH_VARARGS, - "Returns if the class inherits or is of given type name" - }, - {"help", reinterpret_cast(reinterpret_cast(PythonQtClassWrapper_help)), METH_NOARGS, - "Shows the help of available methods for this class" - }, - {"delete", reinterpret_cast(reinterpret_cast(PythonQtClassWrapper_delete)), METH_VARARGS, - "Deletes the given C++ object" - }, - {nullptr, nullptr, 0 , nullptr} /* Sentinel */ + {"className", reinterpret_cast(reinterpret_cast(PythonQtClassWrapper_classname)), METH_NOARGS, + "Return the classname of the object"}, + {"inherits", reinterpret_cast(reinterpret_cast(PythonQtClassWrapper_inherits)), METH_VARARGS, + "Returns if the class inherits or is of given type name"}, + {"help", reinterpret_cast(reinterpret_cast(PythonQtClassWrapper_help)), METH_NOARGS, + "Shows the help of available methods for this class"}, + {"delete", reinterpret_cast(reinterpret_cast(PythonQtClassWrapper_delete)), METH_VARARGS, + "Deletes the given C++ object"}, + {nullptr, nullptr, 0, nullptr} /* Sentinel */ }; -static PyObject* PythonQtClassWrapper_getDummyInstanceForProperty(PythonQtClassWrapper* wrapper, const QString& property) +static PyObject* PythonQtClassWrapper_getDummyInstanceForProperty(PythonQtClassWrapper* wrapper, + const QString& property) { PythonQtClassInfo* info = wrapper->classInfo()->getClassInfoForProperty(property); if (info) { @@ -443,10 +448,10 @@ static PyObject* PythonQtClassWrapper_getDummyInstanceForProperty(PythonQtClassW Py_RETURN_NONE; } -static PyObject *PythonQtClassWrapper_getattro(PyObject *obj, PyObject *name) +static PyObject* PythonQtClassWrapper_getattro(PyObject* obj, PyObject* name) { - const char *attributeName; - PythonQtClassWrapper *wrapper = (PythonQtClassWrapper *)obj; + const char* attributeName; + PythonQtClassWrapper* wrapper = (PythonQtClassWrapper*)obj; if ((attributeName = PyUnicode_AsUTF8(name)) == nullptr) { return nullptr; @@ -457,8 +462,8 @@ static PyObject *PythonQtClassWrapper_getattro(PyObject *obj, PyObject *name) return superAttr; } - if (qstrcmp(attributeName, "__dict__")==0) { - PyObject* objectDict = ((PyTypeObject *)wrapper)->tp_dict; + if (qstrcmp(attributeName, "__dict__") == 0) { + PyObject* objectDict = ((PyTypeObject*)wrapper)->tp_dict; if (!wrapper->classInfo()) { Py_INCREF(objectDict); return objectDict; @@ -519,8 +524,7 @@ static PyObject *PythonQtClassWrapper_getattro(PyObject *obj, PyObject *name) PyObject* enumValue = member._enumValue; Py_INCREF(enumValue); return enumValue; - } else if (member._type == PythonQtMemberInfo::EnumWrapper || - member._type == PythonQtMemberInfo::NestedClass) { + } else if (member._type == PythonQtMemberInfo::EnumWrapper || member._type == PythonQtMemberInfo::NestedClass) { PyObject* enumWrapper = member._pythonType; Py_INCREF(enumWrapper); return enumWrapper; @@ -533,8 +537,7 @@ static PyObject *PythonQtClassWrapper_getattro(PyObject *obj, PyObject *name) if (qualifiedMember._type == PythonQtMemberInfo::Slot) { // return the qualified member, so that virtual calls on classes call the qualified member return PythonQtSlotFunction_New(qualifiedMember._slot, obj, nullptr); - } - else { + } else { // we return all slots, even the instance slots, since they are callable as unbound slots with self argument return PythonQtSlotFunction_New(member._slot, obj, nullptr); } @@ -559,14 +562,15 @@ static PyObject *PythonQtClassWrapper_getattro(PyObject *obj, PyObject *name) return internalMethod; } - QString error = QString(wrapper->classInfo()->className()) + " has no attribute named '" + QString(attributeName) + "'"; + QString error = + QString(wrapper->classInfo()->className()) + " has no attribute named '" + QString(attributeName) + "'"; PyErr_SetString(PyExc_AttributeError, QStringToPythonConstCharPointer(error)); return nullptr; } -static int PythonQtClassWrapper_setattro(PyObject *obj,PyObject *name,PyObject *value) +static int PythonQtClassWrapper_setattro(PyObject* obj, PyObject* name, PyObject* value) { - return PyType_Type.tp_setattro(obj,name,value); + return PyType_Type.tp_setattro(obj, name, value); } /* @@ -594,45 +598,45 @@ static PyObject * PythonQtClassWrapper_repr(PyObject * obj) */ PyTypeObject PythonQtClassWrapper_Type = { - PyVarObject_HEAD_INIT(nullptr, 0) /*tp_base*/ - "PythonQt.PythonQtClassWrapper", /*tp_name*/ - sizeof(PythonQtClassWrapper), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - nullptr, /*tp_dealloc*/ - 0, /*tp_vectorcall_offset*/ - nullptr, /*tp_getattr*/ - nullptr, /*tp_setattr*/ - nullptr, /*tp_compare*/ - nullptr, //PythonQtClassWrapper_repr, /*tp_repr*/ - nullptr, /*tp_as_number*/ - nullptr, /*tp_as_sequence*/ - nullptr, /*tp_as_mapping*/ - nullptr, /*tp_hash */ - nullptr, /*tp_call*/ - nullptr, /*tp_str*/ - PythonQtClassWrapper_getattro, /*tp_getattro*/ - PythonQtClassWrapper_setattro, /*tp_setattro*/ - nullptr, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - nullptr, /* tp_doc */ - nullptr, /* tp_traverse */ - nullptr, /* tp_clear */ - nullptr, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - nullptr, /* tp_iter */ - nullptr, /* tp_iternext */ - PythonQtClassWrapper_methods, /* tp_methods */ - nullptr, /* tp_members */ - nullptr, /* tp_getset */ - nullptr, /* tp_base */ - nullptr, /* tp_dict */ - nullptr, /* tp_descr_get */ - nullptr, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PythonQtClassWrapper_init, /* tp_init */ - PythonQtClassWrapper_alloc, /* tp_alloc */ - nullptr, /* tp_new */ - nullptr, /* tp_free */ + PyVarObject_HEAD_INIT(nullptr, 0) /*tp_base*/ + "PythonQt.PythonQtClassWrapper", /*tp_name*/ + sizeof(PythonQtClassWrapper), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + nullptr, /*tp_dealloc*/ + 0, /*tp_vectorcall_offset*/ + nullptr, /*tp_getattr*/ + nullptr, /*tp_setattr*/ + nullptr, /*tp_compare*/ + nullptr, //PythonQtClassWrapper_repr, /*tp_repr*/ + nullptr, /*tp_as_number*/ + nullptr, /*tp_as_sequence*/ + nullptr, /*tp_as_mapping*/ + nullptr, /*tp_hash */ + nullptr, /*tp_call*/ + nullptr, /*tp_str*/ + PythonQtClassWrapper_getattro, /*tp_getattro*/ + PythonQtClassWrapper_setattro, /*tp_setattro*/ + nullptr, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + nullptr, /* tp_doc */ + nullptr, /* tp_traverse */ + nullptr, /* tp_clear */ + nullptr, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + nullptr, /* tp_iter */ + nullptr, /* tp_iternext */ + PythonQtClassWrapper_methods, /* tp_methods */ + nullptr, /* tp_members */ + nullptr, /* tp_getset */ + nullptr, /* tp_base */ + nullptr, /* tp_dict */ + nullptr, /* tp_descr_get */ + nullptr, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)PythonQtClassWrapper_init, /* tp_init */ + PythonQtClassWrapper_alloc, /* tp_alloc */ + nullptr, /* tp_new */ + nullptr, /* tp_free */ }; //------------------------------------------------------- diff --git a/src/PythonQtConversion.cpp b/src/PythonQtConversion.cpp index 72f36a84b..96da8be47 100644 --- a/src/PythonQtConversion.cpp +++ b/src/PythonQtConversion.cpp @@ -49,15 +49,15 @@ #include #if QT_VERSION < 0x060000 -#include + #include Q_DECLARE_METATYPE(QStringRef) int PythonQtConv::stringRefTypeId = 0; #else -#include -#include -#include + #include + #include + #include int PythonQtConv::stringViewTypeId = 0; int PythonQtConv::anyStringViewTypeId = 0; @@ -71,15 +71,16 @@ PythonQtConvertPythonSequenceToQVariantListCB* PythonQtConv::_pythonSequenceToQV PyObject* PythonQtConv::GetPyBool(bool val) { - PyObject* r = val?Py_True:Py_False; + PyObject* r = val ? Py_True : Py_False; Py_INCREF(r); return r; } -PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::ParameterInfo& info, const void* data) { +PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::ParameterInfo& info, const void* data) +{ // is it an enum value? if (info.enumWrapper) { - if (info.pointerCount==0) { + if (info.pointerCount == 0) { return PythonQtPrivate::createEnumValueInstance(info.enumWrapper, *((unsigned int*)data)); } else { // we do not support pointers to enums (who needs them?) @@ -97,8 +98,9 @@ PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::Paramet } else { Py_RETURN_NONE; } - } else if ((info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) && - info.isQList && (info.innerNamePointerCount == 1)) { + } else if ((info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) && info.isQList + && (info.innerNamePointerCount == 1)) + { // it is a QList template: QList* listPtr = nullptr; if (info.pointerCount == 1) { @@ -117,7 +119,7 @@ PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::Paramet // if a converter is registered, we use is: PythonQtConvertMetaTypeToPythonCB* converter = _metaTypeToPythonConverters.value(info.typeId); if (converter) { - return (*converter)(info.pointerCount==0?data:*((void**)data), info.typeId); + return (*converter)(info.pointerCount == 0 ? data : *((void**)data), info.typeId); } } @@ -151,7 +153,8 @@ PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::Paramet Py_RETURN_NONE; } -PyObject* PythonQtConv::convertQtValueToPythonInternal(int type, const void* data) { +PyObject* PythonQtConv::convertQtValueToPythonInternal(int type, const void* data) +{ switch (type) { case QMetaType::Void: Py_RETURN_NONE; @@ -185,7 +188,7 @@ PyObject* PythonQtConv::convertQtValueToPythonInternal(int type, const void* dat return PyLong_FromLongLong(*((qint64*)data)); case QMetaType::ULongLong: return PyLong_FromUnsignedLongLong(*((quint64*)data)); - // implicit conversion from QByteArray to str has been removed: + // implicit conversion from QByteArray to str has been removed: //case QMetaType::QByteArray: { // QByteArray* v = (QByteArray*) data; // return PyBytes_FromStringAndSize(*v, v->size()); @@ -207,7 +210,7 @@ PyObject* PythonQtConv::convertQtValueToPythonInternal(int type, const void* dat #endif return PythonQtConv::QVariantToPyObject(*((QVariant*)data)); case QMetaType::QObjectStar: -#if( QT_VERSION < QT_VERSION_CHECK(5,0,0) ) +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) case QMetaType::QWidgetStar: #endif return PythonQt::priv()->wrapQObject(*((QObject**)data)); @@ -223,85 +226,88 @@ PyObject* PythonQtConv::convertQtValueToPythonInternal(int type, const void* dat if (type > 0) { return createCopyFromMetaType(type, data); } else { - std::cerr << "Unknown type that can not be converted to Python: " << type << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + std::cerr << "Unknown type that can not be converted to Python: " << type << ", in " << __FILE__ << ":" + << __LINE__ << std::endl; } } } Py_RETURN_NONE; - } - - void* PythonQtConv::CreateQtReturnValue(const PythonQtMethodInfo::ParameterInfo& info, PythonQtArgumentFrame* frame) { - void* ptr = nullptr; - if (info.pointerCount>1) { - return nullptr; - } else if (info.pointerCount==1) { - PythonQtArgumentFrame_ADD_VALUE(frame, void*, nullptr, ptr); - } else if (info.enumWrapper) { - // create enum return value - PythonQtArgumentFrame_ADD_VALUE(frame, long, 0, ptr); - } else { - switch (info.typeId) { - case QMetaType::Char: - case QMetaType::UChar: - case QMetaType::Short: - case QMetaType::UShort: - case QMetaType::Long: - case QMetaType::ULong: - case QMetaType::Bool: - case QMetaType::Int: - case QMetaType::UInt: - case QMetaType::QChar: - case QMetaType::Float: - case QMetaType::Double: - case QMetaType::LongLong: - case QMetaType::ULongLong: - PythonQtArgumentFrame_ADD_VALUE(frame, qint64, 0, ptr); - break; - case PythonQtMethodInfo::Variant: - PythonQtArgumentFrame_ADD_VARIANT_VALUE(frame, 0, ptr); - // return the ptr to the variant - break; - default: - // check if we have a QList of pointers, which we can circumvent with a QList - if (info.isQList && (info.innerNamePointerCount == 1)) { - static int id = PythonQtUtils::metaTypeIdFromTypeName("QList"); - PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID(frame, id, ptr); - // return the constData pointer that will be filled with the result value later on - ptr = (void*)((QVariant*)ptr)->constData(); - } - - if (!ptr && info.typeId != PythonQtMethodInfo::Unknown) { - // everything else is stored in a QVariant, if we know the meta type... - PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID(frame, info.typeId, ptr); - // return the constData pointer that will be filled with the result value later on - ptr = (void*)((QVariant*)ptr)->constData(); - } - } - } - return ptr; - } - - void* PythonQtConv::castWrapperTo(PythonQtInstanceWrapper* wrapper, const QByteArray& className, bool& ok) - { - void* object; - if (wrapper->classInfo()->isCPPWrapper()) { - object = wrapper->_wrappedPtr; - } else { - QObject* tmp = wrapper->_obj; - object = tmp; - } - if (object) { - // if we can be upcasted to the given name, we pass the casted pointer in: - object = wrapper->classInfo()->castTo(object, className); - ok = object!=nullptr; - } else { - // if it is a NULL ptr, we need to check if it inherits, so that we might pass the NULL ptr - ok = wrapper->classInfo()->inherits(className); - } - return object; - } - -void* PythonQtConv::handlePythonToQtAutoConversion(int typeId, PyObject* obj, void* alreadyAllocatedCPPObject, PythonQtArgumentFrame* frame) +} + +void* PythonQtConv::CreateQtReturnValue(const PythonQtMethodInfo::ParameterInfo& info, PythonQtArgumentFrame* frame) +{ + void* ptr = nullptr; + if (info.pointerCount > 1) { + return nullptr; + } else if (info.pointerCount == 1) { + PythonQtArgumentFrame_ADD_VALUE(frame, void*, nullptr, ptr); + } else if (info.enumWrapper) { + // create enum return value + PythonQtArgumentFrame_ADD_VALUE(frame, long, 0, ptr); + } else { + switch (info.typeId) { + case QMetaType::Char: + case QMetaType::UChar: + case QMetaType::Short: + case QMetaType::UShort: + case QMetaType::Long: + case QMetaType::ULong: + case QMetaType::Bool: + case QMetaType::Int: + case QMetaType::UInt: + case QMetaType::QChar: + case QMetaType::Float: + case QMetaType::Double: + case QMetaType::LongLong: + case QMetaType::ULongLong: + PythonQtArgumentFrame_ADD_VALUE(frame, qint64, 0, ptr); + break; + case PythonQtMethodInfo::Variant: + PythonQtArgumentFrame_ADD_VARIANT_VALUE(frame, 0, ptr); + // return the ptr to the variant + break; + default: + // check if we have a QList of pointers, which we can circumvent with a QList + if (info.isQList && (info.innerNamePointerCount == 1)) { + static int id = PythonQtUtils::metaTypeIdFromTypeName("QList"); + PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID(frame, id, ptr); + // return the constData pointer that will be filled with the result value later on + ptr = (void*)((QVariant*)ptr)->constData(); + } + + if (!ptr && info.typeId != PythonQtMethodInfo::Unknown) { + // everything else is stored in a QVariant, if we know the meta type... + PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID(frame, info.typeId, ptr); + // return the constData pointer that will be filled with the result value later on + ptr = (void*)((QVariant*)ptr)->constData(); + } + } + } + return ptr; +} + +void* PythonQtConv::castWrapperTo(PythonQtInstanceWrapper* wrapper, const QByteArray& className, bool& ok) +{ + void* object; + if (wrapper->classInfo()->isCPPWrapper()) { + object = wrapper->_wrappedPtr; + } else { + QObject* tmp = wrapper->_obj; + object = tmp; + } + if (object) { + // if we can be upcasted to the given name, we pass the casted pointer in: + object = wrapper->classInfo()->castTo(object, className); + ok = object != nullptr; + } else { + // if it is a NULL ptr, we need to check if it inherits, so that we might pass the NULL ptr + ok = wrapper->classInfo()->inherits(className); + } + return object; +} + +void* PythonQtConv::handlePythonToQtAutoConversion(int typeId, PyObject* obj, void* alreadyAllocatedCPPObject, + PythonQtArgumentFrame* frame) { void* ptr = alreadyAllocatedCPPObject; @@ -374,423 +380,397 @@ void* PythonQtConv::handlePythonToQtAutoConversion(int typeId, PyObject* obj, vo return nullptr; } -void* PythonQtConv::ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& info, PyObject* obj, bool strict, PythonQtClassInfo* /*classInfo*/, void* alreadyAllocatedCPPObject, PythonQtArgumentFrame* frame) - { - bool ok = false; - void* ptr = nullptr; - - // autoconversion of QPen/QBrush/QCursor/QColor from different type - if (info.pointerCount==0 && !strict) { - ptr = handlePythonToQtAutoConversion(info.typeId, obj, alreadyAllocatedCPPObject, frame); - if (ptr) { - return ptr; - } - } - if (info.pointerCount==1 && PythonQtBoolResult_Check(obj) && info.typeId == QMetaType::Bool) { - PythonQtBoolResultObject* boolResul = (PythonQtBoolResultObject*)obj; - // store the wrapped pointer in an extra pointer and let ptr point to the extra pointer - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject,frame, void*, &boolResul->_value, ptr); - return ptr; - } - - if (PyObject_TypeCheck(obj, &PythonQtInstanceWrapper_Type) && - info.typeId != PythonQtMethodInfo::Variant && +void* PythonQtConv::ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& info, PyObject* obj, bool strict, + PythonQtClassInfo* /*classInfo*/, void* alreadyAllocatedCPPObject, PythonQtArgumentFrame* frame) +{ + bool ok = false; + void* ptr = nullptr; + + // autoconversion of QPen/QBrush/QCursor/QColor from different type + if (info.pointerCount == 0 && !strict) { + ptr = handlePythonToQtAutoConversion(info.typeId, obj, alreadyAllocatedCPPObject, frame); + if (ptr) { + return ptr; + } + } + if (info.pointerCount == 1 && PythonQtBoolResult_Check(obj) && info.typeId == QMetaType::Bool) { + PythonQtBoolResultObject* boolResul = (PythonQtBoolResultObject*)obj; + // store the wrapped pointer in an extra pointer and let ptr point to the extra pointer + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, &boolResul->_value, ptr); + return ptr; + } + + if (PyObject_TypeCheck(obj, &PythonQtInstanceWrapper_Type) && info.typeId != PythonQtMethodInfo::Variant && #if QT_VERSION >= 0x060000 - info.typeId != byteArrayViewTypeId && // this case is handled later on + info.typeId != byteArrayViewTypeId && // this case is handled later on #endif - !PythonQt::priv()->isPythonQtAnyObjectPtrMetaId(info.typeId)) { - // if we have a Qt wrapper object and if we do not need a QVariant, we do the following: - // (the Variant case is handled below in a switch) - - // a C++ wrapper (can be passed as pointer or reference) - PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)obj; - void* object = castWrapperTo(wrap, info.name, ok); - if (ok) { - if (info.passOwnershipToCPP) { - // Example: QLayout::addWidget(QWidget*) - wrap->passOwnershipToCPP(); - } else if (info.passOwnershipToPython) { - // Example: QLayout::removeWidget(QWidget*) - wrap->passOwnershipToPython(); - } - if (info.pointerCount==1) { - // store the wrapped pointer in an extra pointer and let ptr point to the extra pointer - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject,frame, void*, object, ptr); - } else if (info.pointerCount==0) { - // store the wrapped pointer directly, since we are a reference - ptr = object; - } - } else { - // not matching, maybe a PyObject*? - if (info.name == "PyObject" && info.pointerCount==1) { - // handle low level PyObject directly - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, obj, ptr); - } - } - } else if (info.pointerCount == 1) { - // a pointer - if (info.typeId == QMetaType::Char || info.typeId == QMetaType::UChar) - { - if (obj->ob_type == &PyBytes_Type) { - // take direct reference to string data - const char* data = PyBytes_AS_STRING(obj); - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, (void*)data, ptr); - } else { - // convert to string - QString str = PyObjGetString(obj, strict, ok); - if (ok) { - QByteArray bytes; - bytes = str.toUtf8(); - if (ok) { - void* ptr2 = nullptr; - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr,frame, QVariant(bytes), ptr2); - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject,frame, void*, (((QByteArray*)((QVariant*)ptr2)->constData())->data()), ptr); - } - } - } - } else if (info.typeId == QMetaType::QString) { - // TODO: this is a special case for bad Qt APIs which take a QString*, like QtGui.QFileDialog.getSaveFileName - // In general we would need to decide to either support * args for all basic types (ignoring the fact that the - // result value is not useable in Python), or if all these APIs need to be wrapped manually/differently, like PyQt/PySide do. - QString str = PyObjGetString(obj, strict, ok); - if (ok) { - void* ptr2 = nullptr; - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr,frame, QVariant(str), ptr2); - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject,frame, void*, (void*)((QVariant*)ptr2)->constData(), ptr); - } - } else if (info.name == "PyObject") { - // handle low level PyObject directly - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, obj, ptr); - } else if (obj == Py_None) { - // None is treated as a NULL ptr - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, nullptr, ptr); - } else { - void* foreignWrapper = PythonQt::priv()->unwrapForeignWrapper(info.name, obj); - if (foreignWrapper) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, foreignWrapper, ptr); - } else { - // if we are not strict, we try if we are passed a 0 integer - if (!strict) { - bool ok; - int value = PyObjGetInt(obj, true, ok); - if (ok && value==0) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, nullptr, ptr); - } - } - } - } - } else if (info.pointerCount == 0) { - // not a pointer - switch (info.typeId) { - case QMetaType::Char: - { - int val = PyObjGetInt(obj, strict, ok); - if (ok && (val >= CHAR_MIN && val <= CHAR_MAX)) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, char, val, ptr); - } - } - break; - case QMetaType::UChar: - { - int val = PyObjGetInt(obj, strict, ok); - if (ok && (val >= 0 && val <= UCHAR_MAX)) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned char, val, ptr); - } - } - break; - case QMetaType::Short: - { - int val = PyObjGetInt(obj, strict, ok); - if (ok && (val >= SHRT_MIN && val <= SHRT_MAX)) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, short, val, ptr); - } - } - break; - case QMetaType::UShort: - { - int val = PyObjGetInt(obj, strict, ok); - if (ok && (val >= 0 && val <= USHRT_MAX)) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned short, val, ptr); - } - } - break; - case QMetaType::Long: - { - auto val = PyObjGetLongLong(obj, strict, ok); - if (ok && (val >= LONG_MIN && val <= LONG_MAX)) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, long, val, ptr); - } - } - break; - case QMetaType::ULong: - { - auto val = PyObjGetULongLong(obj, strict, ok); - if (ok && val <= ULONG_MAX) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned long, val, ptr); - } - } - break; - case QMetaType::Bool: - { - bool val = PyObjGetBool(obj, strict, ok); - if (ok) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, bool, val, ptr); - } - } - break; - case QMetaType::Int: - { - qint64 val = PyObjGetLongLong(obj, strict, ok); - if (ok && (val >= INT_MIN && val <= INT_MAX)) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, int, val, ptr); - } - } - break; - case QMetaType::UInt: - { - auto val = PyObjGetLongLong(obj, strict, ok); - if (ok && (val >= 0 && val <= UINT_MAX)) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned int, val, ptr); - } - } - break; - case QMetaType::QChar: - { - int val = PyObjGetInt(obj, strict, ok); - if (ok && (val >= 0 && val <= USHRT_MAX)) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned short, val, ptr); - } - } - break; - case QMetaType::Float: - { - float val = (float)PyObjGetDouble(obj, strict, ok); - if (ok) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, float, val, ptr); - } - } - break; - case QMetaType::Double: - { - double val = PyObjGetDouble(obj, strict, ok); - if (ok) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, double, val, ptr); - } - } - break; - case QMetaType::LongLong: - { - qint64 val = PyObjGetLongLong(obj, strict, ok); - if (ok) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, qint64, val, ptr); - } - } - break; - case QMetaType::ULongLong: - { - quint64 val = PyObjGetULongLong(obj, strict, ok); - if (ok) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, quint64, val, ptr); - } - } - break; - case QMetaType::QByteArray: - { - QByteArray bytes = PyObjGetBytesAllowString(obj, strict, ok); - if (ok) { - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject,frame, QVariant(bytes), ptr); - ptr = (void*)((QVariant*)ptr)->constData(); - } - } - break; - case QMetaType::QString: - { - QString str = PyObjGetString(obj, strict, ok); - if (ok) { - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, QVariant(str), ptr); - ptr = (void*)((QVariant*)ptr)->constData(); - } - } - break; - case QMetaType::QStringList: - { - QStringList l = PyObjToStringList(obj, strict, ok); - if (ok) { - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject,frame, QVariant(l), ptr); - ptr = (void*)((QVariant*)ptr)->constData(); - } - } - break; - - case PythonQtMethodInfo::Variant: - { - QVariant v = PyObjToQVariant(obj); - // the only case where conversion can fail it None and we want to pass that to, e.g. setProperty(), - // so we do not check v.isValid() here - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject,frame, v, ptr); - } - break; - default: - { - // check for enum case - if (info.enumWrapper) { - unsigned int val = 0; - ok = false; - if ((PyObject*)obj->ob_type == info.enumWrapper) { - // we have a exact enum type match: - val = PyLong_AS_LONG(obj); - ok = true; - } - else if (!strict) { - // we try to get any integer, when not being strict. If we are strict, integers are not wanted because - // we want an integer overload to be taken first! - val = (unsigned int)PyObjGetLongLong(obj, false, ok); - } - if (ok) { - PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned int, val, ptr); - return ptr; - } - else { - return nullptr; - } - } - - // Handle QStringView et al, which need a reference to a persistent QString + !PythonQt::priv()->isPythonQtAnyObjectPtrMetaId(info.typeId)) + { + // if we have a Qt wrapper object and if we do not need a QVariant, we do the following: + // (the Variant case is handled below in a switch) + + // a C++ wrapper (can be passed as pointer or reference) + PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)obj; + void* object = castWrapperTo(wrap, info.name, ok); + if (ok) { + if (info.passOwnershipToCPP) { + // Example: QLayout::addWidget(QWidget*) + wrap->passOwnershipToCPP(); + } else if (info.passOwnershipToPython) { + // Example: QLayout::removeWidget(QWidget*) + wrap->passOwnershipToPython(); + } + if (info.pointerCount == 1) { + // store the wrapped pointer in an extra pointer and let ptr point to the extra pointer + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, object, ptr); + } else if (info.pointerCount == 0) { + // store the wrapped pointer directly, since we are a reference + ptr = object; + } + } else { + // not matching, maybe a PyObject*? + if (info.name == "PyObject" && info.pointerCount == 1) { + // handle low level PyObject directly + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, obj, ptr); + } + } + } else if (info.pointerCount == 1) { + // a pointer + if (info.typeId == QMetaType::Char || info.typeId == QMetaType::UChar) { + if (obj->ob_type == &PyBytes_Type) { + // take direct reference to string data + const char* data = PyBytes_AS_STRING(obj); + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, (void*)data, ptr); + } else { + // convert to string + QString str = PyObjGetString(obj, strict, ok); + if (ok) { + QByteArray bytes; + bytes = str.toUtf8(); + if (ok) { + void* ptr2 = nullptr; + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr, frame, QVariant(bytes), ptr2); + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, + (((QByteArray*)((QVariant*)ptr2)->constData())->data()), ptr); + } + } + } + } else if (info.typeId == QMetaType::QString) { + // TODO: this is a special case for bad Qt APIs which take a QString*, like QtGui.QFileDialog.getSaveFileName + // In general we would need to decide to either support * args for all basic types (ignoring the fact that the + // result value is not useable in Python), or if all these APIs need to be wrapped manually/differently, like PyQt/PySide do. + QString str = PyObjGetString(obj, strict, ok); + if (ok) { + void* ptr2 = nullptr; + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr, frame, QVariant(str), ptr2); + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, + (void*)((QVariant*)ptr2)->constData(), ptr); + } + } else if (info.name == "PyObject") { + // handle low level PyObject directly + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, obj, ptr); + } else if (obj == Py_None) { + // None is treated as a NULL ptr + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, nullptr, ptr); + } else { + void* foreignWrapper = PythonQt::priv()->unwrapForeignWrapper(info.name, obj); + if (foreignWrapper) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, foreignWrapper, ptr); + } else { + // if we are not strict, we try if we are passed a 0 integer + if (!strict) { + bool ok; + int value = PyObjGetInt(obj, true, ok); + if (ok && value == 0) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, void*, nullptr, ptr); + } + } + } + } + } else if (info.pointerCount == 0) { + // not a pointer + switch (info.typeId) { + case QMetaType::Char: + { + int val = PyObjGetInt(obj, strict, ok); + if (ok && (val >= CHAR_MIN && val <= CHAR_MAX)) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, char, val, ptr); + } + } break; + case QMetaType::UChar: + { + int val = PyObjGetInt(obj, strict, ok); + if (ok && (val >= 0 && val <= UCHAR_MAX)) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned char, val, ptr); + } + } break; + case QMetaType::Short: + { + int val = PyObjGetInt(obj, strict, ok); + if (ok && (val >= SHRT_MIN && val <= SHRT_MAX)) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, short, val, ptr); + } + } break; + case QMetaType::UShort: + { + int val = PyObjGetInt(obj, strict, ok); + if (ok && (val >= 0 && val <= USHRT_MAX)) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned short, val, ptr); + } + } break; + case QMetaType::Long: + { + auto val = PyObjGetLongLong(obj, strict, ok); + if (ok && (val >= LONG_MIN && val <= LONG_MAX)) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, long, val, ptr); + } + } break; + case QMetaType::ULong: + { + auto val = PyObjGetULongLong(obj, strict, ok); + if (ok && val <= ULONG_MAX) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned long, val, ptr); + } + } break; + case QMetaType::Bool: + { + bool val = PyObjGetBool(obj, strict, ok); + if (ok) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, bool, val, ptr); + } + } break; + case QMetaType::Int: + { + qint64 val = PyObjGetLongLong(obj, strict, ok); + if (ok && (val >= INT_MIN && val <= INT_MAX)) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, int, val, ptr); + } + } break; + case QMetaType::UInt: + { + auto val = PyObjGetLongLong(obj, strict, ok); + if (ok && (val >= 0 && val <= UINT_MAX)) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned int, val, ptr); + } + } break; + case QMetaType::QChar: + { + int val = PyObjGetInt(obj, strict, ok); + if (ok && (val >= 0 && val <= USHRT_MAX)) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned short, val, ptr); + } + } break; + case QMetaType::Float: + { + float val = (float)PyObjGetDouble(obj, strict, ok); + if (ok) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, float, val, ptr); + } + } break; + case QMetaType::Double: + { + double val = PyObjGetDouble(obj, strict, ok); + if (ok) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, double, val, ptr); + } + } break; + case QMetaType::LongLong: + { + qint64 val = PyObjGetLongLong(obj, strict, ok); + if (ok) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, qint64, val, ptr); + } + } break; + case QMetaType::ULongLong: + { + quint64 val = PyObjGetULongLong(obj, strict, ok); + if (ok) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, quint64, val, ptr); + } + } break; + case QMetaType::QByteArray: + { + QByteArray bytes = PyObjGetBytesAllowString(obj, strict, ok); + if (ok) { + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, QVariant(bytes), ptr); + ptr = (void*)((QVariant*)ptr)->constData(); + } + } break; + case QMetaType::QString: + { + QString str = PyObjGetString(obj, strict, ok); + if (ok) { + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, QVariant(str), ptr); + ptr = (void*)((QVariant*)ptr)->constData(); + } + } break; + case QMetaType::QStringList: + { + QStringList l = PyObjToStringList(obj, strict, ok); + if (ok) { + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, QVariant(l), ptr); + ptr = (void*)((QVariant*)ptr)->constData(); + } + } break; + + case PythonQtMethodInfo::Variant: + { + QVariant v = PyObjToQVariant(obj); + // the only case where conversion can fail it None and we want to pass that to, e.g. setProperty(), + // so we do not check v.isValid() here + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, v, ptr); + } break; + default: + { + // check for enum case + if (info.enumWrapper) { + unsigned int val = 0; + ok = false; + if ((PyObject*)obj->ob_type == info.enumWrapper) { + // we have a exact enum type match: + val = PyLong_AS_LONG(obj); + ok = true; + } else if (!strict) { + // we try to get any integer, when not being strict. If we are strict, integers are not wanted because + // we want an integer overload to be taken first! + val = (unsigned int)PyObjGetLongLong(obj, false, ok); + } + if (ok) { + PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, unsigned int, val, ptr); + return ptr; + } else { + return nullptr; + } + } + + // Handle QStringView et al, which need a reference to a persistent QString #if QT_VERSION < 0x060000 - if (info.typeId == stringRefTypeId) { - QString str = PyObjGetString(obj, strict, ok); - if (ok) { - void* ptr2 = nullptr; - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr, frame, QVariant(str), ptr2); - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, - QVariant::fromValue(QStringRef((const QString*)((QVariant*)ptr2)->constData())), ptr); - ptr = (void*)((QVariant*)ptr)->constData(); - return ptr; - } - else { - return nullptr; - } - } + if (info.typeId == stringRefTypeId) { + QString str = PyObjGetString(obj, strict, ok); + if (ok) { + void* ptr2 = nullptr; + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr, frame, QVariant(str), ptr2); + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, + QVariant::fromValue(QStringRef((const QString*)((QVariant*)ptr2)->constData())), ptr); + ptr = (void*)((QVariant*)ptr)->constData(); + return ptr; + } else { + return nullptr; + } + } #else - if (info.typeId == stringViewTypeId) { - // Handle QStringView, which needs a reference to a persistent QString - QString str = PyObjGetString(obj, strict, ok); - if (ok) { - void* ptr2 = nullptr; - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr, frame, QVariant(str), ptr2); - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, - QVariant::fromValue(QStringView(*((const QString*)((QVariant*)ptr2)->constData()))), ptr); - ptr = (void*)((QVariant*)ptr)->constData(); - return ptr; - } - else { - return nullptr; - } - } - else if (info.typeId == anyStringViewTypeId) { - // Handle QAnyStringView, which needs a reference to a persistent QString - QString str = PyObjGetString(obj, strict, ok); - if (ok) { - void* ptr2 = nullptr; - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr, frame, QVariant(str), ptr2); - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, - QVariant::fromValue(QAnyStringView(*((const QString*)((QVariant*)ptr2)->constData()))), ptr); - ptr = (void*)((QVariant*)ptr)->constData(); - return ptr; - } - else { - return nullptr; - } - } - else if (info.typeId == byteArrayViewTypeId) { - // Handle QByteArrayView, which needs a reference to a persistent QByteArray - QByteArray ba = PyObjGetBytesAllowString(obj, strict, ok); - if (ok) { - void* ptr2 = nullptr; - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr, frame, QVariant(ba), ptr2); - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, - QVariant::fromValue(QByteArrayView(*((const QByteArray*)((QVariant*)ptr2)->constData()))), ptr); - ptr = (void*)((QVariant*)ptr)->constData(); - return ptr; - } - else { - return nullptr; - } - } + if (info.typeId == stringViewTypeId) { + // Handle QStringView, which needs a reference to a persistent QString + QString str = PyObjGetString(obj, strict, ok); + if (ok) { + void* ptr2 = nullptr; + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr, frame, QVariant(str), ptr2); + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, + QVariant::fromValue(QStringView(*((const QString*)((QVariant*)ptr2)->constData()))), ptr); + ptr = (void*)((QVariant*)ptr)->constData(); + return ptr; + } else { + return nullptr; + } + } else if (info.typeId == anyStringViewTypeId) { + // Handle QAnyStringView, which needs a reference to a persistent QString + QString str = PyObjGetString(obj, strict, ok); + if (ok) { + void* ptr2 = nullptr; + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr, frame, QVariant(str), ptr2); + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, + QVariant::fromValue(QAnyStringView(*((const QString*)((QVariant*)ptr2)->constData()))), ptr); + ptr = (void*)((QVariant*)ptr)->constData(); + return ptr; + } else { + return nullptr; + } + } else if (info.typeId == byteArrayViewTypeId) { + // Handle QByteArrayView, which needs a reference to a persistent QByteArray + QByteArray ba = PyObjGetBytesAllowString(obj, strict, ok); + if (ok) { + void* ptr2 = nullptr; + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(nullptr, frame, QVariant(ba), ptr2); + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, + QVariant::fromValue(QByteArrayView(*((const QByteArray*)((QVariant*)ptr2)->constData()))), ptr); + ptr = (void*)((QVariant*)ptr)->constData(); + return ptr; + } else { + return nullptr; + } + } #endif - if (info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) { - // check for QList case, where we will use a QList QVariant - if (info.isQList && (info.innerNamePointerCount == 1)) { - static int id = PythonQtUtils::metaTypeIdFromTypeName("QList"); - if (!alreadyAllocatedCPPObject) { - PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID_IF_NEEDED(alreadyAllocatedCPPObject, frame, id, ptr); - ptr = (void*)((QVariant*)ptr)->constData(); - } else { - ptr = alreadyAllocatedCPPObject; - } - ok = ConvertPythonListToQListOfPointerType(obj, (QList*)ptr, info, strict); - if (ok) { - return ptr; - } else { - return nullptr; - } - } - } - - // We only do this for registered type > QMetaType::User for performance reasons. - if (info.typeId >= QMetaType::User || info.typeId == QMetaType::QByteArrayList) { - // Maybe we have a special converter that is registered for that type: - PythonQtConvertPythonToMetaTypeCB* converter = _pythonToMetaTypeConverters.value(info.typeId); - if (converter) { - if (!alreadyAllocatedCPPObject) { - // create a new empty variant of concrete type: - PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID_IF_NEEDED(alreadyAllocatedCPPObject,frame, info.typeId, ptr); - ptr = (void*)((QVariant*)ptr)->constData(); - } else { - ptr = alreadyAllocatedCPPObject; - } - // now call the converter, passing the internal object of the variant - ok = (*converter)(obj, ptr, info.typeId, strict); - if (ok) { - return ptr; - } else { - return nullptr; - } - } - } - // if no type id is available, conversion to a QVariant makes no sense/is not possible - if (info.typeId != PythonQtMethodInfo::Unknown) { - // for all other types, we use the same qvariant conversion and pass out the constData of the variant: - QVariant v = PyObjToQVariant(obj, info.typeId); - if (v.isValid()) { - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject,frame, v, ptr); - ptr = (void*)((QVariant*)ptr)->constData(); - } - } - } + if (info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) { + // check for QList case, where we will use a QList QVariant + if (info.isQList && (info.innerNamePointerCount == 1)) { + static int id = PythonQtUtils::metaTypeIdFromTypeName("QList"); + if (!alreadyAllocatedCPPObject) { + PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID_IF_NEEDED(alreadyAllocatedCPPObject, frame, id, ptr); + ptr = (void*)((QVariant*)ptr)->constData(); + } else { + ptr = alreadyAllocatedCPPObject; + } + ok = ConvertPythonListToQListOfPointerType(obj, (QList*)ptr, info, strict); + if (ok) { + return ptr; + } else { + return nullptr; + } + } + } + + // We only do this for registered type > QMetaType::User for performance reasons. + if (info.typeId >= QMetaType::User || info.typeId == QMetaType::QByteArrayList) { + // Maybe we have a special converter that is registered for that type: + PythonQtConvertPythonToMetaTypeCB* converter = _pythonToMetaTypeConverters.value(info.typeId); + if (converter) { + if (!alreadyAllocatedCPPObject) { + // create a new empty variant of concrete type: + PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID_IF_NEEDED(alreadyAllocatedCPPObject, frame, info.typeId, ptr); + ptr = (void*)((QVariant*)ptr)->constData(); + } else { + ptr = alreadyAllocatedCPPObject; + } + // now call the converter, passing the internal object of the variant + ok = (*converter)(obj, ptr, info.typeId, strict); + if (ok) { + return ptr; + } else { + return nullptr; + } + } + } + // if no type id is available, conversion to a QVariant makes no sense/is not possible + if (info.typeId != PythonQtMethodInfo::Unknown) { + // for all other types, we use the same qvariant conversion and pass out the constData of the variant: + QVariant v = PyObjToQVariant(obj, info.typeId); + if (v.isValid()) { + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedCPPObject, frame, v, ptr); + ptr = (void*)((QVariant*)ptr)->constData(); + } + } + } } } return ptr; } - -QStringList PythonQtConv::PyObjToStringList(PyObject* val, bool strict, bool& ok) { +QStringList PythonQtConv::PyObjToStringList(PyObject* val, bool strict, bool& ok) +{ QStringList v; ok = false; // if we are strict, we do not want to convert a string to a stringlist // (strings in python are detected to be sequences) - if (strict && - (val->ob_type == &PyBytes_Type || - PyUnicode_Check(val))) { + if (strict && (val->ob_type == &PyBytes_Type || PyUnicode_Check(val))) { return v; } if (PySequence_Check(val)) { int count = PySequence_Size(val); if (count >= 0) { - for (int i = 0;iob_type == &PyLong_Type) { @@ -916,7 +899,8 @@ int PythonQtConv::PyObjGetInt(PyObject* val, bool strict, bool &ok) { return d; } -qint64 PythonQtConv::PyObjGetLongLong(PyObject* val, bool strict, bool &ok) { +qint64 PythonQtConv::PyObjGetLongLong(PyObject* val, bool strict, bool& ok) +{ qint64 d = 0; ok = true; if (val->ob_type == &PyLong_Type) { @@ -946,7 +930,8 @@ qint64 PythonQtConv::PyObjGetLongLong(PyObject* val, bool strict, bool &ok) { return d; } -quint64 PythonQtConv::PyObjGetULongLong(PyObject* val, bool strict, bool &ok) { +quint64 PythonQtConv::PyObjGetULongLong(PyObject* val, bool strict, bool& ok) +{ quint64 d = 0; ok = true; if (Py_TYPE(val) == &PyLong_Type) { @@ -976,7 +961,8 @@ quint64 PythonQtConv::PyObjGetULongLong(PyObject* val, bool strict, bool &ok) { return d; } -double PythonQtConv::PyObjGetDouble(PyObject* val, bool strict, bool &ok) { +double PythonQtConv::PyObjGetDouble(PyObject* val, bool strict, bool& ok) +{ double d = 0; ok = true; if (val->ob_type == &PyFloat_Type) { @@ -1003,7 +989,7 @@ double PythonQtConv::PyObjGetDouble(PyObject* val, bool strict, bool &ok) { return d; } -template +template void PythonQtConv::pythonToMapVariant(PyObject* val, QVariant& result) { if (PyMapping_Check(val)) { @@ -1014,11 +1000,11 @@ void PythonQtConv::pythonToMapVariant(PyObject* val, QVariant& result) PyObject* value; PyObject* key; PyObject* tuple; - for (int i = 0;i= 0x060000 - return QVariant(QMetaType(typeId), copy); + return QVariant(QMetaType(typeId), copy); #else - return QVariant(typeId, copy); + return QVariant(typeId, copy); #endif - } +} } QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) @@ -1043,11 +1028,12 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) QVariant v; bool ok = true; - if (type == -1 + if (type == -1 #if QT_VERSION >= 0x040800 - || type == QMetaType::QVariant + || type == QMetaType::QVariant #endif - ) { + ) + { // no special type requested if (val == nullptr) { type = QMetaType::UnknownType; // Equivalent to QVariant::Invalid or unregistered type @@ -1061,8 +1047,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) // return int if the value fits into that range, // otherwise it would not be possible to get an int from Python 3 qint64 d = PyLong_AsLongLong(val); - if (d > std::numeric_limits::max() || - d < std::numeric_limits::min()) { + if (d > std::numeric_limits::max() || d < std::numeric_limits::min()) { type = QMetaType::LongLong; } else { type = QMetaType::Int; @@ -1073,7 +1058,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)val; // c++ wrapper, check if the class names of the c++ objects match if (wrap->classInfo()->isCPPWrapper()) { - if (wrap->classInfo()->metaTypeId()>0) { + if (wrap->classInfo()->metaTypeId() > 0) { // construct a new variant from the C++ object if it has a meta type (this will COPY the object!) v = variantFromType(wrap->classInfo()->metaTypeId(), wrap->_wrappedPtr); } else { @@ -1107,96 +1092,94 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) return v; break; case QMetaType::Int: - { - int d = PyObjGetInt(val, false, ok); - if (ok) return QVariant(d); - } - break; + { + int d = PyObjGetInt(val, false, ok); + if (ok) + return QVariant(d); + } break; case QMetaType::UInt: - { - int d = PyObjGetInt(val, false,ok); - if (ok) v = QVariant((unsigned int)d); - } - break; + { + int d = PyObjGetInt(val, false, ok); + if (ok) + v = QVariant((unsigned int)d); + } break; case QMetaType::Bool: - { - int d = PyObjGetBool(val,false,ok); - if (ok) v = QVariant((bool)(d!=0)); - } - break; + { + int d = PyObjGetBool(val, false, ok); + if (ok) + v = QVariant((bool)(d != 0)); + } break; case QMetaType::Double: - { - double d = PyObjGetDouble(val,false,ok); - if (ok) v = QVariant(d); - } - break; + { + double d = PyObjGetDouble(val, false, ok); + if (ok) + v = QVariant(d); + } break; case QMetaType::Float: - { - float d = (float) PyObjGetDouble(val,false,ok); - if (ok) v = QVariant::fromValue(d); - } - break; + { + float d = (float)PyObjGetDouble(val, false, ok); + if (ok) + v = QVariant::fromValue(d); + } break; case QMetaType::Long: - { - long d = (long) PyObjGetLongLong(val,false,ok); - if (ok) v = QVariant::fromValue(d); - } - break; + { + long d = (long)PyObjGetLongLong(val, false, ok); + if (ok) + v = QVariant::fromValue(d); + } break; case QMetaType::ULong: - { - unsigned long d = (unsigned long) PyObjGetLongLong(val,false,ok); - if (ok) v = QVariant::fromValue(d); - } - break; + { + unsigned long d = (unsigned long)PyObjGetLongLong(val, false, ok); + if (ok) + v = QVariant::fromValue(d); + } break; case QMetaType::LongLong: - { - qint64 d = PyObjGetLongLong(val, false, ok); - if (ok) v = QVariant::fromValue(d); - } - break; + { + qint64 d = PyObjGetLongLong(val, false, ok); + if (ok) + v = QVariant::fromValue(d); + } break; case QMetaType::ULongLong: - { - quint64 d = PyObjGetULongLong(val, false, ok); - if (ok) v = QVariant::fromValue(d); - } - break; + { + quint64 d = PyObjGetULongLong(val, false, ok); + if (ok) + v = QVariant::fromValue(d); + } break; case QMetaType::Short: - { - short d = (short) PyObjGetInt(val,false,ok); - if (ok) v = QVariant::fromValue(d); - } - break; + { + short d = (short)PyObjGetInt(val, false, ok); + if (ok) + v = QVariant::fromValue(d); + } break; case QMetaType::UShort: - { - unsigned short d = (unsigned short) PyObjGetInt(val,false,ok); - if (ok) v = QVariant::fromValue(d); - } - break; + { + unsigned short d = (unsigned short)PyObjGetInt(val, false, ok); + if (ok) + v = QVariant::fromValue(d); + } break; case QMetaType::Char: - { - char d = (char) PyObjGetInt(val,false,ok); - if (ok) v = QVariant::fromValue(d); - } - break; + { + char d = (char)PyObjGetInt(val, false, ok); + if (ok) + v = QVariant::fromValue(d); + } break; case QMetaType::UChar: - { - unsigned char d = (unsigned char) PyObjGetInt(val,false,ok); - if (ok) v = QVariant::fromValue(d); - } - break; + { + unsigned char d = (unsigned char)PyObjGetInt(val, false, ok); + if (ok) + v = QVariant::fromValue(d); + } break; case QMetaType::QByteArray: - { - bool ok; - v = QVariant(PyObjGetBytes(val, false, ok)); - } - break; + { + bool ok; + v = QVariant(PyObjGetBytes(val, false, ok)); + } break; case QMetaType::QString: - { - bool ok; - v = QVariant(PyObjGetString(val, false, ok)); - } - break; + { + bool ok; + v = QVariant(PyObjGetString(val, false, ok)); + } break; case QMetaType::QVariantMap: pythonToMapVariant(val, v); @@ -1228,17 +1211,15 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) v = list; } } - } - break; + } break; case QMetaType::QStringList: - { - bool ok; - QStringList l = PyObjToStringList(val, false, ok); - if (ok) { - v = l; - } + { + bool ok; + QStringList l = PyObjToStringList(val, false, ok); + if (ok) { + v = l; } - break; + } break; default: if (PyObject_TypeCheck(val, &PythonQtInstanceWrapper_Type)) { @@ -1259,14 +1240,13 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) if (ok) { if (isPtr) { v = variantFromType(type, &object); - } - else { + } else { v = variantFromType(type, object); } } } } else if (static_cast(type) >= QMetaType::User) { - // not an instance wrapper, but there might be other converters + // not an instance wrapper, but there might be other converters // Maybe we have a special converter that is registered for that type: PythonQtConvertPythonToMetaTypeCB* converter = _pythonToMetaTypeConverters.value(type); if (converter) { @@ -1299,7 +1279,7 @@ PyObject* PythonQtConv::QStringToPyObject(const QString& str) if (str.isNull()) { return PyUnicode_FromString(""); } else { - return PyUnicode_DecodeUTF16((const char*)str.utf16(), str.length()*2, nullptr, nullptr); + return PyUnicode_DecodeUTF16((const char*)str.utf16(), str.length() * 2, nullptr, nullptr); } } @@ -1321,7 +1301,7 @@ PyObject* PythonQtConv::QStringListToPyList(const QStringList& list) { PyObject* result = PyList_New(list.count()); int i = 0; - for (QStringList::ConstIterator it = list.begin(); it!=list.end(); ++it) { + for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { PyList_SET_ITEM(result, i, PythonQtConv::QStringToPyObject(*it)); i++; } @@ -1345,14 +1325,14 @@ PyObject* PythonQtConv::QVariantToPyObject(const QVariant& v) return obj; } -template -PyObject* PythonQtConv::mapToPython (const Map& m) +template +PyObject* PythonQtConv::mapToPython(const Map& m) { PyObject* result = PyDict_New(); typename Map::const_iterator t = m.constBegin(); PyObject* key; PyObject* val; - for (;t!=m.constEnd();t++) { + for (; t != m.constEnd(); t++) { key = QStringToPyObject(t.key()); val = QVariantToPyObject(t.value()); PyDict_SetItem(result, key, val); @@ -1362,15 +1342,18 @@ PyObject* PythonQtConv::mapToPython (const Map& m) return result; } -PyObject* PythonQtConv::QVariantMapToPyObject(const QVariantMap& m) { +PyObject* PythonQtConv::QVariantMapToPyObject(const QVariantMap& m) +{ return mapToPython(m); } -PyObject* PythonQtConv::QVariantHashToPyObject(const QVariantHash& m) { +PyObject* PythonQtConv::QVariantHashToPyObject(const QVariantHash& m) +{ return mapToPython(m); } -PyObject* PythonQtConv::QVariantListToPyObject(const QVariantList& l) { +PyObject* PythonQtConv::QVariantListToPyObject(const QVariantList& l) +{ PyObject* result = PyTuple_New(l.count()); int i = 0; for (const QVariant& v : l) { @@ -1382,7 +1365,8 @@ PyObject* PythonQtConv::QVariantListToPyObject(const QVariantList& l) { return result; } -PyObject* PythonQtConv::ConvertQListOfPointerTypeToPythonList(QList* list, const PythonQtMethodInfo::ParameterInfo& info) +PyObject* PythonQtConv::ConvertQListOfPointerTypeToPythonList(QList* list, + const PythonQtMethodInfo::ParameterInfo& info) { PyObject* result = PyTuple_New(list->count()); int i = 0; @@ -1402,7 +1386,8 @@ PyObject* PythonQtConv::ConvertQListOfPointerTypeToPythonList(QList* list return result; } -bool PythonQtConv::ConvertPythonListToQListOfPointerType(PyObject* obj, QList* list, const PythonQtMethodInfo::ParameterInfo& info, bool /*strict*/) +bool PythonQtConv::ConvertPythonListToQListOfPointerType(PyObject* obj, QList* list, + const PythonQtMethodInfo::ParameterInfo& info, bool /*strict*/) { bool result = false; if (PySequence_Check(obj)) { @@ -1410,8 +1395,8 @@ bool PythonQtConv::ConvertPythonListToQListOfPointerType(PyObject* obj, QList= 0) { result = true; PyObject* value; - for (int i = 0;i(data); - r = QString::number(s->width()) + ", " + QString::number(s->height()); - } - break; - case QMetaType::QSizeF: { - const QSizeF* s = static_cast(data); - r = QString::number(s->width()) + ", " + QString::number(s->height()); - } - break; - case QMetaType::QPoint: { - const QPoint* s = static_cast(data); - r = QString::number(s->x()) + ", " + QString::number(s->y()); - } - break; - case QMetaType::QPointF: { - const QPointF* s = static_cast(data); - r = QString::number(s->x()) + ", " + QString::number(s->y()); - } - break; - case QMetaType::QRect: { - const QRect* s = static_cast(data); - r = QString::number(s->x()) + ", " + QString::number(s->y()); - r += ", " + QString::number(s->width()) + ", " + QString::number(s->height()); - } - break; - case QMetaType::QRectF: { - const QRectF* s = static_cast(data); - r = QString::number(s->x()) + ", " + QString::number(s->y()); - r += ", " + QString::number(s->width()) + ", " + QString::number(s->height()); - } - break; - case QMetaType::QDate: { - const QDate* s = static_cast(data); - r = s->toString(Qt::ISODate); - } - break; - case QMetaType::QDateTime: { - const QDateTime* s = static_cast(data); - r = s->toString(Qt::ISODate); - } - break; - case QMetaType::QTime: { - const QTime* s = static_cast(data); - r = s->toString(Qt::ISODate); - } - break; - case QMetaType::QPixmap: - { - const QPixmap* s = static_cast(data); - r = QString("Pixmap ") + QString::number(s->width()) + ", " + QString::number(s->height()); - } - break; - case QMetaType::QImage: - { - const QImage* s = static_cast(data); - r = QString("Image ") + QString::number(s->width()) + ", " + QString::number(s->height()); + case QMetaType::QSize: + { + const QSize* s = static_cast(data); + r = QString::number(s->width()) + ", " + QString::number(s->height()); + } break; + case QMetaType::QSizeF: + { + const QSizeF* s = static_cast(data); + r = QString::number(s->width()) + ", " + QString::number(s->height()); + } break; + case QMetaType::QPoint: + { + const QPoint* s = static_cast(data); + r = QString::number(s->x()) + ", " + QString::number(s->y()); + } break; + case QMetaType::QPointF: + { + const QPointF* s = static_cast(data); + r = QString::number(s->x()) + ", " + QString::number(s->y()); + } break; + case QMetaType::QRect: + { + const QRect* s = static_cast(data); + r = QString::number(s->x()) + ", " + QString::number(s->y()); + r += ", " + QString::number(s->width()) + ", " + QString::number(s->height()); + } break; + case QMetaType::QRectF: + { + const QRectF* s = static_cast(data); + r = QString::number(s->x()) + ", " + QString::number(s->y()); + r += ", " + QString::number(s->width()) + ", " + QString::number(s->height()); + } break; + case QMetaType::QDate: + { + const QDate* s = static_cast(data); + r = s->toString(Qt::ISODate); + } break; + case QMetaType::QDateTime: + { + const QDateTime* s = static_cast(data); + r = s->toString(Qt::ISODate); + } break; + case QMetaType::QTime: + { + const QTime* s = static_cast(data); + r = s->toString(Qt::ISODate); + } break; + case QMetaType::QPixmap: + { + const QPixmap* s = static_cast(data); + r = QString("Pixmap ") + QString::number(s->width()) + ", " + QString::number(s->height()); + } break; + case QMetaType::QImage: + { + const QImage* s = static_cast(data); + r = QString("Image ") + QString::number(s->width()) + ", " + QString::number(s->height()); + } break; + case QMetaType::QUrl: + { + const QUrl* s = static_cast(data); + r = s->toString(); + } break; + //TODO: add more printing for other variant types + default: + // this creates a copy, but that should not be expensive for typical simple variants + // (but we do not want to do this for our own user types!) + if (type > 0 && type < (int)QMetaType::User) { + r = variantFromType(type, data).toString(); } - break; - case QMetaType::QUrl: - { - const QUrl* s = static_cast(data); - r = s->toString(); - } - break; - //TODO: add more printing for other variant types - default: - // this creates a copy, but that should not be expensive for typical simple variants - // (but we do not want to do this for our own user types!) - if (type>0 && type < (int)QMetaType::User) { - r = variantFromType(type, data).toString(); - } } return r; } -PyObject* PythonQtConv::createCopyFromMetaType( int type, const void* data ) +PyObject* PythonQtConv::createCopyFromMetaType(int type, const void* data) { // if the type is known, we can construct it via QMetaType::construct -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) void* newCPPObject = QMetaType(type).create(data); #elif QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) void* newCPPObject = QMetaType::create(type, data); @@ -1532,7 +1514,8 @@ PyObject* PythonQtConv::createCopyFromMetaType( int type, const void* data ) void* newCPPObject = QMetaType::construct(type, data); #endif // XXX this could be optimized by using metatypeid directly - PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(newCPPObject, QByteArray(PythonQtUtils::typeNameFromMetaTypeId(type))); + PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(newCPPObject, + QByteArray(PythonQtUtils::typeNameFromMetaTypeId(type))); wrap->_ownedByPythonQt = true; wrap->_useQMetaTypeDestroy = true; return (PyObject*)wrap; @@ -1590,7 +1573,7 @@ QByteArray PythonQtConv::getCPPTypeName(PyObject* type) } } } else if (type == Py_None) { - result = "void"; + result = "void"; } else { bool dummy; result = QMetaObject::normalizedType(PyObjGetString(type, true, dummy).toUtf8()); @@ -1622,7 +1605,7 @@ PyObject* PythonQtConv::convertFromQListOfPythonQtObjectPtr(const void* inObject { QList& list = *((QList*)inObject); PyObject* tuple = PyTuple_New(list.size()); - for (int i = 0; i* */ outList, int /*metaTypeId*/, bool /*strict*/) +bool PythonQtConv::convertToQListOfPythonQtObjectPtr(PyObject* obj, void* /* QList* */ outList, + int /*metaTypeId*/, bool /*strict*/) { bool result = false; QList& list = *((QList*)outList); @@ -1640,8 +1624,8 @@ bool PythonQtConv::convertToQListOfPythonQtObjectPtr(PyObject* obj, void* /* QLi if (count >= 0) { PyObject* value; result = true; - for (int i = 0;i >(#type"<"#innertype">"); \ -PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonListToListOfValueType, innertype>); \ -PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertListOfValueTypeToPythonList, innertype>); \ -} + { \ + int typeId = qRegisterMetaType>(#type "<" #innertype ">"); \ + PythonQtConv::registerPythonToMetaTypeConverter(typeId, \ + PythonQtConvertPythonListToListOfValueType, innertype>); \ + PythonQtConv::registerMetaTypeToPythonConverter(typeId, \ + PythonQtConvertListOfValueTypeToPythonList, innertype>); \ + } #define PythonQtRegisterListTemplateConverterForKnownClass(type, innertype) \ -{ int typeId = qRegisterMetaType >(#type"<"#innertype">"); \ - PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonListToListOfKnownClass, innertype>); \ - PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertListOfKnownClassToPythonList, innertype>); \ -} + { \ + int typeId = qRegisterMetaType>(#type "<" #innertype ">"); \ + PythonQtConv::registerPythonToMetaTypeConverter(typeId, \ + PythonQtConvertPythonListToListOfKnownClass, innertype>); \ + PythonQtConv::registerMetaTypeToPythonConverter(typeId, \ + PythonQtConvertListOfKnownClassToPythonList, innertype>); \ + } #define PythonQtRegisterQPairConverter(type1, type2) \ -{ int typeId = qRegisterMetaType >("QPair<"#type1","#type2">"); \ - PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonToPair); \ - PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertPairToPython); \ -} + { \ + int typeId = qRegisterMetaType>("QPair<" #type1 "," #type2 ">"); \ + PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonToPair); \ + PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertPairToPython); \ + } #define PythonQtRegisterIntegerMapConverter(type, innertype) \ -{ int typeId = qRegisterMetaType >(#type""); \ - PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonToIntegerMap, innertype>); \ - PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertIntegerMapToPython, innertype>); \ -} + { \ + int typeId = qRegisterMetaType>(#type ""); \ + PythonQtConv::registerPythonToMetaTypeConverter(typeId, \ + PythonQtConvertPythonToIntegerMap, innertype>); \ + PythonQtConv::registerMetaTypeToPythonConverter(typeId, \ + PythonQtConvertIntegerMapToPython, innertype>); \ + } #define PythonQtRegisterListTemplateQPairConverter(listtype, type1, type2) \ -{ \ - qRegisterMetaType >("QPair<"#type1","#type2">"); \ - int typeId = qRegisterMetaType > >(#listtype">"); \ - PythonQtConv::registerPythonToMetaTypeConverter(typeId, PythonQtConvertPythonListToListOfPair >, type1, type2>); \ - PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertListOfPairToPythonList >, type1, type2>); \ -} + { \ + qRegisterMetaType>("QPair<" #type1 "," #type2 ">"); \ + int typeId = qRegisterMetaType>>(#listtype ">"); \ + PythonQtConv::registerPythonToMetaTypeConverter(typeId, \ + PythonQtConvertPythonListToListOfPair>, type1, type2>); \ + PythonQtConv::registerMetaTypeToPythonConverter(typeId, \ + PythonQtConvertListOfPairToPythonList>, type1, type2>); \ + } #define PythonQtRegisterToolClassesTemplateConverter(innertype) \ PythonQtRegisterListTemplateConverter(QList, innertype); \ @@ -98,7 +110,8 @@ PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertListOfVal PythonQtRegisterListTemplateConverterForKnownClass(std::vector, innertype); //! a static class that offers methods for type conversion -class PYTHONQT_EXPORT PythonQtConv { +class PYTHONQT_EXPORT PythonQtConv +{ public: @@ -109,7 +122,8 @@ class PYTHONQT_EXPORT PythonQtConv { static PyObject* ConvertQtValueToPython(const PythonQtMethodInfo::ParameterInfo& info, const void* data); //! convert python object to Qt (according to the given parameter) and if the conversion should be strict (classInfo is currently not used anymore) - static void* ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& info, PyObject* obj, bool strict, PythonQtClassInfo* classInfo, void* alreadyAllocatedCPPObject, PythonQtArgumentFrame* frame = nullptr); + static void* ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& info, PyObject* obj, bool strict, + PythonQtClassInfo* classInfo, void* alreadyAllocatedCPPObject, PythonQtArgumentFrame* frame = nullptr); //! creates a data storage for the passed parameter type and returns a void pointer to be set as arg[0] of qt_metacall static void* CreateQtReturnValue(const PythonQtMethodInfo::ParameterInfo& info, PythonQtArgumentFrame* frame); @@ -123,27 +137,32 @@ class PYTHONQT_EXPORT PythonQtConv { //! converts QStringList to Python list static PyObject* QStringListToPyList(const QStringList& list); - //! get string representation of py object + //! get string representation of py object static QString PyObjGetRepresentation(PyObject* val); //! get string value from py object - static QString PyObjGetString(PyObject* val) { bool ok; QString s = PyObjGetString(val, false, ok); return s; } + static QString PyObjGetString(PyObject* val) + { + bool ok; + QString s = PyObjGetString(val, false, ok); + return s; + } //! get string value from py object - static QString PyObjGetString(PyObject* val, bool strict, bool &ok); + static QString PyObjGetString(PyObject* val, bool strict, bool& ok); //! get bytes from py object - static QByteArray PyObjGetBytes(PyObject* val, bool strict, bool &ok); + static QByteArray PyObjGetBytes(PyObject* val, bool strict, bool& ok); //! get bytes from py object, also allows Python string static QByteArray PyObjGetBytesAllowString(PyObject* val, bool strict, bool& ok); //! get int from py object - static int PyObjGetInt(PyObject* val, bool strict, bool &ok); + static int PyObjGetInt(PyObject* val, bool strict, bool& ok); //! get int64 from py object - static qint64 PyObjGetLongLong(PyObject* val, bool strict, bool &ok); + static qint64 PyObjGetLongLong(PyObject* val, bool strict, bool& ok); //! get int64 from py object - static quint64 PyObjGetULongLong(PyObject* val, bool strict, bool &ok); + static quint64 PyObjGetULongLong(PyObject* val, bool strict, bool& ok); //! get double from py object - static double PyObjGetDouble(PyObject* val, bool strict, bool &ok); + static double PyObjGetDouble(PyObject* val, bool strict, bool& ok); //! get bool from py object - static bool PyObjGetBool(PyObject* val, bool strict, bool &ok); + static bool PyObjGetBool(PyObject* val, bool strict, bool& ok); //! create a string list from python sequence static QStringList PyObjToStringList(PyObject* val, bool strict, bool& ok); @@ -163,30 +182,43 @@ class PYTHONQT_EXPORT PythonQtConv { static QString CPPObjectToString(int type, const void* data); //! register a converter callback from python to cpp for given metatype - static void registerPythonToMetaTypeConverter(int metaTypeId, PythonQtConvertPythonToMetaTypeCB* cb) { _pythonToMetaTypeConverters.insert(metaTypeId, cb); } + static void registerPythonToMetaTypeConverter(int metaTypeId, PythonQtConvertPythonToMetaTypeCB* cb) + { + _pythonToMetaTypeConverters.insert(metaTypeId, cb); + } //! register a converter callback from cpp to python for given metatype - static void registerMetaTypeToPythonConverter(int metaTypeId, PythonQtConvertMetaTypeToPythonCB* cb) { _metaTypeToPythonConverters.insert(metaTypeId, cb); } + static void registerMetaTypeToPythonConverter(int metaTypeId, PythonQtConvertMetaTypeToPythonCB* cb) + { + _metaTypeToPythonConverters.insert(metaTypeId, cb); + } //! set a callback that is called when a Python sequence should be converted to a QVariantList //! to allow special conversion. - static void setPythonSequenceToQVariantListCallback(PythonQtConvertPythonSequenceToQVariantListCB* cb) { _pythonSequenceToQVariantListCB = cb; } + static void setPythonSequenceToQVariantListCallback(PythonQtConvertPythonSequenceToQVariantListCB* cb) + { + _pythonSequenceToQVariantListCB = cb; + } //! converts the Qt parameter given in \c data, interpreting it as a \c type registered qvariant/meta type, into a Python object, static PyObject* convertQtValueToPythonInternal(int type, const void* data); //! creates a copy of given object, using the QMetaType - static PyObject* createCopyFromMetaType( int type, const void* object ); + static PyObject* createCopyFromMetaType(int type, const void* object); //! cast wrapper to given className if possible static void* castWrapperTo(PythonQtInstanceWrapper* wrapper, const QByteArray& className, bool& ok); - static bool convertToPythonQtObjectPtr(PyObject* obj, void* /* PythonQtObjectPtr* */ outPtr, int /*metaTypeId*/, bool /*strict*/); + static bool convertToPythonQtObjectPtr(PyObject* obj, void* /* PythonQtObjectPtr* */ outPtr, int /*metaTypeId*/, + bool /*strict*/); static PyObject* convertFromPythonQtObjectPtr(const void* /* PythonQtObjectPtr* */ inObject, int /*metaTypeId*/); - static bool convertToPythonQtSafeObjectPtr(PyObject* obj, void* /* PythonQtObjectPtr* */ outPtr, int /*metaTypeId*/, bool /*strict*/); + static bool convertToPythonQtSafeObjectPtr(PyObject* obj, void* /* PythonQtObjectPtr* */ outPtr, int /*metaTypeId*/, + bool /*strict*/); static PyObject* convertFromPythonQtSafeObjectPtr(const void* /* PythonQtObjectPtr* */ inObject, int /*metaTypeId*/); - static bool convertToQListOfPythonQtObjectPtr(PyObject* obj, void* /* QList* */ outList, int /*metaTypeId*/, bool /*strict*/); - static PyObject* convertFromQListOfPythonQtObjectPtr(const void* /* QList* */ inObject, int /*metaTypeId*/); + static bool convertToQListOfPythonQtObjectPtr(PyObject* obj, void* /* QList* */ outList, + int /*metaTypeId*/, bool /*strict*/); + static PyObject* convertFromQListOfPythonQtObjectPtr(const void* /* QList* */ inObject, + int /*metaTypeId*/); #if QT_VERSION < 0x060000 static PyObject* convertFromStringRef(const void* inObject, int /*metaTypeId*/); #else @@ -207,22 +239,25 @@ class PYTHONQT_EXPORT PythonQtConv { protected: static QHash _metaTypeToPythonConverters; static QHash _pythonToMetaTypeConverters; - static PythonQtConvertPythonSequenceToQVariantListCB* _pythonSequenceToQVariantListCB; + static PythonQtConvertPythonSequenceToQVariantListCB* _pythonSequenceToQVariantListCB; //! handle automatic conversion of some special types (QColor, QBrush, ...) - static void* handlePythonToQtAutoConversion(int typeId, PyObject* obj, void* alreadyAllocatedCPPObject, PythonQtArgumentFrame* frame); + static void* handlePythonToQtAutoConversion(int typeId, PyObject* obj, void* alreadyAllocatedCPPObject, + PythonQtArgumentFrame* frame); //! converts the list of pointers of given type to Python - static PyObject* ConvertQListOfPointerTypeToPythonList(QList* list, const PythonQtMethodInfo::ParameterInfo& info); + static PyObject* ConvertQListOfPointerTypeToPythonList(QList* list, + const PythonQtMethodInfo::ParameterInfo& info); //! tries to convert the python object to a QList of pointers to \c type objects, returns true on success - static bool ConvertPythonListToQListOfPointerType(PyObject* obj, QList* list, const PythonQtMethodInfo::ParameterInfo& info, bool strict); + static bool ConvertPythonListToQListOfPointerType(PyObject* obj, QList* list, + const PythonQtMethodInfo::ParameterInfo& info, bool strict); //! helper template method for conversion from Python to QVariantMap/Hash - template + template static void pythonToMapVariant(PyObject* val, QVariant& result); //! helper template function for QVariantMapToPyObject/QVariantHashToPyObject - template - static PyObject* mapToPython (const Map& m); + template + static PyObject* mapToPython(const Map& m); #if QT_VERSION < 0x060000 static int stringRefTypeId; @@ -237,9 +272,11 @@ template PyObject* PythonQtConvertListOfValueTypeToPythonList(const void* /*QList* */ inList, int metaTypeId) { ListType* list = (ListType*)inList; - static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); + static const int innerType = + PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); if (innerType == QMetaType::UnknownType) { - std::cerr << "PythonQtConvertListOfValueTypeToPythonList: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; + std::cerr << "PythonQtConvertListOfValueTypeToPythonList: unknown inner type " + << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; } PyObject* result = PyTuple_New(list->size()); int i = 0; @@ -251,12 +288,15 @@ PyObject* PythonQtConvertListOfValueTypeToPythonList(const void* /*QList* */ } template -bool PythonQtConvertPythonListToListOfValueType(PyObject* obj, void* /*QList* */ outList, int metaTypeId, bool /*strict*/) +bool PythonQtConvertPythonListToListOfValueType(PyObject* obj, void* /*QList* */ outList, int metaTypeId, + bool /*strict*/) { ListType* list = (ListType*)outList; - static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); + static const int innerType = + PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); if (innerType == QMetaType::UnknownType) { - std::cerr << "PythonQtConvertPythonListToListOfValueType: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; + std::cerr << "PythonQtConvertPythonListToListOfValueType: unknown inner type " + << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; } bool result = false; if (PySequence_Check(obj)) { @@ -264,8 +304,8 @@ bool PythonQtConvertPythonListToListOfValueType(PyObject* obj, void* /*QList* if (count >= 0) { result = true; PyObject* value; - for (int i = 0;i PyObject* PythonQtConvertListOfKnownClassToPythonList(const void* /*QList* */ inList, int metaTypeId) { ListType* list = (ListType*)inList; - static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo(PythonQtMethodInfo::getInnerListTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)))); + static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo( + PythonQtMethodInfo::getInnerListTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)))); if (innerType == nullptr) { - std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; + std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for " + << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; } PyObject* result = PyTuple_New(list->size()); int i = 0; for (const T& value : *list) { T* newObject = new T(value); - PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(newObject, innerType->className()); + PythonQtInstanceWrapper* wrap = + (PythonQtInstanceWrapper*)PythonQt::priv()->wrapPtr(newObject, innerType->className()); wrap->_ownedByPythonQt = true; PyTuple_SET_ITEM(result, i, (PyObject*)wrap); i++; @@ -304,12 +347,15 @@ PyObject* PythonQtConvertListOfKnownClassToPythonList(const void* /*QList* */ } template -bool PythonQtConvertPythonListToListOfKnownClass(PyObject* obj, void* /*QList* */ outList, int metaTypeId, bool /*strict*/) +bool PythonQtConvertPythonListToListOfKnownClass(PyObject* obj, void* /*QList* */ outList, int metaTypeId, + bool /*strict*/) { ListType* list = (ListType*)outList; - static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo(PythonQtMethodInfo::getInnerListTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)))); + static PythonQtClassInfo* innerType = PythonQt::priv()->getClassInfo( + PythonQtMethodInfo::getInnerListTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)))); if (innerType == nullptr) { - std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; + std::cerr << "PythonQtConvertListOfKnownClassToPythonList: unknown inner type for " + << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; } bool result = false; if (PySequence_Check(obj)) { @@ -349,14 +395,16 @@ PyObject* PythonQtConvertPairToPython(const void* /*QPair* */ inPair, int QPair* pair = (QPair*)inPair; static int innerType1 = -1; static int innerType2 = -1; - if (innerType1==-1) { - QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); + if (innerType1 == -1) { + QByteArray innerTypes = + PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); QList names = innerTypes.split(','); innerType1 = PythonQtUtils::metaTypeIdFromTypeName(names.at(0).trimmed()); innerType2 = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed()); } if (innerType1 == QMetaType::UnknownType || innerType2 == QMetaType::UnknownType) { - std::cerr << "PythonQtConvertPairToPython: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; + std::cerr << "PythonQtConvertPairToPython: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) + << std::endl; } PyObject* result = PyTuple_New(2); PyTuple_SET_ITEM(result, 0, PythonQtConv::convertQtValueToPythonInternal(innerType1, &pair->first)); @@ -371,13 +419,15 @@ bool PythonQtConvertPythonToPair(PyObject* obj, void* /*QPair* */ outPair static int innerType1 = -1; static int innerType2 = -1; if (innerType1 == -1) { - QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); + QByteArray innerTypes = + PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); QList names = innerTypes.split(','); innerType1 = PythonQtUtils::metaTypeIdFromTypeName(names.at(0).trimmed()); innerType2 = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed()); } if (innerType1 == QMetaType::UnknownType || innerType2 == QMetaType::UnknownType) { - std::cerr << "PythonQtConvertPythonToPair: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; + std::cerr << "PythonQtConvertPythonToPair: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) + << std::endl; } bool result = false; if (PySequence_Check(obj)) { @@ -416,9 +466,11 @@ template PyObject* PythonQtConvertListOfPairToPythonList(const void* /*QList >* */ inList, int metaTypeId) { ListType* list = (ListType*)inList; - static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); + static int innerType = + PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); if (innerType == QMetaType::UnknownType) { - std::cerr << "PythonQtConvertListOfPairToPythonList: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; + std::cerr << "PythonQtConvertListOfPairToPythonList: unknown inner type " + << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; } PyObject* result = PyTuple_New(list->size()); int i = 0; @@ -432,12 +484,15 @@ PyObject* PythonQtConvertListOfPairToPythonList(const void* /*QList } template -bool PythonQtConvertPythonListToListOfPair(PyObject* obj, void* /*QList >* */ outList, int metaTypeId, bool /*strict*/) +bool PythonQtConvertPythonListToListOfPair(PyObject* obj, void* /*QList >* */ outList, int metaTypeId, + bool /*strict*/) { ListType* list = (ListType*)outList; - static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); + static int innerType = + PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); if (innerType == QMetaType::UnknownType) { - std::cerr << "PythonQtConvertPythonListToListOfPair: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; + std::cerr << "PythonQtConvertPythonListToListOfPair: unknown inner type " + << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; } bool result = false; if (PySequence_Check(obj)) { @@ -448,7 +503,7 @@ bool PythonQtConvertPythonListToListOfPair(PyObject* obj, void* /*QList pair; value = PySequence_GetItem(obj, i); - if (PythonQtConvertPythonToPair(value, &pair, innerType, false)) { + if (PythonQtConvertPythonToPair(value, &pair, innerType, false)) { Py_XDECREF(value); list->push_back(pair); } else { @@ -470,12 +525,14 @@ PyObject* PythonQtConvertIntegerMapToPython(const void* /*QMap* */ inMap MapType* map = (MapType*)inMap; static int innerType = -1; if (innerType == -1) { - QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); + QByteArray innerTypes = + PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); QList names = innerTypes.split(','); innerType = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed()); } if (innerType == QMetaType::UnknownType) { - std::cerr << "PythonQtConvertIntegerMapToPython: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; + std::cerr << "PythonQtConvertIntegerMapToPython: unknown inner type " + << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; } PyObject* result = PyDict_New(); @@ -498,12 +555,14 @@ bool PythonQtConvertPythonToIntegerMap(PyObject* val, void* /*QMap* */ o MapType* map = (MapType*)outMap; static int innerType = -1; if (innerType == -1) { - QByteArray innerTypes = PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); + QByteArray innerTypes = + PythonQtMethodInfo::getInnerTemplateTypeName(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId))); QList names = innerTypes.split(','); innerType = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed()); } if (innerType == QMetaType::UnknownType) { - std::cerr << "PythonQtConvertPythonToIntegerMap: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; + std::cerr << "PythonQtConvertPythonToIntegerMap: unknown inner type " + << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl; } bool result = false; if (PyMapping_Check(val)) { @@ -536,5 +595,4 @@ bool PythonQtConvertPythonToIntegerMap(PyObject* val, void* /*QMap* */ o return result; } - #endif diff --git a/src/PythonQtCppWrapperFactory.h b/src/PythonQtCppWrapperFactory.h index d3cf4f6d4..3bc0be640 100644 --- a/src/PythonQtCppWrapperFactory.h +++ b/src/PythonQtCppWrapperFactory.h @@ -61,8 +61,7 @@ class PYTHONQT_EXPORT PythonQtCppWrapperFactory virtual ~PythonQtCppWrapperFactory() {}; //! create a wrapper for the given object - virtual QObject* create(const QByteArray& classname, void *ptr) = 0; - + virtual QObject* create(const QByteArray& classname, void* ptr) = 0; }; //! Factory interface for C++ classes that can be mapped directly from/to @@ -76,13 +75,11 @@ class PYTHONQT_EXPORT PythonQtForeignWrapperFactory //! create a Python object (with new reference count), wrapping the given \p ptr as class of type \p classname //! Return NULL (and not Py_None) if the object could not be wrapped. - virtual PyObject* wrap(const QByteArray& classname, void *ptr) = 0; + virtual PyObject* wrap(const QByteArray& classname, void* ptr) = 0; //! unwrap the given object to a C++ object of type \p classname if possible //! Return NULL otherwise. - virtual void* unwrap(const QByteArray& classname, PyObject* object) = 0; - + virtual void* unwrap(const QByteArray& classname, PyObject* object) = 0; }; #endif - diff --git a/src/PythonQtDoc.h b/src/PythonQtDoc.h index 3588e0933..682baec96 100644 --- a/src/PythonQtDoc.h +++ b/src/PythonQtDoc.h @@ -1,5 +1,5 @@ #ifndef _PYTHONQTDOC_H -#define _PYTHONQTDOC_H + #define _PYTHONQTDOC_H /* * diff --git a/src/PythonQtImportFileInterface.h b/src/PythonQtImportFileInterface.h index ea8afbb1d..1710cffb4 100644 --- a/src/PythonQtImportFileInterface.h +++ b/src/PythonQtImportFileInterface.h @@ -49,7 +49,8 @@ //! Defines an abstract interface to file access for the Python import statement. //! see PythonQt::setImporter() -class PythonQtImportFileInterface { +class PythonQtImportFileInterface +{ Q_DISABLE_COPY(PythonQtImportFileInterface) public: // get rid of warnings @@ -80,8 +81,6 @@ class PythonQtImportFileInterface { //! called by PythonQt after successful import to allow //! recording of imports virtual void importedModule(const QString& /*module*/) {} - }; #endif - diff --git a/src/PythonQtImporter.cpp b/src/PythonQtImporter.cpp index 4ef17937a..4318d3f67 100644 --- a/src/PythonQtImporter.cpp +++ b/src/PythonQtImporter.cpp @@ -53,9 +53,9 @@ #include #include -#define IS_SOURCE 0x0 +#define IS_SOURCE 0x0 #define IS_BYTECODE 0x1 -#define IS_PACKAGE 0x2 +#define IS_PACKAGE 0x2 struct st_mlab_searchorder { char suffix[14]; @@ -67,23 +67,16 @@ struct st_mlab_searchorder { non-package .pyc, .pyo and .py entries. The .pyc and .pyo entries are swapped by initmlabimport() if we run in optimized mode. Also, '/' is replaced by SEP there. */ - struct st_mlab_searchorder mlab_searchorder[] = { - {"/__init__.pyc", IS_PACKAGE | IS_BYTECODE}, - {"/__init__.pyo", IS_PACKAGE | IS_BYTECODE}, - {"/__init__.py", IS_PACKAGE | IS_SOURCE}, - {".pyc", IS_BYTECODE}, - {".pyo", IS_BYTECODE}, - {".py", IS_SOURCE}, - {"", 0} -}; +struct st_mlab_searchorder mlab_searchorder[] = {{"/__init__.pyc", IS_PACKAGE | IS_BYTECODE}, + {"/__init__.pyo", IS_PACKAGE | IS_BYTECODE}, {"/__init__.py", IS_PACKAGE | IS_SOURCE}, {".pyc", IS_BYTECODE}, + {".pyo", IS_BYTECODE}, {".py", IS_SOURCE}, {"", 0}}; extern PyTypeObject PythonQtImporter_Type; -PyObject *PythonQtImportError; +PyObject* PythonQtImportError; -namespace -{ +namespace { -#if PY_VERSION_HEX >= 0x030C0000 // Python >= 3.12 +#if PY_VERSION_HEX >= 0x030C0000 // Python >= 3.12 int getSysFlag(const char* flag_name) { PyObject* flags = PySys_GetObject("flags"); @@ -92,18 +85,22 @@ int getSysFlag(const char* flag_name) } PyObject* flag = PyObject_GetAttrString(flags, flag_name); if (!flag) { - PyErr_Clear(); return false; + PyErr_Clear(); + return false; } int flag_value = (int)PyLong_AsLong(flag); Py_DECREF(flag); - if (PyErr_Occurred()) { PyErr_Clear(); return 0; }; + if (PyErr_Occurred()) { + PyErr_Clear(); + return 0; + }; return flag_value; } #endif int getSysVerbose() { -#if PY_VERSION_HEX >= 0x030C0000 // Python >= 3.12 +#if PY_VERSION_HEX >= 0x030C0000 // Python >= 3.12 return getSysFlag("verbose"); #else return Py_VerboseFlag; @@ -112,7 +109,7 @@ int getSysVerbose() int getSysOptimizationLevel() { -#if PY_VERSION_HEX >= 0x030C0000 // Python >= 3.12 +#if PY_VERSION_HEX >= 0x030C0000 // Python >= 3.12 return getSysFlag("optimize"); #else return Py_OptimizeFlag; @@ -124,8 +121,8 @@ int getSysOptimizationLevel() QString PythonQtImport::getSubName(const QString& str) { int idx = str.lastIndexOf('.'); - if (idx!=-1) { - return str.mid(idx+1); + if (idx != -1) { + return str.mid(idx + 1); } else { return str; } @@ -135,14 +132,14 @@ PythonQtImport::ModuleInfo PythonQtImport::getModuleInfo(PythonQtImporter* self, { ModuleInfo info; QString subname; - struct st_mlab_searchorder *zso; + struct st_mlab_searchorder* zso; subname = getSubName(fullname); QString path = *self->_path + "/" + subname; QString test; // test if it is a shared library (they have precedence over *.py files and this is used in eggs) - for (const QString& suffix : PythonQt::priv( )->sharedLibrarySuffixes()) { + for (const QString& suffix : PythonQt::priv()->sharedLibrarySuffixes()) { test = path + suffix; if (PythonQt::importInterface()->exists(test)) { info.fullPath = test; @@ -156,38 +153,34 @@ PythonQtImport::ModuleInfo PythonQtImport::getModuleInfo(PythonQtImporter* self, if (PythonQt::importInterface()->exists(test)) { info.fullPath = test; info.moduleName = subname; - info.type = (zso->type & IS_PACKAGE)?MI_PACKAGE:MI_MODULE; + info.type = (zso->type & IS_PACKAGE) ? MI_PACKAGE : MI_MODULE; return info; } } return info; } - /* PythonQtImporter.__init__ Just store the path argument (or reject if it is in the ignorePaths list */ -int PythonQtImporter_init(PythonQtImporter *self, PyObject *args, PyObject * /*kwds*/) +int PythonQtImporter_init(PythonQtImporter* self, PyObject* args, PyObject* /*kwds*/) { self->_path = nullptr; const char* cpath; - if (!PyArg_ParseTuple(args, "s", - &cpath)) + if (!PyArg_ParseTuple(args, "s", &cpath)) return -1; QString path(cpath); if (PythonQt::importInterface()->exists(path)) { if (PythonQt::importInterface()->isEggArchive(path)) { - PyErr_SetString(PythonQtImportError, - "path is an egg archive, which is unsupported by PythonQt"); + PyErr_SetString(PythonQtImportError, "path is an egg archive, which is unsupported by PythonQt"); return -1; } else { const QStringList& ignorePaths = PythonQt::self()->getImporterIgnorePaths(); for (const QString& ignorePath : ignorePaths) { if (path.startsWith(ignorePath)) { - PyErr_SetString(PythonQtImportError, - "path ignored"); + PyErr_SetString(PythonQtImportError, "path ignored"); return -1; } } @@ -196,33 +189,29 @@ int PythonQtImporter_init(PythonQtImporter *self, PyObject *args, PyObject * /*k return 0; } } else { - PyErr_SetString(PythonQtImportError, - "path does not exist error"); + PyErr_SetString(PythonQtImportError, "path does not exist error"); return -1; } } -void -PythonQtImporter_dealloc(PythonQtImporter *self) +void PythonQtImporter_dealloc(PythonQtImporter* self) { // free the stored path - if (self->_path) delete self->_path; + if (self->_path) + delete self->_path; // free ourself - Py_TYPE(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject*)self); } - /* Check whether we can satisfy the import of the module named by 'fullname'. Return self if we can, None if we can't. */ -PyObject * -PythonQtImporter_find_module(PyObject *obj, PyObject *args) +PyObject* PythonQtImporter_find_module(PyObject* obj, PyObject* args) { - PythonQtImporter *self = (PythonQtImporter *)obj; - PyObject *path = nullptr; - char *fullname; + PythonQtImporter* self = (PythonQtImporter*)obj; + PyObject* path = nullptr; + char* fullname; - if (!PyArg_ParseTuple(args, "s|O:PythonQtImporter.find_module", - &fullname, &path)) + if (!PyArg_ParseTuple(args, "s|O:PythonQtImporter.find_module", &fullname, &path)) return nullptr; //qDebug() << "looking for " << fullname << " at " << *self->_path; @@ -230,24 +219,22 @@ PythonQtImporter_find_module(PyObject *obj, PyObject *args) PythonQtImport::ModuleInfo info = PythonQtImport::getModuleInfo(self, fullname); if (info.type != PythonQtImport::MI_NOT_FOUND) { Py_INCREF(self); - return (PyObject *)self; + return (PyObject*)self; } else { Py_RETURN_NONE; } } -PyObject * -PythonQtImporter_iter_modules(PyObject *obj, PyObject *args) +PyObject* PythonQtImporter_iter_modules(PyObject* obj, PyObject* args) { // The pkgutil.iter_modules expects an importer to implement // "iter_modules"... We use the generic ImpImporter to handle that. // This is needed for import completion of the jedi library. const char* prefix; - if (!PyArg_ParseTuple(args, "|s", - &prefix)) { + if (!PyArg_ParseTuple(args, "|s", &prefix)) { return nullptr; } - PythonQtImporter *self = (PythonQtImporter *)obj; + PythonQtImporter* self = (PythonQtImporter*)obj; PythonQtObjectPtr pkgutil = PythonQt::self()->importModule("pkgutil"); PythonQtObjectPtr importer = pkgutil.call("ImpImporter", QVariantList() << *self->_path); PythonQtObjectPtr result = importer.call("iter_modules", QVariantList() << QString::fromUtf8(prefix)); @@ -257,15 +244,13 @@ PythonQtImporter_iter_modules(PyObject *obj, PyObject *args) } /* Load and return the module named by 'fullname'. */ -PyObject * -PythonQtImporter_load_module(PyObject *obj, PyObject *args) +PyObject* PythonQtImporter_load_module(PyObject* obj, PyObject* args) { - PythonQtImporter *self = (PythonQtImporter *)obj; + PythonQtImporter* self = (PythonQtImporter*)obj; PyObject *code = nullptr, *mod = nullptr, *dict = nullptr; - char *fullname = NULL; + char* fullname = NULL; - if (!PyArg_ParseTuple(args, "s:PythonQtImporter.load_module", - &fullname)) + if (!PyArg_ParseTuple(args, "s:PythonQtImporter.load_module", &fullname)) return nullptr; PythonQtImport::ModuleInfo info = PythonQtImport::getModuleInfo(self, fullname); @@ -288,7 +273,7 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args) } dict = PyModule_GetDict(mod); - if (PyDict_SetItemString(dict, "__loader__", (PyObject *)self) != 0) { + if (PyDict_SetItemString(dict, "__loader__", (PyObject*)self) != 0) { Py_DECREF(code); Py_DECREF(mod); return nullptr; @@ -299,10 +284,8 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args) QString subname = info.moduleName; int err; - fullpath = PyUnicode_FromFormat("%s%c%s", - QStringToPythonConstCharPointer(*self->_path), - SEP, - QStringToPythonConstCharPointer(subname)); + fullpath = PyUnicode_FromFormat("%s%c%s", QStringToPythonConstCharPointer(*self->_path), SEP, + QStringToPythonConstCharPointer(subname)); if (fullpath == nullptr) { Py_DECREF(code); Py_DECREF(mod); @@ -350,8 +333,7 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args) Py_DECREF(code); if (getSysVerbose()) { - PySys_WriteStderr("import %s # loaded from %s\n", - fullname, QStringToPythonConstCharPointer(fullPath)); + PySys_WriteStderr("import %s # loaded from %s\n", fullname, QStringToPythonConstCharPointer(fullPath)); } } else { PythonQtObjectPtr imp; @@ -371,7 +353,7 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args) if (result.isValid()) { // This will return a tuple with (file, pathname, description=(suffix,mode,type)) QVariantList list = result.toList(); - if (list.count()==3) { + if (list.count() == 3) { // We prepend the full module name (including package prefix) list.prepend(QString(fullname)); #ifdef __linux @@ -395,26 +377,22 @@ PythonQtImporter_load_module(PyObject *obj, PyObject *args) file.call("close"); } } else { - PyErr_Format(PythonQtImportError, "can't find module '%s'", - qPrintable(info.moduleName)); + PyErr_Format(PythonQtImportError, "can't find module '%s'", qPrintable(info.moduleName)); } } return mod; } - -PyObject * -PythonQtImporter_get_data(PyObject* /*obj*/, PyObject* /*args*/) +PyObject* PythonQtImporter_get_data(PyObject* /*obj*/, PyObject* /*args*/) { // EXTRA, NOT YET IMPLEMENTED return nullptr; } -PyObject * -PythonQtImporter_get_code(PyObject *obj, PyObject *args) +PyObject* PythonQtImporter_get_code(PyObject* obj, PyObject* args) { - PythonQtImporter *self = (PythonQtImporter *)obj; - char *fullname; + PythonQtImporter* self = (PythonQtImporter*)obj; + char* fullname; if (!PyArg_ParseTuple(args, "s:PythonQtImporter.get_code", &fullname)) return nullptr; @@ -424,15 +402,13 @@ PythonQtImporter_get_code(PyObject *obj, PyObject *args) return PythonQtImport::getModuleCode(self, fullname, notused, notused2); } -PyObject * -PythonQtImporter_get_source(PyObject * /*obj*/, PyObject * /*args*/) +PyObject* PythonQtImporter_get_source(PyObject* /*obj*/, PyObject* /*args*/) { // EXTRA, NOT YET IMPLEMENTED return nullptr; } -PyDoc_STRVAR(doc_find_module, -"find_module(fullname, path=None) -> self or None.\n\ +PyDoc_STRVAR(doc_find_module, "find_module(fullname, path=None) -> self or None.\n\ \n\ Search for a module specified by 'fullname'. 'fullname' must be the\n\ fully qualified (dotted) module name. It returns the PythonQtImporter\n\ @@ -440,54 +416,41 @@ instance itself if the module was found, or None if it wasn't.\n\ The optional 'path' argument is ignored -- it's there for compatibility\n\ with the importer protocol."); -PyDoc_STRVAR(doc_load_module, -"load_module(fullname) -> module.\n\ +PyDoc_STRVAR(doc_load_module, "load_module(fullname) -> module.\n\ \n\ Load the module specified by 'fullname'. 'fullname' must be the\n\ fully qualified (dotted) module name. It returns the imported\n\ module, or raises PythonQtImportError if it wasn't found."); -PyDoc_STRVAR(doc_get_data, -"get_data(pathname) -> string with file data.\n\ +PyDoc_STRVAR(doc_get_data, "get_data(pathname) -> string with file data.\n\ \n\ Return the data associated with 'pathname'. Raise IOError if\n\ the file wasn't found."); -PyDoc_STRVAR(doc_get_code, -"get_code(fullname) -> code object.\n\ +PyDoc_STRVAR(doc_get_code, "get_code(fullname) -> code object.\n\ \n\ Return the code object for the specified module. Raise PythonQtImportError\n\ is the module couldn't be found."); -PyDoc_STRVAR(doc_get_source, -"get_source(fullname) -> source string.\n\ +PyDoc_STRVAR(doc_get_source, "get_source(fullname) -> source string.\n\ \n\ Return the source code for the specified module. Raise PythonQtImportError\n\ is the module couldn't be found, return None if the archive does\n\ contain the module, but has no source for it."); -PyDoc_STRVAR(doc_iter_modules, - "Needed for pkgutil"); +PyDoc_STRVAR(doc_iter_modules, "Needed for pkgutil"); PyMethodDef PythonQtImporter_methods[] = { - {"find_module", PythonQtImporter_find_module, METH_VARARGS, - doc_find_module}, - {"load_module", PythonQtImporter_load_module, METH_VARARGS, - doc_load_module}, - {"iter_modules", PythonQtImporter_iter_modules, METH_VARARGS, - doc_iter_modules}, - {"get_data", PythonQtImporter_get_data, METH_VARARGS, - doc_get_data}, - {"get_code", PythonQtImporter_get_code, METH_VARARGS, - doc_get_code}, - {"get_source", PythonQtImporter_get_source, METH_VARARGS, - doc_get_source}, - {nullptr, nullptr, 0 , nullptr} /* sentinel */ + {"find_module", PythonQtImporter_find_module, METH_VARARGS, doc_find_module}, + {"load_module", PythonQtImporter_load_module, METH_VARARGS, doc_load_module}, + {"iter_modules", PythonQtImporter_iter_modules, METH_VARARGS, doc_iter_modules}, + {"get_data", PythonQtImporter_get_data, METH_VARARGS, doc_get_data}, + {"get_code", PythonQtImporter_get_code, METH_VARARGS, doc_get_code}, + {"get_source", PythonQtImporter_get_source, METH_VARARGS, doc_get_source}, + {nullptr, nullptr, 0, nullptr} /* sentinel */ }; - -PyDoc_STRVAR(PythonQtImporter_doc, -"PythonQtImporter(path) -> PythonQtImporter object\n\ +PyDoc_STRVAR(PythonQtImporter_doc, "PythonQtImporter(path) -> PythonQtImporter object\n\ \n\ Create a new PythonQtImporter instance. 'path' must be a valid path on disk/or inside of a zip file known to MeVisLab\n\ . Every path is accepted."); @@ -496,56 +459,54 @@ Create a new PythonQtImporter instance. 'path' must be a valid path on disk/or i PyTypeObject PythonQtImporter_Type = { PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0) /*tp_base*/ - "PythonQtImport.PythonQtImporter", /* tp_name */ - sizeof(PythonQtImporter), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PythonQtImporter_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ - nullptr, /* tp_getattr */ - nullptr, /* tp_setattr */ - nullptr, /* tp_compare */ - nullptr, /* tp_repr */ - nullptr, /* tp_as_number */ - nullptr, /* tp_as_sequence */ - nullptr, /* tp_as_mapping */ - nullptr, /* tp_hash */ - nullptr, /* tp_call */ - nullptr, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - nullptr, /* tp_setattro */ - nullptr, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE , /* tp_flags */ - PythonQtImporter_doc, /* tp_doc */ - nullptr, /* tp_traverse */ - nullptr, /* tp_clear */ - nullptr, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - nullptr, /* tp_iter */ - nullptr, /* tp_iternext */ - PythonQtImporter_methods, /* tp_methods */ - nullptr, /* tp_members */ - nullptr, /* tp_getset */ - nullptr, /* tp_base */ - nullptr, /* tp_dict */ - nullptr, /* tp_descr_get */ - nullptr, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PythonQtImporter_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - PyObject_Del, /* tp_free */ + "PythonQtImport.PythonQtImporter", /* tp_name */ + sizeof(PythonQtImporter), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PythonQtImporter_dealloc, /* tp_dealloc */ + 0, /* tp_vectorcall_offset */ + nullptr, /* tp_getattr */ + nullptr, /* tp_setattr */ + nullptr, /* tp_compare */ + nullptr, /* tp_repr */ + nullptr, /* tp_as_number */ + nullptr, /* tp_as_sequence */ + nullptr, /* tp_as_mapping */ + nullptr, /* tp_hash */ + nullptr, /* tp_call */ + nullptr, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + nullptr, /* tp_setattro */ + nullptr, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + PythonQtImporter_doc, /* tp_doc */ + nullptr, /* tp_traverse */ + nullptr, /* tp_clear */ + nullptr, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + nullptr, /* tp_iter */ + nullptr, /* tp_iternext */ + PythonQtImporter_methods, /* tp_methods */ + nullptr, /* tp_members */ + nullptr, /* tp_getset */ + nullptr, /* tp_base */ + nullptr, /* tp_dict */ + nullptr, /* tp_descr_get */ + nullptr, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)PythonQtImporter_init, /* tp_init */ + PyType_GenericAlloc, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + PyObject_Del, /* tp_free */ }; - /* Given a buffer, return the long that is represented by the first 4 bytes, encoded as little endian. This partially reimplements marshal.c:r_long() */ -long -PythonQtImport::getLong(unsigned char *buf) +long PythonQtImport::getLong(unsigned char* buf) { long x; - x = buf[0]; - x |= (long)buf[1] << 8; + x = buf[0]; + x |= (long)buf[1] << 8; x |= (long)buf[2] << 16; x |= (long)buf[3] << 24; #if SIZEOF_LONG > 4 @@ -555,10 +516,9 @@ PythonQtImport::getLong(unsigned char *buf) return x; } -FILE * -open_exclusive(const QString& filename) +FILE* open_exclusive(const QString& filename) { -#if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC) +#if defined(O_EXCL) && defined(O_CREAT) && defined(O_WRONLY) && defined(O_TRUNC) /* Use O_EXCL to avoid a race condition when another process tries to write the same file. When that happens, our open() call fails, which is just fine (since it's only a cache). @@ -568,15 +528,15 @@ open_exclusive(const QString& filename) QFile::remove(filename); int fd; - int flags = O_EXCL|O_CREAT|O_WRONLY|O_TRUNC; -#ifdef O_BINARY - flags |= O_BINARY; /* necessary for Windows */ -#endif -#ifdef WIN32 + int flags = O_EXCL | O_CREAT | O_WRONLY | O_TRUNC; + #ifdef O_BINARY + flags |= O_BINARY; /* necessary for Windows */ + #endif + #ifdef WIN32 fd = _wopen((const wchar_t*)filename.utf16(), flags, 0666); -#else + #else fd = open(filename.toLocal8Bit(), flags, 0666); -#endif + #endif if (fd < 0) return nullptr; return fdopen(fd, "wb"); @@ -586,10 +546,9 @@ open_exclusive(const QString& filename) #endif } - -void PythonQtImport::writeCompiledModule(PyCodeObject *co, const QString& filename, long mtime, long sourceSize) +void PythonQtImport::writeCompiledModule(PyCodeObject* co, const QString& filename, long mtime, long sourceSize) { - FILE *fp; + FILE* fp; // we do not want to write Qt resources to disk, do we? if (filename.startsWith(":")) { return; @@ -597,8 +556,7 @@ void PythonQtImport::writeCompiledModule(PyCodeObject *co, const QString& filena fp = open_exclusive(filename); if (fp == nullptr) { if (getSysVerbose()) { - PySys_WriteStderr( - "# can't create %s\n", QStringToPythonConstCharPointer(filename)); + PySys_WriteStderr("# can't create %s\n", QStringToPythonConstCharPointer(filename)); } return; } @@ -606,7 +564,7 @@ void PythonQtImport::writeCompiledModule(PyCodeObject *co, const QString& filena /* First write a 0 for mtime */ PyMarshal_WriteLongToFile(0L, fp, Py_MARSHAL_VERSION); PyMarshal_WriteLongToFile(sourceSize, fp, Py_MARSHAL_VERSION); - PyMarshal_WriteObjectToFile((PyObject *)co, fp, Py_MARSHAL_VERSION); + PyMarshal_WriteObjectToFile((PyObject*)co, fp, Py_MARSHAL_VERSION); if (ferror(fp)) { if (getSysVerbose()) { PySys_WriteStderr("# can't write %s\n", QStringToPythonConstCharPointer(filename)); @@ -631,42 +589,40 @@ void PythonQtImport::writeCompiledModule(PyCodeObject *co, const QString& filena match (we do this instead of raising an exception as we fall back to .py if available and we don't want to mask other errors). Returns a new reference. */ -PyObject * -PythonQtImport::unmarshalCode(const QString& path, const QByteArray& data, time_t mtime) +PyObject* PythonQtImport::unmarshalCode(const QString& path, const QByteArray& data, time_t mtime) { - PyObject *code; + PyObject* code; // ugly cast, but Python API is not const safe - char *buf = (char*) data.constData(); + char* buf = (char*)data.constData(); int size = data.size(); if (size <= 9) { - PySys_WriteStderr("# %s has bad pyc data\n", - QStringToPythonConstCharPointer(path)); + PySys_WriteStderr("# %s has bad pyc data\n", QStringToPythonConstCharPointer(path)); Py_RETURN_NONE; } - if (getLong((unsigned char *)buf) != PyImport_GetMagicNumber()) { + if (getLong((unsigned char*)buf) != PyImport_GetMagicNumber()) { if (getSysVerbose()) { - PySys_WriteStderr("# %s has bad magic\n", - QStringToPythonConstCharPointer(path)); + PySys_WriteStderr("# %s has bad magic\n", QStringToPythonConstCharPointer(path)); } Py_RETURN_NONE; } if (mtime != 0) { - time_t timeDiff = getLong((unsigned char *)buf + 4) - mtime; - if (timeDiff<0) { timeDiff = -timeDiff; } + time_t timeDiff = getLong((unsigned char*)buf + 4) - mtime; + if (timeDiff < 0) { + timeDiff = -timeDiff; + } if (timeDiff > 1) { if (getSysVerbose()) { - PySys_WriteStderr("# %s has bad mtime\n", - QStringToPythonConstCharPointer(path)); + PySys_WriteStderr("# %s has bad mtime\n", QStringToPythonConstCharPointer(path)); } Py_RETURN_NONE; } } // Python 3 also stores the size of the *.py file, but we ignore it for now - int sourceSize = getLong((unsigned char *)buf + 8); + int sourceSize = getLong((unsigned char*)buf + 8); Q_UNUSED(sourceSize) // read the module code = PyMarshal_ReadObjectFromString(buf + 12, size - 12); @@ -674,24 +630,19 @@ PythonQtImport::unmarshalCode(const QString& path, const QByteArray& data, time_ return nullptr; if (!PyCode_Check(code)) { Py_DECREF(code); - PyErr_Format(PyExc_TypeError, - "compiled module %.200s is not a code object", - QStringToPythonConstCharPointer(path)); + PyErr_Format(PyExc_TypeError, "compiled module %.200s is not a code object", QStringToPythonConstCharPointer(path)); return nullptr; } return code; } - /* Given a string buffer containing Python source code, compile it return and return a code object as a new reference. */ -PyObject * -PythonQtImport::compileSource(const QString& path, const QByteArray& data) +PyObject* PythonQtImport::compileSource(const QString& path, const QByteArray& data) { - PyObject *code; + PyObject* code; PyObject* filename = PythonQtConv::QStringToPyObject(path); - code = Py_CompileStringObject(data.data(), filename, - Py_file_input, nullptr, -1); + code = Py_CompileStringObject(data.data(), filename, Py_file_input, nullptr, -1); Py_DECREF(filename); return code; } @@ -707,66 +658,62 @@ QString PythonQtImport::getSourceFilename(const QString& cacheFile) QString pyFilename; if (cacheFile.length() > 0) { pyFilename = cacheFile; - pyFilename.truncate(pyFilename.length()-1); + pyFilename.truncate(pyFilename.length() - 1); } return pyFilename; } -namespace +namespace { +qint64 toSecsSinceEpoch(const QDateTime& time) { - qint64 toSecsSinceEpoch(const QDateTime& time) - { #if QT_VERSION < 0x060000 - return time.toTime_t(); + return time.toTime_t(); #else - return time.toSecsSinceEpoch(); + return time.toSecsSinceEpoch(); #endif - } +} } /* Return the code object for the module named by 'fullname' from the Zip archive as a new reference. */ -PyObject * -PythonQtImport::getCodeFromData(const QString& path, int isbytecode,int /*ispackage*/, time_t mtime) +PyObject* PythonQtImport::getCodeFromData(const QString& path, int isbytecode, int /*ispackage*/, time_t mtime) { - PyObject *code; + PyObject* code; QByteArray qdata; - if (!isbytecode) { - // mlabDebugConst("MLABPython", "reading source " << path); - bool ok; - qdata = PythonQt::importInterface()->readSourceFile(path, ok); - if (!ok) { - // mlabErrorConst("PythonQtImporter","File could not be verified" << path); - return nullptr; - } - if (qdata == " ") { - qdata.clear(); - } - } else { - qdata = PythonQt::importInterface()->readFileAsBytes(path); + if (!isbytecode) { + // mlabDebugConst("MLABPython", "reading source " << path); + bool ok; + qdata = PythonQt::importInterface()->readSourceFile(path, ok); + if (!ok) { + // mlabErrorConst("PythonQtImporter","File could not be verified" << path); + return nullptr; } + if (qdata == " ") { + qdata.clear(); + } + } else { + qdata = PythonQt::importInterface()->readFileAsBytes(path); + } if (isbytecode) { // mlabDebugConst("MLABPython", "reading bytecode " << path); code = unmarshalCode(path, qdata, mtime); - } - else { - // mlabDebugConst("MLABPython", "compiling source " << path); + } else { + // mlabDebugConst("MLABPython", "compiling source " << path); code = compileSource(path, qdata); if (code) { // save a pyc file if possible QDateTime time; time = PythonQt::importInterface()->lastModifiedDate(path); - QString cacheFilename = getCacheFilename(path, /*isOptimizedFilename=*/false); + QString cacheFilename = getCacheFilename(path, /*isOptimizedFilename=*/false); writeCompiledModule((PyCodeObject*)code, cacheFilename, toSecsSinceEpoch(time), /*sourceSize=*/qdata.length()); } } return code; } -time_t -PythonQtImport::getMTimeOfSource(const QString& path) +time_t PythonQtImport::getMTimeOfSource(const QString& path) { time_t mtime = 0; QString path2 = getSourceFilename(path); @@ -782,23 +729,22 @@ PythonQtImport::getMTimeOfSource(const QString& path) /* Get the code object associated with the module specified by 'fullname'. */ -PyObject * -PythonQtImport::getModuleCode(PythonQtImporter *self, const char* fullname, QString& modpath, QString& cachemodpath) +PyObject* PythonQtImport::getModuleCode(PythonQtImporter* self, const char* fullname, QString& modpath, + QString& cachemodpath) { QString subname; - struct st_mlab_searchorder *zso; + struct st_mlab_searchorder* zso; subname = getSubName(fullname); QString path = *self->_path + "/" + subname; QString test; - for (zso = mlab_searchorder; *zso->suffix;zso++) { - PyObject *code = nullptr; + for (zso = mlab_searchorder; *zso->suffix; zso++) { + PyObject* code = nullptr; test = path + zso->suffix; if (getSysVerbose() > 1) { - PySys_WriteStderr("# trying %s\n", - QStringToPythonConstCharPointer(test)); + PySys_WriteStderr("# trying %s\n", QStringToPythonConstCharPointer(test)); } if (PythonQt::importInterface()->exists(test)) { time_t mtime = 0; @@ -835,14 +781,14 @@ PythonQtImport::getModuleCode(PythonQtImporter *self, const char* fullname, QStr QString PythonQtImport::replaceExtension(const QString& str, const QString& ext) { - QString r; - int i = str.lastIndexOf('.'); - if (i!=-1) { - r = str.mid(0,i) + "." + ext; - } else { - r = str + "." + ext; - } - return r; + QString r; + int i = str.lastIndexOf('.'); + if (i != -1) { + r = str.mid(0, i) + "." + ext; + } else { + r = str + "." + ext; + } + return r; } PyObject* PythonQtImport::getCodeFromPyc(const QString& file) @@ -868,25 +814,24 @@ PyObject* PythonQtImport::getCodeFromPyc(const QString& file) Py_DECREF(code); } } - code = getCodeFromData(file,false,false,0); + code = getCodeFromData(file, false, false, 0); return code; } /* Module init */ -PyDoc_STRVAR(mlabimport_doc, -"Imports python files into PythonQt, completely replaces internal python import"); +PyDoc_STRVAR(mlabimport_doc, "Imports python files into PythonQt, completely replaces internal python import"); static struct PyModuleDef PythonQtImport_def = { - PyModuleDef_HEAD_INIT, /* m_base */ - "PythonQtImport", /* m_name */ - mlabimport_doc, /* m_doc */ - -1, /* m_size */ - nullptr, /* m_methods */ - nullptr, /* m_reload */ - nullptr, /* m_traverse */ - nullptr, /* m_clear */ - nullptr /* m_free */ + PyModuleDef_HEAD_INIT, /* m_base */ + "PythonQtImport", /* m_name */ + mlabimport_doc, /* m_doc */ + -1, /* m_size */ + nullptr, /* m_methods */ + nullptr, /* m_reload */ + nullptr, /* m_traverse */ + nullptr, /* m_clear */ + nullptr /* m_free */ }; void PythonQtImport::init() @@ -897,7 +842,7 @@ void PythonQtImport::init() } first = false; - PyObject *mod; + PyObject* mod; if (PyType_Ready(&PythonQtImporter_Type) < 0) return; @@ -919,21 +864,19 @@ void PythonQtImport::init() mod = PyModule_Create(&PythonQtImport_def); - PythonQtImportError = PyErr_NewException(const_cast("PythonQtImport.PythonQtImportError"), - PyExc_ImportError, nullptr); + PythonQtImportError = + PyErr_NewException(const_cast("PythonQtImport.PythonQtImportError"), PyExc_ImportError, nullptr); if (PythonQtImportError == nullptr) return; Py_INCREF(PythonQtImportError); - if (PyModule_AddObject(mod, "PythonQtImportError", - PythonQtImportError) < 0) { + if (PyModule_AddObject(mod, "PythonQtImportError", PythonQtImportError) < 0) { Py_DECREF(PythonQtImportError); return; } Py_INCREF(&PythonQtImporter_Type); - if (PyModule_AddObject(mod, "PythonQtImporter", - (PyObject *)&PythonQtImporter_Type) < 0) { + if (PyModule_AddObject(mod, "PythonQtImporter", (PyObject*)&PythonQtImporter_Type) < 0) { Py_DECREF(&PythonQtImporter_Type); return; } diff --git a/src/PythonQtImporter.h b/src/PythonQtImporter.h index d9595c4cd..677b040aa 100644 --- a/src/PythonQtImporter.h +++ b/src/PythonQtImporter.h @@ -53,14 +53,12 @@ #include #include - //! defines a python object that stores a Qt slot info struct PythonQtImporter { PyObject_HEAD QString* _path; }; - //! implements importing of python files into PythonQt /*! also compiles/marshalls/unmarshalls py/pyc files and handles time stamps correctly */ @@ -68,19 +66,12 @@ class PythonQtImport { public: - enum ModuleType { - MI_NOT_FOUND, - MI_MODULE, - MI_PACKAGE, - MI_SHAREDLIBRARY - }; + enum ModuleType { MI_NOT_FOUND, MI_MODULE, MI_PACKAGE, MI_SHAREDLIBRARY }; struct ModuleInfo { - ModuleInfo() { - type = MI_NOT_FOUND; - } - QString fullPath; //!< the full path to the found file - QString moduleName; //!< the module name without the package prefix + ModuleInfo() { type = MI_NOT_FOUND; } + QString fullPath; //!< the full path to the found file + QString moduleName; //!< the module name without the package prefix ModuleType type; }; @@ -88,30 +79,27 @@ class PythonQtImport static void init(); //! writes the python code to disk, marshalling and writing the time stamp - static void writeCompiledModule(PyCodeObject *co, const QString& filename, long mtime, long sourceSize); + static void writeCompiledModule(PyCodeObject* co, const QString& filename, long mtime, long sourceSize); /*! Given the contents of a .py[co] file in a buffer, unmarshal the data and return the code object. Return None if it the magic word doesn't match (we do this instead of raising an exception as we fall back to .py if available and we don't want to mask other errors). Returns a new reference. */ - static PyObject *unmarshalCode(const QString& path, const QByteArray& data, time_t mtime); + static PyObject* unmarshalCode(const QString& path, const QByteArray& data, time_t mtime); //! Given a string buffer containing Python source code, compile it //! return and return a code object as a new reference. - static PyObject *compileSource(const QString& path, const QByteArray& data); + static PyObject* compileSource(const QString& path, const QByteArray& data); //! Return the code object for the module named by 'fullname' from the //! Zip archive as a new reference. - static PyObject *getCodeFromData(const QString& path, int isbytecode = 0, int ispackage = 0, - time_t mtime = 0); + static PyObject* getCodeFromData(const QString& path, int isbytecode = 0, int ispackage = 0, time_t mtime = 0); //! Get the code object associated with the module specified by //! 'fullname'. In Python3, modpath will always be the path to the *.py file and cachemodpath the path //! to the *.pyc file (if it exists). - static PyObject * getModuleCode(PythonQtImporter *self, - const char* fullname, QString& modpath, QString& cachemodpath); - + static PyObject* getModuleCode(PythonQtImporter* self, const char* fullname, QString& modpath, QString& cachemodpath); //! gets the compiled code for the given *.py file if there is a valid pyc file, otherwise compiles the file and writes the pyc static PyObject* getCodeFromPyc(const QString& file); @@ -125,7 +113,7 @@ class PythonQtImport //! Given a buffer, return the long that is represented by the first //! 4 bytes, encoded as little endian. This partially reimplements //! marshal.c:r_long() - static long getLong(unsigned char *buf); + static long getLong(unsigned char* buf); //! get time stamp of file static time_t getMTimeOfSource(const QString& path); @@ -141,4 +129,3 @@ class PythonQtImport }; #endif - diff --git a/src/PythonQtInstanceWrapper.cpp b/src/PythonQtInstanceWrapper.cpp index 639333808..b57488f5f 100644 --- a/src/PythonQtInstanceWrapper.cpp +++ b/src/PythonQtInstanceWrapper.cpp @@ -48,8 +48,8 @@ #include "PythonQtClassInfo.h" #include "PythonQtConversion.h" - -static void PythonQtInstanceWrapper_deleteObject(PythonQtInstanceWrapper* self, bool force = false) { +static void PythonQtInstanceWrapper_deleteObject(PythonQtInstanceWrapper* self, bool force = false) +{ // is this a C++ wrapper? if (self->_wrappedPtr) { @@ -65,12 +65,11 @@ static void PythonQtInstanceWrapper_deleteObject(PythonQtInstanceWrapper* self, if (unrefCB) { (*unrefCB)(self->_wrappedPtr); self->_wrappedPtr = nullptr; - } - else if (force || self->_ownedByPythonQt) { + } else if (force || self->_ownedByPythonQt) { int type = self->classInfo()->metaTypeId(); - if (self->_useQMetaTypeDestroy && type>=0) { + if (self->_useQMetaTypeDestroy && type >= 0) { // use QMetaType to destroy the object -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QMetaType(type).destroy(self->_wrappedPtr); #else QMetaType::destroy(type, self->_wrappedPtr); @@ -84,9 +83,9 @@ static void PythonQtInstanceWrapper_deleteObject(PythonQtInstanceWrapper* self, PythonQtSlotInfo::invokeQtMethod(slot->decorator(), slot, args); self->_wrappedPtr = nullptr; } else { - if (type>=0) { + if (type >= 0) { // use QMetaType to destroy the object -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QMetaType(type).destroy(self->_wrappedPtr); #else QMetaType::destroy(type, self->_wrappedPtr); @@ -115,7 +114,7 @@ static void PythonQtInstanceWrapper_deleteObject(PythonQtInstanceWrapper* self, delete self->_obj; } } else { - if (self->_obj->parent()==nullptr) { + if (self->_obj->parent() == nullptr) { // tell someone who is interested that the qobject is no longer wrapped, if it has no parent PythonQt::qObjectNoLongerWrappedCB(self->_obj); } @@ -134,12 +133,12 @@ static void PythonQtInstanceWrapper_dealloc(PythonQtInstanceWrapper* self) Py_TYPE(self)->tp_free((PyObject*)self); } -static PyObject* PythonQtInstanceWrapper_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) +static PyObject* PythonQtInstanceWrapper_new(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { //PythonQtClassWrapper *classType = (PythonQtClassWrapper*)type; - PythonQtInstanceWrapper *self; + PythonQtInstanceWrapper* self; static PyObject* emptyTuple = nullptr; - if (emptyTuple==nullptr) { + if (emptyTuple == nullptr) { emptyTuple = PyTuple_New(0); } @@ -153,10 +152,10 @@ static PyObject* PythonQtInstanceWrapper_new(PyTypeObject *type, PyObject * /*ar self->_isShellInstance = false; self->_shellInstanceRefCountsWrapper = false; } - return (PyObject *)self; + return (PyObject*)self; } -int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper * self, PyObject * args, PyObject * kwds) +int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper* self, PyObject* args, PyObject* kwds) { if (args == PythonQtPrivate::dummyTuple()) { // we are called from the internal PythonQt API, so our data will be filled later on... @@ -167,7 +166,8 @@ int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper * self, PyObject * args if (self->classInfo()->constructors()) { void* directCPPPointer = nullptr; PythonQtPassThisOwnershipType ownership; - PythonQtSlotFunction_CallImpl(self->classInfo(), nullptr, self->classInfo()->constructors(), args, kwds, nullptr, &directCPPPointer, &ownership); + PythonQtSlotFunction_CallImpl(self->classInfo(), nullptr, self->classInfo()->constructors(), args, kwds, nullptr, + &directCPPPointer, &ownership); if (PyErr_Occurred()) { return -1; } @@ -208,8 +208,7 @@ int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper * self, PyObject * args // to C++ immediately) // Alternatively, if it is a QObject and the object already has a parent when it is constructed, // the ownership should be moved to C++ as well, so that the shell instance stays alive. - if (ownership == PassOwnershipToCPP || - (isQObject && self->_obj && self->_obj->parent())) { + if (ownership == PassOwnershipToCPP || (isQObject && self->_obj && self->_obj->parent())) { self->passOwnershipToCPP(); } } @@ -221,7 +220,7 @@ int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper * self, PyObject * args return 0; } -static PyObject *PythonQtInstanceWrapper_richcompare(PythonQtInstanceWrapper* wrapper, PyObject* other, int code) +static PyObject* PythonQtInstanceWrapper_richcompare(PythonQtInstanceWrapper* wrapper, PyObject* other, int code) { if (PythonQt::self() == nullptr || PythonQt::priv() == nullptr) { Py_RETURN_NOTIMPLEMENTED; @@ -264,46 +263,40 @@ static PyObject *PythonQtInstanceWrapper_richcompare(PythonQtInstanceWrapper* wr QByteArray memberName; switch (code) { case Py_LT: - { - static QByteArray name = "__lt__"; - memberName = name; - } - break; + { + static QByteArray name = "__lt__"; + memberName = name; + } break; case Py_LE: - { - static QByteArray name = "__le__"; - memberName = name; - } - break; + { + static QByteArray name = "__le__"; + memberName = name; + } break; case Py_EQ: - { - static QByteArray name = "__eq__"; - memberName = name; - } - break; + { + static QByteArray name = "__eq__"; + memberName = name; + } break; case Py_NE: - { - static QByteArray name = "__ne__"; - memberName = name; - } - break; + { + static QByteArray name = "__ne__"; + memberName = name; + } break; case Py_GT: - { - static QByteArray name = "__gt__"; - memberName = name; - } - break; + { + static QByteArray name = "__gt__"; + memberName = name; + } break; case Py_GE: - { - static QByteArray name = "__ge__"; - memberName = name; - } - break; + { + static QByteArray name = "__ge__"; + memberName = name; + } break; } PythonQtMemberInfo opSlot = wrapper->classInfo()->member(memberName); @@ -311,7 +304,8 @@ static PyObject *PythonQtInstanceWrapper_richcompare(PythonQtInstanceWrapper* wr PyObject* args = PyTuple_New(1); Py_INCREF(other); PyTuple_SET_ITEM(args, 0, other); - PyObject* result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, args, nullptr, wrapper->_wrappedPtr); + PyObject* result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, opSlot._slot, args, nullptr, + wrapper->_wrappedPtr); Py_DECREF(args); if (result == nullptr) { // special handling of EQ and NE, if call fails we just return EQ == false / NE == true. @@ -330,26 +324,25 @@ static PyObject *PythonQtInstanceWrapper_richcompare(PythonQtInstanceWrapper* wr } } - -static PyObject *PythonQtInstanceWrapper_classname(PythonQtInstanceWrapper* obj) +static PyObject* PythonQtInstanceWrapper_classname(PythonQtInstanceWrapper* obj) { return PyUnicode_FromString(Py_TYPE(obj)->tp_name); } -PyObject *PythonQtInstanceWrapper_inherits(PythonQtInstanceWrapper* obj, PyObject *args) +PyObject* PythonQtInstanceWrapper_inherits(PythonQtInstanceWrapper* obj, PyObject* args) { if (PythonQt::self() == nullptr || PythonQt::priv() == nullptr) { PyErr_SetString(PyExc_RuntimeError, "PythonQt is not initialized (or has been finalized)"); return nullptr; } - char *name = nullptr; - if (!PyArg_ParseTuple(args, "s:PythonQtInstanceWrapper.inherits",&name)) { + char* name = nullptr; + if (!PyArg_ParseTuple(args, "s:PythonQtInstanceWrapper.inherits", &name)) { return nullptr; } return PythonQtConv::GetPyBool(obj->classInfo()->inherits(name)); } -static PyObject *PythonQtInstanceWrapper_help(PythonQtInstanceWrapper* obj) +static PyObject* PythonQtInstanceWrapper_help(PythonQtInstanceWrapper* obj) { if (PythonQt::self() == nullptr || PythonQt::priv() == nullptr) { Py_RETURN_NONE; @@ -357,7 +350,7 @@ static PyObject *PythonQtInstanceWrapper_help(PythonQtInstanceWrapper* obj) return PythonQt::self()->helpCalled(obj->classInfo()); } -PyObject *PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper * self) +PyObject* PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper* self) { if (PythonQt::self() == nullptr || PythonQt::priv() == nullptr) { Py_RETURN_NONE; @@ -365,7 +358,8 @@ PyObject *PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper * self) PythonQtMemberInfo deleteSlot = self->classInfo()->member("py_delete"); if (deleteSlot._type == PythonQtMemberInfo::Slot) { // call the py_delete slot instead of internal C++ destructor... - PyObject* resultObj = PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, deleteSlot._slot, nullptr, nullptr, self->_wrappedPtr); + PyObject* resultObj = PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, deleteSlot._slot, nullptr, + nullptr, self->_wrappedPtr); Py_XDECREF(resultObj); } else { PythonQtInstanceWrapper_deleteObject(self, true); @@ -373,37 +367,31 @@ PyObject *PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper * self) Py_RETURN_NONE; } - static PyMethodDef PythonQtInstanceWrapper_methods[] = { - {"className", reinterpret_cast(reinterpret_cast(PythonQtInstanceWrapper_classname)), METH_NOARGS, - "Return the classname of the object" - }, - {"inherits", reinterpret_cast(reinterpret_cast(PythonQtInstanceWrapper_inherits)), METH_VARARGS, - "Returns if the class inherits or is of given type name" - }, - {"help", reinterpret_cast(reinterpret_cast(PythonQtInstanceWrapper_help)), METH_NOARGS, - "Shows the help of available methods for this class" - }, - {"delete", reinterpret_cast(reinterpret_cast(PythonQtInstanceWrapper_delete)), METH_NOARGS, - "Deletes the C++ object (at your own risk, my friend!)" - }, -{nullptr, nullptr, 0, nullptr} /* Sentinel */ + {"className", reinterpret_cast(reinterpret_cast(PythonQtInstanceWrapper_classname)), METH_NOARGS, + "Return the classname of the object"}, + {"inherits", reinterpret_cast(reinterpret_cast(PythonQtInstanceWrapper_inherits)), METH_VARARGS, + "Returns if the class inherits or is of given type name"}, + {"help", reinterpret_cast(reinterpret_cast(PythonQtInstanceWrapper_help)), METH_NOARGS, + "Shows the help of available methods for this class"}, + {"delete", reinterpret_cast(reinterpret_cast(PythonQtInstanceWrapper_delete)), METH_NOARGS, + "Deletes the C++ object (at your own risk, my friend!)"}, + {nullptr, nullptr, 0, nullptr} /* Sentinel */ }; - -static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) +static PyObject* PythonQtInstanceWrapper_getattro(PyObject* obj, PyObject* name) { if (PythonQt::self() == nullptr || PythonQt::priv() == nullptr) { return PyObject_GenericGetAttr(obj, name); } - const char *attributeName; - PythonQtInstanceWrapper *wrapper = (PythonQtInstanceWrapper *)obj; + const char* attributeName; + PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)obj; if ((attributeName = PyUnicode_AsUTF8(name)) == nullptr) { return nullptr; } - if (qstrcmp(attributeName, "__dict__")==0) { + if (qstrcmp(attributeName, "__dict__") == 0) { PyObject* objectDict = PyBaseObject_Type.tp_getattro(obj, name); PyObject* dict = PyDict_Copy(objectDict); Py_DECREF(objectDict); @@ -417,7 +405,8 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) PyDict_SetItemString(dict, QStringToPythonConstCharPointer(name), o); Py_DECREF(o); } else { - std::cerr << "PythonQtInstanceWrapper: something is wrong, could not get attribute " << QStringToPythonConstCharPointer(name) << std::endl; + std::cerr << "PythonQtInstanceWrapper: something is wrong, could not get attribute " + << QStringToPythonConstCharPointer(name) << std::endl; } } @@ -439,13 +428,14 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) PythonQtMemberInfo member = wrapper->classInfo()->member(dynamicDictString); if (member._type == PythonQtMemberInfo::Slot) { PyObject* args = PyTuple_New(0); - PyObject* result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, member._slot, args, nullptr, wrapper->_wrappedPtr); + PyObject* result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, member._slot, args, + nullptr, wrapper->_wrappedPtr); Py_DECREF(args); if (result) { if (PyDict_Check(result)) { PyDict_Merge(dict, result, false); } else { - std::cerr << "py_dynamic_dict() should return a dictionary!" << std::endl; + std::cerr << "py_dynamic_dict() should return a dictionary!" << std::endl; } } } @@ -510,7 +500,8 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) QString methodName = "getProperty('"; methodName += attributeName; methodName += "')"; - profilingCB(PythonQt::Enter, wrapper->_obj->metaObject()->className(), QStringToPythonConstCharPointer(methodName), nullptr); + profilingCB(PythonQt::Enter, wrapper->_obj->metaObject()->className(), + QStringToPythonConstCharPointer(methodName), nullptr); } PyObject* value = PythonQtConv::QVariantToPyObject(member._property.read(wrapper->_obj)); @@ -525,7 +516,8 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) Py_RETURN_NONE; } } else { - QString error = QString("Trying to read property '") + attributeName + "' from a destroyed " + wrapper->classInfo()->className() + " object"; + QString error = QString("Trying to read property '") + attributeName + "' from a destroyed " + + wrapper->classInfo()->className() + " object"; PyErr_SetString(PyExc_ValueError, QStringToPythonConstCharPointer(error)); return nullptr; } @@ -537,58 +529,57 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) return PythonQtSignalFunction_New(member._slot, obj, nullptr); break; case PythonQtMemberInfo::EnumValue: - { - PyObject* enumValue = member._enumValue; - Py_INCREF(enumValue); - return enumValue; - } - break; + { + PyObject* enumValue = member._enumValue; + Py_INCREF(enumValue); + return enumValue; + } break; case PythonQtMemberInfo::EnumWrapper: case PythonQtMemberInfo::NestedClass: { - PyObject* enumWrapper = member._pythonType; - Py_INCREF(enumWrapper); - return enumWrapper; - } - break; + PyObject* enumWrapper = member._pythonType; + Py_INCREF(enumWrapper); + return enumWrapper; + } break; case PythonQtMemberInfo::NotFound: + { + static const QByteArray getterString("py_get_"); + // check for a getter slot + PythonQtMemberInfo member = wrapper->classInfo()->member(getterString + attributeName); + if (member._type == PythonQtMemberInfo::Slot) { + return PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, member._slot, nullptr, nullptr, + wrapper->_wrappedPtr); + } + { - static const QByteArray getterString("py_get_"); - // check for a getter slot - PythonQtMemberInfo member = wrapper->classInfo()->member(getterString + attributeName); + static const QByteArray dynamicGetterString("py_dynamic_get_attrib"); + // check for a dynamic getter slot + PythonQtMemberInfo member = wrapper->classInfo()->member(dynamicGetterString); if (member._type == PythonQtMemberInfo::Slot) { - return PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, member._slot, nullptr, nullptr, wrapper->_wrappedPtr); - } - - { - static const QByteArray dynamicGetterString("py_dynamic_get_attrib"); - // check for a dynamic getter slot - PythonQtMemberInfo member = wrapper->classInfo()->member(dynamicGetterString); - if (member._type == PythonQtMemberInfo::Slot) { - PyObject* args = PyTuple_New(1); - Py_INCREF(name); - PyTuple_SET_ITEM(args, 0, name); - PyObject* result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, member._slot, args, nullptr, wrapper->_wrappedPtr); - Py_DECREF(args); - if (result) { - return result; - } else { - // in case of result == NULL, expect that the code as thrown a std::exception - // and clear the Python error: - PyErr_Clear(); - } + PyObject* args = PyTuple_New(1); + Py_INCREF(name); + PyTuple_SET_ITEM(args, 0, name); + PyObject* result = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, member._slot, args, + nullptr, wrapper->_wrappedPtr); + Py_DECREF(args); + if (result) { + return result; + } else { + // in case of result == NULL, expect that the code as thrown a std::exception + // and clear the Python error: + PyErr_Clear(); } } + } - // handle dynamic properties - if (wrapper->_obj) { - QVariant v = wrapper->_obj->property(attributeName); - if (v.isValid()) { - return PythonQtConv::QVariantToPyObject(v); - } + // handle dynamic properties + if (wrapper->_obj) { + QVariant v = wrapper->_obj->property(attributeName); + if (v.isValid()) { + return PythonQtConv::QVariantToPyObject(v); } } - break; + } break; default: // is an invalid type, go on break; @@ -605,14 +596,15 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) // look for a child QObjectList children = wrapper->_obj->children(); for (int i = 0; i < children.count(); i++) { - QObject *child = children.at(i); + QObject* child = children.at(i); if (child->objectName() == attributeName) { return PythonQt::priv()->wrapQObject(child); } } } - QString error = QString(wrapper->classInfo()->className()) + " has no attribute named '" + QString(attributeName) + "'"; + QString error = + QString(wrapper->classInfo()->className()) + " has no attribute named '" + QString(attributeName) + "'"; if (wrapper->_obj) { error += PythonQt::self()->qObjectMissingAttributeCallback(wrapper->_obj, QString(attributeName)); } @@ -621,15 +613,16 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) return nullptr; } -static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObject *value) +static int PythonQtInstanceWrapper_setattro(PyObject* obj, PyObject* name, PyObject* value) { if (PythonQt::self() == nullptr || PythonQt::priv() == nullptr) { - PyErr_SetString(PyExc_AttributeError, "PythonQt is not initialized (or has been finalized); cannot set attributes on this wrapper"); + PyErr_SetString(PyExc_AttributeError, + "PythonQt is not initialized (or has been finalized); cannot set attributes on this wrapper"); return -1; } QString error; - const char *attributeName; - PythonQtInstanceWrapper *wrapper = (PythonQtInstanceWrapper *)obj; + const char* attributeName; + PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)obj; if ((attributeName = PyUnicode_AsUTF8(name)) == nullptr) return -1; @@ -638,7 +631,8 @@ static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObjec if (member._type == PythonQtMemberInfo::Property) { if (!wrapper->_obj) { - error = QString("Trying to set property '") + attributeName + "' on a destroyed " + wrapper->classInfo()->className() + " object"; + error = QString("Trying to set property '") + attributeName + "' on a destroyed " + + wrapper->classInfo()->className() + " object"; PyErr_SetString(PyExc_AttributeError, QStringToPythonConstCharPointer(error)); return -1; } @@ -660,7 +654,8 @@ static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObjec QString methodName = "setProperty('"; methodName += attributeName; methodName += "')"; - profilingCB(PythonQt::Enter, wrapper->_obj->metaObject()->className(), QStringToPythonConstCharPointer(methodName), nullptr); + profilingCB(PythonQt::Enter, wrapper->_obj->metaObject()->className(), + QStringToPythonConstCharPointer(methodName), nullptr); } success = prop.write(wrapper->_obj, v); @@ -672,9 +667,9 @@ static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObjec if (success) { return 0; } else { - error = QString("Property '") + attributeName + "' of type '" + - prop.typeName() + "' does not accept an object of type " - + QString(value->ob_type->tp_name) + " (" + PythonQtConv::PyObjGetRepresentation(value) + ")"; + error = QString("Property '") + attributeName + "' of type '" + prop.typeName() + + "' does not accept an object of type " + QString(value->ob_type->tp_name) + " (" + + PythonQtConv::PyObjGetRepresentation(value) + ")"; } } else { error = QString("Property '") + attributeName + "' of " + obj->ob_type->tp_name + " object is not writable"; @@ -688,9 +683,9 @@ static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObjec } else if (member._type == PythonQtMemberInfo::EnumWrapper) { error = QString("Enum '") + attributeName + "' can not be overwritten on " + obj->ob_type->tp_name + " object"; } else if (member._type == PythonQtMemberInfo::NestedClass) { - error = QString("Nested class '") + attributeName + "' can not be overwritten on " + obj->ob_type->tp_name + " object"; - } - else if (member._type == PythonQtMemberInfo::NotFound) { + error = + QString("Nested class '") + attributeName + "' can not be overwritten on " + obj->ob_type->tp_name + " object"; + } else if (member._type == PythonQtMemberInfo::NotFound) { // check for a setter slot static const QByteArray setterString("py_set_"); PythonQtMemberInfo setter = wrapper->classInfo()->member(setterString + attributeName); @@ -700,7 +695,8 @@ static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObjec PyObject* args = PyTuple_New(1); Py_INCREF(value); PyTuple_SET_ITEM(args, 0, value); - PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, setter._slot, args, nullptr, wrapper->_wrappedPtr, &result); + PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, setter._slot, args, nullptr, + wrapper->_wrappedPtr, &result); Py_DECREF(args); return 0; } @@ -715,7 +711,7 @@ static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObjec return 0; } else { error = QString("Dynamic property '") + attributeName + "' does not accept an object of type " - + QString(value->ob_type->tp_name) + " (" + PythonQtConv::PyObjGetRepresentation(value) + ")"; + + QString(value->ob_type->tp_name) + " (" + PythonQtConv::PyObjGetRepresentation(value) + ")"; PyErr_SetString(PyExc_AttributeError, QStringToPythonConstCharPointer(error)); return -1; } @@ -743,9 +739,10 @@ static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObjec } PyErr_Clear(); // otherwise call the default Python setattro - return PyBaseObject_Type.tp_setattro(obj,name,value); + return PyBaseObject_Type.tp_setattro(obj, name, value); } else { - error = QString("'") + attributeName + "' does not exist on " + obj->ob_type->tp_name + " and creating new attributes on C++ objects is not allowed"; + error = QString("'") + attributeName + "' does not exist on " + obj->ob_type->tp_name + + " and creating new attributes on C++ objects is not allowed"; } } @@ -753,7 +750,8 @@ static int PythonQtInstanceWrapper_setattro(PyObject *obj,PyObject *name,PyObjec return -1; } -static QString getStringFromObject(PythonQtInstanceWrapper* wrapper) { +static QString getStringFromObject(PythonQtInstanceWrapper* wrapper) +{ QString result; if (wrapper->_wrappedPtr) { // first try some manually string conversions for some variants @@ -767,7 +765,8 @@ static QString getStringFromObject(PythonQtInstanceWrapper* wrapper) { // next, try to call py_toString PythonQtMemberInfo info = wrapper->classInfo()->member("py_toString"); if (info._type == PythonQtMemberInfo::Slot) { - PyObject* resultObj = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, info._slot, nullptr, nullptr, wrapper->_wrappedPtr); + PyObject* resultObj = PythonQtSlotFunction_CallImpl(wrapper->classInfo(), wrapper->_obj, info._slot, nullptr, + nullptr, wrapper->_wrappedPtr); if (resultObj) { result = PythonQtConv::PyObjGetString(resultObj); Py_DECREF(resultObj); @@ -777,7 +776,7 @@ static QString getStringFromObject(PythonQtInstanceWrapper* wrapper) { return result; } -static PyObject * PythonQtInstanceWrapper_str(PyObject * obj) +static PyObject* PythonQtInstanceWrapper_str(PyObject* obj) { if (PythonQt::self() == nullptr || PythonQt::priv() == nullptr) { return PyUnicode_New(0, 0); @@ -786,7 +785,7 @@ static PyObject * PythonQtInstanceWrapper_str(PyObject * obj) // QByteArray should be directly returned as a str if (wrapper->classInfo()->metaTypeId() == QMetaType::QByteArray) { - QByteArray* b = (QByteArray*) wrapper->_wrappedPtr; + QByteArray* b = (QByteArray*)wrapper->_wrappedPtr; // Note: In Python 2, this was used to access the data() of a byte array. // Since in Python 3 str() will return a unicode, this is no longer possible. // The user needs to call .data() to get access to the data as bytes. @@ -801,14 +800,15 @@ static PyObject * PythonQtInstanceWrapper_str(PyObject * obj) } const char* typeName = obj->ob_type->tp_name; - QObject *qobj = wrapper->_obj; + QObject* qobj = wrapper->_obj; QString str = getStringFromObject(wrapper); if (!str.isEmpty()) { return PyUnicode_FromFormat("%s", QStringToPythonConstCharPointer(str)); } if (wrapper->_wrappedPtr) { if (wrapper->_obj) { - return PyUnicode_FromFormat("%s (C++ Object %p wrapped by %s %p))", typeName, wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj); + return PyUnicode_FromFormat("%s (C++ Object %p wrapped by %s %p))", typeName, wrapper->_wrappedPtr, + wrapper->_obj->metaObject()->className(), qobj); } else { return PyUnicode_FromFormat("%s (C++ Object %p)", typeName, wrapper->_wrappedPtr); } @@ -817,7 +817,7 @@ static PyObject * PythonQtInstanceWrapper_str(PyObject * obj) } } -static PyObject * PythonQtInstanceWrapper_repr(PyObject * obj) +static PyObject* PythonQtInstanceWrapper_repr(PyObject* obj) { if (PythonQt::self() == nullptr || PythonQt::priv() == nullptr) { return PyUnicode_New(0, 0); @@ -825,18 +825,20 @@ static PyObject * PythonQtInstanceWrapper_repr(PyObject * obj) PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)obj; const char* typeName = obj->ob_type->tp_name; - QObject *qobj = wrapper->_obj; + QObject* qobj = wrapper->_obj; QString str = getStringFromObject(wrapper); if (!str.isEmpty()) { if (str.startsWith(typeName)) { return PyUnicode_FromFormat("%s", QStringToPythonConstCharPointer(str)); } else { - return PyUnicode_FromFormat("%s (%s, at: %p)", typeName, QStringToPythonConstCharPointer(str), wrapper->_wrappedPtr ? wrapper->_wrappedPtr : qobj); + return PyUnicode_FromFormat("%s (%s, at: %p)", typeName, QStringToPythonConstCharPointer(str), + wrapper->_wrappedPtr ? wrapper->_wrappedPtr : qobj); } } if (wrapper->_wrappedPtr) { if (wrapper->_obj) { - return PyUnicode_FromFormat("%s (C++ object at: %p wrapped by %s at: %p)", typeName, wrapper->_wrappedPtr, wrapper->_obj->metaObject()->className(), qobj); + return PyUnicode_FromFormat("%s (C++ object at: %p wrapped by %s at: %p)", typeName, wrapper->_wrappedPtr, + wrapper->_obj->metaObject()->className(), qobj); } else { return PyUnicode_FromFormat("%s (C++ object at: %p)", typeName, wrapper->_wrappedPtr); } @@ -845,14 +847,13 @@ static PyObject * PythonQtInstanceWrapper_repr(PyObject * obj) } } -static int PythonQtInstanceWrapper_builtin_bool(PyObject *obj) +static int PythonQtInstanceWrapper_builtin_bool(PyObject* obj) { PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)obj; - return (wrapper->_wrappedPtr == nullptr && wrapper->_obj == nullptr)?0:1; + return (wrapper->_wrappedPtr == nullptr && wrapper->_obj == nullptr) ? 0 : 1; } - -static long PythonQtInstanceWrapper_hash(PythonQtInstanceWrapper *obj) +static long PythonQtInstanceWrapper_hash(PythonQtInstanceWrapper* obj) { if (obj->_wrappedPtr != nullptr) { return static_cast(reinterpret_cast(obj->_wrappedPtr)); @@ -862,86 +863,83 @@ static long PythonQtInstanceWrapper_hash(PythonQtInstanceWrapper *obj) } } - - // we override nb_nonzero, so that one can do 'if' expressions to test for a NULL ptr static PyNumberMethods PythonQtInstanceWrapper_as_number = { - nullptr, /* nb_add */ - nullptr, /* nb_subtract */ - nullptr, /* nb_multiply */ - nullptr, /* nb_remainder */ - nullptr, /* nb_divmod */ - nullptr, /* nb_power */ - nullptr, /* nb_negative */ - nullptr, /* nb_positive */ - nullptr, /* nb_absolute */ - PythonQtInstanceWrapper_builtin_bool, /* nb_bool */ - nullptr, /* nb_invert */ - nullptr, /* nb_lshift */ - nullptr, /* nb_rshift */ - nullptr, /* nb_and */ - nullptr, /* nb_xor */ - nullptr, /* nb_or */ - nullptr, /* nb_int */ - nullptr, /* nb_reserved */ - nullptr, /* nb_float */ - nullptr, /* nb_inplace_add */ - nullptr, /* nb_inplace_subtract */ - nullptr, /* nb_inplace_multiply */ - nullptr, /* nb_inplace_remainder */ - nullptr, /* nb_inplace_power */ - nullptr, /* nb_inplace_lshift */ - nullptr, /* nb_inplace_rshift */ - nullptr, /* nb_inplace_and */ - nullptr, /* nb_inplace_xor */ - nullptr, /* nb_inplace_or */ - nullptr, /* nb_floor_divide */ - nullptr, /* nb_true_divide */ - nullptr, /* nb_inplace_floor_divide */ - nullptr, /* nb_inplace_true_divide */ - nullptr, /* nb_index */ + nullptr, /* nb_add */ + nullptr, /* nb_subtract */ + nullptr, /* nb_multiply */ + nullptr, /* nb_remainder */ + nullptr, /* nb_divmod */ + nullptr, /* nb_power */ + nullptr, /* nb_negative */ + nullptr, /* nb_positive */ + nullptr, /* nb_absolute */ + PythonQtInstanceWrapper_builtin_bool, /* nb_bool */ + nullptr, /* nb_invert */ + nullptr, /* nb_lshift */ + nullptr, /* nb_rshift */ + nullptr, /* nb_and */ + nullptr, /* nb_xor */ + nullptr, /* nb_or */ + nullptr, /* nb_int */ + nullptr, /* nb_reserved */ + nullptr, /* nb_float */ + nullptr, /* nb_inplace_add */ + nullptr, /* nb_inplace_subtract */ + nullptr, /* nb_inplace_multiply */ + nullptr, /* nb_inplace_remainder */ + nullptr, /* nb_inplace_power */ + nullptr, /* nb_inplace_lshift */ + nullptr, /* nb_inplace_rshift */ + nullptr, /* nb_inplace_and */ + nullptr, /* nb_inplace_xor */ + nullptr, /* nb_inplace_or */ + nullptr, /* nb_floor_divide */ + nullptr, /* nb_true_divide */ + nullptr, /* nb_inplace_floor_divide */ + nullptr, /* nb_inplace_true_divide */ + nullptr, /* nb_index */ }; PyTypeObject PythonQtInstanceWrapper_Type = { - PyVarObject_HEAD_INIT(&PythonQtClassWrapper_Type, 0) /*tp_base*/ - "PythonQt.PythonQtInstanceWrapper", /*tp_name*/ - sizeof(PythonQtInstanceWrapper), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PythonQtInstanceWrapper_dealloc, /*tp_dealloc*/ - 0, /*tp_vectorcall_offset*/ - nullptr, /*tp_getattr*/ - nullptr, /*tp_setattr*/ - nullptr, /*tp_compare*/ - PythonQtInstanceWrapper_repr, /*tp_repr*/ - &PythonQtInstanceWrapper_as_number, /*tp_as_number*/ - nullptr, /*tp_as_sequence*/ - nullptr, /*tp_as_mapping*/ - (hashfunc)PythonQtInstanceWrapper_hash, /*tp_hash */ - nullptr, /*tp_call*/ - PythonQtInstanceWrapper_str, /*tp_str*/ - PythonQtInstanceWrapper_getattro, /*tp_getattro*/ - PythonQtInstanceWrapper_setattro, /*tp_setattro*/ - nullptr, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "PythonQtInstanceWrapper object", /* tp_doc */ - nullptr, /* tp_traverse */ - nullptr, /* tp_clear */ - (richcmpfunc)PythonQtInstanceWrapper_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - nullptr, /* tp_iter */ - nullptr, /* tp_iternext */ - PythonQtInstanceWrapper_methods, /* tp_methods */ - nullptr, /* tp_members */ - nullptr, /* tp_getset */ - nullptr, /* tp_base */ - nullptr, /* tp_dict */ - nullptr, /* tp_descr_get */ - nullptr, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PythonQtInstanceWrapper_init, /* tp_init */ - nullptr, /* tp_alloc */ - PythonQtInstanceWrapper_new, /* tp_new */ + PyVarObject_HEAD_INIT(&PythonQtClassWrapper_Type, 0) /*tp_base*/ + "PythonQt.PythonQtInstanceWrapper", /*tp_name*/ + sizeof(PythonQtInstanceWrapper), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)PythonQtInstanceWrapper_dealloc, /*tp_dealloc*/ + 0, /*tp_vectorcall_offset*/ + nullptr, /*tp_getattr*/ + nullptr, /*tp_setattr*/ + nullptr, /*tp_compare*/ + PythonQtInstanceWrapper_repr, /*tp_repr*/ + &PythonQtInstanceWrapper_as_number, /*tp_as_number*/ + nullptr, /*tp_as_sequence*/ + nullptr, /*tp_as_mapping*/ + (hashfunc)PythonQtInstanceWrapper_hash, /*tp_hash */ + nullptr, /*tp_call*/ + PythonQtInstanceWrapper_str, /*tp_str*/ + PythonQtInstanceWrapper_getattro, /*tp_getattro*/ + PythonQtInstanceWrapper_setattro, /*tp_setattro*/ + nullptr, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + "PythonQtInstanceWrapper object", /* tp_doc */ + nullptr, /* tp_traverse */ + nullptr, /* tp_clear */ + (richcmpfunc)PythonQtInstanceWrapper_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + nullptr, /* tp_iter */ + nullptr, /* tp_iternext */ + PythonQtInstanceWrapper_methods, /* tp_methods */ + nullptr, /* tp_members */ + nullptr, /* tp_getset */ + nullptr, /* tp_base */ + nullptr, /* tp_dict */ + nullptr, /* tp_descr_get */ + nullptr, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)PythonQtInstanceWrapper_init, /* tp_init */ + nullptr, /* tp_alloc */ + PythonQtInstanceWrapper_new, /* tp_new */ }; //------------------------------------------------------- - diff --git a/src/PythonQtInstanceWrapper.h b/src/PythonQtInstanceWrapper.h index 66f2c34aa..c58862131 100644 --- a/src/PythonQtInstanceWrapper.h +++ b/src/PythonQtInstanceWrapper.h @@ -63,20 +63,23 @@ struct PythonQtInstanceWrapper { PyObject_HEAD //! the class information, this is set even if the _obj or _wrappedPtr is NULL to support typed NULL pointers - inline PythonQtClassInfo* classInfo() - { return ((PythonQtClassWrapper*)Py_TYPE(this))->_classInfo; } + inline PythonQtClassInfo* classInfo() { return ((PythonQtClassWrapper*)Py_TYPE(this))->_classInfo; } inline PythonQtDynamicClassInfo* dynamicClassInfo() - { return ((PythonQtClassWrapper*)Py_TYPE(this))->_dynamicClassInfo; } + { + return ((PythonQtClassWrapper*)Py_TYPE(this))->_dynamicClassInfo; + } //! set the QObject pointer - void setQObject(QObject* object) { + void setQObject(QObject* object) + { _obj = object; _objPointerCopy = object; } //! Passes the ownership of the wrapped object to C++ - void passOwnershipToCPP() { + void passOwnershipToCPP() + { // we pass the ownership to C++ _ownedByPythonQt = false; // handle shell instance @@ -91,7 +94,8 @@ struct PythonQtInstanceWrapper { } //! Passes the ownership to Python - void passOwnershipToPython() { + void passOwnershipToPython() + { _ownedByPythonQt = true; // if the shell instance was owned by C++ and the ownership goes to Python, // we need to remove the extra ref count that kept the Python part alive from the C++ side. @@ -101,7 +105,6 @@ struct PythonQtInstanceWrapper { } } - //! pointer to the wrapped Qt object or if _wrappedPtr is set, the Qt object that wraps the C++ Ptr QPointer _obj; //! a copy of the _obj pointer, which is required because the wrapper needs to @@ -109,7 +112,7 @@ struct PythonQtInstanceWrapper { void* _objPointerCopy; //! optional C++ object Ptr that is wrapped by the above _obj - void* _wrappedPtr; + void* _wrappedPtr; // TODO xxx: put booleans into int that holds flags @@ -124,12 +127,10 @@ struct PythonQtInstanceWrapper { //! stores if the shell instance (C++) owns the wrapper with its ref count bool _shellInstanceRefCountsWrapper; - }; -int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper * self, PyObject * args, PyObject * kwds); +int PythonQtInstanceWrapper_init(PythonQtInstanceWrapper* self, PyObject* args, PyObject* kwds); -PyObject *PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper * self); +PyObject* PythonQtInstanceWrapper_delete(PythonQtInstanceWrapper* self); #endif - diff --git a/src/PythonQtMethodInfo.cpp b/src/PythonQtMethodInfo.cpp index 2fb493fcd..828f8044a 100644 --- a/src/PythonQtMethodInfo.cpp +++ b/src/PythonQtMethodInfo.cpp @@ -86,8 +86,9 @@ void PythonQtMethodInfo::setupAllowThreads() { bool allowThreads = true; for (const ParameterInfo& info : qAsConst(_parameters)) { - if (info.name == "PyObject" || info.name == "PythonQtObjectPtr" || - info.innerName == "PyObject" || info.innerName == "PythonQtObjectPtr") { + if (info.name == "PyObject" || info.name == "PythonQtObjectPtr" || info.innerName == "PyObject" + || info.innerName == "PythonQtObjectPtr") + { allowThreads = false; break; } @@ -95,7 +96,8 @@ void PythonQtMethodInfo::setupAllowThreads() _shouldAllowThreads = allowThreads; } -const PythonQtMethodInfo* PythonQtMethodInfo::getCachedMethodInfo(const QMetaMethod& signal, PythonQtClassInfo* classInfo) +const PythonQtMethodInfo* PythonQtMethodInfo::getCachedMethodInfo(const QMetaMethod& signal, + PythonQtClassInfo* classInfo) { QByteArray sig(PythonQtUtils::signature(signal)); sig = sig.mid(sig.indexOf('(')); @@ -114,8 +116,8 @@ const PythonQtMethodInfo* PythonQtMethodInfo::getCachedMethodInfoFromArgumentLis QList arguments; QByteArray fullSig = typeName; fullSig += "("; - for (int i =1;i1) { + for (int i = 1; i < numArgs; i++) { + if (i > 1) { fullSig += ","; } QByteArray arg(args[i]); @@ -143,24 +145,22 @@ void PythonQtMethodInfo::fillParameterInfo(ParameterInfo& type, const QByteArray type.newOwnerOfThis = false; int len = name.length(); - if (len>0) { + if (len > 0) { if (name.startsWith("PythonQtPassOwnershipToCPP<")) { type.passOwnershipToCPP = true; - name = name.mid(27, len-28); + name = name.mid(27, len - 28); len -= 28; - } else - if (name.startsWith("PythonQtPassOwnershipToPython<")) { + } else if (name.startsWith("PythonQtPassOwnershipToPython<")) { type.passOwnershipToPython = true; - name = name.mid(30, len-31); + name = name.mid(30, len - 31); len -= 31; - } else - if (name.startsWith("PythonQtNewOwnerOfThis<")) { + } else if (name.startsWith("PythonQtNewOwnerOfThis<")) { type.newOwnerOfThis = true; - name = name.mid(23, len-24); + name = name.mid(23, len - 24); len -= 24; } - if (strncmp(name.constData(), "const ", 6)==0) { + if (strncmp(name.constData(), "const ", 6) == 0) { name = name.mid(6); len -= 6; type.isConst = true; @@ -170,15 +170,15 @@ void PythonQtMethodInfo::fillParameterInfo(ParameterInfo& type, const QByteArray char pointerCount = 0; bool hadReference = false; // remove * and & from the end of the string - while (name.at(len-1) == '*') { + while (name.at(len - 1) == '*') { len--; pointerCount++; } - while (name.at(len-1) == '&') { + while (name.at(len - 1) == '&') { len--; hadReference = true; } - if (len!=name.length()) { + if (len != name.length()) { name = name.left(len); } type.pointerCount = pointerCount; @@ -192,7 +192,7 @@ void PythonQtMethodInfo::fillParameterInfo(ParameterInfo& type, const QByteArray type.typeId = nameToType(name); if (type.typeId == Unknown) { type.typeId = PythonQtUtils::metaTypeIdFromTypeName(name.constData()); -#if( QT_VERSION >= QT_VERSION_CHECK(5,0,0) ) +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) if (type.typeId == QMetaType::UnknownType) { #else if (type.typeId == QMetaType::Void) { @@ -334,17 +334,17 @@ int PythonQtMethodInfo::nameToType(const char* name) } #ifdef PYTHONQT_SUPPORT_ML_TYPES - _parameterTypeDict.insert("MLuint8", QMetaType::UChar); - _parameterTypeDict.insert("MLint8", QMetaType::Char); + _parameterTypeDict.insert("MLuint8", QMetaType::UChar); + _parameterTypeDict.insert("MLint8", QMetaType::Char); _parameterTypeDict.insert("MLuint16", QMetaType::UShort); - _parameterTypeDict.insert("MLint16", QMetaType::Short); + _parameterTypeDict.insert("MLint16", QMetaType::Short); _parameterTypeDict.insert("MLuint32", QMetaType::UInt); - _parameterTypeDict.insert("MLint32", QMetaType::Int); + _parameterTypeDict.insert("MLint32", QMetaType::Int); _parameterTypeDict.insert("MLuint64", QMetaType::ULongLong); - _parameterTypeDict.insert("MLint64", QMetaType::LongLong); - _parameterTypeDict.insert("MLuint", QMetaType::ULongLong); - _parameterTypeDict.insert("MLint", QMetaType::LongLong); - _parameterTypeDict.insert("MLfloat", QMetaType::Float); + _parameterTypeDict.insert("MLint64", QMetaType::LongLong); + _parameterTypeDict.insert("MLuint", QMetaType::ULongLong); + _parameterTypeDict.insert("MLint", QMetaType::LongLong); + _parameterTypeDict.insert("MLfloat", QMetaType::Float); _parameterTypeDict.insert("MLdouble", QMetaType::Double); #endif @@ -376,7 +376,7 @@ int PythonQtMethodInfo::nameToType(const char* name) _parameterTypeDict.insert("QLineF", QMetaType::QLineF); _parameterTypeDict.insert("QPoint", QMetaType::QPoint); _parameterTypeDict.insert("QPointF", QMetaType::QPointF); -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) _parameterTypeDict.insert("QRegExp", QMetaType::QRegExp); #endif _parameterTypeDict.insert("QRegularExpression", QMetaType::QRegularExpression); @@ -394,7 +394,7 @@ int PythonQtMethodInfo::nameToType(const char* name) _parameterTypeDict.insert("QKeySequence", QMetaType::QKeySequence); _parameterTypeDict.insert("QPen", QMetaType::QPen); _parameterTypeDict.insert("QTextLength", QMetaType::QTextLength); -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) _parameterTypeDict.insert("QMatrix", QMetaType::QMatrix); #endif _parameterTypeDict.insert("QMatrix4x4", QMetaType::QMatrix4x4); @@ -404,7 +404,7 @@ int PythonQtMethodInfo::nameToType(const char* name) // own special types... (none so far, could be e.g. ObjectList } QHash::const_iterator it = _parameterTypeDict.find(name); - if (it!=_parameterTypeDict.end()) { + if (it != _parameterTypeDict.end()) { return it.value(); } else { return PythonQtMethodInfo::Unknown; @@ -413,7 +413,7 @@ int PythonQtMethodInfo::nameToType(const char* name) void PythonQtMethodInfo::cleanupCachedMethodInfos() { - QHashIterator i(_cachedSignatures); + QHashIterator i(_cachedSignatures); while (i.hasNext()) { delete i.next().value(); } @@ -424,8 +424,8 @@ void PythonQtMethodInfo::cleanupCachedMethodInfos() void PythonQtMethodInfo::addParameterTypeAlias(const QByteArray& alias, const QByteArray& name) { #if QT_VERSION >= 0x060000 - QByteArray alias2{ alias }; - QByteArray name2{ name }; + QByteArray alias2 {alias}; + QByteArray name2 {name}; // in Qt6 QPair has been replaced by std::pair, QVector is really QList, and there is no space between ">" alias2.replace("QPair", "std::pair").replace("QVector", "QList").replace("> >", ">>"); name2.replace("QPair", "std::pair").replace("QVector", "QList").replace("> >", ">>"); @@ -452,17 +452,16 @@ const PythonQtMethodInfo::ParameterInfo& PythonQtMethodInfo::getParameterInfoFor void PythonQtSlotInfo::deleteOverloadsAndThis() { PythonQtSlotInfo* cur = this; - while(cur) { + while (cur) { PythonQtSlotInfo* next = cur->nextInfo(); delete cur; cur = next; } } - QString PythonQtSlotInfo::fullSignature(bool skipReturnValue, int optionalArgsIndex) const -{ - int firstArgOffset = isInstanceDecorator()?2:1; +{ + int firstArgOffset = isInstanceDecorator() ? 2 : 1; QString result; QByteArray sig = slotName(); QList names = _meta.parameterNames(); @@ -475,19 +474,17 @@ QString PythonQtSlotInfo::fullSignature(bool skipReturnValue, int optionalArgsIn if (sig.startsWith("new_")) { sig = sig.mid(4); isConstructor = true; - } - else if (sig.startsWith("py_q_")) { + } else if (sig.startsWith("py_q_")) { sig = sig.mid(5); - } - else if (sig.startsWith("delete_")) { + } else if (sig.startsWith("delete_")) { sig = sig.mid(7); isDestructor = true; - } else if(sig.startsWith("static_")) { + } else if (sig.startsWith("static_")) { isStatic = true; sig = sig.mid(7); int idx = sig.indexOf("_"); - if (idx>=0) { - sig = sig.mid(idx+1); + if (idx >= 0) { + sig = sig.mid(idx + 1); } } } @@ -495,11 +492,11 @@ QString PythonQtSlotInfo::fullSignature(bool skipReturnValue, int optionalArgsIn result += sig; result += "("; - for (int i = firstArgOffset; i<_parameters.count(); i++) { + for (int i = firstArgOffset; i < _parameters.count(); i++) { if ((optionalArgsIndex + firstArgOffset) == i) { result += " ["; } - if (i!=firstArgOffset) { + if (i != firstArgOffset) { result += ", "; } //if (_parameters.at(i).isConst) { @@ -515,9 +512,9 @@ QString PythonQtSlotInfo::fullSignature(bool skipReturnValue, int optionalArgsIn // stars.fill('*', _parameters.at(i).pointerCount); // result += stars; //} - if (!names.at(i-1).isEmpty()) { + if (!names.at(i - 1).isEmpty()) { result += " "; - result += names.at(i-1); + result += names.at(i - 1); } } if (optionalArgsIndex != -1) { @@ -527,13 +524,13 @@ QString PythonQtSlotInfo::fullSignature(bool skipReturnValue, int optionalArgsIn if (isStatic) { result = QString("static ") + result; - } + } if (isConstructor) { -// result = QString("constructor ") + result; - } + // result = QString("constructor ") + result; + } if (isDestructor) { result = QString("~") + result; - } + } if (!skipReturnValue) { if (!_parameters.at(0).name.isEmpty()) { @@ -544,19 +541,17 @@ QString PythonQtSlotInfo::fullSignature(bool skipReturnValue, int optionalArgsIn return result; } - QByteArray PythonQtSlotInfo::slotName(bool removeDecorators) const { QByteArray name = PythonQtUtils::methodName(_meta); if (removeDecorators) { if (name.startsWith("py_q_")) { name = name.mid(5); - } else - if (name.startsWith("static_")) { + } else if (name.startsWith("static_")) { name = name.mid(7); int idx = name.indexOf("_"); - if (idx>=0) { - name = name.mid(idx+1); + if (idx >= 0) { + name = name.mid(idx + 1); } } } @@ -602,7 +597,7 @@ QStringList PythonQtSlotInfo::overloads(bool skipReturnValue) const QList otherArguments = other->arguments(); int paramCount = qMin(currentArguments.size(), otherArguments.size()); int sameArgs = 0; - for (int i = 0; i PythonQtSlotInfo::arguments() const { QList result; - for (int i = isInstanceDecorator()?2:1; i<_parameters.size(); i++) { + for (int i = isInstanceDecorator() ? 2 : 1; i < _parameters.size(); i++) { result << _parameters[i]; } return result; diff --git a/src/PythonQtMethodInfo.h b/src/PythonQtMethodInfo.h index db8499044..74de96549 100644 --- a/src/PythonQtMethodInfo.h +++ b/src/PythonQtMethodInfo.h @@ -58,18 +58,15 @@ typedef struct _object PyObject; class PYTHONQT_EXPORT PythonQtMethodInfo { public: - enum ParameterType { - Unknown = -1, - Variant = -2 - }; + enum ParameterType { Unknown = -1, Variant = -2 }; //! stores various informations about a parameter/type name struct ParameterInfo { QByteArray name; - QByteArray innerName; // if the type is a template, this stores the inner name - PyObject* enumWrapper; // if it is an enum, a pointer to the enum wrapper - int typeId; // a mixture from QMetaType and ParameterType - char pointerCount; // the number of pointer indirections + QByteArray innerName; // if the type is a template, this stores the inner name + PyObject* enumWrapper; // if it is an enum, a pointer to the enum wrapper + int typeId; // a mixture from QMetaType and ParameterType + char pointerCount; // the number of pointer indirections char innerNamePointerCount; // the number of pointer indirections in the inner name bool isConst; bool isReference; @@ -79,13 +76,12 @@ class PYTHONQT_EXPORT PythonQtMethodInfo bool newOwnerOfThis; }; - PythonQtMethodInfo() { - _shouldAllowThreads = true; - }; + PythonQtMethodInfo() { _shouldAllowThreads = true; }; ~PythonQtMethodInfo() {}; PythonQtMethodInfo(const QMetaMethod& meta, PythonQtClassInfo* classInfo); PythonQtMethodInfo(const QByteArray& typeName, const QList& args); - PythonQtMethodInfo(const PythonQtMethodInfo& other) { + PythonQtMethodInfo(const PythonQtMethodInfo& other) + { _parameters = other._parameters; _shouldAllowThreads = other._shouldAllowThreads; } @@ -101,7 +97,7 @@ class PYTHONQT_EXPORT PythonQtMethodInfo static void cleanupCachedMethodInfos(); //! returns the number of parameters including the return value - int parameterCount() const { return _parameters.size(); }; + int parameterCount() const { return _parameters.size(); }; //! returns the id for the given type (using an internal dictionary) static int nameToType(const char* name); @@ -145,18 +141,17 @@ class PYTHONQT_EXPORT PythonQtMethodInfo QList _parameters; bool _shouldAllowThreads; - }; //! stores information about a slot, including a next pointer to overloaded slots class PYTHONQT_EXPORT PythonQtSlotInfo : public PythonQtMethodInfo { public: - enum Type { - MemberSlot, InstanceDecorator, ClassDecorator - }; + enum Type { MemberSlot, InstanceDecorator, ClassDecorator }; - PythonQtSlotInfo(const PythonQtSlotInfo& info):PythonQtMethodInfo() { + PythonQtSlotInfo(const PythonQtSlotInfo& info) + : PythonQtMethodInfo() + { _meta = info._meta; _parameters = info._parameters; _shouldAllowThreads = info._shouldAllowThreads; @@ -167,7 +162,9 @@ class PYTHONQT_EXPORT PythonQtSlotInfo : public PythonQtMethodInfo _upcastingOffset = 0; } - PythonQtSlotInfo(PythonQtClassInfo* classInfo, const QMetaMethod& meta, int slotIndex, QObject* decorator = nullptr, Type type = MemberSlot ):PythonQtMethodInfo() + PythonQtSlotInfo(PythonQtClassInfo* classInfo, const QMetaMethod& meta, int slotIndex, QObject* decorator = nullptr, + Type type = MemberSlot) + : PythonQtMethodInfo() { const PythonQtMethodInfo* info = getCachedMethodInfo(meta, classInfo); _meta = meta; @@ -180,7 +177,6 @@ class PYTHONQT_EXPORT PythonQtSlotInfo : public PythonQtMethodInfo _upcastingOffset = 0; } - public: //! get the parameter infos for the arguments, without return type and instance decorator. QList arguments() const; @@ -197,16 +193,16 @@ class PYTHONQT_EXPORT PythonQtSlotInfo : public PythonQtMethodInfo int slotIndex() const { return _slotIndex; } //! get next overloaded slot (which has the same name) - PythonQtSlotInfo* nextInfo() const { return _next; } + PythonQtSlotInfo* nextInfo() const { return _next; } //! set the next overloaded slot void setNextInfo(PythonQtSlotInfo* next) { _next = next; } //! returns if the slot is a decorator slot - bool isInstanceDecorator() const { return _decorator!=nullptr && _type == InstanceDecorator; } + bool isInstanceDecorator() const { return _decorator != nullptr && _type == InstanceDecorator; } //! returns if the slot is a constructor slot - bool isClassDecorator() const { return _decorator!=nullptr && _type == ClassDecorator; } + bool isClassDecorator() const { return _decorator != nullptr && _type == ClassDecorator; } QObject* decorator() const { return _decorator; } @@ -238,15 +234,14 @@ class PYTHONQT_EXPORT PythonQtSlotInfo : public PythonQtMethodInfo static bool getGlobalShouldAllowThreads(); private: - int _slotIndex; + int _slotIndex; PythonQtSlotInfo* _next; - QObject* _decorator; - Type _type; - QMetaMethod _meta; - int _upcastingOffset; + QObject* _decorator; + Type _type; + QMetaMethod _meta; + int _upcastingOffset; static bool _globalShouldAllowThreads; }; - #endif diff --git a/src/PythonQtMisc.cpp b/src/PythonQtMisc.cpp index fdc90871d..ccbadf350 100644 --- a/src/PythonQtMisc.cpp +++ b/src/PythonQtMisc.cpp @@ -56,9 +56,7 @@ PythonQtArgumentFrame::PythonQtArgumentFrame() _podArgs.reserve(PYTHONQT_MAX_ARGUMENT_FRAME_SIZE); } -PythonQtArgumentFrame::~PythonQtArgumentFrame() -{ -} +PythonQtArgumentFrame::~PythonQtArgumentFrame() {} PythonQtArgumentFrame* PythonQtArgumentFrame::newFrame() { @@ -101,7 +99,8 @@ void PythonQtArgumentFrame::reset() QVariant* PythonQtArgumentFrame::nextVariantPtr() { if (_variantArgs.size() >= PYTHONQT_MAX_ARGUMENT_FRAME_SIZE) { - std::cerr << "PYTHONQT_MAX_ARGUMENT_FRAME_SIZE QVariants exceeded, use less complex slots or increase size!" << std::endl; + std::cerr << "PYTHONQT_MAX_ARGUMENT_FRAME_SIZE QVariants exceeded, use less complex slots or increase size!" + << std::endl; } _variantArgs.push_back(QVariant()); return &_variantArgs[_variantArgs.size() - 1]; @@ -110,7 +109,8 @@ QVariant* PythonQtArgumentFrame::nextVariantPtr() quint64* PythonQtArgumentFrame::nextPODPtr() { if (_podArgs.size() >= PYTHONQT_MAX_ARGUMENT_FRAME_SIZE) { - std::cerr << "PYTHONQT_MAX_ARGUMENT_FRAME_SIZE PODs exceeded, use less complex slots or increase size!" << std::endl; + std::cerr << "PYTHONQT_MAX_ARGUMENT_FRAME_SIZE PODs exceeded, use less complex slots or increase size!" + << std::endl; } _podArgs.push_back(0); return &_podArgs[_podArgs.size() - 1]; diff --git a/src/PythonQtMisc.h b/src/PythonQtMisc.h index c13eddee1..5c8a70b00 100644 --- a/src/PythonQtMisc.h +++ b/src/PythonQtMisc.h @@ -49,57 +49,60 @@ #define PYTHONQT_MAX_ARGS 32 #define PythonQtArgumentFrame_ADD_VALUE(store, type, value, ptr) \ -{ type* item = (type*)store->nextPODPtr(); \ - *item = value; \ - ptr = (void*)item; \ -} - -#define PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedPtr,store, type, value, ptr) \ -{ \ - type* item = (type*)(alreadyAllocatedPtr?alreadyAllocatedPtr:store->nextPODPtr()); \ - *item = value; \ - ptr = (void*)item; \ -} + { \ + type* item = (type*)store->nextPODPtr(); \ + *item = value; \ + ptr = (void*)item; \ + } + +#define PythonQtArgumentFrame_ADD_VALUE_IF_NEEDED(alreadyAllocatedPtr, store, type, value, ptr) \ + { \ + type* item = (type*)(alreadyAllocatedPtr ? alreadyAllocatedPtr : store->nextPODPtr()); \ + *item = value; \ + ptr = (void*)item; \ + } #define PythonQtArgumentFrame_ADD_VARIANT_VALUE(store, value, ptr) \ -{ QVariant* item = store->nextVariantPtr(); \ - *item = value; \ - ptr = (void*)item; \ -} + { \ + QVariant* item = store->nextVariantPtr(); \ + *item = value; \ + ptr = (void*)item; \ + } #if QT_VERSION >= 0x060000 -#define PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID(store, id, ptr) \ - PythonQtArgumentFrame_ADD_VARIANT_VALUE(store, QVariant(QMetaType(id)), ptr) + #define PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID(store, id, ptr) \ + PythonQtArgumentFrame_ADD_VARIANT_VALUE(store, QVariant(QMetaType(id)), ptr) #else -#define PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID(store, id, ptr) \ - PythonQtArgumentFrame_ADD_VARIANT_VALUE(store, QVariant::Type(id), ptr) + #define PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID(store, id, ptr) \ + PythonQtArgumentFrame_ADD_VARIANT_VALUE(store, QVariant::Type(id), ptr) #endif -#define PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedPtr,store, value, ptr) \ -{ \ - QVariant* item = (QVariant*)(alreadyAllocatedPtr?alreadyAllocatedPtr:store->nextVariantPtr()); \ - *item = value; \ - ptr = (void*)item; \ -} +#define PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedPtr, store, value, ptr) \ + { \ + QVariant* item = (QVariant*)(alreadyAllocatedPtr ? alreadyAllocatedPtr : store->nextVariantPtr()); \ + *item = value; \ + ptr = (void*)item; \ + } #if QT_VERSION >= 0x060000 -#define PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID_IF_NEEDED(alreadyAllocatedPtr,store, id, ptr) \ - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedPtr,store, QVariant(QMetaType(id)), ptr) + #define PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID_IF_NEEDED(alreadyAllocatedPtr, store, id, ptr) \ + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedPtr, store, QVariant(QMetaType(id)), ptr) #else -#define PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID_IF_NEEDED(alreadyAllocatedPtr,store, id, ptr) \ - PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedPtr,store, QVariant::Type(id), ptr) + #define PythonQtArgumentFrame_ADD_VARIANT_VALUE_BY_ID_IF_NEEDED(alreadyAllocatedPtr, store, id, ptr) \ + PythonQtArgumentFrame_ADD_VARIANT_VALUE_IF_NEEDED(alreadyAllocatedPtr, store, QVariant::Type(id), ptr) #endif //! Stores C++ arguments for a qt_metacall (which are created when converting data from Python to C++) -class PythonQtArgumentFrame { +class PythonQtArgumentFrame +{ public: //! Create a new (empty) frame (which is typically reused from a freelist) @@ -116,13 +119,13 @@ class PythonQtArgumentFrame { //! Get next pointer to a variant QVariant* nextVariantPtr(); //! Get next pointer to a POD. - quint64* nextPODPtr(); + quint64* nextPODPtr(); private: PythonQtArgumentFrame(); ~PythonQtArgumentFrame(); - std::vector _podArgs; + std::vector _podArgs; std::vector _variantArgs; PythonQtArgumentFrame* _freeListNext; diff --git a/src/PythonQtObjectPtr.cpp b/src/PythonQtObjectPtr.cpp index 8a214ec81..66b6ff200 100644 --- a/src/PythonQtObjectPtr.cpp +++ b/src/PythonQtObjectPtr.cpp @@ -40,15 +40,15 @@ //---------------------------------------------------------------------------------- #include - + #ifndef Py_XSETREF // Some Python2, but not the latest one -#define Py_XSETREF(op1, op2) \ - do { \ - auto **op = &(op1); \ - PyObject *tmp = static_cast(*op); \ - *op = (op2); \ - Py_XDECREF(tmp); \ - } while (0) + #define Py_XSETREF(op1, op2) \ + do { \ + auto** op = &(op1); \ + PyObject* tmp = static_cast(*op); \ + *op = (op2); \ + Py_XDECREF(tmp); \ + } while (0) #endif QVariant PythonQtObjectPtr::evalScript(const QString& script, int start) @@ -86,7 +86,6 @@ QVariant PythonQtObjectPtr::getVariable(const QString& name) return PythonQt::self()->getVariable(_object, name); } - QVariant PythonQtObjectPtr::call(const QString& callable, const QVariantList& args, const QVariantMap& kwargs) { return PythonQt::self()->call(_object, callable, args, kwargs); @@ -103,13 +102,15 @@ PythonQtObjectPtr::PythonQtObjectPtr(PyObject* o) _object = o; } -PythonQtObjectPtr::PythonQtObjectPtr(PythonQtSafeObjectPtr &&p) :_object(p.takeObject()) +PythonQtObjectPtr::PythonQtObjectPtr(PythonQtSafeObjectPtr&& p) + : _object(p.takeObject()) { } PythonQtObjectPtr::~PythonQtObjectPtr() { - if (Py_IsInitialized()) Py_XDECREF(_object); + if (Py_IsInitialized()) + Py_XDECREF(_object); } void PythonQtObjectPtr::setNewRef(PyObject* o) @@ -119,7 +120,7 @@ void PythonQtObjectPtr::setNewRef(PyObject* o) } } -bool PythonQtObjectPtr::fromVariant(const QVariant& variant) +bool PythonQtObjectPtr::fromVariant(const QVariant& variant) { if (!variant.isNull()) { PyObject* object = nullptr; @@ -130,11 +131,10 @@ bool PythonQtObjectPtr::fromVariant(const QVariant& variant) } setObject(object); return true; - } - else { + } else { setObject(nullptr); return false; - } + } } QVariant PythonQtObjectPtr::toVariant() @@ -142,8 +142,7 @@ QVariant PythonQtObjectPtr::toVariant() return QVariant::fromValue(PythonQtSafeObjectPtr(*this)); } - -PythonQtObjectPtr & PythonQtObjectPtr::operator=(PythonQtSafeObjectPtr &&p) +PythonQtObjectPtr& PythonQtObjectPtr::operator=(PythonQtSafeObjectPtr&& p) { Py_XSETREF(_object, p.takeObject()); return *this; @@ -172,7 +171,8 @@ PythonQtSafeObjectPtr::~PythonQtSafeObjectPtr() { if (_object) { PYTHONQT_GIL_SCOPE - if (Py_IsInitialized()) Py_DECREF(_object); + if (Py_IsInitialized()) + Py_DECREF(_object); } } @@ -193,7 +193,6 @@ void PythonQtSafeObjectPtr::setObjectUnsafe(PyObject* o) } } - //-------------------------------------------------------------------------- // we do this here to allow toLocalVariant() to create a QVariant diff --git a/src/PythonQtObjectPtr.h b/src/PythonQtObjectPtr.h index 84e6ed70c..71be01f6c 100644 --- a/src/PythonQtObjectPtr.h +++ b/src/PythonQtObjectPtr.h @@ -56,23 +56,30 @@ class PythonQtSafeObjectPtr; class PYTHONQT_EXPORT PythonQtObjectPtr { public: - PythonQtObjectPtr():_object(nullptr) {} + PythonQtObjectPtr() + : _object(nullptr) + { + } - PythonQtObjectPtr(const PythonQtObjectPtr &p) - :_object(nullptr) { + PythonQtObjectPtr(const PythonQtObjectPtr& p) + : _object(nullptr) + { setObject(p.object()); } //! rvalue copy constructor, does not need any incref/decref. - PythonQtObjectPtr(PythonQtObjectPtr &&p) noexcept - :_object(p.takeObject()) { + PythonQtObjectPtr(PythonQtObjectPtr&& p) noexcept + : _object(p.takeObject()) + { } //! rvalue copy constructor, does not need any incref/decref. - PythonQtObjectPtr(PythonQtSafeObjectPtr &&p); + PythonQtObjectPtr(PythonQtSafeObjectPtr&& p); //! If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count. - PythonQtObjectPtr(const QVariant& variant):_object(nullptr) { + PythonQtObjectPtr(const QVariant& variant) + : _object(nullptr) + { fromVariant(variant); } @@ -89,13 +96,15 @@ class PYTHONQT_EXPORT PythonQtObjectPtr //! Returns a PythonQtObjectPtr as a QVariant. Only use this when you know that the variant is only used locally and not stored outside of the current GIL scope. QVariant toLocalVariant(); - PythonQtObjectPtr &operator=(const PythonQtObjectPtr &p) { + PythonQtObjectPtr& operator=(const PythonQtObjectPtr& p) + { setObject(p.object()); return *this; } //! rvalue assignment operator that steals the reference from p - PythonQtObjectPtr &operator=(PythonQtObjectPtr &&p) noexcept { + PythonQtObjectPtr& operator=(PythonQtObjectPtr&& p) noexcept + { if (_object) { setObject(nullptr); } @@ -104,50 +113,40 @@ class PYTHONQT_EXPORT PythonQtObjectPtr } //! rvalue assignment operator that steals the reference from p - PythonQtObjectPtr &operator=(PythonQtSafeObjectPtr &&p); + PythonQtObjectPtr& operator=(PythonQtSafeObjectPtr&& p); - PythonQtObjectPtr &operator=(PyObject* o) { + PythonQtObjectPtr& operator=(PyObject* o) + { setObject(o); return *this; } - - PythonQtObjectPtr &operator=(const QVariant& variant) { + PythonQtObjectPtr& operator=(const QVariant& variant) + { fromVariant(variant); return *this; } + bool operator==(const PythonQtObjectPtr& p) const { return object() == p.object(); } - bool operator==( const PythonQtObjectPtr &p ) const { - return object() == p.object(); - } - - bool operator!= ( const PythonQtObjectPtr& p ) const { - return !( *this == p ); - } + bool operator!=(const PythonQtObjectPtr& p) const { return !(*this == p); } - bool operator==( PyObject* p ) const { - return object() == p; - } + bool operator==(PyObject* p) const { return object() == p; } - bool operator!= ( PyObject* p ) const { - return object() != p; - } + bool operator!=(PyObject* p) const { return object() != p; } bool isNull() const { return !object(); } PyObject* operator->() const { return object(); } - PyObject& operator*() const { return *( object() ); } + PyObject& operator*() const { return *(object()); } operator PyObject*() const { return object(); } //! sets the object and passes the ownership (stealing the reference, in Python slang) void setNewRef(PyObject* o); - PyObject* object() const { - return _object; - } + PyObject* object() const { return _object; } //! evaluates the given script code in the context of this object and returns the result value QVariant evalScript(const QString& script, int start = Py_file_input); @@ -172,14 +171,16 @@ class PYTHONQT_EXPORT PythonQtObjectPtr QVariant getVariable(const QString& name); //! call the given python object (in the scope of the current object), returns the result converted to a QVariant - QVariant call(const QString& callable, const QVariantList& args = QVariantList(), const QVariantMap& kwargs = QVariantMap()); + QVariant call(const QString& callable, const QVariantList& args = QVariantList(), + const QVariantMap& kwargs = QVariantMap()); //! call the contained python object directly, returns the result converted to a QVariant QVariant call(const QVariantList& args = QVariantList(), const QVariantMap& kwargs = QVariantMap()); //! takes the object from the pointer, leaving the pointer empty. //! the caller has to take care about the decref of the taken object! - PyObject* takeObject() { + PyObject* takeObject() + { PyObject* o = _object; _object = nullptr; return o; @@ -197,45 +198,55 @@ class PYTHONQT_EXPORT PythonQtObjectPtr class PYTHONQT_EXPORT PythonQtSafeObjectPtr { public: - PythonQtSafeObjectPtr() :_object(nullptr) {} + PythonQtSafeObjectPtr() + : _object(nullptr) + { + } - PythonQtSafeObjectPtr(const PythonQtSafeObjectPtr &p) - :_object(nullptr) { + PythonQtSafeObjectPtr(const PythonQtSafeObjectPtr& p) + : _object(nullptr) + { setObject(p.object()); } - PythonQtSafeObjectPtr(const PythonQtObjectPtr &p) - :_object(nullptr) { + PythonQtSafeObjectPtr(const PythonQtObjectPtr& p) + : _object(nullptr) + { setObject(p.object()); } //! rvalue copy constructor, does not need any incref/decref. - PythonQtSafeObjectPtr(PythonQtSafeObjectPtr &&p) noexcept - :_object(p._object) { + PythonQtSafeObjectPtr(PythonQtSafeObjectPtr&& p) noexcept + : _object(p._object) + { p._object = nullptr; } //! rvalue copy constructor, does not need any incref/decref. - PythonQtSafeObjectPtr(PythonQtObjectPtr &&p) - :_object(p.takeObject()) { + PythonQtSafeObjectPtr(PythonQtObjectPtr&& p) + : _object(p.takeObject()) + { } PythonQtSafeObjectPtr(PyObject* o); ~PythonQtSafeObjectPtr(); - PythonQtSafeObjectPtr &operator=(const PythonQtSafeObjectPtr &p) { + PythonQtSafeObjectPtr& operator=(const PythonQtSafeObjectPtr& p) + { setObject(p.object()); return *this; } - PythonQtSafeObjectPtr &operator=(const PythonQtObjectPtr &p) { + PythonQtSafeObjectPtr& operator=(const PythonQtObjectPtr& p) + { setObjectUnsafe(p.object()); return *this; } //! rvalue assignment operator that steals the reference from p - PythonQtSafeObjectPtr &operator=(PythonQtSafeObjectPtr &&p) noexcept { + PythonQtSafeObjectPtr& operator=(PythonQtSafeObjectPtr&& p) noexcept + { if (_object) { setObject(nullptr); } @@ -245,7 +256,8 @@ class PYTHONQT_EXPORT PythonQtSafeObjectPtr } //! rvalue assignment operator that steals the reference from p - PythonQtSafeObjectPtr &operator=(PythonQtObjectPtr &&p) { + PythonQtSafeObjectPtr& operator=(PythonQtObjectPtr&& p) + { if (_object) { setObjectUnsafe(nullptr); } @@ -253,26 +265,19 @@ class PYTHONQT_EXPORT PythonQtSafeObjectPtr return *this; } - PythonQtSafeObjectPtr &operator=(PyObject* o) { + PythonQtSafeObjectPtr& operator=(PyObject* o) + { setObject(o); return *this; } - bool operator==(const PythonQtSafeObjectPtr &p) const { - return object() == p.object(); - } + bool operator==(const PythonQtSafeObjectPtr& p) const { return object() == p.object(); } - bool operator!= (const PythonQtSafeObjectPtr& p) const { - return !(*this == p); - } + bool operator!=(const PythonQtSafeObjectPtr& p) const { return !(*this == p); } - bool operator==(PyObject* p) const { - return object() == p; - } + bool operator==(PyObject* p) const { return object() == p; } - bool operator!= (PyObject* p) const { - return object() != p; - } + bool operator!=(PyObject* p) const { return object() != p; } bool isNull() const { return !object(); } @@ -282,13 +287,12 @@ class PYTHONQT_EXPORT PythonQtSafeObjectPtr operator PyObject*() const { return object(); } - PyObject* object() const { - return _object; - } + PyObject* object() const { return _object; } //! takes the object from the pointer, leaving the pointer empty. //! the caller has to take care about the decref of the taken object! - PyObject* takeObject() { + PyObject* takeObject() + { PyObject* o = _object; _object = nullptr; return o; @@ -310,4 +314,3 @@ class PYTHONQT_EXPORT PythonQtSafeObjectPtr Q_DECLARE_METATYPE(PythonQtSafeObjectPtr) #endif - diff --git a/src/PythonQtProperty.cpp b/src/PythonQtProperty.cpp index 6c3ea198b..87d7cc9ae 100644 --- a/src/PythonQtProperty.cpp +++ b/src/PythonQtProperty.cpp @@ -34,30 +34,20 @@ #include "PythonQtSignal.h" #include "PythonQtConversion.h" -int PythonQtProperty_init(PyObject *object, PyObject *args, PyObject *kw) +int PythonQtProperty_init(PyObject* object, PyObject* args, PyObject* kw) { PythonQtProperty* self = (PythonQtProperty*)object; self->data = new PythonQtPropertyData(); PythonQtPropertyData* data = self->data; PyObject* type = nullptr; - static const char *kwlist[] = - { - "type", - "fget", "fset", "freset", "fdel", - "doc", - "designable", "scriptable", "stored", "user", "constant", "final", - "notify", - nullptr - }; + static const char* kwlist[] = {"type", "fget", "fset", "freset", "fdel", "doc", "designable", "scriptable", "stored", + "user", "constant", "final", "notify", nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, kw, - "O|OOOOObbbbbbO!:QtCore.QProperty", (char**)kwlist, - &type, - &(data->fget), &(data->fset), &(data->freset), &(data->fdel), - &(data->doc), - &(data->designable), &(data->scriptable), &(data->stored), &(data->user), &(data->constant), &(data->final), - &PythonQtSignalFunction_Type, &(data->notify))) + if (!PyArg_ParseTupleAndKeywords(args, kw, "O|OOOOObbbbbbO!:QtCore.QProperty", (char**)kwlist, &type, &(data->fget), + &(data->fset), &(data->freset), &(data->fdel), &(data->doc), &(data->designable), &(data->scriptable), + &(data->stored), &(data->user), &(data->constant), &(data->final), &PythonQtSignalFunction_Type, + &(data->notify))) { return 0; } @@ -155,7 +145,7 @@ PyObject* PythonQtProperty_call(PyObject* object, PyObject* args, PyObject* kw) { Q_UNUSED(kw) if (PyTuple_Size(args) == 1) { - PyObject *func = PyTuple_GetItem(args, 0); + PyObject* func = PyTuple_GetItem(args, 0); return PythonQtProperty_getter(object, func); } else { PyErr_SetString(PyExc_TypeError, "Property expects a single callable."); @@ -164,15 +154,14 @@ PyObject* PythonQtProperty_call(PyObject* object, PyObject* args, PyObject* kw) } static PyMethodDef PythonQtProperty_methods[] = { - { "setter", (PyCFunction)PythonQtProperty_setter, METH_O, "Sets the fset function." }, - { "getter", (PyCFunction)PythonQtProperty_getter, METH_O, "Sets the fget function." }, - { "write", (PyCFunction)PythonQtProperty_setter, METH_O, "Sets the fset function." }, - { "read", (PyCFunction)PythonQtProperty_getter, METH_O, "Sets the fget function." }, - { nullptr, nullptr, 0, nullptr } /* Sentinel */ + {"setter", (PyCFunction)PythonQtProperty_setter, METH_O, "Sets the fset function."}, + {"getter", (PyCFunction)PythonQtProperty_getter, METH_O, "Sets the fget function."}, + {"write", (PyCFunction)PythonQtProperty_setter, METH_O, "Sets the fset function."}, + {"read", (PyCFunction)PythonQtProperty_getter, METH_O, "Sets the fget function."}, + {nullptr, nullptr, 0, nullptr} /* Sentinel */ }; - -static PyObject *PythonQtProperty_get_doc(PythonQtProperty* self, void * /*closure*/) +static PyObject* PythonQtProperty_get_doc(PythonQtProperty* self, void* /*closure*/) { if (self->data->doc) { Py_INCREF(self->data->doc); @@ -184,62 +173,61 @@ static PyObject *PythonQtProperty_get_doc(PythonQtProperty* self, void * /*closu } static PyGetSetDef PythonQtProperty_getsets[] = { - { const_cast("__doc__"), (getter)PythonQtProperty_get_doc, nullptr, nullptr }, - { nullptr, nullptr, nullptr,nullptr }, + {const_cast("__doc__"), (getter)PythonQtProperty_get_doc, nullptr, nullptr}, + {nullptr, nullptr, nullptr, nullptr}, }; -PyDoc_STRVAR(PythonQtProperty_doc, - "Property(type, fget=None, fset=None, freset=None, fdel=None, doc=None,\n" - " designable=True, scriptable=True, stored=True, user=False,\n" - " constant=False, final=False, notify=None) -> Property\n"); +PyDoc_STRVAR(PythonQtProperty_doc, "Property(type, fget=None, fset=None, freset=None, fdel=None, doc=None,\n" + " designable=True, scriptable=True, stored=True, user=False,\n" + " constant=False, final=False, notify=None) -> Property\n"); PyTypeObject PythonQtProperty_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) /*tp_base*/ - "PythonQt.QtCore.Property", /*tp_name*/ - sizeof(PythonQtProperty), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - PythonQtProperty_dealloc, /*tp_dealloc*/ - 0, /*tp_vectorcall_offset*/ - nullptr, /*tp_getattr*/ - nullptr, /*tp_setattr*/ - nullptr, /*tp_compare*/ - nullptr, /*tp_repr*/ - nullptr, /*tp_as_number*/ - nullptr, /*tp_as_sequence*/ - nullptr, /*tp_as_mapping*/ - nullptr, /*tp_hash */ - PythonQtProperty_call, /*tp_call*/ - nullptr, /*tp_str*/ - nullptr, /*tp_getattro*/ - nullptr, /*tp_setattro*/ - nullptr, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - PythonQtProperty_doc, /*tp_doc */ - nullptr, /*tp_traverse */ - nullptr, /*tp_clear */ - nullptr, /*tp_richcompare */ - 0, /*tp_weaklistoffset */ - nullptr, /*tp_iter */ - nullptr, /*tp_iternext */ - PythonQtProperty_methods, /*tp_methods */ - nullptr, /*tp_members */ - PythonQtProperty_getsets, /*tp_getset */ - nullptr, /*tp_base */ - nullptr, /*tp_dict */ - nullptr, /*tp_descr_get */ - nullptr, /*tp_descr_set */ - 0, /*tp_dictoffset */ - PythonQtProperty_init, /*tp_init */ - nullptr, /*tp_alloc */ - PyType_GenericNew, /*tp_new */ - nullptr, /*tp_free */ - nullptr, /*tp_is_gc */ - nullptr, /*tp_bases */ - nullptr, /*tp_mro */ - nullptr, /*tp_cache */ - nullptr, /*tp_subclasses */ - nullptr, /*tp_weaklist */ - nullptr, /*tp_del */ + PyVarObject_HEAD_INIT(&PyType_Type, 0) /*tp_base*/ + "PythonQt.QtCore.Property", /*tp_name*/ + sizeof(PythonQtProperty), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + PythonQtProperty_dealloc, /*tp_dealloc*/ + 0, /*tp_vectorcall_offset*/ + nullptr, /*tp_getattr*/ + nullptr, /*tp_setattr*/ + nullptr, /*tp_compare*/ + nullptr, /*tp_repr*/ + nullptr, /*tp_as_number*/ + nullptr, /*tp_as_sequence*/ + nullptr, /*tp_as_mapping*/ + nullptr, /*tp_hash */ + PythonQtProperty_call, /*tp_call*/ + nullptr, /*tp_str*/ + nullptr, /*tp_getattro*/ + nullptr, /*tp_setattro*/ + nullptr, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + PythonQtProperty_doc, /*tp_doc */ + nullptr, /*tp_traverse */ + nullptr, /*tp_clear */ + nullptr, /*tp_richcompare */ + 0, /*tp_weaklistoffset */ + nullptr, /*tp_iter */ + nullptr, /*tp_iternext */ + PythonQtProperty_methods, /*tp_methods */ + nullptr, /*tp_members */ + PythonQtProperty_getsets, /*tp_getset */ + nullptr, /*tp_base */ + nullptr, /*tp_dict */ + nullptr, /*tp_descr_get */ + nullptr, /*tp_descr_set */ + 0, /*tp_dictoffset */ + PythonQtProperty_init, /*tp_init */ + nullptr, /*tp_alloc */ + PyType_GenericNew, /*tp_new */ + nullptr, /*tp_free */ + nullptr, /*tp_is_gc */ + nullptr, /*tp_bases */ + nullptr, /*tp_mro */ + nullptr, /*tp_cache */ + nullptr, /*tp_subclasses */ + nullptr, /*tp_weaklist */ + nullptr, /*tp_del */ }; bool PythonQtPropertyData::callSetter(PyObject* wrapper, PyObject* newValue) @@ -288,7 +276,7 @@ bool PythonQtPropertyData::callReset(PyObject* wrapper) bool ok = (result != nullptr); Py_XDECREF(result); Py_DECREF(pyargs); - return ok; + return ok; } else { PyErr_Format(PyExc_TypeError, "Property is not resettable."); return false; diff --git a/src/PythonQtProperty.h b/src/PythonQtProperty.h index ef4d6a3cb..370b52a61 100644 --- a/src/PythonQtProperty.h +++ b/src/PythonQtProperty.h @@ -43,9 +43,9 @@ extern PYTHONQT_EXPORT PyTypeObject PythonQtProperty_Type; #define PythonQtProperty_Check(op) (Py_TYPE(op) == &PythonQtProperty_Type) -struct PythonQtPropertyData -{ - PythonQtPropertyData() { +struct PythonQtPropertyData { + PythonQtPropertyData() + { fget = nullptr; fset = nullptr; fdel = nullptr; diff --git a/src/PythonQtPythonInclude.h b/src/PythonQtPythonInclude.h index d1bdf9617..b88f51b26 100644 --- a/src/PythonQtPythonInclude.h +++ b/src/PythonQtPythonInclude.h @@ -35,34 +35,34 @@ // Undefine macros that features.h defines to avoid redefinition warning #ifdef _POSIX_C_SOURCE -# undef _POSIX_C_SOURCE + #undef _POSIX_C_SOURCE #endif #ifdef _XOPEN_SOURCE -# undef _XOPEN_SOURCE + #undef _XOPEN_SOURCE #endif // Undefine Qt keywords that conflict with Python headers #ifdef slots -#undef slots -#define PYTHONQT_RESTORE_KEYWORDS + #undef slots + #define PYTHONQT_RESTORE_KEYWORDS #endif //From https://github.com/boostorg/python/pull/253 // Python.h defines a macro with hypot name, what breaks libstdc++ math header // that it tries to include afterwards. -# if defined(__MINGW32__) -# include -# include -# endif +#if defined(__MINGW32__) + #include + #include +#endif -// -// Use the real python debugging library if it is provided. +// +// Use the real python debugging library if it is provided. // Otherwise use the "documented" trick involving checking for _DEBUG // and undefined that symbol while we include Python headers. // Update: this method does not fool Microsoft Visual C++ 8 anymore; two // of its header files (crtdefs.h and use_ansi.h) check if _DEBUG was set -// or not, and set flags accordingly (_CRT_MANIFEST_RETAIL, +// or not, and set flags accordingly (_CRT_MANIFEST_RETAIL, // _CRT_MANIFEST_DEBUG, _CRT_MANIFEST_INCONSISTENT). The next time the // check is performed in the same compilation unit, and the flags are found, // and error is triggered. Let's prevent that by setting _CRT_NOFORCE_MANIFEST. @@ -72,60 +72,60 @@ // release Python DLL if it is available by undefining _DEBUG while // including Python.h #if defined(PYTHONQT_USE_RELEASE_PYTHON_FALLBACK) && defined(_DEBUG) -# define PYTHONQT_UNDEF_DEBUG -// Include these low level headers before undefing _DEBUG. Otherwise when doing -// a debug build against a release build of python the compiler will end up -// including these low level headers without DEBUG enabled, causing it to try -// and link release versions of this low level C api. -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# undef _DEBUG -# if defined(_MSC_VER) && _MSC_VER >= 1400 -# define _CRT_NOFORCE_MANIFEST 1 -# define _STL_NOFORCE_MANIFEST 1 -# endif + #define PYTHONQT_UNDEF_DEBUG + // Include these low level headers before undefing _DEBUG. Otherwise when doing + // a debug build against a release build of python the compiler will end up + // including these low level headers without DEBUG enabled, causing it to try + // and link release versions of this low level C api. + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #undef _DEBUG + #if defined(_MSC_VER) && _MSC_VER >= 1400 + #define _CRT_NOFORCE_MANIFEST 1 + #define _STL_NOFORCE_MANIFEST 1 + #endif #endif #include #ifdef PYTHONQT_UNDEF_DEBUG -# define _DEBUG + #define _DEBUG #endif // By including Python.h on Linux truncate could have been defined (in unistd.h) // which would lead to compiler errors. Therefore: #ifdef truncate -# undef truncate + #undef truncate #endif // get Qt keywords back #ifdef PYTHONQT_RESTORE_KEYWORDS -#define slots Q_SLOTS -#undef PYTHONQT_RESTORE_KEYWORDS + #define slots Q_SLOTS + #undef PYTHONQT_RESTORE_KEYWORDS #endif #if PY_MAJOR_VERSION < 3 -#error "PythonQt requires Python >= 3.x" + #error "PythonQt requires Python >= 3.x" #endif // Optional compatibility shim for legacy wrappers generated by older PythonQt. // Enable by defining PYTHONQT_USE_PYSTRING_SHIM (deprecated). #if defined(PYTHONQT_USE_PYSTRING_SHIM) -#define PY3K -#define PyString_FromString PyUnicode_FromString + #define PY3K + #define PyString_FromString PyUnicode_FromString #endif // Avoid clashes with libstdc++ by undefining ctype macros @@ -133,14 +133,13 @@ // (_PY_PORT_CTYPE_UTF8_ISSUE is defined by CPython’s pyport.h; we apply these // undefs only in C++ builds.) #if defined(_PY_PORT_CTYPE_UTF8_ISSUE) && defined(__cplusplus) -#undef isalnum -#undef isalpha -#undef islower -#undef isspace -#undef isupper -#undef tolower -#undef toupper + #undef isalnum + #undef isalpha + #undef islower + #undef isspace + #undef isupper + #undef tolower + #undef toupper #endif #endif - diff --git a/src/PythonQtQFileImporter.cpp b/src/PythonQtQFileImporter.cpp index 548e4b885..39c773739 100644 --- a/src/PythonQtQFileImporter.cpp +++ b/src/PythonQtQFileImporter.cpp @@ -44,13 +44,12 @@ #include "PythonQtQFileImporter.h" -PythonQtQFileImporter::PythonQtQFileImporter() { -} +PythonQtQFileImporter::PythonQtQFileImporter() {} -PythonQtQFileImporter::~PythonQtQFileImporter() { -} +PythonQtQFileImporter::~PythonQtQFileImporter() {} -QByteArray PythonQtQFileImporter::readFileAsBytes (const QString &filename) { +QByteArray PythonQtQFileImporter::readFileAsBytes(const QString& filename) +{ QFile f(filename); if (f.open(QIODevice::ReadOnly)) { return f.readAll(); @@ -59,7 +58,8 @@ QByteArray PythonQtQFileImporter::readFileAsBytes (const QString &filename) { } } -QByteArray PythonQtQFileImporter::readSourceFile (const QString &filename, bool &ok) { +QByteArray PythonQtQFileImporter::readSourceFile(const QString& filename, bool& ok) +{ QFile f(filename); if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { ok = true; @@ -70,15 +70,18 @@ QByteArray PythonQtQFileImporter::readSourceFile (const QString &filename, bool } } -bool PythonQtQFileImporter::exists (const QString &filename) { +bool PythonQtQFileImporter::exists(const QString& filename) +{ return QFile::exists(filename); } -bool PythonQtQFileImporter::isEggArchive(const QString& filename) { +bool PythonQtQFileImporter::isEggArchive(const QString& filename) +{ return filename.toLower().endsWith(".egg") && !QFileInfo(filename).isDir(); } -QDateTime PythonQtQFileImporter::lastModifiedDate (const QString &filename) { +QDateTime PythonQtQFileImporter::lastModifiedDate(const QString& filename) +{ QFileInfo fi(filename); return fi.lastModified(); } diff --git a/src/PythonQtQFileImporter.h b/src/PythonQtQFileImporter.h index 2510b12b1..b44dbbd8e 100644 --- a/src/PythonQtQFileImporter.h +++ b/src/PythonQtQFileImporter.h @@ -46,20 +46,20 @@ #include "PythonQtImportFileInterface.h" //! default importer implementation using QFile to load python code -class PythonQtQFileImporter : public PythonQtImportFileInterface { +class PythonQtQFileImporter : public PythonQtImportFileInterface +{ public: - PythonQtQFileImporter(); - ~PythonQtQFileImporter() override; + PythonQtQFileImporter(); + ~PythonQtQFileImporter() override; - QByteArray readFileAsBytes (const QString &filename) override; + QByteArray readFileAsBytes(const QString& filename) override; - QByteArray readSourceFile (const QString &filename, bool &ok) override; + QByteArray readSourceFile(const QString& filename, bool& ok) override; - bool exists (const QString &filename) override; - bool isEggArchive(const QString& filename) override; - - QDateTime lastModifiedDate (const QString &filename) override; + bool exists(const QString& filename) override; + bool isEggArchive(const QString& filename) override; + QDateTime lastModifiedDate(const QString& filename) override; }; #endif diff --git a/src/PythonQtSignal.cpp b/src/PythonQtSignal.cpp index 7b9bba135..402b47338 100644 --- a/src/PythonQtSignal.cpp +++ b/src/PythonQtSignal.cpp @@ -56,15 +56,15 @@ //----------------------------------------------------------------------------------- -static PythonQtSignalFunctionObject *PythonQtSignal_free_list = nullptr; +static PythonQtSignalFunctionObject* PythonQtSignal_free_list = nullptr; -PyObject *PythonQtSignalFunction_Call(PyObject *func, PyObject *args, PyObject *kw) +PyObject* PythonQtSignalFunction_Call(PyObject* func, PyObject* args, PyObject* kw) { PythonQtSignalFunctionObject* f = (PythonQtSignalFunctionObject*)func; return PythonQtMemberFunction_Call(f->m_ml, f->m_self, args, kw); } -PyObject *PythonQtSignalFunction_tpNew(PyTypeObject *subtype, PyObject *args, PyObject *kwds) +PyObject* PythonQtSignalFunction_tpNew(PyTypeObject* subtype, PyObject* args, PyObject* kwds) { Q_UNUSED(subtype) Q_UNUSED(args) @@ -72,16 +72,14 @@ PyObject *PythonQtSignalFunction_tpNew(PyTypeObject *subtype, PyObject *args, Py return PythonQtSignalFunction_New(nullptr, nullptr, nullptr); } -PyObject * -PythonQtSignalFunction_New(PythonQtSlotInfo *ml, PyObject *self, PyObject *module) +PyObject* PythonQtSignalFunction_New(PythonQtSlotInfo* ml, PyObject* self, PyObject* module) { - PythonQtSignalFunctionObject *op; + PythonQtSignalFunctionObject* op; op = PythonQtSignal_free_list; if (op != nullptr) { - PythonQtSignal_free_list = (PythonQtSignalFunctionObject *)(op->m_self); + PythonQtSignal_free_list = (PythonQtSignalFunctionObject*)(op->m_self); PyObject_INIT(op, &PythonQtSignalFunction_Type); - } - else { + } else { op = PyObject_GC_New(PythonQtSignalFunctionObject, &PythonQtSignalFunction_Type); if (op == nullptr) return nullptr; @@ -93,13 +91,12 @@ PythonQtSignalFunction_New(PythonQtSlotInfo *ml, PyObject *self, PyObject *modul Py_XINCREF(module); op->m_module = module; PyObject_GC_Track(op); - return (PyObject *)op; + return (PyObject*)op; } /* Methods (the standard built-in methods, that is) */ -static void -meth_dealloc(PyObject *o) +static void meth_dealloc(PyObject* o) { PyObject_GC_UnTrack(o); auto m = reinterpret_cast(o); @@ -109,18 +106,16 @@ meth_dealloc(PyObject *o) } Py_XDECREF(m->m_self); Py_XDECREF(m->m_module); - m->m_self = (PyObject *)PythonQtSignal_free_list; + m->m_self = (PyObject*)PythonQtSignal_free_list; PythonQtSignal_free_list = m; } -static PyObject * -meth_get__doc__(PythonQtSignalFunctionObject * /*m*/, void * /*closure*/) +static PyObject* meth_get__doc__(PythonQtSignalFunctionObject* /*m*/, void* /*closure*/) { Py_RETURN_NONE; } -static PyObject * -meth_get__name__(PythonQtSignalFunctionObject *m, void * /*closure*/) +static PyObject* meth_get__name__(PythonQtSignalFunctionObject* m, void* /*closure*/) { if (m->m_ml) { return PyUnicode_FromString(m->m_ml->signature()); @@ -129,8 +124,7 @@ meth_get__name__(PythonQtSignalFunctionObject *m, void * /*closure*/) } } -static int -meth_traverse(PythonQtSignalFunctionObject *m, visitproc visit, void *arg) +static int meth_traverse(PythonQtSignalFunctionObject* m, visitproc visit, void* arg) { int err; if (m->m_self != nullptr) { @@ -146,10 +140,9 @@ meth_traverse(PythonQtSignalFunctionObject *m, visitproc visit, void *arg) return 0; } -static PyObject * -meth_get__self__(PythonQtSignalFunctionObject *m, void * /*closure*/) +static PyObject* meth_get__self__(PythonQtSignalFunctionObject* m, void* /*closure*/) { - PyObject *self; + PyObject* self; self = m->m_self; if (self == nullptr) self = Py_None; @@ -157,34 +150,32 @@ meth_get__self__(PythonQtSignalFunctionObject *m, void * /*closure*/) return self; } -static PyGetSetDef meth_getsets [] = { - {const_cast("__doc__"), (getter)meth_get__doc__, nullptr, nullptr}, +static PyGetSetDef meth_getsets[] = { + {const_cast("__doc__"), (getter)meth_get__doc__, nullptr, nullptr}, {const_cast("__name__"), (getter)meth_get__name__, nullptr, nullptr}, {const_cast("__self__"), (getter)meth_get__self__, nullptr, nullptr}, - {nullptr, nullptr, nullptr,nullptr}, + {nullptr, nullptr, nullptr, nullptr}, }; #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 6 -#define PY_WRITE_RESTRICTED WRITE_RESTRICTED + #define PY_WRITE_RESTRICTED WRITE_RESTRICTED #endif #define OFF(x) offsetof(PythonQtSignalFunctionObject, x) -static PyMemberDef meth_members[] = { - {const_cast("__module__"), T_OBJECT, OFF(m_module), PY_WRITE_RESTRICTED}, - {nullptr} -}; +static PyMemberDef meth_members[] = {{const_cast("__module__"), T_OBJECT, OFF(m_module), PY_WRITE_RESTRICTED}, + {nullptr}}; -int PythonQtSignalFunction_init(PyObject *object, PyObject *args, PyObject *kw) +int PythonQtSignalFunction_init(PyObject* object, PyObject* args, PyObject* kw) { Q_UNUSED(kw) PythonQtSignalFunctionObject* self = (PythonQtSignalFunctionObject*)object; self->_dynamicInfo = new PythonQtDynamicSignalInfo(); - + QList argList; Py_ssize_t argc = PyTuple_Size(args); for (Py_ssize_t i = 0; i < argc; i++) { - PyObject *argType = PyTuple_GET_ITEM(args, i); + PyObject* argType = PyTuple_GET_ITEM(args, i); if (!PythonQtConv::isStringType(argType->ob_type) && PySequence_Check(argType)) { // it is not a string and a sequence, so it defines an overload int count = PySequence_Size(argType); @@ -203,7 +194,7 @@ int PythonQtSignalFunction_init(PyObject *object, PyObject *args, PyObject *kw) } Py_XDECREF(value); } - self->_dynamicInfo->signatures << localArgList.join(","); + self->_dynamicInfo->signatures << localArgList.join(","); } } else { // normal signature (not given as overload sequences) @@ -227,31 +218,32 @@ int PythonQtSignalFunction_init(PyObject *object, PyObject *args, PyObject *kw) return 1; } -static PyObject *PythonQtSignalFunction_parameterTypes(PythonQtSignalFunctionObject* type) +static PyObject* PythonQtSignalFunction_parameterTypes(PythonQtSignalFunctionObject* type) { return PythonQtMemberFunction_parameterTypes(type->m_ml); } -static PyObject *PythonQtSignalFunction_parameterNames(PythonQtSignalFunctionObject* type) +static PyObject* PythonQtSignalFunction_parameterNames(PythonQtSignalFunctionObject* type) { return PythonQtMemberFunction_parameterNames(type->m_ml); } -static PyObject *PythonQtSignalFunction_typeName(PythonQtSignalFunctionObject* type) +static PyObject* PythonQtSignalFunction_typeName(PythonQtSignalFunctionObject* type) { return PythonQtMemberFunction_typeName(type->m_ml); } -static PyObject *PythonQtSignalFunction_connect(PythonQtSignalFunctionObject* type, PyObject *args) +static PyObject* PythonQtSignalFunction_connect(PythonQtSignalFunctionObject* type, PyObject* args) { if (PyObject_TypeCheck(type->m_self, &PythonQtInstanceWrapper_Type)) { - PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*) type->m_self; + PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*)type->m_self; if (self->_obj) { Py_ssize_t argc = PyTuple_Size(args); - if (argc==1) { + if (argc == 1) { // connect with Python callable PyObject* callable = PyTuple_GET_ITEM(args, 0); - bool result = PythonQt::self()->addSignalHandler(self->_obj, QByteArray("2") + type->m_ml->signature(), callable); + bool result = + PythonQt::self()->addSignalHandler(self->_obj, QByteArray("2") + type->m_ml->signature(), callable); return PythonQtConv::GetPyBool(result); } else { PyErr_SetString(PyExc_ValueError, "Called connect with wrong number of arguments"); @@ -261,19 +253,19 @@ static PyObject *PythonQtSignalFunction_connect(PythonQtSignalFunctionObject* ty return nullptr; } -static PyObject *PythonQtSignalFunction_disconnect(PythonQtSignalFunctionObject* type, PyObject *args) +static PyObject* PythonQtSignalFunction_disconnect(PythonQtSignalFunctionObject* type, PyObject* args) { if (PyObject_TypeCheck(type->m_self, &PythonQtInstanceWrapper_Type)) { - PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*) type->m_self; + PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*)type->m_self; if (self->_obj) { Py_ssize_t argc = PyTuple_Size(args); QByteArray signal = QByteArray("2") + type->m_ml->signature(); - if (argc==1) { + if (argc == 1) { // disconnect with Python callable PyObject* callable = PyTuple_GET_ITEM(args, 0); bool result = PythonQt::self()->removeSignalHandler(self->_obj, signal, callable); return PythonQtConv::GetPyBool(result); - } else if (argc==0) { + } else if (argc == 0) { bool result = PythonQt::self()->removeSignalHandler(self->_obj, signal, nullptr); result |= QObject::disconnect(self->_obj, signal, nullptr, nullptr); return PythonQtConv::GetPyBool(result); @@ -285,56 +277,46 @@ static PyObject *PythonQtSignalFunction_disconnect(PythonQtSignalFunctionObject* return nullptr; } -static PyObject *PythonQtSignalFunction_emit(PythonQtSignalFunctionObject* func, PyObject *args) +static PyObject* PythonQtSignalFunction_emit(PythonQtSignalFunctionObject* func, PyObject* args) { PythonQtSignalFunctionObject* f = (PythonQtSignalFunctionObject*)func; return PythonQtMemberFunction_Call(f->m_ml, f->m_self, args, nullptr); } static PyMethodDef meth_methods[] = { - {"parameterTypes", reinterpret_cast(reinterpret_cast(PythonQtSignalFunction_parameterTypes)), METH_NOARGS, - "Returns a tuple of tuples of the C++ parameter types for all overloads of the signal" - }, - {"parameterNames", reinterpret_cast(reinterpret_cast(PythonQtSignalFunction_parameterNames)), METH_NOARGS, - "Returns a tuple of tuples of the C++ parameter type names (if available), for all overloads of the signal" - }, + {"parameterTypes", reinterpret_cast(reinterpret_cast(PythonQtSignalFunction_parameterTypes)), + METH_NOARGS, "Returns a tuple of tuples of the C++ parameter types for all overloads of the signal"}, + {"parameterNames", reinterpret_cast(reinterpret_cast(PythonQtSignalFunction_parameterNames)), + METH_NOARGS, + "Returns a tuple of tuples of the C++ parameter type names (if available), for all overloads of the signal"}, {"typeName", reinterpret_cast(reinterpret_cast(PythonQtSignalFunction_typeName)), METH_NOARGS, - "Returns a tuple of the C++ return value types of each signal overload" - }, + "Returns a tuple of the C++ return value types of each signal overload"}, {"connect", reinterpret_cast(reinterpret_cast(PythonQtSignalFunction_connect)), METH_VARARGS, - "Connects the signal to the Python callable" - }, - {"disconnect", reinterpret_cast(reinterpret_cast(PythonQtSignalFunction_disconnect)), METH_VARARGS, - "Disconnects the signal from the given Python callable or disconnects all if no argument is passed." - }, + "Connects the signal to the Python callable"}, + {"disconnect", reinterpret_cast(reinterpret_cast(PythonQtSignalFunction_disconnect)), + METH_VARARGS, "Disconnects the signal from the given Python callable or disconnects all if no argument is passed."}, {"emit", reinterpret_cast(reinterpret_cast(PythonQtSignalFunction_emit)), METH_VARARGS, - "Emits the signal with given arguments" - }, - {nullptr, nullptr, 0 , nullptr} /* Sentinel */ + "Emits the signal with given arguments"}, + {nullptr, nullptr, 0, nullptr} /* Sentinel */ }; -static PyObject * -meth_repr(PythonQtSignalFunctionObject *f) +static PyObject* meth_repr(PythonQtSignalFunctionObject* f) { if (!f->m_ml) { // TODO return PyUnicode_FromString("Signal"); } if (f->m_self->ob_type == &PythonQtClassWrapper_Type) { - PythonQtClassWrapper* self = (PythonQtClassWrapper*) f->m_self; - return PyUnicode_FromFormat("", - f->m_ml->slotName().constData(), + PythonQtClassWrapper* self = (PythonQtClassWrapper*)f->m_self; + return PyUnicode_FromFormat("", f->m_ml->slotName().constData(), self->classInfo()->className().constData()); } else { - return PyUnicode_FromFormat("", - f->m_ml->slotName().constData(), - f->m_self->ob_type->tp_name, - f->m_self); + return PyUnicode_FromFormat("", f->m_ml->slotName().constData(), + f->m_self->ob_type->tp_name, f->m_self); } } -static int -meth_compare(PythonQtSignalFunctionObject *a, PythonQtSignalFunctionObject *b) +static int meth_compare(PythonQtSignalFunctionObject* a, PythonQtSignalFunctionObject* b) { if (a->m_self != b->m_self) return (a->m_self < b->m_self) ? -1 : 1; @@ -346,10 +328,9 @@ meth_compare(PythonQtSignalFunctionObject *a, PythonQtSignalFunctionObject *b) return 1; } -static long -meth_hash(PythonQtSignalFunctionObject *a) +static long meth_hash(PythonQtSignalFunctionObject* a) { - long x,y; + long x, y; if (a->m_self == nullptr) x = 0; else { @@ -367,8 +348,7 @@ meth_hash(PythonQtSignalFunctionObject *a) } // for python 3.x -static PyObject* -meth_richcompare(PythonQtSignalFunctionObject *a, PythonQtSignalFunctionObject *b, int op) +static PyObject* meth_richcompare(PythonQtSignalFunctionObject* a, PythonQtSignalFunctionObject* b, int op) { int x = meth_compare(a, b); bool r = false; @@ -390,69 +370,66 @@ meth_richcompare(PythonQtSignalFunctionObject *a, PythonQtSignalFunctionObject * Py_RETURN_FALSE; } -PyDoc_STRVAR(PythonQtSignalFunction_doc, - "Signal(*types) -> Signal\n"); +PyDoc_STRVAR(PythonQtSignalFunction_doc, "Signal(*types) -> Signal\n"); PyTypeObject PythonQtSignalFunction_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) /*tp_base*/ - "QtCore.Signal", /* tp_name */ - sizeof(PythonQtSignalFunctionObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)meth_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ - nullptr, /* tp_getattr */ - nullptr, /* tp_setattr */ - nullptr, - (reprfunc)meth_repr, /* tp_repr */ - nullptr, /* tp_as_number */ - nullptr, /* tp_as_sequence */ - // TODO: implement tp_as_mapping to support overload resolution on the signal - nullptr, /* tp_as_mapping */ - (hashfunc)meth_hash, /* tp_hash */ - PythonQtSignalFunction_Call, /* tp_call */ - nullptr, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - nullptr, /* tp_setattro */ - nullptr, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - PythonQtSignalFunction_doc, /* tp_doc */ - (traverseproc)meth_traverse, /* tp_traverse */ - nullptr, /* tp_clear */ - (richcmpfunc)meth_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - nullptr, /* tp_iter */ - nullptr, /* tp_iternext */ - meth_methods, /* tp_methods */ - meth_members, /* tp_members */ - meth_getsets, /* tp_getset */ - nullptr, /* tp_base */ - nullptr, /* tp_dict */ - nullptr, /*tp_descr_get */ - nullptr, /*tp_descr_set */ - 0, /*tp_dictoffset */ - PythonQtSignalFunction_init, /*tp_init */ - nullptr, /*tp_alloc */ - PythonQtSignalFunction_tpNew, /*tp_new */ - nullptr, /*tp_free */ - nullptr, /*tp_is_gc */ - nullptr, /*tp_bases */ - nullptr, /*tp_mro */ - nullptr, /*tp_cache */ - nullptr, /*tp_subclasses */ - nullptr, /*tp_weaklist */ - nullptr, /*tp_del */ + PyVarObject_HEAD_INIT(&PyType_Type, 0) /*tp_base*/ + "QtCore.Signal", /* tp_name */ + sizeof(PythonQtSignalFunctionObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)meth_dealloc, /* tp_dealloc */ + 0, /* tp_vectorcall_offset */ + nullptr, /* tp_getattr */ + nullptr, /* tp_setattr */ + nullptr, + (reprfunc)meth_repr, /* tp_repr */ + nullptr, /* tp_as_number */ + nullptr, /* tp_as_sequence */ + // TODO: implement tp_as_mapping to support overload resolution on the signal + nullptr, /* tp_as_mapping */ + (hashfunc)meth_hash, /* tp_hash */ + PythonQtSignalFunction_Call, /* tp_call */ + nullptr, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + nullptr, /* tp_setattro */ + nullptr, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + PythonQtSignalFunction_doc, /* tp_doc */ + (traverseproc)meth_traverse, /* tp_traverse */ + nullptr, /* tp_clear */ + (richcmpfunc)meth_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + nullptr, /* tp_iter */ + nullptr, /* tp_iternext */ + meth_methods, /* tp_methods */ + meth_members, /* tp_members */ + meth_getsets, /* tp_getset */ + nullptr, /* tp_base */ + nullptr, /* tp_dict */ + nullptr, /*tp_descr_get */ + nullptr, /*tp_descr_set */ + 0, /*tp_dictoffset */ + PythonQtSignalFunction_init, /*tp_init */ + nullptr, /*tp_alloc */ + PythonQtSignalFunction_tpNew, /*tp_new */ + nullptr, /*tp_free */ + nullptr, /*tp_is_gc */ + nullptr, /*tp_bases */ + nullptr, /*tp_mro */ + nullptr, /*tp_cache */ + nullptr, /*tp_subclasses */ + nullptr, /*tp_weaklist */ + nullptr, /*tp_del */ }; /* Clear out the free list */ -void -PythonQtSignalFunction_Fini(void) +void PythonQtSignalFunction_Fini(void) { while (PythonQtSignal_free_list) { - PythonQtSignalFunctionObject *v = PythonQtSignal_free_list; - PythonQtSignal_free_list = (PythonQtSignalFunctionObject *)(v->m_self); + PythonQtSignalFunctionObject* v = PythonQtSignal_free_list; + PythonQtSignal_free_list = (PythonQtSignalFunctionObject*)(v->m_self); PyObject_GC_Del(v); } } - diff --git a/src/PythonQtSignal.h b/src/PythonQtSignal.h index 9e0165dda..a817bc6ae 100644 --- a/src/PythonQtSignal.h +++ b/src/PythonQtSignal.h @@ -53,23 +53,20 @@ extern PYTHONQT_EXPORT PyTypeObject PythonQtSignalFunction_Type; #define PythonQtSignalFunction_Check(op) (Py_TYPE(op) == &PythonQtSignalFunction_Type) -PyObject* PythonQtSignalFunction_New(PythonQtSlotInfo *, PyObject *, - PyObject *); +PyObject* PythonQtSignalFunction_New(PythonQtSlotInfo*, PyObject*, PyObject*); -struct PythonQtDynamicSignalInfo -{ +struct PythonQtDynamicSignalInfo { QByteArray name; QList signatures; }; //! defines a python object that stores a Qt signal info struct PythonQtSignalFunctionObject { - PyObject_HEAD - PythonQtSlotInfo *m_ml; /* Description of the C function to call */ - PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ - PyObject *m_module; /* The __module__ attribute, can be anything */ - PythonQtDynamicSignalInfo* _dynamicInfo; + PyObject_HEAD + PythonQtSlotInfo* m_ml; /* Description of the C function to call */ + PyObject* m_self; /* Passed as 'self' arg to the C func, can be NULL */ + PyObject* m_module; /* The __module__ attribute, can be anything */ + PythonQtDynamicSignalInfo* _dynamicInfo; }; - #endif diff --git a/src/PythonQtSignalReceiver.cpp b/src/PythonQtSignalReceiver.cpp index 2fe6e4b00..fd1814fd4 100644 --- a/src/PythonQtSignalReceiver.cpp +++ b/src/PythonQtSignalReceiver.cpp @@ -50,7 +50,8 @@ int PythonQtSignalReceiver::_destroyedSignal1Id = -2; int PythonQtSignalReceiver::_destroyedSignal2Id = -2; -void PythonQtSignalTarget::call(void **arguments) const { +void PythonQtSignalTarget::call(void** arguments) const +{ PYTHONQT_GIL_SCOPE PyObject* result = call(_callable, methodInfo(), arguments); if (result) { @@ -59,7 +60,8 @@ void PythonQtSignalTarget::call(void **arguments) const { } } -PyObject* PythonQtSignalTarget::call(PyObject* callable, const PythonQtMethodInfo* methodInfos, void **arguments, bool skipFirstArgumentOfMethodInfo) +PyObject* PythonQtSignalTarget::call(PyObject* callable, const PythonQtMethodInfo* methodInfos, void** arguments, + bool skipFirstArgumentOfMethodInfo) { Q_UNUSED(skipFirstArgumentOfMethodInfo) @@ -93,16 +95,16 @@ PyObject* PythonQtSignalTarget::call(PyObject* callable, const PythonQtMethodInf const PythonQtMethodInfo* m = methodInfos; // parameterCount includes return value: int count = m->parameterCount(); - if (numPythonArgs!=-1) { - if (count>numPythonArgs+1) { + if (numPythonArgs != -1) { + if (count > numPythonArgs + 1) { // take less arguments - count = numPythonArgs+1; + count = numPythonArgs + 1; } } PyObject* pargs = nullptr; - if (count>1) { - pargs = PyTuple_New(count-1); + if (count > 1) { + pargs = PyTuple_New(count - 1); } bool err = false; // transform Qt values to Python @@ -117,7 +119,7 @@ PyObject* PythonQtSignalTarget::call(PyObject* callable, const PythonQtMethodInf } if (arg) { // steals reference, no unref - PyTuple_SetItem(pargs, i-1, arg); + PyTuple_SetItem(pargs, i - 1, arg); } else { err = true; break; @@ -142,14 +144,15 @@ PyObject* PythonQtSignalTarget::call(PyObject* callable, const PythonQtMethodInf return result; } -bool PythonQtSignalTarget::isSame( int signalId, PyObject* callable ) const +bool PythonQtSignalTarget::isSame(int signalId, PyObject* callable) const { return PyObject_RichCompareBool(callable, _callable, Py_EQ) && (signalId == _signalId); } //------------------------------------------------------------------------------ -PythonQtSignalReceiver::PythonQtSignalReceiver(QObject* obj):PythonQtSignalReceiverBase(obj) +PythonQtSignalReceiver::PythonQtSignalReceiver(QObject* obj) + : PythonQtSignalReceiverBase(obj) { if (_destroyedSignal1Id == -2) { // initialize these once @@ -186,12 +189,11 @@ PythonQtSignalReceiver::~PythonQtSignalReceiver() } } - bool PythonQtSignalReceiver::addSignalHandler(const char* signal, PyObject* callable) { bool flag = false; int sigId = getSignalIndex(signal); - if (sigId>=0) { + if (sigId >= 0) { // create PythonQtMethodInfo from signal QMetaMethod meta = _obj->metaObject()->method(sigId); const PythonQtMethodInfo* signalInfo = PythonQtMethodInfo::getCachedMethodInfo(meta, _objClassInfo); @@ -205,7 +207,7 @@ bool PythonQtSignalReceiver::addSignalHandler(const char* signal, PyObject* call if (sigId == _destroyedSignal1Id || sigId == _destroyedSignal2Id) { _destroyedSignalCount++; - if (_destroyedSignalCount==1) { + if (_destroyedSignalCount == 1) { // make ourself parent of PythonQt, to not get deleted as a child of the QObject we are // listening to, since we do that manually when we receive the destroyed signal this->setParent(PythonQt::priv()); @@ -219,7 +221,7 @@ bool PythonQtSignalReceiver::removeSignalHandler(const char* signal, PyObject* c { int foundCount = 0; int sigId = getSignalIndex(signal); - if (sigId>=0) { + if (sigId >= 0) { QMutableListIterator i(_targets); if (callable) { while (i.hasNext()) { @@ -240,35 +242,35 @@ bool PythonQtSignalReceiver::removeSignalHandler(const char* signal, PyObject* c } } } - if ((foundCount>0) && ((sigId == _destroyedSignal1Id) || (sigId == _destroyedSignal2Id))) { + if ((foundCount > 0) && ((sigId == _destroyedSignal1Id) || (sigId == _destroyedSignal2Id))) { _destroyedSignalCount -= foundCount; - if (_destroyedSignalCount==0) { + if (_destroyedSignalCount == 0) { // make ourself child of QObject again, to get deleted when the object gets deleted this->setParent(_obj); } } - return foundCount>0; + return foundCount > 0; } int PythonQtSignalReceiver::getSignalIndex(const char* signal) { - int sigId = _obj->metaObject()->indexOfSignal(signal+1); - if (sigId<0) { - QByteArray tmpSig = QMetaObject::normalizedSignature(signal+1); + int sigId = _obj->metaObject()->indexOfSignal(signal + 1); + if (sigId < 0) { + QByteArray tmpSig = QMetaObject::normalizedSignature(signal + 1); sigId = _obj->metaObject()->indexOfSignal(tmpSig); } return sigId; } -int PythonQtSignalReceiver::qt_metacall(QMetaObject::Call c, int id, void **arguments) +int PythonQtSignalReceiver::qt_metacall(QMetaObject::Call c, int id, void** arguments) { -// mlabDebugConst("PythonQt", "PythonQtSignalReceiver invoke " << _obj->className() << " " << _obj->name() << " " << id); + // mlabDebugConst("PythonQt", "PythonQtSignalReceiver invoke " << _obj->className() << " " << _obj->name() << " " << id); if (c != QMetaObject::InvokeMetaMethod) { QObject::qt_metacall(c, id, arguments); } bool shouldDelete = false; - for(const PythonQtSignalTarget& t : qAsConst(_targets)) { + for (const PythonQtSignalTarget& t : qAsConst(_targets)) { if (t.slotId() == id) { const int sigId = t.signalId(); t.call(arguments); @@ -287,4 +289,3 @@ int PythonQtSignalReceiver::qt_metacall(QMetaObject::Call c, int id, void **argu } return 0; } - diff --git a/src/PythonQtSignalReceiver.h b/src/PythonQtSignalReceiver.h index d0b6b4910..a8ca3f774 100644 --- a/src/PythonQtSignalReceiver.h +++ b/src/PythonQtSignalReceiver.h @@ -53,15 +53,17 @@ class PythonQtClassInfo; //! stores information about a signal target /*! copy construction and assignment works fine with the C++ standard behavior and are thus not implemented */ -class PYTHONQT_EXPORT PythonQtSignalTarget { +class PYTHONQT_EXPORT PythonQtSignalTarget +{ public: - PythonQtSignalTarget() { + PythonQtSignalTarget() + { _signalId = -1; _methodInfo = nullptr; _slotId = -1; } - PythonQtSignalTarget(int signalId,const PythonQtMethodInfo* methodInfo, int slotId, PyObject* callable) + PythonQtSignalTarget(int signalId, const PythonQtMethodInfo* methodInfo, int slotId, PyObject* callable) { _signalId = signalId; _slotId = slotId; @@ -69,30 +71,30 @@ class PYTHONQT_EXPORT PythonQtSignalTarget { _callable = callable; }; - ~PythonQtSignalTarget() { - }; + ~PythonQtSignalTarget() {}; //! get the id of the original signal int signalId() const { return _signalId; } //! get the id that was assigned to this simulated slot - int slotId() const { return _slotId; } + int slotId() const { return _slotId; } //! get the signals parameter info - const PythonQtMethodInfo* methodInfo() const { return _methodInfo; } + const PythonQtMethodInfo* methodInfo() const { return _methodInfo; } //! call the python callable with the given arguments (as defined in methodInfo) - void call(void **arguments) const; + void call(void** arguments) const; //! check if it is the same signal target bool isSame(int signalId, PyObject* callable) const; //! call the given callable with arguments described by PythonQtMethodInfo, returns a new reference as result value (or NULL) - static PyObject* call(PyObject* callable, const PythonQtMethodInfo* methodInfo, void **arguments, bool skipFirstArgumentOfMethodInfo = false); + static PyObject* call(PyObject* callable, const PythonQtMethodInfo* methodInfo, void** arguments, + bool skipFirstArgumentOfMethodInfo = false); private: - int _signalId; - int _slotId; + int _signalId; + int _slotId; const PythonQtMethodInfo* _methodInfo; PythonQtSafeObjectPtr _callable; }; @@ -100,16 +102,19 @@ class PYTHONQT_EXPORT PythonQtSignalTarget { //! base class for signal receivers /*! */ -class PythonQtSignalReceiverBase : public QObject { +class PythonQtSignalReceiverBase : public QObject +{ Q_OBJECT public: - PythonQtSignalReceiverBase(QObject* obj):QObject(obj) {}; + PythonQtSignalReceiverBase(QObject* obj) + : QObject(obj) {}; }; //! receives all signals for one QObject /*! we derive from our base but do not declare the QObject macro because we want to reimplement qt_metacall only. */ -class PythonQtSignalReceiver : public PythonQtSignalReceiverBase { +class PythonQtSignalReceiver : public PythonQtSignalReceiverBase +{ public: PythonQtSignalReceiver(QObject* obj); @@ -122,7 +127,7 @@ class PythonQtSignalReceiver : public PythonQtSignalReceiverBase { bool removeSignalHandler(const char* signal, PyObject* callable = nullptr); //! we implement this method to simulate a number of slots that match the ids in _targets - int qt_metacall(QMetaObject::Call c, int id, void **arguments) override; + int qt_metacall(QMetaObject::Call c, int id, void** arguments) override; private: //! get the index of the signal @@ -139,6 +144,4 @@ class PythonQtSignalReceiver : public PythonQtSignalReceiverBase { static int _destroyedSignal2Id; }; - #endif - diff --git a/src/PythonQtSlot.cpp b/src/PythonQtSlot.cpp index 37ca34af7..11c9608dc 100644 --- a/src/PythonQtSlot.cpp +++ b/src/PythonQtSlot.cpp @@ -53,10 +53,12 @@ #include #if defined(__GNUG__) && !defined(__clang__) -#include + #include #endif -bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObject* args, bool strict, PythonQtSlotInfo* info, void* firstArgument, PyObject** pythonReturnValue, void** directReturnValuePointer, PythonQtPassThisOwnershipType* passThisOwnershipToCPP) +bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObject* args, bool strict, + PythonQtSlotInfo* info, void* firstArgument, PyObject** pythonReturnValue, void** directReturnValuePointer, + PythonQtPassThisOwnershipType* passThisOwnershipToCPP) { if (directReturnValuePointer) { *directReturnValuePointer = nullptr; @@ -74,7 +76,7 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj // set return argument to NULL argList[0] = nullptr; - + bool ok = true; PythonQtPassThisOwnershipType passThisOwnership = IgnoreOwnership; @@ -92,21 +94,22 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj } if (arg1) { // upcast to correct parent class - arg1 = ((char*)arg1)+info->upcastingOffset(); + arg1 = ((char*)arg1) + info->upcastingOffset(); } argList[1] = &arg1; } - for (int i = 1 + instanceDecoOffset; i pass ownership of this to someObject) - if (argList[i] && (*(void**)argList[i])==nullptr) { + if (argList[i] && (*(void**)argList[i]) == nullptr) { // if the object to which the ownership should be passed is NULL, // we need to pass the ownership to Python passThisOwnership = PassOwnershipToPython; @@ -128,7 +131,7 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj if (!directReturnValuePointer) { // create empty default value for the return value argList[0] = PythonQtConv::CreateQtReturnValue(returnValueParam, frame); - if (argList[0]==nullptr) { + if (argList[0] == nullptr) { // return value could not be created, maybe we have a registered class with a default constructor, so that we can construct the pythonqt wrapper object and // pass its internal pointer PythonQtClassInfo* info = PythonQt::priv()->getClassInfo(returnValueParam.name); @@ -148,7 +151,6 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj } } - PythonQt::ProfilingCB* profilingCB = PythonQt::priv()->profilingCB(); if (profilingCB) { const char* className = nullptr; @@ -163,29 +165,29 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj // invoke the slot via metacall bool hadException = false; - QObject* obj = info->decorator()?info->decorator():objectToCall; + QObject* obj = info->decorator() ? info->decorator() : objectToCall; if (!obj) { hadException = true; PyErr_SetString(PyExc_RuntimeError, "Trying to call a slot on a deleted QObject!"); } else { try { PythonQtSlotInfo::invokeQtMethod(obj, info, argList); - } catch (std::out_of_range & e) { + } catch (std::out_of_range& e) { hadException = true; QByteArray what("std::out_of_range: "); what += e.what(); PyErr_SetString(PyExc_IndexError, what.constData()); - } catch (std::bad_alloc & e) { + } catch (std::bad_alloc& e) { hadException = true; QByteArray what("std::bad_alloc: "); what += e.what(); PyErr_SetString(PyExc_MemoryError, what.constData()); - } catch (std::runtime_error & e) { + } catch (std::runtime_error& e) { hadException = true; QByteArray what("std::runtime_error: "); what += e.what(); PyErr_SetString(PyExc_RuntimeError, what.constData()); - } catch (std::logic_error & e) { + } catch (std::logic_error& e) { hadException = true; QByteArray what("std::logic_error: "); what += e.what(); @@ -197,7 +199,7 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj PyErr_SetString(PyExc_RuntimeError, what.constData()); #ifdef PYTHONQT_CATCH_ALL_EXCEPTIONS #if defined(__GNUG__) && !defined(__clang__) - } catch (abi::__forced_unwind &) { + } catch (abi::__forced_unwind&) { throw; #endif } catch (...) { @@ -206,7 +208,7 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj #endif } } - + if (profilingCB) { profilingCB(PythonQt::Leave, nullptr, nullptr, nullptr); } @@ -223,7 +225,9 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj } } } else { - QString e = QString("Called ") + info->fullSignature() + ", return type '" + returnValueParam.name + "' is ignored because it is unknown to PythonQt. Probably you should register it using qRegisterMetaType() or add a default constructor decorator to the class."; + QString e = QString("Called ") + info->fullSignature() + ", return type '" + returnValueParam.name + + "' is ignored because it is unknown to PythonQt. Probably you should register it using " + "qRegisterMetaType() or add a default constructor decorator to the class."; PyErr_SetString(PyExc_ValueError, QStringToPythonConstCharPointer(e)); result = nullptr; ok = false; @@ -237,7 +241,7 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj PythonQtArgumentFrame::deleteFrame(frame); *pythonReturnValue = result; - + if (result && returnValueParam.passOwnershipToPython) { // if the ownership should be passed to PythonQt, it has to be a PythonQtInstanceWrapper, // cast it and pass the ownership @@ -247,7 +251,7 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj } // NOTE: a return value can not pass the ownership to CPP, it would not make sense... } - // Either we have a + // Either we have a // a) a result value // b) a directReturnValuePointer and it has a value or the return value is void // NOTE: it is important to only return here, otherwise the stack will not be popped!!! @@ -256,25 +260,27 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj //----------------------------------------------------------------------------------- -static PythonQtSlotFunctionObject *pythonqtslot_free_list = nullptr; +static PythonQtSlotFunctionObject* pythonqtslot_free_list = nullptr; -PyObject *PythonQtSlotFunction_Call(PyObject *func, PyObject *args, PyObject *kw) +PyObject* PythonQtSlotFunction_Call(PyObject* func, PyObject* args, PyObject* kw) { PythonQtSlotFunctionObject* f = (PythonQtSlotFunctionObject*)func; return PythonQtMemberFunction_Call(f->m_ml, f->m_self, args, kw); } -PyObject *PythonQtMemberFunction_Call(PythonQtSlotInfo* info, PyObject* m_self, PyObject *args, PyObject *kw) +PyObject* PythonQtMemberFunction_Call(PythonQtSlotInfo* info, PyObject* m_self, PyObject* args, PyObject* kw) { if (PyObject_TypeCheck(m_self, &PythonQtInstanceWrapper_Type)) { - PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*) m_self; - if (!info->isClassDecorator() && (self->_obj==nullptr && self->_wrappedPtr==nullptr)) { - QString error = QString("Trying to call '") + info->slotName() + "' on a destroyed " + self->classInfo()->className() + " object"; + PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*)m_self; + if (!info->isClassDecorator() && (self->_obj == nullptr && self->_wrappedPtr == nullptr)) { + QString error = QString("Trying to call '") + info->slotName() + "' on a destroyed " + + self->classInfo()->className() + " object"; PyErr_SetString(PyExc_ValueError, QStringToPythonConstCharPointer(error)); return nullptr; } else { PythonQtPassThisOwnershipType ownership; - PyObject* result = PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, info, args, kw, self->_wrappedPtr, nullptr, &ownership); + PyObject* result = PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, info, args, kw, self->_wrappedPtr, + nullptr, &ownership); if (ownership == PassOwnershipToCPP) { self->passOwnershipToCPP(); } else if (ownership == PassOwnershipToPython) { @@ -283,26 +289,29 @@ PyObject *PythonQtMemberFunction_Call(PythonQtSlotInfo* info, PyObject* m_self, return result; } } else if (m_self->ob_type == &PythonQtClassWrapper_Type) { - PythonQtClassWrapper* type = (PythonQtClassWrapper*) m_self; + PythonQtClassWrapper* type = (PythonQtClassWrapper*)m_self; if (info->isClassDecorator()) { return PythonQtSlotFunction_CallImpl(type->classInfo(), nullptr, info, args, kw); } else { // otherwise, it is an unbound call and we have an instanceDecorator or normal slot... Py_ssize_t argc = PyTuple_Size(args); - if (argc>0) { + if (argc > 0) { PyObject* firstArg = PyTuple_GET_ITEM(args, 0); if (PyObject_TypeCheck(firstArg, (PyTypeObject*)&PythonQtInstanceWrapper_Type) - && ((PythonQtInstanceWrapper*)firstArg)->classInfo()->inherits(type->classInfo())) { + && ((PythonQtInstanceWrapper*)firstArg)->classInfo()->inherits(type->classInfo())) + { PythonQtInstanceWrapper* self = (PythonQtInstanceWrapper*)firstArg; - if (!info->isClassDecorator() && (self->_obj==nullptr && self->_wrappedPtr==nullptr)) { - QString error = QString("Trying to call '") + info->slotName() + "' on a destroyed " + self->classInfo()->className() + " object"; + if (!info->isClassDecorator() && (self->_obj == nullptr && self->_wrappedPtr == nullptr)) { + QString error = QString("Trying to call '") + info->slotName() + "' on a destroyed " + + self->classInfo()->className() + " object"; PyErr_SetString(PyExc_ValueError, QStringToPythonConstCharPointer(error)); return nullptr; } // strip the first argument... PyObject* newargs = PyTuple_GetSlice(args, 1, argc); PythonQtPassThisOwnershipType ownership; - PyObject* result = PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, info, newargs, kw, self->_wrappedPtr, nullptr, &ownership); + PyObject* result = PythonQtSlotFunction_CallImpl(self->classInfo(), self->_obj, info, newargs, kw, + self->_wrappedPtr, nullptr, &ownership); if (ownership == PassOwnershipToCPP) { self->passOwnershipToCPP(); } else if (ownership == PassOwnershipToPython) { @@ -312,13 +321,15 @@ PyObject *PythonQtMemberFunction_Call(PythonQtSlotInfo* info, PyObject* m_self, return result; } else { // first arg is not of correct type! - QString error = "slot " + info->fullSignature() + " requires " + type->classInfo()->className() + " instance as first argument, got " + firstArg->ob_type->tp_name; + QString error = "slot " + info->fullSignature() + " requires " + type->classInfo()->className() + + " instance as first argument, got " + firstArg->ob_type->tp_name; PyErr_SetString(PyExc_ValueError, QStringToPythonConstCharPointer(error)); return nullptr; } } else { // wrong number of args - QString error = "slot " + info->fullSignature() + " requires " + type->classInfo()->className() + " instance as first argument."; + QString error = "slot " + info->fullSignature() + " requires " + type->classInfo()->className() + + " instance as first argument."; PyErr_SetString(PyExc_ValueError, QStringToPythonConstCharPointer(error)); return nullptr; } @@ -328,22 +339,24 @@ PyObject *PythonQtMemberFunction_Call(PythonQtSlotInfo* info, PyObject* m_self, } namespace { - QString limitString(const QString& aString, int maxLength = 2000, const QString& ellipsis = "...") - { - if (aString.length() <= maxLength) - return aString; +QString limitString(const QString& aString, int maxLength = 2000, const QString& ellipsis = "...") +{ + if (aString.length() <= maxLength) + return aString; - const int beforeSize = (maxLength - ellipsis.length()) / 2; - auto beforeEllipsis = aString.left(beforeSize); - auto afterEllipsis = aString.right(maxLength - ellipsis.length() - beforeSize); + const int beforeSize = (maxLength - ellipsis.length()) / 2; + auto beforeEllipsis = aString.left(beforeSize); + auto afterEllipsis = aString.right(maxLength - ellipsis.length() - beforeSize); - return beforeEllipsis + ellipsis + afterEllipsis; - } + return beforeEllipsis + ellipsis + afterEllipsis; +} }; -PyObject *PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* objectToCall, PythonQtSlotInfo* info, PyObject *args, PyObject * kw, void* firstArg, void** directReturnValuePointer, PythonQtPassThisOwnershipType* passThisOwnershipToCPP) +PyObject* PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* objectToCall, PythonQtSlotInfo* info, + PyObject* args, PyObject* kw, void* firstArg, void** directReturnValuePointer, + PythonQtPassThisOwnershipType* passThisOwnershipToCPP) { - int argc = args?PyTuple_Size(args):0; + int argc = args ? PyTuple_Size(args) : 0; if (passThisOwnershipToCPP) { *passThisOwnershipToCPP = IgnoreOwnership; @@ -356,9 +369,9 @@ PyObject *PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* o *directReturnValuePointer = nullptr; } - if( (kw != nullptr && PyDict_Check(kw) && (PyDict_Size(kw) > 0)) ) { + if ((kw != nullptr && PyDict_Check(kw) && (PyDict_Size(kw) > 0))) { // -------------------keyword args slot call ------------------------- - + // keyword arguments are given as dict, must be mapped to arguments in correct order // very complicated, so call them only on a slot with last variable name kwargs // slot must be implemented as @@ -366,10 +379,10 @@ PyObject *PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* o int numCombinedArgs = argc + 1; PyObject* combinedArgs = PyTuple_New(numCombinedArgs); - for (int i = 0; imetaMethod()->typeName() << " " << slotInfo->signature().constData() << std::endl; + std::cout << "called " << slotInfo->metaMethod()->typeName() << " " << slotInfo->signature().constData() + << std::endl; #endif - ok = PythonQtCallSlot(classInfo, objectToCall, combinedArgs, false, slotInfo, firstArg, &r, directReturnValuePointer, passThisOwnershipToCPP); + ok = PythonQtCallSlot(classInfo, objectToCall, combinedArgs, false, slotInfo, firstArg, &r, + directReturnValuePointer, passThisOwnershipToCPP); if (!ok && !PyErr_Occurred()) { - QString e = QString("Called ") + info->fullSignature() + " with wrong arguments: " + limitString(PythonQtConv::PyObjGetString(args)); + QString e = QString("Called ") + info->fullSignature() + + " with wrong arguments: " + limitString(PythonQtConv::PyObjGetString(args)); PyErr_SetString(PyExc_ValueError, QStringToPythonConstCharPointer(e)); } } else { - QString e = QString("Called ") + info->fullSignature() + " with keyword arguments, but called slot does not support kwargs."; + QString e = QString("Called ") + info->fullSignature() + + " with keyword arguments, but called slot does not support kwargs."; PyErr_SetString(PyExc_ValueError, QStringToPythonConstCharPointer(e)); } Py_DECREF(combinedArgs); } else { - // -------------------Normal slot call ------------------------- + // -------------------Normal slot call ------------------------- if (info->nextInfo()) { // overloaded slot call, try on all slots with strict conversion first bool strict = true; PythonQtSlotInfo* i = info; while (i) { bool skipFirst = i->isInstanceDecorator(); - if (i->parameterCount()-1-(skipFirst?1:0) == argc) { + if (i->parameterCount() - 1 - (skipFirst ? 1 : 0) == argc) { PyErr_Clear(); - ok = PythonQtCallSlot(classInfo, objectToCall, args, strict, i, firstArg, &r, directReturnValuePointer, passThisOwnershipToCPP); - if (PyErr_Occurred() || ok) break; + ok = PythonQtCallSlot(classInfo, objectToCall, args, strict, i, firstArg, &r, directReturnValuePointer, + passThisOwnershipToCPP); + if (PyErr_Occurred() || ok) + break; } i = i->nextInfo(); if (!i) { @@ -427,7 +446,9 @@ PyObject *PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* o } } if (!ok && !PyErr_Occurred()) { - QString e = QString("Could not find matching overload for given arguments:\n" + limitString(PythonQtConv::PyObjGetString(args)) + "\n The following slots are available:\n"); + QString e = + QString("Could not find matching overload for given arguments:\n" + + limitString(PythonQtConv::PyObjGetString(args)) + "\n The following slots are available:\n"); PythonQtSlotInfo* i = info; while (i) { e += QString(i->fullSignature()) + "\n"; @@ -438,18 +459,21 @@ PyObject *PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* o } else { // simple (non-overloaded) slot call bool skipFirst = info->isInstanceDecorator(); - if (info->parameterCount()-1-(skipFirst?1:0) == argc) { + if (info->parameterCount() - 1 - (skipFirst ? 1 : 0) == argc) { PyErr_Clear(); - #ifdef PYTHONQT_DEBUG +#ifdef PYTHONQT_DEBUG std::cout << "called " << info->metaMethod()->typeName() << " " << info->signature().constData() << std::endl; - #endif - ok = PythonQtCallSlot(classInfo, objectToCall, args, false, info, firstArg, &r, directReturnValuePointer, passThisOwnershipToCPP); +#endif + ok = PythonQtCallSlot(classInfo, objectToCall, args, false, info, firstArg, &r, directReturnValuePointer, + passThisOwnershipToCPP); if (!ok && !PyErr_Occurred()) { - QString e = QString("Called ") + info->fullSignature() + " with wrong arguments: " + limitString(PythonQtConv::PyObjGetString(args)); + QString e = QString("Called ") + info->fullSignature() + + " with wrong arguments: " + limitString(PythonQtConv::PyObjGetString(args)); PyErr_SetString(PyExc_ValueError, QStringToPythonConstCharPointer(e)); } } else { - QString e = QString("Called ") + info->fullSignature() + " with wrong number of arguments: " + limitString(PythonQtConv::PyObjGetString(args)); + QString e = QString("Called ") + info->fullSignature() + + " with wrong number of arguments: " + limitString(PythonQtConv::PyObjGetString(args)); PyErr_SetString(PyExc_ValueError, QStringToPythonConstCharPointer(e)); } } @@ -458,16 +482,14 @@ PyObject *PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* o return r; } -PyObject * -PythonQtSlotFunction_New(PythonQtSlotInfo *ml, PyObject *self, PyObject *module) +PyObject* PythonQtSlotFunction_New(PythonQtSlotInfo* ml, PyObject* self, PyObject* module) { - PythonQtSlotFunctionObject *op; + PythonQtSlotFunctionObject* op; op = pythonqtslot_free_list; if (op != nullptr) { - pythonqtslot_free_list = (PythonQtSlotFunctionObject *)(op->m_self); + pythonqtslot_free_list = (PythonQtSlotFunctionObject*)(op->m_self); PyObject_INIT(op, &PythonQtSlotFunction_Type); - } - else { + } else { op = PyObject_GC_New(PythonQtSlotFunctionObject, &PythonQtSlotFunction_Type); if (op == nullptr) return nullptr; @@ -478,44 +500,40 @@ PythonQtSlotFunction_New(PythonQtSlotInfo *ml, PyObject *self, PyObject *module) Py_XINCREF(module); op->m_module = module; PyObject_GC_Track(op); - return (PyObject *)op; + return (PyObject*)op; } -PythonQtSlotInfo* -PythonQtSlotFunction_GetSlotInfo(PyObject *op) +PythonQtSlotInfo* PythonQtSlotFunction_GetSlotInfo(PyObject* op) { if (!PythonQtSlotFunction_Check(op)) { PyErr_Format(PyExc_SystemError, "%s:%d: bad argument to internal function", __FILE__, __LINE__); return nullptr; } - return ((PythonQtSlotFunctionObject *)op) -> m_ml; + return ((PythonQtSlotFunctionObject*)op)->m_ml; } -PyObject * -PythonQtSlotFunction_GetSelf(PyObject *op) +PyObject* PythonQtSlotFunction_GetSelf(PyObject* op) { if (!PythonQtSlotFunction_Check(op)) { PyErr_Format(PyExc_SystemError, "%s:%d: bad argument to internal function", __FILE__, __LINE__); return nullptr; } - return ((PythonQtSlotFunctionObject *)op) -> m_self; + return ((PythonQtSlotFunctionObject*)op)->m_self; } /* Methods (the standard built-in methods, that is) */ -static void -meth_dealloc(PyObject *o) +static void meth_dealloc(PyObject* o) { PyObject_GC_UnTrack(o); - auto m = static_cast(static_cast(o)); + auto m = static_cast(static_cast(o)); Py_XDECREF(m->m_self); Py_XDECREF(m->m_module); - m->m_self = (PyObject *)pythonqtslot_free_list; + m->m_self = (PyObject*)pythonqtslot_free_list; pythonqtslot_free_list = m; } -static PyObject * -meth_get__doc__(PythonQtSlotFunctionObject * m, void * /*closure*/) +static PyObject* meth_get__doc__(PythonQtSlotFunctionObject* m, void* /*closure*/) { QByteArray doc; PythonQtSlotInfo* info = m->m_ml; @@ -540,28 +558,30 @@ meth_get__doc__(PythonQtSlotFunctionObject * m, void * /*closure*/) if (!names.at(i - 1).isEmpty()) { doc += names.at(i - 1); } else { - doc += QString(QChar((char) ('a' + i - firstArgOffset))).toLatin1(); + doc += QString(QChar((char)('a' + i - firstArgOffset))).toLatin1(); } } doc += ")"; QByteArray pyReturnType; if (returnType == "QString" || returnType == "SbName" || returnType == "SbString") { pyReturnType = "str"; - } else if (returnType.startsWith("QVector<") || returnType.startsWith("QList<") || - returnType == "QStringList" || returnType == "QObjectList" || returnType == "QVariantList") { + } else if (returnType.startsWith("QVector<") || returnType.startsWith("QList<") || returnType == "QStringList" + || returnType == "QObjectList" || returnType == "QVariantList") + { pyReturnType = "tuple"; - } else if (returnType.startsWith("QHash<") || returnType.startsWith("QMap<") || - returnType == "QVariantMap" || returnType == "QVariantHash") { + } else if (returnType.startsWith("QHash<") || returnType.startsWith("QMap<") || returnType == "QVariantMap" + || returnType == "QVariantHash") + { pyReturnType = "dict"; } else if (returnTypeId == QMetaType::Bool) { pyReturnType = "bool"; } else if (returnTypeId == PythonQtMethodInfo::Variant) { pyReturnType = "object"; - } else if (returnTypeId == QMetaType::Char || returnTypeId == QMetaType::UChar || - returnTypeId == QMetaType::Short || returnTypeId == QMetaType::UShort || - returnTypeId == QMetaType::Int || returnTypeId == QMetaType::UInt || - returnTypeId == QMetaType::Long || returnTypeId == QMetaType::ULong || - returnTypeId == QMetaType::LongLong || returnTypeId == QMetaType::ULongLong) { + } else if (returnTypeId == QMetaType::Char || returnTypeId == QMetaType::UChar || returnTypeId == QMetaType::Short + || returnTypeId == QMetaType::UShort || returnTypeId == QMetaType::Int || returnTypeId == QMetaType::UInt + || returnTypeId == QMetaType::Long || returnTypeId == QMetaType::ULong + || returnTypeId == QMetaType::LongLong || returnTypeId == QMetaType::ULongLong) + { pyReturnType = "int"; } else if (returnTypeId == QMetaType::Float || returnTypeId == QMetaType::Double) { pyReturnType = "float"; @@ -582,14 +602,12 @@ meth_get__doc__(PythonQtSlotFunctionObject * m, void * /*closure*/) return PyUnicode_FromString(doc.constData()); } -static PyObject * -meth_get__name__(PythonQtSlotFunctionObject *m, void * /*closure*/) +static PyObject* meth_get__name__(PythonQtSlotFunctionObject* m, void* /*closure*/) { return PyUnicode_FromString(m->m_ml->slotName(true)); } -static int -meth_traverse(PythonQtSlotFunctionObject *m, visitproc visit, void *arg) +static int meth_traverse(PythonQtSlotFunctionObject* m, visitproc visit, void* arg) { int err; if (m->m_self != nullptr) { @@ -605,10 +623,9 @@ meth_traverse(PythonQtSlotFunctionObject *m, visitproc visit, void *arg) return 0; } -static PyObject * -meth_get__self__(PythonQtSlotFunctionObject *m, void * /*closure*/) +static PyObject* meth_get__self__(PythonQtSlotFunctionObject* m, void* /*closure*/) { - PyObject *self; + PyObject* self; self = m->m_self; if (self == nullptr) self = Py_None; @@ -616,40 +633,38 @@ meth_get__self__(PythonQtSlotFunctionObject *m, void * /*closure*/) return self; } -static PyGetSetDef meth_getsets [] = { - {const_cast("__doc__"), (getter)meth_get__doc__, nullptr, nullptr}, +static PyGetSetDef meth_getsets[] = { + {const_cast("__doc__"), (getter)meth_get__doc__, nullptr, nullptr}, {const_cast("__name__"), (getter)meth_get__name__, nullptr, nullptr}, {const_cast("__self__"), (getter)meth_get__self__, nullptr, nullptr}, - {nullptr, nullptr, nullptr,nullptr}, + {nullptr, nullptr, nullptr, nullptr}, }; #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 6 -#define PY_WRITE_RESTRICTED WRITE_RESTRICTED + #define PY_WRITE_RESTRICTED WRITE_RESTRICTED #endif #define OFF(x) offsetof(PythonQtSlotFunctionObject, x) -static PyMemberDef meth_members[] = { - {const_cast("__module__"), T_OBJECT, OFF(m_module), PY_WRITE_RESTRICTED}, - {nullptr} -}; +static PyMemberDef meth_members[] = {{const_cast("__module__"), T_OBJECT, OFF(m_module), PY_WRITE_RESTRICTED}, + {nullptr}}; -static PyObject *PythonQtSlotFunction_parameterTypes(PythonQtSlotFunctionObject* type) +static PyObject* PythonQtSlotFunction_parameterTypes(PythonQtSlotFunctionObject* type) { return PythonQtMemberFunction_parameterTypes(type->m_ml); } -static PyObject *PythonQtSlotFunction_parameterNames(PythonQtSlotFunctionObject* type) +static PyObject* PythonQtSlotFunction_parameterNames(PythonQtSlotFunctionObject* type) { return PythonQtMemberFunction_parameterNames(type->m_ml); } -static PyObject *PythonQtSlotFunction_typeName(PythonQtSlotFunctionObject* type) +static PyObject* PythonQtSlotFunction_typeName(PythonQtSlotFunctionObject* type) { return PythonQtMemberFunction_typeName(type->m_ml); } -PyObject *PythonQtMemberFunction_parameterTypes(PythonQtSlotInfo* theInfo) +PyObject* PythonQtMemberFunction_parameterTypes(PythonQtSlotInfo* theInfo) { PythonQtSlotInfo* info = theInfo; int count = 0; @@ -659,10 +674,10 @@ PyObject *PythonQtMemberFunction_parameterTypes(PythonQtSlotInfo* theInfo) } info = theInfo; PyObject* result = PyTuple_New(count); - for (int j = 0;j types = info->metaMethod()->parameterTypes(); PyObject* tuple = PyTuple_New(types.count()); - for (int i = 0; inextInfo(); @@ -671,7 +686,7 @@ PyObject *PythonQtMemberFunction_parameterTypes(PythonQtSlotInfo* theInfo) return result; } -PyObject *PythonQtMemberFunction_parameterNames(PythonQtSlotInfo* theInfo) +PyObject* PythonQtMemberFunction_parameterNames(PythonQtSlotInfo* theInfo) { PythonQtSlotInfo* info = theInfo; int count = 0; @@ -681,10 +696,10 @@ PyObject *PythonQtMemberFunction_parameterNames(PythonQtSlotInfo* theInfo) } info = theInfo; PyObject* result = PyTuple_New(count); - for (int j = 0;j names = info->metaMethod()->parameterNames(); PyObject* tuple = PyTuple_New(names.count()); - for (int i = 0; inextInfo(); @@ -693,7 +708,7 @@ PyObject *PythonQtMemberFunction_parameterNames(PythonQtSlotInfo* theInfo) return result; } -PyObject *PythonQtMemberFunction_typeName(PythonQtSlotInfo* theInfo) +PyObject* PythonQtMemberFunction_typeName(PythonQtSlotInfo* theInfo) { PythonQtSlotInfo* info = theInfo; int count = 0; @@ -703,7 +718,7 @@ PyObject *PythonQtMemberFunction_typeName(PythonQtSlotInfo* theInfo) } info = theInfo; PyObject* result = PyTuple_New(count); - for (int j = 0;jmetaMethod()); PyTuple_SET_ITEM(result, j, PyUnicode_FromString(name.constData())); info = info->nextInfo(); @@ -712,36 +727,29 @@ PyObject *PythonQtMemberFunction_typeName(PythonQtSlotInfo* theInfo) } static PyMethodDef meth_methods[] = { - {"parameterTypes", reinterpret_cast(reinterpret_cast(PythonQtSlotFunction_parameterTypes)), METH_NOARGS, - "Returns a tuple of tuples of the C++ parameter types for all overloads of the slot" - }, - {"parameterNames", reinterpret_cast(reinterpret_cast(PythonQtSlotFunction_parameterNames)), METH_NOARGS, - "Returns a tuple of tuples of the C++ parameter type names (if available), for all overloads of the slot" - }, + {"parameterTypes", reinterpret_cast(reinterpret_cast(PythonQtSlotFunction_parameterTypes)), + METH_NOARGS, "Returns a tuple of tuples of the C++ parameter types for all overloads of the slot"}, + {"parameterNames", reinterpret_cast(reinterpret_cast(PythonQtSlotFunction_parameterNames)), + METH_NOARGS, + "Returns a tuple of tuples of the C++ parameter type names (if available), for all overloads of the slot"}, {"typeName", reinterpret_cast(reinterpret_cast(PythonQtSlotFunction_typeName)), METH_NOARGS, - "Returns a tuple of the C++ return value types of each slot overload" - }, - {nullptr, nullptr, 0 , nullptr} /* Sentinel */ + "Returns a tuple of the C++ return value types of each slot overload"}, + {nullptr, nullptr, 0, nullptr} /* Sentinel */ }; -static PyObject * -meth_repr(PythonQtSlotFunctionObject *f) +static PyObject* meth_repr(PythonQtSlotFunctionObject* f) { if (f->m_self->ob_type == &PythonQtClassWrapper_Type) { - PythonQtClassWrapper* self = (PythonQtClassWrapper*) f->m_self; - return PyUnicode_FromFormat("", - f->m_ml->slotName().constData(), + PythonQtClassWrapper* self = (PythonQtClassWrapper*)f->m_self; + return PyUnicode_FromFormat("", f->m_ml->slotName().constData(), self->classInfo()->className().constData()); } else { - return PyUnicode_FromFormat("", - f->m_ml->slotName().constData(), - f->m_self->ob_type->tp_name, - f->m_self); + return PyUnicode_FromFormat("", f->m_ml->slotName().constData(), + f->m_self->ob_type->tp_name, f->m_self); } } -static int -meth_compare(PythonQtSlotFunctionObject *a, PythonQtSlotFunctionObject *b) +static int meth_compare(PythonQtSlotFunctionObject* a, PythonQtSlotFunctionObject* b) { if (a->m_self != b->m_self) return (a->m_self < b->m_self) ? -1 : 1; @@ -753,10 +761,9 @@ meth_compare(PythonQtSlotFunctionObject *a, PythonQtSlotFunctionObject *b) return 1; } -static long -meth_hash(PythonQtSlotFunctionObject *a) +static long meth_hash(PythonQtSlotFunctionObject* a) { - long x,y; + long x, y; if (a->m_self == nullptr) x = 0; else { @@ -774,8 +781,7 @@ meth_hash(PythonQtSlotFunctionObject *a) } // for python 3.x -static PyObject* -meth_richcompare(PythonQtSlotFunctionObject *a, PythonQtSlotFunctionObject *b, int op) +static PyObject* meth_richcompare(PythonQtSlotFunctionObject* a, PythonQtSlotFunctionObject* b, int op) { int x = meth_compare(a, b); bool r = false; @@ -797,15 +803,13 @@ meth_richcompare(PythonQtSlotFunctionObject *a, PythonQtSlotFunctionObject *b, i Py_RETURN_FALSE; } -static PyObject* -meth_descr_get(PyObject *descr, PyObject *obj, PyObject* type) +static PyObject* meth_descr_get(PyObject* descr, PyObject* obj, PyObject* type) { Q_UNUSED(type) if (PythonQtSlotFunction_Check(descr)) { - PythonQtSlotFunctionObject *slotObj = (PythonQtSlotFunctionObject*)descr; + PythonQtSlotFunctionObject* slotObj = (PythonQtSlotFunctionObject*)descr; return PythonQtSlotFunction_New(slotObj->m_ml, obj, nullptr); - } - else { + } else { // wrong type Py_IncRef(descr); return descr; @@ -813,50 +817,48 @@ meth_descr_get(PyObject *descr, PyObject *obj, PyObject* type) } PyTypeObject PythonQtSlotFunction_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) /*tp_base*/ - "builtin_qt_slot", /* tp_itemsize */ - sizeof(PythonQtSlotFunctionObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)meth_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ - nullptr, /* tp_getattr */ - nullptr, /* tp_setattr */ - nullptr, - (reprfunc)meth_repr, /* tp_repr */ - nullptr, /* tp_as_number */ - nullptr, /* tp_as_sequence */ - nullptr, /* tp_as_mapping */ - (hashfunc)meth_hash, /* tp_hash */ - PythonQtSlotFunction_Call, /* tp_call */ - nullptr, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - nullptr, /* tp_setattro */ - nullptr, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - nullptr, /* tp_doc */ - (traverseproc)meth_traverse, /* tp_traverse */ - nullptr, /* tp_clear */ - (richcmpfunc)meth_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - nullptr, /* tp_iter */ - nullptr, /* tp_iternext */ - meth_methods, /* tp_methods */ - meth_members, /* tp_members */ - meth_getsets, /* tp_getset */ - nullptr, /* tp_base */ - nullptr, /* tp_dict */ - meth_descr_get, /* tp_descr_get */ + PyVarObject_HEAD_INIT(&PyType_Type, 0) /*tp_base*/ + "builtin_qt_slot", /* tp_itemsize */ + sizeof(PythonQtSlotFunctionObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)meth_dealloc, /* tp_dealloc */ + 0, /* tp_vectorcall_offset */ + nullptr, /* tp_getattr */ + nullptr, /* tp_setattr */ + nullptr, + (reprfunc)meth_repr, /* tp_repr */ + nullptr, /* tp_as_number */ + nullptr, /* tp_as_sequence */ + nullptr, /* tp_as_mapping */ + (hashfunc)meth_hash, /* tp_hash */ + PythonQtSlotFunction_Call, /* tp_call */ + nullptr, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + nullptr, /* tp_setattro */ + nullptr, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + nullptr, /* tp_doc */ + (traverseproc)meth_traverse, /* tp_traverse */ + nullptr, /* tp_clear */ + (richcmpfunc)meth_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + nullptr, /* tp_iter */ + nullptr, /* tp_iternext */ + meth_methods, /* tp_methods */ + meth_members, /* tp_members */ + meth_getsets, /* tp_getset */ + nullptr, /* tp_base */ + nullptr, /* tp_dict */ + meth_descr_get, /* tp_descr_get */ }; /* Clear out the free list */ -void -PythonQtSlotFunction_Fini(void) +void PythonQtSlotFunction_Fini(void) { while (pythonqtslot_free_list) { - PythonQtSlotFunctionObject *v = pythonqtslot_free_list; - pythonqtslot_free_list = (PythonQtSlotFunctionObject *)(v->m_self); + PythonQtSlotFunctionObject* v = pythonqtslot_free_list; + pythonqtslot_free_list = (PythonQtSlotFunctionObject*)(v->m_self); PyObject_GC_Del(v); } } - diff --git a/src/PythonQtSlot.h b/src/PythonQtSlot.h index 1040a9223..5528d5d3d 100644 --- a/src/PythonQtSlot.h +++ b/src/PythonQtSlot.h @@ -49,44 +49,38 @@ class PythonQtSlotInfo; -enum PythonQtPassThisOwnershipType -{ - IgnoreOwnership, - PassOwnershipToCPP, - PassOwnershipToPython -}; +enum PythonQtPassThisOwnershipType { IgnoreOwnership, PassOwnershipToCPP, PassOwnershipToPython }; extern PYTHONQT_EXPORT PyTypeObject PythonQtSlotFunction_Type; #define PythonQtSlotFunction_Check(op) (Py_TYPE(op) == &PythonQtSlotFunction_Type) -PythonQtSlotInfo* PythonQtSlotFunction_GetSlotInfo(PyObject *); -PyObject* PythonQtSlotFunction_GetSelf(PyObject *); +PythonQtSlotInfo* PythonQtSlotFunction_GetSlotInfo(PyObject*); +PyObject* PythonQtSlotFunction_GetSelf(PyObject*); /* Macros for direct access to these values. Type checks are *not* done, so use with care. */ -#define PythonQtSlotFunction_GET_SELF(func) \ - (((PythonQtSlotFunctionObject *)func) -> m_self) +#define PythonQtSlotFunction_GET_SELF(func) (((PythonQtSlotFunctionObject*)func)->m_self) -PyObject* PythonQtSlotFunction_Call(PyObject *, PyObject *, PyObject *); +PyObject* PythonQtSlotFunction_Call(PyObject*, PyObject*, PyObject*); -PyObject *PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* objectToCall, PythonQtSlotInfo* info, PyObject *args, PyObject *kw, void* firstArg=nullptr, void** directReturnValuePointer=nullptr, PythonQtPassThisOwnershipType* passThisOwnershipToCPP = nullptr); +PyObject* PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* objectToCall, PythonQtSlotInfo* info, + PyObject* args, PyObject* kw, void* firstArg = nullptr, void** directReturnValuePointer = nullptr, + PythonQtPassThisOwnershipType* passThisOwnershipToCPP = nullptr); -PyObject* PythonQtSlotFunction_New(PythonQtSlotInfo *, PyObject *, - PyObject *); +PyObject* PythonQtSlotFunction_New(PythonQtSlotInfo*, PyObject*, PyObject*); -PyObject *PythonQtMemberFunction_Call(PythonQtSlotInfo* info, PyObject* m_self, PyObject *args, PyObject *kw); -PyObject *PythonQtMemberFunction_parameterTypes(PythonQtSlotInfo* theInfo); -PyObject *PythonQtMemberFunction_parameterNames(PythonQtSlotInfo* theInfo); -PyObject *PythonQtMemberFunction_typeName(PythonQtSlotInfo* theInfo); +PyObject* PythonQtMemberFunction_Call(PythonQtSlotInfo* info, PyObject* m_self, PyObject* args, PyObject* kw); +PyObject* PythonQtMemberFunction_parameterTypes(PythonQtSlotInfo* theInfo); +PyObject* PythonQtMemberFunction_parameterNames(PythonQtSlotInfo* theInfo); +PyObject* PythonQtMemberFunction_typeName(PythonQtSlotInfo* theInfo); //! defines a python object that stores a Qt slot info struct PythonQtSlotFunctionObject { - PyObject_HEAD - PythonQtSlotInfo *m_ml; /* Description of the C function to call */ - PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ - PyObject *m_module; /* The __module__ attribute, can be anything */ + PyObject_HEAD + PythonQtSlotInfo* m_ml; /* Description of the C function to call */ + PyObject* m_self; /* Passed as 'self' arg to the C func, can be NULL */ + PyObject* m_module; /* The __module__ attribute, can be anything */ }; - #endif diff --git a/src/PythonQtSlotDecorator.cpp b/src/PythonQtSlotDecorator.cpp index 9cdf57f9f..b3100bb08 100644 --- a/src/PythonQtSlotDecorator.cpp +++ b/src/PythonQtSlotDecorator.cpp @@ -33,7 +33,7 @@ #include "PythonQtSlotDecorator.h" #include "PythonQtConversion.h" -int PythonQtSlotDecorator_init(PyObject *object, PyObject *args, PyObject *kw) +int PythonQtSlotDecorator_init(PyObject* object, PyObject* args, PyObject* kw) { PythonQtSlotDecorator* self = (PythonQtSlotDecorator*)object; self->returnType = new QByteArray(); @@ -44,7 +44,7 @@ int PythonQtSlotDecorator_init(PyObject *object, PyObject *args, PyObject *kw) static const char* kwlist[] = {"name", "result", nullptr}; static PyObject* emptyTuple = PyTuple_New(0); - if (!PyArg_ParseTupleAndKeywords(emptyTuple, kw, "|sO:QtCore.Slot", (char**) kwlist, &argName, &argResult)) { + if (!PyArg_ParseTupleAndKeywords(emptyTuple, kw, "|sO:QtCore.Slot", (char**)kwlist, &argName, &argResult)) { return 0; } @@ -65,10 +65,10 @@ int PythonQtSlotDecorator_init(PyObject *object, PyObject *args, PyObject *kw) } QList argList; - + Py_ssize_t argc = PyTuple_Size(args); for (Py_ssize_t i = 0; i < argc; i++) { - PyObject *argType = PyTuple_GET_ITEM(args, i); + PyObject* argType = PyTuple_GET_ITEM(args, i); QByteArray typeName = PythonQtConv::getCPPTypeName(argType); if (!typeName.isEmpty()) { argList << typeName; @@ -79,7 +79,7 @@ int PythonQtSlotDecorator_init(PyObject *object, PyObject *args, PyObject *kw) } *self->args = argList.join(","); - + return 1; } @@ -122,55 +122,53 @@ PyObject* PythonQtSlotDecorator_call(PyObject* object, PyObject* args, PyObject* return function; } - -PyDoc_STRVAR(PythonQtSlotDecorator_doc, - "Slot(*types, result=type) -> Slot\n"); +PyDoc_STRVAR(PythonQtSlotDecorator_doc, "Slot(*types, result=type) -> Slot\n"); PyTypeObject PythonQtSlotDecorator_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) /*tp_base*/ - "PythonQt.QtCore.Slot", /*tp_name*/ - sizeof(PythonQtSlotDecorator), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - nullptr, /*tp_dealloc*/ - 0, /*tp_vectorcall_offset*/ - nullptr, /*tp_getattr*/ - nullptr, /*tp_setattr*/ - nullptr, /*tp_compare*/ - nullptr, /*tp_repr*/ - nullptr, /*tp_as_number*/ - nullptr, /*tp_as_sequence*/ - nullptr, /*tp_as_mapping*/ - nullptr, /*tp_hash */ - PythonQtSlotDecorator_call, /*tp_call*/ - nullptr, /*tp_str*/ - nullptr, /*tp_getattro*/ - nullptr, /*tp_setattro*/ - nullptr, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - PythonQtSlotDecorator_doc, /*tp_doc */ - nullptr, /*tp_traverse */ - nullptr, /*tp_clear */ - nullptr, /*tp_richcompare */ - 0, /*tp_weaklistoffset */ - nullptr, /*tp_iter */ - nullptr, /*tp_iternext */ - nullptr, /*tp_methods */ - nullptr, /*tp_members */ - nullptr, /*tp_getset */ - nullptr, /*tp_base */ - nullptr, /*tp_dict */ - nullptr, /*tp_descr_get */ - nullptr, /*tp_descr_set */ - 0, /*tp_dictoffset */ - PythonQtSlotDecorator_init, /*tp_init */ - nullptr, /*tp_alloc */ - PyType_GenericNew, /*tp_new */ - nullptr, /*tp_free */ - nullptr, /*tp_is_gc */ - nullptr, /*tp_bases */ - nullptr, /*tp_mro */ - nullptr, /*tp_cache */ - nullptr, /*tp_subclasses */ - nullptr, /*tp_weaklist */ - nullptr, /*tp_del */ + PyVarObject_HEAD_INIT(&PyType_Type, 0) /*tp_base*/ + "PythonQt.QtCore.Slot", /*tp_name*/ + sizeof(PythonQtSlotDecorator), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + nullptr, /*tp_dealloc*/ + 0, /*tp_vectorcall_offset*/ + nullptr, /*tp_getattr*/ + nullptr, /*tp_setattr*/ + nullptr, /*tp_compare*/ + nullptr, /*tp_repr*/ + nullptr, /*tp_as_number*/ + nullptr, /*tp_as_sequence*/ + nullptr, /*tp_as_mapping*/ + nullptr, /*tp_hash */ + PythonQtSlotDecorator_call, /*tp_call*/ + nullptr, /*tp_str*/ + nullptr, /*tp_getattro*/ + nullptr, /*tp_setattro*/ + nullptr, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + PythonQtSlotDecorator_doc, /*tp_doc */ + nullptr, /*tp_traverse */ + nullptr, /*tp_clear */ + nullptr, /*tp_richcompare */ + 0, /*tp_weaklistoffset */ + nullptr, /*tp_iter */ + nullptr, /*tp_iternext */ + nullptr, /*tp_methods */ + nullptr, /*tp_members */ + nullptr, /*tp_getset */ + nullptr, /*tp_base */ + nullptr, /*tp_dict */ + nullptr, /*tp_descr_get */ + nullptr, /*tp_descr_set */ + 0, /*tp_dictoffset */ + PythonQtSlotDecorator_init, /*tp_init */ + nullptr, /*tp_alloc */ + PyType_GenericNew, /*tp_new */ + nullptr, /*tp_free */ + nullptr, /*tp_is_gc */ + nullptr, /*tp_bases */ + nullptr, /*tp_mro */ + nullptr, /*tp_cache */ + nullptr, /*tp_subclasses */ + nullptr, /*tp_weaklist */ + nullptr, /*tp_del */ }; diff --git a/src/PythonQtStdDecorators.cpp b/src/PythonQtStdDecorators.cpp index ca1ddcfbc..25ba6b300 100644 --- a/src/PythonQtStdDecorators.cpp +++ b/src/PythonQtStdDecorators.cpp @@ -56,22 +56,24 @@ bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, P bool result = false; QByteArray signalTmp = signal; char first = signalTmp.at(0); - if (first<'0' || first>'9') { + if (first < '0' || first > '9') { signalTmp = "2" + signalTmp; } if (sender) { result = PythonQt::self()->addSignalHandler(sender, signalTmp, callable); if (!result) { - if (sender->metaObject()->indexOfSignal(QMetaObject::normalizedSignature(signalTmp.constData()+1)) == -1) { - std::cerr << "PythonQt: QObject::connect() signal '" << signal.constData() << "' does not exist on " << sender->metaObject()->className() << std::endl; + if (sender->metaObject()->indexOfSignal(QMetaObject::normalizedSignature(signalTmp.constData() + 1)) == -1) { + std::cerr << "PythonQt: QObject::connect() signal '" << signal.constData() << "' does not exist on " + << sender->metaObject()->className() << std::endl; } } } return result; } -bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot, Qt::ConnectionType type) +bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, QObject* receiver, + const QByteArray& slot, Qt::ConnectionType type) { if (signal.size() == 0) { std::cerr << "PythonQt: QObject::connect() signal is empty." << std::endl; @@ -85,13 +87,13 @@ bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, Q if (sender && receiver) { QByteArray signalTmp = signal; char first = signalTmp.at(0); - if (first<'0' || first>'9') { + if (first < '0' || first > '9') { signalTmp = "2" + signalTmp; } QByteArray slotTmp = slot; first = slotTmp.at(0); - if (first<'0' || first>'9') { + if (first < '0' || first > '9') { slotTmp = "1" + slotTmp; } r = QObject::connect(sender, signalTmp, receiver, slotTmp, type); @@ -109,7 +111,7 @@ bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal bool result = false; QByteArray signalTmp = signal; char first = signalTmp.at(0); - if (first<'0' || first>'9') { + if (first < '0' || first > '9') { signalTmp = "2" + signalTmp; } if (sender) { @@ -118,15 +120,17 @@ bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal result |= QObject::disconnect(sender, signalTmp, nullptr, nullptr); } if (!result) { - if (sender->metaObject()->indexOfSignal(QMetaObject::normalizedSignature(signalTmp.constData()+1)) == -1) { - std::cerr << "PythonQt: QObject::disconnect() signal '" << signal.constData() << "' does not exist on " << sender->metaObject()->className() << std::endl; + if (sender->metaObject()->indexOfSignal(QMetaObject::normalizedSignature(signalTmp.constData() + 1)) == -1) { + std::cerr << "PythonQt: QObject::disconnect() signal '" << signal.constData() << "' does not exist on " + << sender->metaObject()->className() << std::endl; } } } return result; } -bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot) +bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, + const QByteArray& slot) { bool r = false; if (signal.size() == 0) { @@ -140,13 +144,13 @@ bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal if (sender && receiver) { QByteArray signalTmp = signal; char first = signalTmp.at(0); - if (first<'0' || first>'9') { + if (first < '0' || first > '9') { signalTmp = "2" + signalTmp; } QByteArray slotTmp = slot; first = slotTmp.at(0); - if (first<'0' || first>'9') { + if (first < '0' || first > '9') { slotTmp = "1" + slotTmp; } @@ -155,7 +159,8 @@ bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal return r; } -QObject* PythonQtStdDecorators::parent(QObject* o) { +QObject* PythonQtStdDecorators::parent(QObject* o) +{ return o->parent(); } @@ -181,10 +186,12 @@ QVariant PythonQtStdDecorators::property(QObject* o, const char* name) QString PythonQtStdDecorators::tr(QObject* obj, const QString& text, const QString& ambig, int n) { -#if( QT_VERSION >= QT_VERSION_CHECK(5,0,0) ) - return QCoreApplication::translate(obj->metaObject()->className(), text.toUtf8().constData(), ambig.toUtf8().constData(), n); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + return QCoreApplication::translate(obj->metaObject()->className(), text.toUtf8().constData(), + ambig.toUtf8().constData(), n); #else - return QCoreApplication::translate(obj->metaObject()->className(), text.toUtf8().constData(), ambig.toUtf8().constData(), QCoreApplication::CodecForTr, n); + return QCoreApplication::translate(obj->metaObject()->className(), text.toUtf8().constData(), + ambig.toUtf8().constData(), QCoreApplication::CodecForTr, n); #endif } @@ -224,12 +231,10 @@ QList PythonQtStdDecorators::findChildren(QObject* parent, PyObject* t meta = ((PythonQtClassWrapper*)type)->classInfo()->metaObject(); } else if (PyObject_TypeCheck(type, &PythonQtInstanceWrapper_Type)) { meta = ((PythonQtInstanceWrapper*)type)->classInfo()->metaObject(); - } - else if (PyBytes_Check(type) || PyUnicode_Check(type)) { + } else if (PyBytes_Check(type) || PyUnicode_Check(type)) { typeName = PythonQtConv::PyObjGetString(type).toUtf8(); } - QList list; if (typeName.isEmpty() && !meta) { @@ -250,8 +255,7 @@ QList PythonQtStdDecorators::findChildren(QObject* parent, PyObject* t meta = ((PythonQtClassWrapper*)type)->classInfo()->metaObject(); } else if (PyObject_TypeCheck(type, &PythonQtInstanceWrapper_Type)) { meta = ((PythonQtInstanceWrapper*)type)->classInfo()->metaObject(); - } - else if (PyBytes_Check(type) || PyUnicode_Check(type)) { + } else if (PyBytes_Check(type) || PyUnicode_Check(type)) { typeName = PythonQtConv::PyObjGetString(type).toUtf8(); } @@ -266,9 +270,10 @@ QList PythonQtStdDecorators::findChildren(QObject* parent, PyObject* t return list; } -QObject* PythonQtStdDecorators::findChild(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name) +QObject* PythonQtStdDecorators::findChild(QObject* parent, const char* typeName, const QMetaObject* meta, + const QString& name) { - const QObjectList &children = parent->children(); + const QObjectList& children = parent->children(); int i; for (i = 0; i < children.size(); ++i) { @@ -281,8 +286,7 @@ QObject* PythonQtStdDecorators::findChild(QObject* parent, const char* typeName, if (!name.isNull() && obj->objectName() != name) continue; - if ((typeName && obj->inherits(typeName)) || - (meta && meta->cast(obj))) + if ((typeName && obj->inherits(typeName)) || (meta && meta->cast(obj))) return obj; } @@ -296,7 +300,8 @@ QObject* PythonQtStdDecorators::findChild(QObject* parent, const char* typeName, return nullptr; } -int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name, QList& list) +int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, + const QString& name, QList& list) { const QObjectList& children = parent->children(); int i; @@ -311,9 +316,8 @@ int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, c if (!name.isNull() && obj->objectName() != name) continue; - if ((typeName && obj->inherits(typeName)) || - (meta && meta->cast(obj))) { - list += obj; + if ((typeName && obj->inherits(typeName)) || (meta && meta->cast(obj))) { + list += obj; } if (findChildren(obj, typeName, meta, name, list) < 0) @@ -323,7 +327,8 @@ int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, c return 0; } -int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegularExpression& regExp, QList& list) +int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, + const QRegularExpression& regExp, QList& list) { const QObjectList& children = parent->children(); int i; @@ -339,9 +344,8 @@ int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, c if (match.hasMatch() == false) continue; - if ((typeName && obj->inherits(typeName)) || - (meta && meta->cast(obj))) { - list += obj; + if ((typeName && obj->inherits(typeName)) || (meta && meta->cast(obj))) { + list += obj; } if (findChildren(obj, typeName, meta, regExp, list) < 0) @@ -351,7 +355,7 @@ int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, c return 0; } -const QMetaObject* PythonQtStdDecorators::metaObject( QObject* obj ) +const QMetaObject* PythonQtStdDecorators::metaObject(QObject* obj) { return obj->metaObject(); } @@ -367,7 +371,7 @@ void PythonQtConfigAPI::setTaskDoneCallback(PyObject* object) //--------------------------------------------------------------------------- -bool PythonQtDebugAPI::isOwnedByPython( PyObject* object ) +bool PythonQtDebugAPI::isOwnedByPython(PyObject* object) { if (PyObject_TypeCheck(object, &PythonQtInstanceWrapper_Type)) { PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)object; @@ -376,7 +380,7 @@ bool PythonQtDebugAPI::isOwnedByPython( PyObject* object ) return true; } -bool PythonQtDebugAPI::isDerivedShellInstance( PyObject* object ) +bool PythonQtDebugAPI::isDerivedShellInstance(PyObject* object) { if (PyObject_TypeCheck(object, &PythonQtInstanceWrapper_Type)) { PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)object; @@ -385,7 +389,7 @@ bool PythonQtDebugAPI::isDerivedShellInstance( PyObject* object ) return false; } -bool PythonQtDebugAPI::hasExtraShellRefCount( PyObject* object ) +bool PythonQtDebugAPI::hasExtraShellRefCount(PyObject* object) { if (PyObject_TypeCheck(object, &PythonQtInstanceWrapper_Type)) { PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)object; @@ -394,7 +398,7 @@ bool PythonQtDebugAPI::hasExtraShellRefCount( PyObject* object ) return false; } -bool PythonQtDebugAPI::passOwnershipToCPP( PyObject* object ) +bool PythonQtDebugAPI::passOwnershipToCPP(PyObject* object) { if (PyObject_TypeCheck(object, &PythonQtInstanceWrapper_Type)) { PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)object; @@ -404,7 +408,7 @@ bool PythonQtDebugAPI::passOwnershipToCPP( PyObject* object ) return false; } -bool PythonQtDebugAPI::passOwnershipToPython( PyObject* object ) +bool PythonQtDebugAPI::passOwnershipToPython(PyObject* object) { if (PyObject_TypeCheck(object, &PythonQtInstanceWrapper_Type)) { PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)object; @@ -414,12 +418,12 @@ bool PythonQtDebugAPI::passOwnershipToPython( PyObject* object ) return false; } -bool PythonQtDebugAPI::isPythonQtInstanceWrapper( PyObject* object ) +bool PythonQtDebugAPI::isPythonQtInstanceWrapper(PyObject* object) { return PyObject_TypeCheck(object, &PythonQtInstanceWrapper_Type) != 0; } -bool PythonQtDebugAPI::isPythonQtClassWrapper( PyObject* object ) +bool PythonQtDebugAPI::isPythonQtClassWrapper(PyObject* object) { return PyObject_TypeCheck(object, &PythonQtClassWrapper_Type) != 0; } @@ -449,4 +453,3 @@ void PythonQtSingleShotTimer::slotTimeout() // delete ourself deleteLater(); } - diff --git a/src/PythonQtStdDecorators.h b/src/PythonQtStdDecorators.h index 3b1179d1b..aa5771c74 100644 --- a/src/PythonQtStdDecorators.h +++ b/src/PythonQtStdDecorators.h @@ -59,7 +59,7 @@ #include #include #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) -#include + #include #endif class PYTHONQT_EXPORT PythonQtStdDecorators : public QObject @@ -68,30 +68,48 @@ class PYTHONQT_EXPORT PythonQtStdDecorators : public QObject public Q_SLOTS: bool connect(QObject* sender, const QByteArray& signal, PyObject* callable); - bool connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot, Qt::ConnectionType type = Qt::AutoConnection); - bool connect(QObject* receiver, QObject* sender, const QByteArray& signal, const QByteArray& slot, Qt::ConnectionType type = Qt::AutoConnection) { return connect(sender, signal, receiver, slot, type); } - bool static_QObject_connect(QObject* sender, const QByteArray& signal, PyObject* callable) { return connect(sender, signal, callable); } - bool static_QObject_connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot, Qt::ConnectionType type = Qt::AutoConnection) { return connect(sender, signal, receiver, slot, type); } + bool connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot, + Qt::ConnectionType type = Qt::AutoConnection); + bool connect(QObject* receiver, QObject* sender, const QByteArray& signal, const QByteArray& slot, + Qt::ConnectionType type = Qt::AutoConnection) + { + return connect(sender, signal, receiver, slot, type); + } + bool static_QObject_connect(QObject* sender, const QByteArray& signal, PyObject* callable) + { + return connect(sender, signal, callable); + } + bool static_QObject_connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot, + Qt::ConnectionType type = Qt::AutoConnection) + { + return connect(sender, signal, receiver, slot, type); + } bool disconnect(QObject* sender, const QByteArray& signal, PyObject* callable = nullptr); bool disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot); - bool static_QObject_disconnect(QObject* sender, const QByteArray& signal, PyObject* callable = nullptr) { return disconnect(sender, signal, callable); } - bool static_QObject_disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot) { return disconnect(sender, signal, receiver, slot); } + bool static_QObject_disconnect(QObject* sender, const QByteArray& signal, PyObject* callable = nullptr) + { + return disconnect(sender, signal, callable); + } + bool static_QObject_disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot) + { + return disconnect(sender, signal, receiver, slot); + } - const QMetaObject* metaObject( QObject* obj ); + const QMetaObject* metaObject(QObject* obj); QObject* parent(QObject* o); void setParent(QObject* o, PythonQtNewOwnerOfThis parent); const QObjectList* children(QObject* o); QObject* findChild(QObject* parent, PyObject* type, const QString& name = QString()); - QList findChildren(QObject* parent, PyObject* type, const QString& name= QString()); + QList findChildren(QObject* parent, PyObject* type, const QString& name = QString()); QList findChildren(QObject* parent, PyObject* type, const QRegularExpression& regExp); bool setProperty(QObject* o, const char* name, const QVariant& value); QVariant property(QObject* o, const char* name); double static_Qt_qAbs(double a) { return qAbs(a); } - double static_Qt_qBound(double a,double b,double c) { return qBound(a,b,c); } + double static_Qt_qBound(double a, double b, double c) { return qBound(a, b, c); } void static_Qt_qDebug(const QByteArray& msg) { qDebug("%s", msg.constData()); } // TODO: multi arg qDebug... void static_Qt_qWarning(const QByteArray& msg) { qWarning("%s", msg.constData()); } @@ -134,8 +152,10 @@ public Q_SLOTS: private: QObject* findChild(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name); - int findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name, QList& list); - int findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegularExpression& regExp, QList& list); + int findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name, + QList& list); + int findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegularExpression& regExp, + QList& list); }; class PythonQtSingleShotTimer : public QTimer @@ -145,7 +165,7 @@ class PythonQtSingleShotTimer : public QTimer PythonQtSingleShotTimer(int msec, const PythonQtObjectPtr& callable); ~PythonQtSingleShotTimer() override; -public Q_SLOTS : +public Q_SLOTS: void slotTimeout(); private: @@ -158,8 +178,8 @@ class PythonQtWrapper_QMetaObject : public QObject public Q_SLOTS: // Python 3: PythonQt shadows className, so we need an extra getClassName method... - const char *getClassName(QMetaObject* obj) const { return obj->className(); } - const QMetaObject *superClass(QMetaObject* obj) const { return obj->superClass(); } + const char* getClassName(QMetaObject* obj) const { return obj->className(); } + const QMetaObject* superClass(QMetaObject* obj) const { return obj->superClass(); } int methodOffset(QMetaObject* obj) const { return obj->methodOffset(); } int enumeratorOffset(QMetaObject* obj) const { return obj->enumeratorOffset(); } @@ -172,13 +192,16 @@ public Q_SLOTS: int propertyCount(QMetaObject* obj) const { return obj->propertyCount(); } int classInfoCount(QMetaObject* obj) const { return obj->classInfoCount(); } - int indexOfConstructor(QMetaObject* obj, const char *constructor) const { return obj->indexOfConstructor(constructor); } - int indexOfMethod(QMetaObject* obj, const char *method) const { return obj->indexOfMethod(method); } - int indexOfSignal(QMetaObject* obj, const char *signal) const { return obj->indexOfSignal(signal); } - int indexOfSlot(QMetaObject* obj, const char *slot) const { return obj->indexOfSlot(slot); } - int indexOfEnumerator(QMetaObject* obj, const char *name) const { return obj->indexOfEnumerator(name); } - int indexOfProperty(QMetaObject* obj, const char *name) const { return obj->indexOfProperty(name); } - int indexOfClassInfo(QMetaObject* obj, const char *name) const { return obj->indexOfClassInfo(name); } + int indexOfConstructor(QMetaObject* obj, const char* constructor) const + { + return obj->indexOfConstructor(constructor); + } + int indexOfMethod(QMetaObject* obj, const char* method) const { return obj->indexOfMethod(method); } + int indexOfSignal(QMetaObject* obj, const char* signal) const { return obj->indexOfSignal(signal); } + int indexOfSlot(QMetaObject* obj, const char* slot) const { return obj->indexOfSlot(slot); } + int indexOfEnumerator(QMetaObject* obj, const char* name) const { return obj->indexOfEnumerator(name); } + int indexOfProperty(QMetaObject* obj, const char* name) const { return obj->indexOfProperty(name); } + int indexOfClassInfo(QMetaObject* obj, const char* name) const { return obj->indexOfClassInfo(name); } QMetaMethod constructor(QMetaObject* obj, int index) const { return obj->constructor(index); } QMetaMethod method(QMetaObject* obj, int index) const { return obj->method(index); } @@ -187,10 +210,15 @@ public Q_SLOTS: QMetaClassInfo classInfo(QMetaObject* obj, int index) const { return obj->classInfo(index); } QMetaProperty userProperty(QMetaObject* obj) const { return obj->userProperty(); } - bool static_QMetaObject_checkConnectArgs(const char *signal, const char *method) { return QMetaObject::checkConnectArgs(signal, method); } - QByteArray static_QMetaObject_normalizedSignature(const char *method) { return QMetaObject::normalizedSignature(method); } - QByteArray static_QMetaObject_normalizedType(const char *type) { return QMetaObject::normalizedType(type); } - + bool static_QMetaObject_checkConnectArgs(const char* signal, const char* method) + { + return QMetaObject::checkConnectArgs(signal, method); + } + QByteArray static_QMetaObject_normalizedSignature(const char* method) + { + return QMetaObject::normalizedSignature(method); + } + QByteArray static_QMetaObject_normalizedType(const char* type) { return QMetaObject::normalizedType(type); } }; //! Some methods to set properties of PythonQt from Python @@ -198,7 +226,8 @@ class PYTHONQT_EXPORT PythonQtConfigAPI : public QObject { Q_OBJECT public: - PythonQtConfigAPI(QObject* parent):QObject(parent) {}; + PythonQtConfigAPI(QObject* parent) + : QObject(parent) {}; public slots: //! Set a callable that is used as the argument for the add_done_callback for the Task/Future @@ -206,31 +235,31 @@ public slots: void setTaskDoneCallback(PyObject* object); }; - //! Some helper methods that allow testing of the ownership class PYTHONQT_EXPORT PythonQtDebugAPI : public QObject { Q_OBJECT - public: - PythonQtDebugAPI(QObject* parent):QObject(parent) {}; - - public slots: - //! Returns if the C++ object is owned by PythonQt and will be deleted when the reference goes away. - bool isOwnedByPython(PyObject* object); - //! Returns if the C++ object is an instance of a Python class that derives a C++ class. - bool isDerivedShellInstance(PyObject* object); - //! Returns if the shell instance has an extra ref count from the C++ side. - bool hasExtraShellRefCount(PyObject* object); - - //! Pass the ownership of the given object to CPP (so that it will not be deleted by Python if the reference goes away) - bool passOwnershipToCPP(PyObject* object); - //! Pass the ownership of the given object to Python (so that the C++ object will be deleted when the Python reference goes away) - bool passOwnershipToPython(PyObject* object); - - //! Returns if the given object is a PythonQt instance wrapper (or derived class) - bool isPythonQtInstanceWrapper(PyObject* object); - //! Returns if the given object is a PythonQt class wrapper (or derived class) - bool isPythonQtClassWrapper(PyObject* object); +public: + PythonQtDebugAPI(QObject* parent) + : QObject(parent) {}; + +public slots: + //! Returns if the C++ object is owned by PythonQt and will be deleted when the reference goes away. + bool isOwnedByPython(PyObject* object); + //! Returns if the C++ object is an instance of a Python class that derives a C++ class. + bool isDerivedShellInstance(PyObject* object); + //! Returns if the shell instance has an extra ref count from the C++ side. + bool hasExtraShellRefCount(PyObject* object); + + //! Pass the ownership of the given object to CPP (so that it will not be deleted by Python if the reference goes away) + bool passOwnershipToCPP(PyObject* object); + //! Pass the ownership of the given object to Python (so that the C++ object will be deleted when the Python reference goes away) + bool passOwnershipToPython(PyObject* object); + + //! Returns if the given object is a PythonQt instance wrapper (or derived class) + bool isPythonQtInstanceWrapper(PyObject* object); + //! Returns if the given object is a PythonQt class wrapper (or derived class) + bool isPythonQtClassWrapper(PyObject* object); }; #endif diff --git a/src/PythonQtStdIn.cpp b/src/PythonQtStdIn.cpp index ae881990b..e17e6a6b9 100644 --- a/src/PythonQtStdIn.cpp +++ b/src/PythonQtStdIn.cpp @@ -42,21 +42,21 @@ #include "PythonQtStdIn.h" #include "PythonQt.h" -static PyObject *PythonQtStdInRedirect_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) +static PyObject* PythonQtStdInRedirect_new(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - PythonQtStdInRedirect *self; - self = (PythonQtStdInRedirect *)type->tp_alloc(type, 0); + PythonQtStdInRedirect* self; + self = (PythonQtStdInRedirect*)type->tp_alloc(type, 0); self->_cb = nullptr; self->_callData = nullptr; self->_isatty = false; - return (PyObject *)self; + return (PyObject*)self; } -static PyObject *PythonQtStdInRedirect_readline(PyObject * self, PyObject * args) +static PyObject* PythonQtStdInRedirect_readline(PyObject* self, PyObject* args) { Q_UNUSED(args) - PythonQtStdInRedirect* s = (PythonQtStdInRedirect*)self; + PythonQtStdInRedirect* s = (PythonQtStdInRedirect*)self; QString string; if (s->_cb) { string = (*s->_cb)(s->_callData); @@ -64,7 +64,7 @@ static PyObject *PythonQtStdInRedirect_readline(PyObject * self, PyObject * args return Py_BuildValue("s", QStringToPythonConstCharPointer(string)); } -static PyObject *PythonQtStdInRedirect_isatty(PyObject * self, PyObject * /*args*/) +static PyObject* PythonQtStdInRedirect_isatty(PyObject* self, PyObject* /*args*/) { PythonQtStdInRedirect* s = (PythonQtStdInRedirect*)self; PyObject* r = s->_isatty ? Py_True : Py_False; @@ -73,55 +73,53 @@ static PyObject *PythonQtStdInRedirect_isatty(PyObject * self, PyObject * /*args } static PyMethodDef PythonQtStdInRedirect_methods[] = { - {"readline", (PyCFunction)PythonQtStdInRedirect_readline, METH_VARARGS, - "read input line"}, - {"isatty", (PyCFunction)PythonQtStdInRedirect_isatty, METH_NOARGS, - "returns True if this is a tty-like device. False by default." - }, - {nullptr, nullptr, 0 , nullptr} /* sentinel */ + {"readline", (PyCFunction)PythonQtStdInRedirect_readline, METH_VARARGS, "read input line"}, + {"isatty", (PyCFunction)PythonQtStdInRedirect_isatty, METH_NOARGS, + "returns True if this is a tty-like device. False by default."}, + {nullptr, nullptr, 0, nullptr} /* sentinel */ }; static PyMemberDef PythonQtStdInRedirect_members[] = { - {nullptr} /* Sentinel */ + {nullptr} /* Sentinel */ }; PyTypeObject PythonQtStdInRedirectType = { - PyVarObject_HEAD_INIT(nullptr, 0) /*tp_base*/ - "PythonQtStdInRedirect", /*tp_name*/ - sizeof(PythonQtStdInRedirect), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - nullptr, /*tp_dealloc*/ - 0, /*tp_vectorcall_offset*/ - nullptr, /*tp_getattr*/ - nullptr, /*tp_setattr*/ - nullptr, /*tp_compare*/ - nullptr, /*tp_repr*/ - nullptr, /*tp_as_number*/ - nullptr, /*tp_as_sequence*/ - nullptr, /*tp_as_mapping*/ - nullptr, /*tp_hash */ - nullptr, /*tp_call*/ - nullptr, /*tp_str*/ - nullptr, /*tp_getattro*/ - nullptr, /*tp_setattro*/ - nullptr, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "PythonQtStdInRedirect", /* tp_doc */ - nullptr, /* tp_traverse */ - nullptr, /* tp_clear */ - nullptr, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - nullptr, /* tp_iter */ - nullptr, /* tp_iternext */ - PythonQtStdInRedirect_methods, /* tp_methods */ - PythonQtStdInRedirect_members, /* tp_members */ - nullptr, /* tp_getset */ - nullptr, /* tp_base */ - nullptr, /* tp_dict */ - nullptr, /* tp_descr_get */ - nullptr, /* tp_descr_set */ - 0, /* tp_dictoffset */ - nullptr, /* tp_init */ - nullptr, /* tp_alloc */ - PythonQtStdInRedirect_new, /* tp_new */ + PyVarObject_HEAD_INIT(nullptr, 0) /*tp_base*/ + "PythonQtStdInRedirect", /*tp_name*/ + sizeof(PythonQtStdInRedirect), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + nullptr, /*tp_dealloc*/ + 0, /*tp_vectorcall_offset*/ + nullptr, /*tp_getattr*/ + nullptr, /*tp_setattr*/ + nullptr, /*tp_compare*/ + nullptr, /*tp_repr*/ + nullptr, /*tp_as_number*/ + nullptr, /*tp_as_sequence*/ + nullptr, /*tp_as_mapping*/ + nullptr, /*tp_hash */ + nullptr, /*tp_call*/ + nullptr, /*tp_str*/ + nullptr, /*tp_getattro*/ + nullptr, /*tp_setattro*/ + nullptr, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + "PythonQtStdInRedirect", /* tp_doc */ + nullptr, /* tp_traverse */ + nullptr, /* tp_clear */ + nullptr, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + nullptr, /* tp_iter */ + nullptr, /* tp_iternext */ + PythonQtStdInRedirect_methods, /* tp_methods */ + PythonQtStdInRedirect_members, /* tp_members */ + nullptr, /* tp_getset */ + nullptr, /* tp_base */ + nullptr, /* tp_dict */ + nullptr, /* tp_descr_get */ + nullptr, /* tp_descr_set */ + 0, /* tp_dictoffset */ + nullptr, /* tp_init */ + nullptr, /* tp_alloc */ + PythonQtStdInRedirect_new, /* tp_new */ }; diff --git a/src/PythonQtStdIn.h b/src/PythonQtStdIn.h index c32a16901..8f429ffdc 100644 --- a/src/PythonQtStdIn.h +++ b/src/PythonQtStdIn.h @@ -42,7 +42,6 @@ */ //---------------------------------------------------------------------------------- - #include "PythonQtPythonInclude.h" #include "structmember.h" #include @@ -57,7 +56,7 @@ typedef QString PythonQtInputChangedCB(void* callData); struct PythonQtStdInRedirect { PyObject_HEAD PythonQtInputChangedCB* _cb; - void * _callData; + void* _callData; bool _isatty; }; diff --git a/src/PythonQtStdOut.cpp b/src/PythonQtStdOut.cpp index 181510b92..ae07d3c31 100644 --- a/src/PythonQtStdOut.cpp +++ b/src/PythonQtStdOut.cpp @@ -41,29 +41,29 @@ #include "PythonQtStdOut.h" -static PyObject *PythonQtStdOutRedirect_new(PyTypeObject *type, PyObject * /*args*/, PyObject * /*kwds*/) +static PyObject* PythonQtStdOutRedirect_new(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - PythonQtStdOutRedirect *self; - self = (PythonQtStdOutRedirect *)type->tp_alloc(type, 0); + PythonQtStdOutRedirect* self; + self = (PythonQtStdOutRedirect*)type->tp_alloc(type, 0); self->softspace = 0; self->closed = false; self->_cb = nullptr; - return (PyObject *)self; + return (PyObject*)self; } -static PyObject *PythonQtStdOutRedirect_write(PyObject *self, PyObject *args) +static PyObject* PythonQtStdOutRedirect_write(PyObject* self, PyObject* args) { - PythonQtStdOutRedirect* s = (PythonQtStdOutRedirect*)self; + PythonQtStdOutRedirect* s = (PythonQtStdOutRedirect*)self; if (s->_cb) { QString output; - if (PyTuple_GET_SIZE(args)>=1) { - PyObject* obj = PyTuple_GET_ITEM(args,0); + if (PyTuple_GET_SIZE(args) >= 1) { + PyObject* obj = PyTuple_GET_ITEM(args, 0); if (PyUnicode_Check(obj)) { output = QString::fromUtf8(PyUnicode_AsUTF8(obj)); } else { - char *string; + char* string; if (!PyArg_ParseTuple(args, "s", &string)) { return nullptr; } @@ -81,75 +81,70 @@ static PyObject *PythonQtStdOutRedirect_write(PyObject *self, PyObject *args) return Py_BuildValue(""); } -static PyObject *PythonQtStdOutRedirect_flush(PyObject * /*self*/, PyObject * /*args*/) +static PyObject* PythonQtStdOutRedirect_flush(PyObject* /*self*/, PyObject* /*args*/) { return Py_BuildValue(""); } -static PyObject *PythonQtStdOutRedirect_isatty(PyObject * /*self*/, PyObject * /*args*/) +static PyObject* PythonQtStdOutRedirect_isatty(PyObject* /*self*/, PyObject* /*args*/) { Py_RETURN_FALSE; } static PyMethodDef PythonQtStdOutRedirect_methods[] = { - {"write", (PyCFunction)PythonQtStdOutRedirect_write, METH_VARARGS, - "redirect the writing to a callback"}, + {"write", (PyCFunction)PythonQtStdOutRedirect_write, METH_VARARGS, "redirect the writing to a callback"}, {"flush", (PyCFunction)PythonQtStdOutRedirect_flush, METH_VARARGS, - "flush the output, currently not implemented but needed for logging framework" - }, - {"isatty", (PyCFunction)PythonQtStdOutRedirect_isatty, METH_NOARGS, - "return False since this object is not a tty-like device. Needed for logging framework" - }, - {nullptr, nullptr, 0 , nullptr} /* sentinel */ + "flush the output, currently not implemented but needed for logging framework"}, + {"isatty", (PyCFunction)PythonQtStdOutRedirect_isatty, METH_NOARGS, + "return False since this object is not a tty-like device. Needed for logging framework"}, + {nullptr, nullptr, 0, nullptr} /* sentinel */ }; static PyMemberDef PythonQtStdOutRedirect_members[] = { {const_cast("softspace"), T_INT, offsetof(PythonQtStdOutRedirect, softspace), 0, - const_cast("soft space flag") - }, - { const_cast("closed"), T_BOOL, offsetof(PythonQtStdOutRedirect, closed), 0, - const_cast("soft space flag") - }, - {nullptr} /* Sentinel */ + const_cast("soft space flag")}, + {const_cast("closed"), T_BOOL, offsetof(PythonQtStdOutRedirect, closed), 0, + const_cast("soft space flag")}, + {nullptr} /* Sentinel */ }; PyTypeObject PythonQtStdOutRedirectType = { - PyVarObject_HEAD_INIT(nullptr, 0) /*tp_base*/ - "PythonQtStdOutRedirect", /*tp_name*/ - sizeof(PythonQtStdOutRedirect), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - nullptr, /*tp_dealloc*/ - 0, /*tp_vectorcall_offset*/ - nullptr, /*tp_getattr*/ - nullptr, /*tp_setattr*/ - nullptr, /*tp_compare*/ - nullptr, /*tp_repr*/ - nullptr, /*tp_as_number*/ - nullptr, /*tp_as_sequence*/ - nullptr, /*tp_as_mapping*/ - nullptr, /*tp_hash */ - nullptr, /*tp_call*/ - nullptr, /*tp_str*/ - nullptr, /*tp_getattro*/ - nullptr, /*tp_setattro*/ - nullptr, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "PythonQtStdOutRedirect", /* tp_doc */ - nullptr, /* tp_traverse */ - nullptr, /* tp_clear */ - nullptr, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - nullptr, /* tp_iter */ - nullptr, /* tp_iternext */ - PythonQtStdOutRedirect_methods, /* tp_methods */ - PythonQtStdOutRedirect_members, /* tp_members */ - nullptr, /* tp_getset */ - nullptr, /* tp_base */ - nullptr, /* tp_dict */ - nullptr, /* tp_descr_get */ - nullptr, /* tp_descr_set */ - 0, /* tp_dictoffset */ - nullptr, /* tp_init */ - nullptr, /* tp_alloc */ - PythonQtStdOutRedirect_new, /* tp_new */ + PyVarObject_HEAD_INIT(nullptr, 0) /*tp_base*/ + "PythonQtStdOutRedirect", /*tp_name*/ + sizeof(PythonQtStdOutRedirect), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + nullptr, /*tp_dealloc*/ + 0, /*tp_vectorcall_offset*/ + nullptr, /*tp_getattr*/ + nullptr, /*tp_setattr*/ + nullptr, /*tp_compare*/ + nullptr, /*tp_repr*/ + nullptr, /*tp_as_number*/ + nullptr, /*tp_as_sequence*/ + nullptr, /*tp_as_mapping*/ + nullptr, /*tp_hash */ + nullptr, /*tp_call*/ + nullptr, /*tp_str*/ + nullptr, /*tp_getattro*/ + nullptr, /*tp_setattro*/ + nullptr, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + "PythonQtStdOutRedirect", /* tp_doc */ + nullptr, /* tp_traverse */ + nullptr, /* tp_clear */ + nullptr, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + nullptr, /* tp_iter */ + nullptr, /* tp_iternext */ + PythonQtStdOutRedirect_methods, /* tp_methods */ + PythonQtStdOutRedirect_members, /* tp_members */ + nullptr, /* tp_getset */ + nullptr, /* tp_base */ + nullptr, /* tp_dict */ + nullptr, /* tp_descr_get */ + nullptr, /* tp_descr_set */ + 0, /* tp_dictoffset */ + nullptr, /* tp_init */ + nullptr, /* tp_alloc */ + PythonQtStdOutRedirect_new, /* tp_new */ }; diff --git a/src/PythonQtStdOut.h b/src/PythonQtStdOut.h index 1b675dfb8..b89163602 100644 --- a/src/PythonQtStdOut.h +++ b/src/PythonQtStdOut.h @@ -42,7 +42,6 @@ */ //---------------------------------------------------------------------------------- - #include "PythonQtPythonInclude.h" #include "structmember.h" diff --git a/src/PythonQtSystem.h b/src/PythonQtSystem.h index d49345eeb..962ea509d 100644 --- a/src/PythonQtSystem.h +++ b/src/PythonQtSystem.h @@ -42,21 +42,18 @@ */ //---------------------------------------------------------------------------------- - #if defined(WIN32) - #ifdef PYTHONQT_EXPORTS - #define PYTHONQT_EXPORT __declspec(dllexport) - #else - #define PYTHONQT_EXPORT __declspec(dllimport) - #endif + #ifdef PYTHONQT_EXPORTS + #define PYTHONQT_EXPORT __declspec(dllexport) + #else + #define PYTHONQT_EXPORT __declspec(dllimport) + #endif #else - #ifdef PYTHONQT_EXPORTS - #define PYTHONQT_EXPORT __attribute__((__visibility__("default"))) - #else - #define PYTHONQT_EXPORT - #endif + #ifdef PYTHONQT_EXPORTS + #define PYTHONQT_EXPORT __attribute__((__visibility__("default"))) + #else + #define PYTHONQT_EXPORT + #endif #endif - #endif - diff --git a/src/PythonQtThreadSupport.cpp b/src/PythonQtThreadSupport.cpp index fe81bed1e..e5fef9d83 100644 --- a/src/PythonQtThreadSupport.cpp +++ b/src/PythonQtThreadSupport.cpp @@ -44,7 +44,8 @@ bool PythonQtGILScope::_enableGILScope = false; -PythonQtGILScope::PythonQtGILScope() : _ensured(false) +PythonQtGILScope::PythonQtGILScope() + : _ensured(false) { if (_enableGILScope) { _state = PyGILState_Ensure(); diff --git a/src/PythonQtThreadSupport.h b/src/PythonQtThreadSupport.h index f57e821d3..c17013117 100644 --- a/src/PythonQtThreadSupport.h +++ b/src/PythonQtThreadSupport.h @@ -46,13 +46,13 @@ #define PYTHONQT_FULL_THREAD_SUPPORT #ifdef PYTHONQT_FULL_THREAD_SUPPORT -#define PYTHONQT_GIL_SUPPORT -#define PYTHONQT_ALLOW_THREADS_SUPPORT + #define PYTHONQT_GIL_SUPPORT + #define PYTHONQT_ALLOW_THREADS_SUPPORT #endif #ifdef PYTHONQT_GIL_SUPPORT -#define PYTHONQT_GIL_SCOPE PythonQtGILScope internal_pythonqt_gilscope; + #define PYTHONQT_GIL_SCOPE PythonQtGILScope internal_pythonqt_gilscope; //! Ensures/releases the Python GIL //! An instance of this class can be used to @@ -82,7 +82,7 @@ class PYTHONQT_EXPORT PythonQtGILScope #else -#define PYTHONQT_GIL_SCOPE + #define PYTHONQT_GIL_SCOPE //! Empty dummy implementation. class PythonQtGILScope @@ -96,7 +96,7 @@ class PythonQtGILScope #ifdef PYTHONQT_ALLOW_THREADS_SUPPORT -#define PYTHONQT_ALLOW_THREADS_SCOPE PythonQtThreadStateSaver internal_pythonqt_savethread; + #define PYTHONQT_ALLOW_THREADS_SCOPE PythonQtThreadStateSaver internal_pythonqt_savethread; //! This class wraps the Python save/restore thread state API. //! It can be used to allow other Python threads to run when entering C++ code @@ -105,19 +105,14 @@ class PythonQtThreadStateSaver { Q_DISABLE_COPY(PythonQtThreadStateSaver) public: - PythonQtThreadStateSaver() { - save(); - } + PythonQtThreadStateSaver() { save(); } - ~PythonQtThreadStateSaver() { - restore(); - } + ~PythonQtThreadStateSaver() { restore(); } - void save() { - _state = PyEval_SaveThread(); - } + void save() { _state = PyEval_SaveThread(); } - void restore() { + void restore() + { if (_state) { PyEval_RestoreThread(_state); _state = nullptr; @@ -130,7 +125,7 @@ class PythonQtThreadStateSaver #else -#define PYTHONQT_ALLOW_THREADS_SCOPE + #define PYTHONQT_ALLOW_THREADS_SCOPE //! Empty dummy implementation. class PythonQtThreadStateSaver diff --git a/src/PythonQtUtils.h b/src/PythonQtUtils.h index c342df2e6..7fba4bf8c 100644 --- a/src/PythonQtUtils.h +++ b/src/PythonQtUtils.h @@ -49,63 +49,67 @@ #include #include -namespace PythonQtUtils +namespace PythonQtUtils { +inline QByteArray signature(const QMetaMethod& method) { - inline QByteArray signature(const QMetaMethod& method) { -#if( QT_VERSION >= QT_VERSION_CHECK(5,0,0) ) - return method.methodSignature(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + return method.methodSignature(); #else - return QByteArray(method.signature()); + return QByteArray(method.signature()); #endif - } +} - inline QByteArray methodName(const QMetaMethod& method) { -#if( QT_VERSION >= QT_VERSION_CHECK(5,0,0) ) - return method.name(); +inline QByteArray methodName(const QMetaMethod& method) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + return method.name(); #else - QByteArray sig(method.signature()); - int idx = sig.indexOf('('); - sig = sig.left(idx); - return sig; + QByteArray sig(method.signature()); + int idx = sig.indexOf('('); + sig = sig.left(idx); + return sig; #endif - } +} - inline QByteArray typeName(const QMetaMethod& method) { -#if( QT_VERSION >= QT_VERSION_CHECK(5,0,0) ) - QByteArray result = method.typeName(); - if (result == "void") { - return QByteArray(); - } else { - return result; - } +inline QByteArray typeName(const QMetaMethod& method) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + QByteArray result = method.typeName(); + if (result == "void") { + return QByteArray(); + } else { + return result; + } #else - return method.typeName(); + return method.typeName(); #endif - } +} - //! Returns of the python object is a class type - inline bool isPythonClassType(PyObject* obj) { - return PyType_Check(obj); - } +//! Returns of the python object is a class type +inline bool isPythonClassType(PyObject* obj) +{ + return PyType_Check(obj); +} - //! Returns the meta type ID from a type name - inline int metaTypeIdFromTypeName(const QByteArray& className) { -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) - return QMetaType::fromName(className.constData()).id(); +//! Returns the meta type ID from a type name +inline int metaTypeIdFromTypeName(const QByteArray& className) +{ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return QMetaType::fromName(className.constData()).id(); #else - return QMetaType::type(className.constData()); + return QMetaType::type(className.constData()); #endif - } +} - //! Returns the type name from a meta type ID - inline const char * typeNameFromMetaTypeId(int metaTypeId) { -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) - return QMetaType(metaTypeId).name(); +//! Returns the type name from a meta type ID +inline const char* typeNameFromMetaTypeId(int metaTypeId) +{ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return QMetaType(metaTypeId).name(); #else - return QMetaType::typeName(metaTypeId); + return QMetaType::typeName(metaTypeId); #endif - } +} } #endif - diff --git a/src/PythonQtVariants.h b/src/PythonQtVariants.h index d2ba9eff6..f5d046286 100644 --- a/src/PythonQtVariants.h +++ b/src/PythonQtVariants.h @@ -73,8 +73,7 @@ #include #include #if QT_VERSION < 0x060000 -#include + #include #endif #endif - diff --git a/src/gui/PythonQtScriptingConsole.cpp b/src/gui/PythonQtScriptingConsole.cpp index 27366afcf..98b58d703 100644 --- a/src/gui/PythonQtScriptingConsole.cpp +++ b/src/gui/PythonQtScriptingConsole.cpp @@ -56,20 +56,21 @@ //----------------------------------------------------------------------------- -PythonQtScriptingConsole::PythonQtScriptingConsole(QWidget* parent, const PythonQtObjectPtr& context, Qt::WindowFlags windowFlags) -: QTextEdit(parent) { +PythonQtScriptingConsole::PythonQtScriptingConsole(QWidget* parent, const PythonQtObjectPtr& context, + Qt::WindowFlags windowFlags) + : QTextEdit(parent) +{ setWindowFlags(windowFlags); _defaultTextCharacterFormat = currentCharFormat(); - _context = context; - _historyPosition = 0; - _hadError = false; + _context = context; + _historyPosition = 0; + _hadError = false; _completer = new QCompleter(this); _completer->setWidget(this); - QObject::connect(_completer, SIGNAL(activated(const QString&)), - this, SLOT(insertCompletion(const QString&))); + QObject::connect(_completer, SIGNAL(activated(const QString&)), this, SLOT(insertCompletion(const QString&))); clear(); @@ -83,10 +84,10 @@ void PythonQtScriptingConsole::stdOut(const QString& s) { _stdOut += s; int idx; - while ((idx = _stdOut.indexOf('\n'))!=-1) { + while ((idx = _stdOut.indexOf('\n')) != -1) { consoleMessage(_stdOut.left(idx)); std::cout << QStringToPythonConstCharPointer(_stdOut.left(idx)) << std::endl; - _stdOut = _stdOut.mid(idx+1); + _stdOut = _stdOut.mid(idx + 1); } } @@ -95,10 +96,10 @@ void PythonQtScriptingConsole::stdErr(const QString& s) _hadError = true; _stdErr += s; int idx; - while ((idx = _stdErr.indexOf('\n'))!=-1) { + while ((idx = _stdErr.indexOf('\n')) != -1) { consoleMessage(_stdErr.left(idx)); std::cerr << QStringToPythonConstCharPointer(_stdErr.left(idx)) << std::endl; - _stdErr = _stdErr.mid(idx+1); + _stdErr = _stdErr.mid(idx + 1); } } @@ -114,14 +115,12 @@ void PythonQtScriptingConsole::flushStdOut() //----------------------------------------------------------------------------- -PythonQtScriptingConsole::~PythonQtScriptingConsole() { -} - - +PythonQtScriptingConsole::~PythonQtScriptingConsole() {} //----------------------------------------------------------------------------- -void PythonQtScriptingConsole::clear() { +void PythonQtScriptingConsole::clear() +{ QTextEdit::clear(); appendCommandPrompt(); @@ -142,7 +141,7 @@ void PythonQtScriptingConsole::executeLine(bool storeOnly) // i don't know where this trailing space is coming from, blast it! if (code.endsWith(" ")) { - code.truncate(code.length()-1); + code.truncate(code.length() - 1); } if (!code.isEmpty()) { @@ -158,7 +157,6 @@ void PythonQtScriptingConsole::executeLine(bool storeOnly) } // Insert a new command prompt appendCommandPrompt(storeOnly); - } void PythonQtScriptingConsole::executeCode(const QString& code) @@ -199,10 +197,10 @@ void PythonQtScriptingConsole::executeCode(const QString& code) } } - //----------------------------------------------------------------------------- -void PythonQtScriptingConsole::appendCommandPrompt(bool storeOnly) { +void PythonQtScriptingConsole::appendCommandPrompt(bool storeOnly) +{ if (storeOnly) { _commandPrompt = "...> "; } else { @@ -215,11 +213,10 @@ void PythonQtScriptingConsole::appendCommandPrompt(bool storeOnly) { setTextCursor(cursor); } - - //----------------------------------------------------------------------------- -void PythonQtScriptingConsole::setCurrentFont(const QColor& color, bool bold) { +void PythonQtScriptingConsole::setCurrentFont(const QColor& color, bool bold) +{ QTextCharFormat charFormat(_defaultTextCharacterFormat); @@ -234,11 +231,10 @@ void PythonQtScriptingConsole::setCurrentFont(const QColor& color, bool bold) { setCurrentCharFormat(charFormat); } - - //----------------------------------------------------------------------------- -int PythonQtScriptingConsole::commandPromptPosition() { +int PythonQtScriptingConsole::commandPromptPosition() +{ QTextCursor textCursor(this->textCursor()); textCursor.movePosition(QTextCursor::End); @@ -246,15 +242,13 @@ int PythonQtScriptingConsole::commandPromptPosition() { return textCursor.block().position() + _commandPrompt.length(); } - - //----------------------------------------------------------------------------- void PythonQtScriptingConsole::insertCompletion(const QString& completion) { QTextCursor tc = textCursor(); tc.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor); - if (tc.selectedText()==".") { + if (tc.selectedText() == ".") { tc.insertText(QString(".") + completion); } else { tc = textCursor(); @@ -268,13 +262,13 @@ void PythonQtScriptingConsole::insertCompletion(const QString& completion) //----------------------------------------------------------------------------- void PythonQtScriptingConsole::handleTabCompletion() { - QTextCursor textCursor = this->textCursor(); + QTextCursor textCursor = this->textCursor(); int pos = textCursor.position(); textCursor.setPosition(commandPromptPosition()); textCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); int startPos = textCursor.selectionStart(); - int offset = pos-startPos; + int offset = pos - startPos; QString text = textCursor.selectedText(); QString textToComplete; @@ -288,13 +282,12 @@ void PythonQtScriptingConsole::handleTabCompletion() } } - QString lookup; QString compareText = textToComplete; int dot = compareText.lastIndexOf('.'); - if (dot!=-1) { + if (dot != -1) { lookup = compareText.mid(0, dot); - compareText = compareText.mid(dot+1, offset); + compareText = compareText.mid(dot + 1, offset); } if (!lookup.isEmpty() || !compareText.isEmpty()) { compareText = compareText.toLower(); @@ -305,7 +298,7 @@ void PythonQtScriptingConsole::handleTabCompletion() found << n; } } - + if (!found.isEmpty()) { _completer->setCompletionPrefix(compareText); _completer->setCompletionMode(QCompleter::PopupCompletion); @@ -314,9 +307,9 @@ void PythonQtScriptingConsole::handleTabCompletion() QTextCursor c = this->textCursor(); c.movePosition(QTextCursor::StartOfWord); QRect cr = cursorRect(c); - cr.setWidth(_completer->popup()->sizeHintForColumn(0) - + _completer->popup()->verticalScrollBar()->sizeHint().width()); - cr.translate(0,8); + cr.setWidth( + _completer->popup()->sizeHintForColumn(0) + _completer->popup()->verticalScrollBar()->sizeHint().width()); + cr.translate(0, 8); _completer->complete(cr); } else { _completer->popup()->hide(); @@ -326,7 +319,8 @@ void PythonQtScriptingConsole::handleTabCompletion() } } -void PythonQtScriptingConsole::keyPressEvent(QKeyEvent* event) { +void PythonQtScriptingConsole::keyPressEvent(QKeyEvent* event) +{ if (_completer && _completer->popup()->isVisible()) { // The following keys are forwarded by the completer to the widget @@ -344,15 +338,15 @@ void PythonQtScriptingConsole::keyPressEvent(QKeyEvent* event) { case Qt::Key_Escape: case Qt::Key_Tab: case Qt::Key_Backtab: - + event->ignore(); return; // let the completer do default behavior default: break; } } - bool eventHandled = false; - QTextCursor textCursor = this->textCursor(); + bool eventHandled = false; + QTextCursor textCursor = this->textCursor(); int key = event->key(); switch (key) { @@ -372,7 +366,7 @@ void PythonQtScriptingConsole::keyPressEvent(QKeyEvent* event) { case Qt::Key_Up: // Display the previous command in the history - if (_historyPosition>0) { + if (_historyPosition > 0) { _historyPosition--; changeHistory(); } @@ -383,7 +377,7 @@ void PythonQtScriptingConsole::keyPressEvent(QKeyEvent* event) { case Qt::Key_Down: // Display the next command in the history - if (_historyPosition+1<_history.count()) { + if (_historyPosition + 1 < _history.count()) { _historyPosition++; changeHistory(); } @@ -451,8 +445,8 @@ void PythonQtScriptingConsole::keyPressEvent(QKeyEvent* event) { } if (eventHandled) { - if(_completer != nullptr) { - _completer->popup()->hide(); + if (_completer != nullptr) { + _completer->popup()->hide(); } event->accept(); @@ -468,11 +462,10 @@ void PythonQtScriptingConsole::keyPressEvent(QKeyEvent* event) { } } - - //----------------------------------------------------------------------------- -void PythonQtScriptingConsole::cut() { +void PythonQtScriptingConsole::cut() +{ bool deletionAllowed = verifySelectionBeforeDeletion(); if (deletionAllowed) { @@ -480,20 +473,18 @@ void PythonQtScriptingConsole::cut() { } } - - //----------------------------------------------------------------------------- -bool PythonQtScriptingConsole::verifySelectionBeforeDeletion() { +bool PythonQtScriptingConsole::verifySelectionBeforeDeletion() +{ bool deletionAllowed = true; - QTextCursor textCursor = this->textCursor(); int commandPromptPosition = this->commandPromptPosition(); - int selectionStart = textCursor.selectionStart(); - int selectionEnd = textCursor.selectionEnd(); + int selectionStart = textCursor.selectionStart(); + int selectionEnd = textCursor.selectionEnd(); if (textCursor.hasSelection()) { @@ -502,14 +493,13 @@ bool PythonQtScriptingConsole::verifySelectionBeforeDeletion() { // to the part and deletion is allowed. If the selection occurs before the // last command prompt, then deletion is not allowed. - if (selectionStart < commandPromptPosition || - selectionEnd < commandPromptPosition) { + if (selectionStart < commandPromptPosition || selectionEnd < commandPromptPosition) { // Assure selectionEnd is bigger than selection start if (selectionStart > selectionEnd) { - int tmp = selectionEnd; - selectionEnd = selectionStart; - selectionStart = tmp; + int tmp = selectionEnd; + selectionEnd = selectionStart; + selectionStart = tmp; } if (selectionEnd < commandPromptPosition) { @@ -544,11 +534,10 @@ bool PythonQtScriptingConsole::verifySelectionBeforeDeletion() { return deletionAllowed; } - - //----------------------------------------------------------------------------- -void PythonQtScriptingConsole::changeHistory() { +void PythonQtScriptingConsole::changeHistory() +{ // Select the text after the last command prompt ... QTextCursor textCursor = this->textCursor(); @@ -562,11 +551,10 @@ void PythonQtScriptingConsole::changeHistory() { setTextCursor(textCursor); } - - //----------------------------------------------------------------------------- -void PythonQtScriptingConsole::consoleMessage(const QString & message) { +void PythonQtScriptingConsole::consoleMessage(const QString& message) +{ append(QString()); insertPlainText(message); diff --git a/src/gui/PythonQtScriptingConsole.h b/src/gui/PythonQtScriptingConsole.h index 26e028fa5..86337adeb 100644 --- a/src/gui/PythonQtScriptingConsole.h +++ b/src/gui/PythonQtScriptingConsole.h @@ -64,16 +64,20 @@ public Q_SLOTS: void executeLine(bool storeOnly); //! derived key press event - void keyPressEvent (QKeyEvent * e) override; + void keyPressEvent(QKeyEvent* e) override; //! output from console - void consoleMessage(const QString & message); + void consoleMessage(const QString& message); //! get history QStringList history() { return _history; } //! set history - void setHistory(const QStringList& h) { _history = h; _historyPosition = h.count(); } + void setHistory(const QStringList& h) + { + _history = h; + _historyPosition = h.count(); + } //! clear the console void clear(); @@ -96,9 +100,7 @@ public Q_SLOTS: bool hadError() { return _hadError; } //! returns true if python cerr had an error - void clearError() { - _hadError = false; - } + void clearError() { _hadError = false; } protected: //! handle the pressing of tab @@ -112,7 +114,7 @@ public Q_SLOTS: bool verifySelectionBeforeDeletion(); //! Sets the current font - void setCurrentFont(const QColor& color = QColor(0,0,0), bool bold = false); + void setCurrentFont(const QColor& color = QColor(0, 0, 0), bool bold = false); //! change the history according to _historyPos void changeHistory(); @@ -120,14 +122,13 @@ public Q_SLOTS: //! flush output that was not yet printed void flushStdOut(); - private: void executeCode(const QString& code); PythonQtObjectPtr _context; QStringList _history; - int _historyPosition; + int _historyPosition; QString _clickedAnchor; QString _storageKey; @@ -144,7 +145,4 @@ public Q_SLOTS: bool _hadError; }; - - #endif - diff --git a/tests/PythonQtTestCleanup.cpp b/tests/PythonQtTestCleanup.cpp index c10681d1b..862931215 100644 --- a/tests/PythonQtTestCleanup.cpp +++ b/tests/PythonQtTestCleanup.cpp @@ -2,13 +2,9 @@ #include "PythonQt.h" #include "PythonQt_QtAll.h" -void PythonQtTestCleanup::initTestCase() -{ -} +void PythonQtTestCleanup::initTestCase() {} -void PythonQtTestCleanup::cleanupTestCase() -{ -} +void PythonQtTestCleanup::cleanupTestCase() {} void PythonQtTestCleanup::init() { @@ -37,42 +33,36 @@ void PythonQtTestCleanup::cleanup() void PythonQtTestCleanup::testQtEnum() { - QVERIFY(_helper->runScript( - "import PythonQt.QtCore\n" \ - "x = PythonQt.QtCore.QFile.ReadOnly\n" \ - "obj.setPassed()" - )); + QVERIFY(_helper->runScript("import PythonQt.QtCore\n" + "x = PythonQt.QtCore.QFile.ReadOnly\n" + "obj.setPassed()")); } void PythonQtTestCleanup::testCallQtMethodInDestructorOwnedQTimer() { - QVERIFY(_helper->runScript( - "import PythonQt.QtCore\n" \ - "class TimerWrapper(object):\n" \ - " def __init__(self):\n" \ - " self.timer = PythonQt.QtCore.QTimer()\n" \ - " def __del__(self):\n" \ - " self.timer.setSingleShot(True)\n" \ - "x = TimerWrapper()\n" \ - "del x\n" \ - "obj.setPassed()\n" - )); + QVERIFY(_helper->runScript("import PythonQt.QtCore\n" + "class TimerWrapper(object):\n" + " def __init__(self):\n" + " self.timer = PythonQt.QtCore.QTimer()\n" + " def __del__(self):\n" + " self.timer.setSingleShot(True)\n" + "x = TimerWrapper()\n" + "del x\n" + "obj.setPassed()\n")); } void PythonQtTestCleanup::testCallQtMethodInDestructorWeakRefGuarded() { - QVERIFY(_helper->runScript( - "import weakref\n" \ - "import PythonQt.QtCore\n" \ - "class TimerWrapper(object):\n" \ - " def __init__(self):\n" \ - " self.timerWeakRef = weakref.ref(PythonQt.QtCore.QTimer())\n" \ - " def __del__(self):\n" \ - " if self.timerWeakRef():\n" \ - " self.timerWeakRef().setSingleShot(True)\n" \ - "x = TimerWrapper()\n" \ - "obj.setPassed()\n" - )); + QVERIFY(_helper->runScript("import weakref\n" + "import PythonQt.QtCore\n" + "class TimerWrapper(object):\n" + " def __init__(self):\n" + " self.timerWeakRef = weakref.ref(PythonQt.QtCore.QTimer())\n" + " def __del__(self):\n" + " if self.timerWeakRef():\n" + " self.timerWeakRef().setSingleShot(True)\n" + "x = TimerWrapper()\n" + "obj.setPassed()\n")); } void PythonQtTestCleanup::testSignalReceiverCleanup() @@ -81,18 +71,16 @@ void PythonQtTestCleanup::testSignalReceiverCleanup() // Test that PythonQtSignalReceiver is cleaned up properly, // i.e. PythonQt::cleanup() doesn't segfault - QVERIFY(_helper->runScript( - "import PythonQt.QtCore\n" \ - "timer = PythonQt.QtCore.QTimer(obj)\n" \ - "timer.connect('destroyed()', obj.onDestroyed)\n" \ - "obj.setPassed()\n" - )); + QVERIFY(_helper->runScript("import PythonQt.QtCore\n" + "timer = PythonQt.QtCore.QTimer(obj)\n" + "timer.connect('destroyed()', obj.onDestroyed)\n" + "obj.setPassed()\n")); } void PythonQtTestCleanup::testPyFinalizeThenPythonQtCleanup() { if (Py_IsInitialized()) { - Py_Finalize(); + Py_Finalize(); } PythonQt::cleanup(); diff --git a/tests/PythonQtTestCleanup.h b/tests/PythonQtTestCleanup.h index c7e593e24..32e188b64 100644 --- a/tests/PythonQtTestCleanup.h +++ b/tests/PythonQtTestCleanup.h @@ -31,15 +31,14 @@ class PythonQtTestCleanupHelper : public QObject { Q_OBJECT public: - PythonQtTestCleanupHelper() : - _passed(false) { - }; + PythonQtTestCleanupHelper() + : _passed(false) {}; bool runScript(const char* script); public Q_SLOTS: void setPassed() { _passed = true; } - void onDestroyed(QObject *) { } + void onDestroyed(QObject*) {} private: bool _passed; diff --git a/tests/PythonQtTestMain.cpp b/tests/PythonQtTestMain.cpp index 8b6dd82fe..1ae76e2a6 100644 --- a/tests/PythonQtTestMain.cpp +++ b/tests/PythonQtTestMain.cpp @@ -45,7 +45,7 @@ #include -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { QApplication qapp(argc, argv); @@ -83,4 +83,3 @@ int main(int argc, char *argv[]) } return failCount != 0 ? EXIT_FAILURE : EXIT_SUCCESS; } - diff --git a/tests/PythonQtTests.cpp b/tests/PythonQtTests.cpp index 6ae19bb7d..b9286e48b 100644 --- a/tests/PythonQtTests.cpp +++ b/tests/PythonQtTests.cpp @@ -60,7 +60,8 @@ void PythonQtMemoryTests::testInitAlreadyInitialized() PythonQt::cleanup(); } -void PythonQtMemoryTests::testSeveralCleanup() { +void PythonQtMemoryTests::testSeveralCleanup() +{ PythonQt::init(); PythonQt::cleanup(); @@ -68,7 +69,8 @@ void PythonQtMemoryTests::testSeveralCleanup() { PythonQt::cleanup(); } -void PythonQtMemoryTests::testInitWithPreconfig() { +void PythonQtMemoryTests::testInitWithPreconfig() +{ #if PY_VERSION_HEX >= 0x03080000 PyConfig config; PyConfig_InitPythonConfig(&config); @@ -86,37 +88,36 @@ void PythonQtTestSlotCalling::initTestCase() PythonQt::self()->addObject(main, "obj", _helper); } -void PythonQtTestSlotCalling::init() { - -} - +void PythonQtTestSlotCalling::init() {} -void* polymorphic_ClassB_Handler(const void* ptr, const char** className) { +void* polymorphic_ClassB_Handler(const void* ptr, const char** className) +{ ClassB* o = (ClassB*)ptr; - if (o->type()==2) { + if (o->type() == 2) { *className = "ClassB"; return (ClassB*)o; } - if (o->type()==3) { + if (o->type() == 3) { *className = "ClassC"; return (ClassC*)o; } - if (o->type()==4) { + if (o->type() == 4) { *className = "ClassD"; return (ClassD*)o; } return NULL; } -void PythonQtTestSlotCalling::testInheritance() { - PythonQt::self()->registerCPPClass("ClassA",NULL,NULL, PythonQtCreateObject); - PythonQt::self()->registerCPPClass("ClassB",NULL,NULL, PythonQtCreateObject); - PythonQt::self()->registerCPPClass("ClassC",NULL,NULL, PythonQtCreateObject); - PythonQt::self()->addParentClass("ClassC", "ClassA", PythonQtUpcastingOffset()); - PythonQt::self()->addParentClass("ClassC", "ClassB", PythonQtUpcastingOffset()); +void PythonQtTestSlotCalling::testInheritance() +{ + PythonQt::self()->registerCPPClass("ClassA", NULL, NULL, PythonQtCreateObject); + PythonQt::self()->registerCPPClass("ClassB", NULL, NULL, PythonQtCreateObject); + PythonQt::self()->registerCPPClass("ClassC", NULL, NULL, PythonQtCreateObject); + PythonQt::self()->addParentClass("ClassC", "ClassA", PythonQtUpcastingOffset()); + PythonQt::self()->addParentClass("ClassC", "ClassB", PythonQtUpcastingOffset()); PythonQt::self()->registerClass(&ClassD::staticMetaObject, NULL, PythonQtCreateObject); - PythonQt::self()->addParentClass("ClassD", "ClassA", PythonQtUpcastingOffset()); - PythonQt::self()->addParentClass("ClassD", "ClassB", PythonQtUpcastingOffset()); + PythonQt::self()->addParentClass("ClassD", "ClassA", PythonQtUpcastingOffset()); + PythonQt::self()->addParentClass("ClassD", "ClassB", PythonQtUpcastingOffset()); PythonQtObjectPtr classA = PythonQt::self()->getMainModule().getVariable("PythonQt.private.ClassA"); PythonQtObjectPtr classB = PythonQt::self()->getMainModule().getVariable("PythonQt.private.ClassB"); @@ -157,20 +158,34 @@ void PythonQtTestSlotCalling::testInheritance() { PythonQt::self()->addPolymorphicHandler("ClassB", polymorphic_ClassB_Handler); - QVERIFY(_helper->runScript("if type(obj.getClassBPtr(obj.createClassB()))==PythonQt.private.ClassB: obj.setPassed();\n")); + QVERIFY( + _helper->runScript("if type(obj.getClassBPtr(obj.createClassB()))==PythonQt.private.ClassB: obj.setPassed();\n")); QVERIFY(_helper->runScript("if type(obj.createClassCAsB())==PythonQt.private.ClassC: obj.setPassed();\n")); QVERIFY(_helper->runScript("if type(obj.createClassDAsB())==PythonQt.private.ClassD: obj.setPassed();\n")); - } -void PythonQtTestSlotCalling::testAutoConversion() { - QVERIFY(_helper->runScript("if obj.setAutoConvertColor(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.setAutoConvertBrush(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QBrush(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.setAutoConvertPen(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QPen(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.setAutoConvertBrush(PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red))==PythonQt.Qt.QBrush(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.setAutoConvertPen(PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red))==PythonQt.Qt.QPen(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.setAutoConvertCursor(PythonQt.Qt.QCursor(PythonQt.QtCore.Qt.UpArrowCursor)).shape()==PythonQt.Qt.QCursor(PythonQt.QtCore.Qt.UpArrowCursor).shape(): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.setAutoConvertCursor(PythonQt.QtCore.Qt.UpArrowCursor).shape()==PythonQt.Qt.QCursor(PythonQt.QtCore.Qt.UpArrowCursor).shape(): obj.setPassed();\n")); +void PythonQtTestSlotCalling::testAutoConversion() +{ + QVERIFY(_helper->runScript( + "if obj.setAutoConvertColor(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red): " + "obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.setAutoConvertBrush(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QBrush(PythonQt.QtCore.Qt.red): " + "obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.setAutoConvertPen(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QPen(PythonQt.QtCore.Qt.red): obj.setPassed();\n")); + QVERIFY(_helper->runScript("if " + "obj.setAutoConvertBrush(PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red))==PythonQt.Qt.QBrush(" + "PythonQt.QtCore.Qt.red): obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.setAutoConvertPen(PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red))==PythonQt.Qt.QPen(PythonQt.QtCore.Qt.red): " + "obj.setPassed();\n")); + QVERIFY(_helper->runScript("if " + "obj.setAutoConvertCursor(PythonQt.Qt.QCursor(PythonQt.QtCore.Qt.UpArrowCursor)).shape()==" + "PythonQt.Qt.QCursor(PythonQt.QtCore.Qt.UpArrowCursor).shape(): obj.setPassed();\n")); + QVERIFY(_helper->runScript("if " + "obj.setAutoConvertCursor(PythonQt.QtCore.Qt.UpArrowCursor).shape()==PythonQt.Qt.QCursor(" + "PythonQt.QtCore.Qt.UpArrowCursor).shape(): obj.setPassed();\n")); } void PythonQtTestSlotCalling::testNoArgSlotCall() @@ -191,7 +206,6 @@ void PythonQtTestSlotCalling::testOverloadedCall() QVERIFY(_helper->runScript("obj.overload(12,13); obj.setPassed();\n", 6)); } - void PythonQtTestSlotCalling::testKeywordCall() { QVERIFY(_helper->runScript("if obj.keywordInt(5,value=6)==11: obj.setPassed();\n")); @@ -205,20 +219,26 @@ void PythonQtTestSlotCalling::testPyObjectSlotCall() QVERIFY(_helper->runScript("if obj.getPyObject('Hello')=='Hello': obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.getPyObjectFromVariant(PythonQt)==PythonQt: obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.getPyObjectFromVariant2(PythonQt)==PythonQt: obj.setPassed();\n")); -// QVERIFY(_helper->runScript("if obj.getPyObjectFromPtr(PythonQt)==PythonQt: obj.setPassed();\n")); + // QVERIFY(_helper->runScript("if obj.getPyObjectFromPtr(PythonQt)==PythonQt: obj.setPassed();\n")); } void PythonQtTestSlotCalling::testCPPSlotCalls() { // test QColor compare operation - QVERIFY(_helper->runScript("if PythonQt.QtGui.QColor(1,2,3)==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();obj.testNoArg()\n")); - QVERIFY(_helper->runScript("if PythonQt.QtGui.QColor(1,2,3)!=PythonQt.QtGui.QColor(3,2,1): obj.setPassed();obj.testNoArg()\n")); + QVERIFY(_helper->runScript( + "if PythonQt.QtGui.QColor(1,2,3)==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();obj.testNoArg()\n")); + QVERIFY(_helper->runScript( + "if PythonQt.QtGui.QColor(1,2,3)!=PythonQt.QtGui.QColor(3,2,1): obj.setPassed();obj.testNoArg()\n")); // test passing/returning QColors - QVERIFY(_helper->runScript("if obj.getQColor1(PythonQt.QtGui.QColor(1,2,3))==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQColor2(PythonQt.QtGui.QColor(1,2,3))==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQColor3(PythonQt.QtGui.QColor(1,2,3))==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQColor4(PythonQt.QtGui.QColor(1,2,3))==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQColor1(PythonQt.QtGui.QColor(1,2,3))==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQColor2(PythonQt.QtGui.QColor(1,2,3))==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQColor3(PythonQt.QtGui.QColor(1,2,3))==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQColor4(PythonQt.QtGui.QColor(1,2,3))==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.getQColor5()==PythonQt.QtGui.QColor(1,2,3): obj.setPassed();\n")); } @@ -254,9 +274,11 @@ void PythonQtTestSlotCalling::testQVariantSlotCalls() QVERIFY(_helper->runScript("if obj.getQVariant('testStr')=='testStr': obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.getQVariant(('test','test2'))==('test','test2'): obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.getQVariant(('test',12, 47.11))==('test',12, 47.11): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQVariant({'test':'bla','test2':47.11})=={'test':'bla','test2':47.11}: obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQVariant({'test':'bla','test2':47.11})=={'test':'bla','test2':47.11}: obj.setPassed();\n")); QEXPECT_FAIL("", "Testing to pass a map and compare with a different map", Continue); - QVERIFY(_helper->runScript("if obj.getQVariant({'test':'bla2','test2':47.11})=={'test':'bla','test2':47.11}: obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQVariant({'test':'bla2','test2':47.11})=={'test':'bla','test2':47.11}: obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.getQVariant(obj)==obj: obj.setPassed();\n")); } @@ -264,8 +286,8 @@ void PythonQtTestSlotCalling::testQListSlotCalls() { QVERIFY(_helper->runScript("if obj.getQListInt()==(1,2,3): obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.getQListUnsignedInt()==(1,2,3): obj.setPassed();\n")); -// QVERIFY(_helper->runScript("if obj.getQListGLuint()==(1,2,3): obj.setPassed();\n")); -// QVERIFY(_helper->runScript("if obj.getQListGLuint64()==(1,2,3): obj.setPassed();\n")); + // QVERIFY(_helper->runScript("if obj.getQListGLuint()==(1,2,3): obj.setPassed();\n")); + // QVERIFY(_helper->runScript("if obj.getQListGLuint64()==(1,2,3): obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.getQListqint64()==(1,2,3): obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.getQListquint64()==(1,2,3): obj.setPassed();\n")); @@ -273,22 +295,33 @@ void PythonQtTestSlotCalling::testQListSlotCalls() QVERIFY(_helper->runScript("if obj.getQListdouble()==(1.1,2.2,3.3): obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.getQListfloat()==(1,2,3): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQListDayOfWeek((PythonQt.QtCore.Qt.Monday, PythonQt.QtCore.Qt.Friday))==(PythonQt.QtCore.Qt.Monday, PythonQt.QtCore.Qt.Friday): obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQListDayOfWeek((PythonQt.QtCore.Qt.Monday, PythonQt.QtCore.Qt.Friday))==(PythonQt.QtCore.Qt.Monday, " + "PythonQt.QtCore.Qt.Friday): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQPair((1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)))==(1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQPairVariant((1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)))==(1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)): obj.setPassed();\n")); + QVERIFY(_helper->runScript("if obj.getQPair((1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)))==(1.2, " + "PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)): obj.setPassed();\n")); + QVERIFY(_helper->runScript("if obj.getQPairVariant((1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)))==(1.2, " + "PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQVectorQPair1(((1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)),))==((1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)),): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQVectorQPair2(((1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)),))==((1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)),): obj.setPassed();\n")); + QVERIFY(_helper->runScript("if obj.getQVectorQPair1(((1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)),))==((1.2, " + "PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)),): obj.setPassed();\n")); + QVERIFY(_helper->runScript("if obj.getQVectorQPair2(((1.2, PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)),))==((1.2, " + "PythonQt.QtGui.QColor(PythonQt.QtCore.Qt.red)),): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQListQSize()==(PythonQt.QtCore.QSize(1,2), PythonQt.QtCore.QSize(3,4)): obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQListQSize((PythonQt.QtCore.QSize(1,2), PythonQt.QtCore.QSize(3,4)))==(PythonQt.QtCore.QSize(1,2), PythonQt.QtCore.QSize(3,4)): obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQListQSize()==(PythonQt.QtCore.QSize(1,2), PythonQt.QtCore.QSize(3,4)): obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQListQSize((PythonQt.QtCore.QSize(1,2), PythonQt.QtCore.QSize(3,4)))==(PythonQt.QtCore.QSize(1,2), " + "PythonQt.QtCore.QSize(3,4)): obj.setPassed();\n")); } void PythonQtTestSlotCalling::testQMapSlotCalls() { - QVERIFY(_helper->runScript("if obj.getQMapIntVariant({1:'test', 47:48, 49:47.11})=={1:'test', 47:48, 49:47.11}: obj.setPassed();\n")); - QVERIFY(_helper->runScript("if obj.getQMapIntString({1:'test', 47:'a', 49:'bcd'})=={1:'test', 47:'a', 49:'bcd'}: obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQMapIntVariant({1:'test', 47:48, 49:47.11})=={1:'test', 47:48, 49:47.11}: obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "if obj.getQMapIntString({1:'test', 47:'a', 49:'bcd'})=={1:'test', 47:'a', 49:'bcd'}: obj.setPassed();\n")); } void PythonQtTestSlotCalling::testObjectSlotCalls() @@ -312,56 +345,75 @@ void PythonQtTestSlotCalling::testCppFactory() QVERIFY(_helper->runScript("if obj.createPQCppObject(12).getHeight()==12: obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.createPQCppObject(12).getH()==12: obj.setPassed();\n")); QVERIFY(_helper->runScript("pq1 = obj.createPQCppObject(12);\n" - "pq2 = obj.createPQCppObject(13);\n" - "pq3 = obj.getPQCppObject(pq1);\n" - "pq4 = obj.getPQCppObject(pq2);\n" - "if pq3.getHeight()==12 and pq4.getHeight()==13: obj.setPassed();\n" - )); + "pq2 = obj.createPQCppObject(13);\n" + "pq3 = obj.getPQCppObject(pq1);\n" + "pq4 = obj.getPQCppObject(pq2);\n" + "if pq3.getHeight()==12 and pq4.getHeight()==13: obj.setPassed();\n")); QVERIFY(_helper->runScript("if obj.createPQCppObjectNoWrap(12).getH()==12: obj.setPassed();\n")); - + QVERIFY(_helper->runScript("if obj.getPQCppObjectNoWrapAsValue().getH()==47: obj.setPassed();\n")); - + qRegisterMetaType("PQUnknownButRegisteredValueObject"); - QVERIFY(_helper->runScript("a = obj.getUnknownButRegisteredValueObjectAsPtr();print(a);\nif a!=None: obj.setPassed();\n")); - QVERIFY(_helper->runScript("a = obj.getUnknownButRegisteredValueObjectAsValue();print(a);\nif a!=None: obj.setPassed();\n")); + QVERIFY( + _helper->runScript("a = obj.getUnknownButRegisteredValueObjectAsPtr();print(a);\nif a!=None: obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "a = obj.getUnknownButRegisteredValueObjectAsValue();print(a);\nif a!=None: obj.setPassed();\n")); QVERIFY(_helper->runScript("a = obj.getUnknownValueObjectAsPtr();print(a);\nif a!=None: obj.setPassed();\n")); - QEXPECT_FAIL("", "Testing by value return without the object being registered as QMetaType or having registered a default constructor decorator", Continue); + QEXPECT_FAIL("", + "Testing by value return without the object being registered as QMetaType or having registered a default " + "constructor decorator", + Continue); QVERIFY(_helper->runScript("a = obj.getUnknownValueObjectAsValue();print(a);\nif a!=None: obj.setPassed();\n")); - + // expect to get strict call to double overload - QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt.private import PQCppObjectNoWrap\na = PQCppObjectNoWrap(22.2)\nif a.getH()==2: obj.setPassed();\n")); + QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt.private import PQCppObjectNoWrap\na = " + "PQCppObjectNoWrap(22.2)\nif a.getH()==2: obj.setPassed();\n")); // expect to get un-strict call to double overload - QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt.private import PQCppObjectNoWrap\na = PQCppObjectNoWrap(22)\nif a.getH()==2: obj.setPassed();\n")); + QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt.private import PQCppObjectNoWrap\na = " + "PQCppObjectNoWrap(22)\nif a.getH()==2: obj.setPassed();\n")); // expect to get strict call to copy constructor overload - QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt.private import PQCppObjectNoWrap\na = PQCppObjectNoWrap(PQCppObjectNoWrap())\nprint(a.getH())\nif a.getH()==1: obj.setPassed();\n")); + QVERIFY( + _helper->runScript("obj.testNoArg()\nfrom PythonQt.private import PQCppObjectNoWrap\na = " + "PQCppObjectNoWrap(PQCppObjectNoWrap())\nprint(a.getH())\nif a.getH()==1: obj.setPassed();\n")); // test decorated enums // already registered by signals test //PythonQt::self()->registerCPPClass("PQCppObject2",NULL,NULL, PythonQtCreateObject); - + // local enum (decorated) - QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt.private import PQCppObject2\na = PQCppObject2()\nprint(a.testEnumFlag1)\nif a.testEnumFlag1(PQCppObject2.TestEnumValue2)==PQCppObject2.TestEnumValue2: obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "obj.testNoArg()\nfrom PythonQt.private import PQCppObject2\na = PQCppObject2()\nprint(a.testEnumFlag1)\nif " + "a.testEnumFlag1(PQCppObject2.TestEnumValue2)==PQCppObject2.TestEnumValue2: obj.setPassed();\n")); // enum with namespace (decorated) - QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt.private import PQCppObject2\na = PQCppObject2()\nif a.testEnumFlag2(PQCppObject2.TestEnumValue2)==PQCppObject2.TestEnumValue2: obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "obj.testNoArg()\nfrom PythonQt.private import PQCppObject2\na = PQCppObject2()\nif " + "a.testEnumFlag2(PQCppObject2.TestEnumValue2)==PQCppObject2.TestEnumValue2: obj.setPassed();\n")); // with int overload to check overloading - QVERIFY(_helper->runScript("obj.testNoArg()\nfrom PythonQt.private import PQCppObject2\na = PQCppObject2()\nif a.testEnumFlag3(PQCppObject2.TestEnumValue2)==PQCppObject2.TestEnumValue2: obj.setPassed();\n")); - + QVERIFY(_helper->runScript( + "obj.testNoArg()\nfrom PythonQt.private import PQCppObject2\na = PQCppObject2()\nif " + "a.testEnumFlag3(PQCppObject2.TestEnumValue2)==PQCppObject2.TestEnumValue2: obj.setPassed();\n")); } -PQCppObject2Decorator::TestEnumFlag PQCppObject2Decorator::testEnumFlag1(PQCppObject2* /*obj*/, PQCppObject2Decorator::TestEnumFlag flag) { +PQCppObject2Decorator::TestEnumFlag PQCppObject2Decorator::testEnumFlag1(PQCppObject2* /*obj*/, + PQCppObject2Decorator::TestEnumFlag flag) +{ return flag; } -PQCppObject2::TestEnumFlag PQCppObject2Decorator::testEnumFlag2(PQCppObject2* /*obj*/, PQCppObject2::TestEnumFlag flag) { +PQCppObject2::TestEnumFlag PQCppObject2Decorator::testEnumFlag2(PQCppObject2* /*obj*/, PQCppObject2::TestEnumFlag flag) +{ return flag; } // with int overload -PQCppObject2Decorator::TestEnumFlag PQCppObject2Decorator::testEnumFlag3(PQCppObject2* /*obj*/, int /*flag*/) { +PQCppObject2Decorator::TestEnumFlag PQCppObject2Decorator::testEnumFlag3(PQCppObject2* /*obj*/, int /*flag*/) +{ return (TestEnumFlag)-1; } -PQCppObject2Decorator::TestEnumFlag PQCppObject2Decorator::testEnumFlag3(PQCppObject2* /*obj*/, PQCppObject2Decorator::TestEnumFlag flag) { +PQCppObject2Decorator::TestEnumFlag PQCppObject2Decorator::testEnumFlag3(PQCppObject2* /*obj*/, + PQCppObject2Decorator::TestEnumFlag flag) +{ return flag; } @@ -374,14 +426,19 @@ void PythonQtTestSlotCalling::testProperties() { QVERIFY(_helper->runScript("obj.intProp = 47\nif obj.intProp == 47: obj.setPassed();\n")); QVERIFY(_helper->runScript("obj.floatProp = 47\nif obj.floatProp == 47: obj.setPassed();\n")); - QVERIFY(_helper->runScript("obj.variantListProp = (1,'test')\nif obj.variantListProp == (1,'test'): obj.setPassed();\n")); - QVERIFY(_helper->runScript("obj.variantMapProp = {'test':'a', 'bla':'blubb'}\nif obj.variantMapProp == {'test':'a', 'bla':'blubb'}: obj.setPassed();\n")); - QVERIFY(_helper->runScript("obj.variantProp = {'test':'a', 'bla':'blubb'}\nif obj.variantProp == {'test':'a', 'bla':'blubb'}: obj.setPassed();\n")); + QVERIFY( + _helper->runScript("obj.variantListProp = (1,'test')\nif obj.variantListProp == (1,'test'): obj.setPassed();\n")); + QVERIFY(_helper->runScript("obj.variantMapProp = {'test':'a', 'bla':'blubb'}\nif obj.variantMapProp == {'test':'a', " + "'bla':'blubb'}: obj.setPassed();\n")); + QVERIFY(_helper->runScript("obj.variantProp = {'test':'a', 'bla':'blubb'}\nif obj.variantProp == {'test':'a', " + "'bla':'blubb'}: obj.setPassed();\n")); QVERIFY(_helper->runScript("obj.variantProp = 'test'\nif obj.variantProp == 'test': obj.setPassed();\n")); QVERIFY(_helper->runScript("obj.variantProp = 47.11\nif obj.variantProp == 47.11: obj.setPassed();\n")); QVERIFY(_helper->runScript("obj.qObjectProp = obj\nif obj.qObjectProp == obj: obj.setPassed();\n")); - QVERIFY(_helper->runScript("obj.qObjectListProp = (obj,obj,obj)\nif obj.qObjectListProp == (obj,obj,obj): obj.setPassed();\n")); - QVERIFY(_helper->runScript("obj.sizeProp = PythonQt.QtCore.QSize(1,2)\nif obj.sizeProp == PythonQt.QtCore.QSize(1,2): obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "obj.qObjectListProp = (obj,obj,obj)\nif obj.qObjectListProp == (obj,obj,obj): obj.setPassed();\n")); + QVERIFY(_helper->runScript( + "obj.sizeProp = PythonQt.QtCore.QSize(1,2)\nif obj.sizeProp == PythonQt.QtCore.QSize(1,2): obj.setPassed();\n")); } bool PythonQtTestSlotCallingHelper::runScript(const char* script, int expectedOverload) @@ -390,10 +447,9 @@ bool PythonQtTestSlotCallingHelper::runScript(const char* script, int expectedOv _passed = false; _calledOverload = -1; PyRun_SimpleString(script); - return _called && _passed && _calledOverload==expectedOverload; + return _called && _passed && _calledOverload == expectedOverload; } - void PythonQtTestSignalHandler::initTestCase() { _helper = new PythonQtTestSignalHandlerHelper(this); @@ -413,12 +469,13 @@ void PythonQtTestSignalHandler::testSignalHandler() QVERIFY(_helper->emitFloatSignal(12)); // test decorated enums - PythonQt::self()->registerCPPClass("PQCppObject2",NULL,NULL, PythonQtCreateObject); + PythonQt::self()->registerCPPClass("PQCppObject2", NULL, NULL, PythonQtCreateObject); PyRun_SimpleString("def testEnumSignal(a):\n if a==1: obj.setPassed();\n"); - QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(enumSignal(PQCppObject2::TestEnumFlag)), main, "testEnumSignal")); + QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(enumSignal(PQCppObject2::TestEnumFlag)), main, + "testEnumSignal")); QVERIFY(_helper->emitEnumSignal(PQCppObject2::TestEnumValue2)); - + PyRun_SimpleString("def testVariantSignal(a):\n if a==obj.expectedVariant(): obj.setPassed();\n"); QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(variantSignal(QVariant)), main, "testVariantSignal")); _helper->setExpectedVariant(QString("Test")); @@ -430,21 +487,24 @@ void PythonQtTestSignalHandler::testSignalHandler() _helper->setExpectedVariant(QVariant::fromValue((QObject*)_helper)); QVERIFY(_helper->emitVariantSignal(QVariant::fromValue((QObject*)_helper))); - PyRun_SimpleString("def testComplexSignal(a,b,l,o):\n if a==12 and b==13 and l==('test1','test2') and o == obj: obj.setPassed();\n"); + PyRun_SimpleString( + "def testComplexSignal(a,b,l,o):\n if a==12 and b==13 and l==('test1','test2') and o == obj: obj.setPassed();\n"); // intentionally not normalized signal: - QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(complexSignal( int, float , const QStringList , QObject*)), main, "testComplexSignal")); - QVERIFY(_helper->emitComplexSignal(12,13,QStringList() << "test1" << "test2", _helper)); + QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(complexSignal(int, float, const QStringList, QObject*)), + main, "testComplexSignal")); + QVERIFY(_helper->emitComplexSignal(12, 13, QStringList() << "test1" << "test2", _helper)); // try removing the handler - QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(complexSignal( int, float , const QStringList , QObject*)), main, "testComplexSignal")); + QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(complexSignal(int, float, const QStringList, QObject*)), + main, "testComplexSignal")); // and emit the signal, which should fail because the handler was removed - QVERIFY(!_helper->emitComplexSignal(12,13,QStringList() << "test1" << "test2", _helper)); + QVERIFY(!_helper->emitComplexSignal(12, 13, QStringList() << "test1" << "test2", _helper)); QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(intSignal(int)), main, "testIntSignal")); QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(floatSignal(float)), main, "testFloatSignal")); QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(variantSignal(QVariant)), main, "testVariantSignal")); - QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(enumSignal(PQCppObject2::TestEnumFlag)), main, "testEnumSignal")); - + QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(enumSignal(PQCppObject2::TestEnumFlag)), main, + "testEnumSignal")); } void PythonQtTestSignalHandler::testRecursiveSignalHandler() @@ -459,7 +519,6 @@ void PythonQtTestSignalHandler::testRecursiveSignalHandler() QVERIFY(_helper->emitSignal1(12)); } - void PythonQtTestApi::initTestCase() { _helper = new PythonQtTestApiHelper(); @@ -479,7 +538,6 @@ void PythonQtTestApi::testProperties() main.evalScript("obj.objectName = 'hello2'"); QVERIFY(QString("hello2") == main.getVariable("obj.objectName").toString()); - } void PythonQtTestApi::testDynamicProperties() @@ -488,7 +546,7 @@ void PythonQtTestApi::testDynamicProperties() // this fails and should fail, but how could that be tested? // main.evalScript("obj.testProp = 1"); - + // create a new dynamic property main.evalScript("obj.setProperty('testProp','testValue')"); @@ -504,7 +562,7 @@ void PythonQtTestApi::testDynamicProperties() // check if dynamic property is in introspection QStringList l = PythonQt::self()->introspection(PythonQt::self()->getMainModule(), "obj", PythonQt::Anything); QVERIFY(l.contains("testProp")); - + // check with None, previous value expected main.evalScript("obj.testProp = None"); QVERIFY(12 == main.getVariable("obj.testProp").toInt()); @@ -515,21 +573,20 @@ void PythonQtTestApi::testDynamicProperties() // check if dynamic property is really gone QStringList l2 = PythonQt::self()->introspection(PythonQt::self()->getMainModule(), "obj", PythonQt::Anything); QVERIFY(!l2.contains("testProp")); - } - -bool PythonQtTestApiHelper::call(const QString& function, const QVariantList& args, const QVariant& expectedResult) { +bool PythonQtTestApiHelper::call(const QString& function, const QVariantList& args, const QVariant& expectedResult) +{ _passed = false; QVariant r = PythonQt::self()->call(PythonQt::self()->getMainModule(), function, args); - return _passed && expectedResult==r; + return _passed && expectedResult == r; } void PythonQtTestApi::testCall() { PythonQtObjectPtr main = PythonQt::self()->getMainModule(); - QVERIFY(qvariant_cast(PythonQt::self()->getVariable(main, "obj"))==_helper); + QVERIFY(qvariant_cast(PythonQt::self()->getVariable(main, "obj")) == _helper); PyRun_SimpleString("def testCallNoArgs():\n obj.setPassed();\n"); QVERIFY(_helper->call("testCallNoArgs", QVariantList(), QVariant())); @@ -538,9 +595,10 @@ void PythonQtTestApi::testCall() QVERIFY(_helper->call("testCall1", QVariantList() << QVariant("test"), QVariant(QString("test2")))); PyRun_SimpleString("def testCall2(a, b):\n if a=='test' and b==obj: obj.setPassed();\n return obj;\n"); - QVariant r = PythonQt::self()->call(PythonQt::self()->getMainModule(), "testCall2", QVariantList() << QVariant("test") << QVariant::fromValue((QObject*)_helper)); + QVariant r = PythonQt::self()->call(PythonQt::self()->getMainModule(), "testCall2", + QVariantList() << QVariant("test") << QVariant::fromValue((QObject*)_helper)); QObject* p = qvariant_cast(r); - QVERIFY(p==_helper); + QVERIFY(p == _helper); } void PythonQtTestApi::testVariables() @@ -548,10 +606,10 @@ void PythonQtTestApi::testVariables() PythonQt::self()->addObject(PythonQt::self()->getMainModule(), "someObject", _helper); QVariant v = PythonQt::self()->getVariable(PythonQt::self()->getMainModule(), "someObject"); QObject* p = qvariant_cast(v); - QVERIFY(p==_helper); + QVERIFY(p == _helper); // test for unset variable QVariant v2 = PythonQt::self()->getVariable(PythonQt::self()->getMainModule(), "someObject2"); - QVERIFY(v2==QVariant()); + QVERIFY(v2 == QVariant()); QVariant someValue = QStringList() << "test1" << "test2"; PythonQt::self()->addVariable(PythonQt::self()->getMainModule(), "someValue", someValue); @@ -568,7 +626,7 @@ void PythonQtTestApi::testVariables() // check that at least these three variables are set s << "obj" << "someObject" << "someValue"; for (const QString& value : s) { - QVERIFY(l.indexOf(value)!=-1); + QVERIFY(l.indexOf(value) != -1); } // insert a second time! @@ -577,7 +635,7 @@ void PythonQtTestApi::testVariables() PythonQt::self()->removeVariable(PythonQt::self()->getMainModule(), "someObject"); // we expect to find no variable QVariant v4 = PythonQt::self()->getVariable(PythonQt::self()->getMainModule(), "someObject"); - QVERIFY(v4==QVariant()); + QVERIFY(v4 == QVariant()); } void PythonQtTestApi::testImporter() @@ -589,8 +647,8 @@ void PythonQtTestApi::testImporter() void PythonQtTestApi::testQtNamespace() { - QVERIFY(_main.getVariable("PythonQt.QtCore.Qt.red").toInt()==Qt::red); - QVERIFY(_main.getVariable("PythonQt.QtCore.Qt.FlatCap").toInt()==Qt::FlatCap); + QVERIFY(_main.getVariable("PythonQt.QtCore.Qt.red").toInt() == Qt::red); + QVERIFY(_main.getVariable("PythonQt.QtCore.Qt.FlatCap").toInt() == Qt::FlatCap); QVERIFY(PythonQtObjectPtr(_main.getVariable("PythonQt.QtCore.Qt.mightBeRichText"))); // check for an enum type wrapper QVERIFY(PythonQtObjectPtr(_main.getVariable("PythonQt.QtCore.Qt.AlignmentFlag"))); @@ -600,7 +658,7 @@ void PythonQtTestApi::testQtNamespace() void PythonQtTestApi::testConnects() { -// QVERIFY(qvariant_cast(_main.evalScript("PythonQt.Qt.QColor(PythonQt.Qt.Qt.red)" ,Py_eval_input)) == QColor(Qt::red)); + // QVERIFY(qvariant_cast(_main.evalScript("PythonQt.Qt.QColor(PythonQt.Qt.Qt.red)" ,Py_eval_input)) == QColor(Qt::red)); //TODO: add signal/slot connect both with QObject.connect and connect } @@ -614,28 +672,29 @@ void PythonQtTestApi::testQColorDecorators() colorClass = _main.getVariable("PythonQt.Qt.QColor"); QVERIFY(colorClass); // constructors - QVERIFY(qvariant_cast(colorClass.call(QVariantList() << 1 << 2 << 3)) == QColor(1,2,3)); + QVERIFY(qvariant_cast(colorClass.call(QVariantList() << 1 << 2 << 3)) == QColor(1, 2, 3)); QVERIFY(qvariant_cast(colorClass.call()) == QColor()); QEXPECT_FAIL("", "Testing non-existing constructor", Continue); QVERIFY(colorClass.call(QVariantList() << 1 << 2) != QVariant()); // check that enum overload is taken over int - QVERIFY(qvariant_cast(_main.evalScript("PythonQt.Qt.QColor(PythonQt.Qt.Qt.red)" ,Py_eval_input)) == QColor(Qt::red)); + QVERIFY(qvariant_cast(_main.evalScript("PythonQt.Qt.QColor(PythonQt.Qt.Qt.red)", Py_eval_input)) + == QColor(Qt::red)); // check that int overload is taken over enum - QVERIFY(qvariant_cast(_main.evalScript("PythonQt.Qt.QColor(0x112233)" ,Py_eval_input)) == QColor(0x112233)); + QVERIFY(qvariant_cast(_main.evalScript("PythonQt.Qt.QColor(0x112233)", Py_eval_input)) == QColor(0x112233)); // check for decorated Cmyk enum value QVERIFY(colorClass.getVariable("Cmyk").toInt() == QColor::Cmyk); PythonQtObjectPtr staticMethod = colorClass.getVariable("fromRgb"); QVERIFY(staticMethod); // direct call of static method via class - QVERIFY(qvariant_cast(colorClass.call("fromRgb", QVariantList() << 1 << 2 << 3)) == QColor(1,2,3)); + QVERIFY(qvariant_cast(colorClass.call("fromRgb", QVariantList() << 1 << 2 << 3)) == QColor(1, 2, 3)); // direct call of static method - QVERIFY(qvariant_cast(staticMethod.call(QVariantList() << 1 << 2 << 3)) == QColor(1,2,3)); + QVERIFY(qvariant_cast(staticMethod.call(QVariantList() << 1 << 2 << 3)) == QColor(1, 2, 3)); PythonQtObjectPtr publicMethod = colorClass.getVariable("red"); QVERIFY(publicMethod); // call with passing self in: - QVERIFY(colorClass.call("red", QVariantList() << QColor(255,0,0)).toInt() == 255); + QVERIFY(colorClass.call("red", QVariantList() << QColor(255, 0, 0)).toInt() == 255); } QByteArray PythonQtTestApiHelper::readFileAsBytes(const QString& /*filename*/) @@ -656,11 +715,11 @@ bool PythonQtTestApiHelper::exists(const QString& /*filename*/) return true; } -QDateTime PythonQtTestApiHelper::lastModifiedDate(const QString& /*filename*/) { +QDateTime PythonQtTestApiHelper::lastModifiedDate(const QString& /*filename*/) +{ return QDateTime::currentDateTime(); } - void PythonQtTestApi::testRedirect() { connect(PythonQt::self(), SIGNAL(pythonStdOut(const QString&)), _helper, SLOT(stdOut(const QString&))); @@ -678,7 +737,7 @@ void PythonQtTestApiHelper::stdErr(const QString& s) qDebug() << s; } -QObject* PythonQtTestCppFactory::create(const QByteArray& name, void *ptr) +QObject* PythonQtTestCppFactory::create(const QByteArray& name, void* ptr) { if (name == "PQCppObject") { return new PQCppObjectWrapper(ptr); diff --git a/tests/PythonQtTests.h b/tests/PythonQtTests.h index 00f06cf46..3588107d1 100644 --- a/tests/PythonQtTests.h +++ b/tests/PythonQtTests.h @@ -87,20 +87,21 @@ private Q_SLOTS: void testProperties(); void testDynamicProperties(); - + private: PythonQtTestApiHelper* _helper; PythonQtObjectPtr _main; - }; -class ClassA { +class ClassA +{ public: ClassA() { x = 1; } int x; }; -class ClassB { +class ClassB +{ public: ClassB() { y = 2; } int y; @@ -108,7 +109,8 @@ class ClassB { virtual int type() { return 2; } }; -class ClassC : public ClassA, public ClassB { +class ClassC : public ClassA, public ClassB +{ public: ClassC() { z = 3; } int z; @@ -116,53 +118,57 @@ class ClassC : public ClassA, public ClassB { virtual int type() { return 3; } }; -class ClassD : public QObject, public ClassA, public ClassB { +class ClassD : public QObject, public ClassA, public ClassB +{ Q_OBJECT public: ClassD() { d = 4; } - public Q_SLOTS: - int getD() { return d; } +public Q_SLOTS: + int getD() { return d; } + private: int d; virtual int type() { return 4; } }; -class ClassAWrapper : public QObject { +class ClassAWrapper : public QObject +{ Q_OBJECT public Q_SLOTS: ClassA* new_ClassA() { return new ClassA; } int getX(ClassA* o) { return o->x; } }; -class ClassBWrapper : public QObject { +class ClassBWrapper : public QObject +{ Q_OBJECT public Q_SLOTS: ClassB* new_ClassB() { return new ClassB; } int getY(ClassB* o) { return o->y; } }; -class ClassCWrapper : public QObject { +class ClassCWrapper : public QObject +{ Q_OBJECT public Q_SLOTS: ClassC* new_ClassC() { return new ClassC; } int getZ(ClassC* o) { return o->z; } }; -class ClassDWrapper : public QObject { +class ClassDWrapper : public QObject +{ Q_OBJECT - public Q_SLOTS: - ClassD* new_ClassD() { return new ClassD; } +public Q_SLOTS: + ClassD* new_ClassD() { return new ClassD; } }; - //! test the PythonQt api (helper) -class PythonQtTestApiHelper : public QObject , public PythonQtImportFileInterface +class PythonQtTestApiHelper : public QObject, public PythonQtImportFileInterface { Q_OBJECT public: - PythonQtTestApiHelper() { - }; + PythonQtTestApiHelper() {}; bool call(const QString& function, const QVariantList& args, const QVariant& expectedResult); @@ -173,7 +179,7 @@ class PythonQtTestApiHelper : public QObject , public PythonQtImportFileInterfac virtual bool exists(const QString& filename); virtual QDateTime lastModifiedDate(const QString& filename); - + virtual bool isEggArchive(const QString&) { return false; } public Q_SLOTS: @@ -188,16 +194,16 @@ public Q_SLOTS: bool _passed; }; - // test implementation of the wrapper factory -class PythonQtTestCppFactory : public PythonQtCppWrapperFactory +class PythonQtTestCppFactory : public PythonQtCppWrapperFactory { public: - virtual QObject* create(const QByteArray& name, void *ptr); + virtual QObject* create(const QByteArray& name, void* ptr); }; //! an cpp object to be wrapped -class PQCppObject { +class PQCppObject +{ public: PQCppObject(int h) { _height = h; } @@ -210,30 +216,30 @@ class PQCppObject { }; //! an qobject that wraps the existing cpp object -class PQCppObjectWrapper : public QObject { +class PQCppObjectWrapper : public QObject +{ Q_OBJECT public: - PQCppObjectWrapper(void* ptr) { - _ptr = (PQCppObject*)ptr; - } + PQCppObjectWrapper(void* ptr) { _ptr = (PQCppObject*)ptr; } public Q_SLOTS: - int getHeight() { return _ptr->getHeight(); } + int getHeight() { return _ptr->getHeight(); } void setHeight(int h) { _ptr->setHeight(h); } private: PQCppObject* _ptr; }; -class PQCppObjectDecorator : public QObject { +class PQCppObjectDecorator : public QObject +{ Q_OBJECT public Q_SLOTS: - int getH(PQCppObject* obj) { return obj->getHeight(); } - + int getH(PQCppObject* obj) { return obj->getHeight(); } }; //! an cpp object to be wrapped by decorators only -class PQCppObjectNoWrap { +class PQCppObjectNoWrap +{ public: PQCppObjectNoWrap() { _height = 0; } @@ -246,65 +252,50 @@ class PQCppObjectNoWrap { int _height; }; -class PQCppObjectNoWrapDecorator : public QObject { +class PQCppObjectNoWrapDecorator : public QObject +{ Q_OBJECT - -public Q_SLOTS: - PQCppObjectNoWrap* new_PQCppObjectNoWrap() { - return new PQCppObjectNoWrap(0); - } - PQCppObjectNoWrap* new_PQCppObjectNoWrap(const PQCppObjectNoWrap& /*other*/) { - return new PQCppObjectNoWrap(1); - } - PQCppObjectNoWrap* new_PQCppObjectNoWrap(double /*value*/) { - return new PQCppObjectNoWrap(2); - } - int getH(PQCppObjectNoWrap* obj) { return obj->getHeight(); } +public Q_SLOTS: + PQCppObjectNoWrap* new_PQCppObjectNoWrap() { return new PQCppObjectNoWrap(0); } + PQCppObjectNoWrap* new_PQCppObjectNoWrap(const PQCppObjectNoWrap& /*other*/) { return new PQCppObjectNoWrap(1); } + PQCppObjectNoWrap* new_PQCppObjectNoWrap(double /*value*/) { return new PQCppObjectNoWrap(2); } + int getH(PQCppObjectNoWrap* obj) { return obj->getHeight(); } }; - //! an cpp object that is to be wrapped by decorators only -class PQCppObject2 { - +class PQCppObject2 +{ + public: - enum TestEnumFlag { - TestEnumValue1 = 0, - TestEnumValue2 = 1 - }; - + enum TestEnumFlag { TestEnumValue1 = 0, TestEnumValue2 = 1 }; + PQCppObject2() {} - }; -class PQCppObject2Decorator : public QObject { +class PQCppObject2Decorator : public QObject +{ Q_OBJECT - + public: Q_ENUMS(TestEnumFlag) Q_FLAGS(TestEnum) - - enum TestEnumFlag { - TestEnumValue1 = 0, - TestEnumValue2 = 1 - }; - + + enum TestEnumFlag { TestEnumValue1 = 0, TestEnumValue2 = 1 }; + Q_DECLARE_FLAGS(TestEnum, TestEnumFlag) - - public Q_SLOTS: - PQCppObject2* new_PQCppObject2() { - return new PQCppObject2(); - } + +public Q_SLOTS: + PQCppObject2* new_PQCppObject2() { return new PQCppObject2(); } TestEnumFlag testEnumFlag1(PQCppObject2* obj, TestEnumFlag flag); PQCppObject2::TestEnumFlag testEnumFlag2(PQCppObject2* obj, PQCppObject2::TestEnumFlag flag); - + // with int overload TestEnumFlag testEnumFlag3(PQCppObject2* obj, int flag); TestEnumFlag testEnumFlag3(PQCppObject2* obj, TestEnumFlag flag); - }; class PQUnknownValueObject @@ -346,7 +337,6 @@ private Q_SLOTS: private: PythonQtTestSlotCallingHelper* _helper; - }; //! helper class for slot calling test @@ -354,7 +344,8 @@ class PythonQtTestSlotCallingHelper : public QObject { Q_OBJECT public: - PythonQtTestSlotCallingHelper(PythonQtTestSlotCalling* test) { + PythonQtTestSlotCallingHelper(PythonQtTestSlotCalling* test) + { _test = test; _qObjectProp = NULL; }; @@ -364,39 +355,103 @@ class PythonQtTestSlotCallingHelper : public QObject Q_PROPERTY(int intProp READ intProp WRITE setIntProp) Q_PROPERTY(float floatProp READ floatProp WRITE setFloatProp) Q_PROPERTY(QVariantList variantListProp READ variantListProp WRITE setVariantListProp) - Q_PROPERTY(QVariantMap variantMapProp READ variantMapProp WRITE setVariantMapProp) - Q_PROPERTY(QVariant variantProp READ variantProp WRITE setVariantProp) - Q_PROPERTY(QObject* qObjectProp READ qObjectProp WRITE setQObjectProp) - Q_PROPERTY(QList qObjectListProp READ qObjectListProp WRITE setQObjectListProp) + Q_PROPERTY(QVariantMap variantMapProp READ variantMapProp WRITE setVariantMapProp) + Q_PROPERTY(QVariant variantProp READ variantProp WRITE setVariantProp) + Q_PROPERTY(QObject* qObjectProp READ qObjectProp WRITE setQObjectProp) + Q_PROPERTY(QList qObjectListProp READ qObjectListProp WRITE setQObjectListProp) Q_PROPERTY(QSize sizeProp READ sizeProp WRITE setSizeProp) public: - int intProp() const { _called = true; return _intProp; } - void setIntProp(int value) { _called = true; _intProp = value; } - float floatProp() const { _called = true; return _floatProp; } - void setFloatProp(float value) { _called = true; _floatProp = value; } + int intProp() const + { + _called = true; + return _intProp; + } + void setIntProp(int value) + { + _called = true; + _intProp = value; + } + float floatProp() const + { + _called = true; + return _floatProp; + } + void setFloatProp(float value) + { + _called = true; + _floatProp = value; + } - QVariantList variantListProp() const { _called = true; return _variantListProp; } - void setVariantListProp(const QVariantList& value) { _called = true; _variantListProp = value; } + QVariantList variantListProp() const + { + _called = true; + return _variantListProp; + } + void setVariantListProp(const QVariantList& value) + { + _called = true; + _variantListProp = value; + } - QVariantMap variantMapProp() const { _called = true; return _variantMapProp; } - void setVariantMapProp(const QVariantMap& value) { _called = true; _variantMapProp = value; } + QVariantMap variantMapProp() const + { + _called = true; + return _variantMapProp; + } + void setVariantMapProp(const QVariantMap& value) + { + _called = true; + _variantMapProp = value; + } - QVariant variantProp() const { _called = true; return _variantProp; } - void setVariantProp(const QVariant& value) { _called = true; _variantProp = value; } + QVariant variantProp() const + { + _called = true; + return _variantProp; + } + void setVariantProp(const QVariant& value) + { + _called = true; + _variantProp = value; + } - QObject* qObjectProp() const { _called = true; return _qObjectProp; } - void setQObjectProp(QObject* value) { _called = true; _qObjectProp = value; } + QObject* qObjectProp() const + { + _called = true; + return _qObjectProp; + } + void setQObjectProp(QObject* value) + { + _called = true; + _qObjectProp = value; + } - QObjectList qObjectListProp() const { _called = true; return _qObjectListProp; } - void setQObjectListProp(const QObjectList& value) { _called = true; _qObjectListProp = value; } + QObjectList qObjectListProp() const + { + _called = true; + return _qObjectListProp; + } + void setQObjectListProp(const QObjectList& value) + { + _called = true; + _qObjectListProp = value; + } - QSize sizeProp() const { _called = true; return _sizeProp; } - void setSizeProp(const QSize& value) { _called = true; _sizeProp = value; } + QSize sizeProp() const + { + _called = true; + return _sizeProp; + } + void setSizeProp(const QSize& value) + { + _called = true; + _sizeProp = value; + } private: - int _intProp; + int _intProp; float _floatProp; QVariantList _variantListProp; QVariantMap _variantMapProp; @@ -414,79 +469,270 @@ public Q_SLOTS: void testNoArg() { _called = true; } //! overload test! - void overload(bool /*a*/) { _calledOverload = 0; _called = true; } - void overload(float /*a*/) { _calledOverload = 1; _called = true;} - void overload(int /*a*/) { _calledOverload = 2; _called = true;} - void overload(const QString& /*str*/) { _calledOverload = 3; _called = true;} - void overload(const QStringList& /*str*/) { _calledOverload = 4; _called = true;} - void overload(QObject* /*str*/) { _calledOverload = 5; _called = true;} - void overload(float /*a*/, int /*b*/) { _calledOverload = 6; _called = true;} + void overload(bool /*a*/) + { + _calledOverload = 0; + _called = true; + } + void overload(float /*a*/) + { + _calledOverload = 1; + _called = true; + } + void overload(int /*a*/) + { + _calledOverload = 2; + _called = true; + } + void overload(const QString& /*str*/) + { + _calledOverload = 3; + _called = true; + } + void overload(const QStringList& /*str*/) + { + _calledOverload = 4; + _called = true; + } + void overload(QObject* /*str*/) + { + _calledOverload = 5; + _called = true; + } + void overload(float /*a*/, int /*b*/) + { + _calledOverload = 6; + _called = true; + } //!keyword argument tests - int keywordInt(int i, const QVariantMap& kwargs = QVariantMap()) { _called = true; return (i + kwargs["value"].toInt()); } - int keywordOnly(const QVariantMap& kwargs = QVariantMap()) { _called = true; return kwargs.count(); } + int keywordInt(int i, const QVariantMap& kwargs = QVariantMap()) + { + _called = true; + return (i + kwargs["value"].toInt()); + } + int keywordOnly(const QVariantMap& kwargs = QVariantMap()) + { + _called = true; + return kwargs.count(); + } //! POD values: - int getInt(int a) { _called = true; return a; } - unsigned int getUInt(unsigned int a) { _called = true; return a; } - bool getBool(bool a) { _called = true; return a; } - char getChar(char a) { _called = true; return a; } - unsigned char getUChar(unsigned char a) { _called = true; return a; } - long getLong(long a) { _called = true; return a; } - unsigned long getULong(unsigned long a) { _called = true; return a; } - short getShort(short a) { _called = true; return a; } - unsigned short getUShort(unsigned short a) { _called = true; return a; } - QChar getQChar(QChar a) { _called = true; return a; } - qint64 getLongLong(qint64 a) { _called = true; return a; } - quint64 getULongLong(quint64 a) { _called = true; return a; } - double getDouble(double d) { _called = true; return d; } - float getFloat(float d) { _called = true; return d; } + int getInt(int a) + { + _called = true; + return a; + } + unsigned int getUInt(unsigned int a) + { + _called = true; + return a; + } + bool getBool(bool a) + { + _called = true; + return a; + } + char getChar(char a) + { + _called = true; + return a; + } + unsigned char getUChar(unsigned char a) + { + _called = true; + return a; + } + long getLong(long a) + { + _called = true; + return a; + } + unsigned long getULong(unsigned long a) + { + _called = true; + return a; + } + short getShort(short a) + { + _called = true; + return a; + } + unsigned short getUShort(unsigned short a) + { + _called = true; + return a; + } + QChar getQChar(QChar a) + { + _called = true; + return a; + } + qint64 getLongLong(qint64 a) + { + _called = true; + return a; + } + quint64 getULongLong(quint64 a) + { + _called = true; + return a; + } + double getDouble(double d) + { + _called = true; + return d; + } + float getFloat(float d) + { + _called = true; + return d; + } //! important qt types: - QString getQString(const QString& s) { _called = true; return s; } - QStringList getQStringList(const QStringList& l) { _called = true; return l; } - QVariant getQVariant(const QVariant& var) { _called = true; return var; } - - QList getQListInt() { _called = true; return QList() << 1 << 2 << 3; } - QList getQListUnsignedInt() { _called = true; return QList() << 1 << 2 << 3; } - QList getQListqreal() { _called = true; return QList() << 1.1 << 2.2 << 3.3; } - QList getQListfloat() { _called = true; return QList() << 1 << 2 << 3; } - QList getQListdouble() { _called = true; return QList() << 1.1 << 2.2 << 3.3; } - QList getQListquint64() { _called = true; return QList() << 1 << 2 << 3; } - QList getQListqint64() { _called = true; return QList() << 1 << 2 << 3; } + QString getQString(const QString& s) + { + _called = true; + return s; + } + QStringList getQStringList(const QStringList& l) + { + _called = true; + return l; + } + QVariant getQVariant(const QVariant& var) + { + _called = true; + return var; + } + + QList getQListInt() + { + _called = true; + return QList() << 1 << 2 << 3; + } + QList getQListUnsignedInt() + { + _called = true; + return QList() << 1 << 2 << 3; + } + QList getQListqreal() + { + _called = true; + return QList() << 1.1 << 2.2 << 3.3; + } + QList getQListfloat() + { + _called = true; + return QList() << 1 << 2 << 3; + } + QList getQListdouble() + { + _called = true; + return QList() << 1.1 << 2.2 << 3.3; + } + QList getQListquint64() + { + _called = true; + return QList() << 1 << 2 << 3; + } + QList getQListqint64() + { + _called = true; + return QList() << 1 << 2 << 3; + } //QList getQListGLuint64() { _called = true; return QList() << 1 << 2 << 3; } //QList getQListGLuint() { _called = true; return QList() << 1 << 2 << 3; } - QList getQListQSize() { _called = true; return QList() << QSize(1,2) << QSize(3,4); } - QList getQListQSize(const QList& list) { _called = true; return list; } + QList getQListQSize() + { + _called = true; + return QList() << QSize(1, 2) << QSize(3, 4); + } + QList getQListQSize(const QList& list) + { + _called = true; + return list; + } + + QList getQListDayOfWeek(const QList& days) + { + _called = true; + return days; + } + + QMap getQMapIntVariant(const QMap& map) + { + _called = true; + return map; + } + QMap getQMapIntString(const QMap& map) + { + _called = true; + return map; + } - QList getQListDayOfWeek(const QList& days) { _called = true; return days; } - - QMap getQMapIntVariant(const QMap& map) { _called = true; return map; } - QMap getQMapIntString(const QMap& map) { _called = true; return map; } + QVector> getQVectorQPair1(const QVector>& list) + { + _called = true; + return list; + } + QVector> getQVectorQPair2(const QVector>& list) + { + _called = true; + return list; + } - QVector > getQVectorQPair1(const QVector > &list) { _called = true; return list; } - QVector > getQVectorQPair2(const QVector > &list) { _called = true; return list; } - - QPair getQPair(const QPair& pair) { _called = true; return pair; } + QPair getQPair(const QPair& pair) + { + _called = true; + return pair; + } - QPair getQPairVariant(const QPair& pair) { _called = true; return pair; } + QPair getQPairVariant(const QPair& pair) + { + _called = true; + return pair; + } // QColor as representative for C++ value classes - QColor getQColor1(const QColor& var) { _called = true; return var; } - QColor getQColor2(QColor& var) { _called = true; return var; } - QColor getQColor3(QColor* col) { _called = true; return *col; } - QColor getQColor4(const QVariant& color) { _called = true; return qvariant_cast(color); } - QColor* getQColor5() { _called = true; static QColor c(1,2,3); return &c; } + QColor getQColor1(const QColor& var) + { + _called = true; + return var; + } + QColor getQColor2(QColor& var) + { + _called = true; + return var; + } + QColor getQColor3(QColor* col) + { + _called = true; + return *col; + } + QColor getQColor4(const QVariant& color) + { + _called = true; + return qvariant_cast(color); + } + QColor* getQColor5() + { + _called = true; + static QColor c(1, 2, 3); + return &c; + } - PyObject* getPyObject(PyObject* obj) { + PyObject* getPyObject(PyObject* obj) + { _called = true; // returned object needs to get an extra ref count! Py_XINCREF(obj); return obj; } - PyObject* getPyObjectFromVariant(const QVariant& val) { + PyObject* getPyObjectFromVariant(const QVariant& val) + { _called = true; PythonQtObjectPtr value = val; PyObject* obj = value.object(); @@ -494,62 +740,186 @@ public Q_SLOTS: Py_XINCREF(obj); return obj; } - QVariant getPyObjectFromVariant2(const QVariant& val) { _called = true; return val; } + QVariant getPyObjectFromVariant2(const QVariant& val) + { + _called = true; + return val; + } //! testing pointer passing - PythonQtTestSlotCallingHelper* getTestObject(PythonQtTestSlotCallingHelper* obj) { _called = true; return obj; } + PythonQtTestSlotCallingHelper* getTestObject(PythonQtTestSlotCallingHelper* obj) + { + _called = true; + return obj; + } //! testing inheritance checking - QObject* getQObject(QObject* obj) { _called = true; return obj; } - QWidget* getQWidget(QWidget* obj) { _called = true; return obj; } + QObject* getQObject(QObject* obj) + { + _called = true; + return obj; + } + QWidget* getQWidget(QWidget* obj) + { + _called = true; + return obj; + } //! testing if an object that was not wrapped is wrapped earlier is wrapped correctly - QObject* getNewObject() { _called = true; return new PythonQtTestSlotCallingHelper(NULL); } + QObject* getNewObject() + { + _called = true; + return new PythonQtTestSlotCallingHelper(NULL); + } - QVariantList getMultiArgs(int a, double b, const QString& str) { _called = true; return (QVariantList() << a << b << str); } + QVariantList getMultiArgs(int a, double b, const QString& str) + { + _called = true; + return (QVariantList() << a << b << str); + } //! cpp wrapper factory test - PQCppObject* createPQCppObject(int h) { _called = true; return new PQCppObject(h); } + PQCppObject* createPQCppObject(int h) + { + _called = true; + return new PQCppObject(h); + } //! cpp wrapper factory test - PQCppObject* getPQCppObject(PQCppObject* p) { _called = true; return p; } + PQCppObject* getPQCppObject(PQCppObject* p) + { + _called = true; + return p; + } //! cpp wrapper factory test - PQCppObjectNoWrap* createPQCppObjectNoWrap(int h) { _called = true; return new PQCppObjectNoWrap(h); } + PQCppObjectNoWrap* createPQCppObjectNoWrap(int h) + { + _called = true; + return new PQCppObjectNoWrap(h); + } //! cpp wrapper factory test - PQCppObjectNoWrap* getPQCppObjectNoWrap(PQCppObjectNoWrap* p) { _called = true; return p; } + PQCppObjectNoWrap* getPQCppObjectNoWrap(PQCppObjectNoWrap* p) + { + _called = true; + return p; + } //! get a return by value PQCppObjectNoWrap - PQCppObjectNoWrap getPQCppObjectNoWrapAsValue() { _called = true; return PQCppObjectNoWrap(47); } - - PQUnknownButRegisteredValueObject getUnknownButRegisteredValueObjectAsValue() { _called = true; return PQUnknownButRegisteredValueObject(); } - PQUnknownValueObject getUnknownValueObjectAsValue() { _called = true; return PQUnknownValueObject(); } - - PQUnknownButRegisteredValueObject* getUnknownButRegisteredValueObjectAsPtr() { _called = true; return new PQUnknownButRegisteredValueObject(); } - PQUnknownValueObject* getUnknownValueObjectAsPtr() { _called = true; return new PQUnknownValueObject(); } - - ClassA* getClassAPtr(ClassA* o) { _called = true; return o; } - ClassB* getClassBPtr(ClassB* o) { _called = true; return o; } - ClassC* getClassCPtr(ClassC* o) { _called = true; return o; } - ClassD* getClassDPtr(ClassD* o) { _called = true; return o; } - - ClassA* createClassA() { _called = true; return new ClassA; } - ClassB* createClassB() { _called = true; return new ClassB; } - ClassC* createClassC() { _called = true; return new ClassC; } - ClassD* createClassD() { _called = true; return new ClassD; } - ClassA* createClassCAsA() { _called = true; return new ClassC; } - ClassB* createClassCAsB() { _called = true; return new ClassC; } - ClassA* createClassDAsA() { _called = true; return new ClassD; } - ClassB* createClassDAsB() { _called = true; return new ClassD; } - - QColor setAutoConvertColor(const QColor& color) { _called = true; return color; } - QBrush setAutoConvertBrush(const QBrush& brush) { _called = true; return brush; } - QPen setAutoConvertPen(const QPen& pen) { _called = true; return pen; } - QCursor setAutoConvertCursor(const QCursor& cursor) { _called = true; return cursor; } - + PQCppObjectNoWrap getPQCppObjectNoWrapAsValue() + { + _called = true; + return PQCppObjectNoWrap(47); + } + + PQUnknownButRegisteredValueObject getUnknownButRegisteredValueObjectAsValue() + { + _called = true; + return PQUnknownButRegisteredValueObject(); + } + PQUnknownValueObject getUnknownValueObjectAsValue() + { + _called = true; + return PQUnknownValueObject(); + } + + PQUnknownButRegisteredValueObject* getUnknownButRegisteredValueObjectAsPtr() + { + _called = true; + return new PQUnknownButRegisteredValueObject(); + } + PQUnknownValueObject* getUnknownValueObjectAsPtr() + { + _called = true; + return new PQUnknownValueObject(); + } + + ClassA* getClassAPtr(ClassA* o) + { + _called = true; + return o; + } + ClassB* getClassBPtr(ClassB* o) + { + _called = true; + return o; + } + ClassC* getClassCPtr(ClassC* o) + { + _called = true; + return o; + } + ClassD* getClassDPtr(ClassD* o) + { + _called = true; + return o; + } + + ClassA* createClassA() + { + _called = true; + return new ClassA; + } + ClassB* createClassB() + { + _called = true; + return new ClassB; + } + ClassC* createClassC() + { + _called = true; + return new ClassC; + } + ClassD* createClassD() + { + _called = true; + return new ClassD; + } + ClassA* createClassCAsA() + { + _called = true; + return new ClassC; + } + ClassB* createClassCAsB() + { + _called = true; + return new ClassC; + } + ClassA* createClassDAsA() + { + _called = true; + return new ClassD; + } + ClassB* createClassDAsB() + { + _called = true; + return new ClassD; + } + + QColor setAutoConvertColor(const QColor& color) + { + _called = true; + return color; + } + QBrush setAutoConvertBrush(const QBrush& brush) + { + _called = true; + return brush; + } + QPen setAutoConvertPen(const QPen& pen) + { + _called = true; + return pen; + } + QCursor setAutoConvertCursor(const QCursor& cursor) + { + _called = true; + return cursor; + } + private: bool _passed; mutable bool _called; - int _calledOverload; + int _calledOverload; PythonQtTestSlotCalling* _test; }; @@ -568,7 +938,6 @@ private Q_SLOTS: private: PythonQtTestSignalHandlerHelper* _helper; - }; //! helper class for signal testing @@ -577,26 +946,64 @@ class PythonQtTestSignalHandlerHelper : public QObject Q_OBJECT public: - PythonQtTestSignalHandlerHelper(PythonQtTestSignalHandler* test) { - _test = test; - } + PythonQtTestSignalHandlerHelper(PythonQtTestSignalHandler* test) { _test = test; } public Q_SLOTS: void setPassed() { _passed = true; } - bool emitIntSignal(int a) { _passed = false; emit intSignal(a); return _passed; } - bool emitFloatSignal(float a) { _passed = false; emit floatSignal(a); return _passed; } - bool emitEnumSignal(PQCppObject2::TestEnumFlag flag) { _passed = false; emit enumSignal(flag); return _passed; } + bool emitIntSignal(int a) + { + _passed = false; + emit intSignal(a); + return _passed; + } + bool emitFloatSignal(float a) + { + _passed = false; + emit floatSignal(a); + return _passed; + } + bool emitEnumSignal(PQCppObject2::TestEnumFlag flag) + { + _passed = false; + emit enumSignal(flag); + return _passed; + } - bool emitVariantSignal(const QVariant& v) { _passed = false; emit variantSignal(v); return _passed; } + bool emitVariantSignal(const QVariant& v) + { + _passed = false; + emit variantSignal(v); + return _passed; + } QVariant expectedVariant() { return _v; } void setExpectedVariant(const QVariant& v) { _v = v; } - bool emitComplexSignal(int a, float b, const QStringList& l, QObject* obj) { _passed = false; emit complexSignal(a,b,l,obj); return _passed; } + bool emitComplexSignal(int a, float b, const QStringList& l, QObject* obj) + { + _passed = false; + emit complexSignal(a, b, l, obj); + return _passed; + } - bool emitSignal1(int a) { _passed = false; emit signal1(a); return _passed; } - bool emitSignal2(const QString& s) { _passed = false; emit signal2(s); return _passed; } - bool emitSignal3(float a) { _passed = false; emit signal3(a); return _passed; } + bool emitSignal1(int a) + { + _passed = false; + emit signal1(a); + return _passed; + } + bool emitSignal2(const QString& s) + { + _passed = false; + emit signal2(s); + return _passed; + } + bool emitSignal3(float a) + { + _passed = false; + emit signal3(a); + return _passed; + } Q_SIGNALS: void intSignal(int); From d34047150db457028538c39d26fb1801e541e9c8 Mon Sep 17 00:00:00 2001 From: mrbean-bremen Date: Wed, 19 Nov 2025 12:59:13 +0100 Subject: [PATCH 3/4] Changes after removing training spaces --- .github/workflows/build.yml | 12 +- .github/workflows/build_latest.yml | 10 +- .github/workflows/builddocs.yml | 6 +- COPYING | 20 +- build/PythonQt.prf | 6 +- build/PythonQt_QtAll.prf | 4 +- build/common.prf | 2 +- build/python.prf | 6 +- .../CPPPyWrapperExample.pro | 6 +- examples/CPPPyWrapperExample/README.txt | 2 +- examples/CPPPyWrapperExample/eyed3tagger.py | 2 +- .../PyCPPWrapperExample.pro | 4 +- .../PyCustomMetaTypeExample.pro | 6 +- .../PyDecoratorsExample.pro | 6 +- examples/PyDecoratorsExample/example.py | 2 +- examples/PyGettingStarted/GettingStarted.py | 4 +- .../PyGettingStarted/PyGettingStarted.pro | 6 +- examples/PyGuiExample/PyGuiExample.pro | 8 +- examples/PyLauncher/PyLauncher.pro | 8 +- .../PyScriptingConsole/PyScriptingConsole.pro | 14 +- extensions/PythonQt_QtAll/PythonQt_QtAll.pro | 6 +- .../com_trolltech_qt_core0.cpp | 156 +++++++-------- .../com_trolltech_qt_core0.h | 16 +- .../com_trolltech_qt_core1.cpp | 132 ++++++------- .../com_trolltech_qt_core2.cpp | 102 +++++----- .../com_trolltech_qt_core2.h | 4 +- .../com_trolltech_qt_core3.cpp | 122 ++++++------ .../com_trolltech_qt_core4.cpp | 30 +-- .../com_trolltech_qt_core4.h | 2 +- .../com_trolltech_qt_core_init.cpp | 2 +- .../com_trolltech_qt_core_builtin0.cpp | 108 +++++----- .../com_trolltech_qt_core_builtin0.h | 2 +- .../com_trolltech_qt_gui0.cpp | 92 ++++----- .../com_trolltech_qt_gui1.cpp | 104 +++++----- .../com_trolltech_qt_gui10.cpp | 114 +++++------ .../com_trolltech_qt_gui11.cpp | 92 ++++----- .../com_trolltech_qt_gui11.h | 4 +- .../com_trolltech_qt_gui12.cpp | 112 +++++------ .../com_trolltech_qt_gui2.cpp | 94 ++++----- .../com_trolltech_qt_gui2.h | 4 +- .../com_trolltech_qt_gui3.cpp | 108 +++++----- .../com_trolltech_qt_gui4.cpp | 106 +++++----- .../com_trolltech_qt_gui5.cpp | 114 +++++------ .../com_trolltech_qt_gui5.h | 6 +- .../com_trolltech_qt_gui6.cpp | 104 +++++----- .../com_trolltech_qt_gui7.cpp | 122 ++++++------ .../com_trolltech_qt_gui8.cpp | 98 +++++----- .../com_trolltech_qt_gui9.cpp | 136 ++++++------- .../com_trolltech_qt_gui_builtin0.cpp | 184 +++++++++--------- .../com_trolltech_qt_multimedia0.cpp | 144 +++++++------- .../com_trolltech_qt_multimedia1.cpp | 132 ++++++------- .../com_trolltech_qt_multimedia2.cpp | 140 ++++++------- .../com_trolltech_qt_multimedia3.cpp | 46 ++--- .../com_trolltech_qt_network0.cpp | 118 +++++------ .../com_trolltech_qt_network1.cpp | 102 +++++----- .../com_trolltech_qt_network_init.cpp | 2 +- .../com_trolltech_qt_opengl0.cpp | 58 +++--- .../com_trolltech_qt_qml0.cpp | 126 ++++++------ .../com_trolltech_qt_quick0.cpp | 86 ++++---- .../com_trolltech_qt_quick1.cpp | 32 +-- .../com_trolltech_qt_sql0.cpp | 54 ++--- .../com_trolltech_qt_svg0.cpp | 20 +- .../com_trolltech_qt_uitools0.cpp | 2 +- .../com_trolltech_qt_webenginewidgets0.cpp | 56 +++--- .../com_trolltech_qt_webkit0.cpp | 58 +++--- .../com_trolltech_qt_xml0.cpp | 122 ++++++------ .../com_trolltech_qt_xml1.cpp | 38 ++-- .../com_trolltech_qt_xmlpatterns0.cpp | 86 ++++---- generator/CMakeLists.txt | 14 +- generator/LGPL_EXCEPTION.txt | 2 +- generator/LICENSE.LGPL | 20 +- generator/generator.pri | 4 +- generator/generator.pro | 2 +- generator/shellimplgenerator.cpp | 2 +- .../simplecpp/do_not_stop_on_error.patch | 2 +- generator/typesystem_network.xml | 10 +- generator/typesystem_opengl.xml | 4 +- generator/typesystem_quick.xml | 2 +- generator/typesystem_sql.xml | 2 +- generator/typesystem_svg.xml | 2 +- generator/typesystem_uitools.xml | 2 +- generator/typesystem_webenginewidgets.xml | 2 +- generator/typesystem_webkit.xml | 8 +- src/PythonQtDoc.h | 10 +- src/src.pri | 2 +- src/src.pro | 4 +- 86 files changed, 1963 insertions(+), 1963 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a05ce0fab..1c04b3a65 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,14 +2,14 @@ name: Build on: push: - branches: + branches: - main pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true - + defaults: run: shell: bash @@ -47,14 +47,14 @@ jobs: libqt5quickwidgets5* \ qtmultimedia5-dev apt-get clean - + - name: Checkout PythonQt uses: actions/checkout@v5 - name: Ccache uses: hendrikmuhs/ccache-action@v1.2.19 with: - key: ${{ runner.os }}-ubuntu-${{ matrix.container_version }} + key: ${{ runner.os }}-ubuntu-${{ matrix.container_version }} evict-old-files: 'job' - name: Build PythonQt (generator_only) @@ -237,9 +237,9 @@ jobs: - name: Ccache uses: hendrikmuhs/ccache-action@v1.2.19 with: - key: ${{ runner.os }}-${{ matrix.qt-version }} + key: ${{ runner.os }}-${{ matrix.qt-version }} evict-old-files: 'job' - + - name: Detect exact versions id : versions run : | diff --git a/.github/workflows/build_latest.yml b/.github/workflows/build_latest.yml index 8d1ca4a34..30ac95f6c 100644 --- a/.github/workflows/build_latest.yml +++ b/.github/workflows/build_latest.yml @@ -2,14 +2,14 @@ name: Check generated_cpp on: push: - branches: + branches: - main pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true - + defaults: run: shell: bash @@ -24,7 +24,7 @@ jobs: python-version: [ '3.12' ] runs-on: ${{ matrix.os }}-latest steps: - + - name: Install MSVC if: ${{ matrix.os == 'windows' }} uses: ilammy/msvc-dev-cmd@v1 @@ -52,7 +52,7 @@ jobs: key: ${{ runner.os }}-${{ matrix.qt-version }} evict-old-files: 'job' if: ${{ matrix.os == 'ubuntu' }} - + - name: Set environment id: setenv run: | @@ -113,7 +113,7 @@ jobs: PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \ UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \ make check TESTARGS="-platform offscreen" - + - name: Build PythonQt Windows (exclude_generator) shell: cmd if: ${{ matrix.os == 'windows' }} diff --git a/.github/workflows/builddocs.yml b/.github/workflows/builddocs.yml index efc32278b..668b312e4 100644 --- a/.github/workflows/builddocs.yml +++ b/.github/workflows/builddocs.yml @@ -2,7 +2,7 @@ name: Build and Deploy Documentation on: push: - branches: + branches: - main defaults: @@ -21,11 +21,11 @@ jobs: - name: Build documentation run: | - cd doxygen + cd doxygen doxygen touch html/.nojekyll cd .. - + - name: Deploy to GitHub Pages uses: JamesIves/github-pages-deploy-action@v4 with: diff --git a/COPYING b/COPYING index c00103def..67870f655 100644 --- a/COPYING +++ b/COPYING @@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - + Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a @@ -111,7 +111,7 @@ modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - + GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - + 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an @@ -158,7 +158,7 @@ Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - + 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 @@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - + Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. @@ -267,7 +267,7 @@ Library will still fall under Section 6.) distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - + 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work @@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - + 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined @@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - + 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or @@ -422,7 +422,7 @@ conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - + 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is @@ -456,7 +456,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - + How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest diff --git a/build/PythonQt.prf b/build/PythonQt.prf index 208c10742..fb80d3efc 100644 --- a/build/PythonQt.prf +++ b/build/PythonQt.prf @@ -1,14 +1,14 @@ # profile for non-mevis users to link to PythonQt -include ( python.prf ) +include ( python.prf ) INCLUDEPATH += $$PWD/../src # check if debug or release CONFIG(debug, debug|release) { - DEBUG_EXT = _d + DEBUG_EXT = _d } else { - DEBUG_EXT = + DEBUG_EXT = } PYTHONQT_LIB_NAME=PythonQt-Qt$${QT_MAJOR_VERSION}-Python$${PYTHON_VERSION}$${DEBUG_EXT} diff --git a/build/PythonQt_QtAll.prf b/build/PythonQt_QtAll.prf index dffc4806d..02f4ad2f2 100644 --- a/build/PythonQt_QtAll.prf +++ b/build/PythonQt_QtAll.prf @@ -4,9 +4,9 @@ INCLUDEPATH += $$PWD/../extensions/PythonQt_QtAll # check if debug or release CONFIG(debug, debug|release) { - DEBUG_EXT = _d + DEBUG_EXT = _d } else { - DEBUG_EXT = + DEBUG_EXT = } diff --git a/build/common.prf b/build/common.prf index 90a845f48..ba3b80ada 100644 --- a/build/common.prf +++ b/build/common.prf @@ -14,7 +14,7 @@ # for all debug builds, add "_d" extension to target CONFIG(debug, debug|release) { - TARGET = $${TARGET}_d + TARGET = $${TARGET}_d } # Allow override (e.g., qmake PYTHONQT_GENERATED_PATH=/abs/path) diff --git a/build/python.prf b/build/python.prf index aec051e90..900a54121 100644 --- a/build/python.prf +++ b/build/python.prf @@ -58,9 +58,9 @@ contains(PKGCONFIG, "python.*"){ # check if debug or release CONFIG(debug, debug|release) { - DEBUG_EXT = _d + DEBUG_EXT = _d } else { - DEBUG_EXT = + DEBUG_EXT = } isEmpty(PYTHON_PATH):PYTHON_PATH=$(PYTHON_PATH) @@ -79,7 +79,7 @@ contains(PKGCONFIG, "python.*"){ } else:unix { # on linux, python-config is used to autodetect Python. # make sure that you have installed a matching python-dev package. - + PYTHON_CONFIG = $${PYTHON_DIR}/bin/python$${PYTHON_VERSION}-config PYTHON_CONFIG_OPTIONS_LIBS = --libs equals(PYTHON_VERSION_MAJOR, 3):!lessThan(PYTHON_VERSION_MINOR, 8) { diff --git a/examples/CPPPyWrapperExample/CPPPyWrapperExample.pro b/examples/CPPPyWrapperExample/CPPPyWrapperExample.pro index 164349955..f8dd44706 100644 --- a/examples/CPPPyWrapperExample/CPPPyWrapperExample.pro +++ b/examples/CPPPyWrapperExample/CPPPyWrapperExample.pro @@ -6,12 +6,12 @@ mac:CONFIG -= app_bundle DESTDIR = ../../lib -include ( ../../build/common.prf ) -include ( ../../build/PythonQt.prf ) +include ( ../../build/common.prf ) +include ( ../../build/PythonQt.prf ) QT += widgets SOURCES += \ - CPPPyWrapperExample.cpp + CPPPyWrapperExample.cpp RESOURCES += CPPPyWrapperExample.qrc diff --git a/examples/CPPPyWrapperExample/README.txt b/examples/CPPPyWrapperExample/README.txt index 41de29374..df3925b1e 100644 --- a/examples/CPPPyWrapperExample/README.txt +++ b/examples/CPPPyWrapperExample/README.txt @@ -2,6 +2,6 @@ This example shows how to add user defined Python classes to the embedded Python mainModule. It also shows how to create objects in Python, -hold onto reference counted smart pointers to them from +hold onto reference counted smart pointers to them from a Qt application, and invoke methods on them via the PythonQtObjectPtr interface. diff --git a/examples/CPPPyWrapperExample/eyed3tagger.py b/examples/CPPPyWrapperExample/eyed3tagger.py index 78e522ef9..e8ca65d2a 100644 --- a/examples/CPPPyWrapperExample/eyed3tagger.py +++ b/examples/CPPPyWrapperExample/eyed3tagger.py @@ -5,6 +5,6 @@ def __init__(self, fileName = None): def fileName(self): return self.fn - + def setFileName(self, fileName): self.fn = fileName diff --git a/examples/PyCPPWrapperExample/PyCPPWrapperExample.pro b/examples/PyCPPWrapperExample/PyCPPWrapperExample.pro index 7ada73196..efb4325a1 100644 --- a/examples/PyCPPWrapperExample/PyCPPWrapperExample.pro +++ b/examples/PyCPPWrapperExample/PyCPPWrapperExample.pro @@ -9,8 +9,8 @@ TEMPLATE = app DESTDIR = ../../lib -include ( ../../build/common.prf ) -include ( ../../build/PythonQt.prf ) +include ( ../../build/common.prf ) +include ( ../../build/PythonQt.prf ) QT += widgets diff --git a/examples/PyCustomMetaTypeExample/PyCustomMetaTypeExample.pro b/examples/PyCustomMetaTypeExample/PyCustomMetaTypeExample.pro index 952449f5a..735c936ac 100644 --- a/examples/PyCustomMetaTypeExample/PyCustomMetaTypeExample.pro +++ b/examples/PyCustomMetaTypeExample/PyCustomMetaTypeExample.pro @@ -9,9 +9,9 @@ TEMPLATE = app DESTDIR = ../../lib -include ( ../../build/common.prf ) -include ( ../../build/PythonQt.prf ) - +include ( ../../build/common.prf ) +include ( ../../build/PythonQt.prf ) + QT += widgets HEADERS += \ diff --git a/examples/PyDecoratorsExample/PyDecoratorsExample.pro b/examples/PyDecoratorsExample/PyDecoratorsExample.pro index 06bb8de4d..c0788d05e 100644 --- a/examples/PyDecoratorsExample/PyDecoratorsExample.pro +++ b/examples/PyDecoratorsExample/PyDecoratorsExample.pro @@ -9,9 +9,9 @@ TEMPLATE = app DESTDIR = ../../lib -include ( ../../build/common.prf ) -include ( ../../build/PythonQt.prf ) - +include ( ../../build/common.prf ) +include ( ../../build/PythonQt.prf ) + QT += widgets HEADERS += \ diff --git a/examples/PyDecoratorsExample/example.py b/examples/PyDecoratorsExample/example.py index 4c7267cc7..f08d3190d 100644 --- a/examples/PyDecoratorsExample/example.py +++ b/examples/PyDecoratorsExample/example.py @@ -21,7 +21,7 @@ # call the wrapped method on CPP object print (yourCpp.doSomething(3)) -# show slots available on yourCpp +# show slots available on yourCpp print (dir(yourCpp)) # destructor will be called: diff --git a/examples/PyGettingStarted/GettingStarted.py b/examples/PyGettingStarted/GettingStarted.py index ff88dcbba..bd8e26607 100644 --- a/examples/PyGettingStarted/GettingStarted.py +++ b/examples/PyGettingStarted/GettingStarted.py @@ -7,7 +7,7 @@ box.browser.html = 'Hello Qt!' # set the title of the button -box.button1.text = 'Append Text' +box.button1.text = 'Append Text' # set the text of the line edit box.edit.text = '42' @@ -16,7 +16,7 @@ # to the text browser def appendLine(): box.browser.append(box.edit.text) - + # connect the button's clicked signal to our python method box.button1.connect('clicked()', appendLine) # connect the lineedit's returnPressed signal to our python method diff --git a/examples/PyGettingStarted/PyGettingStarted.pro b/examples/PyGettingStarted/PyGettingStarted.pro index bf1d4d050..985cded33 100644 --- a/examples/PyGettingStarted/PyGettingStarted.pro +++ b/examples/PyGettingStarted/PyGettingStarted.pro @@ -11,12 +11,12 @@ DESTDIR = ../../lib CONFIG += console -include ( ../../build/common.prf ) -include ( ../../build/PythonQt.prf ) +include ( ../../build/common.prf ) +include ( ../../build/PythonQt.prf ) QT += widgets SOURCES += \ - main.cpp + main.cpp RESOURCES += PyGettingStarted.qrc diff --git a/examples/PyGuiExample/PyGuiExample.pro b/examples/PyGuiExample/PyGuiExample.pro index bd200da05..c9524ccc1 100644 --- a/examples/PyGuiExample/PyGuiExample.pro +++ b/examples/PyGuiExample/PyGuiExample.pro @@ -13,11 +13,11 @@ DESTDIR = ../../lib QT += widgets -include ( ../../build/common.prf ) -include ( ../../build/PythonQt.prf ) -include ( ../../build/PythonQt_QtAll.prf ) +include ( ../../build/common.prf ) +include ( ../../build/PythonQt.prf ) +include ( ../../build/PythonQt_QtAll.prf ) SOURCES += \ - main.cpp + main.cpp RESOURCES += PyGuiExample.qrc diff --git a/examples/PyLauncher/PyLauncher.pro b/examples/PyLauncher/PyLauncher.pro index e8b9686b1..1954896c4 100644 --- a/examples/PyLauncher/PyLauncher.pro +++ b/examples/PyLauncher/PyLauncher.pro @@ -13,9 +13,9 @@ DESTDIR = ../../lib QT += widgets -include ( ../../build/common.prf ) -include ( ../../build/PythonQt.prf ) -include ( ../../build/PythonQt_QtAll.prf ) +include ( ../../build/common.prf ) +include ( ../../build/PythonQt.prf ) +include ( ../../build/PythonQt_QtAll.prf ) SOURCES += \ - main.cpp + main.cpp diff --git a/examples/PyScriptingConsole/PyScriptingConsole.pro b/examples/PyScriptingConsole/PyScriptingConsole.pro index b2b7b5115..64b7a3f23 100644 --- a/examples/PyScriptingConsole/PyScriptingConsole.pro +++ b/examples/PyScriptingConsole/PyScriptingConsole.pro @@ -11,17 +11,17 @@ DESTDIR = ../../lib mac:CONFIG-= app_bundle -include ( ../../build/common.prf ) -include ( ../../build/PythonQt.prf ) -include ( ../../build/PythonQt_QtAll.prf ) +include ( ../../build/common.prf ) +include ( ../../build/PythonQt.prf ) +include ( ../../build/PythonQt_QtAll.prf ) QT += widgets HEADERS += \ - PyExampleObject.h - + PyExampleObject.h + SOURCES += \ - PyExampleObject.cpp \ - main.cpp + PyExampleObject.cpp \ + main.cpp RESOURCES += PyScriptingConsole.qrc diff --git a/extensions/PythonQt_QtAll/PythonQt_QtAll.pro b/extensions/PythonQt_QtAll/PythonQt_QtAll.pro index 39293951d..8931d18c4 100644 --- a/extensions/PythonQt_QtAll/PythonQt_QtAll.pro +++ b/extensions/PythonQt_QtAll/PythonQt_QtAll.pro @@ -35,8 +35,8 @@ TEMPLATE = lib DESTDIR = ../../lib -include ( ../../build/common.prf ) -include ( ../../build/PythonQt.prf ) +include ( ../../build/common.prf ) +include ( ../../build/PythonQt.prf ) TARGET = $$replace(TARGET, PythonXY, Python$${PYTHON_VERSION}) CONFIG += qt strict_c++ msvc_mp @@ -51,7 +51,7 @@ DEFINES += PYTHONQT_QTALL_EXPORTS HEADERS += \ $$PWD/PythonQt_QtAll.h - + SOURCES += \ $$PWD/PythonQt_QtAll.cpp diff --git a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core0.cpp b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core0.cpp index 936bfdd90..a61fdacbf 100644 --- a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core0.cpp +++ b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core0.cpp @@ -235,7 +235,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAnimation::updateDirection(QAbstractAnimation::Direction direction0) { @@ -282,7 +282,7 @@ if (_wrapper) { QAbstractAnimation::updateState(newState0, oldState1); } QAbstractAnimation* PythonQtWrapper_QAbstractAnimation::new_QAbstractAnimation(QObject* parent) -{ +{ return new PythonQtShell_QAbstractAnimation(parent); } const QMetaObject* PythonQtShell_QAbstractAnimation::metaObject() const { @@ -1596,7 +1596,7 @@ if (_wrapper) { QAbstractItemModel::timerEvent(event0); } QAbstractItemModel* PythonQtWrapper_QAbstractItemModel::new_QAbstractItemModel(QObject* parent) -{ +{ return new PythonQtShell_QAbstractItemModel(parent); } const QMetaObject* PythonQtShell_QAbstractItemModel::metaObject() const { @@ -3041,7 +3041,7 @@ if (_wrapper) { QAbstractListModel::timerEvent(event0); } QAbstractListModel* PythonQtWrapper_QAbstractListModel::new_QAbstractListModel(QObject* parent) -{ +{ return new PythonQtShell_QAbstractListModel(parent); } const QMetaObject* PythonQtShell_QAbstractListModel::metaObject() const { @@ -3193,7 +3193,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractState::onExit(QEvent* event0) { @@ -3215,7 +3215,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractState::timerEvent(QTimerEvent* event0) { @@ -3240,7 +3240,7 @@ if (_wrapper) { QAbstractState::timerEvent(event0); } QAbstractState* PythonQtWrapper_QAbstractState::new_QAbstractState(QState* parent) -{ +{ return new PythonQtShell_QAbstractState(parent); } const QMetaObject* PythonQtShell_QAbstractState::metaObject() const { @@ -3450,7 +3450,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractTransition::timerEvent(QTimerEvent* event0) { @@ -3475,7 +3475,7 @@ if (_wrapper) { QAbstractTransition::timerEvent(event0); } QAbstractTransition* PythonQtWrapper_QAbstractTransition::new_QAbstractTransition(QState* sourceState) -{ +{ return new PythonQtShell_QAbstractTransition(sourceState); } const QMetaObject* PythonQtShell_QAbstractTransition::metaObject() const { @@ -3747,7 +3747,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAnimationGroup::updateDirection(QAbstractAnimation::Direction direction0) { @@ -3794,7 +3794,7 @@ if (_wrapper) { QAnimationGroup::updateState(newState0, oldState1); } QAnimationGroup* PythonQtWrapper_QAnimationGroup::new_QAnimationGroup(QObject* parent) -{ +{ return new PythonQtShell_QAnimationGroup(parent); } const QMetaObject* PythonQtShell_QAnimationGroup::metaObject() const { @@ -3853,7 +3853,7 @@ PythonQtPassOwnershipToPython PythonQtWrapper_QAnimationG QApplicationStateChangeEvent* PythonQtWrapper_QApplicationStateChangeEvent::new_QApplicationStateChangeEvent(Qt::ApplicationState state) -{ +{ return new QApplicationStateChangeEvent(state); } Qt::ApplicationState PythonQtWrapper_QApplicationStateChangeEvent::applicationState(QApplicationStateChangeEvent* theWrappedObject) const @@ -3868,7 +3868,7 @@ PythonQtShell_QBasicMutex::~PythonQtShell_QBasicMutex() { if (priv) { priv->shellClassDeleted(this); } } QBasicMutex* PythonQtWrapper_QBasicMutex::new_QBasicMutex() -{ +{ return new PythonQtShell_QBasicMutex(); } bool PythonQtWrapper_QBasicMutex::isRecursive(QBasicMutex* theWrappedObject) @@ -3904,11 +3904,11 @@ void PythonQtWrapper_QBasicMutex::unlock(QBasicMutex* theWrappedObject) QBasicTimer* PythonQtWrapper_QBasicTimer::new_QBasicTimer() -{ +{ return new QBasicTimer(); } QBasicTimer* PythonQtWrapper_QBasicTimer::new_QBasicTimer(const QBasicTimer& arg__1) -{ +{ return new QBasicTimer(arg__1); } bool PythonQtWrapper_QBasicTimer::isActive(QBasicTimer* theWrappedObject) const @@ -4646,11 +4646,11 @@ if (_wrapper) { return QBuffer::writeData(data0, len1); } QBuffer* PythonQtWrapper_QBuffer::new_QBuffer(QByteArray* buf, QObject* parent) -{ +{ return new PythonQtShell_QBuffer(buf, parent); } QBuffer* PythonQtWrapper_QBuffer::new_QBuffer(QObject* parent) -{ +{ return new PythonQtShell_QBuffer(parent); } const QMetaObject* PythonQtShell_QBuffer::metaObject() const { @@ -4699,19 +4699,19 @@ void PythonQtWrapper_QBuffer::setData(QBuffer* theWrappedObject, const QByteArra QByteArrayMatcher* PythonQtWrapper_QByteArrayMatcher::new_QByteArrayMatcher() -{ +{ return new QByteArrayMatcher(); } QByteArrayMatcher* PythonQtWrapper_QByteArrayMatcher::new_QByteArrayMatcher(const QByteArray& pattern) -{ +{ return new QByteArrayMatcher(pattern); } QByteArrayMatcher* PythonQtWrapper_QByteArrayMatcher::new_QByteArrayMatcher(const QByteArrayMatcher& other) -{ +{ return new QByteArrayMatcher(other); } QByteArrayMatcher* PythonQtWrapper_QByteArrayMatcher::new_QByteArrayMatcher(const char* pattern, int length) -{ +{ return new QByteArrayMatcher(pattern, length); } int PythonQtWrapper_QByteArrayMatcher::indexIn(QByteArrayMatcher* theWrappedObject, const QByteArray& ba, int from) const @@ -4741,7 +4741,7 @@ PythonQtShell_QByteArray__FromBase64Result::~PythonQtShell_QByteArray__FromBase6 if (priv) { priv->shellClassDeleted(this); } } QByteArray::FromBase64Result* PythonQtWrapper_QByteArray__FromBase64Result::new_QByteArray__FromBase64Result() -{ +{ return new PythonQtShell_QByteArray__FromBase64Result(); } bool PythonQtWrapper_QByteArray__FromBase64Result::operator_cast_bool(QByteArray::FromBase64Result* theWrappedObject) const @@ -4777,19 +4777,19 @@ void PythonQtWrapper_QByteArray__FromBase64Result::swap(QByteArray::FromBase64Re QCalendar* PythonQtWrapper_QCalendar::new_QCalendar() -{ +{ return new QCalendar(); } QCalendar* PythonQtWrapper_QCalendar::new_QCalendar(QCalendar::System system) -{ +{ return new QCalendar(system); } QCalendar* PythonQtWrapper_QCalendar::new_QCalendar(QLatin1String name) -{ +{ return new QCalendar(name); } QCalendar* PythonQtWrapper_QCalendar::new_QCalendar(QStringView name) -{ +{ return new QCalendar(name); } QStringList PythonQtWrapper_QCalendar::static_QCalendar_availableCalendars() @@ -4929,11 +4929,11 @@ PythonQtShell_QCalendar__YearMonthDay::~PythonQtShell_QCalendar__YearMonthDay() if (priv) { priv->shellClassDeleted(this); } } QCalendar::YearMonthDay* PythonQtWrapper_QCalendar__YearMonthDay::new_QCalendar__YearMonthDay() -{ +{ return new PythonQtShell_QCalendar__YearMonthDay(); } QCalendar::YearMonthDay* PythonQtWrapper_QCalendar__YearMonthDay::new_QCalendar__YearMonthDay(int y, int m, int d) -{ +{ return new PythonQtShell_QCalendar__YearMonthDay(y, m, d); } bool PythonQtWrapper_QCalendar__YearMonthDay::isValid(QCalendar::YearMonthDay* theWrappedObject) const @@ -4944,11 +4944,11 @@ bool PythonQtWrapper_QCalendar__YearMonthDay::isValid(QCalendar::YearMonthDay* QCborArray* PythonQtWrapper_QCborArray::new_QCborArray() -{ +{ return new QCborArray(); } QCborArray* PythonQtWrapper_QCborArray::new_QCborArray(const QCborArray& other) -{ +{ return new QCborArray(other); } void PythonQtWrapper_QCborArray::append(QCborArray* theWrappedObject, const QCborValue& value) @@ -5160,7 +5160,7 @@ PythonQtShell_QCborError::~PythonQtShell_QCborError() { if (priv) { priv->shellClassDeleted(this); } } QCborError* PythonQtWrapper_QCborError::new_QCborError() -{ +{ return new PythonQtShell_QCborError(); } QString PythonQtWrapper_QCborError::toString(QCborError* theWrappedObject) const @@ -5172,11 +5172,11 @@ QString PythonQtWrapper_QCborError::py_toString(QCborError* obj) { return obj->t QCborMap* PythonQtWrapper_QCborMap::new_QCborMap() -{ +{ return new QCborMap(); } QCborMap* PythonQtWrapper_QCborMap::new_QCborMap(const QCborMap& other) -{ +{ return new QCborMap(other); } void PythonQtWrapper_QCborMap::clear(QCborMap* theWrappedObject) @@ -5368,7 +5368,7 @@ PythonQtShell_QCborParserError::~PythonQtShell_QCborParserError() { if (priv) { priv->shellClassDeleted(this); } } QCborParserError* PythonQtWrapper_QCborParserError::new_QCborParserError() -{ +{ return new PythonQtShell_QCborParserError(); } QString PythonQtWrapper_QCborParserError::errorString(QCborParserError* theWrappedObject) const @@ -5379,23 +5379,23 @@ QString PythonQtWrapper_QCborParserError::errorString(QCborParserError* theWrap QCborStreamReader* PythonQtWrapper_QCborStreamReader::new_QCborStreamReader() -{ +{ return new QCborStreamReader(); } QCborStreamReader* PythonQtWrapper_QCborStreamReader::new_QCborStreamReader(QIODevice* device) -{ +{ return new QCborStreamReader(device); } QCborStreamReader* PythonQtWrapper_QCborStreamReader::new_QCborStreamReader(const QByteArray& data) -{ +{ return new QCborStreamReader(data); } QCborStreamReader* PythonQtWrapper_QCborStreamReader::new_QCborStreamReader(const char* data, qsizetype len) -{ +{ return new QCborStreamReader(data, len); } QCborStreamReader* PythonQtWrapper_QCborStreamReader::new_QCborStreamReader(const unsigned char* data, qsizetype len) -{ +{ return new QCborStreamReader(data, len); } void PythonQtWrapper_QCborStreamReader::addData(QCborStreamReader* theWrappedObject, const QByteArray& data) @@ -5636,11 +5636,11 @@ QCborStreamReader::Type PythonQtWrapper_QCborStreamReader::type(QCborStreamRead QCborStreamWriter* PythonQtWrapper_QCborStreamWriter::new_QCborStreamWriter(QByteArray* data) -{ +{ return new QCborStreamWriter(data); } QCborStreamWriter* PythonQtWrapper_QCborStreamWriter::new_QCborStreamWriter(QIODevice* device) -{ +{ return new QCborStreamWriter(device); } void PythonQtWrapper_QCborStreamWriter::append(QCborStreamWriter* theWrappedObject, QCborKnownTags tag) @@ -5766,75 +5766,75 @@ void PythonQtWrapper_QCborStreamWriter::startMap(QCborStreamWriter* theWrappedOb QCborValue* PythonQtWrapper_QCborValue::new_QCborValue() -{ +{ return new QCborValue(); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(QCborKnownTags t_, const QCborValue& tv) -{ +{ return new QCborValue(t_, tv); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(QCborSimpleType st) -{ +{ return new QCborValue(st); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(QCborValue::Type t_) -{ +{ return new QCborValue(t_); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(bool b_) -{ +{ return new QCborValue(b_); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(const QByteArray& ba) -{ +{ return new QCborValue(ba); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(const QCborArray& a) -{ +{ return new QCborValue(a); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(const QCborMap& m) -{ +{ return new QCborValue(m); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(const QCborValue& other) -{ +{ return new QCborValue(other); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(const QDateTime& dt) -{ +{ return new QCborValue(dt); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(const QRegularExpression& rx) -{ +{ return new QCborValue(rx); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(const QString& s) -{ +{ return new QCborValue(s); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(const QUrl& url) -{ +{ return new QCborValue(url); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(const QUuid& uuid) -{ +{ return new QCborValue(uuid); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(const char* s) -{ +{ return new QCborValue(s); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(double v) -{ +{ return new QCborValue(v); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(int i) -{ +{ return new QCborValue(i); } QCborValue* PythonQtWrapper_QCborValue::new_QCborValue(qint64 i) -{ +{ return new QCborValue(i); } int PythonQtWrapper_QCborValue::compare(QCborValue* theWrappedObject, const QCborValue& other) const @@ -6130,7 +6130,7 @@ PythonQtShell_QChildEvent::~PythonQtShell_QChildEvent() { if (priv) { priv->shellClassDeleted(this); } } QChildEvent* PythonQtWrapper_QChildEvent::new_QChildEvent(QEvent::Type type, QObject* child) -{ +{ return new PythonQtShell_QChildEvent(type, child); } bool PythonQtWrapper_QChildEvent::added(QChildEvent* theWrappedObject) const @@ -6156,15 +6156,15 @@ bool PythonQtWrapper_QChildEvent::removed(QChildEvent* theWrappedObject) const QCollator* PythonQtWrapper_QCollator::new_QCollator() -{ +{ return new QCollator(); } QCollator* PythonQtWrapper_QCollator::new_QCollator(const QCollator& arg__1) -{ +{ return new QCollator(arg__1); } QCollator* PythonQtWrapper_QCollator::new_QCollator(const QLocale& locale) -{ +{ return new QCollator(locale); } Qt::CaseSensitivity PythonQtWrapper_QCollator::caseSensitivity(QCollator* theWrappedObject) const @@ -6240,7 +6240,7 @@ void PythonQtWrapper_QCollator::swap(QCollator* theWrappedObject, QCollator& ot QCollatorSortKey* PythonQtWrapper_QCollatorSortKey::new_QCollatorSortKey(const QCollatorSortKey& other) -{ +{ return new QCollatorSortKey(other); } int PythonQtWrapper_QCollatorSortKey::compare(QCollatorSortKey* theWrappedObject, const QCollatorSortKey& key) const @@ -6266,23 +6266,23 @@ void PythonQtWrapper_QCollatorSortKey::swap(QCollatorSortKey* theWrappedObject, QCommandLineOption* PythonQtWrapper_QCommandLineOption::new_QCommandLineOption(const QCommandLineOption& other) -{ +{ return new QCommandLineOption(other); } QCommandLineOption* PythonQtWrapper_QCommandLineOption::new_QCommandLineOption(const QString& name) -{ +{ return new QCommandLineOption(name); } QCommandLineOption* PythonQtWrapper_QCommandLineOption::new_QCommandLineOption(const QString& name, const QString& description, const QString& valueName, const QString& defaultValue) -{ +{ return new QCommandLineOption(name, description, valueName, defaultValue); } QCommandLineOption* PythonQtWrapper_QCommandLineOption::new_QCommandLineOption(const QStringList& names) -{ +{ return new QCommandLineOption(names); } QCommandLineOption* PythonQtWrapper_QCommandLineOption::new_QCommandLineOption(const QStringList& names, const QString& description, const QString& valueName, const QString& defaultValue) -{ +{ return new QCommandLineOption(names, description, valueName, defaultValue); } QStringList PythonQtWrapper_QCommandLineOption::defaultValues(QCommandLineOption* theWrappedObject) const @@ -6348,7 +6348,7 @@ QString PythonQtWrapper_QCommandLineOption::valueName(QCommandLineOption* theWr QCommandLineParser* PythonQtWrapper_QCommandLineParser::new_QCommandLineParser() -{ +{ return new QCommandLineParser(); } QCommandLineOption PythonQtWrapper_QCommandLineParser::addHelpOption(QCommandLineParser* theWrappedObject) @@ -6701,7 +6701,7 @@ QString PythonQtWrapper_QCoreApplication::static_QCoreApplication_translate(con QCryptographicHash* PythonQtWrapper_QCryptographicHash::new_QCryptographicHash(QCryptographicHash::Algorithm method) -{ +{ return new QCryptographicHash(method); } bool PythonQtWrapper_QCryptographicHash::addData(QCryptographicHash* theWrappedObject, QIODevice* device) @@ -6737,19 +6737,19 @@ QByteArray PythonQtWrapper_QCryptographicHash::result(QCryptographicHash* theWr QDataStream* PythonQtWrapper_QDataStream::new_QDataStream() -{ +{ return new QDataStream(); } QDataStream* PythonQtWrapper_QDataStream::new_QDataStream(QByteArray* arg__1, QIODevice::OpenMode flags) -{ +{ return new QDataStream(arg__1, flags); } QDataStream* PythonQtWrapper_QDataStream::new_QDataStream(QIODevice* arg__1) -{ +{ return new QDataStream(arg__1); } QDataStream* PythonQtWrapper_QDataStream::new_QDataStream(const QByteArray& arg__1) -{ +{ return new QDataStream(arg__1); } void PythonQtWrapper_QDataStream::abortTransaction(QDataStream* theWrappedObject) @@ -6845,15 +6845,15 @@ int PythonQtWrapper_QDataStream::version(QDataStream* theWrappedObject) const QDeadlineTimer* PythonQtWrapper_QDeadlineTimer::new_QDeadlineTimer(QDeadlineTimer::ForeverConstant arg__1, Qt::TimerType type_) -{ +{ return new QDeadlineTimer(arg__1, type_); } QDeadlineTimer* PythonQtWrapper_QDeadlineTimer::new_QDeadlineTimer(Qt::TimerType type_) -{ +{ return new QDeadlineTimer(type_); } QDeadlineTimer* PythonQtWrapper_QDeadlineTimer::new_QDeadlineTimer(qint64 msecs, Qt::TimerType type) -{ +{ return new QDeadlineTimer(msecs, type); } QDeadlineTimer PythonQtWrapper_QDeadlineTimer::static_QDeadlineTimer_addNSecs(QDeadlineTimer dt, qint64 nsecs) diff --git a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core0.h b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core0.h index 3d92256c1..d2e542326 100644 --- a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core0.h +++ b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core0.h @@ -820,7 +820,7 @@ void delete_QCalendar(QCalendar* obj) { delete obj; } public: const static int Unspecified = QCalendar::Unspecified; - + }; @@ -1002,7 +1002,7 @@ void delete_QCborMap(QCborMap* obj) { delete obj; } { theWrappedObject->insert(key, value_); } - + }; @@ -1105,16 +1105,16 @@ void delete_QCborStreamReader(QCborStreamReader* obj) { delete obj; } auto result = theWrappedObject->readByteArray(); return result.status == QCborStreamReader::Ok ? result.data : QByteArray(); } - + QString readString(QCborStreamReader* theWrappedObject) { auto result = theWrappedObject->readString(); return result.status == QCborStreamReader::Ok ? result.data : QString(); } - + qint64 toTag(QCborStreamReader* theWrappedObject) const { return static_cast(theWrappedObject->toTag()); } - + }; @@ -1255,11 +1255,11 @@ void delete_QCborValue(QCborValue* obj) { delete obj; } QCborValue* new_QCborValue(qint64 tag, const QCborValue& taggedValue) { return new QCborValue(QCborTag(tag), taggedValue); } - + qint64 tag(QCborValue* theWrappedObject, qint64 defaultValue) const { return static_cast(theWrappedObject->tag(QCborTag(defaultValue))); } - + }; @@ -1586,7 +1586,7 @@ void delete_QDataStream(QDataStream* obj) { delete obj; } return Py_None; } } - + }; diff --git a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core1.cpp b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core1.cpp index 187936627..725287259 100644 --- a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core1.cpp +++ b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core1.cpp @@ -42,7 +42,7 @@ #include QDeferredDeleteEvent* PythonQtWrapper_QDeferredDeleteEvent::new_QDeferredDeleteEvent() -{ +{ return new QDeferredDeleteEvent(); } int PythonQtWrapper_QDeferredDeleteEvent::loopLevel(QDeferredDeleteEvent* theWrappedObject) const @@ -53,15 +53,15 @@ int PythonQtWrapper_QDeferredDeleteEvent::loopLevel(QDeferredDeleteEvent* theWr QDir* PythonQtWrapper_QDir::new_QDir(const QDir& arg__1) -{ +{ return new QDir(arg__1); } QDir* PythonQtWrapper_QDir::new_QDir(const QString& path) -{ +{ return new QDir(path); } QDir* PythonQtWrapper_QDir::new_QDir(const QString& path, const QString& nameFilter, QDir::SortFlags sort, QDir::Filters filter) -{ +{ return new QDir(path, nameFilter, sort, filter); } QString PythonQtWrapper_QDir::absoluteFilePath(QDir* theWrappedObject, const QString& fileName) const @@ -394,19 +394,19 @@ QString PythonQtWrapper_QDir::py_toString(QDir* obj) { QDirIterator* PythonQtWrapper_QDirIterator::new_QDirIterator(const QDir& dir, QDirIterator::IteratorFlags flags) -{ +{ return new QDirIterator(dir, flags); } QDirIterator* PythonQtWrapper_QDirIterator::new_QDirIterator(const QString& path, QDir::Filters filter, QDirIterator::IteratorFlags flags) -{ +{ return new QDirIterator(path, filter, flags); } QDirIterator* PythonQtWrapper_QDirIterator::new_QDirIterator(const QString& path, QDirIterator::IteratorFlags flags) -{ +{ return new QDirIterator(path, flags); } QDirIterator* PythonQtWrapper_QDirIterator::new_QDirIterator(const QString& path, const QStringList& nameFilters, QDir::Filters filters, QDirIterator::IteratorFlags flags) -{ +{ return new QDirIterator(path, nameFilters, filters, flags); } QFileInfo PythonQtWrapper_QDirIterator::fileInfo(QDirIterator* theWrappedObject) const @@ -442,7 +442,7 @@ QString PythonQtWrapper_QDirIterator::path(QDirIterator* theWrappedObject) cons QDynamicPropertyChangeEvent* PythonQtWrapper_QDynamicPropertyChangeEvent::new_QDynamicPropertyChangeEvent(const QByteArray& name) -{ +{ return new QDynamicPropertyChangeEvent(name); } QByteArray PythonQtWrapper_QDynamicPropertyChangeEvent::propertyName(QDynamicPropertyChangeEvent* theWrappedObject) const @@ -453,11 +453,11 @@ QByteArray PythonQtWrapper_QDynamicPropertyChangeEvent::propertyName(QDynamicPr QEasingCurve* PythonQtWrapper_QEasingCurve::new_QEasingCurve(QEasingCurve::Type type) -{ +{ return new QEasingCurve(type); } QEasingCurve* PythonQtWrapper_QEasingCurve::new_QEasingCurve(const QEasingCurve& other) -{ +{ return new QEasingCurve(other); } void PythonQtWrapper_QEasingCurve::addCubicBezierSegment(QEasingCurve* theWrappedObject, const QPointF& c1, const QPointF& c2, const QPointF& endPoint) @@ -560,7 +560,7 @@ QString PythonQtWrapper_QEasingCurve::py_toString(QEasingCurve* obj) { QElapsedTimer* PythonQtWrapper_QElapsedTimer::new_QElapsedTimer() -{ +{ return new QElapsedTimer(); } QElapsedTimer::ClockType PythonQtWrapper_QElapsedTimer::static_QElapsedTimer_clockType() @@ -640,11 +640,11 @@ PythonQtShell_QEvent::~PythonQtShell_QEvent() { if (priv) { priv->shellClassDeleted(this); } } QEvent* PythonQtWrapper_QEvent::new_QEvent(QEvent::Type type) -{ +{ return new PythonQtShell_QEvent(type); } QEvent* PythonQtWrapper_QEvent::new_QEvent(const QEvent& other) -{ +{ return new PythonQtShell_QEvent(other); } void PythonQtWrapper_QEvent::accept(QEvent* theWrappedObject) @@ -833,7 +833,7 @@ if (_wrapper) { QEventLoop::timerEvent(event0); } QEventLoop* PythonQtWrapper_QEventLoop::new_QEventLoop(QObject* parent) -{ +{ return new PythonQtShell_QEventLoop(parent); } const QMetaObject* PythonQtShell_QEventLoop::metaObject() const { @@ -1073,11 +1073,11 @@ if (_wrapper) { QEventTransition::timerEvent(event0); } QEventTransition* PythonQtWrapper_QEventTransition::new_QEventTransition(QObject* object, QEvent::Type type, QState* sourceState) -{ +{ return new PythonQtShell_QEventTransition(object, type, sourceState); } QEventTransition* PythonQtWrapper_QEventTransition::new_QEventTransition(QState* sourceState) -{ +{ return new PythonQtShell_QEventTransition(sourceState); } const QMetaObject* PythonQtShell_QEventTransition::metaObject() const { @@ -1153,7 +1153,7 @@ if (_wrapper) { return QStringList(); } QFactoryInterface* PythonQtWrapper_QFactoryInterface::new_QFactoryInterface() -{ +{ return new PythonQtShell_QFactoryInterface(); } QStringList PythonQtWrapper_QFactoryInterface::keys(QFactoryInterface* theWrappedObject) const @@ -1949,19 +1949,19 @@ if (_wrapper) { return QFile::writeData(data0, len1); } QFile* PythonQtWrapper_QFile::new_QFile() -{ +{ return new PythonQtShell_QFile(); } QFile* PythonQtWrapper_QFile::new_QFile(QObject* parent) -{ +{ return new PythonQtShell_QFile(parent); } QFile* PythonQtWrapper_QFile::new_QFile(const QString& name) -{ +{ return new PythonQtShell_QFile(name); } QFile* PythonQtWrapper_QFile::new_QFile(const QString& name, QObject* parent) -{ +{ return new PythonQtShell_QFile(name, parent); } const QMetaObject* PythonQtShell_QFile::metaObject() const { @@ -2870,11 +2870,11 @@ if (_wrapper) { return QFileDevice::writeData(data0, len1); } QFileDevice* PythonQtWrapper_QFileDevice::new_QFileDevice() -{ +{ return new PythonQtShell_QFileDevice(); } QFileDevice* PythonQtWrapper_QFileDevice::new_QFileDevice(QObject* parent) -{ +{ return new PythonQtShell_QFileDevice(parent); } const QMetaObject* PythonQtShell_QFileDevice::metaObject() const { @@ -2953,23 +2953,23 @@ void PythonQtWrapper_QFileDevice::unsetError(QFileDevice* theWrappedObject) QFileInfo* PythonQtWrapper_QFileInfo::new_QFileInfo() -{ +{ return new QFileInfo(); } QFileInfo* PythonQtWrapper_QFileInfo::new_QFileInfo(const QDir& dir, const QString& file) -{ +{ return new QFileInfo(dir, file); } QFileInfo* PythonQtWrapper_QFileInfo::new_QFileInfo(const QFile& file) -{ +{ return new QFileInfo(file); } QFileInfo* PythonQtWrapper_QFileInfo::new_QFileInfo(const QFileInfo& fileinfo) -{ +{ return new QFileInfo(fileinfo); } QFileInfo* PythonQtWrapper_QFileInfo::new_QFileInfo(const QString& file) -{ +{ return new QFileInfo(file); } QDir PythonQtWrapper_QFileInfo::absoluteDir(QFileInfo* theWrappedObject) const @@ -3378,7 +3378,7 @@ if (_wrapper) { QFileSelector::timerEvent(event0); } QFileSelector* PythonQtWrapper_QFileSelector::new_QFileSelector(QObject* parent) -{ +{ return new PythonQtShell_QFileSelector(parent); } const QMetaObject* PythonQtShell_QFileSelector::metaObject() const { @@ -3558,11 +3558,11 @@ if (_wrapper) { QFileSystemWatcher::timerEvent(event0); } QFileSystemWatcher* PythonQtWrapper_QFileSystemWatcher::new_QFileSystemWatcher(QObject* parent) -{ +{ return new PythonQtShell_QFileSystemWatcher(parent); } QFileSystemWatcher* PythonQtWrapper_QFileSystemWatcher::new_QFileSystemWatcher(const QStringList& paths, QObject* parent) -{ +{ return new PythonQtShell_QFileSystemWatcher(paths, parent); } const QMetaObject* PythonQtShell_QFileSystemWatcher::metaObject() const { @@ -3791,7 +3791,7 @@ if (_wrapper) { QFinalState::timerEvent(event0); } QFinalState* PythonQtWrapper_QFinalState::new_QFinalState(QState* parent) -{ +{ return new PythonQtShell_QFinalState(parent); } const QMetaObject* PythonQtShell_QFinalState::metaObject() const { @@ -3990,11 +3990,11 @@ if (_wrapper) { QHistoryState::timerEvent(event0); } QHistoryState* PythonQtWrapper_QHistoryState::new_QHistoryState(QHistoryState::HistoryType type, QState* parent) -{ +{ return new PythonQtShell_QHistoryState(type, parent); } QHistoryState* PythonQtWrapper_QHistoryState::new_QHistoryState(QState* parent) -{ +{ return new PythonQtShell_QHistoryState(parent); } const QMetaObject* PythonQtShell_QHistoryState::metaObject() const { @@ -4696,11 +4696,11 @@ if (_wrapper) { return qint64(); } QIODevice* PythonQtWrapper_QIODevice::new_QIODevice() -{ +{ return new PythonQtShell_QIODevice(); } QIODevice* PythonQtWrapper_QIODevice::new_QIODevice(QObject* parent) -{ +{ return new PythonQtShell_QIODevice(parent); } const QMetaObject* PythonQtShell_QIODevice::metaObject() const { @@ -6323,7 +6323,7 @@ if (_wrapper) { QIdentityProxyModel::timerEvent(event0); } QIdentityProxyModel* PythonQtWrapper_QIdentityProxyModel::new_QIdentityProxyModel(QObject* parent) -{ +{ return new PythonQtShell_QIdentityProxyModel(parent); } const QMetaObject* PythonQtShell_QIdentityProxyModel::metaObject() const { @@ -6342,11 +6342,11 @@ int PythonQtShell_QIdentityProxyModel::qt_metacall(QMetaObject::Call call, int i QJsonArray* PythonQtWrapper_QJsonArray::new_QJsonArray() -{ +{ return new QJsonArray(); } QJsonArray* PythonQtWrapper_QJsonArray::new_QJsonArray(const QJsonArray& other) -{ +{ return new QJsonArray(other); } void PythonQtWrapper_QJsonArray::append(QJsonArray* theWrappedObject, const QJsonValue& value) @@ -6523,19 +6523,19 @@ PythonQtShell_QJsonDocument::~PythonQtShell_QJsonDocument() { if (priv) { priv->shellClassDeleted(this); } } QJsonDocument* PythonQtWrapper_QJsonDocument::new_QJsonDocument() -{ +{ return new PythonQtShell_QJsonDocument(); } QJsonDocument* PythonQtWrapper_QJsonDocument::new_QJsonDocument(const QJsonArray& array) -{ +{ return new PythonQtShell_QJsonDocument(array); } QJsonDocument* PythonQtWrapper_QJsonDocument::new_QJsonDocument(const QJsonDocument& other) -{ +{ return new PythonQtShell_QJsonDocument(other); } QJsonDocument* PythonQtWrapper_QJsonDocument::new_QJsonDocument(const QJsonObject& object) -{ +{ return new PythonQtShell_QJsonDocument(object); } QJsonArray PythonQtWrapper_QJsonDocument::array(QJsonDocument* theWrappedObject) const @@ -6673,11 +6673,11 @@ QString PythonQtWrapper_QJsonDocument::py_toString(QJsonDocument* obj) { QJsonObject* PythonQtWrapper_QJsonObject::new_QJsonObject() -{ +{ return new QJsonObject(); } QJsonObject* PythonQtWrapper_QJsonObject::new_QJsonObject(const QJsonObject& other) -{ +{ return new QJsonObject(other); } bool PythonQtWrapper_QJsonObject::contains(QJsonObject* theWrappedObject, const QString& key) const @@ -6799,7 +6799,7 @@ PythonQtShell_QJsonParseError::~PythonQtShell_QJsonParseError() { if (priv) { priv->shellClassDeleted(this); } } QJsonParseError* PythonQtWrapper_QJsonParseError::new_QJsonParseError() -{ +{ return new PythonQtShell_QJsonParseError(); } QString PythonQtWrapper_QJsonParseError::errorString(QJsonParseError* theWrappedObject) const @@ -6810,43 +6810,43 @@ QString PythonQtWrapper_QJsonParseError::errorString(QJsonParseError* theWrappe QJsonValue* PythonQtWrapper_QJsonValue::new_QJsonValue(QJsonValue::Type arg__1) -{ +{ return new QJsonValue(arg__1); } QJsonValue* PythonQtWrapper_QJsonValue::new_QJsonValue(bool b) -{ +{ return new QJsonValue(b); } QJsonValue* PythonQtWrapper_QJsonValue::new_QJsonValue(const QJsonArray& a) -{ +{ return new QJsonValue(a); } QJsonValue* PythonQtWrapper_QJsonValue::new_QJsonValue(const QJsonObject& o) -{ +{ return new QJsonValue(o); } QJsonValue* PythonQtWrapper_QJsonValue::new_QJsonValue(const QJsonValue& other) -{ +{ return new QJsonValue(other); } QJsonValue* PythonQtWrapper_QJsonValue::new_QJsonValue(const QString& s) -{ +{ return new QJsonValue(s); } QJsonValue* PythonQtWrapper_QJsonValue::new_QJsonValue(const char* s) -{ +{ return new QJsonValue(s); } QJsonValue* PythonQtWrapper_QJsonValue::new_QJsonValue(double n) -{ +{ return new QJsonValue(n); } QJsonValue* PythonQtWrapper_QJsonValue::new_QJsonValue(int n) -{ +{ return new QJsonValue(n); } QJsonValue* PythonQtWrapper_QJsonValue::new_QJsonValue(qint64 v) -{ +{ return new QJsonValue(v); } QJsonValue PythonQtWrapper_QJsonValue::static_QJsonValue_fromVariant(const QVariant& variant) @@ -7124,19 +7124,19 @@ if (_wrapper) { QLibrary::timerEvent(event0); } QLibrary* PythonQtWrapper_QLibrary::new_QLibrary(QObject* parent) -{ +{ return new PythonQtShell_QLibrary(parent); } QLibrary* PythonQtWrapper_QLibrary::new_QLibrary(const QString& fileName, QObject* parent) -{ +{ return new PythonQtShell_QLibrary(fileName, parent); } QLibrary* PythonQtWrapper_QLibrary::new_QLibrary(const QString& fileName, const QString& version, QObject* parent) -{ +{ return new PythonQtShell_QLibrary(fileName, version, parent); } QLibrary* PythonQtWrapper_QLibrary::new_QLibrary(const QString& fileName, int verNum, QObject* parent) -{ +{ return new PythonQtShell_QLibrary(fileName, verNum, parent); } const QMetaObject* PythonQtShell_QLibrary::metaObject() const { @@ -7247,7 +7247,7 @@ QStringList PythonQtWrapper_QLibraryInfo::static_QLibraryInfo_platformPluginArg QLockFile* PythonQtWrapper_QLockFile::new_QLockFile(const QString& fileName) -{ +{ return new QLockFile(fileName); } QLockFile::LockError PythonQtWrapper_QLockFile::error(QLockFile* theWrappedObject) const @@ -7345,15 +7345,15 @@ void PythonQtWrapper_QLoggingCategory::static_QLoggingCategory_setFilterRules(co QMarginsF* PythonQtWrapper_QMarginsF::new_QMarginsF() -{ +{ return new QMarginsF(); } QMarginsF* PythonQtWrapper_QMarginsF::new_QMarginsF(const QMargins& margins) -{ +{ return new QMarginsF(margins); } QMarginsF* PythonQtWrapper_QMarginsF::new_QMarginsF(qreal left, qreal top, qreal right, qreal bottom) -{ +{ return new QMarginsF(left, top, right, bottom); } qreal PythonQtWrapper_QMarginsF::bottom(QMarginsF* theWrappedObject) const @@ -7501,7 +7501,7 @@ QString PythonQtWrapper_QMarginsF::py_toString(QMarginsF* obj) { QMessageAuthenticationCode* PythonQtWrapper_QMessageAuthenticationCode::new_QMessageAuthenticationCode(QCryptographicHash::Algorithm method, const QByteArray& key) -{ +{ return new QMessageAuthenticationCode(method, key); } bool PythonQtWrapper_QMessageAuthenticationCode::addData(QMessageAuthenticationCode* theWrappedObject, QIODevice* device) diff --git a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core2.cpp b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core2.cpp index 35c047306..09e367994 100644 --- a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core2.cpp +++ b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core2.cpp @@ -41,31 +41,31 @@ PythonQtShell_QMessageLogContext::~PythonQtShell_QMessageLogContext() { if (priv) { priv->shellClassDeleted(this); } } QMessageLogContext* PythonQtWrapper_QMessageLogContext::new_QMessageLogContext() -{ +{ return new PythonQtShell_QMessageLogContext(); } QMessageLogContext* PythonQtWrapper_QMessageLogContext::new_QMessageLogContext(const char* fileName, int lineNumber, const char* functionName, const char* categoryName) -{ +{ return new PythonQtShell_QMessageLogContext(fileName, lineNumber, functionName, categoryName); } QMessageLogger* PythonQtWrapper_QMessageLogger::new_QMessageLogger() -{ +{ return new QMessageLogger(); } QMessageLogger* PythonQtWrapper_QMessageLogger::new_QMessageLogger(const char* file, int line, const char* function) -{ +{ return new QMessageLogger(file, line, function); } QMessageLogger* PythonQtWrapper_QMessageLogger::new_QMessageLogger(const char* file, int line, const char* function, const char* category) -{ +{ return new QMessageLogger(file, line, function, category); } QMetaClassInfo* PythonQtWrapper_QMetaClassInfo::new_QMetaClassInfo() -{ +{ return new QMetaClassInfo(); } const QMetaObject* PythonQtWrapper_QMetaClassInfo::enclosingMetaObject(QMetaClassInfo* theWrappedObject) const @@ -86,7 +86,7 @@ const char* PythonQtWrapper_QMetaClassInfo::value(QMetaClassInfo* theWrappedObj QMetaEnum* PythonQtWrapper_QMetaEnum::new_QMetaEnum() -{ +{ return new QMetaEnum(); } const QMetaObject* PythonQtWrapper_QMetaEnum::enclosingMetaObject(QMetaEnum* theWrappedObject) const @@ -162,7 +162,7 @@ QByteArray PythonQtWrapper_QMetaEnum::valueToKeys(QMetaEnum* theWrappedObject, QMetaMethod* PythonQtWrapper_QMetaMethod::new_QMetaMethod() -{ +{ return new QMetaMethod(); } QMetaMethod::Access PythonQtWrapper_QMetaMethod::access(QMetaMethod* theWrappedObject) const @@ -263,7 +263,7 @@ const char* PythonQtWrapper_QMetaMethod::typeName(QMetaMethod* theWrappedObject QMetaProperty* PythonQtWrapper_QMetaProperty::new_QMetaProperty() -{ +{ return new QMetaProperty(); } const QMetaObject* PythonQtWrapper_QMetaProperty::enclosingMetaObject(QMetaProperty* theWrappedObject) const @@ -434,7 +434,7 @@ bool PythonQtWrapper_QMetaProperty::writeOnGadget(QMetaProperty* theWrappedObje QMetaType* PythonQtWrapper_QMetaType::new_QMetaType(const int type) -{ +{ return new QMetaType(type); } bool PythonQtWrapper_QMetaType::static_QMetaType_compare(const void* lhs, const void* rhs, int typeId, int* result) @@ -850,7 +850,7 @@ if (_wrapper) { QMimeData::timerEvent(event0); } QMimeData* PythonQtWrapper_QMimeData::new_QMimeData() -{ +{ return new PythonQtShell_QMimeData(); } const QMetaObject* PythonQtShell_QMimeData::metaObject() const { @@ -979,7 +979,7 @@ QList PythonQtWrapper_QMimeData::urls(QMimeData* theWrappedObject) const QMimeDatabase* PythonQtWrapper_QMimeDatabase::new_QMimeDatabase() -{ +{ return new QMimeDatabase(); } QList PythonQtWrapper_QMimeDatabase::allMimeTypes(QMimeDatabase* theWrappedObject) const @@ -1040,11 +1040,11 @@ QString PythonQtWrapper_QMimeDatabase::suffixForFileName(QMimeDatabase* theWrap QMimeType* PythonQtWrapper_QMimeType::new_QMimeType() -{ +{ return new QMimeType(); } QMimeType* PythonQtWrapper_QMimeType::new_QMimeType(const QMimeType& other) -{ +{ return new QMimeType(other); } QStringList PythonQtWrapper_QMimeType::aliases(QMimeType* theWrappedObject) const @@ -1147,7 +1147,7 @@ QString PythonQtWrapper_QMimeType::py_toString(QMimeType* obj) { QModelIndex* PythonQtWrapper_QModelIndex::new_QModelIndex() -{ +{ return new QModelIndex(); } QModelIndex PythonQtWrapper_QModelIndex::child(QModelIndex* theWrappedObject, int row, int column) const @@ -1240,11 +1240,11 @@ QString PythonQtWrapper_QModelIndex::py_toString(QModelIndex* obj) { QMutex* PythonQtWrapper_QMutex::new_QMutex() -{ +{ return new QMutex(); } QMutex* PythonQtWrapper_QMutex::new_QMutex(QMutex::RecursionMode mode) -{ +{ return new QMutex(mode); } bool PythonQtWrapper_QMutex::isRecursive(QMutex* theWrappedObject) const @@ -1275,11 +1275,11 @@ void PythonQtWrapper_QMutex::unlock(QMutex* theWrappedObject) QMutexLocker* PythonQtWrapper_QMutexLocker::new_QMutexLocker(QBasicMutex* m) -{ +{ return new QMutexLocker(m); } QMutexLocker* PythonQtWrapper_QMutexLocker::new_QMutexLocker(QRecursiveMutex* m) -{ +{ return new QMutexLocker(m); } QMutex* PythonQtWrapper_QMutexLocker::mutex(QMutexLocker* theWrappedObject) const @@ -1436,7 +1436,7 @@ if (_wrapper) { QObject::timerEvent(event0); } QObject* PythonQtWrapper_QObject::new_QObject(QObject* parent) -{ +{ return new PythonQtShell_QObject(parent); } const QMetaObject* PythonQtShell_QObject::metaObject() const { @@ -1589,7 +1589,7 @@ PythonQtShell_QOperatingSystemVersion::~PythonQtShell_QOperatingSystemVersion() if (priv) { priv->shellClassDeleted(this); } } QOperatingSystemVersion* PythonQtWrapper_QOperatingSystemVersion::new_QOperatingSystemVersion(QOperatingSystemVersion::OSType osType, int vmajor, int vminor, int vmicro) -{ +{ return new PythonQtShell_QOperatingSystemVersion(osType, vmajor, vminor, vmicro); } QOperatingSystemVersion PythonQtWrapper_QOperatingSystemVersion::static_QOperatingSystemVersion_current() @@ -1897,7 +1897,7 @@ if (_wrapper) { QParallelAnimationGroup::updateState(newState0, oldState1); } QParallelAnimationGroup* PythonQtWrapper_QParallelAnimationGroup::new_QParallelAnimationGroup(QObject* parent) -{ +{ return new PythonQtShell_QParallelAnimationGroup(parent); } const QMetaObject* PythonQtShell_QParallelAnimationGroup::metaObject() const { @@ -2151,11 +2151,11 @@ if (_wrapper) { QPauseAnimation::updateState(newState0, oldState1); } QPauseAnimation* PythonQtWrapper_QPauseAnimation::new_QPauseAnimation(QObject* parent) -{ +{ return new PythonQtShell_QPauseAnimation(parent); } QPauseAnimation* PythonQtWrapper_QPauseAnimation::new_QPauseAnimation(int msecs, QObject* parent) -{ +{ return new PythonQtShell_QPauseAnimation(msecs, parent); } const QMetaObject* PythonQtShell_QPauseAnimation::metaObject() const { @@ -2179,15 +2179,15 @@ void PythonQtWrapper_QPauseAnimation::setDuration(QPauseAnimation* theWrappedObj QPersistentModelIndex* PythonQtWrapper_QPersistentModelIndex::new_QPersistentModelIndex() -{ +{ return new QPersistentModelIndex(); } QPersistentModelIndex* PythonQtWrapper_QPersistentModelIndex::new_QPersistentModelIndex(const QModelIndex& index) -{ +{ return new QPersistentModelIndex(index); } QPersistentModelIndex* PythonQtWrapper_QPersistentModelIndex::new_QPersistentModelIndex(const QPersistentModelIndex& other) -{ +{ return new QPersistentModelIndex(other); } QModelIndex PythonQtWrapper_QPersistentModelIndex::child(QPersistentModelIndex* theWrappedObject, int row, int column) const @@ -2960,7 +2960,7 @@ if (_wrapper) { return QProcess::writeData(data0, len1); } QProcess* PythonQtWrapper_QProcess::new_QProcess(QObject* parent) -{ +{ return new PythonQtShell_QProcess(parent); } const QMetaObject* PythonQtShell_QProcess::metaObject() const { @@ -3204,11 +3204,11 @@ QString PythonQtWrapper_QProcess::workingDirectory(QProcess* theWrappedObject) QProcessEnvironment* PythonQtWrapper_QProcessEnvironment::new_QProcessEnvironment() -{ +{ return new QProcessEnvironment(); } QProcessEnvironment* PythonQtWrapper_QProcessEnvironment::new_QProcessEnvironment(const QProcessEnvironment& other) -{ +{ return new QProcessEnvironment(other); } void PythonQtWrapper_QProcessEnvironment::clear(QProcessEnvironment* theWrappedObject) @@ -3574,11 +3574,11 @@ if (_wrapper) { QPropertyAnimation::updateState(newState0, oldState1); } QPropertyAnimation* PythonQtWrapper_QPropertyAnimation::new_QPropertyAnimation(QObject* parent) -{ +{ return new PythonQtShell_QPropertyAnimation(parent); } QPropertyAnimation* PythonQtWrapper_QPropertyAnimation::new_QPropertyAnimation(QObject* target, const QByteArray& propertyName, QObject* parent) -{ +{ return new PythonQtShell_QPropertyAnimation(target, propertyName, parent); } const QMetaObject* PythonQtShell_QPropertyAnimation::metaObject() const { @@ -3617,19 +3617,19 @@ QObject* PythonQtWrapper_QPropertyAnimation::targetObject(QPropertyAnimation* t QRandomGenerator* PythonQtWrapper_QRandomGenerator::new_QRandomGenerator(const QRandomGenerator& other) -{ +{ return new QRandomGenerator(other); } QRandomGenerator* PythonQtWrapper_QRandomGenerator::new_QRandomGenerator(const unsigned int* begin, const unsigned int* end) -{ +{ return new QRandomGenerator(begin, end); } QRandomGenerator* PythonQtWrapper_QRandomGenerator::new_QRandomGenerator(const unsigned int* seedBuffer, qsizetype len) -{ +{ return new QRandomGenerator(seedBuffer, len); } QRandomGenerator* PythonQtWrapper_QRandomGenerator::new_QRandomGenerator(unsigned int seedValue) -{ +{ return new QRandomGenerator(seedValue); } double PythonQtWrapper_QRandomGenerator::bounded(QRandomGenerator* theWrappedObject, double highest) @@ -3730,19 +3730,19 @@ QRandomGenerator* PythonQtWrapper_QRandomGenerator::static_QRandomGenerator_sys QRandomGenerator64* PythonQtWrapper_QRandomGenerator64::new_QRandomGenerator64(const QRandomGenerator& other) -{ +{ return new QRandomGenerator64(other); } QRandomGenerator64* PythonQtWrapper_QRandomGenerator64::new_QRandomGenerator64(const unsigned int* begin, const unsigned int* end) -{ +{ return new QRandomGenerator64(begin, end); } QRandomGenerator64* PythonQtWrapper_QRandomGenerator64::new_QRandomGenerator64(const unsigned int* seedBuffer, qsizetype len) -{ +{ return new QRandomGenerator64(seedBuffer, len); } QRandomGenerator64* PythonQtWrapper_QRandomGenerator64::new_QRandomGenerator64(unsigned int seedValue) -{ +{ return new QRandomGenerator64(seedValue); } void PythonQtWrapper_QRandomGenerator64::discard(QRandomGenerator64* theWrappedObject, quint64 z) @@ -3788,7 +3788,7 @@ QRandomGenerator64* PythonQtWrapper_QRandomGenerator64::static_QRandomGenerator QReadLocker* PythonQtWrapper_QReadLocker::new_QReadLocker(QReadWriteLock* readWriteLock) -{ +{ return new QReadLocker(readWriteLock); } QReadWriteLock* PythonQtWrapper_QReadLocker::readWriteLock(QReadLocker* theWrappedObject) const @@ -3809,7 +3809,7 @@ void PythonQtWrapper_QReadLocker::unlock(QReadLocker* theWrappedObject) QReadWriteLock* PythonQtWrapper_QReadWriteLock::new_QReadWriteLock(QReadWriteLock::RecursionMode recursionMode) -{ +{ return new QReadWriteLock(recursionMode); } void PythonQtWrapper_QReadWriteLock::lockForRead(QReadWriteLock* theWrappedObject) @@ -3850,21 +3850,21 @@ void PythonQtWrapper_QReadWriteLock::unlock(QReadWriteLock* theWrappedObject) QRecursiveMutex* PythonQtWrapper_QRecursiveMutex::new_QRecursiveMutex() -{ +{ return new QRecursiveMutex(); } QRegExp* PythonQtWrapper_QRegExp::new_QRegExp() -{ +{ return new QRegExp(); } QRegExp* PythonQtWrapper_QRegExp::new_QRegExp(const QRegExp& rx) -{ +{ return new QRegExp(rx); } QRegExp* PythonQtWrapper_QRegExp::new_QRegExp(const QString& pattern, Qt::CaseSensitivity cs, QRegExp::PatternSyntax syntax) -{ +{ return new QRegExp(pattern, cs, syntax); } QString PythonQtWrapper_QRegExp::cap(QRegExp* theWrappedObject, int nth) @@ -4002,11 +4002,11 @@ QString PythonQtWrapper_QRegExp::py_toString(QRegExp* obj) { QRegularExpressionMatch* PythonQtWrapper_QRegularExpressionMatch::new_QRegularExpressionMatch() -{ +{ return new QRegularExpressionMatch(); } QRegularExpressionMatch* PythonQtWrapper_QRegularExpressionMatch::new_QRegularExpressionMatch(const QRegularExpressionMatch& match) -{ +{ return new QRegularExpressionMatch(match); } QString PythonQtWrapper_QRegularExpressionMatch::captured(QRegularExpressionMatch* theWrappedObject, const QString& name) const @@ -4129,11 +4129,11 @@ QString PythonQtWrapper_QRegularExpressionMatch::py_toString(QRegularExpressionM QRegularExpressionMatchIterator* PythonQtWrapper_QRegularExpressionMatchIterator::new_QRegularExpressionMatchIterator() -{ +{ return new QRegularExpressionMatchIterator(); } QRegularExpressionMatchIterator* PythonQtWrapper_QRegularExpressionMatchIterator::new_QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator& iterator) -{ +{ return new QRegularExpressionMatchIterator(iterator); } bool PythonQtWrapper_QRegularExpressionMatchIterator::hasNext(QRegularExpressionMatchIterator* theWrappedObject) const @@ -4188,7 +4188,7 @@ PythonQtShell_QResource::~PythonQtShell_QResource() { if (priv) { priv->shellClassDeleted(this); } } QResource* PythonQtWrapper_QResource::new_QResource(const QString& file, const QLocale& locale) -{ +{ return new PythonQtShell_QResource(file, locale); } QString PythonQtWrapper_QResource::absoluteFilePath(QResource* theWrappedObject) const diff --git a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core2.h b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core2.h index a41646574..0bc2b8ba8 100644 --- a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core2.h +++ b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core2.h @@ -461,7 +461,7 @@ void delete_QMutexLocker(QMutexLocker* obj) { delete obj; } void __enter__(QMutexLocker* /*self*/) {} void __exit__(QMutexLocker* self, PyObject* /*type*/, PyObject* /*value*/, PyObject* /*traceback*/) { self->unlock(); } - + }; @@ -993,7 +993,7 @@ void delete_QReadLocker(QReadLocker* obj) { delete obj; } void __enter__(QReadLocker* /*self*/) {} void __exit__(QReadLocker* self, PyObject* /*type*/, PyObject* /*value*/, PyObject* /*traceback*/) { self->unlock(); } - + }; diff --git a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core3.cpp b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core3.cpp index 39cb91b48..50bb96232 100644 --- a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core3.cpp +++ b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core3.cpp @@ -63,10 +63,10 @@ if (_wrapper) { } } } - + } QRunnable* PythonQtWrapper_QRunnable::new_QRunnable() -{ +{ return new PythonQtShell_QRunnable(); } bool PythonQtWrapper_QRunnable::autoDelete(QRunnable* theWrappedObject) const @@ -850,15 +850,15 @@ if (_wrapper) { return QSaveFile::writeData(data0, len1); } QSaveFile* PythonQtWrapper_QSaveFile::new_QSaveFile(QObject* parent) -{ +{ return new PythonQtShell_QSaveFile(parent); } QSaveFile* PythonQtWrapper_QSaveFile::new_QSaveFile(const QString& name) -{ +{ return new PythonQtShell_QSaveFile(name); } QSaveFile* PythonQtWrapper_QSaveFile::new_QSaveFile(const QString& name, QObject* parent) -{ +{ return new PythonQtShell_QSaveFile(name, parent); } const QMetaObject* PythonQtShell_QSaveFile::metaObject() const { @@ -902,7 +902,7 @@ void PythonQtWrapper_QSaveFile::setFileName(QSaveFile* theWrappedObject, const Q QSemaphore* PythonQtWrapper_QSemaphore::new_QSemaphore(int n) -{ +{ return new QSemaphore(n); } void PythonQtWrapper_QSemaphore::acquire(QSemaphore* theWrappedObject, int n) @@ -1168,7 +1168,7 @@ if (_wrapper) { QSequentialAnimationGroup::updateState(newState0, oldState1); } QSequentialAnimationGroup* PythonQtWrapper_QSequentialAnimationGroup::new_QSequentialAnimationGroup(QObject* parent) -{ +{ return new PythonQtShell_QSequentialAnimationGroup(parent); } const QMetaObject* PythonQtShell_QSequentialAnimationGroup::metaObject() const { @@ -1338,27 +1338,27 @@ if (_wrapper) { QSettings::timerEvent(event0); } QSettings* PythonQtWrapper_QSettings::new_QSettings(QObject* parent) -{ +{ return new PythonQtShell_QSettings(parent); } QSettings* PythonQtWrapper_QSettings::new_QSettings(QSettings::Format format, QSettings::Scope scope, const QString& organization, const QString& application, QObject* parent) -{ +{ return new PythonQtShell_QSettings(format, scope, organization, application, parent); } QSettings* PythonQtWrapper_QSettings::new_QSettings(QSettings::Scope scope, QObject* parent) -{ +{ return new PythonQtShell_QSettings(scope, parent); } QSettings* PythonQtWrapper_QSettings::new_QSettings(QSettings::Scope scope, const QString& organization, const QString& application, QObject* parent) -{ +{ return new PythonQtShell_QSettings(scope, organization, application, parent); } QSettings* PythonQtWrapper_QSettings::new_QSettings(const QString& fileName, QSettings::Format format, QObject* parent) -{ +{ return new PythonQtShell_QSettings(fileName, format, parent); } QSettings* PythonQtWrapper_QSettings::new_QSettings(const QString& organization, const QString& application, QObject* parent) -{ +{ return new PythonQtShell_QSettings(organization, application, parent); } const QMetaObject* PythonQtShell_QSettings::metaObject() const { @@ -1678,11 +1678,11 @@ if (_wrapper) { QSharedMemory::timerEvent(event0); } QSharedMemory* PythonQtWrapper_QSharedMemory::new_QSharedMemory(QObject* parent) -{ +{ return new PythonQtShell_QSharedMemory(parent); } QSharedMemory* PythonQtWrapper_QSharedMemory::new_QSharedMemory(const QString& key, QObject* parent) -{ +{ return new PythonQtShell_QSharedMemory(key, parent); } const QMetaObject* PythonQtShell_QSharedMemory::metaObject() const { @@ -1776,11 +1776,11 @@ bool PythonQtWrapper_QSharedMemory::unlock(QSharedMemory* theWrappedObject) QSignalBlocker* PythonQtWrapper_QSignalBlocker::new_QSignalBlocker(QObject& o) -{ +{ return new QSignalBlocker(o); } QSignalBlocker* PythonQtWrapper_QSignalBlocker::new_QSignalBlocker(QObject* o) -{ +{ return new QSignalBlocker(o); } void PythonQtWrapper_QSignalBlocker::reblock(QSignalBlocker* theWrappedObject) @@ -1932,7 +1932,7 @@ if (_wrapper) { QSignalMapper::timerEvent(event0); } QSignalMapper* PythonQtWrapper_QSignalMapper::new_QSignalMapper(QObject* parent) -{ +{ return new PythonQtShell_QSignalMapper(parent); } const QMetaObject* PythonQtShell_QSignalMapper::metaObject() const { @@ -2187,11 +2187,11 @@ if (_wrapper) { QSignalTransition::timerEvent(event0); } QSignalTransition* PythonQtWrapper_QSignalTransition::new_QSignalTransition(QState* sourceState) -{ +{ return new PythonQtShell_QSignalTransition(sourceState); } QSignalTransition* PythonQtWrapper_QSignalTransition::new_QSignalTransition(const QObject* sender, const char* signal, QState* sourceState) -{ +{ return new PythonQtShell_QSignalTransition(sender, signal, sourceState); } const QMetaObject* PythonQtShell_QSignalTransition::metaObject() const { @@ -2366,7 +2366,7 @@ if (_wrapper) { QSocketNotifier::timerEvent(event0); } QSocketNotifier* PythonQtWrapper_QSocketNotifier::new_QSocketNotifier(qintptr socket, QSocketNotifier::Type arg__2, QObject* parent) -{ +{ return new PythonQtShell_QSocketNotifier(socket, arg__2, parent); } const QMetaObject* PythonQtShell_QSocketNotifier::metaObject() const { @@ -2627,11 +2627,11 @@ if (_wrapper) { QState::timerEvent(event0); } QState* PythonQtWrapper_QState::new_QState(QState* parent) -{ +{ return new PythonQtShell_QState(parent); } QState* PythonQtWrapper_QState::new_QState(QState::ChildMode childMode, QState* parent) -{ +{ return new PythonQtShell_QState(childMode, parent); } const QMetaObject* PythonQtShell_QState::metaObject() const { @@ -2978,11 +2978,11 @@ if (_wrapper) { QStateMachine::timerEvent(event0); } QStateMachine* PythonQtWrapper_QStateMachine::new_QStateMachine(QObject* parent) -{ +{ return new PythonQtShell_QStateMachine(parent); } QStateMachine* PythonQtWrapper_QStateMachine::new_QStateMachine(QState::ChildMode childMode, QObject* parent) -{ +{ return new PythonQtShell_QStateMachine(childMode, parent); } const QMetaObject* PythonQtShell_QStateMachine::metaObject() const { @@ -3106,7 +3106,7 @@ void PythonQtWrapper_QStateMachine::setGlobalRestorePolicy(QStateMachine* theWra QStateMachine::SignalEvent* PythonQtWrapper_QStateMachine__SignalEvent::new_QStateMachine__SignalEvent(QObject* sender, int signalIndex, const QList& arguments) -{ +{ return new QStateMachine::SignalEvent(sender, signalIndex, arguments); } QList PythonQtWrapper_QStateMachine__SignalEvent::arguments(QStateMachine::SignalEvent* theWrappedObject) const @@ -3127,7 +3127,7 @@ int PythonQtWrapper_QStateMachine__SignalEvent::signalIndex(QStateMachine::Sign QStateMachine::WrappedEvent* PythonQtWrapper_QStateMachine__WrappedEvent::new_QStateMachine__WrappedEvent(QObject* object, QEvent* event) -{ +{ return new QStateMachine::WrappedEvent(object, event); } QEvent* PythonQtWrapper_QStateMachine__WrappedEvent::event(QStateMachine::WrappedEvent* theWrappedObject) const @@ -3143,19 +3143,19 @@ QObject* PythonQtWrapper_QStateMachine__WrappedEvent::object(QStateMachine::Wra QStorageInfo* PythonQtWrapper_QStorageInfo::new_QStorageInfo() -{ +{ return new QStorageInfo(); } QStorageInfo* PythonQtWrapper_QStorageInfo::new_QStorageInfo(const QDir& dir) -{ +{ return new QStorageInfo(dir); } QStorageInfo* PythonQtWrapper_QStorageInfo::new_QStorageInfo(const QStorageInfo& other) -{ +{ return new QStorageInfo(other); } QStorageInfo* PythonQtWrapper_QStorageInfo::new_QStorageInfo(const QString& path) -{ +{ return new QStorageInfo(path); } int PythonQtWrapper_QStorageInfo::blockSize(QStorageInfo* theWrappedObject) const @@ -3278,15 +3278,15 @@ QString PythonQtWrapper_QStorageInfo::py_toString(QStorageInfo* obj) { QStringMatcher* PythonQtWrapper_QStringMatcher::new_QStringMatcher() -{ +{ return new QStringMatcher(); } QStringMatcher* PythonQtWrapper_QStringMatcher::new_QStringMatcher(const QString& pattern, Qt::CaseSensitivity cs) -{ +{ return new QStringMatcher(pattern, cs); } QStringMatcher* PythonQtWrapper_QStringMatcher::new_QStringMatcher(const QStringMatcher& other) -{ +{ return new QStringMatcher(other); } Qt::CaseSensitivity PythonQtWrapper_QStringMatcher::caseSensitivity(QStringMatcher* theWrappedObject) const @@ -3326,7 +3326,7 @@ PythonQtShell_QSysInfo::~PythonQtShell_QSysInfo() { if (priv) { priv->shellClassDeleted(this); } } QSysInfo* PythonQtWrapper_QSysInfo::new_QSysInfo() -{ +{ return new PythonQtShell_QSysInfo(); } QByteArray PythonQtWrapper_QSysInfo::static_QSysInfo_bootUniqueId() @@ -3387,7 +3387,7 @@ QString PythonQtWrapper_QSysInfo::static_QSysInfo_productVersion() QSystemSemaphore* PythonQtWrapper_QSystemSemaphore::new_QSystemSemaphore(const QString& key, int initialValue, QSystemSemaphore::AccessMode mode) -{ +{ return new QSystemSemaphore(key, initialValue, mode); } bool PythonQtWrapper_QSystemSemaphore::acquire(QSystemSemaphore* theWrappedObject) @@ -3423,11 +3423,11 @@ void PythonQtWrapper_QSystemSemaphore::setKey(QSystemSemaphore* theWrappedObject QTemporaryDir* PythonQtWrapper_QTemporaryDir::new_QTemporaryDir() -{ +{ return new QTemporaryDir(); } QTemporaryDir* PythonQtWrapper_QTemporaryDir::new_QTemporaryDir(const QString& templateName) -{ +{ return new QTemporaryDir(templateName); } bool PythonQtWrapper_QTemporaryDir::autoRemove(QTemporaryDir* theWrappedObject) const @@ -4253,19 +4253,19 @@ if (_wrapper) { return QTemporaryFile::writeData(data0, len1); } QTemporaryFile* PythonQtWrapper_QTemporaryFile::new_QTemporaryFile() -{ +{ return new PythonQtShell_QTemporaryFile(); } QTemporaryFile* PythonQtWrapper_QTemporaryFile::new_QTemporaryFile(QObject* parent) -{ +{ return new PythonQtShell_QTemporaryFile(parent); } QTemporaryFile* PythonQtWrapper_QTemporaryFile::new_QTemporaryFile(const QString& templateName) -{ +{ return new PythonQtShell_QTemporaryFile(templateName); } QTemporaryFile* PythonQtWrapper_QTemporaryFile::new_QTemporaryFile(const QString& templateName, QObject* parent) -{ +{ return new PythonQtShell_QTemporaryFile(templateName, parent); } const QMetaObject* PythonQtShell_QTemporaryFile::metaObject() const { @@ -4339,15 +4339,15 @@ void PythonQtWrapper_QTemporaryFile::setFileTemplate(QTemporaryFile* theWrappedO QTextBoundaryFinder* PythonQtWrapper_QTextBoundaryFinder::new_QTextBoundaryFinder() -{ +{ return new QTextBoundaryFinder(); } QTextBoundaryFinder* PythonQtWrapper_QTextBoundaryFinder::new_QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, const QString& string) -{ +{ return new QTextBoundaryFinder(type, string); } QTextBoundaryFinder* PythonQtWrapper_QTextBoundaryFinder::new_QTextBoundaryFinder(const QTextBoundaryFinder& other) -{ +{ return new QTextBoundaryFinder(other); } QTextBoundaryFinder::BoundaryReasons PythonQtWrapper_QTextBoundaryFinder::boundaryReasons(QTextBoundaryFinder* theWrappedObject) const @@ -4577,7 +4577,7 @@ if (_wrapper) { return QByteArray(); } QTextCodec* PythonQtWrapper_QTextCodec::new_QTextCodec() -{ +{ return new PythonQtShell_QTextCodec(); } QList PythonQtWrapper_QTextCodec::aliases(QTextCodec* theWrappedObject) const @@ -4693,11 +4693,11 @@ QString PythonQtWrapper_QTextCodec::toUnicode(QTextCodec* theWrappedObject, con QTextDecoder* PythonQtWrapper_QTextDecoder::new_QTextDecoder(const QTextCodec* codec) -{ +{ return new QTextDecoder(codec); } QTextDecoder* PythonQtWrapper_QTextDecoder::new_QTextDecoder(const QTextCodec* codec, QTextCodec::ConversionFlags flags) -{ +{ return new QTextDecoder(codec, flags); } bool PythonQtWrapper_QTextDecoder::hasFailure(QTextDecoder* theWrappedObject) const @@ -4718,11 +4718,11 @@ QString PythonQtWrapper_QTextDecoder::toUnicode(QTextDecoder* theWrappedObject, QTextEncoder* PythonQtWrapper_QTextEncoder::new_QTextEncoder(const QTextCodec* codec) -{ +{ return new QTextEncoder(codec); } QTextEncoder* PythonQtWrapper_QTextEncoder::new_QTextEncoder(const QTextCodec* codec, QTextCodec::ConversionFlags flags) -{ +{ return new QTextEncoder(codec, flags); } QByteArray PythonQtWrapper_QTextEncoder::fromUnicode(QTextEncoder* theWrappedObject, const QString& str) @@ -4742,15 +4742,15 @@ PythonQtShell_QTextStream::~PythonQtShell_QTextStream() { if (priv) { priv->shellClassDeleted(this); } } QTextStream* PythonQtWrapper_QTextStream::new_QTextStream() -{ +{ return new PythonQtShell_QTextStream(); } QTextStream* PythonQtWrapper_QTextStream::new_QTextStream(QIODevice* device) -{ +{ return new PythonQtShell_QTextStream(device); } QTextStream* PythonQtWrapper_QTextStream::new_QTextStream(const QByteArray& array, QIODevice::OpenMode openMode) -{ +{ return new PythonQtShell_QTextStream(array, openMode); } bool PythonQtWrapper_QTextStream::atEnd(QTextStream* theWrappedObject) const @@ -5164,7 +5164,7 @@ if (_wrapper) { QThread::timerEvent(event0); } QThread* PythonQtWrapper_QThread::new_QThread(QObject* parent) -{ +{ return new PythonQtShell_QThread(parent); } const QMetaObject* PythonQtShell_QThread::metaObject() const { @@ -5439,7 +5439,7 @@ if (_wrapper) { QThreadPool::timerEvent(event0); } QThreadPool* PythonQtWrapper_QThreadPool::new_QThreadPool(QObject* parent) -{ +{ return new PythonQtShell_QThreadPool(parent); } const QMetaObject* PythonQtShell_QThreadPool::metaObject() const { @@ -5712,7 +5712,7 @@ if (_wrapper) { return QTimeLine::valueForTime(msec0); } QTimeLine* PythonQtWrapper_QTimeLine::new_QTimeLine(int duration, QObject* parent) -{ +{ return new PythonQtShell_QTimeLine(duration, parent); } const QMetaObject* PythonQtShell_QTimeLine::metaObject() const { @@ -5846,23 +5846,23 @@ qreal PythonQtWrapper_QTimeLine::valueForTime(QTimeLine* theWrappedObject, int QTimeZone* PythonQtWrapper_QTimeZone::new_QTimeZone() -{ +{ return new QTimeZone(); } QTimeZone* PythonQtWrapper_QTimeZone::new_QTimeZone(const QByteArray& ianaId) -{ +{ return new QTimeZone(ianaId); } QTimeZone* PythonQtWrapper_QTimeZone::new_QTimeZone(const QByteArray& zoneId, int offsetSeconds, const QString& name, const QString& abbreviation, QLocale::Country country, const QString& comment) -{ +{ return new QTimeZone(zoneId, offsetSeconds, name, abbreviation, country, comment); } QTimeZone* PythonQtWrapper_QTimeZone::new_QTimeZone(const QTimeZone& other) -{ +{ return new QTimeZone(other); } QTimeZone* PythonQtWrapper_QTimeZone::new_QTimeZone(int offsetSeconds) -{ +{ return new QTimeZone(offsetSeconds); } QString PythonQtWrapper_QTimeZone::abbreviation(QTimeZone* theWrappedObject, const QDateTime& atDateTime) const diff --git a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core4.cpp b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core4.cpp index 9ed540b9b..44e719cf0 100644 --- a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core4.cpp +++ b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core4.cpp @@ -162,7 +162,7 @@ if (_wrapper) { QTimer::timerEvent(arg__1); } QTimer* PythonQtWrapper_QTimer::new_QTimer(QObject* parent) -{ +{ return new PythonQtShell_QTimer(parent); } const QMetaObject* PythonQtShell_QTimer::metaObject() const { @@ -240,7 +240,7 @@ PythonQtShell_QTimerEvent::~PythonQtShell_QTimerEvent() { if (priv) { priv->shellClassDeleted(this); } } QTimerEvent* PythonQtWrapper_QTimerEvent::new_QTimerEvent(int timerId) -{ +{ return new PythonQtShell_QTimerEvent(timerId); } int PythonQtWrapper_QTimerEvent::timerId(QTimerEvent* theWrappedObject) const @@ -453,7 +453,7 @@ if (_wrapper) { return QTranslator::translate(context0, sourceText1, disambiguation2, n3); } QTranslator* PythonQtWrapper_QTranslator::new_QTranslator(QObject* parent) -{ +{ return new PythonQtShell_QTranslator(parent); } const QMetaObject* PythonQtShell_QTranslator::metaObject() const { @@ -507,19 +507,19 @@ QString PythonQtWrapper_QTranslator::translate(QTranslator* theWrappedObject, c QUrlQuery* PythonQtWrapper_QUrlQuery::new_QUrlQuery() -{ +{ return new QUrlQuery(); } QUrlQuery* PythonQtWrapper_QUrlQuery::new_QUrlQuery(const QString& queryString) -{ +{ return new QUrlQuery(queryString); } QUrlQuery* PythonQtWrapper_QUrlQuery::new_QUrlQuery(const QUrl& url) -{ +{ return new QUrlQuery(url); } QUrlQuery* PythonQtWrapper_QUrlQuery::new_QUrlQuery(const QUrlQuery& other) -{ +{ return new QUrlQuery(other); } void PythonQtWrapper_QUrlQuery::addQueryItem(QUrlQuery* theWrappedObject, const QString& key, const QString& value) @@ -640,19 +640,19 @@ PythonQtShell_QUuid::~PythonQtShell_QUuid() { if (priv) { priv->shellClassDeleted(this); } } QUuid* PythonQtWrapper_QUuid::new_QUuid() -{ +{ return new PythonQtShell_QUuid(); } QUuid* PythonQtWrapper_QUuid::new_QUuid(const QByteArray& arg__1) -{ +{ return new PythonQtShell_QUuid(arg__1); } QUuid* PythonQtWrapper_QUuid::new_QUuid(const QString& arg__1) -{ +{ return new PythonQtShell_QUuid(arg__1); } QUuid* PythonQtWrapper_QUuid::new_QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3, uchar b4, uchar b5, uchar b6, uchar b7, uchar b8) -{ +{ return new PythonQtShell_QUuid(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8); } QUuid PythonQtWrapper_QUuid::static_QUuid_createUuid() @@ -1069,7 +1069,7 @@ if (_wrapper) { QVariantAnimation::updateState(newState0, oldState1); } QVariantAnimation* PythonQtWrapper_QVariantAnimation::new_QVariantAnimation(QObject* parent) -{ +{ return new PythonQtShell_QVariantAnimation(parent); } const QMetaObject* PythonQtShell_QVariantAnimation::metaObject() const { @@ -1158,7 +1158,7 @@ void PythonQtWrapper_QVariantAnimation::updateCurrentValue(QVariantAnimation* th QWaitCondition* PythonQtWrapper_QWaitCondition::new_QWaitCondition() -{ +{ return new QWaitCondition(); } void PythonQtWrapper_QWaitCondition::notify_all(QWaitCondition* theWrappedObject) @@ -1204,7 +1204,7 @@ void PythonQtWrapper_QWaitCondition::wakeOne(QWaitCondition* theWrappedObject) QWriteLocker* PythonQtWrapper_QWriteLocker::new_QWriteLocker(QReadWriteLock* readWriteLock) -{ +{ return new QWriteLocker(readWriteLock); } QReadWriteLock* PythonQtWrapper_QWriteLocker::readWriteLock(QWriteLocker* theWrappedObject) const @@ -1295,7 +1295,7 @@ if (_wrapper) { return QXmlStreamEntityResolver::resolveUndeclaredEntity(name0); } QXmlStreamEntityResolver* PythonQtWrapper_QXmlStreamEntityResolver::new_QXmlStreamEntityResolver() -{ +{ return new PythonQtShell_QXmlStreamEntityResolver(); } QString PythonQtWrapper_QXmlStreamEntityResolver::resolveEntity(QXmlStreamEntityResolver* theWrappedObject, const QString& publicId, const QString& systemId) diff --git a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core4.h b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core4.h index 5b3a44f9d..1ea5f2343 100644 --- a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core4.h +++ b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core4.h @@ -364,7 +364,7 @@ void delete_QWriteLocker(QWriteLocker* obj) { delete obj; } void __enter__(QWriteLocker* /*self*/) {} void __exit__(QWriteLocker* self, PyObject* /*type*/, PyObject* /*value*/, PyObject* /*traceback*/) { self->unlock(); } - + }; diff --git a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core_init.cpp b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core_init.cpp index 32efc9dec..ff919b85d 100644 --- a/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core_init.cpp +++ b/generated_cpp_515/com_trolltech_qt_core/com_trolltech_qt_core_init.cpp @@ -176,7 +176,7 @@ PythonQt::priv()->registerClass(&QVariantAnimation::staticMetaObject, "QtCore", PythonQt::priv()->registerCPPClass("QWaitCondition", "", "QtCore", PythonQtCreateObject, nullptr, module, 0); PythonQt::priv()->registerCPPClass("QWriteLocker", "", "QtCore", PythonQtCreateObject, nullptr, module, PythonQt::Type_EnterExit); PythonQt::priv()->registerCPPClass("QXmlStreamEntityResolver", "", "QtCore", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); -PythonQt::priv()->registerGlobalNamespace("QtCore", "QtCore", PythonQtCreateObject, PythonQtWrapper_QtCore::staticMetaObject, module); +PythonQt::priv()->registerGlobalNamespace("QtCore", "QtCore", PythonQtCreateObject, PythonQtWrapper_QtCore::staticMetaObject, module); PythonQt::self()->addPolymorphicHandler("QEvent", polymorphichandler_QEvent); diff --git a/generated_cpp_515/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp b/generated_cpp_515/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp index 59599351c..07523c7f8 100644 --- a/generated_cpp_515/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp +++ b/generated_cpp_515/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.cpp @@ -32,15 +32,15 @@ #include QBitArray* PythonQtWrapper_QBitArray::new_QBitArray() -{ +{ return new QBitArray(); } QBitArray* PythonQtWrapper_QBitArray::new_QBitArray(const QBitArray& other) -{ +{ return new QBitArray(other); } QBitArray* PythonQtWrapper_QBitArray::new_QBitArray(int size, bool val) -{ +{ return new QBitArray(size, val); } bool PythonQtWrapper_QBitArray::at(QBitArray* theWrappedObject, int i) const @@ -208,15 +208,15 @@ QString PythonQtWrapper_QBitArray::py_toString(QBitArray* obj) { QByteArray* PythonQtWrapper_QByteArray::new_QByteArray() -{ +{ return new QByteArray(); } QByteArray* PythonQtWrapper_QByteArray::new_QByteArray(const QByteArray& arg__1) -{ +{ return new QByteArray(arg__1); } QByteArray* PythonQtWrapper_QByteArray::new_QByteArray(int size, char c) -{ +{ return new QByteArray(size, c); } QByteArray* PythonQtWrapper_QByteArray::append(QByteArray* theWrappedObject, char c) @@ -802,15 +802,15 @@ void PythonQtWrapper_QByteArray::truncate(QByteArray* theWrappedObject, int pos QDate* PythonQtWrapper_QDate::new_QDate() -{ +{ return new QDate(); } QDate* PythonQtWrapper_QDate::new_QDate(int y, int m, int d) -{ +{ return new QDate(y, m, d); } QDate* PythonQtWrapper_QDate::new_QDate(int y, int m, int d, QCalendar cal) -{ +{ return new QDate(y, m, d, cal); } QDate PythonQtWrapper_QDate::addDays(QDate* theWrappedObject, qint64 days) const @@ -1092,27 +1092,27 @@ QString PythonQtWrapper_QDate::py_toString(QDate* obj) { return obj->toString(); QDateTime* PythonQtWrapper_QDateTime::new_QDateTime() -{ +{ return new QDateTime(); } QDateTime* PythonQtWrapper_QDateTime::new_QDateTime(const QDate& arg__1) -{ +{ return new QDateTime(arg__1); } QDateTime* PythonQtWrapper_QDateTime::new_QDateTime(const QDate& arg__1, const QTime& arg__2, Qt::TimeSpec spec) -{ +{ return new QDateTime(arg__1, arg__2, spec); } QDateTime* PythonQtWrapper_QDateTime::new_QDateTime(const QDate& date, const QTime& time, Qt::TimeSpec spec, int offsetSeconds) -{ +{ return new QDateTime(date, time, spec, offsetSeconds); } QDateTime* PythonQtWrapper_QDateTime::new_QDateTime(const QDate& date, const QTime& time, const QTimeZone& timeZone) -{ +{ return new QDateTime(date, time, timeZone); } QDateTime* PythonQtWrapper_QDateTime::new_QDateTime(const QDateTime& other) -{ +{ return new QDateTime(other); } QDateTime PythonQtWrapper_QDateTime::addDays(QDateTime* theWrappedObject, qint64 days) const @@ -1429,15 +1429,15 @@ QString PythonQtWrapper_QDateTime::py_toString(QDateTime* obj) { return obj->toS QLine* PythonQtWrapper_QLine::new_QLine() -{ +{ return new QLine(); } QLine* PythonQtWrapper_QLine::new_QLine(const QPoint& pt1, const QPoint& pt2) -{ +{ return new QLine(pt1, pt2); } QLine* PythonQtWrapper_QLine::new_QLine(int x1, int y1, int x2, int y2) -{ +{ return new QLine(x1, y1, x2, y2); } QPoint PythonQtWrapper_QLine::center(QLine* theWrappedObject) const @@ -1570,19 +1570,19 @@ QString PythonQtWrapper_QLine::py_toString(QLine* obj) { QLineF* PythonQtWrapper_QLineF::new_QLineF() -{ +{ return new QLineF(); } QLineF* PythonQtWrapper_QLineF::new_QLineF(const QLine& line) -{ +{ return new QLineF(line); } QLineF* PythonQtWrapper_QLineF::new_QLineF(const QPointF& pt1, const QPointF& pt2) -{ +{ return new QLineF(pt1, pt2); } QLineF* PythonQtWrapper_QLineF::new_QLineF(qreal x1, qreal y1, qreal x2, qreal y2) -{ +{ return new QLineF(x1, y1, x2, y2); } qreal PythonQtWrapper_QLineF::angle(QLineF* theWrappedObject) const @@ -1780,23 +1780,23 @@ QString PythonQtWrapper_QLineF::py_toString(QLineF* obj) { QLocale* PythonQtWrapper_QLocale::new_QLocale() -{ +{ return new QLocale(); } QLocale* PythonQtWrapper_QLocale::new_QLocale(QLocale::Language language, QLocale::Country country) -{ +{ return new QLocale(language, country); } QLocale* PythonQtWrapper_QLocale::new_QLocale(QLocale::Language language, QLocale::Script script, QLocale::Country country) -{ +{ return new QLocale(language, script, country); } QLocale* PythonQtWrapper_QLocale::new_QLocale(const QLocale& other) -{ +{ return new QLocale(other); } QLocale* PythonQtWrapper_QLocale::new_QLocale(const QString& name) -{ +{ return new QLocale(name); } QString PythonQtWrapper_QLocale::amText(QLocale* theWrappedObject) const @@ -2299,11 +2299,11 @@ QString PythonQtWrapper_QLocale::py_toString(QLocale* obj) { QPoint* PythonQtWrapper_QPoint::new_QPoint() -{ +{ return new QPoint(); } QPoint* PythonQtWrapper_QPoint::new_QPoint(int xpos, int ypos) -{ +{ return new QPoint(xpos, ypos); } int PythonQtWrapper_QPoint::static_QPoint_dotProduct(const QPoint& p1, const QPoint& p2) @@ -2451,15 +2451,15 @@ QString PythonQtWrapper_QPoint::py_toString(QPoint* obj) { QPointF* PythonQtWrapper_QPointF::new_QPointF() -{ +{ return new QPointF(); } QPointF* PythonQtWrapper_QPointF::new_QPointF(const QPoint& p) -{ +{ return new QPointF(p); } QPointF* PythonQtWrapper_QPointF::new_QPointF(qreal xpos, qreal ypos) -{ +{ return new QPointF(xpos, ypos); } qreal PythonQtWrapper_QPointF::static_QPointF_dotProduct(const QPointF& p1, const QPointF& p2) @@ -2592,19 +2592,19 @@ QString PythonQtWrapper_QPointF::py_toString(QPointF* obj) { QRect* PythonQtWrapper_QRect::new_QRect() -{ +{ return new QRect(); } QRect* PythonQtWrapper_QRect::new_QRect(const QPoint& topleft, const QPoint& bottomright) -{ +{ return new QRect(topleft, bottomright); } QRect* PythonQtWrapper_QRect::new_QRect(const QPoint& topleft, const QSize& size) -{ +{ return new QRect(topleft, size); } QRect* PythonQtWrapper_QRect::new_QRect(int left, int top, int width, int height) -{ +{ return new QRect(left, top, width, height); } void PythonQtWrapper_QRect::adjust(QRect* theWrappedObject, int x1, int y1, int x2, int y2) @@ -2977,23 +2977,23 @@ QString PythonQtWrapper_QRect::py_toString(QRect* obj) { QRectF* PythonQtWrapper_QRectF::new_QRectF() -{ +{ return new QRectF(); } QRectF* PythonQtWrapper_QRectF::new_QRectF(const QPointF& topleft, const QPointF& bottomRight) -{ +{ return new QRectF(topleft, bottomRight); } QRectF* PythonQtWrapper_QRectF::new_QRectF(const QPointF& topleft, const QSizeF& size) -{ +{ return new QRectF(topleft, size); } QRectF* PythonQtWrapper_QRectF::new_QRectF(const QRect& rect) -{ +{ return new QRectF(rect); } QRectF* PythonQtWrapper_QRectF::new_QRectF(qreal left, qreal top, qreal width, qreal height) -{ +{ return new QRectF(left, top, width, height); } void PythonQtWrapper_QRectF::adjust(QRectF* theWrappedObject, qreal x1, qreal y1, qreal x2, qreal y2) @@ -3371,15 +3371,15 @@ QString PythonQtWrapper_QRectF::py_toString(QRectF* obj) { QRegularExpression* PythonQtWrapper_QRegularExpression::new_QRegularExpression() -{ +{ return new QRegularExpression(); } QRegularExpression* PythonQtWrapper_QRegularExpression::new_QRegularExpression(const QRegularExpression& re) -{ +{ return new QRegularExpression(re); } QRegularExpression* PythonQtWrapper_QRegularExpression::new_QRegularExpression(const QString& pattern, QRegularExpression::PatternOptions options) -{ +{ return new QRegularExpression(pattern, options); } QString PythonQtWrapper_QRegularExpression::static_QRegularExpression_anchoredPattern(const QString& expression) @@ -3497,11 +3497,11 @@ QString PythonQtWrapper_QRegularExpression::py_toString(QRegularExpression* obj) QSize* PythonQtWrapper_QSize::new_QSize() -{ +{ return new QSize(); } QSize* PythonQtWrapper_QSize::new_QSize(int w, int h) -{ +{ return new QSize(w, h); } QSize PythonQtWrapper_QSize::boundedTo(QSize* theWrappedObject, const QSize& arg__1) const @@ -3659,15 +3659,15 @@ QString PythonQtWrapper_QSize::py_toString(QSize* obj) { QSizeF* PythonQtWrapper_QSizeF::new_QSizeF() -{ +{ return new QSizeF(); } QSizeF* PythonQtWrapper_QSizeF::new_QSizeF(const QSize& sz) -{ +{ return new QSizeF(sz); } QSizeF* PythonQtWrapper_QSizeF::new_QSizeF(qreal w, qreal h) -{ +{ return new QSizeF(w, h); } QSizeF PythonQtWrapper_QSizeF::boundedTo(QSizeF* theWrappedObject, const QSizeF& arg__1) const @@ -3830,11 +3830,11 @@ QString PythonQtWrapper_QSizeF::py_toString(QSizeF* obj) { QTime* PythonQtWrapper_QTime::new_QTime() -{ +{ return new QTime(); } QTime* PythonQtWrapper_QTime::new_QTime(int h, int m, int s, int ms) -{ +{ return new QTime(h, m, s, ms); } QTime PythonQtWrapper_QTime::addMSecs(QTime* theWrappedObject, int ms) const @@ -3991,15 +3991,15 @@ QString PythonQtWrapper_QTime::py_toString(QTime* obj) { return obj->toString(); QUrl* PythonQtWrapper_QUrl::new_QUrl() -{ +{ return new QUrl(); } QUrl* PythonQtWrapper_QUrl::new_QUrl(const QString& url, QUrl::ParsingMode mode) -{ +{ return new QUrl(url, mode); } QUrl* PythonQtWrapper_QUrl::new_QUrl(const QUrl& copy) -{ +{ return new QUrl(copy); } QUrl PythonQtWrapper_QUrl::adjusted(QUrl* theWrappedObject, QUrl::FormattingOptions options) const diff --git a/generated_cpp_515/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h b/generated_cpp_515/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h index 14b22a91a..709117667 100644 --- a/generated_cpp_515/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h +++ b/generated_cpp_515/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h @@ -214,7 +214,7 @@ void delete_QByteArray(QByteArray* obj) { delete obj; } PyObject* data(QByteArray* b) { return PyBytes_FromStringAndSize(b->data(), b->size()); } - + }; diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui0.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui0.cpp index 4448976a5..2b744840e 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui0.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui0.cpp @@ -1092,7 +1092,7 @@ if (_wrapper) { } } } - + } QPaintDevice* PythonQtShell_QAbstractButton::redirected(QPoint* offset0) const { @@ -1326,7 +1326,7 @@ if (_wrapper) { QAbstractButton::wheelEvent(event0); } QAbstractButton* PythonQtWrapper_QAbstractButton::new_QAbstractButton(QWidget* parent) -{ +{ return new PythonQtShell_QAbstractButton(parent); } const QMetaObject* PythonQtShell_QAbstractButton::metaObject() const { @@ -1990,7 +1990,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -2184,7 +2184,7 @@ if (_wrapper) { } } } - + } bool PythonQtShell_QAbstractGraphicsShapeItem::sceneEvent(QEvent* event0) { @@ -2396,7 +2396,7 @@ if (_wrapper) { QAbstractGraphicsShapeItem::wheelEvent(event0); } QAbstractGraphicsShapeItem* PythonQtWrapper_QAbstractGraphicsShapeItem::new_QAbstractGraphicsShapeItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QAbstractGraphicsShapeItem(parent); } QBrush PythonQtWrapper_QAbstractGraphicsShapeItem::brush(QAbstractGraphicsShapeItem* theWrappedObject) const @@ -2676,7 +2676,7 @@ if (_wrapper) { } } } - + } QVector PythonQtShell_QAbstractItemDelegate::paintingRoles() const { @@ -2833,7 +2833,7 @@ if (_wrapper) { QAbstractItemDelegate::updateEditorGeometry(editor0, option1, index2); } QAbstractItemDelegate* PythonQtWrapper_QAbstractItemDelegate::new_QAbstractItemDelegate(QObject* parent) -{ +{ return new PythonQtShell_QAbstractItemDelegate(parent); } const QMetaObject* PythonQtShell_QAbstractItemDelegate::metaObject() const { @@ -4344,7 +4344,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractItemView::selectAll() { @@ -4520,7 +4520,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractItemView::setSelectionModel(QItemSelectionModel* selectionModel0) { @@ -5139,7 +5139,7 @@ if (_wrapper) { QAbstractItemView::wheelEvent(arg__1); } QAbstractItemView* PythonQtWrapper_QAbstractItemView::new_QAbstractItemView(QWidget* parent) -{ +{ return new PythonQtShell_QAbstractItemView(parent); } const QMetaObject* PythonQtShell_QAbstractItemView::metaObject() const { @@ -6832,7 +6832,7 @@ if (_wrapper) { QAbstractPrintDialog::wheelEvent(event0); } QAbstractPrintDialog* PythonQtWrapper_QAbstractPrintDialog::new_QAbstractPrintDialog(QPrinter* printer, QWidget* parent) -{ +{ return new PythonQtShell_QAbstractPrintDialog(printer, parent); } const QMetaObject* PythonQtShell_QAbstractPrintDialog::metaObject() const { @@ -8300,7 +8300,7 @@ if (_wrapper) { QAbstractProxyModel::timerEvent(event0); } QAbstractProxyModel* PythonQtWrapper_QAbstractProxyModel::new_QAbstractProxyModel(QObject* parent) -{ +{ return new PythonQtShell_QAbstractProxyModel(parent); } const QMetaObject* PythonQtShell_QAbstractProxyModel::metaObject() const { @@ -9607,7 +9607,7 @@ if (_wrapper) { QAbstractScrollArea::wheelEvent(arg__1); } QAbstractScrollArea* PythonQtWrapper_QAbstractScrollArea::new_QAbstractScrollArea(QWidget* parent) -{ +{ return new PythonQtShell_QAbstractScrollArea(parent); } const QMetaObject* PythonQtShell_QAbstractScrollArea::metaObject() const { @@ -10921,7 +10921,7 @@ if (_wrapper) { QAbstractSlider::wheelEvent(e0); } QAbstractSlider* PythonQtWrapper_QAbstractSlider::new_QAbstractSlider(QWidget* parent) -{ +{ return new PythonQtShell_QAbstractSlider(parent); } const QMetaObject* PythonQtShell_QAbstractSlider::metaObject() const { @@ -12340,7 +12340,7 @@ if (_wrapper) { QAbstractSpinBox::wheelEvent(event0); } QAbstractSpinBox* PythonQtWrapper_QAbstractSpinBox::new_QAbstractSpinBox(QWidget* parent) -{ +{ return new PythonQtShell_QAbstractSpinBox(parent); } const QMetaObject* PythonQtShell_QAbstractSpinBox::metaObject() const { @@ -13678,7 +13678,7 @@ if (_wrapper) { QAbstractTableModel::timerEvent(event0); } QAbstractTableModel* PythonQtWrapper_QAbstractTableModel::new_QAbstractTableModel(QObject* parent) -{ +{ return new PythonQtShell_QAbstractTableModel(parent); } const QMetaObject* PythonQtShell_QAbstractTableModel::metaObject() const { @@ -13797,7 +13797,7 @@ if (_wrapper) { } } } - + } QSizeF PythonQtShell_QAbstractTextDocumentLayout::documentSize() const { @@ -13852,7 +13852,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractTextDocumentLayout::drawInlineObject(QPainter* painter0, const QRectF& rect1, QTextInlineObject object2, int posInDocument3, const QTextFormat& format4) { @@ -14108,7 +14108,7 @@ if (_wrapper) { QAbstractTextDocumentLayout::timerEvent(event0); } QAbstractTextDocumentLayout* PythonQtWrapper_QAbstractTextDocumentLayout::new_QAbstractTextDocumentLayout(QTextDocument* doc) -{ +{ return new PythonQtShell_QAbstractTextDocumentLayout(doc); } const QMetaObject* PythonQtShell_QAbstractTextDocumentLayout::metaObject() const { @@ -14236,7 +14236,7 @@ PythonQtShell_QAbstractTextDocumentLayout__PaintContext::~PythonQtShell_QAbstrac if (priv) { priv->shellClassDeleted(this); } } QAbstractTextDocumentLayout::PaintContext* PythonQtWrapper_QAbstractTextDocumentLayout__PaintContext::new_QAbstractTextDocumentLayout__PaintContext() -{ +{ return new PythonQtShell_QAbstractTextDocumentLayout__PaintContext(); } @@ -14246,7 +14246,7 @@ PythonQtShell_QAbstractTextDocumentLayout__Selection::~PythonQtShell_QAbstractTe if (priv) { priv->shellClassDeleted(this); } } QAbstractTextDocumentLayout::Selection* PythonQtWrapper_QAbstractTextDocumentLayout__Selection::new_QAbstractTextDocumentLayout__Selection() -{ +{ return new PythonQtShell_QAbstractTextDocumentLayout__Selection(); } @@ -14256,7 +14256,7 @@ PythonQtShell_QAccessibleEvent::~PythonQtShell_QAccessibleEvent() { if (priv) { priv->shellClassDeleted(this); } } QAccessibleEvent* PythonQtWrapper_QAccessibleEvent::new_QAccessibleEvent(QObject* obj, QAccessible::Event typ) -{ +{ return new PythonQtShell_QAccessibleEvent(obj, typ); } int PythonQtWrapper_QAccessibleEvent::child(QAccessibleEvent* theWrappedObject) const @@ -14425,15 +14425,15 @@ if (_wrapper) { QAction::timerEvent(event0); } QAction* PythonQtWrapper_QAction::new_QAction(QObject* parent) -{ +{ return new PythonQtShell_QAction(parent); } QAction* PythonQtWrapper_QAction::new_QAction(const QIcon& icon, const QString& text, QObject* parent) -{ +{ return new PythonQtShell_QAction(icon, text, parent); } QAction* PythonQtWrapper_QAction::new_QAction(const QString& text, QObject* parent) -{ +{ return new PythonQtShell_QAction(text, parent); } const QMetaObject* PythonQtShell_QAction::metaObject() const { @@ -14704,7 +14704,7 @@ QString PythonQtWrapper_QAction::py_toString(QAction* obj) { QActionEvent* PythonQtWrapper_QActionEvent::new_QActionEvent(int type, QAction* action, QAction* before) -{ +{ return new QActionEvent(type, action, before); } QAction* PythonQtWrapper_QActionEvent::action(QActionEvent* theWrappedObject) const @@ -14856,7 +14856,7 @@ if (_wrapper) { QActionGroup::timerEvent(event0); } QActionGroup* PythonQtWrapper_QActionGroup::new_QActionGroup(QObject* parent) -{ +{ return new PythonQtShell_QActionGroup(parent); } const QMetaObject* PythonQtShell_QActionGroup::metaObject() const { @@ -15152,7 +15152,7 @@ QIcon PythonQtWrapper_QApplication::static_QApplication_windowIcon() QBackingStore* PythonQtWrapper_QBackingStore::new_QBackingStore(QWindow* window) -{ +{ return new QBackingStore(window); } void PythonQtWrapper_QBackingStore::beginPaint(QBackingStore* theWrappedObject, const QRegion& arg__1) @@ -15976,7 +15976,7 @@ if (_wrapper) { return QBoxLayout::widget(); } QBoxLayout* PythonQtWrapper_QBoxLayout::new_QBoxLayout(QBoxLayout::Direction arg__1, QWidget* parent) -{ +{ return new PythonQtShell_QBoxLayout(arg__1, parent); } const QMetaObject* PythonQtShell_QBoxLayout::metaObject() const { @@ -16231,7 +16231,7 @@ if (_wrapper) { QButtonGroup::timerEvent(event0); } QButtonGroup* PythonQtWrapper_QButtonGroup::new_QButtonGroup(QObject* parent) -{ +{ return new PythonQtShell_QButtonGroup(parent); } const QMetaObject* PythonQtShell_QButtonGroup::metaObject() const { @@ -17470,7 +17470,7 @@ if (_wrapper) { QCalendarWidget::wheelEvent(event0); } QCalendarWidget* PythonQtWrapper_QCalendarWidget::new_QCalendarWidget(QWidget* parent) -{ +{ return new PythonQtShell_QCalendarWidget(parent); } const QMetaObject* PythonQtShell_QCalendarWidget::metaObject() const { @@ -18879,11 +18879,11 @@ if (_wrapper) { QCheckBox::wheelEvent(event0); } QCheckBox* PythonQtWrapper_QCheckBox::new_QCheckBox(QWidget* parent) -{ +{ return new PythonQtShell_QCheckBox(parent); } QCheckBox* PythonQtWrapper_QCheckBox::new_QCheckBox(const QString& text, QWidget* parent) -{ +{ return new PythonQtShell_QCheckBox(text, parent); } const QMetaObject* PythonQtShell_QCheckBox::metaObject() const { @@ -19014,7 +19014,7 @@ QString PythonQtWrapper_QClipboard::text(QClipboard* theWrappedObject, QString& QCloseEvent* PythonQtWrapper_QCloseEvent::new_QCloseEvent() -{ +{ return new QCloseEvent(); } @@ -20267,11 +20267,11 @@ if (_wrapper) { QColorDialog::wheelEvent(event0); } QColorDialog* PythonQtWrapper_QColorDialog::new_QColorDialog(QWidget* parent) -{ +{ return new PythonQtShell_QColorDialog(parent); } QColorDialog* PythonQtWrapper_QColorDialog::new_QColorDialog(const QColor& initial, QWidget* parent) -{ +{ return new PythonQtShell_QColorDialog(initial, parent); } const QMetaObject* PythonQtShell_QColorDialog::metaObject() const { @@ -20365,27 +20365,27 @@ bool PythonQtWrapper_QColorDialog::testOption(QColorDialog* theWrappedObject, Q QColorSpace* PythonQtWrapper_QColorSpace::new_QColorSpace() -{ +{ return new QColorSpace(); } QColorSpace* PythonQtWrapper_QColorSpace::new_QColorSpace(QColorSpace::NamedColorSpace namedColorSpace) -{ +{ return new QColorSpace(namedColorSpace); } QColorSpace* PythonQtWrapper_QColorSpace::new_QColorSpace(QColorSpace::Primaries primaries, QColorSpace::TransferFunction transferFunction, float gamma) -{ +{ return new QColorSpace(primaries, transferFunction, gamma); } QColorSpace* PythonQtWrapper_QColorSpace::new_QColorSpace(QColorSpace::Primaries primaries, float gamma) -{ +{ return new QColorSpace(primaries, gamma); } QColorSpace* PythonQtWrapper_QColorSpace::new_QColorSpace(const QColorSpace& colorSpace) -{ +{ return new QColorSpace(colorSpace); } QColorSpace* PythonQtWrapper_QColorSpace::new_QColorSpace(const QPointF& whitePoint, const QPointF& redPoint, const QPointF& greenPoint, const QPointF& bluePoint, QColorSpace::TransferFunction transferFunction, float gamma) -{ +{ return new QColorSpace(whitePoint, redPoint, greenPoint, bluePoint, transferFunction, gamma); } QColorSpace PythonQtWrapper_QColorSpace::static_QColorSpace_fromIccProfile(const QByteArray& iccProfile) @@ -20483,11 +20483,11 @@ QString PythonQtWrapper_QColorSpace::py_toString(QColorSpace* obj) { QColorTransform* PythonQtWrapper_QColorTransform::new_QColorTransform() -{ +{ return new QColorTransform(); } QColorTransform* PythonQtWrapper_QColorTransform::new_QColorTransform(const QColorTransform& colorTransform) -{ +{ return new QColorTransform(colorTransform); } QRgba64 PythonQtWrapper_QColorTransform::map(QColorTransform* theWrappedObject, QRgba64 rgba64) const @@ -22788,7 +22788,7 @@ if (_wrapper) { QColumnView::wheelEvent(arg__1); } QColumnView* PythonQtWrapper_QColumnView::new_QColumnView(QWidget* parent) -{ +{ return new PythonQtShell_QColumnView(parent); } const QMetaObject* PythonQtShell_QColumnView::metaObject() const { @@ -24039,7 +24039,7 @@ if (_wrapper) { QComboBox::wheelEvent(e0); } QComboBox* PythonQtWrapper_QComboBox::new_QComboBox(QWidget* parent) -{ +{ return new PythonQtShell_QComboBox(parent); } const QMetaObject* PythonQtShell_QComboBox::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui1.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui1.cpp index 626362bcb..b2ea17a42 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui1.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui1.cpp @@ -1295,15 +1295,15 @@ if (_wrapper) { QCommandLinkButton::wheelEvent(event0); } QCommandLinkButton* PythonQtWrapper_QCommandLinkButton::new_QCommandLinkButton(QWidget* parent) -{ +{ return new PythonQtShell_QCommandLinkButton(parent); } QCommandLinkButton* PythonQtWrapper_QCommandLinkButton::new_QCommandLinkButton(const QString& text, QWidget* parent) -{ +{ return new PythonQtShell_QCommandLinkButton(text, parent); } QCommandLinkButton* PythonQtWrapper_QCommandLinkButton::new_QCommandLinkButton(const QString& text, const QString& description, QWidget* parent) -{ +{ return new PythonQtShell_QCommandLinkButton(text, description, parent); } const QMetaObject* PythonQtShell_QCommandLinkButton::metaObject() const { @@ -2084,7 +2084,7 @@ if (_wrapper) { QCommonStyle::unpolish(widget0); } QCommonStyle* PythonQtWrapper_QCommonStyle::new_QCommonStyle() -{ +{ return new PythonQtShell_QCommonStyle(); } const QMetaObject* PythonQtShell_QCommonStyle::metaObject() const { @@ -2305,15 +2305,15 @@ if (_wrapper) { QCompleter::timerEvent(event0); } QCompleter* PythonQtWrapper_QCompleter::new_QCompleter(QAbstractItemModel* model, QObject* parent) -{ +{ return new PythonQtShell_QCompleter(model, parent); } QCompleter* PythonQtWrapper_QCompleter::new_QCompleter(QObject* parent) -{ +{ return new PythonQtShell_QCompleter(parent); } QCompleter* PythonQtWrapper_QCompleter::new_QCompleter(const QStringList& completions, QObject* parent) -{ +{ return new PythonQtShell_QCompleter(completions, parent); } const QMetaObject* PythonQtShell_QCompleter::metaObject() const { @@ -3707,7 +3707,7 @@ if (_wrapper) { QConcatenateTablesProxyModel::timerEvent(event0); } QConcatenateTablesProxyModel* PythonQtWrapper_QConcatenateTablesProxyModel::new_QConcatenateTablesProxyModel(QObject* parent) -{ +{ return new PythonQtShell_QConcatenateTablesProxyModel(parent); } const QMetaObject* PythonQtShell_QConcatenateTablesProxyModel::metaObject() const { @@ -3751,15 +3751,15 @@ QList PythonQtWrapper_QConcatenateTablesProxyModel::sourc QConicalGradient* PythonQtWrapper_QConicalGradient::new_QConicalGradient() -{ +{ return new QConicalGradient(); } QConicalGradient* PythonQtWrapper_QConicalGradient::new_QConicalGradient(const QPointF& center, qreal startAngle) -{ +{ return new QConicalGradient(center, startAngle); } QConicalGradient* PythonQtWrapper_QConicalGradient::new_QConicalGradient(qreal cx, qreal cy, qreal startAngle) -{ +{ return new QConicalGradient(cx, cy, startAngle); } qreal PythonQtWrapper_QConicalGradient::angle(QConicalGradient* theWrappedObject) const @@ -3794,15 +3794,15 @@ PythonQtShell_QContextMenuEvent::~PythonQtShell_QContextMenuEvent() { if (priv) { priv->shellClassDeleted(this); } } QContextMenuEvent* PythonQtWrapper_QContextMenuEvent::new_QContextMenuEvent(QContextMenuEvent::Reason reason, const QPoint& pos) -{ +{ return new PythonQtShell_QContextMenuEvent(reason, pos); } QContextMenuEvent* PythonQtWrapper_QContextMenuEvent::new_QContextMenuEvent(QContextMenuEvent::Reason reason, const QPoint& pos, const QPoint& globalPos) -{ +{ return new PythonQtShell_QContextMenuEvent(reason, pos, globalPos); } QContextMenuEvent* PythonQtWrapper_QContextMenuEvent::new_QContextMenuEvent(QContextMenuEvent::Reason reason, const QPoint& pos, const QPoint& globalPos, Qt::KeyboardModifiers modifiers) -{ +{ return new PythonQtShell_QContextMenuEvent(reason, pos, globalPos, modifiers); } const QPoint* PythonQtWrapper_QContextMenuEvent::globalPos(QContextMenuEvent* theWrappedObject) const @@ -4001,7 +4001,7 @@ if (_wrapper) { QDataWidgetMapper::timerEvent(event0); } QDataWidgetMapper* PythonQtWrapper_QDataWidgetMapper::new_QDataWidgetMapper(QObject* parent) -{ +{ return new PythonQtShell_QDataWidgetMapper(parent); } const QMetaObject* PythonQtShell_QDataWidgetMapper::metaObject() const { @@ -5456,11 +5456,11 @@ if (_wrapper) { QDateEdit::wheelEvent(event0); } QDateEdit* PythonQtWrapper_QDateEdit::new_QDateEdit(QWidget* parent) -{ +{ return new PythonQtShell_QDateEdit(parent); } QDateEdit* PythonQtWrapper_QDateEdit::new_QDateEdit(const QDate& date, QWidget* parent) -{ +{ return new PythonQtShell_QDateEdit(date, parent); } const QMetaObject* PythonQtShell_QDateEdit::metaObject() const { @@ -6825,27 +6825,27 @@ if (_wrapper) { QDateTimeEdit::wheelEvent(event0); } QDateTimeEdit* PythonQtWrapper_QDateTimeEdit::new_QDateTimeEdit(QWidget* parent) -{ +{ return new PythonQtShell_QDateTimeEdit(parent); } QDateTimeEdit* PythonQtWrapper_QDateTimeEdit::new_QDateTimeEdit(const QDate& d, QWidget* parent) -{ +{ return new PythonQtShell_QDateTimeEdit(d, parent); } QDateTimeEdit* PythonQtWrapper_QDateTimeEdit::new_QDateTimeEdit(const QDateTime& dt, QWidget* parent) -{ +{ return new PythonQtShell_QDateTimeEdit(dt, parent); } QDateTimeEdit* PythonQtWrapper_QDateTimeEdit::new_QDateTimeEdit(const QTime& t, QWidget* parent) -{ +{ return new PythonQtShell_QDateTimeEdit(t, parent); } QDateTimeEdit* PythonQtWrapper_QDateTimeEdit::new_QDateTimeEdit(const QVariant& val, QMetaType::Type parserType, QWidget* parent) -{ +{ return new PythonQtShell_QDateTimeEdit(val, parserType, parent); } QDateTimeEdit* PythonQtWrapper_QDateTimeEdit::new_QDateTimeEdit(const QVariant& val, QVariant::Type parserType, QWidget* parent) -{ +{ return new PythonQtShell_QDateTimeEdit(val, parserType, parent); } const QMetaObject* PythonQtShell_QDateTimeEdit::metaObject() const { @@ -7098,7 +7098,7 @@ PythonQtShell_QDesktopServices::~PythonQtShell_QDesktopServices() { if (priv) { priv->shellClassDeleted(this); } } QDesktopServices* PythonQtWrapper_QDesktopServices::new_QDesktopServices() -{ +{ return new PythonQtShell_QDesktopServices(); } bool PythonQtWrapper_QDesktopServices::static_QDesktopServices_openUrl(const QUrl& url) @@ -8267,7 +8267,7 @@ if (_wrapper) { QDesktopWidget::wheelEvent(event0); } QDesktopWidget* PythonQtWrapper_QDesktopWidget::new_QDesktopWidget() -{ +{ return new PythonQtShell_QDesktopWidget(); } const QMetaObject* PythonQtShell_QDesktopWidget::metaObject() const { @@ -9521,7 +9521,7 @@ if (_wrapper) { QDial::wheelEvent(e0); } QDial* PythonQtWrapper_QDial::new_QDial(QWidget* parent) -{ +{ return new PythonQtShell_QDial(parent); } const QMetaObject* PythonQtShell_QDial::metaObject() const { @@ -10849,7 +10849,7 @@ if (_wrapper) { QDialog::wheelEvent(event0); } QDialog* PythonQtWrapper_QDialog::new_QDialog(QWidget* parent, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QDialog(parent, f); } const QMetaObject* PythonQtShell_QDialog::metaObject() const { @@ -12056,19 +12056,19 @@ if (_wrapper) { QDialogButtonBox::wheelEvent(event0); } QDialogButtonBox* PythonQtWrapper_QDialogButtonBox::new_QDialogButtonBox(QDialogButtonBox::StandardButtons buttons, QWidget* parent) -{ +{ return new PythonQtShell_QDialogButtonBox(buttons, parent); } QDialogButtonBox* PythonQtWrapper_QDialogButtonBox::new_QDialogButtonBox(QDialogButtonBox::StandardButtons buttons, Qt::Orientation orientation, QWidget* parent) -{ +{ return new PythonQtShell_QDialogButtonBox(buttons, orientation, parent); } QDialogButtonBox* PythonQtWrapper_QDialogButtonBox::new_QDialogButtonBox(QWidget* parent) -{ +{ return new PythonQtShell_QDialogButtonBox(parent); } QDialogButtonBox* PythonQtWrapper_QDialogButtonBox::new_QDialogButtonBox(Qt::Orientation orientation, QWidget* parent) -{ +{ return new PythonQtShell_QDialogButtonBox(orientation, parent); } const QMetaObject* PythonQtShell_QDialogButtonBox::metaObject() const { @@ -13387,11 +13387,11 @@ if (_wrapper) { QDirModel::timerEvent(event0); } QDirModel* PythonQtWrapper_QDirModel::new_QDirModel(QObject* parent) -{ +{ return new PythonQtShell_QDirModel(parent); } QDirModel* PythonQtWrapper_QDirModel::new_QDirModel(const QStringList& nameFilters, QDir::Filters filters, QDir::SortFlags sort, QObject* parent) -{ +{ return new PythonQtShell_QDirModel(nameFilters, filters, sort, parent); } const QMetaObject* PythonQtShell_QDirModel::metaObject() const { @@ -14673,11 +14673,11 @@ if (_wrapper) { QDockWidget::wheelEvent(event0); } QDockWidget* PythonQtWrapper_QDockWidget::new_QDockWidget(QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QDockWidget(parent, flags); } QDockWidget* PythonQtWrapper_QDockWidget::new_QDockWidget(const QString& title, QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QDockWidget(title, parent, flags); } const QMetaObject* PythonQtShell_QDockWidget::metaObject() const { @@ -16107,7 +16107,7 @@ if (_wrapper) { QDoubleSpinBox::wheelEvent(event0); } QDoubleSpinBox* PythonQtWrapper_QDoubleSpinBox::new_QDoubleSpinBox(QWidget* parent) -{ +{ return new PythonQtShell_QDoubleSpinBox(parent); } const QMetaObject* PythonQtShell_QDoubleSpinBox::metaObject() const { @@ -16434,11 +16434,11 @@ if (_wrapper) { return QDoubleValidator::validate(arg__1, arg__2); } QDoubleValidator* PythonQtWrapper_QDoubleValidator::new_QDoubleValidator(QObject* parent) -{ +{ return new PythonQtShell_QDoubleValidator(parent); } QDoubleValidator* PythonQtWrapper_QDoubleValidator::new_QDoubleValidator(double bottom, double top, int decimals, QObject* parent) -{ +{ return new PythonQtShell_QDoubleValidator(bottom, top, decimals, parent); } const QMetaObject* PythonQtShell_QDoubleValidator::metaObject() const { @@ -16638,7 +16638,7 @@ if (_wrapper) { QDrag::timerEvent(event0); } QDrag* PythonQtWrapper_QDrag::new_QDrag(QObject* dragSource) -{ +{ return new PythonQtShell_QDrag(dragSource); } const QMetaObject* PythonQtShell_QDrag::metaObject() const { @@ -16732,13 +16732,13 @@ QObject* PythonQtWrapper_QDrag::target(QDrag* theWrappedObject) const QDragEnterEvent* PythonQtWrapper_QDragEnterEvent::new_QDragEnterEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData* data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) -{ +{ return new QDragEnterEvent(pos, actions, data, buttons, modifiers); } QDragLeaveEvent* PythonQtWrapper_QDragLeaveEvent::new_QDragLeaveEvent() -{ +{ return new QDragLeaveEvent(); } @@ -16748,7 +16748,7 @@ PythonQtShell_QDragMoveEvent::~PythonQtShell_QDragMoveEvent() { if (priv) { priv->shellClassDeleted(this); } } QDragMoveEvent* PythonQtWrapper_QDragMoveEvent::new_QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData* data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, QEvent::Type type) -{ +{ return new PythonQtShell_QDragMoveEvent(pos, actions, data, buttons, modifiers, type); } void PythonQtWrapper_QDragMoveEvent::accept(QDragMoveEvent* theWrappedObject, const QRect& r) @@ -16773,7 +16773,7 @@ PythonQtShell_QDropEvent::~PythonQtShell_QDropEvent() { if (priv) { priv->shellClassDeleted(this); } } QDropEvent* PythonQtWrapper_QDropEvent::new_QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData* data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, QEvent::Type type) -{ +{ return new PythonQtShell_QDropEvent(pos, actions, data, buttons, modifiers, type); } void PythonQtWrapper_QDropEvent::acceptProposedAction(QDropEvent* theWrappedObject) @@ -16838,7 +16838,7 @@ PythonQtShell_QEnterEvent::~PythonQtShell_QEnterEvent() { if (priv) { priv->shellClassDeleted(this); } } QEnterEvent* PythonQtWrapper_QEnterEvent::new_QEnterEvent(const QPointF& localPos, const QPointF& windowPos, const QPointF& screenPos) -{ +{ return new PythonQtShell_QEnterEvent(localPos, windowPos, screenPos); } QPoint PythonQtWrapper_QEnterEvent::globalPos(QEnterEvent* theWrappedObject) const @@ -18158,7 +18158,7 @@ if (_wrapper) { QErrorMessage::wheelEvent(event0); } QErrorMessage* PythonQtWrapper_QErrorMessage::new_QErrorMessage(QWidget* parent) -{ +{ return new PythonQtShell_QErrorMessage(parent); } const QMetaObject* PythonQtShell_QErrorMessage::metaObject() const { @@ -18186,7 +18186,7 @@ PythonQtShell_QExposeEvent::~PythonQtShell_QExposeEvent() { if (priv) { priv->shellClassDeleted(this); } } QExposeEvent* PythonQtWrapper_QExposeEvent::new_QExposeEvent(const QRegion& rgn) -{ +{ return new PythonQtShell_QExposeEvent(rgn); } const QRegion* PythonQtWrapper_QExposeEvent::region(QExposeEvent* theWrappedObject) const @@ -19444,11 +19444,11 @@ if (_wrapper) { QFileDialog::wheelEvent(event0); } QFileDialog* PythonQtWrapper_QFileDialog::new_QFileDialog(QWidget* parent, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QFileDialog(parent, f); } QFileDialog* PythonQtWrapper_QFileDialog::new_QFileDialog(QWidget* parent, const QString& caption, const QString& directory, const QString& filter) -{ +{ return new PythonQtShell_QFileDialog(parent, caption, directory, filter); } const QMetaObject* PythonQtShell_QFileDialog::metaObject() const { @@ -19900,7 +19900,7 @@ if (_wrapper) { return QFileIconProvider::type(info0); } QFileIconProvider* PythonQtWrapper_QFileIconProvider::new_QFileIconProvider() -{ +{ return new PythonQtShell_QFileIconProvider(); } QIcon PythonQtWrapper_QFileIconProvider::icon(QFileIconProvider* theWrappedObject, QFileIconProvider::IconType type) const @@ -19931,11 +19931,11 @@ QString PythonQtWrapper_QFileIconProvider::type(QFileIconProvider* theWrappedOb QFileOpenEvent* PythonQtWrapper_QFileOpenEvent::new_QFileOpenEvent(const QString& file) -{ +{ return new QFileOpenEvent(file); } QFileOpenEvent* PythonQtWrapper_QFileOpenEvent::new_QFileOpenEvent(const QUrl& url) -{ +{ return new QFileOpenEvent(url); } QString PythonQtWrapper_QFileOpenEvent::file(QFileOpenEvent* theWrappedObject) const @@ -21181,7 +21181,7 @@ if (_wrapper) { QFileSystemModel::timerEvent(event0); } QFileSystemModel* PythonQtWrapper_QFileSystemModel::new_QFileSystemModel(QObject* parent) -{ +{ return new PythonQtShell_QFileSystemModel(parent); } const QMetaObject* PythonQtShell_QFileSystemModel::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui10.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui10.cpp index 28ff90dab..19f50967e 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui10.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui10.cpp @@ -95,21 +95,21 @@ PythonQtShell_QStyleOptionViewItemV4::~PythonQtShell_QStyleOptionViewItemV4() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionViewItemV4* PythonQtWrapper_QStyleOptionViewItemV4::new_QStyleOptionViewItemV4() -{ +{ return new PythonQtShell_QStyleOptionViewItemV4(); } QStylePainter* PythonQtWrapper_QStylePainter::new_QStylePainter() -{ +{ return new QStylePainter(); } QStylePainter* PythonQtWrapper_QStylePainter::new_QStylePainter(QPaintDevice* pd, QWidget* w) -{ +{ return new QStylePainter(pd, w); } QStylePainter* PythonQtWrapper_QStylePainter::new_QStylePainter(QWidget* w) -{ +{ return new QStylePainter(w); } bool PythonQtWrapper_QStylePainter::begin(QStylePainter* theWrappedObject, QPaintDevice* pd, QWidget* w) @@ -324,7 +324,7 @@ if (_wrapper) { QStylePlugin::timerEvent(event0); } QStylePlugin* PythonQtWrapper_QStylePlugin::new_QStylePlugin(QObject* parent) -{ +{ return new PythonQtShell_QStylePlugin(parent); } const QMetaObject* PythonQtShell_QStylePlugin::metaObject() const { @@ -814,7 +814,7 @@ if (_wrapper) { QStyledItemDelegate::updateEditorGeometry(editor0, option1, index2); } QStyledItemDelegate* PythonQtWrapper_QStyledItemDelegate::new_QStyledItemDelegate(QObject* parent) -{ +{ return new PythonQtShell_QStyledItemDelegate(parent); } const QMetaObject* PythonQtShell_QStyledItemDelegate::metaObject() const { @@ -989,7 +989,7 @@ if (_wrapper) { return QSurface::SurfaceType(); } QSurface* PythonQtWrapper_QSurface::new_QSurface(QSurface::SurfaceClass type) -{ +{ return new PythonQtShell_QSurface(type); } QSurfaceFormat PythonQtWrapper_QSurface::format(QSurface* theWrappedObject) const @@ -1025,15 +1025,15 @@ QSurface::SurfaceType PythonQtWrapper_QSurface::surfaceType(QSurface* theWrappe QSurfaceFormat* PythonQtWrapper_QSurfaceFormat::new_QSurfaceFormat() -{ +{ return new QSurfaceFormat(); } QSurfaceFormat* PythonQtWrapper_QSurfaceFormat::new_QSurfaceFormat(QSurfaceFormat::FormatOptions options) -{ +{ return new QSurfaceFormat(options); } QSurfaceFormat* PythonQtWrapper_QSurfaceFormat::new_QSurfaceFormat(const QSurfaceFormat& other) -{ +{ return new QSurfaceFormat(other); } int PythonQtWrapper_QSurfaceFormat::alphaBufferSize(QSurfaceFormat* theWrappedObject) const @@ -1402,7 +1402,7 @@ if (_wrapper) { QSwipeGesture::timerEvent(event0); } QSwipeGesture* PythonQtWrapper_QSwipeGesture::new_QSwipeGesture(QObject* parent) -{ +{ return new PythonQtShell_QSwipeGesture(parent); } const QMetaObject* PythonQtShell_QSwipeGesture::metaObject() const { @@ -1574,7 +1574,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QSyntaxHighlighter::timerEvent(QTimerEvent* event0) { @@ -1599,11 +1599,11 @@ if (_wrapper) { QSyntaxHighlighter::timerEvent(event0); } QSyntaxHighlighter* PythonQtWrapper_QSyntaxHighlighter::new_QSyntaxHighlighter(QObject* parent) -{ +{ return new PythonQtShell_QSyntaxHighlighter(parent); } QSyntaxHighlighter* PythonQtWrapper_QSyntaxHighlighter::new_QSyntaxHighlighter(QTextDocument* parent) -{ +{ return new PythonQtShell_QSyntaxHighlighter(parent); } const QMetaObject* PythonQtShell_QSyntaxHighlighter::metaObject() const { @@ -1823,11 +1823,11 @@ if (_wrapper) { QSystemTrayIcon::timerEvent(event0); } QSystemTrayIcon* PythonQtWrapper_QSystemTrayIcon::new_QSystemTrayIcon(QObject* parent) -{ +{ return new PythonQtShell_QSystemTrayIcon(parent); } QSystemTrayIcon* PythonQtWrapper_QSystemTrayIcon::new_QSystemTrayIcon(const QIcon& icon, QObject* parent) -{ +{ return new PythonQtShell_QSystemTrayIcon(icon, parent); } const QMetaObject* PythonQtShell_QSystemTrayIcon::metaObject() const { @@ -3176,7 +3176,7 @@ if (_wrapper) { QTabBar::wheelEvent(event0); } QTabBar* PythonQtWrapper_QTabBar::new_QTabBar(QWidget* parent) -{ +{ return new PythonQtShell_QTabBar(parent); } const QMetaObject* PythonQtShell_QTabBar::metaObject() const { @@ -4697,7 +4697,7 @@ if (_wrapper) { QTabWidget::wheelEvent(event0); } QTabWidget* PythonQtWrapper_QTabWidget::new_QTabWidget(QWidget* parent) -{ +{ return new PythonQtShell_QTabWidget(parent); } const QMetaObject* PythonQtShell_QTabWidget::metaObject() const { @@ -7203,7 +7203,7 @@ if (_wrapper) { QTableView::wheelEvent(arg__1); } QTableView* PythonQtWrapper_QTableView::new_QTableView(QWidget* parent) -{ +{ return new PythonQtShell_QTableView(parent); } const QMetaObject* PythonQtShell_QTableView::metaObject() const { @@ -9714,11 +9714,11 @@ if (_wrapper) { QTableWidget::wheelEvent(arg__1); } QTableWidget* PythonQtWrapper_QTableWidget::new_QTableWidget(QWidget* parent) -{ +{ return new PythonQtShell_QTableWidget(parent); } QTableWidget* PythonQtWrapper_QTableWidget::new_QTableWidget(int rows, int columns, QWidget* parent) -{ +{ return new PythonQtShell_QTableWidget(rows, columns, parent); } const QMetaObject* PythonQtShell_QTableWidget::metaObject() const { @@ -10128,15 +10128,15 @@ if (_wrapper) { QTableWidgetItem::write(out0); } QTableWidgetItem* PythonQtWrapper_QTableWidgetItem::new_QTableWidgetItem(const QIcon& icon, const QString& text, int type) -{ +{ return new PythonQtShell_QTableWidgetItem(icon, text, type); } QTableWidgetItem* PythonQtWrapper_QTableWidgetItem::new_QTableWidgetItem(const QString& text, int type) -{ +{ return new PythonQtShell_QTableWidgetItem(text, type); } QTableWidgetItem* PythonQtWrapper_QTableWidgetItem::new_QTableWidgetItem(int type) -{ +{ return new PythonQtShell_QTableWidgetItem(type); } QBrush PythonQtWrapper_QTableWidgetItem::background(QTableWidgetItem* theWrappedObject) const @@ -10327,15 +10327,15 @@ void PythonQtWrapper_QTableWidgetItem::write(QTableWidgetItem* theWrappedObject, QTableWidgetSelectionRange* PythonQtWrapper_QTableWidgetSelectionRange::new_QTableWidgetSelectionRange() -{ +{ return new QTableWidgetSelectionRange(); } QTableWidgetSelectionRange* PythonQtWrapper_QTableWidgetSelectionRange::new_QTableWidgetSelectionRange(const QTableWidgetSelectionRange& other) -{ +{ return new QTableWidgetSelectionRange(other); } QTableWidgetSelectionRange* PythonQtWrapper_QTableWidgetSelectionRange::new_QTableWidgetSelectionRange(int top, int left, int bottom, int right) -{ +{ return new QTableWidgetSelectionRange(top, left, bottom, right); } int PythonQtWrapper_QTableWidgetSelectionRange::bottomRow(QTableWidgetSelectionRange* theWrappedObject) const @@ -10380,11 +10380,11 @@ PythonQtShell_QTabletEvent::~PythonQtShell_QTabletEvent() { if (priv) { priv->shellClassDeleted(this); } } QTabletEvent* PythonQtWrapper_QTabletEvent::new_QTabletEvent(QEvent::Type t, const QPointF& pos, const QPointF& globalPos, int device, int pointerType, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID) -{ +{ return new PythonQtShell_QTabletEvent(t, pos, globalPos, device, pointerType, pressure, xTilt, yTilt, tangentialPressure, rotation, z, keyState, uniqueID); } QTabletEvent* PythonQtWrapper_QTabletEvent::new_QTabletEvent(QEvent::Type t, const QPointF& pos, const QPointF& globalPos, int device, int pointerType, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID, Qt::MouseButton button, Qt::MouseButtons buttons) -{ +{ return new PythonQtShell_QTabletEvent(t, pos, globalPos, device, pointerType, pressure, xTilt, yTilt, tangentialPressure, rotation, z, keyState, uniqueID, button, buttons); } Qt::MouseButton PythonQtWrapper_QTabletEvent::button(QTabletEvent* theWrappedObject) const @@ -10636,7 +10636,7 @@ if (_wrapper) { QTapAndHoldGesture::timerEvent(event0); } QTapAndHoldGesture* PythonQtWrapper_QTapAndHoldGesture::new_QTapAndHoldGesture(QObject* parent) -{ +{ return new PythonQtShell_QTapAndHoldGesture(parent); } const QMetaObject* PythonQtShell_QTapAndHoldGesture::metaObject() const { @@ -10811,7 +10811,7 @@ if (_wrapper) { QTapGesture::timerEvent(event0); } QTapGesture* PythonQtWrapper_QTapGesture::new_QTapGesture(QObject* parent) -{ +{ return new PythonQtShell_QTapGesture(parent); } const QMetaObject* PythonQtShell_QTapGesture::metaObject() const { @@ -10840,11 +10840,11 @@ void PythonQtWrapper_QTapGesture::setPosition(QTapGesture* theWrappedObject, con QTextBlock* PythonQtWrapper_QTextBlock::new_QTextBlock() -{ +{ return new QTextBlock(); } QTextBlock* PythonQtWrapper_QTextBlock::new_QTextBlock(const QTextBlock& o) -{ +{ return new QTextBlock(o); } QTextBlock::iterator PythonQtWrapper_QTextBlock::begin(QTextBlock* theWrappedObject) const @@ -11029,11 +11029,11 @@ PythonQtShell_QTextBlockFormat::~PythonQtShell_QTextBlockFormat() { if (priv) { priv->shellClassDeleted(this); } } QTextBlockFormat* PythonQtWrapper_QTextBlockFormat::new_QTextBlockFormat() -{ +{ return new PythonQtShell_QTextBlockFormat(); } QTextBlockFormat* PythonQtWrapper_QTextBlockFormat::new_QTextBlockFormat(const QTextFormat& fmt) -{ +{ return new PythonQtShell_QTextBlockFormat(fmt); } Qt::Alignment PythonQtWrapper_QTextBlockFormat::alignment(QTextBlockFormat* theWrappedObject) const @@ -11386,7 +11386,7 @@ if (_wrapper) { QTextBlockGroup::timerEvent(event0); } QTextBlockGroup* PythonQtWrapper_QTextBlockGroup::new_QTextBlockGroup(QTextDocument* doc) -{ +{ return new PythonQtShell_QTextBlockGroup(doc); } const QMetaObject* PythonQtShell_QTextBlockGroup::metaObject() const { @@ -11429,7 +11429,7 @@ PythonQtShell_QTextBlockUserData::~PythonQtShell_QTextBlockUserData() { if (priv) { priv->shellClassDeleted(this); } } QTextBlockUserData* PythonQtWrapper_QTextBlockUserData::new_QTextBlockUserData() -{ +{ return new PythonQtShell_QTextBlockUserData(); } @@ -12946,7 +12946,7 @@ if (_wrapper) { QTextBrowser::wheelEvent(e0); } QTextBrowser* PythonQtWrapper_QTextBrowser::new_QTextBrowser(QWidget* parent) -{ +{ return new PythonQtShell_QTextBrowser(parent); } const QMetaObject* PythonQtShell_QTextBrowser::metaObject() const { @@ -13049,11 +13049,11 @@ PythonQtShell_QTextCharFormat::~PythonQtShell_QTextCharFormat() { if (priv) { priv->shellClassDeleted(this); } } QTextCharFormat* PythonQtWrapper_QTextCharFormat::new_QTextCharFormat() -{ +{ return new PythonQtShell_QTextCharFormat(); } QTextCharFormat* PythonQtWrapper_QTextCharFormat::new_QTextCharFormat(const QTextFormat& fmt) -{ +{ return new PythonQtShell_QTextCharFormat(fmt); } QString PythonQtWrapper_QTextCharFormat::anchorHref(QTextCharFormat* theWrappedObject) const @@ -13369,23 +13369,23 @@ QTextCharFormat::VerticalAlignment PythonQtWrapper_QTextCharFormat::verticalAli QTextCursor* PythonQtWrapper_QTextCursor::new_QTextCursor() -{ +{ return new QTextCursor(); } QTextCursor* PythonQtWrapper_QTextCursor::new_QTextCursor(QTextDocument* document) -{ +{ return new QTextCursor(document); } QTextCursor* PythonQtWrapper_QTextCursor::new_QTextCursor(QTextFrame* frame) -{ +{ return new QTextCursor(frame); } QTextCursor* PythonQtWrapper_QTextCursor::new_QTextCursor(const QTextBlock& block) -{ +{ return new QTextCursor(block); } QTextCursor* PythonQtWrapper_QTextCursor::new_QTextCursor(const QTextCursor& cursor) -{ +{ return new QTextCursor(cursor); } int PythonQtWrapper_QTextCursor::anchor(QTextCursor* theWrappedObject) const @@ -13975,11 +13975,11 @@ if (_wrapper) { QTextDocument::timerEvent(event0); } QTextDocument* PythonQtWrapper_QTextDocument::new_QTextDocument(QObject* parent) -{ +{ return new PythonQtShell_QTextDocument(parent); } QTextDocument* PythonQtWrapper_QTextDocument::new_QTextDocument(const QString& text, QObject* parent) -{ +{ return new PythonQtShell_QTextDocument(text, parent); } const QMetaObject* PythonQtShell_QTextDocument::metaObject() const { @@ -14398,19 +14398,19 @@ bool PythonQtWrapper_QTextDocument::useDesignMetrics(QTextDocument* theWrappedO QTextDocumentFragment* PythonQtWrapper_QTextDocumentFragment::new_QTextDocumentFragment() -{ +{ return new QTextDocumentFragment(); } QTextDocumentFragment* PythonQtWrapper_QTextDocumentFragment::new_QTextDocumentFragment(const QTextCursor& range) -{ +{ return new QTextDocumentFragment(range); } QTextDocumentFragment* PythonQtWrapper_QTextDocumentFragment::new_QTextDocumentFragment(const QTextDocument* document) -{ +{ return new QTextDocumentFragment(document); } QTextDocumentFragment* PythonQtWrapper_QTextDocumentFragment::new_QTextDocumentFragment(const QTextDocumentFragment& rhs) -{ +{ return new QTextDocumentFragment(rhs); } QTextDocumentFragment PythonQtWrapper_QTextDocumentFragment::static_QTextDocumentFragment_fromHtml(const QString& html) @@ -14446,15 +14446,15 @@ QString PythonQtWrapper_QTextDocumentFragment::toPlainText(QTextDocumentFragmen QTextDocumentWriter* PythonQtWrapper_QTextDocumentWriter::new_QTextDocumentWriter() -{ +{ return new QTextDocumentWriter(); } QTextDocumentWriter* PythonQtWrapper_QTextDocumentWriter::new_QTextDocumentWriter(QIODevice* device, const QByteArray& format) -{ +{ return new QTextDocumentWriter(device, format); } QTextDocumentWriter* PythonQtWrapper_QTextDocumentWriter::new_QTextDocumentWriter(const QString& fileName, const QByteArray& format) -{ +{ return new QTextDocumentWriter(fileName, format); } QTextCodec* PythonQtWrapper_QTextDocumentWriter::codec(QTextDocumentWriter* theWrappedObject) const @@ -15916,11 +15916,11 @@ if (_wrapper) { QTextEdit::wheelEvent(e0); } QTextEdit* PythonQtWrapper_QTextEdit::new_QTextEdit(QWidget* parent) -{ +{ return new PythonQtShell_QTextEdit(parent); } QTextEdit* PythonQtWrapper_QTextEdit::new_QTextEdit(const QString& text, QWidget* parent) -{ +{ return new PythonQtShell_QTextEdit(text, parent); } const QMetaObject* PythonQtShell_QTextEdit::metaObject() const { @@ -16298,7 +16298,7 @@ PythonQtShell_QTextEdit__ExtraSelection::~PythonQtShell_QTextEdit__ExtraSelectio if (priv) { priv->shellClassDeleted(this); } } QTextEdit::ExtraSelection* PythonQtWrapper_QTextEdit__ExtraSelection::new_QTextEdit__ExtraSelection() -{ +{ return new PythonQtShell_QTextEdit__ExtraSelection(); } diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui11.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui11.cpp index dc1cc11aa..69463c69f 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui11.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui11.cpp @@ -73,11 +73,11 @@ #include QTextFragment* PythonQtWrapper_QTextFragment::new_QTextFragment() -{ +{ return new QTextFragment(); } QTextFragment* PythonQtWrapper_QTextFragment::new_QTextFragment(const QTextFragment& o) -{ +{ return new QTextFragment(o); } QTextCharFormat PythonQtWrapper_QTextFragment::charFormat(QTextFragment* theWrappedObject) const @@ -274,7 +274,7 @@ if (_wrapper) { QTextFrame::timerEvent(event0); } QTextFrame* PythonQtWrapper_QTextFrame::new_QTextFrame(QTextDocument* doc) -{ +{ return new PythonQtShell_QTextFrame(doc); } const QMetaObject* PythonQtShell_QTextFrame::metaObject() const { @@ -347,11 +347,11 @@ PythonQtShell_QTextFrameFormat::~PythonQtShell_QTextFrameFormat() { if (priv) { priv->shellClassDeleted(this); } } QTextFrameFormat* PythonQtWrapper_QTextFrameFormat::new_QTextFrameFormat() -{ +{ return new PythonQtShell_QTextFrameFormat(); } QTextFrameFormat* PythonQtWrapper_QTextFrameFormat::new_QTextFrameFormat(const QTextFormat& fmt) -{ +{ return new PythonQtShell_QTextFrameFormat(fmt); } qreal PythonQtWrapper_QTextFrameFormat::border(QTextFrameFormat* theWrappedObject) const @@ -506,11 +506,11 @@ PythonQtShell_QTextImageFormat::~PythonQtShell_QTextImageFormat() { if (priv) { priv->shellClassDeleted(this); } } QTextImageFormat* PythonQtWrapper_QTextImageFormat::new_QTextImageFormat() -{ +{ return new PythonQtShell_QTextImageFormat(); } QTextImageFormat* PythonQtWrapper_QTextImageFormat::new_QTextImageFormat(const QTextFormat& format) -{ +{ return new PythonQtShell_QTextImageFormat(format); } qreal PythonQtWrapper_QTextImageFormat::height(QTextImageFormat* theWrappedObject) const @@ -561,7 +561,7 @@ qreal PythonQtWrapper_QTextImageFormat::width(QTextImageFormat* theWrappedObjec QTextInlineObject* PythonQtWrapper_QTextInlineObject::new_QTextInlineObject() -{ +{ return new QTextInlineObject(); } qreal PythonQtWrapper_QTextInlineObject::ascent(QTextInlineObject* theWrappedObject) const @@ -636,7 +636,7 @@ PythonQtShell_QTextItem::~PythonQtShell_QTextItem() { if (priv) { priv->shellClassDeleted(this); } } QTextItem* PythonQtWrapper_QTextItem::new_QTextItem() -{ +{ return new PythonQtShell_QTextItem(); } qreal PythonQtWrapper_QTextItem::ascent(QTextItem* theWrappedObject) const @@ -672,19 +672,19 @@ qreal PythonQtWrapper_QTextItem::width(QTextItem* theWrappedObject) const QTextLayout* PythonQtWrapper_QTextLayout::new_QTextLayout() -{ +{ return new QTextLayout(); } QTextLayout* PythonQtWrapper_QTextLayout::new_QTextLayout(const QString& text) -{ +{ return new QTextLayout(text); } QTextLayout* PythonQtWrapper_QTextLayout::new_QTextLayout(const QString& text, const QFont& font, QPaintDevice* paintdevice) -{ +{ return new QTextLayout(text, font, paintdevice); } QTextLayout* PythonQtWrapper_QTextLayout::new_QTextLayout(const QTextBlock& b) -{ +{ return new QTextLayout(b); } QList PythonQtWrapper_QTextLayout::additionalFormats(QTextLayout* theWrappedObject) const @@ -904,13 +904,13 @@ PythonQtShell_QTextLayout__FormatRange::~PythonQtShell_QTextLayout__FormatRange( if (priv) { priv->shellClassDeleted(this); } } QTextLayout::FormatRange* PythonQtWrapper_QTextLayout__FormatRange::new_QTextLayout__FormatRange() -{ +{ return new PythonQtShell_QTextLayout__FormatRange(); } QTextLine* PythonQtWrapper_QTextLine::new_QTextLine() -{ +{ return new QTextLine(); } qreal PythonQtWrapper_QTextLine::ascent(QTextLine* theWrappedObject) const @@ -1248,7 +1248,7 @@ if (_wrapper) { QTextList::timerEvent(event0); } QTextList* PythonQtWrapper_QTextList::new_QTextList(QTextDocument* doc) -{ +{ return new PythonQtShell_QTextList(doc); } const QMetaObject* PythonQtShell_QTextList::metaObject() const { @@ -1316,11 +1316,11 @@ PythonQtShell_QTextListFormat::~PythonQtShell_QTextListFormat() { if (priv) { priv->shellClassDeleted(this); } } QTextListFormat* PythonQtWrapper_QTextListFormat::new_QTextListFormat() -{ +{ return new PythonQtShell_QTextListFormat(); } QTextListFormat* PythonQtWrapper_QTextListFormat::new_QTextListFormat(const QTextFormat& fmt) -{ +{ return new PythonQtShell_QTextListFormat(fmt); } int PythonQtWrapper_QTextListFormat::indent(QTextListFormat* theWrappedObject) const @@ -1507,7 +1507,7 @@ if (_wrapper) { QTextObject::timerEvent(event0); } QTextObject* PythonQtWrapper_QTextObject::new_QTextObject(QTextDocument* doc) -{ +{ return new PythonQtShell_QTextObject(doc); } const QMetaObject* PythonQtShell_QTextObject::metaObject() const { @@ -1551,15 +1551,15 @@ void PythonQtWrapper_QTextObject::setFormat(QTextObject* theWrappedObject, const QTextOption* PythonQtWrapper_QTextOption::new_QTextOption() -{ +{ return new QTextOption(); } QTextOption* PythonQtWrapper_QTextOption::new_QTextOption(Qt::Alignment alignment) -{ +{ return new QTextOption(alignment); } QTextOption* PythonQtWrapper_QTextOption::new_QTextOption(const QTextOption& o) -{ +{ return new QTextOption(o); } Qt::Alignment PythonQtWrapper_QTextOption::alignment(QTextOption* theWrappedObject) const @@ -1659,11 +1659,11 @@ PythonQtShell_QTextOption__Tab::~PythonQtShell_QTextOption__Tab() { if (priv) { priv->shellClassDeleted(this); } } QTextOption::Tab* PythonQtWrapper_QTextOption__Tab::new_QTextOption__Tab() -{ +{ return new PythonQtShell_QTextOption__Tab(); } QTextOption::Tab* PythonQtWrapper_QTextOption__Tab::new_QTextOption__Tab(qreal pos, QTextOption::TabType tabType, QChar delim) -{ +{ return new PythonQtShell_QTextOption__Tab(pos, tabType, delim); } bool PythonQtWrapper_QTextOption__Tab::__ne__(QTextOption::Tab* theWrappedObject, const QTextOption::Tab& other) const @@ -1815,7 +1815,7 @@ if (_wrapper) { QTextTable::timerEvent(event0); } QTextTable* PythonQtWrapper_QTextTable::new_QTextTable(QTextDocument* doc) -{ +{ return new PythonQtShell_QTextTable(doc); } const QMetaObject* PythonQtShell_QTextTable::metaObject() const { @@ -1929,11 +1929,11 @@ void PythonQtWrapper_QTextTable::splitCell(QTextTable* theWrappedObject, int ro QTextTableCell* PythonQtWrapper_QTextTableCell::new_QTextTableCell() -{ +{ return new QTextTableCell(); } QTextTableCell* PythonQtWrapper_QTextTableCell::new_QTextTableCell(const QTextTableCell& o) -{ +{ return new QTextTableCell(o); } QTextFrame::iterator PythonQtWrapper_QTextTableCell::begin(QTextTableCell* theWrappedObject) const @@ -2023,11 +2023,11 @@ PythonQtShell_QTextTableCellFormat::~PythonQtShell_QTextTableCellFormat() { if (priv) { priv->shellClassDeleted(this); } } QTextTableCellFormat* PythonQtWrapper_QTextTableCellFormat::new_QTextTableCellFormat() -{ +{ return new PythonQtShell_QTextTableCellFormat(); } QTextTableCellFormat* PythonQtWrapper_QTextTableCellFormat::new_QTextTableCellFormat(const QTextFormat& fmt) -{ +{ return new PythonQtShell_QTextTableCellFormat(fmt); } qreal PythonQtWrapper_QTextTableCellFormat::bottomBorder(QTextTableCellFormat* theWrappedObject) const @@ -2222,11 +2222,11 @@ PythonQtShell_QTextTableFormat::~PythonQtShell_QTextTableFormat() { if (priv) { priv->shellClassDeleted(this); } } QTextTableFormat* PythonQtWrapper_QTextTableFormat::new_QTextTableFormat() -{ +{ return new PythonQtShell_QTextTableFormat(); } QTextTableFormat* PythonQtWrapper_QTextTableFormat::new_QTextTableFormat(const QTextFormat& fmt) -{ +{ return new PythonQtShell_QTextTableFormat(fmt); } Qt::Alignment PythonQtWrapper_QTextTableFormat::alignment(QTextTableFormat* theWrappedObject) const @@ -2316,11 +2316,11 @@ PythonQtShell_QTileRules::~PythonQtShell_QTileRules() { if (priv) { priv->shellClassDeleted(this); } } QTileRules* PythonQtWrapper_QTileRules::new_QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule) -{ +{ return new PythonQtShell_QTileRules(horizontalRule, verticalRule); } QTileRules* PythonQtWrapper_QTileRules::new_QTileRules(Qt::TileRule rule) -{ +{ return new PythonQtShell_QTileRules(rule); } @@ -3672,11 +3672,11 @@ if (_wrapper) { QTimeEdit::wheelEvent(event0); } QTimeEdit* PythonQtWrapper_QTimeEdit::new_QTimeEdit(QWidget* parent) -{ +{ return new PythonQtShell_QTimeEdit(parent); } QTimeEdit* PythonQtWrapper_QTimeEdit::new_QTimeEdit(const QTime& time, QWidget* parent) -{ +{ return new PythonQtShell_QTimeEdit(time, parent); } const QMetaObject* PythonQtShell_QTimeEdit::metaObject() const { @@ -4843,11 +4843,11 @@ if (_wrapper) { QToolBar::wheelEvent(event0); } QToolBar* PythonQtWrapper_QToolBar::new_QToolBar(QWidget* parent) -{ +{ return new PythonQtShell_QToolBar(parent); } QToolBar* PythonQtWrapper_QToolBar::new_QToolBar(const QString& title, QWidget* parent) -{ +{ return new PythonQtShell_QToolBar(title, parent); } const QMetaObject* PythonQtShell_QToolBar::metaObject() const { @@ -5001,7 +5001,7 @@ QWidget* PythonQtWrapper_QToolBar::widgetForAction(QToolBar* theWrappedObject, QToolBarChangeEvent* PythonQtWrapper_QToolBarChangeEvent::new_QToolBarChangeEvent(bool t) -{ +{ return new QToolBarChangeEvent(t); } bool PythonQtWrapper_QToolBarChangeEvent::toggle(QToolBarChangeEvent* theWrappedObject) const @@ -6204,7 +6204,7 @@ if (_wrapper) { QToolBox::wheelEvent(event0); } QToolBox* PythonQtWrapper_QToolBox::new_QToolBox(QWidget* parent, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QToolBox(parent, f); } const QMetaObject* PythonQtShell_QToolBox::metaObject() const { @@ -7548,7 +7548,7 @@ if (_wrapper) { QToolButton::wheelEvent(event0); } QToolButton* PythonQtWrapper_QToolButton::new_QToolButton(QWidget* parent) -{ +{ return new PythonQtShell_QToolButton(parent); } const QMetaObject* PythonQtShell_QToolButton::metaObject() const { @@ -7684,7 +7684,7 @@ QString PythonQtWrapper_QToolTip::static_QToolTip_text() QTouchDevice* PythonQtWrapper_QTouchDevice::new_QTouchDevice() -{ +{ return new QTouchDevice(); } QTouchDevice::Capabilities PythonQtWrapper_QTouchDevice::capabilities(QTouchDevice* theWrappedObject) const @@ -7746,7 +7746,7 @@ PythonQtShell_QTouchEvent::~PythonQtShell_QTouchEvent() { if (priv) { priv->shellClassDeleted(this); } } QTouchEvent* PythonQtWrapper_QTouchEvent::new_QTouchEvent(QEvent::Type eventType, QTouchDevice* device, Qt::KeyboardModifiers modifiers, Qt::TouchPointStates touchPointStates, const QList& touchPoints) -{ +{ return new PythonQtShell_QTouchEvent(eventType, device, modifiers, touchPointStates, touchPoints); } QTouchDevice* PythonQtWrapper_QTouchEvent::device(QTouchEvent* theWrappedObject) const @@ -7802,11 +7802,11 @@ QWindow* PythonQtWrapper_QTouchEvent::window(QTouchEvent* theWrappedObject) con QTouchEvent::TouchPoint* PythonQtWrapper_QTouchEvent__TouchPoint::new_QTouchEvent__TouchPoint(const QTouchEvent::TouchPoint& other) -{ +{ return new QTouchEvent::TouchPoint(other); } QTouchEvent::TouchPoint* PythonQtWrapper_QTouchEvent__TouchPoint::new_QTouchEvent__TouchPoint(int id) -{ +{ return new QTouchEvent::TouchPoint(id); } QSizeF PythonQtWrapper_QTouchEvent__TouchPoint::ellipseDiameters(QTouchEvent::TouchPoint* theWrappedObject) const @@ -9443,7 +9443,7 @@ if (_wrapper) { QTransposeProxyModel::timerEvent(event0); } QTransposeProxyModel* PythonQtWrapper_QTransposeProxyModel::new_QTransposeProxyModel(QObject* parent) -{ +{ return new PythonQtShell_QTransposeProxyModel(parent); } const QMetaObject* PythonQtShell_QTransposeProxyModel::metaObject() const { @@ -11743,7 +11743,7 @@ if (_wrapper) { QTreeView::wheelEvent(arg__1); } QTreeView* PythonQtWrapper_QTreeView::new_QTreeView(QWidget* parent) -{ +{ return new PythonQtShell_QTreeView(parent); } const QMetaObject* PythonQtShell_QTreeView::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui11.h b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui11.h index bd2fe7640..e30798fe3 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui11.h +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui11.h @@ -1073,7 +1073,7 @@ void delete_QToolBar(QToolBar* obj) { delete obj; } PythonQt::self()->addSignalHandler(a, SIGNAL(triggered(bool)), callable); return a; } - + QAction* addAction (QToolBar* menu, const QIcon& icon, const QString& text, PyObject* callable) { QAction* a = menu->addAction(text); @@ -1081,7 +1081,7 @@ void delete_QToolBar(QToolBar* obj) { delete obj; } PythonQt::self()->addSignalHandler(a, SIGNAL(triggered(bool)), callable); return a; } - + }; diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui12.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui12.cpp index 7f8e095a8..c8ee9f291 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui12.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui12.cpp @@ -2458,7 +2458,7 @@ if (_wrapper) { QTreeWidget::wheelEvent(arg__1); } QTreeWidget* PythonQtWrapper_QTreeWidget::new_QTreeWidget(QWidget* parent) -{ +{ return new PythonQtShell_QTreeWidget(parent); } const QMetaObject* PythonQtShell_QTreeWidget::metaObject() const { @@ -2838,35 +2838,35 @@ if (_wrapper) { QTreeWidgetItem::write(out0); } QTreeWidgetItem* PythonQtWrapper_QTreeWidgetItem::new_QTreeWidgetItem(PythonQtNewOwnerOfThis treeview, QTreeWidgetItem* after, int type) -{ +{ return new PythonQtShell_QTreeWidgetItem(treeview, after, type); } QTreeWidgetItem* PythonQtWrapper_QTreeWidgetItem::new_QTreeWidgetItem(PythonQtNewOwnerOfThis treeview, const QStringList& strings, int type) -{ +{ return new PythonQtShell_QTreeWidgetItem(treeview, strings, type); } QTreeWidgetItem* PythonQtWrapper_QTreeWidgetItem::new_QTreeWidgetItem(PythonQtNewOwnerOfThis treeview, int type) -{ +{ return new PythonQtShell_QTreeWidgetItem(treeview, type); } QTreeWidgetItem* PythonQtWrapper_QTreeWidgetItem::new_QTreeWidgetItem(PythonQtNewOwnerOfThis parent, QTreeWidgetItem* after, int type) -{ +{ return new PythonQtShell_QTreeWidgetItem(parent, after, type); } QTreeWidgetItem* PythonQtWrapper_QTreeWidgetItem::new_QTreeWidgetItem(PythonQtNewOwnerOfThis parent, const QStringList& strings, int type) -{ +{ return new PythonQtShell_QTreeWidgetItem(parent, strings, type); } QTreeWidgetItem* PythonQtWrapper_QTreeWidgetItem::new_QTreeWidgetItem(PythonQtNewOwnerOfThis parent, int type) -{ +{ return new PythonQtShell_QTreeWidgetItem(parent, type); } QTreeWidgetItem* PythonQtWrapper_QTreeWidgetItem::new_QTreeWidgetItem(const QStringList& strings, int type) -{ +{ return new PythonQtShell_QTreeWidgetItem(strings, type); } QTreeWidgetItem* PythonQtWrapper_QTreeWidgetItem::new_QTreeWidgetItem(int type) -{ +{ return new PythonQtShell_QTreeWidgetItem(type); } void PythonQtWrapper_QTreeWidgetItem::addChild(QTreeWidgetItem* theWrappedObject, PythonQtPassOwnershipToCPP child) @@ -3281,11 +3281,11 @@ if (_wrapper) { QUndoCommand::undo(); } QUndoCommand* PythonQtWrapper_QUndoCommand::new_QUndoCommand(QUndoCommand* parent) -{ +{ return new PythonQtShell_QUndoCommand(parent); } QUndoCommand* PythonQtWrapper_QUndoCommand::new_QUndoCommand(const QString& text, QUndoCommand* parent) -{ +{ return new PythonQtShell_QUndoCommand(text, parent); } QString PythonQtWrapper_QUndoCommand::actionText(QUndoCommand* theWrappedObject) const @@ -3482,7 +3482,7 @@ if (_wrapper) { QUndoGroup::timerEvent(event0); } QUndoGroup* PythonQtWrapper_QUndoGroup::new_QUndoGroup(QObject* parent) -{ +{ return new PythonQtShell_QUndoGroup(parent); } const QMetaObject* PythonQtShell_QUndoGroup::metaObject() const { @@ -3692,7 +3692,7 @@ if (_wrapper) { QUndoStack::timerEvent(event0); } QUndoStack* PythonQtWrapper_QUndoStack::new_QUndoStack(QObject* parent) -{ +{ return new PythonQtShell_QUndoStack(parent); } const QMetaObject* PythonQtShell_QUndoStack::metaObject() const { @@ -6043,15 +6043,15 @@ if (_wrapper) { QUndoView::wheelEvent(e0); } QUndoView* PythonQtWrapper_QUndoView::new_QUndoView(QUndoGroup* group, QWidget* parent) -{ +{ return new PythonQtShell_QUndoView(group, parent); } QUndoView* PythonQtWrapper_QUndoView::new_QUndoView(QUndoStack* stack, QWidget* parent) -{ +{ return new PythonQtShell_QUndoView(stack, parent); } QUndoView* PythonQtWrapper_QUndoView::new_QUndoView(QWidget* parent) -{ +{ return new PythonQtShell_QUndoView(parent); } const QMetaObject* PythonQtShell_QUndoView::metaObject() const { @@ -6863,11 +6863,11 @@ if (_wrapper) { return QVBoxLayout::widget(); } QVBoxLayout* PythonQtWrapper_QVBoxLayout::new_QVBoxLayout() -{ +{ return new PythonQtShell_QVBoxLayout(); } QVBoxLayout* PythonQtWrapper_QVBoxLayout::new_QVBoxLayout(QWidget* parent) -{ +{ return new PythonQtShell_QVBoxLayout(parent); } const QMetaObject* PythonQtShell_QVBoxLayout::metaObject() const { @@ -7077,7 +7077,7 @@ if (_wrapper) { return QValidator::State(); } QValidator* PythonQtWrapper_QValidator::new_QValidator(QObject* parent) -{ +{ return new PythonQtShell_QValidator(parent); } const QMetaObject* PythonQtShell_QValidator::metaObject() const { @@ -7116,27 +7116,27 @@ QValidator::State PythonQtWrapper_QValidator::validate(QValidator* theWrappedOb QVector2D* PythonQtWrapper_QVector2D::new_QVector2D() -{ +{ return new QVector2D(); } QVector2D* PythonQtWrapper_QVector2D::new_QVector2D(const QPoint& point) -{ +{ return new QVector2D(point); } QVector2D* PythonQtWrapper_QVector2D::new_QVector2D(const QPointF& point) -{ +{ return new QVector2D(point); } QVector2D* PythonQtWrapper_QVector2D::new_QVector2D(const QVector3D& vector) -{ +{ return new QVector2D(vector); } QVector2D* PythonQtWrapper_QVector2D::new_QVector2D(const QVector4D& vector) -{ +{ return new QVector2D(vector); } QVector2D* PythonQtWrapper_QVector2D::new_QVector2D(float xpos, float ypos) -{ +{ return new QVector2D(xpos, ypos); } float PythonQtWrapper_QVector2D::distanceToLine(QVector2D* theWrappedObject, const QVector2D& point, const QVector2D& direction) const @@ -7314,31 +7314,31 @@ QString PythonQtWrapper_QVector2D::py_toString(QVector2D* obj) { QVector3D* PythonQtWrapper_QVector3D::new_QVector3D() -{ +{ return new QVector3D(); } QVector3D* PythonQtWrapper_QVector3D::new_QVector3D(const QPoint& point) -{ +{ return new QVector3D(point); } QVector3D* PythonQtWrapper_QVector3D::new_QVector3D(const QPointF& point) -{ +{ return new QVector3D(point); } QVector3D* PythonQtWrapper_QVector3D::new_QVector3D(const QVector2D& vector) -{ +{ return new QVector3D(vector); } QVector3D* PythonQtWrapper_QVector3D::new_QVector3D(const QVector2D& vector, float zpos) -{ +{ return new QVector3D(vector, zpos); } QVector3D* PythonQtWrapper_QVector3D::new_QVector3D(const QVector4D& vector) -{ +{ return new QVector3D(vector); } QVector3D* PythonQtWrapper_QVector3D::new_QVector3D(float xpos, float ypos, float zpos) -{ +{ return new QVector3D(xpos, ypos, zpos); } QVector3D PythonQtWrapper_QVector3D::static_QVector3D_crossProduct(const QVector3D& v1, const QVector3D& v2) @@ -7566,35 +7566,35 @@ QString PythonQtWrapper_QVector3D::py_toString(QVector3D* obj) { QVector4D* PythonQtWrapper_QVector4D::new_QVector4D() -{ +{ return new QVector4D(); } QVector4D* PythonQtWrapper_QVector4D::new_QVector4D(const QPoint& point) -{ +{ return new QVector4D(point); } QVector4D* PythonQtWrapper_QVector4D::new_QVector4D(const QPointF& point) -{ +{ return new QVector4D(point); } QVector4D* PythonQtWrapper_QVector4D::new_QVector4D(const QVector2D& vector) -{ +{ return new QVector4D(vector); } QVector4D* PythonQtWrapper_QVector4D::new_QVector4D(const QVector2D& vector, float zpos, float wpos) -{ +{ return new QVector4D(vector, zpos, wpos); } QVector4D* PythonQtWrapper_QVector4D::new_QVector4D(const QVector3D& vector) -{ +{ return new QVector4D(vector); } QVector4D* PythonQtWrapper_QVector4D::new_QVector4D(const QVector3D& vector, float wpos) -{ +{ return new QVector4D(vector, wpos); } QVector4D* PythonQtWrapper_QVector4D::new_QVector4D(float xpos, float ypos, float zpos, float wpos) -{ +{ return new QVector4D(xpos, ypos, zpos, wpos); } float PythonQtWrapper_QVector4D::static_QVector4D_dotProduct(const QVector4D& v1, const QVector4D& v2) @@ -7829,7 +7829,7 @@ void PythonQtWrapper_QWhatsThis::static_QWhatsThis_showText(const QPoint& pos, QWhatsThisClickedEvent* PythonQtWrapper_QWhatsThisClickedEvent::new_QWhatsThisClickedEvent(const QString& href) -{ +{ return new QWhatsThisClickedEvent(href); } QString PythonQtWrapper_QWhatsThisClickedEvent::href(QWhatsThisClickedEvent* theWrappedObject) const @@ -7844,31 +7844,31 @@ PythonQtShell_QWheelEvent::~PythonQtShell_QWheelEvent() { if (priv) { priv->shellClassDeleted(this); } } QWheelEvent* PythonQtWrapper_QWheelEvent::new_QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoint angleDelta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, bool inverted, Qt::MouseEventSource source) -{ +{ return new PythonQtShell_QWheelEvent(pos, globalPos, pixelDelta, angleDelta, buttons, modifiers, phase, inverted, source); } QWheelEvent* PythonQtWrapper_QWheelEvent::new_QWheelEvent(const QPointF& pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) -{ +{ return new PythonQtShell_QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation, buttons, modifiers); } QWheelEvent* PythonQtWrapper_QWheelEvent::new_QWheelEvent(const QPointF& pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase) -{ +{ return new PythonQtShell_QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation, buttons, modifiers, phase); } QWheelEvent* PythonQtWrapper_QWheelEvent::new_QWheelEvent(const QPointF& pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source) -{ +{ return new PythonQtShell_QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation, buttons, modifiers, phase, source); } QWheelEvent* PythonQtWrapper_QWheelEvent::new_QWheelEvent(const QPointF& pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source, bool inverted) -{ +{ return new PythonQtShell_QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation, buttons, modifiers, phase, source, inverted); } QWheelEvent* PythonQtWrapper_QWheelEvent::new_QWheelEvent(const QPointF& pos, const QPointF& globalPos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient) -{ +{ return new PythonQtShell_QWheelEvent(pos, globalPos, delta, buttons, modifiers, orient); } QWheelEvent* PythonQtWrapper_QWheelEvent::new_QWheelEvent(const QPointF& pos, int delta, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::Orientation orient) -{ +{ return new PythonQtShell_QWheelEvent(pos, delta, buttons, modifiers, orient); } QPoint PythonQtWrapper_QWheelEvent::angleDelta(QWheelEvent* theWrappedObject) const @@ -9112,7 +9112,7 @@ if (_wrapper) { QWidget::wheelEvent(event0); } QWidget* PythonQtWrapper_QWidget::new_QWidget(QWidget* parent, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QWidget(parent, f); } const QMetaObject* PythonQtShell_QWidget::metaObject() const { @@ -10584,7 +10584,7 @@ if (_wrapper) { QWidgetAction::timerEvent(event0); } QWidgetAction* PythonQtWrapper_QWidgetAction::new_QWidgetAction(QObject* parent) -{ +{ return new PythonQtShell_QWidgetAction(parent); } const QMetaObject* PythonQtShell_QWidgetAction::metaObject() const { @@ -11115,7 +11115,7 @@ if (_wrapper) { return QWidgetItem::widget(); } QWidgetItem* PythonQtWrapper_QWidgetItem::new_QWidgetItem(QWidget* w) -{ +{ return new PythonQtShell_QWidgetItem(w); } @@ -11774,11 +11774,11 @@ if (_wrapper) { QWindow::wheelEvent(arg__1); } QWindow* PythonQtWrapper_QWindow::new_QWindow(QScreen* screen) -{ +{ return new PythonQtShell_QWindow(screen); } QWindow* PythonQtWrapper_QWindow::new_QWindow(QWindow* parent) -{ +{ return new PythonQtShell_QWindow(parent); } const QMetaObject* PythonQtShell_QWindow::metaObject() const { @@ -12279,7 +12279,7 @@ QString PythonQtWrapper_QWindow::py_toString(QWindow* obj) { QWindowStateChangeEvent* PythonQtWrapper_QWindowStateChangeEvent::new_QWindowStateChangeEvent(Qt::WindowStates aOldState, bool isOverride) -{ +{ return new QWindowStateChangeEvent(aOldState, isOverride); } bool PythonQtWrapper_QWindowStateChangeEvent::isOverride(QWindowStateChangeEvent* theWrappedObject) const @@ -13674,7 +13674,7 @@ if (_wrapper) { QWizard::wheelEvent(event0); } QWizard* PythonQtWrapper_QWizard::new_QWizard(QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QWizard(parent, flags); } const QMetaObject* PythonQtShell_QWizard::metaObject() const { @@ -15169,7 +15169,7 @@ if (_wrapper) { QWizardPage::wheelEvent(event0); } QWizardPage* PythonQtWrapper_QWizardPage::new_QWizardPage(QWidget* parent) -{ +{ return new PythonQtShell_QWizardPage(parent); } const QMetaObject* PythonQtShell_QWizardPage::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui2.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui2.cpp index fbd0f808e..45e5618d6 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui2.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui2.cpp @@ -74,7 +74,7 @@ #include QFocusEvent* PythonQtWrapper_QFocusEvent::new_QFocusEvent(QEvent::Type type, Qt::FocusReason reason) -{ +{ return new QFocusEvent(type, reason); } bool PythonQtWrapper_QFocusEvent::gotFocus(QFocusEvent* theWrappedObject) const @@ -1243,7 +1243,7 @@ if (_wrapper) { QFocusFrame::wheelEvent(event0); } QFocusFrame* PythonQtWrapper_QFocusFrame::new_QFocusFrame(QWidget* parent) -{ +{ return new PythonQtShell_QFocusFrame(parent); } const QMetaObject* PythonQtShell_QFocusFrame::metaObject() const { @@ -2469,7 +2469,7 @@ if (_wrapper) { QFontComboBox::wheelEvent(e0); } QFontComboBox* PythonQtWrapper_QFontComboBox::new_QFontComboBox(QWidget* parent) -{ +{ return new PythonQtShell_QFontComboBox(parent); } const QMetaObject* PythonQtShell_QFontComboBox::metaObject() const { @@ -2513,7 +2513,7 @@ QFontDatabase::WritingSystem PythonQtWrapper_QFontComboBox::writingSystem(QFont QFontDatabase* PythonQtWrapper_QFontDatabase::new_QFontDatabase() -{ +{ return new QFontDatabase(); } int PythonQtWrapper_QFontDatabase::static_QFontDatabase_addApplicationFont(const QString& fileName) @@ -3906,11 +3906,11 @@ if (_wrapper) { QFontDialog::wheelEvent(event0); } QFontDialog* PythonQtWrapper_QFontDialog::new_QFontDialog(QWidget* parent) -{ +{ return new PythonQtShell_QFontDialog(parent); } QFontDialog* PythonQtWrapper_QFontDialog::new_QFontDialog(const QFont& initial, QWidget* parent) -{ +{ return new PythonQtShell_QFontDialog(initial, parent); } const QMetaObject* PythonQtShell_QFontDialog::metaObject() const { @@ -3979,11 +3979,11 @@ bool PythonQtWrapper_QFontDialog::testOption(QFontDialog* theWrappedObject, QFo QFontInfo* PythonQtWrapper_QFontInfo::new_QFontInfo(const QFont& arg__1) -{ +{ return new QFontInfo(arg__1); } QFontInfo* PythonQtWrapper_QFontInfo::new_QFontInfo(const QFontInfo& arg__1) -{ +{ return new QFontInfo(arg__1); } bool PythonQtWrapper_QFontInfo::bold(QFontInfo* theWrappedObject) const @@ -4074,15 +4074,15 @@ int PythonQtWrapper_QFontInfo::weight(QFontInfo* theWrappedObject) const QFontMetrics* PythonQtWrapper_QFontMetrics::new_QFontMetrics(const QFont& arg__1) -{ +{ return new QFontMetrics(arg__1); } QFontMetrics* PythonQtWrapper_QFontMetrics::new_QFontMetrics(const QFont& font, QPaintDevice* pd) -{ +{ return new QFontMetrics(font, pd); } QFontMetrics* PythonQtWrapper_QFontMetrics::new_QFontMetrics(const QFontMetrics& arg__1) -{ +{ return new QFontMetrics(arg__1); } int PythonQtWrapper_QFontMetrics::ascent(QFontMetrics* theWrappedObject) const @@ -4258,11 +4258,11 @@ int PythonQtWrapper_QFontMetrics::xHeight(QFontMetrics* theWrappedObject) const QFontMetricsF* PythonQtWrapper_QFontMetricsF::new_QFontMetricsF(const QFont& font) -{ +{ return new QFontMetricsF(font); } QFontMetricsF* PythonQtWrapper_QFontMetricsF::new_QFontMetricsF(const QFont& font, QPaintDevice* pd) -{ +{ return new QFontMetricsF(font, pd); } qreal PythonQtWrapper_QFontMetricsF::ascent(QFontMetricsF* theWrappedObject) const @@ -5186,7 +5186,7 @@ if (_wrapper) { return QFormLayout::widget(); } QFormLayout* PythonQtWrapper_QFormLayout::new_QFormLayout(QWidget* parent) -{ +{ return new PythonQtShell_QFormLayout(parent); } const QMetaObject* PythonQtShell_QFormLayout::metaObject() const { @@ -5419,7 +5419,7 @@ PythonQtShell_QFormLayout__TakeRowResult::~PythonQtShell_QFormLayout__TakeRowRes if (priv) { priv->shellClassDeleted(this); } } QFormLayout::TakeRowResult* PythonQtWrapper_QFormLayout__TakeRowResult::new_QFormLayout__TakeRowResult() -{ +{ return new PythonQtShell_QFormLayout__TakeRowResult(); } @@ -6573,7 +6573,7 @@ if (_wrapper) { QFrame::wheelEvent(event0); } QFrame* PythonQtWrapper_QFrame::new_QFrame(QWidget* parent, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QFrame(parent, f); } const QMetaObject* PythonQtShell_QFrame::metaObject() const { @@ -6808,7 +6808,7 @@ if (_wrapper) { QGesture::timerEvent(event0); } QGesture* PythonQtWrapper_QGesture::new_QGesture(QObject* parent) -{ +{ return new PythonQtShell_QGesture(parent); } const QMetaObject* PythonQtShell_QGesture::metaObject() const { @@ -6874,7 +6874,7 @@ QString PythonQtWrapper_QGesture::py_toString(QGesture* obj) { QGestureEvent* PythonQtWrapper_QGestureEvent::new_QGestureEvent(const QList& gestures) -{ +{ return new QGestureEvent(gestures); } void PythonQtWrapper_QGestureEvent::accept(QGestureEvent* theWrappedObject, QGesture* arg__1) @@ -7054,7 +7054,7 @@ if (_wrapper) { QGestureRecognizer::reset(state0); } QGestureRecognizer* PythonQtWrapper_QGestureRecognizer::new_QGestureRecognizer() -{ +{ return new PythonQtShell_QGestureRecognizer(); } QGesture* PythonQtWrapper_QGestureRecognizer::create(QGestureRecognizer* theWrappedObject, QObject* target) @@ -7085,11 +7085,11 @@ void PythonQtWrapper_QGestureRecognizer::static_QGestureRecognizer_unregisterRec QGlyphRun* PythonQtWrapper_QGlyphRun::new_QGlyphRun() -{ +{ return new QGlyphRun(); } QGlyphRun* PythonQtWrapper_QGlyphRun::new_QGlyphRun(const QGlyphRun& other) -{ +{ return new QGlyphRun(other); } QRectF PythonQtWrapper_QGlyphRun::boundingRect(QGlyphRun* theWrappedObject) const @@ -7225,11 +7225,11 @@ bool PythonQtWrapper_QGlyphRun::underline(QGlyphRun* theWrappedObject) const QGradient* PythonQtWrapper_QGradient::new_QGradient() -{ +{ return new QGradient(); } QGradient* PythonQtWrapper_QGradient::new_QGradient(QGradient::Preset arg__1) -{ +{ return new QGradient(arg__1); } QGradient::CoordinateMode PythonQtWrapper_QGradient::coordinateMode(QGradient* theWrappedObject) const @@ -7547,7 +7547,7 @@ if (_wrapper) { QGraphicsAnchorLayout::widgetEvent(e0); } QGraphicsAnchorLayout* PythonQtWrapper_QGraphicsAnchorLayout::new_QGraphicsAnchorLayout(QGraphicsLayoutItem* parent) -{ +{ return new PythonQtShell_QGraphicsAnchorLayout(parent); } QGraphicsAnchor* PythonQtWrapper_QGraphicsAnchorLayout::addAnchor(QGraphicsAnchorLayout* theWrappedObject, QGraphicsLayoutItem* firstItem, Qt::AnchorPoint firstEdge, QGraphicsLayoutItem* secondItem, Qt::AnchorPoint secondEdge) @@ -7811,7 +7811,7 @@ if (_wrapper) { QGraphicsBlurEffect::timerEvent(event0); } QGraphicsBlurEffect* PythonQtWrapper_QGraphicsBlurEffect::new_QGraphicsBlurEffect(QObject* parent) -{ +{ return new PythonQtShell_QGraphicsBlurEffect(parent); } const QMetaObject* PythonQtShell_QGraphicsBlurEffect::metaObject() const { @@ -8053,7 +8053,7 @@ if (_wrapper) { QGraphicsColorizeEffect::timerEvent(event0); } QGraphicsColorizeEffect* PythonQtWrapper_QGraphicsColorizeEffect::new_QGraphicsColorizeEffect(QObject* parent) -{ +{ return new PythonQtShell_QGraphicsColorizeEffect(parent); } const QMetaObject* PythonQtShell_QGraphicsColorizeEffect::metaObject() const { @@ -8295,7 +8295,7 @@ if (_wrapper) { QGraphicsDropShadowEffect::timerEvent(event0); } QGraphicsDropShadowEffect* PythonQtWrapper_QGraphicsDropShadowEffect::new_QGraphicsDropShadowEffect(QObject* parent) -{ +{ return new PythonQtShell_QGraphicsDropShadowEffect(parent); } const QMetaObject* PythonQtShell_QGraphicsDropShadowEffect::metaObject() const { @@ -8439,7 +8439,7 @@ if (_wrapper) { } } } - + } bool PythonQtShell_QGraphicsEffect::event(QEvent* event0) { @@ -8552,7 +8552,7 @@ if (_wrapper) { QGraphicsEffect::timerEvent(event0); } QGraphicsEffect* PythonQtWrapper_QGraphicsEffect::new_QGraphicsEffect(QObject* parent) -{ +{ return new PythonQtShell_QGraphicsEffect(parent); } const QMetaObject* PythonQtShell_QGraphicsEffect::metaObject() const { @@ -9146,7 +9146,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -9552,15 +9552,15 @@ if (_wrapper) { QGraphicsEllipseItem::wheelEvent(event0); } QGraphicsEllipseItem* PythonQtWrapper_QGraphicsEllipseItem::new_QGraphicsEllipseItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsEllipseItem(parent); } QGraphicsEllipseItem* PythonQtWrapper_QGraphicsEllipseItem::new_QGraphicsEllipseItem(const QRectF& rect, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsEllipseItem(rect, parent); } QGraphicsEllipseItem* PythonQtWrapper_QGraphicsEllipseItem::new_QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsEllipseItem(x, y, w, h, parent); } QRectF PythonQtWrapper_QGraphicsEllipseItem::rect(QGraphicsEllipseItem* theWrappedObject) const @@ -9836,7 +9836,7 @@ if (_wrapper) { QGraphicsGridLayout::widgetEvent(e0); } QGraphicsGridLayout* PythonQtWrapper_QGraphicsGridLayout::new_QGraphicsGridLayout(QGraphicsLayoutItem* parent) -{ +{ return new PythonQtShell_QGraphicsGridLayout(parent); } void PythonQtWrapper_QGraphicsGridLayout::addItem(QGraphicsGridLayout* theWrappedObject, PythonQtPassOwnershipToCPP item, int row, int column, Qt::Alignment alignment) @@ -10562,7 +10562,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -10756,7 +10756,7 @@ if (_wrapper) { } } } - + } bool PythonQtShell_QGraphicsItem::sceneEvent(QEvent* event0) { @@ -10968,7 +10968,7 @@ if (_wrapper) { QGraphicsItem::wheelEvent(event0); } QGraphicsItem* PythonQtWrapper_QGraphicsItem::new_QGraphicsItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsItem(parent); } bool PythonQtWrapper_QGraphicsItem::acceptDrops(QGraphicsItem* theWrappedObject) const @@ -12196,7 +12196,7 @@ if (_wrapper) { QGraphicsItemAnimation::timerEvent(event0); } QGraphicsItemAnimation* PythonQtWrapper_QGraphicsItemAnimation::new_QGraphicsItemAnimation(QObject* parent) -{ +{ return new PythonQtShell_QGraphicsItemAnimation(parent); } const QMetaObject* PythonQtShell_QGraphicsItemAnimation::metaObject() const { @@ -12875,7 +12875,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -13281,7 +13281,7 @@ if (_wrapper) { QGraphicsItemGroup::wheelEvent(event0); } QGraphicsItemGroup* PythonQtWrapper_QGraphicsItemGroup::new_QGraphicsItemGroup(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsItemGroup(parent); } void PythonQtWrapper_QGraphicsItemGroup::addToGroup(QGraphicsItemGroup* theWrappedObject, QGraphicsItem* item) @@ -13430,7 +13430,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QGraphicsLayout::setGeometry(const QRectF& rect0) { @@ -13532,7 +13532,7 @@ if (_wrapper) { QGraphicsLayout::widgetEvent(e0); } QGraphicsLayout* PythonQtWrapper_QGraphicsLayout::new_QGraphicsLayout(QGraphicsLayoutItem* parent) -{ +{ return new PythonQtShell_QGraphicsLayout(parent); } void PythonQtWrapper_QGraphicsLayout::activate(QGraphicsLayout* theWrappedObject) @@ -13696,7 +13696,7 @@ if (_wrapper) { QGraphicsLayoutItem::updateGeometry(); } QGraphicsLayoutItem* PythonQtWrapper_QGraphicsLayoutItem::new_QGraphicsLayoutItem(QGraphicsLayoutItem* parent, bool isLayout) -{ +{ return new PythonQtShell_QGraphicsLayoutItem(parent, isLayout); } QRectF PythonQtWrapper_QGraphicsLayoutItem::contentsRect(QGraphicsLayoutItem* theWrappedObject) const @@ -14417,7 +14417,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -14823,15 +14823,15 @@ if (_wrapper) { QGraphicsLineItem::wheelEvent(event0); } QGraphicsLineItem* PythonQtWrapper_QGraphicsLineItem::new_QGraphicsLineItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsLineItem(parent); } QGraphicsLineItem* PythonQtWrapper_QGraphicsLineItem::new_QGraphicsLineItem(const QLineF& line, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsLineItem(line, parent); } QGraphicsLineItem* PythonQtWrapper_QGraphicsLineItem::new_QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsLineItem(x1, y1, x2, y2, parent); } QLineF PythonQtWrapper_QGraphicsLineItem::line(QGraphicsLineItem* theWrappedObject) const diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui2.h b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui2.h index 15c40f125..9abe71d28 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui2.h +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui2.h @@ -455,7 +455,7 @@ void delete_QFontInfo(QFontInfo* obj) { delete obj; } int weight(QFontInfo* theWrappedObject) const; QFontInfo* new_QFontInfo() { return new QFontInfo(QFont()); } - + }; @@ -506,7 +506,7 @@ void delete_QFontMetrics(QFontMetrics* obj) { delete obj; } int xHeight(QFontMetrics* theWrappedObject) const; QFontMetrics* new_QFontMetrics() { return new QFontMetrics(QFont()); } - + }; diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui3.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui3.cpp index 81577815a..0e86b08c1 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui3.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui3.cpp @@ -313,11 +313,11 @@ if (_wrapper) { QGraphicsLinearLayout::widgetEvent(e0); } QGraphicsLinearLayout* PythonQtWrapper_QGraphicsLinearLayout::new_QGraphicsLinearLayout(QGraphicsLayoutItem* parent) -{ +{ return new PythonQtShell_QGraphicsLinearLayout(parent); } QGraphicsLinearLayout* PythonQtWrapper_QGraphicsLinearLayout::new_QGraphicsLinearLayout(Qt::Orientation orientation, QGraphicsLayoutItem* parent) -{ +{ return new PythonQtShell_QGraphicsLinearLayout(orientation, parent); } void PythonQtWrapper_QGraphicsLinearLayout::addItem(QGraphicsLinearLayout* theWrappedObject, PythonQtPassOwnershipToCPP item) @@ -1038,7 +1038,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -1232,7 +1232,7 @@ if (_wrapper) { } } } - + } bool PythonQtShell_QGraphicsObject::sceneEvent(QEvent* event0) { @@ -1466,7 +1466,7 @@ if (_wrapper) { QGraphicsObject::wheelEvent(event0); } QGraphicsObject* PythonQtWrapper_QGraphicsObject::new_QGraphicsObject(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsObject(parent); } const QMetaObject* PythonQtShell_QGraphicsObject::metaObject() const { @@ -1715,7 +1715,7 @@ if (_wrapper) { QGraphicsOpacityEffect::timerEvent(event0); } QGraphicsOpacityEffect* PythonQtWrapper_QGraphicsOpacityEffect::new_QGraphicsOpacityEffect(QObject* parent) -{ +{ return new PythonQtShell_QGraphicsOpacityEffect(parent); } const QMetaObject* PythonQtShell_QGraphicsOpacityEffect::metaObject() const { @@ -2269,7 +2269,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -2675,11 +2675,11 @@ if (_wrapper) { QGraphicsPathItem::wheelEvent(event0); } QGraphicsPathItem* PythonQtWrapper_QGraphicsPathItem::new_QGraphicsPathItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsPathItem(parent); } QGraphicsPathItem* PythonQtWrapper_QGraphicsPathItem::new_QGraphicsPathItem(const QPainterPath& path, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsPathItem(path, parent); } QPainterPath PythonQtWrapper_QGraphicsPathItem::path(QGraphicsPathItem* theWrappedObject) const @@ -3220,7 +3220,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -3626,11 +3626,11 @@ if (_wrapper) { QGraphicsPixmapItem::wheelEvent(event0); } QGraphicsPixmapItem* PythonQtWrapper_QGraphicsPixmapItem::new_QGraphicsPixmapItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsPixmapItem(parent); } QGraphicsPixmapItem* PythonQtWrapper_QGraphicsPixmapItem::new_QGraphicsPixmapItem(const QPixmap& pixmap, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsPixmapItem(pixmap, parent); } QPointF PythonQtWrapper_QGraphicsPixmapItem::offset(QGraphicsPixmapItem* theWrappedObject) const @@ -4206,7 +4206,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -4612,11 +4612,11 @@ if (_wrapper) { QGraphicsPolygonItem::wheelEvent(event0); } QGraphicsPolygonItem* PythonQtWrapper_QGraphicsPolygonItem::new_QGraphicsPolygonItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsPolygonItem(parent); } QGraphicsPolygonItem* PythonQtWrapper_QGraphicsPolygonItem::new_QGraphicsPolygonItem(const QPolygonF& polygon, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsPolygonItem(polygon, parent); } Qt::FillRule PythonQtWrapper_QGraphicsPolygonItem::fillRule(QGraphicsPolygonItem* theWrappedObject) const @@ -5464,7 +5464,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -6222,7 +6222,7 @@ if (_wrapper) { return QGraphicsProxyWidget::windowFrameSectionAt(pos0); } QGraphicsProxyWidget* PythonQtWrapper_QGraphicsProxyWidget::new_QGraphicsProxyWidget(PythonQtNewOwnerOfThis parent, Qt::WindowFlags wFlags) -{ +{ return new PythonQtShell_QGraphicsProxyWidget(parent, wFlags); } const QMetaObject* PythonQtShell_QGraphicsProxyWidget::metaObject() const { @@ -6786,7 +6786,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -7192,15 +7192,15 @@ if (_wrapper) { QGraphicsRectItem::wheelEvent(event0); } QGraphicsRectItem* PythonQtWrapper_QGraphicsRectItem::new_QGraphicsRectItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsRectItem(parent); } QGraphicsRectItem* PythonQtWrapper_QGraphicsRectItem::new_QGraphicsRectItem(const QRectF& rect, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsRectItem(rect, parent); } QGraphicsRectItem* PythonQtWrapper_QGraphicsRectItem::new_QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsRectItem(x, y, w, h, parent); } QRectF PythonQtWrapper_QGraphicsRectItem::rect(QGraphicsRectItem* theWrappedObject) const @@ -7379,7 +7379,7 @@ if (_wrapper) { QGraphicsRotation::timerEvent(event0); } QGraphicsRotation* PythonQtWrapper_QGraphicsRotation::new_QGraphicsRotation(QObject* parent) -{ +{ return new PythonQtShell_QGraphicsRotation(parent); } const QMetaObject* PythonQtShell_QGraphicsRotation::metaObject() const { @@ -7591,7 +7591,7 @@ if (_wrapper) { QGraphicsScale::timerEvent(event0); } QGraphicsScale* PythonQtWrapper_QGraphicsScale::new_QGraphicsScale(QObject* parent) -{ +{ return new PythonQtShell_QGraphicsScale(parent); } const QMetaObject* PythonQtShell_QGraphicsScale::metaObject() const { @@ -8237,15 +8237,15 @@ if (_wrapper) { QGraphicsScene::wheelEvent(event0); } QGraphicsScene* PythonQtWrapper_QGraphicsScene::new_QGraphicsScene(QObject* parent) -{ +{ return new PythonQtShell_QGraphicsScene(parent); } QGraphicsScene* PythonQtWrapper_QGraphicsScene::new_QGraphicsScene(const QRectF& sceneRect, QObject* parent) -{ +{ return new PythonQtShell_QGraphicsScene(sceneRect, parent); } QGraphicsScene* PythonQtWrapper_QGraphicsScene::new_QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject* parent) -{ +{ return new PythonQtShell_QGraphicsScene(x, y, width, height, parent); } const QMetaObject* PythonQtShell_QGraphicsScene::metaObject() const { @@ -8734,7 +8734,7 @@ qreal PythonQtWrapper_QGraphicsScene::width(QGraphicsScene* theWrappedObject) c QGraphicsSceneContextMenuEvent* PythonQtWrapper_QGraphicsSceneContextMenuEvent::new_QGraphicsSceneContextMenuEvent(QEvent::Type type) -{ +{ return new QGraphicsSceneContextMenuEvent(type); } Qt::KeyboardModifiers PythonQtWrapper_QGraphicsSceneContextMenuEvent::modifiers(QGraphicsSceneContextMenuEvent* theWrappedObject) const @@ -8790,7 +8790,7 @@ void PythonQtWrapper_QGraphicsSceneContextMenuEvent::setScreenPos(QGraphicsScene QGraphicsSceneDragDropEvent* PythonQtWrapper_QGraphicsSceneDragDropEvent::new_QGraphicsSceneDragDropEvent(QEvent::Type type) -{ +{ return new QGraphicsSceneDragDropEvent(type); } void PythonQtWrapper_QGraphicsSceneDragDropEvent::acceptProposedAction(QGraphicsSceneDragDropEvent* theWrappedObject) @@ -8891,7 +8891,7 @@ QWidget* PythonQtWrapper_QGraphicsSceneDragDropEvent::source(QGraphicsSceneDrag QGraphicsSceneEvent* PythonQtWrapper_QGraphicsSceneEvent::new_QGraphicsSceneEvent(QEvent::Type type) -{ +{ return new QGraphicsSceneEvent(type); } QWidget* PythonQtWrapper_QGraphicsSceneEvent::widget(QGraphicsSceneEvent* theWrappedObject) const @@ -8909,7 +8909,7 @@ QString PythonQtWrapper_QGraphicsSceneEvent::py_toString(QGraphicsSceneEvent* ob QGraphicsSceneHelpEvent* PythonQtWrapper_QGraphicsSceneHelpEvent::new_QGraphicsSceneHelpEvent(QEvent::Type type) -{ +{ return new QGraphicsSceneHelpEvent(type); } QPointF PythonQtWrapper_QGraphicsSceneHelpEvent::scenePos(QGraphicsSceneHelpEvent* theWrappedObject) const @@ -8935,7 +8935,7 @@ void PythonQtWrapper_QGraphicsSceneHelpEvent::setScreenPos(QGraphicsSceneHelpEve QGraphicsSceneHoverEvent* PythonQtWrapper_QGraphicsSceneHoverEvent::new_QGraphicsSceneHoverEvent(QEvent::Type type) -{ +{ return new QGraphicsSceneHoverEvent(type); } QPointF PythonQtWrapper_QGraphicsSceneHoverEvent::lastPos(QGraphicsSceneHoverEvent* theWrappedObject) const @@ -9011,7 +9011,7 @@ void PythonQtWrapper_QGraphicsSceneHoverEvent::setScreenPos(QGraphicsSceneHoverE QGraphicsSceneMouseEvent* PythonQtWrapper_QGraphicsSceneMouseEvent::new_QGraphicsSceneMouseEvent(QEvent::Type type) -{ +{ return new QGraphicsSceneMouseEvent(type); } Qt::MouseButton PythonQtWrapper_QGraphicsSceneMouseEvent::button(QGraphicsSceneMouseEvent* theWrappedObject) const @@ -9157,7 +9157,7 @@ Qt::MouseEventSource PythonQtWrapper_QGraphicsSceneMouseEvent::source(QGraphics QGraphicsSceneMoveEvent* PythonQtWrapper_QGraphicsSceneMoveEvent::new_QGraphicsSceneMoveEvent() -{ +{ return new QGraphicsSceneMoveEvent(); } QPointF PythonQtWrapper_QGraphicsSceneMoveEvent::newPos(QGraphicsSceneMoveEvent* theWrappedObject) const @@ -9183,7 +9183,7 @@ void PythonQtWrapper_QGraphicsSceneMoveEvent::setOldPos(QGraphicsSceneMoveEvent* QGraphicsSceneResizeEvent* PythonQtWrapper_QGraphicsSceneResizeEvent::new_QGraphicsSceneResizeEvent() -{ +{ return new QGraphicsSceneResizeEvent(); } QSizeF PythonQtWrapper_QGraphicsSceneResizeEvent::newSize(QGraphicsSceneResizeEvent* theWrappedObject) const @@ -9209,7 +9209,7 @@ void PythonQtWrapper_QGraphicsSceneResizeEvent::setOldSize(QGraphicsSceneResizeE QGraphicsSceneWheelEvent* PythonQtWrapper_QGraphicsSceneWheelEvent::new_QGraphicsSceneWheelEvent(QEvent::Type type) -{ +{ return new QGraphicsSceneWheelEvent(type); } Qt::MouseButtons PythonQtWrapper_QGraphicsSceneWheelEvent::buttons(QGraphicsSceneWheelEvent* theWrappedObject) const @@ -9810,7 +9810,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -10216,11 +10216,11 @@ if (_wrapper) { QGraphicsSimpleTextItem::wheelEvent(event0); } QGraphicsSimpleTextItem* PythonQtWrapper_QGraphicsSimpleTextItem::new_QGraphicsSimpleTextItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsSimpleTextItem(parent); } QGraphicsSimpleTextItem* PythonQtWrapper_QGraphicsSimpleTextItem::new_QGraphicsSimpleTextItem(const QString& text, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsSimpleTextItem(text, parent); } QFont PythonQtWrapper_QGraphicsSimpleTextItem::font(QGraphicsSimpleTextItem* theWrappedObject) const @@ -10881,7 +10881,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -11309,11 +11309,11 @@ if (_wrapper) { QGraphicsTextItem::wheelEvent(event0); } QGraphicsTextItem* PythonQtWrapper_QGraphicsTextItem::new_QGraphicsTextItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsTextItem(parent); } QGraphicsTextItem* PythonQtWrapper_QGraphicsTextItem::new_QGraphicsTextItem(const QString& text, QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsTextItem(text, parent); } const QMetaObject* PythonQtShell_QGraphicsTextItem::metaObject() const { @@ -11460,7 +11460,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QGraphicsTransform::childEvent(QChildEvent* event0) { @@ -11595,7 +11595,7 @@ if (_wrapper) { QGraphicsTransform::timerEvent(event0); } QGraphicsTransform* PythonQtWrapper_QGraphicsTransform::new_QGraphicsTransform(QObject* parent) -{ +{ return new PythonQtShell_QGraphicsTransform(parent); } const QMetaObject* PythonQtShell_QGraphicsTransform::metaObject() const { @@ -12943,11 +12943,11 @@ if (_wrapper) { QGraphicsView::wheelEvent(event0); } QGraphicsView* PythonQtWrapper_QGraphicsView::new_QGraphicsView(QGraphicsScene* scene, QWidget* parent) -{ +{ return new PythonQtShell_QGraphicsView(scene, parent); } QGraphicsView* PythonQtWrapper_QGraphicsView::new_QGraphicsView(QWidget* parent) -{ +{ return new PythonQtShell_QGraphicsView(parent); } const QMetaObject* PythonQtShell_QGraphicsView::metaObject() const { @@ -14183,7 +14183,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -14941,7 +14941,7 @@ if (_wrapper) { return QGraphicsWidget::windowFrameSectionAt(pos0); } QGraphicsWidget* PythonQtWrapper_QGraphicsWidget::new_QGraphicsWidget(QGraphicsItem* parent, Qt::WindowFlags wFlags) -{ +{ return new PythonQtShell_QGraphicsWidget(parent, wFlags); } const QMetaObject* PythonQtShell_QGraphicsWidget::metaObject() const { @@ -16053,11 +16053,11 @@ if (_wrapper) { return QGridLayout::widget(); } QGridLayout* PythonQtWrapper_QGridLayout::new_QGridLayout() -{ +{ return new PythonQtShell_QGridLayout(); } QGridLayout* PythonQtWrapper_QGridLayout::new_QGridLayout(QWidget* parent) -{ +{ return new PythonQtShell_QGridLayout(parent); } const QMetaObject* PythonQtShell_QGridLayout::metaObject() const { @@ -17354,11 +17354,11 @@ if (_wrapper) { QGroupBox::wheelEvent(event0); } QGroupBox* PythonQtWrapper_QGroupBox::new_QGroupBox(QWidget* parent) -{ +{ return new PythonQtShell_QGroupBox(parent); } QGroupBox* PythonQtWrapper_QGroupBox::new_QGroupBox(const QString& title, QWidget* parent) -{ +{ return new PythonQtShell_QGroupBox(title, parent); } const QMetaObject* PythonQtShell_QGroupBox::metaObject() const { @@ -18447,11 +18447,11 @@ if (_wrapper) { return QHBoxLayout::widget(); } QHBoxLayout* PythonQtWrapper_QHBoxLayout::new_QHBoxLayout() -{ +{ return new PythonQtShell_QHBoxLayout(); } QHBoxLayout* PythonQtWrapper_QHBoxLayout::new_QHBoxLayout(QWidget* parent) -{ +{ return new PythonQtShell_QHBoxLayout(parent); } const QMetaObject* PythonQtShell_QHBoxLayout::metaObject() const { @@ -20762,7 +20762,7 @@ if (_wrapper) { QHeaderView::wheelEvent(arg__1); } QHeaderView* PythonQtWrapper_QHeaderView::new_QHeaderView(Qt::Orientation orientation, QWidget* parent) -{ +{ return new PythonQtShell_QHeaderView(orientation, parent); } const QMetaObject* PythonQtShell_QHeaderView::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui4.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui4.cpp index e400f318a..363cd7269 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui4.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui4.cpp @@ -69,7 +69,7 @@ #include QHelpEvent* PythonQtWrapper_QHelpEvent::new_QHelpEvent(QEvent::Type type, const QPoint& pos, const QPoint& globalPos) -{ +{ return new QHelpEvent(type, pos, globalPos); } const QPoint* PythonQtWrapper_QHelpEvent::globalPos(QHelpEvent* theWrappedObject) const @@ -105,7 +105,7 @@ int PythonQtWrapper_QHelpEvent::y(QHelpEvent* theWrappedObject) const QHideEvent* PythonQtWrapper_QHideEvent::new_QHideEvent() -{ +{ return new QHideEvent(); } @@ -115,7 +115,7 @@ PythonQtShell_QHoverEvent::~PythonQtShell_QHoverEvent() { if (priv) { priv->shellClassDeleted(this); } } QHoverEvent* PythonQtWrapper_QHoverEvent::new_QHoverEvent(QEvent::Type type, const QPointF& pos, const QPointF& oldPos, Qt::KeyboardModifiers modifiers) -{ +{ return new PythonQtShell_QHoverEvent(type, pos, oldPos, modifiers); } QPoint PythonQtWrapper_QHoverEvent::oldPos(QHoverEvent* theWrappedObject) const @@ -141,7 +141,7 @@ const QPointF* PythonQtWrapper_QHoverEvent::posF(QHoverEvent* theWrappedObject) QIconDragEvent* PythonQtWrapper_QIconDragEvent::new_QIconDragEvent() -{ +{ return new QIconDragEvent(); } @@ -379,7 +379,7 @@ if (_wrapper) { } } } - + } QPixmap PythonQtShell_QIconEngine::pixmap(const QSize& size0, QIcon::Mode mode1, QIcon::State state2) { @@ -481,11 +481,11 @@ if (_wrapper) { return QIconEngine::write(out0); } QIconEngine* PythonQtWrapper_QIconEngine::new_QIconEngine() -{ +{ return new PythonQtShell_QIconEngine(); } QIconEngine* PythonQtWrapper_QIconEngine::new_QIconEngine(const QIconEngine& other) -{ +{ return new PythonQtShell_QIconEngine(other); } QSize PythonQtWrapper_QIconEngine::actualSize(QIconEngine* theWrappedObject, const QSize& size, QIcon::Mode mode, QIcon::State state) @@ -978,7 +978,7 @@ if (_wrapper) { return QImageIOHandler::write(image0); } QImageIOHandler* PythonQtWrapper_QImageIOHandler::new_QImageIOHandler() -{ +{ return new PythonQtShell_QImageIOHandler(); } bool PythonQtWrapper_QImageIOHandler::canRead(QImageIOHandler* theWrappedObject) const @@ -1271,7 +1271,7 @@ if (_wrapper) { QImageIOPlugin::timerEvent(event0); } QImageIOPlugin* PythonQtWrapper_QImageIOPlugin::new_QImageIOPlugin(QObject* parent) -{ +{ return new PythonQtShell_QImageIOPlugin(parent); } const QMetaObject* PythonQtShell_QImageIOPlugin::metaObject() const { @@ -1300,15 +1300,15 @@ QImageIOHandler* PythonQtWrapper_QImageIOPlugin::create(QImageIOPlugin* theWrap QImageReader* PythonQtWrapper_QImageReader::new_QImageReader() -{ +{ return new QImageReader(); } QImageReader* PythonQtWrapper_QImageReader::new_QImageReader(QIODevice* device, const QByteArray& format) -{ +{ return new QImageReader(device, format); } QImageReader* PythonQtWrapper_QImageReader::new_QImageReader(const QString& fileName, const QByteArray& format) -{ +{ return new QImageReader(fileName, format); } bool PythonQtWrapper_QImageReader::autoDetectImageFormat(QImageReader* theWrappedObject) const @@ -1564,15 +1564,15 @@ QString PythonQtWrapper_QImageReader::static_QImageReader_trUtf8(const char* s QImageWriter* PythonQtWrapper_QImageWriter::new_QImageWriter() -{ +{ return new QImageWriter(); } QImageWriter* PythonQtWrapper_QImageWriter::new_QImageWriter(QIODevice* device, const QByteArray& format) -{ +{ return new QImageWriter(device, format); } QImageWriter* PythonQtWrapper_QImageWriter::new_QImageWriter(const QString& fileName, const QByteArray& format) -{ +{ return new QImageWriter(fileName, format); } bool PythonQtWrapper_QImageWriter::canWrite(QImageWriter* theWrappedObject) const @@ -2975,7 +2975,7 @@ if (_wrapper) { QInputDialog::wheelEvent(event0); } QInputDialog* PythonQtWrapper_QInputDialog::new_QInputDialog(QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QInputDialog(parent, flags); } const QMetaObject* PythonQtShell_QInputDialog::metaObject() const { @@ -3233,7 +3233,7 @@ PythonQtShell_QInputEvent::~PythonQtShell_QInputEvent() { if (priv) { priv->shellClassDeleted(this); } } QInputEvent* PythonQtWrapper_QInputEvent::new_QInputEvent(QEvent::Type type, Qt::KeyboardModifiers modifiers) -{ +{ return new PythonQtShell_QInputEvent(type, modifiers); } Qt::KeyboardModifiers PythonQtWrapper_QInputEvent::modifiers(QInputEvent* theWrappedObject) const @@ -3331,15 +3331,15 @@ void PythonQtWrapper_QInputMethod::setVisible(QInputMethod* theWrappedObject, bo QInputMethodEvent* PythonQtWrapper_QInputMethodEvent::new_QInputMethodEvent() -{ +{ return new QInputMethodEvent(); } QInputMethodEvent* PythonQtWrapper_QInputMethodEvent::new_QInputMethodEvent(const QInputMethodEvent& other) -{ +{ return new QInputMethodEvent(other); } QInputMethodEvent* PythonQtWrapper_QInputMethodEvent::new_QInputMethodEvent(const QString& preeditText, const QList& attributes) -{ +{ return new QInputMethodEvent(preeditText, attributes); } const QList* PythonQtWrapper_QInputMethodEvent::attributes(QInputMethodEvent* theWrappedObject) const @@ -3379,17 +3379,17 @@ PythonQtShell_QInputMethodEvent__Attribute::~PythonQtShell_QInputMethodEvent__At if (priv) { priv->shellClassDeleted(this); } } QInputMethodEvent::Attribute* PythonQtWrapper_QInputMethodEvent__Attribute::new_QInputMethodEvent__Attribute(QInputMethodEvent::AttributeType typ, int s, int l) -{ +{ return new PythonQtShell_QInputMethodEvent__Attribute(typ, s, l); } QInputMethodEvent::Attribute* PythonQtWrapper_QInputMethodEvent__Attribute::new_QInputMethodEvent__Attribute(QInputMethodEvent::AttributeType typ, int s, int l, QVariant val) -{ +{ return new PythonQtShell_QInputMethodEvent__Attribute(typ, s, l, val); } QInputMethodQueryEvent* PythonQtWrapper_QInputMethodQueryEvent::new_QInputMethodQueryEvent(Qt::InputMethodQueries queries) -{ +{ return new QInputMethodQueryEvent(queries); } Qt::InputMethodQueries PythonQtWrapper_QInputMethodQueryEvent::queries(QInputMethodQueryEvent* theWrappedObject) const @@ -3623,11 +3623,11 @@ if (_wrapper) { return QIntValidator::validate(arg__1, arg__2); } QIntValidator* PythonQtWrapper_QIntValidator::new_QIntValidator(QObject* parent) -{ +{ return new PythonQtShell_QIntValidator(parent); } QIntValidator* PythonQtWrapper_QIntValidator::new_QIntValidator(int bottom, int top, QObject* parent) -{ +{ return new PythonQtShell_QIntValidator(bottom, top, parent); } const QMetaObject* PythonQtShell_QIntValidator::metaObject() const { @@ -4170,7 +4170,7 @@ if (_wrapper) { QItemDelegate::updateEditorGeometry(editor0, option1, index2); } QItemDelegate* PythonQtWrapper_QItemDelegate::new_QItemDelegate(QObject* parent) -{ +{ return new PythonQtShell_QItemDelegate(parent); } const QMetaObject* PythonQtShell_QItemDelegate::metaObject() const { @@ -4334,7 +4334,7 @@ if (_wrapper) { return QByteArray(); } QItemEditorCreatorBase* PythonQtWrapper_QItemEditorCreatorBase::new_QItemEditorCreatorBase() -{ +{ return new PythonQtShell_QItemEditorCreatorBase(); } QWidget* PythonQtWrapper_QItemEditorCreatorBase::createWidget(QItemEditorCreatorBase* theWrappedObject, QWidget* parent) const @@ -4420,7 +4420,7 @@ if (_wrapper) { return QItemEditorFactory::valuePropertyName(userType0); } QItemEditorFactory* PythonQtWrapper_QItemEditorFactory::new_QItemEditorFactory() -{ +{ return new PythonQtShell_QItemEditorFactory(); } QWidget* PythonQtWrapper_QItemEditorFactory::createEditor(QItemEditorFactory* theWrappedObject, int userType, QWidget* parent) const @@ -4451,11 +4451,11 @@ QByteArray PythonQtWrapper_QItemEditorFactory::valuePropertyName(QItemEditorFac QItemSelection* PythonQtWrapper_QItemSelection::new_QItemSelection() -{ +{ return new QItemSelection(); } QItemSelection* PythonQtWrapper_QItemSelection::new_QItemSelection(const QModelIndex& topLeft, const QModelIndex& bottomRight) -{ +{ return new QItemSelection(topLeft, bottomRight); } void PythonQtWrapper_QItemSelection::append(QItemSelection* theWrappedObject, const QItemSelectionRange& t) @@ -4999,11 +4999,11 @@ if (_wrapper) { QItemSelectionModel::timerEvent(event0); } QItemSelectionModel* PythonQtWrapper_QItemSelectionModel::new_QItemSelectionModel(QAbstractItemModel* model) -{ +{ return new PythonQtShell_QItemSelectionModel(model); } QItemSelectionModel* PythonQtWrapper_QItemSelectionModel::new_QItemSelectionModel(QAbstractItemModel* model, QObject* parent) -{ +{ return new PythonQtShell_QItemSelectionModel(model, parent); } const QMetaObject* PythonQtShell_QItemSelectionModel::metaObject() const { @@ -5097,19 +5097,19 @@ void PythonQtWrapper_QItemSelectionModel::setModel(QItemSelectionModel* theWrapp QItemSelectionRange* PythonQtWrapper_QItemSelectionRange::new_QItemSelectionRange() -{ +{ return new QItemSelectionRange(); } QItemSelectionRange* PythonQtWrapper_QItemSelectionRange::new_QItemSelectionRange(const QItemSelectionRange& other) -{ +{ return new QItemSelectionRange(other); } QItemSelectionRange* PythonQtWrapper_QItemSelectionRange::new_QItemSelectionRange(const QModelIndex& index) -{ +{ return new QItemSelectionRange(index); } QItemSelectionRange* PythonQtWrapper_QItemSelectionRange::new_QItemSelectionRange(const QModelIndex& topL, const QModelIndex& bottomR) -{ +{ return new QItemSelectionRange(topL, bottomR); } int PythonQtWrapper_QItemSelectionRange::bottom(QItemSelectionRange* theWrappedObject) const @@ -5236,11 +5236,11 @@ PythonQtShell_QKeyEvent::~PythonQtShell_QKeyEvent() { if (priv) { priv->shellClassDeleted(this); } } QKeyEvent* PythonQtWrapper_QKeyEvent::new_QKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text, bool autorep, ushort count) -{ +{ return new PythonQtShell_QKeyEvent(type, key, modifiers, text, autorep, count); } QKeyEvent* PythonQtWrapper_QKeyEvent::new_QKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, unsigned int nativeScanCode, unsigned int nativeVirtualKey, unsigned int nativeModifiers, const QString& text, bool autorep, ushort count) -{ +{ return new PythonQtShell_QKeyEvent(type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count); } int PythonQtWrapper_QKeyEvent::count(QKeyEvent* theWrappedObject) const @@ -5482,11 +5482,11 @@ if (_wrapper) { QKeyEventTransition::timerEvent(event0); } QKeyEventTransition* PythonQtWrapper_QKeyEventTransition::new_QKeyEventTransition(QObject* object, QEvent::Type type, int key, QState* sourceState) -{ +{ return new PythonQtShell_QKeyEventTransition(object, type, key, sourceState); } QKeyEventTransition* PythonQtWrapper_QKeyEventTransition::new_QKeyEventTransition(QState* sourceState) -{ +{ return new PythonQtShell_QKeyEventTransition(sourceState); } const QMetaObject* PythonQtShell_QKeyEventTransition::metaObject() const { @@ -6673,11 +6673,11 @@ if (_wrapper) { QKeySequenceEdit::wheelEvent(event0); } QKeySequenceEdit* PythonQtWrapper_QKeySequenceEdit::new_QKeySequenceEdit(QWidget* parent) -{ +{ return new PythonQtShell_QKeySequenceEdit(parent); } QKeySequenceEdit* PythonQtWrapper_QKeySequenceEdit::new_QKeySequenceEdit(const QKeySequence& keySequence, QWidget* parent) -{ +{ return new PythonQtShell_QKeySequenceEdit(keySequence, parent); } const QMetaObject* PythonQtShell_QKeySequenceEdit::metaObject() const { @@ -7849,11 +7849,11 @@ if (_wrapper) { QLCDNumber::wheelEvent(event0); } QLCDNumber* PythonQtWrapper_QLCDNumber::new_QLCDNumber(QWidget* parent) -{ +{ return new PythonQtShell_QLCDNumber(parent); } QLCDNumber* PythonQtWrapper_QLCDNumber::new_QLCDNumber(uint numDigits, QWidget* parent) -{ +{ return new PythonQtShell_QLCDNumber(numDigits, parent); } const QMetaObject* PythonQtShell_QLCDNumber::metaObject() const { @@ -9075,11 +9075,11 @@ if (_wrapper) { QLabel::wheelEvent(event0); } QLabel* PythonQtWrapper_QLabel::new_QLabel(QWidget* parent, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QLabel(parent, f); } QLabel* PythonQtWrapper_QLabel::new_QLabel(const QString& text, QWidget* parent, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QLabel(text, parent, f); } const QMetaObject* PythonQtShell_QLabel::metaObject() const { @@ -9256,7 +9256,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QLayout::childEvent(QChildEvent* e0) { @@ -9996,11 +9996,11 @@ if (_wrapper) { return QLayout::widget(); } QLayout* PythonQtWrapper_QLayout::new_QLayout() -{ +{ return new PythonQtShell_QLayout(); } QLayout* PythonQtWrapper_QLayout::new_QLayout(QWidget* parent) -{ +{ return new PythonQtShell_QLayout(parent); } const QMetaObject* PythonQtShell_QLayout::metaObject() const { @@ -10584,7 +10584,7 @@ if (_wrapper) { } } } - + } QSize PythonQtShell_QLayoutItem::sizeHint() const { @@ -10686,7 +10686,7 @@ if (_wrapper) { return QLayoutItem::widget(); } QLayoutItem* PythonQtWrapper_QLayoutItem::new_QLayoutItem(Qt::Alignment alignment) -{ +{ return new PythonQtShell_QLayoutItem(alignment); } Qt::Alignment PythonQtWrapper_QLayoutItem::alignment(QLayoutItem* theWrappedObject) const @@ -11925,11 +11925,11 @@ if (_wrapper) { QLineEdit::wheelEvent(event0); } QLineEdit* PythonQtWrapper_QLineEdit::new_QLineEdit(QWidget* parent) -{ +{ return new PythonQtShell_QLineEdit(parent); } QLineEdit* PythonQtWrapper_QLineEdit::new_QLineEdit(const QString& arg__1, QWidget* parent) -{ +{ return new PythonQtShell_QLineEdit(arg__1, parent); } const QMetaObject* PythonQtShell_QLineEdit::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui5.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui5.cpp index b08ec73df..8fc208a1c 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui5.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui5.cpp @@ -92,15 +92,15 @@ #include QLinearGradient* PythonQtWrapper_QLinearGradient::new_QLinearGradient() -{ +{ return new QLinearGradient(); } QLinearGradient* PythonQtWrapper_QLinearGradient::new_QLinearGradient(const QPointF& start, const QPointF& finalStop) -{ +{ return new QLinearGradient(start, finalStop); } QLinearGradient* PythonQtWrapper_QLinearGradient::new_QLinearGradient(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop) -{ +{ return new QLinearGradient(xStart, yStart, xFinalStop, yFinalStop); } QPointF PythonQtWrapper_QLinearGradient::finalStop(QLinearGradient* theWrappedObject) const @@ -2373,7 +2373,7 @@ if (_wrapper) { QListView::wheelEvent(e0); } QListView* PythonQtWrapper_QListView::new_QListView(QWidget* parent) -{ +{ return new PythonQtShell_QListView(parent); } const QMetaObject* PythonQtShell_QListView::metaObject() const { @@ -4914,7 +4914,7 @@ if (_wrapper) { QListWidget::wheelEvent(e0); } QListWidget* PythonQtWrapper_QListWidget::new_QListWidget(QWidget* parent) -{ +{ return new PythonQtShell_QListWidget(parent); } const QMetaObject* PythonQtShell_QListWidget::metaObject() const { @@ -5264,15 +5264,15 @@ if (_wrapper) { QListWidgetItem::write(out0); } QListWidgetItem* PythonQtWrapper_QListWidgetItem::new_QListWidgetItem(PythonQtNewOwnerOfThis listview, int type) -{ +{ return new PythonQtShell_QListWidgetItem(listview, type); } QListWidgetItem* PythonQtWrapper_QListWidgetItem::new_QListWidgetItem(const QIcon& icon, const QString& text, PythonQtNewOwnerOfThis listview, int type) -{ +{ return new PythonQtShell_QListWidgetItem(icon, text, listview, type); } QListWidgetItem* PythonQtWrapper_QListWidgetItem::new_QListWidgetItem(const QString& text, PythonQtNewOwnerOfThis listview, int type) -{ +{ return new PythonQtShell_QListWidgetItem(text, listview, type); } QBrush PythonQtWrapper_QListWidgetItem::background(QListWidgetItem* theWrappedObject) const @@ -6644,7 +6644,7 @@ if (_wrapper) { QMainWindow::wheelEvent(event0); } QMainWindow* PythonQtWrapper_QMainWindow::new_QMainWindow(QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QMainWindow(parent, flags); } const QMetaObject* PythonQtShell_QMainWindow::metaObject() const { @@ -6908,11 +6908,11 @@ bool PythonQtWrapper_QMainWindow::unifiedTitleAndToolBarOnMac(QMainWindow* theW QMargins* PythonQtWrapper_QMargins::new_QMargins() -{ +{ return new QMargins(); } QMargins* PythonQtWrapper_QMargins::new_QMargins(int left, int top, int right, int bottom) -{ +{ return new QMargins(left, top, right, bottom); } int PythonQtWrapper_QMargins::bottom(QMargins* theWrappedObject) const @@ -7075,15 +7075,15 @@ QString PythonQtWrapper_QMargins::py_toString(QMargins* obj) { QMatrix* PythonQtWrapper_QMatrix::new_QMatrix() -{ +{ return new QMatrix(); } QMatrix* PythonQtWrapper_QMatrix::new_QMatrix(const QMatrix& other) -{ +{ return new QMatrix(other); } QMatrix* PythonQtWrapper_QMatrix::new_QMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy) -{ +{ return new QMatrix(m11, m12, m21, m22, dx, dy); } qreal PythonQtWrapper_QMatrix::determinant(QMatrix* theWrappedObject) const @@ -8519,7 +8519,7 @@ if (_wrapper) { QMdiArea::wheelEvent(arg__1); } QMdiArea* PythonQtWrapper_QMdiArea::new_QMdiArea(QWidget* parent) -{ +{ return new PythonQtShell_QMdiArea(parent); } const QMetaObject* PythonQtShell_QMdiArea::metaObject() const { @@ -9801,7 +9801,7 @@ if (_wrapper) { QMdiSubWindow::wheelEvent(event0); } QMdiSubWindow* PythonQtWrapper_QMdiSubWindow::new_QMdiSubWindow(QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QMdiSubWindow(parent, flags); } const QMetaObject* PythonQtShell_QMdiSubWindow::metaObject() const { @@ -11048,11 +11048,11 @@ if (_wrapper) { QMenu::wheelEvent(arg__1); } QMenu* PythonQtWrapper_QMenu::new_QMenu(QWidget* parent) -{ +{ return new PythonQtShell_QMenu(parent); } QMenu* PythonQtWrapper_QMenu::new_QMenu(const QString& title, QWidget* parent) -{ +{ return new PythonQtShell_QMenu(title, parent); } const QMetaObject* PythonQtShell_QMenu::metaObject() const { @@ -12439,7 +12439,7 @@ if (_wrapper) { QMenuBar::wheelEvent(event0); } QMenuBar* PythonQtWrapper_QMenuBar::new_QMenuBar(QWidget* parent) -{ +{ return new PythonQtShell_QMenuBar(parent); } const QMetaObject* PythonQtShell_QMenuBar::metaObject() const { @@ -13815,11 +13815,11 @@ if (_wrapper) { QMessageBox::wheelEvent(event0); } QMessageBox* PythonQtWrapper_QMessageBox::new_QMessageBox(QMessageBox::Icon icon, const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QMessageBox(icon, title, text, buttons, parent, flags); } QMessageBox* PythonQtWrapper_QMessageBox::new_QMessageBox(QWidget* parent) -{ +{ return new PythonQtShell_QMessageBox(parent); } const QMetaObject* PythonQtShell_QMessageBox::metaObject() const { @@ -14062,19 +14062,19 @@ PythonQtShell_QMouseEvent::~PythonQtShell_QMouseEvent() { if (priv) { priv->shellClassDeleted(this); } } QMouseEvent* PythonQtWrapper_QMouseEvent::new_QMouseEvent(QEvent::Type type, const QPointF& localPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) -{ +{ return new PythonQtShell_QMouseEvent(type, localPos, button, buttons, modifiers); } QMouseEvent* PythonQtWrapper_QMouseEvent::new_QMouseEvent(QEvent::Type type, const QPointF& localPos, const QPointF& screenPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) -{ +{ return new PythonQtShell_QMouseEvent(type, localPos, screenPos, button, buttons, modifiers); } QMouseEvent* PythonQtWrapper_QMouseEvent::new_QMouseEvent(QEvent::Type type, const QPointF& localPos, const QPointF& windowPos, const QPointF& screenPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) -{ +{ return new PythonQtShell_QMouseEvent(type, localPos, windowPos, screenPos, button, buttons, modifiers); } QMouseEvent* PythonQtWrapper_QMouseEvent::new_QMouseEvent(QEvent::Type type, const QPointF& localPos, const QPointF& windowPos, const QPointF& screenPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source) -{ +{ return new PythonQtShell_QMouseEvent(type, localPos, windowPos, screenPos, button, buttons, modifiers, source); } Qt::MouseButton PythonQtWrapper_QMouseEvent::button(QMouseEvent* theWrappedObject) const @@ -14341,11 +14341,11 @@ if (_wrapper) { QMouseEventTransition::timerEvent(event0); } QMouseEventTransition* PythonQtWrapper_QMouseEventTransition::new_QMouseEventTransition(QObject* object, QEvent::Type type, Qt::MouseButton button, QState* sourceState) -{ +{ return new PythonQtShell_QMouseEventTransition(object, type, button, sourceState); } QMouseEventTransition* PythonQtWrapper_QMouseEventTransition::new_QMouseEventTransition(QState* sourceState) -{ +{ return new PythonQtShell_QMouseEventTransition(sourceState); } const QMetaObject* PythonQtShell_QMouseEventTransition::metaObject() const { @@ -14398,7 +14398,7 @@ PythonQtShell_QMoveEvent::~PythonQtShell_QMoveEvent() { if (priv) { priv->shellClassDeleted(this); } } QMoveEvent* PythonQtWrapper_QMoveEvent::new_QMoveEvent(const QPoint& pos, const QPoint& oldPos) -{ +{ return new PythonQtShell_QMoveEvent(pos, oldPos); } const QPoint* PythonQtWrapper_QMoveEvent::oldPos(QMoveEvent* theWrappedObject) const @@ -14550,15 +14550,15 @@ if (_wrapper) { QMovie::timerEvent(event0); } QMovie* PythonQtWrapper_QMovie::new_QMovie(QIODevice* device, const QByteArray& format, QObject* parent) -{ +{ return new PythonQtShell_QMovie(device, format, parent); } QMovie* PythonQtWrapper_QMovie::new_QMovie(QObject* parent) -{ +{ return new PythonQtShell_QMovie(parent); } QMovie* PythonQtWrapper_QMovie::new_QMovie(const QString& fileName, const QByteArray& format, QObject* parent) -{ +{ return new PythonQtShell_QMovie(fileName, format, parent); } const QMetaObject* PythonQtShell_QMovie::metaObject() const { @@ -14711,11 +14711,11 @@ PythonQtShell_QNativeGestureEvent::~PythonQtShell_QNativeGestureEvent() { if (priv) { priv->shellClassDeleted(this); } } QNativeGestureEvent* PythonQtWrapper_QNativeGestureEvent::new_QNativeGestureEvent(Qt::NativeGestureType type, const QPointF& localPos, const QPointF& windowPos, const QPointF& screenPos, qreal value, ulong sequenceId, quint64 intArgument) -{ +{ return new PythonQtShell_QNativeGestureEvent(type, localPos, windowPos, screenPos, value, sequenceId, intArgument); } QNativeGestureEvent* PythonQtWrapper_QNativeGestureEvent::new_QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice* dev, const QPointF& localPos, const QPointF& windowPos, const QPointF& screenPos, qreal value, ulong sequenceId, quint64 intArgument) -{ +{ return new PythonQtShell_QNativeGestureEvent(type, dev, localPos, windowPos, screenPos, value, sequenceId, intArgument); } const QTouchDevice* PythonQtWrapper_QNativeGestureEvent::device(QNativeGestureEvent* theWrappedObject) const @@ -14996,11 +14996,11 @@ if (_wrapper) { QOffscreenSurface::timerEvent(event0); } QOffscreenSurface* PythonQtWrapper_QOffscreenSurface::new_QOffscreenSurface(QScreen* screen) -{ +{ return new PythonQtShell_QOffscreenSurface(screen); } QOffscreenSurface* PythonQtWrapper_QOffscreenSurface::new_QOffscreenSurface(QScreen* screen, QObject* parent) -{ +{ return new PythonQtShell_QOffscreenSurface(screen, parent); } const QMetaObject* PythonQtShell_QOffscreenSurface::metaObject() const { @@ -15064,15 +15064,15 @@ void PythonQtWrapper_QOffscreenSurface::setScreen(QOffscreenSurface* theWrappedO QOpenGLBuffer* PythonQtWrapper_QOpenGLBuffer::new_QOpenGLBuffer() -{ +{ return new QOpenGLBuffer(); } QOpenGLBuffer* PythonQtWrapper_QOpenGLBuffer::new_QOpenGLBuffer(QOpenGLBuffer::Type type) -{ +{ return new QOpenGLBuffer(type); } QOpenGLBuffer* PythonQtWrapper_QOpenGLBuffer::new_QOpenGLBuffer(const QOpenGLBuffer& other) -{ +{ return new QOpenGLBuffer(other); } void PythonQtWrapper_QOpenGLBuffer::allocate(QOpenGLBuffer* theWrappedObject, const void* data, int count) @@ -15304,7 +15304,7 @@ if (_wrapper) { QOpenGLContext::timerEvent(event0); } QOpenGLContext* PythonQtWrapper_QOpenGLContext::new_QOpenGLContext(QObject* parent) -{ +{ return new PythonQtShell_QOpenGLContext(parent); } const QMetaObject* PythonQtShell_QOpenGLContext::metaObject() const { @@ -15483,27 +15483,27 @@ PythonQtShell_QOpenGLFramebufferObject::~PythonQtShell_QOpenGLFramebufferObject( if (priv) { priv->shellClassDeleted(this); } } QOpenGLFramebufferObject* PythonQtWrapper_QOpenGLFramebufferObject::new_QOpenGLFramebufferObject(const QSize& size, GLenum target) -{ +{ return new PythonQtShell_QOpenGLFramebufferObject(size, target); } QOpenGLFramebufferObject* PythonQtWrapper_QOpenGLFramebufferObject::new_QOpenGLFramebufferObject(const QSize& size, QOpenGLFramebufferObject::Attachment attachment, GLenum target, GLenum internalFormat) -{ +{ return new PythonQtShell_QOpenGLFramebufferObject(size, attachment, target, internalFormat); } QOpenGLFramebufferObject* PythonQtWrapper_QOpenGLFramebufferObject::new_QOpenGLFramebufferObject(const QSize& size, const QOpenGLFramebufferObjectFormat& format) -{ +{ return new PythonQtShell_QOpenGLFramebufferObject(size, format); } QOpenGLFramebufferObject* PythonQtWrapper_QOpenGLFramebufferObject::new_QOpenGLFramebufferObject(int width, int height, GLenum target) -{ +{ return new PythonQtShell_QOpenGLFramebufferObject(width, height, target); } QOpenGLFramebufferObject* PythonQtWrapper_QOpenGLFramebufferObject::new_QOpenGLFramebufferObject(int width, int height, QOpenGLFramebufferObject::Attachment attachment, GLenum target, GLenum internalFormat) -{ +{ return new PythonQtShell_QOpenGLFramebufferObject(width, height, attachment, target, internalFormat); } QOpenGLFramebufferObject* PythonQtWrapper_QOpenGLFramebufferObject::new_QOpenGLFramebufferObject(int width, int height, const QOpenGLFramebufferObjectFormat& format) -{ +{ return new PythonQtShell_QOpenGLFramebufferObject(width, height, format); } void PythonQtWrapper_QOpenGLFramebufferObject::addColorAttachment(QOpenGLFramebufferObject* theWrappedObject, const QSize& size, GLenum internalFormat) @@ -15649,11 +15649,11 @@ int PythonQtWrapper_QOpenGLFramebufferObject::width(QOpenGLFramebufferObject* t QOpenGLFramebufferObjectFormat* PythonQtWrapper_QOpenGLFramebufferObjectFormat::new_QOpenGLFramebufferObjectFormat() -{ +{ return new QOpenGLFramebufferObjectFormat(); } QOpenGLFramebufferObjectFormat* PythonQtWrapper_QOpenGLFramebufferObjectFormat::new_QOpenGLFramebufferObjectFormat(const QOpenGLFramebufferObjectFormat& other) -{ +{ return new QOpenGLFramebufferObjectFormat(other); } QOpenGLFramebufferObject::Attachment PythonQtWrapper_QOpenGLFramebufferObjectFormat::attachment(QOpenGLFramebufferObjectFormat* theWrappedObject) const @@ -15937,15 +15937,15 @@ if (_wrapper) { return QOpenGLPaintDevice::sharedPainter(); } QOpenGLPaintDevice* PythonQtWrapper_QOpenGLPaintDevice::new_QOpenGLPaintDevice() -{ +{ return new PythonQtShell_QOpenGLPaintDevice(); } QOpenGLPaintDevice* PythonQtWrapper_QOpenGLPaintDevice::new_QOpenGLPaintDevice(const QSize& size) -{ +{ return new PythonQtShell_QOpenGLPaintDevice(size); } QOpenGLPaintDevice* PythonQtWrapper_QOpenGLPaintDevice::new_QOpenGLPaintDevice(int width, int height) -{ +{ return new PythonQtShell_QOpenGLPaintDevice(width, height); } QOpenGLContext* PythonQtWrapper_QOpenGLPaintDevice::context(QOpenGLPaintDevice* theWrappedObject) const @@ -16142,7 +16142,7 @@ if (_wrapper) { QOpenGLShader::timerEvent(event0); } QOpenGLShader* PythonQtWrapper_QOpenGLShader::new_QOpenGLShader(QOpenGLShader::ShaderType type, QObject* parent) -{ +{ return new PythonQtShell_QOpenGLShader(type, parent); } const QMetaObject* PythonQtShell_QOpenGLShader::metaObject() const { @@ -16380,7 +16380,7 @@ if (_wrapper) { QOpenGLShaderProgram::timerEvent(event0); } QOpenGLShaderProgram* PythonQtWrapper_QOpenGLShaderProgram::new_QOpenGLShaderProgram(QObject* parent) -{ +{ return new PythonQtShell_QOpenGLShaderProgram(parent); } const QMetaObject* PythonQtShell_QOpenGLShaderProgram::metaObject() const { @@ -16979,11 +16979,11 @@ int PythonQtWrapper_QOpenGLShaderProgram::uniformLocation(QOpenGLShaderProgram* QOpenGLTexture* PythonQtWrapper_QOpenGLTexture::new_QOpenGLTexture(QOpenGLTexture::Target target) -{ +{ return new QOpenGLTexture(target); } QOpenGLTexture* PythonQtWrapper_QOpenGLTexture::new_QOpenGLTexture(const QImage& image, QOpenGLTexture::MipMapGeneration genMipMaps) -{ +{ return new QOpenGLTexture(image, genMipMaps); } void PythonQtWrapper_QOpenGLTexture::allocateStorage(QOpenGLTexture* theWrappedObject) @@ -17406,7 +17406,7 @@ QString PythonQtWrapper_QOpenGLTexture::py_toString(QOpenGLTexture* obj) { QOpenGLTextureBlitter* PythonQtWrapper_QOpenGLTextureBlitter::new_QOpenGLTextureBlitter() -{ +{ return new QOpenGLTextureBlitter(); } void PythonQtWrapper_QOpenGLTextureBlitter::bind(QOpenGLTextureBlitter* theWrappedObject, GLenum target) @@ -17598,7 +17598,7 @@ if (_wrapper) { QOpenGLTimeMonitor::timerEvent(event0); } QOpenGLTimeMonitor* PythonQtWrapper_QOpenGLTimeMonitor::new_QOpenGLTimeMonitor(QObject* parent) -{ +{ return new PythonQtShell_QOpenGLTimeMonitor(parent); } const QMetaObject* PythonQtShell_QOpenGLTimeMonitor::metaObject() const { @@ -17808,7 +17808,7 @@ if (_wrapper) { QOpenGLTimerQuery::timerEvent(event0); } QOpenGLTimerQuery* PythonQtWrapper_QOpenGLTimerQuery::new_QOpenGLTimerQuery(QObject* parent) -{ +{ return new PythonQtShell_QOpenGLTimerQuery(parent); } const QMetaObject* PythonQtShell_QOpenGLTimerQuery::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui5.h b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui5.h index e8ed5c38a..adc989e8e 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui5.h +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui5.h @@ -1340,7 +1340,7 @@ void delete_QMenu(QMenu* obj) { delete obj; } PythonQt::self()->addSignalHandler(a, SIGNAL(triggered(bool)), callable); return a; } - + QAction* addAction (QMenu* menu, const QIcon& icon, const QString& text, PyObject* callable, const QKeySequence& shortcut = 0) { QAction* a = menu->addAction(text); @@ -1349,7 +1349,7 @@ void delete_QMenu(QMenu* obj) { delete obj; } PythonQt::self()->addSignalHandler(a, SIGNAL(triggered(bool)), callable); return a; } - + }; @@ -1504,7 +1504,7 @@ void delete_QMenuBar(QMenuBar* obj) { delete obj; } PythonQt::self()->addSignalHandler(a, SIGNAL(triggered(bool)), callable); return a; } - + }; diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui6.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui6.cpp index f3d8255d8..f986e0b7b 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui6.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui6.cpp @@ -82,15 +82,15 @@ #include QOpenGLVersionProfile* PythonQtWrapper_QOpenGLVersionProfile::new_QOpenGLVersionProfile() -{ +{ return new QOpenGLVersionProfile(); } QOpenGLVersionProfile* PythonQtWrapper_QOpenGLVersionProfile::new_QOpenGLVersionProfile(const QOpenGLVersionProfile& other) -{ +{ return new QOpenGLVersionProfile(other); } QOpenGLVersionProfile* PythonQtWrapper_QOpenGLVersionProfile::new_QOpenGLVersionProfile(const QSurfaceFormat& format) -{ +{ return new QOpenGLVersionProfile(format); } bool PythonQtWrapper_QOpenGLVersionProfile::hasProfiles(QOpenGLVersionProfile* theWrappedObject) const @@ -289,7 +289,7 @@ if (_wrapper) { QOpenGLVertexArrayObject::timerEvent(event0); } QOpenGLVertexArrayObject* PythonQtWrapper_QOpenGLVertexArrayObject::new_QOpenGLVertexArrayObject(QObject* parent) -{ +{ return new PythonQtShell_QOpenGLVertexArrayObject(parent); } const QMetaObject* PythonQtShell_QOpenGLVertexArrayObject::metaObject() const { @@ -1552,7 +1552,7 @@ if (_wrapper) { QOpenGLWidget::wheelEvent(event0); } QOpenGLWidget* PythonQtWrapper_QOpenGLWidget::new_QOpenGLWidget(QWidget* parent, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QOpenGLWidget(parent, f); } const QMetaObject* PythonQtShell_QOpenGLWidget::metaObject() const { @@ -2585,11 +2585,11 @@ if (_wrapper) { QOpenGLWindow::wheelEvent(arg__1); } QOpenGLWindow* PythonQtWrapper_QOpenGLWindow::new_QOpenGLWindow(QOpenGLContext* shareContext, QOpenGLWindow::UpdateBehavior updateBehavior, QWindow* parent) -{ +{ return new PythonQtShell_QOpenGLWindow(shareContext, updateBehavior, parent); } QOpenGLWindow* PythonQtWrapper_QOpenGLWindow::new_QOpenGLWindow(QOpenGLWindow::UpdateBehavior updateBehavior, QWindow* parent) -{ +{ return new PythonQtShell_QOpenGLWindow(updateBehavior, parent); } const QMetaObject* PythonQtShell_QOpenGLWindow::metaObject() const { @@ -2673,15 +2673,15 @@ QOpenGLWindow::UpdateBehavior PythonQtWrapper_QOpenGLWindow::updateBehavior(QOp QPageLayout* PythonQtWrapper_QPageLayout::new_QPageLayout() -{ +{ return new QPageLayout(); } QPageLayout* PythonQtWrapper_QPageLayout::new_QPageLayout(const QPageLayout& other) -{ +{ return new QPageLayout(other); } QPageLayout* PythonQtWrapper_QPageLayout::new_QPageLayout(const QPageSize& pageSize, QPageLayout::Orientation orientation, const QMarginsF& margins, QPageLayout::Unit units, const QMarginsF& minMargins) -{ +{ return new QPageLayout(pageSize, orientation, margins, units, minMargins); } QRectF PythonQtWrapper_QPageLayout::fullRect(QPageLayout* theWrappedObject) const @@ -4111,11 +4111,11 @@ if (_wrapper) { QPageSetupDialog::wheelEvent(event0); } QPageSetupDialog* PythonQtWrapper_QPageSetupDialog::new_QPageSetupDialog(QPrinter* printer, QWidget* parent) -{ +{ return new PythonQtShell_QPageSetupDialog(printer, parent); } QPageSetupDialog* PythonQtWrapper_QPageSetupDialog::new_QPageSetupDialog(QWidget* parent) -{ +{ return new PythonQtShell_QPageSetupDialog(parent); } const QMetaObject* PythonQtShell_QPageSetupDialog::metaObject() const { @@ -4144,23 +4144,23 @@ QPrinter* PythonQtWrapper_QPageSetupDialog::printer(QPageSetupDialog* theWrappe QPageSize* PythonQtWrapper_QPageSize::new_QPageSize() -{ +{ return new QPageSize(); } QPageSize* PythonQtWrapper_QPageSize::new_QPageSize(QPageSize::PageSizeId pageSizeId) -{ +{ return new QPageSize(pageSizeId); } QPageSize* PythonQtWrapper_QPageSize::new_QPageSize(const QPageSize& other) -{ +{ return new QPageSize(other); } QPageSize* PythonQtWrapper_QPageSize::new_QPageSize(const QSize& pointSize, const QString& name, QPageSize::SizeMatchPolicy matchPolicy) -{ +{ return new QPageSize(pointSize, name, matchPolicy); } QPageSize* PythonQtWrapper_QPageSize::new_QPageSize(const QSizeF& size, QPageSize::Unit units, const QString& name, QPageSize::SizeMatchPolicy matchPolicy) -{ +{ return new QPageSize(size, units, name, matchPolicy); } QSizeF PythonQtWrapper_QPageSize::definitionSize(QPageSize* theWrappedObject) const @@ -4394,7 +4394,7 @@ PythonQtShell_QPagedPaintDevice__Margins::~PythonQtShell_QPagedPaintDevice__Marg if (priv) { priv->shellClassDeleted(this); } } QPagedPaintDevice::Margins* PythonQtWrapper_QPagedPaintDevice__Margins::new_QPagedPaintDevice__Margins() -{ +{ return new PythonQtShell_QPagedPaintDevice__Margins(); } @@ -4591,7 +4591,7 @@ if (_wrapper) { return QPaintDevice::sharedPainter(); } QPaintDevice* PythonQtWrapper_QPaintDevice::new_QPaintDevice() -{ +{ return new PythonQtShell_QPaintDevice(); } int PythonQtWrapper_QPaintDevice::colorCount(QPaintDevice* theWrappedObject) const @@ -4935,7 +4935,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QPaintEngine::drawPoints(const QPoint* points0, int pointCount1) { @@ -5199,10 +5199,10 @@ if (_wrapper) { } } } - + } QPaintEngine* PythonQtWrapper_QPaintEngine::new_QPaintEngine(QPaintEngine::PaintEngineFeatures features) -{ +{ return new PythonQtShell_QPaintEngine(features); } bool PythonQtWrapper_QPaintEngine::begin(QPaintEngine* theWrappedObject, QPaintDevice* pdev) @@ -5382,7 +5382,7 @@ PythonQtShell_QPaintEngineState::~PythonQtShell_QPaintEngineState() { if (priv) { priv->shellClassDeleted(this); } } QPaintEngineState* PythonQtWrapper_QPaintEngineState::new_QPaintEngineState() -{ +{ return new PythonQtShell_QPaintEngineState(); } QBrush PythonQtWrapper_QPaintEngineState::backgroundBrush(QPaintEngineState* theWrappedObject) const @@ -5487,11 +5487,11 @@ PythonQtShell_QPaintEvent::~PythonQtShell_QPaintEvent() { if (priv) { priv->shellClassDeleted(this); } } QPaintEvent* PythonQtWrapper_QPaintEvent::new_QPaintEvent(const QRect& paintRect) -{ +{ return new PythonQtShell_QPaintEvent(paintRect); } QPaintEvent* PythonQtWrapper_QPaintEvent::new_QPaintEvent(const QRegion& paintRegion) -{ +{ return new PythonQtShell_QPaintEvent(paintRegion); } const QRect* PythonQtWrapper_QPaintEvent::rect(QPaintEvent* theWrappedObject) const @@ -5507,11 +5507,11 @@ const QRegion* PythonQtWrapper_QPaintEvent::region(QPaintEvent* theWrappedObjec QPainter* PythonQtWrapper_QPainter::new_QPainter() -{ +{ return new QPainter(); } QPainter* PythonQtWrapper_QPainter::new_QPainter(QPaintDevice* arg__1) -{ +{ return new QPainter(arg__1); } const QBrush* PythonQtWrapper_QPainter::background(QPainter* theWrappedObject) const @@ -6467,15 +6467,15 @@ const QTransform* PythonQtWrapper_QPainter::worldTransform(QPainter* theWrapped QPainterPath* PythonQtWrapper_QPainterPath::new_QPainterPath() -{ +{ return new QPainterPath(); } QPainterPath* PythonQtWrapper_QPainterPath::new_QPainterPath(const QPainterPath& other) -{ +{ return new QPainterPath(other); } QPainterPath* PythonQtWrapper_QPainterPath::new_QPainterPath(const QPointF& startPoint) -{ +{ return new QPainterPath(startPoint); } void PythonQtWrapper_QPainterPath::addEllipse(QPainterPath* theWrappedObject, const QPointF& center, qreal rx, qreal ry) @@ -6903,11 +6903,11 @@ QString PythonQtWrapper_QPainterPath::py_toString(QPainterPath* obj) { QPainterPathStroker* PythonQtWrapper_QPainterPathStroker::new_QPainterPathStroker() -{ +{ return new QPainterPathStroker(); } QPainterPathStroker* PythonQtWrapper_QPainterPathStroker::new_QPainterPathStroker(const QPen& pen) -{ +{ return new QPainterPathStroker(pen); } Qt::PenCapStyle PythonQtWrapper_QPainterPathStroker::capStyle(QPainterPathStroker* theWrappedObject) const @@ -6997,7 +6997,7 @@ PythonQtShell_QPainterPath__Element::~PythonQtShell_QPainterPath__Element() { if (priv) { priv->shellClassDeleted(this); } } QPainterPath::Element* PythonQtWrapper_QPainterPath__Element::new_QPainterPath__Element() -{ +{ return new PythonQtShell_QPainterPath__Element(); } bool PythonQtWrapper_QPainterPath__Element::isCurveTo(QPainterPath::Element* theWrappedObject) const @@ -7037,7 +7037,7 @@ PythonQtShell_QPainter__PixmapFragment::~PythonQtShell_QPainter__PixmapFragment( if (priv) { priv->shellClassDeleted(this); } } QPainter::PixmapFragment* PythonQtWrapper_QPainter__PixmapFragment::new_QPainter__PixmapFragment() -{ +{ return new PythonQtShell_QPainter__PixmapFragment(); } QPainter::PixmapFragment PythonQtWrapper_QPainter__PixmapFragment::static_QPainter__PixmapFragment_create(const QPointF& pos, const QRectF& sourceRect, qreal scaleX, qreal scaleY, qreal rotation, qreal opacity) @@ -7184,7 +7184,7 @@ if (_wrapper) { QPanGesture::timerEvent(event0); } QPanGesture* PythonQtWrapper_QPanGesture::new_QPanGesture(QObject* parent) -{ +{ return new PythonQtShell_QPanGesture(parent); } const QMetaObject* PythonQtShell_QPanGesture::metaObject() const { @@ -7660,11 +7660,11 @@ if (_wrapper) { QPdfWriter::timerEvent(event0); } QPdfWriter* PythonQtWrapper_QPdfWriter::new_QPdfWriter(QIODevice* device) -{ +{ return new PythonQtShell_QPdfWriter(device); } QPdfWriter* PythonQtWrapper_QPdfWriter::new_QPdfWriter(const QString& filename) -{ +{ return new PythonQtShell_QPdfWriter(filename); } const QMetaObject* PythonQtShell_QPdfWriter::metaObject() const { @@ -7929,11 +7929,11 @@ if (_wrapper) { return QPicture::sharedPainter(); } QPicture* PythonQtWrapper_QPicture::new_QPicture(const QPicture& arg__1) -{ +{ return new PythonQtShell_QPicture(arg__1); } QPicture* PythonQtWrapper_QPicture::new_QPicture(int formatVersion) -{ +{ return new PythonQtShell_QPicture(formatVersion); } QRect PythonQtWrapper_QPicture::boundingRect(QPicture* theWrappedObject) const @@ -8239,7 +8239,7 @@ if (_wrapper) { QPictureFormatPlugin::timerEvent(event0); } QPictureFormatPlugin* PythonQtWrapper_QPictureFormatPlugin::new_QPictureFormatPlugin(QObject* parent) -{ +{ return new PythonQtShell_QPictureFormatPlugin(parent); } const QMetaObject* PythonQtShell_QPictureFormatPlugin::metaObject() const { @@ -8273,15 +8273,15 @@ bool PythonQtWrapper_QPictureFormatPlugin::savePicture(QPictureFormatPlugin* th QPictureIO* PythonQtWrapper_QPictureIO::new_QPictureIO() -{ +{ return new QPictureIO(); } QPictureIO* PythonQtWrapper_QPictureIO::new_QPictureIO(QIODevice* ioDevice, const char* format) -{ +{ return new QPictureIO(ioDevice, format); } QPictureIO* PythonQtWrapper_QPictureIO::new_QPictureIO(const QString& fileName, const char* format) -{ +{ return new QPictureIO(fileName, format); } QString PythonQtWrapper_QPictureIO::description(QPictureIO* theWrappedObject) const @@ -8543,7 +8543,7 @@ if (_wrapper) { QPinchGesture::timerEvent(event0); } QPinchGesture* PythonQtWrapper_QPinchGesture::new_QPinchGesture(QObject* parent) -{ +{ return new PythonQtShell_QPinchGesture(parent); } const QMetaObject* PythonQtShell_QPinchGesture::metaObject() const { @@ -8672,11 +8672,11 @@ qreal PythonQtWrapper_QPinchGesture::totalScaleFactor(QPinchGesture* theWrapped QPixelFormat* PythonQtWrapper_QPixelFormat::new_QPixelFormat() -{ +{ return new QPixelFormat(); } QPixelFormat* PythonQtWrapper_QPixelFormat::new_QPixelFormat(QPixelFormat::ColorModel colorModel, uchar firstSize, uchar secondSize, uchar thirdSize, uchar fourthSize, uchar fifthSize, uchar alphaSize, QPixelFormat::AlphaUsage alphaUsage, QPixelFormat::AlphaPosition alphaPosition, QPixelFormat::AlphaPremultiplied premultiplied, QPixelFormat::TypeInterpretation typeInterpretation, QPixelFormat::ByteOrder byteOrder, uchar subEnum) -{ +{ return new QPixelFormat(colorModel, firstSize, secondSize, thirdSize, fourthSize, fifthSize, alphaSize, alphaUsage, alphaPosition, premultiplied, typeInterpretation, byteOrder, subEnum); } QPixelFormat::AlphaPosition PythonQtWrapper_QPixelFormat::alphaPosition(QPixelFormat* theWrappedObject) const @@ -8806,7 +8806,7 @@ PythonQtShell_QPixmapCache::~PythonQtShell_QPixmapCache() { if (priv) { priv->shellClassDeleted(this); } } QPixmapCache* PythonQtWrapper_QPixmapCache::new_QPixmapCache() -{ +{ return new PythonQtShell_QPixmapCache(); } int PythonQtWrapper_QPixmapCache::static_QPixmapCache_cacheLimit() @@ -8862,11 +8862,11 @@ void PythonQtWrapper_QPixmapCache::static_QPixmapCache_setCacheLimit(int arg__1 QPixmapCache::Key* PythonQtWrapper_QPixmapCache__Key::new_QPixmapCache__Key() -{ +{ return new QPixmapCache::Key(); } QPixmapCache::Key* PythonQtWrapper_QPixmapCache__Key::new_QPixmapCache__Key(const QPixmapCache::Key& other) -{ +{ return new QPixmapCache::Key(other); } bool PythonQtWrapper_QPixmapCache__Key::isValid(QPixmapCache::Key* theWrappedObject) const @@ -9308,7 +9308,7 @@ if (_wrapper) { QPlainTextDocumentLayout::timerEvent(event0); } QPlainTextDocumentLayout* PythonQtWrapper_QPlainTextDocumentLayout::new_QPlainTextDocumentLayout(QTextDocument* document) -{ +{ return new PythonQtShell_QPlainTextDocumentLayout(document); } const QMetaObject* PythonQtShell_QPlainTextDocumentLayout::metaObject() const { @@ -10748,11 +10748,11 @@ if (_wrapper) { QPlainTextEdit::wheelEvent(e0); } QPlainTextEdit* PythonQtWrapper_QPlainTextEdit::new_QPlainTextEdit(QWidget* parent) -{ +{ return new PythonQtShell_QPlainTextEdit(parent); } QPlainTextEdit* PythonQtWrapper_QPlainTextEdit::new_QPlainTextEdit(const QString& text, QWidget* parent) -{ +{ return new PythonQtShell_QPlainTextEdit(text, parent); } const QMetaObject* PythonQtShell_QPlainTextEdit::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui7.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui7.cpp index 02478e30d..b252d6a93 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui7.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui7.cpp @@ -80,7 +80,7 @@ PythonQtShell_QPlatformSurfaceEvent::~PythonQtShell_QPlatformSurfaceEvent() { if (priv) { priv->shellClassDeleted(this); } } QPlatformSurfaceEvent* PythonQtWrapper_QPlatformSurfaceEvent::new_QPlatformSurfaceEvent(QPlatformSurfaceEvent::SurfaceEventType surfaceEventType) -{ +{ return new PythonQtShell_QPlatformSurfaceEvent(surfaceEventType); } QPlatformSurfaceEvent::SurfaceEventType PythonQtWrapper_QPlatformSurfaceEvent::surfaceEventType(QPlatformSurfaceEvent* theWrappedObject) const @@ -91,27 +91,27 @@ QPlatformSurfaceEvent::SurfaceEventType PythonQtWrapper_QPlatformSurfaceEvent:: QPolygonF* PythonQtWrapper_QPolygonF::new_QPolygonF() -{ +{ return new QPolygonF(); } QPolygonF* PythonQtWrapper_QPolygonF::new_QPolygonF(const QPolygon& a) -{ +{ return new QPolygonF(a); } QPolygonF* PythonQtWrapper_QPolygonF::new_QPolygonF(const QPolygonF& a) -{ +{ return new QPolygonF(a); } QPolygonF* PythonQtWrapper_QPolygonF::new_QPolygonF(const QRectF& r) -{ +{ return new QPolygonF(r); } QPolygonF* PythonQtWrapper_QPolygonF::new_QPolygonF(const QVector& v) -{ +{ return new QPolygonF(v); } QPolygonF* PythonQtWrapper_QPolygonF::new_QPolygonF(int size) -{ +{ return new QPolygonF(size); } void PythonQtWrapper_QPolygonF::append(QPolygonF* theWrappedObject, const QPointF& t) @@ -1721,11 +1721,11 @@ if (_wrapper) { QPrintDialog::wheelEvent(event0); } QPrintDialog* PythonQtWrapper_QPrintDialog::new_QPrintDialog(QPrinter* printer, QWidget* parent) -{ +{ return new PythonQtShell_QPrintDialog(printer, parent); } QPrintDialog* PythonQtWrapper_QPrintDialog::new_QPrintDialog(QWidget* parent) -{ +{ return new PythonQtShell_QPrintDialog(parent); } const QMetaObject* PythonQtShell_QPrintDialog::metaObject() const { @@ -1957,10 +1957,10 @@ if (_wrapper) { } } } - + } QPrintEngine* PythonQtWrapper_QPrintEngine::new_QPrintEngine() -{ +{ return new PythonQtShell_QPrintEngine(); } bool PythonQtWrapper_QPrintEngine::abort(QPrintEngine* theWrappedObject) @@ -3243,11 +3243,11 @@ if (_wrapper) { QPrintPreviewDialog::wheelEvent(event0); } QPrintPreviewDialog* PythonQtWrapper_QPrintPreviewDialog::new_QPrintPreviewDialog(QPrinter* printer, QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QPrintPreviewDialog(printer, parent, flags); } QPrintPreviewDialog* PythonQtWrapper_QPrintPreviewDialog::new_QPrintPreviewDialog(QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QPrintPreviewDialog(parent, flags); } const QMetaObject* PythonQtShell_QPrintPreviewDialog::metaObject() const { @@ -4424,11 +4424,11 @@ if (_wrapper) { QPrintPreviewWidget::wheelEvent(event0); } QPrintPreviewWidget* PythonQtWrapper_QPrintPreviewWidget::new_QPrintPreviewWidget(QPrinter* printer, QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QPrintPreviewWidget(printer, parent, flags); } QPrintPreviewWidget* PythonQtWrapper_QPrintPreviewWidget::new_QPrintPreviewWidget(QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QPrintPreviewWidget(parent, flags); } const QMetaObject* PythonQtShell_QPrintPreviewWidget::metaObject() const { @@ -4767,11 +4767,11 @@ if (_wrapper) { return QPrinter::sharedPainter(); } QPrinter* PythonQtWrapper_QPrinter::new_QPrinter(QPrinter::PrinterMode mode) -{ +{ return new PythonQtShell_QPrinter(mode); } QPrinter* PythonQtWrapper_QPrinter::new_QPrinter(const QPrinterInfo& printer, QPrinter::PrinterMode mode) -{ +{ return new PythonQtShell_QPrinter(printer, mode); } bool PythonQtWrapper_QPrinter::abort(QPrinter* theWrappedObject) @@ -5107,15 +5107,15 @@ int PythonQtWrapper_QPrinter::winPageSize(QPrinter* theWrappedObject) const QPrinterInfo* PythonQtWrapper_QPrinterInfo::new_QPrinterInfo() -{ +{ return new QPrinterInfo(); } QPrinterInfo* PythonQtWrapper_QPrinterInfo::new_QPrinterInfo(const QPrinter& printer) -{ +{ return new QPrinterInfo(printer); } QPrinterInfo* PythonQtWrapper_QPrinterInfo::new_QPrinterInfo(const QPrinterInfo& other) -{ +{ return new QPrinterInfo(other); } QStringList PythonQtWrapper_QPrinterInfo::static_QPrinterInfo_availablePrinterNames() @@ -6427,7 +6427,7 @@ if (_wrapper) { QProgressBar::wheelEvent(event0); } QProgressBar* PythonQtWrapper_QProgressBar::new_QProgressBar(QWidget* parent) -{ +{ return new PythonQtShell_QProgressBar(parent); } const QMetaObject* PythonQtShell_QProgressBar::metaObject() const { @@ -7788,11 +7788,11 @@ if (_wrapper) { QProgressDialog::wheelEvent(event0); } QProgressDialog* PythonQtWrapper_QProgressDialog::new_QProgressDialog(QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QProgressDialog(parent, flags); } QProgressDialog* PythonQtWrapper_QProgressDialog::new_QProgressDialog(const QString& labelText, const QString& cancelButtonText, int minimum, int maximum, QWidget* parent, Qt::WindowFlags flags) -{ +{ return new PythonQtShell_QProgressDialog(labelText, cancelButtonText, minimum, maximum, parent, flags); } const QMetaObject* PythonQtShell_QProgressDialog::metaObject() const { @@ -8666,11 +8666,11 @@ if (_wrapper) { QProxyStyle::unpolish(widget0); } QProxyStyle* PythonQtWrapper_QProxyStyle::new_QProxyStyle(QStyle* style) -{ +{ return new PythonQtShell_QProxyStyle(style); } QProxyStyle* PythonQtWrapper_QProxyStyle::new_QProxyStyle(const QString& key) -{ +{ return new PythonQtShell_QProxyStyle(key); } const QMetaObject* PythonQtShell_QProxyStyle::metaObject() const { @@ -9929,15 +9929,15 @@ if (_wrapper) { QPushButton::wheelEvent(event0); } QPushButton* PythonQtWrapper_QPushButton::new_QPushButton(QWidget* parent) -{ +{ return new PythonQtShell_QPushButton(parent); } QPushButton* PythonQtWrapper_QPushButton::new_QPushButton(const QIcon& icon, const QString& text, QWidget* parent) -{ +{ return new PythonQtShell_QPushButton(icon, text, parent); } QPushButton* PythonQtWrapper_QPushButton::new_QPushButton(const QString& text, QWidget* parent) -{ +{ return new PythonQtShell_QPushButton(text, parent); } const QMetaObject* PythonQtShell_QPushButton::metaObject() const { @@ -10011,19 +10011,19 @@ QSize PythonQtWrapper_QPushButton::sizeHint(QPushButton* theWrappedObject) cons QQuaternion* PythonQtWrapper_QQuaternion::new_QQuaternion() -{ +{ return new QQuaternion(); } QQuaternion* PythonQtWrapper_QQuaternion::new_QQuaternion(const QVector4D& vector) -{ +{ return new QQuaternion(vector); } QQuaternion* PythonQtWrapper_QQuaternion::new_QQuaternion(float scalar, const QVector3D& vector) -{ +{ return new QQuaternion(scalar, vector); } QQuaternion* PythonQtWrapper_QQuaternion::new_QQuaternion(float scalar, float xpos, float ypos, float zpos) -{ +{ return new QQuaternion(scalar, xpos, ypos, zpos); } QQuaternion PythonQtWrapper_QQuaternion::conjugate(QQuaternion* theWrappedObject) const @@ -10296,31 +10296,31 @@ QString PythonQtWrapper_QQuaternion::py_toString(QQuaternion* obj) { QRadialGradient* PythonQtWrapper_QRadialGradient::new_QRadialGradient() -{ +{ return new QRadialGradient(); } QRadialGradient* PythonQtWrapper_QRadialGradient::new_QRadialGradient(const QPointF& center, qreal centerRadius, const QPointF& focalPoint, qreal focalRadius) -{ +{ return new QRadialGradient(center, centerRadius, focalPoint, focalRadius); } QRadialGradient* PythonQtWrapper_QRadialGradient::new_QRadialGradient(const QPointF& center, qreal radius) -{ +{ return new QRadialGradient(center, radius); } QRadialGradient* PythonQtWrapper_QRadialGradient::new_QRadialGradient(const QPointF& center, qreal radius, const QPointF& focalPoint) -{ +{ return new QRadialGradient(center, radius, focalPoint); } QRadialGradient* PythonQtWrapper_QRadialGradient::new_QRadialGradient(qreal cx, qreal cy, qreal centerRadius, qreal fx, qreal fy, qreal focalRadius) -{ +{ return new QRadialGradient(cx, cy, centerRadius, fx, fy, focalRadius); } QRadialGradient* PythonQtWrapper_QRadialGradient::new_QRadialGradient(qreal cx, qreal cy, qreal radius) -{ +{ return new QRadialGradient(cx, cy, radius); } QRadialGradient* PythonQtWrapper_QRadialGradient::new_QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qreal fy) -{ +{ return new QRadialGradient(cx, cy, radius, fx, fy); } QPointF PythonQtWrapper_QRadialGradient::center(QRadialGradient* theWrappedObject) const @@ -11611,11 +11611,11 @@ if (_wrapper) { QRadioButton::wheelEvent(event0); } QRadioButton* PythonQtWrapper_QRadioButton::new_QRadioButton(QWidget* parent) -{ +{ return new PythonQtShell_QRadioButton(parent); } QRadioButton* PythonQtWrapper_QRadioButton::new_QRadioButton(const QString& text, QWidget* parent) -{ +{ return new PythonQtShell_QRadioButton(text, parent); } const QMetaObject* PythonQtShell_QRadioButton::metaObject() const { @@ -12478,7 +12478,7 @@ if (_wrapper) { QRasterWindow::wheelEvent(arg__1); } QRasterWindow* PythonQtWrapper_QRasterWindow::new_QRasterWindow(QWindow* parent) -{ +{ return new PythonQtShell_QRasterWindow(parent); } const QMetaObject* PythonQtShell_QRasterWindow::metaObject() const { @@ -12497,19 +12497,19 @@ int PythonQtShell_QRasterWindow::qt_metacall(QMetaObject::Call call, int id, voi QRawFont* PythonQtWrapper_QRawFont::new_QRawFont() -{ +{ return new QRawFont(); } QRawFont* PythonQtWrapper_QRawFont::new_QRawFont(const QByteArray& fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) -{ +{ return new QRawFont(fontData, pixelSize, hintingPreference); } QRawFont* PythonQtWrapper_QRawFont::new_QRawFont(const QRawFont& other) -{ +{ return new QRawFont(other); } QRawFont* PythonQtWrapper_QRawFont::new_QRawFont(const QString& fileName, qreal pixelSize, QFont::HintingPreference hintingPreference) -{ +{ return new QRawFont(fileName, pixelSize, hintingPreference); } QVector PythonQtWrapper_QRawFont::advancesForGlyphIndexes(QRawFont* theWrappedObject, const QVector& glyphIndexes) const @@ -12896,11 +12896,11 @@ if (_wrapper) { return QRegExpValidator::validate(input0, pos1); } QRegExpValidator* PythonQtWrapper_QRegExpValidator::new_QRegExpValidator(QObject* parent) -{ +{ return new PythonQtShell_QRegExpValidator(parent); } QRegExpValidator* PythonQtWrapper_QRegExpValidator::new_QRegExpValidator(const QRegExp& rx, QObject* parent) -{ +{ return new PythonQtShell_QRegExpValidator(rx, parent); } const QMetaObject* PythonQtShell_QRegExpValidator::metaObject() const { @@ -13120,11 +13120,11 @@ if (_wrapper) { return QRegularExpressionValidator::validate(input0, pos1); } QRegularExpressionValidator* PythonQtWrapper_QRegularExpressionValidator::new_QRegularExpressionValidator(QObject* parent) -{ +{ return new PythonQtShell_QRegularExpressionValidator(parent); } QRegularExpressionValidator* PythonQtWrapper_QRegularExpressionValidator::new_QRegularExpressionValidator(const QRegularExpression& re, QObject* parent) -{ +{ return new PythonQtShell_QRegularExpressionValidator(re, parent); } const QMetaObject* PythonQtShell_QRegularExpressionValidator::metaObject() const { @@ -13152,7 +13152,7 @@ PythonQtShell_QResizeEvent::~PythonQtShell_QResizeEvent() { if (priv) { priv->shellClassDeleted(this); } } QResizeEvent* PythonQtWrapper_QResizeEvent::new_QResizeEvent(const QSize& size, const QSize& oldSize) -{ +{ return new PythonQtShell_QResizeEvent(size, oldSize); } const QSize* PythonQtWrapper_QResizeEvent::oldSize(QResizeEvent* theWrappedObject) const @@ -13168,7 +13168,7 @@ const QSize* PythonQtWrapper_QResizeEvent::size(QResizeEvent* theWrappedObject) QRgba64* PythonQtWrapper_QRgba64::new_QRgba64() -{ +{ return new QRgba64(); } unsigned short PythonQtWrapper_QRgba64::alpha(QRgba64* theWrappedObject) const @@ -14437,7 +14437,7 @@ if (_wrapper) { QRubberBand::wheelEvent(event0); } QRubberBand* PythonQtWrapper_QRubberBand::new_QRubberBand(QRubberBand::Shape arg__1, QWidget* arg__2) -{ +{ return new PythonQtShell_QRubberBand(arg__1, arg__2); } const QMetaObject* PythonQtShell_QRubberBand::metaObject() const { @@ -14680,7 +14680,7 @@ QString PythonQtWrapper_QScreen::py_toString(QScreen* obj) { QScreenOrientationChangeEvent* PythonQtWrapper_QScreenOrientationChangeEvent::new_QScreenOrientationChangeEvent(QScreen* screen, Qt::ScreenOrientation orientation) -{ +{ return new QScreenOrientationChangeEvent(screen, orientation); } Qt::ScreenOrientation PythonQtWrapper_QScreenOrientationChangeEvent::orientation(QScreenOrientationChangeEvent* theWrappedObject) const @@ -15954,7 +15954,7 @@ if (_wrapper) { QScrollArea::wheelEvent(arg__1); } QScrollArea* PythonQtWrapper_QScrollArea::new_QScrollArea(QWidget* parent) -{ +{ return new PythonQtShell_QScrollArea(parent); } const QMetaObject* PythonQtShell_QScrollArea::metaObject() const { @@ -17188,11 +17188,11 @@ if (_wrapper) { QScrollBar::wheelEvent(arg__1); } QScrollBar* PythonQtWrapper_QScrollBar::new_QScrollBar(QWidget* parent) -{ +{ return new PythonQtShell_QScrollBar(parent); } QScrollBar* PythonQtWrapper_QScrollBar::new_QScrollBar(Qt::Orientation arg__1, QWidget* parent) -{ +{ return new PythonQtShell_QScrollBar(arg__1, parent); } const QMetaObject* PythonQtShell_QScrollBar::metaObject() const { @@ -17221,7 +17221,7 @@ QSize PythonQtWrapper_QScrollBar::sizeHint(QScrollBar* theWrappedObject) const QScrollEvent* PythonQtWrapper_QScrollEvent::new_QScrollEvent(const QPointF& contentPos, const QPointF& overshoot, QScrollEvent::ScrollState scrollState) -{ +{ return new QScrollEvent(contentPos, overshoot, scrollState); } QPointF PythonQtWrapper_QScrollEvent::contentPos(QScrollEvent* theWrappedObject) const @@ -17242,7 +17242,7 @@ QScrollEvent::ScrollState PythonQtWrapper_QScrollEvent::scrollState(QScrollEven QScrollPrepareEvent* PythonQtWrapper_QScrollPrepareEvent::new_QScrollPrepareEvent(const QPointF& startPos) -{ +{ return new QScrollPrepareEvent(startPos); } QPointF PythonQtWrapper_QScrollPrepareEvent::contentPos(QScrollPrepareEvent* theWrappedObject) const @@ -17384,11 +17384,11 @@ PythonQtShell_QScrollerProperties::~PythonQtShell_QScrollerProperties() { if (priv) { priv->shellClassDeleted(this); } } QScrollerProperties* PythonQtWrapper_QScrollerProperties::new_QScrollerProperties() -{ +{ return new PythonQtShell_QScrollerProperties(); } QScrollerProperties* PythonQtWrapper_QScrollerProperties::new_QScrollerProperties(const QScrollerProperties& sp) -{ +{ return new PythonQtShell_QScrollerProperties(sp); } bool PythonQtWrapper_QScrollerProperties::__ne__(QScrollerProperties* theWrappedObject, const QScrollerProperties& sp) const diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui8.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui8.cpp index 80479ff53..886ace564 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui8.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui8.cpp @@ -281,11 +281,11 @@ if (_wrapper) { QShortcut::timerEvent(event0); } QShortcut* PythonQtWrapper_QShortcut::new_QShortcut(QWidget* parent) -{ +{ return new PythonQtShell_QShortcut(parent); } QShortcut* PythonQtWrapper_QShortcut::new_QShortcut(const QKeySequence& key, QWidget* parent, const char* member, const char* ambiguousMember, Qt::ShortcutContext shortcutContext) -{ +{ return new PythonQtShell_QShortcut(key, parent, member, ambiguousMember, shortcutContext); } const QMetaObject* PythonQtShell_QShortcut::metaObject() const { @@ -368,7 +368,7 @@ PythonQtShell_QShortcutEvent::~PythonQtShell_QShortcutEvent() { if (priv) { priv->shellClassDeleted(this); } } QShortcutEvent* PythonQtWrapper_QShortcutEvent::new_QShortcutEvent(const QKeySequence& key, int id, bool ambiguous) -{ +{ return new PythonQtShell_QShortcutEvent(key, id, ambiguous); } bool PythonQtWrapper_QShortcutEvent::isAmbiguous(QShortcutEvent* theWrappedObject) const @@ -389,7 +389,7 @@ int PythonQtWrapper_QShortcutEvent::shortcutId(QShortcutEvent* theWrappedObject QShowEvent* PythonQtWrapper_QShowEvent::new_QShowEvent() -{ +{ return new QShowEvent(); } @@ -1543,7 +1543,7 @@ if (_wrapper) { QSizeGrip::wheelEvent(event0); } QSizeGrip* PythonQtWrapper_QSizeGrip::new_QSizeGrip(QWidget* parent) -{ +{ return new PythonQtShell_QSizeGrip(parent); } const QMetaObject* PythonQtShell_QSizeGrip::metaObject() const { @@ -2737,11 +2737,11 @@ if (_wrapper) { QSlider::wheelEvent(e0); } QSlider* PythonQtWrapper_QSlider::new_QSlider(QWidget* parent) -{ +{ return new PythonQtShell_QSlider(parent); } QSlider* PythonQtWrapper_QSlider::new_QSlider(Qt::Orientation orientation, QWidget* parent) -{ +{ return new PythonQtShell_QSlider(orientation, parent); } const QMetaObject* PythonQtShell_QSlider::metaObject() const { @@ -4273,7 +4273,7 @@ if (_wrapper) { QSortFilterProxyModel::timerEvent(event0); } QSortFilterProxyModel* PythonQtWrapper_QSortFilterProxyModel::new_QSortFilterProxyModel(QObject* parent) -{ +{ return new PythonQtShell_QSortFilterProxyModel(parent); } const QMetaObject* PythonQtShell_QSortFilterProxyModel::metaObject() const { @@ -4889,7 +4889,7 @@ if (_wrapper) { return QSpacerItem::widget(); } QSpacerItem* PythonQtWrapper_QSpacerItem::new_QSpacerItem(int w, int h, QSizePolicy::Policy hData, QSizePolicy::Policy vData) -{ +{ return new PythonQtShell_QSpacerItem(w, h, hData, vData); } void PythonQtWrapper_QSpacerItem::changeSize(QSpacerItem* theWrappedObject, int w, int h, QSizePolicy::Policy hData, QSizePolicy::Policy vData) @@ -6251,7 +6251,7 @@ if (_wrapper) { QSpinBox::wheelEvent(event0); } QSpinBox* PythonQtWrapper_QSpinBox::new_QSpinBox(QWidget* parent) -{ +{ return new PythonQtShell_QSpinBox(parent); } const QMetaObject* PythonQtShell_QSpinBox::metaObject() const { @@ -7535,15 +7535,15 @@ if (_wrapper) { QSplashScreen::wheelEvent(event0); } QSplashScreen* PythonQtWrapper_QSplashScreen::new_QSplashScreen(QScreen* screen, const QPixmap& pixmap, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QSplashScreen(screen, pixmap, f); } QSplashScreen* PythonQtWrapper_QSplashScreen::new_QSplashScreen(QWidget* parent, const QPixmap& pixmap, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QSplashScreen(parent, pixmap, f); } QSplashScreen* PythonQtWrapper_QSplashScreen::new_QSplashScreen(const QPixmap& pixmap, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QSplashScreen(pixmap, f); } const QMetaObject* PythonQtShell_QSplashScreen::metaObject() const { @@ -8768,11 +8768,11 @@ if (_wrapper) { QSplitter::wheelEvent(event0); } QSplitter* PythonQtWrapper_QSplitter::new_QSplitter(QWidget* parent) -{ +{ return new PythonQtShell_QSplitter(parent); } QSplitter* PythonQtWrapper_QSplitter::new_QSplitter(Qt::Orientation arg__1, QWidget* parent) -{ +{ return new PythonQtShell_QSplitter(arg__1, parent); } const QMetaObject* PythonQtShell_QSplitter::metaObject() const { @@ -10089,7 +10089,7 @@ if (_wrapper) { QSplitterHandle::wheelEvent(event0); } QSplitterHandle* PythonQtWrapper_QSplitterHandle::new_QSplitterHandle(Qt::Orientation o, QSplitter* parent) -{ +{ return new PythonQtShell_QSplitterHandle(o, parent); } const QMetaObject* PythonQtShell_QSplitterHandle::metaObject() const { @@ -10873,15 +10873,15 @@ if (_wrapper) { QStackedLayout::timerEvent(event0); } QStackedLayout* PythonQtWrapper_QStackedLayout::new_QStackedLayout() -{ +{ return new PythonQtShell_QStackedLayout(); } QStackedLayout* PythonQtWrapper_QStackedLayout::new_QStackedLayout(QLayout* parentLayout) -{ +{ return new PythonQtShell_QStackedLayout(parentLayout); } QStackedLayout* PythonQtWrapper_QStackedLayout::new_QStackedLayout(QWidget* parent) -{ +{ return new PythonQtShell_QStackedLayout(parent); } const QMetaObject* PythonQtShell_QStackedLayout::metaObject() const { @@ -12083,7 +12083,7 @@ if (_wrapper) { QStackedWidget::wheelEvent(event0); } QStackedWidget* PythonQtWrapper_QStackedWidget::new_QStackedWidget(QWidget* parent) -{ +{ return new PythonQtShell_QStackedWidget(parent); } const QMetaObject* PythonQtShell_QStackedWidget::metaObject() const { @@ -12311,23 +12311,23 @@ if (_wrapper) { QStandardItem::write(out0); } QStandardItem* PythonQtWrapper_QStandardItem::new_QStandardItem() -{ +{ return new PythonQtShell_QStandardItem(); } QStandardItem* PythonQtWrapper_QStandardItem::new_QStandardItem(const QIcon& icon, const QString& text) -{ +{ return new PythonQtShell_QStandardItem(icon, text); } QStandardItem* PythonQtWrapper_QStandardItem::new_QStandardItem(const QStandardItem& other) -{ +{ return new PythonQtShell_QStandardItem(other); } QStandardItem* PythonQtWrapper_QStandardItem::new_QStandardItem(const QString& text) -{ +{ return new PythonQtShell_QStandardItem(text); } QStandardItem* PythonQtWrapper_QStandardItem::new_QStandardItem(int rows, int columns) -{ +{ return new PythonQtShell_QStandardItem(rows, columns); } QString PythonQtWrapper_QStandardItem::accessibleDescription(QStandardItem* theWrappedObject) const @@ -13993,11 +13993,11 @@ if (_wrapper) { QStandardItemModel::timerEvent(event0); } QStandardItemModel* PythonQtWrapper_QStandardItemModel::new_QStandardItemModel(QObject* parent) -{ +{ return new PythonQtShell_QStandardItemModel(parent); } QStandardItemModel* PythonQtWrapper_QStandardItemModel::new_QStandardItemModel(int rows, int columns, QObject* parent) -{ +{ return new PythonQtShell_QStandardItemModel(rows, columns, parent); } const QMetaObject* PythonQtShell_QStandardItemModel::metaObject() const { @@ -14181,15 +14181,15 @@ QStandardItem* PythonQtWrapper_QStandardItemModel::verticalHeaderItem(QStandard QStaticText* PythonQtWrapper_QStaticText::new_QStaticText() -{ +{ return new QStaticText(); } QStaticText* PythonQtWrapper_QStaticText::new_QStaticText(const QStaticText& other) -{ +{ return new QStaticText(other); } QStaticText* PythonQtWrapper_QStaticText::new_QStaticText(const QString& text) -{ +{ return new QStaticText(text); } bool PythonQtWrapper_QStaticText::__ne__(QStaticText* theWrappedObject, const QStaticText& arg__1) const @@ -15423,7 +15423,7 @@ if (_wrapper) { QStatusBar::wheelEvent(event0); } QStatusBar* PythonQtWrapper_QStatusBar::new_QStatusBar(QWidget* parent) -{ +{ return new PythonQtShell_QStatusBar(parent); } const QMetaObject* PythonQtShell_QStatusBar::metaObject() const { @@ -15492,7 +15492,7 @@ void PythonQtWrapper_QStatusBar::setSizeGripEnabled(QStatusBar* theWrappedObject QStatusTipEvent* PythonQtWrapper_QStatusTipEvent::new_QStatusTipEvent(const QString& tip) -{ +{ return new QStatusTipEvent(tip); } QString PythonQtWrapper_QStatusTipEvent::tip(QStatusTipEvent* theWrappedObject) const @@ -16629,11 +16629,11 @@ if (_wrapper) { QStringListModel::timerEvent(event0); } QStringListModel* PythonQtWrapper_QStringListModel::new_QStringListModel(QObject* parent) -{ +{ return new PythonQtShell_QStringListModel(parent); } QStringListModel* PythonQtWrapper_QStringListModel::new_QStringListModel(const QStringList& strings, QObject* parent) -{ +{ return new PythonQtShell_QStringListModel(strings, parent); } const QMetaObject* PythonQtShell_QStringListModel::metaObject() const { @@ -16818,7 +16818,7 @@ PythonQtShell_QStyleFactory::~PythonQtShell_QStyleFactory() { if (priv) { priv->shellClassDeleted(this); } } QStyleFactory* PythonQtWrapper_QStyleFactory::new_QStyleFactory() -{ +{ return new PythonQtShell_QStyleFactory(); } QStyle* PythonQtWrapper_QStyleFactory::static_QStyleFactory_create(const QString& arg__1) @@ -16838,7 +16838,7 @@ PythonQtShell_QStyleHintReturn::~PythonQtShell_QStyleHintReturn() { if (priv) { priv->shellClassDeleted(this); } } QStyleHintReturn* PythonQtWrapper_QStyleHintReturn::new_QStyleHintReturn(int version, int type) -{ +{ return new PythonQtShell_QStyleHintReturn(version, type); } @@ -16848,7 +16848,7 @@ PythonQtShell_QStyleHintReturnMask::~PythonQtShell_QStyleHintReturnMask() { if (priv) { priv->shellClassDeleted(this); } } QStyleHintReturnMask* PythonQtWrapper_QStyleHintReturnMask::new_QStyleHintReturnMask() -{ +{ return new PythonQtShell_QStyleHintReturnMask(); } @@ -16858,7 +16858,7 @@ PythonQtShell_QStyleHintReturnVariant::~PythonQtShell_QStyleHintReturnVariant() if (priv) { priv->shellClassDeleted(this); } } QStyleHintReturnVariant* PythonQtWrapper_QStyleHintReturnVariant::new_QStyleHintReturnVariant() -{ +{ return new PythonQtShell_QStyleHintReturnVariant(); } @@ -17040,11 +17040,11 @@ PythonQtShell_QStyleOption::~PythonQtShell_QStyleOption() { if (priv) { priv->shellClassDeleted(this); } } QStyleOption* PythonQtWrapper_QStyleOption::new_QStyleOption(const QStyleOption& other) -{ +{ return new PythonQtShell_QStyleOption(other); } QStyleOption* PythonQtWrapper_QStyleOption::new_QStyleOption(int version, int type) -{ +{ return new PythonQtShell_QStyleOption(version, type); } void PythonQtWrapper_QStyleOption::initFrom(QStyleOption* theWrappedObject, const QWidget* w) @@ -17066,15 +17066,15 @@ PythonQtShell_QStyleOptionButton::~PythonQtShell_QStyleOptionButton() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionButton* PythonQtWrapper_QStyleOptionButton::new_QStyleOptionButton() -{ +{ return new PythonQtShell_QStyleOptionButton(); } QStyleOptionButton* PythonQtWrapper_QStyleOptionButton::new_QStyleOptionButton(const QStyleOptionButton& other) -{ +{ return new PythonQtShell_QStyleOptionButton(other); } QStyleOptionButton* PythonQtWrapper_QStyleOptionButton::new_QStyleOptionButton(int version) -{ +{ return new PythonQtShell_QStyleOptionButton(version); } QStyleOptionButton* PythonQtWrapper_QStyleOptionButton::operator_assign(QStyleOptionButton* theWrappedObject, const QStyleOptionButton& arg__1) @@ -17089,15 +17089,15 @@ PythonQtShell_QStyleOptionComboBox::~PythonQtShell_QStyleOptionComboBox() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionComboBox* PythonQtWrapper_QStyleOptionComboBox::new_QStyleOptionComboBox() -{ +{ return new PythonQtShell_QStyleOptionComboBox(); } QStyleOptionComboBox* PythonQtWrapper_QStyleOptionComboBox::new_QStyleOptionComboBox(const QStyleOptionComboBox& other) -{ +{ return new PythonQtShell_QStyleOptionComboBox(other); } QStyleOptionComboBox* PythonQtWrapper_QStyleOptionComboBox::new_QStyleOptionComboBox(int version) -{ +{ return new PythonQtShell_QStyleOptionComboBox(version); } QStyleOptionComboBox* PythonQtWrapper_QStyleOptionComboBox::operator_assign(QStyleOptionComboBox* theWrappedObject, const QStyleOptionComboBox& arg__1) @@ -17112,15 +17112,15 @@ PythonQtShell_QStyleOptionDockWidget::~PythonQtShell_QStyleOptionDockWidget() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionDockWidget* PythonQtWrapper_QStyleOptionDockWidget::new_QStyleOptionDockWidget() -{ +{ return new PythonQtShell_QStyleOptionDockWidget(); } QStyleOptionDockWidget* PythonQtWrapper_QStyleOptionDockWidget::new_QStyleOptionDockWidget(const QStyleOptionDockWidget& other) -{ +{ return new PythonQtShell_QStyleOptionDockWidget(other); } QStyleOptionDockWidget* PythonQtWrapper_QStyleOptionDockWidget::new_QStyleOptionDockWidget(int version) -{ +{ return new PythonQtShell_QStyleOptionDockWidget(version); } QStyleOptionDockWidget* PythonQtWrapper_QStyleOptionDockWidget::operator_assign(QStyleOptionDockWidget* theWrappedObject, const QStyleOptionDockWidget& arg__1) diff --git a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui9.cpp b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui9.cpp index fc2e44ca8..2b169c50d 100644 --- a/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui9.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui/com_trolltech_qt_gui9.cpp @@ -12,7 +12,7 @@ PythonQtShell_QStyleOptionDockWidgetV2::~PythonQtShell_QStyleOptionDockWidgetV2( if (priv) { priv->shellClassDeleted(this); } } QStyleOptionDockWidgetV2* PythonQtWrapper_QStyleOptionDockWidgetV2::new_QStyleOptionDockWidgetV2() -{ +{ return new PythonQtShell_QStyleOptionDockWidgetV2(); } @@ -22,15 +22,15 @@ PythonQtShell_QStyleOptionFocusRect::~PythonQtShell_QStyleOptionFocusRect() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionFocusRect* PythonQtWrapper_QStyleOptionFocusRect::new_QStyleOptionFocusRect() -{ +{ return new PythonQtShell_QStyleOptionFocusRect(); } QStyleOptionFocusRect* PythonQtWrapper_QStyleOptionFocusRect::new_QStyleOptionFocusRect(const QStyleOptionFocusRect& other) -{ +{ return new PythonQtShell_QStyleOptionFocusRect(other); } QStyleOptionFocusRect* PythonQtWrapper_QStyleOptionFocusRect::new_QStyleOptionFocusRect(int version) -{ +{ return new PythonQtShell_QStyleOptionFocusRect(version); } QStyleOptionFocusRect* PythonQtWrapper_QStyleOptionFocusRect::operator_assign(QStyleOptionFocusRect* theWrappedObject, const QStyleOptionFocusRect& arg__1) @@ -45,15 +45,15 @@ PythonQtShell_QStyleOptionFrame::~PythonQtShell_QStyleOptionFrame() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionFrame* PythonQtWrapper_QStyleOptionFrame::new_QStyleOptionFrame() -{ +{ return new PythonQtShell_QStyleOptionFrame(); } QStyleOptionFrame* PythonQtWrapper_QStyleOptionFrame::new_QStyleOptionFrame(const QStyleOptionFrame& other) -{ +{ return new PythonQtShell_QStyleOptionFrame(other); } QStyleOptionFrame* PythonQtWrapper_QStyleOptionFrame::new_QStyleOptionFrame(int version) -{ +{ return new PythonQtShell_QStyleOptionFrame(version); } QStyleOptionFrame* PythonQtWrapper_QStyleOptionFrame::operator_assign(QStyleOptionFrame* theWrappedObject, const QStyleOptionFrame& arg__1) @@ -68,7 +68,7 @@ PythonQtShell_QStyleOptionFrameV2::~PythonQtShell_QStyleOptionFrameV2() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionFrameV2* PythonQtWrapper_QStyleOptionFrameV2::new_QStyleOptionFrameV2() -{ +{ return new PythonQtShell_QStyleOptionFrameV2(); } @@ -78,7 +78,7 @@ PythonQtShell_QStyleOptionFrameV3::~PythonQtShell_QStyleOptionFrameV3() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionFrameV3* PythonQtWrapper_QStyleOptionFrameV3::new_QStyleOptionFrameV3() -{ +{ return new PythonQtShell_QStyleOptionFrameV3(); } @@ -88,15 +88,15 @@ PythonQtShell_QStyleOptionGraphicsItem::~PythonQtShell_QStyleOptionGraphicsItem( if (priv) { priv->shellClassDeleted(this); } } QStyleOptionGraphicsItem* PythonQtWrapper_QStyleOptionGraphicsItem::new_QStyleOptionGraphicsItem() -{ +{ return new PythonQtShell_QStyleOptionGraphicsItem(); } QStyleOptionGraphicsItem* PythonQtWrapper_QStyleOptionGraphicsItem::new_QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem& other) -{ +{ return new PythonQtShell_QStyleOptionGraphicsItem(other); } QStyleOptionGraphicsItem* PythonQtWrapper_QStyleOptionGraphicsItem::new_QStyleOptionGraphicsItem(int version) -{ +{ return new PythonQtShell_QStyleOptionGraphicsItem(version); } qreal PythonQtWrapper_QStyleOptionGraphicsItem::static_QStyleOptionGraphicsItem_levelOfDetailFromTransform(const QTransform& worldTransform) @@ -116,15 +116,15 @@ PythonQtShell_QStyleOptionGroupBox::~PythonQtShell_QStyleOptionGroupBox() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionGroupBox* PythonQtWrapper_QStyleOptionGroupBox::new_QStyleOptionGroupBox() -{ +{ return new PythonQtShell_QStyleOptionGroupBox(); } QStyleOptionGroupBox* PythonQtWrapper_QStyleOptionGroupBox::new_QStyleOptionGroupBox(const QStyleOptionGroupBox& other) -{ +{ return new PythonQtShell_QStyleOptionGroupBox(other); } QStyleOptionGroupBox* PythonQtWrapper_QStyleOptionGroupBox::new_QStyleOptionGroupBox(int version) -{ +{ return new PythonQtShell_QStyleOptionGroupBox(version); } QStyleOptionGroupBox* PythonQtWrapper_QStyleOptionGroupBox::operator_assign(QStyleOptionGroupBox* theWrappedObject, const QStyleOptionGroupBox& arg__1) @@ -139,15 +139,15 @@ PythonQtShell_QStyleOptionHeader::~PythonQtShell_QStyleOptionHeader() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionHeader* PythonQtWrapper_QStyleOptionHeader::new_QStyleOptionHeader() -{ +{ return new PythonQtShell_QStyleOptionHeader(); } QStyleOptionHeader* PythonQtWrapper_QStyleOptionHeader::new_QStyleOptionHeader(const QStyleOptionHeader& other) -{ +{ return new PythonQtShell_QStyleOptionHeader(other); } QStyleOptionHeader* PythonQtWrapper_QStyleOptionHeader::new_QStyleOptionHeader(int version) -{ +{ return new PythonQtShell_QStyleOptionHeader(version); } QStyleOptionHeader* PythonQtWrapper_QStyleOptionHeader::operator_assign(QStyleOptionHeader* theWrappedObject, const QStyleOptionHeader& arg__1) @@ -162,15 +162,15 @@ PythonQtShell_QStyleOptionMenuItem::~PythonQtShell_QStyleOptionMenuItem() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionMenuItem* PythonQtWrapper_QStyleOptionMenuItem::new_QStyleOptionMenuItem() -{ +{ return new PythonQtShell_QStyleOptionMenuItem(); } QStyleOptionMenuItem* PythonQtWrapper_QStyleOptionMenuItem::new_QStyleOptionMenuItem(const QStyleOptionMenuItem& other) -{ +{ return new PythonQtShell_QStyleOptionMenuItem(other); } QStyleOptionMenuItem* PythonQtWrapper_QStyleOptionMenuItem::new_QStyleOptionMenuItem(int version) -{ +{ return new PythonQtShell_QStyleOptionMenuItem(version); } QStyleOptionMenuItem* PythonQtWrapper_QStyleOptionMenuItem::operator_assign(QStyleOptionMenuItem* theWrappedObject, const QStyleOptionMenuItem& arg__1) @@ -185,15 +185,15 @@ PythonQtShell_QStyleOptionProgressBar::~PythonQtShell_QStyleOptionProgressBar() if (priv) { priv->shellClassDeleted(this); } } QStyleOptionProgressBar* PythonQtWrapper_QStyleOptionProgressBar::new_QStyleOptionProgressBar() -{ +{ return new PythonQtShell_QStyleOptionProgressBar(); } QStyleOptionProgressBar* PythonQtWrapper_QStyleOptionProgressBar::new_QStyleOptionProgressBar(const QStyleOptionProgressBar& other) -{ +{ return new PythonQtShell_QStyleOptionProgressBar(other); } QStyleOptionProgressBar* PythonQtWrapper_QStyleOptionProgressBar::new_QStyleOptionProgressBar(int version) -{ +{ return new PythonQtShell_QStyleOptionProgressBar(version); } QStyleOptionProgressBar* PythonQtWrapper_QStyleOptionProgressBar::operator_assign(QStyleOptionProgressBar* theWrappedObject, const QStyleOptionProgressBar& arg__1) @@ -208,7 +208,7 @@ PythonQtShell_QStyleOptionProgressBarV2::~PythonQtShell_QStyleOptionProgressBarV if (priv) { priv->shellClassDeleted(this); } } QStyleOptionProgressBarV2* PythonQtWrapper_QStyleOptionProgressBarV2::new_QStyleOptionProgressBarV2() -{ +{ return new PythonQtShell_QStyleOptionProgressBarV2(); } @@ -218,15 +218,15 @@ PythonQtShell_QStyleOptionRubberBand::~PythonQtShell_QStyleOptionRubberBand() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionRubberBand* PythonQtWrapper_QStyleOptionRubberBand::new_QStyleOptionRubberBand() -{ +{ return new PythonQtShell_QStyleOptionRubberBand(); } QStyleOptionRubberBand* PythonQtWrapper_QStyleOptionRubberBand::new_QStyleOptionRubberBand(const QStyleOptionRubberBand& other) -{ +{ return new PythonQtShell_QStyleOptionRubberBand(other); } QStyleOptionRubberBand* PythonQtWrapper_QStyleOptionRubberBand::new_QStyleOptionRubberBand(int version) -{ +{ return new PythonQtShell_QStyleOptionRubberBand(version); } QStyleOptionRubberBand* PythonQtWrapper_QStyleOptionRubberBand::operator_assign(QStyleOptionRubberBand* theWrappedObject, const QStyleOptionRubberBand& arg__1) @@ -241,15 +241,15 @@ PythonQtShell_QStyleOptionSizeGrip::~PythonQtShell_QStyleOptionSizeGrip() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionSizeGrip* PythonQtWrapper_QStyleOptionSizeGrip::new_QStyleOptionSizeGrip() -{ +{ return new PythonQtShell_QStyleOptionSizeGrip(); } QStyleOptionSizeGrip* PythonQtWrapper_QStyleOptionSizeGrip::new_QStyleOptionSizeGrip(const QStyleOptionSizeGrip& other) -{ +{ return new PythonQtShell_QStyleOptionSizeGrip(other); } QStyleOptionSizeGrip* PythonQtWrapper_QStyleOptionSizeGrip::new_QStyleOptionSizeGrip(int version) -{ +{ return new PythonQtShell_QStyleOptionSizeGrip(version); } QStyleOptionSizeGrip* PythonQtWrapper_QStyleOptionSizeGrip::operator_assign(QStyleOptionSizeGrip* theWrappedObject, const QStyleOptionSizeGrip& arg__1) @@ -264,15 +264,15 @@ PythonQtShell_QStyleOptionSlider::~PythonQtShell_QStyleOptionSlider() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionSlider* PythonQtWrapper_QStyleOptionSlider::new_QStyleOptionSlider() -{ +{ return new PythonQtShell_QStyleOptionSlider(); } QStyleOptionSlider* PythonQtWrapper_QStyleOptionSlider::new_QStyleOptionSlider(const QStyleOptionSlider& other) -{ +{ return new PythonQtShell_QStyleOptionSlider(other); } QStyleOptionSlider* PythonQtWrapper_QStyleOptionSlider::new_QStyleOptionSlider(int version) -{ +{ return new PythonQtShell_QStyleOptionSlider(version); } QStyleOptionSlider* PythonQtWrapper_QStyleOptionSlider::operator_assign(QStyleOptionSlider* theWrappedObject, const QStyleOptionSlider& arg__1) @@ -287,15 +287,15 @@ PythonQtShell_QStyleOptionSpinBox::~PythonQtShell_QStyleOptionSpinBox() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionSpinBox* PythonQtWrapper_QStyleOptionSpinBox::new_QStyleOptionSpinBox() -{ +{ return new PythonQtShell_QStyleOptionSpinBox(); } QStyleOptionSpinBox* PythonQtWrapper_QStyleOptionSpinBox::new_QStyleOptionSpinBox(const QStyleOptionSpinBox& other) -{ +{ return new PythonQtShell_QStyleOptionSpinBox(other); } QStyleOptionSpinBox* PythonQtWrapper_QStyleOptionSpinBox::new_QStyleOptionSpinBox(int version) -{ +{ return new PythonQtShell_QStyleOptionSpinBox(version); } QStyleOptionSpinBox* PythonQtWrapper_QStyleOptionSpinBox::operator_assign(QStyleOptionSpinBox* theWrappedObject, const QStyleOptionSpinBox& arg__1) @@ -310,15 +310,15 @@ PythonQtShell_QStyleOptionTab::~PythonQtShell_QStyleOptionTab() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionTab* PythonQtWrapper_QStyleOptionTab::new_QStyleOptionTab() -{ +{ return new PythonQtShell_QStyleOptionTab(); } QStyleOptionTab* PythonQtWrapper_QStyleOptionTab::new_QStyleOptionTab(const QStyleOptionTab& other) -{ +{ return new PythonQtShell_QStyleOptionTab(other); } QStyleOptionTab* PythonQtWrapper_QStyleOptionTab::new_QStyleOptionTab(int version) -{ +{ return new PythonQtShell_QStyleOptionTab(version); } QStyleOptionTab* PythonQtWrapper_QStyleOptionTab::operator_assign(QStyleOptionTab* theWrappedObject, const QStyleOptionTab& arg__1) @@ -333,15 +333,15 @@ PythonQtShell_QStyleOptionTabBarBase::~PythonQtShell_QStyleOptionTabBarBase() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionTabBarBase* PythonQtWrapper_QStyleOptionTabBarBase::new_QStyleOptionTabBarBase() -{ +{ return new PythonQtShell_QStyleOptionTabBarBase(); } QStyleOptionTabBarBase* PythonQtWrapper_QStyleOptionTabBarBase::new_QStyleOptionTabBarBase(const QStyleOptionTabBarBase& other) -{ +{ return new PythonQtShell_QStyleOptionTabBarBase(other); } QStyleOptionTabBarBase* PythonQtWrapper_QStyleOptionTabBarBase::new_QStyleOptionTabBarBase(int version) -{ +{ return new PythonQtShell_QStyleOptionTabBarBase(version); } QStyleOptionTabBarBase* PythonQtWrapper_QStyleOptionTabBarBase::operator_assign(QStyleOptionTabBarBase* theWrappedObject, const QStyleOptionTabBarBase& arg__1) @@ -356,7 +356,7 @@ PythonQtShell_QStyleOptionTabBarBaseV2::~PythonQtShell_QStyleOptionTabBarBaseV2( if (priv) { priv->shellClassDeleted(this); } } QStyleOptionTabBarBaseV2* PythonQtWrapper_QStyleOptionTabBarBaseV2::new_QStyleOptionTabBarBaseV2() -{ +{ return new PythonQtShell_QStyleOptionTabBarBaseV2(); } @@ -366,7 +366,7 @@ PythonQtShell_QStyleOptionTabV2::~PythonQtShell_QStyleOptionTabV2() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionTabV2* PythonQtWrapper_QStyleOptionTabV2::new_QStyleOptionTabV2() -{ +{ return new PythonQtShell_QStyleOptionTabV2(); } @@ -376,7 +376,7 @@ PythonQtShell_QStyleOptionTabV3::~PythonQtShell_QStyleOptionTabV3() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionTabV3* PythonQtWrapper_QStyleOptionTabV3::new_QStyleOptionTabV3() -{ +{ return new PythonQtShell_QStyleOptionTabV3(); } @@ -386,15 +386,15 @@ PythonQtShell_QStyleOptionTabWidgetFrame::~PythonQtShell_QStyleOptionTabWidgetFr if (priv) { priv->shellClassDeleted(this); } } QStyleOptionTabWidgetFrame* PythonQtWrapper_QStyleOptionTabWidgetFrame::new_QStyleOptionTabWidgetFrame() -{ +{ return new PythonQtShell_QStyleOptionTabWidgetFrame(); } QStyleOptionTabWidgetFrame* PythonQtWrapper_QStyleOptionTabWidgetFrame::new_QStyleOptionTabWidgetFrame(const QStyleOptionTabWidgetFrame& other) -{ +{ return new PythonQtShell_QStyleOptionTabWidgetFrame(other); } QStyleOptionTabWidgetFrame* PythonQtWrapper_QStyleOptionTabWidgetFrame::new_QStyleOptionTabWidgetFrame(int version) -{ +{ return new PythonQtShell_QStyleOptionTabWidgetFrame(version); } QStyleOptionTabWidgetFrame* PythonQtWrapper_QStyleOptionTabWidgetFrame::operator_assign(QStyleOptionTabWidgetFrame* theWrappedObject, const QStyleOptionTabWidgetFrame& arg__1) @@ -409,7 +409,7 @@ PythonQtShell_QStyleOptionTabWidgetFrameV2::~PythonQtShell_QStyleOptionTabWidget if (priv) { priv->shellClassDeleted(this); } } QStyleOptionTabWidgetFrameV2* PythonQtWrapper_QStyleOptionTabWidgetFrameV2::new_QStyleOptionTabWidgetFrameV2() -{ +{ return new PythonQtShell_QStyleOptionTabWidgetFrameV2(); } @@ -419,15 +419,15 @@ PythonQtShell_QStyleOptionTitleBar::~PythonQtShell_QStyleOptionTitleBar() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionTitleBar* PythonQtWrapper_QStyleOptionTitleBar::new_QStyleOptionTitleBar() -{ +{ return new PythonQtShell_QStyleOptionTitleBar(); } QStyleOptionTitleBar* PythonQtWrapper_QStyleOptionTitleBar::new_QStyleOptionTitleBar(const QStyleOptionTitleBar& other) -{ +{ return new PythonQtShell_QStyleOptionTitleBar(other); } QStyleOptionTitleBar* PythonQtWrapper_QStyleOptionTitleBar::new_QStyleOptionTitleBar(int version) -{ +{ return new PythonQtShell_QStyleOptionTitleBar(version); } QStyleOptionTitleBar* PythonQtWrapper_QStyleOptionTitleBar::operator_assign(QStyleOptionTitleBar* theWrappedObject, const QStyleOptionTitleBar& arg__1) @@ -442,15 +442,15 @@ PythonQtShell_QStyleOptionToolBar::~PythonQtShell_QStyleOptionToolBar() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionToolBar* PythonQtWrapper_QStyleOptionToolBar::new_QStyleOptionToolBar() -{ +{ return new PythonQtShell_QStyleOptionToolBar(); } QStyleOptionToolBar* PythonQtWrapper_QStyleOptionToolBar::new_QStyleOptionToolBar(const QStyleOptionToolBar& other) -{ +{ return new PythonQtShell_QStyleOptionToolBar(other); } QStyleOptionToolBar* PythonQtWrapper_QStyleOptionToolBar::new_QStyleOptionToolBar(int version) -{ +{ return new PythonQtShell_QStyleOptionToolBar(version); } QStyleOptionToolBar* PythonQtWrapper_QStyleOptionToolBar::operator_assign(QStyleOptionToolBar* theWrappedObject, const QStyleOptionToolBar& arg__1) @@ -465,15 +465,15 @@ PythonQtShell_QStyleOptionToolBox::~PythonQtShell_QStyleOptionToolBox() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionToolBox* PythonQtWrapper_QStyleOptionToolBox::new_QStyleOptionToolBox() -{ +{ return new PythonQtShell_QStyleOptionToolBox(); } QStyleOptionToolBox* PythonQtWrapper_QStyleOptionToolBox::new_QStyleOptionToolBox(const QStyleOptionToolBox& other) -{ +{ return new PythonQtShell_QStyleOptionToolBox(other); } QStyleOptionToolBox* PythonQtWrapper_QStyleOptionToolBox::new_QStyleOptionToolBox(int version) -{ +{ return new PythonQtShell_QStyleOptionToolBox(version); } QStyleOptionToolBox* PythonQtWrapper_QStyleOptionToolBox::operator_assign(QStyleOptionToolBox* theWrappedObject, const QStyleOptionToolBox& arg__1) @@ -488,7 +488,7 @@ PythonQtShell_QStyleOptionToolBoxV2::~PythonQtShell_QStyleOptionToolBoxV2() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionToolBoxV2* PythonQtWrapper_QStyleOptionToolBoxV2::new_QStyleOptionToolBoxV2() -{ +{ return new PythonQtShell_QStyleOptionToolBoxV2(); } @@ -498,15 +498,15 @@ PythonQtShell_QStyleOptionToolButton::~PythonQtShell_QStyleOptionToolButton() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionToolButton* PythonQtWrapper_QStyleOptionToolButton::new_QStyleOptionToolButton() -{ +{ return new PythonQtShell_QStyleOptionToolButton(); } QStyleOptionToolButton* PythonQtWrapper_QStyleOptionToolButton::new_QStyleOptionToolButton(const QStyleOptionToolButton& other) -{ +{ return new PythonQtShell_QStyleOptionToolButton(other); } QStyleOptionToolButton* PythonQtWrapper_QStyleOptionToolButton::new_QStyleOptionToolButton(int version) -{ +{ return new PythonQtShell_QStyleOptionToolButton(version); } QStyleOptionToolButton* PythonQtWrapper_QStyleOptionToolButton::operator_assign(QStyleOptionToolButton* theWrappedObject, const QStyleOptionToolButton& arg__1) @@ -521,15 +521,15 @@ PythonQtShell_QStyleOptionViewItem::~PythonQtShell_QStyleOptionViewItem() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionViewItem* PythonQtWrapper_QStyleOptionViewItem::new_QStyleOptionViewItem() -{ +{ return new PythonQtShell_QStyleOptionViewItem(); } QStyleOptionViewItem* PythonQtWrapper_QStyleOptionViewItem::new_QStyleOptionViewItem(const QStyleOptionViewItem& other) -{ +{ return new PythonQtShell_QStyleOptionViewItem(other); } QStyleOptionViewItem* PythonQtWrapper_QStyleOptionViewItem::new_QStyleOptionViewItem(int version) -{ +{ return new PythonQtShell_QStyleOptionViewItem(version); } QStyleOptionViewItem* PythonQtWrapper_QStyleOptionViewItem::operator_assign(QStyleOptionViewItem* theWrappedObject, const QStyleOptionViewItem& arg__1) @@ -544,7 +544,7 @@ PythonQtShell_QStyleOptionViewItemV2::~PythonQtShell_QStyleOptionViewItemV2() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionViewItemV2* PythonQtWrapper_QStyleOptionViewItemV2::new_QStyleOptionViewItemV2() -{ +{ return new PythonQtShell_QStyleOptionViewItemV2(); } @@ -554,7 +554,7 @@ PythonQtShell_QStyleOptionViewItemV3::~PythonQtShell_QStyleOptionViewItemV3() { if (priv) { priv->shellClassDeleted(this); } } QStyleOptionViewItemV3* PythonQtWrapper_QStyleOptionViewItemV3::new_QStyleOptionViewItemV3() -{ +{ return new PythonQtShell_QStyleOptionViewItemV3(); } diff --git a/generated_cpp_515/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.cpp b/generated_cpp_515/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.cpp index ff4d679fe..6e77b88db 100644 --- a/generated_cpp_515/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.cpp +++ b/generated_cpp_515/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.cpp @@ -245,27 +245,27 @@ if (_wrapper) { return QBitmap::sharedPainter(); } QBitmap* PythonQtWrapper_QBitmap::new_QBitmap() -{ +{ return new PythonQtShell_QBitmap(); } QBitmap* PythonQtWrapper_QBitmap::new_QBitmap(const QBitmap& other) -{ +{ return new PythonQtShell_QBitmap(other); } QBitmap* PythonQtWrapper_QBitmap::new_QBitmap(const QPixmap& arg__1) -{ +{ return new PythonQtShell_QBitmap(arg__1); } QBitmap* PythonQtWrapper_QBitmap::new_QBitmap(const QSize& arg__1) -{ +{ return new PythonQtShell_QBitmap(arg__1); } QBitmap* PythonQtWrapper_QBitmap::new_QBitmap(const QString& fileName, const char* format) -{ +{ return new PythonQtShell_QBitmap(fileName, format); } QBitmap* PythonQtWrapper_QBitmap::new_QBitmap(int w, int h) -{ +{ return new PythonQtShell_QBitmap(w, h); } void PythonQtWrapper_QBitmap::clear(QBitmap* theWrappedObject) @@ -301,39 +301,39 @@ QBitmap PythonQtWrapper_QBitmap::transformed(QBitmap* theWrappedObject, const Q QBrush* PythonQtWrapper_QBrush::new_QBrush() -{ +{ return new QBrush(); } QBrush* PythonQtWrapper_QBrush::new_QBrush(Qt::BrushStyle bs) -{ +{ return new QBrush(bs); } QBrush* PythonQtWrapper_QBrush::new_QBrush(Qt::GlobalColor color, const QPixmap& pixmap) -{ +{ return new QBrush(color, pixmap); } QBrush* PythonQtWrapper_QBrush::new_QBrush(const QBrush& brush) -{ +{ return new QBrush(brush); } QBrush* PythonQtWrapper_QBrush::new_QBrush(const QColor& color, Qt::BrushStyle bs) -{ +{ return new QBrush(color, bs); } QBrush* PythonQtWrapper_QBrush::new_QBrush(const QColor& color, const QPixmap& pixmap) -{ +{ return new QBrush(color, pixmap); } QBrush* PythonQtWrapper_QBrush::new_QBrush(const QGradient& gradient) -{ +{ return new QBrush(gradient); } QBrush* PythonQtWrapper_QBrush::new_QBrush(const QImage& image) -{ +{ return new QBrush(image); } QBrush* PythonQtWrapper_QBrush::new_QBrush(const QPixmap& pixmap) -{ +{ return new QBrush(pixmap); } const QColor* PythonQtWrapper_QBrush::color(QBrush* theWrappedObject) const @@ -446,31 +446,31 @@ QString PythonQtWrapper_QBrush::py_toString(QBrush* obj) { QColor* PythonQtWrapper_QColor::new_QColor() -{ +{ return new QColor(); } QColor* PythonQtWrapper_QColor::new_QColor(QRgba64 rgba64) -{ +{ return new QColor(rgba64); } QColor* PythonQtWrapper_QColor::new_QColor(Qt::GlobalColor color) -{ +{ return new QColor(color); } QColor* PythonQtWrapper_QColor::new_QColor(const QColor& color) -{ +{ return new QColor(color); } QColor* PythonQtWrapper_QColor::new_QColor(const QString& name) -{ +{ return new QColor(name); } QColor* PythonQtWrapper_QColor::new_QColor(int r, int g, int b, int a) -{ +{ return new QColor(r, g, b, a); } QColor* PythonQtWrapper_QColor::new_QColor(unsigned int rgb) -{ +{ return new QColor(rgb); } int PythonQtWrapper_QColor::alpha(QColor* theWrappedObject) const @@ -928,23 +928,23 @@ QString PythonQtWrapper_QColor::py_toString(QColor* obj) { QCursor* PythonQtWrapper_QCursor::new_QCursor() -{ +{ return new QCursor(); } QCursor* PythonQtWrapper_QCursor::new_QCursor(Qt::CursorShape shape) -{ +{ return new QCursor(shape); } QCursor* PythonQtWrapper_QCursor::new_QCursor(const QBitmap& bitmap, const QBitmap& mask, int hotX, int hotY) -{ +{ return new QCursor(bitmap, mask, hotX, hotY); } QCursor* PythonQtWrapper_QCursor::new_QCursor(const QCursor& cursor) -{ +{ return new QCursor(cursor); } QCursor* PythonQtWrapper_QCursor::new_QCursor(const QPixmap& pixmap, int hotX, int hotY) -{ +{ return new QCursor(pixmap, hotX, hotY); } const QBitmap* PythonQtWrapper_QCursor::bitmap(QCursor* theWrappedObject) const @@ -1042,23 +1042,23 @@ QString PythonQtWrapper_QCursor::py_toString(QCursor* obj) { QFont* PythonQtWrapper_QFont::new_QFont() -{ +{ return new QFont(); } QFont* PythonQtWrapper_QFont::new_QFont(const QFont& font) -{ +{ return new QFont(font); } QFont* PythonQtWrapper_QFont::new_QFont(const QFont& font, QPaintDevice* pd) -{ +{ return new QFont(font, pd); } QFont* PythonQtWrapper_QFont::new_QFont(const QFont& font, const QPaintDevice* pd) -{ +{ return new QFont(font, pd); } QFont* PythonQtWrapper_QFont::new_QFont(const QString& family, int pointSize, int weight, bool italic) -{ +{ return new QFont(family, pointSize, weight, italic); } bool PythonQtWrapper_QFont::bold(QFont* theWrappedObject) const @@ -1440,23 +1440,23 @@ QString PythonQtWrapper_QFont::py_toString(QFont* obj) { return obj->toString(); QIcon* PythonQtWrapper_QIcon::new_QIcon() -{ +{ return new QIcon(); } QIcon* PythonQtWrapper_QIcon::new_QIcon(PythonQtPassOwnershipToCPP engine) -{ +{ return new QIcon(engine); } QIcon* PythonQtWrapper_QIcon::new_QIcon(const QIcon& other) -{ +{ return new QIcon(other); } QIcon* PythonQtWrapper_QIcon::new_QIcon(const QPixmap& pixmap) -{ +{ return new QIcon(pixmap); } QIcon* PythonQtWrapper_QIcon::new_QIcon(const QString& fileName) -{ +{ return new QIcon(fileName); } QSize PythonQtWrapper_QIcon::actualSize(QIcon* theWrappedObject, QWindow* window, const QSize& size, QIcon::Mode mode, QIcon::State state) const @@ -1810,23 +1810,23 @@ if (_wrapper) { return QImage::sharedPainter(); } QImage* PythonQtWrapper_QImage::new_QImage() -{ +{ return new PythonQtShell_QImage(); } QImage* PythonQtWrapper_QImage::new_QImage(const QImage& arg__1) -{ +{ return new PythonQtShell_QImage(arg__1); } QImage* PythonQtWrapper_QImage::new_QImage(const QSize& size, QImage::Format format) -{ +{ return new PythonQtShell_QImage(size, format); } QImage* PythonQtWrapper_QImage::new_QImage(const QString& fileName, const char* format) -{ +{ return new PythonQtShell_QImage(fileName, format); } QImage* PythonQtWrapper_QImage::new_QImage(int width, int height, QImage::Format format) -{ +{ return new PythonQtShell_QImage(width, height, format); } bool PythonQtWrapper_QImage::allGray(QImage* theWrappedObject) const @@ -2309,23 +2309,23 @@ QString PythonQtWrapper_QImage::py_toString(QImage* obj) { QKeySequence* PythonQtWrapper_QKeySequence::new_QKeySequence() -{ +{ return new QKeySequence(); } QKeySequence* PythonQtWrapper_QKeySequence::new_QKeySequence(QKeySequence::StandardKey key) -{ +{ return new QKeySequence(key); } QKeySequence* PythonQtWrapper_QKeySequence::new_QKeySequence(const QKeySequence& ks) -{ +{ return new QKeySequence(ks); } QKeySequence* PythonQtWrapper_QKeySequence::new_QKeySequence(const QString& key, QKeySequence::SequenceFormat format) -{ +{ return new QKeySequence(key, format); } QKeySequence* PythonQtWrapper_QKeySequence::new_QKeySequence(int k1, int k2, int k3, int k4) -{ +{ return new QKeySequence(k1, k2, k3, k4); } int PythonQtWrapper_QKeySequence::count(QKeySequence* theWrappedObject) const @@ -2427,27 +2427,27 @@ QString PythonQtWrapper_QKeySequence::py_toString(QKeySequence* obj) { return ob QMatrix4x4* PythonQtWrapper_QMatrix4x4::new_QMatrix4x4() -{ +{ return new QMatrix4x4(); } QMatrix4x4* PythonQtWrapper_QMatrix4x4::new_QMatrix4x4(const QMatrix& matrix) -{ +{ return new QMatrix4x4(matrix); } QMatrix4x4* PythonQtWrapper_QMatrix4x4::new_QMatrix4x4(const QTransform& transform) -{ +{ return new QMatrix4x4(transform); } QMatrix4x4* PythonQtWrapper_QMatrix4x4::new_QMatrix4x4(const float* values) -{ +{ return new QMatrix4x4(values); } QMatrix4x4* PythonQtWrapper_QMatrix4x4::new_QMatrix4x4(const float* values, int cols, int rows) -{ +{ return new QMatrix4x4(values, cols, rows); } QMatrix4x4* PythonQtWrapper_QMatrix4x4::new_QMatrix4x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44) -{ +{ return new QMatrix4x4(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44); } QVector4D PythonQtWrapper_QMatrix4x4::column(QMatrix4x4* theWrappedObject, int index) const @@ -2775,27 +2775,27 @@ QString PythonQtWrapper_QMatrix4x4::py_toString(QMatrix4x4* obj) { QPalette* PythonQtWrapper_QPalette::new_QPalette() -{ +{ return new QPalette(); } QPalette* PythonQtWrapper_QPalette::new_QPalette(Qt::GlobalColor button) -{ +{ return new QPalette(button); } QPalette* PythonQtWrapper_QPalette::new_QPalette(const QBrush& windowText, const QBrush& button, const QBrush& light, const QBrush& dark, const QBrush& mid, const QBrush& text, const QBrush& bright_text, const QBrush& base, const QBrush& window) -{ +{ return new QPalette(windowText, button, light, dark, mid, text, bright_text, base, window); } QPalette* PythonQtWrapper_QPalette::new_QPalette(const QColor& button) -{ +{ return new QPalette(button); } QPalette* PythonQtWrapper_QPalette::new_QPalette(const QColor& button, const QColor& window) -{ +{ return new QPalette(button, window); } QPalette* PythonQtWrapper_QPalette::new_QPalette(const QPalette& palette) -{ +{ return new QPalette(palette); } const QBrush* PythonQtWrapper_QPalette::alternateBase(QPalette* theWrappedObject) const @@ -3023,23 +3023,23 @@ QString PythonQtWrapper_QPalette::py_toString(QPalette* obj) { QPen* PythonQtWrapper_QPen::new_QPen() -{ +{ return new QPen(); } QPen* PythonQtWrapper_QPen::new_QPen(Qt::PenStyle arg__1) -{ +{ return new QPen(arg__1); } QPen* PythonQtWrapper_QPen::new_QPen(const QBrush& brush, qreal width, Qt::PenStyle s, Qt::PenCapStyle c, Qt::PenJoinStyle j) -{ +{ return new QPen(brush, width, s, c, j); } QPen* PythonQtWrapper_QPen::new_QPen(const QColor& color) -{ +{ return new QPen(color); } QPen* PythonQtWrapper_QPen::new_QPen(const QPen& pen) -{ +{ return new QPen(pen); } QBrush PythonQtWrapper_QPen::brush(QPen* theWrappedObject) const @@ -3383,23 +3383,23 @@ if (_wrapper) { return QPixmap::sharedPainter(); } QPixmap* PythonQtWrapper_QPixmap::new_QPixmap() -{ +{ return new PythonQtShell_QPixmap(); } QPixmap* PythonQtWrapper_QPixmap::new_QPixmap(const QPixmap& arg__1) -{ +{ return new PythonQtShell_QPixmap(arg__1); } QPixmap* PythonQtWrapper_QPixmap::new_QPixmap(const QSize& arg__1) -{ +{ return new PythonQtShell_QPixmap(arg__1); } QPixmap* PythonQtWrapper_QPixmap::new_QPixmap(const QString& fileName, const char* format, Qt::ImageConversionFlags flags) -{ +{ return new PythonQtShell_QPixmap(fileName, format, flags); } QPixmap* PythonQtWrapper_QPixmap::new_QPixmap(int w, int h) -{ +{ return new PythonQtShell_QPixmap(w, h); } qint64 PythonQtWrapper_QPixmap::cacheKey(QPixmap* theWrappedObject) const @@ -3642,23 +3642,23 @@ QString PythonQtWrapper_QPixmap::py_toString(QPixmap* obj) { QPolygon* PythonQtWrapper_QPolygon::new_QPolygon() -{ +{ return new QPolygon(); } QPolygon* PythonQtWrapper_QPolygon::new_QPolygon(const QPolygon& other) -{ +{ return new QPolygon(other); } QPolygon* PythonQtWrapper_QPolygon::new_QPolygon(const QRect& r, bool closed) -{ +{ return new QPolygon(r, closed); } QPolygon* PythonQtWrapper_QPolygon::new_QPolygon(const QVector& v) -{ +{ return new QPolygon(v); } QPolygon* PythonQtWrapper_QPolygon::new_QPolygon(int size) -{ +{ return new QPolygon(size); } void PythonQtWrapper_QPolygon::append(QPolygon* theWrappedObject, const QPoint& t) @@ -4011,27 +4011,27 @@ QString PythonQtWrapper_QPolygon::py_toString(QPolygon* obj) { QRegion* PythonQtWrapper_QRegion::new_QRegion() -{ +{ return new QRegion(); } QRegion* PythonQtWrapper_QRegion::new_QRegion(const QBitmap& bitmap) -{ +{ return new QRegion(bitmap); } QRegion* PythonQtWrapper_QRegion::new_QRegion(const QPolygon& pa, Qt::FillRule fillRule) -{ +{ return new QRegion(pa, fillRule); } QRegion* PythonQtWrapper_QRegion::new_QRegion(const QRect& r, QRegion::RegionType t) -{ +{ return new QRegion(r, t); } QRegion* PythonQtWrapper_QRegion::new_QRegion(const QRegion& region) -{ +{ return new QRegion(region); } QRegion* PythonQtWrapper_QRegion::new_QRegion(int x, int y, int w, int h, QRegion::RegionType t) -{ +{ return new QRegion(x, y, w, h, t); } const QRect* PythonQtWrapper_QRegion::begin(QRegion* theWrappedObject) const @@ -4209,11 +4209,11 @@ QString PythonQtWrapper_QRegion::py_toString(QRegion* obj) { QSizePolicy* PythonQtWrapper_QSizePolicy::new_QSizePolicy() -{ +{ return new QSizePolicy(); } QSizePolicy* PythonQtWrapper_QSizePolicy::new_QSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical, QSizePolicy::ControlType type) -{ +{ return new QSizePolicy(horizontal, vertical, type); } QSizePolicy::ControlType PythonQtWrapper_QSizePolicy::controlType(QSizePolicy* theWrappedObject) const @@ -4341,15 +4341,15 @@ QString PythonQtWrapper_QSizePolicy::py_toString(QSizePolicy* obj) { QTextFormat* PythonQtWrapper_QTextFormat::new_QTextFormat() -{ +{ return new QTextFormat(); } QTextFormat* PythonQtWrapper_QTextFormat::new_QTextFormat(const QTextFormat& rhs) -{ +{ return new QTextFormat(rhs); } QTextFormat* PythonQtWrapper_QTextFormat::new_QTextFormat(int type) -{ +{ return new QTextFormat(type); } QBrush PythonQtWrapper_QTextFormat::background(QTextFormat* theWrappedObject) const @@ -4617,11 +4617,11 @@ QString PythonQtWrapper_QTextFormat::py_toString(QTextFormat* obj) { QTextLength* PythonQtWrapper_QTextLength::new_QTextLength() -{ +{ return new QTextLength(); } QTextLength* PythonQtWrapper_QTextLength::new_QTextLength(QTextLength::Type type, qreal value) -{ +{ return new QTextLength(type, value); } bool PythonQtWrapper_QTextLength::__ne__(QTextLength* theWrappedObject, const QTextLength& other) const @@ -4669,23 +4669,23 @@ QString PythonQtWrapper_QTextLength::py_toString(QTextLength* obj) { QTransform* PythonQtWrapper_QTransform::new_QTransform() -{ +{ return new QTransform(); } QTransform* PythonQtWrapper_QTransform::new_QTransform(const QMatrix& mtx) -{ +{ return new QTransform(mtx); } QTransform* PythonQtWrapper_QTransform::new_QTransform(const QTransform& other) -{ +{ return new QTransform(other); } QTransform* PythonQtWrapper_QTransform::new_QTransform(qreal h11, qreal h12, qreal h13, qreal h21, qreal h22, qreal h23, qreal h31, qreal h32, qreal h33) -{ +{ return new QTransform(h11, h12, h13, h21, h22, h23, h31, h32, h33); } QTransform* PythonQtWrapper_QTransform::new_QTransform(qreal h11, qreal h12, qreal h21, qreal h22, qreal dx, qreal dy) -{ +{ return new QTransform(h11, h12, h21, h22, dx, dy); } QTransform PythonQtWrapper_QTransform::adjoint(QTransform* theWrappedObject) const diff --git a/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia0.cpp b/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia0.cpp index 7cbaa834c..fe58f2f49 100644 --- a/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia0.cpp +++ b/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia0.cpp @@ -469,7 +469,7 @@ if (_wrapper) { QAbstractAudioDeviceInfo::timerEvent(event0); } QAbstractAudioDeviceInfo* PythonQtWrapper_QAbstractAudioDeviceInfo::new_QAbstractAudioDeviceInfo() -{ +{ return new PythonQtShell_QAbstractAudioDeviceInfo(); } const QMetaObject* PythonQtShell_QAbstractAudioDeviceInfo::metaObject() const { @@ -930,7 +930,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioInput::resume() { @@ -952,7 +952,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioInput::setBufferSize(int value0) { @@ -974,7 +974,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioInput::setFormat(const QAudioFormat& fmt0) { @@ -996,7 +996,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioInput::setNotifyInterval(int milliSeconds0) { @@ -1018,7 +1018,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioInput::setVolume(qreal arg__1) { @@ -1040,7 +1040,7 @@ if (_wrapper) { } } } - + } QIODevice* PythonQtShell_QAbstractAudioInput::start() { @@ -1095,7 +1095,7 @@ if (_wrapper) { } } } - + } QAudio::State PythonQtShell_QAbstractAudioInput::state() const { @@ -1150,7 +1150,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioInput::suspend() { @@ -1172,7 +1172,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioInput::timerEvent(QTimerEvent* event0) { @@ -1230,7 +1230,7 @@ if (_wrapper) { return qreal(); } QAbstractAudioInput* PythonQtWrapper_QAbstractAudioInput::new_QAbstractAudioInput() -{ +{ return new PythonQtShell_QAbstractAudioInput(); } const QMetaObject* PythonQtShell_QAbstractAudioInput::metaObject() const { @@ -1779,7 +1779,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioOutput::resume() { @@ -1801,7 +1801,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioOutput::setBufferSize(int value0) { @@ -1823,7 +1823,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioOutput::setCategory(const QString& arg__1) { @@ -1867,7 +1867,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioOutput::setNotifyInterval(int milliSeconds0) { @@ -1889,7 +1889,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioOutput::setVolume(qreal arg__1) { @@ -1966,7 +1966,7 @@ if (_wrapper) { } } } - + } QAudio::State PythonQtShell_QAbstractAudioOutput::state() const { @@ -2021,7 +2021,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioOutput::suspend() { @@ -2043,7 +2043,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractAudioOutput::timerEvent(QTimerEvent* event0) { @@ -2101,7 +2101,7 @@ if (_wrapper) { return QAbstractAudioOutput::volume(); } QAbstractAudioOutput* PythonQtWrapper_QAbstractAudioOutput::new_QAbstractAudioOutput() -{ +{ return new PythonQtShell_QAbstractAudioOutput(); } const QMetaObject* PythonQtShell_QAbstractAudioOutput::metaObject() const { @@ -2374,10 +2374,10 @@ if (_wrapper) { } } } - + } QAbstractVideoBuffer* PythonQtWrapper_QAbstractVideoBuffer::new_QAbstractVideoBuffer(QAbstractVideoBuffer::HandleType type) -{ +{ return new PythonQtShell_QAbstractVideoBuffer(type); } QVariant PythonQtWrapper_QAbstractVideoBuffer::handle(QAbstractVideoBuffer* theWrappedObject) const @@ -2736,7 +2736,7 @@ if (_wrapper) { QAbstractVideoSurface::timerEvent(event0); } QAbstractVideoSurface* PythonQtWrapper_QAbstractVideoSurface::new_QAbstractVideoSurface(QObject* parent) -{ +{ return new PythonQtShell_QAbstractVideoSurface(parent); } const QMetaObject* PythonQtShell_QAbstractVideoSurface::metaObject() const { @@ -2822,19 +2822,19 @@ qreal PythonQtWrapper_QAudio::static_QAudio_convertVolume(qreal volume, QAudio QAudioBuffer* PythonQtWrapper_QAudioBuffer::new_QAudioBuffer() -{ +{ return new QAudioBuffer(); } QAudioBuffer* PythonQtWrapper_QAudioBuffer::new_QAudioBuffer(const QAudioBuffer& other) -{ +{ return new QAudioBuffer(other); } QAudioBuffer* PythonQtWrapper_QAudioBuffer::new_QAudioBuffer(const QByteArray& data, const QAudioFormat& format, qint64 startTime) -{ +{ return new QAudioBuffer(data, format, startTime); } QAudioBuffer* PythonQtWrapper_QAudioBuffer::new_QAudioBuffer(int numFrames, const QAudioFormat& format, qint64 startTime) -{ +{ return new QAudioBuffer(numFrames, format, startTime); } int PythonQtWrapper_QAudioBuffer::byteCount(QAudioBuffer* theWrappedObject) const @@ -3185,7 +3185,7 @@ if (_wrapper) { QAudioDecoder::unbind(arg__1); } QAudioDecoder* PythonQtWrapper_QAudioDecoder::new_QAudioDecoder(QObject* parent) -{ +{ return new PythonQtShell_QAudioDecoder(parent); } const QMetaObject* PythonQtShell_QAudioDecoder::metaObject() const { @@ -3572,7 +3572,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAudioDecoderControl::setSourceDevice(QIODevice* device0) { @@ -3594,7 +3594,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAudioDecoderControl::setSourceFilename(const QString& fileName0) { @@ -3616,7 +3616,7 @@ if (_wrapper) { } } } - + } QIODevice* PythonQtShell_QAudioDecoderControl::sourceDevice() const { @@ -3704,7 +3704,7 @@ if (_wrapper) { } } } - + } QAudioDecoder::State PythonQtShell_QAudioDecoderControl::state() const { @@ -3759,7 +3759,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAudioDecoderControl::timerEvent(QTimerEvent* event0) { @@ -3784,7 +3784,7 @@ if (_wrapper) { QAudioDecoderControl::timerEvent(event0); } QAudioDecoderControl* PythonQtWrapper_QAudioDecoderControl::new_QAudioDecoderControl(QObject* parent) -{ +{ return new PythonQtShell_QAudioDecoderControl(parent); } const QMetaObject* PythonQtShell_QAudioDecoderControl::metaObject() const { @@ -3868,11 +3868,11 @@ void PythonQtWrapper_QAudioDecoderControl::stop(QAudioDecoderControl* theWrapped QAudioDeviceInfo* PythonQtWrapper_QAudioDeviceInfo::new_QAudioDeviceInfo() -{ +{ return new QAudioDeviceInfo(); } QAudioDeviceInfo* PythonQtWrapper_QAudioDeviceInfo::new_QAudioDeviceInfo(const QAudioDeviceInfo& other) -{ +{ return new QAudioDeviceInfo(other); } QList PythonQtWrapper_QAudioDeviceInfo::static_QAudioDeviceInfo_availableDevices(QAudio::Mode mode) @@ -3968,11 +3968,11 @@ QList PythonQtWrapper_QAudioDeviceInfo::supportedSam QAudioEncoderSettings* PythonQtWrapper_QAudioEncoderSettings::new_QAudioEncoderSettings() -{ +{ return new QAudioEncoderSettings(); } QAudioEncoderSettings* PythonQtWrapper_QAudioEncoderSettings::new_QAudioEncoderSettings(const QAudioEncoderSettings& other) -{ +{ return new QAudioEncoderSettings(other); } int PythonQtWrapper_QAudioEncoderSettings::bitRate(QAudioEncoderSettings* theWrappedObject) const @@ -4277,7 +4277,7 @@ if (_wrapper) { } } } - + } QStringList PythonQtShell_QAudioEncoderSettingsControl::supportedAudioCodecs() const { @@ -4368,7 +4368,7 @@ if (_wrapper) { QAudioEncoderSettingsControl::timerEvent(event0); } QAudioEncoderSettingsControl* PythonQtWrapper_QAudioEncoderSettingsControl::new_QAudioEncoderSettingsControl(QObject* parent) -{ +{ return new PythonQtShell_QAudioEncoderSettingsControl(parent); } const QMetaObject* PythonQtShell_QAudioEncoderSettingsControl::metaObject() const { @@ -4412,11 +4412,11 @@ QList PythonQtWrapper_QAudioEncoderSettingsControl::supportedSampleRates( QAudioFormat* PythonQtWrapper_QAudioFormat::new_QAudioFormat() -{ +{ return new QAudioFormat(); } QAudioFormat* PythonQtWrapper_QAudioFormat::new_QAudioFormat(const QAudioFormat& other) -{ +{ return new QAudioFormat(other); } QAudioFormat::Endian PythonQtWrapper_QAudioFormat::byteOrder(QAudioFormat* theWrappedObject) const @@ -4680,11 +4680,11 @@ if (_wrapper) { QAudioInput::timerEvent(event0); } QAudioInput* PythonQtWrapper_QAudioInput::new_QAudioInput(const QAudioDeviceInfo& audioDeviceInfo, const QAudioFormat& format, QObject* parent) -{ +{ return new PythonQtShell_QAudioInput(audioDeviceInfo, format, parent); } QAudioInput* PythonQtWrapper_QAudioInput::new_QAudioInput(const QAudioFormat& format, QObject* parent) -{ +{ return new PythonQtShell_QAudioInput(format, parent); } const QMetaObject* PythonQtShell_QAudioInput::metaObject() const { @@ -5063,7 +5063,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAudioInputSelectorControl::timerEvent(QTimerEvent* event0) { @@ -5088,7 +5088,7 @@ if (_wrapper) { QAudioInputSelectorControl::timerEvent(event0); } QAudioInputSelectorControl* PythonQtWrapper_QAudioInputSelectorControl::new_QAudioInputSelectorControl(QObject* parent) -{ +{ return new PythonQtShell_QAudioInputSelectorControl(parent); } const QMetaObject* PythonQtShell_QAudioInputSelectorControl::metaObject() const { @@ -5263,11 +5263,11 @@ if (_wrapper) { QAudioOutput::timerEvent(event0); } QAudioOutput* PythonQtWrapper_QAudioOutput::new_QAudioOutput(const QAudioDeviceInfo& audioDeviceInfo, const QAudioFormat& format, QObject* parent) -{ +{ return new PythonQtShell_QAudioOutput(audioDeviceInfo, format, parent); } QAudioOutput* PythonQtWrapper_QAudioOutput::new_QAudioOutput(const QAudioFormat& format, QObject* parent) -{ +{ return new PythonQtShell_QAudioOutput(format, parent); } const QMetaObject* PythonQtShell_QAudioOutput::metaObject() const { @@ -5656,7 +5656,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAudioOutputSelectorControl::timerEvent(QTimerEvent* event0) { @@ -5681,7 +5681,7 @@ if (_wrapper) { QAudioOutputSelectorControl::timerEvent(event0); } QAudioOutputSelectorControl* PythonQtWrapper_QAudioOutputSelectorControl::new_QAudioOutputSelectorControl(QObject* parent) -{ +{ return new PythonQtShell_QAudioOutputSelectorControl(parent); } const QMetaObject* PythonQtShell_QAudioOutputSelectorControl::metaObject() const { @@ -5856,7 +5856,7 @@ if (_wrapper) { QAudioProbe::timerEvent(event0); } QAudioProbe* PythonQtWrapper_QAudioProbe::new_QAudioProbe(QObject* parent) -{ +{ return new PythonQtShell_QAudioProbe(parent); } const QMetaObject* PythonQtShell_QAudioProbe::metaObject() const { @@ -6092,7 +6092,7 @@ if (_wrapper) { QAudioRecorder::timerEvent(event0); } QAudioRecorder* PythonQtWrapper_QAudioRecorder::new_QAudioRecorder(QObject* parent) -{ +{ return new PythonQtShell_QAudioRecorder(parent); } const QMetaObject* PythonQtShell_QAudioRecorder::metaObject() const { @@ -6297,7 +6297,7 @@ if (_wrapper) { } } } - + } QList PythonQtShell_QAudioRoleControl::supportedAudioRoles() const { @@ -6355,7 +6355,7 @@ if (_wrapper) { QAudioRoleControl::timerEvent(event0); } QAudioRoleControl* PythonQtWrapper_QAudioRoleControl::new_QAudioRoleControl(QObject* parent) -{ +{ return new PythonQtShell_QAudioRoleControl(parent); } const QMetaObject* PythonQtShell_QAudioRoleControl::metaObject() const { @@ -6525,7 +6525,7 @@ if (_wrapper) { return nullptr; } QAudioSystemFactoryInterface* PythonQtWrapper_QAudioSystemFactoryInterface::new_QAudioSystemFactoryInterface() -{ +{ return new PythonQtShell_QAudioSystemFactoryInterface(); } QList PythonQtWrapper_QAudioSystemFactoryInterface::availableDevices(QAudioSystemFactoryInterface* theWrappedObject, QAudio::Mode arg__1) const @@ -6687,7 +6687,7 @@ if (_wrapper) { return nullptr; } QAudioSystemPlugin* PythonQtWrapper_QAudioSystemPlugin::new_QAudioSystemPlugin(QObject* parent) -{ +{ return new PythonQtShell_QAudioSystemPlugin(parent); } const QMetaObject* PythonQtShell_QAudioSystemPlugin::metaObject() const { @@ -7016,19 +7016,19 @@ if (_wrapper) { QCamera::unbind(arg__1); } QCamera* PythonQtWrapper_QCamera::new_QCamera(QCamera::Position position, QObject* parent) -{ +{ return new PythonQtShell_QCamera(position, parent); } QCamera* PythonQtWrapper_QCamera::new_QCamera(QObject* parent) -{ +{ return new PythonQtShell_QCamera(parent); } QCamera* PythonQtWrapper_QCamera::new_QCamera(const QByteArray& deviceName, QObject* parent) -{ +{ return new PythonQtShell_QCamera(deviceName, parent); } QCamera* PythonQtWrapper_QCamera::new_QCamera(const QCameraInfo& cameraInfo, QObject* parent) -{ +{ return new PythonQtShell_QCamera(cameraInfo, parent); } const QMetaObject* PythonQtShell_QCamera::metaObject() const { @@ -7333,7 +7333,7 @@ if (_wrapper) { } } } - + } QList PythonQtShell_QCameraCaptureBufferFormatControl::supportedBufferFormats() const { @@ -7391,7 +7391,7 @@ if (_wrapper) { QCameraCaptureBufferFormatControl::timerEvent(event0); } QCameraCaptureBufferFormatControl* PythonQtWrapper_QCameraCaptureBufferFormatControl::new_QCameraCaptureBufferFormatControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraCaptureBufferFormatControl(parent); } const QMetaObject* PythonQtShell_QCameraCaptureBufferFormatControl::metaObject() const { @@ -7624,7 +7624,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QCameraCaptureDestinationControl::timerEvent(QTimerEvent* event0) { @@ -7649,7 +7649,7 @@ if (_wrapper) { QCameraCaptureDestinationControl::timerEvent(event0); } QCameraCaptureDestinationControl* PythonQtWrapper_QCameraCaptureDestinationControl::new_QCameraCaptureDestinationControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraCaptureDestinationControl(parent); } const QMetaObject* PythonQtShell_QCameraCaptureDestinationControl::metaObject() const { @@ -7915,7 +7915,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QCameraControl::setState(QCamera::State state0) { @@ -7937,7 +7937,7 @@ if (_wrapper) { } } } - + } QCamera::State PythonQtShell_QCameraControl::state() const { @@ -8028,7 +8028,7 @@ if (_wrapper) { QCameraControl::timerEvent(event0); } QCameraControl* PythonQtWrapper_QCameraControl::new_QCameraControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraControl(parent); } const QMetaObject* PythonQtShell_QCameraControl::metaObject() const { @@ -8485,7 +8485,7 @@ if (_wrapper) { QCameraExposureControl::timerEvent(event0); } QCameraExposureControl* PythonQtWrapper_QCameraExposureControl::new_QCameraExposureControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraExposureControl(parent); } const QMetaObject* PythonQtShell_QCameraExposureControl::metaObject() const { @@ -8728,7 +8728,7 @@ if (_wrapper) { } } } - + } bool PythonQtShell_QCameraFeedbackControl::setEventFeedbackEnabled(QCameraFeedbackControl::EventType arg__1, bool arg__2) { @@ -8819,7 +8819,7 @@ if (_wrapper) { QCameraFeedbackControl::timerEvent(event0); } QCameraFeedbackControl* PythonQtWrapper_QCameraFeedbackControl::new_QCameraFeedbackControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraFeedbackControl(parent); } const QMetaObject* PythonQtShell_QCameraFeedbackControl::metaObject() const { @@ -9095,7 +9095,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QCameraFlashControl::timerEvent(QTimerEvent* event0) { @@ -9120,7 +9120,7 @@ if (_wrapper) { QCameraFlashControl::timerEvent(event0); } QCameraFlashControl* PythonQtWrapper_QCameraFlashControl::new_QCameraFlashControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraFlashControl(parent); } const QMetaObject* PythonQtShell_QCameraFlashControl::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia1.cpp b/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia1.cpp index a92e7bf65..059a23e9c 100644 --- a/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia1.cpp +++ b/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia1.cpp @@ -480,7 +480,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QCameraFocusControl::setFocusMode(QCameraFocus::FocusModes mode0) { @@ -502,7 +502,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QCameraFocusControl::setFocusPointMode(QCameraFocus::FocusPointMode mode0) { @@ -524,7 +524,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QCameraFocusControl::timerEvent(QTimerEvent* event0) { @@ -549,7 +549,7 @@ if (_wrapper) { QCameraFocusControl::timerEvent(event0); } QCameraFocusControl* PythonQtWrapper_QCameraFocusControl::new_QCameraFocusControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraFocusControl(parent); } const QMetaObject* PythonQtShell_QCameraFocusControl::metaObject() const { @@ -613,15 +613,15 @@ void PythonQtWrapper_QCameraFocusControl::setFocusPointMode(QCameraFocusControl* QCameraFocusZone* PythonQtWrapper_QCameraFocusZone::new_QCameraFocusZone() -{ +{ return new QCameraFocusZone(); } QCameraFocusZone* PythonQtWrapper_QCameraFocusZone::new_QCameraFocusZone(const QCameraFocusZone& other) -{ +{ return new QCameraFocusZone(other); } QCameraFocusZone* PythonQtWrapper_QCameraFocusZone::new_QCameraFocusZone(const QRectF& area, QCameraFocusZone::FocusZoneStatus status) -{ +{ return new QCameraFocusZone(area, status); } QRectF PythonQtWrapper_QCameraFocusZone::area(QCameraFocusZone* theWrappedObject) const @@ -864,7 +864,7 @@ if (_wrapper) { QCameraImageCapture::timerEvent(event0); } QCameraImageCapture* PythonQtWrapper_QCameraImageCapture::new_QCameraImageCapture(QMediaObject* mediaObject, QObject* parent) -{ +{ return new PythonQtShell_QCameraImageCapture(mediaObject, parent); } const QMetaObject* PythonQtShell_QCameraImageCapture::metaObject() const { @@ -986,7 +986,7 @@ if (_wrapper) { } } } - + } int PythonQtShell_QCameraImageCaptureControl::capture(const QString& fileName0) { @@ -1217,7 +1217,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QCameraImageCaptureControl::timerEvent(QTimerEvent* event0) { @@ -1242,7 +1242,7 @@ if (_wrapper) { QCameraImageCaptureControl::timerEvent(event0); } QCameraImageCaptureControl* PythonQtWrapper_QCameraImageCaptureControl::new_QCameraImageCaptureControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraImageCaptureControl(parent); } const QMetaObject* PythonQtShell_QCameraImageCaptureControl::metaObject() const { @@ -1615,7 +1615,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QCameraImageProcessingControl::timerEvent(QTimerEvent* event0) { @@ -1640,7 +1640,7 @@ if (_wrapper) { QCameraImageProcessingControl::timerEvent(event0); } QCameraImageProcessingControl* PythonQtWrapper_QCameraImageProcessingControl::new_QCameraImageProcessingControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraImageProcessingControl(parent); } const QMetaObject* PythonQtShell_QCameraImageProcessingControl::metaObject() const { @@ -1679,15 +1679,15 @@ void PythonQtWrapper_QCameraImageProcessingControl::setParameter(QCameraImagePro QCameraInfo* PythonQtWrapper_QCameraInfo::new_QCameraInfo(const QByteArray& name) -{ +{ return new QCameraInfo(name); } QCameraInfo* PythonQtWrapper_QCameraInfo::new_QCameraInfo(const QCamera& camera) -{ +{ return new QCameraInfo(camera); } QCameraInfo* PythonQtWrapper_QCameraInfo::new_QCameraInfo(const QCameraInfo& other) -{ +{ return new QCameraInfo(other); } QList PythonQtWrapper_QCameraInfo::static_QCameraInfo_availableCameras(QCamera::Position position) @@ -1952,7 +1952,7 @@ if (_wrapper) { QCameraInfoControl::timerEvent(event0); } QCameraInfoControl* PythonQtWrapper_QCameraInfoControl::new_QCameraInfoControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraInfoControl(parent); } const QMetaObject* PythonQtShell_QCameraInfoControl::metaObject() const { @@ -2147,7 +2147,7 @@ if (_wrapper) { } } } - + } QCamera::LockTypes PythonQtShell_QCameraLocksControl::supportedLocks() const { @@ -2224,10 +2224,10 @@ if (_wrapper) { } } } - + } QCameraLocksControl* PythonQtWrapper_QCameraLocksControl::new_QCameraLocksControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraLocksControl(parent); } const QMetaObject* PythonQtShell_QCameraLocksControl::metaObject() const { @@ -3480,7 +3480,7 @@ if (_wrapper) { QCameraViewfinder::wheelEvent(event0); } QCameraViewfinder* PythonQtWrapper_QCameraViewfinder::new_QCameraViewfinder(QWidget* parent) -{ +{ return new PythonQtShell_QCameraViewfinder(parent); } const QMetaObject* PythonQtShell_QCameraViewfinder::metaObject() const { @@ -3499,11 +3499,11 @@ int PythonQtShell_QCameraViewfinder::qt_metacall(QMetaObject::Call call, int id, QCameraViewfinderSettings* PythonQtWrapper_QCameraViewfinderSettings::new_QCameraViewfinderSettings() -{ +{ return new QCameraViewfinderSettings(); } QCameraViewfinderSettings* PythonQtWrapper_QCameraViewfinderSettings::new_QCameraViewfinderSettings(const QCameraViewfinderSettings& other) -{ +{ return new QCameraViewfinderSettings(other); } bool PythonQtWrapper_QCameraViewfinderSettings::isNull(QCameraViewfinderSettings* theWrappedObject) const @@ -3755,7 +3755,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QCameraViewfinderSettingsControl::timerEvent(QTimerEvent* event0) { @@ -3813,7 +3813,7 @@ if (_wrapper) { return QVariant(); } QCameraViewfinderSettingsControl* PythonQtWrapper_QCameraViewfinderSettingsControl::new_QCameraViewfinderSettingsControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraViewfinderSettingsControl(parent); } const QMetaObject* PythonQtShell_QCameraViewfinderSettingsControl::metaObject() const { @@ -3980,7 +3980,7 @@ if (_wrapper) { } } } - + } QList PythonQtShell_QCameraViewfinderSettingsControl2::supportedViewfinderSettings() const { @@ -4071,7 +4071,7 @@ if (_wrapper) { return QCameraViewfinderSettings(); } QCameraViewfinderSettingsControl2* PythonQtWrapper_QCameraViewfinderSettingsControl2::new_QCameraViewfinderSettingsControl2(QObject* parent) -{ +{ return new PythonQtShell_QCameraViewfinderSettingsControl2(parent); } const QMetaObject* PythonQtShell_QCameraViewfinderSettingsControl2::metaObject() const { @@ -4458,10 +4458,10 @@ if (_wrapper) { } } } - + } QCameraZoomControl* PythonQtWrapper_QCameraZoomControl::new_QCameraZoomControl(QObject* parent) -{ +{ return new PythonQtShell_QCameraZoomControl(parent); } const QMetaObject* PythonQtShell_QCameraZoomControl::metaObject() const { @@ -4519,11 +4519,11 @@ PythonQtShell_QCamera__FrameRateRange::~PythonQtShell_QCamera__FrameRateRange() if (priv) { priv->shellClassDeleted(this); } } QCamera::FrameRateRange* PythonQtWrapper_QCamera__FrameRateRange::new_QCamera__FrameRateRange() -{ +{ return new PythonQtShell_QCamera__FrameRateRange(); } QCamera::FrameRateRange* PythonQtWrapper_QCamera__FrameRateRange::new_QCamera__FrameRateRange(qreal minimum, qreal maximum) -{ +{ return new PythonQtShell_QCamera__FrameRateRange(minimum, maximum); } bool PythonQtWrapper_QCamera__FrameRateRange::__ne__(QCamera::FrameRateRange* theWrappedObject, const QCamera::FrameRateRange& r2) @@ -5174,7 +5174,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -5668,7 +5668,7 @@ if (_wrapper) { QGraphicsVideoItem::wheelEvent(event0); } QGraphicsVideoItem* PythonQtWrapper_QGraphicsVideoItem::new_QGraphicsVideoItem(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsVideoItem(parent); } const QMetaObject* PythonQtShell_QGraphicsVideoItem::metaObject() const { @@ -5926,7 +5926,7 @@ if (_wrapper) { } } } - + } QStringList PythonQtShell_QImageEncoderControl::supportedImageCodecs() const { @@ -6017,7 +6017,7 @@ if (_wrapper) { QImageEncoderControl::timerEvent(event0); } QImageEncoderControl* PythonQtWrapper_QImageEncoderControl::new_QImageEncoderControl(QObject* parent) -{ +{ return new PythonQtShell_QImageEncoderControl(parent); } const QMetaObject* PythonQtShell_QImageEncoderControl::metaObject() const { @@ -6061,11 +6061,11 @@ QList PythonQtWrapper_QImageEncoderControl::supportedResolutions(QImage QImageEncoderSettings* PythonQtWrapper_QImageEncoderSettings::new_QImageEncoderSettings() -{ +{ return new QImageEncoderSettings(); } QImageEncoderSettings* PythonQtWrapper_QImageEncoderSettings::new_QImageEncoderSettings(const QImageEncoderSettings& other) -{ +{ return new QImageEncoderSettings(other); } QString PythonQtWrapper_QImageEncoderSettings::codec(QImageEncoderSettings* theWrappedObject) const @@ -6282,7 +6282,7 @@ if (_wrapper) { QMediaAudioProbeControl::timerEvent(event0); } QMediaAudioProbeControl* PythonQtWrapper_QMediaAudioProbeControl::new_QMediaAudioProbeControl(QObject* parent) -{ +{ return new PythonQtShell_QMediaAudioProbeControl(parent); } const QMetaObject* PythonQtShell_QMediaAudioProbeControl::metaObject() const { @@ -6470,7 +6470,7 @@ if (_wrapper) { QMediaAvailabilityControl::timerEvent(event0); } QMediaAvailabilityControl* PythonQtWrapper_QMediaAvailabilityControl::new_QMediaAvailabilityControl(QObject* parent) -{ +{ return new PythonQtShell_QMediaAvailabilityControl(parent); } const QMetaObject* PythonQtShell_QMediaAvailabilityControl::metaObject() const { @@ -6564,7 +6564,7 @@ if (_wrapper) { return bool(); } QMediaBindableInterface* PythonQtWrapper_QMediaBindableInterface::new_QMediaBindableInterface() -{ +{ return new PythonQtShell_QMediaBindableInterface(); } QMediaObject* PythonQtWrapper_QMediaBindableInterface::mediaObject(QMediaBindableInterface* theWrappedObject) const @@ -6779,7 +6779,7 @@ if (_wrapper) { } } } - + } QStringList PythonQtShell_QMediaContainerControl::supportedContainers() const { @@ -6837,7 +6837,7 @@ if (_wrapper) { QMediaContainerControl::timerEvent(event0); } QMediaContainerControl* PythonQtWrapper_QMediaContainerControl::new_QMediaContainerControl(QObject* parent) -{ +{ return new PythonQtShell_QMediaContainerControl(parent); } const QMetaObject* PythonQtShell_QMediaContainerControl::metaObject() const { @@ -6876,31 +6876,31 @@ QStringList PythonQtWrapper_QMediaContainerControl::supportedContainers(QMediaC QMediaContent* PythonQtWrapper_QMediaContent::new_QMediaContent() -{ +{ return new QMediaContent(); } QMediaContent* PythonQtWrapper_QMediaContent::new_QMediaContent(QMediaPlaylist* playlist, const QUrl& contentUrl, bool takeOwnership) -{ +{ return new QMediaContent(playlist, contentUrl, takeOwnership); } QMediaContent* PythonQtWrapper_QMediaContent::new_QMediaContent(const QList& resources) -{ +{ return new QMediaContent(resources); } QMediaContent* PythonQtWrapper_QMediaContent::new_QMediaContent(const QMediaContent& other) -{ +{ return new QMediaContent(other); } QMediaContent* PythonQtWrapper_QMediaContent::new_QMediaContent(const QMediaResource& contentResource) -{ +{ return new QMediaContent(contentResource); } QMediaContent* PythonQtWrapper_QMediaContent::new_QMediaContent(const QNetworkRequest& contentRequest) -{ +{ return new QMediaContent(contentRequest); } QMediaContent* PythonQtWrapper_QMediaContent::new_QMediaContent(const QUrl& contentUrl) -{ +{ return new QMediaContent(contentUrl); } QNetworkRequest PythonQtWrapper_QMediaContent::canonicalRequest(QMediaContent* theWrappedObject) const @@ -7092,7 +7092,7 @@ if (_wrapper) { QMediaControl::timerEvent(event0); } QMediaControl* PythonQtWrapper_QMediaControl::new_QMediaControl(QObject* parent) -{ +{ return new PythonQtShell_QMediaControl(parent); } const QMetaObject* PythonQtShell_QMediaControl::metaObject() const { @@ -7343,7 +7343,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaGaplessPlaybackControl::setNextMedia(const QMediaContent& media0) { @@ -7365,7 +7365,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaGaplessPlaybackControl::timerEvent(QTimerEvent* event0) { @@ -7390,7 +7390,7 @@ if (_wrapper) { QMediaGaplessPlaybackControl::timerEvent(event0); } QMediaGaplessPlaybackControl* PythonQtWrapper_QMediaGaplessPlaybackControl::new_QMediaGaplessPlaybackControl(QObject* parent) -{ +{ return new PythonQtShell_QMediaGaplessPlaybackControl(parent); } const QMetaObject* PythonQtShell_QMediaGaplessPlaybackControl::metaObject() const { @@ -7600,7 +7600,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaNetworkAccessControl::timerEvent(QTimerEvent* event0) { @@ -7625,7 +7625,7 @@ if (_wrapper) { QMediaNetworkAccessControl::timerEvent(event0); } QMediaNetworkAccessControl* PythonQtWrapper_QMediaNetworkAccessControl::new_QMediaNetworkAccessControl(QObject* parent) -{ +{ return new PythonQtShell_QMediaNetworkAccessControl(parent); } const QMetaObject* PythonQtShell_QMediaNetworkAccessControl::metaObject() const { @@ -7944,7 +7944,7 @@ if (_wrapper) { QMediaObject::unbind(arg__1); } QMediaObject* PythonQtWrapper_QMediaObject::new_QMediaObject(QObject* parent, QMediaService* service) -{ +{ return new PythonQtShell_QMediaObject(parent, service); } const QMetaObject* PythonQtShell_QMediaObject::metaObject() const { @@ -8313,7 +8313,7 @@ if (_wrapper) { QMediaPlayer::unbind(arg__1); } QMediaPlayer* PythonQtWrapper_QMediaPlayer::new_QMediaPlayer(QObject* parent, QMediaPlayer::Flags flags) -{ +{ return new PythonQtShell_QMediaPlayer(parent, flags); } const QMetaObject* PythonQtShell_QMediaPlayer::metaObject() const { @@ -8945,7 +8945,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaPlayerControl::play() { @@ -8967,7 +8967,7 @@ if (_wrapper) { } } } - + } qreal PythonQtShell_QMediaPlayerControl::playbackRate() const { @@ -9055,7 +9055,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaPlayerControl::setMuted(bool mute0) { @@ -9077,7 +9077,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaPlayerControl::setPlaybackRate(qreal rate0) { @@ -9099,7 +9099,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaPlayerControl::setPosition(qint64 position0) { @@ -9121,7 +9121,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaPlayerControl::setVolume(int volume0) { @@ -9143,7 +9143,7 @@ if (_wrapper) { } } } - + } QMediaPlayer::State PythonQtShell_QMediaPlayerControl::state() const { @@ -9198,7 +9198,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaPlayerControl::timerEvent(QTimerEvent* event0) { @@ -9256,7 +9256,7 @@ if (_wrapper) { return int(); } QMediaPlayerControl* PythonQtWrapper_QMediaPlayerControl::new_QMediaPlayerControl(QObject* parent) -{ +{ return new PythonQtShell_QMediaPlayerControl(parent); } const QMetaObject* PythonQtShell_QMediaPlayerControl::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia2.cpp b/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia2.cpp index 2b8a2ae28..9cd7563c0 100644 --- a/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia2.cpp +++ b/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia2.cpp @@ -234,7 +234,7 @@ if (_wrapper) { QMediaPlaylist::timerEvent(event0); } QMediaPlaylist* PythonQtWrapper_QMediaPlaylist::new_QMediaPlaylist(QObject* parent) -{ +{ return new PythonQtShell_QMediaPlaylist(parent); } const QMetaObject* PythonQtShell_QMediaPlaylist::metaObject() const { @@ -580,7 +580,7 @@ if (_wrapper) { QMediaRecorder::timerEvent(event0); } QMediaRecorder* PythonQtWrapper_QMediaRecorder::new_QMediaRecorder(QMediaObject* mediaObject, QObject* parent) -{ +{ return new PythonQtShell_QMediaRecorder(mediaObject, parent); } const QMetaObject* PythonQtShell_QMediaRecorder::metaObject() const { @@ -787,7 +787,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaRecorderControl::childEvent(QChildEvent* event0) { @@ -1018,7 +1018,7 @@ if (_wrapper) { } } } - + } bool PythonQtShell_QMediaRecorderControl::setOutputLocation(const QUrl& location0) { @@ -1073,7 +1073,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMediaRecorderControl::setVolume(qreal volume0) { @@ -1095,7 +1095,7 @@ if (_wrapper) { } } } - + } QMediaRecorder::State PythonQtShell_QMediaRecorderControl::state() const { @@ -1219,7 +1219,7 @@ if (_wrapper) { return qreal(); } QMediaRecorderControl* PythonQtWrapper_QMediaRecorderControl::new_QMediaRecorderControl(QObject* parent) -{ +{ return new PythonQtShell_QMediaRecorderControl(parent); } const QMetaObject* PythonQtShell_QMediaRecorderControl::metaObject() const { @@ -1278,19 +1278,19 @@ qreal PythonQtWrapper_QMediaRecorderControl::volume(QMediaRecorderControl* theW QMediaResource* PythonQtWrapper_QMediaResource::new_QMediaResource() -{ +{ return new QMediaResource(); } QMediaResource* PythonQtWrapper_QMediaResource::new_QMediaResource(const QMediaResource& other) -{ +{ return new QMediaResource(other); } QMediaResource* PythonQtWrapper_QMediaResource::new_QMediaResource(const QNetworkRequest& request, const QString& mimeType) -{ +{ return new QMediaResource(request, mimeType); } QMediaResource* PythonQtWrapper_QMediaResource::new_QMediaResource(const QUrl& url, const QString& mimeType) -{ +{ return new QMediaResource(url, mimeType); } int PythonQtWrapper_QMediaResource::audioBitRate(QMediaResource* theWrappedObject) const @@ -1559,7 +1559,7 @@ if (_wrapper) { } } } - + } QMediaControl* PythonQtShell_QMediaService::requestControl(const char* name0) { @@ -1617,7 +1617,7 @@ if (_wrapper) { QMediaService::timerEvent(event0); } QMediaService* PythonQtWrapper_QMediaService::new_QMediaService(QObject* parent) -{ +{ return new PythonQtShell_QMediaService(parent); } const QMetaObject* PythonQtShell_QMediaService::metaObject() const { @@ -1716,7 +1716,7 @@ if (_wrapper) { return QCamera::Position(); } QMediaServiceCameraInfoInterface* PythonQtWrapper_QMediaServiceCameraInfoInterface::new_QMediaServiceCameraInfoInterface() -{ +{ return new PythonQtShell_QMediaServiceCameraInfoInterface(); } int PythonQtWrapper_QMediaServiceCameraInfoInterface::cameraOrientation(QMediaServiceCameraInfoInterface* theWrappedObject, const QByteArray& device) const @@ -1769,7 +1769,7 @@ if (_wrapper) { return QByteArray(); } QMediaServiceDefaultDeviceInterface* PythonQtWrapper_QMediaServiceDefaultDeviceInterface::new_QMediaServiceDefaultDeviceInterface() -{ +{ return new PythonQtShell_QMediaServiceDefaultDeviceInterface(); } QByteArray PythonQtWrapper_QMediaServiceDefaultDeviceInterface::defaultDevice(QMediaServiceDefaultDeviceInterface* theWrappedObject, const QByteArray& service) const @@ -1836,10 +1836,10 @@ if (_wrapper) { } } } - + } QMediaServiceProviderFactoryInterface* PythonQtWrapper_QMediaServiceProviderFactoryInterface::new_QMediaServiceProviderFactoryInterface() -{ +{ return new PythonQtShell_QMediaServiceProviderFactoryInterface(); } QMediaService* PythonQtWrapper_QMediaServiceProviderFactoryInterface::create(QMediaServiceProviderFactoryInterface* theWrappedObject, const QString& key) @@ -1855,23 +1855,23 @@ void PythonQtWrapper_QMediaServiceProviderFactoryInterface::release(QMediaServic QMediaServiceProviderHint* PythonQtWrapper_QMediaServiceProviderHint::new_QMediaServiceProviderHint() -{ +{ return new QMediaServiceProviderHint(); } QMediaServiceProviderHint* PythonQtWrapper_QMediaServiceProviderHint::new_QMediaServiceProviderHint(QCamera::Position position) -{ +{ return new QMediaServiceProviderHint(position); } QMediaServiceProviderHint* PythonQtWrapper_QMediaServiceProviderHint::new_QMediaServiceProviderHint(const QByteArray& device) -{ +{ return new QMediaServiceProviderHint(device); } QMediaServiceProviderHint* PythonQtWrapper_QMediaServiceProviderHint::new_QMediaServiceProviderHint(const QMediaServiceProviderHint& other) -{ +{ return new QMediaServiceProviderHint(other); } QMediaServiceProviderHint* PythonQtWrapper_QMediaServiceProviderHint::new_QMediaServiceProviderHint(const QString& mimeType, const QStringList& codecs) -{ +{ return new QMediaServiceProviderHint(mimeType, codecs); } QCamera::Position PythonQtWrapper_QMediaServiceProviderHint::cameraPosition(QMediaServiceProviderHint* theWrappedObject) const @@ -1978,10 +1978,10 @@ if (_wrapper) { } } } - + } QMediaServiceProviderPlugin* PythonQtWrapper_QMediaServiceProviderPlugin::new_QMediaServiceProviderPlugin() -{ +{ return new PythonQtShell_QMediaServiceProviderPlugin(); } const QMetaObject* PythonQtShell_QMediaServiceProviderPlugin::metaObject() const { @@ -2080,7 +2080,7 @@ if (_wrapper) { return QList(); } QMediaServiceSupportedDevicesInterface* PythonQtWrapper_QMediaServiceSupportedDevicesInterface::new_QMediaServiceSupportedDevicesInterface() -{ +{ return new PythonQtShell_QMediaServiceSupportedDevicesInterface(); } QString PythonQtWrapper_QMediaServiceSupportedDevicesInterface::deviceDescription(QMediaServiceSupportedDevicesInterface* theWrappedObject, const QByteArray& service, const QByteArray& device) @@ -2166,7 +2166,7 @@ if (_wrapper) { return QStringList(); } QMediaServiceSupportedFormatsInterface* PythonQtWrapper_QMediaServiceSupportedFormatsInterface::new_QMediaServiceSupportedFormatsInterface() -{ +{ return new PythonQtShell_QMediaServiceSupportedFormatsInterface(); } QMultimedia::SupportEstimate PythonQtWrapper_QMediaServiceSupportedFormatsInterface::hasSupport(QMediaServiceSupportedFormatsInterface* theWrappedObject, const QString& mimeType, const QStringList& codecs) const @@ -2381,7 +2381,7 @@ if (_wrapper) { } } } - + } int PythonQtShell_QMediaStreamsControl::streamCount() { @@ -2472,7 +2472,7 @@ if (_wrapper) { QMediaStreamsControl::timerEvent(event0); } QMediaStreamsControl* PythonQtWrapper_QMediaStreamsControl::new_QMediaStreamsControl(QObject* parent) -{ +{ return new PythonQtShell_QMediaStreamsControl(parent); } const QMetaObject* PythonQtShell_QMediaStreamsControl::metaObject() const { @@ -2516,15 +2516,15 @@ QMediaStreamsControl::StreamType PythonQtWrapper_QMediaStreamsControl::streamTy QMediaTimeInterval* PythonQtWrapper_QMediaTimeInterval::new_QMediaTimeInterval() -{ +{ return new QMediaTimeInterval(); } QMediaTimeInterval* PythonQtWrapper_QMediaTimeInterval::new_QMediaTimeInterval(const QMediaTimeInterval& arg__1) -{ +{ return new QMediaTimeInterval(arg__1); } QMediaTimeInterval* PythonQtWrapper_QMediaTimeInterval::new_QMediaTimeInterval(qint64 start, qint64 end) -{ +{ return new QMediaTimeInterval(start, end); } bool PythonQtWrapper_QMediaTimeInterval::contains(QMediaTimeInterval* theWrappedObject, qint64 time) const @@ -2575,19 +2575,19 @@ QMediaTimeInterval PythonQtWrapper_QMediaTimeInterval::translated(QMediaTimeInt QMediaTimeRange* PythonQtWrapper_QMediaTimeRange::new_QMediaTimeRange() -{ +{ return new QMediaTimeRange(); } QMediaTimeRange* PythonQtWrapper_QMediaTimeRange::new_QMediaTimeRange(const QMediaTimeInterval& arg__1) -{ +{ return new QMediaTimeRange(arg__1); } QMediaTimeRange* PythonQtWrapper_QMediaTimeRange::new_QMediaTimeRange(const QMediaTimeRange& range) -{ +{ return new QMediaTimeRange(range); } QMediaTimeRange* PythonQtWrapper_QMediaTimeRange::new_QMediaTimeRange(qint64 start, qint64 end) -{ +{ return new QMediaTimeRange(start, end); } void PythonQtWrapper_QMediaTimeRange::addInterval(QMediaTimeRange* theWrappedObject, const QMediaTimeInterval& interval) @@ -2851,7 +2851,7 @@ if (_wrapper) { QMediaVideoProbeControl::timerEvent(event0); } QMediaVideoProbeControl* PythonQtWrapper_QMediaVideoProbeControl::new_QMediaVideoProbeControl(QObject* parent) -{ +{ return new PythonQtShell_QMediaVideoProbeControl(parent); } const QMetaObject* PythonQtShell_QMediaVideoProbeControl::metaObject() const { @@ -3105,7 +3105,7 @@ if (_wrapper) { QMetaDataReaderControl::timerEvent(event0); } QMetaDataReaderControl* PythonQtWrapper_QMetaDataReaderControl::new_QMetaDataReaderControl(QObject* parent) -{ +{ return new PythonQtShell_QMetaDataReaderControl(parent); } const QMetaObject* PythonQtShell_QMetaDataReaderControl::metaObject() const { @@ -3404,7 +3404,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QMetaDataWriterControl::timerEvent(QTimerEvent* event0) { @@ -3429,7 +3429,7 @@ if (_wrapper) { QMetaDataWriterControl::timerEvent(event0); } QMetaDataWriterControl* PythonQtWrapper_QMetaDataWriterControl::new_QMetaDataWriterControl(QObject* parent) -{ +{ return new PythonQtShell_QMetaDataWriterControl(parent); } const QMetaObject* PythonQtShell_QMetaDataWriterControl::metaObject() const { @@ -3677,7 +3677,7 @@ if (_wrapper) { QRadioData::timerEvent(event0); } QRadioData* PythonQtWrapper_QRadioData::new_QRadioData(QMediaObject* mediaObject, QObject* parent) -{ +{ return new PythonQtShell_QRadioData(mediaObject, parent); } const QMetaObject* PythonQtShell_QRadioData::metaObject() const { @@ -4072,7 +4072,7 @@ if (_wrapper) { } } } - + } QString PythonQtShell_QRadioDataControl::stationId() const { @@ -4163,7 +4163,7 @@ if (_wrapper) { QRadioDataControl::timerEvent(event0); } QRadioDataControl* PythonQtWrapper_QRadioDataControl::new_QRadioDataControl(QObject* parent) -{ +{ return new PythonQtShell_QRadioDataControl(parent); } const QMetaObject* PythonQtShell_QRadioDataControl::metaObject() const { @@ -4517,7 +4517,7 @@ if (_wrapper) { QRadioTuner::unbind(arg__1); } QRadioTuner* PythonQtWrapper_QRadioTuner::new_QRadioTuner(QObject* parent) -{ +{ return new PythonQtShell_QRadioTuner(parent); } const QMetaObject* PythonQtShell_QRadioTuner::metaObject() const { @@ -4677,7 +4677,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QRadioTunerControl::childEvent(QChildEvent* event0) { @@ -5139,7 +5139,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QRadioTunerControl::searchBackward() { @@ -5161,7 +5161,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QRadioTunerControl::searchForward() { @@ -5183,7 +5183,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QRadioTunerControl::setBand(QRadioTuner::Band b0) { @@ -5205,7 +5205,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QRadioTunerControl::setFrequency(int frequency0) { @@ -5227,7 +5227,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QRadioTunerControl::setMuted(bool muted0) { @@ -5249,7 +5249,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QRadioTunerControl::setStereoMode(QRadioTuner::StereoMode mode0) { @@ -5271,7 +5271,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QRadioTunerControl::setVolume(int volume0) { @@ -5293,7 +5293,7 @@ if (_wrapper) { } } } - + } int PythonQtShell_QRadioTunerControl::signalStrength() const { @@ -5348,7 +5348,7 @@ if (_wrapper) { } } } - + } QRadioTuner::State PythonQtShell_QRadioTunerControl::state() const { @@ -5436,7 +5436,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QRadioTunerControl::timerEvent(QTimerEvent* event0) { @@ -5494,7 +5494,7 @@ if (_wrapper) { return int(); } QRadioTunerControl* PythonQtWrapper_QRadioTunerControl::new_QRadioTunerControl(QObject* parent) -{ +{ return new PythonQtShell_QRadioTunerControl(parent); } const QMetaObject* PythonQtShell_QRadioTunerControl::metaObject() const { @@ -5779,7 +5779,7 @@ if (_wrapper) { QSound::timerEvent(event0); } QSound* PythonQtWrapper_QSound::new_QSound(const QString& filename, QObject* parent) -{ +{ return new PythonQtShell_QSound(filename, parent); } const QMetaObject* PythonQtShell_QSound::metaObject() const { @@ -5964,11 +5964,11 @@ if (_wrapper) { QSoundEffect::timerEvent(event0); } QSoundEffect* PythonQtWrapper_QSoundEffect::new_QSoundEffect(QObject* parent) -{ +{ return new PythonQtShell_QSoundEffect(parent); } QSoundEffect* PythonQtWrapper_QSoundEffect::new_QSoundEffect(const QAudioDeviceInfo& audioDevice, QObject* parent) -{ +{ return new PythonQtShell_QSoundEffect(audioDevice, parent); } const QMetaObject* PythonQtShell_QSoundEffect::metaObject() const { @@ -6360,7 +6360,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoDeviceSelectorControl::timerEvent(QTimerEvent* event0) { @@ -6385,7 +6385,7 @@ if (_wrapper) { QVideoDeviceSelectorControl::timerEvent(event0); } QVideoDeviceSelectorControl* PythonQtWrapper_QVideoDeviceSelectorControl::new_QVideoDeviceSelectorControl(QObject* parent) -{ +{ return new PythonQtShell_QVideoDeviceSelectorControl(parent); } const QMetaObject* PythonQtShell_QVideoDeviceSelectorControl::metaObject() const { @@ -6429,11 +6429,11 @@ int PythonQtWrapper_QVideoDeviceSelectorControl::selectedDevice(QVideoDeviceSel QVideoEncoderSettings* PythonQtWrapper_QVideoEncoderSettings::new_QVideoEncoderSettings() -{ +{ return new QVideoEncoderSettings(); } QVideoEncoderSettings* PythonQtWrapper_QVideoEncoderSettings::new_QVideoEncoderSettings(const QVideoEncoderSettings& other) -{ +{ return new QVideoEncoderSettings(other); } int PythonQtWrapper_QVideoEncoderSettings::bitRate(QVideoEncoderSettings* theWrappedObject) const @@ -6677,7 +6677,7 @@ if (_wrapper) { } } } - + } QList PythonQtShell_QVideoEncoderSettingsControl::supportedFrameRates(const QVideoEncoderSettings& settings0, bool* continuous1) const { @@ -6867,7 +6867,7 @@ if (_wrapper) { return QVideoEncoderSettings(); } QVideoEncoderSettingsControl* PythonQtWrapper_QVideoEncoderSettingsControl::new_QVideoEncoderSettingsControl(QObject* parent) -{ +{ return new PythonQtShell_QVideoEncoderSettingsControl(parent); } const QMetaObject* PythonQtShell_QVideoEncoderSettingsControl::metaObject() const { @@ -6916,23 +6916,23 @@ QVideoEncoderSettings PythonQtWrapper_QVideoEncoderSettingsControl::videoSettin QVideoFrame* PythonQtWrapper_QVideoFrame::new_QVideoFrame() -{ +{ return new QVideoFrame(); } QVideoFrame* PythonQtWrapper_QVideoFrame::new_QVideoFrame(QAbstractVideoBuffer* buffer, const QSize& size, QVideoFrame::PixelFormat format) -{ +{ return new QVideoFrame(buffer, size, format); } QVideoFrame* PythonQtWrapper_QVideoFrame::new_QVideoFrame(const QImage& image) -{ +{ return new QVideoFrame(image); } QVideoFrame* PythonQtWrapper_QVideoFrame::new_QVideoFrame(const QVideoFrame& other) -{ +{ return new QVideoFrame(other); } QVideoFrame* PythonQtWrapper_QVideoFrame::new_QVideoFrame(int bytes, const QSize& size, int bytesPerLine, QVideoFrame::PixelFormat format) -{ +{ return new QVideoFrame(bytes, size, bytesPerLine, format); } QMap PythonQtWrapper_QVideoFrame::availableMetaData(QVideoFrame* theWrappedObject) const @@ -7266,7 +7266,7 @@ if (_wrapper) { QVideoProbe::timerEvent(event0); } QVideoProbe* PythonQtWrapper_QVideoProbe::new_QVideoProbe(QObject* parent) -{ +{ return new PythonQtShell_QVideoProbe(parent); } const QMetaObject* PythonQtShell_QVideoProbe::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia3.cpp b/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia3.cpp index 46f2e5844..eb6719258 100644 --- a/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia3.cpp +++ b/generated_cpp_515/com_trolltech_qt_multimedia/com_trolltech_qt_multimedia3.cpp @@ -176,7 +176,7 @@ if (_wrapper) { } } } - + } QAbstractVideoSurface* PythonQtShell_QVideoRendererControl::surface() const { @@ -234,7 +234,7 @@ if (_wrapper) { QVideoRendererControl::timerEvent(event0); } QVideoRendererControl* PythonQtWrapper_QVideoRendererControl::new_QVideoRendererControl(QObject* parent) -{ +{ return new PythonQtShell_QVideoRendererControl(parent); } const QMetaObject* PythonQtShell_QVideoRendererControl::metaObject() const { @@ -263,15 +263,15 @@ QAbstractVideoSurface* PythonQtWrapper_QVideoRendererControl::surface(QVideoRen QVideoSurfaceFormat* PythonQtWrapper_QVideoSurfaceFormat::new_QVideoSurfaceFormat() -{ +{ return new QVideoSurfaceFormat(); } QVideoSurfaceFormat* PythonQtWrapper_QVideoSurfaceFormat::new_QVideoSurfaceFormat(const QSize& size, QVideoFrame::PixelFormat pixelFormat, QAbstractVideoBuffer::HandleType handleType) -{ +{ return new QVideoSurfaceFormat(size, pixelFormat, handleType); } QVideoSurfaceFormat* PythonQtWrapper_QVideoSurfaceFormat::new_QVideoSurfaceFormat(const QVideoSurfaceFormat& format) -{ +{ return new QVideoSurfaceFormat(format); } int PythonQtWrapper_QVideoSurfaceFormat::frameHeight(QVideoSurfaceFormat* theWrappedObject) const @@ -1638,7 +1638,7 @@ if (_wrapper) { QVideoWidget::wheelEvent(event0); } QVideoWidget* PythonQtWrapper_QVideoWidget::new_QVideoWidget(QWidget* parent) -{ +{ return new PythonQtShell_QVideoWidget(parent); } const QMetaObject* PythonQtShell_QVideoWidget::metaObject() const { @@ -2023,7 +2023,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWidgetControl::setBrightness(int brightness0) { @@ -2045,7 +2045,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWidgetControl::setContrast(int contrast0) { @@ -2067,7 +2067,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWidgetControl::setFullScreen(bool fullScreen0) { @@ -2089,7 +2089,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWidgetControl::setHue(int hue0) { @@ -2111,7 +2111,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWidgetControl::setSaturation(int saturation0) { @@ -2133,7 +2133,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWidgetControl::timerEvent(QTimerEvent* event0) { @@ -2191,7 +2191,7 @@ if (_wrapper) { return nullptr; } QVideoWidgetControl* PythonQtWrapper_QVideoWidgetControl::new_QVideoWidgetControl(QObject* parent) -{ +{ return new PythonQtShell_QVideoWidgetControl(parent); } const QMetaObject* PythonQtShell_QVideoWidgetControl::metaObject() const { @@ -2639,7 +2639,7 @@ if (_wrapper) { } } } - + } int PythonQtShell_QVideoWindowControl::saturation() const { @@ -2694,7 +2694,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWindowControl::setBrightness(int brightness0) { @@ -2716,7 +2716,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWindowControl::setContrast(int contrast0) { @@ -2738,7 +2738,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWindowControl::setDisplayRect(const QRect& rect0) { @@ -2760,7 +2760,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWindowControl::setFullScreen(bool fullScreen0) { @@ -2782,7 +2782,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWindowControl::setHue(int hue0) { @@ -2804,7 +2804,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWindowControl::setSaturation(int saturation0) { @@ -2826,7 +2826,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWindowControl::setWinId(WId id0) { @@ -2848,7 +2848,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QVideoWindowControl::timerEvent(QTimerEvent* event0) { @@ -2906,7 +2906,7 @@ if (_wrapper) { return WId(); } QVideoWindowControl* PythonQtWrapper_QVideoWindowControl::new_QVideoWindowControl(QObject* parent) -{ +{ return new PythonQtShell_QVideoWindowControl(parent); } const QMetaObject* PythonQtShell_QVideoWindowControl::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network0.cpp b/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network0.cpp index 9b2967bf5..8e3b41643 100644 --- a/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network0.cpp +++ b/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network0.cpp @@ -121,7 +121,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractNetworkCache::customEvent(QEvent* event0) { @@ -264,7 +264,7 @@ if (_wrapper) { } } } - + } QNetworkCacheMetaData PythonQtShell_QAbstractNetworkCache::metaData(const QUrl& url0) { @@ -407,10 +407,10 @@ if (_wrapper) { } } } - + } QAbstractNetworkCache* PythonQtWrapper_QAbstractNetworkCache::new_QAbstractNetworkCache(QObject* parent) -{ +{ return new PythonQtShell_QAbstractNetworkCache(parent); } const QMetaObject* PythonQtShell_QAbstractNetworkCache::metaObject() const { @@ -1414,7 +1414,7 @@ if (_wrapper) { return QAbstractSocket::writeData(data0, len1); } QAbstractSocket* PythonQtWrapper_QAbstractSocket::new_QAbstractSocket(QAbstractSocket::SocketType socketType, QObject* parent) -{ +{ return new PythonQtShell_QAbstractSocket(socketType, parent); } const QMetaObject* PythonQtShell_QAbstractSocket::metaObject() const { @@ -1623,11 +1623,11 @@ bool PythonQtWrapper_QAbstractSocket::waitForDisconnected(QAbstractSocket* theW QAuthenticator* PythonQtWrapper_QAuthenticator::new_QAuthenticator() -{ +{ return new QAuthenticator(); } QAuthenticator* PythonQtWrapper_QAuthenticator::new_QAuthenticator(const QAuthenticator& other) -{ +{ return new QAuthenticator(other); } bool PythonQtWrapper_QAuthenticator::isNull(QAuthenticator* theWrappedObject) const @@ -1693,11 +1693,11 @@ QString PythonQtWrapper_QAuthenticator::user(QAuthenticator* theWrappedObject) QDnsDomainNameRecord* PythonQtWrapper_QDnsDomainNameRecord::new_QDnsDomainNameRecord() -{ +{ return new QDnsDomainNameRecord(); } QDnsDomainNameRecord* PythonQtWrapper_QDnsDomainNameRecord::new_QDnsDomainNameRecord(const QDnsDomainNameRecord& other) -{ +{ return new QDnsDomainNameRecord(other); } QString PythonQtWrapper_QDnsDomainNameRecord::name(QDnsDomainNameRecord* theWrappedObject) const @@ -1728,11 +1728,11 @@ QString PythonQtWrapper_QDnsDomainNameRecord::value(QDnsDomainNameRecord* theWr QDnsHostAddressRecord* PythonQtWrapper_QDnsHostAddressRecord::new_QDnsHostAddressRecord() -{ +{ return new QDnsHostAddressRecord(); } QDnsHostAddressRecord* PythonQtWrapper_QDnsHostAddressRecord::new_QDnsHostAddressRecord(const QDnsHostAddressRecord& other) -{ +{ return new QDnsHostAddressRecord(other); } QString PythonQtWrapper_QDnsHostAddressRecord::name(QDnsHostAddressRecord* theWrappedObject) const @@ -1899,15 +1899,15 @@ if (_wrapper) { QDnsLookup::timerEvent(event0); } QDnsLookup* PythonQtWrapper_QDnsLookup::new_QDnsLookup(QDnsLookup::Type type, const QString& name, QObject* parent) -{ +{ return new PythonQtShell_QDnsLookup(type, name, parent); } QDnsLookup* PythonQtWrapper_QDnsLookup::new_QDnsLookup(QDnsLookup::Type type, const QString& name, const QHostAddress& nameserver, QObject* parent) -{ +{ return new PythonQtShell_QDnsLookup(type, name, nameserver, parent); } QDnsLookup* PythonQtWrapper_QDnsLookup::new_QDnsLookup(QObject* parent) -{ +{ return new PythonQtShell_QDnsLookup(parent); } const QMetaObject* PythonQtShell_QDnsLookup::metaObject() const { @@ -2006,11 +2006,11 @@ QDnsLookup::Type PythonQtWrapper_QDnsLookup::type(QDnsLookup* theWrappedObject) QDnsMailExchangeRecord* PythonQtWrapper_QDnsMailExchangeRecord::new_QDnsMailExchangeRecord() -{ +{ return new QDnsMailExchangeRecord(); } QDnsMailExchangeRecord* PythonQtWrapper_QDnsMailExchangeRecord::new_QDnsMailExchangeRecord(const QDnsMailExchangeRecord& other) -{ +{ return new QDnsMailExchangeRecord(other); } QString PythonQtWrapper_QDnsMailExchangeRecord::exchange(QDnsMailExchangeRecord* theWrappedObject) const @@ -2046,11 +2046,11 @@ unsigned int PythonQtWrapper_QDnsMailExchangeRecord::timeToLive(QDnsMailExchang QDnsServiceRecord* PythonQtWrapper_QDnsServiceRecord::new_QDnsServiceRecord() -{ +{ return new QDnsServiceRecord(); } QDnsServiceRecord* PythonQtWrapper_QDnsServiceRecord::new_QDnsServiceRecord(const QDnsServiceRecord& other) -{ +{ return new QDnsServiceRecord(other); } QString PythonQtWrapper_QDnsServiceRecord::name(QDnsServiceRecord* theWrappedObject) const @@ -2096,11 +2096,11 @@ unsigned short PythonQtWrapper_QDnsServiceRecord::weight(QDnsServiceRecord* the QDnsTextRecord* PythonQtWrapper_QDnsTextRecord::new_QDnsTextRecord() -{ +{ return new QDnsTextRecord(); } QDnsTextRecord* PythonQtWrapper_QDnsTextRecord::new_QDnsTextRecord(const QDnsTextRecord& other) -{ +{ return new QDnsTextRecord(other); } QString PythonQtWrapper_QDnsTextRecord::name(QDnsTextRecord* theWrappedObject) const @@ -2267,7 +2267,7 @@ if (_wrapper) { QDtls::timerEvent(event0); } QDtls* PythonQtWrapper_QDtls::new_QDtls(QSslSocket::SslMode mode, QObject* parent) -{ +{ return new PythonQtShell_QDtls(mode, parent); } const QMetaObject* PythonQtShell_QDtls::metaObject() const { @@ -2557,7 +2557,7 @@ if (_wrapper) { QDtlsClientVerifier::timerEvent(event0); } QDtlsClientVerifier* PythonQtWrapper_QDtlsClientVerifier::new_QDtlsClientVerifier(QObject* parent) -{ +{ return new PythonQtShell_QDtlsClientVerifier(parent); } const QMetaObject* PythonQtShell_QDtlsClientVerifier::metaObject() const { @@ -2610,41 +2610,41 @@ PythonQtShell_QDtlsClientVerifier__GeneratorParameters::~PythonQtShell_QDtlsClie if (priv) { priv->shellClassDeleted(this); } } QDtlsClientVerifier::GeneratorParameters* PythonQtWrapper_QDtlsClientVerifier__GeneratorParameters::new_QDtlsClientVerifier__GeneratorParameters() -{ +{ return new PythonQtShell_QDtlsClientVerifier__GeneratorParameters(); } QDtlsClientVerifier::GeneratorParameters* PythonQtWrapper_QDtlsClientVerifier__GeneratorParameters::new_QDtlsClientVerifier__GeneratorParameters(QCryptographicHash::Algorithm a, const QByteArray& s) -{ +{ return new PythonQtShell_QDtlsClientVerifier__GeneratorParameters(a, s); } QHostAddress* PythonQtWrapper_QHostAddress::new_QHostAddress() -{ +{ return new QHostAddress(); } QHostAddress* PythonQtWrapper_QHostAddress::new_QHostAddress(QHostAddress::SpecialAddress address) -{ +{ return new QHostAddress(address); } QHostAddress* PythonQtWrapper_QHostAddress::new_QHostAddress(const QHostAddress& copy) -{ +{ return new QHostAddress(copy); } QHostAddress* PythonQtWrapper_QHostAddress::new_QHostAddress(const QIPv6Address& ip6Addr) -{ +{ return new QHostAddress(ip6Addr); } QHostAddress* PythonQtWrapper_QHostAddress::new_QHostAddress(const QString& address) -{ +{ return new QHostAddress(address); } QHostAddress* PythonQtWrapper_QHostAddress::new_QHostAddress(const unsigned char* ip6Addr) -{ +{ return new QHostAddress(ip6Addr); } QHostAddress* PythonQtWrapper_QHostAddress::new_QHostAddress(unsigned int ip4Addr) -{ +{ return new QHostAddress(ip4Addr); } void PythonQtWrapper_QHostAddress::clear(QHostAddress* theWrappedObject) @@ -2811,11 +2811,11 @@ QString PythonQtWrapper_QHostAddress::py_toString(QHostAddress* obj) { return ob QHostInfo* PythonQtWrapper_QHostInfo::new_QHostInfo(const QHostInfo& d) -{ +{ return new QHostInfo(d); } QHostInfo* PythonQtWrapper_QHostInfo::new_QHostInfo(int lookupId) -{ +{ return new QHostInfo(lookupId); } void PythonQtWrapper_QHostInfo::static_QHostInfo_abortHostLookup(int lookupId) @@ -2901,11 +2901,11 @@ void PythonQtWrapper_QHostInfo::swap(QHostInfo* theWrappedObject, QHostInfo& ot QHstsPolicy* PythonQtWrapper_QHstsPolicy::new_QHstsPolicy() -{ +{ return new QHstsPolicy(); } QHstsPolicy* PythonQtWrapper_QHstsPolicy::new_QHstsPolicy(const QHstsPolicy& rhs) -{ +{ return new QHstsPolicy(rhs); } QDateTime PythonQtWrapper_QHstsPolicy::expiry(QHstsPolicy* theWrappedObject) const @@ -2966,11 +2966,11 @@ void PythonQtWrapper_QHstsPolicy::swap(QHstsPolicy* theWrappedObject, QHstsPolic QHttp2Configuration* PythonQtWrapper_QHttp2Configuration::new_QHttp2Configuration() -{ +{ return new QHttp2Configuration(); } QHttp2Configuration* PythonQtWrapper_QHttp2Configuration::new_QHttp2Configuration(const QHttp2Configuration& other) -{ +{ return new QHttp2Configuration(other); } bool PythonQtWrapper_QHttp2Configuration::huffmanCompressionEnabled(QHttp2Configuration* theWrappedObject) const @@ -3152,11 +3152,11 @@ if (_wrapper) { QHttpMultiPart::timerEvent(event0); } QHttpMultiPart* PythonQtWrapper_QHttpMultiPart::new_QHttpMultiPart(QHttpMultiPart::ContentType contentType, QObject* parent) -{ +{ return new PythonQtShell_QHttpMultiPart(contentType, parent); } QHttpMultiPart* PythonQtWrapper_QHttpMultiPart::new_QHttpMultiPart(QObject* parent) -{ +{ return new PythonQtShell_QHttpMultiPart(parent); } const QMetaObject* PythonQtShell_QHttpMultiPart::metaObject() const { @@ -3195,11 +3195,11 @@ void PythonQtWrapper_QHttpMultiPart::setContentType(QHttpMultiPart* theWrappedOb QHttpPart* PythonQtWrapper_QHttpPart::new_QHttpPart() -{ +{ return new QHttpPart(); } QHttpPart* PythonQtWrapper_QHttpPart::new_QHttpPart(const QHttpPart& other) -{ +{ return new QHttpPart(other); } bool PythonQtWrapper_QHttpPart::__ne__(QHttpPart* theWrappedObject, const QHttpPart& other) const @@ -3249,7 +3249,7 @@ PythonQtShell_QIPv6Address::~PythonQtShell_QIPv6Address() { if (priv) { priv->shellClassDeleted(this); } } QIPv6Address* PythonQtWrapper_QIPv6Address::new_QIPv6Address() -{ +{ return new PythonQtShell_QIPv6Address(); } @@ -3479,7 +3479,7 @@ if (_wrapper) { QLocalServer::timerEvent(event0); } QLocalServer* PythonQtWrapper_QLocalServer::new_QLocalServer(QObject* parent) -{ +{ return new PythonQtShell_QLocalServer(parent); } const QMetaObject* PythonQtShell_QLocalServer::metaObject() const { @@ -4241,7 +4241,7 @@ if (_wrapper) { return QLocalSocket::writeData(arg__1, arg__2); } QLocalSocket* PythonQtWrapper_QLocalSocket::new_QLocalSocket(QObject* parent) -{ +{ return new PythonQtShell_QLocalSocket(parent); } const QMetaObject* PythonQtShell_QLocalSocket::metaObject() const { @@ -4514,7 +4514,7 @@ if (_wrapper) { QNetworkAccessManager::timerEvent(event0); } QNetworkAccessManager* PythonQtWrapper_QNetworkAccessManager::new_QNetworkAccessManager(QObject* parent) -{ +{ return new PythonQtShell_QNetworkAccessManager(parent); } const QMetaObject* PythonQtShell_QNetworkAccessManager::metaObject() const { @@ -4753,11 +4753,11 @@ int PythonQtWrapper_QNetworkAccessManager::transferTimeout(QNetworkAccessManage QNetworkAddressEntry* PythonQtWrapper_QNetworkAddressEntry::new_QNetworkAddressEntry() -{ +{ return new QNetworkAddressEntry(); } QNetworkAddressEntry* PythonQtWrapper_QNetworkAddressEntry::new_QNetworkAddressEntry(const QNetworkAddressEntry& other) -{ +{ return new QNetworkAddressEntry(other); } QHostAddress PythonQtWrapper_QNetworkAddressEntry::broadcast(QNetworkAddressEntry* theWrappedObject) const @@ -4863,11 +4863,11 @@ QDeadlineTimer PythonQtWrapper_QNetworkAddressEntry::validityLifetime(QNetworkA QNetworkCacheMetaData* PythonQtWrapper_QNetworkCacheMetaData::new_QNetworkCacheMetaData() -{ +{ return new QNetworkCacheMetaData(); } QNetworkCacheMetaData* PythonQtWrapper_QNetworkCacheMetaData::new_QNetworkCacheMetaData(const QNetworkCacheMetaData& other) -{ +{ return new QNetworkCacheMetaData(other); } QHash PythonQtWrapper_QNetworkCacheMetaData::attributes(QNetworkCacheMetaData* theWrappedObject) const @@ -4963,11 +4963,11 @@ QUrl PythonQtWrapper_QNetworkCacheMetaData::url(QNetworkCacheMetaData* theWrapp QNetworkConfiguration* PythonQtWrapper_QNetworkConfiguration::new_QNetworkConfiguration() -{ +{ return new QNetworkConfiguration(); } QNetworkConfiguration* PythonQtWrapper_QNetworkConfiguration::new_QNetworkConfiguration(const QNetworkConfiguration& other) -{ +{ return new QNetworkConfiguration(other); } QNetworkConfiguration::BearerType PythonQtWrapper_QNetworkConfiguration::bearerType(QNetworkConfiguration* theWrappedObject) const @@ -5194,7 +5194,7 @@ if (_wrapper) { QNetworkConfigurationManager::timerEvent(event0); } QNetworkConfigurationManager* PythonQtWrapper_QNetworkConfigurationManager::new_QNetworkConfigurationManager(QObject* parent) -{ +{ return new PythonQtShell_QNetworkConfigurationManager(parent); } const QMetaObject* PythonQtShell_QNetworkConfigurationManager::metaObject() const { @@ -5238,11 +5238,11 @@ bool PythonQtWrapper_QNetworkConfigurationManager::isOnline(QNetworkConfigurati QNetworkCookie* PythonQtWrapper_QNetworkCookie::new_QNetworkCookie(const QByteArray& name, const QByteArray& value) -{ +{ return new QNetworkCookie(name, value); } QNetworkCookie* PythonQtWrapper_QNetworkCookie::new_QNetworkCookie(const QNetworkCookie& other) -{ +{ return new QNetworkCookie(other); } QString PythonQtWrapper_QNetworkCookie::domain(QNetworkCookie* theWrappedObject) const @@ -5699,7 +5699,7 @@ if (_wrapper) { return QNetworkCookieJar::validateCookie(cookie0, url1); } QNetworkCookieJar* PythonQtWrapper_QNetworkCookieJar::new_QNetworkCookieJar(QObject* parent) -{ +{ return new PythonQtShell_QNetworkCookieJar(parent); } const QMetaObject* PythonQtShell_QNetworkCookieJar::metaObject() const { @@ -5758,15 +5758,15 @@ bool PythonQtWrapper_QNetworkCookieJar::validateCookie(QNetworkCookieJar* theWr QNetworkDatagram* PythonQtWrapper_QNetworkDatagram::new_QNetworkDatagram() -{ +{ return new QNetworkDatagram(); } QNetworkDatagram* PythonQtWrapper_QNetworkDatagram::new_QNetworkDatagram(const QByteArray& data, const QHostAddress& destinationAddress, unsigned short port) -{ +{ return new QNetworkDatagram(data, destinationAddress, port); } QNetworkDatagram* PythonQtWrapper_QNetworkDatagram::new_QNetworkDatagram(const QNetworkDatagram& other) -{ +{ return new QNetworkDatagram(other); } void PythonQtWrapper_QNetworkDatagram::clear(QNetworkDatagram* theWrappedObject) @@ -6262,7 +6262,7 @@ if (_wrapper) { QNetworkDiskCache::updateMetaData(metaData0); } QNetworkDiskCache* PythonQtWrapper_QNetworkDiskCache::new_QNetworkDiskCache(QObject* parent) -{ +{ return new PythonQtShell_QNetworkDiskCache(parent); } const QMetaObject* PythonQtShell_QNetworkDiskCache::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network1.cpp b/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network1.cpp index 55fa6aa2f..529a5280f 100644 --- a/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network1.cpp +++ b/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network1.cpp @@ -40,11 +40,11 @@ #include QNetworkInterface* PythonQtWrapper_QNetworkInterface::new_QNetworkInterface() -{ +{ return new QNetworkInterface(); } QNetworkInterface* PythonQtWrapper_QNetworkInterface::new_QNetworkInterface(const QNetworkInterface& other) -{ +{ return new QNetworkInterface(other); } QList PythonQtWrapper_QNetworkInterface::addressEntries(QNetworkInterface* theWrappedObject) const @@ -137,15 +137,15 @@ QString PythonQtWrapper_QNetworkInterface::py_toString(QNetworkInterface* obj) { QNetworkProxy* PythonQtWrapper_QNetworkProxy::new_QNetworkProxy() -{ +{ return new QNetworkProxy(); } QNetworkProxy* PythonQtWrapper_QNetworkProxy::new_QNetworkProxy(QNetworkProxy::ProxyType type, const QString& hostName, unsigned short port, const QString& user, const QString& password) -{ +{ return new QNetworkProxy(type, hostName, port, user, password); } QNetworkProxy* PythonQtWrapper_QNetworkProxy::new_QNetworkProxy(const QNetworkProxy& other) -{ +{ return new QNetworkProxy(other); } QNetworkProxy PythonQtWrapper_QNetworkProxy::static_QNetworkProxy_applicationProxy() @@ -320,7 +320,7 @@ if (_wrapper) { return QList(); } QNetworkProxyFactory* PythonQtWrapper_QNetworkProxyFactory::new_QNetworkProxyFactory() -{ +{ return new PythonQtShell_QNetworkProxyFactory(); } QList PythonQtWrapper_QNetworkProxyFactory::static_QNetworkProxyFactory_proxyForQuery(const QNetworkProxyQuery& query) @@ -356,35 +356,35 @@ bool PythonQtWrapper_QNetworkProxyFactory::static_QNetworkProxyFactory_usesSyst QNetworkProxyQuery* PythonQtWrapper_QNetworkProxyQuery::new_QNetworkProxyQuery() -{ +{ return new QNetworkProxyQuery(); } QNetworkProxyQuery* PythonQtWrapper_QNetworkProxyQuery::new_QNetworkProxyQuery(const QNetworkConfiguration& networkConfiguration, const QString& hostname, int port, const QString& protocolTag, QNetworkProxyQuery::QueryType queryType) -{ +{ return new QNetworkProxyQuery(networkConfiguration, hostname, port, protocolTag, queryType); } QNetworkProxyQuery* PythonQtWrapper_QNetworkProxyQuery::new_QNetworkProxyQuery(const QNetworkConfiguration& networkConfiguration, const QUrl& requestUrl, QNetworkProxyQuery::QueryType queryType) -{ +{ return new QNetworkProxyQuery(networkConfiguration, requestUrl, queryType); } QNetworkProxyQuery* PythonQtWrapper_QNetworkProxyQuery::new_QNetworkProxyQuery(const QNetworkConfiguration& networkConfiguration, unsigned short bindPort, const QString& protocolTag, QNetworkProxyQuery::QueryType queryType) -{ +{ return new QNetworkProxyQuery(networkConfiguration, bindPort, protocolTag, queryType); } QNetworkProxyQuery* PythonQtWrapper_QNetworkProxyQuery::new_QNetworkProxyQuery(const QNetworkProxyQuery& other) -{ +{ return new QNetworkProxyQuery(other); } QNetworkProxyQuery* PythonQtWrapper_QNetworkProxyQuery::new_QNetworkProxyQuery(const QString& hostname, int port, const QString& protocolTag, QNetworkProxyQuery::QueryType queryType) -{ +{ return new QNetworkProxyQuery(hostname, port, protocolTag, queryType); } QNetworkProxyQuery* PythonQtWrapper_QNetworkProxyQuery::new_QNetworkProxyQuery(const QUrl& requestUrl, QNetworkProxyQuery::QueryType queryType) -{ +{ return new QNetworkProxyQuery(requestUrl, queryType); } QNetworkProxyQuery* PythonQtWrapper_QNetworkProxyQuery::new_QNetworkProxyQuery(unsigned short bindPort, const QString& protocolTag, QNetworkProxyQuery::QueryType queryType) -{ +{ return new QNetworkProxyQuery(bindPort, protocolTag, queryType); } int PythonQtWrapper_QNetworkProxyQuery::localPort(QNetworkProxyQuery* theWrappedObject) const @@ -505,7 +505,7 @@ if (_wrapper) { } } } - + } bool PythonQtShell_QNetworkReply::atEnd() const { @@ -1267,7 +1267,7 @@ if (_wrapper) { return QNetworkReply::writeData(data0, len1); } QNetworkReply* PythonQtWrapper_QNetworkReply::new_QNetworkReply(QObject* parent) -{ +{ return new PythonQtShell_QNetworkReply(parent); } const QMetaObject* PythonQtShell_QNetworkReply::metaObject() const { @@ -1426,15 +1426,15 @@ QUrl PythonQtWrapper_QNetworkReply::url(QNetworkReply* theWrappedObject) const QNetworkRequest* PythonQtWrapper_QNetworkRequest::new_QNetworkRequest() -{ +{ return new QNetworkRequest(); } QNetworkRequest* PythonQtWrapper_QNetworkRequest::new_QNetworkRequest(const QNetworkRequest& other) -{ +{ return new QNetworkRequest(other); } QNetworkRequest* PythonQtWrapper_QNetworkRequest::new_QNetworkRequest(const QUrl& url) -{ +{ return new QNetworkRequest(url); } QVariant PythonQtWrapper_QNetworkRequest::attribute(QNetworkRequest* theWrappedObject, QNetworkRequest::Attribute code, const QVariant& defaultValue) const @@ -1755,7 +1755,7 @@ if (_wrapper) { QNetworkSession::timerEvent(event0); } QNetworkSession* PythonQtWrapper_QNetworkSession::new_QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent) -{ +{ return new PythonQtShell_QNetworkSession(connConfig, parent); } const QMetaObject* PythonQtShell_QNetworkSession::metaObject() const { @@ -1849,11 +1849,11 @@ bool PythonQtWrapper_QNetworkSession::waitForOpened(QNetworkSession* theWrapped QOcspResponse* PythonQtWrapper_QOcspResponse::new_QOcspResponse() -{ +{ return new QOcspResponse(); } QOcspResponse* PythonQtWrapper_QOcspResponse::new_QOcspResponse(const QOcspResponse& other) -{ +{ return new QOcspResponse(other); } QOcspCertificateStatus PythonQtWrapper_QOcspResponse::certificateStatus(QOcspResponse* theWrappedObject) const @@ -1899,15 +1899,15 @@ void PythonQtWrapper_QOcspResponse::swap(QOcspResponse* theWrappedObject, QOcspR #ifndef QT_NO_SSL QSslCertificate* PythonQtWrapper_QSslCertificate::new_QSslCertificate(QIODevice* device, QSsl::EncodingFormat format) -{ +{ return new QSslCertificate(device, format); } QSslCertificate* PythonQtWrapper_QSslCertificate::new_QSslCertificate(const QByteArray& data, QSsl::EncodingFormat format) -{ +{ return new QSslCertificate(data, format); } QSslCertificate* PythonQtWrapper_QSslCertificate::new_QSslCertificate(const QSslCertificate& other) -{ +{ return new QSslCertificate(other); } void PythonQtWrapper_QSslCertificate::clear(QSslCertificate* theWrappedObject) @@ -2092,11 +2092,11 @@ QString PythonQtWrapper_QSslCertificate::py_toString(QSslCertificate* obj) { #ifndef QT_NO_SSL QSslCertificateExtension* PythonQtWrapper_QSslCertificateExtension::new_QSslCertificateExtension() -{ +{ return new QSslCertificateExtension(); } QSslCertificateExtension* PythonQtWrapper_QSslCertificateExtension::new_QSslCertificateExtension(const QSslCertificateExtension& other) -{ +{ return new QSslCertificateExtension(other); } bool PythonQtWrapper_QSslCertificateExtension::isCritical(QSslCertificateExtension* theWrappedObject) const @@ -2139,19 +2139,19 @@ QVariant PythonQtWrapper_QSslCertificateExtension::value(QSslCertificateExtensi #ifndef QT_NO_SSL QSslCipher* PythonQtWrapper_QSslCipher::new_QSslCipher() -{ +{ return new QSslCipher(); } QSslCipher* PythonQtWrapper_QSslCipher::new_QSslCipher(const QSslCipher& other) -{ +{ return new QSslCipher(other); } QSslCipher* PythonQtWrapper_QSslCipher::new_QSslCipher(const QString& name) -{ +{ return new QSslCipher(name); } QSslCipher* PythonQtWrapper_QSslCipher::new_QSslCipher(const QString& name, QSsl::SslProtocol protocol) -{ +{ return new QSslCipher(name, protocol); } QString PythonQtWrapper_QSslCipher::authenticationMethod(QSslCipher* theWrappedObject) const @@ -2235,11 +2235,11 @@ PythonQtShell_QSslConfiguration::~PythonQtShell_QSslConfiguration() { if (priv) { priv->shellClassDeleted(this); } } QSslConfiguration* PythonQtWrapper_QSslConfiguration::new_QSslConfiguration() -{ +{ return new PythonQtShell_QSslConfiguration(); } QSslConfiguration* PythonQtWrapper_QSslConfiguration::new_QSslConfiguration(const QSslConfiguration& other) -{ +{ return new PythonQtShell_QSslConfiguration(other); } void PythonQtWrapper_QSslConfiguration::addCaCertificate(QSslConfiguration* theWrappedObject, const QSslCertificate& certificate) @@ -2537,11 +2537,11 @@ bool PythonQtWrapper_QSslConfiguration::testSslOption(QSslConfiguration* theWra #ifndef QT_NO_SSL QSslDiffieHellmanParameters* PythonQtWrapper_QSslDiffieHellmanParameters::new_QSslDiffieHellmanParameters() -{ +{ return new QSslDiffieHellmanParameters(); } QSslDiffieHellmanParameters* PythonQtWrapper_QSslDiffieHellmanParameters::new_QSslDiffieHellmanParameters(const QSslDiffieHellmanParameters& other) -{ +{ return new QSslDiffieHellmanParameters(other); } QSslDiffieHellmanParameters PythonQtWrapper_QSslDiffieHellmanParameters::static_QSslDiffieHellmanParameters_defaultParameters() @@ -2611,7 +2611,7 @@ QString PythonQtWrapper_QSslDiffieHellmanParameters::py_toString(QSslDiffieHellm #ifndef QT_NO_SSL QSslEllipticCurve* PythonQtWrapper_QSslEllipticCurve::new_QSslEllipticCurve() -{ +{ return new QSslEllipticCurve(); } QSslEllipticCurve PythonQtWrapper_QSslEllipticCurve::static_QSslEllipticCurve_fromLongName(const QString& name) @@ -2666,19 +2666,19 @@ QString PythonQtWrapper_QSslEllipticCurve::py_toString(QSslEllipticCurve* obj) { #ifndef QT_NO_SSL QSslError* PythonQtWrapper_QSslError::new_QSslError() -{ +{ return new QSslError(); } QSslError* PythonQtWrapper_QSslError::new_QSslError(QSslError::SslError error) -{ +{ return new QSslError(error); } QSslError* PythonQtWrapper_QSslError::new_QSslError(QSslError::SslError error, const QSslCertificate& certificate) -{ +{ return new QSslError(error, certificate); } QSslError* PythonQtWrapper_QSslError::new_QSslError(const QSslError& other) -{ +{ return new QSslError(other); } QSslCertificate PythonQtWrapper_QSslError::certificate(QSslError* theWrappedObject) const @@ -2728,23 +2728,23 @@ QString PythonQtWrapper_QSslError::py_toString(QSslError* obj) { #ifndef QT_NO_SSL QSslKey* PythonQtWrapper_QSslKey::new_QSslKey() -{ +{ return new QSslKey(); } QSslKey* PythonQtWrapper_QSslKey::new_QSslKey(QIODevice* device, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format, QSsl::KeyType type, const QByteArray& passPhrase) -{ +{ return new QSslKey(device, algorithm, format, type, passPhrase); } QSslKey* PythonQtWrapper_QSslKey::new_QSslKey(Qt::HANDLE handle, QSsl::KeyType type) -{ +{ return new QSslKey(handle, type); } QSslKey* PythonQtWrapper_QSslKey::new_QSslKey(const QByteArray& encoded, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format, QSsl::KeyType type, const QByteArray& passPhrase) -{ +{ return new QSslKey(encoded, algorithm, format, type, passPhrase); } QSslKey* PythonQtWrapper_QSslKey::new_QSslKey(const QSslKey& other) -{ +{ return new QSslKey(other); } QSsl::KeyAlgorithm PythonQtWrapper_QSslKey::algorithm(QSslKey* theWrappedObject) const @@ -2819,11 +2819,11 @@ QString PythonQtWrapper_QSslKey::py_toString(QSslKey* obj) { #ifndef QT_NO_SSL QSslPreSharedKeyAuthenticator* PythonQtWrapper_QSslPreSharedKeyAuthenticator::new_QSslPreSharedKeyAuthenticator() -{ +{ return new QSslPreSharedKeyAuthenticator(); } QSslPreSharedKeyAuthenticator* PythonQtWrapper_QSslPreSharedKeyAuthenticator::new_QSslPreSharedKeyAuthenticator(const QSslPreSharedKeyAuthenticator& authenticator) -{ +{ return new QSslPreSharedKeyAuthenticator(authenticator); } QByteArray PythonQtWrapper_QSslPreSharedKeyAuthenticator::identity(QSslPreSharedKeyAuthenticator* theWrappedObject) const @@ -3809,7 +3809,7 @@ if (_wrapper) { return QSslSocket::writeData(data0, len1); } QSslSocket* PythonQtWrapper_QSslSocket::new_QSslSocket(QObject* parent) -{ +{ return new PythonQtShell_QSslSocket(parent); } const QMetaObject* PythonQtShell_QSslSocket::metaObject() const { @@ -4338,7 +4338,7 @@ if (_wrapper) { QTcpServer::timerEvent(event0); } QTcpServer* PythonQtWrapper_QTcpServer::new_QTcpServer(QObject* parent) -{ +{ return new PythonQtShell_QTcpServer(parent); } const QMetaObject* PythonQtShell_QTcpServer::metaObject() const { @@ -5407,7 +5407,7 @@ if (_wrapper) { return QTcpSocket::writeData(data0, len1); } QTcpSocket* PythonQtWrapper_QTcpSocket::new_QTcpSocket(QObject* parent) -{ +{ return new PythonQtShell_QTcpSocket(parent); } const QMetaObject* PythonQtShell_QTcpSocket::metaObject() const { @@ -6376,7 +6376,7 @@ if (_wrapper) { return QUdpSocket::writeData(data0, len1); } QUdpSocket* PythonQtWrapper_QUdpSocket::new_QUdpSocket(QObject* parent) -{ +{ return new PythonQtShell_QUdpSocket(parent); } const QMetaObject* PythonQtShell_QUdpSocket::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network_init.cpp b/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network_init.cpp index fd46f3949..a026d259d 100644 --- a/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network_init.cpp +++ b/generated_cpp_515/com_trolltech_qt_network/com_trolltech_qt_network_init.cpp @@ -80,7 +80,7 @@ PythonQt::priv()->registerClass(&QSslSocket::staticMetaObject, "QtNetwork", Pyth PythonQt::priv()->registerClass(&QTcpServer::staticMetaObject, "QtNetwork", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerClass(&QTcpSocket::staticMetaObject, "QtNetwork", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, PythonQt::Type_NonZero); PythonQt::priv()->registerClass(&QUdpSocket::staticMetaObject, "QtNetwork", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, PythonQt::Type_NonZero); -PythonQt::priv()->registerGlobalNamespace("QtNetwork", "QtNetwork", PythonQtCreateObject, PythonQtWrapper_QtNetwork::staticMetaObject, module); +PythonQt::priv()->registerGlobalNamespace("QtNetwork", "QtNetwork", PythonQtCreateObject, PythonQtWrapper_QtNetwork::staticMetaObject, module); PythonQtRegisterListTemplateConverterForKnownClass(QList, QDnsDomainNameRecord); diff --git a/generated_cpp_515/com_trolltech_qt_opengl/com_trolltech_qt_opengl0.cpp b/generated_cpp_515/com_trolltech_qt_opengl/com_trolltech_qt_opengl0.cpp index 1abe64b30..373e13e01 100644 --- a/generated_cpp_515/com_trolltech_qt_opengl/com_trolltech_qt_opengl0.cpp +++ b/generated_cpp_515/com_trolltech_qt_opengl/com_trolltech_qt_opengl0.cpp @@ -57,15 +57,15 @@ #include QGLBuffer* PythonQtWrapper_QGLBuffer::new_QGLBuffer() -{ +{ return new QGLBuffer(); } QGLBuffer* PythonQtWrapper_QGLBuffer::new_QGLBuffer(QGLBuffer::Type type) -{ +{ return new QGLBuffer(type); } QGLBuffer* PythonQtWrapper_QGLBuffer::new_QGLBuffer(const QGLBuffer& other) -{ +{ return new QGLBuffer(other); } void PythonQtWrapper_QGLBuffer::allocate(QGLBuffer* theWrappedObject, const void* data, int count) @@ -165,11 +165,11 @@ PythonQtShell_QGLColormap::~PythonQtShell_QGLColormap() { if (priv) { priv->shellClassDeleted(this); } } QGLColormap* PythonQtWrapper_QGLColormap::new_QGLColormap() -{ +{ return new PythonQtShell_QGLColormap(); } QGLColormap* PythonQtWrapper_QGLColormap::new_QGLColormap(const QGLColormap& arg__1) -{ +{ return new PythonQtShell_QGLColormap(arg__1); } QColor PythonQtWrapper_QGLColormap::entryColor(QGLColormap* theWrappedObject, int idx) const @@ -361,11 +361,11 @@ if (_wrapper) { QGLContext::swapBuffers(); } QGLContext* PythonQtWrapper_QGLContext::new_QGLContext(const QGLFormat& format) -{ +{ return new PythonQtShell_QGLContext(format); } QGLContext* PythonQtWrapper_QGLContext::new_QGLContext(const QGLFormat& format, QPaintDevice* device) -{ +{ return new PythonQtShell_QGLContext(format, device); } bool PythonQtWrapper_QGLContext::static_QGLContext_areSharing(const QGLContext* context1, const QGLContext* context2) @@ -551,15 +551,15 @@ bool PythonQtWrapper_QGLContext::windowCreated(QGLContext* theWrappedObject) co QGLFormat* PythonQtWrapper_QGLFormat::new_QGLFormat() -{ +{ return new QGLFormat(); } QGLFormat* PythonQtWrapper_QGLFormat::new_QGLFormat(QGL::FormatOptions options, int plane) -{ +{ return new QGLFormat(options, plane); } QGLFormat* PythonQtWrapper_QGLFormat::new_QGLFormat(const QGLFormat& other) -{ +{ return new QGLFormat(other); } bool PythonQtWrapper_QGLFormat::accum(QGLFormat* theWrappedObject) const @@ -1053,27 +1053,27 @@ if (_wrapper) { return QGLFramebufferObject::sharedPainter(); } QGLFramebufferObject* PythonQtWrapper_QGLFramebufferObject::new_QGLFramebufferObject(const QSize& size, GLenum target) -{ +{ return new PythonQtShell_QGLFramebufferObject(size, target); } QGLFramebufferObject* PythonQtWrapper_QGLFramebufferObject::new_QGLFramebufferObject(const QSize& size, QGLFramebufferObject::Attachment attachment, GLenum target, GLenum internal_format) -{ +{ return new PythonQtShell_QGLFramebufferObject(size, attachment, target, internal_format); } QGLFramebufferObject* PythonQtWrapper_QGLFramebufferObject::new_QGLFramebufferObject(const QSize& size, const QGLFramebufferObjectFormat& format) -{ +{ return new PythonQtShell_QGLFramebufferObject(size, format); } QGLFramebufferObject* PythonQtWrapper_QGLFramebufferObject::new_QGLFramebufferObject(int width, int height, GLenum target) -{ +{ return new PythonQtShell_QGLFramebufferObject(width, height, target); } QGLFramebufferObject* PythonQtWrapper_QGLFramebufferObject::new_QGLFramebufferObject(int width, int height, QGLFramebufferObject::Attachment attachment, GLenum target, GLenum internal_format) -{ +{ return new PythonQtShell_QGLFramebufferObject(width, height, attachment, target, internal_format); } QGLFramebufferObject* PythonQtWrapper_QGLFramebufferObject::new_QGLFramebufferObject(int width, int height, const QGLFramebufferObjectFormat& format) -{ +{ return new PythonQtShell_QGLFramebufferObject(width, height, format); } QGLFramebufferObject::Attachment PythonQtWrapper_QGLFramebufferObject::attachment(QGLFramebufferObject* theWrappedObject) const @@ -1159,11 +1159,11 @@ QImage PythonQtWrapper_QGLFramebufferObject::toImage(QGLFramebufferObject* theW QGLFramebufferObjectFormat* PythonQtWrapper_QGLFramebufferObjectFormat::new_QGLFramebufferObjectFormat() -{ +{ return new QGLFramebufferObjectFormat(); } QGLFramebufferObjectFormat* PythonQtWrapper_QGLFramebufferObjectFormat::new_QGLFramebufferObjectFormat(const QGLFramebufferObjectFormat& other) -{ +{ return new QGLFramebufferObjectFormat(other); } QGLFramebufferObject::Attachment PythonQtWrapper_QGLFramebufferObjectFormat::attachment(QGLFramebufferObjectFormat* theWrappedObject) const @@ -1234,11 +1234,11 @@ GLenum PythonQtWrapper_QGLFramebufferObjectFormat::textureTarget(QGLFramebuffer QGLFunctions* PythonQtWrapper_QGLFunctions::new_QGLFunctions() -{ +{ return new QGLFunctions(); } QGLFunctions* PythonQtWrapper_QGLFunctions::new_QGLFunctions(const QGLContext* context) -{ +{ return new QGLFunctions(context); } void PythonQtWrapper_QGLFunctions::glActiveTexture(QGLFunctions* theWrappedObject, GLenum texture) @@ -1925,11 +1925,11 @@ if (_wrapper) { return QGLPixelBuffer::sharedPainter(); } QGLPixelBuffer* PythonQtWrapper_QGLPixelBuffer::new_QGLPixelBuffer(const QSize& size, const QGLFormat& format, QGLWidget* shareWidget) -{ +{ return new PythonQtShell_QGLPixelBuffer(size, format, shareWidget); } QGLPixelBuffer* PythonQtWrapper_QGLPixelBuffer::new_QGLPixelBuffer(int width, int height, const QGLFormat& format, QGLWidget* shareWidget) -{ +{ return new PythonQtShell_QGLPixelBuffer(width, height, format, shareWidget); } uint PythonQtWrapper_QGLPixelBuffer::bindTexture(QGLPixelBuffer* theWrappedObject, const QImage& image, GLenum target) @@ -2166,11 +2166,11 @@ if (_wrapper) { QGLShader::timerEvent(event0); } QGLShader* PythonQtWrapper_QGLShader::new_QGLShader(QGLShader::ShaderType type, QObject* parent) -{ +{ return new PythonQtShell_QGLShader(type, parent); } QGLShader* PythonQtWrapper_QGLShader::new_QGLShader(QGLShader::ShaderType type, const QGLContext* context, QObject* parent) -{ +{ return new PythonQtShell_QGLShader(type, context, parent); } const QMetaObject* PythonQtShell_QGLShader::metaObject() const { @@ -2408,11 +2408,11 @@ if (_wrapper) { QGLShaderProgram::timerEvent(event0); } QGLShaderProgram* PythonQtWrapper_QGLShaderProgram::new_QGLShaderProgram(QObject* parent) -{ +{ return new PythonQtShell_QGLShaderProgram(parent); } QGLShaderProgram* PythonQtWrapper_QGLShaderProgram::new_QGLShaderProgram(const QGLContext* context, QObject* parent) -{ +{ return new PythonQtShell_QGLShaderProgram(context, parent); } const QMetaObject* PythonQtShell_QGLShaderProgram::metaObject() const { @@ -4354,15 +4354,15 @@ if (_wrapper) { QGLWidget::wheelEvent(event0); } QGLWidget* PythonQtWrapper_QGLWidget::new_QGLWidget(QGLContext* context, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QGLWidget(context, parent, shareWidget, f); } QGLWidget* PythonQtWrapper_QGLWidget::new_QGLWidget(QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QGLWidget(parent, shareWidget, f); } QGLWidget* PythonQtWrapper_QGLWidget::new_QGLWidget(const QGLFormat& format, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f) -{ +{ return new PythonQtShell_QGLWidget(format, parent, shareWidget, f); } const QMetaObject* PythonQtShell_QGLWidget::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_qml/com_trolltech_qt_qml0.cpp b/generated_cpp_515/com_trolltech_qt_qml/com_trolltech_qt_qml0.cpp index 29ba06548..6303d08be 100644 --- a/generated_cpp_515/com_trolltech_qt_qml/com_trolltech_qt_qml0.cpp +++ b/generated_cpp_515/com_trolltech_qt_qml/com_trolltech_qt_qml0.cpp @@ -165,11 +165,11 @@ if (_wrapper) { QJSEngine::timerEvent(event0); } QJSEngine* PythonQtWrapper_QJSEngine::new_QJSEngine() -{ +{ return new PythonQtShell_QJSEngine(); } QJSEngine* PythonQtWrapper_QJSEngine::new_QJSEngine(QObject* parent) -{ +{ return new PythonQtShell_QJSEngine(parent); } const QMetaObject* PythonQtShell_QJSEngine::metaObject() const { @@ -268,35 +268,35 @@ QString PythonQtWrapper_QJSEngine::uiLanguage(QJSEngine* theWrappedObject) cons QJSValue* PythonQtWrapper_QJSValue::new_QJSValue(QJSValue::SpecialValue value) -{ +{ return new QJSValue(value); } QJSValue* PythonQtWrapper_QJSValue::new_QJSValue(bool value) -{ +{ return new QJSValue(value); } QJSValue* PythonQtWrapper_QJSValue::new_QJSValue(const QJSValue& other) -{ +{ return new QJSValue(other); } QJSValue* PythonQtWrapper_QJSValue::new_QJSValue(const QString& value) -{ +{ return new QJSValue(value); } QJSValue* PythonQtWrapper_QJSValue::new_QJSValue(const char* str) -{ +{ return new QJSValue(str); } QJSValue* PythonQtWrapper_QJSValue::new_QJSValue(double value) -{ +{ return new QJSValue(value); } QJSValue* PythonQtWrapper_QJSValue::new_QJSValue(int value) -{ +{ return new QJSValue(value); } QJSValue* PythonQtWrapper_QJSValue::new_QJSValue(uint value) -{ +{ return new QJSValue(value); } QJSValue PythonQtWrapper_QJSValue::call(QJSValue* theWrappedObject, const QList& args) @@ -540,7 +540,7 @@ if (_wrapper) { return QUrl(); } QQmlAbstractUrlInterceptor* PythonQtWrapper_QQmlAbstractUrlInterceptor::new_QQmlAbstractUrlInterceptor() -{ +{ return new PythonQtShell_QQmlAbstractUrlInterceptor(); } QUrl PythonQtWrapper_QQmlAbstractUrlInterceptor::intercept(QQmlAbstractUrlInterceptor* theWrappedObject, const QUrl& path, QQmlAbstractUrlInterceptor::DataType type) @@ -687,15 +687,15 @@ if (_wrapper) { QQmlApplicationEngine::timerEvent(event0); } QQmlApplicationEngine* PythonQtWrapper_QQmlApplicationEngine::new_QQmlApplicationEngine(QObject* parent) -{ +{ return new PythonQtShell_QQmlApplicationEngine(parent); } QQmlApplicationEngine* PythonQtWrapper_QQmlApplicationEngine::new_QQmlApplicationEngine(const QString& filePath, QObject* parent) -{ +{ return new PythonQtShell_QQmlApplicationEngine(filePath, parent); } QQmlApplicationEngine* PythonQtWrapper_QQmlApplicationEngine::new_QQmlApplicationEngine(const QUrl& url, QObject* parent) -{ +{ return new PythonQtShell_QQmlApplicationEngine(url, parent); } const QMetaObject* PythonQtShell_QQmlApplicationEngine::metaObject() const { @@ -948,27 +948,27 @@ if (_wrapper) { QQmlComponent::timerEvent(event0); } QQmlComponent* PythonQtWrapper_QQmlComponent::new_QQmlComponent(QObject* parent) -{ +{ return new PythonQtShell_QQmlComponent(parent); } QQmlComponent* PythonQtWrapper_QQmlComponent::new_QQmlComponent(QQmlEngine* arg__1, QObject* parent) -{ +{ return new PythonQtShell_QQmlComponent(arg__1, parent); } QQmlComponent* PythonQtWrapper_QQmlComponent::new_QQmlComponent(QQmlEngine* arg__1, const QString& fileName, QObject* parent) -{ +{ return new PythonQtShell_QQmlComponent(arg__1, fileName, parent); } QQmlComponent* PythonQtWrapper_QQmlComponent::new_QQmlComponent(QQmlEngine* arg__1, const QString& fileName, QQmlComponent::CompilationMode mode, QObject* parent) -{ +{ return new PythonQtShell_QQmlComponent(arg__1, fileName, mode, parent); } QQmlComponent* PythonQtWrapper_QQmlComponent::new_QQmlComponent(QQmlEngine* arg__1, const QUrl& url, QObject* parent) -{ +{ return new PythonQtShell_QQmlComponent(arg__1, url, parent); } QQmlComponent* PythonQtWrapper_QQmlComponent::new_QQmlComponent(QQmlEngine* arg__1, const QUrl& url, QQmlComponent::CompilationMode mode, QObject* parent) -{ +{ return new PythonQtShell_QQmlComponent(arg__1, url, mode, parent); } const QMetaObject* PythonQtShell_QQmlComponent::metaObject() const { @@ -1208,11 +1208,11 @@ if (_wrapper) { QQmlContext::timerEvent(event0); } QQmlContext* PythonQtWrapper_QQmlContext::new_QQmlContext(QQmlContext* parent, QObject* objParent) -{ +{ return new PythonQtShell_QQmlContext(parent, objParent); } QQmlContext* PythonQtWrapper_QQmlContext::new_QQmlContext(QQmlEngine* parent, QObject* objParent) -{ +{ return new PythonQtShell_QQmlContext(parent, objParent); } const QMetaObject* PythonQtShell_QQmlContext::metaObject() const { @@ -1291,7 +1291,7 @@ void PythonQtWrapper_QQmlContext::setContextProperty(QQmlContext* theWrappedObje QQmlDebuggingEnabler* PythonQtWrapper_QQmlDebuggingEnabler::new_QQmlDebuggingEnabler(bool printWarning) -{ +{ return new QQmlDebuggingEnabler(printWarning); } bool PythonQtWrapper_QQmlDebuggingEnabler::static_QQmlDebuggingEnabler_connectToLocalDebugger(const QString& socketFileName, QQmlDebuggingEnabler::StartMode mode) @@ -1473,7 +1473,7 @@ if (_wrapper) { QQmlEngine::timerEvent(event0); } QQmlEngine* PythonQtWrapper_QQmlEngine::new_QQmlEngine(QObject* p) -{ +{ return new PythonQtShell_QQmlEngine(p); } const QMetaObject* PythonQtShell_QQmlEngine::metaObject() const { @@ -1642,11 +1642,11 @@ QQmlAbstractUrlInterceptor* PythonQtWrapper_QQmlEngine::urlInterceptor(QQmlEngi QQmlError* PythonQtWrapper_QQmlError::new_QQmlError() -{ +{ return new QQmlError(); } QQmlError* PythonQtWrapper_QQmlError::new_QQmlError(const QQmlError& arg__1) -{ +{ return new QQmlError(arg__1); } int PythonQtWrapper_QQmlError::column(QQmlError* theWrappedObject) const @@ -1864,15 +1864,15 @@ if (_wrapper) { QQmlExpression::timerEvent(event0); } QQmlExpression* PythonQtWrapper_QQmlExpression::new_QQmlExpression() -{ +{ return new PythonQtShell_QQmlExpression(); } QQmlExpression* PythonQtWrapper_QQmlExpression::new_QQmlExpression(QQmlContext* arg__1, QObject* arg__2, const QString& arg__3, QObject* arg__4) -{ +{ return new PythonQtShell_QQmlExpression(arg__1, arg__2, arg__3, arg__4); } QQmlExpression* PythonQtWrapper_QQmlExpression::new_QQmlExpression(const QQmlScriptString& arg__1, QQmlContext* arg__2, QObject* arg__3, QObject* arg__4) -{ +{ return new PythonQtShell_QQmlExpression(arg__1, arg__2, arg__3, arg__4); } const QMetaObject* PythonQtShell_QQmlExpression::metaObject() const { @@ -1989,7 +1989,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QQmlExtensionInterface::registerTypes(const char* uri0) { @@ -2011,10 +2011,10 @@ if (_wrapper) { } } } - + } QQmlExtensionInterface* PythonQtWrapper_QQmlExtensionInterface::new_QQmlExtensionInterface() -{ +{ return new PythonQtShell_QQmlExtensionInterface(); } void PythonQtWrapper_QQmlExtensionInterface::initializeEngine(QQmlExtensionInterface* theWrappedObject, QQmlEngine* engine, const char* uri) @@ -2070,10 +2070,10 @@ if (_wrapper) { } } } - + } QQmlExtensionPlugin* PythonQtWrapper_QQmlExtensionPlugin::new_QQmlExtensionPlugin(QObject* parent) -{ +{ return new PythonQtShell_QQmlExtensionPlugin(parent); } const QMetaObject* PythonQtShell_QQmlExtensionPlugin::metaObject() const { @@ -2107,15 +2107,15 @@ void PythonQtWrapper_QQmlExtensionPlugin::registerTypes(QQmlExtensionPlugin* the QQmlFile* PythonQtWrapper_QQmlFile::new_QQmlFile() -{ +{ return new QQmlFile(); } QQmlFile* PythonQtWrapper_QQmlFile::new_QQmlFile(QQmlEngine* arg__1, const QString& arg__2) -{ +{ return new QQmlFile(arg__1, arg__2); } QQmlFile* PythonQtWrapper_QQmlFile::new_QQmlFile(QQmlEngine* arg__1, const QUrl& arg__2) -{ +{ return new QQmlFile(arg__1, arg__2); } void PythonQtWrapper_QQmlFile::clear(QQmlFile* theWrappedObject) @@ -2377,7 +2377,7 @@ if (_wrapper) { QQmlFileSelector::timerEvent(event0); } QQmlFileSelector* PythonQtWrapper_QQmlFileSelector::new_QQmlFileSelector(QQmlEngine* engine, QObject* parent) -{ +{ return new PythonQtShell_QQmlFileSelector(engine, parent); } const QMetaObject* PythonQtShell_QQmlFileSelector::metaObject() const { @@ -2447,7 +2447,7 @@ if (_wrapper) { QQmlIncubationController::incubatingObjectCountChanged(arg__1); } QQmlIncubationController* PythonQtWrapper_QQmlIncubationController::new_QQmlIncubationController() -{ +{ return new PythonQtShell_QQmlIncubationController(); } QQmlEngine* PythonQtWrapper_QQmlIncubationController::engine(QQmlIncubationController* theWrappedObject) const @@ -2526,7 +2526,7 @@ if (_wrapper) { QQmlIncubator::statusChanged(arg__1); } QQmlIncubator* PythonQtWrapper_QQmlIncubator::new_QQmlIncubator(QQmlIncubator::IncubationMode arg__1) -{ +{ return new PythonQtShell_QQmlIncubator(arg__1); } void PythonQtWrapper_QQmlIncubator::clear(QQmlIncubator* theWrappedObject) @@ -2597,7 +2597,7 @@ void PythonQtWrapper_QQmlIncubator::statusChanged(QQmlIncubator* theWrappedObjec QQmlInfo* PythonQtWrapper_QQmlInfo::new_QQmlInfo(const QQmlInfo& arg__1) -{ +{ return new QQmlInfo(arg__1); } QQmlInfo* PythonQtWrapper_QQmlInfo::__lshift__(QQmlInfo* theWrappedObject, QChar t) @@ -2693,15 +2693,15 @@ QQmlInfo* PythonQtWrapper_QQmlInfo::__lshift__(QQmlInfo* theWrappedObject, unsi QQmlListReference* PythonQtWrapper_QQmlListReference::new_QQmlListReference() -{ +{ return new QQmlListReference(); } QQmlListReference* PythonQtWrapper_QQmlListReference::new_QQmlListReference(QObject* arg__1, const char* property, QQmlEngine* arg__3) -{ +{ return new QQmlListReference(arg__1, property, arg__3); } QQmlListReference* PythonQtWrapper_QQmlListReference::new_QQmlListReference(const QQmlListReference& arg__1) -{ +{ return new QQmlListReference(arg__1); } bool PythonQtWrapper_QQmlListReference::append(QQmlListReference* theWrappedObject, QObject* arg__1) const @@ -2834,7 +2834,7 @@ if (_wrapper) { return nullptr; } QQmlNetworkAccessManagerFactory* PythonQtWrapper_QQmlNetworkAccessManagerFactory::new_QQmlNetworkAccessManagerFactory() -{ +{ return new PythonQtShell_QQmlNetworkAccessManagerFactory(); } QNetworkAccessManager* PythonQtWrapper_QQmlNetworkAccessManagerFactory::create(QQmlNetworkAccessManagerFactory* theWrappedObject, QObject* parent) @@ -2868,7 +2868,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QQmlParserStatus::componentComplete() { @@ -2890,10 +2890,10 @@ if (_wrapper) { } } } - + } QQmlParserStatus* PythonQtWrapper_QQmlParserStatus::new_QQmlParserStatus() -{ +{ return new PythonQtShell_QQmlParserStatus(); } void PythonQtWrapper_QQmlParserStatus::classBegin(QQmlParserStatus* theWrappedObject) @@ -2909,35 +2909,35 @@ void PythonQtWrapper_QQmlParserStatus::componentComplete(QQmlParserStatus* theWr QQmlProperty* PythonQtWrapper_QQmlProperty::new_QQmlProperty() -{ +{ return new QQmlProperty(); } QQmlProperty* PythonQtWrapper_QQmlProperty::new_QQmlProperty(QObject* arg__1) -{ +{ return new QQmlProperty(arg__1); } QQmlProperty* PythonQtWrapper_QQmlProperty::new_QQmlProperty(QObject* arg__1, QQmlContext* arg__2) -{ +{ return new QQmlProperty(arg__1, arg__2); } QQmlProperty* PythonQtWrapper_QQmlProperty::new_QQmlProperty(QObject* arg__1, QQmlEngine* arg__2) -{ +{ return new QQmlProperty(arg__1, arg__2); } QQmlProperty* PythonQtWrapper_QQmlProperty::new_QQmlProperty(QObject* arg__1, const QString& arg__2) -{ +{ return new QQmlProperty(arg__1, arg__2); } QQmlProperty* PythonQtWrapper_QQmlProperty::new_QQmlProperty(QObject* arg__1, const QString& arg__2, QQmlContext* arg__3) -{ +{ return new QQmlProperty(arg__1, arg__2, arg__3); } QQmlProperty* PythonQtWrapper_QQmlProperty::new_QQmlProperty(QObject* arg__1, const QString& arg__2, QQmlEngine* arg__3) -{ +{ return new QQmlProperty(arg__1, arg__2, arg__3); } QQmlProperty* PythonQtWrapper_QQmlProperty::new_QQmlProperty(const QQmlProperty& arg__1) -{ +{ return new QQmlProperty(arg__1); } bool PythonQtWrapper_QQmlProperty::connectNotifySignal(QQmlProperty* theWrappedObject, QObject* dest, const char* slot) const @@ -3262,7 +3262,7 @@ if (_wrapper) { return QQmlPropertyMap::updateValue(key0, input1); } QQmlPropertyMap* PythonQtWrapper_QQmlPropertyMap::new_QQmlPropertyMap(QObject* parent) -{ +{ return new PythonQtShell_QQmlPropertyMap(parent); } const QMetaObject* PythonQtShell_QQmlPropertyMap::metaObject() const { @@ -3354,10 +3354,10 @@ if (_wrapper) { } } } - + } QQmlPropertyValueSource* PythonQtWrapper_QQmlPropertyValueSource::new_QQmlPropertyValueSource() -{ +{ return new PythonQtShell_QQmlPropertyValueSource(); } void PythonQtWrapper_QQmlPropertyValueSource::setTarget(QQmlPropertyValueSource* theWrappedObject, const QQmlProperty& arg__1) @@ -3368,11 +3368,11 @@ void PythonQtWrapper_QQmlPropertyValueSource::setTarget(QQmlPropertyValueSource* QQmlScriptString* PythonQtWrapper_QQmlScriptString::new_QQmlScriptString() -{ +{ return new QQmlScriptString(); } QQmlScriptString* PythonQtWrapper_QQmlScriptString::new_QQmlScriptString(const QQmlScriptString& arg__1) -{ +{ return new QQmlScriptString(arg__1); } bool PythonQtWrapper_QQmlScriptString::booleanLiteral(QQmlScriptString* theWrappedObject, bool* ok) const @@ -3446,10 +3446,10 @@ if (_wrapper) { } } } - + } QQmlTypesExtensionInterface* PythonQtWrapper_QQmlTypesExtensionInterface::new_QQmlTypesExtensionInterface() -{ +{ return new PythonQtShell_QQmlTypesExtensionInterface(); } void PythonQtWrapper_QQmlTypesExtensionInterface::registerTypes(QQmlTypesExtensionInterface* theWrappedObject, const char* uri) diff --git a/generated_cpp_515/com_trolltech_qt_quick/com_trolltech_qt_quick0.cpp b/generated_cpp_515/com_trolltech_qt_quick/com_trolltech_qt_quick0.cpp index 16ffe705a..5c14c7aa9 100644 --- a/generated_cpp_515/com_trolltech_qt_quick/com_trolltech_qt_quick0.cpp +++ b/generated_cpp_515/com_trolltech_qt_quick/com_trolltech_qt_quick0.cpp @@ -977,7 +977,7 @@ if (_wrapper) { QQuickFramebufferObject::windowDeactivateEvent(); } QQuickFramebufferObject* PythonQtWrapper_QQuickFramebufferObject::new_QQuickFramebufferObject(QQuickItem* parent) -{ +{ return new PythonQtShell_QQuickFramebufferObject(parent); } const QMetaObject* PythonQtShell_QQuickFramebufferObject::metaObject() const { @@ -1077,7 +1077,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QQuickFramebufferObject__Renderer::synchronize(QQuickFramebufferObject* arg__1) { @@ -1102,7 +1102,7 @@ if (_wrapper) { QQuickFramebufferObject::Renderer::synchronize(arg__1); } QQuickFramebufferObject::Renderer* PythonQtWrapper_QQuickFramebufferObject__Renderer::new_QQuickFramebufferObject__Renderer() -{ +{ return new PythonQtShell_QQuickFramebufferObject__Renderer(); } QOpenGLFramebufferObject* PythonQtWrapper_QQuickFramebufferObject__Renderer::createFramebufferObject(QQuickFramebufferObject::Renderer* theWrappedObject, const QSize& size) @@ -2023,7 +2023,7 @@ if (_wrapper) { QQuickItem::windowDeactivateEvent(); } QQuickItem* PythonQtWrapper_QQuickItem::new_QQuickItem(QQuickItem* parent) -{ +{ return new PythonQtShell_QQuickItem(parent); } const QMetaObject* PythonQtShell_QQuickItem::metaObject() const { @@ -3472,7 +3472,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QQuickPaintedItem::releaseResources() { @@ -3673,7 +3673,7 @@ if (_wrapper) { QQuickPaintedItem::windowDeactivateEvent(); } QQuickPaintedItem* PythonQtWrapper_QQuickPaintedItem::new_QQuickPaintedItem(QQuickItem* parent) -{ +{ return new PythonQtShell_QQuickPaintedItem(parent); } const QMetaObject* PythonQtShell_QQuickPaintedItem::metaObject() const { @@ -3966,7 +3966,7 @@ if (_wrapper) { QQuickRenderControl::timerEvent(event0); } QQuickRenderControl* PythonQtWrapper_QQuickRenderControl::new_QQuickRenderControl(QObject* parent) -{ +{ return new PythonQtShell_QQuickRenderControl(parent); } const QMetaObject* PythonQtShell_QQuickRenderControl::metaObject() const { @@ -4166,7 +4166,7 @@ if (_wrapper) { QQuickTextDocument::timerEvent(event0); } QQuickTextDocument* PythonQtWrapper_QQuickTextDocument::new_QQuickTextDocument(QQuickItem* parent) -{ +{ return new PythonQtShell_QQuickTextDocument(parent); } const QMetaObject* PythonQtShell_QQuickTextDocument::metaObject() const { @@ -4213,7 +4213,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QQuickTransform::childEvent(QChildEvent* event0) { @@ -4348,7 +4348,7 @@ if (_wrapper) { QQuickTransform::timerEvent(event0); } QQuickTransform* PythonQtWrapper_QQuickTransform::new_QQuickTransform(QObject* parent) -{ +{ return new PythonQtShell_QQuickTransform(parent); } const QMetaObject* PythonQtShell_QQuickTransform::metaObject() const { @@ -5035,19 +5035,19 @@ if (_wrapper) { QQuickView::wheelEvent(arg__1); } QQuickView* PythonQtWrapper_QQuickView::new_QQuickView(QQmlEngine* engine, QWindow* parent) -{ +{ return new PythonQtShell_QQuickView(engine, parent); } QQuickView* PythonQtWrapper_QQuickView::new_QQuickView(QWindow* parent) -{ +{ return new PythonQtShell_QQuickView(parent); } QQuickView* PythonQtWrapper_QQuickView::new_QQuickView(const QUrl& source, QQuickRenderControl* renderControl) -{ +{ return new PythonQtShell_QQuickView(source, renderControl); } QQuickView* PythonQtWrapper_QQuickView::new_QQuickView(const QUrl& source, QWindow* parent) -{ +{ return new PythonQtShell_QQuickView(source, parent); } const QMetaObject* PythonQtShell_QQuickView::metaObject() const { @@ -6264,15 +6264,15 @@ if (_wrapper) { QQuickWidget::wheelEvent(arg__1); } QQuickWidget* PythonQtWrapper_QQuickWidget::new_QQuickWidget(QQmlEngine* engine, QWidget* parent) -{ +{ return new PythonQtShell_QQuickWidget(engine, parent); } QQuickWidget* PythonQtWrapper_QQuickWidget::new_QQuickWidget(QWidget* parent) -{ +{ return new PythonQtShell_QQuickWidget(parent); } QQuickWidget* PythonQtWrapper_QQuickWidget::new_QQuickWidget(const QUrl& source, QWidget* parent) -{ +{ return new PythonQtShell_QQuickWidget(source, parent); } const QMetaObject* PythonQtShell_QQuickWidget::metaObject() const { @@ -7019,11 +7019,11 @@ if (_wrapper) { QQuickWindow::wheelEvent(arg__1); } QQuickWindow* PythonQtWrapper_QQuickWindow::new_QQuickWindow(QQuickRenderControl* renderControl) -{ +{ return new PythonQtShell_QQuickWindow(renderControl); } QQuickWindow* PythonQtWrapper_QQuickWindow::new_QQuickWindow(QWindow* parent) -{ +{ return new PythonQtShell_QQuickWindow(parent); } const QMetaObject* PythonQtShell_QQuickWindow::metaObject() const { @@ -7238,7 +7238,7 @@ PythonQtShell_QQuickWindow__GraphicsStateInfo::~PythonQtShell_QQuickWindow__Grap if (priv) { priv->shellClassDeleted(this); } } QQuickWindow::GraphicsStateInfo* PythonQtWrapper_QQuickWindow__GraphicsStateInfo::new_QQuickWindow__GraphicsStateInfo() -{ +{ return new PythonQtShell_QQuickWindow__GraphicsStateInfo(); } @@ -7377,7 +7377,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QSGAbstractRenderer::renderScene(uint fboId0) { @@ -7399,7 +7399,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QSGAbstractRenderer::timerEvent(QTimerEvent* event0) { @@ -7424,7 +7424,7 @@ if (_wrapper) { QSGAbstractRenderer::timerEvent(event0); } QSGAbstractRenderer* PythonQtWrapper_QSGAbstractRenderer::new_QSGAbstractRenderer(QObject* parent) -{ +{ return new PythonQtShell_QSGAbstractRenderer(parent); } const QMetaObject* PythonQtShell_QSGAbstractRenderer::metaObject() const { @@ -7587,7 +7587,7 @@ if (_wrapper) { QSGBasicGeometryNode::preprocess(); } QSGBasicGeometryNode* PythonQtWrapper_QSGBasicGeometryNode::new_QSGBasicGeometryNode(QSGNode::NodeType type) -{ +{ return new PythonQtShell_QSGBasicGeometryNode(type); } const QSGClipNode* PythonQtWrapper_QSGBasicGeometryNode::clipList(QSGBasicGeometryNode* theWrappedObject) const @@ -7687,7 +7687,7 @@ if (_wrapper) { QSGClipNode::preprocess(); } QSGClipNode* PythonQtWrapper_QSGClipNode::new_QSGClipNode() -{ +{ return new PythonQtShell_QSGClipNode(); } QRectF PythonQtWrapper_QSGClipNode::clipRect(QSGClipNode* theWrappedObject) const @@ -7736,7 +7736,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QSGDynamicTexture::childEvent(QChildEvent* event0) { @@ -8135,7 +8135,7 @@ if (_wrapper) { return bool(); } QSGDynamicTexture* PythonQtWrapper_QSGDynamicTexture::new_QSGDynamicTexture() -{ +{ return new PythonQtShell_QSGDynamicTexture(); } const QMetaObject* PythonQtShell_QSGDynamicTexture::metaObject() const { @@ -8295,7 +8295,7 @@ if (_wrapper) { QSGEngine::timerEvent(event0); } QSGEngine* PythonQtWrapper_QSGEngine::new_QSGEngine(QObject* parent) -{ +{ return new PythonQtShell_QSGEngine(parent); } const QMetaObject* PythonQtShell_QSGEngine::metaObject() const { @@ -8381,7 +8381,7 @@ if (_wrapper) { return QSGFlatColorMaterial::type(); } QSGFlatColorMaterial* PythonQtWrapper_QSGFlatColorMaterial::new_QSGFlatColorMaterial() -{ +{ return new PythonQtShell_QSGFlatColorMaterial(); } const QColor* PythonQtWrapper_QSGFlatColorMaterial::color(QSGFlatColorMaterial* theWrappedObject) const @@ -8406,7 +8406,7 @@ PythonQtShell_QSGGeometry::~PythonQtShell_QSGGeometry() { if (priv) { priv->shellClassDeleted(this); } } QSGGeometry* PythonQtWrapper_QSGGeometry::new_QSGGeometry(const QSGGeometry::AttributeSet& attribs, int vertexCount, int indexCount, int indexType) -{ +{ return new PythonQtShell_QSGGeometry(attribs, vertexCount, indexCount, indexType); } void PythonQtWrapper_QSGGeometry::allocate(QSGGeometry* theWrappedObject, int vertexCount, int indexCount) @@ -8661,7 +8661,7 @@ if (_wrapper) { QSGGeometryNode::preprocess(); } QSGGeometryNode* PythonQtWrapper_QSGGeometryNode::new_QSGGeometryNode() -{ +{ return new PythonQtShell_QSGGeometryNode(); } qreal PythonQtWrapper_QSGGeometryNode::inheritedOpacity(QSGGeometryNode* theWrappedObject) const @@ -8698,7 +8698,7 @@ PythonQtShell_QSGGeometry__Attribute::~PythonQtShell_QSGGeometry__Attribute() { if (priv) { priv->shellClassDeleted(this); } } QSGGeometry::Attribute* PythonQtWrapper_QSGGeometry__Attribute::new_QSGGeometry__Attribute() -{ +{ return new PythonQtShell_QSGGeometry__Attribute(); } QSGGeometry::Attribute PythonQtWrapper_QSGGeometry__Attribute::static_QSGGeometry__Attribute_create(int pos, int tupleSize, int primitiveType, bool isPosition) @@ -8718,7 +8718,7 @@ PythonQtShell_QSGGeometry__AttributeSet::~PythonQtShell_QSGGeometry__AttributeSe if (priv) { priv->shellClassDeleted(this); } } QSGGeometry::AttributeSet* PythonQtWrapper_QSGGeometry__AttributeSet::new_QSGGeometry__AttributeSet() -{ +{ return new PythonQtShell_QSGGeometry__AttributeSet(); } @@ -8728,7 +8728,7 @@ PythonQtShell_QSGGeometry__ColoredPoint2D::~PythonQtShell_QSGGeometry__ColoredPo if (priv) { priv->shellClassDeleted(this); } } QSGGeometry::ColoredPoint2D* PythonQtWrapper_QSGGeometry__ColoredPoint2D::new_QSGGeometry__ColoredPoint2D() -{ +{ return new PythonQtShell_QSGGeometry__ColoredPoint2D(); } void PythonQtWrapper_QSGGeometry__ColoredPoint2D::set(QSGGeometry::ColoredPoint2D* theWrappedObject, float nx, float ny, uchar nr, uchar ng, uchar nb, uchar na) @@ -8743,7 +8743,7 @@ PythonQtShell_QSGGeometry__Point2D::~PythonQtShell_QSGGeometry__Point2D() { if (priv) { priv->shellClassDeleted(this); } } QSGGeometry::Point2D* PythonQtWrapper_QSGGeometry__Point2D::new_QSGGeometry__Point2D() -{ +{ return new PythonQtShell_QSGGeometry__Point2D(); } void PythonQtWrapper_QSGGeometry__Point2D::set(QSGGeometry::Point2D* theWrappedObject, float nx, float ny) @@ -8758,7 +8758,7 @@ PythonQtShell_QSGGeometry__TexturedPoint2D::~PythonQtShell_QSGGeometry__Textured if (priv) { priv->shellClassDeleted(this); } } QSGGeometry::TexturedPoint2D* PythonQtWrapper_QSGGeometry__TexturedPoint2D::new_QSGGeometry__TexturedPoint2D() -{ +{ return new PythonQtShell_QSGGeometry__TexturedPoint2D(); } void PythonQtWrapper_QSGGeometry__TexturedPoint2D::set(QSGGeometry::TexturedPoint2D* theWrappedObject, float nx, float ny, float ntx, float nty) @@ -8845,7 +8845,7 @@ PythonQtShell_QSGMaterialType::~PythonQtShell_QSGMaterialType() { if (priv) { priv->shellClassDeleted(this); } } QSGMaterialType* PythonQtWrapper_QSGMaterialType::new_QSGMaterialType() -{ +{ return new PythonQtShell_QSGMaterialType(); } @@ -8929,7 +8929,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QSGNinePatchNode::setDevicePixelRatio(qreal ratio0) { @@ -8951,7 +8951,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QSGNinePatchNode::setPadding(qreal left0, qreal top1, qreal right2, qreal bottom3) { @@ -8973,7 +8973,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QSGNinePatchNode::setTexture(QSGTexture* texture0) { @@ -8995,7 +8995,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QSGNinePatchNode::update() { @@ -9017,10 +9017,10 @@ if (_wrapper) { } } } - + } QSGNinePatchNode* PythonQtWrapper_QSGNinePatchNode::new_QSGNinePatchNode() -{ +{ return new PythonQtShell_QSGNinePatchNode(); } void PythonQtWrapper_QSGNinePatchNode::static_QSGNinePatchNode_rebuildGeometry(QSGTexture* texture, QSGGeometry* geometry, const QVector4D& padding, const QRectF& bounds, qreal dpr) diff --git a/generated_cpp_515/com_trolltech_qt_quick/com_trolltech_qt_quick1.cpp b/generated_cpp_515/com_trolltech_qt_quick/com_trolltech_qt_quick1.cpp index aef37912e..4c19aeacb 100644 --- a/generated_cpp_515/com_trolltech_qt_quick/com_trolltech_qt_quick1.cpp +++ b/generated_cpp_515/com_trolltech_qt_quick/com_trolltech_qt_quick1.cpp @@ -80,11 +80,11 @@ if (_wrapper) { QSGNode::preprocess(); } QSGNode* PythonQtWrapper_QSGNode::new_QSGNode() -{ +{ return new PythonQtShell_QSGNode(); } QSGNode* PythonQtWrapper_QSGNode::new_QSGNode(QSGNode::NodeType type) -{ +{ return new PythonQtShell_QSGNode(type); } void PythonQtWrapper_QSGNode::appendChildNode(QSGNode* theWrappedObject, QSGNode* node) @@ -426,7 +426,7 @@ if (_wrapper) { QSGNodeVisitor::visitNode(n0); } QSGNodeVisitor* PythonQtWrapper_QSGNodeVisitor::new_QSGNodeVisitor() -{ +{ return new PythonQtShell_QSGNodeVisitor(); } void PythonQtWrapper_QSGNodeVisitor::enterClipNode(QSGNodeVisitor* theWrappedObject, QSGClipNode* arg__1) @@ -541,7 +541,7 @@ if (_wrapper) { QSGOpacityNode::preprocess(); } QSGOpacityNode* PythonQtWrapper_QSGOpacityNode::new_QSGOpacityNode() -{ +{ return new PythonQtShell_QSGOpacityNode(); } qreal PythonQtWrapper_QSGOpacityNode::combinedOpacity(QSGOpacityNode* theWrappedObject) const @@ -718,7 +718,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QSGRectangleNode::setRect(const QRectF& rect0) { @@ -740,10 +740,10 @@ if (_wrapper) { } } } - + } QSGRectangleNode* PythonQtWrapper_QSGRectangleNode::new_QSGRectangleNode() -{ +{ return new PythonQtShell_QSGRectangleNode(); } QColor PythonQtWrapper_QSGRectangleNode::color(QSGRectangleNode* theWrappedObject) const @@ -907,10 +907,10 @@ if (_wrapper) { } } } - + } QSGRenderNode* PythonQtWrapper_QSGRenderNode::new_QSGRenderNode() -{ +{ return new PythonQtShell_QSGRenderNode(); } const QSGClipNode* PythonQtWrapper_QSGRenderNode::clipList(QSGRenderNode* theWrappedObject) const @@ -1181,7 +1181,7 @@ if (_wrapper) { return int(); } QSGRenderNode::RenderState* PythonQtWrapper_QSGRenderNode__RenderState::new_QSGRenderNode__RenderState() -{ +{ return new PythonQtShell_QSGRenderNode__RenderState(); } const QRegion* PythonQtWrapper_QSGRenderNode__RenderState::clipRegion(QSGRenderNode::RenderState* theWrappedObject) const @@ -1281,7 +1281,7 @@ if (_wrapper) { QSGRootNode::preprocess(); } QSGRootNode* PythonQtWrapper_QSGRootNode::new_QSGRootNode() -{ +{ return new PythonQtShell_QSGRootNode(); } QString PythonQtWrapper_QSGRootNode::py_toString(QSGRootNode* obj) { @@ -1317,7 +1317,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QSGTexture::childEvent(QChildEvent* event0) { @@ -1683,7 +1683,7 @@ if (_wrapper) { QSGTexture::timerEvent(event0); } QSGTexture* PythonQtWrapper_QSGTexture::new_QSGTexture() -{ +{ return new PythonQtShell_QSGTexture(); } const QMetaObject* PythonQtShell_QSGTexture::metaObject() const { @@ -1844,7 +1844,7 @@ if (_wrapper) { return QSGTextureMaterial::type(); } QSGTextureMaterial* PythonQtWrapper_QSGTextureMaterial::new_QSGTextureMaterial() -{ +{ return new PythonQtShell_QSGTextureMaterial(); } QSGMaterialType* PythonQtWrapper_QSGTextureMaterial::type(QSGTextureMaterial* theWrappedObject) const @@ -2024,7 +2024,7 @@ if (_wrapper) { QSGTextureProvider::timerEvent(event0); } QSGTextureProvider* PythonQtWrapper_QSGTextureProvider::new_QSGTextureProvider() -{ +{ return new PythonQtShell_QSGTextureProvider(); } const QMetaObject* PythonQtShell_QSGTextureProvider::metaObject() const { @@ -2107,7 +2107,7 @@ if (_wrapper) { QSGTransformNode::preprocess(); } QSGTransformNode* PythonQtWrapper_QSGTransformNode::new_QSGTransformNode() -{ +{ return new PythonQtShell_QSGTransformNode(); } const QMatrix4x4* PythonQtWrapper_QSGTransformNode::combinedMatrix(QSGTransformNode* theWrappedObject) const diff --git a/generated_cpp_515/com_trolltech_qt_sql/com_trolltech_qt_sql0.cpp b/generated_cpp_515/com_trolltech_qt_sql/com_trolltech_qt_sql0.cpp index 038809e75..da72df082 100644 --- a/generated_cpp_515/com_trolltech_qt_sql/com_trolltech_qt_sql0.cpp +++ b/generated_cpp_515/com_trolltech_qt_sql/com_trolltech_qt_sql0.cpp @@ -42,19 +42,19 @@ PythonQtShell_QSqlDatabase::~PythonQtShell_QSqlDatabase() { if (priv) { priv->shellClassDeleted(this); } } QSqlDatabase* PythonQtWrapper_QSqlDatabase::new_QSqlDatabase() -{ +{ return new PythonQtShell_QSqlDatabase(); } QSqlDatabase* PythonQtWrapper_QSqlDatabase::new_QSqlDatabase(QSqlDriver* driver) -{ +{ return new PythonQtShell_QSqlDatabase(driver); } QSqlDatabase* PythonQtWrapper_QSqlDatabase::new_QSqlDatabase(const QSqlDatabase& other) -{ +{ return new PythonQtShell_QSqlDatabase(other); } QSqlDatabase* PythonQtWrapper_QSqlDatabase::new_QSqlDatabase(const QString& type) -{ +{ return new PythonQtShell_QSqlDatabase(type); } QSqlDatabase PythonQtWrapper_QSqlDatabase::static_QSqlDatabase_addDatabase(QSqlDriver* driver, const QString& connectionName) @@ -388,7 +388,7 @@ if (_wrapper) { } } } - + } bool PythonQtShell_QSqlDriver::commitTransaction() { @@ -1161,7 +1161,7 @@ if (_wrapper) { return QSqlDriver::unsubscribeFromNotification(name0); } QSqlDriver* PythonQtWrapper_QSqlDriver::new_QSqlDriver(QObject* parent) -{ +{ return new PythonQtShell_QSqlDriver(parent); } const QMetaObject* PythonQtShell_QSqlDriver::metaObject() const { @@ -1357,7 +1357,7 @@ if (_wrapper) { return nullptr; } QSqlDriverCreatorBase* PythonQtWrapper_QSqlDriverCreatorBase::new_QSqlDriverCreatorBase() -{ +{ return new PythonQtShell_QSqlDriverCreatorBase(); } QSqlDriver* PythonQtWrapper_QSqlDriverCreatorBase::createObject(QSqlDriverCreatorBase* theWrappedObject) const @@ -1368,15 +1368,15 @@ QSqlDriver* PythonQtWrapper_QSqlDriverCreatorBase::createObject(QSqlDriverCreat QSqlError* PythonQtWrapper_QSqlError::new_QSqlError(const QSqlError& other) -{ +{ return new QSqlError(other); } QSqlError* PythonQtWrapper_QSqlError::new_QSqlError(const QString& driverText, const QString& databaseText, QSqlError::ErrorType type, const QString& errorCode) -{ +{ return new QSqlError(driverText, databaseText, type, errorCode); } QSqlError* PythonQtWrapper_QSqlError::new_QSqlError(const QString& driverText, const QString& databaseText, QSqlError::ErrorType type, int number) -{ +{ return new QSqlError(driverText, databaseText, type, number); } QString PythonQtWrapper_QSqlError::databaseText(QSqlError* theWrappedObject) const @@ -1459,15 +1459,15 @@ QString PythonQtWrapper_QSqlError::py_toString(QSqlError* obj) { QSqlField* PythonQtWrapper_QSqlField::new_QSqlField(const QSqlField& other) -{ +{ return new QSqlField(other); } QSqlField* PythonQtWrapper_QSqlField::new_QSqlField(const QString& fieldName, QVariant::Type type) -{ +{ return new QSqlField(fieldName, type); } QSqlField* PythonQtWrapper_QSqlField::new_QSqlField(const QString& fieldName, QVariant::Type type, const QString& tableName) -{ +{ return new QSqlField(fieldName, type, tableName); } void PythonQtWrapper_QSqlField::clear(QSqlField* theWrappedObject) @@ -1630,11 +1630,11 @@ QString PythonQtWrapper_QSqlField::py_toString(QSqlField* obj) { QSqlIndex* PythonQtWrapper_QSqlIndex::new_QSqlIndex(const QSqlIndex& other) -{ +{ return new QSqlIndex(other); } QSqlIndex* PythonQtWrapper_QSqlIndex::new_QSqlIndex(const QString& cursorName, const QString& name) -{ +{ return new QSqlIndex(cursorName, name); } void PythonQtWrapper_QSqlIndex::append(QSqlIndex* theWrappedObject, const QSqlField& field) @@ -1680,19 +1680,19 @@ void PythonQtWrapper_QSqlIndex::setName(QSqlIndex* theWrappedObject, const QStri QSqlQuery* PythonQtWrapper_QSqlQuery::new_QSqlQuery(QSqlDatabase db) -{ +{ return new QSqlQuery(db); } QSqlQuery* PythonQtWrapper_QSqlQuery::new_QSqlQuery(QSqlResult* r) -{ +{ return new QSqlQuery(r); } QSqlQuery* PythonQtWrapper_QSqlQuery::new_QSqlQuery(const QSqlQuery& other) -{ +{ return new QSqlQuery(other); } QSqlQuery* PythonQtWrapper_QSqlQuery::new_QSqlQuery(const QString& query, QSqlDatabase db) -{ +{ return new QSqlQuery(query, db); } void PythonQtWrapper_QSqlQuery::addBindValue(QSqlQuery* theWrappedObject, const QVariant& val, QSql::ParamType type) @@ -3129,7 +3129,7 @@ if (_wrapper) { QSqlQueryModel::timerEvent(event0); } QSqlQueryModel* PythonQtWrapper_QSqlQueryModel::new_QSqlQueryModel(QObject* parent) -{ +{ return new PythonQtShell_QSqlQueryModel(parent); } const QMetaObject* PythonQtShell_QSqlQueryModel::metaObject() const { @@ -3248,11 +3248,11 @@ void PythonQtWrapper_QSqlQueryModel::setQuery(QSqlQueryModel* theWrappedObject, QSqlRecord* PythonQtWrapper_QSqlRecord::new_QSqlRecord() -{ +{ return new QSqlRecord(); } QSqlRecord* PythonQtWrapper_QSqlRecord::new_QSqlRecord(const QSqlRecord& other) -{ +{ return new QSqlRecord(other); } void PythonQtWrapper_QSqlRecord::append(QSqlRecord* theWrappedObject, const QSqlField& field) @@ -3405,11 +3405,11 @@ QString PythonQtWrapper_QSqlRecord::py_toString(QSqlRecord* obj) { QSqlRelation* PythonQtWrapper_QSqlRelation::new_QSqlRelation() -{ +{ return new QSqlRelation(); } QSqlRelation* PythonQtWrapper_QSqlRelation::new_QSqlRelation(const QString& aTableName, const QString& indexCol, const QString& displayCol) -{ +{ return new QSqlRelation(aTableName, indexCol, displayCol); } QString PythonQtWrapper_QSqlRelation::displayColumn(QSqlRelation* theWrappedObject) const @@ -5072,7 +5072,7 @@ if (_wrapper) { return QSqlRelationalTableModel::updateRowInTable(row0, values1); } QSqlRelationalTableModel* PythonQtWrapper_QSqlRelationalTableModel::new_QSqlRelationalTableModel(QObject* parent, QSqlDatabase db) -{ +{ return new PythonQtShell_QSqlRelationalTableModel(parent, db); } const QMetaObject* PythonQtShell_QSqlRelationalTableModel::metaObject() const { @@ -5929,7 +5929,7 @@ if (_wrapper) { return int(); } QSqlResult* PythonQtWrapper_QSqlResult::new_QSqlResult(const QSqlDriver* db) -{ +{ return new PythonQtShell_QSqlResult(db); } void PythonQtWrapper_QSqlResult::addBindValue(QSqlResult* theWrappedObject, const QVariant& val, QSql::ParamType type) @@ -7762,7 +7762,7 @@ if (_wrapper) { return QSqlTableModel::updateRowInTable(row0, values1); } QSqlTableModel* PythonQtWrapper_QSqlTableModel::new_QSqlTableModel(QObject* parent, QSqlDatabase db) -{ +{ return new PythonQtShell_QSqlTableModel(parent, db); } const QMetaObject* PythonQtShell_QSqlTableModel::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_svg/com_trolltech_qt_svg0.cpp b/generated_cpp_515/com_trolltech_qt_svg/com_trolltech_qt_svg0.cpp index cf0ccd281..ee759567c 100644 --- a/generated_cpp_515/com_trolltech_qt_svg/com_trolltech_qt_svg0.cpp +++ b/generated_cpp_515/com_trolltech_qt_svg/com_trolltech_qt_svg0.cpp @@ -694,7 +694,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -1122,11 +1122,11 @@ if (_wrapper) { QGraphicsSvgItem::wheelEvent(event0); } QGraphicsSvgItem* PythonQtWrapper_QGraphicsSvgItem::new_QGraphicsSvgItem(QGraphicsItem* parentItem) -{ +{ return new PythonQtShell_QGraphicsSvgItem(parentItem); } QGraphicsSvgItem* PythonQtWrapper_QGraphicsSvgItem::new_QGraphicsSvgItem(const QString& fileName, QGraphicsItem* parentItem) -{ +{ return new PythonQtShell_QGraphicsSvgItem(fileName, parentItem); } const QMetaObject* PythonQtShell_QGraphicsSvgItem::metaObject() const { @@ -1376,7 +1376,7 @@ if (_wrapper) { return QSvgGenerator::sharedPainter(); } QSvgGenerator* PythonQtWrapper_QSvgGenerator::new_QSvgGenerator() -{ +{ return new PythonQtShell_QSvgGenerator(); } QString PythonQtWrapper_QSvgGenerator::description(QSvgGenerator* theWrappedObject) const @@ -1598,19 +1598,19 @@ if (_wrapper) { QSvgRenderer::timerEvent(event0); } QSvgRenderer* PythonQtWrapper_QSvgRenderer::new_QSvgRenderer(QObject* parent) -{ +{ return new PythonQtShell_QSvgRenderer(parent); } QSvgRenderer* PythonQtWrapper_QSvgRenderer::new_QSvgRenderer(QXmlStreamReader* contents, QObject* parent) -{ +{ return new PythonQtShell_QSvgRenderer(contents, parent); } QSvgRenderer* PythonQtWrapper_QSvgRenderer::new_QSvgRenderer(const QByteArray& contents, QObject* parent) -{ +{ return new PythonQtShell_QSvgRenderer(contents, parent); } QSvgRenderer* PythonQtWrapper_QSvgRenderer::new_QSvgRenderer(const QString& filename, QObject* parent) -{ +{ return new PythonQtShell_QSvgRenderer(filename, parent); } const QMetaObject* PythonQtShell_QSvgRenderer::metaObject() const { @@ -2867,11 +2867,11 @@ if (_wrapper) { QSvgWidget::wheelEvent(event0); } QSvgWidget* PythonQtWrapper_QSvgWidget::new_QSvgWidget(QWidget* parent) -{ +{ return new PythonQtShell_QSvgWidget(parent); } QSvgWidget* PythonQtWrapper_QSvgWidget::new_QSvgWidget(const QString& file, QWidget* parent) -{ +{ return new PythonQtShell_QSvgWidget(file, parent); } const QMetaObject* PythonQtShell_QSvgWidget::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_uitools/com_trolltech_qt_uitools0.cpp b/generated_cpp_515/com_trolltech_qt_uitools/com_trolltech_qt_uitools0.cpp index 30d5f8fcd..c2db68d7e 100644 --- a/generated_cpp_515/com_trolltech_qt_uitools/com_trolltech_qt_uitools0.cpp +++ b/generated_cpp_515/com_trolltech_qt_uitools/com_trolltech_qt_uitools0.cpp @@ -286,7 +286,7 @@ if (_wrapper) { QUiLoader::timerEvent(event0); } QUiLoader* PythonQtWrapper_QUiLoader::new_QUiLoader(QObject* parent) -{ +{ return new PythonQtShell_QUiLoader(parent); } const QMetaObject* PythonQtShell_QUiLoader::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_webenginewidgets/com_trolltech_qt_webenginewidgets0.cpp b/generated_cpp_515/com_trolltech_qt_webenginewidgets/com_trolltech_qt_webenginewidgets0.cpp index 1e137dc90..aa240c115 100644 --- a/generated_cpp_515/com_trolltech_qt_webenginewidgets/com_trolltech_qt_webenginewidgets0.cpp +++ b/generated_cpp_515/com_trolltech_qt_webenginewidgets/com_trolltech_qt_webenginewidgets0.cpp @@ -216,7 +216,7 @@ if (_wrapper) { QWebChannel::timerEvent(event0); } QWebChannel* PythonQtWrapper_QWebChannel::new_QWebChannel(QObject* parent) -{ +{ return new PythonQtShell_QWebChannel(parent); } const QMetaObject* PythonQtShell_QWebChannel::metaObject() const { @@ -398,7 +398,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QWebChannelAbstractTransport::timerEvent(QTimerEvent* event0) { @@ -423,7 +423,7 @@ if (_wrapper) { QWebChannelAbstractTransport::timerEvent(event0); } QWebChannelAbstractTransport* PythonQtWrapper_QWebChannelAbstractTransport::new_QWebChannelAbstractTransport(QObject* parent) -{ +{ return new PythonQtShell_QWebChannelAbstractTransport(parent); } const QMetaObject* PythonQtShell_QWebChannelAbstractTransport::metaObject() const { @@ -442,11 +442,11 @@ int PythonQtShell_QWebChannelAbstractTransport::qt_metacall(QMetaObject::Call ca QWebEngineCertificateError* PythonQtWrapper_QWebEngineCertificateError::new_QWebEngineCertificateError(const QWebEngineCertificateError& other) -{ +{ return new QWebEngineCertificateError(other); } QWebEngineCertificateError* PythonQtWrapper_QWebEngineCertificateError::new_QWebEngineCertificateError(int error, QUrl url, bool overridable, QString errorDescription) -{ +{ return new QWebEngineCertificateError(error, url, overridable, errorDescription); } bool PythonQtWrapper_QWebEngineCertificateError::answered(QWebEngineCertificateError* theWrappedObject) const @@ -507,7 +507,7 @@ QUrl PythonQtWrapper_QWebEngineCertificateError::url(QWebEngineCertificateError QWebEngineClientCertificateSelection* PythonQtWrapper_QWebEngineClientCertificateSelection::new_QWebEngineClientCertificateSelection(const QWebEngineClientCertificateSelection& arg__1) -{ +{ return new QWebEngineClientCertificateSelection(arg__1); } QVector PythonQtWrapper_QWebEngineClientCertificateSelection::certificates(QWebEngineClientCertificateSelection* theWrappedObject) const @@ -591,7 +591,7 @@ PythonQtShell_QWebEngineCookieStore__FilterRequest::~PythonQtShell_QWebEngineCoo if (priv) { priv->shellClassDeleted(this); } } QWebEngineCookieStore::FilterRequest* PythonQtWrapper_QWebEngineCookieStore__FilterRequest::new_QWebEngineCookieStore__FilterRequest() -{ +{ return new PythonQtShell_QWebEngineCookieStore__FilterRequest(); } @@ -709,11 +709,11 @@ QUrl PythonQtWrapper_QWebEngineDownloadItem::url(QWebEngineDownloadItem* theWra QWebEngineFindTextResult* PythonQtWrapper_QWebEngineFindTextResult::new_QWebEngineFindTextResult() -{ +{ return new QWebEngineFindTextResult(); } QWebEngineFindTextResult* PythonQtWrapper_QWebEngineFindTextResult::new_QWebEngineFindTextResult(const QWebEngineFindTextResult& other) -{ +{ return new QWebEngineFindTextResult(other); } int PythonQtWrapper_QWebEngineFindTextResult::activeMatch(QWebEngineFindTextResult* theWrappedObject) const @@ -843,7 +843,7 @@ void PythonQtWrapper_QWebEngineHistory::readFrom(QWebEngineHistory* theWrappedOb QWebEngineHistoryItem* PythonQtWrapper_QWebEngineHistoryItem::new_QWebEngineHistoryItem(const QWebEngineHistoryItem& other) -{ +{ return new QWebEngineHistoryItem(other); } QUrl PythonQtWrapper_QWebEngineHistoryItem::iconUrl(QWebEngineHistoryItem* theWrappedObject) const @@ -889,11 +889,11 @@ QUrl PythonQtWrapper_QWebEngineHistoryItem::url(QWebEngineHistoryItem* theWrapp QWebEngineHttpRequest* PythonQtWrapper_QWebEngineHttpRequest::new_QWebEngineHttpRequest(const QUrl& url, const QWebEngineHttpRequest::Method& method) -{ +{ return new QWebEngineHttpRequest(url, method); } QWebEngineHttpRequest* PythonQtWrapper_QWebEngineHttpRequest::new_QWebEngineHttpRequest(const QWebEngineHttpRequest& other) -{ +{ return new QWebEngineHttpRequest(other); } bool PythonQtWrapper_QWebEngineHttpRequest::hasHeader(QWebEngineHttpRequest* theWrappedObject, const QByteArray& headerName) const @@ -1421,11 +1421,11 @@ if (_wrapper) { QWebEnginePage::triggerAction(action0, checked1); } QWebEnginePage* PythonQtWrapper_QWebEnginePage::new_QWebEnginePage(QObject* parent) -{ +{ return new PythonQtShell_QWebEnginePage(parent); } QWebEnginePage* PythonQtWrapper_QWebEnginePage::new_QWebEnginePage(QWebEngineProfile* profile, QObject* parent) -{ +{ return new PythonQtShell_QWebEnginePage(profile, parent); } const QMetaObject* PythonQtShell_QWebEnginePage::metaObject() const { @@ -1875,11 +1875,11 @@ if (_wrapper) { QWebEngineProfile::timerEvent(event0); } QWebEngineProfile* PythonQtWrapper_QWebEngineProfile::new_QWebEngineProfile(QObject* parent) -{ +{ return new PythonQtShell_QWebEngineProfile(parent); } QWebEngineProfile* PythonQtWrapper_QWebEngineProfile::new_QWebEngineProfile(const QString& name, QObject* parent) -{ +{ return new PythonQtShell_QWebEngineProfile(name, parent); } const QMetaObject* PythonQtShell_QWebEngineProfile::metaObject() const { @@ -2098,7 +2098,7 @@ bool PythonQtWrapper_QWebEngineProfile::visitedLinksContainsUrl(QWebEngineProfi QWebEngineQuotaRequest* PythonQtWrapper_QWebEngineQuotaRequest::new_QWebEngineQuotaRequest() -{ +{ return new QWebEngineQuotaRequest(); } void PythonQtWrapper_QWebEngineQuotaRequest::accept(QWebEngineQuotaRequest* theWrappedObject) @@ -2134,7 +2134,7 @@ qint64 PythonQtWrapper_QWebEngineQuotaRequest::requestedSize(QWebEngineQuotaReq QWebEngineRegisterProtocolHandlerRequest* PythonQtWrapper_QWebEngineRegisterProtocolHandlerRequest::new_QWebEngineRegisterProtocolHandlerRequest() -{ +{ return new QWebEngineRegisterProtocolHandlerRequest(); } void PythonQtWrapper_QWebEngineRegisterProtocolHandlerRequest::accept(QWebEngineRegisterProtocolHandlerRequest* theWrappedObject) @@ -2170,11 +2170,11 @@ QString PythonQtWrapper_QWebEngineRegisterProtocolHandlerRequest::scheme(QWebEn QWebEngineScript* PythonQtWrapper_QWebEngineScript::new_QWebEngineScript() -{ +{ return new QWebEngineScript(); } QWebEngineScript* PythonQtWrapper_QWebEngineScript::new_QWebEngineScript(const QWebEngineScript& other) -{ +{ return new QWebEngineScript(other); } QWebEngineScript::InjectionPoint PythonQtWrapper_QWebEngineScript::injectionPoint(QWebEngineScript* theWrappedObject) const @@ -2586,7 +2586,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QWebEngineUrlRequestInterceptor::timerEvent(QTimerEvent* event0) { @@ -2611,7 +2611,7 @@ if (_wrapper) { QWebEngineUrlRequestInterceptor::timerEvent(event0); } QWebEngineUrlRequestInterceptor* PythonQtWrapper_QWebEngineUrlRequestInterceptor::new_QWebEngineUrlRequestInterceptor(QObject* p) -{ +{ return new PythonQtShell_QWebEngineUrlRequestInterceptor(p); } const QMetaObject* PythonQtShell_QWebEngineUrlRequestInterceptor::metaObject() const { @@ -2672,15 +2672,15 @@ QUrl PythonQtWrapper_QWebEngineUrlRequestJob::requestUrl(QWebEngineUrlRequestJo QWebEngineUrlScheme* PythonQtWrapper_QWebEngineUrlScheme::new_QWebEngineUrlScheme() -{ +{ return new QWebEngineUrlScheme(); } QWebEngineUrlScheme* PythonQtWrapper_QWebEngineUrlScheme::new_QWebEngineUrlScheme(const QByteArray& name) -{ +{ return new QWebEngineUrlScheme(name); } QWebEngineUrlScheme* PythonQtWrapper_QWebEngineUrlScheme::new_QWebEngineUrlScheme(const QWebEngineUrlScheme& that) -{ +{ return new QWebEngineUrlScheme(that); } int PythonQtWrapper_QWebEngineUrlScheme::defaultPort(QWebEngineUrlScheme* theWrappedObject) const @@ -2884,7 +2884,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QWebEngineUrlSchemeHandler::timerEvent(QTimerEvent* event0) { @@ -2909,7 +2909,7 @@ if (_wrapper) { QWebEngineUrlSchemeHandler::timerEvent(event0); } QWebEngineUrlSchemeHandler* PythonQtWrapper_QWebEngineUrlSchemeHandler::new_QWebEngineUrlSchemeHandler(QObject* parent) -{ +{ return new PythonQtShell_QWebEngineUrlSchemeHandler(parent); } const QMetaObject* PythonQtShell_QWebEngineUrlSchemeHandler::metaObject() const { @@ -4114,7 +4114,7 @@ if (_wrapper) { QWebEngineView::wheelEvent(event0); } QWebEngineView* PythonQtWrapper_QWebEngineView::new_QWebEngineView(QWidget* parent) -{ +{ return new PythonQtShell_QWebEngineView(parent); } const QMetaObject* PythonQtShell_QWebEngineView::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.cpp b/generated_cpp_515/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.cpp index 95c7b74ef..af9b2b06e 100644 --- a/generated_cpp_515/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.cpp +++ b/generated_cpp_515/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.cpp @@ -894,7 +894,7 @@ if (_wrapper) { Py_DECREF(obj); if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) { returnValue = value1; - } + } return returnValue; } else { PyErr_Clear(); @@ -1652,7 +1652,7 @@ if (_wrapper) { return QGraphicsWebView::windowFrameSectionAt(pos0); } QGraphicsWebView* PythonQtWrapper_QGraphicsWebView::new_QGraphicsWebView(QGraphicsItem* parent) -{ +{ return new PythonQtShell_QGraphicsWebView(parent); } const QMetaObject* PythonQtShell_QGraphicsWebView::metaObject() const { @@ -1796,7 +1796,7 @@ qreal PythonQtWrapper_QGraphicsWebView::zoomFactor(QGraphicsWebView* theWrapped QWebDatabase* PythonQtWrapper_QWebDatabase::new_QWebDatabase(const QWebDatabase& other) -{ +{ return new QWebDatabase(other); } QString PythonQtWrapper_QWebDatabase::displayName(QWebDatabase* theWrappedObject) const @@ -1847,11 +1847,11 @@ qint64 PythonQtWrapper_QWebDatabase::size(QWebDatabase* theWrappedObject) const QWebElement* PythonQtWrapper_QWebElement::new_QWebElement() -{ +{ return new QWebElement(); } QWebElement* PythonQtWrapper_QWebElement::new_QWebElement(const QWebElement& arg__1) -{ +{ return new QWebElement(arg__1); } void PythonQtWrapper_QWebElement::addClass(QWebElement* theWrappedObject, const QString& name) @@ -2177,15 +2177,15 @@ QWebFrame* PythonQtWrapper_QWebElement::webFrame(QWebElement* theWrappedObject) QWebElementCollection* PythonQtWrapper_QWebElementCollection::new_QWebElementCollection() -{ +{ return new QWebElementCollection(); } QWebElementCollection* PythonQtWrapper_QWebElementCollection::new_QWebElementCollection(const QWebElement& contextElement, const QString& query) -{ +{ return new QWebElementCollection(contextElement, query); } QWebElementCollection* PythonQtWrapper_QWebElementCollection::new_QWebElementCollection(const QWebElementCollection& arg__1) -{ +{ return new QWebElementCollection(arg__1); } void PythonQtWrapper_QWebElementCollection::append(QWebElementCollection* theWrappedObject, const QWebElementCollection& collection) @@ -2603,7 +2603,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QWebHistoryInterface::childEvent(QChildEvent* event0) { @@ -2771,7 +2771,7 @@ if (_wrapper) { QWebHistoryInterface::timerEvent(event0); } QWebHistoryInterface* PythonQtWrapper_QWebHistoryInterface::new_QWebHistoryInterface(QObject* parent) -{ +{ return new PythonQtShell_QWebHistoryInterface(parent); } const QMetaObject* PythonQtShell_QWebHistoryInterface::metaObject() const { @@ -2810,7 +2810,7 @@ void PythonQtWrapper_QWebHistoryInterface::static_QWebHistoryInterface_setDefaul QWebHistoryItem* PythonQtWrapper_QWebHistoryItem::new_QWebHistoryItem(const QWebHistoryItem& other) -{ +{ return new QWebHistoryItem(other); } QIcon PythonQtWrapper_QWebHistoryItem::icon(QWebHistoryItem* theWrappedObject) const @@ -2866,11 +2866,11 @@ QVariant PythonQtWrapper_QWebHistoryItem::userData(QWebHistoryItem* theWrappedO QWebHitTestResult* PythonQtWrapper_QWebHitTestResult::new_QWebHitTestResult() -{ +{ return new QWebHitTestResult(); } QWebHitTestResult* PythonQtWrapper_QWebHitTestResult::new_QWebHitTestResult(const QWebHitTestResult& other) -{ +{ return new QWebHitTestResult(other); } QString PythonQtWrapper_QWebHitTestResult::alternateText(QWebHitTestResult* theWrappedObject) const @@ -4119,7 +4119,7 @@ if (_wrapper) { QWebInspector::wheelEvent(event0); } QWebInspector* PythonQtWrapper_QWebInspector::new_QWebInspector(QWidget* parent) -{ +{ return new PythonQtShell_QWebInspector(parent); } const QMetaObject* PythonQtShell_QWebInspector::metaObject() const { @@ -4685,7 +4685,7 @@ if (_wrapper) { return QWebPage::userAgentForUrl(url0); } QWebPage* PythonQtWrapper_QWebPage::new_QWebPage(QObject* parent) -{ +{ return new PythonQtShell_QWebPage(parent); } const QMetaObject* PythonQtShell_QWebPage::metaObject() const { @@ -5013,7 +5013,7 @@ PythonQtShell_QWebPage__ChooseMultipleFilesExtensionOption::~PythonQtShell_QWebP if (priv) { priv->shellClassDeleted(this); } } QWebPage::ChooseMultipleFilesExtensionOption* PythonQtWrapper_QWebPage__ChooseMultipleFilesExtensionOption::new_QWebPage__ChooseMultipleFilesExtensionOption() -{ +{ return new PythonQtShell_QWebPage__ChooseMultipleFilesExtensionOption(); } @@ -5023,7 +5023,7 @@ PythonQtShell_QWebPage__ChooseMultipleFilesExtensionReturn::~PythonQtShell_QWebP if (priv) { priv->shellClassDeleted(this); } } QWebPage::ChooseMultipleFilesExtensionReturn* PythonQtWrapper_QWebPage__ChooseMultipleFilesExtensionReturn::new_QWebPage__ChooseMultipleFilesExtensionReturn() -{ +{ return new PythonQtShell_QWebPage__ChooseMultipleFilesExtensionReturn(); } @@ -5033,7 +5033,7 @@ PythonQtShell_QWebPage__ErrorPageExtensionOption::~PythonQtShell_QWebPage__Error if (priv) { priv->shellClassDeleted(this); } } QWebPage::ErrorPageExtensionOption* PythonQtWrapper_QWebPage__ErrorPageExtensionOption::new_QWebPage__ErrorPageExtensionOption() -{ +{ return new PythonQtShell_QWebPage__ErrorPageExtensionOption(); } @@ -5043,7 +5043,7 @@ PythonQtShell_QWebPage__ErrorPageExtensionReturn::~PythonQtShell_QWebPage__Error if (priv) { priv->shellClassDeleted(this); } } QWebPage::ErrorPageExtensionReturn* PythonQtWrapper_QWebPage__ErrorPageExtensionReturn::new_QWebPage__ErrorPageExtensionReturn() -{ +{ return new PythonQtShell_QWebPage__ErrorPageExtensionReturn(); } @@ -5053,7 +5053,7 @@ PythonQtShell_QWebPage__ExtensionOption::~PythonQtShell_QWebPage__ExtensionOptio if (priv) { priv->shellClassDeleted(this); } } QWebPage::ExtensionOption* PythonQtWrapper_QWebPage__ExtensionOption::new_QWebPage__ExtensionOption() -{ +{ return new PythonQtShell_QWebPage__ExtensionOption(); } @@ -5063,7 +5063,7 @@ PythonQtShell_QWebPage__ExtensionReturn::~PythonQtShell_QWebPage__ExtensionRetur if (priv) { priv->shellClassDeleted(this); } } QWebPage::ExtensionReturn* PythonQtWrapper_QWebPage__ExtensionReturn::new_QWebPage__ExtensionReturn() -{ +{ return new PythonQtShell_QWebPage__ExtensionReturn(); } @@ -5359,7 +5359,7 @@ if (_wrapper) { QWebPluginFactory::timerEvent(event0); } QWebPluginFactory* PythonQtWrapper_QWebPluginFactory::new_QWebPluginFactory(QObject* parent) -{ +{ return new PythonQtShell_QWebPluginFactory(parent); } const QMetaObject* PythonQtShell_QWebPluginFactory::metaObject() const { @@ -5407,7 +5407,7 @@ PythonQtShell_QWebPluginFactory__ExtensionOption::~PythonQtShell_QWebPluginFacto if (priv) { priv->shellClassDeleted(this); } } QWebPluginFactory::ExtensionOption* PythonQtWrapper_QWebPluginFactory__ExtensionOption::new_QWebPluginFactory__ExtensionOption() -{ +{ return new PythonQtShell_QWebPluginFactory__ExtensionOption(); } @@ -5417,7 +5417,7 @@ PythonQtShell_QWebPluginFactory__ExtensionReturn::~PythonQtShell_QWebPluginFacto if (priv) { priv->shellClassDeleted(this); } } QWebPluginFactory::ExtensionReturn* PythonQtWrapper_QWebPluginFactory__ExtensionReturn::new_QWebPluginFactory__ExtensionReturn() -{ +{ return new PythonQtShell_QWebPluginFactory__ExtensionReturn(); } @@ -5427,7 +5427,7 @@ PythonQtShell_QWebPluginFactory__MimeType::~PythonQtShell_QWebPluginFactory__Mim if (priv) { priv->shellClassDeleted(this); } } QWebPluginFactory::MimeType* PythonQtWrapper_QWebPluginFactory__MimeType::new_QWebPluginFactory__MimeType() -{ +{ return new PythonQtShell_QWebPluginFactory__MimeType(); } bool PythonQtWrapper_QWebPluginFactory__MimeType::__ne__(QWebPluginFactory::MimeType* theWrappedObject, const QWebPluginFactory::MimeType& other) const @@ -5447,17 +5447,17 @@ PythonQtShell_QWebPluginFactory__Plugin::~PythonQtShell_QWebPluginFactory__Plugi if (priv) { priv->shellClassDeleted(this); } } QWebPluginFactory::Plugin* PythonQtWrapper_QWebPluginFactory__Plugin::new_QWebPluginFactory__Plugin() -{ +{ return new PythonQtShell_QWebPluginFactory__Plugin(); } QWebSecurityOrigin* PythonQtWrapper_QWebSecurityOrigin::new_QWebSecurityOrigin(const QUrl& url) -{ +{ return new QWebSecurityOrigin(url); } QWebSecurityOrigin* PythonQtWrapper_QWebSecurityOrigin::new_QWebSecurityOrigin(const QWebSecurityOrigin& other) -{ +{ return new QWebSecurityOrigin(other); } void PythonQtWrapper_QWebSecurityOrigin::addAccessWhitelistEntry(QWebSecurityOrigin* theWrappedObject, const QString& scheme, const QString& host, QWebSecurityOrigin::SubdomainSetting subdomainSetting) @@ -6926,7 +6926,7 @@ if (_wrapper) { QWebView::wheelEvent(arg__1); } QWebView* PythonQtWrapper_QWebView::new_QWebView(QWidget* parent) -{ +{ return new PythonQtShell_QWebView(parent); } const QMetaObject* PythonQtShell_QWebView::metaObject() const { diff --git a/generated_cpp_515/com_trolltech_qt_xml/com_trolltech_qt_xml0.cpp b/generated_cpp_515/com_trolltech_qt_xml/com_trolltech_qt_xml0.cpp index d92765592..a15902b62 100644 --- a/generated_cpp_515/com_trolltech_qt_xml/com_trolltech_qt_xml0.cpp +++ b/generated_cpp_515/com_trolltech_qt_xml/com_trolltech_qt_xml0.cpp @@ -11,11 +11,11 @@ #include QDomAttr* PythonQtWrapper_QDomAttr::new_QDomAttr() -{ +{ return new QDomAttr(); } QDomAttr* PythonQtWrapper_QDomAttr::new_QDomAttr(const QDomAttr& x) -{ +{ return new QDomAttr(x); } QString PythonQtWrapper_QDomAttr::name(QDomAttr* theWrappedObject) const @@ -46,21 +46,21 @@ QString PythonQtWrapper_QDomAttr::value(QDomAttr* theWrappedObject) const QDomCDATASection* PythonQtWrapper_QDomCDATASection::new_QDomCDATASection() -{ +{ return new QDomCDATASection(); } QDomCDATASection* PythonQtWrapper_QDomCDATASection::new_QDomCDATASection(const QDomCDATASection& x) -{ +{ return new QDomCDATASection(x); } QDomCharacterData* PythonQtWrapper_QDomCharacterData::new_QDomCharacterData() -{ +{ return new QDomCharacterData(); } QDomCharacterData* PythonQtWrapper_QDomCharacterData::new_QDomCharacterData(const QDomCharacterData& x) -{ +{ return new QDomCharacterData(x); } void PythonQtWrapper_QDomCharacterData::appendData(QDomCharacterData* theWrappedObject, const QString& arg) @@ -106,29 +106,29 @@ QString PythonQtWrapper_QDomCharacterData::substringData(QDomCharacterData* the QDomComment* PythonQtWrapper_QDomComment::new_QDomComment() -{ +{ return new QDomComment(); } QDomComment* PythonQtWrapper_QDomComment::new_QDomComment(const QDomComment& x) -{ +{ return new QDomComment(x); } QDomDocument* PythonQtWrapper_QDomDocument::new_QDomDocument() -{ +{ return new QDomDocument(); } QDomDocument* PythonQtWrapper_QDomDocument::new_QDomDocument(const QDomDocument& x) -{ +{ return new QDomDocument(x); } QDomDocument* PythonQtWrapper_QDomDocument::new_QDomDocument(const QDomDocumentType& doctype) -{ +{ return new QDomDocument(doctype); } QDomDocument* PythonQtWrapper_QDomDocument::new_QDomDocument(const QString& name) -{ +{ return new QDomDocument(name); } QDomAttr PythonQtWrapper_QDomDocument::createAttribute(QDomDocument* theWrappedObject, const QString& name) @@ -275,21 +275,21 @@ QString PythonQtWrapper_QDomDocument::py_toString(QDomDocument* obj) { return ob QDomDocumentFragment* PythonQtWrapper_QDomDocumentFragment::new_QDomDocumentFragment() -{ +{ return new QDomDocumentFragment(); } QDomDocumentFragment* PythonQtWrapper_QDomDocumentFragment::new_QDomDocumentFragment(const QDomDocumentFragment& x) -{ +{ return new QDomDocumentFragment(x); } QDomDocumentType* PythonQtWrapper_QDomDocumentType::new_QDomDocumentType() -{ +{ return new QDomDocumentType(); } QDomDocumentType* PythonQtWrapper_QDomDocumentType::new_QDomDocumentType(const QDomDocumentType& x) -{ +{ return new QDomDocumentType(x); } QDomNamedNodeMap PythonQtWrapper_QDomDocumentType::entities(QDomDocumentType* theWrappedObject) const @@ -325,11 +325,11 @@ QString PythonQtWrapper_QDomDocumentType::systemId(QDomDocumentType* theWrapped QDomElement* PythonQtWrapper_QDomElement::new_QDomElement() -{ +{ return new QDomElement(); } QDomElement* PythonQtWrapper_QDomElement::new_QDomElement(const QDomElement& x) -{ +{ return new QDomElement(x); } QString PythonQtWrapper_QDomElement::attribute(QDomElement* theWrappedObject, const QString& name, const QString& defValue) const @@ -465,11 +465,11 @@ QString PythonQtWrapper_QDomElement::text(QDomElement* theWrappedObject) const QDomEntity* PythonQtWrapper_QDomEntity::new_QDomEntity() -{ +{ return new QDomEntity(); } QDomEntity* PythonQtWrapper_QDomEntity::new_QDomEntity(const QDomEntity& x) -{ +{ return new QDomEntity(x); } QString PythonQtWrapper_QDomEntity::notationName(QDomEntity* theWrappedObject) const @@ -490,21 +490,21 @@ QString PythonQtWrapper_QDomEntity::systemId(QDomEntity* theWrappedObject) cons QDomEntityReference* PythonQtWrapper_QDomEntityReference::new_QDomEntityReference() -{ +{ return new QDomEntityReference(); } QDomEntityReference* PythonQtWrapper_QDomEntityReference::new_QDomEntityReference(const QDomEntityReference& x) -{ +{ return new QDomEntityReference(x); } QDomImplementation* PythonQtWrapper_QDomImplementation::new_QDomImplementation() -{ +{ return new QDomImplementation(); } QDomImplementation* PythonQtWrapper_QDomImplementation::new_QDomImplementation(const QDomImplementation& arg__1) -{ +{ return new QDomImplementation(arg__1); } QDomDocument PythonQtWrapper_QDomImplementation::createDocument(QDomImplementation* theWrappedObject, const QString& nsURI, const QString& qName, const QDomDocumentType& doctype) @@ -550,11 +550,11 @@ void PythonQtWrapper_QDomImplementation::static_QDomImplementation_setInvalidDat QDomNamedNodeMap* PythonQtWrapper_QDomNamedNodeMap::new_QDomNamedNodeMap() -{ +{ return new QDomNamedNodeMap(); } QDomNamedNodeMap* PythonQtWrapper_QDomNamedNodeMap::new_QDomNamedNodeMap(const QDomNamedNodeMap& arg__1) -{ +{ return new QDomNamedNodeMap(arg__1); } bool PythonQtWrapper_QDomNamedNodeMap::contains(QDomNamedNodeMap* theWrappedObject, const QString& name) const @@ -630,11 +630,11 @@ int PythonQtWrapper_QDomNamedNodeMap::size(QDomNamedNodeMap* theWrappedObject) QDomNode* PythonQtWrapper_QDomNode::new_QDomNode() -{ +{ return new QDomNode(); } QDomNode* PythonQtWrapper_QDomNode::new_QDomNode(const QDomNode& arg__1) -{ +{ return new QDomNode(arg__1); } QDomNode PythonQtWrapper_QDomNode::appendChild(QDomNode* theWrappedObject, const QDomNode& newChild) @@ -960,11 +960,11 @@ QDomText PythonQtWrapper_QDomNode::toText(QDomNode* theWrappedObject) const QDomNodeList* PythonQtWrapper_QDomNodeList::new_QDomNodeList() -{ +{ return new QDomNodeList(); } QDomNodeList* PythonQtWrapper_QDomNodeList::new_QDomNodeList(const QDomNodeList& arg__1) -{ +{ return new QDomNodeList(arg__1); } QDomNode PythonQtWrapper_QDomNodeList::at(QDomNodeList* theWrappedObject, int index) const @@ -1010,11 +1010,11 @@ int PythonQtWrapper_QDomNodeList::size(QDomNodeList* theWrappedObject) const QDomNotation* PythonQtWrapper_QDomNotation::new_QDomNotation() -{ +{ return new QDomNotation(); } QDomNotation* PythonQtWrapper_QDomNotation::new_QDomNotation(const QDomNotation& x) -{ +{ return new QDomNotation(x); } QString PythonQtWrapper_QDomNotation::publicId(QDomNotation* theWrappedObject) const @@ -1030,11 +1030,11 @@ QString PythonQtWrapper_QDomNotation::systemId(QDomNotation* theWrappedObject) QDomProcessingInstruction* PythonQtWrapper_QDomProcessingInstruction::new_QDomProcessingInstruction() -{ +{ return new QDomProcessingInstruction(); } QDomProcessingInstruction* PythonQtWrapper_QDomProcessingInstruction::new_QDomProcessingInstruction(const QDomProcessingInstruction& x) -{ +{ return new QDomProcessingInstruction(x); } QString PythonQtWrapper_QDomProcessingInstruction::data(QDomProcessingInstruction* theWrappedObject) const @@ -1055,11 +1055,11 @@ QString PythonQtWrapper_QDomProcessingInstruction::target(QDomProcessingInstruc QDomText* PythonQtWrapper_QDomText::new_QDomText() -{ +{ return new QDomText(); } QDomText* PythonQtWrapper_QDomText::new_QDomText(const QDomText& x) -{ +{ return new QDomText(x); } QDomText PythonQtWrapper_QDomText::splitText(QDomText* theWrappedObject, int offset) @@ -1074,11 +1074,11 @@ PythonQtShell_QXmlAttributes::~PythonQtShell_QXmlAttributes() { if (priv) { priv->shellClassDeleted(this); } } QXmlAttributes* PythonQtWrapper_QXmlAttributes::new_QXmlAttributes() -{ +{ return new PythonQtShell_QXmlAttributes(); } QXmlAttributes* PythonQtWrapper_QXmlAttributes::new_QXmlAttributes(const QXmlAttributes& arg__1) -{ +{ return new PythonQtShell_QXmlAttributes(arg__1); } void PythonQtWrapper_QXmlAttributes::append(QXmlAttributes* theWrappedObject, const QString& qName, const QString& uri, const QString& localPart, const QString& value) @@ -1423,7 +1423,7 @@ if (_wrapper) { } } } - + } bool PythonQtShell_QXmlContentHandler::skippedEntity(const QString& name0) { @@ -1558,7 +1558,7 @@ if (_wrapper) { return bool(); } QXmlContentHandler* PythonQtWrapper_QXmlContentHandler::new_QXmlContentHandler() -{ +{ return new PythonQtShell_QXmlContentHandler(); } bool PythonQtWrapper_QXmlContentHandler::characters(QXmlContentHandler* theWrappedObject, const QString& ch) @@ -1727,7 +1727,7 @@ if (_wrapper) { return bool(); } QXmlDTDHandler* PythonQtWrapper_QXmlDTDHandler::new_QXmlDTDHandler() -{ +{ return new PythonQtShell_QXmlDTDHandler(); } QString PythonQtWrapper_QXmlDTDHandler::errorString(QXmlDTDHandler* theWrappedObject) const @@ -1884,7 +1884,7 @@ if (_wrapper) { return bool(); } QXmlDeclHandler* PythonQtWrapper_QXmlDeclHandler::new_QXmlDeclHandler() -{ +{ return new PythonQtShell_QXmlDeclHandler(); } bool PythonQtWrapper_QXmlDeclHandler::attributeDecl(QXmlDeclHandler* theWrappedObject, const QString& eName, const QString& aName, const QString& type, const QString& valueDefault, const QString& value) @@ -2827,7 +2827,7 @@ if (_wrapper) { return QXmlDefaultHandler::warning(exception0); } QXmlDefaultHandler* PythonQtWrapper_QXmlDefaultHandler::new_QXmlDefaultHandler() -{ +{ return new PythonQtShell_QXmlDefaultHandler(); } @@ -2903,7 +2903,7 @@ if (_wrapper) { return bool(); } QXmlEntityResolver* PythonQtWrapper_QXmlEntityResolver::new_QXmlEntityResolver() -{ +{ return new PythonQtShell_QXmlEntityResolver(); } QString PythonQtWrapper_QXmlEntityResolver::errorString(QXmlEntityResolver* theWrappedObject) const @@ -3055,7 +3055,7 @@ if (_wrapper) { return bool(); } QXmlErrorHandler* PythonQtWrapper_QXmlErrorHandler::new_QXmlErrorHandler() -{ +{ return new PythonQtShell_QXmlErrorHandler(); } bool PythonQtWrapper_QXmlErrorHandler::error(QXmlErrorHandler* theWrappedObject, const QXmlParseException& exception) @@ -3272,11 +3272,11 @@ if (_wrapper) { QXmlInputSource::setData(dat0); } QXmlInputSource* PythonQtWrapper_QXmlInputSource::new_QXmlInputSource() -{ +{ return new PythonQtShell_QXmlInputSource(); } QXmlInputSource* PythonQtWrapper_QXmlInputSource::new_QXmlInputSource(QIODevice* dev) -{ +{ return new PythonQtShell_QXmlInputSource(dev); } QString PythonQtWrapper_QXmlInputSource::data(QXmlInputSource* theWrappedObject) const @@ -3585,7 +3585,7 @@ if (_wrapper) { return bool(); } QXmlLexicalHandler* PythonQtWrapper_QXmlLexicalHandler::new_QXmlLexicalHandler() -{ +{ return new PythonQtShell_QXmlLexicalHandler(); } bool PythonQtWrapper_QXmlLexicalHandler::comment(QXmlLexicalHandler* theWrappedObject, const QString& ch) @@ -3701,7 +3701,7 @@ if (_wrapper) { return int(); } QXmlLocator* PythonQtWrapper_QXmlLocator::new_QXmlLocator() -{ +{ return new PythonQtShell_QXmlLocator(); } int PythonQtWrapper_QXmlLocator::columnNumber(QXmlLocator* theWrappedObject) const @@ -3717,11 +3717,11 @@ int PythonQtWrapper_QXmlLocator::lineNumber(QXmlLocator* theWrappedObject) cons QXmlParseException* PythonQtWrapper_QXmlParseException::new_QXmlParseException(const QString& name, int c, int l, const QString& p, const QString& s) -{ +{ return new QXmlParseException(name, c, l, p, s); } QXmlParseException* PythonQtWrapper_QXmlParseException::new_QXmlParseException(const QXmlParseException& other) -{ +{ return new QXmlParseException(other); } int PythonQtWrapper_QXmlParseException::columnNumber(QXmlParseException* theWrappedObject) const @@ -4171,7 +4171,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QXmlReader::setDTDHandler(QXmlDTDHandler* handler0) { @@ -4193,7 +4193,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QXmlReader::setDeclHandler(QXmlDeclHandler* handler0) { @@ -4215,7 +4215,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QXmlReader::setEntityResolver(QXmlEntityResolver* handler0) { @@ -4237,7 +4237,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QXmlReader::setErrorHandler(QXmlErrorHandler* handler0) { @@ -4259,7 +4259,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QXmlReader::setFeature(const QString& name0, bool value1) { @@ -4281,7 +4281,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QXmlReader::setLexicalHandler(QXmlLexicalHandler* handler0) { @@ -4303,7 +4303,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QXmlReader::setProperty(const QString& name0, void* value1) { @@ -4325,10 +4325,10 @@ if (_wrapper) { } } } - + } QXmlReader* PythonQtWrapper_QXmlReader::new_QXmlReader() -{ +{ return new PythonQtShell_QXmlReader(); } QXmlDTDHandler* PythonQtWrapper_QXmlReader::DTDHandler(QXmlReader* theWrappedObject) const @@ -5076,7 +5076,7 @@ if (_wrapper) { QXmlSimpleReader::setProperty(name0, value1); } QXmlSimpleReader* PythonQtWrapper_QXmlSimpleReader::new_QXmlSimpleReader() -{ +{ return new PythonQtShell_QXmlSimpleReader(); } bool PythonQtWrapper_QXmlSimpleReader::parse(QXmlSimpleReader* theWrappedObject, const QXmlInputSource* input, bool incremental) diff --git a/generated_cpp_515/com_trolltech_qt_xml/com_trolltech_qt_xml1.cpp b/generated_cpp_515/com_trolltech_qt_xml/com_trolltech_qt_xml1.cpp index c7a9e8097..ea4315d8a 100644 --- a/generated_cpp_515/com_trolltech_qt_xml/com_trolltech_qt_xml1.cpp +++ b/generated_cpp_515/com_trolltech_qt_xml/com_trolltech_qt_xml1.cpp @@ -11,19 +11,19 @@ #include QXmlStreamAttribute* PythonQtWrapper_QXmlStreamAttribute::new_QXmlStreamAttribute() -{ +{ return new QXmlStreamAttribute(); } QXmlStreamAttribute* PythonQtWrapper_QXmlStreamAttribute::new_QXmlStreamAttribute(const QString& namespaceUri, const QString& name, const QString& value) -{ +{ return new QXmlStreamAttribute(namespaceUri, name, value); } QXmlStreamAttribute* PythonQtWrapper_QXmlStreamAttribute::new_QXmlStreamAttribute(const QString& qualifiedName, const QString& value) -{ +{ return new QXmlStreamAttribute(qualifiedName, value); } QXmlStreamAttribute* PythonQtWrapper_QXmlStreamAttribute::new_QXmlStreamAttribute(const QXmlStreamAttribute& arg__1) -{ +{ return new QXmlStreamAttribute(arg__1); } bool PythonQtWrapper_QXmlStreamAttribute::isDefault(QXmlStreamAttribute* theWrappedObject) const @@ -69,7 +69,7 @@ QStringRef PythonQtWrapper_QXmlStreamAttribute::value(QXmlStreamAttribute* theW QXmlStreamAttributes* PythonQtWrapper_QXmlStreamAttributes::new_QXmlStreamAttributes() -{ +{ return new QXmlStreamAttributes(); } void PythonQtWrapper_QXmlStreamAttributes::append(QXmlStreamAttributes* theWrappedObject, const QString& namespaceUri, const QString& name, const QString& value) @@ -330,11 +330,11 @@ QStringRef PythonQtWrapper_QXmlStreamAttributes::value(QXmlStreamAttributes* th QXmlStreamEntityDeclaration* PythonQtWrapper_QXmlStreamEntityDeclaration::new_QXmlStreamEntityDeclaration() -{ +{ return new QXmlStreamEntityDeclaration(); } QXmlStreamEntityDeclaration* PythonQtWrapper_QXmlStreamEntityDeclaration::new_QXmlStreamEntityDeclaration(const QXmlStreamEntityDeclaration& arg__1) -{ +{ return new QXmlStreamEntityDeclaration(arg__1); } QStringRef PythonQtWrapper_QXmlStreamEntityDeclaration::name(QXmlStreamEntityDeclaration* theWrappedObject) const @@ -375,15 +375,15 @@ QStringRef PythonQtWrapper_QXmlStreamEntityDeclaration::value(QXmlStreamEntityD QXmlStreamNamespaceDeclaration* PythonQtWrapper_QXmlStreamNamespaceDeclaration::new_QXmlStreamNamespaceDeclaration() -{ +{ return new QXmlStreamNamespaceDeclaration(); } QXmlStreamNamespaceDeclaration* PythonQtWrapper_QXmlStreamNamespaceDeclaration::new_QXmlStreamNamespaceDeclaration(const QString& prefix, const QString& namespaceUri) -{ +{ return new QXmlStreamNamespaceDeclaration(prefix, namespaceUri); } QXmlStreamNamespaceDeclaration* PythonQtWrapper_QXmlStreamNamespaceDeclaration::new_QXmlStreamNamespaceDeclaration(const QXmlStreamNamespaceDeclaration& arg__1) -{ +{ return new QXmlStreamNamespaceDeclaration(arg__1); } QStringRef PythonQtWrapper_QXmlStreamNamespaceDeclaration::namespaceUri(QXmlStreamNamespaceDeclaration* theWrappedObject) const @@ -409,11 +409,11 @@ QStringRef PythonQtWrapper_QXmlStreamNamespaceDeclaration::prefix(QXmlStreamNam QXmlStreamNotationDeclaration* PythonQtWrapper_QXmlStreamNotationDeclaration::new_QXmlStreamNotationDeclaration() -{ +{ return new QXmlStreamNotationDeclaration(); } QXmlStreamNotationDeclaration* PythonQtWrapper_QXmlStreamNotationDeclaration::new_QXmlStreamNotationDeclaration(const QXmlStreamNotationDeclaration& arg__1) -{ +{ return new QXmlStreamNotationDeclaration(arg__1); } QStringRef PythonQtWrapper_QXmlStreamNotationDeclaration::name(QXmlStreamNotationDeclaration* theWrappedObject) const @@ -444,19 +444,19 @@ QStringRef PythonQtWrapper_QXmlStreamNotationDeclaration::systemId(QXmlStreamNo QXmlStreamReader* PythonQtWrapper_QXmlStreamReader::new_QXmlStreamReader() -{ +{ return new QXmlStreamReader(); } QXmlStreamReader* PythonQtWrapper_QXmlStreamReader::new_QXmlStreamReader(QIODevice* device) -{ +{ return new QXmlStreamReader(device); } QXmlStreamReader* PythonQtWrapper_QXmlStreamReader::new_QXmlStreamReader(const QByteArray& data) -{ +{ return new QXmlStreamReader(data); } QXmlStreamReader* PythonQtWrapper_QXmlStreamReader::new_QXmlStreamReader(const QString& data) -{ +{ return new QXmlStreamReader(data); } void PythonQtWrapper_QXmlStreamReader::addData(QXmlStreamReader* theWrappedObject, const QByteArray& data) @@ -737,15 +737,15 @@ QXmlStreamReader::TokenType PythonQtWrapper_QXmlStreamReader::tokenType(QXmlStr QXmlStreamWriter* PythonQtWrapper_QXmlStreamWriter::new_QXmlStreamWriter() -{ +{ return new QXmlStreamWriter(); } QXmlStreamWriter* PythonQtWrapper_QXmlStreamWriter::new_QXmlStreamWriter(QByteArray* array) -{ +{ return new QXmlStreamWriter(array); } QXmlStreamWriter* PythonQtWrapper_QXmlStreamWriter::new_QXmlStreamWriter(QIODevice* device) -{ +{ return new QXmlStreamWriter(device); } bool PythonQtWrapper_QXmlStreamWriter::autoFormatting(QXmlStreamWriter* theWrappedObject) const diff --git a/generated_cpp_515/com_trolltech_qt_xmlpatterns/com_trolltech_qt_xmlpatterns0.cpp b/generated_cpp_515/com_trolltech_qt_xmlpatterns/com_trolltech_qt_xmlpatterns0.cpp index 12cf06079..d8ac82d34 100644 --- a/generated_cpp_515/com_trolltech_qt_xmlpatterns/com_trolltech_qt_xmlpatterns0.cpp +++ b/generated_cpp_515/com_trolltech_qt_xmlpatterns/com_trolltech_qt_xmlpatterns0.cpp @@ -158,7 +158,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractMessageHandler::timerEvent(QTimerEvent* event0) { @@ -183,7 +183,7 @@ if (_wrapper) { QAbstractMessageHandler::timerEvent(event0); } QAbstractMessageHandler* PythonQtWrapper_QAbstractMessageHandler::new_QAbstractMessageHandler(QObject* parent) -{ +{ return new PythonQtShell_QAbstractMessageHandler(parent); } const QMetaObject* PythonQtShell_QAbstractMessageHandler::metaObject() const { @@ -381,7 +381,7 @@ if (_wrapper) { QAbstractUriResolver::timerEvent(event0); } QAbstractUriResolver* PythonQtWrapper_QAbstractUriResolver::new_QAbstractUriResolver(QObject* parent) -{ +{ return new PythonQtShell_QAbstractUriResolver(parent); } const QMetaObject* PythonQtShell_QAbstractUriResolver::metaObject() const { @@ -904,7 +904,7 @@ if (_wrapper) { return QVariant(); } QAbstractXmlNodeModel* PythonQtWrapper_QAbstractXmlNodeModel::new_QAbstractXmlNodeModel() -{ +{ return new PythonQtShell_QAbstractXmlNodeModel(); } QVector PythonQtWrapper_QAbstractXmlNodeModel::attributes(QAbstractXmlNodeModel* theWrappedObject, const QXmlNodeModelIndex& element) const @@ -1028,7 +1028,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::attribute(const QXmlName& name0, const QStringRef& value1) { @@ -1050,7 +1050,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::characters(const QStringRef& value0) { @@ -1072,7 +1072,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::comment(const QString& value0) { @@ -1094,7 +1094,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::endDocument() { @@ -1116,7 +1116,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::endElement() { @@ -1138,7 +1138,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::endOfSequence() { @@ -1160,7 +1160,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::namespaceBinding(const QXmlName& name0) { @@ -1182,7 +1182,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::processingInstruction(const QXmlName& target0, const QString& value1) { @@ -1204,7 +1204,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::startDocument() { @@ -1226,7 +1226,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::startElement(const QXmlName& name0) { @@ -1248,7 +1248,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::startOfSequence() { @@ -1270,7 +1270,7 @@ if (_wrapper) { } } } - + } void PythonQtShell_QAbstractXmlReceiver::whitespaceOnly(const QStringRef& value0) { @@ -1295,7 +1295,7 @@ if (_wrapper) { QAbstractXmlReceiver::whitespaceOnly(value0); } QAbstractXmlReceiver* PythonQtWrapper_QAbstractXmlReceiver::new_QAbstractXmlReceiver() -{ +{ return new PythonQtShell_QAbstractXmlReceiver(); } void PythonQtWrapper_QAbstractXmlReceiver::atomicValue(QAbstractXmlReceiver* theWrappedObject, const QVariant& value) @@ -1869,7 +1869,7 @@ if (_wrapper) { return QVariant(); } QSimpleXmlNodeModel* PythonQtWrapper_QSimpleXmlNodeModel::new_QSimpleXmlNodeModel(const QXmlNamePool& namePool) -{ +{ return new PythonQtShell_QSimpleXmlNodeModel(namePool); } QXmlNamePool* PythonQtWrapper_QSimpleXmlNodeModel::namePool(QSimpleXmlNodeModel* theWrappedObject) const @@ -1880,15 +1880,15 @@ QXmlNamePool* PythonQtWrapper_QSimpleXmlNodeModel::namePool(QSimpleXmlNodeModel QSourceLocation* PythonQtWrapper_QSourceLocation::new_QSourceLocation() -{ +{ return new QSourceLocation(); } QSourceLocation* PythonQtWrapper_QSourceLocation::new_QSourceLocation(const QSourceLocation& other) -{ +{ return new QSourceLocation(other); } QSourceLocation* PythonQtWrapper_QSourceLocation::new_QSourceLocation(const QUrl& uri, int line, int column) -{ +{ return new QSourceLocation(uri, line, column); } qint64 PythonQtWrapper_QSourceLocation::column(QSourceLocation* theWrappedObject) const @@ -2236,7 +2236,7 @@ if (_wrapper) { QXmlFormatter::whitespaceOnly(value0); } QXmlFormatter* PythonQtWrapper_QXmlFormatter::new_QXmlFormatter(const QXmlQuery& query, QIODevice* outputDevice) -{ +{ return new PythonQtShell_QXmlFormatter(query, outputDevice); } int PythonQtWrapper_QXmlFormatter::indentationDepth(QXmlFormatter* theWrappedObject) const @@ -2252,19 +2252,19 @@ void PythonQtWrapper_QXmlFormatter::setIndentationDepth(QXmlFormatter* theWrappe QXmlItem* PythonQtWrapper_QXmlItem::new_QXmlItem() -{ +{ return new QXmlItem(); } QXmlItem* PythonQtWrapper_QXmlItem::new_QXmlItem(const QVariant& atomicValue) -{ +{ return new QXmlItem(atomicValue); } QXmlItem* PythonQtWrapper_QXmlItem::new_QXmlItem(const QXmlItem& other) -{ +{ return new QXmlItem(other); } QXmlItem* PythonQtWrapper_QXmlItem::new_QXmlItem(const QXmlNodeModelIndex& node) -{ +{ return new QXmlItem(node); } bool PythonQtWrapper_QXmlItem::isAtomicValue(QXmlItem* theWrappedObject) const @@ -2295,15 +2295,15 @@ QXmlNodeModelIndex PythonQtWrapper_QXmlItem::toNodeModelIndex(QXmlItem* theWrap QXmlName* PythonQtWrapper_QXmlName::new_QXmlName() -{ +{ return new QXmlName(); } QXmlName* PythonQtWrapper_QXmlName::new_QXmlName(QXmlNamePool& namePool, const QString& localName, const QString& namespaceURI, const QString& prefix) -{ +{ return new QXmlName(namePool, localName, namespaceURI, prefix); } QXmlName* PythonQtWrapper_QXmlName::new_QXmlName(const QXmlName& other) -{ +{ return new QXmlName(other); } QXmlName PythonQtWrapper_QXmlName::static_QXmlName_fromClarkName(const QString& clarkName, const QXmlNamePool& namePool) @@ -2354,21 +2354,21 @@ QString PythonQtWrapper_QXmlName::toClarkName(QXmlName* theWrappedObject, const QXmlNamePool* PythonQtWrapper_QXmlNamePool::new_QXmlNamePool() -{ +{ return new QXmlNamePool(); } QXmlNamePool* PythonQtWrapper_QXmlNamePool::new_QXmlNamePool(const QXmlNamePool& other) -{ +{ return new QXmlNamePool(other); } QXmlNodeModelIndex* PythonQtWrapper_QXmlNodeModelIndex::new_QXmlNodeModelIndex() -{ +{ return new QXmlNodeModelIndex(); } QXmlNodeModelIndex* PythonQtWrapper_QXmlNodeModelIndex::new_QXmlNodeModelIndex(const QXmlNodeModelIndex& other) -{ +{ return new QXmlNodeModelIndex(other); } qint64 PythonQtWrapper_QXmlNodeModelIndex::additionalData(QXmlNodeModelIndex* theWrappedObject) const @@ -2409,19 +2409,19 @@ bool PythonQtWrapper_QXmlNodeModelIndex::__eq__(QXmlNodeModelIndex* theWrappedO QXmlQuery* PythonQtWrapper_QXmlQuery::new_QXmlQuery() -{ +{ return new QXmlQuery(); } QXmlQuery* PythonQtWrapper_QXmlQuery::new_QXmlQuery(QXmlQuery::QueryLanguage queryLanguage, const QXmlNamePool& np) -{ +{ return new QXmlQuery(queryLanguage, np); } QXmlQuery* PythonQtWrapper_QXmlQuery::new_QXmlQuery(const QXmlNamePool& np) -{ +{ return new QXmlQuery(np); } QXmlQuery* PythonQtWrapper_QXmlQuery::new_QXmlQuery(const QXmlQuery& other) -{ +{ return new QXmlQuery(other); } void PythonQtWrapper_QXmlQuery::bindVariable(QXmlQuery* theWrappedObject, const QString& localName, QIODevice* arg__2) @@ -2576,7 +2576,7 @@ PythonQtShell_QXmlResultItems::~PythonQtShell_QXmlResultItems() { if (priv) { priv->shellClassDeleted(this); } } QXmlResultItems* PythonQtWrapper_QXmlResultItems::new_QXmlResultItems() -{ +{ return new PythonQtShell_QXmlResultItems(); } QXmlItem PythonQtWrapper_QXmlResultItems::current(QXmlResultItems* theWrappedObject) const @@ -2597,11 +2597,11 @@ QXmlItem PythonQtWrapper_QXmlResultItems::next(QXmlResultItems* theWrappedObjec QXmlSchema* PythonQtWrapper_QXmlSchema::new_QXmlSchema() -{ +{ return new QXmlSchema(); } QXmlSchema* PythonQtWrapper_QXmlSchema::new_QXmlSchema(const QXmlSchema& other) -{ +{ return new QXmlSchema(other); } QUrl PythonQtWrapper_QXmlSchema::documentUri(QXmlSchema* theWrappedObject) const @@ -2672,11 +2672,11 @@ const QAbstractUriResolver* PythonQtWrapper_QXmlSchema::uriResolver(QXmlSchema* QXmlSchemaValidator* PythonQtWrapper_QXmlSchemaValidator::new_QXmlSchemaValidator() -{ +{ return new QXmlSchemaValidator(); } QXmlSchemaValidator* PythonQtWrapper_QXmlSchemaValidator::new_QXmlSchemaValidator(const QXmlSchema& schema) -{ +{ return new QXmlSchemaValidator(schema); } QAbstractMessageHandler* PythonQtWrapper_QXmlSchemaValidator::messageHandler(QXmlSchemaValidator* theWrappedObject) const @@ -3027,7 +3027,7 @@ if (_wrapper) { QXmlSerializer::whitespaceOnly(value0); } QXmlSerializer* PythonQtWrapper_QXmlSerializer::new_QXmlSerializer(const QXmlQuery& query, QIODevice* outputDevice) -{ +{ return new PythonQtShell_QXmlSerializer(query, outputDevice); } const QTextCodec* PythonQtWrapper_QXmlSerializer::codec(QXmlSerializer* theWrappedObject) const diff --git a/generator/CMakeLists.txt b/generator/CMakeLists.txt index 1d659dd87..0801c58c0 100644 --- a/generator/CMakeLists.txt +++ b/generator/CMakeLists.txt @@ -20,9 +20,9 @@ if(QT4_FOUND) if(${found_qt_version} VERSION_LESS ${minimum_required_qt_version}) message(FATAL_ERROR "error: PythonQt requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${found_qt_version}.") endif() - + set(QT_USE_QTXML ON) - + include(${QT_USE_FILE}) else() message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable") @@ -50,7 +50,7 @@ set(sources parser/tokens.cpp parser/type_compiler.cpp parser/visitor.cpp - + abstractmetabuilder.cpp abstractmetalang.cpp asttoxml.cpp @@ -72,7 +72,7 @@ set(sources typeparser.cpp typesystem.cpp ) - + #----------------------------------------------------------------------------- # List headers. This list is used for the install command. @@ -93,7 +93,7 @@ set(moc_sources shellheadergenerator.h shellimplgenerator.h ) - + #----------------------------------------------------------------------------- # UI files @@ -141,9 +141,9 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/parser ${CMAKE_CURRENT_SOURCE_DIR}/parser/rpp ) - + add_definitions(-DRXX_ALLOCATOR_INIT_0) - + add_executable(${PROJECT_NAME} ${sources} ${gen_moc_sources} diff --git a/generator/LGPL_EXCEPTION.txt b/generator/LGPL_EXCEPTION.txt index 8f73eca77..a54c00e44 100644 --- a/generator/LGPL_EXCEPTION.txt +++ b/generator/LGPL_EXCEPTION.txt @@ -4,7 +4,7 @@ As an additional permission to the GNU Lesser General Public License version 2.1, the object code form of a "work that uses the Library" may incorporate material from a header file that is part of the Library. You may distribute such object code under terms of your choice, provided that: - (i) the header files of the Library have not been modified; and + (i) the header files of the Library have not been modified; and (ii) the incorporated material is limited to numerical parameters, data structure layouts, accessors, macros, inline functions and templates; and diff --git a/generator/LICENSE.LGPL b/generator/LICENSE.LGPL index 22bc77aac..496833e65 100644 --- a/generator/LICENSE.LGPL +++ b/generator/LICENSE.LGPL @@ -65,7 +65,7 @@ modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - + Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a @@ -121,7 +121,7 @@ modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - + GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -156,7 +156,7 @@ such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - + 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an @@ -168,7 +168,7 @@ Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - + 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 @@ -226,7 +226,7 @@ instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - + Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. @@ -277,7 +277,7 @@ Library will still fall under Section 6.) distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - + 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work @@ -339,7 +339,7 @@ restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - + 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined @@ -380,7 +380,7 @@ subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - + 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or @@ -432,7 +432,7 @@ conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - + 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is @@ -466,7 +466,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - + How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest diff --git a/generator/generator.pri b/generator/generator.pri index c7d58552e..c70e38ecc 100644 --- a/generator/generator.pri +++ b/generator/generator.pri @@ -50,7 +50,7 @@ HEADERS += \ - + SOURCES += \ $$GENERATORPATH/generator.cpp \ $$GENERATORPATH/main.cpp \ @@ -67,7 +67,7 @@ SOURCES += \ $$GENERATORPATH/prigenerator.cpp \ - + QT += core xml win32-msvc.net { diff --git a/generator/generator.pro b/generator/generator.pro index c159e23b9..477260e12 100644 --- a/generator/generator.pro +++ b/generator/generator.pro @@ -13,7 +13,7 @@ HEADERS += \ shellimplgenerator.h \ shellheadergenerator.h \ setupgenerator.h - + SOURCES += \ generatorsetqtscript.cpp \ metaqtscriptbuilder.cpp \ diff --git a/generator/shellimplgenerator.cpp b/generator/shellimplgenerator.cpp index 2302d650d..38d18d3c1 100644 --- a/generator/shellimplgenerator.cpp +++ b/generator/shellimplgenerator.cpp @@ -55,7 +55,7 @@ QString ShellImplGenerator::fileNameForClass(const AbstractMetaClass* meta_class } /* UNUSED -static bool include_less_than(const Include &a, const Include &b) +static bool include_less_than(const Include &a, const Include &b) { return a.name < b.name; } diff --git a/generator/simplecpp/do_not_stop_on_error.patch b/generator/simplecpp/do_not_stop_on_error.patch index 85047dcd4..35db41dc2 100644 --- a/generator/simplecpp/do_not_stop_on_error.patch +++ b/generator/simplecpp/do_not_stop_on_error.patch @@ -13,5 +13,5 @@ index 84e4b54b..88cedd4e 100644 } +*/ } - + if (rawtok->str() == DEFINE) { diff --git a/generator/typesystem_network.xml b/generator/typesystem_network.xml index c1d917ece..fbf4b0e36 100644 --- a/generator/typesystem_network.xml +++ b/generator/typesystem_network.xml @@ -77,7 +77,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -161,7 +161,7 @@ - + @@ -241,12 +241,12 @@ - + - + diff --git a/generator/typesystem_opengl.xml b/generator/typesystem_opengl.xml index b8de602c5..f5e8a9b18 100644 --- a/generator/typesystem_opengl.xml +++ b/generator/typesystem_opengl.xml @@ -18,7 +18,7 @@ - + @@ -50,7 +50,7 @@ - + diff --git a/generator/typesystem_quick.xml b/generator/typesystem_quick.xml index 02d6abdc7..b4bae78e5 100644 --- a/generator/typesystem_quick.xml +++ b/generator/typesystem_quick.xml @@ -73,7 +73,7 @@ - + diff --git a/generator/typesystem_sql.xml b/generator/typesystem_sql.xml index ad50a2593..f80d9bef9 100644 --- a/generator/typesystem_sql.xml +++ b/generator/typesystem_sql.xml @@ -25,7 +25,7 @@ - + diff --git a/generator/typesystem_svg.xml b/generator/typesystem_svg.xml index c4e5a6a7b..7da919b5e 100644 --- a/generator/typesystem_svg.xml +++ b/generator/typesystem_svg.xml @@ -1,6 +1,6 @@ - + diff --git a/generator/typesystem_uitools.xml b/generator/typesystem_uitools.xml index 9b5b3b9d9..d037c3028 100644 --- a/generator/typesystem_uitools.xml +++ b/generator/typesystem_uitools.xml @@ -1,5 +1,5 @@ - + diff --git a/generator/typesystem_webenginewidgets.xml b/generator/typesystem_webenginewidgets.xml index 0cafeba32..1ac0dfe89 100644 --- a/generator/typesystem_webenginewidgets.xml +++ b/generator/typesystem_webenginewidgets.xml @@ -13,7 +13,7 @@ - + diff --git a/generator/typesystem_webkit.xml b/generator/typesystem_webkit.xml index 84ba47e4d..e334cbbb8 100644 --- a/generator/typesystem_webkit.xml +++ b/generator/typesystem_webkit.xml @@ -29,7 +29,7 @@ - + @@ -94,7 +94,7 @@ - + @@ -124,8 +124,8 @@ - + - + diff --git a/src/PythonQtDoc.h b/src/PythonQtDoc.h index 682baec96..97772ecff 100644 --- a/src/PythonQtDoc.h +++ b/src/PythonQtDoc.h @@ -221,8 +221,8 @@ Qt framework. -# \anchor qvariant QVariants are mapped recursively as given above, e.g. a dictionary can contain lists of dictionaries of doubles. -# \anchor pyobject PyObject is passed as direct pointer, which allows to pass/return any Python object directly to/from - a Qt slot that uses PyObject* as its argument/return value. - + a Qt slot that uses PyObject* as its argument/return value. + All Qt QVariant types are implemented, PythonQt supports the complete Qt API for these objects. @@ -273,11 +273,11 @@ Qt framework. \code class MySender(QtCore.QObject): - + emitProgress = QtCore.Signal(float) # this is actually a double argument in C++ - + class MyReceiver(QtCore.QObject): - + @QtCore.Slot(float) def progress(self, value): print(f"progress: {value}") diff --git a/src/src.pri b/src/src.pri index 68f5bfb23..441043486 100644 --- a/src/src.pri +++ b/src/src.pri @@ -42,7 +42,7 @@ HEADERS += \ $$PWD/PythonQtUtils.h \ $$PWD/PythonQtBoolResult.h \ $$PWD/PythonQtThreadSupport.h \ - + SOURCES += \ $$PWD/PythonQtStdDecorators.cpp \ $$PWD/PythonQt.cpp \ diff --git a/src/src.pro b/src/src.pro index bba84356c..e7fba7578 100644 --- a/src/src.pro +++ b/src/src.pro @@ -35,11 +35,11 @@ macx { } } -include ( ../build/common.prf ) +include ( ../build/common.prf ) include ( ../build/python.prf ) TARGET = $$replace(TARGET, PythonXY, Python$${PYTHON_VERSION}) -include ( src.pri ) +include ( src.pri ) include($${PYTHONQT_GENERATED_PATH}/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin.pri) include($${PYTHONQT_GENERATED_PATH}/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin.pri) From f093a67cc80de20de1055bb391183d8c34e2c177 Mon Sep 17 00:00:00 2001 From: mrbean-bremen Date: Wed, 19 Nov 2025 13:53:55 +0100 Subject: [PATCH 4/4] Use Qt 6.10.0 explicitly in CI, as 6.10.1 fails - probably a problem with aqtinstall, see https://github.com/miurahr/aqtinstall/issues/803 --- .github/workflows/build_latest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_latest.yml b/.github/workflows/build_latest.yml index 30ac95f6c..07990f4d3 100644 --- a/.github/workflows/build_latest.yml +++ b/.github/workflows/build_latest.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu', 'windows'] - qt-version: [ '5.12.*', '5.15.*', '6.10.*' ] + qt-version: [ '5.12.*', '5.15.*', '6.10.0' ] python-version: [ '3.12' ] runs-on: ${{ matrix.os }}-latest steps: