Kaydet (Commit) 25fb4426 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

loplugin:cstylecast: bridges

Change-Id: I7c41b90c9af045fd452ee62ed0c5d9b261236855
üst 7b1261f6
...@@ -68,7 +68,7 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod( ...@@ -68,7 +68,7 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
// Get pointer to method // Get pointer to method
sal_uInt64 pMethod = *((sal_uInt64 *)pThis); sal_uInt64 pMethod = *((sal_uInt64 *)pThis);
pMethod += 8 * nVtableIndex; pMethod += 8 * nVtableIndex;
data.pMethod = *((sal_uInt64 *)pMethod); data.pMethod = *reinterpret_cast<sal_uInt64 *>(pMethod);
// Load parameters to stack, if necessary // Load parameters to stack, if necessary
sal_uInt64* pCallStack = NULL; sal_uInt64* pCallStack = NULL;
......
...@@ -132,7 +132,7 @@ std::type_info * RTTI::getRTTI(typelib_TypeDescription const & pTypeDescr) ...@@ -132,7 +132,7 @@ std::type_info * RTTI::getRTTI(typelib_TypeDescription const & pTypeDescr)
std::type_info * base_rtti = getRTTI( std::type_info * base_rtti = getRTTI(
ctd.pBaseTypeDescription->aBase); ctd.pBaseTypeDescription->aBase);
rtti = new __cxxabiv1::__si_class_type_info( rtti = new __cxxabiv1::__si_class_type_info(
strdup( rttiName ), (__cxxabiv1::__class_type_info *)base_rtti ); strdup( rttiName ), static_cast<__cxxabiv1::__class_type_info *>(base_rtti) );
} }
else else
{ {
......
...@@ -298,7 +298,7 @@ void JNI_context::java_exc_occurred() const ...@@ -298,7 +298,7 @@ void JNI_context::java_exc_occurred() const
JLocalAutoRef jo_Object( *this, jo_class ); JLocalAutoRef jo_Object( *this, jo_class );
// method Object.toString() // method Object.toString()
jmethodID method_Object_toString = m_env->GetMethodID( jmethodID method_Object_toString = m_env->GetMethodID(
(jclass) jo_Object.get(), "toString", "()Ljava/lang/String;" ); static_cast<jclass>(jo_Object.get()), "toString", "()Ljava/lang/String;" );
if (JNI_FALSE != m_env->ExceptionCheck()) if (JNI_FALSE != m_env->ExceptionCheck())
{ {
m_env->ExceptionClear(); m_env->ExceptionClear();
...@@ -319,12 +319,12 @@ void JNI_context::java_exc_occurred() const ...@@ -319,12 +319,12 @@ void JNI_context::java_exc_occurred() const
get_stack_trace() ); get_stack_trace() );
} }
jsize len = m_env->GetStringLength( (jstring) jo_descr.get() ); jsize len = m_env->GetStringLength( static_cast<jstring>(jo_descr.get()) );
std::unique_ptr< rtl_mem > ustr_mem( std::unique_ptr< rtl_mem > ustr_mem(
rtl_mem::allocate( rtl_mem::allocate(
sizeof (rtl_uString) + (len * sizeof (sal_Unicode)) ) ); sizeof (rtl_uString) + (len * sizeof (sal_Unicode)) ) );
rtl_uString * ustr = (rtl_uString *)ustr_mem.get(); rtl_uString * ustr = (rtl_uString *)ustr_mem.get();
m_env->GetStringRegion( (jstring) jo_descr.get(), 0, len, ustr->buffer ); m_env->GetStringRegion( static_cast<jstring>(jo_descr.get()), 0, len, ustr->buffer );
if (m_env->ExceptionCheck()) if (m_env->ExceptionCheck())
{ {
m_env->ExceptionClear(); m_env->ExceptionClear();
...@@ -383,7 +383,7 @@ OUString JNI_context::get_stack_trace( jobject jo_exc ) const ...@@ -383,7 +383,7 @@ OUString JNI_context::get_stack_trace( jobject jo_exc ) const
{ {
// static method JNI_proxy.get_stack_trace() // static method JNI_proxy.get_stack_trace()
jmethodID method = m_env->GetStaticMethodID( jmethodID method = m_env->GetStaticMethodID(
(jclass) jo_JNI_proxy.get(), "get_stack_trace", static_cast<jclass>(jo_JNI_proxy.get()), "get_stack_trace",
"(Ljava/lang/Throwable;)Ljava/lang/String;" ); "(Ljava/lang/Throwable;)Ljava/lang/String;" );
if (assert_no_exception() && (0 != method)) if (assert_no_exception() && (0 != method))
{ {
...@@ -391,17 +391,17 @@ OUString JNI_context::get_stack_trace( jobject jo_exc ) const ...@@ -391,17 +391,17 @@ OUString JNI_context::get_stack_trace( jobject jo_exc ) const
arg.l = jo_exc; arg.l = jo_exc;
JLocalAutoRef jo_stack_trace( JLocalAutoRef jo_stack_trace(
*this, m_env->CallStaticObjectMethodA( *this, m_env->CallStaticObjectMethodA(
(jclass) jo_JNI_proxy.get(), method, &arg ) ); static_cast<jclass>(jo_JNI_proxy.get()), method, &arg ) );
if (assert_no_exception()) if (assert_no_exception())
{ {
jsize len = jsize len =
m_env->GetStringLength( (jstring) jo_stack_trace.get() ); m_env->GetStringLength( static_cast<jstring>(jo_stack_trace.get()) );
std::unique_ptr< rtl_mem > ustr_mem( std::unique_ptr< rtl_mem > ustr_mem(
rtl_mem::allocate( rtl_mem::allocate(
sizeof (rtl_uString) + (len * sizeof (sal_Unicode)) ) ); sizeof (rtl_uString) + (len * sizeof (sal_Unicode)) ) );
rtl_uString * ustr = (rtl_uString *)ustr_mem.get(); rtl_uString * ustr = (rtl_uString *)ustr_mem.get();
m_env->GetStringRegion( m_env->GetStringRegion(
(jstring) jo_stack_trace.get(), 0, len, ustr->buffer ); static_cast<jstring>(jo_stack_trace.get()), 0, len, ustr->buffer );
if (assert_no_exception()) if (assert_no_exception())
{ {
ustr->refCount = 1; ustr->refCount = 1;
......
...@@ -119,7 +119,7 @@ void Bridge::handle_uno_exc( JNI_context const & jni, uno_Any * uno_exc ) const ...@@ -119,7 +119,7 @@ void Bridge::handle_uno_exc( JNI_context const & jni, uno_Any * uno_exc ) const
uno_any_destruct( uno_exc, 0 ); uno_any_destruct( uno_exc, 0 );
JLocalAutoRef jo_exc( jni, java_exc.l ); JLocalAutoRef jo_exc( jni, java_exc.l );
jint res = jni->Throw( (jthrowable) jo_exc.get() ); jint res = jni->Throw( static_cast<jthrowable>(jo_exc.get()) );
if (0 != res) if (0 != res)
{ {
// call toString() // call toString()
...@@ -129,7 +129,7 @@ void Bridge::handle_uno_exc( JNI_context const & jni, uno_Any * uno_exc ) const ...@@ -129,7 +129,7 @@ void Bridge::handle_uno_exc( JNI_context const & jni, uno_Any * uno_exc ) const
jni.ensure_no_exception(); jni.ensure_no_exception();
throw BridgeRuntimeError( throw BridgeRuntimeError(
"throwing java exception failed: " "throwing java exception failed: "
+ jstring_to_oustring( jni, (jstring) jo_descr.get() ) + jstring_to_oustring( jni, static_cast<jstring>(jo_descr.get()) )
+ jni.get_stack_trace() ); + jni.get_stack_trace() );
} }
} }
...@@ -421,7 +421,7 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call( ...@@ -421,7 +421,7 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call(
jni.get_stack_trace() ); jni.get_stack_trace() );
} }
OUString type_name( OUString type_name(
jstring_to_oustring( jni, (jstring) jo_type_name.get() ) ); jstring_to_oustring( jni, static_cast<jstring>(jo_type_name.get()) ) );
JNI_type_info const * info = JNI_type_info const * info =
jni_info->get_type_info( jni, type_name ); jni_info->get_type_info( jni, type_name );
if (typelib_TypeClass_INTERFACE != info->m_td.get()->eTypeClass) if (typelib_TypeClass_INTERFACE != info->m_td.get()->eTypeClass)
......
...@@ -78,7 +78,7 @@ void Bridge::handle_java_exc( ...@@ -78,7 +78,7 @@ void Bridge::handle_java_exc(
jo_class.get(), getJniInfo()->m_method_Class_getName, 0 ) ); jo_class.get(), getJniInfo()->m_method_Class_getName, 0 ) );
jni.ensure_no_exception(); jni.ensure_no_exception();
OUString exc_name( OUString exc_name(
jstring_to_oustring( jni, (jstring) jo_class_name.get() ) ); jstring_to_oustring( jni, static_cast<jstring>(jo_class_name.get()) ) );
::com::sun::star::uno::TypeDescription td( exc_name.pData ); ::com::sun::star::uno::TypeDescription td( exc_name.pData );
if (!td.is() || (typelib_TypeClass_EXCEPTION != td.get()->eTypeClass)) if (!td.is() || (typelib_TypeClass_EXCEPTION != td.get()->eTypeClass))
...@@ -90,7 +90,7 @@ void Bridge::handle_java_exc( ...@@ -90,7 +90,7 @@ void Bridge::handle_java_exc(
jni.ensure_no_exception(); jni.ensure_no_exception();
throw BridgeRuntimeError( throw BridgeRuntimeError(
"non-UNO exception occurred: " "non-UNO exception occurred: "
+ jstring_to_oustring( jni, (jstring) jo_descr.get() ) + jstring_to_oustring( jni, static_cast<jstring>(jo_descr.get()) )
+ jni.get_stack_trace( jo_exc.get() ) ); + jni.get_stack_trace( jo_exc.get() ) );
} }
...@@ -221,20 +221,20 @@ void Bridge::call_java( ...@@ -221,20 +221,20 @@ void Bridge::call_java(
jni, jni->CallObjectMethodA( jni, jni->CallObjectMethodA(
jo_method.get(), getJniInfo()->m_method_Object_toString, 0 ) ); jo_method.get(), getJniInfo()->m_method_Object_toString, 0 ) );
jni.ensure_no_exception(); jni.ensure_no_exception();
trace_buf.append( jstring_to_oustring( jni, (jstring) jo_descr.get() ) ); trace_buf.append( jstring_to_oustring( jni, static_cast<jstring>(jo_descr.get()) ) );
trace_buf.append( " on " ); trace_buf.append( " on " );
jo_descr.reset( jo_descr.reset(
jni->CallObjectMethodA( jni->CallObjectMethodA(
javaI, getJniInfo()->m_method_Object_toString, 0 ) ); javaI, getJniInfo()->m_method_Object_toString, 0 ) );
jni.ensure_no_exception(); jni.ensure_no_exception();
trace_buf.append( jstring_to_oustring( jni, (jstring) jo_descr.get() ) ); trace_buf.append( jstring_to_oustring( jni, static_cast<jstring>(jo_descr.get()) ) );
trace_buf.append( " (" ); trace_buf.append( " (" );
JLocalAutoRef jo_class( jni, jni->GetObjectClass( javaI ) ); JLocalAutoRef jo_class( jni, jni->GetObjectClass( javaI ) );
jo_descr.reset( jo_descr.reset(
jni->CallObjectMethodA( jni->CallObjectMethodA(
jo_class.get(), getJniInfo()->m_method_Object_toString, 0 ) ); jo_class.get(), getJniInfo()->m_method_Object_toString, 0 ) );
jni.ensure_no_exception(); jni.ensure_no_exception();
trace_buf.append( jstring_to_oustring( jni, (jstring) jo_descr.get() ) ); trace_buf.append( jstring_to_oustring( jni, static_cast<jstring>(jo_descr.get()) ) );
trace_buf.append( ")" ); trace_buf.append( ")" );
SAL_INFO("bridges", trace_buf.makeStringAndClear()); SAL_INFO("bridges", trace_buf.makeStringAndClear());
#endif #endif
...@@ -441,7 +441,7 @@ inline UNO_proxy::UNO_proxy( ...@@ -441,7 +441,7 @@ inline UNO_proxy::UNO_proxy(
jni.ensure_no_exception(); jni.ensure_no_exception();
m_javaI = jni->NewGlobalRef( jo_iface ); m_javaI = jni->NewGlobalRef( jo_iface );
m_jo_oid = (jstring) jni->NewGlobalRef( jo_oid ); m_jo_oid = static_cast<jstring>(jni->NewGlobalRef( jo_oid ));
bridge->acquire(); bridge->acquire();
m_bridge = bridge; m_bridge = bridge;
...@@ -485,7 +485,7 @@ uno_Interface * Bridge::map_to_uno( ...@@ -485,7 +485,7 @@ uno_Interface * Bridge::map_to_uno(
jobject javaI, JNI_interface_type_info const * info ) const jobject javaI, JNI_interface_type_info const * info ) const
{ {
JLocalAutoRef jo_oid( jni, compute_oid( jni, javaI ) ); JLocalAutoRef jo_oid( jni, compute_oid( jni, javaI ) );
OUString oid( jstring_to_oustring( jni, (jstring) jo_oid.get() ) ); OUString oid( jstring_to_oustring( jni, static_cast<jstring>(jo_oid.get()) ) );
uno_Interface * pUnoI = 0; uno_Interface * pUnoI = 0;
(*m_uno_env->getRegisteredInterface)( (*m_uno_env->getRegisteredInterface)(
...@@ -497,7 +497,7 @@ uno_Interface * Bridge::map_to_uno( ...@@ -497,7 +497,7 @@ uno_Interface * Bridge::map_to_uno(
// refcount initially 1 // refcount initially 1
pUnoI = new UNO_proxy( pUnoI = new UNO_proxy(
jni, const_cast< Bridge * >( this ), jni, const_cast< Bridge * >( this ),
javaI, (jstring) jo_oid.get(), oid, info ); javaI, static_cast<jstring>(jo_oid.get()), oid, info );
(*m_uno_env->registerProxyInterface)( (*m_uno_env->registerProxyInterface)(
m_uno_env, (void **)&pUnoI, m_uno_env, (void **)&pUnoI,
......
...@@ -96,15 +96,11 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) { ...@@ -96,15 +96,11 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) {
if ( filename.endswith(".h") ) { if ( filename.endswith(".h") ) {
return true; return true;
} }
if ( compat::isInMainFile(compiler.getSourceManager(), spellingLocation) ) { if (!compat::isInMainFile(compiler.getSourceManager(), spellingLocation)
if (filename.startswith(SRCDIR "/bridges/")) { // I'm not messing with this code - far too dangerous && (filename == SRCDIR "/include/tools/solar.h"
return true; || filename.startswith(SRCDIR "/include/cppuhelper/")))
} {
} else { return true;
if (filename == SRCDIR "/include/tools/solar.h"
|| filename.startswith(SRCDIR "/include/cppuhelper/")) {
return true;
}
} }
report( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,
......
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