aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename shiboken2 to shiboken6Friedemann Kleint2020-10-281-3280/+0
| | | | | | | | Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I4cb5ee4c8df539546014b08202a7b1e98ed3ff07 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken2: Add location to error messages about added functionsFriedemann Kleint2020-10-281-2/+4
| | | | | Change-Id: I39210642a96e98328d193f4e81ecad82b496d6c9 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken2: AbstractMetaArgument: use QSharedData[Pointer]Friedemann Kleint2020-10-271-60/+55
| | | | | | | | | | | | | | | | | | | | Similar to AbstractMetaType, AbstractMetaArgument was previously kept as a raw pointer. The data were copied numerous times by AbstractMetaArgument::copy() when adding the inherited functions to a AbstractMetaClass. Similar to what was done for AbstractMetaType in 6cad0686101b252cfdbd1a6768a2b02c39aa1d8a, change the type to be based on QSharedData[Pointer]. It can then be passed around and treated like a C++ value type, with Qt sharing the data when possible behind the scenes. * Remove inheritance from AbstractMetaVariable by moving the fields over. * Remove the unused field m_originalName. Change-Id: Ic9e476ca71e163de131fbecc267d0a4e336cb0b9 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken2: Improve error messages about cyclic dependenciesFriedemann Kleint2020-10-271-5/+10
| | | | | | | | | | Return a struct instead of a plain list from Graph::topologicalSort() which contains the offending indexes and output the elements in case of failure. Task-number: PYSIDE-1202 Change-Id: Ib7f70c78be0e84272f31d802677c7fc333aa32f4 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken2: AbstractMetaType: use QSharedData[Pointer]Friedemann Kleint2020-10-231-146/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, shiboken2 kept AbstractMetaType by a raw pointer. The data were copied numerous times by AbstractMetaType::copy() when adding the inherited functions to a AbstractMetaClass or specializing templates, sometimes with a bool flag indicating ownership. To get rid of the copies and ownership issues, change the type to be based on QSharedData[Pointer]. It can then be passed around and treated like a C++ value type, with Qt sharing the data when possible behind the scenes. - Extract AbstractMetaType to a separate header/source - Remove unused AbstractMetaType::setInstantiationInCpp() - Remove unused member m_package - Rewrite the comparison of AbstractMetaType which becomes relevant for checking/detaching to do a complete comparison. It was previously unused, intended for a different implementation of view types with special cases. - Rework debug formatting - Invalid meta types are indicated by the "Invalid" usage pattern instead of null pointers Change-Id: Ic4b1feecafb4f0355f39e178c2703b104e45cf6c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-211-1/+3
|\ | | | | | | Change-Id: I8831b840fa7816b8919ecbaab17b41822a0a6012
| * shiboken2: Fix one more instance of an invalid metatype passed aroundFriedemann Kleint2020-10-211-1/+3
| | | | | | | | | | | | | | Add the missing call to decideUsagePattern(). Change-Id: Ibfe07afa3f830cefc953b8702aeca57e2b615f36 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-201-2/+4
|\| | | | | | | Change-Id: Iaabea628351fac9da88b5779b537f62262ff82a7
| * shiboken2: Ensure there are no AbstractMetaType with Invalid usageFriedemann Kleint2020-10-201-2/+4
| | | | | | | | | | | | | | | | | | | | Introduce new values for the pattern enum representing template parameters, which were previously invalid and add a missing call to decideUsagePattern(). Change-Id: I7edeb80a67ab1edfe895e96311d54c9128fad5a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-161-17/+65
|\| | | | | | | Change-Id: I27beffe4a6e2fc2f818960c3b9f5ffbfaac4a670
| * Enable typesystem typedefs across modulesFriedemann Kleint2020-10-151-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding a specialization of template type ValueWithUnit from libsample to libother would fail since the SBK index array of libsample would be used with the index from libother for it. Build up the inheritance for typesystem typedefs early on and add a lookup which matches the template specializations found during traversing functions to the type def and the class that is generated for it so that it can be used. As a side effect, special case entries for template specializations can be deleted from the signature mappings since they change to the class name and thus are normal types. Task-number: PYSIDE-1202 Change-Id: I5cc9650f70e9dc975171c80919685ebf5e752749 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * shiboken2: Enable setting up inheritance for templates early onFriedemann Kleint2020-10-151-17/+24
| | | | | | | | | | | | | | | | | | | | | | Split the code adding the specialized template functions from AbstractMetaBuilderPrivate::inheritTemplate() into a separate function. The part setting up the base classes can then be called at an earlier stage so that it is known when traversing the functions. Task-number: PYSIDE-1202 Change-Id: I958d357b78572c9b5130dbe1bf517d2af82a6f1a Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-141-43/+43
|\| | | | | | | Change-Id: I46f5d2dc758d0e1f23377c91ba7496793461771e
| * shiboken2: Find all template classes for added functionsFriedemann Kleint2020-10-141-3/+11
| | | | | | | | | | | | Task-number: PYSIDE-1202 Change-Id: I7039b113ffd43289f96f890ca55cb5b9b4607c92 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * shiboken2: Some RefactoringsFriedemann Kleint2020-10-141-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | - AbstractMetaType: Pass TypeEntry to constructor - AbstractMetaType: Return instantiations() by const ref - AbstractMetaClass: Make baseTemplateInstantiations a member instead of a global hash. Simplify the code accordingly. Task-number: PYSIDE-1202 Change-Id: I1a18aa4ff97481af8cb13e8732fe3952c48edb29 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * shiboken2: Use an AbstractMetaType for "void"Friedemann Kleint2020-10-131-32/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, nullptr for an AbstractMetaType meant "void", particularly for function return types. The problem with this is that it causes unexpected crashes when dealing with template types like QFuture<void> due to one of the instantiations of the AbstractMetaType being nullptr. Use an AbstractMetaType based on the existing "void" type entry for this. Task-number: PYSIDE-1202 Change-Id: Ib06035cc7903480fd509f7e927d9114c55d51b62 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-081-11/+8
|\| | | | | | | Change-Id: I30aaad19852c50b1222222ba66171f9c98ecb7c8
| * shiboken2: Rearrange values of enum TypeEntry::CodeGenerationFriedemann Kleint2020-10-081-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TypeEntry::CodeGeneration::GenerateCpp was unused. Consequently, the GenerateAll mask is not needed, either. Replace GenerateCpp and GenerateTargetLang by a generic GenerateCode value. Introduce a new GenerationDisabled value to be able to distinguish a generate='no' XML attribute from a plain rejection. Fix many invalid usages of bool generateCode() testing against the flag value. Use the enum instead of uint for the code generation field. Task-number: PYSIDE-1202 Change-Id: I0aec5bd1ebfb9a50b80d5a187372c4271490e1b3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Add QStringView/QByteArrayViewFriedemann Kleint2020-09-301-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | View types as function parameters cannot be converted in the standard way shiboken does it: QStringView cppArg0; pythonToCpp(pyArg, &cppArg0); since they reference some other data. Introduce a new "viewOn" member to type system entry for them. It causes the function arguments to be replaced by their viewed-on types (stringview->string) via metatype. Add a test in libsample and a test for QUuid::fromString(QStringView). Test returning QStringView via QRegularExpressionMatch::capturedView(). Task-number: QTBUG-84319 Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Task-number: PYSIDE-487 Change-Id: Iddb4ea268a54928d290e29012e2738772fae83f0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-291-5/+5
|\| | | | | | | Change-Id: Ie6da3938b82f5ebe96dd12bd65a3ccc4180d2fba
| * shiboken2: MetaBuilder/ApiExtractor/Generator: Return class/enum/function ↵Friedemann Kleint2020-09-281-5/+5
| | | | | | | | | | | | | | | | | | | | lists by const ref This allows for removing a few temporary variables and/or qAsConst(). Task-number: PYSIDE-1075 Change-Id: I0fe3544f0ce4d3a8d56de9c93e300972e0844177 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-241-71/+24
|\| | | | | | | Change-Id: I7e4c7f9378706438715362b1e2da9a3cd2794562
| * shiboken2: Add a way of specifying properties in typesystem XMLFriedemann Kleint2020-09-231-1/+22
| | | | | | | | | | | | | | | | | | | | Add a list of TypeSystemProperty to ComplexTypeEntry, parse it from XML and add those properties in AbstractMetaBuilderPrivate::parseQ_Properties(). Task-number: PYSIDE-1019 Change-Id: Idf6ecde7c9de6bf1e56be423921672152e97de70 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * shiboken2: Refactor property parsingFriedemann Kleint2020-09-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Store AbstractMetaType instead of TypeEntry in QPropertySpec for more complete type information and better parsing. Introduce a struct TypeSystemProperty to the typesystem which can be later populated from a newly introduced typesystem XML element. Rewrite the parser to first populate a TypeSystemProperty and convert it to QPropertySpec with type lookup in a second step. Change the parser algorithm to first look for any of the READ/WRITE tokens and split the tokens leading up to them into type name and property name in order to parse complex types like Q_PROPERTY(QList<QSpriteSheetItem *> sprites READ sprites.. correctly. Task-number: PYSIDE-1019 Change-Id: I942bc659cc236d31041cdc22e26a82d270599033 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken2: Move class PropertySpec into its own source fileFriedemann Kleint2020-09-221-70/+2
| | | | | | | | | | | | | | | | Move the class and the parser function into its own source file. Task-number: PYSIDE-1019 Change-Id: If403f799f6b8da769fd8b47dd958a7430d061ad8 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-221-6/+21
|\| | | | | | | Change-Id: Id0fc76666bbdb254a833eeb6909a0874b2611bf3
| * Shiboken2: Take member fields into account when sorting classesFriedemann Kleint2020-09-211-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | The type converters for class-type member fields need to be initialized before the respective classes; thus a dependency needs to be added Generator::classesTopologicalSorted(). Factor out common code and loop over the member fields, adding the dependencies to the graph. Task-number: PYSIDE-1224 Change-Id: Iec306aa7559453d41f7f62fefd5825db66aa4815 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-161-2/+3
|\| | | | | | | Change-Id: I114a003e36bbe9eb7452f13c1515e3419648e228
| * Do some cleanup to pysideproperty.cpp and feature selectChristian Tismer2020-09-141-2/+3
| | | | | | | | | | Change-Id: Id7e1a4f9f938f9b86e1e905936b78c1531f5a566 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-101-5/+19
|\| | | | | | | Change-Id: I8a627fd459c3f9601d078a00d3d77c8b3fe04304
| * shiboken2: Fix property parsingFriedemann Kleint2020-09-101-5/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Use simplify() on the specification to allow for arbitrary white space - Fix misplaced qualifiers like Q_PROPERTY(QXYSeries *series... - Output the error of translateType() in the "Unable to decide type of property.." warning - Handle '*' indirections in the type name for type lookup and add the indirections to PropertySpec. This fixes most of the "Unable to decide type of property.." warnings of the build Task-number: PYSIDE-1019 Change-Id: I8028536b1f52816c4eb66b23f6c5b3b161489dc5 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Remove most QT_VERSION checksFriedemann Kleint2020-09-031-4/+0
| | | | | | | | | | | | | | | | | | As a drive by, adapt to changed values of QMetaObject::Call. Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: Ic55a5da910c9ef022af3dedf749f80153f519ebf Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Start porting away from QStringRefFriedemann Kleint2020-08-191-1/+2
|/ | | | | | | | | | | | | QStringRef will be replaced by QStringView. Remove most usages or use auto. This will require a 2nd cleanup removing its usages from the QXmlStreamReader code once this has landed in qtbase. Task-number: QTBUG-84319 Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: I2885df70d5f883bcad7bb3a31618fc1d63116df5 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken2: Refactor the parsing of Q_PROPERTY()Friedemann Kleint2020-07-141-37/+63
| | | | | | | | | Split the function and add more error handling, add the source location to the message Task-number: PYSIDE-1019 Change-Id: I74276b2f163ff52db6792e3f3b8907ad392f1055 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken2: Do not strip arguments of unknown types of virtual functionsFriedemann Kleint2020-06-301-1/+3
| | | | | | | | | | | | | shiboken2 would strip arguments of unknown types with default values off the function as a convenience. This should not happen for virtual functions since the wrapper will then generate an invalid override functions (happens in Qt 6 for virtual QSGTextureWrapper::removedFromAtlas(QRhiResourceUpdateBatch *) since QRhiResourceUpdateBatch is currently still private). Task-number: PYSIDE-904 Change-Id: I0216e8329820dcda4556e1b685333005db0cf58c Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken2: Add file location to more warningsFriedemann Kleint2020-06-231-28/+20
| | | | | | | | | | | | | | | | | | | | Output most warnings in the standard file:line syntax used by compilers. This is done for C++ source code and typesystem files. Introduce a class SourceLocation and add it to type entry, AbstractMetaFunction and AbstractMetaClass. Move more messages into messages.cpp and output the location. Change the errors reported by the XML typesystem parser to the same format. [ChangeLog][shiboken] A number of error and warning messages have been prefixed by file name and line for better tooling. Task-number: PYSIDE-904 Change-Id: Ie2008f4060757e9d7ca1b25c00c7c5585240a7b8 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Further build fixes for Qt 6Friedemann Kleint2020-06-221-1/+0
| | | | | Change-Id: I2463997f1eb2012cbbd0192a019ca57beaf55d5b Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Allow for multiple header files on command lineFriedemann Kleint2020-06-031-11/+14
| | | | | | | | | | | | | | | | | | Change ApiExtractor and MetaBuilder to use QFileInfoList. Refactor the options handling to work on a struct separating options from positional arguments to make handling multiple file names easier. Refactor and streamline the options parsing code a bit, avoid duplicated parsing of project files. Print the usage when positional arguments are missing. [ChangeLog][shiboken] shiboken now accepts multiple headers on the command line. Change-Id: I221ab5a71232af1323408f77295137dc92e3d582 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Support non-type template parameters in functionsFriedemann Kleint2020-05-191-6/+18
| | | | | | | | | Create dummy constant value type entries on the fly as is done for classes. Fixes: PYSIDE-1296 Change-Id: I7990a44d5bf32dbf4bf801e06eb1af655ab8f488 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Fix duplicate base classesFriedemann Kleint2020-05-181-4/+0
| | | | | | | | | | | | When adding the code model dumping functions, it was noted that base classes show up duplicated. Remove code snippet adding the base class again, which is apparently a remnant from before removal of the InterfaceTypeEntry, ba366999c39e864b2999e6df2693ced3dbe34046. Task-number: PYSIDE-1265 Change-Id: I80737a5fb7b3a4505d8ab89dda252ad8878e0418 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Enable injecting raw code for setattro/getattroFriedemann Kleint2020-05-041-1/+6
| | | | | | | | | | | | | Setattro/getattro functions can be added. As shiboken also uses these functions internally, the code blocks are inserted into those implementations. As those are special functions, only raw code is injected. No macros are replaced for arguments or instances. Fixes: PYSIDE-1280 Change-Id: I207dcf70b3a9f5edc51ff6566b31a2a8aa4776ed Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Change most debug messages to use qCInfoFriedemann Kleint2020-04-281-6/+9
| | | | | | | | | | | | A a check for the verbose level where missing, improve the formatting and use qCInfo. Adjust some levels. As an exception, leave the actual code model DOM dump within qCDebug. Task-number: PYSIDE-1265 Change-Id: I7d1d8015a35a543ae0b58ad9e3667ecdb741ce82 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Remove some progress and other messagesFriedemann Kleint2020-04-181-16/+0
| | | | | | Task-number: PYSIDE-1265 Change-Id: I8c9651efcbe3d893ba191e0cf78cdcea39410b5c Reviewed-by: Christian Tismer <tismer@stackless.com>
* Merge remote-tracking branch 'origin/5.14' into 5.15Friedemann Kleint2020-03-251-24/+43
|\ | | | | | | Change-Id: Ibcd8a3b5c6d1d2f636fd21b162c67a85e727c2c4
| * shiboken: Enable flags types in added functionsFriedemann Kleint2020-03-231-0/+2
| | | | | | | | | | | | | | | | | | | | Add a search for flags entries to translateType(AddedFunction::TypeInfo). Task-number: PYSIDE-946 Task-number: PYSIDE-1241 Change-Id: I8f0092ad2dd546fdf8678864e49ad2940e7bb8dc Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken: Improve error messages about invalid types of added functionsFriedemann Kleint2020-03-231-24/+41
| | | | | | | | | | | | | | | | | | | | | | Change translateType() to pass up the error instead of aborting so that the error is printed in traverseFunction() along with the name. The abort in case of failure will then occur in fillAddedFunctions(). Task-number: PYSIDE-946 Task-number: PYSIDE-1241 Change-Id: Iee9ca478b28c8f82d9c4b6c5165f3028bf1e0d08 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken: Refactor base class handlingFriedemann Kleint2020-02-061-33/+11
| | | | | | | | | | | | | | | | | | Change the m_baseClass pointer into a vector to handle multiple inheritance. It will receive the base classes which previously were handled as interfaces. Change-Id: Idc6a5d6ce53bb9bbe054397194b660bd748e3042 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | shiboken: Remove InterfaceTypeEntryFriedemann Kleint2020-02-061-40/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | InterfaceTypeEntry is a relic from Java, which does not have multiple inheritance. Remove it and handle it as object-type. Just removing the code breaks tests though, since AbstractMetaClass only has one pointer to its base class. The other base classes are added to the interface list. FAIL! shiboken2:testmultipleinheritance Newly detected Real test failure! FAIL! shiboken2:sample::ownership_invalidate_after_use Newly detected Real test failure! FAIL! shiboken2:sample::visibilitychange Newly detected Real test failure! [ChangeLog][shiboken] interface-type has been deprecated. object-type should be used instead. Change-Id: I19e876d82b26c2ef7865e3fafc74503c6cbd5a8b Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | shiboken: Make it possible to specify smartpointer instantiationsFriedemann Kleint2020-02-051-20/+48
| | | | | | | | | | | | | | | | | | | | | | | | Add an attribute "instantiations" to the smart-pointer-type element, which allows to specify a comma-separated list of instantiation types for which wrappers should be generated in the module. This avoids clashes of indexes. Task-number: PYSIDE-1024 Change-Id: Iac4b93b91ca4982064beef4c5abafc547052e7f1 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | shiboken: Small code cleanupFriedemann Kleint2020-02-041-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix some left-over nullptr issues, C-style casts and some signedness issues. Remove some unused functions and parameters. Remove empty statements. Add defined() around macros, fixing warnings like: warning: '_WINDOWS' is not defined, evaluates to 0 Change-Id: Idaa4334cb0edb3661ca766c248ec18ab85b0ee8e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>