diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-11-29 01:26:56 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-11-30 13:50:08 -0300 |
commit | 78bf7bca1fe92052ae7b64827ae81bbe25bd8c3d (patch) | |
tree | 19bd083348c0ad3aaa9c479a2fcb239004be26b0 /libshiboken/bindingmanager.h | |
parent | 697f24dfa96b15a46e9e5afa79e102e9a5100d73 (diff) |
Added method to take care of the details of ownership transfer to C++.
Simple ownership transference, i.e. without parenting, is now performed
by the new BindingManager::transferOwnershipToCpp method. It remove the
parent of the transfered object and proceeds transfer or invalidation
if needed. The generated code for simple ownership transfer from Python
to C++ now reflects this change.
Fixed the method BlackBox::keepObjectType that steals an ObjectType
ownership to C++ to remove it from its parent also. The BlackBox
class does not take care of the stolen object as a proper parent
would, but its destructor deletes the object, so the "unparenting"
is needed to avoid freeing the same memory twice.
Created an unit test that adds children to a parent ObjectType and then
steal the children to C++ with BlackBox.keepObjectType.
Reviewed by Hugo Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'libshiboken/bindingmanager.h')
-rw-r--r-- | libshiboken/bindingmanager.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libshiboken/bindingmanager.h b/libshiboken/bindingmanager.h index fe5767d32..602066f91 100644 --- a/libshiboken/bindingmanager.h +++ b/libshiboken/bindingmanager.h @@ -64,6 +64,14 @@ public: /// Convenience method to invalidate the Python wrapper for a C++ wrapped object. Do nothing if C++ pointer has no Python wrapper. void invalidateWrapper(const void* cptr); + /// Transfers the ownership of a Python wrapper to C++. + void transferOwnershipToCpp(PyBaseWrapper* wrapper); + /// Convenience method to call transferOwnershipToCpp with a properly cast PyBaseWrapper. + inline void transferOwnershipToCpp(PyObject* wrapper) + { + transferOwnershipToCpp(reinterpret_cast<PyBaseWrapper*>(wrapper)); + } + private: ~BindingManager(); // disable copy |