diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-01-11 12:54:43 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-01-17 09:14:45 +0000 |
commit | 25485f7785ea7fdd5e7466fb83edae9bc582f842 (patch) | |
tree | 7c8360b84c166cb8a0175a5c3807522e4f96b64d | |
parent | b69ceee2f2cd344c836c2e3a2084a2e749e3e351 (diff) |
libshiboken: Remove some C-style casts
Replace by C++ casts.
Change-Id: I20d88ff021c681e63a6a4328c3402308f8c188e5
Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r-- | libshiboken/basewrapper.cpp | 30 | ||||
-rw-r--r-- | libshiboken/bindingmanager.cpp | 17 | ||||
-rw-r--r-- | libshiboken/conversions.h | 9 | ||||
-rw-r--r-- | libshiboken/debugfreehook.cpp | 2 | ||||
-rw-r--r-- | libshiboken/sbkconverter.cpp | 19 | ||||
-rw-r--r-- | libshiboken/sbkconverter_p.h | 23 | ||||
-rw-r--r-- | libshiboken/sbkenum.cpp | 30 | ||||
-rw-r--r-- | libshiboken/sbkmodule.cpp | 2 | ||||
-rw-r--r-- | libshiboken/sbkpython.h | 2 |
9 files changed, 70 insertions, 64 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp index d89ff422b..af517bc36 100644 --- a/libshiboken/basewrapper.cpp +++ b/libshiboken/basewrapper.cpp @@ -529,7 +529,7 @@ void init() if (PyType_Ready(&SbkObjectType_Type) < 0) Py_FatalError("[libshiboken] Failed to initialise Shiboken.BaseWrapperType metatype."); - if (PyType_Ready((PyTypeObject *)&SbkObject_Type) < 0) + if (PyType_Ready(reinterpret_cast<PyTypeObject *>(&SbkObject_Type)) < 0) Py_FatalError("[libshiboken] Failed to initialise Shiboken.BaseWrapper type."); shibokenAlreadInitialised = true; @@ -734,25 +734,25 @@ bool introduceWrapperType(PyObject* enclosingObject, setDestructorFunction(type, cppObjDtor); if (baseType) { - type->super.ht_type.tp_base = (PyTypeObject*)baseType; + type->super.ht_type.tp_base = reinterpret_cast<PyTypeObject *>(baseType); if (baseTypes) { for (int i = 0; i < PySequence_Fast_GET_SIZE(baseTypes); ++i) - BindingManager::instance().addClassInheritance((SbkObjectType*)PySequence_Fast_GET_ITEM(baseTypes, i), type); + BindingManager::instance().addClassInheritance(reinterpret_cast<SbkObjectType *>(PySequence_Fast_GET_ITEM(baseTypes, i)), type); type->super.ht_type.tp_bases = baseTypes; } else { BindingManager::instance().addClassInheritance(baseType, type); } } - if (PyType_Ready((PyTypeObject*)type) < 0) + if (PyType_Ready(reinterpret_cast<PyTypeObject *>(type)) < 0) return false; if (isInnerClass) - return PyDict_SetItemString(enclosingObject, typeName, (PyObject*)type) == 0; + return PyDict_SetItemString(enclosingObject, typeName, reinterpret_cast<PyObject *>(type)) == 0; //PyModule_AddObject steals type's reference. - Py_INCREF((PyObject*)type); - return PyModule_AddObject(enclosingObject, typeName, (PyObject*)type) == 0; + Py_INCREF(reinterpret_cast<PyObject *>(type)); + return PyModule_AddObject(enclosingObject, typeName, reinterpret_cast<PyObject *>(type)) == 0; } void setSubTypeInitHook(SbkObjectType* self, SubTypeInitHook func) @@ -879,7 +879,7 @@ void getOwnership(SbkObject* self) self->d->hasOwnership = true; if (self->d->containsCppWrapper) - Py_DECREF((PyObject*) self); // Remove extra ref + Py_DECREF(reinterpret_cast<PyObject *>(self)); // Remove extra ref else makeValid(self); // Make the object valid again } @@ -902,7 +902,7 @@ void releaseOwnership(SbkObject* self) // If We have control over object life if (self->d->containsCppWrapper) - Py_INCREF((PyObject*) self); // keep the python object alive until the wrapper destructor call + Py_INCREF(reinterpret_cast<PyObject *>(self)); // keep the python object alive until the wrapper destructor call else invalidate(self); // If I do not know when this object will die We need to invalidate this to avoid use after } @@ -939,7 +939,7 @@ static void recursive_invalidate(PyObject* pyobj, std::set<SbkObject*>& seen) static void recursive_invalidate(SbkObject* self, std::set<SbkObject*>& seen) { // Skip if this object not is a valid object or if it's already been seen - if (!self || ((PyObject*)self == Py_None) || seen.find(self) != seen.end()) + if (!self || reinterpret_cast<PyObject *>(self) == Py_None || seen.find(self) != seen.end()) return; seen.insert(self); @@ -982,7 +982,7 @@ static void recursive_invalidate(SbkObject* self, std::set<SbkObject*>& seen) void makeValid(SbkObject* self) { // Skip if this object not is a valid object - if (!self || ((PyObject*)self == Py_None) || self->d->validCppObject) + if (!self || reinterpret_cast<PyObject *>(self) == Py_None || self->d->validCppObject) return; // Mark object as invalid only if this is not a wrapper class @@ -1163,7 +1163,7 @@ void destroy(SbkObject* self, void* cppData) if (!hasParent && self->d->containsCppWrapper && !self->d->hasOwnership) { // Remove extra ref used by c++ object this will case the pyobject destruction // This can cause the object death - Py_DECREF((PyObject*)self); + Py_DECREF(reinterpret_cast<PyObject *>(self)); } //Python Object is not destroyed yet @@ -1398,7 +1398,7 @@ std::string info(SbkObject* self) s << "C++ address....... "; std::list<SbkObjectType*>::const_iterator it = bases.begin(); for (int i = 0; it != bases.end(); ++it, ++i) - s << ((PyTypeObject*)*it)->tp_name << "/" << self->d->cptr[i] << ' '; + s << reinterpret_cast<PyTypeObject *>(*it)->tp_name << '/' << self->d->cptr[i] << ' '; s << "\n"; } else { @@ -1413,7 +1413,7 @@ std::string info(SbkObject* self) if (self->d->parentInfo && self->d->parentInfo->parent) { s << "parent............ "; - Shiboken::AutoDecRef parent(PyObject_Str((PyObject*)self->d->parentInfo->parent)); + Shiboken::AutoDecRef parent(PyObject_Str(reinterpret_cast<PyObject *>(self->d->parentInfo->parent))); s << String::toCString(parent) << "\n"; } @@ -1421,7 +1421,7 @@ std::string info(SbkObject* self) s << "children.......... "; ChildrenList& children = self->d->parentInfo->children; for (ChildrenList::const_iterator it = children.begin(); it != children.end(); ++it) { - Shiboken::AutoDecRef child(PyObject_Str((PyObject*)*it)); + Shiboken::AutoDecRef child(PyObject_Str(reinterpret_cast<PyObject *>(*it))); s << String::toCString(child) << ' '; } s << '\n'; diff --git a/libshiboken/bindingmanager.cpp b/libshiboken/bindingmanager.cpp index 8cdc0b65f..5fbd11d1f 100644 --- a/libshiboken/bindingmanager.cpp +++ b/libshiboken/bindingmanager.cpp @@ -126,10 +126,11 @@ static void showWrapperMap(const WrapperMap& wrapperMap) fprintf(stderr, "WrapperMap: %p (size: %d)\n", &wrapperMap, (int) wrapperMap.size()); WrapperMap::const_iterator iter; for (iter = wrapperMap.begin(); iter != wrapperMap.end(); ++iter) { + const SbkObject *sbkObj = iter->second; fprintf(stderr, "key: %p, value: %p (%s, refcnt: %d)\n", iter->first, - iter->second, - Py_TYPE(iter->second)->tp_name, - (int) ((PyObject*)iter->second)->ob_refcnt); + static_cast<const void *>(sbkObj), + Py_TYPE(sbkObj)->tp_name, + int(reinterpret_cast<const PyObject *>(sbkObj)->ob_refcnt)); } fprintf(stderr, "-------------------------------\n"); } @@ -232,13 +233,13 @@ void BindingManager::releaseWrapper(SbkObject* sbkObj) void** cptrs = reinterpret_cast<SbkObject*>(sbkObj)->d->cptr; for (int i = 0; i < numBases; ++i) { - void* cptr = cptrs[i]; + unsigned char *cptr = reinterpret_cast<unsigned char *>(cptrs[i]); m_d->releaseWrapper(cptr); if (d && d->mi_offsets) { int* offset = d->mi_offsets; while (*offset != -1) { if (*offset > 0) - m_d->releaseWrapper((void*) ((std::size_t) cptr + (*offset))); + m_d->releaseWrapper(cptr + *offset); offset++; } } @@ -259,19 +260,19 @@ PyObject* BindingManager::getOverride(const void* cptr, const char* methodName) SbkObject* wrapper = retrieveWrapper(cptr); // The refcount can be 0 if the object is dieing and someone called // a virtual method from the destructor - if (!wrapper || ((PyObject*)wrapper)->ob_refcnt == 0) + if (!wrapper || reinterpret_cast<const PyObject *>(wrapper)->ob_refcnt == 0) return 0; if (wrapper->ob_dict) { PyObject* method = PyDict_GetItemString(wrapper->ob_dict, methodName); if (method) { - Py_INCREF((PyObject*)method); + Py_INCREF(reinterpret_cast<PyObject *>(method)); return method; } } PyObject* pyMethodName = Shiboken::String::fromCString(methodName); - PyObject* method = PyObject_GetAttr((PyObject*)wrapper, pyMethodName); + PyObject *method = PyObject_GetAttr(reinterpret_cast<PyObject *>(wrapper), pyMethodName); if (method && PyMethod_Check(method) && reinterpret_cast<PyMethodObject*>(method)->im_self == reinterpret_cast<PyObject*>(wrapper)) { diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h index 599497dc1..f0af2be8e 100644 --- a/libshiboken/conversions.h +++ b/libshiboken/conversions.h @@ -131,7 +131,7 @@ struct Converter<T*> static T* toCpp(PyObject* pyobj) { if (PyObject_TypeCheck(pyobj, SbkType<T>())) - return (T*) Object::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()); + return reinterpret_cast<T *>(Object::cppPointer(reinterpret_cast<SbkObject *>(pyobj), SbkType<T>())); else if (Converter<T>::isConvertible(pyobj)) return new T(Converter<T>::toCpp(pyobj)); else if (pyobj == Py_None) @@ -163,7 +163,7 @@ struct Converter<void*> { if (!cppobj) Py_RETURN_NONE; - PyObject* result = (PyObject*) cppobj; + PyObject *result = reinterpret_cast<PyObject *>(cppobj); Py_INCREF(result); return result; } @@ -242,10 +242,11 @@ struct ObjectTypeConverter { if (pyobj == Py_None) return 0; + SbkObject *sbkObj = reinterpret_cast<SbkObject *>(pyobj); SbkObjectType* shiboType = reinterpret_cast<SbkObjectType*>(pyobj->ob_type); if (ObjectType::hasCast(shiboType)) - return reinterpret_cast<T*>(ObjectType::cast(shiboType, reinterpret_cast<SbkObject*>(pyobj), SbkType<T>())); - return (T*) Object::cppPointer(reinterpret_cast<SbkObject*>(pyobj), SbkType<T>()); + return reinterpret_cast<T*>(ObjectType::cast(shiboType, sbkObj, SbkType<T>())); + return reinterpret_cast<T *>(Object::cppPointer(sbkObj, SbkType<T>())); } }; diff --git a/libshiboken/debugfreehook.cpp b/libshiboken/debugfreehook.cpp index 5f3b9ae8d..f5757a70f 100644 --- a/libshiboken/debugfreehook.cpp +++ b/libshiboken/debugfreehook.cpp @@ -69,7 +69,7 @@ static int testPointerBeingFreed(void *ptr) SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(ptr); fprintf(stderr, "SbkObject still in binding map when deleted: "); - PyObject_Print((PyObject*)wrapper, stderr, 0); + PyObject_Print(reinterpret_cast<PyObject *>(wrapper), stderr, 0); fprintf(stderr, "\n"); #ifdef _WIN32 diff --git a/libshiboken/sbkconverter.cpp b/libshiboken/sbkconverter.cpp index 12e1e728a..17af66e22 100644 --- a/libshiboken/sbkconverter.cpp +++ b/libshiboken/sbkconverter.cpp @@ -123,9 +123,10 @@ SbkConverter* createConverter(SbkObjectType* type, CppToPythonFunc pointerToPythonFunc, CppToPythonFunc copyToPythonFunc) { - SbkConverter* converter = createConverterObject((PyTypeObject*)type, - toCppPointerConvFunc, toCppPointerCheckFunc, - pointerToPythonFunc, copyToPythonFunc); + SbkConverter *converter = + createConverterObject(reinterpret_cast<PyTypeObject *>(type), + toCppPointerConvFunc, toCppPointerCheckFunc, + pointerToPythonFunc, copyToPythonFunc); type->d->converter = converter; return converter; } @@ -195,7 +196,7 @@ PyObject* referenceToPython(SbkConverter* converter, const void* cppIn) { assert(cppIn); - PyObject* pyOut = (PyObject*)BindingManager::instance().retrieveWrapper(cppIn); + PyObject *pyOut = reinterpret_cast<PyObject *>(BindingManager::instance().retrieveWrapper(cppIn)); if (pyOut) { Py_INCREF(pyOut); return pyOut; @@ -275,7 +276,7 @@ void* cppPointer(PyTypeObject* desiredType, SbkObject* pyIn) assert(pyIn); if (!ObjectType::checkType(desiredType)) return pyIn; - SbkObjectType* inType = (SbkObjectType*)Py_TYPE(pyIn); + SbkObjectType *inType = reinterpret_cast<SbkObjectType *>(Py_TYPE(pyIn)); if (ObjectType::hasCast(inType)) return ObjectType::cast(inType, pyIn, desiredType); return Object::cppPointer(pyIn, desiredType); @@ -286,7 +287,9 @@ void pythonToCppPointer(SbkObjectType* type, PyObject* pyIn, void* cppOut) assert(type); assert(pyIn); assert(cppOut); - *((void**)cppOut) = (pyIn == Py_None) ? 0 : cppPointer((PyTypeObject*)type, (SbkObject*)pyIn); + *reinterpret_cast<void **>(cppOut) = pyIn == Py_None + ? 0 + : cppPointer(reinterpret_cast<PyTypeObject *>(type), reinterpret_cast<SbkObject *>(pyIn)); } void pythonToCppPointer(SbkConverter* converter, PyObject* pyIn, void* cppOut) @@ -294,7 +297,9 @@ void pythonToCppPointer(SbkConverter* converter, PyObject* pyIn, void* cppOut) assert(converter); assert(pyIn); assert(cppOut); - *((void**)cppOut) = (pyIn == Py_None) ? 0 : cppPointer((PyTypeObject*)converter->pythonType, (SbkObject*)pyIn); + *reinterpret_cast<void **>(cppOut) = pyIn == Py_None + ? 0 + : cppPointer(reinterpret_cast<PyTypeObject *>(converter->pythonType), reinterpret_cast<SbkObject *>(pyIn)); } static void _pythonToCppCopy(SbkConverter* converter, PyObject* pyIn, void* cppOut) diff --git a/libshiboken/sbkconverter_p.h b/libshiboken/sbkconverter_p.h index 0269a31b8..b38561780 100644 --- a/libshiboken/sbkconverter_p.h +++ b/libshiboken/sbkconverter_p.h @@ -267,7 +267,7 @@ struct IntPrimitive : TwoPrimitive<INT> { static PyObject* toPython(const void* cppIn) { - return PyInt_FromLong((long)*((INT*)cppIn)); + return PyInt_FromLong(*reinterpret_cast<const INT *>(cppIn)); } static void toCpp(PyObject* pyIn, void* cppOut) { @@ -309,7 +309,7 @@ struct UnsignedLongPrimitive : IntPrimitive<LONG> { static PyObject* toPython(const void* cppIn) { - return PyLong_FromUnsignedLong(*((LONG*)cppIn)); + return PyLong_FromUnsignedLong(*reinterpret_cast<const LONG *>(cppIn)); } }; template <> struct Primitive<unsigned int> : UnsignedLongPrimitive<unsigned int> {}; @@ -390,11 +390,11 @@ struct FloatPrimitive : TwoPrimitive<FLOAT> { static PyObject* toPython(const void* cppIn) { - return PyFloat_FromDouble((double)*((FLOAT*)cppIn)); + return PyFloat_FromDouble(*reinterpret_cast<const FLOAT *>(cppIn)); } static void toCpp(PyObject* pyIn, void* cppOut) { - *((FLOAT*)cppOut) = (FLOAT) PyLong_AsLong(pyIn); + *reinterpret_cast<FLOAT *>(cppOut) = FLOAT(PyLong_AsLong(pyIn)); } static PythonToCppFunc isConvertible(PyObject* pyIn) { @@ -404,7 +404,7 @@ struct FloatPrimitive : TwoPrimitive<FLOAT> } static void otherToCpp(PyObject* pyIn, void* cppOut) { - *((FLOAT*)cppOut) = (FLOAT) PyFloat_AsDouble(pyIn); + *reinterpret_cast<FLOAT *>(cppOut) = FLOAT(PyFloat_AsDouble(pyIn)); } static PythonToCppFunc isOtherConvertible(PyObject* pyIn) { @@ -423,7 +423,7 @@ struct Primitive<bool> : OnePrimitive<bool> { static PyObject* toPython(const void* cppIn) { - return PyBool_FromLong(*((bool*)cppIn)); + return PyBool_FromLong(*reinterpret_cast<const bool *>(cppIn)); } static PythonToCppFunc isConvertible(PyObject* pyIn) { @@ -433,7 +433,7 @@ struct Primitive<bool> : OnePrimitive<bool> } static void toCpp(PyObject* pyIn, void* cppOut) { - *((bool*)cppOut) = (bool) PyInt_AS_LONG(pyIn); + *reinterpret_cast<bool *>(cppOut) = PyInt_AS_LONG(pyIn) != 0; } }; @@ -444,8 +444,7 @@ struct CharPrimitive : IntPrimitive<CHAR> { static void toCpp(PyObject* pyIn, void* cppOut) { - - *((CHAR*)cppOut) = (CHAR) Shiboken::String::toCString(pyIn)[0]; + *reinterpret_cast<CHAR *>(cppOut) = CHAR(Shiboken::String::toCString(pyIn)[0]); } static PythonToCppFunc isConvertible(PyObject* pyIn) { @@ -458,7 +457,7 @@ struct CharPrimitive : IntPrimitive<CHAR> PY_LONG_LONG result = PyLong_AsLongLong(pyIn); if (OverFlowChecker<CHAR>::check(result, pyIn)) PyErr_SetObject(PyExc_OverflowError, 0); - *((CHAR*)cppOut) = (CHAR) result; + *reinterpret_cast<CHAR *>(cppOut) = CHAR(result); } static PythonToCppFunc isOtherConvertible(PyObject* pyIn) { @@ -557,14 +556,14 @@ struct Primitive<void*> : OnePrimitive<void*> SbkDbg() << cppIn; if (!cppIn) Py_RETURN_NONE; - PyObject* result = (PyObject*) cppIn; + PyObject *result = reinterpret_cast<PyObject *>(const_cast<void *>(cppIn)); Py_INCREF(result); return result; } static void toCpp(PyObject* pyIn, void* cppOut) { SbkDbg() << pyIn; - *((void**)cppOut) = pyIn; + *reinterpret_cast<void **>(cppOut) = pyIn; } static PythonToCppFunc isConvertible(PyObject *) { diff --git a/libshiboken/sbkenum.cpp b/libshiboken/sbkenum.cpp index a507d728a..0902077ed 100644 --- a/libshiboken/sbkenum.cpp +++ b/libshiboken/sbkenum.cpp @@ -72,28 +72,28 @@ struct SbkEnumObject static PyObject* SbkEnumObject_repr(PyObject* self) { - PyObject* enumName = ((SbkEnumObject*)self)->ob_name; - if (enumName) - return Shiboken::String::fromFormat("%s.%s", self->ob_type->tp_name, PyBytes_AS_STRING(enumName)); + const SbkEnumObject *enumObj = reinterpret_cast<SbkEnumObject *>(self); + if (enumObj->ob_name) + return Shiboken::String::fromFormat("%s.%s", self->ob_type->tp_name, PyBytes_AS_STRING(enumObj->ob_name)); else - return Shiboken::String::fromFormat("%s(%ld)", self->ob_type->tp_name, ((SbkEnumObject*)self)->ob_value); + return Shiboken::String::fromFormat("%s(%ld)", self->ob_type->tp_name, enumObj->ob_value); } static int SbkEnumObject_print(PyObject* self, FILE* fp, int) { Py_BEGIN_ALLOW_THREADS - PyObject* enumName = ((SbkEnumObject*)self)->ob_name; - if (enumName) - fprintf(fp, "%s.%s", self->ob_type->tp_name, PyBytes_AS_STRING(enumName)); + const SbkEnumObject *enumObj = reinterpret_cast<SbkEnumObject *>(self); + if (enumObj->ob_name) + fprintf(fp, "%s.%s", self->ob_type->tp_name, PyBytes_AS_STRING(enumObj->ob_name)); else - fprintf(fp, "%s(%ld)", self->ob_type->tp_name, ((SbkEnumObject*)self)->ob_value); + fprintf(fp, "%s(%ld)", self->ob_type->tp_name, enumObj->ob_value); Py_END_ALLOW_THREADS return 0; } static PyObject* SbkEnumObject_name(PyObject* self, void*) { - SbkEnumObject* enum_self = (SbkEnumObject*)self; + SbkEnumObject *enum_self = reinterpret_cast<SbkEnumObject *>(self); if (enum_self->ob_name == NULL) Py_RETURN_NONE; @@ -428,10 +428,10 @@ PyObject* getEnumItemFromValue(PyTypeObject* enumType, long itemValue) PyObject* values = PyDict_GetItemString(enumType->tp_dict, const_cast<char*>("values")); while (PyDict_Next(values, &pos, &key, &value)) { - SbkEnumObject* obj = (SbkEnumObject*)value; + SbkEnumObject *obj = reinterpret_cast<SbkEnumObject *>(value); if (obj->ob_value == itemValue) { Py_INCREF(obj); - return reinterpret_cast<PyObject*>(obj); + return value; } } return 0; @@ -455,9 +455,9 @@ PyTypeObject* createGlobalEnum(PyObject* module, const char* name, const char* f PyTypeObject* enumType = createEnum(fullName, cppName, name, flagsType); Shiboken::TypeResolver::createValueTypeResolver<int>("Qt::WindowType"); Shiboken::TypeResolver::createValueTypeResolver<int>("WindowType"); - if (enumType && PyModule_AddObject(module, name, (PyObject*)enumType) < 0) + if (enumType && PyModule_AddObject(module, name, reinterpret_cast<PyObject *>(enumType)) < 0) return 0; - if (flagsType && PyModule_AddObject(module, flagsType->tp_name, (PyObject*)flagsType) < 0) + if (flagsType && PyModule_AddObject(module, flagsType->tp_name, reinterpret_cast<PyObject *>(flagsType)) < 0) return 0; return enumType; } @@ -465,9 +465,9 @@ PyTypeObject* createGlobalEnum(PyObject* module, const char* name, const char* f PyTypeObject* createScopedEnum(SbkObjectType* scope, const char* name, const char* fullName, const char* cppName, PyTypeObject* flagsType) { PyTypeObject* enumType = createEnum(fullName, cppName, name, flagsType); - if (enumType && PyDict_SetItemString(scope->super.ht_type.tp_dict, name, (PyObject*)enumType) < 0) + if (enumType && PyDict_SetItemString(scope->super.ht_type.tp_dict, name, reinterpret_cast<PyObject *>(enumType)) < 0) return 0; - if (flagsType && PyDict_SetItemString(scope->super.ht_type.tp_dict, flagsType->tp_name, (PyObject*)flagsType) < 0) + if (flagsType && PyDict_SetItemString(scope->super.ht_type.tp_dict, flagsType->tp_name, reinterpret_cast<PyObject *>(flagsType)) < 0) return 0; return enumType; } diff --git a/libshiboken/sbkmodule.cpp b/libshiboken/sbkmodule.cpp index e364d7c95..084e23efa 100644 --- a/libshiboken/sbkmodule.cpp +++ b/libshiboken/sbkmodule.cpp @@ -89,7 +89,7 @@ PyObject* create(const char* moduleName, void* moduleData) { Shiboken::init(); #ifndef IS_PY3K - return Py_InitModule(moduleName, (PyMethodDef*)moduleData); + return Py_InitModule(moduleName, reinterpret_cast<PyMethodDef *>(moduleData)); #else return PyModule_Create(reinterpret_cast<PyModuleDef*>(moduleData)); #endif diff --git a/libshiboken/sbkpython.h b/libshiboken/sbkpython.h index a8242d4a8..208618d50 100644 --- a/libshiboken/sbkpython.h +++ b/libshiboken/sbkpython.h @@ -66,7 +66,7 @@ (PyNumber_Check(X) && (!PyInstance_Check(X) || PyObject_HasAttrString(X, "__trunc__"))) #define SBK_NB_BOOL(x) (x).nb_nonzero #define SBK_STR_NAME "str" - #define SBK_PyMethod_New(X, Y) PyMethod_New(X, Y, (PyObject*)Py_TYPE(Y)) + #define SBK_PyMethod_New(X, Y) PyMethod_New(X, Y, reinterpret_cast<PyObject *>(Py_TYPE(Y))) #define Py_hash_t long #endif |