diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-01-17 19:00:24 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-01-20 09:06:50 +0100 |
commit | 7b8329866734a25a723596444ad23a1c4f7dbf9b (patch) | |
tree | 00f1def3572a9c058bd5ed2bfb1ad6df817a9d28 /pyuno/source/module | |
parent | 00173d8c3a17f9dc00ead78392812a98397cf277 (diff) |
Some more loplugin:cstylecast: pyuno
Change-Id: I80c9fdb45c9f58ac3cd1b0fab2631b903194e268
Diffstat (limited to 'pyuno/source/module')
-rw-r--r-- | pyuno/source/module/pyuno.cxx | 28 | ||||
-rw-r--r-- | pyuno/source/module/pyuno_adapter.cxx | 2 | ||||
-rw-r--r-- | pyuno/source/module/pyuno_callable.cxx | 6 | ||||
-rw-r--r-- | pyuno/source/module/pyuno_except.cxx | 4 | ||||
-rw-r--r-- | pyuno/source/module/pyuno_module.cxx | 11 | ||||
-rw-r--r-- | pyuno/source/module/pyuno_runtime.cxx | 12 | ||||
-rw-r--r-- | pyuno/source/module/pyuno_type.cxx | 6 |
7 files changed, 34 insertions, 35 deletions
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx index ac9ca52349f2..518a5af6ec30 100644 --- a/pyuno/source/module/pyuno.cxx +++ b/pyuno/source/module/pyuno.cxx @@ -130,12 +130,12 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); assert( pTypeDescr ); - typelib_CompoundTypeDescription * pCompType = (typelib_CompoundTypeDescription *)pTypeDescr; + typelib_CompoundTypeDescription * pCompType = reinterpret_cast<typelib_CompoundTypeDescription *>(pTypeDescr); sal_Int32 nDescr = pCompType->nMembers; if (pCompType->pBaseTypeDescription) { - buf.append( val2str( pVal, ((typelib_TypeDescription *)pCompType->pBaseTypeDescription)->pWeakRef,mode ) ); + buf.append( val2str( pVal, pCompType->pBaseTypeDescription->aBase.pWeakRef, mode ) ); if (nDescr) buf.append( ", " ); } @@ -168,7 +168,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef uno_Sequence * pSequence = *(uno_Sequence **)pVal; typelib_TypeDescription * pElementTypeDescr = 0; - TYPELIB_DANGER_GET( &pElementTypeDescr, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType ); + TYPELIB_DANGER_GET( &pElementTypeDescr, reinterpret_cast<typelib_IndirectTypeDescription *>(pTypeDescr)->pType ); sal_Int32 nElementSize = pElementTypeDescr->nSize; sal_Int32 nElements = pSequence->nElements; @@ -213,15 +213,15 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef typelib_TypeDescription * pTypeDescr = 0; TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); - sal_Int32 * pValues = ((typelib_EnumTypeDescription *)pTypeDescr)->pEnumValues; - sal_Int32 nPos = ((typelib_EnumTypeDescription *)pTypeDescr)->nEnumValues; + sal_Int32 * pValues = reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->pEnumValues; + sal_Int32 nPos = reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->nEnumValues; while (nPos--) { if (pValues[nPos] == *(int *)pVal) break; } if (nPos >= 0) - buf.append( ((typelib_EnumTypeDescription *)pTypeDescr)->ppEnumNames[nPos] ); + buf.append( reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->ppEnumNames[nPos] ); else buf.append( '?' ); @@ -296,7 +296,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef PyObject *PyUNO_repr( PyObject * self ) { - PyUNO *me = (PyUNO * ) self; + PyUNO *me = reinterpret_cast<PyUNO *>(self); PyObject * ret = 0; if( me->members->wrappedObject.getValueType().getTypeClass() @@ -328,7 +328,7 @@ PyObject *PyUNO_invoke( PyObject *object, const char *name , PyObject *args ) PyRef paras,callable; if( PyObject_IsInstance( object, getPyUnoClass().get() ) ) { - PyUNO* me = (PyUNO*) object; + PyUNO* me = reinterpret_cast<PyUNO*>(object); OUString attrName = OUString::createFromAscii(name); if (! me->members->xInvocation->hasMethod (attrName)) { @@ -393,7 +393,7 @@ PyObject *PyUNO_invoke( PyObject *object, const char *name , PyObject *args ) PyObject *PyUNO_str( PyObject * self ) { - PyUNO *me = ( PyUNO * ) self; + PyUNO *me = reinterpret_cast<PyUNO *>(self); OStringBuffer buf; @@ -428,7 +428,7 @@ PyObject *PyUNO_str( PyObject * self ) PyObject* PyUNO_dir (PyObject* self) { - PyUNO* me = (PyUNO*) self; + PyUNO* me = reinterpret_cast<PyUNO*>(self); PyObject* member_list = NULL; Sequence<OUString> oo_member_list; @@ -461,7 +461,7 @@ PyObject* PyUNO_getattr (PyObject* self, char* name) Runtime runtime; - me = (PyUNO*) self; + me = reinterpret_cast<PyUNO*>(self); if (strcmp (name, "__dict__") == 0) { Py_INCREF (Py_TYPE(me)->tp_dict); @@ -539,7 +539,7 @@ int PyUNO_setattr (PyObject* self, char* name, PyObject* value) { PyUNO* me; - me = (PyUNO*) self; + me = reinterpret_cast<PyUNO*>(self); try { Runtime runtime; @@ -644,7 +644,7 @@ static PyObject* PyUNO_cmp( PyObject *self, PyObject *that, int op ) static PyMethodDef PyUNOMethods[] = { - {"__dir__", (PyCFunction)PyUNO_dir, METH_NOARGS, NULL}, + {"__dir__", reinterpret_cast<PyCFunction>(PyUNO_dir), METH_NOARGS, NULL}, {NULL, NULL, 0, NULL} }; @@ -766,7 +766,7 @@ PyObject* PyUNO_new_UNCHECKED ( self->members = new PyUNOInternals(); self->members->xInvocation = tmp_invocation; self->members->wrappedObject = targetInterface; - return (PyObject*) self; + return reinterpret_cast<PyObject*>(self); } } diff --git a/pyuno/source/module/pyuno_adapter.cxx b/pyuno/source/module/pyuno_adapter.cxx index 83bb271eede4..fe01dbe2e6fe 100644 --- a/pyuno/source/module/pyuno_adapter.cxx +++ b/pyuno/source/module/pyuno_adapter.cxx @@ -83,7 +83,7 @@ void raiseInvocationTargetExceptionWhenNeeded( const Runtime &runtime ) if( PyErr_Occurred() ) { PyRef excType, excValue, excTraceback; - PyErr_Fetch( (PyObject **)&excType, (PyObject**)&excValue,(PyObject**)&excTraceback); + PyErr_Fetch(reinterpret_cast<PyObject **>(&excType), reinterpret_cast<PyObject**>(&excValue), reinterpret_cast<PyObject**>(&excTraceback)); Any unoExc( runtime.extractUnoException( excType, excValue, excTraceback ) ); throw InvocationTargetException( ((com::sun::star::uno::Exception*)unoExc.getValue())->Message, diff --git a/pyuno/source/module/pyuno_callable.cxx b/pyuno/source/module/pyuno_callable.cxx index 5b1d62feb8e2..b70cc2f81b88 100644 --- a/pyuno/source/module/pyuno_callable.cxx +++ b/pyuno/source/module/pyuno_callable.cxx @@ -53,7 +53,7 @@ void PyUNO_callable_del (PyObject* self) { PyUNO_callable* me; - me = (PyUNO_callable*) self; + me = reinterpret_cast<PyUNO_callable*>(self); delete me->members; PyObject_Del (self); @@ -71,7 +71,7 @@ PyObject* PyUNO_callable_call( Any any_params; Any ret_value; RuntimeCargo *cargo = 0; - me = (PyUNO_callable*) self; + me = reinterpret_cast<PyUNO_callable*>(self); PyRef ret; try @@ -255,7 +255,7 @@ PyRef PyUNO_callable_new ( self->members->methodName = methodName; self->members->mode = mode; - return PyRef( (PyObject*)self, SAL_NO_ACQUIRE ); + return PyRef( reinterpret_cast<PyObject*>(self), SAL_NO_ACQUIRE ); } } diff --git a/pyuno/source/module/pyuno_except.cxx b/pyuno/source/module/pyuno_except.cxx index 1835784c9358..f9adec7f08da 100644 --- a/pyuno/source/module/pyuno_except.cxx +++ b/pyuno/source/module/pyuno_except.cxx @@ -109,7 +109,7 @@ static PyRef createClass( const OUString & name, const Runtime &runtime ) PyRef base; if( isInterface ) { - typelib_InterfaceTypeDescription *pDesc = (typelib_InterfaceTypeDescription * )desc.get(); + typelib_InterfaceTypeDescription *pDesc = reinterpret_cast<typelib_InterfaceTypeDescription *>(desc.get()); if( pDesc->pBaseTypeDescription ) { base = getClass( pDesc->pBaseTypeDescription->aBase.pTypeName, runtime ); @@ -121,7 +121,7 @@ static PyRef createClass( const OUString & name, const Runtime &runtime ) } else { - typelib_CompoundTypeDescription *pDesc = (typelib_CompoundTypeDescription*)desc.get(); + typelib_CompoundTypeDescription *pDesc = reinterpret_cast<typelib_CompoundTypeDescription*>(desc.get()); if( pDesc->pBaseTypeDescription ) { base = getClass( pDesc->pBaseTypeDescription->aBase.pTypeName, runtime ); diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx index 4968e6602164..c2187afcccd8 100644 --- a/pyuno/source/module/pyuno_module.cxx +++ b/pyuno/source/module/pyuno_module.cxx @@ -350,8 +350,7 @@ static PyObject* initTestEnvironment( oslGenericFunction const pFunc( mod.getFunctionSymbol("test_init")); if (!pFunc) { abort(); } - // guess casting pFunc is undefined behavior but don't see a better way - ((void (SAL_CALL *)(XMultiServiceFactory*)) pFunc) (xMSF.get()); + reinterpret_cast<void (SAL_CALL *)(XMultiServiceFactory*)>(pFunc)(xMSF.get()); } catch (const com::sun::star::uno::Exception &) { @@ -403,13 +402,13 @@ static PyObject *createUnoStructHelper( if (idl_class.is ()) { idl_class->createObject (IdlStruct); - PyUNO *me = (PyUNO*)PyUNO_new_UNCHECKED( IdlStruct, c->xInvocation ); - PyRef returnCandidate( (PyObject*)me, SAL_NO_ACQUIRE ); + PyUNO *me = reinterpret_cast<PyUNO*>(PyUNO_new_UNCHECKED( IdlStruct, c->xInvocation )); + PyRef returnCandidate( reinterpret_cast<PyObject*>(me), SAL_NO_ACQUIRE ); TypeDescription desc( typeName ); OSL_ASSERT( desc.is() ); // could already instantiate an XInvocation2 ! typelib_CompoundTypeDescription *pCompType = - ( typelib_CompoundTypeDescription * ) desc.get(); + reinterpret_cast<typelib_CompoundTypeDescription *>(desc.get()); fillStructState state; if ( PyTuple_Size( initializer ) > 0 || PyDict_Size( keywordArgs ) > 0 ) fillStruct( me->members->xInvocation, pCompType, initializer, keywordArgs, state, runtime ); @@ -632,7 +631,7 @@ static PyObject * generateUuid( SAL_UNUSED_PARAMETER PyObject *, SAL_UNUSED_PARAMETER PyObject * ) { Sequence< sal_Int8 > seq( 16 ); - rtl_createUuid( (sal_uInt8*)seq.getArray() , 0 , sal_False ); + rtl_createUuid( reinterpret_cast<sal_uInt8*>(seq.getArray()) , 0 , sal_False ); PyRef ret; try { diff --git a/pyuno/source/module/pyuno_runtime.cxx b/pyuno/source/module/pyuno_runtime.cxx index 3825f2af9ab6..cafd84b1047b 100644 --- a/pyuno/source/module/pyuno_runtime.cxx +++ b/pyuno/source/module/pyuno_runtime.cxx @@ -161,7 +161,7 @@ static PyRef importUnoModule( ) throw ( RuntimeException ) if( PyErr_Occurred() ) { PyRef excType, excValue, excTraceback; - PyErr_Fetch( (PyObject **)&excType, (PyObject**)&excValue,(PyObject**)&excTraceback); + PyErr_Fetch( reinterpret_cast<PyObject **>(&excType), reinterpret_cast<PyObject**>(&excValue), reinterpret_cast<PyObject**>(&excTraceback)); // As of Python 2.7 this gives a rather non-useful "<traceback object at 0xADDRESS>", // but it is the best we can do in the absence of uno._uno_extract_printable_stacktrace // Who knows, a future Python might print something better. @@ -186,7 +186,7 @@ static void readLoggingConfig( sal_Int32 *pLevel, FILE **ppFile ) OUString fileName; osl_getModuleURLFromFunctionAddress( reinterpret_cast< oslGenericFunction >(readLoggingConfig), - (rtl_uString **) &fileName ); + &fileName.pData ); fileName = fileName.copy( fileName.lastIndexOf( '/' )+1 ); #ifdef MACOSX fileName += "../" LIBO_ETC_FOLDER "/"; @@ -460,7 +460,7 @@ PyRef Runtime::any2PyObject (const Any &a ) const { desc.makeComplete(); typelib_EnumTypeDescription *pEnumDesc = - (typelib_EnumTypeDescription *) desc.get(); + reinterpret_cast<typelib_EnumTypeDescription *>(desc.get()); for( int i = 0 ; i < pEnumDesc->nEnumValues ; i ++ ) { if( pEnumDesc->pEnumValues[i] == l ) @@ -740,7 +740,7 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con if( PyStrBytes_Check( str.get() ) ) { seq = Sequence<sal_Int8 > ( - (sal_Int8*) PyStrBytes_AsString(str.get()), PyStrBytes_Size(str.get())); + reinterpret_cast<sal_Int8*>(PyStrBytes_AsString(str.get())), PyStrBytes_Size(str.get())); } a <<= seq; } @@ -757,7 +757,7 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con else if( isInstanceOfStructOrException( o ) ) { PyRef struc(PyObject_GetAttrString( o , "value" ),SAL_NO_ACQUIRE); - PyUNO * obj = (PyUNO*)struc.get(); + PyUNO * obj = reinterpret_cast<PyUNO*>(struc.get()); Reference< XMaterialHolder > holder( obj->members->xInvocation, UNO_QUERY ); if( holder.is( ) ) a = holder->getMaterial(); @@ -770,7 +770,7 @@ Any Runtime::pyObject2Any ( const PyRef & source, enum ConversionMode mode ) con else if( PyObject_IsInstance( o, getPyUnoClass().get() ) ) { PyUNO* o_pi; - o_pi = (PyUNO*) o; + o_pi = reinterpret_cast<PyUNO*>(o); if (o_pi->members->wrappedObject.getValueTypeClass () == com::sun::star::uno::TypeClass_STRUCT || o_pi->members->wrappedObject.getValueTypeClass () == diff --git a/pyuno/source/module/pyuno_type.cxx b/pyuno/source/module/pyuno_type.cxx index 283362669c00..08f487a1289f 100644 --- a/pyuno/source/module/pyuno_type.cxx +++ b/pyuno/source/module/pyuno_type.cxx @@ -174,11 +174,11 @@ Any PyEnum2Enum( PyObject *obj ) throw ( RuntimeException ) desc.makeComplete(); - typelib_EnumTypeDescription *pEnumDesc = (typelib_EnumTypeDescription*) desc.get(); + typelib_EnumTypeDescription *pEnumDesc = reinterpret_cast<typelib_EnumTypeDescription*>(desc.get()); int i = 0; for( i = 0; i < pEnumDesc->nEnumValues ; i ++ ) { - if( (*((OUString *)&pEnumDesc->ppEnumNames[i])).equalsAscii( stringValue ) ) + if( OUString::unacquired(&pEnumDesc->ppEnumNames[i]).equalsAscii( stringValue ) ) { break; } @@ -293,7 +293,7 @@ PyObject *PyUNO_ByteSequence_new( const com::sun::star::uno::Sequence< sal_Int8 > &byteSequence, const Runtime &r ) { PyRef str( - PyStrBytes_FromStringAndSize( (char*)byteSequence.getConstArray(), byteSequence.getLength()), + PyStrBytes_FromStringAndSize( reinterpret_cast<char const *>(byteSequence.getConstArray()), byteSequence.getLength()), SAL_NO_ACQUIRE ); PyRef args( PyTuple_New( 1 ), SAL_NO_ACQUIRE, NOT_NULL ); PyTuple_SetItem( args.get() , 0 , str.getAcquired() ); |