aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetalang.h
Commit message (Collapse)AuthorAgeFilesLines
* Add exception handlingFriedemann Kleint2018-09-271-1/+8
| | | | | | | | | | | | | 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: Refactor code for querying functions of AbstractMetaClassFriedemann Kleint2018-09-181-8/+7
| | | | | | | | | Move the checking code to a static method taking an AbstractMetaFunction and add static methods operating on a list. This makes it possible to implement checks without constructing temporary lists. Change-Id: I9b137858f81396f8243f2d1be5277e6a38be4c84 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Simplify code looking for copy constructorsFriedemann Kleint2018-09-181-1/+2
| | | | | | | | | Replace various loops operating on lists by a convenience function AbstractMetaFunction *AbstractMetaClass::copyConstructor() const Change-Id: If38b954ae01856a84835a17a7e4d3e981b5aac9b Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Extend exception specificationFriedemann Kleint2018-09-171-3/+3
| | | | | | | | | | | | | Change boolean 'noexcept' flag into an enumeration that indicates whether a function throws, is 'noexcept' or the behavior is unknown. This makes it easier to implement an 'auto' mode for exception handling. Task-number: PYSIDE-62 Change-Id: I4e5405863e5af2a54f3528ba5eb5c51d3929703d Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Do not generate implicit conversions for array-modified constructorsFriedemann Kleint2018-09-141-0/+1
| | | | | | | | | | | 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: Refactor Generator::minimalConstructor(AbstractMetaClass)Friedemann Kleint2018-09-131-0/+7
| | | | | | | | | | | | | | | | | | | | 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: Remove data fields representing unimplemented attributesFriedemann Kleint2018-08-301-8/+0
| | | | | | | | | Remove member variables and enumeration values. Task-number: PYSIDE-743 Change-Id: Id7bff33b180e99e19d02bd895e45e4f0749dc042 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* shiboken: Refactor code involved in inheriting template classesFriedemann Kleint2018-08-031-0/+8
| | | | | | | | | | | | | | | | - Add a helper template to conveniently search for a MetaClass by name and convenience function to search in lists. - Remove parameter bool *ok from AbstractMetaBuilderPrivate::inheritTemplateType() and check on returned pointer instead. - In the inheritTemplate*() functions, use QScopedPointer to ensure the result is deleted on failure. - Search for a shadowing function first before creating the copy in inheritTemplate(). Task-number: PYSIDE-725 Change-Id: I3183087fb42b22a2189c17b94eaafdb4c1151f0e Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Fix the allow-thread attribute to actually have an effectFriedemann Kleint2018-07-251-0/+3
| | | | | | | | | | | | | | | | 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: Add exception specification to clang parserFriedemann Kleint2018-07-241-0/+5
| | | | | | | | | For exception handling, calls into C++ might need to wrapped in try/catch. Detect noexcept functions for which this can be omitted. Task-number: PYSIDE-62 Change-Id: I37aced91ace184edf211a457a60c131d516a4037 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix some clang-tidy warnings in shibokenFriedemann Kleint2018-07-231-2/+2
| | | | | | | | | | | | | | | | | - '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 comparison to AbstractMetaTypeFriedemann Kleint2018-07-231-0/+7
| | | | | | | | | | | Extend the existing rudimentary comparison function from the meta builder and provide comparison operators. This will be useful for later refactorings. Task-number: PYSIDE-672 Change-Id: I793656a733db676d9bc3ab8910869e50274f6a79 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Improve support for volatileFriedemann Kleint2018-07-111-1/+5
| | | | | | | | | | | Previously, the volatile keyword ended up as a part of the qualified type name while parsing in translateType(). Add the token to TypeParser and add it to AbstractMetaType. Task-number: PYSIDE-672 Change-Id: I553ea1b35e7e99ffde4442471b82e32be84731ba Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Introduce enumeration for C++ indirectionsFriedemann Kleint2018-07-111-8/+15
| | | | | | | | | | | Replace the int "indirections" field of TypeInfo and AbstractMetaType by a Vector of an enumeration representing '*' and "* const". It is then possible distinguish between "int *" and "int *const". Task-number: PYSIDE-672 Change-Id: I68677fa515abb7e94217fc1c2b6ac28b42678284 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Documentation: Skip methods added by the meta builderFriedemann Kleint2018-05-181-1/+3
| | | | | | | | | Introduce an attribute for added methods and exclude them from the documentation generation. Task-number: PYSIDE-363 Change-Id: I06d3f468bcec4d0480012d29e26dabadae51634b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix wrongly generated code for enums passed by const-refFriedemann Kleint2018-05-161-0/+2
| | | | | | | | | | | | | | First encountered in: QtScxmlEvent::setEventType(const EventType &); The metatype was wrongly detected as NativePointerPattern in AbstractMetaType::determineUsagePattern(). Introduce a helper for detecting plain const-ref and use that consistently. Change-Id: I6b105bc99ae63e4737c5d628e79f23b7acbcca3d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Change license from all the filesCristian Maureira-Fredes2018-05-031-1/+1
| | | | | | | | | | | | | | | | | Removing the word 'project' from all the headers, and changing the PySide reference from the examples to Qt for Python: The following line was used inside the source/ and build_scripts/ directory: for i in $(grep -r "the Qt for Python project" * |grep -v "pyside2-tools" | awk '{print $1}' | sed 's/:.*//g');do sed -i 's/the\ Qt\ for\ Python\ project/Qt\ for\ Python/g' $i;done and the following line was used inside the examples/ directory: for i in $(grep -r "of the PySide" * |grep -v "pyside2-tools" | awk '{print $1}' | sed 's/:.*//g');do sed -i 's/of\ the\ PySide/of\ the\ Qt\ for\ Python/g' $i;done Change-Id: Ic480714686ad62ac4d81c670f87f1c2033d4ffa1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Rename PySide references to Qt for PythonCristian Maureira-Fredes2018-04-271-1/+1
| | | | | | | | | When referring to the project one should use "Qt for Python" and for the module "PySide2" Change-Id: I36497df245c9f6dd60d6e160e2fc805e48cefcae Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Use enum values from ClangFriedemann Kleint2018-04-191-3/+8
| | | | | | | | | | | | | | Remove a lot of ugly value parsing code in favor of clang_getEnumConstantDeclValue() and clang_getEnumConstantDeclUnsignedValue() depending on the type. Introduce a class EnumValue containing a union of qint64 and quint64 values to represent signed/unsigned values correctly and use that in the code model and meta language classes. Change-Id: If2efb7cfd560237907678b8f6fdfb0bc689c0c93 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Detect class enums by Clang entirelyFriedemann Kleint2018-04-191-2/+6
| | | | | | | | | | | | | | The Clang function clang_EnumDecl_isScoped() tells whether an enum is a class, so, there is no need to specify that in the typesystem. Use that information to pass it up to the metalang classes and revert the parts of 44cb6c51e6c3b43376f284941454dc8c13b81c3f that added it to the type system. Task-number: PYSIDE-487 Change-Id: Ie10885f74168821d0307e91b6f1f7f3f30dd074b Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Refactor finding of enumerationsFriedemann Kleint2018-02-231-2/+3
| | | | | | | | | | | | | | | - Add helper AbstractMetaEnum::findEnumValue() which finds unqualified as well as qualified enum values. - Remove unused function bstractMetaClass::findEnumForValue(QString). - Remove 2nd parameter from AbstractMetaClass::findEnumValue(QString, AbstractMetaEnum *). The comment claimed that it is excluded from the search, but the condition was the reverse. Just removing it apparently does not do harm. Task-number: PYSIDE-487 Change-Id: I32b036045ea335b805fba79df327cc42d787f18c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Documentation extraction: Add error handlingFriedemann Kleint2018-02-211-2/+5
| | | | | | | | | Trim the strings returned by the XPath queries and warn about failing queries. Task-number: PYSIDE-363 Change-Id: Ia0233d490497597cb78aa16b0908fe226270705c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Remove attributes Final and FinalInCppFriedemann Kleint2017-12-211-14/+1
| | | | | | | | | | Apparently, the meaning of FinalInCpp for functions was "virtual and not private". The previous code cleanup removed most uses of them. For the remaining cases, checking for virtual is sufficient. Change-Id: I6f794e36b99920af36fd0eba895be673dc35d9dd Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Remove unused code in abstractmetalang.hFriedemann Kleint2017-12-211-141/+1
| | | | | | | | | | | | The AbstractMeta* classes had a lot of functions trying to determine whether wrapper functions/classes should be generated. Apparently at some stage, this functionality was moved to the generator classes (apparently in conjunction with the "protected hack"), leaving the functions unused. Change-Id: Ia3fef96fe86cc6a6f9c70c674635bccf510362bc Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Stop using the FinalInCpp attribute for classesFriedemann Kleint2017-12-091-8/+16
| | | | | | | | | | | | | | | Besides its use for functions, the FinalInCpp attribute was used for classes meaning something like neither the class nor its derived classes can be constructed due to presence of private destructors and absence of non-private constructors. Since 'final' is now a reserved word in C++ 11, this becomes confusing. Remove the usage of the attribute for classes, add a bit field indicating presence of a private constructors and a new function isConstructible() instead. Change-Id: Ieb2f9943c21511e4f59d228885361e3ad66fb266 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Refactor copying of the MetaLang* classesFriedemann Kleint2017-12-061-1/+12
| | | | | | | | | Disable copying of the base classes AbstractMetaAttributes and AbstractMetaVariable and refactor the copy() functions of the derived classes in terms of protected assign*() functions. Change-Id: I6cbe1cfa02207230e914ad41dddba46c866cb689 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Unify constructors of the MetaLang* classesFriedemann Kleint2017-12-051-97/+45
| | | | | | | | | Use member initialization where possible. Move constructors/destructors of classes in hierarchies out of line (fixing Clang warnings about classes having no virtual out of line methods). Change-Id: I511e7261a077db259e6c305cb1dcb08c1ee4810f Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Use information about virtual from the code modelFriedemann Kleint2017-12-021-2/+0
| | | | | Change-Id: I27411e810fc3b3ff9d3bb629b5ebc2c7fdaa59ef Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken/MetaLang: Add information about override/finalFriedemann Kleint2017-12-021-0/+6
| | | | | | | Take over information from code model and test. Change-Id: Ibed2973e09b117966ed241798125f60ba337b0e9 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken/AbstractMetaAttributes: Remove some unused attributesFriedemann Kleint2017-12-011-21/+0
| | | | | | | Remove Native, FinalOverload, InterfaceFunction, Fake. Change-Id: I1232751169fafb144387343857a962bafee714e9 Reviewed-by: Christian Tismer <tismer@stackless.com>
* CodeModel: Handle access of inherited classesFriedemann Kleint2017-09-251-0/+6
| | | | | | | | | | | | | | Store the access of the base class in the code model. Remove protected/private base classes in the abstract meta builder as otherwise invalid code will be generated for classes like QAbstract3DGraph : public QWindow, protected QOpenGLFunctions when the protected hack is not in use (on Windows). Task-number: PYSIDE-487 Change-Id: I5bc2dad16f903da86e6e41450c2f9a76726ac028 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Add new <array> argument modification indicating array usageFriedemann Kleint2017-08-031-0/+1
| | | | | | | | | | | | The modification can be used to indicate that for example int* is meant to be used as int[]. This is reflected in the NativePointerAsArrayPattern usage pattern of AbstractMetaType. Task-number: PYSIDE-354 Task-number: PYSIDE-516 Change-Id: Icaeb3cce4be9ce06caa2cab628d4e8fc1b684819 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* libshiboken: Add Array convertersFriedemann Kleint2017-08-031-0/+4
| | | | | | | | | | | | | | | | Add a SbkArrayConverter struct which provides a list of check functions that return a converter function for an array of matching size. Add simple array converters for arrays of C++ primitive types. Instances of the ArrayHandle<>, Array2Handle<> templates will be generated which may point to internal data or allocated arrays. Task-number: PYSIDE-354 Task-number: PYSIDE-516 Change-Id: I157606891fad345ccd7af6d4a9d4dcb0c634b2f4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* AbstractMetaType: Join the signature functionsFriedemann Kleint2017-07-111-1/+2
| | | | | | | | | | Introduce a common helper function to format the signature for minimalSignature() / cppSignature() which differ only by whitespace. Task-number: PYSIDE-354 Task-number: PYSIDE-516 Change-Id: Ife6be7001618d73a7a2bc15e91bff4ae42192a45 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Remove AbstractMetaFunction::invalid()Friedemann Kleint2017-05-291-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change AbstractMetaBuilderPrivate::traverseFunction() to consistently return 0 if something does not fit. Previously, functions with half-parsed arguments with the invalid flag set were returned. This caused strange side effects since the flag was not checked in all places. The only relevant information is whether some constructors were rejected. In that case, no default constructors or default copy constructors should be generated. This is now determined by checking the code model function item; the attribute HasRejectConstructor is introduced for this. This fixes: - Make it possible to reject the QTextStreamManipulator constructor taking a function pointer without having a default constructor generated: typedef void (QTextStream::*QTSMFI)(int); QTextStreamManipulator(QTSMFI m, int a) Q_DECL_NOTHROW - Implement QtCharts whose class QAbstractSeries has a rejected constructor. Change-Id: I6310574ba677dac20699f257340d2c2a55674353 Reviewed-by: Christian Tismer <tismer@stackless.com>
* move everying into sources/shiboken2 (5.9 edition)Oswald Buddenhagen2017-05-221-0/+1976
in preparation for a subtree merge. this should not be necessary to do in a separate commit, but git is a tad stupid about following history correctly without it.