aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken/bindingmanager.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-11-15 01:20:07 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-11-18 09:22:50 -0300
commit1081714f5275261420a74ac333a117fd2bbca0c4 (patch)
tree6c0b17ba834516b10d0fe713ba9b80682ee4ee0d /libshiboken/bindingmanager.cpp
parent80282277d0845a65739c33675aa9a91b10faa4b1 (diff)
Shiboken retrieves a Python wrapper object from its corresponding
C++ object using the memory address of the former to retrieve the latter. When multiple inheritance is involved, a C++ object passed to C++ could be caught back downcasted to one of its parents with a different memory address, following the memory layout for multiple inheritance used by the compiler. This poses a problem to keep the Python identity of a C++ object. The solution was to extend the traditional PyTypeObject with a number array with all the possible displacements to be added to an object pointer to produce the memory addresses for the valid pointers that could appear from all the possible type casts involving the object parents. All the possible pointers are registered (and unregistered) by the binding wrapper manager. To store the multiple inheritance information the ShiboTypeObject structure was created, expanding the original PyTypeObject with two fields: mi_offsets an integer array containing the possible displacements from the object base pointer. The array has the value -1 at its end. mi_init the function that will initialize the mi_offsets array it is called at the first instaciation of a multiple inheriting object.
Diffstat (limited to 'libshiboken/bindingmanager.cpp')
-rw-r--r--libshiboken/bindingmanager.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libshiboken/bindingmanager.cpp b/libshiboken/bindingmanager.cpp
index 4ae49f868..ff1ac37e4 100644
--- a/libshiboken/bindingmanager.cpp
+++ b/libshiboken/bindingmanager.cpp
@@ -98,7 +98,7 @@ PyObject* BindingManager::getOverride(const void* cptr, const char* methodName)
PyObject* wrapper = retrieveWrapper(cptr);
if (wrapper) {
- PyTypeObject* baseWrapperType = ((Shiboken::PyBaseWrapper*)wrapper)->baseWrapperType;
+ PyTypeObject* baseWrapperType = (PyTypeObject*) ((Shiboken::PyBaseWrapper*)wrapper)->baseWrapperType;
PyObject* method = PyObject_GetAttrString(wrapper, const_cast<char*>(methodName));
if (method) {
PyObject* defaultMethod = 0;