aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken/bindingmanager.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-09-15 15:26:40 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:14 -0300
commit6bf564204fe977dccf94ed58ddea7fd5eaf4a1fa (patch)
tree8b58405cdf2eb1c2dcd295540037c0896628da39 /libshiboken/bindingmanager.cpp
parent24206196a34b4faeb4b720efcc84747f35accf94 (diff)
Using Py_TYPE macro instead of direct access to ob_type to work with Python 2.x and 3.x.
Enclosing PyCObject uses inside #ifdefs
Diffstat (limited to 'libshiboken/bindingmanager.cpp')
-rw-r--r--libshiboken/bindingmanager.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/libshiboken/bindingmanager.cpp b/libshiboken/bindingmanager.cpp
index 09d6fc962..77a384b5f 100644
--- a/libshiboken/bindingmanager.cpp
+++ b/libshiboken/bindingmanager.cpp
@@ -108,8 +108,8 @@ static void showWrapperMap(const WrapperMap& wrapperMap)
for (iter = wrapperMap.begin(); iter != wrapperMap.end(); ++iter) {
fprintf(stderr, "key: %p, value: %p (%s, refcnt: %d)\n", iter->first,
iter->second,
- iter->second->ob_type->tp_name,
- (int) iter->second->ob_refcnt);
+ Py_TYPE(iter->second)->tp_name,
+ (int) ((PyObject*)iter->second)->ob_refcnt);
}
fprintf(stderr, "-------------------------------\n");
}
@@ -176,7 +176,7 @@ bool BindingManager::hasWrapper(const void* cptr)
void BindingManager::registerWrapper(SbkObject* pyObj, void* cptr)
{
- SbkObjectType* instanceType = reinterpret_cast<SbkObjectType*>(pyObj->ob_type);
+ SbkObjectType* instanceType = reinterpret_cast<SbkObjectType*>(Py_TYPE(pyObj));
SbkObjectTypePrivate* d = instanceType->d;
if (!d)
@@ -197,9 +197,9 @@ void BindingManager::registerWrapper(SbkObject* pyObj, void* cptr)
void BindingManager::releaseWrapper(SbkObject* sbkObj)
{
- SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(sbkObj->ob_type);
+ SbkObjectType* sbkType = reinterpret_cast<SbkObjectType*>(Py_TYPE(sbkObj));
SbkObjectTypePrivate* d = sbkType->d;
- int numBases = ((d && d->is_multicpp) ? getNumberOfCppBaseClasses(sbkObj->ob_type) : 1);
+ int numBases = ((d && d->is_multicpp) ? getNumberOfCppBaseClasses(Py_TYPE(sbkObj)) : 1);
void** cptrs = reinterpret_cast<SbkObject*>(sbkObj)->d->cptr;
for (int i = 0; i < numBases; ++i) {
@@ -247,7 +247,7 @@ PyObject* BindingManager::getOverride(const void* cptr, const char* methodName)
if (method && PyMethod_Check(method)
&& reinterpret_cast<PyMethodObject*>(method)->im_self == reinterpret_cast<PyObject*>(wrapper)) {
PyObject* defaultMethod;
- PyObject* mro = wrapper->ob_type->tp_mro;
+ PyObject* mro = Py_TYPE(wrapper)->tp_mro;
// The first class in the mro (index 0) is the class being checked and it should not be tested.
// The last class in the mro (size - 1) is the base Python object class which should not be tested also.