summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-11-24 14:20:44 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-11-24 14:34:09 -0200
commitac10a67837433328f6a9ca51475a2eb7e29e4e03 (patch)
tree52ea68f9319ee6a1da4e219faf0589406d20c21c
parent2651ec7b04923db3c64ff59fcc5cb9c966d685f6 (diff)
downloadshiboken-ac10a67837433328f6a9ca51475a2eb7e29e4e03.tar.gz
shiboken-ac10a67837433328f6a9ca51475a2eb7e29e4e03.tar.xz
shiboken-ac10a67837433328f6a9ca51475a2eb7e29e4e03.zip
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>
-rw-r--r--libshiboken/bindingmanager.cpp9
-rw-r--r--libshiboken/bindingmanager.h12
2 files changed, 21 insertions, 0 deletions
diff --git a/libshiboken/bindingmanager.cpp b/libshiboken/bindingmanager.cpp
index a4385261..2bcf2deb 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 b6d4ac42..e12558b4 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