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 .
20 #include <sal/config.h>
26 #include <com/sun/star/uno/Exception.hpp>
27 #include <com/sun/star/uno/RuntimeException.hpp>
28 #include <com/sun/star/uno/genfunc.hxx>
29 #include <o3tl/runtimetooustring.hxx>
34 #include "unointerfaceproxy.hxx"
35 #include "vtables.hxx"
39 #define SET_FP(n, p) \
40 __asm__( "ldx %0, %%l0\n\t" \
41 "ldd [%%l0], %%f" #n "\n" \
44 using namespace com::sun::star::uno
;
48 void fillReturn(const typelib_TypeDescription
* pTypeDescr
,
49 long long * oret
, float * fret
, double * dret
, void * pRegisterReturn
)
51 for (const typelib_CompoundTypeDescription
*p
=
52 reinterpret_cast<const typelib_CompoundTypeDescription
*>( pTypeDescr
);
53 p
!= NULL
; p
= p
->pBaseTypeDescription
)
56 for (sal_Int32 i
= 0; i
< p
->nMembers
; ++i
)
58 typelib_TypeDescriptionReference
*pTypeInStruct
= p
->ppTypeRefs
[ i
];
60 sal_Int32 nOff
= p
->pMemberOffsets
[ i
];
62 switch (pTypeInStruct
->eTypeClass
)
64 case typelib_TypeClass_HYPER
:
65 case typelib_TypeClass_UNSIGNED_HYPER
:
66 *(long*)((char *)pRegisterReturn
+ nOff
) = *(long*)((char *)oret
+ nOff
);
68 case typelib_TypeClass_LONG
:
69 case typelib_TypeClass_UNSIGNED_LONG
:
70 case typelib_TypeClass_ENUM
:
71 *(int*)((char *)pRegisterReturn
+ nOff
) = *(int*)((char *)oret
+ nOff
);
73 case typelib_TypeClass_CHAR
:
74 case typelib_TypeClass_SHORT
:
75 case typelib_TypeClass_UNSIGNED_SHORT
:
76 *(unsigned short*)((char *)pRegisterReturn
+ nOff
) = *(unsigned short*)((char *)oret
+ nOff
);
78 case typelib_TypeClass_BOOLEAN
:
79 case typelib_TypeClass_BYTE
:
80 *(unsigned char*)((char *)pRegisterReturn
+ nOff
) = *(unsigned char*)((char *)oret
+ nOff
);
82 case typelib_TypeClass_FLOAT
:
83 *(float*)((char *)pRegisterReturn
+ nOff
) = *(float*)((char *)fret
+ nOff
);
85 case typelib_TypeClass_DOUBLE
:
86 *(double*)((char *)pRegisterReturn
+ nOff
) = *(double*)((char *)dret
+ nOff
);
88 case typelib_TypeClass_STRUCT
:
89 case typelib_TypeClass_EXCEPTION
:
91 typelib_TypeDescription
* td
= NULL
;
92 TYPELIB_DANGER_GET(&td
, pTypeInStruct
);
94 (long long *)((char *)oret
+ nOff
),
95 (float *)((char *)fret
+ nOff
),
96 (double *)((char *)dret
+ nOff
),
97 (char *)pRegisterReturn
+ nOff
);
98 TYPELIB_DANGER_RELEASE(td
);
107 // The call instruction within the asm section of callVirtualMethod may throw
108 // exceptions. So that the compiler handles this correctly, it is important
109 // that (a) callVirtualMethod might call dummy_can_throw_anything (although this
110 // never happens at runtime), which in turn can throw exceptions, and (b)
111 // callVirtualMethod is not inlined at its call site (so that any exceptions are
112 // caught which are thrown from the instruction calling callVirtualMethod):
114 void callVirtualMethod( void * pAdjustedThisPtr
,
115 sal_Int32 nVtableIndex
,
116 void * pRegisterReturn
,
117 typelib_TypeDescriptionReference
* pReturnTypeRef
,
118 sal_Int64
* pStackHypers
,
119 sal_Int32 nStackHypers
,
120 typelib_MethodParameter
* pParams
, sal_Int32 nParams
) __attribute__((noinline
));
122 void callVirtualMethod( void * pAdjustedThisPtr
,
123 sal_Int32
/* nVtableIndex */,
124 void * pRegisterReturn
,
125 typelib_TypeDescriptionReference
* pReturnTypeRef
,
126 sal_Int64
* pStackHypers
,
127 #if OSL_DEBUG_LEVEL > 0
128 sal_Int32 nStackHypers
,
130 // sal_Int64 * /*pStackHypers*/,
131 sal_Int32
/*nStackHypers*/,
133 typelib_MethodParameter
* pParams
, sal_Int32 nParams
)
135 // parameter list is mixed list of * and values
136 // reference parameters are pointers
138 assert(pStackHypers
&& pAdjustedThisPtr
);
139 static_assert( (sizeof(void *) == 8) &&
140 (sizeof(sal_Int64
) == 8), "### unexpected size of int!" );
141 assert(nStackHypers
&& pStackHypers
&& "### no stack in callVirtualMethod !");
144 if (! pAdjustedThisPtr
) CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something
146 long bSimpleReturn
= !CPPU_CURRENT_NAMESPACE::return_in_hidden_param( pReturnTypeRef
);
148 int paramsOffset
= bSimpleReturn
? 1 : 2;
149 for (sal_Int32 i
= 0; i
< nParams
; ++i
)
151 if (!pParams
[i
].bOut
)
153 switch (pParams
[i
].pTypeRef
->eTypeClass
) {
154 case typelib_TypeClass_FLOAT
:
155 case typelib_TypeClass_DOUBLE
:
157 int paramArrayIdx
= i
+ paramsOffset
;
158 assert(paramArrayIdx
< nStackHypers
);
159 void *p
= &pStackHypers
[paramArrayIdx
];
160 switch (paramArrayIdx
) {
161 // Cannot be 0 - paramsOffset >= 1
207 // Anything larger is passed on the stack
220 volatile long long saveReg
[14];
230 "stx %%l0, [%[saveReg]]\n\t"
231 "stx %%l1, [%[saveReg]+8]\n\t"
232 "mov %[saveReg], %%l1\n\t"
233 "add %%l1, 16, %%l0\n\t"
234 "stx %%l2, [%%l0]\n\t"
235 "add %%l0, 8, %%l0\n\t"
236 "stx %%l3, [%%l0]\n\t"
237 "add %%l0, 8, %%l0\n\t"
238 "stx %%l4, [%%l0]\n\t"
239 "add %%l0, 8, %%l0\n\t"
240 "stx %%l5, [%%l0]\n\t"
241 "add %%l0, 8, %%l0\n\t"
242 "stx %%o0, [%%l0]\n\t"
243 "add %%l0, 8, %%l0\n\t"
244 "stx %%o1, [%%l0]\n\t"
245 "add %%l0, 8, %%l0\n\t"
246 "stx %%o2, [%%l0]\n\t"
247 "add %%l0, 8, %%l0\n\t"
248 "stx %%o3, [%%l0]\n\t"
249 "add %%l0, 8, %%l0\n\t"
250 "stx %%o4, [%%l0]\n\t"
251 "add %%l0, 8, %%l0\n\t"
252 "stx %%o5, [%%l0]\n\t"
253 "add %%l0, 8, %%l0\n\t"
254 "stx %%l6, [%%l0]\n\t"
255 "add %%l0, 8, %%l0\n\t"
256 "stx %%l7, [%%l0]\n\t"
259 // increase our own stackframe if necessary
260 "mov %%sp, %%l3\n\t" // save stack ptr for readjustment
262 "subcc %%i5, 6, %%l0\n\t"
266 "sllx %%l0, 3, %%l0\n\t"
267 "add %%l0, 192, %%l0\n\t"
268 "add %%sp, 2047, %%l1\n\t" // old stack ptr
269 "sub %%l1, %%l0, %%l0\n\t" // future stack ptr
270 "andcc %%l0, 15, %%g0\n\t" // align stack to 16
273 "sub %%l0, 8, %%l0\n"
275 "mov %%l0, %%o5\n\t" // save newly computed stack ptr
276 "add %%g0, 16, %%o4\n"
278 // now copy hypers down to save register window
279 // and local variables
281 "ldx [%%l1], %%l2\n\t"
282 "stx %%l2,[%%l0]\n\t"
283 "add %%l0, 8, %%l0\n\t"
284 "add %%l1, 8, %%l1\n\t"
285 "subcc %%o4, 1, %%o4\n\t"
289 "sub %%o5, 2047, %%sp\n\t" // move new stack ptr (hopefully) atomically - with bias
290 // while register window is valid in both spaces
291 // (scheduling might hit in copyDown loop)
293 "sub %%i5, 6, %%l0\n\t" // copy parameters past the sixth to stack
294 "add %%i4, 48, %%l1\n\t"
295 "add %%sp, 2223, %%l2\n" // 2047+176
297 "ldx [%%l1], %%o0\n\t"
298 "stx %%o0, [%%l2]\n\t"
299 "add %%l1, 8, %%l1\n\t"
300 "add %%l2, 8, %%l2\n\t"
301 "subcc %%l0, 1, %%l0\n\t"
306 "mov %%i5, %%l0\n\t" // prepare out registers
309 "ldx [%%l1], %%o0\n\t"// // prepare complex return ptr
310 //"ldd [%%l1], %%f0\n\t"
311 //"stx %%o0, [%%sp+2047+128]\n\t"
312 "sub %%l0, 1, %%l0\n\t"
313 "add %%l1, 8, %%l1\n\t"
314 //"subxcc %%o0, %%g0, %%o0\n\t"
315 //"bne .LhadComplexReturn\n\t"
318 // No complex return ptr - this (next on stack) goes in %o0
320 //"ldx [%%l1], %%o0\n\t"
321 //"subcc %%l0, 1, %%l0\n\t"
324 //"add %%l1, 8, %%l1\n\t"
326 //".LhadComplexReturn:\n\t"
327 "ldx [%%l1], %%o1\n\t"
328 //"ldd [%%l1], %%f2\n\t"
329 "subcc %%l0, 1, %%l0\n\t"
333 "add %%l1, 8, %%l1\n\t"
334 "ldx [%%l1], %%o2\n\t"
335 //"ldd [%%l1], %%f4\n\t"
336 "subcc %%l0, 1, %%l0\n\t"
340 "add %%l1, 8, %%l1\n\t"
341 "ldx [%%l1], %%o3\n\t"
342 //"ldd [%%l1], %%f6\n\t"
343 "subcc %%l0, 1, %%l0\n\t"
347 "add %%l1, 8, %%l1\n\t"
348 "ldx [%%l1], %%o4\n\t"
349 //"ldd [%%l1], %%f8\n\t"
350 "subcc %%l0, 1, %%l0\n\t"
354 "add %%l1, 8, %%l1\n\t"
356 //"ldd [%%l1], %%f10\n\t"
359 "ldx [%%i0], %%l0\n\t" // get vtable ptr
361 "sllx %%i1, 3, %%l6\n\t"
362 // "add %%l6, 8, %%l6\n\t"
363 "add %%l6, %%l0, %%l0\n\t"
364 // // vtable has 8byte wide entries,
365 // // upper half contains 2 half words, of which the first
366 // // is the this ptr patch !
367 // // first entry is (or __tf)
369 // "ldsh [%%l0], %%l6\n\t" // load this ptr patch
370 // "add %%l6, %%o0, %%o0\n\t" // patch this ptr
372 // "add %%l0, 4, %%l0\n\t" // get virtual function ptr
373 "ldx [%%l0], %%l0\n\t"
375 // "ldx %0, %%l2\n\t"
376 // "subcc %%l2, %%g0, %%l2\n\t"
377 // "be .LcomplexCall\n\t"
381 // "ba .LcallReturned\n\t"
383 // ".LcomplexCall:\n\t"
388 // ".LcallReturned:\n\t"
389 "subcc %%l3, %%sp, %%g0\n\t"
392 // Copy register save area back up
393 // Note: copy in reverse order (top down) in case areas overlap
394 "add %%sp, 2167, %%l0\n\t" // 2047+120
395 "add %%l3, 2167, %%l1\n\t"
396 "add %%g0, 16, %%o4\n\t"
398 "ldx [%%l0], %%l2\n\t"
399 "stx %%l2, [%%l1]\n\t"
400 "sub %%l0, 8, %%l0\n\t"
401 "sub %%l1, 8, %%l1\n\t"
402 "subcc %%o4, 1, %%o4\n\t"
407 "mov %%l3, %%sp\n\t" // readjust stack so that our locals are where they belong
409 // save possible return registers into our locals
410 "stx %%o0, %[oret0]\n\t"
411 "stx %%o1, %[oret1]\n\t"
412 "stx %%o2, %[oret2]\n\t"
413 "stx %%o3, %[oret3]\n\t"
414 "std %%f0, %[dret0]\n\t"
415 "std %%f2, %[dret1]\n\t"
416 "std %%f4, %[dret2]\n\t"
417 "std %%f6, %[dret3]\n\t"
421 "ldx [%%l7], %%l0\n\t"
422 "add %%l7, 8, %%l7\n\t"
423 "ldx [%%l7], %%l1\n\t"
424 "add %%l7, 8, %%l7\n\t"
425 "ldx [%%l7], %%l2\n\t"
426 "add %%l7, 8, %%l7\n\t"
427 "ldx [%%l7], %%l3\n\t"
428 "add %%l7, 8, %%l7\n\t"
429 "ldx [%%l7], %%l4\n\t"
430 "add %%l7, 8, %%l7\n\t"
431 "ldx [%%l7], %%l5\n\t"
432 "add %%l7, 8, %%l7\n\t"
433 "ldx [%%l7], %%o0\n\t"
434 "add %%l7, 8, %%l7\n\t"
435 "ldx [%%l7], %%o1\n\t"
436 "add %%l7, 8, %%l7\n\t"
437 "ldx [%%l7], %%o2\n\t"
438 "add %%l7, 8, %%l7\n\t"
439 "ldx [%%l7], %%o3\n\t"
440 "add %%l7, 8, %%l7\n\t"
441 "ldx [%%l7], %%o4\n\t"
442 "add %%l7, 8, %%l7\n\t"
443 "ldx [%%l7], %%o5\n\t"
444 "add %%l7, 8, %%l7\n\t"
445 "ldx [%%l7], %%l6\n\t"
446 "add %%l7, 8, %%l7\n\t"
447 "ldx [%%l7], %%l7\n\t"
449 //"=m"(bSimpleReturn),
450 [oret0
]"=m"(oret
[0]), [oret1
]"=m"(oret
[1]), [oret2
]"=m"(oret
[2]), [oret3
]"=m"(oret
[3]),
451 [dret0
]"=m"(fdret
.d
[0]), [dret1
]"=m"(fdret
.d
[1]), [dret2
]"=m"(fdret
.d
[2]), [dret3
]"=m"(fdret
.d
[3])
454 [saveReg
]"r"(&saveReg
[0])
458 switch(pReturnTypeRef
->eTypeClass
)
460 case typelib_TypeClass_HYPER
:
461 case typelib_TypeClass_UNSIGNED_HYPER
:
462 *(long*)pRegisterReturn
= oret
[0];
464 case typelib_TypeClass_LONG
:
465 case typelib_TypeClass_UNSIGNED_LONG
:
466 case typelib_TypeClass_ENUM
:
467 *(int*)pRegisterReturn
= (int)oret
[0];
469 case typelib_TypeClass_CHAR
:
470 case typelib_TypeClass_SHORT
:
471 case typelib_TypeClass_UNSIGNED_SHORT
:
472 *(unsigned short*)pRegisterReturn
= (unsigned short)oret
[0];
474 case typelib_TypeClass_BOOLEAN
:
475 case typelib_TypeClass_BYTE
:
476 *(unsigned char*)pRegisterReturn
= (unsigned char)oret
[0];
478 case typelib_TypeClass_FLOAT
:
479 *(float*)pRegisterReturn
= fdret
.f
[0];
481 case typelib_TypeClass_DOUBLE
:
482 *(double*)pRegisterReturn
= fdret
.d
[0];
484 case typelib_TypeClass_STRUCT
:
485 case typelib_TypeClass_EXCEPTION
:
487 sal_Int32
const nRetSize
= pReturnTypeRef
->pType
->nSize
;
488 if (bSimpleReturn
&& nRetSize
<= 32 && nRetSize
> 0)
490 typelib_TypeDescription
* pTypeDescr
= 0;
491 TYPELIB_DANGER_GET( &pTypeDescr
, pReturnTypeRef
);
492 fillReturn(pTypeDescr
, oret
, fdret
.f
, fdret
.d
, pRegisterReturn
);
493 TYPELIB_DANGER_RELEASE( pTypeDescr
);
502 static void cpp_call(
503 bridges::cpp_uno::shared::UnoInterfaceProxy
* pThis
,
504 bridges::cpp_uno::shared::VtableSlot aVtableSlot
,
505 typelib_TypeDescriptionReference
* pReturnTypeRef
,
506 sal_Int32 nParams
, typelib_MethodParameter
* pParams
,
507 void * pUnoReturn
, void * pUnoArgs
[], uno_Any
** ppUnoExc
)
509 // max space for: complex ret ptr, this, values|ptr ...
511 (char *)alloca( (nParams
+2) * sizeof(sal_Int64
) );
512 char * pCppStackStart
= pCppStack
;
514 //fprintf(stderr, "pCppStack: %p, pCppStackStart: %p\n", pCppStack, pCppStackStart);
517 typelib_TypeDescription
* pReturnTypeDescr
= 0;
518 TYPELIB_DANGER_GET( &pReturnTypeDescr
, pReturnTypeRef
);
519 assert(pReturnTypeDescr
);
521 void * pCppReturn
= 0; // if != 0 && != pUnoReturn, needs reconversion
523 if (pReturnTypeDescr
)
525 if ( CPPU_CURRENT_NAMESPACE::return_in_hidden_param( pReturnTypeRef
) )
527 // complex return via ptr
528 pCppReturn
= *(void **)pCppStack
= (bridges::cpp_uno::shared::relatesToInterfaceType(pReturnTypeDescr
)
529 ? alloca( pReturnTypeDescr
->nSize
)
530 : pUnoReturn
); // direct way
531 pCppStack
+= sizeof(void*);
535 pCppReturn
= pUnoReturn
; // direct way for simple types
539 void * pAdjustedThisPtr
= reinterpret_cast< void ** >(pThis
->getCppI())
540 + aVtableSlot
.offset
;
541 *(void**)pCppStack
= pAdjustedThisPtr
;
542 pCppStack
+= sizeof( void* );
545 static_assert(sizeof(void *) == sizeof(sal_Int64
), "### unexpected size!");
547 void ** pCppArgs
= (void **)alloca( 3 * sizeof(void *) * nParams
);
548 // indices of values this have to be converted (interface conversion cpp<=>uno)
549 sal_Int32
* pTempIndices
= (sal_Int32
*)(pCppArgs
+ nParams
);
550 // type descriptions for reconversions
551 typelib_TypeDescription
** ppTempParamTypeDescr
= (typelib_TypeDescription
**)(pCppArgs
+ (2 * nParams
));
553 sal_Int32 nTempIndices
= 0;
555 for ( sal_Int32 nPos
= 0; nPos
< nParams
; ++nPos
)
557 const typelib_MethodParameter
& rParam
= pParams
[nPos
];
558 typelib_TypeDescription
* pParamTypeDescr
= 0;
559 TYPELIB_DANGER_GET( &pParamTypeDescr
, rParam
.pTypeRef
);
560 if (!rParam
.bOut
&& bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr
))
562 uno_copyAndConvertData( pCppArgs
[nPos
] = alloca( 8 ), pUnoArgs
[nPos
], pParamTypeDescr
,
563 pThis
->getBridge()->getUno2Cpp() );
565 switch (pParamTypeDescr
->eTypeClass
)
567 case typelib_TypeClass_LONG
:
568 *(sal_Int64
*)pCppStack
= *(sal_Int32
*)pCppArgs
[nPos
];
570 case typelib_TypeClass_UNSIGNED_LONG
:
571 case typelib_TypeClass_ENUM
:
572 *(sal_Int64
*)pCppStack
= *(sal_uInt32
*)pCppArgs
[nPos
];
574 case typelib_TypeClass_CHAR
:
575 case typelib_TypeClass_SHORT
:
576 *(sal_Int64
*)pCppStack
= *(sal_Int16
*)pCppArgs
[nPos
];
578 case typelib_TypeClass_UNSIGNED_SHORT
:
579 *(sal_Int64
*)pCppStack
= *(sal_uInt16
*)pCppArgs
[nPos
];
581 case typelib_TypeClass_BOOLEAN
:
582 case typelib_TypeClass_BYTE
:
583 *(sal_Int64
*)pCppStack
= *(sal_Int8
*)pCppArgs
[nPos
];
585 case typelib_TypeClass_FLOAT
:
586 *(float *)(pCppStack
+4) = *(float *)pCppArgs
[nPos
];
588 case typelib_TypeClass_DOUBLE
:
589 *(double *)pCppStack
= *(double *)pCppArgs
[nPos
];
591 case typelib_TypeClass_HYPER
:
592 case typelib_TypeClass_UNSIGNED_HYPER
:
593 *(sal_Int64
*)pCppStack
= *(sal_Int64
*)pCppArgs
[nPos
];
599 TYPELIB_DANGER_RELEASE( pParamTypeDescr
);
601 else // ptr to complex value | ref
603 if (! rParam
.bIn
) // is pure out
605 // cpp out is constructed mem, uno out is not!
607 *(void **)pCppStack
= pCppArgs
[nPos
] = alloca( pParamTypeDescr
->nSize
),
609 pTempIndices
[nTempIndices
] = nPos
; // default constructed for cpp call
610 // will be released at reconversion
611 ppTempParamTypeDescr
[nTempIndices
++] = pParamTypeDescr
;
614 else if (bridges::cpp_uno::shared::relatesToInterfaceType(
617 uno_copyAndConvertData(
618 *(void **)pCppStack
= pCppArgs
[nPos
] = alloca( pParamTypeDescr
->nSize
),
619 pUnoArgs
[nPos
], pParamTypeDescr
,
620 pThis
->getBridge()->getUno2Cpp() );
622 pTempIndices
[nTempIndices
] = nPos
; // has to be reconverted
623 // will be released at reconversion
624 ppTempParamTypeDescr
[nTempIndices
++] = pParamTypeDescr
;
628 *(void **)pCppStack
= pCppArgs
[nPos
] = pUnoArgs
[nPos
];
630 TYPELIB_DANGER_RELEASE( pParamTypeDescr
);
633 pCppStack
+= sizeof(sal_Int64
); // standard parameter length
638 int nStackHypers
= (pCppStack
- pCppStackStart
)/sizeof(sal_Int64
);
639 assert( !( (pCppStack
- pCppStackStart
) & 7) && "UNALIGNED STACK !!! (Please DO panic" );
641 //fprintf( stderr, "callVirtualMethod: %p, %lld, %p, %p, %p, %lld\n",
643 // (long long)aVtableSlot.index,
647 // (long long)nStackHypers);
654 (sal_Int64
*)pCppStackStart
,
658 } catch (css::uno::Exception
&) {
660 } catch (std::exception
& e
) {
661 throw css::uno::RuntimeException(
662 "C++ code threw " + o3tl::runtimeToOUString(typeid(e
).name()) + ": "
663 + o3tl::runtimeToOUString(e
.what()));
665 throw css::uno::RuntimeException("C++ code threw unknown exception");
667 // NO exception occurred...
670 // reconvert temporary params
671 for ( ; nTempIndices
--; )
673 sal_Int32 nIndex
= pTempIndices
[nTempIndices
];
674 typelib_TypeDescription
* pParamTypeDescr
= ppTempParamTypeDescr
[nTempIndices
];
676 if (pParams
[nIndex
].bIn
)
678 if (pParams
[nIndex
].bOut
) // inout
680 uno_destructData( pUnoArgs
[nIndex
], pParamTypeDescr
, 0 ); // destroy uno value
681 uno_copyAndConvertData( pUnoArgs
[nIndex
], pCppArgs
[nIndex
], pParamTypeDescr
,
682 pThis
->getBridge()->getCpp2Uno() );
687 uno_copyAndConvertData( pUnoArgs
[nIndex
], pCppArgs
[nIndex
], pParamTypeDescr
,
688 pThis
->getBridge()->getCpp2Uno() );
690 // destroy temp cpp param => cpp: every param was constructed
691 uno_destructData( pCppArgs
[nIndex
], pParamTypeDescr
, cpp_release
);
693 TYPELIB_DANGER_RELEASE( pParamTypeDescr
);
696 if (pCppReturn
&& pUnoReturn
!= pCppReturn
)
698 uno_copyAndConvertData( pUnoReturn
, pCppReturn
, pReturnTypeDescr
,
699 pThis
->getBridge()->getCpp2Uno() );
700 uno_destructData( pCppReturn
, pReturnTypeDescr
, cpp_release
);
706 CPPU_CURRENT_NAMESPACE::fillUnoException(*ppUnoExc
, pThis
->getBridge()->getCpp2Uno());
709 for ( ; nTempIndices
--; )
711 sal_Int32 nIndex
= pTempIndices
[nTempIndices
];
712 // destroy temp cpp param => cpp: every param was constructed
713 uno_destructData( pCppArgs
[nIndex
], ppTempParamTypeDescr
[nTempIndices
], cpp_release
);
714 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr
[nTempIndices
] );
717 if (pReturnTypeDescr
)
718 TYPELIB_DANGER_RELEASE( pReturnTypeDescr
);
724 namespace bridges::cpp_uno::shared
{
726 void unoInterfaceProxyDispatch(
727 uno_Interface
* pUnoI
, const typelib_TypeDescription
* pMemberDescr
,
728 void * pReturn
, void * pArgs
[], uno_Any
** ppException
)
730 #if defined BRIDGES_DEBUG
731 OString
cstr( OUStringToOString( pMemberDescr
->pTypeName
, RTL_TEXTENCODING_ASCII_US
) );
732 fprintf( stderr
, "received dispatch( %s )\n", cstr
.getStr() );
736 bridges::cpp_uno::shared::UnoInterfaceProxy
* pThis
737 = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy
* >(pUnoI
);
738 // typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
740 switch (pMemberDescr
->eTypeClass
)
742 case typelib_TypeClass_INTERFACE_ATTRIBUTE
:
744 VtableSlot
aVtableSlot(
747 typelib_InterfaceAttributeTypeDescription
const * >(
751 // dependent dispatch
754 ((typelib_InterfaceAttributeTypeDescription
*)pMemberDescr
)->pAttributeTypeRef
,
756 pReturn
, pArgs
, ppException
);
761 typelib_MethodParameter aParam
;
763 ((typelib_InterfaceAttributeTypeDescription
*)pMemberDescr
)->pAttributeTypeRef
;
764 aParam
.bIn
= sal_True
;
765 aParam
.bOut
= sal_False
;
767 typelib_TypeDescriptionReference
* pReturnTypeRef
= 0;
768 OUString
aVoidName("void");
769 typelib_typedescriptionreference_new(
770 &pReturnTypeRef
, typelib_TypeClass_VOID
, aVoidName
.pData
);
772 // dependent dispatch
773 aVtableSlot
.index
+= 1; // get, then set method
778 pReturn
, pArgs
, ppException
);
780 typelib_typedescriptionreference_release( pReturnTypeRef
);
785 case typelib_TypeClass_INTERFACE_METHOD
:
787 VtableSlot
aVtableSlot(
790 typelib_InterfaceMethodTypeDescription
const * >(
792 switch (aVtableSlot
.index
)
795 case 1: // acquire uno interface
796 (*pUnoI
->acquire
)( pUnoI
);
799 case 2: // release uno interface
800 (*pUnoI
->release
)( pUnoI
);
803 case 0: // queryInterface() opt
805 typelib_TypeDescription
* pTD
= 0;
806 TYPELIB_DANGER_GET( &pTD
, reinterpret_cast< Type
* >( pArgs
[0] )->getTypeLibType() );
809 uno_Interface
* pInterface
= 0;
810 (*pThis
->pBridge
->getUnoEnv()->getRegisteredInterface
)(
811 pThis
->pBridge
->getUnoEnv(),
812 (void **)&pInterface
, pThis
->oid
.pData
, (typelib_InterfaceTypeDescription
*)pTD
);
817 reinterpret_cast< uno_Any
* >( pReturn
),
818 &pInterface
, pTD
, 0 );
819 (*pInterface
->release
)( pInterface
);
820 TYPELIB_DANGER_RELEASE( pTD
);
824 TYPELIB_DANGER_RELEASE( pTD
);
826 } // else perform queryInterface()
828 // dependent dispatch
831 ((typelib_InterfaceMethodTypeDescription
*)pMemberDescr
)->pReturnTypeRef
,
832 ((typelib_InterfaceMethodTypeDescription
*)pMemberDescr
)->nParams
,
833 ((typelib_InterfaceMethodTypeDescription
*)pMemberDescr
)->pParams
,
834 pReturn
, pArgs
, ppException
);
840 ::com::sun::star::uno::RuntimeException
aExc(
841 "illegal member type description!",
842 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>() );
844 Type
const & rExcType
= cppu::UnoType
<decltype(aExc
)>::get();
845 // binary identical null reference
846 ::uno_type_any_construct( *ppException
, &aExc
, rExcType
.getTypeLibType(), 0 );
853 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */