diff options
author | Christian Tismer <tismer@stackless.com> | 2018-08-22 14:41:41 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2018-08-23 07:51:54 +0000 |
commit | b45a890df5bb26c3a4feb8d57dd994fdaaf9c750 (patch) | |
tree | cd425ec17ee5bb3211b4e97c37bf2ac8b91cb075 /sources/shiboken2/libshiboken/typespec.cpp | |
parent | 50dca3ef00ffe074959cccb4b2b451cbf0afd384 (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/shiboken2/libshiboken/typespec.cpp')
-rw-r--r-- | sources/shiboken2/libshiboken/typespec.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
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" |