diff options
author | Renato Filho <renato.filho@openbossa.org> | 2011-05-31 15:43:57 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:15:24 -0300 |
commit | a2dac99260317da72265cc2a69b97a4353eda791 (patch) | |
tree | 3ea1f0a914b41657e4edb6ae2cc0d52282603f65 /libshiboken | |
parent | ab5690f7a11f280409dc7f8ce17cb528e2829834 (diff) |
Created the function 'removeReference', used to remove a specific
reference from other object.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libshiboken')
-rw-r--r-- | libshiboken/basewrapper.cpp | 16 | ||||
-rw-r--r-- | libshiboken/basewrapper.h | 8 |
2 files changed, 24 insertions, 0 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp index e53e495d4..8dc931727 100644 --- a/libshiboken/basewrapper.cpp +++ b/libshiboken/basewrapper.cpp @@ -1096,6 +1096,22 @@ void keepReference(SbkObject* self, const char* key, PyObject* referredObject, b } } +void removeReference(SbkObject* self, const char* key, PyObject* referredObject) +{ + if (!referredObject || (referredObject == Py_None)) + return; + + if (!self->d->referredObjects) + return; + + RefCountMap& refCountMap = *(self->d->referredObjects); + RefCountMap::iterator iter = refCountMap.find(key); + if (iter != refCountMap.end()) { + decRefPyObjectList(iter->second); + refCountMap.erase(iter); + } +} + void clearReferences(SbkObject* self) { if (!self->d->referredObjects) diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h index bca252c72..b7c3e3865 100644 --- a/libshiboken/basewrapper.h +++ b/libshiboken/basewrapper.h @@ -336,6 +336,14 @@ LIBSHIBOKEN_API void* getTypeUserData(SbkObject* wrapper); */ LIBSHIBOKEN_API void keepReference(SbkObject* self, const char* key, PyObject* referredObject, bool append = false); +/** + * Removes any reference previously added by keepReference function + * \param self the wrapper instance that keeps references to other objects. + * \param key a key that identifies the C++ method signature and argument from where the referred Object came + * \param referredObject the object whose reference is used by the self object. + */ +LIBSHIBOKEN_API void removeReference(SbkObject* self, const char* key, PyObject* referredObject); + } // namespace Object } // namespace Shiboken |