summaryrefslogtreecommitdiffstats
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
parentc6d32c0339749257ac1b97a48f3c8fdd6f10e50c (diff)
downloadshiboken-9a5e72d08f908183d7bf8abcb3546cf509f9362d.tar.gz
shiboken-9a5e72d08f908183d7bf8abcb3546cf509f9362d.tar.xz
shiboken-9a5e72d08f908183d7bf8abcb3546cf509f9362d.zip
Added flag is_user_type to identify types created by the user which inherits binded types
from binded types.
-rw-r--r--cppgenerator.cpp3
-rw-r--r--libshiboken/basewrapper.cpp1
-rw-r--r--libshiboken/basewrapper.h16
3 files changed, 16 insertions, 4 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index 3b08b670..388d45e9 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -1950,7 +1950,8 @@ void CppGenerator::writeClassDefinition(QTextStream& s, const AbstractMetaClass*
s << INDENT << "/*ext_isconvertible*/ 0," << endl;
s << INDENT << "/*ext_tocpp*/ 0," << endl;
s << INDENT << "/*cpp_dtor*/ " << cpp_dtor << ',' << endl;
- s << INDENT << "/*is_multicpp*/ 0" << endl;
+ s << INDENT << "/*is_multicpp*/ 0," << endl;
+ s << INDENT << "/*is_user_type*/ 0" << endl;
s << "};" << endl;
}
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index a49ec0df..36e14b10 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 7297f4c3..168d3f43 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;
}
/**