Kaydet (Commit) 8375ac01 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up C-style casts from pointers to void

Change-Id: I3676d56e65dd2d5b36882073c63e571a79819fee
üst d0c9cb0c
...@@ -73,7 +73,7 @@ static void raiseRuntimeExceptionWhenNeeded() throw ( RuntimeException ) ...@@ -73,7 +73,7 @@ static void raiseRuntimeExceptionWhenNeeded() throw ( RuntimeException )
OUStringBuffer buf; OUStringBuffer buf;
buf.appendAscii( "python-loader:" ); buf.appendAscii( "python-loader:" );
if( a.hasValue() ) if( a.hasValue() )
buf.append( ((com::sun::star::uno::Exception *)a.getValue())->Message ); buf.append( static_cast<com::sun::star::uno::Exception const *>(a.getValue())->Message );
throw RuntimeException( buf.makeStringAndClear() ); throw RuntimeException( buf.makeStringAndClear() );
} }
} }
......
...@@ -84,10 +84,10 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef ...@@ -84,10 +84,10 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
case typelib_TypeClass_INTERFACE: case typelib_TypeClass_INTERFACE:
{ {
buf.append( "0x" ); buf.append( "0x" );
buf.append( reinterpret_cast< sal_IntPtr >(*(void **)pVal), 16 ); buf.append( reinterpret_cast< sal_IntPtr >(*static_cast<void * const *>(pVal)), 16 );
if( VAL2STR_MODE_DEEP == mode ) if( VAL2STR_MODE_DEEP == mode )
{ {
buf.append( "{" ); Reference< XInterface > r = *( Reference< XInterface > * ) pVal; buf.append( "{" ); Reference< XInterface > r = *static_cast<Reference< XInterface > const *>(pVal);
Reference< XServiceInfo > serviceInfo( r, UNO_QUERY); Reference< XServiceInfo > serviceInfo( r, UNO_QUERY);
Reference< XTypeProvider > typeProvider(r,UNO_QUERY); Reference< XTypeProvider > typeProvider(r,UNO_QUERY);
if( serviceInfo.is() ) if( serviceInfo.is() )
...@@ -150,7 +150,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef ...@@ -150,7 +150,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
buf.append( " = " ); buf.append( " = " );
typelib_TypeDescription * pMemberType = 0; typelib_TypeDescription * pMemberType = 0;
TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] ); TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] );
buf.append( val2str( (char *)pVal + pMemberOffsets[nPos], pMemberType->pWeakRef, mode ) ); buf.append( val2str( static_cast<char const *>(pVal) + pMemberOffsets[nPos], pMemberType->pWeakRef, mode ) );
TYPELIB_DANGER_RELEASE( pMemberType ); TYPELIB_DANGER_RELEASE( pMemberType );
if (nPos < (nDescr -1)) if (nPos < (nDescr -1))
buf.append( ", " ); buf.append( ", " );
...@@ -166,7 +166,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef ...@@ -166,7 +166,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
typelib_TypeDescription * pTypeDescr = 0; typelib_TypeDescription * pTypeDescr = 0;
TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
uno_Sequence * pSequence = *(uno_Sequence **)pVal; uno_Sequence * pSequence = *static_cast<uno_Sequence * const *>(pVal);
typelib_TypeDescription * pElementTypeDescr = 0; typelib_TypeDescription * pElementTypeDescr = 0;
TYPELIB_DANGER_GET( &pElementTypeDescr, reinterpret_cast<typelib_IndirectTypeDescription *>(pTypeDescr)->pType ); TYPELIB_DANGER_GET( &pElementTypeDescr, reinterpret_cast<typelib_IndirectTypeDescription *>(pTypeDescr)->pType );
...@@ -195,17 +195,17 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef ...@@ -195,17 +195,17 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
} }
case typelib_TypeClass_ANY: case typelib_TypeClass_ANY:
buf.append( "{ " ); buf.append( "{ " );
buf.append( val2str( ((uno_Any *)pVal)->pData, buf.append( val2str( static_cast<uno_Any const *>(pVal)->pData,
((uno_Any *)pVal)->pType , static_cast<uno_Any const *>(pVal)->pType ,
mode) ); mode) );
buf.append( " }" ); buf.append( " }" );
break; break;
case typelib_TypeClass_TYPE: case typelib_TypeClass_TYPE:
buf.append( (*(typelib_TypeDescriptionReference **)pVal)->pTypeName ); buf.append( (*static_cast<typelib_TypeDescriptionReference * const *>(pVal))->pTypeName );
break; break;
case typelib_TypeClass_STRING: case typelib_TypeClass_STRING:
buf.append( '\"' ); buf.append( '\"' );
buf.append( *(rtl_uString **)pVal ); buf.append( *static_cast<rtl_uString * const *>(pVal) );
buf.append( '\"' ); buf.append( '\"' );
break; break;
case typelib_TypeClass_ENUM: case typelib_TypeClass_ENUM:
...@@ -217,7 +217,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef ...@@ -217,7 +217,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
sal_Int32 nPos = reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->nEnumValues; sal_Int32 nPos = reinterpret_cast<typelib_EnumTypeDescription *>(pTypeDescr)->nEnumValues;
while (nPos--) while (nPos--)
{ {
if (pValues[nPos] == *(int *)pVal) if (pValues[nPos] == *static_cast<int const *>(pVal))
break; break;
} }
if (nPos >= 0) if (nPos >= 0)
...@@ -229,41 +229,41 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef ...@@ -229,41 +229,41 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
break; break;
} }
case typelib_TypeClass_BOOLEAN: case typelib_TypeClass_BOOLEAN:
if (*(sal_Bool *)pVal) if (*static_cast<sal_Bool const *>(pVal))
buf.append( "true" ); buf.append( "true" );
else else
buf.append( "false" ); buf.append( "false" );
break; break;
case typelib_TypeClass_CHAR: case typelib_TypeClass_CHAR:
buf.append( '\'' ); buf.append( '\'' );
buf.append( *(sal_Unicode *)pVal ); buf.append( *static_cast<sal_Unicode const *>(pVal) );
buf.append( '\'' ); buf.append( '\'' );
break; break;
case typelib_TypeClass_FLOAT: case typelib_TypeClass_FLOAT:
buf.append( *(float *)pVal ); buf.append( *static_cast<float const *>(pVal) );
break; break;
case typelib_TypeClass_DOUBLE: case typelib_TypeClass_DOUBLE:
buf.append( *(double *)pVal ); buf.append( *static_cast<double const *>(pVal) );
break; break;
case typelib_TypeClass_BYTE: case typelib_TypeClass_BYTE:
buf.append( "0x" ); buf.append( "0x" );
buf.append( (sal_Int32)*(sal_Int8 *)pVal, 16 ); buf.append( (sal_Int32)*static_cast<sal_Int8 const *>(pVal), 16 );
break; break;
case typelib_TypeClass_SHORT: case typelib_TypeClass_SHORT:
buf.append( "0x" ); buf.append( "0x" );
buf.append( (sal_Int32)*(sal_Int16 *)pVal, 16 ); buf.append( (sal_Int32)*static_cast<sal_Int16 const *>(pVal), 16 );
break; break;
case typelib_TypeClass_UNSIGNED_SHORT: case typelib_TypeClass_UNSIGNED_SHORT:
buf.append( "0x" ); buf.append( "0x" );
buf.append( (sal_Int32)*(sal_uInt16 *)pVal, 16 ); buf.append( (sal_Int32)*static_cast<sal_uInt16 const *>(pVal), 16 );
break; break;
case typelib_TypeClass_LONG: case typelib_TypeClass_LONG:
buf.append( "0x" ); buf.append( "0x" );
buf.append( *(sal_Int32 *)pVal, 16 ); buf.append( *static_cast<sal_Int32 const *>(pVal), 16 );
break; break;
case typelib_TypeClass_UNSIGNED_LONG: case typelib_TypeClass_UNSIGNED_LONG:
buf.append( "0x" ); buf.append( "0x" );
buf.append( (sal_Int64)*(sal_uInt32 *)pVal, 16 ); buf.append( (sal_Int64)*static_cast<sal_uInt32 const *>(pVal), 16 );
break; break;
case typelib_TypeClass_HYPER: case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER: case typelib_TypeClass_UNSIGNED_HYPER:
...@@ -278,7 +278,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef ...@@ -278,7 +278,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef
buf.append( aVal, 16 ); buf.append( aVal, 16 );
} }
#else #else
buf.append( *(sal_Int64 *)pVal, 16 ); buf.append( *static_cast<sal_Int64 const *>(pVal), 16 );
#endif #endif
break; break;
......
...@@ -86,7 +86,7 @@ void raiseInvocationTargetExceptionWhenNeeded( const Runtime &runtime ) ...@@ -86,7 +86,7 @@ void raiseInvocationTargetExceptionWhenNeeded( const Runtime &runtime )
PyErr_Fetch(reinterpret_cast<PyObject **>(&excType), reinterpret_cast<PyObject**>(&excValue), reinterpret_cast<PyObject**>(&excTraceback)); PyErr_Fetch(reinterpret_cast<PyObject **>(&excType), reinterpret_cast<PyObject**>(&excValue), reinterpret_cast<PyObject**>(&excTraceback));
Any unoExc( runtime.extractUnoException( excType, excValue, excTraceback ) ); Any unoExc( runtime.extractUnoException( excType, excValue, excTraceback ) );
throw InvocationTargetException( throw InvocationTargetException(
((com::sun::star::uno::Exception*)unoExc.getValue())->Message, static_cast<com::sun::star::uno::Exception const *>(unoExc.getValue())->Message,
Reference<XInterface>(), unoExc ); Reference<XInterface>(), unoExc );
} }
} }
......
...@@ -380,7 +380,7 @@ PyRef Runtime::any2PyObject (const Any &a ) const ...@@ -380,7 +380,7 @@ PyRef Runtime::any2PyObject (const Any &a ) const
} }
case typelib_TypeClass_CHAR: case typelib_TypeClass_CHAR:
{ {
sal_Unicode c = *(sal_Unicode*)a.getValue(); sal_Unicode c = *static_cast<sal_Unicode const *>(a.getValue());
return PyRef( PyUNO_char_new( c , *this ), SAL_NO_ACQUIRE ); return PyRef( PyUNO_char_new( c , *this ), SAL_NO_ACQUIRE );
} }
case typelib_TypeClass_BOOLEAN: case typelib_TypeClass_BOOLEAN:
...@@ -454,7 +454,7 @@ PyRef Runtime::any2PyObject (const Any &a ) const ...@@ -454,7 +454,7 @@ PyRef Runtime::any2PyObject (const Any &a ) const
} }
case typelib_TypeClass_ENUM: case typelib_TypeClass_ENUM:
{ {
sal_Int32 l = *(sal_Int32 *) a.getValue(); sal_Int32 l = *static_cast<sal_Int32 const *>(a.getValue());
TypeDescription desc( a.getValueType() ); TypeDescription desc( a.getValueType() );
if( desc.is() ) if( desc.is() )
{ {
...@@ -500,7 +500,7 @@ PyRef Runtime::any2PyObject (const Any &a ) const ...@@ -500,7 +500,7 @@ PyRef Runtime::any2PyObject (const Any &a ) const
// assuming that the Message is always the first member, wuuuu // assuming that the Message is always the first member, wuuuu
void *pData = (void*)a.getValue(); void *pData = (void*)a.getValue();
OUString message = *(OUString * )pData; OUString message = *static_cast<OUString *>(pData);
PyRef pymsg = ustring2PyString( message ); PyRef pymsg = ustring2PyString( message );
PyTuple_SetItem( args.get(), 0 , pymsg.getAcquired() ); PyTuple_SetItem( args.get(), 0 , pymsg.getAcquired() );
// the exception base functions want to have an "args" tuple, // the exception base functions want to have an "args" tuple,
...@@ -1024,7 +1024,7 @@ PyThreadAttach::~PyThreadAttach() ...@@ -1024,7 +1024,7 @@ PyThreadAttach::~PyThreadAttach()
PyObject *value = PyObject *value =
PyDict_GetItemString( PyThreadState_GetDict( ), g_NUMERICID ); PyDict_GetItemString( PyThreadState_GetDict( ), g_NUMERICID );
if( value ) if( value )
setlocale( LC_NUMERIC, (const char * ) PyLong_AsVoidPtr( value ) ); setlocale( LC_NUMERIC, static_cast<const char *>(PyLong_AsVoidPtr( value )) );
PyThreadState_Clear( tstate ); PyThreadState_Clear( tstate );
PyEval_ReleaseThread( tstate ); PyEval_ReleaseThread( tstate );
PyThreadState_Delete( tstate ); PyThreadState_Delete( tstate );
...@@ -1037,7 +1037,7 @@ PyThreadDetach::PyThreadDetach() throw ( com::sun::star::uno::RuntimeException ) ...@@ -1037,7 +1037,7 @@ PyThreadDetach::PyThreadDetach() throw ( com::sun::star::uno::RuntimeException )
PyObject *value = PyObject *value =
PyDict_GetItemString( PyThreadState_GetDict( ), g_NUMERICID ); PyDict_GetItemString( PyThreadState_GetDict( ), g_NUMERICID );
if( value ) if( value )
setlocale( LC_NUMERIC, (const char * ) PyLong_AsVoidPtr( value ) ); setlocale( LC_NUMERIC, static_cast<const char *>(PyLong_AsVoidPtr( value )) );
PyEval_ReleaseThread( tstate ); PyEval_ReleaseThread( tstate );
} }
......
...@@ -222,13 +222,13 @@ Type PyType2Type( PyObject * o ) throw(RuntimeException ) ...@@ -222,13 +222,13 @@ Type PyType2Type( PyObject * o ) throw(RuntimeException )
buf.appendAscii( "type " ).append(name).appendAscii( " is unknown" ); buf.appendAscii( "type " ).append(name).appendAscii( " is unknown" );
throw RuntimeException( buf.makeStringAndClear() ); throw RuntimeException( buf.makeStringAndClear() );
} }
if( desc.get()->eTypeClass != (typelib_TypeClass) *(sal_Int32*)enumValue.getValue() ) if( desc.get()->eTypeClass != (typelib_TypeClass) *static_cast<sal_Int32 const *>(enumValue.getValue()) )
{ {
OUStringBuffer buf; OUStringBuffer buf;
buf.appendAscii( "pyuno.checkType: " ).append(name).appendAscii( " is a " ); buf.appendAscii( "pyuno.checkType: " ).append(name).appendAscii( " is a " );
buf.appendAscii( typeClassToString( (TypeClass) desc.get()->eTypeClass) ); buf.appendAscii( typeClassToString( (TypeClass) desc.get()->eTypeClass) );
buf.appendAscii( ", but type got construct with typeclass " ); buf.appendAscii( ", but type got construct with typeclass " );
buf.appendAscii( typeClassToString( (TypeClass) *(sal_Int32*)enumValue.getValue() ) ); buf.appendAscii( typeClassToString( (TypeClass) *static_cast<sal_Int32 const *>(enumValue.getValue()) ) );
throw RuntimeException( buf.makeStringAndClear() ); throw RuntimeException( buf.makeStringAndClear() );
} }
return desc.get()->pWeakRef; return desc.get()->pWeakRef;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment