aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/typesystem.h
Commit message (Collapse)AuthorAgeFilesLines
* shiboken6: Add further methods to smart pointersFriedemann Kleint2021-11-251-0/+5
| | | | | | | | | | | | | | | | | Add attributes for reset() and null-check. The shared pointer in the test uses isNull() which works due to the --use-isnull-as-nb_nonzero option, but it should be possible to explicitly specify that. [ChangeLog][shiboken6] Attributes for reset() and null-check of smart pointers have been added. Task-number: PYSIDE-454 Change-Id: I22571eeb43f7f98b6a77b31066bf8daa681cb044 Reviewed-by: Christian Tismer <tismer@stackless.com> (cherry picked from commit eef987d0faaf1122f191a6ad92343d98f197715d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* shiboken6: TypeEntry: Use a pointer to the target lang API type entryFriedemann Kleint2021-09-241-1/+4
| | | | | | | | | | | | | Replace the string m_targetLangApiName by a pointer to the type entry; allowing to retrieve the check function. Similarly, in TargetToNativeConversion::sourceTypeCheck(), use the existing type entry to retrieve the check function, allowing for removing some heuristics. Task-number: PYSIDE-1660 Change-Id: Ieeda43f804b4e129d3cc0984e36bd0c0d546fd86 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Add built-in CPython typesFriedemann Kleint2021-09-241-0/+24
| | | | | | | | | | | | | | Add the CPython types along with their check functions. Introduce a new Python type entry for this. [ChangeLog][shiboken6] CPython types like PyObject, PySequence are now built into shiboken6 and no longer need to be specified in the typesystem files. Task-number: PYSIDE-1660 Change-Id: Ia2a7e5445c11b99cae069818aa5b0e1aa169533c Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Add opaque containers for C++ sequence containersFriedemann Kleint2021-09-241-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a class that directly wraps a C++ sequence container, allow for modifying them. For all instantiated containers, generate a special (sequence) type that wraps the C++ container directly. For example, it will be accessible as a QList_int. This is achieved via providing a template for a type private that relies on a conversion traits template for conversion. Only the conversion traits specialization code needs to be generated. Use cases: - Allowing for modifying Fields of such container types (non-owning) - Pass it into functions taking such containers instead of converting back and forth from a PyList (constructed in Python, owning) [ChangeLog][shiboken6] Support for opaque C++ sequence scontainers has been added, allowing to pass a wrapped C++ container directly instead of converting it back and forth from Python sequences. Task-number: PYSIDE-1605 Change-Id: I49d378eb1a0151730d817d5bdd4b71a7c3b5cdda Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Improve typesystem debug outputFriedemann Kleint2021-09-221-0/+7
| | | | | | | | | | | Add some debug output for PrimitiveTypeEntry and indicate built-in types. As a drive-by, add explamatory comment. Task-number: PYSIDE-1660 Change-Id: I870b7f3c2d344a6a3944ea8ac7ccb0d864cbe294 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Refactor PrimitiveTypeEntry::basicReferencedTypeEntry()Friedemann Kleint2021-09-221-9/+13
| | | | | | | | | | | | | | | | | Change it to always return "this" or the referenced type and add another getter referencesType() to check whether it actually references another entry. Also add another convenience function TypeEntry::asPrimitive(). This saves a lot of if's. Also remove ShibokenGenerator::pythonPrimitiveTypeName(PrimitiveTypeEntry *). Task-number: PYSIDE-1660 Change-Id: I7b3c2f32e67d64176bf0b9f11a2c4dea2d6273ba Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Add support for built-in typesFriedemann Kleint2021-09-171-0/+3
| | | | | | | | | Add a built-in flag to TypeEntry and fix the duplicate type entry checking logic to handle built-in types with a different warning. Task-number: PYSIDE-1660 Change-Id: I22b0fc92b0f19b4163a4311441638176ff6a4bfb Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Streamline the check function helpersFriedemann Kleint2021-09-171-0/+1
| | | | | | | | | Move the check for a check function specified in the type system from guessCPythonCheckFunction() to the calling functions. Task-number: PYSIDE-1660 Change-Id: I6d4eb30cfd98abe0aef5e49b1a54b5324b81bf7c Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Refactor handling of values with copy constructor onlyFriedemann Kleint2021-09-111-0/+4
| | | | | | | | | | | | | | | ShibokenGenerato::valueTypeWithCopyConstructorOnly() is frequently called when writing argument conversions. Instead of repeatedly searching for classes and looping its functions, determine the value once in AbstractMetaBuilder and set it as a boolean flag on class and type entry. Move the functions from ShibokenGenerator to AbstractMetaType. Task-number: PYSIDE-1605 Change-Id: If6701ff87b8dd23039f1d35daa6c9291acd0aa87 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Simplify the container typesFriedemann Kleint2021-07-201-10/+0
| | | | | | | | | | Remove the sequence types that are equivalent to list. Remove the hash types that are equivalent to map. Remove some functions that were left-over from Java. Task-number: PYSIDE-1605 Change-Id: If28344d39d44ac7ccf25dbc12a3a60a3693fc67d Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Add support for operator boolFriedemann Kleint2021-07-021-0/+7
| | | | | | | | | | | | | | | | [ChangeLog][shiboken6] operator bool can now be used for bool conversions (nb_bool) besides Qt-style isNull() methods. Add a command line option --use-operator-bool-as-nb_nonzero similar to use-isnull-as-nb_nonzero, enabling the use of operator bool for bool conversions. Make it possible to override both settings in typesystem XML. Task-number: PYSIDE-1334 Change-Id: I9c567e1b2cb97b22b41b3d9918046d793632160e Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Add a check-function attribute to custom type entriesFriedemann Kleint2021-06-111-0/+15
| | | | | | | | | | | | | | | | | shiboken knows some check functions and defaults to typeName + "_Check" in the end. For custom types in modified function arguments, it is useful to be able to specify a custom check function so that the overload decisor finds the right type. Add a CustomTypeEntry class with a checkFunction member for this. [ChangeLog][shiboken6] It is now possible to specify a check function for custom types in the typesystem. Pick-to: 6.1 Change-Id: I21ec541afd5073dede09d359f2e2e16a0c6a0a05 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Introduce a private attributeFriedemann Kleint2021-06-091-0/+3
| | | | | | | | | | | Generate a separate, private module header containing classes marked as "private" in the typesystem. This can be used for classes that are not used in dependent modules and helps to prevent propagation of for example private headers required for them. Task-number: PYSIDE-802 Change-Id: If7f19c152d007c689bf719e13292107dceb802da Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Mark old syntax for conversion rules as deprecatedFriedemann Kleint2021-05-261-15/+5
| | | | | | | | | | | | | TypeEntry had a string member for conversion rules (besides the nested "target-to-native" and "native-to-target" attributes) that was populated from the "file" attribute depending on the "class" attribute ("target"/"native"). Remove code path and flags for "native" since they were not used. Rename the member to targetConversionRule() for clarity and add a warning and FIXME comments. Pick-to: 6.1 Change-Id: I2a991d438e48c1cc0519d077cb3c0599f9800eb7 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Remove "Invalid" enumeration values that exist only for error ↵Friedemann Kleint2021-05-201-1/+0
| | | | | | | | | | | checking Change the lookup functions to return a std::optional, allowing for removing the defaults. Use uniform error handling and messages. Pick-to: 6.1 Change-Id: I49cb414e1044693f75af914d7c3c0dc45140ffc8 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Implement the force-abstract attributeFriedemann Kleint2021-01-291-1/+2
| | | | | Change-Id: Ib445fe0a42b8ab4bc4e1010fc26267471bb80145 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: De-virtualize TypeEntry::targetLangApiName()Friedemann Kleint2020-12-221-21/+8
| | | | | | | | | | | It is only used for the "target" attribute of PrimitiveTypeEntry, all other overridden methods return some Java-ish name. Make it a settable property and remove the overridden methods. Pick-to: 6.0 Change-Id: I34dd3c7a2cb3ea4f6968dc8c8d1a70aad9fbf5ed Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Add support for a snake case typesystem attributeFriedemann Kleint2020-12-071-0/+13
| | | | | | | | | | | | | Add a snake case attribute to type system, complex type entry, function type entry as well as to function and field modifications. Add a function definitionNames() to AbstractMetaFunction/Field returning the names under which the function/field will be registered. Change the code writing the registration accordingly. Fixes: PYSIDE-1441 Change-Id: I178390bb80fa25aad9f8a56e99e4cc70064178eb Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Refactor field modificationsFriedemann Kleint2020-12-021-1/+0
| | | | | | | | | | | Decouple class FieldModification from the base class Modification since it does not need its attributes and turn in into a value class using QSharedDataPointer for consistency with FunctionModification. Remove some unused code and simplify removed handling. Change-Id: I9997559acd529bd070df5ff84610fe75c74a71a5 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Replace QVector by QListFriedemann Kleint2020-11-251-2/+2
| | | | | | | | | | | | | | | | Change AbstractMetaClass::templateArguments() to return TypeEntries (const TypeEntry *) instead non-const. Remove redundant typedef OverloadData::MetaFunctionList. Use existing typedefs in some places. Add new typedefs for MetaObjectBuilder::EnumValues and AbstractMetaFunctionCList. Change-Id: Ia241b5fbe54d60ea57175fb1f6c844604e066a3d Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Move further C++ check functions from the generators to MetaLang*Friedemann Kleint2020-11-171-0/+6
| | | | | | | | | Rename isCppPrimitive() to isExtendedCppPrimitive() to disambiguate from the existing TypeEntry::isCppPrimitive() and to indicate that it includes more types, like std::string. Change-Id: I5ac62fb721e648c26fa4a5634595ff08937a7155 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Move further C++ check functions from the generators to MetaLang*Friedemann Kleint2020-11-171-0/+7
| | | | | Change-Id: I14fe14a2c7a5efff01dcd34bc1682cd8e264ab86 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Introduce a private class hierarchy for TypeEntryFriedemann Kleint2020-11-101-595/+190
| | | | | | | | | | | | | | | | | Move the data members of the TypeEntry classes to private classes, using convenience macros modeled after Qt's Q_D macro. The main motivation here is header hygiene and decoupling; typesystem.h was including a lot of classes. This requires moving some code around: - Move the debug formatting helpers of the TypeEntry classes from typedatabase.cpp to typesystem.cpp. - Move struct TypeRejection to typedatabase.h - Reorder typesystem.cpp in order of declaration. Change-Id: I24fe501d98940afd44caf75057cd6131cfbd6b6e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Split out modification classes from typesystemFriedemann Kleint2020-11-061-505/+5
| | | | | | | | Change Modification::Modifiers to be a QFlags and remove unused functions. Change-Id: Ia4a6b9ef06415275b33891cb04772780cd7f2d65 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Move defaultValue from AddedFunction::TypeInfo to ↵Friedemann Kleint2020-11-051-2/+2
| | | | | | | | | | AddedFunction::Argument It does not really belong into the type. This makes it easier to merge CodeModel's TypeInfo and AddedFunction::TypeInfo. Change-Id: I38c947839e4dc785aad70e8636838db020f031d4 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Add element <declare-function>Friedemann Kleint2020-10-301-0/+4
| | | | | | | | | | Make it possible to simply declare functions that the code parser cannot see. Task-number: PYSIDE-904 Task-number: PYSIDE-1339 Change-Id: If50bc0f1fc77a63e753b6fa440e6f08dd312ce4c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Rename shiboken2 to shiboken6Friedemann Kleint2020-10-281-0/+1701
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>