aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-07-28 18:51:34 +0200
committerChristian Tismer <tismer@stackless.com>2021-08-11 10:04:10 +0200
commit21a160203c68a165a6f6923d238300587e5fc921 (patch)
tree3bd0617d89ff28f810d566e2c65a360b4d1f352f
parentdbcd0e9d51a77ab925d5ac730d8480f91dd8115e (diff)
feature: move getFeatureSelectId to Shiboken and refactor
++ the 6.1 version caused problems due to missing pieces ++ the classmethod patch was missing, too 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 Change-Id: I99116eefc0faf24a6eb9a16d79b21a5cc7ae299e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 521dc4b6dcdd7d04a9ef6afe273833016f7ba31c)
-rw-r--r--sources/pyside6/libpyside/feature_select.cpp33
-rw-r--r--sources/shiboken6/ApiExtractor/modifications.h2
-rw-r--r--sources/shiboken6/libshiboken/CMakeLists.txt4
-rw-r--r--sources/shiboken6/libshiboken/basewrapper.cpp135
-rw-r--r--sources/shiboken6/libshiboken/bindingmanager.cpp9
-rw-r--r--sources/shiboken6/libshiboken/sbkfeature_base.cpp206
-rw-r--r--sources/shiboken6/libshiboken/sbkfeature_base.h56
-rw-r--r--sources/shiboken6/libshiboken/signature/signature.cpp11
-rw-r--r--sources/shiboken6/libshiboken/signature/signature_helper.cpp13
-rw-r--r--sources/shiboken6/libshiboken/signature/signature_p.h1
10 files changed, 279 insertions, 191 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)
diff --git a/sources/shiboken6/ApiExtractor/modifications.h b/sources/shiboken6/ApiExtractor/modifications.h
index 547e4e4ab..2f2e2e351 100644
--- a/sources/shiboken6/ApiExtractor/modifications.h
+++ b/sources/shiboken6/ApiExtractor/modifications.h
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
diff --git a/sources/shiboken6/libshiboken/CMakeLists.txt b/sources/shiboken6/libshiboken/CMakeLists.txt
index 241318178..c97eb5114 100644
--- a/sources/shiboken6/libshiboken/CMakeLists.txt
+++ b/sources/shiboken6/libshiboken/CMakeLists.txt
@@ -50,6 +50,7 @@ helper.cpp
sbkarrayconverter.cpp
sbkconverter.cpp
sbkenum.cpp
+sbkfeature_base.cpp
sbkmodule.cpp
sbkstring.cpp
sbkstaticstrings.cpp
@@ -101,7 +102,7 @@ shiboken_compute_python_includes()
shiboken_compute_python_libraries()
if(PYTHON_LIMITED_API)
- target_compile_definitions(libshiboken PUBLIC "-DPy_LIMITED_API=0x03050000")
+ target_compile_definitions(libshiboken PUBLIC "-DPy_LIMITED_API=0x03060000")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -129,6 +130,7 @@ install(FILES
sbkarrayconverter.h
sbkconverter.h
sbkenum.h
+ sbkfeature_base.h
sbkmodule.h
sbkstring.h
sbkstaticstrings.h
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp
index e9bdc15af..51a10d100 100644
--- a/sources/shiboken6/libshiboken/basewrapper.cpp
+++ b/sources/shiboken6/libshiboken/basewrapper.cpp
@@ -43,6 +43,7 @@
#include "helper.h"
#include "sbkconverter.h"
#include "sbkenum.h"
+#include "sbkfeature_base.h"
#include "sbkstring.h"
#include "sbkstaticstrings.h"
#include "sbkstaticstrings_p.h"
@@ -94,7 +95,6 @@ void Sbk_object_dealloc(PyObject *self)
static void SbkObjectTypeDealloc(PyObject *pyObj);
static PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *kwds);
-static SelectableFeatureHook SelectFeatureSet = nullptr;
static DestroyQAppHook DestroyQApplication = nullptr;
// PYSIDE-1470: Provide a hook to kill an Application from Shiboken.
@@ -103,8 +103,6 @@ void setDestroyQApplication(DestroyQAppHook func)
DestroyQApplication = func;
}
-static PyObject *Sbk_TypeGet___dict__(PyTypeObject *type, void *context); // forward
-
static int
check_set_special_type_attr(PyTypeObject *type, PyObject *value, const char *name)
{
@@ -144,9 +142,6 @@ static PyGetSetDef SbkObjectType_Type_getsetlist[] = {
{nullptr, nullptr, nullptr, nullptr, nullptr} // Sentinel
};
-static PyObject *(*type_getattro)(PyObject *type, PyObject *name); // forward
-static PyObject *mangled_type_getattro(PyTypeObject *type, PyObject *name); // forward
-
static PyType_Slot SbkObjectType_Type_slots[] = {
{Py_tp_dealloc, reinterpret_cast<void *>(SbkObjectTypeDealloc)},
{Py_tp_getattro, reinterpret_cast<void *>(mangled_type_getattro)},
@@ -167,16 +162,8 @@ static PyType_Spec SbkObjectType_Type_spec = {
PyTypeObject *SbkObjectType_TypeF(void)
{
- static PyTypeObject *type = nullptr;
- if (!type) {
- // PYSIDE-1019: Insert the default tp_getattro explicitly here
- // so we can overwrite it a bit.
- type_getattro = PyType_Type.tp_getattro;
- SbkObjectType_Type_spec.basicsize =
- PepHeapType_SIZE + sizeof(SbkObjectTypePrivate *);
- type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpec(&SbkObjectType_Type_spec));
- }
- return type;
+ static auto type = SbkType_FromSpec(&SbkObjectType_Type_spec);
+ return reinterpret_cast<PyTypeObject *>(type);
}
static PyObject *SbkObjectGetDict(PyObject *pObj, void *)
@@ -239,9 +226,6 @@ static int SbkObject_clear(PyObject *self)
return 0;
}
-static PyObject *SbkObject_GenericGetAttr(PyObject *obj, PyObject *name);
-static int SbkObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value);
-
static PyType_Slot SbkObject_Type_slots[] = {
{Py_tp_getattro, reinterpret_cast<void *>(SbkObject_GenericGetAttr)},
{Py_tp_setattro, reinterpret_cast<void *>(SbkObject_GenericSetAttr)},
@@ -479,119 +463,6 @@ PyObject *MakeQAppWrapper(PyTypeObject *type)
return qApp_curr;
}
-//////////////////////////////////////////////////////////////////////////////
-//
-// PYSIDE-1019: Support switchable extensions
-//
-// We simply exchange the complete class dicts.
-//
-// This is done in which replaces
-// --------------- --------------
-// mangled_type_getattro type_getattro
-// Sbk_TypeGet___dict__ type_dict
-// SbkObject_GenericGetAttr PyObject_GenericGetAttr
-// SbkObject_GenericSetAttr PyObject_GenericSetAttr
-//
-
-SelectableFeatureHook initSelectableFeature(SelectableFeatureHook func)
-{
- auto ret = SelectFeatureSet;
- SelectFeatureSet = func;
- return ret;
-}
-
-static PyObject *mangled_type_getattro(PyTypeObject *type, PyObject *name)
-{
- /*
- * Note: This `type_getattro` version is only the default that comes
- * from `PyType_Type.tp_getattro`. This does *not* interfere in any way
- * with the complex `tp_getattro` of `QObject` and other instances.
- * What we change here is the meta class of `QObject`.
- */
- if (SelectFeatureSet != nullptr)
- type->tp_dict = SelectFeatureSet(type);
- return type_getattro(reinterpret_cast<PyObject *>(type), name);
-}
-
-static PyObject *Sbk_TypeGet___dict__(PyTypeObject *type, void *context)
-{
- /*
- * This is the override for getting a dict.
- */
- auto dict = type->tp_dict;
- if (dict == nullptr)
- Py_RETURN_NONE;
- if (SelectFeatureSet != nullptr)
- dict = SelectFeatureSet(type);
- return PyDictProxy_New(dict);
-}
-
-// These functions replace the standard PyObject_Generic(Get|Set)Attr functions.
-// They provide the default that "object" inherits.
-// Everything else is directly handled by cppgenerator that calls `Feature::Select`.
-static PyObject *SbkObject_GenericGetAttr(PyObject *obj, PyObject *name)
-{
- auto type = Py_TYPE(obj);
- if (SelectFeatureSet != nullptr)
- type->tp_dict = SelectFeatureSet(type);
- return PyObject_GenericGetAttr(obj, name);
-}
-
-static int SbkObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
-{
- auto type = Py_TYPE(obj);
- if (SelectFeatureSet != nullptr)
- type->tp_dict = SelectFeatureSet(type);
- return PyObject_GenericSetAttr(obj, name, value);
-}
-
-// Caching the select Id.
-int SbkObjectType_GetReserved(PyTypeObject *type)
-{
- auto ptr = PepType_SOTP(reinterpret_cast<SbkObjectType *>(type));
- // PYSIDE-1019: During import PepType_SOTP is still zero.
- if (ptr == nullptr)
- return -1;
- return ptr->pyside_reserved_bits;
-}
-
-void SbkObjectType_SetReserved(PyTypeObject *type, int value)
-{
- auto ptr = PepType_SOTP(reinterpret_cast<SbkObjectType *>(type));
- // PYSIDE-1019: During import PepType_SOTP is still zero.
- if (ptr == nullptr)
- return;
- ptr->pyside_reserved_bits = value;
-}
-
-const char **SbkObjectType_GetPropertyStrings(PyTypeObject *type)
-{
- auto ptr = PepType_SOTP(reinterpret_cast<SbkObjectType *>(type));
- // PYSIDE-1019: During import PepType_SOTP is still zero.
- if (ptr == nullptr)
- return nullptr;
- return ptr->propertyStrings;
-}
-
-void SbkObjectType_SetPropertyStrings(PyTypeObject *type, const char **strings)
-{
- auto ptr = PepType_SOTP(reinterpret_cast<SbkObjectType *>(type));
- // PYSIDE-1019: During import PepType_SOTP is still zero.
- if (ptr == nullptr)
- return;
- ptr->propertyStrings = strings;
-}
-
-// PYSIDE-1626: Enforcing a context switch without further action.
-void SbkObjectType_UpdateFeature(PyTypeObject *type)
-{
- if (SelectFeatureSet != nullptr)
- type->tp_dict = SelectFeatureSet(type);
-}
-
-//
-//////////////////////////////////////////////////////////////////////////////
-
static PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
{
// Check if all bases are new style before calling type.tp_new
diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp
index 1c7bec5f5..1cb0c3822 100644
--- a/sources/shiboken6/libshiboken/bindingmanager.cpp
+++ b/sources/shiboken6/libshiboken/bindingmanager.cpp
@@ -44,6 +44,7 @@
#include "gilstate.h"
#include "sbkstring.h"
#include "sbkstaticstrings.h"
+#include "sbkfeature_base.h"
#include "debugfreehook.h"
#include <cstddef>
@@ -273,14 +274,6 @@ SbkObject *BindingManager::retrieveWrapper(const void *cptr)
return iter->second;
}
-static inline int currentSelectId(PyTypeObject *type)
-{
- int sel = SbkObjectType_GetReserved(type);
- // This could theoretically be -1 if used too early.
- assert(sel >= 0);
- return sel;
-}
-
PyObject *BindingManager::getOverride(const void *cptr,
PyObject *nameCache[],
const char *methodName)
diff --git a/sources/shiboken6/libshiboken/sbkfeature_base.cpp b/sources/shiboken6/libshiboken/sbkfeature_base.cpp
new file mode 100644
index 000000000..0cbaf46be
--- /dev/null
+++ b/sources/shiboken6/libshiboken/sbkfeature_base.cpp
@@ -0,0 +1,206 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "basewrapper.h"
+#include "basewrapper_p.h"
+#include "autodecref.h"
+#include "sbkstring.h"
+#include "sbkstaticstrings.h"
+#include "sbkstaticstrings_p.h"
+#include "signature.h"
+#include "sbkfeature_base.h"
+
+using namespace Shiboken;
+
+extern "C"
+{
+
+////////////////////////////////////////////////////////////////////////////
+//
+// getFeatureSelectId
+//
+// This function is needed here already for signature handling.
+// Maybe the same function from feature_select.cpp will be replaced.
+//
+
+static PyObject *cached_globals = nullptr;
+static PyObject *last_select_id = nullptr;
+
+PyObject *getFeatureSelectId()
+{
+ static PyObject *undef = PyLong_FromLong(-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;
+}
+
+int currentSelectId(PyTypeObject *type)
+{
+ int sel = SbkObjectType_GetReserved(type);
+ // This could theoretically be -1 if used too early.
+ assert(sel >= 0);
+ return sel;
+}
+
+void initFeatureShibokenPart()
+{
+ static PyObject *no_sel = PyLong_FromLong(0);
+ last_select_id = no_sel;
+ // Reset the cache. This is called at any "from __feature__ import".
+ cached_globals = nullptr;
+}
+
+static SelectableFeatureHook SelectFeatureSet = nullptr;
+
+SelectableFeatureHook initSelectableFeature(SelectableFeatureHook func)
+{
+ auto ret = SelectFeatureSet;
+ SelectFeatureSet = func;
+ return ret;
+}
+
+PyObject *mangled_type_getattro(PyTypeObject *type, PyObject *name)
+{
+ /*
+ * Note: This `type_getattro` version is only the default that comes
+ * from `PyType_Type.tp_getattro`. This does *not* interfere in any way
+ * with the complex `tp_getattro` of `QObject` and other instances.
+ * What we change here is the meta class of `QObject`.
+ */
+ static getattrofunc type_getattro = PyType_Type.tp_getattro;
+ if (SelectFeatureSet != nullptr)
+ type->tp_dict = SelectFeatureSet(type);
+ return type_getattro(reinterpret_cast<PyObject *>(type), name);
+}
+
+PyObject *Sbk_TypeGet___dict__(PyTypeObject *type, void *context)
+{
+ /*
+ * This is the override for getting a dict.
+ */
+ auto dict = type->tp_dict;
+ if (dict == nullptr)
+ Py_RETURN_NONE;
+ if (SelectFeatureSet != nullptr)
+ dict = SelectFeatureSet(type);
+ return PyDictProxy_New(dict);
+}
+
+// These functions replace the standard PyObject_Generic(Get|Set)Attr functions.
+// They provide the default that "object" inherits.
+// Everything else is directly handled by cppgenerator that calls `Feature::Select`.
+PyObject *SbkObject_GenericGetAttr(PyObject *obj, PyObject *name)
+{
+ auto type = Py_TYPE(obj);
+ if (SelectFeatureSet != nullptr)
+ type->tp_dict = SelectFeatureSet(type);
+ return PyObject_GenericGetAttr(obj, name);
+}
+
+int SbkObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
+{
+ auto type = Py_TYPE(obj);
+ if (SelectFeatureSet != nullptr)
+ type->tp_dict = SelectFeatureSet(type);
+ return PyObject_GenericSetAttr(obj, name, value);
+}
+
+// Caching the select Id.
+int SbkObjectType_GetReserved(PyTypeObject *type)
+{
+ auto ptr = PepType_SOTP(reinterpret_cast<SbkObjectType *>(type));
+ // PYSIDE-1019: During import PepType_SOTP is still zero.
+ if (ptr == nullptr)
+ return -1;
+ return ptr->pyside_reserved_bits;
+}
+
+void SbkObjectType_SetReserved(PyTypeObject *type, int value)
+{
+ auto ptr = PepType_SOTP(reinterpret_cast<SbkObjectType *>(type));
+ // PYSIDE-1019: During import PepType_SOTP is still zero.
+ if (ptr == nullptr)
+ return;
+ ptr->pyside_reserved_bits = value;
+}
+
+const char **SbkObjectType_GetPropertyStrings(PyTypeObject *type)
+{
+ auto ptr = PepType_SOTP(reinterpret_cast<SbkObjectType *>(type));
+ // PYSIDE-1019: During import PepType_SOTP is still zero.
+ if (ptr == nullptr)
+ return nullptr;
+ return ptr->propertyStrings;
+}
+
+void SbkObjectType_SetPropertyStrings(PyTypeObject *type, const char **strings)
+{
+ auto ptr = PepType_SOTP(reinterpret_cast<SbkObjectType *>(type));
+ // PYSIDE-1019: During import PepType_SOTP is still zero.
+ if (ptr == nullptr)
+ return;
+ ptr->propertyStrings = strings;
+}
+
+// PYSIDE-1626: Enforcing a context switch without further action.
+void SbkObjectType_UpdateFeature(PyTypeObject *type)
+{
+ if (SelectFeatureSet != nullptr)
+ type->tp_dict = SelectFeatureSet(type);
+}
+
+} // extern "C"
diff --git a/sources/shiboken6/libshiboken/sbkfeature_base.h b/sources/shiboken6/libshiboken/sbkfeature_base.h
new file mode 100644
index 000000000..064bd8ab4
--- /dev/null
+++ b/sources/shiboken6/libshiboken/sbkfeature_base.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SBKFEATURE_BASE_H
+#define SBKFEATURE_BASE_H
+
+extern "C"
+{
+
+LIBSHIBOKEN_API PyObject *getFeatureSelectId();
+LIBSHIBOKEN_API int currentSelectId(PyTypeObject *type);
+LIBSHIBOKEN_API void initFeatureShibokenPart();
+LIBSHIBOKEN_API PyObject *mangled_type_getattro(PyTypeObject *type, PyObject *name);
+LIBSHIBOKEN_API PyObject *Sbk_TypeGet___dict__(PyTypeObject *type, void *context);
+LIBSHIBOKEN_API PyObject *SbkObject_GenericGetAttr(PyObject *obj, PyObject *name);
+LIBSHIBOKEN_API int SbkObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value);
+
+} // extern "C"
+
+#endif // SBKFEATURE_BASE_H
diff --git a/sources/shiboken6/libshiboken/signature/signature.cpp b/sources/shiboken6/libshiboken/signature/signature.cpp
index 624d55a3e..c844e2694 100644
--- a/sources/shiboken6/libshiboken/signature/signature.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature.cpp
@@ -54,7 +54,7 @@
#include "sbkstring.h"
#include "sbkstaticstrings.h"
#include "sbkstaticstrings_p.h"
-
+#include "sbkfeature_base.h"
#include "signature_p.h"
#include <structmember.h>
@@ -106,19 +106,22 @@ PyObject *GetTypeKey(PyObject *ob)
*
* PYSIDE-1286: We use correct __module__ and __qualname__, now.
*/
+ // XXX we obtain also the current selection.
+ // from the current module name.
AutoDecRef module_name(PyObject_GetAttr(ob, PyMagicName::module()));
if (module_name.isNull()) {
// We have no module_name because this is a module ;-)
PyErr_Clear();
module_name.reset(PyObject_GetAttr(ob, PyMagicName::name()));
- return Py_BuildValue("O", module_name.object());
+ return Py_BuildValue("O"/*i"*/, module_name.object()/*, getFeatureSelectId()*/);
}
- AutoDecRef class_name(_get_qualname(ob));
+ AutoDecRef class_name(PyObject_GetAttr(ob, PyMagicName::qualname()));
if (class_name.isNull()) {
Py_FatalError("Signature: missing class name in GetTypeKey");
return nullptr;
}
- return Py_BuildValue("(OO)", module_name.object(), class_name.object());
+ return Py_BuildValue("(O"/*i*/"O)", module_name.object(), /*getFeatureSelectId(),*/
+ class_name.object());
}
static PyObject *empty_dict = nullptr;
diff --git a/sources/shiboken6/libshiboken/signature/signature_helper.cpp b/sources/shiboken6/libshiboken/signature/signature_helper.cpp
index f38740254..d27ddeabb 100644
--- a/sources/shiboken6/libshiboken/signature/signature_helper.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature_helper.cpp
@@ -57,19 +57,6 @@ using namespace Shiboken;
extern "C" {
-// Helper for __qualname__ which might not always exist in Python 2 (type).
-PyObject *_get_qualname(PyObject *ob)
-{
- // We support __qualname__ for types, only.
- assert(PyType_Check(ob));
- PyObject *name = PyObject_GetAttr(ob, PyMagicName::qualname());
- if (name == nullptr) {
- PyErr_Clear();
- name = PyObject_GetAttr(ob, PyMagicName::name());
- }
- return name;
-}
-
static int _fixup_getset(PyTypeObject *type, const char *name, PyGetSetDef *new_gsp)
{
/*
diff --git a/sources/shiboken6/libshiboken/signature/signature_p.h b/sources/shiboken6/libshiboken/signature/signature_p.h
index cdfc1cbc1..7e622f3f1 100644
--- a/sources/shiboken6/libshiboken/signature/signature_p.h
+++ b/sources/shiboken6/libshiboken/signature/signature_p.h
@@ -93,7 +93,6 @@ PyObject *pyside_tp_get___doc__(PyObject *tp);
// signature_helper.cpp
-PyObject *_get_qualname(PyObject *ob);
int add_more_getsets(PyTypeObject *type, PyGetSetDef *gsp, PyObject **doc_descr);
PyObject *name_key_to_func(PyObject *ob);
int insert_snake_case_variants(PyObject *dict);