26#include <com/sun/star/uno/Exception.hpp>
27#include <com/sun/star/uno/RuntimeException.hpp>
28#include <com/sun/star/uno/genfunc.hxx>
40 __asm__( "ldx %0, %%l0\n\t" \
41 "ldd [%%l0], %%f" #n "\n" \
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:
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);
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));
124 void * pRegisterReturn,
125 typelib_TypeDescriptionReference * pReturnTypeRef,
126 sal_Int64 * pStackHypers,
127#
if OSL_DEBUG_LEVEL > 0
128 sal_Int32 nStackHypers,
133 typelib_MethodParameter * pParams, sal_Int32 nParams)
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 !");
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) {
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"
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"
269 "sub %%l1, %%l0, %%l0\n\t"
270 "andcc %%l0, 15, %%g0\n\t"
273 "sub %%l0, 8, %%l0\n"
276 "add %%g0, 16, %%o4\n"
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"
293 "sub %%i5, 6, %%l0\n\t"
294 "add %%i4, 48, %%l1\n\t"
295 "add %%sp, 2223, %%l2\n"
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"
309 "ldx [%%l1], %%o0\n\t"
312 "sub %%l0, 1, %%l0\n\t"
313 "add %%l1, 8, %%l1\n\t"
327 "ldx [%%l1], %%o1\n\t"
329 "subcc %%l0, 1, %%l0\n\t"
333 "add %%l1, 8, %%l1\n\t"
334 "ldx [%%l1], %%o2\n\t"
336 "subcc %%l0, 1, %%l0\n\t"
340 "add %%l1, 8, %%l1\n\t"
341 "ldx [%%l1], %%o3\n\t"
343 "subcc %%l0, 1, %%l0\n\t"
347 "add %%l1, 8, %%l1\n\t"
348 "ldx [%%l1], %%o4\n\t"
350 "subcc %%l0, 1, %%l0\n\t"
354 "add %%l1, 8, %%l1\n\t"
359 "ldx [%%i0], %%l0\n\t"
361"sllx %%i1, 3, %%l6\n\t"
363 "add %%l6, %%l0, %%l0\n\t"
373 "ldx [%%l0], %%l0\n\t"
389 "subcc %%l3, %%sp, %%g0\n\t"
394 "add %%sp, 2167, %%l0\n\t"
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"
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"
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)
491 TYPELIB_DANGER_GET( &pTypeDescr, pReturnTypeRef );
492 fillReturn(pTypeDescr, oret, fdret.f, fdret.d, pRegisterReturn);
493 TYPELIB_DANGER_RELEASE( pTypeDescr );
505 typelib_TypeDescriptionReference * pReturnTypeRef,
506 sal_Int32 nParams, typelib_MethodParameter * pParams,
507 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
511 (
char *)alloca( (nParams+2) *
sizeof(sal_Int64) );
512 char * pCppStackStart = pCppStack;
518 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
519 assert(pReturnTypeDescr);
521 void * pCppReturn = 0;
523 if (pReturnTypeDescr)
529 ? alloca( pReturnTypeDescr->nSize )
531 pCppStack +=
sizeof(
void*);
535 pCppReturn = pUnoReturn;
539 void * pAdjustedThisPtr =
reinterpret_cast< void **
>(pThis->
getCppI())
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 );
549 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
553 sal_Int32 nTempIndices = 0;
557 const typelib_MethodParameter & rParam = pParams[
nPos];
559 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
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:
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 );
607 *(
void **)pCppStack = pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
609 pTempIndices[nTempIndices] =
nPos;
611 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
618 *(
void **)pCppStack = pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
619 pUnoArgs[
nPos], pParamTypeDescr,
622 pTempIndices[nTempIndices] =
nPos;
624 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
628 *(
void **)pCppStack = pCppArgs[
nPos] = pUnoArgs[
nPos];
630 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
633 pCppStack +=
sizeof(sal_Int64);
638 int nStackHypers = (pCppStack - pCppStackStart)/
sizeof(sal_Int64);
639 assert( !( (pCppStack - pCppStackStart ) & 7) &&
"UNALIGNED STACK !!! (Please DO panic" );
654 (sal_Int64 *)pCppStackStart,
658 }
catch (css::uno::Exception &) {
660 }
catch (std::exception & e) {
661 throw css::uno::RuntimeException(
665 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
671 for ( ; nTempIndices--; )
673 sal_Int32
nIndex = pTempIndices[nTempIndices];
693 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
696 if (pCppReturn && pUnoReturn != pCppReturn)
709 for ( ; nTempIndices--; )
711 sal_Int32
nIndex = pTempIndices[nTempIndices];
714 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
717 if (pReturnTypeDescr)
718 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
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() );
740 switch (pMemberDescr->eTypeClass)
742 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
744 VtableSlot aVtableSlot(
747 typelib_InterfaceAttributeTypeDescription
const *
>(
754 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
756 pReturn, pArgs, ppException );
761 typelib_MethodParameter aParam;
763 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
767 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
768 OUString aVoidName(
"void");
770 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
773 aVtableSlot.index += 1;
778 pReturn, pArgs, ppException );
785 case typelib_TypeClass_INTERFACE_METHOD:
787 VtableSlot aVtableSlot(
790 typelib_InterfaceMethodTypeDescription
const *
>(
792 switch (aVtableSlot.index)
796 (*pUnoI->acquire)( pUnoI );
800 (*pUnoI->release)( pUnoI );
806 TYPELIB_DANGER_GET( &pTD,
reinterpret_cast< Type *
>( pArgs[0] )->getTypeLibType() );
809 uno_Interface * pInterface = 0;
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 );
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!",
846 ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
uno_Mapping * getUno2Cpp()
uno_ExtEnvironment * getUnoEnv()
uno_Mapping * getCpp2Uno()
A uno proxy wrapping a cpp interface.
com::sun::star::uno::XInterface * getCppI()
void SAL_CALL uno_destructData(void *pValue, typelib_TypeDescription *pTypeDescr, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
void SAL_CALL uno_constructData(void *pMem, typelib_TypeDescription *pTypeDescr) SAL_THROW_EXTERN_C()
void SAL_CALL uno_copyAndConvertData(void *pDest, void *pSource, typelib_TypeDescription *pTypeDescr, uno_Mapping *mapping) SAL_THROW_EXTERN_C()
register sal_uInt32 r28 __asm__("%r28")
void callVirtualMethod(void *pThis, sal_uInt32 nVtableIndex, void *pRegisterReturn, typelib_TypeDescription *pReturnTypeDescr, bool bRegisterReturn, sal_uInt32 *pStack, sal_uInt32 nStack, sal_uInt32 *pGPR, double *pFPR) __attribute__((noinline))
static void cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy *pThis, bridges::cpp_uno::shared::VtableSlot aVtableSlot, typelib_TypeDescriptionReference *pReturnTypeRef, sal_Int32 nParams, typelib_MethodParameter *pParams, void *pUnoReturn, void *pUnoArgs[], uno_Any **ppUnoExc)
struct _typelib_TypeDescription typelib_TypeDescription
bool return_in_hidden_param(typelib_TypeDescriptionReference *pTypeRef)
void dummy_can_throw_anything(char const *)
void fillUnoException(uno_Any *pUnoExc, uno_Mapping *pCpp2Uno)
void unoInterfaceProxyDispatch(uno_Interface *pUnoI, typelib_TypeDescription const *pMemberDescr, void *pReturn, void **pArgs, uno_Any **ppException)
VtableSlot getVtableSlot(typelib_InterfaceAttributeTypeDescription const *ifcMember)
Calculates the vtable slot associated with an interface attribute member.
bool isSimpleType(typelib_TypeClass typeClass)
Determines whether a type is a "simple" type (VOID, BOOLEAN, BYTE, SHORT, UNSIGNED SHORT,...
bool relatesToInterfaceType(typelib_TypeDescription const *type)
Determines whether a type relates to an interface type (is itself an interface type,...
void fillReturn(typelib_TypeDescriptionReference *pTypeRef, sal_Int64 *gret, double *fret, void *pRegisterReturn)
OUString runtimeToOUString(char const *runtimeString)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
Represents a vtable slot of a C++ class.
sal_Int32 index
The index within the vtable.
sal_Int32 offset
The offset of the vtable.
void SAL_CALL typelib_typedescriptionreference_new(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, rtl_uString *pTypeName) SAL_THROW_EXTERN_C()
void SAL_CALL typelib_typedescriptionreference_release(typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
unsigned _Unwind_Word __attribute__((__mode__(__word__)))