From e205a94df825fd6becf5ff7514ae9d40ddc7f456 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 18 Jul 2011 15:29:21 -0300 Subject: Improved documentation on ObjectType's cast related functions. --- libshiboken/basewrapper.cpp | 12 ++++++------ libshiboken/basewrapper.h | 19 ++++++++++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp index 3e9b08a3a..ddfc770ed 100644 --- a/libshiboken/basewrapper.cpp +++ b/libshiboken/basewrapper.cpp @@ -554,19 +554,19 @@ bool isExternalConvertible(SbkObjectType* self, PyObject* obj) return self->d->ext_isconvertible && self->d->ext_isconvertible(obj); } -bool hasCast(SbkObjectType* self) +bool hasCast(SbkObjectType* type) { - return self->d->mi_specialcast; + return type->d->mi_specialcast; } -void* cast(SbkObjectType* self, SbkObject* obj, PyTypeObject *target) +void* cast(SbkObjectType* sourceType, SbkObject* obj, PyTypeObject* targetType) { - return self->d->mi_specialcast(Object::cppPointer(obj, target), reinterpret_cast(target)); + return sourceType->d->mi_specialcast(Object::cppPointer(obj, targetType), reinterpret_cast(targetType)); } -void setCastFunction(SbkObjectType* self, SpecialCastFunction func) +void setCastFunction(SbkObjectType* type, SpecialCastFunction func) { - self->d->mi_specialcast = func; + type->d->mi_specialcast = func; } void setOriginalName(SbkObjectType* self, const char* name) diff --git a/libshiboken/basewrapper.h b/libshiboken/basewrapper.h index 4bcd35e33..f9f2a36a3 100644 --- a/libshiboken/basewrapper.h +++ b/libshiboken/basewrapper.h @@ -133,9 +133,22 @@ LIBSHIBOKEN_API bool hasExternalCppConversions(SbkObjectType* self); LIBSHIBOKEN_API bool isExternalConvertible(SbkObjectType* self, PyObject* obj); LIBSHIBOKEN_API void* callExternalCppConversion(SbkObjectType* self, PyObject* obj); -LIBSHIBOKEN_API bool hasCast(SbkObjectType* self); -LIBSHIBOKEN_API void* cast(SbkObjectType* self, SbkObject* obj, PyTypeObject* target); -LIBSHIBOKEN_API void setCastFunction(SbkObjectType* self, SpecialCastFunction func); +/** + * Tells if the \p type represents an object of a class with multiple inheritance in C++. + * When this occurs, the C++ pointer held by the Python wrapper will need to be cast when + * passed as a parameter that expects a type of its ancestry. + * \returns true if a call to ObjectType::cast() is needed to obtain the correct + * C++ pointer for Python objects of type \p type. + */ +LIBSHIBOKEN_API bool hasCast(SbkObjectType* type); +/** + * Cast the C++ pointer held by a Python object \p obj of type \p sourceType, + * to a C++ pointer of a C++ class indicated by type \p targetType. + * \returns The cast C++ pointer. + */ +LIBSHIBOKEN_API void* cast(SbkObjectType* sourceType, SbkObject* obj, PyTypeObject* targetType); +/// Set the C++ cast function for \p type. +LIBSHIBOKEN_API void setCastFunction(SbkObjectType* type, SpecialCastFunction func); LIBSHIBOKEN_API void setOriginalName(SbkObjectType* self, const char* name); LIBSHIBOKEN_API const char* getOriginalName(SbkObjectType* self); -- cgit v1.2.3