aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpyside/feature_select.cpp
diff options
context:
space:
mode:
authorChristian Tismer <[email protected]>2021-07-28 18:51:34 +0200
committerChristian Tismer <[email protected]>2021-08-05 14:42:55 +0200
commit521dc4b6dcdd7d04a9ef6afe273833016f7ba31c (patch)
treeaeec8adc3e7ac9743cd99baf3e51aa2d8dbbe39a /sources/pyside6/libpyside/feature_select.cpp
parentf825ef2787d495b2aa1a4fd348ec1603d2a2d216 (diff)
feature: move getFeatureSelectId to Shiboken and refactor
This function caused problems when extending the signature module: For class methods, the signature module must become able to distinguish class methods in properties (true_property) which are static methods without a feature. That means: The signature module must know the full info about feature switching. Moving getFeatureSelectId into Shiboken simplifies matters quite a lot. The main feature switching code remains in PySide. Task-number: PYSIDE-1019 Pick-to: 6.1 Change-Id: I99116eefc0faf24a6eb9a16d79b21a5cc7ae299e Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Cristian Maureira-Fredes <[email protected]>
Diffstat (limited to 'sources/pyside6/libpyside/feature_select.cpp')
-rw-r--r--sources/pyside6/libpyside/feature_select.cpp33
1 files changed, 2 insertions, 31 deletions
diff --git a/sources/pyside6/libpyside/feature_select.cpp b/sources/pyside6/libpyside/feature_select.cpp
index 45af38bd7..648ec96a3 100644
--- a/sources/pyside6/libpyside/feature_select.cpp
+++ b/sources/pyside6/libpyside/feature_select.cpp
@@ -43,6 +43,7 @@
#include "class_property.h"
#include <shiboken.h>
+#include <sbkfeature_base.h>
//////////////////////////////////////////////////////////////////////////////
//
@@ -128,39 +129,10 @@ typedef bool(*FeatureProc)(PyTypeObject *type, PyObject *prev_dict, int id);
static FeatureProc *featurePointer = nullptr;
-static PyObject *cached_globals = nullptr;
-static PyObject *last_select_id = nullptr;
-
static PyObject *_fast_id_array[1 + 256] = {};
// this will point to element 1 to allow indexing from -1
static PyObject **fast_id_array;
-static inline PyObject *getFeatureSelectId()
-{
- static PyObject *undef = fast_id_array[-1];
- static PyObject *feature_dict = GetFeatureDict();
- // these things are all borrowed
- PyObject *globals = PyEval_GetGlobals();
- if (globals == nullptr
- || globals == cached_globals)
- return last_select_id;
-
- PyObject *modname = PyDict_GetItem(globals, PyMagicName::name());
- if (modname == nullptr)
- return last_select_id;
-
- PyObject *select_id = PyDict_GetItem(feature_dict, modname);
- if (select_id == nullptr
- || !PyInt_Check(select_id) // int/long cheating
- || select_id == undef)
- return last_select_id;
-
- cached_globals = globals;
- last_select_id = select_id;
- assert(PyInt_AsSsize_t(select_id) >= 0);
- return select_id;
-}
-
// Create a derived dict class
static PyTypeObject *
createDerivedDictType()
@@ -463,7 +435,6 @@ void init()
fast_id_array = &_fast_id_array[1];
for (int idx = -1; idx < 256; ++idx)
fast_id_array[idx] = PyInt_FromLong(idx);
- last_select_id = fast_id_array[0];
featurePointer = featureProcArray;
initSelectableFeature(SelectFeatureSet);
registerCleanupFunction(finalize);
@@ -471,7 +442,7 @@ void init()
is_initialized = true;
}
// Reset the cache. This is called at any "from __feature__ import".
- cached_globals = nullptr;
+ initFeatureShibokenPart();
}
void Enable(bool enable)