diff options
Diffstat (limited to 'libshiboken/basewrapper.cpp')
-rw-r--r-- | libshiboken/basewrapper.cpp | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp index 5de9024e..3337a4d2 100644 --- a/libshiboken/basewrapper.cpp +++ b/libshiboken/basewrapper.cpp @@ -247,6 +247,26 @@ PyObject* SbkBaseWrapperType_TpNew(PyTypeObject* metatype, PyObject* args, PyObj return reinterpret_cast<PyObject*>(newType); } +PyObject* SbkObjectTpNew(PyTypeObject* subtype, PyObject*, PyObject*) +{ + SbkObject* self = reinterpret_cast<SbkObject*>(subtype->tp_alloc(subtype, 0)); + self->d = new SbkBaseWrapperPrivate; + + SbkBaseWrapperType* sbkType = reinterpret_cast<SbkBaseWrapperType*>(subtype); + int numBases = sbkType->is_multicpp ? Shiboken::getNumberOfCppBaseClasses(subtype) : 1; + self->d->cptr = new void*[numBases]; + std::memset(self->d->cptr, 0, sizeof(void*)*numBases); + self->d->hasOwnership = 1; + self->d->containsCppWrapper = 0; + self->d->validCppObject = 0; + self->d->parentInfo = 0; + self->ob_dict = 0; + self->weakreflist = 0; + self->d->referredObjects = 0; + return reinterpret_cast<PyObject*>(self); +} + + } //extern "C" namespace Shiboken @@ -381,25 +401,6 @@ void walkThroughClassHierarchy(PyTypeObject* currentType, HierarchyVisitor* visi } } -PyObject* SbkBaseWrapper_TpNew(PyTypeObject* subtype, PyObject*, PyObject*) -{ - SbkObject* self = reinterpret_cast<SbkObject*>(subtype->tp_alloc(subtype, 0)); - self->d = new SbkBaseWrapperPrivate; - - SbkBaseWrapperType* sbkType = reinterpret_cast<SbkBaseWrapperType*>(subtype); - int numBases = sbkType->is_multicpp ? getNumberOfCppBaseClasses(subtype) : 1; - self->d->cptr = new void*[numBases]; - std::memset(self->d->cptr, 0, sizeof(void*)*numBases); - self->d->hasOwnership = 1; - self->d->containsCppWrapper = 0; - self->d->validCppObject = 0; - self->d->parentInfo = 0; - self->ob_dict = 0; - self->weakreflist = 0; - self->d->referredObjects = 0; - return reinterpret_cast<PyObject*>(self); -} - void setTypeUserData(SbkObject* wrapper, void *user_data, DeleteUserDataFunc d_func) { SbkBaseWrapperType* ob_type = reinterpret_cast<SbkBaseWrapperType*>(wrapper->ob_type); @@ -714,7 +715,7 @@ PyObject* newObject(SbkBaseWrapperType* instanceType, instanceType = BindingManager::instance().resolveType(cptr, instanceType); } - SbkObject* self = reinterpret_cast<SbkObject*>(SbkBaseWrapper_TpNew(reinterpret_cast<PyTypeObject*>(instanceType), 0, 0)); + SbkObject* self = reinterpret_cast<SbkObject*>(SbkObjectTpNew(reinterpret_cast<PyTypeObject*>(instanceType), 0, 0)); self->d->cptr[0] = cptr; self->d->hasOwnership = hasOwnership; self->d->validCppObject = 1; |