From 93afb9ad7f42b9789b1a84281f434f0a8098c063 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Sat, 17 Jan 2015 18:14:27 +0100 Subject: Some more loplugin:cstylecast: bridges Change-Id: Ic224abf67acb212ee20ccf9eb81b5ed5edf851b9 --- bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx | 2 +- .../source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx | 16 ++--- bridges/source/cpp_uno/shared/bridge.cxx | 16 ++--- bridges/source/cpp_uno/shared/component.cxx | 21 +++--- .../source/cpp_uno/shared/cppinterfaceproxy.cxx | 4 +- .../source/cpp_uno/shared/unointerfaceproxy.cxx | 11 ++-- bridges/source/jni_uno/jni_bridge.cxx | 24 +++---- bridges/source/jni_uno/jni_data.cxx | 77 +++++++++++----------- bridges/source/jni_uno/jni_helper.h | 2 +- bridges/source/jni_uno/jni_info.cxx | 6 +- bridges/source/jni_uno/jni_info.h | 2 +- bridges/source/jni_uno/jni_java2uno.cxx | 6 +- bridges/source/jni_uno/jni_uno2java.cxx | 14 ++-- 13 files changed, 97 insertions(+), 104 deletions(-) (limited to 'bridges/source') diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx index c43e0f9ddf9d..ef00adb0b06a 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/rtti.cxx @@ -73,7 +73,7 @@ std::type_info * RTTI::getRTTI(typelib_TypeDescription const & pTypeDescr) { std::type_info * rtti; - OUString const & unoName = *(OUString const *)&pTypeDescr.pTypeName; + OUString const & unoName = OUString::unacquired(&pTypeDescr.pTypeName); osl::MutexGuard guard( m_mutex ); t_rtti_map::const_iterator iFind( m_rttis.find( unoName ) ); diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx index 8f59f9fe2bda..12cc9335c02f 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx @@ -326,7 +326,7 @@ void unoInterfaceProxyDispatch( { #if OSL_DEBUG_LEVEL > 0 // determine vtable call index - sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; + sal_Int32 nMemberPos = reinterpret_cast(pMemberDescr)->nPosition; assert(nMemberPos < pTypeDescr->nAllMembers); #endif VtableSlot aVtableSlot( @@ -340,7 +340,7 @@ void unoInterfaceProxyDispatch( // dependent dispatch cpp_call( pThis, aVtableSlot, - ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef, + reinterpret_cast(pMemberDescr)->pAttributeTypeRef, 0, 0, // no params pReturn, pArgs, ppException ); } @@ -349,7 +349,7 @@ void unoInterfaceProxyDispatch( // is SET typelib_MethodParameter aParam; aParam.pTypeRef = - ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef; + reinterpret_cast(pMemberDescr)->pAttributeTypeRef; aParam.bIn = sal_True; aParam.bOut = sal_False; @@ -375,7 +375,7 @@ void unoInterfaceProxyDispatch( { #if OSL_DEBUG_LEVEL > 0 // determine vtable call index - sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; + sal_Int32 nMemberPos = reinterpret_cast(pMemberDescr)->nPosition; assert(nMemberPos < pTypeDescr->nAllMembers); #endif VtableSlot aVtableSlot( @@ -404,7 +404,7 @@ void unoInterfaceProxyDispatch( uno_Interface * pInterface = 0; (*pThis->getBridge()->getUnoEnv()->getRegisteredInterface)( pThis->getBridge()->getUnoEnv(), - (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD ); + (void **)&pInterface, pThis->oid.pData, reinterpret_cast(pTD) ); if (pInterface) { @@ -423,9 +423,9 @@ void unoInterfaceProxyDispatch( // dependent dispatch cpp_call( pThis, aVtableSlot, - ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef, - ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams, - ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams, + reinterpret_cast(pMemberDescr)->pReturnTypeRef, + reinterpret_cast(pMemberDescr)->nParams, + reinterpret_cast(pMemberDescr)->pParams, pReturn, pArgs, ppException ); } break; diff --git a/bridges/source/cpp_uno/shared/bridge.cxx b/bridges/source/cpp_uno/shared/bridge.cxx index 170484a503f2..5ee05b3d4ad4 100644 --- a/bridges/source/cpp_uno/shared/bridge.cxx +++ b/bridges/source/cpp_uno/shared/bridge.cxx @@ -157,15 +157,15 @@ void Bridge::acquire() { uno_Mapping * pMapping = &aCpp2Uno; ::uno_registerMapping( - &pMapping, freeMapping, (uno_Environment *)pCppEnv, - (uno_Environment *)pUnoEnv, 0 ); + &pMapping, freeMapping, &pCppEnv->aBase, + &pUnoEnv->aBase, 0 ); } else { uno_Mapping * pMapping = &aUno2Cpp; ::uno_registerMapping( - &pMapping, freeMapping, (uno_Environment *)pUnoEnv, - (uno_Environment *)pCppEnv, 0 ); + &pMapping, freeMapping, &pUnoEnv->aBase, + &pCppEnv->aBase, 0 ); } } } @@ -196,14 +196,14 @@ Bridge::Bridge( aUno2Cpp.release = releaseMapping; aUno2Cpp.mapInterface = uno2cppMapping; - (*((uno_Environment *)pCppEnv)->acquire)( (uno_Environment *)pCppEnv ); - (*((uno_Environment *)pUnoEnv)->acquire)( (uno_Environment *)pUnoEnv ); + (*pCppEnv->aBase.acquire)( &pCppEnv->aBase ); + (*pUnoEnv->aBase.acquire)( &pUnoEnv->aBase ); } Bridge::~Bridge() { - (*((uno_Environment *)pUnoEnv)->release)( (uno_Environment *)pUnoEnv ); - (*((uno_Environment *)pCppEnv)->release)( (uno_Environment *)pCppEnv ); + (*pUnoEnv->aBase.release)( &pUnoEnv->aBase ); + (*pCppEnv->aBase.release)( &pCppEnv->aBase ); } } } } diff --git a/bridges/source/cpp_uno/shared/component.cxx b/bridges/source/cpp_uno/shared/component.cxx index 3f4d39f9d7f2..818841d27ec5 100644 --- a/bridges/source/cpp_uno/shared/component.cxx +++ b/bridges/source/cpp_uno/shared/component.cxx @@ -111,13 +111,10 @@ static void s_stub_computeObjectIdentifier(va_list * pParam) oid.append( reinterpret_cast< sal_Int64 >(xHome.get()), 16 ); oid.append( ';' ); // ;environment[context] - oid.append( - *reinterpret_cast< OUString const * >( - &((uno_Environment *) pEnv)->pTypeName ) ); + oid.append( OUString::unacquired(&pEnv->aBase.pTypeName) ); oid.append( '[' ); oid.append( - reinterpret_cast< sal_Int64 >( - ((uno_Environment *)pEnv)->pContext), + reinterpret_cast< sal_Int64 >(pEnv->aBase.pContext), 16 ); // ];good guid oid.append( cppu_cppenv_getStaticOIdPart() ); @@ -184,10 +181,10 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_initEnvironment(uno_Environment * pCppEnv pCppEnv->pTypeName->buffer, rtl_str_getLength(CPPU_CURRENT_LANGUAGE_BINDING_NAME), CPPU_CURRENT_LANGUAGE_BINDING_NAME ) == 0 && "### wrong environment type!"); - ((uno_ExtEnvironment *)pCppEnv)->computeObjectIdentifier + reinterpret_cast(pCppEnv)->computeObjectIdentifier = computeObjectIdentifier; - ((uno_ExtEnvironment *)pCppEnv)->acquireInterface = acquireInterface; - ((uno_ExtEnvironment *)pCppEnv)->releaseInterface = releaseInterface; + reinterpret_cast(pCppEnv)->acquireInterface = acquireInterface; + reinterpret_cast(pCppEnv)->releaseInterface = releaseInterface; pCppEnv->environmentDisposing = environmentDisposing; } @@ -218,8 +215,8 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_ext_getMapping( pFrom->pExtEnv, pTo->pExtEnv, true ); ::uno_registerMapping( &pMapping, bridges::cpp_uno::shared::freeMapping, - (uno_Environment *)pFrom->pExtEnv, - (uno_Environment *)pTo->pExtEnv, 0 ); + &pFrom->pExtEnv->aBase, + &pTo->pExtEnv->aBase, 0 ); } else if (0 == rtl_ustr_ascii_compare( to_envTypeName.pData->buffer, @@ -232,8 +229,8 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_ext_getMapping( pTo->pExtEnv, pFrom->pExtEnv, false ); ::uno_registerMapping( &pMapping, bridges::cpp_uno::shared::freeMapping, - (uno_Environment *)pFrom->pExtEnv, - (uno_Environment *)pTo->pExtEnv, 0 ); + &pFrom->pExtEnv->aBase, + &pTo->pExtEnv->aBase, 0 ); } if (*ppMapping) diff --git a/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx b/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx index c692b33d4f9e..8ca98a841f15 100644 --- a/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx +++ b/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx @@ -86,7 +86,7 @@ void freeCppInterfaceProxy(uno_ExtEnvironment * pEnv, void * pInterface) pThis->pBridge->getUnoEnv(), pThis->pUnoI ); (*pThis->pUnoI->release)( pThis->pUnoI ); ::typelib_typedescription_release( - (typelib_TypeDescription *)pThis->pTypeDescr ); + &pThis->pTypeDescr->aBase ); pThis->pBridge->release(); #if OSL_DEBUG_LEVEL > 1 @@ -153,7 +153,7 @@ CppInterfaceProxy::CppInterfaceProxy( { memset(vtables, 0, sizeof(vtables)); pBridge->acquire(); - ::typelib_typedescription_acquire( (typelib_TypeDescription *)pTypeDescr ); + ::typelib_typedescription_acquire( &pTypeDescr->aBase ); (*pUnoI->acquire)( pUnoI ); (*pBridge->getUnoEnv()->registerInterface)( pBridge->getUnoEnv(), reinterpret_cast< void ** >( &pUnoI ), oid.pData, diff --git a/bridges/source/cpp_uno/shared/unointerfaceproxy.cxx b/bridges/source/cpp_uno/shared/unointerfaceproxy.cxx index ab868df96a80..df6dcb34b9fb 100644 --- a/bridges/source/cpp_uno/shared/unointerfaceproxy.cxx +++ b/bridges/source/cpp_uno/shared/unointerfaceproxy.cxx @@ -40,8 +40,7 @@ void freeUnoInterfaceProxy(uno_ExtEnvironment * pEnv, void * pProxy) (*pThis->pBridge->getCppEnv()->revokeInterface)( pThis->pBridge->getCppEnv(), pThis->pCppI ); pThis->pCppI->release(); - ::typelib_typedescription_release( - (typelib_TypeDescription *)pThis->pTypeDescr ); + ::typelib_typedescription_release(&pThis->pTypeDescr->aBase); pThis->pBridge->release(); #if OSL_DEBUG_LEVEL > 1 @@ -105,11 +104,11 @@ UnoInterfaceProxy::UnoInterfaceProxy( , oid( rOId_ ) { pBridge->acquire(); - ::typelib_typedescription_acquire( (typelib_TypeDescription *)pTypeDescr ); - if (! ((typelib_TypeDescription *)pTypeDescr)->bComplete) + ::typelib_typedescription_acquire(&pTypeDescr->aBase); + if (!pTypeDescr->aBase.bComplete) ::typelib_typedescription_complete( - (typelib_TypeDescription **)&pTypeDescr ); - assert(((typelib_TypeDescription *)pTypeDescr)->bComplete); + reinterpret_cast(&pTypeDescr)); + assert(pTypeDescr->aBase.bComplete); pCppI->acquire(); (*pBridge->getCppEnv()->registerInterface)( pBridge->getCppEnv(), reinterpret_cast< void ** >( &pCppI ), oid.pData, diff --git a/bridges/source/jni_uno/jni_bridge.cxx b/bridges/source/jni_uno/jni_bridge.cxx index e1026c59f9b0..0d37b58d426a 100644 --- a/bridges/source/jni_uno/jni_bridge.cxx +++ b/bridges/source/jni_uno/jni_bridge.cxx @@ -92,7 +92,7 @@ void SAL_CALL Mapping_map_to_uno( JNI_interface_type_info const * info = static_cast< JNI_interface_type_info const * >( bridge->getJniInfo()->get_type_info( - jni, (typelib_TypeDescription *)td ) ); + jni, &td->aBase ) ); uno_Interface * pUnoI = bridge->map_to_uno( jni, javaI, info ); if (0 != *ppUnoI) { @@ -157,7 +157,7 @@ void SAL_CALL Mapping_map_to_java( JNI_interface_type_info const * info = static_cast< JNI_interface_type_info const * >( bridge->getJniInfo()->get_type_info( - jni, (typelib_TypeDescription *)td ) ); + jni, &td->aBase ) ); jobject jlocal = bridge->map_to_java( jni, pUnoI, info ); if (0 != *ppJavaI) jni->DeleteGlobalRef( *ppJavaI ); @@ -202,14 +202,14 @@ void Bridge::acquire() const uno_Mapping * mapping = const_cast< Mapping * >( &m_java2uno ); uno_registerMapping( &mapping, Bridge_free, - m_java_env, (uno_Environment *)m_uno_env, 0 ); + m_java_env, &m_uno_env->aBase, 0 ); } else { uno_Mapping * mapping = const_cast< Mapping * >( &m_uno2java ); uno_registerMapping( &mapping, Bridge_free, - (uno_Environment *)m_uno_env, m_java_env, 0 ); + &m_uno_env->aBase, m_java_env, 0 ); } } } @@ -246,7 +246,7 @@ Bridge::Bridge( throw BridgeRuntimeError("error during JNI-UNO's uno_initEnvironment"); } - (*((uno_Environment *)m_uno_env)->acquire)( (uno_Environment *)m_uno_env ); + (*m_uno_env->aBase.acquire)( &m_uno_env->aBase ); (*m_java_env->acquire)( m_java_env ); // java2uno @@ -265,7 +265,7 @@ Bridge::Bridge( Bridge::~Bridge() { (*m_java_env->release)( m_java_env ); - (*((uno_Environment *)m_uno_env)->release)( (uno_Environment *)m_uno_env ); + (*m_uno_env->aBase.release)( &m_uno_env->aBase ); } JNI_info const * Bridge::getJniInfo() const { @@ -323,7 +323,7 @@ void JNI_context::java_exc_occurred() const std::unique_ptr< rtl_mem > ustr_mem( rtl_mem::allocate( sizeof (rtl_uString) + (len * sizeof (sal_Unicode)) ) ); - rtl_uString * ustr = (rtl_uString *)ustr_mem.get(); + rtl_uString * ustr = reinterpret_cast(ustr_mem.get()); m_env->GetStringRegion( static_cast(jo_descr.get()), 0, len, ustr->buffer ); if (m_env->ExceptionCheck()) { @@ -334,7 +334,7 @@ void JNI_context::java_exc_occurred() const ustr->refCount = 1; ustr->length = len; ustr->buffer[ len ] = '\0'; - OUString message( (rtl_uString *)ustr_mem.release(), SAL_NO_ACQUIRE ); + OUString message( reinterpret_cast(ustr_mem.release()), SAL_NO_ACQUIRE ); throw BridgeRuntimeError( message + get_stack_trace( jo_exc.get() ) ); } @@ -399,7 +399,7 @@ OUString JNI_context::get_stack_trace( jobject jo_exc ) const std::unique_ptr< rtl_mem > ustr_mem( rtl_mem::allocate( sizeof (rtl_uString) + (len * sizeof (sal_Unicode)) ) ); - rtl_uString * ustr = (rtl_uString *)ustr_mem.get(); + rtl_uString * ustr = reinterpret_cast(ustr_mem.get()); m_env->GetStringRegion( static_cast(jo_stack_trace.get()), 0, len, ustr->buffer ); if (assert_no_exception()) @@ -408,7 +408,7 @@ OUString JNI_context::get_stack_trace( jobject jo_exc ) const ustr->length = len; ustr->buffer[ len ] = '\0'; return OUString( - (rtl_uString *)ustr_mem.release(), SAL_NO_ACQUIRE ); + reinterpret_cast(ustr_mem.release()), SAL_NO_ACQUIRE ); } } } @@ -551,7 +551,7 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_ext_getMapping( mapping = &bridge->m_java2uno; uno_registerMapping( &mapping, Bridge_free, - pFrom, (uno_Environment *)pTo->pExtEnv, 0 ); + pFrom, &pTo->pExtEnv->aBase, 0 ); // coverity[leaked_storage] } else if ( from_env_typename == UNO_LB_UNO && to_env_typename == UNO_LB_JAVA ) @@ -561,7 +561,7 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_ext_getMapping( mapping = &bridge->m_uno2java; uno_registerMapping( &mapping, Bridge_free, - (uno_Environment *)pFrom->pExtEnv, pTo, 0 ); + &pFrom->pExtEnv->aBase, pTo, 0 ); // coverity[leaked_storage] } } diff --git a/bridges/source/jni_uno/jni_data.cxx b/bridges/source/jni_uno/jni_data.cxx index 6fa4d834ee75..6d2e2dd4c850 100644 --- a/bridges/source/jni_uno/jni_data.cxx +++ b/bridges/source/jni_uno/jni_data.cxx @@ -35,7 +35,7 @@ inline rtl_mem * seq_allocate( sal_Int32 nElements, sal_Int32 nSize ) { std::unique_ptr< rtl_mem > seq( rtl_mem::allocate( SAL_SEQUENCE_HEADER_SIZE + (nElements * nSize) ) ); - uno_Sequence * p = (uno_Sequence *)seq.get(); + uno_Sequence * p = reinterpret_cast(seq.get()); p->nRefCount = 1; p->nElements = nElements; return seq.release(); @@ -561,7 +561,7 @@ void Bridge::map_to_uno( { std::unique_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (sal_Int64) ) ); - *(jlong *) mem.get() = jni->CallLongMethodA( + *reinterpret_cast(mem.get()) = jni->CallLongMethodA( java_data.l, getJniInfo()->m_method_Long_longValue, 0 ); jni.ensure_no_exception(); pAny->pData = mem.release(); @@ -579,7 +579,7 @@ void Bridge::map_to_uno( { std::unique_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (float) ) ); - *(jfloat *) mem.get() = jni->CallFloatMethodA( + *reinterpret_cast(mem.get()) = jni->CallFloatMethodA( java_data.l, getJniInfo()->m_method_Float_floatValue, 0 ); jni.ensure_no_exception(); pAny->pData = mem.release(); @@ -599,7 +599,7 @@ void Bridge::map_to_uno( { std::unique_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (double) ) ); - *(jdouble *) mem.get() = + *reinterpret_cast(mem.get()) = jni->CallDoubleMethodA( java_data.l, getJniInfo()->m_method_Double_doubleValue, 0 ); @@ -703,7 +703,7 @@ void Bridge::map_to_uno( static_cast< JNI_compound_type_info const * >( info ); typelib_CompoundTypeDescription * comp_td = - (typelib_CompoundTypeDescription *)comp_info->m_td.get(); + reinterpret_cast(comp_info->m_td.get()); bool polymorphic = comp_td->aBase.eTypeClass == typelib_TypeClass_STRUCT && reinterpret_cast< typelib_StructTypeDescription * >( @@ -717,8 +717,7 @@ void Bridge::map_to_uno( { map_to_uno( jni, uno_data, java_data, - ((typelib_TypeDescription *) comp_td->pBaseTypeDescription) - ->pWeakRef, + comp_td->pBaseTypeDescription->aBase.pWeakRef, comp_info->m_base, assign, false /* no out param */ ); } @@ -940,9 +939,7 @@ void Bridge::map_to_uno( if (0 != comp_td->pBaseTypeDescription) { uno_destructData( - uno_data, - (typelib_TypeDescription *) comp_td - ->pBaseTypeDescription, 0 ); + uno_data, &comp_td->pBaseTypeDescription->aBase, 0 ); } } throw; @@ -968,7 +965,7 @@ void Bridge::map_to_uno( TypeDescr td( type ); typelib_TypeDescriptionReference * element_type = - ((typelib_IndirectTypeDescription *)td.get())->pType; + reinterpret_cast(td.get())->pType; std::unique_ptr< rtl_mem > seq; sal_Int32 nElements = jni->GetArrayLength( static_cast(java_data.l) ); @@ -979,21 +976,21 @@ void Bridge::map_to_uno( seq.reset( seq_allocate( nElements, sizeof (sal_Unicode) ) ); jni->GetCharArrayRegion( static_cast(java_data.l), 0, nElements, - (jchar *) ((uno_Sequence *) seq.get())->elements ); + reinterpret_cast(reinterpret_cast(seq.get())->elements) ); jni.ensure_no_exception(); break; case typelib_TypeClass_BOOLEAN: seq.reset( seq_allocate( nElements, sizeof (sal_Bool) ) ); jni->GetBooleanArrayRegion( static_cast(java_data.l), 0, nElements, - (jboolean *) ((uno_Sequence *) seq.get())->elements ); + reinterpret_cast(reinterpret_cast(seq.get())->elements) ); jni.ensure_no_exception(); break; case typelib_TypeClass_BYTE: seq.reset( seq_allocate( nElements, sizeof (sal_Int8) ) ); jni->GetByteArrayRegion( static_cast(java_data.l), 0, nElements, - (jbyte *) ((uno_Sequence *) seq.get())->elements ); + reinterpret_cast(reinterpret_cast(seq.get())->elements) ); jni.ensure_no_exception(); break; case typelib_TypeClass_SHORT: @@ -1001,7 +998,7 @@ void Bridge::map_to_uno( seq.reset( seq_allocate( nElements, sizeof (sal_Int16) ) ); jni->GetShortArrayRegion( static_cast(java_data.l), 0, nElements, - (jshort *) ((uno_Sequence *) seq.get())->elements ); + reinterpret_cast(reinterpret_cast(seq.get())->elements) ); jni.ensure_no_exception(); break; case typelib_TypeClass_LONG: @@ -1009,7 +1006,7 @@ void Bridge::map_to_uno( seq.reset( seq_allocate( nElements, sizeof (sal_Int32) ) ); jni->GetIntArrayRegion( static_cast(java_data.l), 0, nElements, - (jint *) ((uno_Sequence *) seq.get())->elements ); + reinterpret_cast(reinterpret_cast(seq.get())->elements) ); jni.ensure_no_exception(); break; case typelib_TypeClass_HYPER: @@ -1017,21 +1014,21 @@ void Bridge::map_to_uno( seq.reset( seq_allocate( nElements, sizeof (sal_Int64) ) ); jni->GetLongArrayRegion( static_cast(java_data.l), 0, nElements, - (jlong *) ((uno_Sequence *) seq.get())->elements ); + reinterpret_cast(reinterpret_cast(seq.get())->elements) ); jni.ensure_no_exception(); break; case typelib_TypeClass_FLOAT: seq.reset( seq_allocate( nElements, sizeof (float) ) ); jni->GetFloatArrayRegion( static_cast(java_data.l), 0, nElements, - (jfloat *)((uno_Sequence *)seq.get())->elements ); + reinterpret_cast(reinterpret_cast(seq.get())->elements) ); jni.ensure_no_exception(); break; case typelib_TypeClass_DOUBLE: seq.reset( seq_allocate( nElements, sizeof (double) ) ); jni->GetDoubleArrayRegion( static_cast(java_data.l), 0, nElements, - (jdouble *) ((uno_Sequence *) seq.get())->elements ); + reinterpret_cast(reinterpret_cast(seq.get())->elements) ); jni.ensure_no_exception(); break; case typelib_TypeClass_STRING: @@ -1070,7 +1067,7 @@ void Bridge::map_to_uno( jvalue val; val.l = jo.get(); void * p = - ((uno_Sequence *)seq.get())->elements + + reinterpret_cast(seq.get())->elements + (nPos * element_td.get()->nSize); map_to_uno( jni, p, val, element_td.get()->pWeakRef, element_info, @@ -1083,7 +1080,7 @@ void Bridge::map_to_uno( nCleanPos < nPos; ++nCleanPos ) { void * p = - ((uno_Sequence *)seq.get())->elements + + reinterpret_cast(seq.get())->elements + (nCleanPos * element_td.get()->nSize); uno_destructData( p, element_td.get(), 0 ); } @@ -1104,7 +1101,7 @@ void Bridge::map_to_uno( if (assign) uno_destructData( uno_data, td.get(), 0 ); - *(uno_Sequence **)uno_data = (uno_Sequence *)seq.release(); + *(uno_Sequence **)uno_data = reinterpret_cast(seq.release()); break; } case typelib_TypeClass_INTERFACE: @@ -1639,7 +1636,7 @@ void Bridge::map_to_java( // determine inner element type ::com::sun::star::uno::Type element_type( - ((typelib_IndirectTypeDescription *)seq_td.get())->pType ); + reinterpret_cast(seq_td.get())->pType ); while (typelib_TypeClass_SEQUENCE == element_type.getTypeLibType()->eTypeClass) { @@ -1647,7 +1644,7 @@ void Bridge::map_to_java( typelib_typedescriptionreference_assign( reinterpret_cast< typelib_TypeDescriptionReference ** >( &element_type ), - ((typelib_IndirectTypeDescription *)element_td.get()) + reinterpret_cast(element_td.get()) ->pType ); } // box up only if unsigned element type @@ -1855,7 +1852,7 @@ void Bridge::map_to_java( linfo->m_base ) ) { typelib_CompoundTypeDescription * comp_td = - (typelib_CompoundTypeDescription *)linfo->m_td.get(); + reinterpret_cast(linfo->m_td.get()); typelib_TypeDescriptionReference ** ppMemberTypeRefs = comp_td->ppTypeRefs; sal_Int32 * pMemberOffsets = comp_td->pMemberOffsets; @@ -2098,7 +2095,7 @@ void Bridge::map_to_java( TypeDescr td( type ); typelib_TypeDescriptionReference * element_type = - ((typelib_IndirectTypeDescription *)td.get())->pType; + reinterpret_cast(td.get())->pType; switch (element_type->eTypeClass) { @@ -2109,7 +2106,7 @@ void Bridge::map_to_java( { jni->SetCharArrayRegion( static_cast(jo_ar.get()), - 0, nElements, (jchar *) seq->elements ); + 0, nElements, reinterpret_cast(seq->elements) ); jni.ensure_no_exception(); } break; @@ -2120,7 +2117,7 @@ void Bridge::map_to_java( { jni->SetBooleanArrayRegion( static_cast(jo_ar.get()), - 0, nElements, (jboolean *) seq->elements ); + 0, nElements, reinterpret_cast(seq->elements) ); jni.ensure_no_exception(); } break; @@ -2131,7 +2128,7 @@ void Bridge::map_to_java( { jni->SetByteArrayRegion( static_cast(jo_ar.get()), - 0, nElements, (jbyte *) seq->elements ); + 0, nElements, reinterpret_cast(seq->elements) ); jni.ensure_no_exception(); } break; @@ -2143,7 +2140,7 @@ void Bridge::map_to_java( { jni->SetShortArrayRegion( static_cast(jo_ar.get()), - 0, nElements, (jshort *) seq->elements ); + 0, nElements, reinterpret_cast(seq->elements) ); jni.ensure_no_exception(); } break; @@ -2155,7 +2152,7 @@ void Bridge::map_to_java( { jni->SetIntArrayRegion( static_cast(jo_ar.get()), - 0, nElements, (jint *) seq->elements ); + 0, nElements, reinterpret_cast(seq->elements) ); jni.ensure_no_exception(); } break; @@ -2167,7 +2164,7 @@ void Bridge::map_to_java( { jni->SetLongArrayRegion( static_cast(jo_ar.get()), - 0, nElements, (jlong *) seq->elements ); + 0, nElements, reinterpret_cast(seq->elements) ); jni.ensure_no_exception(); } break; @@ -2178,7 +2175,7 @@ void Bridge::map_to_java( { jni->SetFloatArrayRegion( static_cast(jo_ar.get()), - 0, nElements, (jfloat *) seq->elements ); + 0, nElements, reinterpret_cast(seq->elements) ); jni.ensure_no_exception(); } break; @@ -2189,7 +2186,7 @@ void Bridge::map_to_java( { jni->SetDoubleArrayRegion( static_cast(jo_ar.get()), - 0, nElements, (jdouble *) seq->elements ); + 0, nElements, reinterpret_cast(seq->elements) ); jni.ensure_no_exception(); } break; @@ -2201,7 +2198,7 @@ void Bridge::map_to_java( if (in_param) { rtl_uString * const * pp = - (rtl_uString * const *) seq->elements; + reinterpret_cast(seq->elements); for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) { JLocalAutoRef jo_string( @@ -2219,7 +2216,7 @@ void Bridge::map_to_java( if (in_param) { typelib_TypeDescriptionReference * const * pp = - (typelib_TypeDescriptionReference * const *)seq->elements; + reinterpret_cast(seq->elements); for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) { jvalue val; @@ -2240,7 +2237,7 @@ void Bridge::map_to_java( jni.ensure_no_exception(); if (in_param) { - uno_Any const * p = (uno_Any const *)seq->elements; + uno_Any const * p = reinterpret_cast(seq->elements); for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) { jvalue val; @@ -2282,7 +2279,7 @@ void Bridge::map_to_java( jni.ensure_no_exception(); assert( 0 != method_id ); - sal_Int32 const * p = (sal_Int32 const *)seq->elements; + sal_Int32 const * p = reinterpret_cast(seq->elements); for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) { jvalue arg; @@ -2345,7 +2342,7 @@ void Bridge::map_to_java( if (0 < nElements) { TypeDescr element_td( element_type ); - uno_Sequence ** elements = (uno_Sequence **) seq->elements; + uno_Sequence * const * elements = reinterpret_cast(seq->elements); for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) { jvalue java_data2; @@ -2372,7 +2369,7 @@ void Bridge::map_to_java( if (0 < nElements) { - uno_Interface ** pp = (uno_Interface **)seq->elements; + uno_Interface * const * pp = reinterpret_cast(seq->elements); for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) { uno_Interface * pUnoI = pp[ nPos ]; diff --git a/bridges/source/jni_uno/jni_helper.h b/bridges/source/jni_uno/jni_helper.h index 1c67992e23f1..e466e5a3d8f1 100644 --- a/bridges/source/jni_uno/jni_helper.h +++ b/bridges/source/jni_uno/jni_helper.h @@ -44,7 +44,7 @@ inline void jstring_to_ustring( std::unique_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (rtl_uString) + (len * sizeof (sal_Unicode)) ) ); - rtl_uString * ustr = (rtl_uString *)mem.get(); + rtl_uString * ustr = reinterpret_cast(mem.get()); jni->GetStringRegion( jstr, 0, len, (jchar *) ustr->buffer ); jni.ensure_no_exception(); ustr->refCount = 1; diff --git a/bridges/source/jni_uno/jni_info.cxx b/bridges/source/jni_uno/jni_info.cxx index 6db961caffc6..13b8c6b84fb5 100644 --- a/bridges/source/jni_uno/jni_info.cxx +++ b/bridges/source/jni_uno/jni_info.cxx @@ -243,7 +243,7 @@ JNI_compound_type_info::JNI_compound_type_info( reinterpret_cast< typelib_CompoundTypeDescription * >( m_td.get() ); OUString const & uno_name = - OUString::unacquired( &((typelib_TypeDescription *)td)->pTypeName ); + OUString::unacquired( &td->aBase.pTypeName ); // Erase type arguments of instantiated polymorphic struct types: OUString nucleus; @@ -284,10 +284,10 @@ JNI_compound_type_info::JNI_compound_type_info( try { if (type_equals( - ((typelib_TypeDescription *)td)->pWeakRef, + td->aBase.pWeakRef, jni_info->m_Exception_type.getTypeLibType() ) || type_equals( - ((typelib_TypeDescription *)td)->pWeakRef, + td->aBase.pWeakRef, jni_info->m_RuntimeException_type.getTypeLibType() )) { // coverity [ctor_dtor_leak] diff --git a/bridges/source/jni_uno/jni_info.h b/bridges/source/jni_uno/jni_info.h index e38c4b3db0b0..6849dd1b2bdf 100644 --- a/bridges/source/jni_uno/jni_info.h +++ b/bridges/source/jni_uno/jni_info.h @@ -322,7 +322,7 @@ inline void JNI_info::append_sig( buf->append( '[' ); TypeDescr td( type ); append_sig( - buf, ((typelib_IndirectTypeDescription *)td.get())->pType, + buf, reinterpret_cast(td.get())->pType, use_Object_for_type_XInterface, use_slashes ); break; } diff --git a/bridges/source/jni_uno/jni_java2uno.cxx b/bridges/source/jni_uno/jni_java2uno.cxx index a3887f772443..b827a1e07b6a 100644 --- a/bridges/source/jni_uno/jni_java2uno.cxx +++ b/bridges/source/jni_uno/jni_java2uno.cxx @@ -56,7 +56,7 @@ jobject Bridge::map_to_java( // register uno interface (*m_uno_env->registerInterface)( m_uno_env, reinterpret_cast< void ** >( &pUnoI ), - oid.pData, (typelib_InterfaceTypeDescription *)info->m_td.get() ); + oid.pData, reinterpret_cast(info->m_td.get()) ); // create java and register java proxy jvalue args2[ 8 ]; @@ -188,7 +188,7 @@ jobject Bridge::call_uno( return_size + (nParams * sizeof (largest)) ); void ** uno_args = (void **) mem; void * uno_ret = return_size == 0 ? 0 : (mem + (nParams * sizeof (void *))); - largest * uno_args_mem = (largest *) + largest * uno_args_mem = reinterpret_cast (mem + (nParams * sizeof (void *)) + return_size); assert( (0 == nParams) || (nParams == jni->GetArrayLength( jo_args )) ); @@ -581,7 +581,7 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call( // the thing that should not be... no method info found! throw BridgeRuntimeError( "calling undeclared function on interface " - + OUString::unacquired(&((typelib_TypeDescription *)td)->pTypeName) + + OUString::unacquired(&td->aBase.pTypeName) + ": " + method_name + jni.get_stack_trace() ); } catch (const BridgeRuntimeError & err) diff --git a/bridges/source/jni_uno/jni_uno2java.cxx b/bridges/source/jni_uno/jni_uno2java.cxx index 29ef813367da..c36e8a12e9b8 100644 --- a/bridges/source/jni_uno/jni_uno2java.cxx +++ b/bridges/source/jni_uno/jni_uno2java.cxx @@ -462,8 +462,8 @@ inline void UNO_proxy::acquire() const (*m_bridge->m_uno_env->registerProxyInterface)( m_bridge->m_uno_env, &that, UNO_proxy_free, m_oid.pData, - (typelib_InterfaceTypeDescription *)m_type_info->m_td.get() ); - assert( this == (void const * const)that ); + reinterpret_cast(m_type_info->m_td.get()) ); + assert( this == that ); } } @@ -490,7 +490,7 @@ uno_Interface * Bridge::map_to_uno( uno_Interface * pUnoI = 0; (*m_uno_env->getRegisteredInterface)( m_uno_env, (void **)&pUnoI, - oid.pData, (typelib_InterfaceTypeDescription *)info->m_td.get() ); + oid.pData, reinterpret_cast(info->m_td.get()) ); if (0 == pUnoI) // no existing interface, register new proxy { @@ -502,7 +502,7 @@ uno_Interface * Bridge::map_to_uno( (*m_uno_env->registerProxyInterface)( m_uno_env, (void **)&pUnoI, UNO_proxy_free, - oid.pData, (typelib_InterfaceTypeDescription *)info->m_td.get() ); + oid.pData, reinterpret_cast(info->m_td.get()) ); } return pUnoI; } @@ -520,7 +520,7 @@ extern "C" void SAL_CALL UNO_proxy_free( uno_ExtEnvironment * env, void * proxy ) SAL_THROW_EXTERN_C() { - UNO_proxy const * that = reinterpret_cast< UNO_proxy const * >( proxy ); + UNO_proxy * that = reinterpret_cast< UNO_proxy * >( proxy ); Bridge const * bridge = that->m_bridge; assert(env == bridge->m_uno_env); (void) env; @@ -549,7 +549,7 @@ void SAL_CALL UNO_proxy_free( uno_ExtEnvironment * env, void * proxy ) bridge->release(); #if OSL_DEBUG_LEVEL > 0 - *(int *)that = 0xdeadcafe; + *reinterpret_cast(that) = 0xdeadcafe; #endif delete that; } @@ -668,7 +668,7 @@ void SAL_CALL UNO_proxy_dispatch( (*bridge->m_uno_env->getRegisteredInterface)( bridge->m_uno_env, (void **) &pInterface, that->m_oid.pData, - (typelib_InterfaceTypeDescription *)demanded_td.get() ); + reinterpret_cast(demanded_td.get()) ); if (0 == pInterface) { -- cgit