aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2
Commit message (Collapse)AuthorAgeFilesLines
* shiboken: Improve the libdir for windowsCristián Maureira-Fredes2020-02-271-1/+2
| | | | | | | | | | | | | | | | | | | | With virtualenv 20 we have the case where the first path in the PYTHON_LIBRARIES cmake variable was wrong: a_virtual_env/libs/python3.lib so the python code inside the helper didn't have a proper check if the file was valid or it was just a wrong construct. Additionally, the 'prefix' variable will contain the virtual environment directory location, which will not contain the 'libs' directory, because that's included in the system's installation path. To solve this, we use the 'INCLUDEPY' directory, which is correct as a base to create the real 'libs' one. Task-number: PYSIDE-1231 Change-Id: Ifca08d74c49cd57572836a087edb96c089266dc7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 22e359bc19daf19033332aa2d7bb9726c7f4be14) Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix RuntimeError: dictionary changed size during iterationJulien Schueller2019-10-211-1/+1
| | | | | | | | | | Seems the dictionary of modules needs to be copied before iterating Fixes https://github.com/spyder-ide/qtpy/issues/195 Change-Id: I8517e031c4a250856d3318b364b1cd5dab3f8f80 Reviewed-by: Christian Tismer <tismer@stackless.com> (cherry picked from commit dc73e75c1802df9e7594097ca65327b937097b3f) Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix heaptype conflict with QtCore.QObject.__new__in Python 2.7Christian Tismer2019-09-061-40/+54
| | | | | | | | | | | | | | | | | | | | | The patching of the type generation needs to become universal. Additional to the patch for SbkObjectType_TypeF, we now patch * SbkObjectTypeTpNew * introduceWrapperType which makes the modifications for the heaptype flag complete. Actually, the modification of tp_new_wrapper has to be more sophisticated in this general case: We follow the __mro__ and patch exactly those functions which have the old wrapper and add the new wrapper. Change-Id: I51d4d77c99bd18eed2e31d2ab21143c0f4e2ea6c Fixes: PYSIDE-1051 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit cd6172063756a59e02f1a7857bc60a1737214ad1)
* Bump version for 5.12.5Simo Fält2019-08-271-1/+1
| | | | | Change-Id: I741a7880bf87cca4a6482cc0e07e6f878e2e02b3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix crash when accessing a invalid property in the smart pointerRenato Araujo Oliveira Filho2019-08-073-1/+21
| | | | | | | | Sbk_*_getattro receives an utf8 string and we need to convert it to ascii string before use it on PyErr_Format. Change-Id: Ie3cf5286c9eb6b01f86347b00d523837ca41de32 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Allow for "auto" as target of type for CONVERTTOCPP in injected codeFriedemann Kleint2019-07-292-1/+3
| | | | | | Task-number: PYSIDE-1037 Change-Id: Idfc70fe571e4058d0c82db1bd0afea54436fe27c Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: fix a signature bug in __doc__ handling of global functionsChristian Tismer2019-07-231-9/+19
| | | | | | | | | | | | | | | | | The signature module was extended to allow automatic creation of __doc__ attributes by taking str of the signature. This function has to figure out when it should not touch an object that does not come from PySide. The check asked the type that was returned by GetClassOfFunc, but in case of a global function, the module of the function is returned. In order to prevent such mistakes, the function has been renamed to GetClassOrModOf. Change-Id: I055f1f0483674553f9300d642aa516cec607e66c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Keith Kyzivat <keith.kyzivat@qt.io>
* Cleanup signature module before substantial changeChristian Tismer2019-07-177-276/+557
| | | | | | | | | | | | | | | | | | | | | | There were some refinements applied while developing "Support Pointer Primitive Types by Arrays or Result Tuples". This patch moves these changes out which are not essential for that patch. They include - sort all mapping groups by name - replace huge regex by a pattern generator - replace dictionary string entries by SimpleNameSpace - improve PEP 563 handling - simplify "zero(sometype)" substantially - better handling of "QGenericMatrix" (preview) A test for the generated pattern against a reference parser was added. Task-number: PYSIDE-795 Task-number: PYSIDE-951 Change-Id: I5a6b236850c63a7db77b7f7b88881486fd1e61be Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add optional support for types in QSettings::valueCristián Maureira-Fredes2019-07-171-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This add an optional named parameter to the function value() to automatically cast the type that is being returned by the function. An example of this situation could be an ini file that contains the value of a one-element list: settings.setValue('var', ['a']) The the ini file will be: [General] var=a # we cannot know that this is a list! Once we read it, we could specify if we want the default behavior, a str, or to cast the output to a list. settings.value('var') # Will get "a" settings.value('var', type=list) # Will get ["a"] The cppgenerator was modified to add a verification step before trying to get the named parameter, since it could be optional and having one named parameter was assumming that all of them were provided. Change-Id: I8f379debea86b42cf89019d432e990084c9e6614 Fixes: PYSIDE-1010 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Improve handling of pointer types for CONVERTTOCPP in injected codeFriedemann Kleint2019-07-134-4/+47
| | | | | | | | | | | | | | Code snippets like: QByteArray *cppSelf = %CONVERTTOCPP[QByteArray *](obj); cause an assert in shiboken since the '*' is captured into the target of the assignment and is not considered part of the type. Make the error message a bit clearer and add documentation. Fixes: PYSIDE-1037 Change-Id: Ie8da2f57ba91325ea677e1a00852e91726c0e09b Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: List location of anonymous structs in rejected classesFriedemann Kleint2019-07-082-0/+5
| | | | | | | | Anonymous structs showed up as mysterious, empty entries in mjb_rejected_classes.log. Output the location. Change-Id: I0754e426a9fff3d1dac03aa587747ab0d7816df5 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Move typesystem parser out of typesystem.cppFriedemann Kleint2019-07-045-2954/+2990
| | | | | | | | The file is too large to be maintainable. Task-number: PYSIDE-1024 Change-Id: I9e95ede1b7e7ce804059ef510dcec9dc9e773a48 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix qApp import of QCoreApplicationChristian Tismer2019-06-281-5/+7
| | | | | | | | | | The qApp fix for embedding has a recursion bug when QCoreApplication is imported. This patch avoids imports altogether and uses the already captured module, instead. Change-Id: I1af7293a31840f6b09f8611446f6f35952dedd21 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* shiboken: Fix various clang warningsFriedemann Kleint2019-06-2531-153/+151
| | | | | | | | | | | | | | | | | - Avoid copying complex types by using const ref - Use isEmpty() to check for container emptyness - Use range-based for - Use Q_DISABLE_COPY in 'public:' area - Fix spelling error - Use '= default' for trivial constructors/destructors - Remove non-null checks before deletion - Fix misleading indentation - Fix else after return - Simplify boolean expressions - Fix unused parameters, streamline code Change-Id: I8c6cadd8653e220ba8e5bdb4dd55524d13a81768 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Replace C-style casts by C++ castsFriedemann Kleint2019-06-256-20/+19
| | | | | | | | Also change some reinterpret_cast<> to static_cast<> and use standard types for pointer arithmetics. Change-Id: Iafeeab5abffbca87d6f9767da9836bac342058c2 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Replace 'typedef' by 'using'Friedemann Kleint2019-06-2543-145/+133
| | | | | | | | Apply Fixits by Qt Creator with some amendments. Remove iterator types by using auto instead. Change-Id: I8a75323da6ae5cdcc6b67af8be9376408953986b Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Introduce autoFriedemann Kleint2019-06-2521-128/+127
| | | | | | | Apply Fixits by Qt Creator with some amendments. Change-Id: Ib2be1012ef7e8a2ad0e6cd130371bf1e941c4264 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Introduce nullptrFriedemann Kleint2019-06-2565-278/+278
| | | | | | | Apply Fixits by Qt Creator with some amendments. Change-Id: Ie8300ddb834adb8b649324562f2c912a4e8cf4ce Reviewed-by: Christian Tismer <tismer@stackless.com>
* Cleanup pointer and trailing whitespace (omissions)Christian Tismer2019-06-251-8/+8
| | | | | | | | | | | | | | | | | The "Cleanup pointer whitespace" patch was augmented by some C++11 changes. Unfortunately, this was done in the same commit, and so some old whitespace that was removed could re-appear invisibly, since it was in the original version. This fix tries to remove all trailing whitespace and also adds a few " *" corrections that were lost. The "type *" entries in XML files were changed back to "type*". Change-Id: Ic5c945ad64a47455fb15eebdf184b126af5ecd1d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Introduce member initializationFriedemann Kleint2019-06-2515-35/+29
| | | | | | | | | Use member initialization, use default bodies for constructors. Initialize missing members as reported by clang. Change-Id: Ibc51e46a37b310912ec8f274543092dfdda78e1b Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Fix out of bounds string accessFriedemann Kleint2019-06-241-1/+1
| | | | | | | | | | | Fix warning: (shiboken) Using QCharRef with an index pointing outside the valid range of a QString. The corresponding behavior is deprecated, and will be changed in a future version of Qt. introduced by qtbase/c2d2757bccc68e1b981df059786c2e76f2969530 (5.14). This happens when endPos is modified by the prior call to parseType(). Change-Id: I3b81e674c0aa118bd003aa25d8c61d89d772366f Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Cleanup pointer whitespace everywhereChristian Tismer2019-06-2449-1840/+1841
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Among other files to fix, basewrapper.(cpp|h) was full of uncommon pointer whitespace. After fixing that, I could not resist and fixed also libshiboken, generators, and after acceptance also PySide. Most of the time, this regex worked fine (\w\w+)([*&]+)[ ]*(?![&*]*[/=]) replaced with \1 \2 but everything was checked by hand. I did not touch the shiboken tests which are quite hairy. It turned out that inserting a space between a variable and asterisk causes a crash of shiboken, if the same line contains "CONVERTTOCPP". This was temporarily fixed by adding another space after it. Example.. sources/pyside2/PySide2/glue/qtcore.cpp line 977 QByteArray * cppSelf = %CONVERTTOCPP[QByteArray *](obj); //XXX /|\ omitting this space crashes shiboken! cppgenerator.cpp was special, since it was modified to _generate_ correct pointer whitespace. This caused a few testcases to fail, which had to be adjusted, again. This was difficult since some internal names must end on "*" and generated code normally not. Removing the last errors involved binary search on path sets... Apply C++ 11 fixits to the changed code, where applicable. Done-with: Friedemann.Kleint@qt.io Task-number: PYSIDE-1037 Change-Id: I4ac070f52c5efb296c05d581c9d46e6f397a6c81 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Use default compiler on macOSCristián Maureira-Fredes2019-06-191-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While building on macOS the detection of the compiler properly works, but at the time of getting the header libraries we rely on the command: <compiler> -E -x c++ - -v The problem is that since CMake resolves the full path of the compiler we do not properly get the includes that we should, calling the compiler directly via an absolute path (and not via the /usr/bin/clang shim) does not include the default SDK sysroot path. Here is an extract of both executions: * /Library/Developer/CommandLineTools/usr/bin/c++ -E -x c++ - -v #include <...> search starts here: /Library/Developer/CommandLineTools/usr/include/c++/v1 /usr/local/include /Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/include /Library/Developer/CommandLineTools/usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. * c++ -E -x c++ - -v #include <...> search starts here: /usr/local/include /Library/Developer/CommandLineTools/usr/include/c++/v1 /Library/Developer/CommandLineTools/usr/lib/clang/10.0.1/include /Library/Developer/CommandLineTools/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks (framework directory) End of search list. Change-Id: Iff300b3b543f5fb3a43f9ce1ea8986f9bc172323 Fixes: PYSIDE-1032 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix type name for lookup of QFlags<> convertersFriedemann Kleint2019-06-181-8/+23
| | | | | | | | | | | | | | | | | | | | For enum/flags registration, the converters were registered under invalid names like: Shiboken::Conversions::registerConverterName(converter, "QFlags<QFlags<QUrl::ComponentFormattingOption>"); Shiboken::Conversions::registerConverterName(converter, "QFlags<ComponentFormattingOption>"); In addition, QFlags<> is not used for type names in Python. Use the flags name as specified in the typesystem instead: Shiboken::Conversions::registerConverterName(converter, "QUrl::ComponentFormattingOptions"); Shiboken::Conversions::registerConverterName(converter, "ComponentFormattingOptions"); Change-Id: I79525643850bf4296516dfb9576f75b51adf6414 Fixes: PYSIDE-1029 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Generate code for smart pointers only within declaring packageFriedemann Kleint2019-06-131-2/+5
| | | | | | | | | | | | | | | | Check on the type entry whether code needs to be generated in the current package. Fixes: PYSIDE-1024 Change-Id: I82132b077ac6192b96d979cb5596d0e6fecbc76b Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Support the qApp macro in "scriptable application"Christian Tismer2019-06-173-9/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Renamed from "Fix scriptable application to support the qApp macro" because qApp was improved instead of scriptable application. The qApp macro needed some extra effort to support the qApp "macro" which is only defined in the Python wrappers. I took some generated code, created a QApplication instance in Python and used then reduced generated code to get at the object and adjust the refcount. This solution was then rejected, because I can do better, and in fact, scriptable application now has a correct qApp macro too, without any change to scriptable application. The central idea was to look into the module init function at import time and to see if a Q*Application already exists. I was not aware of that import. Many thanks for the rejection! :-) Update.. -------- After many attempts to make the qApp variable correctly behave like always, I recognized that pre-existing Q*Application instances have no wrappers or constructors at all! With that, it is not possible to create a sophisticated qApp macro as a singleton variable in the desired way. Fortunately, this is also not necessary, because a C++ Q*Application cannot be deleted from Python, and there is no point in supporting more that a simple variable. So in case of a pre-existing instance, the qApp variable now gets redirected to that instance. A small test was added to application_test.py that is triggered by an import. A weird effect when "qApp" was typed interactively before calling "QApplication()" was fixed, too. Change-Id: Ic69dd6a21c964838a90f63e316d299b62a54d612 Fixes: PYSIDE-571 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Revert "shiboken: Disambiguate indexes of smart pointer types"Friedemann Kleint2019-06-131-4/+1
| | | | | | | | | | | | This is not the proper fix for the issue. The index of the declaring module needs to be used for this to work. This reverts commit d2d0e397309a1b18eaff9ddee0940007f0e1c4bf. Task-number: PYSIDE-1024 Change-Id: Idc0e859ebda1626b5e841aa96be54317a5f3d0d0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Fix handling shared pointers passed by const-ref, take 2Friedemann Kleint2019-06-132-5/+9
| | | | | | | | | | | | | | | | With fd126b28e1d9b02ea16c813bc392461bdb05bd1d, broken wrapper code would still be generated for "const_QSharedPointer_QSize___&" depending on whether the const-ref or plain value type was encountered first when parsing. Fix the problem by stripping the qualifiers from the metatype added to GeneratorPrivate::m_instantiatedSmartPointers partially reverting fd126b28e1d9b02ea16c813bc392461bdb05bd1d. Change-Id: Ie6691e045b7d65baa3a0bc72dd8637f09eeaf111 Fixes: PYSIDE-1016 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Enable specifying names for a parameters of added functionsFriedemann Kleint2019-06-055-10/+59
| | | | | | | | | | Introduce a way to specify a name for a parameter using '@' delimiters. Fixes: PYSIDE-1017 Change-Id: I3ae505c104a64413ca2bad628d9f9d3e04bb5b88 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Signature: Try to recognize unknown modules in errorhandler.pyChristian Tismer2019-05-301-52/+42
| | | | | | | | | | | | There were unknown modules built with shiboken which mapping.py did not recognize. This is too restrictive, since we can import this module and try to produce something useful. This was rewritten to respect every binary module in sys.modules . Change-Id: I6626c69f002c307bae3eb78a557d1a7309983324 Fixes: PYSIDE-1009 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Complete the help() support for TypesChristian Tismer2019-01-183-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | The help() support based upon the Signature module worked fine but for types. The reason was that the __signature__ module was a new attribute, while __doc__ already existed through an inheritance-like mechanism. When we add __doc__ later, the attributes are already in the cache. PyType_Modified(type) does not help in PySide. The solution was to add tp_getset to the metaclass SbkObjectType_Type which otherwise would have been reached from PyType_Type ('type' in Python). Note.. It makes sense to add the injected documentation to the __doc__ strings as well. This enables help output even with the py_doc web service! Task-number: PYSIDE-908 Change-Id: I09dd4bc6746ee41566a467604c4a68de5d66f94b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Bump version strings to 5.12.4Simo Fält2019-06-101-1/+1
| | | | | Change-Id: If1386242c31e00412f289c9137c6a0427355ed9c Reviewed-by: Christian Tismer <tismer@stackless.com>
* Shiboken: prune non-existent includeJulien Schueller2019-05-281-2/+1
| | | | | Change-Id: I58f872d1e8abf2b624f37434c14e9ef6ea912749 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* CMake: Change the default behavior CMAKE_BUILD_TYPEJulien Schueller2019-06-062-8/+7
| | | | | | | | | | | | | | | | | Instead of setting CMAKE_BUILD_TYPE as a regular variable, set it as a cache value, but only as a default. If the user specifies -DCMAKE_BUILD_TYPE=Foo on the command line, that will take priority. PySide2 will inherit the build type from the shiboken build, also unless explicitly specified on the command line. Fix missing quotes around the build type in shiboken_helpers.cmake. Task-number: PYSIDE-980 Change-Id: I2f7e5f71b66467ca5b30056c42d26d9a54ff265b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Disambiguate indexes of smart pointer typesFriedemann Kleint2019-06-061-1/+4
| | | | | | | | | | Add the module name like it is done for namespaces and containers. Task-number: PYSIDE-1024 Change-Id: Iba8589bfe360763bc186e5129d0ba480b2fb58ae Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* correct bool(qApp) on Python 2Christian Tismer2019-06-061-1/+31
| | | | | | | | | | | | | | | | | | | | | | | The idiom to create an application if none exists qApp or QApplication() did not work on Python 2. This was recognized when another unrelated test broke that tried to use the idiom. This patch adds the missing method to Py_TYPE(Py_None) which Python 3 already has. A test case was added. Side-effect.. The warning about missing braces is gone, after the "PYTHON_IS_PYTHON3" macro is defined. This was forgotten in the review when when the macro was moved out of signature.cpp . Task-number: PYSIDE-571 Change-Id: I9b9304f407cd4cafb3ba0945ffb045802503a343 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Fix generation of init functions and types for const-refs of smart ↵Friedemann Kleint2019-06-064-2/+19
| | | | | | | | | | | | | | pointers Add a convenience to strip all qualifiers and use that. This at least fixes the naming (for example, getInitFunctionName returning "const_QSharedPointer_QSize___&"), the init function for the type itself is missing, though. Task-number: PYSIDE-1016 Change-Id: Id61b3c879199fc061e2846007951e3e9c82b85c4 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Implement the Buffer Protocol on VoidPtrRenaud Aubin2019-06-051-2/+85
| | | | | | | | | | Some use cases need direct data access for performance, e.g. initializing QPolygonF data with numpy.frombuffer. Implementing the Buffer Protocol as described in PEP3118 will allow direct data access. Change-Id: I13c46055b1cba115d099f1becb64c4cd04acdf0e Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix build on centOS/conda forgeFriedemann Kleint2019-05-292-5/+21
| | | | | | | | | | | - Check for the OS name case-insensitively - Use the compiler from cmake via a define - Add sysroot header directory to internal include paths - Extend centOS version to 6.10 Change-Id: Ia3977f3331d51f9bc530accb8defa5fcb648bdfe Fixes: PYSIDE-1012 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Make the __signature__ attribute writable by defaultChristian Tismer2019-05-271-21/+85
| | | | | | | | | | | | | | | | It turned out that the mock tool of the unittest module wants to write into a __signature__ attribute. We now allow this by implementing a writable attribute that memorizes any written value. When __del__ is used, the original value re-appears. We further added a check if a computed __signature__ attribute exists. Then we don't allow write access. This way, defined signatures are read-only, but a non-existent attribute stays writable. Change-Id: Ib70de723e3160787df04e075e5c540a4cb24d410 Fixes: PYSIDE-1004 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Make it possible to extend namespacesFriedemann Kleint2019-05-2216-40/+255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt has some modules, where functions and classes are added to namespaces of other modules. For example, QtGui adds the free functions mightBeRichText() and convertFromPlainText() to the "Qt" namespace and Qt3DQuick adds a namespace "Quick" to the namespace "Qt3DCore" started in Qt3DCore. Shiboken was unable to handle this since the name of the index constant was derived from the namespace name and would thus clash. Also, all code model items from the base module would be re-generated into the extended namespace. To fix this: - No longer join namespace code model items in clang builder. - Search for pre-existing namespaces in traverseNamespace() before creating a new one, continuing populating it. - Add a "files" attribute taking a regular expression to match header names to the namespace type entry, making it possible to restrict code model items by files when extending namespaces (as otherwise, all base items are again added). - Add "extends" attribute specifying the package name of the namespace to extend, which will be used as base type in CPython. - Disambiguate the SBK indexes of namespaces and the init_ functions by adding the module name. Change-Id: Ib552e878911942fa4d52d2bb0c6695e5b2c4c341 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix Shiboken.ObjectType.__new__ for Python 2.7 V2Christian Tismer2019-05-141-11/+88
| | | | | | | | | | | | | | | The original change gave assertion errors and had to be replaced. We now change the heap type flag temporarily in the call to Shiboken.ObjectType.__new__ and restore it afterwards. Change-Id: Ib15ecf2882739dc47db742c2a79e6269cdbb94b6 Fixes: PYSIDE-816 Fixes: PYSIDE-1003 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken: Fix some spelling errors in function namesFriedemann Kleint2019-05-043-6/+6
| | | | | | | | getMultipleIheritanceFunction() -> getMultipleInheritanceFunction() copyMultimpleheritance() -> copyMultipleInheritance() Change-Id: If15b1ec12b6037ac8cff9941e09a281bc219fa20 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Refactor code generating multiple inheritanceFriedemann Kleint2019-05-033-34/+20
| | | | | | | | | - Remove the check function hasMultipleInheritanceInAncestry(), which is nearly identical to getMultipleInheritingClass(). - Modernize the generated code to use C++ casts, uintptr_t and streamline Change-Id: I68f52c2cbf1a589fd31c9c73919365176c56932e Reviewed-by: Christian Tismer <tismer@stackless.com>
* Use PyUnicode_GetLength instead of PyUnicode_GetSizeCristian Maureira-Fredes2019-05-032-1/+7
| | | | | | | | The function PyUnicode_GetSize is deprecated. Change-Id: I0bc0acd35424f29e1f5154deb0429dab5a4aabd4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken documentation: Move TOC to index pageFriedemann Kleint2019-04-302-22/+15
| | | | | Change-Id: I0f7c6a303cb0d404c42ae96f067eece1442c4a33 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken/Generators: Cache class information lists per classFriedemann Kleint2019-04-303-30/+89
| | | | | | | | | | | | | | | | | | The function ShibokenGenerator::getFunctionGroups(class) is called many times for each function during code generation and causes a slowdown for the OpenGL version function classes, which have 1000 member functions. Split away getGlobalFunctionGroups() for the case scope=0 and introduce a global-static cache for class information that is more involved to determine for use by the various generators. Speeds up the generation of the QtGui module including the OpenGL version functions from 420s to 90s. Task-number: PYSIDE-955 Change-Id: I6b6aa35ef2197aa9cddbf339db9eb0220932f361 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Refactor progress message output handlingFriedemann Kleint2019-04-306-68/+65
| | | | | | | | | | | | In class ReportHandler, replace the step counting by a simple pair of startProgress()/endProgress() functions that check for warnings and print the appropriate terminator. Module name and timestamp are now also printed. Add a few more messages and give proper names to the generators. Change-Id: I92b4ef2854b824fbba3d371417edc1f88561a2cb Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Avoid too much stickiness when using --reuse-buildChristian Tismer2019-04-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We had some unwanted cache effects and needed to manually remove certain files before building. Otherwise it could happen that a build pretended to be ok, although there was a bug that prevented generation of the ".pyi" files. Further investigation showed: Using option "--reuse-build" with "no" and then with "yes" creates errors in the signature module. This makes "reuse-build" useless in this case. We now add an "a" to "pyside3d_build" as "pside3da_build" if "--limited-api=yes" was given. (different proposals welcome.) That solved most of the stickiness problems. A left-over lock directory is removed now, since it would prevent re-computation of the .pyi files. This is implemented by a recursive call to the script, where the subprocess does the work and the main process checks if there was a crash and removes the lock. The "--skip" parameter of generate_pyi.py was refined: When set, it is checked if the time stamp of all imported modules is less than the ".pyi" file time stamp. Only then the generation is skipped. By editing any involved python file, the ".pyi" files will be regenerated. Task-number: PYSIDE-560 Change-Id: I1b1d8ffbc58db3d4b38bf65e3795efcad7e7870c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken2: Enable documentation generation with libxml2/libxsltFriedemann Kleint2019-04-2515-190/+631
| | | | | | | | | | | | | | | As QtXmlPatterns is deprecated in Qt 5.14, the documentation build needs to be changed to work with libxml2/libxslt exclusively. Split the XML functionality into separate files for libxslt and Qt and provide an interface for XPATH queries and XSLT transformations in xmlutils.h. Adapt testmodifydocumentation to work on temporary files as libxslt cannot handle Qt resources. Change-Id: I923f5b2e7c1d2511f15788e4b80c7721daeb2bc3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>