diff options
Diffstat (limited to 'sources/shiboken2/libshiboken/typespec.cpp')
-rw-r--r-- | sources/shiboken2/libshiboken/typespec.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/sources/shiboken2/libshiboken/typespec.cpp b/sources/shiboken2/libshiboken/typespec.cpp index d532c97ed..a67daf12d 100644 --- a/sources/shiboken2/libshiboken/typespec.cpp +++ b/sources/shiboken2/libshiboken/typespec.cpp @@ -37,6 +37,7 @@ ** ****************************************************************************/ +#include "sbkpython.h" #include "typespec.h" #include <structmember.h> @@ -514,7 +515,7 @@ best_base(PyObject *bases) } static const short slotoffsets[] = { - -1, /* invalid slot_ */ + -1, /* invalid slot */ /* Generated by typeslots.py */ 0, 0, @@ -603,7 +604,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 +633,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 +677,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 +760,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" |