diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-11-24 14:20:44 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:12:07 -0300 |
commit | fe97dab5ba84e7b2abe7736cf0dbb3b6227d649a (patch) | |
tree | 595ed2640585859cafc1a53136a850d5abf0a394 /libshiboken | |
parent | 5f28a31c58e44303c5fc7f5ba54ca0620c698b6a (diff) |
Added BindingManager::visitAllPyObjects function, used to visit all PyObjects with a function.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libshiboken')
-rw-r--r-- | libshiboken/bindingmanager.cpp | 9 | ||||
-rw-r--r-- | libshiboken/bindingmanager.h | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/libshiboken/bindingmanager.cpp b/libshiboken/bindingmanager.cpp index a43852614..2bcf2debe 100644 --- a/libshiboken/bindingmanager.cpp +++ b/libshiboken/bindingmanager.cpp @@ -277,5 +277,14 @@ std::set<SbkObject*> BindingManager::getAllPyObjects() return pyObjects; } +void BindingManager::visitAllPyObjects(ObjectVisitor visitor, void* data) +{ + WrapperMap copy = m_d->wrapperMapper; + for (WrapperMap::iterator it = copy.begin(); it != copy.end(); ++it) { + if (hasWrapper(it->first)) + visitor(it->second, data); + } +} + } // namespace Shiboken diff --git a/libshiboken/bindingmanager.h b/libshiboken/bindingmanager.h index b6d4ac42b..e12558b4f 100644 --- a/libshiboken/bindingmanager.h +++ b/libshiboken/bindingmanager.h @@ -33,6 +33,8 @@ struct SbkObjectType; namespace Shiboken { +typedef void (*ObjectVisitor)(SbkObject*, void*); + class LIBSHIBOKEN_API BindingManager { public: @@ -50,6 +52,16 @@ public: SbkObjectType* resolveType(void* cptr, SbkObjectType* type); std::set<SbkObject*> getAllPyObjects(); + + /** + * Calls the function \p visitor for each object registered on binding manager. + * \note As various C++ pointers can point to the same PyObject due to multiple inheritance + * a PyObject can be called more than one time for each PyObject. + * \param visitor function called for each object. + * \param data user data passed as second argument to the visitor function. + */ + void visitAllPyObjects(ObjectVisitor visitor, void* data); + private: ~BindingManager(); // disable copy |