aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken/sbkenum.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Improve enum type operations implementationCristian Maureira-Fredes2018-11-201-78/+79
| | | | | | | | | | | | | | | | | | | | | | | The current implementation of the enum operations, wrongly assumes that the first element is always an enum. This patch add some logic to determinate the types we are dealing with, to allow operations like: 2 + QtCore.Qt.Key.Key_1 which were not accepted before. Float numbers are not accepted for enum operations and a test case was included. Some tests were adapted since they were wrongly implemented. Fixes: PYSIDE-830 Change-Id: I407dca2b7c39fc684dbdac19ad45d259403ebadd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> 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>
* | libshiboken: Fix clang-tidy warnings about class definitionsFriedemann Kleint2018-08-311-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | - Add override - Use = default for trivial constructors/destructors - Delete copy and move constructors/assignment and move assignment operators where not needed - Use member initialization and remove constructors from simple structs - Use explicit where applicable Change-Id: Id293dd0008b05243e665347f12fd1dee3b1b70f7 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | libshiboken: Fix remaining clang-tidy warningsFriedemann Kleint2018-08-301-1/+3
| | | | | | | | | | | | | | | | | | | | - Remove else after return/continue/break; unindent code or simplify return conditions - Fix C-style casts - Comment out unused parameter Change-Id: Iea1106023829658cd1ce005fa02d0c8940504dfd Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Limited API: remove the "slot_" workaroundChristian Tismer2018-08-231-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | It has been a problem to compile the file "typespec.*" when using Python 2. For some reason, the name "slot" was not usable. I cannot find out what it was and how it vanished, but now I could remove the work-around without problems. Maybe it is due to some different includes which don't define some macros? Change-Id: If316c9c78a18cffcc5e4cac07610bd7f522db446 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | libshiboken: Fix container typesFriedemann Kleint2018-07-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the ref count map to a unordered_multimap and the remaining lists to vectors. A linked std::list is not suitable for the lists used in libshiboken. Task-number: PYSIDE-727 Change-Id: Ibd65486a58cf43ac66b981bea65597df5a732b63 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | libshiboken: Refactor loopsFriedemann Kleint2018-07-301-4/+2
|/ | | | | | | | | | | Avoid repeated invocation of container.end() in the loop condition by either assigning to a variable or use range-based-for where possible. Use auto for iterators to allow for changing the container type. Task-number: PYSIDE-727 Change-Id: I5217207a3a7fb60823ccbcbf0915bf6cf21a3e4d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Pep 384 Final Cut: Remove PepTypeChristian Tismer2018-07-231-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | 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 limited API incompatibility with Python 3.7Christian Tismer2018-07-101-0/+4
| | | | | | | | | | | | | | | | | When Python 3.7 appeared, the structure of pystate.h was changed, substantially. Unfortunately this structure contains the trashcan code, which is only available as a macro and not part of the limited API. This code is normally not used by application programs. It prevents crashes when chains of millions of objects are deallocated. I disabled this for now when the limited API is active. As soon as somebody complains about crashes, I will try to implement it again in a safe way, but I am not sure if it is worth it in the first place. Task-number: PYSIDE-737 Change-Id: Id0daf391448ddcb9df3d299f859ef024714fa736 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PEP 384-squash: Implement PEP 384Christian Tismer2018-05-301-164/+211
| | | | | | | | | | This is the condensed checkin of 18 commits which created the implementation of PEP 384. Task-number: PYSIDE-560 Change-Id: I834c659af4c2b55b268f8e8dc4cfa53f02502409 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> 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>
* Type system: Add attribute indicating C++ 11 enum classesFriedemann Kleint2018-02-281-4/+9
| | | | | | | | | | | | | Introduce enumeration for the type to EnumTypeEntry which can be specified by the boolean "class" attribute. For the enum classes, the value names need to be qualified by the enum name to match the C++ API. For the C++ generator, add an overload to Shiboken::createScopedEnumItem() that takes a PyTypeObject and add the enum items to the enum so that the name is in the enum scope. Change-Id: Ia0e469d13b08c196b9ddd965b9cf3cc62a38630b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Remove dead / unused code regarding conversionsAlexandru Croitor2017-11-021-6/+0
| | | | | | | | | | | | | | | | | | | | | There's a lot of code that was previously used for doing conversions between C++ / Python types (apparently relying on extensive RTTI / typeid manipulations), which got superseded by a cleaner templated approach. The old code was left behind, and there were a few instances where it was still used even though it wasn't needed, like in QtScript typesystem XML and shiboken's enum handling. Remove the old code, apply the small changes needed to make it work with new the code. This is cleanup to reduce the confusion regarding conversion behavior, and also preparation for a proper implementation of handling "void*" types. Change-Id: I8f16bb31436f9a677bb2d64c7197c4375005b656 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* move everying into sources/shiboken2Oswald Buddenhagen2017-05-221-0/+623
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.