diff options
author | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2010-11-19 14:30:22 -0300 |
---|---|---|
committer | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2010-11-19 16:04:06 -0300 |
commit | b2096155a231797afd397acc8908acb691f3c732 (patch) | |
tree | 35a8588d8373de6303f4f5a40c4dd2715225e000 /libshiboken/conversions.h | |
parent | e1ea3fe74afca099e7bba884256e0be0e6f7d200 (diff) | |
download | shiboken-b2096155a231797afd397acc8908acb691f3c732.tar.gz shiboken-b2096155a231797afd397acc8908acb691f3c732.tar.xz shiboken-b2096155a231797afd397acc8908acb691f3c732.zip |
Created private pointer for Shiboken Meta Type.
Renamed ObjectType to BaseType.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'libshiboken/conversions.h')
-rw-r--r-- | libshiboken/conversions.h | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h index 4d55ef0f..d6a3dd5e 100644 --- a/libshiboken/conversions.h +++ b/libshiboken/conversions.h @@ -99,7 +99,7 @@ struct CppObjectCopier<T, true> { static inline T* copy(const T& obj) { - return reinterpret_cast<T*>(reinterpret_cast<SbkObjectType*>(SbkType<T>())->obj_copier(&obj)); + return reinterpret_cast<T*>(BaseType::copy(reinterpret_cast<SbkBaseType*>(SbkType<T>()), &obj)); } }; @@ -113,7 +113,7 @@ inline PyObject* createWrapper(const T* cppobj, bool hasOwnership = false, bool const char* typeName = 0; if (!isExactType) typeName = typeid(*const_cast<T*>(cppobj)).name(); - return Wrapper::newObject(reinterpret_cast<SbkObjectType*>(SbkType<T>()), + return Wrapper::newObject(reinterpret_cast<SbkBaseType*>(SbkType<T>()), const_cast<T*>(cppobj), hasOwnership, isExactType, typeName); } @@ -213,10 +213,8 @@ struct ValueTypeConverter { if (PyObject_TypeCheck(pyobj, SbkType<T>())) return true; - SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<T>()); - if (shiboType->ext_isconvertible) - return shiboType->ext_isconvertible(pyobj); - return false; + SbkBaseType* shiboType = reinterpret_cast<SbkBaseType*>(SbkType<T>()); + return BaseType::isExternalConvertible(shiboType, pyobj); } static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<T*>(cppobj)); } static inline PyObject* toPython(const T& cppobj) @@ -233,9 +231,9 @@ struct ValueTypeConverter static inline T toCpp(PyObject* pyobj) { if (!PyObject_TypeCheck(pyobj, SbkType<T>())) { - SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(SbkType<T>()); - if (shiboType->ext_tocpp && isConvertible(pyobj)) { - T* cptr = reinterpret_cast<T*>(shiboType->ext_tocpp(pyobj)); + SbkBaseType* shiboType = reinterpret_cast<SbkBaseType*>(SbkType<T>()); + if (BaseType::hasExternalCppConversions(shiboType) && isConvertible(pyobj)) { + T* cptr = reinterpret_cast<T*>(BaseType::callExternalCppConversion(shiboType, pyobj)); std::auto_ptr<T> cptr_auto_ptr(cptr); return *cptr; } @@ -273,11 +271,9 @@ struct ObjectTypeConverter { if (pyobj == Py_None) return 0; - SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(pyobj->ob_type); - if (shiboType->mi_specialcast) - return (T*) shiboType->mi_specialcast( - Wrapper::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()), - reinterpret_cast<SbkObjectType*>(SbkType<T>())); + SbkBaseType* shiboType = reinterpret_cast<SbkBaseType*>(pyobj->ob_type); + if (BaseType::hasCast(shiboType)) + return reinterpret_cast<T*>(BaseType::cast(shiboType, reinterpret_cast<SbkObject*>(pyobj), SbkType<T>())); return (T*) Wrapper::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()); } }; @@ -564,7 +560,7 @@ struct StdListConverter // binded types implementing sequence protocol, otherwise this will // cause a mess like QBitArray being accepted by someone expecting a // QStringList. - if ((SbkType<StdList>() && isShibokenType(pyObj)) || !PySequence_Check(pyObj)) + if ((SbkType<StdList>() && Wrapper::checkType(pyObj)) || !PySequence_Check(pyObj)) return false; for (int i = 0, max = PySequence_Length(pyObj); i < max; ++i) { AutoDecRef item(PySequence_GetItem(pyObj, i)); @@ -610,7 +606,7 @@ struct StdPairConverter { if (PyObject_TypeCheck(pyObj, SbkType<StdPair>())) return true; - if ((SbkType<StdPair>() && isShibokenType(pyObj)) || !PySequence_Check(pyObj) || PySequence_Length(pyObj) != 2) + if ((SbkType<StdPair>() && Wrapper::checkType(pyObj)) || !PySequence_Check(pyObj) || PySequence_Length(pyObj) != 2) return false; AutoDecRef item1(PySequence_GetItem(pyObj, 0)); @@ -655,7 +651,7 @@ struct StdMapConverter { if (PyObject_TypeCheck(pyObj, SbkType<StdMap>())) return true; - if ((SbkType<StdMap>() && isShibokenType(pyObj)) || !PyDict_Check(pyObj)) + if ((SbkType<StdMap>() && Wrapper::checkType(pyObj)) || !PyDict_Check(pyObj)) return false; PyObject* key; |