summaryrefslogtreecommitdiffstats
path: root/libshiboken/basewrapper_p.h
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-11-09 16:47:12 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-11-10 15:36:28 -0200
commit6280785f538dc033e85826bf2525848c75327ea8 (patch)
treea24b0d0a9f7357a1357b23e24a4de1230c3e9234 /libshiboken/basewrapper_p.h
parentc948d05782056d9b12ab0ccf04fa4e1b30478296 (diff)
downloadshiboken-6280785f538dc033e85826bf2525848c75327ea8.tar.gz
shiboken-6280785f538dc033e85826bf2525848c75327ea8.tar.xz
shiboken-6280785f538dc033e85826bf2525848c75327ea8.zip
Moved Shiboken::SbkBaseWrapper outside Shiboken namespace and added a d-pointer to it.
Diffstat (limited to 'libshiboken/basewrapper_p.h')
-rw-r--r--libshiboken/basewrapper_p.h77
1 files changed, 57 insertions, 20 deletions
diff --git a/libshiboken/basewrapper_p.h b/libshiboken/basewrapper_p.h
index 20476d3a..a07f5482 100644
--- a/libshiboken/basewrapper_p.h
+++ b/libshiboken/basewrapper_p.h
@@ -25,11 +25,66 @@
#include <Python.h>
#include <list>
+#include <map>
+
+struct SbkBaseWrapper;
+
+namespace Shiboken
+{
+/**
+ * This mapping associates a method and argument of an wrapper object with the wrapper of
+ * said argument when it needs the binding to help manage its reference counting.
+ */
+typedef std::map<std::string, std::list<PyObject*> > RefCountMap;
+
+
+/// Linked list of SbkBaseWrapper pointers
+typedef std::list<SbkBaseWrapper*> ChildrenList;
+
+/// Struct used to store information about object parent and children.
+struct ParentInfo
+{
+ /// Default ctor.
+ ParentInfo() : parent(0), hasWrapperRef(false) {}
+ /// Pointer to parent object.
+ SbkBaseWrapper* parent;
+ /// List of object children.
+ ChildrenList children;
+ /// has internal ref
+ bool hasWrapperRef;
+};
+
+} // namespace Shiboken
+
+extern "C"
+{
+
+/**
+ * \internal
+ * Private data for SbkBaseWrapper
+ */
+struct SbkBaseWrapperPrivate
+{
+ /// Pointer to the C++ class.
+ void** cptr;
+ /// True when Python is responsible for freeing the used memory.
+ unsigned int hasOwnership : 1;
+ /// Is true when the C++ class of the wrapped object has a virtual destructor AND was created by Python.
+ unsigned int containsCppWrapper : 1;
+ /// Marked as false when the object is lost to C++ and the binding can not know if it was deleted or not.
+ unsigned int validCppObject : 1;
+ /// Information about the object parents and children, can be null.
+ Shiboken::ParentInfo* parentInfo;
+ /// Manage reference counting of objects that are referred but not owned.
+ Shiboken::RefCountMap* referredObjects;
+};
+
+} // extern "C"
namespace Shiboken
{
/**
- * Utility function uset to transform PyObject which suppot sequence protocol in a std::list
+ * Utility function uset to transform PyObject which suppot sequence protocol in a std::list
**/
std::list<PyObject*> splitPyObject(PyObject* pyObj);
@@ -126,30 +181,12 @@ inline std::list<SbkBaseWrapperType*> getCppBaseClasses(PyTypeObject* baseType)
return visitor.bases();
}
-struct SbkBaseWrapper;
-
-/// Linked list of SbkBaseWrapper pointers
-typedef std::list<SbkBaseWrapper*> ChildrenList;
-
-/// Struct used to store information about object parent and children.
-struct ParentInfo
-{
- /// Default ctor.
- ParentInfo() : parent(0), hasWrapperRef(false) {}
- /// Pointer to parent object.
- SbkBaseWrapper* parent;
- /// List of object children.
- ChildrenList children;
- /// has internal ref
- bool hasWrapperRef;
-};
-
/**
* Decrements the reference counters of every object referred by self.
* \param self the wrapper instance that keeps references to other objects.
*/
void clearReferences(SbkBaseWrapper* self);
-}
+} // namespace Shiboken
#endif