aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator
Commit message (Collapse)AuthorAgeFilesLines
* Exclude reverse operations from shift hackCristian Maureira-Fredes2018-11-271-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | An old fix for a QDataStream bug was performing an additional step related reverse operations, to make sure we call them if they were implemented in other classes. This was intended for shift operations. Classes like QVector*, QTransform, and others which include reverse operations like __radd__, and __rmul__ will include this patch too. When implementing a class that inherits from these types, this becomes an infinite loop, which can be solved applying this patch only for shift operations. Due to this change, a QMatrix and a shiboken test needed to be adapted. Change-Id: Ie399837b6435b2cd058648a15f4d5cdff037ac6b Fixes: PYSIDE-192 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Signature: Implement Nested Classes and Functions for ShibokenChristian Tismer2018-11-151-14/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch again contains a complete overhaul of the signature module. The code was re-implemented to properly support nested classes. Also, the code was reduced by AutoDecRef and by adopting a concise C++ style. Note.. We will add a shiboken signature test and complete mapping.py after the split into three projects is done. The split changes a lot and is needed right now! Signatures were quite complete for PySide, but the support for Shiboken was under-developed. Since we are planning to generally enhance error messages by using the Signature module, we should be able to rely on them to always produce a signature. Therefore, a general overhaul was needed to resolve all cornes cases for Python 2 and 3. Nested classes are supported, as well as plain module functions. The usage of the typing module might improve over time, but the Signature implementation is now considered complete. The loader will respect now the path settings which might not be the package dir but the build dir. This is more consistens with COIN testing. Task-number: PYSIDE-795 Change-Id: I246449d4df895dadf2bcb4d997eaa13d78463d9b Reviewed-by: Simo Fält <simo.falt@qt.io>
* shiboken: Generate static_cast for constructor parameters with spaceFriedemann Kleint2018-11-141-2/+7
| | | | | | | | unsigned long(0) does not work, use static_cast<unsigned long>(0). Fixes: PYSIDE-846 Change-Id: If41baebdf0b1228b658408e4c300872d17143e6f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Merge remote-tracking branch 'origin/5.11' into 5.12Friedemann Kleint2018-10-291-1/+1
|\ | | | | | | Change-Id: I3bb491686968e81382c135ab737da259d9796f52
| * Fix Memory Leak Caused By Wrong Limited API DefaultChristian Tismer2018-10-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a type has nullptr as tp_dealloc, there apply different defaults. Static types had object_dealloc as default, while new heaptypes created with type_new have subtype_dealloc as default. A problem was now that PyType_FromSpec also has subtype_dealloc as default. But that is wrong, because a type that was written with the static type approach is already written with object_dealloc in mind and takes somehow care about further issues with that type. When we now convert this type and suddenly use subtype_dealloc instead of object_dealloc, things get pretty wrong. Finding that out was pretty hard and took quite long to understand. The fix was then very easy and is the best proof: Replacing our former (wrong) solution of supplying an SbkDummyDealloc with a function object_dealloc works perfectly, and the leakage completely vanished. The documentation now is also corrected. Task-number: PYSIDE-832 Change-Id: Ifc20c28172eb5663cd5e60dac52e0a43acfb626c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Sort writing of type indices when generating module header fileAlexandru Croitor2018-10-231-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to some unknown determinism, sometimes the type indices written to the generated module header file have a slightly different order, which means that many cpp files need to be rebuilt for no reason (semantically the content of the header file does not change). Make sure to sort the class list by type indices, to try and make the generated header file as deterministic as possible. This is a pre-requisite for improved incremental builds. Change-Id: Ie6a334453cdbfbb601fbac4b6be9291a746650f4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Stop updating timestamps of generated files that haven't changedAlexandru Croitor2018-10-232-27/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a change in preparation for improved incremental builds, where modifying one typesystem XML file will not force rebuilding all generated cpp files. The previous logic was incorrect, file timestamps should not be updated if the generated files are unchanged, instead the build rules need to be adapted to prevent unnecessary rebuilds. Change-Id: Ia47f8ff1970e974d0e617b6891ab58666da3b1ff Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Use class FileOut for the module source file as wellFriedemann Kleint2018-10-193-27/+21
| | | | | | | | | | | | | | | | | | | | | | Ensure the diff/dry-run options work for this file as well. Move the touchFile() utility around and adapt the verifyDirectoryFor() helper to take a string. Task-number: PYSIDE-834 Change-Id: Ic34b5f8eff304d9de85f60082f582f0537805cd4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Fix crash when garbage collecting in a non-GUI threadFriedemann Kleint2018-10-151-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a GUI class happens to be detected unreferenced when garbage collecting in a non-GUI thread and is subsequently deleted, crashes can occur for QWidgets and similar classes. The hitherto unimplemented delete-in-main-thread" attribute should be used. Add the missing implementation. Add the field to shiboken's type entry and SbkObjectTypePrivate class and pass it via newly introduced flags to introduceWrapperType(). Defer the deletion when invoked from the background thread and store the list of destructors in a list in binding manager run by Py_AddPendingCall(). Task-number: PYSIDE-743 Task-number: PYSIDE-810 Change-Id: Id4668a6a1e32392be9dcf1229e1e10c492b2a5f5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Allow building shiboken2 and PySide2 as separate wheelsAlexandru Croitor2018-10-123-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Actually this creates 3 wheel packages: - shiboken2 (the python module and libshiboken shared library) - shiboken2-generator (contains the generator executable, libclang and dependent Qt libraries) - PySide2 (the PySide2 modules and Qt shared libraries, and tools like rcc, uic) Calling the setup.py script will not do the actual build now (in the sense of calling CMake, make, etc.). Instead it will spawn new processes (via subprocess.call) calling the same setup.py script, but with different arguments. These "sub-invocations" will do the actual building. Thus, the "top-level invocation" will decide which packages to build and delegate that to the "sub-invocations" of setup.py. A new optional command line argument is introduced called "--build-type" which defaults to "all", and can also be set to "shiboken2", "shiboken2-generator" and "pyside2". A user can choose which packages to build using this option. The "top-level invocation" uses this option to decide how many "sub-invocations" to execute. A new command line argument called "--internal-build-type" takes the same values as the one above. It defines which package will actually be built in the new spawned "sub-invocation" process. The "top-level invocation" sets this automatically for each "sub-invocation" depending on the value of "--build-type". This option is also useful for developers that may want to debug the python building code in the "sub-invocation". Developers can set this manually via the command line, and thus avoid the process spawning indirection. A new class Config is introduced to facilitate storage of the various state needed for building a single package. A new class SetupRunner is introduced that takes care of the "--build-type" and "--internal-build-type" argument handling and delegation of "sub-invocations". A new class Options is introduced to 'hopefully', in the future, streamline the mess of option handling that we currently have. setup.py now is now simplified to mostly just call SetupRunner.run_setup(). Certain refactorings were done to facilitate further clean-up of the build code, the current code is definitely not the end all be all. Various other changes that were needed to implement the wheel separation: - a new cmake_helpers directory is added to share common cmake code between packages. - the custom popenasync.py file is removed in favor of using subprocess.call in as many places as possible, and thus avoid 10 different functions for process creation. - Manifest.in is removed, because copying to the setuptools build dir is now done directly by prepare_packages functions. - because prepare_packages copies directly to the setuptools build dir, avoiding the pyside_package dir, we do less copying of big Qt files now. - versioning of PySide2 and shiboken2 packages is now separate. shiboken2 and shiboken2-generator share the same versions for now though. - shiboken2 is now listed as a required package for PySide2, to facilitate pip requirements.txt dependencies. - coin_build_instructions currently needs to install an unreleased version of wheel, due to a bug that breaks installation of generated wheel files. - added separate command line options to pyside2_config.py for shiboken2-module and shiboken2-generator. - adapted samplebinding and scriptableapplication projects due to shiboken being a separate package. - adapted pyside2-tool and shiboken2-tool python scripts for setup tools entry points. - made some optimizations not to invoke cmake for shiboken2-generator when doing a top-level "all" build. - fixed unnecessary rpaths not to be included on Linux (mainly the Qt rpaths). Task-nubmer: PYSIDE-749 Change-Id: I0336043955624c1d12ed254802c442608cced5fb Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | Signature: Produce Correctly Nested Python InterfacesChristian Tismer2018-10-103-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The signature extension has been around for a while. As more and more demands arise, the quality of the generated signatures becomes more demanding: All signatures seem quite correct in PySide. But when testing the shiboken signatures, some weird results occurred. It turned out that nested classes were correctly handled by the code generator, but the produced signatures were quite wrong. Example: Before the patch: sample.ValueIdentity.multiplicator()->int After the patch: sample.Photon.ValueIdentity.multiplicator()->int This quirk becomes an issue, because now signatures are replacing the internally generated TypeError messages. Task-number: PYSIDE-510 Task-number: PYSIDE-795 Change-Id: I16a26ecc2a2d384cb3184144d3934b2606723d53 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | shiboken: Check whether enum should be converted to int for the protected hackFriedemann Kleint2018-10-012-1/+23
| | | | | | | | | | | | | | | | | | | | | | Find the AbstractMetaEnum belonging to the type entry and perform some checks. Generally do not use int for public enums. Warn when a protected scoped enum is encountered as this cannot be converted. Task-number: PYSIDE-817 Change-Id: I02b566093b331ea2ea627bf72964aad0a1a51c83 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Refactor finding of enumsFriedemann Kleint2018-09-282-17/+1
| | | | | | | | | | | | | | | | | | | | In the AbstractMetaBuilder, change the list of enums into a QHash with the type entry as key since that is mostly used for searching. Streamline and simplify the search functionality accordingly. Task-number: PYSIDE-817 Change-Id: I205cad1f90bc26511ea6b6e9b76ddb1bae544cf1 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Add exception handlingFriedemann Kleint2018-09-271-3/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | Add XML elements specifying an exception handling mode to type system, complex type entries (classes) and function modifications. From the mode and the exception specification as detected by Clang, deduce whether to generate try/catch code. Task-number: PYSIDE-62 Change-Id: Ib76adc21cefd81bf9f82f819a3c151056c33a3b7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Do not generate implicit conversions for array-modified constructorsFriedemann Kleint2018-09-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | Otherwise, syntax errors would be generated for QMatrix2x2(const float*), which is an array. Change-Id: Ic5c67e221934a4635c2bbeb83cd378ff4a02af66 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Improve handling of non-type template integer parametersFriedemann Kleint2018-09-131-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When trying to specify the base class template<int R, int C> QGenericMatrix of the QMatrixRxN classes, clashes of the SBK..IDX enumeration values occurred since the integers were not part of the type name. Fix that by dynamically adding dummy entries of EnumValueTypeEntry for the integer values encountered on the fly. Task-number: PYSIDE-725 Change-Id: Ie6b4489b5293e04b7c2c76861341c99b136cd558 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Add default constructible with default valuesFriedemann Kleint2018-09-132-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend the check for default constructible by also checking whether the first argument has an unmodified default value, for example: explicit QSqlIndex(const QString &cursorName = QString(), const QString &name = QString()); This can be treated like default constructible, except that {} may not be used for return values. Task-number: PYSIDE-62 Change-Id: I70af2a624de54201158a4b56e51b67ef115c2fc6 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Refactor Generator::minimalConstructor(AbstractMetaClass)Friedemann Kleint2018-09-132-82/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add some convenience functions returning the status of default expressions to AbstractMetaArgument. Rewrite the function to only insert suitable candidates into an ordered multimap instead of looping twice over all candidates. This unearthed a bug in the old algorithm trying to find the maximum number of arguments: When no candidates were found, maxArgs was left at 0, which caused it to assume default constructible. This triggered for the QMatrixNxN classes inheriting QGenericMatrix<int, int, Type> with (unsupported) non-type template parameters. For these, the default constructor needs to be specified now. Task-number: PYSIDE-62 Change-Id: I5ce2bed43001780553048d8af0addaba2b22410b Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | shiboken: Introduce DefaultValueFriedemann Kleint2018-09-124-64/+225
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a small class storing the return value of Generator::minimalConstructor() consisting of a type enumeration and a value, offering formatting for the use cases variable initializations, return values and constructor arguments lists. Having distinct formatting for the different use cases has some advantages: - Can use nullptr without casts (except in constructor arguments lists, where the type is needed for disambiguation). - In the previous implementation using a string, "" indicated an error; so, it was not possible to use it for default-constructors. It is now possible to handle default-constructors for initialization ("Foo f" instead of "Foo f = Foo()". - Can use {} for return values. Task-number: PYSIDE-62 Change-Id: I73229cb957d4b92b43de4cdbc3c66703f48faa61 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Store null enum valuesFriedemann Kleint2018-09-121-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | If an enum has a null value, store that on the EnumTypeEntry for use in Generator::minimalConstructor() as a default value. Fully qualify scoped enum value type entries for this purpose. The value can then be used for default values instead of an ugly static_cast<EnumType>(0). Task-number: PYSIDE-62 Change-Id: I42cb2ca63fb1da6c795df630ab30bded66aac901 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Centralize most msg* functions in a separate fileFriedemann Kleint2018-09-106-94/+8
| | | | | | | | | | | | | | | | | | This makes it easier to maintain a consistent style, unclutters the source and allows for re-using formatting helpers. Change-Id: I4f29637a22afb457f629272e2d86f14bedb36008 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Remove blanks from void returnsFriedemann Kleint2018-09-101-26/+50
| | | | | | | | | | | | | | | | Introduce a little helper class for formatting "return;" or "return value;" depending on a string. Change-Id: I6005af5496696cd83819f1ddbf3f75858b09a49b Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Initialize converter function to 0Friedemann Kleint2018-09-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix warnings: QtCore/qmessagelogcontext_wrapper.cpp:265:9: warning: variable 'pythonToCpp' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized] if (!Shiboken::String::check(pyIn) && (pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter<const char*>(), (pyIn)))) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ QtCore/qmessagelogcontext_wrapper.cpp:271:5: note: uninitialized use occurs here pythonToCpp(pyIn, &cppOut_local); ^~~~~~~~~~~ QtCore/qmessagelogcontext_wrapper.cpp:265:9: note: remove the '&&' if its condition is always true if (!Shiboken::String::check(pyIn) && (pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter<const char*>(), (pyIn)))) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ QtCore/qmessagelogcontext_wrapper.cpp:264:32: note: initialize the variable 'pythonToCpp' to silence this warning PythonToCppFunc pythonToCpp; ^ = nullptr in generated code like: PythonToCppFunc pythonToCpp; if (!Shiboken::String::check(pyIn) && (pythonToCpp = Shiboken::Conversions::isPythonToCppConvertible(Shiboken::Conversions::PrimitiveTypeConverter<const char*>(), (pyIn)))) { PyErr_SetString(PyExc_TypeError, "wrong type attributed to 'file', 'char' or convertible type expected"); return -1; } Change-Id: I4f4f454d32e1a99d26cdf19807a801d98f9256d3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Add a typedef typesystem entryFriedemann Kleint2018-09-051-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | The intention is be able to specify typedef std::optional<int> OptionalInt in the typesystem file and generate code for it (without having a typedef in C++). Task-number: PYSIDE-725 Change-Id: I5847a3c3f68556ac1d0ea3635f65a29caa6cb208 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Replace more character #defines by char constantsFriedemann Kleint2018-09-054-203/+240
| | | | | | | | | | | | | | | | Break up macro concatenation and streamline code. Replace PYTHON_SELF_VAR by "self" since it is not going to change. Change-Id: Ibfffd12bd44eb4dc3390b0a0a2da99e003b04bdc Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | shiboken: Replace some character #defines by char constantsFriedemann Kleint2018-09-044-35/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change defines to variables where possible (not used in string literal concatenations). Remove constants only used in one file from the header. Change regular expressions to raw string literals for clarity. Replace static instance of the CONVERTTOCPP regular expressions by an accessor of ShibokenGenerator. Change PATH_SPLITTER in main.cpp define to a QChar constant. Change-Id: If6766e0467ca2c635788240414c984d60feef875 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Fix visibility of members of the generator classesFriedemann Kleint2018-09-043-169/+172
| | | | | | | | | | | | | | | | | | | | Make visibility more restricted by moving definitions to the private/protected section. Remove virtual from Generator::moduleName() since it is not overridden. Change-Id: I6b43f9679741fa8a5c453b339d9bb4228d74c04c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.11' into devFriedemann Kleint2018-09-041-0/+2
|\| | | | | | | Change-Id: Ie8025300580981c5349b31d4846a7f659481991d
| * shiboken/doc generator: Add FunctionMask case to avoid warningCristian Maureira-Fredes2018-09-031-0/+2
| | | | | | | | | | | | Change-Id: I13226628db54479cc01aab215bb52063684f23c9 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | shiboken: Add support for const Foo* fieldsFriedemann Kleint2018-08-291-4/+23
| | | | | | | | | | | | | | | | Task-number: PYSIDE-304 Task-number: PYSIDE-672 Change-Id: Ic0e8e9ada594f27a8224adfb43847b3b8149c33d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | libpyside: Fix spelling of retrive->retrieveFriedemann Kleint2018-08-241-1/+1
| | | | | | | | | | | | | | Rename method and fix comments. Change-Id: I7765826540de0bf03ac41214d357e605d8e84bcf Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.11' into devFriedemann Kleint2018-08-241-1/+3
|\| | | | | | | Change-Id: Ide71a89ef173d6f3e1fa6960f7b15f1fd6cc1bf1
| * Implement Proper Name ManglingChristian Tismer2018-08-211-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When types have attributes starting with two underscores but ending with at most one, Python uses name mangling to create a unique private variable. PySide needs to obey this rule in the tp_getattro methods. We implemented it as an optimized _Pep_PrivateMangle function that solves the problem internally without exposing the _Py_Mangle function. Remark: I think the exclusion of the _Py_Mangle function is another oversight in the Limited API. Task-number: PYSIDE-772 Change-Id: I0bfc2418dae439e963a16e37443f2099c6980696 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | shiboken: Reduce generated include statementsFriedemann Kleint2018-08-221-8/+0
| | | | | | | | | | | | | | | | Remove shiboken.h from the wrappers and some unneeded headers from the module header. Change-Id: Ib05433e77686e544e3dcae27f5256ae1bbf146e1 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Expose Shiboken generated Python module objectTilman Roeder2018-08-224-10/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | This change exposes the module object (a PyObject*) to the global namespace as Sbk[TYPESYSTEM NAME]ModuleObject. This is useful when generating bindings for cases where Python will run embedded into a host application. This variable is also included in the headers, where it is declared as `extern PyObject* Sbk[TYPESYSTEM NAME]ModuleObject;` for the convenience of developers reading the generated sources. Change-Id: Iaaa38b66b5d3aabc0fb8f995f964cd7aef2a11da Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | shiboken/doc generator: Fix crash when normalizing tablesFriedemann Kleint2018-08-211-1/+7
| | | | | | | | | | | | | | | | | | Do not rely on row 0 to obtain the maximum number of columns, search all instead. Change-Id: I6ddda89c191d1823b346e9e564f31a61de523426 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devFriedemann Kleint2018-08-021-0/+3
|\| | | | | | | Change-Id: Id7cf17491d2bc97f90ccd1db44837b6b66e90eb8
| * shiboken: Work around non-deterministic buildsFriedemann Kleint2018-07-261-0/+3
| | | | | | | | | | | | | | | | Request deterministic ordering of QHash. Task-number: PYSIDE-757 Change-Id: Ifec8f9d39cb183cffeb58440156204f2ccb56a2c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | shiboken: Generate anonymous int-type enums instead of index macrosFriedemann Kleint2018-07-302-41/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #define SBK_QMETAOBJECT_CONNECTION_IDX 158 #define SBK_QTEXTCODEC_CONVERTERSTATE_IDX 246 becomes: enum : int { SBK_QMETAOBJECT_CONNECTION_IDX = 158, SBK_QTEXTCODEC_CONVERTERSTATE_IDX = 246, which is more pleasing to the eye. Rename the helper _writeTypeIndexDefineLine() to _writeTypeIndexValue() for the enum values and split out a function that writes the value only so that some code duplication can be avoided. Change-Id: I0d51afbbe93e515ba1dce1275fa5a01a6bcd95ca Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | shiboken: Fix naming of the index macrosFriedemann Kleint2018-07-271-8/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor the functions and extract a helper so that: #define SBK_QFLAGS_QT_KEYBOARDMODIFIER__IDX becomes #define SBK_QFLAGS_QT_KEYBOARDMODIFIER_IDX Task-number: PYSIDE-757 Change-Id: I1d6d1e0c85f458af90cdffa787748b0da5ac7b85 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Fix non-deterministic order of some SBK type indexesFriedemann Kleint2018-07-263-17/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change underlying type of the type database from a QHash<qualified_name, list of entries> to a QMultiMap<qualified_name, entry>. Previously, there was an allEntries() accessor and a function named entries() building a QHash<qualified_name, entry>. Simplify this so that there is only an entries() accessor returning the QMultiMap. Refactor the various Typedatabase::find() functions to operate on an iterator range of the QMultiMap. This unearthed some bugs: 1) In the generators, the call to findType(packageName()) would return the namespace entry for "sample" instead of the intended module type entry named "sample" due to the ordering. Add a new function to search for module type entries and assert that it finds it. 2) There was a duplicate, empty primitive type entry for QModelIndexList. Task-number: PYSIDE-757 Change-Id: I1814e4ca67d306e1488398507707cfd07b3f2c78 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | shiboken: Fix the allow-thread attribute to actually have an effectFriedemann Kleint2018-07-252-14/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, calls to BEGIN_ALLOW_THREADS/END_ALLOW_THREADS were always generated since the value of XML attribute was not used. Fix it to actually use the value. Since having it default to "no" caused a number of deadlocks (related to thread functions or functions calling a virtual function (potentially reimplemented in Python), introduce "auto" as default value. "auto" turns off BEGIN_ALLOW_THREADS/END_ALLOW_THREADS for simple getter functions. Task-number: PYSIDE-743 Change-Id: I4833afef14f2552c75b3424417c2702ce25cb379 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | shiboken: Output type database in debug modeFriedemann Kleint2018-07-241-1/+3
| | | | | | | | | | Change-Id: Id481aa5593c02c32656b141eaab6af800f978ebe Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devFriedemann Kleint2018-07-241-12/+12
|\| | | | | | | Change-Id: Ie90b31ed1b88f1353261fc4040db2d788df279e6
| * Pep 384 Final Cut: Remove PepTypeChristian Tismer2018-07-231-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While trying to document the Limited API Project, it suddenly struck me: We can make the patch much much simpler and implement it without the necessity to have an extra PepType! Now I am happy to continue the documentation, because it is now no more improvable. This version will last as long as the layout of PyTypeObject does not change substantially. When that happens, then we need to rewrite stuff with the according PyType_GetSlot() access functions. These access functions will until then be complete enough so that we can live without the tricks like inventing a reduced PyTypeObject as was done in the current implementation. Task-number: PYSIDE-560 Change-Id: I49849cc377baa6794a5b53292691e21d6e2853ab Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Fix some clang-tidy warnings in shibokenFriedemann Kleint2018-07-2310-98/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 'else if' after return/break/continue - Use const ref for complex arguments passed by value where possible - Fix 'if (foo) delete foo' to 'delete foo' - Use container.isEmpty() instead of container.size() in checks - Use ' = default' for trivial constructors/destructors - Use range based for where possible - Complete constructor initializer lists - Fix invocations of static methods - Replace some reinterpret_cast by static_cast - Remove unused variables/fields - Use initializer lists for return types Change-Id: Id5b44a2f9d429f66ef069d532a1cd31df796d38e Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Add options for diff and dry-runFriedemann Kleint2018-07-231-0/+20
| | | | | | | | | | | | | | | | | | Refactor and breathe life back into the existing diff/dry-run functionality of class FileOut and make it available via command line options. Change-Id: I32e1e262c0c2e8f107776923477fe9714ad295cf Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devFriedemann Kleint2018-07-201-2/+7
|\| | | | | | | Change-Id: I1b6fdc6b0ac59dd726a9977620f1070bebf237a6
| * Generate fully Qualified Names for FlagsChristian Tismer2018-07-161-2/+7
| | | | | | | | | | | | | | | | | | The flags structure should give correct full names. See the doc in the issue tracker. Task-number: PYSIDE-747 Change-Id: I6b5c602566d3e4b8a2a93e2522e92da956578b18 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | shiboken: Fix command line helpFriedemann Kleint2018-07-192-10/+10
| | | | | | | | | | | | | | | | | | The one-character path options only take one path argument. Add parameter to the doc generator options. Task-number: PYSIDE-363 Change-Id: Ia1a0c1552a5d1e3ec86609e9899e985628874545 Reviewed-by: Christian Tismer <tismer@stackless.com>