1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "jni_bridge.h"
23 #include "rtl/strbuf.hxx"
24 #include "rtl/ustrbuf.hxx"
25 #include "uno/sequence2.h"
28 using namespace ::std
;
29 using namespace ::rtl
;
34 //------------------------------------------------------------------------------
35 inline rtl_mem
* seq_allocate( sal_Int32 nElements
, sal_Int32 nSize
)
37 SAL_WNODEPRECATED_DECLARATIONS_PUSH
38 auto_ptr
< rtl_mem
> seq(
39 rtl_mem::allocate( SAL_SEQUENCE_HEADER_SIZE
+ (nElements
* nSize
) ) );
40 SAL_WNODEPRECATED_DECLARATIONS_POP
41 uno_Sequence
* p
= (uno_Sequence
*)seq
.get();
43 p
->nElements
= nElements
;
47 //______________________________________________________________________________
50 void createDefaultUnoValue(
51 JNI_context
const & jni
, void * uno_data
,
52 typelib_TypeDescriptionReference
* type
,
53 JNI_type_info
const * info
/* maybe 0 */, bool assign
)
55 switch (type
->eTypeClass
) {
56 case typelib_TypeClass_BOOLEAN
:
57 *static_cast< sal_Bool
* >(uno_data
) = false;
60 case typelib_TypeClass_BYTE
:
61 *static_cast< sal_Int8
* >(uno_data
) = 0;
64 case typelib_TypeClass_SHORT
:
65 *static_cast< sal_Int16
* >(uno_data
) = 0;
68 case typelib_TypeClass_UNSIGNED_SHORT
:
69 *static_cast< sal_uInt16
* >(uno_data
) = 0;
72 case typelib_TypeClass_LONG
:
73 *static_cast< sal_Int32
* >(uno_data
) = 0;
76 case typelib_TypeClass_UNSIGNED_LONG
:
77 *static_cast< sal_uInt32
* >(uno_data
) = 0;
80 case typelib_TypeClass_HYPER
:
81 *static_cast< sal_Int64
* >(uno_data
) = 0;
84 case typelib_TypeClass_UNSIGNED_HYPER
:
85 *static_cast< sal_uInt64
* >(uno_data
) = 0;
88 case typelib_TypeClass_FLOAT
:
89 *static_cast< float * >(uno_data
) = 0;
92 case typelib_TypeClass_DOUBLE
:
93 *static_cast< double * >(uno_data
) = 0;
96 case typelib_TypeClass_CHAR
:
97 *static_cast< sal_Unicode
* >(uno_data
) = 0;
100 case typelib_TypeClass_STRING
:
102 *static_cast< rtl_uString
** >(uno_data
) = 0;
104 rtl_uString_new(static_cast< rtl_uString
** >(uno_data
));
107 case typelib_TypeClass_TYPE
:
109 typelib_typedescriptionreference_release(
110 *static_cast< typelib_TypeDescriptionReference
** >(uno_data
));
112 *static_cast< typelib_TypeDescriptionReference
** >(uno_data
)
113 = *typelib_static_type_getByTypeClass(typelib_TypeClass_VOID
);
115 *static_cast< typelib_TypeDescriptionReference
** >(uno_data
) != 0);
116 typelib_typedescriptionreference_acquire(
117 *static_cast< typelib_TypeDescriptionReference
** >(uno_data
));
120 case typelib_TypeClass_ANY
:
122 uno_any_destruct(static_cast< uno_Any
* >(uno_data
), 0);
125 static_cast< uno_Any
* >(uno_data
), 0,
126 jni
.get_info()->m_XInterface_type_info
->m_td
.get(), 0);
129 case typelib_TypeClass_SEQUENCE
:
131 SAL_WNODEPRECATED_DECLARATIONS_PUSH
132 auto_ptr
< rtl_mem
> seq(seq_allocate(0, 0));
133 SAL_WNODEPRECATED_DECLARATIONS_POP
135 uno_type_destructData(uno_data
, type
, 0);
137 *static_cast< uno_Sequence
** >(uno_data
)
138 = reinterpret_cast< uno_Sequence
* >(seq
.release());
142 case typelib_TypeClass_ENUM
:
144 typelib_TypeDescription
* td
= 0;
145 TYPELIB_DANGER_GET(&td
, type
);
146 *static_cast< sal_Int32
* >(uno_data
)
147 = (reinterpret_cast< typelib_EnumTypeDescription
* >(td
)->
149 TYPELIB_DANGER_RELEASE(td
);
153 case typelib_TypeClass_STRUCT
:
156 info
= jni
.get_info()->get_type_info(jni
, type
);
158 JNI_compound_type_info
const * comp_info
159 = static_cast< JNI_compound_type_info
const * >(info
);
160 typelib_CompoundTypeDescription
* comp_td
161 = reinterpret_cast< typelib_CompoundTypeDescription
* >(
162 comp_info
->m_td
.get());
164 sal_Int32 nMembers
= comp_td
->nMembers
;
166 if (comp_td
->pBaseTypeDescription
!= 0) {
167 createDefaultUnoValue(
169 comp_td
->pBaseTypeDescription
->aBase
.pWeakRef
,
170 comp_info
->m_base
, assign
);
172 for (; nPos
< nMembers
; ++nPos
) {
173 createDefaultUnoValue(
175 (static_cast< char * >(uno_data
)
176 + comp_td
->pMemberOffsets
[nPos
]),
177 comp_td
->ppTypeRefs
[nPos
], 0, assign
);
181 for (sal_Int32 i
= 0; i
< nPos
; ++i
) {
182 uno_type_destructData(
183 (static_cast< char * >(uno_data
)
184 + comp_td
->pMemberOffsets
[i
]),
185 comp_td
->ppTypeRefs
[i
], 0);
187 if (comp_td
->pBaseTypeDescription
!= 0) {
189 uno_data
, &comp_td
->pBaseTypeDescription
->aBase
, 0);
197 case typelib_TypeClass_INTERFACE
:
199 uno_Interface
* p
= *static_cast< uno_Interface
** >(uno_data
);
204 *static_cast< uno_Interface
** >(uno_data
) = 0;
215 void Bridge::map_to_uno(
216 JNI_context
const & jni
,
217 void * uno_data
, jvalue java_data
,
218 typelib_TypeDescriptionReference
* type
,
219 JNI_type_info
const * info
/* maybe 0 */,
220 bool assign
, bool out_param
,
221 bool special_wrapped_integral_types
) const
225 (1 == jni
->GetArrayLength( (jarray
) java_data
.l
)) );
227 switch (type
->eTypeClass
)
229 case typelib_TypeClass_CHAR
:
232 jni
->GetCharArrayRegion(
233 (jcharArray
) java_data
.l
, 0, 1, (jchar
*) uno_data
);
234 jni
.ensure_no_exception();
236 else if (special_wrapped_integral_types
)
238 *(jchar
*) uno_data
= jni
->CallCharMethodA(
239 java_data
.l
, m_jni_info
->m_method_Character_charValue
, 0 );
240 jni
.ensure_no_exception();
244 *(jchar
*) uno_data
= java_data
.c
;
247 case typelib_TypeClass_BOOLEAN
:
250 jni
->GetBooleanArrayRegion(
251 (jbooleanArray
) java_data
.l
, 0, 1, (jboolean
*) uno_data
);
252 jni
.ensure_no_exception();
254 else if (special_wrapped_integral_types
)
256 *(jboolean
*) uno_data
= jni
->CallBooleanMethodA(
257 java_data
.l
, m_jni_info
->m_method_Boolean_booleanValue
, 0 );
258 jni
.ensure_no_exception();
262 *(jboolean
*) uno_data
= java_data
.z
;
265 case typelib_TypeClass_BYTE
:
268 jni
->GetByteArrayRegion(
269 (jbyteArray
) java_data
.l
, 0, 1, (jbyte
*) uno_data
);
270 jni
.ensure_no_exception();
272 else if (special_wrapped_integral_types
)
274 *(jbyte
*) uno_data
= jni
->CallByteMethodA(
275 java_data
.l
, m_jni_info
->m_method_Byte_byteValue
, 0 );
276 jni
.ensure_no_exception();
280 *(jbyte
*) uno_data
= java_data
.b
;
283 case typelib_TypeClass_SHORT
:
284 case typelib_TypeClass_UNSIGNED_SHORT
:
287 jni
->GetShortArrayRegion(
288 (jshortArray
) java_data
.l
, 0, 1, (jshort
*) uno_data
);
289 jni
.ensure_no_exception();
291 else if (special_wrapped_integral_types
)
293 *(jshort
*) uno_data
= jni
->CallShortMethodA(
294 java_data
.l
, m_jni_info
->m_method_Short_shortValue
, 0 );
295 jni
.ensure_no_exception();
299 *(jshort
*) uno_data
= java_data
.s
;
302 case typelib_TypeClass_LONG
:
303 case typelib_TypeClass_UNSIGNED_LONG
:
306 jni
->GetIntArrayRegion(
307 (jintArray
) java_data
.l
, 0, 1, (jint
*) uno_data
);
308 jni
.ensure_no_exception();
310 else if (special_wrapped_integral_types
)
312 *(jint
*) uno_data
= jni
->CallIntMethodA(
313 java_data
.l
, m_jni_info
->m_method_Integer_intValue
, 0 );
314 jni
.ensure_no_exception();
318 *(jint
*) uno_data
= java_data
.i
;
321 case typelib_TypeClass_HYPER
:
322 case typelib_TypeClass_UNSIGNED_HYPER
:
325 jni
->GetLongArrayRegion(
326 (jlongArray
) java_data
.l
, 0, 1, (jlong
*) uno_data
);
327 jni
.ensure_no_exception();
329 else if (special_wrapped_integral_types
)
331 *(jlong
*) uno_data
= jni
->CallLongMethodA(
332 java_data
.l
, m_jni_info
->m_method_Long_longValue
, 0 );
333 jni
.ensure_no_exception();
337 *(jlong
*) uno_data
= java_data
.j
;
340 case typelib_TypeClass_FLOAT
:
343 jni
->GetFloatArrayRegion(
344 (jfloatArray
) java_data
.l
, 0, 1, (jfloat
*) uno_data
);
345 jni
.ensure_no_exception();
347 else if (special_wrapped_integral_types
)
349 *(jfloat
*) uno_data
= jni
->CallFloatMethodA(
350 java_data
.l
, m_jni_info
->m_method_Float_floatValue
, 0 );
351 jni
.ensure_no_exception();
355 *(jfloat
*) uno_data
= java_data
.f
;
358 case typelib_TypeClass_DOUBLE
:
361 jni
->GetDoubleArrayRegion(
362 (jdoubleArray
) java_data
.l
, 0, 1, (jdouble
*) uno_data
);
363 jni
.ensure_no_exception();
365 else if (special_wrapped_integral_types
)
367 *(jdouble
*) uno_data
= jni
->CallDoubleMethodA(
368 java_data
.l
, m_jni_info
->m_method_Double_doubleValue
, 0 );
369 jni
.ensure_no_exception();
373 *(jdouble
*) uno_data
= java_data
.d
;
376 case typelib_TypeClass_STRING
:
378 JLocalAutoRef
jo_out_holder( jni
);
382 jni
->GetObjectArrayElement( (jobjectArray
) java_data
.l
, 0 ) );
383 jni
.ensure_no_exception();
384 java_data
.l
= jo_out_holder
.get();
386 if (0 == java_data
.l
)
388 OUStringBuffer
buf( 128 );
389 buf
.append( "[map_to_uno():" );
390 buf
.append( OUString::unacquired( &type
->pTypeName
) );
391 buf
.append( "] null-ref given!" );
392 buf
.append( jni
.get_stack_trace() );
393 throw BridgeRuntimeError( buf
.makeStringAndClear() );
396 *(rtl_uString
**)uno_data
= 0;
398 jni
, (rtl_uString
**)uno_data
, (jstring
) java_data
.l
);
401 case typelib_TypeClass_TYPE
:
403 JLocalAutoRef
jo_out_holder( jni
);
407 jni
->GetObjectArrayElement( (jobjectArray
) java_data
.l
, 0 ) );
408 jni
.ensure_no_exception();
409 java_data
.l
= jo_out_holder
.get();
411 if (0 == java_data
.l
)
413 OUStringBuffer
buf( 128 );
414 buf
.append( "[map_to_uno():" );
415 buf
.append( OUString::unacquired( &type
->pTypeName
) );
416 buf
.append( "] null-ref given!" );
417 buf
.append( jni
.get_stack_trace() );
418 throw BridgeRuntimeError( buf
.makeStringAndClear() );
422 JLocalAutoRef
jo_type_name(
423 jni
, jni
->GetObjectField(
424 java_data
.l
, m_jni_info
->m_field_Type__typeName
) );
425 if (! jo_type_name
.is())
427 OUStringBuffer
buf( 128 );
428 buf
.append( "[map_to_uno():" );
429 buf
.append( OUString::unacquired( &type
->pTypeName
) );
430 buf
.append("] incomplete type object: "
432 buf
.append( jni
.get_stack_trace() );
433 throw BridgeRuntimeError( buf
.makeStringAndClear() );
436 jstring_to_oustring( jni
, (jstring
) jo_type_name
.get() ) );
437 ::com::sun::star::uno::TypeDescription
td( type_name
);
440 OUStringBuffer
buf( 128 );
441 buf
.append( "[map_to_uno():" );
442 buf
.append( OUString::unacquired( &type
->pTypeName
) );
443 buf
.append( "] UNO type not found: " );
444 buf
.append( type_name
);
445 buf
.append( jni
.get_stack_trace() );
446 throw BridgeRuntimeError( buf
.makeStringAndClear() );
448 typelib_typedescriptionreference_acquire( td
.get()->pWeakRef
);
451 typelib_typedescriptionreference_release(
452 *(typelib_TypeDescriptionReference
**)uno_data
);
454 *(typelib_TypeDescriptionReference
**)uno_data
= td
.get()->pWeakRef
;
457 case typelib_TypeClass_ANY
:
459 JLocalAutoRef
jo_out_holder( jni
);
463 jni
->GetObjectArrayElement( (jobjectArray
) java_data
.l
, 0 ) );
464 jni
.ensure_no_exception();
465 java_data
.l
= jo_out_holder
.get();
468 uno_Any
* pAny
= (uno_Any
*)uno_data
;
469 if (0 == java_data
.l
) // null-ref maps to XInterface null-ref
472 uno_any_destruct( pAny
, 0 );
474 pAny
, 0, m_jni_info
->m_XInterface_type_info
->m_td
.get(), 0 );
478 JLocalAutoRef
jo_type( jni
);
479 JLocalAutoRef
jo_wrapped_holder( jni
);
481 if (JNI_FALSE
!= jni
->IsInstanceOf(
482 java_data
.l
, m_jni_info
->m_class_Any
))
485 jo_type
.reset( jni
->GetObjectField(
486 java_data
.l
, m_jni_info
->m_field_Any__type
) );
489 OUStringBuffer
buf( 128 );
490 buf
.append( "[map_to_uno():" );
491 buf
.append( OUString::unacquired( &type
->pTypeName
) );
492 buf
.append( "] no type set at " "com.sun.star.uno.Any!" );
493 buf
.append( jni
.get_stack_trace() );
494 throw BridgeRuntimeError( buf
.makeStringAndClear() );
497 jo_wrapped_holder
.reset(
499 java_data
.l
, m_jni_info
->m_field_Any__object
) );
500 java_data
.l
= jo_wrapped_holder
.get();
504 // create type out of class
505 JLocalAutoRef
jo_class( jni
, jni
->GetObjectClass( java_data
.l
) );
506 jo_type
.reset( create_type( jni
, (jclass
) jo_class
.get() ) );
507 #if OSL_DEBUG_LEVEL > 1
509 JLocalAutoRef
jo_toString(
510 jni
, jni
->CallObjectMethodA(
511 java_data
.l
, m_jni_info
->m_method_Object_toString
, 0 ) );
512 jni
.ensure_no_exception();
514 jstring_to_oustring( jni
, (jstring
) jo_toString
.get() ) );
520 JLocalAutoRef
jo_type_name(
521 jni
, jni
->GetObjectField(
522 jo_type
.get(), m_jni_info
->m_field_Type__typeName
) );
523 jni
.ensure_no_exception();
525 jstring_to_oustring( jni
, (jstring
) jo_type_name
.get() ) );
527 ::com::sun::star::uno::TypeDescription
value_td( type_name
);
530 OUStringBuffer
buf( 128 );
531 buf
.append( "[map_to_uno():" );
532 buf
.append( OUString::unacquired( &type
->pTypeName
) );
533 buf
.append( "] UNO type not found: " );
534 buf
.append( type_name
);
535 buf
.append( jni
.get_stack_trace() );
536 throw BridgeRuntimeError( buf
.makeStringAndClear() );
538 typelib_TypeClass type_class
= value_td
.get()->eTypeClass
;
542 uno_any_destruct( pAny
, 0 );
548 case typelib_TypeClass_VOID
:
549 pAny
->pData
= &pAny
->pReserved
;
551 case typelib_TypeClass_CHAR
:
552 pAny
->pData
= &pAny
->pReserved
;
553 *(jchar
*) pAny
->pData
= jni
->CallCharMethodA(
554 java_data
.l
, m_jni_info
->m_method_Character_charValue
, 0 );
555 jni
.ensure_no_exception();
557 case typelib_TypeClass_BOOLEAN
:
558 pAny
->pData
= &pAny
->pReserved
;
559 *(jboolean
*) pAny
->pData
= jni
->CallBooleanMethodA(
560 java_data
.l
, m_jni_info
->m_method_Boolean_booleanValue
, 0 );
561 jni
.ensure_no_exception();
563 case typelib_TypeClass_BYTE
:
564 pAny
->pData
= &pAny
->pReserved
;
565 *(jbyte
*) pAny
->pData
= jni
->CallByteMethodA(
566 java_data
.l
, m_jni_info
->m_method_Byte_byteValue
, 0 );
567 jni
.ensure_no_exception();
569 case typelib_TypeClass_SHORT
:
570 case typelib_TypeClass_UNSIGNED_SHORT
:
571 pAny
->pData
= &pAny
->pReserved
;
572 *(jshort
*) pAny
->pData
= jni
->CallShortMethodA(
573 java_data
.l
, m_jni_info
->m_method_Short_shortValue
, 0 );
574 jni
.ensure_no_exception();
576 case typelib_TypeClass_LONG
:
577 case typelib_TypeClass_UNSIGNED_LONG
:
578 pAny
->pData
= &pAny
->pReserved
;
579 *(jint
*) pAny
->pData
= jni
->CallIntMethodA(
580 java_data
.l
, m_jni_info
->m_method_Integer_intValue
, 0 );
581 jni
.ensure_no_exception();
583 case typelib_TypeClass_HYPER
:
584 case typelib_TypeClass_UNSIGNED_HYPER
:
585 if (sizeof (sal_Int64
) <= sizeof (void *))
587 pAny
->pData
= &pAny
->pReserved
;
588 *(jlong
*) pAny
->pData
= jni
->CallLongMethodA(
589 java_data
.l
, m_jni_info
->m_method_Long_longValue
, 0 );
590 jni
.ensure_no_exception();
594 SAL_WNODEPRECATED_DECLARATIONS_PUSH
595 auto_ptr
< rtl_mem
> mem(
596 rtl_mem::allocate( sizeof (sal_Int64
) ) );
597 SAL_WNODEPRECATED_DECLARATIONS_POP
598 *(jlong
*) mem
.get() = jni
->CallLongMethodA(
599 java_data
.l
, m_jni_info
->m_method_Long_longValue
, 0 );
600 jni
.ensure_no_exception();
601 pAny
->pData
= mem
.release();
604 case typelib_TypeClass_FLOAT
:
605 if (sizeof (float) <= sizeof (void *))
607 pAny
->pData
= &pAny
->pReserved
;
608 *(jfloat
*) pAny
->pData
= jni
->CallFloatMethodA(
609 java_data
.l
, m_jni_info
->m_method_Float_floatValue
, 0 );
610 jni
.ensure_no_exception();
614 SAL_WNODEPRECATED_DECLARATIONS_PUSH
615 auto_ptr
< rtl_mem
> mem(
616 rtl_mem::allocate( sizeof (float) ) );
617 SAL_WNODEPRECATED_DECLARATIONS_POP
618 *(jfloat
*) mem
.get() = jni
->CallFloatMethodA(
619 java_data
.l
, m_jni_info
->m_method_Float_floatValue
, 0 );
620 jni
.ensure_no_exception();
621 pAny
->pData
= mem
.release();
624 case typelib_TypeClass_DOUBLE
:
625 if (sizeof (double) <= sizeof (void *))
627 pAny
->pData
= &pAny
->pReserved
;
628 *(jdouble
*) pAny
->pData
=
629 jni
->CallDoubleMethodA(
631 m_jni_info
->m_method_Double_doubleValue
, 0 );
632 jni
.ensure_no_exception();
636 SAL_WNODEPRECATED_DECLARATIONS_PUSH
637 auto_ptr
< rtl_mem
> mem(
638 rtl_mem::allocate( sizeof (double) ) );
639 SAL_WNODEPRECATED_DECLARATIONS_POP
640 *(jdouble
*) mem
.get() =
641 jni
->CallDoubleMethodA(
643 m_jni_info
->m_method_Double_doubleValue
, 0 );
644 jni
.ensure_no_exception();
645 pAny
->pData
= mem
.release();
648 case typelib_TypeClass_STRING
:
649 // opt: anies often contain strings; copy string directly
651 pAny
->pData
= &pAny
->pReserved
;
653 jni
, (rtl_uString
**)pAny
->pData
,
654 (jstring
) java_data
.l
);
656 case typelib_TypeClass_TYPE
:
657 case typelib_TypeClass_ENUM
:
658 case typelib_TypeClass_SEQUENCE
:
659 case typelib_TypeClass_INTERFACE
:
660 pAny
->pData
= &pAny
->pReserved
;
662 jni
, pAny
->pData
, java_data
,
663 value_td
.get()->pWeakRef
, 0,
664 false /* no assign */, false /* no out param */ );
666 case typelib_TypeClass_STRUCT
:
667 case typelib_TypeClass_EXCEPTION
:
669 SAL_WNODEPRECATED_DECLARATIONS_PUSH
670 auto_ptr
< rtl_mem
> mem(
671 rtl_mem::allocate( value_td
.get()->nSize
) );
672 SAL_WNODEPRECATED_DECLARATIONS_POP
674 jni
, mem
.get(), java_data
, value_td
.get()->pWeakRef
, 0,
675 false /* no assign */, false /* no out param */ );
676 pAny
->pData
= mem
.release();
681 OUStringBuffer
buf( 128 );
682 buf
.append( "[map_to_uno():" );
683 buf
.append( type_name
);
684 buf
.append( "] unsupported value type " "of any!" );
685 buf
.append( jni
.get_stack_trace() );
686 throw BridgeRuntimeError( buf
.makeStringAndClear() );
694 // restore to valid any
695 uno_any_construct( pAny
, 0, 0, 0 );
699 typelib_typedescriptionreference_acquire( value_td
.get()->pWeakRef
);
700 pAny
->pType
= value_td
.get()->pWeakRef
;
703 case typelib_TypeClass_ENUM
:
705 JLocalAutoRef
jo_out_holder( jni
);
709 jni
->GetObjectArrayElement( (jobjectArray
) java_data
.l
, 0 ) );
710 jni
.ensure_no_exception();
711 java_data
.l
= jo_out_holder
.get();
713 if (0 == java_data
.l
)
715 OUStringBuffer
buf( 128 );
716 buf
.append( "[map_to_uno():" );
717 buf
.append( OUString::unacquired( &type
->pTypeName
) );
718 buf
.append( "] null-ref given!" );
719 buf
.append( jni
.get_stack_trace() );
720 throw BridgeRuntimeError( buf
.makeStringAndClear() );
723 *(jint
*) uno_data
= jni
->GetIntField(
724 java_data
.l
, m_jni_info
->m_field_Enum_m_value
);
727 case typelib_TypeClass_STRUCT
:
728 case typelib_TypeClass_EXCEPTION
:
730 JLocalAutoRef
jo_out_holder( jni
);
734 jni
->GetObjectArrayElement( (jobjectArray
) java_data
.l
, 0 ) );
735 jni
.ensure_no_exception();
736 java_data
.l
= jo_out_holder
.get();
738 if (0 == java_data
.l
)
740 OUStringBuffer
buf( 128 );
741 buf
.append( "[map_to_uno():" );
742 buf
.append( OUString::unacquired( &type
->pTypeName
) );
743 buf
.append( "] null-ref given!" );
744 buf
.append( jni
.get_stack_trace() );
745 throw BridgeRuntimeError( buf
.makeStringAndClear() );
749 info
= m_jni_info
->get_type_info( jni
, type
);
750 JNI_compound_type_info
const * comp_info
=
751 static_cast< JNI_compound_type_info
const * >( info
);
753 typelib_CompoundTypeDescription
* comp_td
=
754 (typelib_CompoundTypeDescription
*)comp_info
->m_td
.get();
756 = comp_td
->aBase
.eTypeClass
== typelib_TypeClass_STRUCT
757 && reinterpret_cast< typelib_StructTypeDescription
* >(
758 comp_td
)->pParameterizedTypes
!= 0;
761 sal_Int32 nMembers
= comp_td
->nMembers
;
764 if (0 != comp_td
->pBaseTypeDescription
)
767 jni
, uno_data
, java_data
,
768 ((typelib_TypeDescription
*) comp_td
->pBaseTypeDescription
)
771 assign
, false /* no out param */ );
774 for ( ; nPos
< nMembers
; ++nPos
)
776 void * p
= (char *)uno_data
+ comp_td
->pMemberOffsets
[ nPos
];
777 typelib_TypeDescriptionReference
* member_type
=
778 comp_td
->ppTypeRefs
[ nPos
];
779 jfieldID field_id
= comp_info
->m_fields
[ nPos
];
780 bool parameterizedType
= polymorphic
781 && reinterpret_cast< typelib_StructTypeDescription
* >(
782 comp_td
)->pParameterizedTypes
[nPos
];
783 switch (member_type
->eTypeClass
)
785 case typelib_TypeClass_CHAR
:
786 if (parameterizedType
) {
788 jni
, jni
->GetObjectField( java_data
.l
, field_id
) );
789 if ( jo
.get() == 0 ) {
795 jni
, p
, val
, member_type
, 0, assign
, false,
799 *(jchar
*) p
= jni
->GetCharField(
800 java_data
.l
, field_id
);
803 case typelib_TypeClass_BOOLEAN
:
804 if (parameterizedType
) {
806 jni
, jni
->GetObjectField( java_data
.l
, field_id
) );
807 if ( jo
.get() == 0 ) {
808 *(jboolean
*) p
= false;
813 jni
, p
, val
, member_type
, 0, assign
, false,
817 *(jboolean
*) p
= jni
->GetBooleanField(
818 java_data
.l
, field_id
);
821 case typelib_TypeClass_BYTE
:
822 if (parameterizedType
) {
824 jni
, jni
->GetObjectField( java_data
.l
, field_id
) );
825 if ( jo
.get() == 0 ) {
831 jni
, p
, val
, member_type
, 0, assign
, false,
835 *(jbyte
*) p
= jni
->GetByteField(
836 java_data
.l
, field_id
);
839 case typelib_TypeClass_SHORT
:
840 case typelib_TypeClass_UNSIGNED_SHORT
:
841 if (parameterizedType
) {
843 jni
, jni
->GetObjectField( java_data
.l
, field_id
) );
844 if ( jo
.get() == 0 ) {
850 jni
, p
, val
, member_type
, 0, assign
, false,
854 *(jshort
*) p
= jni
->GetShortField(
855 java_data
.l
, field_id
);
858 case typelib_TypeClass_LONG
:
859 case typelib_TypeClass_UNSIGNED_LONG
:
860 if (parameterizedType
) {
862 jni
, jni
->GetObjectField( java_data
.l
, field_id
) );
863 if ( jo
.get() == 0 ) {
869 jni
, p
, val
, member_type
, 0, assign
, false,
873 *(jint
*) p
= jni
->GetIntField( java_data
.l
, field_id
);
876 case typelib_TypeClass_HYPER
:
877 case typelib_TypeClass_UNSIGNED_HYPER
:
878 if (parameterizedType
) {
880 jni
, jni
->GetObjectField( java_data
.l
, field_id
) );
881 if ( jo
.get() == 0 ) {
887 jni
, p
, val
, member_type
, 0, assign
, false,
891 *(jlong
*) p
= jni
->GetLongField(
892 java_data
.l
, field_id
);
895 case typelib_TypeClass_FLOAT
:
896 if (parameterizedType
) {
898 jni
, jni
->GetObjectField( java_data
.l
, field_id
) );
899 if ( jo
.get() == 0 ) {
905 jni
, p
, val
, member_type
, 0, assign
, false,
909 *(jfloat
*) p
= jni
->GetFloatField(
910 java_data
.l
, field_id
);
913 case typelib_TypeClass_DOUBLE
:
914 if (parameterizedType
) {
916 jni
, jni
->GetObjectField( java_data
.l
, field_id
) );
917 if ( jo
.get() == 0 ) {
923 jni
, p
, val
, member_type
, 0, assign
, false,
927 *(jdouble
*) p
= jni
->GetDoubleField(
928 java_data
.l
, field_id
);
933 JLocalAutoRef
jo_field( jni
);
937 // special for Message: call Throwable.getMessage()
941 m_jni_info
->m_Exception_type
.getTypeLibType() )
944 m_jni_info
->m_RuntimeException_type
.
945 getTypeLibType() ) );
946 OSL_ASSERT( 0 == nPos
); // first member
949 jni
->CallObjectMethodA(
951 m_jni_info
->m_method_Throwable_getMessage
, 0 )
953 jni
.ensure_no_exception();
959 jni
->GetObjectField( java_data
.l
, field_id
) );
960 checkNull
= parameterizedType
;
962 if (checkNull
&& !jo_field
.is()) {
963 createDefaultUnoValue(jni
, p
, member_type
, 0, assign
);
966 val
.l
= jo_field
.get();
968 jni
, p
, val
, member_type
, 0,
969 assign
, false /* no out param */ );
981 for ( sal_Int32 nCleanup
= 0; nCleanup
< nPos
; ++nCleanup
)
984 (char *)uno_data
+ comp_td
->pMemberOffsets
[ nCleanup
];
985 uno_type_destructData(
986 p
, comp_td
->ppTypeRefs
[ nCleanup
], 0 );
988 if (0 != comp_td
->pBaseTypeDescription
)
992 (typelib_TypeDescription
*) comp_td
993 ->pBaseTypeDescription
, 0 );
1000 case typelib_TypeClass_SEQUENCE
:
1002 JLocalAutoRef
jo_out_holder( jni
);
1005 jo_out_holder
.reset(
1006 jni
->GetObjectArrayElement( (jobjectArray
) java_data
.l
, 0 ) );
1007 jni
.ensure_no_exception();
1008 java_data
.l
= jo_out_holder
.get();
1010 if (0 == java_data
.l
)
1012 OUStringBuffer
buf( 128 );
1013 buf
.append( "[map_to_uno():" );
1014 buf
.append( OUString::unacquired( &type
->pTypeName
) );
1015 buf
.append( "] null-ref given!" );
1016 buf
.append( jni
.get_stack_trace() );
1017 throw BridgeRuntimeError( buf
.makeStringAndClear() );
1020 TypeDescr
td( type
);
1021 typelib_TypeDescriptionReference
* element_type
=
1022 ((typelib_IndirectTypeDescription
*)td
.get())->pType
;
1024 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1025 auto_ptr
< rtl_mem
> seq
;
1026 SAL_WNODEPRECATED_DECLARATIONS_POP
1027 sal_Int32 nElements
= jni
->GetArrayLength( (jarray
) java_data
.l
);
1029 switch (element_type
->eTypeClass
)
1031 case typelib_TypeClass_CHAR
:
1032 seq
.reset( seq_allocate( nElements
, sizeof (sal_Unicode
) ) );
1033 jni
->GetCharArrayRegion(
1034 (jcharArray
) java_data
.l
, 0, nElements
,
1035 (jchar
*) ((uno_Sequence
*) seq
.get())->elements
);
1036 jni
.ensure_no_exception();
1038 case typelib_TypeClass_BOOLEAN
:
1039 seq
.reset( seq_allocate( nElements
, sizeof (sal_Bool
) ) );
1040 jni
->GetBooleanArrayRegion(
1041 (jbooleanArray
) java_data
.l
, 0, nElements
,
1042 (jboolean
*) ((uno_Sequence
*) seq
.get())->elements
);
1043 jni
.ensure_no_exception();
1045 case typelib_TypeClass_BYTE
:
1046 seq
.reset( seq_allocate( nElements
, sizeof (sal_Int8
) ) );
1047 jni
->GetByteArrayRegion(
1048 (jbyteArray
) java_data
.l
, 0, nElements
,
1049 (jbyte
*) ((uno_Sequence
*) seq
.get())->elements
);
1050 jni
.ensure_no_exception();
1052 case typelib_TypeClass_SHORT
:
1053 case typelib_TypeClass_UNSIGNED_SHORT
:
1054 seq
.reset( seq_allocate( nElements
, sizeof (sal_Int16
) ) );
1055 jni
->GetShortArrayRegion(
1056 (jshortArray
) java_data
.l
, 0, nElements
,
1057 (jshort
*) ((uno_Sequence
*) seq
.get())->elements
);
1058 jni
.ensure_no_exception();
1060 case typelib_TypeClass_LONG
:
1061 case typelib_TypeClass_UNSIGNED_LONG
:
1062 seq
.reset( seq_allocate( nElements
, sizeof (sal_Int32
) ) );
1063 jni
->GetIntArrayRegion(
1064 (jintArray
) java_data
.l
, 0, nElements
,
1065 (jint
*) ((uno_Sequence
*) seq
.get())->elements
);
1066 jni
.ensure_no_exception();
1068 case typelib_TypeClass_HYPER
:
1069 case typelib_TypeClass_UNSIGNED_HYPER
:
1070 seq
.reset( seq_allocate( nElements
, sizeof (sal_Int64
) ) );
1071 jni
->GetLongArrayRegion(
1072 (jlongArray
) java_data
.l
, 0, nElements
,
1073 (jlong
*) ((uno_Sequence
*) seq
.get())->elements
);
1074 jni
.ensure_no_exception();
1076 case typelib_TypeClass_FLOAT
:
1077 seq
.reset( seq_allocate( nElements
, sizeof (float) ) );
1078 jni
->GetFloatArrayRegion(
1079 (jfloatArray
) java_data
.l
, 0, nElements
,
1080 (jfloat
*)((uno_Sequence
*)seq
.get())->elements
);
1081 jni
.ensure_no_exception();
1083 case typelib_TypeClass_DOUBLE
:
1084 seq
.reset( seq_allocate( nElements
, sizeof (double) ) );
1085 jni
->GetDoubleArrayRegion(
1086 (jdoubleArray
) java_data
.l
, 0, nElements
,
1087 (jdouble
*) ((uno_Sequence
*) seq
.get())->elements
);
1088 jni
.ensure_no_exception();
1090 case typelib_TypeClass_STRING
:
1091 case typelib_TypeClass_TYPE
:
1092 case typelib_TypeClass_ANY
:
1093 case typelib_TypeClass_ENUM
:
1094 case typelib_TypeClass_STRUCT
:
1095 case typelib_TypeClass_EXCEPTION
:
1096 case typelib_TypeClass_SEQUENCE
:
1097 case typelib_TypeClass_INTERFACE
:
1099 TypeDescr
element_td( element_type
);
1100 seq
.reset( seq_allocate( nElements
, element_td
.get()->nSize
) );
1102 JNI_type_info
const * element_info
;
1103 if (typelib_TypeClass_STRUCT
== element_type
->eTypeClass
||
1104 typelib_TypeClass_EXCEPTION
== element_type
->eTypeClass
||
1105 typelib_TypeClass_INTERFACE
== element_type
->eTypeClass
)
1108 m_jni_info
->get_type_info( jni
, element_td
.get() );
1115 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
1120 jni
, jni
->GetObjectArrayElement(
1121 (jobjectArray
) java_data
.l
, nPos
) );
1122 jni
.ensure_no_exception();
1126 ((uno_Sequence
*)seq
.get())->elements
+
1127 (nPos
* element_td
.get()->nSize
);
1129 jni
, p
, val
, element_td
.get()->pWeakRef
, element_info
,
1130 false /* no assign */, false /* no out param */ );
1135 for ( sal_Int32 nCleanPos
= 0;
1136 nCleanPos
< nPos
; ++nCleanPos
)
1139 ((uno_Sequence
*)seq
.get())->elements
+
1140 (nCleanPos
* element_td
.get()->nSize
);
1141 uno_destructData( p
, element_td
.get(), 0 );
1150 OUStringBuffer
buf( 128 );
1151 buf
.append( "[map_to_uno():" );
1152 buf
.append( OUString::unacquired( &type
->pTypeName
) );
1153 buf
.append( "] unsupported sequence element" " type: " );
1154 buf
.append( OUString::unacquired( &element_type
->pTypeName
) );
1155 buf
.append( jni
.get_stack_trace() );
1156 throw BridgeRuntimeError( buf
.makeStringAndClear() );
1161 uno_destructData( uno_data
, td
.get(), 0 );
1162 *(uno_Sequence
**)uno_data
= (uno_Sequence
*)seq
.release();
1165 case typelib_TypeClass_INTERFACE
:
1167 JLocalAutoRef
jo_out_holder( jni
);
1170 jo_out_holder
.reset(
1171 jni
->GetObjectArrayElement( (jobjectArray
) java_data
.l
, 0 ) );
1172 jni
.ensure_no_exception();
1173 java_data
.l
= jo_out_holder
.get();
1176 if (0 == java_data
.l
) // null-ref
1180 uno_Interface
* p
= *(uno_Interface
**)uno_data
;
1184 *(uno_Interface
**)uno_data
= 0;
1189 info
= m_jni_info
->get_type_info( jni
, type
);
1190 JNI_interface_type_info
const * iface_info
=
1191 static_cast< JNI_interface_type_info
const * >( info
);
1192 uno_Interface
* pUnoI
= map_to_uno( jni
, java_data
.l
, iface_info
);
1195 uno_Interface
* p
= *(uno_Interface
**)uno_data
;
1199 *(uno_Interface
**)uno_data
= pUnoI
;
1205 OUStringBuffer
buf( 128 );
1206 buf
.append( "[map_to_uno():" );
1207 buf
.append( OUString::unacquired( &type
->pTypeName
) );
1208 buf
.append( "] unsupported type!" );
1209 buf
.append( jni
.get_stack_trace() );
1210 throw BridgeRuntimeError( buf
.makeStringAndClear() );
1215 //##############################################################################
1217 //______________________________________________________________________________
1218 void Bridge::map_to_java(
1219 JNI_context
const & jni
,
1220 jvalue
* java_data
, void const * uno_data
,
1221 typelib_TypeDescriptionReference
* type
,
1222 JNI_type_info
const * info
/* maybe 0 */,
1223 bool in_param
, bool out_param
,
1224 bool special_wrapped_integral_types
) const
1226 switch (type
->eTypeClass
)
1228 case typelib_TypeClass_CHAR
:
1231 if (0 == java_data
->l
)
1233 JLocalAutoRef
jo_ar( jni
, jni
->NewCharArray( 1 ) );
1234 jni
.ensure_no_exception();
1237 jni
->SetCharArrayRegion(
1238 (jcharArray
) jo_ar
.get(), 0, 1, (jchar
*) uno_data
);
1239 jni
.ensure_no_exception();
1241 java_data
->l
= jo_ar
.release();
1247 jni
->SetCharArrayRegion(
1248 (jcharArray
) java_data
->l
, 0, 1, (jchar
*) uno_data
);
1249 jni
.ensure_no_exception();
1253 else if (special_wrapped_integral_types
)
1256 arg
.c
= *(jchar
const *) uno_data
;
1257 java_data
->l
= jni
->NewObjectA(
1258 m_jni_info
->m_class_Character
,
1259 m_jni_info
->m_ctor_Character_with_char
, &arg
);
1260 jni
.ensure_no_exception();
1264 java_data
->c
= *(jchar
const *) uno_data
;
1267 case typelib_TypeClass_BOOLEAN
:
1270 if (0 == java_data
->l
)
1272 JLocalAutoRef
jo_ar( jni
, jni
->NewBooleanArray( 1 ) );
1273 jni
.ensure_no_exception();
1276 jni
->SetBooleanArrayRegion(
1277 (jbooleanArray
) jo_ar
.get(),
1278 0, 1, (jboolean
*) uno_data
);
1279 jni
.ensure_no_exception();
1281 java_data
->l
= jo_ar
.release();
1287 jni
->SetBooleanArrayRegion(
1288 (jbooleanArray
) java_data
->l
,
1289 0, 1, (jboolean
*) uno_data
);
1290 jni
.ensure_no_exception();
1294 else if (special_wrapped_integral_types
)
1297 arg
.z
= *(jboolean
const *) uno_data
;
1298 java_data
->l
= jni
->NewObjectA(
1299 m_jni_info
->m_class_Boolean
,
1300 m_jni_info
->m_ctor_Boolean_with_boolean
, &arg
);
1301 jni
.ensure_no_exception();
1305 java_data
->z
= *(jboolean
const *) uno_data
;
1308 case typelib_TypeClass_BYTE
:
1311 if (0 == java_data
->l
)
1313 JLocalAutoRef
jo_ar( jni
, jni
->NewByteArray( 1 ) );
1314 jni
.ensure_no_exception();
1317 jni
->SetByteArrayRegion(
1318 (jbyteArray
) jo_ar
.get(), 0, 1, (jbyte
*) uno_data
);
1319 jni
.ensure_no_exception();
1321 java_data
->l
= jo_ar
.release();
1327 jni
->SetByteArrayRegion(
1328 (jbyteArray
) java_data
->l
, 0, 1, (jbyte
*) uno_data
);
1329 jni
.ensure_no_exception();
1333 else if (special_wrapped_integral_types
)
1336 arg
.b
= *(jbyte
const *) uno_data
;
1337 java_data
->l
= jni
->NewObjectA(
1338 m_jni_info
->m_class_Byte
,
1339 m_jni_info
->m_ctor_Byte_with_byte
, &arg
);
1340 jni
.ensure_no_exception();
1344 java_data
->b
= *(jbyte
const *) uno_data
;
1347 case typelib_TypeClass_SHORT
:
1348 case typelib_TypeClass_UNSIGNED_SHORT
:
1351 if (0 == java_data
->l
)
1353 JLocalAutoRef
jo_ar( jni
, jni
->NewShortArray( 1 ) );
1354 jni
.ensure_no_exception();
1357 jni
->SetShortArrayRegion(
1358 (jshortArray
) jo_ar
.get(), 0, 1, (jshort
*) uno_data
);
1359 jni
.ensure_no_exception();
1361 java_data
->l
= jo_ar
.release();
1367 jni
->SetShortArrayRegion(
1368 (jshortArray
) java_data
->l
, 0, 1, (jshort
*) uno_data
);
1369 jni
.ensure_no_exception();
1373 else if (special_wrapped_integral_types
)
1376 arg
.s
= *(jshort
const *) uno_data
;
1377 java_data
->l
= jni
->NewObjectA(
1378 m_jni_info
->m_class_Short
,
1379 m_jni_info
->m_ctor_Short_with_short
, &arg
);
1380 jni
.ensure_no_exception();
1384 java_data
->s
= *(jshort
const *) uno_data
;
1387 case typelib_TypeClass_LONG
:
1388 case typelib_TypeClass_UNSIGNED_LONG
:
1391 if (0 == java_data
->l
)
1393 JLocalAutoRef
jo_ar( jni
, jni
->NewIntArray( 1 ) );
1394 jni
.ensure_no_exception();
1397 jni
->SetIntArrayRegion(
1398 (jintArray
) jo_ar
.get(), 0, 1, (jint
*) uno_data
);
1399 jni
.ensure_no_exception();
1401 java_data
->l
= jo_ar
.release();
1407 jni
->SetIntArrayRegion(
1408 (jintArray
) java_data
->l
, 0, 1, (jint
*) uno_data
);
1409 jni
.ensure_no_exception();
1413 else if (special_wrapped_integral_types
)
1416 arg
.i
= *(jint
const *) uno_data
;
1417 java_data
->l
= jni
->NewObjectA(
1418 m_jni_info
->m_class_Integer
,
1419 m_jni_info
->m_ctor_Integer_with_int
, &arg
);
1420 jni
.ensure_no_exception();
1424 java_data
->i
= *(jint
const *) uno_data
;
1427 case typelib_TypeClass_HYPER
:
1428 case typelib_TypeClass_UNSIGNED_HYPER
:
1431 if (0 == java_data
->l
)
1433 JLocalAutoRef
jo_ar( jni
, jni
->NewLongArray( 1 ) );
1434 jni
.ensure_no_exception();
1437 jni
->SetLongArrayRegion(
1438 (jlongArray
)jo_ar
.get(), 0, 1, (jlong
*) uno_data
);
1439 jni
.ensure_no_exception();
1441 java_data
->l
= jo_ar
.release();
1447 jni
->SetLongArrayRegion(
1448 (jlongArray
)java_data
->l
, 0, 1, (jlong
*) uno_data
);
1449 jni
.ensure_no_exception();
1453 else if (special_wrapped_integral_types
)
1456 arg
.j
= *(jlong
const *) uno_data
;
1457 java_data
->l
= jni
->NewObjectA(
1458 m_jni_info
->m_class_Long
,
1459 m_jni_info
->m_ctor_Long_with_long
, &arg
);
1460 jni
.ensure_no_exception();
1464 java_data
->j
= *(jlong
const *) uno_data
;
1467 case typelib_TypeClass_FLOAT
:
1470 if (0 == java_data
->l
)
1472 JLocalAutoRef
jo_ar( jni
, jni
->NewFloatArray( 1 ) );
1473 jni
.ensure_no_exception();
1476 jni
->SetFloatArrayRegion(
1477 (jfloatArray
) jo_ar
.get(), 0, 1, (jfloat
*) uno_data
);
1478 jni
.ensure_no_exception();
1480 java_data
->l
= jo_ar
.release();
1486 jni
->SetFloatArrayRegion(
1487 (jfloatArray
) java_data
->l
, 0, 1, (jfloat
*) uno_data
);
1488 jni
.ensure_no_exception();
1492 else if (special_wrapped_integral_types
)
1495 arg
.f
= *(jfloat
const *) uno_data
;
1496 java_data
->l
= jni
->NewObjectA(
1497 m_jni_info
->m_class_Float
,
1498 m_jni_info
->m_ctor_Float_with_float
, &arg
);
1499 jni
.ensure_no_exception();
1503 java_data
->f
= *(jfloat
const *) uno_data
;
1506 case typelib_TypeClass_DOUBLE
:
1509 if (0 == java_data
->l
)
1511 JLocalAutoRef
jo_ar( jni
, jni
->NewDoubleArray( 1 ) );
1512 jni
.ensure_no_exception();
1515 jni
->SetDoubleArrayRegion(
1516 (jdoubleArray
) jo_ar
.get(),
1517 0, 1, (jdouble
*) uno_data
);
1518 jni
.ensure_no_exception();
1520 java_data
->l
= jo_ar
.release();
1526 jni
->SetDoubleArrayRegion(
1527 (jdoubleArray
) java_data
->l
,
1528 0, 1, (jdouble
*) uno_data
);
1529 jni
.ensure_no_exception();
1533 else if (special_wrapped_integral_types
)
1536 arg
.d
= *(double const *)uno_data
;
1537 java_data
->l
= jni
->NewObjectA(
1538 m_jni_info
->m_class_Double
,
1539 m_jni_info
->m_ctor_Double_with_double
, &arg
);
1540 jni
.ensure_no_exception();
1544 java_data
->d
= *(jdouble
const *) uno_data
;
1547 case typelib_TypeClass_STRING
:
1551 JLocalAutoRef
jo_in( jni
);
1556 jni
, *(rtl_uString
* const *) uno_data
) );
1558 if (0 == java_data
->l
)
1560 java_data
->l
= jni
->NewObjectArray(
1561 1, m_jni_info
->m_class_String
, jo_in
.get() );
1562 jni
.ensure_no_exception();
1566 jni
->SetObjectArrayElement(
1567 (jobjectArray
) java_data
->l
, 0, jo_in
.get() );
1568 jni
.ensure_no_exception();
1573 OSL_ASSERT( in_param
);
1575 ustring_to_jstring( jni
, *(rtl_uString
* const *) uno_data
);
1579 case typelib_TypeClass_TYPE
:
1583 JLocalAutoRef
jo_in( jni
);
1589 *(typelib_TypeDescriptionReference
* const *) uno_data
)
1592 if (0 == java_data
->l
)
1594 java_data
->l
= jni
->NewObjectArray(
1595 1, m_jni_info
->m_class_Type
, jo_in
.get() );
1596 jni
.ensure_no_exception();
1600 jni
->SetObjectArrayElement(
1601 (jobjectArray
) java_data
->l
, 0, jo_in
.get() );
1602 jni
.ensure_no_exception();
1607 OSL_ASSERT( in_param
);
1611 *(typelib_TypeDescriptionReference
* const *) uno_data
);
1615 case typelib_TypeClass_ANY
:
1617 JLocalAutoRef
jo_any( jni
);
1620 uno_Any
const * pAny
= (uno_Any
const *)uno_data
;
1622 #if defined BRIDGES_JNI_UNO_FORCE_BOXED_ANY
1623 if (typelib_TypeClass_VOID
== pAny
->pType
->eTypeClass
)
1626 jni
->NewLocalRef( m_jni_info
->m_object_Any_VOID
) );
1632 jni
, &args
[ 1 ], pAny
->pData
, pAny
->pType
, 0,
1633 true /* in */, false /* no out */,
1634 true /* create integral wrappers */ );
1635 jo_any
.reset( args
[ 1 ].l
);
1636 // build up com.sun.star.uno.Any
1637 JLocalAutoRef
jo_type( jni
, create_type( jni
, pAny
->pType
) );
1638 args
[ 0 ].l
= jo_type
.get();
1641 m_jni_info
->m_class_Any
,
1642 m_jni_info
->m_ctor_Any_with_Type_Object
, args
) );
1643 jni
.ensure_no_exception();
1646 switch (pAny
->pType
->eTypeClass
)
1648 case typelib_TypeClass_VOID
:
1650 jni
->NewLocalRef( m_jni_info
->m_object_Any_VOID
) );
1652 case typelib_TypeClass_UNSIGNED_SHORT
:
1655 args
[ 0 ].s
= *(jshort
const *) pAny
->pData
;
1656 JLocalAutoRef
jo_val(
1657 jni
, jni
->NewObjectA(
1658 m_jni_info
->m_class_Short
,
1659 m_jni_info
->m_ctor_Short_with_short
, args
) );
1660 jni
.ensure_no_exception();
1661 // box up in com.sun.star.uno.Any
1662 args
[ 0 ].l
= m_jni_info
->m_object_Type_UNSIGNED_SHORT
;
1663 args
[ 1 ].l
= jo_val
.get();
1666 m_jni_info
->m_class_Any
,
1667 m_jni_info
->m_ctor_Any_with_Type_Object
, args
) );
1668 jni
.ensure_no_exception();
1671 case typelib_TypeClass_UNSIGNED_LONG
:
1674 args
[ 0 ].i
= *(jint
const *) pAny
->pData
;
1675 JLocalAutoRef
jo_val(
1676 jni
, jni
->NewObjectA(
1677 m_jni_info
->m_class_Integer
,
1678 m_jni_info
->m_ctor_Integer_with_int
, args
) );
1679 jni
.ensure_no_exception();
1680 // box up in com.sun.star.uno.Any
1681 args
[ 0 ].l
= m_jni_info
->m_object_Type_UNSIGNED_LONG
;
1682 args
[ 1 ].l
= jo_val
.get();
1685 m_jni_info
->m_class_Any
,
1686 m_jni_info
->m_ctor_Any_with_Type_Object
, args
) );
1687 jni
.ensure_no_exception();
1690 case typelib_TypeClass_UNSIGNED_HYPER
:
1693 args
[ 0 ].j
= *(jlong
const *) pAny
->pData
;
1694 JLocalAutoRef
jo_val(
1695 jni
, jni
->NewObjectA(
1696 m_jni_info
->m_class_Long
,
1697 m_jni_info
->m_ctor_Long_with_long
, args
) );
1698 jni
.ensure_no_exception();
1699 // box up in com.sun.star.uno.Any
1700 args
[ 0 ].l
= m_jni_info
->m_object_Type_UNSIGNED_HYPER
;
1701 args
[ 1 ].l
= jo_val
.get();
1704 m_jni_info
->m_class_Any
,
1705 m_jni_info
->m_ctor_Any_with_Type_Object
, args
) );
1706 jni
.ensure_no_exception();
1709 case typelib_TypeClass_STRING
: // opt strings
1710 jo_any
.reset( ustring_to_jstring(
1711 jni
, (rtl_uString
*) pAny
->pReserved
) );
1713 case typelib_TypeClass_SEQUENCE
:
1716 // prefetch sequence td
1717 TypeDescr
seq_td( pAny
->pType
);
1719 jni
, &java_data2
, pAny
->pData
, seq_td
.get()->pWeakRef
, 0,
1720 true /* in */, false /* no out */,
1721 true /* create integral wrappers */ );
1722 jo_any
.reset( java_data2
.l
);
1724 // determine inner element type
1725 ::com::sun::star::uno::Type
element_type(
1726 ((typelib_IndirectTypeDescription
*)seq_td
.get())->pType
);
1727 while (typelib_TypeClass_SEQUENCE
==
1728 element_type
.getTypeLibType()->eTypeClass
)
1730 TypeDescr
element_td( element_type
.getTypeLibType() );
1731 typelib_typedescriptionreference_assign(
1732 reinterpret_cast< typelib_TypeDescriptionReference
** >(
1734 ((typelib_IndirectTypeDescription
*)element_td
.get())
1737 // box up only if unsigned element type
1738 switch (element_type
.getTypeLibType()->eTypeClass
)
1740 case typelib_TypeClass_UNSIGNED_SHORT
:
1741 case typelib_TypeClass_UNSIGNED_LONG
:
1742 case typelib_TypeClass_UNSIGNED_HYPER
:
1745 JLocalAutoRef
jo_type(
1746 jni
, create_type( jni
, seq_td
.get()->pWeakRef
) );
1747 args
[ 0 ].l
= jo_type
.get();
1748 args
[ 1 ].l
= jo_any
.get();
1751 m_jni_info
->m_class_Any
,
1752 m_jni_info
->m_ctor_Any_with_Type_Object
, args
) );
1753 jni
.ensure_no_exception();
1761 case typelib_TypeClass_INTERFACE
:
1763 uno_Interface
* pUnoI
= (uno_Interface
*)pAny
->pReserved
;
1764 if (is_XInterface( pAny
->pType
))
1771 m_jni_info
->m_XInterface_type_info
) );
1773 // else: empty XInterface ref maps to null-ref
1777 JNI_interface_type_info
const * iface_info
=
1778 static_cast< JNI_interface_type_info
const * >(
1779 m_jni_info
->get_type_info( jni
, pAny
->pType
) );
1782 jo_any
.reset( map_to_java( jni
, pUnoI
, iface_info
) );
1784 // box up in com.sun.star.uno.Any
1786 args
[ 0 ].l
= iface_info
->m_type
;
1787 args
[ 1 ].l
= jo_any
.get();
1790 m_jni_info
->m_class_Any
,
1791 m_jni_info
->m_ctor_Any_with_Type_Object
, args
) );
1792 jni
.ensure_no_exception();
1796 case typelib_TypeClass_STRUCT
:
1798 // Do not lose information about type arguments of instantiated
1799 // polymorphic struct types:
1800 OUString
const & name
= OUString::unacquired(
1801 &pAny
->pType
->pTypeName
);
1802 OSL_ASSERT(!name
.isEmpty());
1803 if (name
[name
.getLength() - 1] == '>')
1805 // Box up in com.sun.star.uno.Any:
1806 JLocalAutoRef
jo_type(jni
, create_type(jni
, pAny
->pType
));
1809 jni
, &java_data2
, pAny
->pData
, pAny
->pType
, 0, true,
1811 jo_any
.reset(java_data2
.l
);
1813 args
[0].l
= jo_type
.get();
1814 args
[1].l
= jo_any
.get();
1817 m_jni_info
->m_class_Any
,
1818 m_jni_info
->m_ctor_Any_with_Type_Object
, args
));
1819 jni
.ensure_no_exception();
1828 jni
, &java_data2
, pAny
->pData
, pAny
->pType
, 0,
1829 true /* in */, false /* no out */,
1830 true /* create integral wrappers */ );
1831 jo_any
.reset( java_data2
.l
);
1840 if (0 == java_data
->l
)
1842 java_data
->l
= jni
->NewObjectArray(
1843 1, m_jni_info
->m_class_Object
, jo_any
.get() );
1844 jni
.ensure_no_exception();
1848 jni
->SetObjectArrayElement(
1849 (jobjectArray
) java_data
->l
, 0, jo_any
.get() );
1850 jni
.ensure_no_exception();
1855 java_data
->l
= jo_any
.release();
1859 case typelib_TypeClass_ENUM
:
1861 OUString
const & type_name
= OUString::unacquired( &type
->pTypeName
);
1863 OUStringToOString( type_name
, RTL_TEXTENCODING_JAVA_UTF8
) );
1864 JLocalAutoRef
jo_enum_class(
1865 jni
, find_class( jni
, class_name
.getStr() ) );
1867 JLocalAutoRef
jo_enum( jni
);
1870 // call static <enum_class>.fromInt( int )
1871 OStringBuffer
sig_buf( 5 + class_name
.getLength() );
1872 sig_buf
.append( "(I)L" );
1873 sig_buf
.append( class_name
.replace( '.', '/' ) );
1874 sig_buf
.append( ';' );
1875 OString
sig( sig_buf
.makeStringAndClear() );
1876 jmethodID method_id
= jni
->GetStaticMethodID(
1877 (jclass
) jo_enum_class
.get(), "fromInt", sig
.getStr() );
1878 jni
.ensure_no_exception();
1879 OSL_ASSERT( 0 != method_id
);
1882 arg
.i
= *(jint
const *) uno_data
;
1884 jni
->CallStaticObjectMethodA(
1885 (jclass
) jo_enum_class
.get(), method_id
, &arg
) );
1886 jni
.ensure_no_exception();
1890 if (0 == java_data
->l
)
1892 java_data
->l
= jni
->NewObjectArray(
1893 1, (jclass
) jo_enum_class
.get(), jo_enum
.get() );
1894 jni
.ensure_no_exception();
1898 jni
->SetObjectArrayElement(
1899 (jobjectArray
) java_data
->l
, 0, jo_enum
.get() );
1900 jni
.ensure_no_exception();
1905 java_data
->l
= jo_enum
.release();
1909 case typelib_TypeClass_STRUCT
:
1910 case typelib_TypeClass_EXCEPTION
:
1913 info
= m_jni_info
->get_type_info( jni
, type
);
1914 JNI_compound_type_info
const * comp_info
=
1915 static_cast< JNI_compound_type_info
const * >( info
);
1917 JLocalAutoRef
jo_comp( jni
);
1920 if (typelib_TypeClass_EXCEPTION
== type
->eTypeClass
)
1922 JLocalAutoRef
jo_message(
1923 jni
, ustring_to_jstring( jni
, *(rtl_uString
**)uno_data
) );
1925 arg
.l
= jo_message
.get();
1928 comp_info
->m_class
, comp_info
->m_exc_ctor
, &arg
) );
1929 jni
.ensure_no_exception();
1933 jo_comp
.reset( jni
->AllocObject( comp_info
->m_class
) );
1934 jni
.ensure_no_exception();
1937 for ( JNI_compound_type_info
const * linfo
= comp_info
;
1939 linfo
= static_cast< JNI_compound_type_info
const * >(
1942 typelib_CompoundTypeDescription
* comp_td
=
1943 (typelib_CompoundTypeDescription
*)linfo
->m_td
.get();
1944 typelib_TypeDescriptionReference
** ppMemberTypeRefs
=
1945 comp_td
->ppTypeRefs
;
1946 sal_Int32
* pMemberOffsets
= comp_td
->pMemberOffsets
;
1948 = comp_td
->aBase
.eTypeClass
== typelib_TypeClass_STRUCT
1949 && reinterpret_cast< typelib_StructTypeDescription
* >(
1950 comp_td
)->pParameterizedTypes
!= 0;
1951 for ( sal_Int32 nPos
= comp_td
->nMembers
; nPos
--; )
1953 jfieldID field_id
= linfo
->m_fields
[ nPos
];
1957 (char const *)uno_data
+ pMemberOffsets
[ nPos
];
1958 typelib_TypeDescriptionReference
* member_type
=
1959 ppMemberTypeRefs
[ nPos
];
1960 bool parameterizedType
= polymorphic
1961 && (reinterpret_cast<
1962 typelib_StructTypeDescription
* >(comp_td
)->
1963 pParameterizedTypes
[nPos
]);
1964 switch (member_type
->eTypeClass
)
1966 case typelib_TypeClass_CHAR
:
1967 if (parameterizedType
) {
1969 arg
.c
= *(jchar
const *) p
;
1973 m_jni_info
->m_class_Character
,
1974 m_jni_info
->m_ctor_Character_with_char
,
1976 jni
.ensure_no_exception();
1977 jni
->SetObjectField(
1978 jo_comp
.get(), field_id
, jo
.get() );
1982 field_id
, *(jchar
const *) p
);
1985 case typelib_TypeClass_BOOLEAN
:
1986 if (parameterizedType
) {
1988 arg
.z
= *(jboolean
const *) p
;
1992 m_jni_info
->m_class_Boolean
,
1993 m_jni_info
->m_ctor_Boolean_with_boolean
,
1995 jni
.ensure_no_exception();
1996 jni
->SetObjectField(
1997 jo_comp
.get(), field_id
, jo
.get() );
1999 jni
->SetBooleanField(
2001 field_id
, *(jboolean
const *) p
);
2004 case typelib_TypeClass_BYTE
:
2005 if (parameterizedType
) {
2007 arg
.b
= *(jbyte
const *) p
;
2011 m_jni_info
->m_class_Byte
,
2012 m_jni_info
->m_ctor_Byte_with_byte
,
2014 jni
.ensure_no_exception();
2015 jni
->SetObjectField(
2016 jo_comp
.get(), field_id
, jo
.get() );
2020 field_id
, *(jbyte
const *) p
);
2023 case typelib_TypeClass_SHORT
:
2024 case typelib_TypeClass_UNSIGNED_SHORT
:
2025 if (parameterizedType
) {
2027 arg
.s
= *(jshort
const *) p
;
2031 m_jni_info
->m_class_Short
,
2032 m_jni_info
->m_ctor_Short_with_short
,
2034 jni
.ensure_no_exception();
2035 jni
->SetObjectField(
2036 jo_comp
.get(), field_id
, jo
.get() );
2040 field_id
, *(jshort
const *) p
);
2043 case typelib_TypeClass_LONG
:
2044 case typelib_TypeClass_UNSIGNED_LONG
:
2045 if (parameterizedType
) {
2047 arg
.i
= *(jint
const *) p
;
2051 m_jni_info
->m_class_Integer
,
2052 m_jni_info
->m_ctor_Integer_with_int
,
2054 jni
.ensure_no_exception();
2055 jni
->SetObjectField(
2056 jo_comp
.get(), field_id
, jo
.get() );
2060 field_id
, *(jint
const *) p
);
2063 case typelib_TypeClass_HYPER
:
2064 case typelib_TypeClass_UNSIGNED_HYPER
:
2065 if (parameterizedType
) {
2067 arg
.j
= *(jlong
const *) p
;
2071 m_jni_info
->m_class_Long
,
2072 m_jni_info
->m_ctor_Long_with_long
,
2074 jni
.ensure_no_exception();
2075 jni
->SetObjectField(
2076 jo_comp
.get(), field_id
, jo
.get() );
2080 field_id
, *(jlong
const *) p
);
2083 case typelib_TypeClass_FLOAT
:
2084 if (parameterizedType
) {
2086 arg
.f
= *(jfloat
const *) p
;
2090 m_jni_info
->m_class_Float
,
2091 m_jni_info
->m_ctor_Float_with_float
,
2093 jni
.ensure_no_exception();
2094 jni
->SetObjectField(
2095 jo_comp
.get(), field_id
, jo
.get() );
2099 field_id
, *(jfloat
const *) p
);
2102 case typelib_TypeClass_DOUBLE
:
2103 if (parameterizedType
) {
2105 arg
.d
= *(jdouble
const *) p
;
2109 m_jni_info
->m_class_Double
,
2110 m_jni_info
->m_ctor_Double_with_double
,
2112 jni
.ensure_no_exception();
2113 jni
->SetObjectField(
2114 jo_comp
.get(), field_id
, jo
.get() );
2116 jni
->SetDoubleField(
2118 field_id
, *(jdouble
const *) p
);
2121 case typelib_TypeClass_STRING
: // string opt here
2123 JLocalAutoRef
jo_string(
2124 jni
, ustring_to_jstring(
2125 jni
, *(rtl_uString
* const *) p
) );
2126 jni
->SetObjectField(
2127 jo_comp
.get(), field_id
, jo_string
.get() );
2134 jni
, &java_data2
, p
, member_type
, 0,
2135 true /* in */, false /* no out */ );
2136 JLocalAutoRef
jo_obj( jni
, java_data2
.l
);
2137 jni
->SetObjectField(
2138 jo_comp
.get(), field_id
, jo_obj
.get() );
2148 if (0 == java_data
->l
)
2151 jni
->NewObjectArray( 1, comp_info
->m_class
, jo_comp
.get() );
2152 jni
.ensure_no_exception();
2156 jni
->SetObjectArrayElement(
2157 (jobjectArray
) java_data
->l
, 0, jo_comp
.get() );
2158 jni
.ensure_no_exception();
2163 java_data
->l
= jo_comp
.release();
2167 case typelib_TypeClass_SEQUENCE
:
2169 // xxx todo: possible opt for pure out sequences
2170 JLocalAutoRef
jo_ar( jni
);
2172 sal_Int32 nElements
;
2173 uno_Sequence
const * seq
= 0;
2176 seq
= *(uno_Sequence
* const *)uno_data
;
2177 nElements
= seq
->nElements
;
2184 TypeDescr
td( type
);
2185 typelib_TypeDescriptionReference
* element_type
=
2186 ((typelib_IndirectTypeDescription
*)td
.get())->pType
;
2188 switch (element_type
->eTypeClass
)
2190 case typelib_TypeClass_CHAR
:
2191 jo_ar
.reset( jni
->NewCharArray( nElements
) );
2192 jni
.ensure_no_exception();
2195 jni
->SetCharArrayRegion(
2196 (jcharArray
) jo_ar
.get(),
2197 0, nElements
, (jchar
*) seq
->elements
);
2198 jni
.ensure_no_exception();
2201 case typelib_TypeClass_BOOLEAN
:
2202 jo_ar
.reset( jni
->NewBooleanArray( nElements
) );
2203 jni
.ensure_no_exception();
2206 jni
->SetBooleanArrayRegion(
2207 (jbooleanArray
) jo_ar
.get(),
2208 0, nElements
, (jboolean
*) seq
->elements
);
2209 jni
.ensure_no_exception();
2212 case typelib_TypeClass_BYTE
:
2213 jo_ar
.reset( jni
->NewByteArray( nElements
) );
2214 jni
.ensure_no_exception();
2217 jni
->SetByteArrayRegion(
2218 (jbyteArray
) jo_ar
.get(),
2219 0, nElements
, (jbyte
*) seq
->elements
);
2220 jni
.ensure_no_exception();
2223 case typelib_TypeClass_SHORT
:
2224 case typelib_TypeClass_UNSIGNED_SHORT
:
2225 jo_ar
.reset( jni
->NewShortArray( nElements
) );
2226 jni
.ensure_no_exception();
2229 jni
->SetShortArrayRegion(
2230 (jshortArray
) jo_ar
.get(),
2231 0, nElements
, (jshort
*) seq
->elements
);
2232 jni
.ensure_no_exception();
2235 case typelib_TypeClass_LONG
:
2236 case typelib_TypeClass_UNSIGNED_LONG
:
2237 jo_ar
.reset( jni
->NewIntArray( nElements
) );
2238 jni
.ensure_no_exception();
2241 jni
->SetIntArrayRegion(
2242 (jintArray
) jo_ar
.get(),
2243 0, nElements
, (jint
*) seq
->elements
);
2244 jni
.ensure_no_exception();
2247 case typelib_TypeClass_HYPER
:
2248 case typelib_TypeClass_UNSIGNED_HYPER
:
2249 jo_ar
.reset( jni
->NewLongArray( nElements
) );
2250 jni
.ensure_no_exception();
2253 jni
->SetLongArrayRegion(
2254 (jlongArray
) jo_ar
.get(),
2255 0, nElements
, (jlong
*) seq
->elements
);
2256 jni
.ensure_no_exception();
2259 case typelib_TypeClass_FLOAT
:
2260 jo_ar
.reset( jni
->NewFloatArray( nElements
) );
2261 jni
.ensure_no_exception();
2264 jni
->SetFloatArrayRegion(
2265 (jfloatArray
) jo_ar
.get(),
2266 0, nElements
, (jfloat
*) seq
->elements
);
2267 jni
.ensure_no_exception();
2270 case typelib_TypeClass_DOUBLE
:
2271 jo_ar
.reset( jni
->NewDoubleArray( nElements
) );
2272 jni
.ensure_no_exception();
2275 jni
->SetDoubleArrayRegion(
2276 (jdoubleArray
) jo_ar
.get(),
2277 0, nElements
, (jdouble
*) seq
->elements
);
2278 jni
.ensure_no_exception();
2281 case typelib_TypeClass_STRING
:
2283 jni
->NewObjectArray(
2284 nElements
, m_jni_info
->m_class_String
, 0 ) );
2285 jni
.ensure_no_exception();
2288 rtl_uString
* const * pp
=
2289 (rtl_uString
* const *) seq
->elements
;
2290 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
2292 JLocalAutoRef
jo_string(
2293 jni
, ustring_to_jstring( jni
, pp
[ nPos
] ) );
2294 jni
->SetObjectArrayElement(
2295 (jobjectArray
) jo_ar
.get(), nPos
, jo_string
.get() );
2296 jni
.ensure_no_exception();
2300 case typelib_TypeClass_TYPE
:
2302 jni
->NewObjectArray( nElements
, m_jni_info
->m_class_Type
, 0 ) );
2303 jni
.ensure_no_exception();
2306 typelib_TypeDescriptionReference
* const * pp
=
2307 (typelib_TypeDescriptionReference
* const *)seq
->elements
;
2308 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
2312 jni
, &val
, &pp
[ nPos
], element_type
, 0,
2313 true /* in */, false /* no out */ );
2314 JLocalAutoRef
jo_element( jni
, val
.l
);
2315 jni
->SetObjectArrayElement(
2316 (jobjectArray
) jo_ar
.get(), nPos
, jo_element
.get() );
2317 jni
.ensure_no_exception();
2321 case typelib_TypeClass_ANY
:
2323 jni
->NewObjectArray(
2324 nElements
, m_jni_info
->m_class_Object
, 0 ) );
2325 jni
.ensure_no_exception();
2328 uno_Any
const * p
= (uno_Any
const *)seq
->elements
;
2329 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
2333 jni
, &val
, &p
[ nPos
], element_type
, 0,
2334 true /* in */, false /* no out */ );
2335 JLocalAutoRef
jo_element( jni
, val
.l
);
2336 jni
->SetObjectArrayElement(
2337 (jobjectArray
) jo_ar
.get(), nPos
, jo_element
.get() );
2338 jni
.ensure_no_exception();
2342 case typelib_TypeClass_ENUM
:
2344 OUString
const & element_type_name
=
2345 OUString::unacquired( &element_type
->pTypeName
);
2348 element_type_name
, RTL_TEXTENCODING_JAVA_UTF8
) );
2349 JLocalAutoRef
jo_enum_class(
2350 jni
, find_class( jni
, class_name
.getStr() ) );
2353 jni
->NewObjectArray(
2354 nElements
, (jclass
) jo_enum_class
.get(), 0 ) );
2355 jni
.ensure_no_exception();
2359 // call static <enum_class>.fromInt( int )
2360 OStringBuffer
sig_buf( 5 + class_name
.getLength() );
2361 sig_buf
.append( "(I)L" );
2362 sig_buf
.append( class_name
.replace( '.', '/' ) );
2363 sig_buf
.append( ';' );
2364 OString
sig( sig_buf
.makeStringAndClear() );
2365 jmethodID method_id
= jni
->GetStaticMethodID(
2366 (jclass
) jo_enum_class
.get(), "fromInt", sig
.getStr() );
2367 jni
.ensure_no_exception();
2368 OSL_ASSERT( 0 != method_id
);
2370 sal_Int32
const * p
= (sal_Int32
const *)seq
->elements
;
2371 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
2375 JLocalAutoRef
jo_enum(
2376 jni
, jni
->CallStaticObjectMethodA(
2377 (jclass
) jo_enum_class
.get(), method_id
, &arg
) );
2378 jni
.ensure_no_exception();
2379 jni
->SetObjectArrayElement(
2380 (jobjectArray
) jo_ar
.get(), nPos
, jo_enum
.get() );
2381 jni
.ensure_no_exception();
2386 case typelib_TypeClass_STRUCT
:
2387 case typelib_TypeClass_EXCEPTION
:
2389 JNI_type_info
const * element_info
=
2390 m_jni_info
->get_type_info( jni
, element_type
);
2393 jni
->NewObjectArray( nElements
, element_info
->m_class
, 0 ) );
2394 jni
.ensure_no_exception();
2398 char * p
= (char *)seq
->elements
;
2399 sal_Int32 nSize
= element_info
->m_td
.get()->nSize
;
2400 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
2404 jni
, &val
, p
+ (nSize
* nPos
),
2405 element_type
, element_info
,
2406 true /* in */, false /* no out */ );
2407 JLocalAutoRef
jo_element( jni
, val
.l
);
2408 jni
->SetObjectArrayElement(
2409 (jobjectArray
) jo_ar
.get(), nPos
, jo_element
.get() );
2410 jni
.ensure_no_exception();
2415 case typelib_TypeClass_SEQUENCE
:
2417 OStringBuffer
buf( 64 );
2418 JNI_info::append_sig(
2419 &buf
, element_type
, false /* use class XInterface */,
2420 false /* '.' instead of '/' */ );
2421 OString
class_name( buf
.makeStringAndClear() );
2422 JLocalAutoRef
jo_seq_class(
2423 jni
, find_class( jni
, class_name
.getStr() ) );
2426 jni
->NewObjectArray(
2427 nElements
, (jclass
) jo_seq_class
.get(), 0 ) );
2428 jni
.ensure_no_exception();
2432 TypeDescr
element_td( element_type
);
2433 uno_Sequence
** elements
= (uno_Sequence
**) seq
->elements
;
2434 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
2438 jni
, &java_data2
, elements
+ nPos
, element_type
, 0,
2439 true /* in */, false /* no out */ );
2440 JLocalAutoRef
jo_seq( jni
, java_data2
.l
);
2441 jni
->SetObjectArrayElement(
2442 (jobjectArray
) jo_ar
.get(), nPos
, jo_seq
.get() );
2443 jni
.ensure_no_exception();
2448 case typelib_TypeClass_INTERFACE
:
2450 JNI_interface_type_info
const * iface_info
=
2451 static_cast< JNI_interface_type_info
const * >(
2452 m_jni_info
->get_type_info( jni
, element_type
) );
2455 jni
->NewObjectArray( nElements
, iface_info
->m_class
, 0 ) );
2456 jni
.ensure_no_exception();
2460 uno_Interface
** pp
= (uno_Interface
**)seq
->elements
;
2461 for ( sal_Int32 nPos
= 0; nPos
< nElements
; ++nPos
)
2463 uno_Interface
* pUnoI
= pp
[ nPos
];
2466 JLocalAutoRef
jo_element(
2467 jni
, map_to_java( jni
, pUnoI
, iface_info
) );
2468 jni
->SetObjectArrayElement(
2469 (jobjectArray
) jo_ar
.get(),
2470 nPos
, jo_element
.get() );
2471 jni
.ensure_no_exception();
2479 OUStringBuffer
buf( 128 );
2480 buf
.append( "[map_to_java():" );
2481 buf
.append( OUString::unacquired( &type
->pTypeName
) );
2482 buf
.append( "] unsupported element type: " );
2483 buf
.append( OUString::unacquired( &element_type
->pTypeName
) );
2484 buf
.append( jni
.get_stack_trace() );
2485 throw BridgeRuntimeError( buf
.makeStringAndClear() );
2491 if (0 == java_data
->l
)
2493 JLocalAutoRef
jo_element_class(
2494 jni
, jni
->GetObjectClass( jo_ar
.get() ) );
2497 java_data
->l
= jni
->NewObjectArray(
2498 1, (jclass
) jo_element_class
.get(), jo_ar
.get() );
2502 java_data
->l
= jni
->NewObjectArray(
2503 1, (jclass
) jo_element_class
.get(), 0 );
2505 jni
.ensure_no_exception();
2509 jni
->SetObjectArrayElement(
2510 (jobjectArray
) java_data
->l
, 0, jo_ar
.get() );
2511 jni
.ensure_no_exception();
2516 java_data
->l
= jo_ar
.release();
2520 case typelib_TypeClass_INTERFACE
:
2522 JLocalAutoRef
jo_iface( jni
);
2525 uno_Interface
* pUnoI
= *(uno_Interface
* const *)uno_data
;
2529 info
= m_jni_info
->get_type_info( jni
, type
);
2530 JNI_interface_type_info
const * iface_info
=
2531 static_cast< JNI_interface_type_info
const * >( info
);
2532 jo_iface
.reset( map_to_java( jni
, pUnoI
, iface_info
) );
2537 if (0 == java_data
->l
)
2540 info
= m_jni_info
->get_type_info( jni
, type
);
2542 jni
->NewObjectArray( 1, info
->m_class
, jo_iface
.get() );
2543 jni
.ensure_no_exception();
2547 jni
->SetObjectArrayElement(
2548 (jobjectArray
) java_data
->l
, 0, jo_iface
.get() );
2549 jni
.ensure_no_exception();
2554 java_data
->l
= jo_iface
.release();
2560 OUStringBuffer
buf( 128 );
2561 buf
.append( "[map_to_java():" );
2562 buf
.append( OUString::unacquired( &type
->pTypeName
) );
2563 buf
.appendAscii( "] unsupported type!" );
2564 buf
.append( jni
.get_stack_trace() );
2565 throw BridgeRuntimeError( buf
.makeStringAndClear() );
2572 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */