Clean up string concatenation

Change-Id: I83515f8907b000eb0506410e9b04f28f4257a3b8
This commit is contained in:
Stephan Bergmann
2013-12-03 15:59:00 +01:00
parent 214c379958
commit 86268546a0
4 changed files with 77 additions and 133 deletions

View File

@@ -24,7 +24,6 @@
#include "jni_bridge.h" #include "jni_bridge.h"
#include "rtl/strbuf.hxx" #include "rtl/strbuf.hxx"
#include "rtl/ustrbuf.hxx"
#include "uno/sequence2.h" #include "uno/sequence2.h"
@@ -388,12 +387,9 @@ void Bridge::map_to_uno(
} }
if (0 == java_data.l) if (0 == java_data.l)
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] null-ref given!" + jni.get_stack_trace() );
buf.append( "] null-ref given!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
if (! assign) if (! assign)
*(rtl_uString **)uno_data = 0; *(rtl_uString **)uno_data = 0;
@@ -413,12 +409,9 @@ void Bridge::map_to_uno(
} }
if (0 == java_data.l) if (0 == java_data.l)
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] null-ref given!" + jni.get_stack_trace() );
buf.append( "] null-ref given!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
// type name // type name
@@ -427,26 +420,20 @@ void Bridge::map_to_uno(
java_data.l, m_jni_info->m_field_Type__typeName ) ); java_data.l, m_jni_info->m_field_Type__typeName ) );
if (! jo_type_name.is()) if (! jo_type_name.is())
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] incomplete type object: no type name!"
buf.append("] incomplete type object: " + jni.get_stack_trace() );
"no type name!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
OUString type_name( OUString type_name(
jstring_to_oustring( jni, (jstring) jo_type_name.get() ) ); jstring_to_oustring( jni, (jstring) jo_type_name.get() ) );
::com::sun::star::uno::TypeDescription td( type_name ); ::com::sun::star::uno::TypeDescription td( type_name );
if (! td.is()) if (! td.is())
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] UNO type not found: " + type_name
buf.append( "] UNO type not found: " ); + jni.get_stack_trace() );
buf.append( type_name );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
typelib_typedescriptionreference_acquire( td.get()->pWeakRef ); typelib_typedescriptionreference_acquire( td.get()->pWeakRef );
if (assign) if (assign)
@@ -489,12 +476,10 @@ void Bridge::map_to_uno(
java_data.l, m_jni_info->m_field_Any__type ) ); java_data.l, m_jni_info->m_field_Any__type ) );
if (! jo_type.is()) if (! jo_type.is())
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] no type set at com.sun.star.uno.Any!"
buf.append( "] no type set at " "com.sun.star.uno.Any!" ); + jni.get_stack_trace() );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
// wrapped value // wrapped value
jo_wrapped_holder.reset( jo_wrapped_holder.reset(
@@ -520,13 +505,10 @@ void Bridge::map_to_uno(
::com::sun::star::uno::TypeDescription value_td( type_name ); ::com::sun::star::uno::TypeDescription value_td( type_name );
if (! value_td.is()) if (! value_td.is())
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] UNO type not found: " + type_name
buf.append( "] UNO type not found: " ); + jni.get_stack_trace() );
buf.append( type_name );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
typelib_TypeClass type_class = value_td.get()->eTypeClass; typelib_TypeClass type_class = value_td.get()->eTypeClass;
@@ -671,12 +653,10 @@ void Bridge::map_to_uno(
} }
default: default:
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + type_name
buf.append( type_name ); + "] unsupported value type of any!"
buf.append( "] unsupported value type " "of any!" ); + jni.get_stack_trace() );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
} }
} }
@@ -705,12 +685,9 @@ void Bridge::map_to_uno(
} }
if (0 == java_data.l) if (0 == java_data.l)
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] null-ref given!" + jni.get_stack_trace() );
buf.append( "] null-ref given!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
*(jint *) uno_data = jni->GetIntField( *(jint *) uno_data = jni->GetIntField(
@@ -730,12 +707,9 @@ void Bridge::map_to_uno(
} }
if (0 == java_data.l) if (0 == java_data.l)
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] null-ref given!" + jni.get_stack_trace() );
buf.append( "] null-ref given!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
if (0 == info) if (0 == info)
@@ -1002,12 +976,9 @@ void Bridge::map_to_uno(
} }
if (0 == java_data.l) if (0 == java_data.l)
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] null-ref given!" + jni.get_stack_trace() );
buf.append( "] null-ref given!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
TypeDescr td( type ); TypeDescr td( type );
@@ -1140,13 +1111,11 @@ void Bridge::map_to_uno(
} }
default: default:
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] unsupported sequence element type: "
buf.append( "] unsupported sequence element" " type: " ); + OUString::unacquired( &element_type->pTypeName )
buf.append( OUString::unacquired( &element_type->pTypeName ) ); + jni.get_stack_trace() );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
} }
@@ -1195,12 +1164,9 @@ void Bridge::map_to_uno(
} }
default: default:
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_uno():" ); "[map_to_uno():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] unsupported type!" + jni.get_stack_trace() );
buf.append( "] unsupported type!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
} }
} }
@@ -2443,13 +2409,11 @@ void Bridge::map_to_java(
} }
default: default:
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_java():" ); "[map_to_java():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] unsupported element type: "
buf.append( "] unsupported element type: " ); + OUString::unacquired( &element_type->pTypeName )
buf.append( OUString::unacquired( &element_type->pTypeName ) ); + jni.get_stack_trace() );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
} }
@@ -2524,12 +2488,9 @@ void Bridge::map_to_java(
} }
default: default:
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "[map_to_java():" ); "[map_to_java():" + OUString::unacquired( &type->pTypeName )
buf.append( OUString::unacquired( &type->pTypeName ) ); + "] unsupported type!" + jni.get_stack_trace() );
buf.appendAscii( "] unsupported type!" );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
} }
} }

View File

@@ -49,11 +49,10 @@ JNI_type_info::JNI_type_info(
m_td.makeComplete(); m_td.makeComplete();
if (! m_td.get()->bComplete) if (! m_td.get()->bComplete)
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "cannot make type complete: " ); "cannot make type complete: "
buf.append( OUString::unacquired( &m_td.get()->pTypeName ) ); + OUString::unacquired( &m_td.get()->pTypeName )
buf.append( jni.get_stack_trace() ); + jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
} }
@@ -366,11 +365,8 @@ JNI_type_info const * JNI_info::create_type_info(
} }
default: default:
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "type info not supported for " ); "type info not supported for " + uno_name + jni.get_stack_trace() );
buf.append( uno_name );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
} }
@@ -465,11 +461,8 @@ JNI_type_info const * JNI_info::get_type_info(
css::uno::TypeDescription td( uno_name ); css::uno::TypeDescription td( uno_name );
if (! td.is()) if (! td.is())
{ {
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "UNO type not found: " ); "UNO type not found: " + uno_name + jni.get_stack_trace() );
buf.append( uno_name );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
info = create_type_info( jni, td.get() ); info = create_type_info( jni, td.get() );
} }

View File

@@ -19,16 +19,13 @@
#include <sal/config.h> #include <sal/config.h>
#include <algorithm>
#include <cassert> #include <cassert>
#include <sal/alloca.h> #include <sal/alloca.h>
#include "jni_bridge.h" #include "jni_bridge.h"
#include <rtl/ustrbuf.hxx>
#include <algorithm>
using namespace ::rtl; using namespace ::rtl;
namespace jni_uno namespace jni_uno
@@ -125,11 +122,10 @@ void Bridge::handle_uno_exc( JNI_context const & jni, uno_Any * uno_exc ) const
jni, jni->CallObjectMethodA( jni, jni->CallObjectMethodA(
jo_exc.get(), m_jni_info->m_method_Object_toString, 0 ) ); jo_exc.get(), m_jni_info->m_method_Object_toString, 0 ) );
jni.ensure_no_exception(); jni.ensure_no_exception();
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "throwing java exception failed: " ); "throwing java exception failed: "
buf.append( jstring_to_oustring( jni, (jstring) jo_descr.get() ) ); + jstring_to_oustring( jni, (jstring) jo_descr.get() )
buf.append( jni.get_stack_trace() ); + jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
} }
else else
@@ -579,14 +575,10 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call(
} }
} }
// the thing that should not be... no method info found! // the thing that should not be... no method info found!
OUStringBuffer buf( 64 ); throw BridgeRuntimeError(
buf.append( "calling undeclared function on interface " ); "calling undeclared function on interface "
buf.append( OUString::unacquired( + OUString::unacquired(&((typelib_TypeDescription *)td)->pTypeName)
&((typelib_TypeDescription *)td)->pTypeName ) ); + ": " + method_name + jni.get_stack_trace() );
buf.append( ": " );
buf.append( method_name );
buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
catch (const BridgeRuntimeError & err) catch (const BridgeRuntimeError & err)
{ {

View File

@@ -90,11 +90,10 @@ void Bridge::handle_java_exc(
jni, jni->CallObjectMethodA( jni, jni->CallObjectMethodA(
jo_exc.get(), m_jni_info->m_method_Object_toString, 0 ) ); jo_exc.get(), m_jni_info->m_method_Object_toString, 0 ) );
jni.ensure_no_exception(); jni.ensure_no_exception();
OUStringBuffer buf( 128 ); throw BridgeRuntimeError(
buf.append( "non-UNO exception occurred: " ); "non-UNO exception occurred: "
buf.append( jstring_to_oustring( jni, (jstring) jo_descr.get() ) ); + jstring_to_oustring( jni, (jstring) jo_descr.get() )
buf.append( jni.get_stack_trace( jo_exc.get() ) ); + jni.get_stack_trace( jo_exc.get() ) );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
SAL_WNODEPRECATED_DECLARATIONS_PUSH SAL_WNODEPRECATED_DECLARATIONS_PUSH
@@ -144,11 +143,10 @@ void Bridge::call_java(
reinterpret_cast<typelib_TypeDescription *>(iface_td) ); reinterpret_cast<typelib_TypeDescription *>(iface_td) );
iface_holder.makeComplete(); iface_holder.makeComplete();
if (! iface_holder.get()->bComplete) { if (! iface_holder.get()->bComplete) {
OUStringBuffer buf; throw BridgeRuntimeError(
buf.append( "cannot make type complete: " ); "cannot make type complete: "
buf.append( OUString::unacquired(&iface_holder.get()->pTypeName) ); + OUString::unacquired(&iface_holder.get()->pTypeName)
buf.append( jni.get_stack_trace() ); + jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
iface_td = reinterpret_cast<typelib_InterfaceTypeDescription *>( iface_td = reinterpret_cast<typelib_InterfaceTypeDescription *>(
iface_holder.get() ); iface_holder.get() );