aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-03-31 16:25:20 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2010-04-05 18:39:45 -0300
commit9a5e72d08f908183d7bf8abcb3546cf509f9362d (patch)
treec9dea886165be863fc11d9a5ccf4c7254139b263 /libshiboken
parentc6d32c0339749257ac1b97a48f3c8fdd6f10e50c (diff)
Added flag is_user_type to identify types created by the user which inherits binded types
from binded types.
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/basewrapper.cpp1
-rw-r--r--libshiboken/basewrapper.h16
2 files changed, 14 insertions, 3 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index a49ec0df4..36e14b10f 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -362,6 +362,7 @@ SbkBaseWrapperType_TpNew(PyTypeObject* metatype, PyObject* args, PyObject* kwds)
newType->cpp_dtor = 0;
newType->is_multicpp = 1;
}
+ newType->is_user_type = 1;
return reinterpret_cast<PyObject*>(newType);
}
diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h
index 7297f4c34..168d3f43f 100644
--- a/libshiboken/basewrapper.h
+++ b/libshiboken/basewrapper.h
@@ -97,6 +97,8 @@ struct LIBSHIBOKEN_API SbkBaseWrapperType
void (*cpp_dtor)(void*);
/// True if this type holds two or more C++ instances, e.g.: a Python class which inherits from two C++ classes.
int is_multicpp:1;
+ /// True if this type was definied by the user.
+ int is_user_type:1;
};
struct ParentInfo;
@@ -151,11 +153,19 @@ LIBSHIBOKEN_API void removeParent(SbkBaseWrapper* child);
LIBSHIBOKEN_API void destroyParentInfo(SbkBaseWrapper* obj, bool removeFromParent = true);
/**
-* Returns true if the type of \p pyObj was created by the Shiboken generator.
+* Returns true if the object is an instance of a type created by the Shiboken generator.
*/
-inline bool isShibokenType(const PyObject* pyObj)
+inline bool isShibokenType(PyObject*& pyObj)
{
- return pyObj->ob_type->ob_type == &Shiboken::SbkBaseWrapperType_Type;
+ return pyObj->ob_type->ob_type == &SbkBaseWrapperType_Type;
+}
+
+/**
+* Returns true if this object is an instance of an user defined type derived from an Shiboken type.
+*/
+inline bool isUserType(PyObject*& pyObj)
+{
+ return isShibokenType(pyObj) && reinterpret_cast<SbkBaseWrapperType*>(pyObj->ob_type)->is_user_type;
}
/**