diff options
Diffstat (limited to 'bridges/source/jni_uno/jni_info.cxx')
-rw-r--r-- | bridges/source/jni_uno/jni_info.cxx | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/bridges/source/jni_uno/jni_info.cxx b/bridges/source/jni_uno/jni_info.cxx index 70839e168eb2..a1a837545530 100644 --- a/bridges/source/jni_uno/jni_info.cxx +++ b/bridges/source/jni_uno/jni_info.cxx @@ -21,21 +21,17 @@ #include <cassert> -#include "jni_bridge.h" +#include "jni_helper.h" #include <com/sun/star/uno/RuntimeException.hpp> #include <jvmaccess/unovirtualmachine.hxx> #include <rtl/string.hxx> #include <rtl/strbuf.hxx> -#include <rtl/ustrbuf.hxx> #include <uno/lbnames.h> -using namespace ::std; -using namespace ::osl; - namespace jni_uno { @@ -169,15 +165,11 @@ JNI_interface_type_info::JNI_interface_type_info( &attribute_td->aBase.pMemberName ); // getter - sig_buf.append( "()" ); - sig_buf.append( type_sig ); + sig_buf.append( "()" + type_sig ); OString method_signature( sig_buf.makeStringAndClear() ); - OUStringBuffer name_buf( 3 + member_name.getLength() ); - name_buf.append( "get" ); - name_buf.append( member_name ); OString method_name( OUStringToOString( - name_buf.makeStringAndClear(), + rtl::Concat2View("get" + member_name), RTL_TEXTENCODING_JAVA_UTF8 ) ); m_methods[ nMethodIndex ] = jni->GetMethodID( static_cast<jclass>(jo_class.get()), method_name.getStr(), @@ -188,16 +180,9 @@ JNI_interface_type_info::JNI_interface_type_info( if (! attribute_td->bReadOnly) { // setter - sig_buf.ensureCapacity( 64 ); - sig_buf.append( '(' ); - sig_buf.append( type_sig ); - sig_buf.append( ")V" ); - method_signature = sig_buf.makeStringAndClear(); - name_buf.ensureCapacity( 3 + member_name.getLength() ); - name_buf.append( "set" ); - name_buf.append( member_name ); + method_signature = "(" + type_sig + ")V"; method_name = OUStringToOString( - name_buf.makeStringAndClear(), + rtl::Concat2View("set" + member_name), RTL_TEXTENCODING_JAVA_UTF8 ); m_methods[ nMethodIndex ] = jni->GetMethodID( static_cast<jclass>(jo_class.get()), method_name.getStr(), @@ -243,12 +228,12 @@ JNI_compound_type_info::JNI_compound_type_info( OUString::unacquired( &td->aBase.pTypeName ); // Erase type arguments of instantiated polymorphic struct types: - OUString nucleus; + std::u16string_view nucleus; sal_Int32 i = uno_name.indexOf( '<' ); if ( i < 0 ) { nucleus = uno_name; } else { - nucleus = uno_name.copy( 0, i ); + nucleus = uno_name.subView( 0, i ); } JLocalAutoRef jo_class( jni, @@ -311,7 +296,7 @@ JNI_compound_type_info::JNI_compound_type_info( && reinterpret_cast< typelib_StructTypeDescription * >( td)->pParameterizedTypes[nPos]) { - sig = OString( "Ljava/lang/Object;" ); + sig = "Ljava/lang/Object;"_ostr; } else { OStringBuffer sig_buf( 32 ); JNI_info::append_sig( &sig_buf, td->ppTypeRefs[ nPos ] ); @@ -369,18 +354,18 @@ JNI_type_info const * JNI_info::create_type_info( // look up JNI_type_info * info; - ClearableMutexGuard guard( m_mutex ); + std::unique_lock guard( m_mutex ); JNI_type_info_holder & holder = m_type_map[ uno_name ]; if (holder.m_info == nullptr) // new insertion { holder.m_info = new_info; - guard.clear(); + guard.unlock(); info = new_info; } else // inserted in the meantime { info = holder.m_info; - guard.clear(); + guard.unlock(); new_info->destroy( jni.get_jni_env() ); } return info; @@ -397,12 +382,12 @@ JNI_type_info const * JNI_info::get_type_info( OUString const & uno_name = OUString::unacquired( &td->pTypeName ); JNI_type_info const * info; - ClearableMutexGuard guard( m_mutex ); + std::unique_lock guard( m_mutex ); t_str2type::const_iterator iFind( m_type_map.find( uno_name ) ); if (iFind == m_type_map.end()) { - guard.clear(); + guard.unlock(); info = create_type_info( jni, td ); } else @@ -424,11 +409,11 @@ JNI_type_info const * JNI_info::get_type_info( OUString const & uno_name = OUString::unacquired( &type->pTypeName ); JNI_type_info const * info; - ClearableMutexGuard guard( m_mutex ); + std::unique_lock guard( m_mutex ); t_str2type::const_iterator iFind( m_type_map.find( uno_name ) ); if (iFind == m_type_map.end()) { - guard.clear(); + guard.unlock(); TypeDescr td( type ); info = create_type_info( jni, td.get() ); } @@ -450,11 +435,11 @@ JNI_type_info const * JNI_info::get_type_info( } JNI_type_info const * info; - ClearableMutexGuard guard( m_mutex ); + std::unique_lock guard( m_mutex ); t_str2type::const_iterator iFind( m_type_map.find( uno_name ) ); if (iFind == m_type_map.end()) { - guard.clear(); + guard.unlock(); css::uno::TypeDescription td( uno_name ); if (! td.is()) { @@ -948,7 +933,7 @@ JNI_info const * JNI_info::get_jni_info( jni_env, static_cast< jobject >(uno_vm->getClassLoader()), jo_class, jo_forName ); - ClearableMutexGuard g( Mutex::getGlobalMutex() ); + osl::ClearableMutexGuard g( osl::Mutex::getGlobalMutex() ); jni_info = reinterpret_cast< JNI_info const * >( jni->GetStaticLongField( |