1*61dff127SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*61dff127SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*61dff127SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*61dff127SAndrew Rist * distributed with this work for additional information 6*61dff127SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*61dff127SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*61dff127SAndrew Rist * "License"); you may not use this file except in compliance 9*61dff127SAndrew Rist * with the License. You may obtain a copy of the License at 10*61dff127SAndrew Rist * 11*61dff127SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*61dff127SAndrew Rist * 13*61dff127SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*61dff127SAndrew Rist * software distributed under the License is distributed on an 15*61dff127SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*61dff127SAndrew Rist * KIND, either express or implied. See the License for the 17*61dff127SAndrew Rist * specific language governing permissions and limitations 18*61dff127SAndrew Rist * under the License. 19*61dff127SAndrew Rist * 20*61dff127SAndrew Rist *************************************************************/ 21*61dff127SAndrew Rist 22*61dff127SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_bridges.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "jni_bridge.h" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "rtl/strbuf.hxx" 30cdf0e10cSrcweir #include "rtl/ustrbuf.hxx" 31cdf0e10cSrcweir #include "uno/sequence2.h" 32cdf0e10cSrcweir 33cdf0e10cSrcweir 34cdf0e10cSrcweir using namespace ::std; 35cdf0e10cSrcweir using namespace ::rtl; 36cdf0e10cSrcweir 37cdf0e10cSrcweir namespace jni_uno 38cdf0e10cSrcweir { 39cdf0e10cSrcweir 40cdf0e10cSrcweir //------------------------------------------------------------------------------ 41cdf0e10cSrcweir inline rtl_mem * seq_allocate( sal_Int32 nElements, sal_Int32 nSize ) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir auto_ptr< rtl_mem > seq( 44cdf0e10cSrcweir rtl_mem::allocate( SAL_SEQUENCE_HEADER_SIZE + (nElements * nSize) ) ); 45cdf0e10cSrcweir uno_Sequence * p = (uno_Sequence *)seq.get(); 46cdf0e10cSrcweir p->nRefCount = 1; 47cdf0e10cSrcweir p->nElements = nElements; 48cdf0e10cSrcweir return seq.release(); 49cdf0e10cSrcweir } 50cdf0e10cSrcweir 51cdf0e10cSrcweir //______________________________________________________________________________ 52cdf0e10cSrcweir namespace { 53cdf0e10cSrcweir 54cdf0e10cSrcweir void createDefaultUnoValue( 55cdf0e10cSrcweir JNI_context const & jni, void * uno_data, 56cdf0e10cSrcweir typelib_TypeDescriptionReference * type, 57cdf0e10cSrcweir JNI_type_info const * info /* maybe 0 */, bool assign) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir switch (type->eTypeClass) { 60cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN: 61cdf0e10cSrcweir *static_cast< sal_Bool * >(uno_data) = false; 62cdf0e10cSrcweir break; 63cdf0e10cSrcweir 64cdf0e10cSrcweir case typelib_TypeClass_BYTE: 65cdf0e10cSrcweir *static_cast< sal_Int8 * >(uno_data) = 0; 66cdf0e10cSrcweir break; 67cdf0e10cSrcweir 68cdf0e10cSrcweir case typelib_TypeClass_SHORT: 69cdf0e10cSrcweir *static_cast< sal_Int16 * >(uno_data) = 0; 70cdf0e10cSrcweir break; 71cdf0e10cSrcweir 72cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 73cdf0e10cSrcweir *static_cast< sal_uInt16 * >(uno_data) = 0; 74cdf0e10cSrcweir break; 75cdf0e10cSrcweir 76cdf0e10cSrcweir case typelib_TypeClass_LONG: 77cdf0e10cSrcweir *static_cast< sal_Int32 * >(uno_data) = 0; 78cdf0e10cSrcweir break; 79cdf0e10cSrcweir 80cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 81cdf0e10cSrcweir *static_cast< sal_uInt32 * >(uno_data) = 0; 82cdf0e10cSrcweir break; 83cdf0e10cSrcweir 84cdf0e10cSrcweir case typelib_TypeClass_HYPER: 85cdf0e10cSrcweir *static_cast< sal_Int64 * >(uno_data) = 0; 86cdf0e10cSrcweir break; 87cdf0e10cSrcweir 88cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 89cdf0e10cSrcweir *static_cast< sal_uInt64 * >(uno_data) = 0; 90cdf0e10cSrcweir break; 91cdf0e10cSrcweir 92cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 93cdf0e10cSrcweir *static_cast< float * >(uno_data) = 0; 94cdf0e10cSrcweir break; 95cdf0e10cSrcweir 96cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 97cdf0e10cSrcweir *static_cast< double * >(uno_data) = 0; 98cdf0e10cSrcweir break; 99cdf0e10cSrcweir 100cdf0e10cSrcweir case typelib_TypeClass_CHAR: 101cdf0e10cSrcweir *static_cast< sal_Unicode * >(uno_data) = 0; 102cdf0e10cSrcweir break; 103cdf0e10cSrcweir 104cdf0e10cSrcweir case typelib_TypeClass_STRING: 105cdf0e10cSrcweir if (!assign) { 106cdf0e10cSrcweir *static_cast< rtl_uString ** >(uno_data) = 0; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir rtl_uString_new(static_cast< rtl_uString ** >(uno_data)); 109cdf0e10cSrcweir break; 110cdf0e10cSrcweir 111cdf0e10cSrcweir case typelib_TypeClass_TYPE: 112cdf0e10cSrcweir if (assign) { 113cdf0e10cSrcweir typelib_typedescriptionreference_release( 114cdf0e10cSrcweir *static_cast< typelib_TypeDescriptionReference ** >(uno_data)); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir *static_cast< typelib_TypeDescriptionReference ** >(uno_data) 117cdf0e10cSrcweir = *typelib_static_type_getByTypeClass(typelib_TypeClass_VOID); 118cdf0e10cSrcweir OSL_ASSERT( 119cdf0e10cSrcweir *static_cast< typelib_TypeDescriptionReference ** >(uno_data) != 0); 120cdf0e10cSrcweir typelib_typedescriptionreference_acquire( 121cdf0e10cSrcweir *static_cast< typelib_TypeDescriptionReference ** >(uno_data)); 122cdf0e10cSrcweir break; 123cdf0e10cSrcweir 124cdf0e10cSrcweir case typelib_TypeClass_ANY: 125cdf0e10cSrcweir if (assign) { 126cdf0e10cSrcweir uno_any_destruct(static_cast< uno_Any * >(uno_data), 0); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir uno_any_construct( 129cdf0e10cSrcweir static_cast< uno_Any * >(uno_data), 0, 130cdf0e10cSrcweir jni.get_info()->m_XInterface_type_info->m_td.get(), 0); 131cdf0e10cSrcweir break; 132cdf0e10cSrcweir 133cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 134cdf0e10cSrcweir { 135cdf0e10cSrcweir auto_ptr< rtl_mem > seq(seq_allocate(0, 0)); 136cdf0e10cSrcweir if (assign) { 137cdf0e10cSrcweir uno_type_destructData(uno_data, type, 0); 138cdf0e10cSrcweir } 139cdf0e10cSrcweir *static_cast< uno_Sequence ** >(uno_data) 140cdf0e10cSrcweir = reinterpret_cast< uno_Sequence * >(seq.release()); 141cdf0e10cSrcweir break; 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir case typelib_TypeClass_ENUM: 145cdf0e10cSrcweir { 146cdf0e10cSrcweir typelib_TypeDescription * td = 0; 147cdf0e10cSrcweir TYPELIB_DANGER_GET(&td, type); 148cdf0e10cSrcweir *static_cast< sal_Int32 * >(uno_data) 149cdf0e10cSrcweir = (reinterpret_cast< typelib_EnumTypeDescription * >(td)-> 150cdf0e10cSrcweir nDefaultEnumValue); 151cdf0e10cSrcweir TYPELIB_DANGER_RELEASE(td); 152cdf0e10cSrcweir break; 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 156cdf0e10cSrcweir { 157cdf0e10cSrcweir if (info == 0) { 158cdf0e10cSrcweir info = jni.get_info()->get_type_info(jni, type); 159cdf0e10cSrcweir } 160cdf0e10cSrcweir JNI_compound_type_info const * comp_info 161cdf0e10cSrcweir = static_cast< JNI_compound_type_info const * >(info); 162cdf0e10cSrcweir typelib_CompoundTypeDescription * comp_td 163cdf0e10cSrcweir = reinterpret_cast< typelib_CompoundTypeDescription * >( 164cdf0e10cSrcweir comp_info->m_td.get()); 165cdf0e10cSrcweir sal_Int32 nPos = 0; 166cdf0e10cSrcweir sal_Int32 nMembers = comp_td->nMembers; 167cdf0e10cSrcweir try { 168cdf0e10cSrcweir if (comp_td->pBaseTypeDescription != 0) { 169cdf0e10cSrcweir createDefaultUnoValue( 170cdf0e10cSrcweir jni, uno_data, 171cdf0e10cSrcweir comp_td->pBaseTypeDescription->aBase.pWeakRef, 172cdf0e10cSrcweir comp_info->m_base, assign); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir for (; nPos < nMembers; ++nPos) { 175cdf0e10cSrcweir createDefaultUnoValue( 176cdf0e10cSrcweir jni, 177cdf0e10cSrcweir (static_cast< char * >(uno_data) 178cdf0e10cSrcweir + comp_td->pMemberOffsets[nPos]), 179cdf0e10cSrcweir comp_td->ppTypeRefs[nPos], 0, assign); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir } catch (...) { 182cdf0e10cSrcweir if (!assign) { 183cdf0e10cSrcweir for (sal_Int32 i = 0; i < nPos; ++i) { 184cdf0e10cSrcweir uno_type_destructData( 185cdf0e10cSrcweir (static_cast< char * >(uno_data) 186cdf0e10cSrcweir + comp_td->pMemberOffsets[i]), 187cdf0e10cSrcweir comp_td->ppTypeRefs[i], 0); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir if (comp_td->pBaseTypeDescription != 0) { 190cdf0e10cSrcweir uno_destructData( 191cdf0e10cSrcweir uno_data, &comp_td->pBaseTypeDescription->aBase, 0); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir } 194cdf0e10cSrcweir throw; 195cdf0e10cSrcweir } 196cdf0e10cSrcweir } 197cdf0e10cSrcweir break; 198cdf0e10cSrcweir 199cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 200cdf0e10cSrcweir if (assign) { 201cdf0e10cSrcweir uno_Interface * p = *static_cast< uno_Interface ** >(uno_data); 202cdf0e10cSrcweir if (p != 0) { 203cdf0e10cSrcweir (*p->release)(p); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir } 206cdf0e10cSrcweir *static_cast< uno_Interface ** >(uno_data) = 0; 207cdf0e10cSrcweir break; 208cdf0e10cSrcweir 209cdf0e10cSrcweir default: 210cdf0e10cSrcweir OSL_ASSERT(false); 211cdf0e10cSrcweir break; 212cdf0e10cSrcweir } 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir void Bridge::map_to_uno( 218cdf0e10cSrcweir JNI_context const & jni, 219cdf0e10cSrcweir void * uno_data, jvalue java_data, 220cdf0e10cSrcweir typelib_TypeDescriptionReference * type, 221cdf0e10cSrcweir JNI_type_info const * info /* maybe 0 */, 222cdf0e10cSrcweir bool assign, bool out_param, 223cdf0e10cSrcweir bool special_wrapped_integral_types ) const 224cdf0e10cSrcweir { 225cdf0e10cSrcweir OSL_ASSERT( 226cdf0e10cSrcweir !out_param || 227cdf0e10cSrcweir (1 == jni->GetArrayLength( (jarray) java_data.l )) ); 228cdf0e10cSrcweir 229cdf0e10cSrcweir switch (type->eTypeClass) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir case typelib_TypeClass_CHAR: 232cdf0e10cSrcweir if (out_param) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir jni->GetCharArrayRegion( 235cdf0e10cSrcweir (jcharArray) java_data.l, 0, 1, (jchar *) uno_data ); 236cdf0e10cSrcweir jni.ensure_no_exception(); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir else if (special_wrapped_integral_types) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir *(jchar *) uno_data = jni->CallCharMethodA( 241cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Character_charValue, 0 ); 242cdf0e10cSrcweir jni.ensure_no_exception(); 243cdf0e10cSrcweir } 244cdf0e10cSrcweir else 245cdf0e10cSrcweir { 246cdf0e10cSrcweir *(jchar *) uno_data = java_data.c; 247cdf0e10cSrcweir } 248cdf0e10cSrcweir break; 249cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN: 250cdf0e10cSrcweir if (out_param) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir jni->GetBooleanArrayRegion( 253cdf0e10cSrcweir (jbooleanArray) java_data.l, 0, 1, (jboolean *) uno_data ); 254cdf0e10cSrcweir jni.ensure_no_exception(); 255cdf0e10cSrcweir } 256cdf0e10cSrcweir else if (special_wrapped_integral_types) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir *(jboolean *) uno_data = jni->CallBooleanMethodA( 259cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Boolean_booleanValue, 0 ); 260cdf0e10cSrcweir jni.ensure_no_exception(); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir else 263cdf0e10cSrcweir { 264cdf0e10cSrcweir *(jboolean *) uno_data = java_data.z; 265cdf0e10cSrcweir } 266cdf0e10cSrcweir break; 267cdf0e10cSrcweir case typelib_TypeClass_BYTE: 268cdf0e10cSrcweir if (out_param) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir jni->GetByteArrayRegion( 271cdf0e10cSrcweir (jbyteArray) java_data.l, 0, 1, (jbyte *) uno_data ); 272cdf0e10cSrcweir jni.ensure_no_exception(); 273cdf0e10cSrcweir } 274cdf0e10cSrcweir else if (special_wrapped_integral_types) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir *(jbyte *) uno_data = jni->CallByteMethodA( 277cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Byte_byteValue, 0 ); 278cdf0e10cSrcweir jni.ensure_no_exception(); 279cdf0e10cSrcweir } 280cdf0e10cSrcweir else 281cdf0e10cSrcweir { 282cdf0e10cSrcweir *(jbyte *) uno_data = java_data.b; 283cdf0e10cSrcweir } 284cdf0e10cSrcweir break; 285cdf0e10cSrcweir case typelib_TypeClass_SHORT: 286cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 287cdf0e10cSrcweir if (out_param) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir jni->GetShortArrayRegion( 290cdf0e10cSrcweir (jshortArray) java_data.l, 0, 1, (jshort *) uno_data ); 291cdf0e10cSrcweir jni.ensure_no_exception(); 292cdf0e10cSrcweir } 293cdf0e10cSrcweir else if (special_wrapped_integral_types) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir *(jshort *) uno_data = jni->CallShortMethodA( 296cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Short_shortValue, 0 ); 297cdf0e10cSrcweir jni.ensure_no_exception(); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir else 300cdf0e10cSrcweir { 301cdf0e10cSrcweir *(jshort *) uno_data = java_data.s; 302cdf0e10cSrcweir } 303cdf0e10cSrcweir break; 304cdf0e10cSrcweir case typelib_TypeClass_LONG: 305cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 306cdf0e10cSrcweir if (out_param) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir jni->GetIntArrayRegion( 309cdf0e10cSrcweir (jintArray) java_data.l, 0, 1, (jint *) uno_data ); 310cdf0e10cSrcweir jni.ensure_no_exception(); 311cdf0e10cSrcweir } 312cdf0e10cSrcweir else if (special_wrapped_integral_types) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir *(jint *) uno_data = jni->CallIntMethodA( 315cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Integer_intValue, 0 ); 316cdf0e10cSrcweir jni.ensure_no_exception(); 317cdf0e10cSrcweir } 318cdf0e10cSrcweir else 319cdf0e10cSrcweir { 320cdf0e10cSrcweir *(jint *) uno_data = java_data.i; 321cdf0e10cSrcweir } 322cdf0e10cSrcweir break; 323cdf0e10cSrcweir case typelib_TypeClass_HYPER: 324cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 325cdf0e10cSrcweir if (out_param) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir jni->GetLongArrayRegion( 328cdf0e10cSrcweir (jlongArray) java_data.l, 0, 1, (jlong *) uno_data ); 329cdf0e10cSrcweir jni.ensure_no_exception(); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir else if (special_wrapped_integral_types) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir *(jlong *) uno_data = jni->CallLongMethodA( 334cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Long_longValue, 0 ); 335cdf0e10cSrcweir jni.ensure_no_exception(); 336cdf0e10cSrcweir } 337cdf0e10cSrcweir else 338cdf0e10cSrcweir { 339cdf0e10cSrcweir *(jlong *) uno_data = java_data.j; 340cdf0e10cSrcweir } 341cdf0e10cSrcweir break; 342cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 343cdf0e10cSrcweir if (out_param) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir jni->GetFloatArrayRegion( 346cdf0e10cSrcweir (jfloatArray) java_data.l, 0, 1, (jfloat *) uno_data ); 347cdf0e10cSrcweir jni.ensure_no_exception(); 348cdf0e10cSrcweir } 349cdf0e10cSrcweir else if (special_wrapped_integral_types) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir *(jfloat *) uno_data = jni->CallFloatMethodA( 352cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Float_floatValue, 0 ); 353cdf0e10cSrcweir jni.ensure_no_exception(); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir else 356cdf0e10cSrcweir { 357cdf0e10cSrcweir *(jfloat *) uno_data = java_data.f; 358cdf0e10cSrcweir } 359cdf0e10cSrcweir break; 360cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 361cdf0e10cSrcweir if (out_param) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir jni->GetDoubleArrayRegion( 364cdf0e10cSrcweir (jdoubleArray) java_data.l, 0, 1, (jdouble *) uno_data ); 365cdf0e10cSrcweir jni.ensure_no_exception(); 366cdf0e10cSrcweir } 367cdf0e10cSrcweir else if (special_wrapped_integral_types) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir *(jdouble *) uno_data = jni->CallDoubleMethodA( 370cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Double_doubleValue, 0 ); 371cdf0e10cSrcweir jni.ensure_no_exception(); 372cdf0e10cSrcweir } 373cdf0e10cSrcweir else 374cdf0e10cSrcweir { 375cdf0e10cSrcweir *(jdouble *) uno_data = java_data.d; 376cdf0e10cSrcweir } 377cdf0e10cSrcweir break; 378cdf0e10cSrcweir case typelib_TypeClass_STRING: 379cdf0e10cSrcweir { 380cdf0e10cSrcweir JLocalAutoRef jo_out_holder( jni ); 381cdf0e10cSrcweir if (out_param) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir jo_out_holder.reset( 384cdf0e10cSrcweir jni->GetObjectArrayElement( (jobjectArray) java_data.l, 0 ) ); 385cdf0e10cSrcweir jni.ensure_no_exception(); 386cdf0e10cSrcweir java_data.l = jo_out_holder.get(); 387cdf0e10cSrcweir } 388cdf0e10cSrcweir if (0 == java_data.l) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir OUStringBuffer buf( 128 ); 391cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 392cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 393cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] null-ref given!") ); 394cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 395cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 396cdf0e10cSrcweir } 397cdf0e10cSrcweir if (! assign) 398cdf0e10cSrcweir *(rtl_uString **)uno_data = 0; 399cdf0e10cSrcweir jstring_to_ustring( 400cdf0e10cSrcweir jni, (rtl_uString **)uno_data, (jstring) java_data.l ); 401cdf0e10cSrcweir break; 402cdf0e10cSrcweir } 403cdf0e10cSrcweir case typelib_TypeClass_TYPE: 404cdf0e10cSrcweir { 405cdf0e10cSrcweir JLocalAutoRef jo_out_holder( jni ); 406cdf0e10cSrcweir if (out_param) 407cdf0e10cSrcweir { 408cdf0e10cSrcweir jo_out_holder.reset( 409cdf0e10cSrcweir jni->GetObjectArrayElement( (jobjectArray) java_data.l, 0 ) ); 410cdf0e10cSrcweir jni.ensure_no_exception(); 411cdf0e10cSrcweir java_data.l = jo_out_holder.get(); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir if (0 == java_data.l) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir OUStringBuffer buf( 128 ); 416cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 417cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 418cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] null-ref given!") ); 419cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 420cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir // type name 424cdf0e10cSrcweir JLocalAutoRef jo_type_name( 425cdf0e10cSrcweir jni, jni->GetObjectField( 426cdf0e10cSrcweir java_data.l, m_jni_info->m_field_Type__typeName ) ); 427cdf0e10cSrcweir if (! jo_type_name.is()) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir OUStringBuffer buf( 128 ); 430cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 431cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 432cdf0e10cSrcweir buf.appendAscii( 433cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("] incomplete type object: " 434cdf0e10cSrcweir "no type name!") ); 435cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 436cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir OUString type_name( 439cdf0e10cSrcweir jstring_to_oustring( jni, (jstring) jo_type_name.get() ) ); 440cdf0e10cSrcweir ::com::sun::star::uno::TypeDescription td( type_name ); 441cdf0e10cSrcweir if (! td.is()) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir OUStringBuffer buf( 128 ); 444cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 445cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 446cdf0e10cSrcweir buf.appendAscii( 447cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("] UNO type not found: ") ); 448cdf0e10cSrcweir buf.append( type_name ); 449cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 450cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 451cdf0e10cSrcweir } 452cdf0e10cSrcweir typelib_typedescriptionreference_acquire( td.get()->pWeakRef ); 453cdf0e10cSrcweir if (assign) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir typelib_typedescriptionreference_release( 456cdf0e10cSrcweir *(typelib_TypeDescriptionReference **)uno_data ); 457cdf0e10cSrcweir } 458cdf0e10cSrcweir *(typelib_TypeDescriptionReference **)uno_data = td.get()->pWeakRef; 459cdf0e10cSrcweir break; 460cdf0e10cSrcweir } 461cdf0e10cSrcweir case typelib_TypeClass_ANY: 462cdf0e10cSrcweir { 463cdf0e10cSrcweir JLocalAutoRef jo_out_holder( jni ); 464cdf0e10cSrcweir if (out_param) 465cdf0e10cSrcweir { 466cdf0e10cSrcweir jo_out_holder.reset( 467cdf0e10cSrcweir jni->GetObjectArrayElement( (jobjectArray) java_data.l, 0 ) ); 468cdf0e10cSrcweir jni.ensure_no_exception(); 469cdf0e10cSrcweir java_data.l = jo_out_holder.get(); 470cdf0e10cSrcweir } 471cdf0e10cSrcweir 472cdf0e10cSrcweir uno_Any * pAny = (uno_Any *)uno_data; 473cdf0e10cSrcweir if (0 == java_data.l) // null-ref maps to XInterface null-ref 474cdf0e10cSrcweir { 475cdf0e10cSrcweir if (assign) 476cdf0e10cSrcweir uno_any_destruct( pAny, 0 ); 477cdf0e10cSrcweir uno_any_construct( 478cdf0e10cSrcweir pAny, 0, m_jni_info->m_XInterface_type_info->m_td.get(), 0 ); 479cdf0e10cSrcweir break; 480cdf0e10cSrcweir } 481cdf0e10cSrcweir 482cdf0e10cSrcweir JLocalAutoRef jo_type( jni ); 483cdf0e10cSrcweir JLocalAutoRef jo_wrapped_holder( jni ); 484cdf0e10cSrcweir 485cdf0e10cSrcweir if (JNI_FALSE != jni->IsInstanceOf( 486cdf0e10cSrcweir java_data.l, m_jni_info->m_class_Any )) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir // boxed any 489cdf0e10cSrcweir jo_type.reset( jni->GetObjectField( 490cdf0e10cSrcweir java_data.l, m_jni_info->m_field_Any__type ) ); 491cdf0e10cSrcweir if (! jo_type.is()) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir OUStringBuffer buf( 128 ); 494cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 495cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 496cdf0e10cSrcweir buf.appendAscii( 497cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("] no type set at " 498cdf0e10cSrcweir "com.sun.star.uno.Any!") ); 499cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 500cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 501cdf0e10cSrcweir } 502cdf0e10cSrcweir // wrapped value 503cdf0e10cSrcweir jo_wrapped_holder.reset( 504cdf0e10cSrcweir jni->GetObjectField( 505cdf0e10cSrcweir java_data.l, m_jni_info->m_field_Any__object ) ); 506cdf0e10cSrcweir java_data.l = jo_wrapped_holder.get(); 507cdf0e10cSrcweir } 508cdf0e10cSrcweir else 509cdf0e10cSrcweir { 510cdf0e10cSrcweir // create type out of class 511cdf0e10cSrcweir JLocalAutoRef jo_class( jni, jni->GetObjectClass( java_data.l ) ); 512cdf0e10cSrcweir jo_type.reset( create_type( jni, (jclass) jo_class.get() ) ); 513cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 514cdf0e10cSrcweir { 515cdf0e10cSrcweir JLocalAutoRef jo_toString( 516cdf0e10cSrcweir jni, jni->CallObjectMethodA( 517cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Object_toString, 0 ) ); 518cdf0e10cSrcweir jni.ensure_no_exception(); 519cdf0e10cSrcweir OUString toString( 520cdf0e10cSrcweir jstring_to_oustring( jni, (jstring) jo_toString.get() ) ); 521cdf0e10cSrcweir } 522cdf0e10cSrcweir #endif 523cdf0e10cSrcweir } 524cdf0e10cSrcweir 525cdf0e10cSrcweir // get type name 526cdf0e10cSrcweir JLocalAutoRef jo_type_name( 527cdf0e10cSrcweir jni, jni->GetObjectField( 528cdf0e10cSrcweir jo_type.get(), m_jni_info->m_field_Type__typeName ) ); 529cdf0e10cSrcweir jni.ensure_no_exception(); 530cdf0e10cSrcweir OUString type_name( 531cdf0e10cSrcweir jstring_to_oustring( jni, (jstring) jo_type_name.get() ) ); 532cdf0e10cSrcweir 533cdf0e10cSrcweir ::com::sun::star::uno::TypeDescription value_td( type_name ); 534cdf0e10cSrcweir if (! value_td.is()) 535cdf0e10cSrcweir { 536cdf0e10cSrcweir OUStringBuffer buf( 128 ); 537cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 538cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 539cdf0e10cSrcweir buf.appendAscii( 540cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("] UNO type not found: ") ); 541cdf0e10cSrcweir buf.append( type_name ); 542cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 543cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 544cdf0e10cSrcweir } 545cdf0e10cSrcweir typelib_TypeClass type_class = value_td.get()->eTypeClass; 546cdf0e10cSrcweir 547cdf0e10cSrcweir if (assign) 548cdf0e10cSrcweir { 549cdf0e10cSrcweir uno_any_destruct( pAny, 0 ); 550cdf0e10cSrcweir } 551cdf0e10cSrcweir try 552cdf0e10cSrcweir { 553cdf0e10cSrcweir switch (type_class) 554cdf0e10cSrcweir { 555cdf0e10cSrcweir case typelib_TypeClass_VOID: 556cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 557cdf0e10cSrcweir break; 558cdf0e10cSrcweir case typelib_TypeClass_CHAR: 559cdf0e10cSrcweir *(jchar *) &pAny->pReserved = jni->CallCharMethodA( 560cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Character_charValue, 0 ); 561cdf0e10cSrcweir jni.ensure_no_exception(); 562cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 563cdf0e10cSrcweir break; 564cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN: 565cdf0e10cSrcweir *(jboolean *) &pAny->pReserved = jni->CallBooleanMethodA( 566cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Boolean_booleanValue, 0 ); 567cdf0e10cSrcweir jni.ensure_no_exception(); 568cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 569cdf0e10cSrcweir break; 570cdf0e10cSrcweir case typelib_TypeClass_BYTE: 571cdf0e10cSrcweir *(jbyte *) &pAny->pReserved = jni->CallByteMethodA( 572cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Byte_byteValue, 0 ); 573cdf0e10cSrcweir jni.ensure_no_exception(); 574cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 575cdf0e10cSrcweir break; 576cdf0e10cSrcweir case typelib_TypeClass_SHORT: 577cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 578cdf0e10cSrcweir *(jshort *) &pAny->pReserved = jni->CallShortMethodA( 579cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Short_shortValue, 0 ); 580cdf0e10cSrcweir jni.ensure_no_exception(); 581cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 582cdf0e10cSrcweir break; 583cdf0e10cSrcweir case typelib_TypeClass_LONG: 584cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 585cdf0e10cSrcweir *(jint *) &pAny->pReserved = jni->CallIntMethodA( 586cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Integer_intValue, 0 ); 587cdf0e10cSrcweir jni.ensure_no_exception(); 588cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 589cdf0e10cSrcweir break; 590cdf0e10cSrcweir case typelib_TypeClass_HYPER: 591cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 592cdf0e10cSrcweir if (sizeof (sal_Int64) <= sizeof (void *)) 593cdf0e10cSrcweir { 594cdf0e10cSrcweir *(jlong *) &pAny->pReserved = jni->CallLongMethodA( 595cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Long_longValue, 0 ); 596cdf0e10cSrcweir jni.ensure_no_exception(); 597cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 598cdf0e10cSrcweir } 599cdf0e10cSrcweir else 600cdf0e10cSrcweir { 601cdf0e10cSrcweir auto_ptr< rtl_mem > mem( 602cdf0e10cSrcweir rtl_mem::allocate( sizeof (sal_Int64) ) ); 603cdf0e10cSrcweir *(jlong *) mem.get() = jni->CallLongMethodA( 604cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Long_longValue, 0 ); 605cdf0e10cSrcweir jni.ensure_no_exception(); 606cdf0e10cSrcweir pAny->pData = mem.release(); 607cdf0e10cSrcweir } 608cdf0e10cSrcweir break; 609cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 610cdf0e10cSrcweir if (sizeof (float) <= sizeof (void *)) 611cdf0e10cSrcweir { 612cdf0e10cSrcweir *(jfloat *) &pAny->pReserved = jni->CallFloatMethodA( 613cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Float_floatValue, 0 ); 614cdf0e10cSrcweir jni.ensure_no_exception(); 615cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 616cdf0e10cSrcweir } 617cdf0e10cSrcweir else 618cdf0e10cSrcweir { 619cdf0e10cSrcweir auto_ptr< rtl_mem > mem( 620cdf0e10cSrcweir rtl_mem::allocate( sizeof (float) ) ); 621cdf0e10cSrcweir *(jfloat *) mem.get() = jni->CallFloatMethodA( 622cdf0e10cSrcweir java_data.l, m_jni_info->m_method_Float_floatValue, 0 ); 623cdf0e10cSrcweir jni.ensure_no_exception(); 624cdf0e10cSrcweir pAny->pData = mem.release(); 625cdf0e10cSrcweir } 626cdf0e10cSrcweir break; 627cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 628cdf0e10cSrcweir if (sizeof (double) <= sizeof (void *)) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir *(jdouble *) &pAny->pReserved = 631cdf0e10cSrcweir jni->CallDoubleMethodA( 632cdf0e10cSrcweir java_data.l, 633cdf0e10cSrcweir m_jni_info->m_method_Double_doubleValue, 0 ); 634cdf0e10cSrcweir jni.ensure_no_exception(); 635cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 636cdf0e10cSrcweir } 637cdf0e10cSrcweir else 638cdf0e10cSrcweir { 639cdf0e10cSrcweir auto_ptr< rtl_mem > mem( 640cdf0e10cSrcweir rtl_mem::allocate( sizeof (double) ) ); 641cdf0e10cSrcweir *(jdouble *) mem.get() = 642cdf0e10cSrcweir jni->CallDoubleMethodA( 643cdf0e10cSrcweir java_data.l, 644cdf0e10cSrcweir m_jni_info->m_method_Double_doubleValue, 0 ); 645cdf0e10cSrcweir jni.ensure_no_exception(); 646cdf0e10cSrcweir pAny->pData = mem.release(); 647cdf0e10cSrcweir } 648cdf0e10cSrcweir break; 649cdf0e10cSrcweir case typelib_TypeClass_STRING: 650cdf0e10cSrcweir // opt: anies often contain strings; copy string directly 651cdf0e10cSrcweir pAny->pReserved = 0; 652cdf0e10cSrcweir jstring_to_ustring( 653cdf0e10cSrcweir jni, (rtl_uString **)&pAny->pReserved, 654cdf0e10cSrcweir (jstring) java_data.l ); 655cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 656cdf0e10cSrcweir break; 657cdf0e10cSrcweir case typelib_TypeClass_TYPE: 658cdf0e10cSrcweir case typelib_TypeClass_ENUM: 659cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 660cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 661cdf0e10cSrcweir map_to_uno( 662cdf0e10cSrcweir jni, &pAny->pReserved, java_data, 663cdf0e10cSrcweir value_td.get()->pWeakRef, 0, 664cdf0e10cSrcweir false /* no assign */, false /* no out param */ ); 665cdf0e10cSrcweir pAny->pData = &pAny->pReserved; 666cdf0e10cSrcweir break; 667cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 668cdf0e10cSrcweir case typelib_TypeClass_EXCEPTION: 669cdf0e10cSrcweir { 670cdf0e10cSrcweir auto_ptr< rtl_mem > mem( 671cdf0e10cSrcweir rtl_mem::allocate( value_td.get()->nSize ) ); 672cdf0e10cSrcweir map_to_uno( 673cdf0e10cSrcweir jni, mem.get(), java_data, value_td.get()->pWeakRef, 0, 674cdf0e10cSrcweir false /* no assign */, false /* no out param */ ); 675cdf0e10cSrcweir pAny->pData = mem.release(); 676cdf0e10cSrcweir break; 677cdf0e10cSrcweir } 678cdf0e10cSrcweir default: 679cdf0e10cSrcweir { 680cdf0e10cSrcweir OUStringBuffer buf( 128 ); 681cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 682cdf0e10cSrcweir buf.append( type_name ); 683cdf0e10cSrcweir buf.appendAscii( 684cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("] unsupported value type " 685cdf0e10cSrcweir "of any!") ); 686cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 687cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 688cdf0e10cSrcweir } 689cdf0e10cSrcweir } 690cdf0e10cSrcweir } 691cdf0e10cSrcweir catch (...) 692cdf0e10cSrcweir { 693cdf0e10cSrcweir if (assign) 694cdf0e10cSrcweir { 695cdf0e10cSrcweir // restore to valid any 696cdf0e10cSrcweir uno_any_construct( pAny, 0, 0, 0 ); 697cdf0e10cSrcweir } 698cdf0e10cSrcweir throw; 699cdf0e10cSrcweir } 700cdf0e10cSrcweir typelib_typedescriptionreference_acquire( value_td.get()->pWeakRef ); 701cdf0e10cSrcweir pAny->pType = value_td.get()->pWeakRef; 702cdf0e10cSrcweir break; 703cdf0e10cSrcweir } 704cdf0e10cSrcweir case typelib_TypeClass_ENUM: 705cdf0e10cSrcweir { 706cdf0e10cSrcweir JLocalAutoRef jo_out_holder( jni ); 707cdf0e10cSrcweir if (out_param) 708cdf0e10cSrcweir { 709cdf0e10cSrcweir jo_out_holder.reset( 710cdf0e10cSrcweir jni->GetObjectArrayElement( (jobjectArray) java_data.l, 0 ) ); 711cdf0e10cSrcweir jni.ensure_no_exception(); 712cdf0e10cSrcweir java_data.l = jo_out_holder.get(); 713cdf0e10cSrcweir } 714cdf0e10cSrcweir if (0 == java_data.l) 715cdf0e10cSrcweir { 716cdf0e10cSrcweir OUStringBuffer buf( 128 ); 717cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 718cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 719cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] null-ref given!") ); 720cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 721cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 722cdf0e10cSrcweir } 723cdf0e10cSrcweir 724cdf0e10cSrcweir *(jint *) uno_data = jni->GetIntField( 725cdf0e10cSrcweir java_data.l, m_jni_info->m_field_Enum_m_value ); 726cdf0e10cSrcweir break; 727cdf0e10cSrcweir } 728cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 729cdf0e10cSrcweir case typelib_TypeClass_EXCEPTION: 730cdf0e10cSrcweir { 731cdf0e10cSrcweir JLocalAutoRef jo_out_holder( jni ); 732cdf0e10cSrcweir if (out_param) 733cdf0e10cSrcweir { 734cdf0e10cSrcweir jo_out_holder.reset( 735cdf0e10cSrcweir jni->GetObjectArrayElement( (jobjectArray) java_data.l, 0 ) ); 736cdf0e10cSrcweir jni.ensure_no_exception(); 737cdf0e10cSrcweir java_data.l = jo_out_holder.get(); 738cdf0e10cSrcweir } 739cdf0e10cSrcweir if (0 == java_data.l) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir OUStringBuffer buf( 128 ); 742cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 743cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 744cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] null-ref given!") ); 745cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 746cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 747cdf0e10cSrcweir } 748cdf0e10cSrcweir 749cdf0e10cSrcweir if (0 == info) 750cdf0e10cSrcweir info = m_jni_info->get_type_info( jni, type ); 751cdf0e10cSrcweir JNI_compound_type_info const * comp_info = 752cdf0e10cSrcweir static_cast< JNI_compound_type_info const * >( info ); 753cdf0e10cSrcweir 754cdf0e10cSrcweir typelib_CompoundTypeDescription * comp_td = 755cdf0e10cSrcweir (typelib_CompoundTypeDescription *)comp_info->m_td.get(); 756cdf0e10cSrcweir bool polymorphic 757cdf0e10cSrcweir = comp_td->aBase.eTypeClass == typelib_TypeClass_STRUCT 758cdf0e10cSrcweir && reinterpret_cast< typelib_StructTypeDescription * >( 759cdf0e10cSrcweir comp_td)->pParameterizedTypes != 0; 760cdf0e10cSrcweir 761cdf0e10cSrcweir sal_Int32 nPos = 0; 762cdf0e10cSrcweir sal_Int32 nMembers = comp_td->nMembers; 763cdf0e10cSrcweir try 764cdf0e10cSrcweir { 765cdf0e10cSrcweir if (0 != comp_td->pBaseTypeDescription) 766cdf0e10cSrcweir { 767cdf0e10cSrcweir map_to_uno( 768cdf0e10cSrcweir jni, uno_data, java_data, 769cdf0e10cSrcweir ((typelib_TypeDescription *) comp_td->pBaseTypeDescription) 770cdf0e10cSrcweir ->pWeakRef, 771cdf0e10cSrcweir comp_info->m_base, 772cdf0e10cSrcweir assign, false /* no out param */ ); 773cdf0e10cSrcweir } 774cdf0e10cSrcweir 775cdf0e10cSrcweir for ( ; nPos < nMembers; ++nPos ) 776cdf0e10cSrcweir { 777cdf0e10cSrcweir void * p = (char *)uno_data + comp_td->pMemberOffsets[ nPos ]; 778cdf0e10cSrcweir typelib_TypeDescriptionReference * member_type = 779cdf0e10cSrcweir comp_td->ppTypeRefs[ nPos ]; 780cdf0e10cSrcweir jfieldID field_id = comp_info->m_fields[ nPos ]; 781cdf0e10cSrcweir bool parameterizedType = polymorphic 782cdf0e10cSrcweir && reinterpret_cast< typelib_StructTypeDescription * >( 783cdf0e10cSrcweir comp_td)->pParameterizedTypes[nPos]; 784cdf0e10cSrcweir switch (member_type->eTypeClass) 785cdf0e10cSrcweir { 786cdf0e10cSrcweir case typelib_TypeClass_CHAR: 787cdf0e10cSrcweir if (parameterizedType) { 788cdf0e10cSrcweir JLocalAutoRef jo( 789cdf0e10cSrcweir jni, jni->GetObjectField( java_data.l, field_id ) ); 790cdf0e10cSrcweir if ( jo.get() == 0 ) { 791cdf0e10cSrcweir *(jchar *) p = 0; 792cdf0e10cSrcweir } else { 793cdf0e10cSrcweir jvalue val; 794cdf0e10cSrcweir val.l = jo.get(); 795cdf0e10cSrcweir map_to_uno( 796cdf0e10cSrcweir jni, p, val, member_type, 0, assign, false, 797cdf0e10cSrcweir true ); 798cdf0e10cSrcweir } 799cdf0e10cSrcweir } else { 800cdf0e10cSrcweir *(jchar *) p = jni->GetCharField( 801cdf0e10cSrcweir java_data.l, field_id ); 802cdf0e10cSrcweir } 803cdf0e10cSrcweir break; 804cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN: 805cdf0e10cSrcweir if (parameterizedType) { 806cdf0e10cSrcweir JLocalAutoRef jo( 807cdf0e10cSrcweir jni, jni->GetObjectField( java_data.l, field_id ) ); 808cdf0e10cSrcweir if ( jo.get() == 0 ) { 809cdf0e10cSrcweir *(jboolean *) p = false; 810cdf0e10cSrcweir } else { 811cdf0e10cSrcweir jvalue val; 812cdf0e10cSrcweir val.l = jo.get(); 813cdf0e10cSrcweir map_to_uno( 814cdf0e10cSrcweir jni, p, val, member_type, 0, assign, false, 815cdf0e10cSrcweir true ); 816cdf0e10cSrcweir } 817cdf0e10cSrcweir } else { 818cdf0e10cSrcweir *(jboolean *) p = jni->GetBooleanField( 819cdf0e10cSrcweir java_data.l, field_id ); 820cdf0e10cSrcweir } 821cdf0e10cSrcweir break; 822cdf0e10cSrcweir case typelib_TypeClass_BYTE: 823cdf0e10cSrcweir if (parameterizedType) { 824cdf0e10cSrcweir JLocalAutoRef jo( 825cdf0e10cSrcweir jni, jni->GetObjectField( java_data.l, field_id ) ); 826cdf0e10cSrcweir if ( jo.get() == 0 ) { 827cdf0e10cSrcweir *(jbyte *) p = 0; 828cdf0e10cSrcweir } else { 829cdf0e10cSrcweir jvalue val; 830cdf0e10cSrcweir val.l = jo.get(); 831cdf0e10cSrcweir map_to_uno( 832cdf0e10cSrcweir jni, p, val, member_type, 0, assign, false, 833cdf0e10cSrcweir true ); 834cdf0e10cSrcweir } 835cdf0e10cSrcweir } else { 836cdf0e10cSrcweir *(jbyte *) p = jni->GetByteField( 837cdf0e10cSrcweir java_data.l, field_id ); 838cdf0e10cSrcweir } 839cdf0e10cSrcweir break; 840cdf0e10cSrcweir case typelib_TypeClass_SHORT: 841cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 842cdf0e10cSrcweir if (parameterizedType) { 843cdf0e10cSrcweir JLocalAutoRef jo( 844cdf0e10cSrcweir jni, jni->GetObjectField( java_data.l, field_id ) ); 845cdf0e10cSrcweir if ( jo.get() == 0 ) { 846cdf0e10cSrcweir *(jshort *) p = 0; 847cdf0e10cSrcweir } else { 848cdf0e10cSrcweir jvalue val; 849cdf0e10cSrcweir val.l = jo.get(); 850cdf0e10cSrcweir map_to_uno( 851cdf0e10cSrcweir jni, p, val, member_type, 0, assign, false, 852cdf0e10cSrcweir true ); 853cdf0e10cSrcweir } 854cdf0e10cSrcweir } else { 855cdf0e10cSrcweir *(jshort *) p = jni->GetShortField( 856cdf0e10cSrcweir java_data.l, field_id ); 857cdf0e10cSrcweir } 858cdf0e10cSrcweir break; 859cdf0e10cSrcweir case typelib_TypeClass_LONG: 860cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 861cdf0e10cSrcweir if (parameterizedType) { 862cdf0e10cSrcweir JLocalAutoRef jo( 863cdf0e10cSrcweir jni, jni->GetObjectField( java_data.l, field_id ) ); 864cdf0e10cSrcweir if ( jo.get() == 0 ) { 865cdf0e10cSrcweir *(jint *) p = 0; 866cdf0e10cSrcweir } else { 867cdf0e10cSrcweir jvalue val; 868cdf0e10cSrcweir val.l = jo.get(); 869cdf0e10cSrcweir map_to_uno( 870cdf0e10cSrcweir jni, p, val, member_type, 0, assign, false, 871cdf0e10cSrcweir true ); 872cdf0e10cSrcweir } 873cdf0e10cSrcweir } else { 874cdf0e10cSrcweir *(jint *) p = jni->GetIntField( java_data.l, field_id ); 875cdf0e10cSrcweir } 876cdf0e10cSrcweir break; 877cdf0e10cSrcweir case typelib_TypeClass_HYPER: 878cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 879cdf0e10cSrcweir if (parameterizedType) { 880cdf0e10cSrcweir JLocalAutoRef jo( 881cdf0e10cSrcweir jni, jni->GetObjectField( java_data.l, field_id ) ); 882cdf0e10cSrcweir if ( jo.get() == 0 ) { 883cdf0e10cSrcweir *(jlong *) p = 0; 884cdf0e10cSrcweir } else { 885cdf0e10cSrcweir jvalue val; 886cdf0e10cSrcweir val.l = jo.get(); 887cdf0e10cSrcweir map_to_uno( 888cdf0e10cSrcweir jni, p, val, member_type, 0, assign, false, 889cdf0e10cSrcweir true ); 890cdf0e10cSrcweir } 891cdf0e10cSrcweir } else { 892cdf0e10cSrcweir *(jlong *) p = jni->GetLongField( 893cdf0e10cSrcweir java_data.l, field_id ); 894cdf0e10cSrcweir } 895cdf0e10cSrcweir break; 896cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 897cdf0e10cSrcweir if (parameterizedType) { 898cdf0e10cSrcweir JLocalAutoRef jo( 899cdf0e10cSrcweir jni, jni->GetObjectField( java_data.l, field_id ) ); 900cdf0e10cSrcweir if ( jo.get() == 0 ) { 901cdf0e10cSrcweir *(jfloat *) p = 0; 902cdf0e10cSrcweir } else { 903cdf0e10cSrcweir jvalue val; 904cdf0e10cSrcweir val.l = jo.get(); 905cdf0e10cSrcweir map_to_uno( 906cdf0e10cSrcweir jni, p, val, member_type, 0, assign, false, 907cdf0e10cSrcweir true ); 908cdf0e10cSrcweir } 909cdf0e10cSrcweir } else { 910cdf0e10cSrcweir *(jfloat *) p = jni->GetFloatField( 911cdf0e10cSrcweir java_data.l, field_id ); 912cdf0e10cSrcweir } 913cdf0e10cSrcweir break; 914cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 915cdf0e10cSrcweir if (parameterizedType) { 916cdf0e10cSrcweir JLocalAutoRef jo( 917cdf0e10cSrcweir jni, jni->GetObjectField( java_data.l, field_id ) ); 918cdf0e10cSrcweir if ( jo.get() == 0 ) { 919cdf0e10cSrcweir *(jdouble *) p = 0; 920cdf0e10cSrcweir } else { 921cdf0e10cSrcweir jvalue val; 922cdf0e10cSrcweir val.l = jo.get(); 923cdf0e10cSrcweir map_to_uno( 924cdf0e10cSrcweir jni, p, val, member_type, 0, assign, false, 925cdf0e10cSrcweir true ); 926cdf0e10cSrcweir } 927cdf0e10cSrcweir } else { 928cdf0e10cSrcweir *(jdouble *) p = jni->GetDoubleField( 929cdf0e10cSrcweir java_data.l, field_id ); 930cdf0e10cSrcweir } 931cdf0e10cSrcweir break; 932cdf0e10cSrcweir default: 933cdf0e10cSrcweir { 934cdf0e10cSrcweir JLocalAutoRef jo_field( jni ); 935cdf0e10cSrcweir bool checkNull; 936cdf0e10cSrcweir if (0 == field_id) 937cdf0e10cSrcweir { 938cdf0e10cSrcweir // special for Message: call Throwable.getMessage() 939cdf0e10cSrcweir OSL_ASSERT( 940cdf0e10cSrcweir type_equals( 941cdf0e10cSrcweir type, 942cdf0e10cSrcweir m_jni_info->m_Exception_type.getTypeLibType() ) 943cdf0e10cSrcweir || type_equals( 944cdf0e10cSrcweir type, 945cdf0e10cSrcweir m_jni_info->m_RuntimeException_type. 946cdf0e10cSrcweir getTypeLibType() ) ); 947cdf0e10cSrcweir OSL_ASSERT( 0 == nPos ); // first member 948cdf0e10cSrcweir // call getMessage() 949cdf0e10cSrcweir jo_field.reset( 950cdf0e10cSrcweir jni->CallObjectMethodA( 951cdf0e10cSrcweir java_data.l, 952cdf0e10cSrcweir m_jni_info->m_method_Throwable_getMessage, 0 ) 953cdf0e10cSrcweir ); 954cdf0e10cSrcweir jni.ensure_no_exception(); 955cdf0e10cSrcweir checkNull = true; 956cdf0e10cSrcweir } 957cdf0e10cSrcweir else 958cdf0e10cSrcweir { 959cdf0e10cSrcweir jo_field.reset( 960cdf0e10cSrcweir jni->GetObjectField( java_data.l, field_id ) ); 961cdf0e10cSrcweir checkNull = parameterizedType; 962cdf0e10cSrcweir } 963cdf0e10cSrcweir if (checkNull && !jo_field.is()) { 964cdf0e10cSrcweir createDefaultUnoValue(jni, p, member_type, 0, assign); 965cdf0e10cSrcweir } else { 966cdf0e10cSrcweir jvalue val; 967cdf0e10cSrcweir val.l = jo_field.get(); 968cdf0e10cSrcweir map_to_uno( 969cdf0e10cSrcweir jni, p, val, member_type, 0, 970cdf0e10cSrcweir assign, false /* no out param */ ); 971cdf0e10cSrcweir } 972cdf0e10cSrcweir break; 973cdf0e10cSrcweir } 974cdf0e10cSrcweir } 975cdf0e10cSrcweir } 976cdf0e10cSrcweir } 977cdf0e10cSrcweir catch (...) 978cdf0e10cSrcweir { 979cdf0e10cSrcweir if (! assign) 980cdf0e10cSrcweir { 981cdf0e10cSrcweir // cleanup 982cdf0e10cSrcweir for ( sal_Int32 nCleanup = 0; nCleanup < nPos; ++nCleanup ) 983cdf0e10cSrcweir { 984cdf0e10cSrcweir void * p = 985cdf0e10cSrcweir (char *)uno_data + comp_td->pMemberOffsets[ nCleanup ]; 986cdf0e10cSrcweir uno_type_destructData( 987cdf0e10cSrcweir p, comp_td->ppTypeRefs[ nCleanup ], 0 ); 988cdf0e10cSrcweir } 989cdf0e10cSrcweir if (0 != comp_td->pBaseTypeDescription) 990cdf0e10cSrcweir { 991cdf0e10cSrcweir uno_destructData( 992cdf0e10cSrcweir uno_data, 993cdf0e10cSrcweir (typelib_TypeDescription *) comp_td 994cdf0e10cSrcweir ->pBaseTypeDescription, 0 ); 995cdf0e10cSrcweir } 996cdf0e10cSrcweir } 997cdf0e10cSrcweir throw; 998cdf0e10cSrcweir } 999cdf0e10cSrcweir break; 1000cdf0e10cSrcweir } 1001cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 1002cdf0e10cSrcweir { 1003cdf0e10cSrcweir JLocalAutoRef jo_out_holder( jni ); 1004cdf0e10cSrcweir if (out_param) 1005cdf0e10cSrcweir { 1006cdf0e10cSrcweir jo_out_holder.reset( 1007cdf0e10cSrcweir jni->GetObjectArrayElement( (jobjectArray) java_data.l, 0 ) ); 1008cdf0e10cSrcweir jni.ensure_no_exception(); 1009cdf0e10cSrcweir java_data.l = jo_out_holder.get(); 1010cdf0e10cSrcweir } 1011cdf0e10cSrcweir if (0 == java_data.l) 1012cdf0e10cSrcweir { 1013cdf0e10cSrcweir OUStringBuffer buf( 128 ); 1014cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 1015cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 1016cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] null-ref given!") ); 1017cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 1018cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 1019cdf0e10cSrcweir } 1020cdf0e10cSrcweir 1021cdf0e10cSrcweir TypeDescr td( type ); 1022cdf0e10cSrcweir typelib_TypeDescriptionReference * element_type = 1023cdf0e10cSrcweir ((typelib_IndirectTypeDescription *)td.get())->pType; 1024cdf0e10cSrcweir 1025cdf0e10cSrcweir auto_ptr< rtl_mem > seq; 1026cdf0e10cSrcweir sal_Int32 nElements = jni->GetArrayLength( (jarray) java_data.l ); 1027cdf0e10cSrcweir 1028cdf0e10cSrcweir switch (element_type->eTypeClass) 1029cdf0e10cSrcweir { 1030cdf0e10cSrcweir case typelib_TypeClass_CHAR: 1031cdf0e10cSrcweir seq.reset( seq_allocate( nElements, sizeof (sal_Unicode) ) ); 1032cdf0e10cSrcweir jni->GetCharArrayRegion( 1033cdf0e10cSrcweir (jcharArray) java_data.l, 0, nElements, 1034cdf0e10cSrcweir (jchar *) ((uno_Sequence *) seq.get())->elements ); 1035cdf0e10cSrcweir jni.ensure_no_exception(); 1036cdf0e10cSrcweir break; 1037cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN: 1038cdf0e10cSrcweir seq.reset( seq_allocate( nElements, sizeof (sal_Bool) ) ); 1039cdf0e10cSrcweir jni->GetBooleanArrayRegion( 1040cdf0e10cSrcweir (jbooleanArray) java_data.l, 0, nElements, 1041cdf0e10cSrcweir (jboolean *) ((uno_Sequence *) seq.get())->elements ); 1042cdf0e10cSrcweir jni.ensure_no_exception(); 1043cdf0e10cSrcweir break; 1044cdf0e10cSrcweir case typelib_TypeClass_BYTE: 1045cdf0e10cSrcweir seq.reset( seq_allocate( nElements, sizeof (sal_Int8) ) ); 1046cdf0e10cSrcweir jni->GetByteArrayRegion( 1047cdf0e10cSrcweir (jbyteArray) java_data.l, 0, nElements, 1048cdf0e10cSrcweir (jbyte *) ((uno_Sequence *) seq.get())->elements ); 1049cdf0e10cSrcweir jni.ensure_no_exception(); 1050cdf0e10cSrcweir break; 1051cdf0e10cSrcweir case typelib_TypeClass_SHORT: 1052cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 1053cdf0e10cSrcweir seq.reset( seq_allocate( nElements, sizeof (sal_Int16) ) ); 1054cdf0e10cSrcweir jni->GetShortArrayRegion( 1055cdf0e10cSrcweir (jshortArray) java_data.l, 0, nElements, 1056cdf0e10cSrcweir (jshort *) ((uno_Sequence *) seq.get())->elements ); 1057cdf0e10cSrcweir jni.ensure_no_exception(); 1058cdf0e10cSrcweir break; 1059cdf0e10cSrcweir case typelib_TypeClass_LONG: 1060cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 1061cdf0e10cSrcweir seq.reset( seq_allocate( nElements, sizeof (sal_Int32) ) ); 1062cdf0e10cSrcweir jni->GetIntArrayRegion( 1063cdf0e10cSrcweir (jintArray) java_data.l, 0, nElements, 1064cdf0e10cSrcweir (jint *) ((uno_Sequence *) seq.get())->elements ); 1065cdf0e10cSrcweir jni.ensure_no_exception(); 1066cdf0e10cSrcweir break; 1067cdf0e10cSrcweir case typelib_TypeClass_HYPER: 1068cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 1069cdf0e10cSrcweir seq.reset( seq_allocate( nElements, sizeof (sal_Int64) ) ); 1070cdf0e10cSrcweir jni->GetLongArrayRegion( 1071cdf0e10cSrcweir (jlongArray) java_data.l, 0, nElements, 1072cdf0e10cSrcweir (jlong *) ((uno_Sequence *) seq.get())->elements ); 1073cdf0e10cSrcweir jni.ensure_no_exception(); 1074cdf0e10cSrcweir break; 1075cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 1076cdf0e10cSrcweir seq.reset( seq_allocate( nElements, sizeof (float) ) ); 1077cdf0e10cSrcweir jni->GetFloatArrayRegion( 1078cdf0e10cSrcweir (jfloatArray) java_data.l, 0, nElements, 1079cdf0e10cSrcweir (jfloat *)((uno_Sequence *)seq.get())->elements ); 1080cdf0e10cSrcweir jni.ensure_no_exception(); 1081cdf0e10cSrcweir break; 1082cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 1083cdf0e10cSrcweir seq.reset( seq_allocate( nElements, sizeof (double) ) ); 1084cdf0e10cSrcweir jni->GetDoubleArrayRegion( 1085cdf0e10cSrcweir (jdoubleArray) java_data.l, 0, nElements, 1086cdf0e10cSrcweir (jdouble *) ((uno_Sequence *) seq.get())->elements ); 1087cdf0e10cSrcweir jni.ensure_no_exception(); 1088cdf0e10cSrcweir break; 1089cdf0e10cSrcweir case typelib_TypeClass_STRING: 1090cdf0e10cSrcweir case typelib_TypeClass_TYPE: 1091cdf0e10cSrcweir case typelib_TypeClass_ANY: 1092cdf0e10cSrcweir case typelib_TypeClass_ENUM: 1093cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 1094cdf0e10cSrcweir case typelib_TypeClass_EXCEPTION: 1095cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 1096cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 1097cdf0e10cSrcweir { 1098cdf0e10cSrcweir TypeDescr element_td( element_type ); 1099cdf0e10cSrcweir seq.reset( seq_allocate( nElements, element_td.get()->nSize ) ); 1100cdf0e10cSrcweir 1101cdf0e10cSrcweir JNI_type_info const * element_info; 1102cdf0e10cSrcweir if (typelib_TypeClass_STRUCT == element_type->eTypeClass || 1103cdf0e10cSrcweir typelib_TypeClass_EXCEPTION == element_type->eTypeClass || 1104cdf0e10cSrcweir typelib_TypeClass_INTERFACE == element_type->eTypeClass) 1105cdf0e10cSrcweir { 1106cdf0e10cSrcweir element_info = 1107cdf0e10cSrcweir m_jni_info->get_type_info( jni, element_td.get() ); 1108cdf0e10cSrcweir } 1109cdf0e10cSrcweir else 1110cdf0e10cSrcweir { 1111cdf0e10cSrcweir element_info = 0; 1112cdf0e10cSrcweir } 1113cdf0e10cSrcweir 1114cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) 1115cdf0e10cSrcweir { 1116cdf0e10cSrcweir try 1117cdf0e10cSrcweir { 1118cdf0e10cSrcweir JLocalAutoRef jo( 1119cdf0e10cSrcweir jni, jni->GetObjectArrayElement( 1120cdf0e10cSrcweir (jobjectArray) java_data.l, nPos ) ); 1121cdf0e10cSrcweir jni.ensure_no_exception(); 1122cdf0e10cSrcweir jvalue val; 1123cdf0e10cSrcweir val.l = jo.get(); 1124cdf0e10cSrcweir void * p = 1125cdf0e10cSrcweir ((uno_Sequence *)seq.get())->elements + 1126cdf0e10cSrcweir (nPos * element_td.get()->nSize); 1127cdf0e10cSrcweir map_to_uno( 1128cdf0e10cSrcweir jni, p, val, element_td.get()->pWeakRef, element_info, 1129cdf0e10cSrcweir false /* no assign */, false /* no out param */ ); 1130cdf0e10cSrcweir } 1131cdf0e10cSrcweir catch (...) 1132cdf0e10cSrcweir { 1133cdf0e10cSrcweir // cleanup 1134cdf0e10cSrcweir for ( sal_Int32 nCleanPos = 0; 1135cdf0e10cSrcweir nCleanPos < nPos; ++nCleanPos ) 1136cdf0e10cSrcweir { 1137cdf0e10cSrcweir void * p = 1138cdf0e10cSrcweir ((uno_Sequence *)seq.get())->elements + 1139cdf0e10cSrcweir (nCleanPos * element_td.get()->nSize); 1140cdf0e10cSrcweir uno_destructData( p, element_td.get(), 0 ); 1141cdf0e10cSrcweir } 1142cdf0e10cSrcweir throw; 1143cdf0e10cSrcweir } 1144cdf0e10cSrcweir } 1145cdf0e10cSrcweir break; 1146cdf0e10cSrcweir } 1147cdf0e10cSrcweir default: 1148cdf0e10cSrcweir { 1149cdf0e10cSrcweir OUStringBuffer buf( 128 ); 1150cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 1151cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 1152cdf0e10cSrcweir buf.appendAscii( 1153cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("] unsupported sequence element" 1154cdf0e10cSrcweir " type: ") ); 1155cdf0e10cSrcweir buf.append( OUString::unacquired( &element_type->pTypeName ) ); 1156cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 1157cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 1158cdf0e10cSrcweir } 1159cdf0e10cSrcweir } 1160cdf0e10cSrcweir 1161cdf0e10cSrcweir if (assign) 1162cdf0e10cSrcweir uno_destructData( uno_data, td.get(), 0 ); 1163cdf0e10cSrcweir *(uno_Sequence **)uno_data = (uno_Sequence *)seq.release(); 1164cdf0e10cSrcweir break; 1165cdf0e10cSrcweir } 1166cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 1167cdf0e10cSrcweir { 1168cdf0e10cSrcweir JLocalAutoRef jo_out_holder( jni ); 1169cdf0e10cSrcweir if (out_param) 1170cdf0e10cSrcweir { 1171cdf0e10cSrcweir jo_out_holder.reset( 1172cdf0e10cSrcweir jni->GetObjectArrayElement( (jobjectArray) java_data.l, 0 ) ); 1173cdf0e10cSrcweir jni.ensure_no_exception(); 1174cdf0e10cSrcweir java_data.l = jo_out_holder.get(); 1175cdf0e10cSrcweir } 1176cdf0e10cSrcweir 1177cdf0e10cSrcweir if (0 == java_data.l) // null-ref 1178cdf0e10cSrcweir { 1179cdf0e10cSrcweir if (assign) 1180cdf0e10cSrcweir { 1181cdf0e10cSrcweir uno_Interface * p = *(uno_Interface **)uno_data; 1182cdf0e10cSrcweir if (0 != p) 1183cdf0e10cSrcweir (*p->release)( p ); 1184cdf0e10cSrcweir } 1185cdf0e10cSrcweir *(uno_Interface **)uno_data = 0; 1186cdf0e10cSrcweir } 1187cdf0e10cSrcweir else 1188cdf0e10cSrcweir { 1189cdf0e10cSrcweir if (0 == info) 1190cdf0e10cSrcweir info = m_jni_info->get_type_info( jni, type ); 1191cdf0e10cSrcweir JNI_interface_type_info const * iface_info = 1192cdf0e10cSrcweir static_cast< JNI_interface_type_info const * >( info ); 1193cdf0e10cSrcweir uno_Interface * pUnoI = map_to_uno( jni, java_data.l, iface_info ); 1194cdf0e10cSrcweir if (assign) 1195cdf0e10cSrcweir { 1196cdf0e10cSrcweir uno_Interface * p = *(uno_Interface **)uno_data; 1197cdf0e10cSrcweir if (0 != p) 1198cdf0e10cSrcweir (*p->release)( p ); 1199cdf0e10cSrcweir } 1200cdf0e10cSrcweir *(uno_Interface **)uno_data = pUnoI; 1201cdf0e10cSrcweir } 1202cdf0e10cSrcweir break; 1203cdf0e10cSrcweir } 1204cdf0e10cSrcweir default: 1205cdf0e10cSrcweir { 1206cdf0e10cSrcweir OUStringBuffer buf( 128 ); 1207cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_uno():") ); 1208cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 1209cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] unsupported type!") ); 1210cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 1211cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 1212cdf0e10cSrcweir } 1213cdf0e10cSrcweir } 1214cdf0e10cSrcweir } 1215cdf0e10cSrcweir 1216cdf0e10cSrcweir //############################################################################## 1217cdf0e10cSrcweir 1218cdf0e10cSrcweir //______________________________________________________________________________ 1219cdf0e10cSrcweir void Bridge::map_to_java( 1220cdf0e10cSrcweir JNI_context const & jni, 1221cdf0e10cSrcweir jvalue * java_data, void const * uno_data, 1222cdf0e10cSrcweir typelib_TypeDescriptionReference * type, 1223cdf0e10cSrcweir JNI_type_info const * info /* maybe 0 */, 1224cdf0e10cSrcweir bool in_param, bool out_param, 1225cdf0e10cSrcweir bool special_wrapped_integral_types ) const 1226cdf0e10cSrcweir { 1227cdf0e10cSrcweir switch (type->eTypeClass) 1228cdf0e10cSrcweir { 1229cdf0e10cSrcweir case typelib_TypeClass_CHAR: 1230cdf0e10cSrcweir if (out_param) 1231cdf0e10cSrcweir { 1232cdf0e10cSrcweir if (0 == java_data->l) 1233cdf0e10cSrcweir { 1234cdf0e10cSrcweir JLocalAutoRef jo_ar( jni, jni->NewCharArray( 1 ) ); 1235cdf0e10cSrcweir jni.ensure_no_exception(); 1236cdf0e10cSrcweir if (in_param) 1237cdf0e10cSrcweir { 1238cdf0e10cSrcweir jni->SetCharArrayRegion( 1239cdf0e10cSrcweir (jcharArray) jo_ar.get(), 0, 1, (jchar *) uno_data ); 1240cdf0e10cSrcweir jni.ensure_no_exception(); 1241cdf0e10cSrcweir } 1242cdf0e10cSrcweir java_data->l = jo_ar.release(); 1243cdf0e10cSrcweir } 1244cdf0e10cSrcweir else 1245cdf0e10cSrcweir { 1246cdf0e10cSrcweir if (in_param) 1247cdf0e10cSrcweir { 1248cdf0e10cSrcweir jni->SetCharArrayRegion( 1249cdf0e10cSrcweir (jcharArray) java_data->l, 0, 1, (jchar *) uno_data ); 1250cdf0e10cSrcweir jni.ensure_no_exception(); 1251cdf0e10cSrcweir } 1252cdf0e10cSrcweir } 1253cdf0e10cSrcweir } 1254cdf0e10cSrcweir else if (special_wrapped_integral_types) 1255cdf0e10cSrcweir { 1256cdf0e10cSrcweir jvalue arg; 1257cdf0e10cSrcweir arg.c = *(jchar const *) uno_data; 1258cdf0e10cSrcweir java_data->l = jni->NewObjectA( 1259cdf0e10cSrcweir m_jni_info->m_class_Character, 1260cdf0e10cSrcweir m_jni_info->m_ctor_Character_with_char, &arg ); 1261cdf0e10cSrcweir jni.ensure_no_exception(); 1262cdf0e10cSrcweir } 1263cdf0e10cSrcweir else 1264cdf0e10cSrcweir { 1265cdf0e10cSrcweir java_data->c = *(jchar const *) uno_data; 1266cdf0e10cSrcweir } 1267cdf0e10cSrcweir break; 1268cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN: 1269cdf0e10cSrcweir if (out_param) 1270cdf0e10cSrcweir { 1271cdf0e10cSrcweir if (0 == java_data->l) 1272cdf0e10cSrcweir { 1273cdf0e10cSrcweir JLocalAutoRef jo_ar( jni, jni->NewBooleanArray( 1 ) ); 1274cdf0e10cSrcweir jni.ensure_no_exception(); 1275cdf0e10cSrcweir if (in_param) 1276cdf0e10cSrcweir { 1277cdf0e10cSrcweir jni->SetBooleanArrayRegion( 1278cdf0e10cSrcweir (jbooleanArray) jo_ar.get(), 1279cdf0e10cSrcweir 0, 1, (jboolean *) uno_data ); 1280cdf0e10cSrcweir jni.ensure_no_exception(); 1281cdf0e10cSrcweir } 1282cdf0e10cSrcweir java_data->l = jo_ar.release(); 1283cdf0e10cSrcweir } 1284cdf0e10cSrcweir else 1285cdf0e10cSrcweir { 1286cdf0e10cSrcweir if (in_param) 1287cdf0e10cSrcweir { 1288cdf0e10cSrcweir jni->SetBooleanArrayRegion( 1289cdf0e10cSrcweir (jbooleanArray) java_data->l, 1290cdf0e10cSrcweir 0, 1, (jboolean *) uno_data ); 1291cdf0e10cSrcweir jni.ensure_no_exception(); 1292cdf0e10cSrcweir } 1293cdf0e10cSrcweir } 1294cdf0e10cSrcweir } 1295cdf0e10cSrcweir else if (special_wrapped_integral_types) 1296cdf0e10cSrcweir { 1297cdf0e10cSrcweir jvalue arg; 1298cdf0e10cSrcweir arg.z = *(jboolean const *) uno_data; 1299cdf0e10cSrcweir java_data->l = jni->NewObjectA( 1300cdf0e10cSrcweir m_jni_info->m_class_Boolean, 1301cdf0e10cSrcweir m_jni_info->m_ctor_Boolean_with_boolean, &arg ); 1302cdf0e10cSrcweir jni.ensure_no_exception(); 1303cdf0e10cSrcweir } 1304cdf0e10cSrcweir else 1305cdf0e10cSrcweir { 1306cdf0e10cSrcweir java_data->z = *(jboolean const *) uno_data; 1307cdf0e10cSrcweir } 1308cdf0e10cSrcweir break; 1309cdf0e10cSrcweir case typelib_TypeClass_BYTE: 1310cdf0e10cSrcweir if (out_param) 1311cdf0e10cSrcweir { 1312cdf0e10cSrcweir if (0 == java_data->l) 1313cdf0e10cSrcweir { 1314cdf0e10cSrcweir JLocalAutoRef jo_ar( jni, jni->NewByteArray( 1 ) ); 1315cdf0e10cSrcweir jni.ensure_no_exception(); 1316cdf0e10cSrcweir if (in_param) 1317cdf0e10cSrcweir { 1318cdf0e10cSrcweir jni->SetByteArrayRegion( 1319cdf0e10cSrcweir (jbyteArray) jo_ar.get(), 0, 1, (jbyte *) uno_data ); 1320cdf0e10cSrcweir jni.ensure_no_exception(); 1321cdf0e10cSrcweir } 1322cdf0e10cSrcweir java_data->l = jo_ar.release(); 1323cdf0e10cSrcweir } 1324cdf0e10cSrcweir else 1325cdf0e10cSrcweir { 1326cdf0e10cSrcweir if (in_param) 1327cdf0e10cSrcweir { 1328cdf0e10cSrcweir jni->SetByteArrayRegion( 1329cdf0e10cSrcweir (jbyteArray) java_data->l, 0, 1, (jbyte *) uno_data ); 1330cdf0e10cSrcweir jni.ensure_no_exception(); 1331cdf0e10cSrcweir } 1332cdf0e10cSrcweir } 1333cdf0e10cSrcweir } 1334cdf0e10cSrcweir else if (special_wrapped_integral_types) 1335cdf0e10cSrcweir { 1336cdf0e10cSrcweir jvalue arg; 1337cdf0e10cSrcweir arg.b = *(jbyte const *) uno_data; 1338cdf0e10cSrcweir java_data->l = jni->NewObjectA( 1339cdf0e10cSrcweir m_jni_info->m_class_Byte, 1340cdf0e10cSrcweir m_jni_info->m_ctor_Byte_with_byte, &arg ); 1341cdf0e10cSrcweir jni.ensure_no_exception(); 1342cdf0e10cSrcweir } 1343cdf0e10cSrcweir else 1344cdf0e10cSrcweir { 1345cdf0e10cSrcweir java_data->b = *(jbyte const *) uno_data; 1346cdf0e10cSrcweir } 1347cdf0e10cSrcweir break; 1348cdf0e10cSrcweir case typelib_TypeClass_SHORT: 1349cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 1350cdf0e10cSrcweir if (out_param) 1351cdf0e10cSrcweir { 1352cdf0e10cSrcweir if (0 == java_data->l) 1353cdf0e10cSrcweir { 1354cdf0e10cSrcweir JLocalAutoRef jo_ar( jni, jni->NewShortArray( 1 ) ); 1355cdf0e10cSrcweir jni.ensure_no_exception(); 1356cdf0e10cSrcweir if (in_param) 1357cdf0e10cSrcweir { 1358cdf0e10cSrcweir jni->SetShortArrayRegion( 1359cdf0e10cSrcweir (jshortArray) jo_ar.get(), 0, 1, (jshort *) uno_data ); 1360cdf0e10cSrcweir jni.ensure_no_exception(); 1361cdf0e10cSrcweir } 1362cdf0e10cSrcweir java_data->l = jo_ar.release(); 1363cdf0e10cSrcweir } 1364cdf0e10cSrcweir else 1365cdf0e10cSrcweir { 1366cdf0e10cSrcweir if (in_param) 1367cdf0e10cSrcweir { 1368cdf0e10cSrcweir jni->SetShortArrayRegion( 1369cdf0e10cSrcweir (jshortArray) java_data->l, 0, 1, (jshort *) uno_data ); 1370cdf0e10cSrcweir jni.ensure_no_exception(); 1371cdf0e10cSrcweir } 1372cdf0e10cSrcweir } 1373cdf0e10cSrcweir } 1374cdf0e10cSrcweir else if (special_wrapped_integral_types) 1375cdf0e10cSrcweir { 1376cdf0e10cSrcweir jvalue arg; 1377cdf0e10cSrcweir arg.s = *(jshort const *) uno_data; 1378cdf0e10cSrcweir java_data->l = jni->NewObjectA( 1379cdf0e10cSrcweir m_jni_info->m_class_Short, 1380cdf0e10cSrcweir m_jni_info->m_ctor_Short_with_short, &arg ); 1381cdf0e10cSrcweir jni.ensure_no_exception(); 1382cdf0e10cSrcweir } 1383cdf0e10cSrcweir else 1384cdf0e10cSrcweir { 1385cdf0e10cSrcweir java_data->s = *(jshort const *) uno_data; 1386cdf0e10cSrcweir } 1387cdf0e10cSrcweir break; 1388cdf0e10cSrcweir case typelib_TypeClass_LONG: 1389cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 1390cdf0e10cSrcweir if (out_param) 1391cdf0e10cSrcweir { 1392cdf0e10cSrcweir if (0 == java_data->l) 1393cdf0e10cSrcweir { 1394cdf0e10cSrcweir JLocalAutoRef jo_ar( jni, jni->NewIntArray( 1 ) ); 1395cdf0e10cSrcweir jni.ensure_no_exception(); 1396cdf0e10cSrcweir if (in_param) 1397cdf0e10cSrcweir { 1398cdf0e10cSrcweir jni->SetIntArrayRegion( 1399cdf0e10cSrcweir (jintArray) jo_ar.get(), 0, 1, (jint *) uno_data ); 1400cdf0e10cSrcweir jni.ensure_no_exception(); 1401cdf0e10cSrcweir } 1402cdf0e10cSrcweir java_data->l = jo_ar.release(); 1403cdf0e10cSrcweir } 1404cdf0e10cSrcweir else 1405cdf0e10cSrcweir { 1406cdf0e10cSrcweir if (in_param) 1407cdf0e10cSrcweir { 1408cdf0e10cSrcweir jni->SetIntArrayRegion( 1409cdf0e10cSrcweir (jintArray) java_data->l, 0, 1, (jint *) uno_data ); 1410cdf0e10cSrcweir jni.ensure_no_exception(); 1411cdf0e10cSrcweir } 1412cdf0e10cSrcweir } 1413cdf0e10cSrcweir } 1414cdf0e10cSrcweir else if (special_wrapped_integral_types) 1415cdf0e10cSrcweir { 1416cdf0e10cSrcweir jvalue arg; 1417cdf0e10cSrcweir arg.i = *(jint const *) uno_data; 1418cdf0e10cSrcweir java_data->l = jni->NewObjectA( 1419cdf0e10cSrcweir m_jni_info->m_class_Integer, 1420cdf0e10cSrcweir m_jni_info->m_ctor_Integer_with_int, &arg ); 1421cdf0e10cSrcweir jni.ensure_no_exception(); 1422cdf0e10cSrcweir } 1423cdf0e10cSrcweir else 1424cdf0e10cSrcweir { 1425cdf0e10cSrcweir java_data->i = *(jint const *) uno_data; 1426cdf0e10cSrcweir } 1427cdf0e10cSrcweir break; 1428cdf0e10cSrcweir case typelib_TypeClass_HYPER: 1429cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 1430cdf0e10cSrcweir if (out_param) 1431cdf0e10cSrcweir { 1432cdf0e10cSrcweir if (0 == java_data->l) 1433cdf0e10cSrcweir { 1434cdf0e10cSrcweir JLocalAutoRef jo_ar( jni, jni->NewLongArray( 1 ) ); 1435cdf0e10cSrcweir jni.ensure_no_exception(); 1436cdf0e10cSrcweir if (in_param) 1437cdf0e10cSrcweir { 1438cdf0e10cSrcweir jni->SetLongArrayRegion( 1439cdf0e10cSrcweir (jlongArray)jo_ar.get(), 0, 1, (jlong *) uno_data ); 1440cdf0e10cSrcweir jni.ensure_no_exception(); 1441cdf0e10cSrcweir } 1442cdf0e10cSrcweir java_data->l = jo_ar.release(); 1443cdf0e10cSrcweir } 1444cdf0e10cSrcweir else 1445cdf0e10cSrcweir { 1446cdf0e10cSrcweir if (in_param) 1447cdf0e10cSrcweir { 1448cdf0e10cSrcweir jni->SetLongArrayRegion( 1449cdf0e10cSrcweir (jlongArray)java_data->l, 0, 1, (jlong *) uno_data ); 1450cdf0e10cSrcweir jni.ensure_no_exception(); 1451cdf0e10cSrcweir } 1452cdf0e10cSrcweir } 1453cdf0e10cSrcweir } 1454cdf0e10cSrcweir else if (special_wrapped_integral_types) 1455cdf0e10cSrcweir { 1456cdf0e10cSrcweir jvalue arg; 1457cdf0e10cSrcweir arg.j = *(jlong const *) uno_data; 1458cdf0e10cSrcweir java_data->l = jni->NewObjectA( 1459cdf0e10cSrcweir m_jni_info->m_class_Long, 1460cdf0e10cSrcweir m_jni_info->m_ctor_Long_with_long, &arg ); 1461cdf0e10cSrcweir jni.ensure_no_exception(); 1462cdf0e10cSrcweir } 1463cdf0e10cSrcweir else 1464cdf0e10cSrcweir { 1465cdf0e10cSrcweir java_data->j = *(jlong const *) uno_data; 1466cdf0e10cSrcweir } 1467cdf0e10cSrcweir break; 1468cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 1469cdf0e10cSrcweir if (out_param) 1470cdf0e10cSrcweir { 1471cdf0e10cSrcweir if (0 == java_data->l) 1472cdf0e10cSrcweir { 1473cdf0e10cSrcweir JLocalAutoRef jo_ar( jni, jni->NewFloatArray( 1 ) ); 1474cdf0e10cSrcweir jni.ensure_no_exception(); 1475cdf0e10cSrcweir if (in_param) 1476cdf0e10cSrcweir { 1477cdf0e10cSrcweir jni->SetFloatArrayRegion( 1478cdf0e10cSrcweir (jfloatArray) jo_ar.get(), 0, 1, (jfloat *) uno_data ); 1479cdf0e10cSrcweir jni.ensure_no_exception(); 1480cdf0e10cSrcweir } 1481cdf0e10cSrcweir java_data->l = jo_ar.release(); 1482cdf0e10cSrcweir } 1483cdf0e10cSrcweir else 1484cdf0e10cSrcweir { 1485cdf0e10cSrcweir if (in_param) 1486cdf0e10cSrcweir { 1487cdf0e10cSrcweir jni->SetFloatArrayRegion( 1488cdf0e10cSrcweir (jfloatArray) java_data->l, 0, 1, (jfloat *) uno_data ); 1489cdf0e10cSrcweir jni.ensure_no_exception(); 1490cdf0e10cSrcweir } 1491cdf0e10cSrcweir } 1492cdf0e10cSrcweir } 1493cdf0e10cSrcweir else if (special_wrapped_integral_types) 1494cdf0e10cSrcweir { 1495cdf0e10cSrcweir jvalue arg; 1496cdf0e10cSrcweir arg.f = *(jfloat const *) uno_data; 1497cdf0e10cSrcweir java_data->l = jni->NewObjectA( 1498cdf0e10cSrcweir m_jni_info->m_class_Float, 1499cdf0e10cSrcweir m_jni_info->m_ctor_Float_with_float, &arg ); 1500cdf0e10cSrcweir jni.ensure_no_exception(); 1501cdf0e10cSrcweir } 1502cdf0e10cSrcweir else 1503cdf0e10cSrcweir { 1504cdf0e10cSrcweir java_data->f = *(jfloat const *) uno_data; 1505cdf0e10cSrcweir } 1506cdf0e10cSrcweir break; 1507cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 1508cdf0e10cSrcweir if (out_param) 1509cdf0e10cSrcweir { 1510cdf0e10cSrcweir if (0 == java_data->l) 1511cdf0e10cSrcweir { 1512cdf0e10cSrcweir JLocalAutoRef jo_ar( jni, jni->NewDoubleArray( 1 ) ); 1513cdf0e10cSrcweir jni.ensure_no_exception(); 1514cdf0e10cSrcweir if (in_param) 1515cdf0e10cSrcweir { 1516cdf0e10cSrcweir jni->SetDoubleArrayRegion( 1517cdf0e10cSrcweir (jdoubleArray) jo_ar.get(), 1518cdf0e10cSrcweir 0, 1, (jdouble *) uno_data ); 1519cdf0e10cSrcweir jni.ensure_no_exception(); 1520cdf0e10cSrcweir } 1521cdf0e10cSrcweir java_data->l = jo_ar.release(); 1522cdf0e10cSrcweir } 1523cdf0e10cSrcweir else 1524cdf0e10cSrcweir { 1525cdf0e10cSrcweir if (in_param) 1526cdf0e10cSrcweir { 1527cdf0e10cSrcweir jni->SetDoubleArrayRegion( 1528cdf0e10cSrcweir (jdoubleArray) java_data->l, 1529cdf0e10cSrcweir 0, 1, (jdouble *) uno_data ); 1530cdf0e10cSrcweir jni.ensure_no_exception(); 1531cdf0e10cSrcweir } 1532cdf0e10cSrcweir } 1533cdf0e10cSrcweir } 1534cdf0e10cSrcweir else if (special_wrapped_integral_types) 1535cdf0e10cSrcweir { 1536cdf0e10cSrcweir jvalue arg; 1537cdf0e10cSrcweir arg.d = *(double const *)uno_data; 1538cdf0e10cSrcweir java_data->l = jni->NewObjectA( 1539cdf0e10cSrcweir m_jni_info->m_class_Double, 1540cdf0e10cSrcweir m_jni_info->m_ctor_Double_with_double, &arg ); 1541cdf0e10cSrcweir jni.ensure_no_exception(); 1542cdf0e10cSrcweir } 1543cdf0e10cSrcweir else 1544cdf0e10cSrcweir { 1545cdf0e10cSrcweir java_data->d = *(jdouble const *) uno_data; 1546cdf0e10cSrcweir } 1547cdf0e10cSrcweir break; 1548cdf0e10cSrcweir case typelib_TypeClass_STRING: 1549cdf0e10cSrcweir { 1550cdf0e10cSrcweir if (out_param) 1551cdf0e10cSrcweir { 1552cdf0e10cSrcweir JLocalAutoRef jo_in( jni ); 1553cdf0e10cSrcweir if (in_param) 1554cdf0e10cSrcweir { 1555cdf0e10cSrcweir jo_in.reset( 1556cdf0e10cSrcweir ustring_to_jstring( 1557cdf0e10cSrcweir jni, *(rtl_uString * const *) uno_data ) ); 1558cdf0e10cSrcweir } 1559cdf0e10cSrcweir if (0 == java_data->l) 1560cdf0e10cSrcweir { 1561cdf0e10cSrcweir java_data->l = jni->NewObjectArray( 1562cdf0e10cSrcweir 1, m_jni_info->m_class_String, jo_in.get() ); 1563cdf0e10cSrcweir jni.ensure_no_exception(); 1564cdf0e10cSrcweir } 1565cdf0e10cSrcweir else 1566cdf0e10cSrcweir { 1567cdf0e10cSrcweir jni->SetObjectArrayElement( 1568cdf0e10cSrcweir (jobjectArray) java_data->l, 0, jo_in.get() ); 1569cdf0e10cSrcweir jni.ensure_no_exception(); 1570cdf0e10cSrcweir } 1571cdf0e10cSrcweir } 1572cdf0e10cSrcweir else 1573cdf0e10cSrcweir { 1574cdf0e10cSrcweir OSL_ASSERT( in_param ); 1575cdf0e10cSrcweir java_data->l = 1576cdf0e10cSrcweir ustring_to_jstring( jni, *(rtl_uString * const *) uno_data ); 1577cdf0e10cSrcweir } 1578cdf0e10cSrcweir break; 1579cdf0e10cSrcweir } 1580cdf0e10cSrcweir case typelib_TypeClass_TYPE: 1581cdf0e10cSrcweir { 1582cdf0e10cSrcweir if (out_param) 1583cdf0e10cSrcweir { 1584cdf0e10cSrcweir JLocalAutoRef jo_in( jni ); 1585cdf0e10cSrcweir if (in_param) 1586cdf0e10cSrcweir { 1587cdf0e10cSrcweir jo_in.reset( 1588cdf0e10cSrcweir create_type( 1589cdf0e10cSrcweir jni, 1590cdf0e10cSrcweir *(typelib_TypeDescriptionReference * const *) uno_data ) 1591cdf0e10cSrcweir ); 1592cdf0e10cSrcweir } 1593cdf0e10cSrcweir if (0 == java_data->l) 1594cdf0e10cSrcweir { 1595cdf0e10cSrcweir java_data->l = jni->NewObjectArray( 1596cdf0e10cSrcweir 1, m_jni_info->m_class_Type, jo_in.get() ); 1597cdf0e10cSrcweir jni.ensure_no_exception(); 1598cdf0e10cSrcweir } 1599cdf0e10cSrcweir else 1600cdf0e10cSrcweir { 1601cdf0e10cSrcweir jni->SetObjectArrayElement( 1602cdf0e10cSrcweir (jobjectArray) java_data->l, 0, jo_in.get() ); 1603cdf0e10cSrcweir jni.ensure_no_exception(); 1604cdf0e10cSrcweir } 1605cdf0e10cSrcweir } 1606cdf0e10cSrcweir else 1607cdf0e10cSrcweir { 1608cdf0e10cSrcweir OSL_ASSERT( in_param ); 1609cdf0e10cSrcweir java_data->l = 1610cdf0e10cSrcweir create_type( 1611cdf0e10cSrcweir jni, 1612cdf0e10cSrcweir *(typelib_TypeDescriptionReference * const *) uno_data ); 1613cdf0e10cSrcweir } 1614cdf0e10cSrcweir break; 1615cdf0e10cSrcweir } 1616cdf0e10cSrcweir case typelib_TypeClass_ANY: 1617cdf0e10cSrcweir { 1618cdf0e10cSrcweir JLocalAutoRef jo_any( jni ); 1619cdf0e10cSrcweir if (in_param) 1620cdf0e10cSrcweir { 1621cdf0e10cSrcweir uno_Any const * pAny = (uno_Any const *)uno_data; 1622cdf0e10cSrcweir 1623cdf0e10cSrcweir #if defined BRIDGES_JNI_UNO_FORCE_BOXED_ANY 1624cdf0e10cSrcweir if (typelib_TypeClass_VOID == pAny->pType->eTypeClass) 1625cdf0e10cSrcweir { 1626cdf0e10cSrcweir jo_any.reset( 1627cdf0e10cSrcweir jni->NewLocalRef( m_jni_info->m_object_Any_VOID ) ); 1628cdf0e10cSrcweir } 1629cdf0e10cSrcweir else 1630cdf0e10cSrcweir { 1631cdf0e10cSrcweir jvalue args[ 2 ]; 1632cdf0e10cSrcweir map_to_java( 1633cdf0e10cSrcweir jni, &args[ 1 ], pAny->pData, pAny->pType, 0, 1634cdf0e10cSrcweir true /* in */, false /* no out */, 1635cdf0e10cSrcweir true /* create integral wrappers */ ); 1636cdf0e10cSrcweir jo_any.reset( args[ 1 ].l ); 1637cdf0e10cSrcweir // build up com.sun.star.uno.Any 1638cdf0e10cSrcweir JLocalAutoRef jo_type( jni, create_type( jni, pAny->pType ) ); 1639cdf0e10cSrcweir args[ 0 ].l = jo_type.get(); 1640cdf0e10cSrcweir jo_any.reset( 1641cdf0e10cSrcweir jni->NewObjectA( 1642cdf0e10cSrcweir m_jni_info->m_class_Any, 1643cdf0e10cSrcweir m_jni_info->m_ctor_Any_with_Type_Object, args ) ); 1644cdf0e10cSrcweir jni.ensure_no_exception(); 1645cdf0e10cSrcweir } 1646cdf0e10cSrcweir #else 1647cdf0e10cSrcweir switch (pAny->pType->eTypeClass) 1648cdf0e10cSrcweir { 1649cdf0e10cSrcweir case typelib_TypeClass_VOID: 1650cdf0e10cSrcweir jo_any.reset( 1651cdf0e10cSrcweir jni->NewLocalRef( m_jni_info->m_object_Any_VOID ) ); 1652cdf0e10cSrcweir break; 1653cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 1654cdf0e10cSrcweir { 1655cdf0e10cSrcweir jvalue args[ 2 ]; 1656cdf0e10cSrcweir args[ 0 ].s = *(jshort const *) &pAny->pReserved; 1657cdf0e10cSrcweir JLocalAutoRef jo_val( 1658cdf0e10cSrcweir jni, jni->NewObjectA( 1659cdf0e10cSrcweir m_jni_info->m_class_Short, 1660cdf0e10cSrcweir m_jni_info->m_ctor_Short_with_short, args ) ); 1661cdf0e10cSrcweir jni.ensure_no_exception(); 1662cdf0e10cSrcweir // box up in com.sun.star.uno.Any 1663cdf0e10cSrcweir args[ 0 ].l = m_jni_info->m_object_Type_UNSIGNED_SHORT; 1664cdf0e10cSrcweir args[ 1 ].l = jo_val.get(); 1665cdf0e10cSrcweir jo_any.reset( 1666cdf0e10cSrcweir jni->NewObjectA( 1667cdf0e10cSrcweir m_jni_info->m_class_Any, 1668cdf0e10cSrcweir m_jni_info->m_ctor_Any_with_Type_Object, args ) ); 1669cdf0e10cSrcweir jni.ensure_no_exception(); 1670cdf0e10cSrcweir break; 1671cdf0e10cSrcweir } 1672cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 1673cdf0e10cSrcweir { 1674cdf0e10cSrcweir jvalue args[ 2 ]; 1675cdf0e10cSrcweir args[ 0 ].i = *(jint const *) &pAny->pReserved; 1676cdf0e10cSrcweir JLocalAutoRef jo_val( 1677cdf0e10cSrcweir jni, jni->NewObjectA( 1678cdf0e10cSrcweir m_jni_info->m_class_Integer, 1679cdf0e10cSrcweir m_jni_info->m_ctor_Integer_with_int, args ) ); 1680cdf0e10cSrcweir jni.ensure_no_exception(); 1681cdf0e10cSrcweir // box up in com.sun.star.uno.Any 1682cdf0e10cSrcweir args[ 0 ].l = m_jni_info->m_object_Type_UNSIGNED_LONG; 1683cdf0e10cSrcweir args[ 1 ].l = jo_val.get(); 1684cdf0e10cSrcweir jo_any.reset( 1685cdf0e10cSrcweir jni->NewObjectA( 1686cdf0e10cSrcweir m_jni_info->m_class_Any, 1687cdf0e10cSrcweir m_jni_info->m_ctor_Any_with_Type_Object, args ) ); 1688cdf0e10cSrcweir jni.ensure_no_exception(); 1689cdf0e10cSrcweir break; 1690cdf0e10cSrcweir } 1691cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 1692cdf0e10cSrcweir { 1693cdf0e10cSrcweir jvalue args[ 2 ]; 1694cdf0e10cSrcweir args[ 0 ].j = *(jlong const *) pAny->pData; 1695cdf0e10cSrcweir JLocalAutoRef jo_val( 1696cdf0e10cSrcweir jni, jni->NewObjectA( 1697cdf0e10cSrcweir m_jni_info->m_class_Long, 1698cdf0e10cSrcweir m_jni_info->m_ctor_Long_with_long, args ) ); 1699cdf0e10cSrcweir jni.ensure_no_exception(); 1700cdf0e10cSrcweir // box up in com.sun.star.uno.Any 1701cdf0e10cSrcweir args[ 0 ].l = m_jni_info->m_object_Type_UNSIGNED_HYPER; 1702cdf0e10cSrcweir args[ 1 ].l = jo_val.get(); 1703cdf0e10cSrcweir jo_any.reset( 1704cdf0e10cSrcweir jni->NewObjectA( 1705cdf0e10cSrcweir m_jni_info->m_class_Any, 1706cdf0e10cSrcweir m_jni_info->m_ctor_Any_with_Type_Object, args ) ); 1707cdf0e10cSrcweir jni.ensure_no_exception(); 1708cdf0e10cSrcweir break; 1709cdf0e10cSrcweir } 1710cdf0e10cSrcweir case typelib_TypeClass_STRING: // opt strings 1711cdf0e10cSrcweir jo_any.reset( ustring_to_jstring( 1712cdf0e10cSrcweir jni, (rtl_uString *) pAny->pReserved ) ); 1713cdf0e10cSrcweir break; 1714cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 1715cdf0e10cSrcweir { 1716cdf0e10cSrcweir jvalue java_data2; 1717cdf0e10cSrcweir // prefetch sequence td 1718cdf0e10cSrcweir TypeDescr seq_td( pAny->pType ); 1719cdf0e10cSrcweir map_to_java( 1720cdf0e10cSrcweir jni, &java_data2, pAny->pData, seq_td.get()->pWeakRef, 0, 1721cdf0e10cSrcweir true /* in */, false /* no out */, 1722cdf0e10cSrcweir true /* create integral wrappers */ ); 1723cdf0e10cSrcweir jo_any.reset( java_data2.l ); 1724cdf0e10cSrcweir 1725cdf0e10cSrcweir // determine inner element type 1726cdf0e10cSrcweir ::com::sun::star::uno::Type element_type( 1727cdf0e10cSrcweir ((typelib_IndirectTypeDescription *)seq_td.get())->pType ); 1728cdf0e10cSrcweir while (typelib_TypeClass_SEQUENCE == 1729cdf0e10cSrcweir element_type.getTypeLibType()->eTypeClass) 1730cdf0e10cSrcweir { 1731cdf0e10cSrcweir TypeDescr element_td( element_type.getTypeLibType() ); 1732cdf0e10cSrcweir typelib_typedescriptionreference_assign( 1733cdf0e10cSrcweir reinterpret_cast< typelib_TypeDescriptionReference ** >( 1734cdf0e10cSrcweir &element_type ), 1735cdf0e10cSrcweir ((typelib_IndirectTypeDescription *)element_td.get()) 1736cdf0e10cSrcweir ->pType ); 1737cdf0e10cSrcweir } 1738cdf0e10cSrcweir // box up only if unsigned element type 1739cdf0e10cSrcweir switch (element_type.getTypeLibType()->eTypeClass) 1740cdf0e10cSrcweir { 1741cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 1742cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 1743cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 1744cdf0e10cSrcweir { 1745cdf0e10cSrcweir jvalue args[ 2 ]; 1746cdf0e10cSrcweir JLocalAutoRef jo_type( 1747cdf0e10cSrcweir jni, create_type( jni, seq_td.get()->pWeakRef ) ); 1748cdf0e10cSrcweir args[ 0 ].l = jo_type.get(); 1749cdf0e10cSrcweir args[ 1 ].l = jo_any.get(); 1750cdf0e10cSrcweir jo_any.reset( 1751cdf0e10cSrcweir jni->NewObjectA( 1752cdf0e10cSrcweir m_jni_info->m_class_Any, 1753cdf0e10cSrcweir m_jni_info->m_ctor_Any_with_Type_Object, args ) ); 1754cdf0e10cSrcweir jni.ensure_no_exception(); 1755cdf0e10cSrcweir break; 1756cdf0e10cSrcweir } 1757cdf0e10cSrcweir default: 1758cdf0e10cSrcweir break; 1759cdf0e10cSrcweir } 1760cdf0e10cSrcweir break; 1761cdf0e10cSrcweir } 1762cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 1763cdf0e10cSrcweir { 1764cdf0e10cSrcweir uno_Interface * pUnoI = (uno_Interface *)pAny->pReserved; 1765cdf0e10cSrcweir if (is_XInterface( pAny->pType )) 1766cdf0e10cSrcweir { 1767cdf0e10cSrcweir if (0 != pUnoI) 1768cdf0e10cSrcweir { 1769cdf0e10cSrcweir jo_any.reset( 1770cdf0e10cSrcweir map_to_java( 1771cdf0e10cSrcweir jni, pUnoI, 1772cdf0e10cSrcweir m_jni_info->m_XInterface_type_info ) ); 1773cdf0e10cSrcweir } 1774cdf0e10cSrcweir // else: empty XInterface ref maps to null-ref 1775cdf0e10cSrcweir } 1776cdf0e10cSrcweir else 1777cdf0e10cSrcweir { 1778cdf0e10cSrcweir JNI_interface_type_info const * iface_info = 1779cdf0e10cSrcweir static_cast< JNI_interface_type_info const * >( 1780cdf0e10cSrcweir m_jni_info->get_type_info( jni, pAny->pType ) ); 1781cdf0e10cSrcweir if (0 != pUnoI) 1782cdf0e10cSrcweir { 1783cdf0e10cSrcweir jo_any.reset( map_to_java( jni, pUnoI, iface_info ) ); 1784cdf0e10cSrcweir } 1785cdf0e10cSrcweir // box up in com.sun.star.uno.Any 1786cdf0e10cSrcweir jvalue args[ 2 ]; 1787cdf0e10cSrcweir args[ 0 ].l = iface_info->m_type; 1788cdf0e10cSrcweir args[ 1 ].l = jo_any.get(); 1789cdf0e10cSrcweir jo_any.reset( 1790cdf0e10cSrcweir jni->NewObjectA( 1791cdf0e10cSrcweir m_jni_info->m_class_Any, 1792cdf0e10cSrcweir m_jni_info->m_ctor_Any_with_Type_Object, args ) ); 1793cdf0e10cSrcweir jni.ensure_no_exception(); 1794cdf0e10cSrcweir } 1795cdf0e10cSrcweir break; 1796cdf0e10cSrcweir } 1797cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 1798cdf0e10cSrcweir { 1799cdf0e10cSrcweir // Do not lose information about type arguments of instantiated 1800cdf0e10cSrcweir // polymorphic struct types: 1801cdf0e10cSrcweir rtl::OUString const & name = rtl::OUString::unacquired( 1802cdf0e10cSrcweir &pAny->pType->pTypeName); 1803cdf0e10cSrcweir OSL_ASSERT(name.getLength() > 0); 1804cdf0e10cSrcweir if (name[name.getLength() - 1] == '>') 1805cdf0e10cSrcweir { 1806cdf0e10cSrcweir // Box up in com.sun.star.uno.Any: 1807cdf0e10cSrcweir JLocalAutoRef jo_type(jni, create_type(jni, pAny->pType)); 1808cdf0e10cSrcweir jvalue java_data2; 1809cdf0e10cSrcweir map_to_java( 1810cdf0e10cSrcweir jni, &java_data2, pAny->pData, pAny->pType, 0, true, 1811cdf0e10cSrcweir false); 1812cdf0e10cSrcweir jo_any.reset(java_data2.l); 1813cdf0e10cSrcweir jvalue args[2]; 1814cdf0e10cSrcweir args[0].l = jo_type.get(); 1815cdf0e10cSrcweir args[1].l = jo_any.get(); 1816cdf0e10cSrcweir jo_any.reset( 1817cdf0e10cSrcweir jni->NewObjectA( 1818cdf0e10cSrcweir m_jni_info->m_class_Any, 1819cdf0e10cSrcweir m_jni_info->m_ctor_Any_with_Type_Object, args)); 1820cdf0e10cSrcweir jni.ensure_no_exception(); 1821cdf0e10cSrcweir break; 1822cdf0e10cSrcweir } 1823cdf0e10cSrcweir // fall through 1824cdf0e10cSrcweir } 1825cdf0e10cSrcweir default: 1826cdf0e10cSrcweir { 1827cdf0e10cSrcweir jvalue java_data2; 1828cdf0e10cSrcweir map_to_java( 1829cdf0e10cSrcweir jni, &java_data2, pAny->pData, pAny->pType, 0, 1830cdf0e10cSrcweir true /* in */, false /* no out */, 1831cdf0e10cSrcweir true /* create integral wrappers */ ); 1832cdf0e10cSrcweir jo_any.reset( java_data2.l ); 1833cdf0e10cSrcweir break; 1834cdf0e10cSrcweir } 1835cdf0e10cSrcweir } 1836cdf0e10cSrcweir #endif 1837cdf0e10cSrcweir } 1838cdf0e10cSrcweir 1839cdf0e10cSrcweir if (out_param) 1840cdf0e10cSrcweir { 1841cdf0e10cSrcweir if (0 == java_data->l) 1842cdf0e10cSrcweir { 1843cdf0e10cSrcweir java_data->l = jni->NewObjectArray( 1844cdf0e10cSrcweir 1, m_jni_info->m_class_Object, jo_any.get() ); 1845cdf0e10cSrcweir jni.ensure_no_exception(); 1846cdf0e10cSrcweir } 1847cdf0e10cSrcweir else 1848cdf0e10cSrcweir { 1849cdf0e10cSrcweir jni->SetObjectArrayElement( 1850cdf0e10cSrcweir (jobjectArray) java_data->l, 0, jo_any.get() ); 1851cdf0e10cSrcweir jni.ensure_no_exception(); 1852cdf0e10cSrcweir } 1853cdf0e10cSrcweir } 1854cdf0e10cSrcweir else 1855cdf0e10cSrcweir { 1856cdf0e10cSrcweir java_data->l = jo_any.release(); 1857cdf0e10cSrcweir } 1858cdf0e10cSrcweir break; 1859cdf0e10cSrcweir } 1860cdf0e10cSrcweir case typelib_TypeClass_ENUM: 1861cdf0e10cSrcweir { 1862cdf0e10cSrcweir OUString const & type_name = OUString::unacquired( &type->pTypeName ); 1863cdf0e10cSrcweir OString class_name( 1864cdf0e10cSrcweir OUStringToOString( type_name, RTL_TEXTENCODING_JAVA_UTF8 ) ); 1865cdf0e10cSrcweir JLocalAutoRef jo_enum_class( 1866cdf0e10cSrcweir jni, find_class( jni, class_name.getStr() ) ); 1867cdf0e10cSrcweir 1868cdf0e10cSrcweir JLocalAutoRef jo_enum( jni ); 1869cdf0e10cSrcweir if (in_param) 1870cdf0e10cSrcweir { 1871cdf0e10cSrcweir // call static <enum_class>.fromInt( int ) 1872cdf0e10cSrcweir OStringBuffer sig_buf( 5 + class_name.getLength() ); 1873cdf0e10cSrcweir sig_buf.append( RTL_CONSTASCII_STRINGPARAM("(I)L") ); 1874cdf0e10cSrcweir sig_buf.append( class_name.replace( '.', '/' ) ); 1875cdf0e10cSrcweir sig_buf.append( ';' ); 1876cdf0e10cSrcweir OString sig( sig_buf.makeStringAndClear() ); 1877cdf0e10cSrcweir jmethodID method_id = jni->GetStaticMethodID( 1878cdf0e10cSrcweir (jclass) jo_enum_class.get(), "fromInt", sig.getStr() ); 1879cdf0e10cSrcweir jni.ensure_no_exception(); 1880cdf0e10cSrcweir OSL_ASSERT( 0 != method_id ); 1881cdf0e10cSrcweir 1882cdf0e10cSrcweir jvalue arg; 1883cdf0e10cSrcweir arg.i = *(jint const *) uno_data; 1884cdf0e10cSrcweir jo_enum.reset( 1885cdf0e10cSrcweir jni->CallStaticObjectMethodA( 1886cdf0e10cSrcweir (jclass) jo_enum_class.get(), method_id, &arg ) ); 1887cdf0e10cSrcweir jni.ensure_no_exception(); 1888cdf0e10cSrcweir } 1889cdf0e10cSrcweir if (out_param) 1890cdf0e10cSrcweir { 1891cdf0e10cSrcweir if (0 == java_data->l) 1892cdf0e10cSrcweir { 1893cdf0e10cSrcweir java_data->l = jni->NewObjectArray( 1894cdf0e10cSrcweir 1, (jclass) jo_enum_class.get(), jo_enum.get() ); 1895cdf0e10cSrcweir jni.ensure_no_exception(); 1896cdf0e10cSrcweir } 1897cdf0e10cSrcweir else 1898cdf0e10cSrcweir { 1899cdf0e10cSrcweir jni->SetObjectArrayElement( 1900cdf0e10cSrcweir (jobjectArray) java_data->l, 0, jo_enum.get() ); 1901cdf0e10cSrcweir jni.ensure_no_exception(); 1902cdf0e10cSrcweir } 1903cdf0e10cSrcweir } 1904cdf0e10cSrcweir else 1905cdf0e10cSrcweir { 1906cdf0e10cSrcweir java_data->l = jo_enum.release(); 1907cdf0e10cSrcweir } 1908cdf0e10cSrcweir break; 1909cdf0e10cSrcweir } 1910cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 1911cdf0e10cSrcweir case typelib_TypeClass_EXCEPTION: 1912cdf0e10cSrcweir { 1913cdf0e10cSrcweir if (0 == info) 1914cdf0e10cSrcweir info = m_jni_info->get_type_info( jni, type ); 1915cdf0e10cSrcweir JNI_compound_type_info const * comp_info = 1916cdf0e10cSrcweir static_cast< JNI_compound_type_info const * >( info ); 1917cdf0e10cSrcweir 1918cdf0e10cSrcweir JLocalAutoRef jo_comp( jni ); 1919cdf0e10cSrcweir if (in_param) 1920cdf0e10cSrcweir { 1921cdf0e10cSrcweir if (typelib_TypeClass_EXCEPTION == type->eTypeClass) 1922cdf0e10cSrcweir { 1923cdf0e10cSrcweir JLocalAutoRef jo_message( 1924cdf0e10cSrcweir jni, ustring_to_jstring( jni, *(rtl_uString **)uno_data ) ); 1925cdf0e10cSrcweir jvalue arg; 1926cdf0e10cSrcweir arg.l = jo_message.get(); 1927cdf0e10cSrcweir jo_comp.reset( 1928cdf0e10cSrcweir jni->NewObjectA( 1929cdf0e10cSrcweir comp_info->m_class, comp_info->m_exc_ctor, &arg ) ); 1930cdf0e10cSrcweir jni.ensure_no_exception(); 1931cdf0e10cSrcweir } 1932cdf0e10cSrcweir else 1933cdf0e10cSrcweir { 1934cdf0e10cSrcweir jo_comp.reset( jni->AllocObject( comp_info->m_class ) ); 1935cdf0e10cSrcweir jni.ensure_no_exception(); 1936cdf0e10cSrcweir } 1937cdf0e10cSrcweir 1938cdf0e10cSrcweir for ( JNI_compound_type_info const * linfo = comp_info; 1939cdf0e10cSrcweir 0 != linfo; 1940cdf0e10cSrcweir linfo = static_cast< JNI_compound_type_info const * >( 1941cdf0e10cSrcweir linfo->m_base ) ) 1942cdf0e10cSrcweir { 1943cdf0e10cSrcweir typelib_CompoundTypeDescription * comp_td = 1944cdf0e10cSrcweir (typelib_CompoundTypeDescription *)linfo->m_td.get(); 1945cdf0e10cSrcweir typelib_TypeDescriptionReference ** ppMemberTypeRefs = 1946cdf0e10cSrcweir comp_td->ppTypeRefs; 1947cdf0e10cSrcweir sal_Int32 * pMemberOffsets = comp_td->pMemberOffsets; 1948cdf0e10cSrcweir bool polymorphic 1949cdf0e10cSrcweir = comp_td->aBase.eTypeClass == typelib_TypeClass_STRUCT 1950cdf0e10cSrcweir && reinterpret_cast< typelib_StructTypeDescription * >( 1951cdf0e10cSrcweir comp_td)->pParameterizedTypes != 0; 1952cdf0e10cSrcweir for ( sal_Int32 nPos = comp_td->nMembers; nPos--; ) 1953cdf0e10cSrcweir { 1954cdf0e10cSrcweir jfieldID field_id = linfo->m_fields[ nPos ]; 1955cdf0e10cSrcweir if (0 != field_id) 1956cdf0e10cSrcweir { 1957cdf0e10cSrcweir void const * p = 1958cdf0e10cSrcweir (char const *)uno_data + pMemberOffsets[ nPos ]; 1959cdf0e10cSrcweir typelib_TypeDescriptionReference * member_type = 1960cdf0e10cSrcweir ppMemberTypeRefs[ nPos ]; 1961cdf0e10cSrcweir bool parameterizedType = polymorphic 1962cdf0e10cSrcweir && (reinterpret_cast< 1963cdf0e10cSrcweir typelib_StructTypeDescription * >(comp_td)-> 1964cdf0e10cSrcweir pParameterizedTypes[nPos]); 1965cdf0e10cSrcweir switch (member_type->eTypeClass) 1966cdf0e10cSrcweir { 1967cdf0e10cSrcweir case typelib_TypeClass_CHAR: 1968cdf0e10cSrcweir if (parameterizedType) { 1969cdf0e10cSrcweir jvalue arg; 1970cdf0e10cSrcweir arg.c = *(jchar const *) p; 1971cdf0e10cSrcweir JLocalAutoRef jo( 1972cdf0e10cSrcweir jni, 1973cdf0e10cSrcweir jni->NewObjectA( 1974cdf0e10cSrcweir m_jni_info->m_class_Character, 1975cdf0e10cSrcweir m_jni_info->m_ctor_Character_with_char, 1976cdf0e10cSrcweir &arg ) ); 1977cdf0e10cSrcweir jni.ensure_no_exception(); 1978cdf0e10cSrcweir jni->SetObjectField( 1979cdf0e10cSrcweir jo_comp.get(), field_id, jo.get() ); 1980cdf0e10cSrcweir } else { 1981cdf0e10cSrcweir jni->SetCharField( 1982cdf0e10cSrcweir jo_comp.get(), 1983cdf0e10cSrcweir field_id, *(jchar const *) p ); 1984cdf0e10cSrcweir } 1985cdf0e10cSrcweir break; 1986cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN: 1987cdf0e10cSrcweir if (parameterizedType) { 1988cdf0e10cSrcweir jvalue arg; 1989cdf0e10cSrcweir arg.z = *(jboolean const *) p; 1990cdf0e10cSrcweir JLocalAutoRef jo( 1991cdf0e10cSrcweir jni, 1992cdf0e10cSrcweir jni->NewObjectA( 1993cdf0e10cSrcweir m_jni_info->m_class_Boolean, 1994cdf0e10cSrcweir m_jni_info->m_ctor_Boolean_with_boolean, 1995cdf0e10cSrcweir &arg ) ); 1996cdf0e10cSrcweir jni.ensure_no_exception(); 1997cdf0e10cSrcweir jni->SetObjectField( 1998cdf0e10cSrcweir jo_comp.get(), field_id, jo.get() ); 1999cdf0e10cSrcweir } else { 2000cdf0e10cSrcweir jni->SetBooleanField( 2001cdf0e10cSrcweir jo_comp.get(), 2002cdf0e10cSrcweir field_id, *(jboolean const *) p ); 2003cdf0e10cSrcweir } 2004cdf0e10cSrcweir break; 2005cdf0e10cSrcweir case typelib_TypeClass_BYTE: 2006cdf0e10cSrcweir if (parameterizedType) { 2007cdf0e10cSrcweir jvalue arg; 2008cdf0e10cSrcweir arg.b = *(jbyte const *) p; 2009cdf0e10cSrcweir JLocalAutoRef jo( 2010cdf0e10cSrcweir jni, 2011cdf0e10cSrcweir jni->NewObjectA( 2012cdf0e10cSrcweir m_jni_info->m_class_Byte, 2013cdf0e10cSrcweir m_jni_info->m_ctor_Byte_with_byte, 2014cdf0e10cSrcweir &arg ) ); 2015cdf0e10cSrcweir jni.ensure_no_exception(); 2016cdf0e10cSrcweir jni->SetObjectField( 2017cdf0e10cSrcweir jo_comp.get(), field_id, jo.get() ); 2018cdf0e10cSrcweir } else { 2019cdf0e10cSrcweir jni->SetByteField( 2020cdf0e10cSrcweir jo_comp.get(), 2021cdf0e10cSrcweir field_id, *(jbyte const *) p ); 2022cdf0e10cSrcweir } 2023cdf0e10cSrcweir break; 2024cdf0e10cSrcweir case typelib_TypeClass_SHORT: 2025cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 2026cdf0e10cSrcweir if (parameterizedType) { 2027cdf0e10cSrcweir jvalue arg; 2028cdf0e10cSrcweir arg.s = *(jshort const *) p; 2029cdf0e10cSrcweir JLocalAutoRef jo( 2030cdf0e10cSrcweir jni, 2031cdf0e10cSrcweir jni->NewObjectA( 2032cdf0e10cSrcweir m_jni_info->m_class_Short, 2033cdf0e10cSrcweir m_jni_info->m_ctor_Short_with_short, 2034cdf0e10cSrcweir &arg ) ); 2035cdf0e10cSrcweir jni.ensure_no_exception(); 2036cdf0e10cSrcweir jni->SetObjectField( 2037cdf0e10cSrcweir jo_comp.get(), field_id, jo.get() ); 2038cdf0e10cSrcweir } else { 2039cdf0e10cSrcweir jni->SetShortField( 2040cdf0e10cSrcweir jo_comp.get(), 2041cdf0e10cSrcweir field_id, *(jshort const *) p ); 2042cdf0e10cSrcweir } 2043cdf0e10cSrcweir break; 2044cdf0e10cSrcweir case typelib_TypeClass_LONG: 2045cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 2046cdf0e10cSrcweir if (parameterizedType) { 2047cdf0e10cSrcweir jvalue arg; 2048cdf0e10cSrcweir arg.i = *(jint const *) p; 2049cdf0e10cSrcweir JLocalAutoRef jo( 2050cdf0e10cSrcweir jni, 2051cdf0e10cSrcweir jni->NewObjectA( 2052cdf0e10cSrcweir m_jni_info->m_class_Integer, 2053cdf0e10cSrcweir m_jni_info->m_ctor_Integer_with_int, 2054cdf0e10cSrcweir &arg ) ); 2055cdf0e10cSrcweir jni.ensure_no_exception(); 2056cdf0e10cSrcweir jni->SetObjectField( 2057cdf0e10cSrcweir jo_comp.get(), field_id, jo.get() ); 2058cdf0e10cSrcweir } else { 2059cdf0e10cSrcweir jni->SetIntField( 2060cdf0e10cSrcweir jo_comp.get(), 2061cdf0e10cSrcweir field_id, *(jint const *) p ); 2062cdf0e10cSrcweir } 2063cdf0e10cSrcweir break; 2064cdf0e10cSrcweir case typelib_TypeClass_HYPER: 2065cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 2066cdf0e10cSrcweir if (parameterizedType) { 2067cdf0e10cSrcweir jvalue arg; 2068cdf0e10cSrcweir arg.j = *(jlong const *) p; 2069cdf0e10cSrcweir JLocalAutoRef jo( 2070cdf0e10cSrcweir jni, 2071cdf0e10cSrcweir jni->NewObjectA( 2072cdf0e10cSrcweir m_jni_info->m_class_Long, 2073cdf0e10cSrcweir m_jni_info->m_ctor_Long_with_long, 2074cdf0e10cSrcweir &arg ) ); 2075cdf0e10cSrcweir jni.ensure_no_exception(); 2076cdf0e10cSrcweir jni->SetObjectField( 2077cdf0e10cSrcweir jo_comp.get(), field_id, jo.get() ); 2078cdf0e10cSrcweir } else { 2079cdf0e10cSrcweir jni->SetLongField( 2080cdf0e10cSrcweir jo_comp.get(), 2081cdf0e10cSrcweir field_id, *(jlong const *) p ); 2082cdf0e10cSrcweir } 2083cdf0e10cSrcweir break; 2084cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 2085cdf0e10cSrcweir if (parameterizedType) { 2086cdf0e10cSrcweir jvalue arg; 2087cdf0e10cSrcweir arg.f = *(jfloat const *) p; 2088cdf0e10cSrcweir JLocalAutoRef jo( 2089cdf0e10cSrcweir jni, 2090cdf0e10cSrcweir jni->NewObjectA( 2091cdf0e10cSrcweir m_jni_info->m_class_Float, 2092cdf0e10cSrcweir m_jni_info->m_ctor_Float_with_float, 2093cdf0e10cSrcweir &arg ) ); 2094cdf0e10cSrcweir jni.ensure_no_exception(); 2095cdf0e10cSrcweir jni->SetObjectField( 2096cdf0e10cSrcweir jo_comp.get(), field_id, jo.get() ); 2097cdf0e10cSrcweir } else { 2098cdf0e10cSrcweir jni->SetFloatField( 2099cdf0e10cSrcweir jo_comp.get(), 2100cdf0e10cSrcweir field_id, *(jfloat const *) p ); 2101cdf0e10cSrcweir } 2102cdf0e10cSrcweir break; 2103cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 2104cdf0e10cSrcweir if (parameterizedType) { 2105cdf0e10cSrcweir jvalue arg; 2106cdf0e10cSrcweir arg.d = *(jdouble const *) p; 2107cdf0e10cSrcweir JLocalAutoRef jo( 2108cdf0e10cSrcweir jni, 2109cdf0e10cSrcweir jni->NewObjectA( 2110cdf0e10cSrcweir m_jni_info->m_class_Double, 2111cdf0e10cSrcweir m_jni_info->m_ctor_Double_with_double, 2112cdf0e10cSrcweir &arg ) ); 2113cdf0e10cSrcweir jni.ensure_no_exception(); 2114cdf0e10cSrcweir jni->SetObjectField( 2115cdf0e10cSrcweir jo_comp.get(), field_id, jo.get() ); 2116cdf0e10cSrcweir } else { 2117cdf0e10cSrcweir jni->SetDoubleField( 2118cdf0e10cSrcweir jo_comp.get(), 2119cdf0e10cSrcweir field_id, *(jdouble const *) p ); 2120cdf0e10cSrcweir } 2121cdf0e10cSrcweir break; 2122cdf0e10cSrcweir case typelib_TypeClass_STRING: // string opt here 2123cdf0e10cSrcweir { 2124cdf0e10cSrcweir JLocalAutoRef jo_string( 2125cdf0e10cSrcweir jni, ustring_to_jstring( 2126cdf0e10cSrcweir jni, *(rtl_uString * const *) p ) ); 2127cdf0e10cSrcweir jni->SetObjectField( 2128cdf0e10cSrcweir jo_comp.get(), field_id, jo_string.get() ); 2129cdf0e10cSrcweir break; 2130cdf0e10cSrcweir } 2131cdf0e10cSrcweir default: 2132cdf0e10cSrcweir { 2133cdf0e10cSrcweir jvalue java_data2; 2134cdf0e10cSrcweir map_to_java( 2135cdf0e10cSrcweir jni, &java_data2, p, member_type, 0, 2136cdf0e10cSrcweir true /* in */, false /* no out */ ); 2137cdf0e10cSrcweir JLocalAutoRef jo_obj( jni, java_data2.l ); 2138cdf0e10cSrcweir jni->SetObjectField( 2139cdf0e10cSrcweir jo_comp.get(), field_id, jo_obj.get() ); 2140cdf0e10cSrcweir break; 2141cdf0e10cSrcweir } 2142cdf0e10cSrcweir } 2143cdf0e10cSrcweir } 2144cdf0e10cSrcweir } 2145cdf0e10cSrcweir } 2146cdf0e10cSrcweir } 2147cdf0e10cSrcweir if (out_param) 2148cdf0e10cSrcweir { 2149cdf0e10cSrcweir if (0 == java_data->l) 2150cdf0e10cSrcweir { 2151cdf0e10cSrcweir java_data->l = 2152cdf0e10cSrcweir jni->NewObjectArray( 1, comp_info->m_class, jo_comp.get() ); 2153cdf0e10cSrcweir jni.ensure_no_exception(); 2154cdf0e10cSrcweir } 2155cdf0e10cSrcweir else 2156cdf0e10cSrcweir { 2157cdf0e10cSrcweir jni->SetObjectArrayElement( 2158cdf0e10cSrcweir (jobjectArray) java_data->l, 0, jo_comp.get() ); 2159cdf0e10cSrcweir jni.ensure_no_exception(); 2160cdf0e10cSrcweir } 2161cdf0e10cSrcweir } 2162cdf0e10cSrcweir else 2163cdf0e10cSrcweir { 2164cdf0e10cSrcweir java_data->l = jo_comp.release(); 2165cdf0e10cSrcweir } 2166cdf0e10cSrcweir break; 2167cdf0e10cSrcweir } 2168cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 2169cdf0e10cSrcweir { 2170cdf0e10cSrcweir // xxx todo: possible opt for pure out sequences 2171cdf0e10cSrcweir JLocalAutoRef jo_ar( jni ); 2172cdf0e10cSrcweir 2173cdf0e10cSrcweir sal_Int32 nElements; 2174cdf0e10cSrcweir uno_Sequence const * seq = 0; 2175cdf0e10cSrcweir if (in_param) 2176cdf0e10cSrcweir { 2177cdf0e10cSrcweir seq = *(uno_Sequence * const *)uno_data; 2178cdf0e10cSrcweir nElements = seq->nElements; 2179cdf0e10cSrcweir } 2180cdf0e10cSrcweir else 2181cdf0e10cSrcweir { 2182cdf0e10cSrcweir nElements = 0; 2183cdf0e10cSrcweir } 2184cdf0e10cSrcweir 2185cdf0e10cSrcweir TypeDescr td( type ); 2186cdf0e10cSrcweir typelib_TypeDescriptionReference * element_type = 2187cdf0e10cSrcweir ((typelib_IndirectTypeDescription *)td.get())->pType; 2188cdf0e10cSrcweir 2189cdf0e10cSrcweir switch (element_type->eTypeClass) 2190cdf0e10cSrcweir { 2191cdf0e10cSrcweir case typelib_TypeClass_CHAR: 2192cdf0e10cSrcweir jo_ar.reset( jni->NewCharArray( nElements ) ); 2193cdf0e10cSrcweir jni.ensure_no_exception(); 2194cdf0e10cSrcweir if (0 < nElements) 2195cdf0e10cSrcweir { 2196cdf0e10cSrcweir jni->SetCharArrayRegion( 2197cdf0e10cSrcweir (jcharArray) jo_ar.get(), 2198cdf0e10cSrcweir 0, nElements, (jchar *) seq->elements ); 2199cdf0e10cSrcweir jni.ensure_no_exception(); 2200cdf0e10cSrcweir } 2201cdf0e10cSrcweir break; 2202cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN: 2203cdf0e10cSrcweir jo_ar.reset( jni->NewBooleanArray( nElements ) ); 2204cdf0e10cSrcweir jni.ensure_no_exception(); 2205cdf0e10cSrcweir if (0 < nElements) 2206cdf0e10cSrcweir { 2207cdf0e10cSrcweir jni->SetBooleanArrayRegion( 2208cdf0e10cSrcweir (jbooleanArray) jo_ar.get(), 2209cdf0e10cSrcweir 0, nElements, (jboolean *) seq->elements ); 2210cdf0e10cSrcweir jni.ensure_no_exception(); 2211cdf0e10cSrcweir } 2212cdf0e10cSrcweir break; 2213cdf0e10cSrcweir case typelib_TypeClass_BYTE: 2214cdf0e10cSrcweir jo_ar.reset( jni->NewByteArray( nElements ) ); 2215cdf0e10cSrcweir jni.ensure_no_exception(); 2216cdf0e10cSrcweir if (0 < nElements) 2217cdf0e10cSrcweir { 2218cdf0e10cSrcweir jni->SetByteArrayRegion( 2219cdf0e10cSrcweir (jbyteArray) jo_ar.get(), 2220cdf0e10cSrcweir 0, nElements, (jbyte *) seq->elements ); 2221cdf0e10cSrcweir jni.ensure_no_exception(); 2222cdf0e10cSrcweir } 2223cdf0e10cSrcweir break; 2224cdf0e10cSrcweir case typelib_TypeClass_SHORT: 2225cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT: 2226cdf0e10cSrcweir jo_ar.reset( jni->NewShortArray( nElements ) ); 2227cdf0e10cSrcweir jni.ensure_no_exception(); 2228cdf0e10cSrcweir if (0 < nElements) 2229cdf0e10cSrcweir { 2230cdf0e10cSrcweir jni->SetShortArrayRegion( 2231cdf0e10cSrcweir (jshortArray) jo_ar.get(), 2232cdf0e10cSrcweir 0, nElements, (jshort *) seq->elements ); 2233cdf0e10cSrcweir jni.ensure_no_exception(); 2234cdf0e10cSrcweir } 2235cdf0e10cSrcweir break; 2236cdf0e10cSrcweir case typelib_TypeClass_LONG: 2237cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_LONG: 2238cdf0e10cSrcweir jo_ar.reset( jni->NewIntArray( nElements ) ); 2239cdf0e10cSrcweir jni.ensure_no_exception(); 2240cdf0e10cSrcweir if (0 < nElements) 2241cdf0e10cSrcweir { 2242cdf0e10cSrcweir jni->SetIntArrayRegion( 2243cdf0e10cSrcweir (jintArray) jo_ar.get(), 2244cdf0e10cSrcweir 0, nElements, (jint *) seq->elements ); 2245cdf0e10cSrcweir jni.ensure_no_exception(); 2246cdf0e10cSrcweir } 2247cdf0e10cSrcweir break; 2248cdf0e10cSrcweir case typelib_TypeClass_HYPER: 2249cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER: 2250cdf0e10cSrcweir jo_ar.reset( jni->NewLongArray( nElements ) ); 2251cdf0e10cSrcweir jni.ensure_no_exception(); 2252cdf0e10cSrcweir if (0 < nElements) 2253cdf0e10cSrcweir { 2254cdf0e10cSrcweir jni->SetLongArrayRegion( 2255cdf0e10cSrcweir (jlongArray) jo_ar.get(), 2256cdf0e10cSrcweir 0, nElements, (jlong *) seq->elements ); 2257cdf0e10cSrcweir jni.ensure_no_exception(); 2258cdf0e10cSrcweir } 2259cdf0e10cSrcweir break; 2260cdf0e10cSrcweir case typelib_TypeClass_FLOAT: 2261cdf0e10cSrcweir jo_ar.reset( jni->NewFloatArray( nElements ) ); 2262cdf0e10cSrcweir jni.ensure_no_exception(); 2263cdf0e10cSrcweir if (0 < nElements) 2264cdf0e10cSrcweir { 2265cdf0e10cSrcweir jni->SetFloatArrayRegion( 2266cdf0e10cSrcweir (jfloatArray) jo_ar.get(), 2267cdf0e10cSrcweir 0, nElements, (jfloat *) seq->elements ); 2268cdf0e10cSrcweir jni.ensure_no_exception(); 2269cdf0e10cSrcweir } 2270cdf0e10cSrcweir break; 2271cdf0e10cSrcweir case typelib_TypeClass_DOUBLE: 2272cdf0e10cSrcweir jo_ar.reset( jni->NewDoubleArray( nElements ) ); 2273cdf0e10cSrcweir jni.ensure_no_exception(); 2274cdf0e10cSrcweir if (0 < nElements) 2275cdf0e10cSrcweir { 2276cdf0e10cSrcweir jni->SetDoubleArrayRegion( 2277cdf0e10cSrcweir (jdoubleArray) jo_ar.get(), 2278cdf0e10cSrcweir 0, nElements, (jdouble *) seq->elements ); 2279cdf0e10cSrcweir jni.ensure_no_exception(); 2280cdf0e10cSrcweir } 2281cdf0e10cSrcweir break; 2282cdf0e10cSrcweir case typelib_TypeClass_STRING: 2283cdf0e10cSrcweir jo_ar.reset( 2284cdf0e10cSrcweir jni->NewObjectArray( 2285cdf0e10cSrcweir nElements, m_jni_info->m_class_String, 0 ) ); 2286cdf0e10cSrcweir jni.ensure_no_exception(); 2287cdf0e10cSrcweir if (in_param) 2288cdf0e10cSrcweir { 2289cdf0e10cSrcweir rtl_uString * const * pp = 2290cdf0e10cSrcweir (rtl_uString * const *) seq->elements; 2291cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) 2292cdf0e10cSrcweir { 2293cdf0e10cSrcweir JLocalAutoRef jo_string( 2294cdf0e10cSrcweir jni, ustring_to_jstring( jni, pp[ nPos ] ) ); 2295cdf0e10cSrcweir jni->SetObjectArrayElement( 2296cdf0e10cSrcweir (jobjectArray) jo_ar.get(), nPos, jo_string.get() ); 2297cdf0e10cSrcweir jni.ensure_no_exception(); 2298cdf0e10cSrcweir } 2299cdf0e10cSrcweir } 2300cdf0e10cSrcweir break; 2301cdf0e10cSrcweir case typelib_TypeClass_TYPE: 2302cdf0e10cSrcweir jo_ar.reset( 2303cdf0e10cSrcweir jni->NewObjectArray( nElements, m_jni_info->m_class_Type, 0 ) ); 2304cdf0e10cSrcweir jni.ensure_no_exception(); 2305cdf0e10cSrcweir if (in_param) 2306cdf0e10cSrcweir { 2307cdf0e10cSrcweir typelib_TypeDescriptionReference * const * pp = 2308cdf0e10cSrcweir (typelib_TypeDescriptionReference * const *)seq->elements; 2309cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) 2310cdf0e10cSrcweir { 2311cdf0e10cSrcweir jvalue val; 2312cdf0e10cSrcweir map_to_java( 2313cdf0e10cSrcweir jni, &val, &pp[ nPos ], element_type, 0, 2314cdf0e10cSrcweir true /* in */, false /* no out */ ); 2315cdf0e10cSrcweir JLocalAutoRef jo_element( jni, val.l ); 2316cdf0e10cSrcweir jni->SetObjectArrayElement( 2317cdf0e10cSrcweir (jobjectArray) jo_ar.get(), nPos, jo_element.get() ); 2318cdf0e10cSrcweir jni.ensure_no_exception(); 2319cdf0e10cSrcweir } 2320cdf0e10cSrcweir } 2321cdf0e10cSrcweir break; 2322cdf0e10cSrcweir case typelib_TypeClass_ANY: 2323cdf0e10cSrcweir jo_ar.reset( 2324cdf0e10cSrcweir jni->NewObjectArray( 2325cdf0e10cSrcweir nElements, m_jni_info->m_class_Object, 0 ) ); 2326cdf0e10cSrcweir jni.ensure_no_exception(); 2327cdf0e10cSrcweir if (in_param) 2328cdf0e10cSrcweir { 2329cdf0e10cSrcweir uno_Any const * p = (uno_Any const *)seq->elements; 2330cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) 2331cdf0e10cSrcweir { 2332cdf0e10cSrcweir jvalue val; 2333cdf0e10cSrcweir map_to_java( 2334cdf0e10cSrcweir jni, &val, &p[ nPos ], element_type, 0, 2335cdf0e10cSrcweir true /* in */, false /* no out */ ); 2336cdf0e10cSrcweir JLocalAutoRef jo_element( jni, val.l ); 2337cdf0e10cSrcweir jni->SetObjectArrayElement( 2338cdf0e10cSrcweir (jobjectArray) jo_ar.get(), nPos, jo_element.get() ); 2339cdf0e10cSrcweir jni.ensure_no_exception(); 2340cdf0e10cSrcweir } 2341cdf0e10cSrcweir } 2342cdf0e10cSrcweir break; 2343cdf0e10cSrcweir case typelib_TypeClass_ENUM: 2344cdf0e10cSrcweir { 2345cdf0e10cSrcweir OUString const & element_type_name = 2346cdf0e10cSrcweir OUString::unacquired( &element_type->pTypeName ); 2347cdf0e10cSrcweir OString class_name( 2348cdf0e10cSrcweir OUStringToOString( 2349cdf0e10cSrcweir element_type_name, RTL_TEXTENCODING_JAVA_UTF8 ) ); 2350cdf0e10cSrcweir JLocalAutoRef jo_enum_class( 2351cdf0e10cSrcweir jni, find_class( jni, class_name.getStr() ) ); 2352cdf0e10cSrcweir 2353cdf0e10cSrcweir jo_ar.reset( 2354cdf0e10cSrcweir jni->NewObjectArray( 2355cdf0e10cSrcweir nElements, (jclass) jo_enum_class.get(), 0 ) ); 2356cdf0e10cSrcweir jni.ensure_no_exception(); 2357cdf0e10cSrcweir 2358cdf0e10cSrcweir if (0 < nElements) 2359cdf0e10cSrcweir { 2360cdf0e10cSrcweir // call static <enum_class>.fromInt( int ) 2361cdf0e10cSrcweir OStringBuffer sig_buf( 5 + class_name.getLength() ); 2362cdf0e10cSrcweir sig_buf.append( RTL_CONSTASCII_STRINGPARAM("(I)L") ); 2363cdf0e10cSrcweir sig_buf.append( class_name.replace( '.', '/' ) ); 2364cdf0e10cSrcweir sig_buf.append( ';' ); 2365cdf0e10cSrcweir OString sig( sig_buf.makeStringAndClear() ); 2366cdf0e10cSrcweir jmethodID method_id = jni->GetStaticMethodID( 2367cdf0e10cSrcweir (jclass) jo_enum_class.get(), "fromInt", sig.getStr() ); 2368cdf0e10cSrcweir jni.ensure_no_exception(); 2369cdf0e10cSrcweir OSL_ASSERT( 0 != method_id ); 2370cdf0e10cSrcweir 2371cdf0e10cSrcweir sal_Int32 const * p = (sal_Int32 const *)seq->elements; 2372cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) 2373cdf0e10cSrcweir { 2374cdf0e10cSrcweir jvalue arg; 2375cdf0e10cSrcweir arg.i = p[ nPos ]; 2376cdf0e10cSrcweir JLocalAutoRef jo_enum( 2377cdf0e10cSrcweir jni, jni->CallStaticObjectMethodA( 2378cdf0e10cSrcweir (jclass) jo_enum_class.get(), method_id, &arg ) ); 2379cdf0e10cSrcweir jni.ensure_no_exception(); 2380cdf0e10cSrcweir jni->SetObjectArrayElement( 2381cdf0e10cSrcweir (jobjectArray) jo_ar.get(), nPos, jo_enum.get() ); 2382cdf0e10cSrcweir jni.ensure_no_exception(); 2383cdf0e10cSrcweir } 2384cdf0e10cSrcweir } 2385cdf0e10cSrcweir break; 2386cdf0e10cSrcweir } 2387cdf0e10cSrcweir case typelib_TypeClass_STRUCT: 2388cdf0e10cSrcweir case typelib_TypeClass_EXCEPTION: 2389cdf0e10cSrcweir { 2390cdf0e10cSrcweir JNI_type_info const * element_info = 2391cdf0e10cSrcweir m_jni_info->get_type_info( jni, element_type ); 2392cdf0e10cSrcweir 2393cdf0e10cSrcweir jo_ar.reset( 2394cdf0e10cSrcweir jni->NewObjectArray( nElements, element_info->m_class, 0 ) ); 2395cdf0e10cSrcweir jni.ensure_no_exception(); 2396cdf0e10cSrcweir 2397cdf0e10cSrcweir if (0 < nElements) 2398cdf0e10cSrcweir { 2399cdf0e10cSrcweir char * p = (char *)seq->elements; 2400cdf0e10cSrcweir sal_Int32 nSize = element_info->m_td.get()->nSize; 2401cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) 2402cdf0e10cSrcweir { 2403cdf0e10cSrcweir jvalue val; 2404cdf0e10cSrcweir map_to_java( 2405cdf0e10cSrcweir jni, &val, p + (nSize * nPos), 2406cdf0e10cSrcweir element_type, element_info, 2407cdf0e10cSrcweir true /* in */, false /* no out */ ); 2408cdf0e10cSrcweir JLocalAutoRef jo_element( jni, val.l ); 2409cdf0e10cSrcweir jni->SetObjectArrayElement( 2410cdf0e10cSrcweir (jobjectArray) jo_ar.get(), nPos, jo_element.get() ); 2411cdf0e10cSrcweir jni.ensure_no_exception(); 2412cdf0e10cSrcweir } 2413cdf0e10cSrcweir } 2414cdf0e10cSrcweir break; 2415cdf0e10cSrcweir } 2416cdf0e10cSrcweir case typelib_TypeClass_SEQUENCE: 2417cdf0e10cSrcweir { 2418cdf0e10cSrcweir OStringBuffer buf( 64 ); 2419cdf0e10cSrcweir JNI_info::append_sig( 2420cdf0e10cSrcweir &buf, element_type, false /* use class XInterface */, 2421cdf0e10cSrcweir false /* '.' instead of '/' */ ); 2422cdf0e10cSrcweir OString class_name( buf.makeStringAndClear() ); 2423cdf0e10cSrcweir JLocalAutoRef jo_seq_class( 2424cdf0e10cSrcweir jni, find_class( jni, class_name.getStr() ) ); 2425cdf0e10cSrcweir 2426cdf0e10cSrcweir jo_ar.reset( 2427cdf0e10cSrcweir jni->NewObjectArray( 2428cdf0e10cSrcweir nElements, (jclass) jo_seq_class.get(), 0 ) ); 2429cdf0e10cSrcweir jni.ensure_no_exception(); 2430cdf0e10cSrcweir 2431cdf0e10cSrcweir if (0 < nElements) 2432cdf0e10cSrcweir { 2433cdf0e10cSrcweir TypeDescr element_td( element_type ); 2434cdf0e10cSrcweir uno_Sequence ** elements = (uno_Sequence **) seq->elements; 2435cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) 2436cdf0e10cSrcweir { 2437cdf0e10cSrcweir jvalue java_data2; 2438cdf0e10cSrcweir map_to_java( 2439cdf0e10cSrcweir jni, &java_data2, elements + nPos, element_type, 0, 2440cdf0e10cSrcweir true /* in */, false /* no out */ ); 2441cdf0e10cSrcweir JLocalAutoRef jo_seq( jni, java_data2.l ); 2442cdf0e10cSrcweir jni->SetObjectArrayElement( 2443cdf0e10cSrcweir (jobjectArray) jo_ar.get(), nPos, jo_seq.get() ); 2444cdf0e10cSrcweir jni.ensure_no_exception(); 2445cdf0e10cSrcweir } 2446cdf0e10cSrcweir } 2447cdf0e10cSrcweir break; 2448cdf0e10cSrcweir } 2449cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 2450cdf0e10cSrcweir { 2451cdf0e10cSrcweir JNI_interface_type_info const * iface_info = 2452cdf0e10cSrcweir static_cast< JNI_interface_type_info const * >( 2453cdf0e10cSrcweir m_jni_info->get_type_info( jni, element_type ) ); 2454cdf0e10cSrcweir 2455cdf0e10cSrcweir jo_ar.reset( 2456cdf0e10cSrcweir jni->NewObjectArray( nElements, iface_info->m_class, 0 ) ); 2457cdf0e10cSrcweir jni.ensure_no_exception(); 2458cdf0e10cSrcweir 2459cdf0e10cSrcweir if (0 < nElements) 2460cdf0e10cSrcweir { 2461cdf0e10cSrcweir uno_Interface ** pp = (uno_Interface **)seq->elements; 2462cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) 2463cdf0e10cSrcweir { 2464cdf0e10cSrcweir uno_Interface * pUnoI = pp[ nPos ]; 2465cdf0e10cSrcweir if (0 != pUnoI) 2466cdf0e10cSrcweir { 2467cdf0e10cSrcweir JLocalAutoRef jo_element( 2468cdf0e10cSrcweir jni, map_to_java( jni, pUnoI, iface_info ) ); 2469cdf0e10cSrcweir jni->SetObjectArrayElement( 2470cdf0e10cSrcweir (jobjectArray) jo_ar.get(), 2471cdf0e10cSrcweir nPos, jo_element.get() ); 2472cdf0e10cSrcweir jni.ensure_no_exception(); 2473cdf0e10cSrcweir } 2474cdf0e10cSrcweir } 2475cdf0e10cSrcweir } 2476cdf0e10cSrcweir break; 2477cdf0e10cSrcweir } 2478cdf0e10cSrcweir default: 2479cdf0e10cSrcweir { 2480cdf0e10cSrcweir OUStringBuffer buf( 128 ); 2481cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_java():") ); 2482cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 2483cdf0e10cSrcweir buf.appendAscii( 2484cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM("] unsupported element type: ") ); 2485cdf0e10cSrcweir buf.append( OUString::unacquired( &element_type->pTypeName ) ); 2486cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 2487cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 2488cdf0e10cSrcweir } 2489cdf0e10cSrcweir } 2490cdf0e10cSrcweir 2491cdf0e10cSrcweir if (out_param) 2492cdf0e10cSrcweir { 2493cdf0e10cSrcweir if (0 == java_data->l) 2494cdf0e10cSrcweir { 2495cdf0e10cSrcweir JLocalAutoRef jo_element_class( 2496cdf0e10cSrcweir jni, jni->GetObjectClass( jo_ar.get() ) ); 2497cdf0e10cSrcweir if (in_param) 2498cdf0e10cSrcweir { 2499cdf0e10cSrcweir java_data->l = jni->NewObjectArray( 2500cdf0e10cSrcweir 1, (jclass) jo_element_class.get(), jo_ar.get() ); 2501cdf0e10cSrcweir } 2502cdf0e10cSrcweir else 2503cdf0e10cSrcweir { 2504cdf0e10cSrcweir java_data->l = jni->NewObjectArray( 2505cdf0e10cSrcweir 1, (jclass) jo_element_class.get(), 0 ); 2506cdf0e10cSrcweir } 2507cdf0e10cSrcweir jni.ensure_no_exception(); 2508cdf0e10cSrcweir } 2509cdf0e10cSrcweir else 2510cdf0e10cSrcweir { 2511cdf0e10cSrcweir jni->SetObjectArrayElement( 2512cdf0e10cSrcweir (jobjectArray) java_data->l, 0, jo_ar.get() ); 2513cdf0e10cSrcweir jni.ensure_no_exception(); 2514cdf0e10cSrcweir } 2515cdf0e10cSrcweir } 2516cdf0e10cSrcweir else 2517cdf0e10cSrcweir { 2518cdf0e10cSrcweir java_data->l = jo_ar.release(); 2519cdf0e10cSrcweir } 2520cdf0e10cSrcweir break; 2521cdf0e10cSrcweir } 2522cdf0e10cSrcweir case typelib_TypeClass_INTERFACE: 2523cdf0e10cSrcweir { 2524cdf0e10cSrcweir JLocalAutoRef jo_iface( jni ); 2525cdf0e10cSrcweir if (in_param) 2526cdf0e10cSrcweir { 2527cdf0e10cSrcweir uno_Interface * pUnoI = *(uno_Interface * const *)uno_data; 2528cdf0e10cSrcweir if (0 != pUnoI) 2529cdf0e10cSrcweir { 2530cdf0e10cSrcweir if (0 == info) 2531cdf0e10cSrcweir info = m_jni_info->get_type_info( jni, type ); 2532cdf0e10cSrcweir JNI_interface_type_info const * iface_info = 2533cdf0e10cSrcweir static_cast< JNI_interface_type_info const * >( info ); 2534cdf0e10cSrcweir jo_iface.reset( map_to_java( jni, pUnoI, iface_info ) ); 2535cdf0e10cSrcweir } 2536cdf0e10cSrcweir } 2537cdf0e10cSrcweir if (out_param) 2538cdf0e10cSrcweir { 2539cdf0e10cSrcweir if (0 == java_data->l) 2540cdf0e10cSrcweir { 2541cdf0e10cSrcweir if (0 == info) 2542cdf0e10cSrcweir info = m_jni_info->get_type_info( jni, type ); 2543cdf0e10cSrcweir java_data->l = 2544cdf0e10cSrcweir jni->NewObjectArray( 1, info->m_class, jo_iface.get() ); 2545cdf0e10cSrcweir jni.ensure_no_exception(); 2546cdf0e10cSrcweir } 2547cdf0e10cSrcweir else 2548cdf0e10cSrcweir { 2549cdf0e10cSrcweir jni->SetObjectArrayElement( 2550cdf0e10cSrcweir (jobjectArray) java_data->l, 0, jo_iface.get() ); 2551cdf0e10cSrcweir jni.ensure_no_exception(); 2552cdf0e10cSrcweir } 2553cdf0e10cSrcweir } 2554cdf0e10cSrcweir else 2555cdf0e10cSrcweir { 2556cdf0e10cSrcweir java_data->l = jo_iface.release(); 2557cdf0e10cSrcweir } 2558cdf0e10cSrcweir break; 2559cdf0e10cSrcweir } 2560cdf0e10cSrcweir default: 2561cdf0e10cSrcweir { 2562cdf0e10cSrcweir OUStringBuffer buf( 128 ); 2563cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[map_to_java():") ); 2564cdf0e10cSrcweir buf.append( OUString::unacquired( &type->pTypeName ) ); 2565cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] unsupported type!") ); 2566cdf0e10cSrcweir buf.append( jni.get_stack_trace() ); 2567cdf0e10cSrcweir throw BridgeRuntimeError( buf.makeStringAndClear() ); 2568cdf0e10cSrcweir } 2569cdf0e10cSrcweir } 2570cdf0e10cSrcweir } 2571cdf0e10cSrcweir 2572cdf0e10cSrcweir } 2573