aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2018-08-22 14:41:41 +0200
committerChristian Tismer <tismer@stackless.com>2018-08-23 07:51:54 +0000
commitb45a890df5bb26c3a4feb8d57dd994fdaaf9c750 (patch)
treecd425ec17ee5bb3211b4e97c37bf2ac8b91cb075 /sources
parent50dca3ef00ffe074959cccb4b2b451cbf0afd384 (diff)
Limited API: remove the "slot_" workaround
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>
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside2/libpyside/pysideqflags.cpp9
-rw-r--r--sources/shiboken2/libshiboken/sbkenum.cpp11
-rw-r--r--sources/shiboken2/libshiboken/typespec.cpp44
-rw-r--r--sources/shiboken2/libshiboken/typespec.h2
4 files changed, 28 insertions, 38 deletions
diff --git a/sources/pyside2/libpyside/pysideqflags.cpp b/sources/pyside2/libpyside/pysideqflags.cpp
index 7a8fa2a05..c33758c5e 100644
--- a/sources/pyside2/libpyside/pysideqflags.cpp
+++ b/sources/pyside2/libpyside/pysideqflags.cpp
@@ -174,13 +174,8 @@ namespace QFlags
newspec->itemsize = SbkNewQFlagsType_spec.itemsize;
newspec->flags = SbkNewQFlagsType_spec.flags;
int idx = -1;
-#ifdef IS_PY3K
-# define SLOT slot
-#else
-# define SLOT slot_
-#endif
- while (numberMethods[++idx].SLOT) {
- assert(SbkNewQFlagsType_slots[idx].SLOT == numberMethods[idx].SLOT);
+ while (numberMethods[++idx].slot) {
+ assert(SbkNewQFlagsType_slots[idx].slot == numberMethods[idx].slot);
SbkNewQFlagsType_slots[idx].pfunc = numberMethods[idx].pfunc;
}
newspec->slots = SbkNewQFlagsType_spec.slots;
diff --git a/sources/shiboken2/libshiboken/sbkenum.cpp b/sources/shiboken2/libshiboken/sbkenum.cpp
index b034d1c0f..fb55267d1 100644
--- a/sources/shiboken2/libshiboken/sbkenum.cpp
+++ b/sources/shiboken2/libshiboken/sbkenum.cpp
@@ -524,13 +524,8 @@ copyNumberMethods(PyTypeObject *flagsType,
int *pidx)
{
int idx = *pidx;
-#ifdef IS_PY3K
-# define SLOT slot
-#else
-# define SLOT slot_
-#endif
#define PUT_SLOT(name) \
- number_slots[idx].SLOT = (name); \
+ number_slots[idx].slot = (name); \
number_slots[idx].pfunc = PyType_GetSlot(flagsType, (name)); \
++idx;
@@ -593,8 +588,8 @@ newTypeWithName(const char* name,
newspec->flags = SbkNewType_spec.flags;
// we must append all the number methods, so rebuild everything:
int idx = 0;
- while (SbkNewType_slots[idx].SLOT) {
- newslots[idx].SLOT = SbkNewType_slots[idx].SLOT;
+ while (SbkNewType_slots[idx].slot) {
+ newslots[idx].slot = SbkNewType_slots[idx].slot;
newslots[idx].pfunc = SbkNewType_slots[idx].pfunc;
++idx;
}
diff --git a/sources/shiboken2/libshiboken/typespec.cpp b/sources/shiboken2/libshiboken/typespec.cpp
index d532c97ed..9123a09e0 100644
--- a/sources/shiboken2/libshiboken/typespec.cpp
+++ b/sources/shiboken2/libshiboken/typespec.cpp
@@ -514,7 +514,7 @@ best_base(PyObject *bases)
}
static const short slotoffsets[] = {
- -1, /* invalid slot_ */
+ -1, /* invalid slot */
/* Generated by typeslots.py */
0,
0,
@@ -603,7 +603,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
PyObject *modname;
char *s;
char *res_start = (char*)res;
- PyType_Slot *slot_;
+ PyType_Slot *slot;
/* Set the type name and qualname */
s = (char *)strrchr(spec->name, '.'); // C++11
@@ -632,11 +632,11 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
if (!bases) {
base = &PyBaseObject_Type;
/* See whether Py_tp_base(s) was specified */
- for (slot_ = spec->slots; slot_->slot_; slot_++) {
- if (slot_->slot_ == Py_tp_base)
- base = (PyTypeObject *)slot_->pfunc; // C++11
- else if (slot_->slot_ == Py_tp_bases) {
- bases = (PyObject *)slot_->pfunc; // C++11
+ for (slot = spec->slots; slot->slot; slot++) {
+ if (slot->slot == Py_tp_base)
+ base = (PyTypeObject *)slot->pfunc; // C++11
+ else if (slot->slot == Py_tp_bases) {
+ bases = (PyObject *)slot->pfunc; // C++11
Py_INCREF(bases);
}
}
@@ -676,23 +676,23 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
type->tp_basicsize = spec->basicsize;
type->tp_itemsize = spec->itemsize;
- for (slot_ = spec->slots; slot_->slot_; slot_++) {
- if (slot_->slot_ < 0
- || (size_t)slot_->slot_ >= Py_ARRAY_LENGTH(slotoffsets)) {
- PyErr_SetString(PyExc_RuntimeError, "invalid slot_ offset");
+ for (slot = spec->slots; slot->slot; slot++) {
+ if (slot->slot < 0
+ || (size_t)slot->slot >= Py_ARRAY_LENGTH(slotoffsets)) {
+ PyErr_SetString(PyExc_RuntimeError, "invalid slot offset");
goto fail;
}
- if (slot_->slot_ == Py_tp_base || slot_->slot_ == Py_tp_bases)
+ if (slot->slot == Py_tp_base || slot->slot == Py_tp_bases)
/* Processed above */
continue;
- *(void**)(res_start + slotoffsets[slot_->slot_]) = slot_->pfunc;
+ *(void**)(res_start + slotoffsets[slot->slot]) = slot->pfunc;
- /* need to make a copy of the docstring slot_, which usually
+ /* need to make a copy of the docstring slot, which usually
points to a static string literal */
- if (slot_->slot_ == Py_tp_doc) {
+ if (slot->slot == Py_tp_doc) {
// No signature in Python 2
- // const char *old_doc = _PyType_DocWithoutSignature(type->tp_name, slot_->pfunc);
- const char *old_doc = (const char *)slot_->pfunc;
+ // const char *old_doc = _PyType_DocWithoutSignature(type->tp_name, slot->pfunc);
+ const char *old_doc = (const char *)slot->pfunc;
size_t len = strlen(old_doc)+1;
char *tp_doc = (char *)PyObject_MALLOC(len); // C++11
if (tp_doc == NULL) {
@@ -759,17 +759,17 @@ PyType_FromSpec(PyType_Spec *spec)
}
void *
-PyType_GetSlot(PyTypeObject *type, int slot_)
+PyType_GetSlot(PyTypeObject *type, int slot)
{
- if (!PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE) || slot_ < 0) {
+ if (!PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE) || slot < 0) {
PyErr_BadInternalCall();
return NULL;
}
- if ((size_t)slot_ >= Py_ARRAY_LENGTH(slotoffsets)) {
- /* Extension module requesting slot_ from a future version */
+ if ((size_t)slot >= Py_ARRAY_LENGTH(slotoffsets)) {
+ /* Extension module requesting slot from a future version */
return NULL;
}
- return *(void**)(((char*)type) + slotoffsets[slot_]);
+ return *(void**)(((char*)type) + slotoffsets[slot]);
}
} // extern "C"
diff --git a/sources/shiboken2/libshiboken/typespec.h b/sources/shiboken2/libshiboken/typespec.h
index 799fcb1b8..46e7dec89 100644
--- a/sources/shiboken2/libshiboken/typespec.h
+++ b/sources/shiboken2/libshiboken/typespec.h
@@ -48,7 +48,7 @@ extern "C"
{
typedef struct{
- int slot_; // slot is somehow reserved in Qt /* slot id, see below */
+ int slot; // slot is somehow reserved in Qt /* slot id, see below */
void *pfunc; /* function pointer */
} PyType_Slot;