26#include <com/sun/star/uno/Exception.hpp>
27#include <com/sun/star/uno/RuntimeException.hpp>
28#include <com/sun/star/uno/genfunc.hxx>
47#if defined(_CALL_ELF) && _CALL_ELF == 2
50 const typelib_CompoundTypeDescription *
p
51 =
reinterpret_cast< const typelib_CompoundTypeDescription *
>(
type);
52 for (sal_Int32 i = 0;
i <
p->nMembers; ++
i)
54 if (
p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_STRUCT ||
55 p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_EXCEPTION)
58 TYPELIB_DANGER_GET(&t,
p->ppTypeRefs[i]);
60 TYPELIB_DANGER_RELEASE(t);
68 if (
p->pBaseTypeDescription != 0)
78#if defined(_CALL_ELF) && _CALL_ELF == 2
79 else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
82 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
87 TYPELIB_DANGER_RELEASE( pTypeDescr );
95void MapReturn(
long r3,
long r4,
double dret, typelib_TypeDescriptionReference* pReturnType,
void *pRegisterReturn)
97 switch (pReturnType->eTypeClass)
99 case typelib_TypeClass_HYPER:
100 case typelib_TypeClass_UNSIGNED_HYPER:
101 *
reinterpret_cast<sal_uInt64 *
>( pRegisterReturn ) = r3;
103 case typelib_TypeClass_LONG:
104 case typelib_TypeClass_UNSIGNED_LONG:
105 case typelib_TypeClass_ENUM:
106 *
reinterpret_cast<sal_uInt32 *
>( pRegisterReturn ) = r3;
108 case typelib_TypeClass_CHAR:
109 case typelib_TypeClass_SHORT:
110 case typelib_TypeClass_UNSIGNED_SHORT:
111 *
reinterpret_cast<sal_uInt16 *
>( pRegisterReturn ) = (
unsigned short)r3;
113 case typelib_TypeClass_BOOLEAN:
114 case typelib_TypeClass_BYTE:
115 *
reinterpret_cast<sal_uInt8 *
>( pRegisterReturn ) = (
unsigned char)r3;
117 case typelib_TypeClass_FLOAT:
118 *
reinterpret_cast<float *
>( pRegisterReturn ) = dret;
120 case typelib_TypeClass_DOUBLE:
121 *
reinterpret_cast<double *
>( pRegisterReturn ) = dret;
123#if defined(_CALL_ELF) && _CALL_ELF == 2
124 case typelib_TypeClass_STRUCT:
125 case typelib_TypeClass_EXCEPTION:
128 sal_uInt64 *pRegisters =
reinterpret_cast<sal_uInt64*
>(pRegisterReturn);
130 if (pReturnType->pType->nSize > 8)
146 sal_uInt64 *pStack, sal_uInt32 nStack,
147 sal_uInt64 *pGPR, sal_uInt32 nGPR,
148 double *pFPR, sal_uInt32 nFPR)
152 nStack = ( nStack + 1 ) & ~1;
160#if OSL_DEBUG_LEVEL > 2
163 fprintf( stderr,
"= callVirtualMethod() =\nGPR's (%d): ", nGPR );
164 for (
int i = 0;
i < nGPR; ++
i )
165 fprintf( stderr,
"0x%lx, ", pGPR[i] );
166 fprintf( stderr,
"\nFPR's (%d): ", nFPR );
167 for (
int i = 0;
i < nFPR; ++
i )
168 fprintf( stderr,
"0x%lx (%f), ", pFPR[i], pFPR[i] );
169 fprintf( stderr,
"\nStack (%d): ", nStack );
170 for (
int i = 0;
i < nStack; ++
i )
171 fprintf( stderr,
"0x%lx, ", pStack[i] );
172 fprintf( stderr,
"\n" );
177 sal_uInt64 *stack = (sal_uInt64 *) __builtin_alloca( nStack * 8 );
178 memcpy( stack, pStack, nStack * 8 );
181 sal_uInt64 pMethod = *((sal_uInt64 *)pThis);
182 pMethod += 8 * nVtableIndex;
183 pMethod = *((sal_uInt64 *)pMethod);
185#if defined(_CALL_ELF) && _CALL_ELF == 2
186 typedef void (* FunctionCall )(...);
188 typedef void (* FunctionCall )( sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64 );
190 FunctionCall pFunc = (FunctionCall)pMethod;
192 volatile double dret;
210 :
"fr1",
"fr2",
"fr3",
"fr4",
"fr5",
"fr6",
"fr7",
"fr8",
"fr9",
211 "fr10",
"fr11",
"fr12",
"fr13"
215 register sal_uInt64 r3
asm(
"r3");
216 register sal_uInt64 r4
asm(
"r4");
218 (*pFunc)(pGPR[0], pGPR[1], pGPR[2], pGPR[3], pGPR[4], pGPR[5], pGPR[6], pGPR[7]);
225 :
"=f" (dret),
"=r" (r3),
"=r" (r4) : );
227 MapReturn(r3, r4, dret,
reinterpret_cast<typelib_TypeDescriptionReference *
>(pReturnTypeDescr), pRegisterReturn);
238#define INSERT_FLOAT( pSV, nr, pFPR, nGPR, pDS, bOverflow ) \
239 if ( nGPR < ppc64::MAX_GPR_REGS ) \
241 if ( nr < ppc64::MAX_SSE_REGS ) \
242 pFPR[nr++] = *reinterpret_cast<float *>( pSV ); \
246 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
248#define INSERT_DOUBLE( pSV, nr, pFPR, nGPR, pDS, bOverflow ) \
249 if ( nGPR < ppc64::MAX_GPR_REGS ) \
251 if ( nr < ppc64::MAX_SSE_REGS ) \
252 pFPR[nr++] = *reinterpret_cast<double *>( pSV ); \
256 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
258#define INSERT_INT64( pSV, nr, pGPR, pDS, bOverflow ) \
259 if ( nr < ppc64::MAX_GPR_REGS ) \
260 pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
264 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
266#define INSERT_INT32( pSV, nr, pGPR, pDS, bOverflow ) \
267 if ( nr < ppc64::MAX_GPR_REGS ) \
268 pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
272 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
274#define INSERT_INT16( pSV, nr, pGPR, pDS, bOverflow ) \
275 if ( nr < ppc64::MAX_GPR_REGS ) \
276 pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
280 *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
282#define INSERT_INT8( pSV, nr, pGPR, pDS, bOverflow ) \
283 if ( nr < ppc64::MAX_GPR_REGS ) \
284 pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
288 *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
293 typelib_TypeDescriptionReference * pReturnTypeRef,
294 sal_Int32 nParams, typelib_MethodParameter * pParams,
295 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
298 sal_uInt64 * pStack = (sal_uInt64 *)alloca( (nParams+3) *
sizeof(sal_Int64) );
299 sal_uInt64 * pStackStart = pStack;
309 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
310 assert(pReturnTypeDescr);
312 void * pCppReturn = 0;
314 bool bOverflow =
false;
316 if (pReturnTypeDescr)
318#if OSL_DEBUG_LEVEL > 2
319 fprintf(stderr,
"return type is %d\n", pReturnTypeDescr->eTypeClass);
325 pCppReturn = pUnoReturn;
326#if OSL_DEBUG_LEVEL > 2
327 fprintf(stderr,
"simple return\n");
334 ? alloca( pReturnTypeDescr->nSize ) : pUnoReturn);
335#if OSL_DEBUG_LEVEL > 2
336 fprintf(stderr,
"pCppReturn/pUnoReturn is %lx/%lx", pCppReturn, pUnoReturn);
338 INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack, bOverflow );
342 void * pAdjustedThisPtr =
reinterpret_cast< void **
>( pThis->
getCppI() ) + aVtableSlot.
offset;
343#
if OSL_DEBUG_LEVEL > 2
344 fprintf(stderr,
"this pointer is %p\n", pAdjustedThisPtr);
346 INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack, bOverflow );
349 void ** pCppArgs = (
void **)alloca( 3 *
sizeof(
void *) * nParams );
351 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
355 sal_Int32 nTempIndices = 0;
357#if OSL_DEBUG_LEVEL > 2
358 fprintf(stderr,
"n params is %d\n", nParams);
363 const typelib_MethodParameter & rParam = pParams[
nPos];
365 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
367#if OSL_DEBUG_LEVEL > 2
369 pParamTypeDescr->eTypeClass);
376 switch (pParamTypeDescr->eTypeClass)
378 case typelib_TypeClass_HYPER:
379 case typelib_TypeClass_UNSIGNED_HYPER:
380#if OSL_DEBUG_LEVEL > 2
381 fprintf(stderr,
"hyper is %lx\n", pCppArgs[
nPos]);
385 case typelib_TypeClass_LONG:
386 case typelib_TypeClass_UNSIGNED_LONG:
387 case typelib_TypeClass_ENUM:
388#if OSL_DEBUG_LEVEL > 2
389 fprintf(stderr,
"long is %x\n", pCppArgs[
nPos]);
393 case typelib_TypeClass_SHORT:
394 case typelib_TypeClass_CHAR:
395 case typelib_TypeClass_UNSIGNED_SHORT:
398 case typelib_TypeClass_BOOLEAN:
399 case typelib_TypeClass_BYTE:
402 case typelib_TypeClass_FLOAT:
405 case typelib_TypeClass_DOUBLE:
413 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
418#if OSL_DEBUG_LEVEL > 2
419 fprintf(stderr,
"complex type again %d\n", rParam.bIn);
423#if OSL_DEBUG_LEVEL > 2
424 fprintf(stderr,
"complex size is %d\n", pParamTypeDescr->nSize );
428 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
430 pTempIndices[nTempIndices] =
nPos;
432 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
437#if OSL_DEBUG_LEVEL > 2
438 fprintf(stderr,
"this one\n");
441 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
444 pTempIndices[nTempIndices] =
nPos;
446 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
450#if OSL_DEBUG_LEVEL > 2
451 fprintf(stderr,
"that one, passing %lx through\n", pUnoArgs[
nPos]);
455 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
465 pAdjustedThisPtr, aVtableSlot.
index,
466 pCppReturn, pReturnTypeDescr,
467 pStackStart, ( pStack - pStackStart ),
470 }
catch (css::uno::Exception &) {
472 }
catch (std::exception & e) {
473 throw css::uno::RuntimeException(
477 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
483 for ( ; nTempIndices--; )
485 sal_Int32
nIndex = pTempIndices[nTempIndices];
505 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
508 if (pCppReturn && pUnoReturn != pCppReturn)
521 for ( ; nTempIndices--; )
523 sal_Int32
nIndex = pTempIndices[nTempIndices];
526 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
529 if (pReturnTypeDescr)
530 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
540 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
546 switch (pMemberDescr->eTypeClass)
548 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
551 VtableSlot aVtableSlot(
554 typelib_InterfaceAttributeTypeDescription
const *
>(
562 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
564 pReturn, pArgs, ppException );
569 typelib_MethodParameter aParam;
571 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
575 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
576 OUString aVoidName(
"void");
578 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
581 aVtableSlot.index += 1;
586 pReturn, pArgs, ppException );
593 case typelib_TypeClass_INTERFACE_METHOD:
596 VtableSlot aVtableSlot(
599 typelib_InterfaceMethodTypeDescription
const *
>(
601 switch (aVtableSlot.index)
605 (*pUnoI->acquire)( pUnoI );
609 (*pUnoI->release)( pUnoI );
615 TYPELIB_DANGER_GET( &pTD,
reinterpret_cast< Type *
>( pArgs[0] )->getTypeLibType() );
618 uno_Interface * pInterface = 0;
621 (
void **)&pInterface, pThis->
oid.pData, (typelib_InterfaceTypeDescription *)pTD );
626 reinterpret_cast< uno_Any *
>( pReturn ),
627 &pInterface, pTD, 0 );
628 (*pInterface->release)( pInterface );
629 TYPELIB_DANGER_RELEASE( pTD );
633 TYPELIB_DANGER_RELEASE( pTD );
640 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
641 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
642 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
643 pReturn, pArgs, ppException );
649 ::com::sun::star::uno::RuntimeException aExc(
650 "illegal member type description!",
655 ::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))
#define INSERT_INT32(pSV, nr, pGPR, pDS, bOverflow)
#define INSERT_FLOAT(pSV, nr, pFPR, nGPR, pDS, bOverflow)
#define INSERT_DOUBLE(pSV, nr, pFPR, nGPR, pDS, bOverflow)
#define INSERT_INT64(pSV, nr, pGPR, pDS, bOverflow)
#define INSERT_INT16(pSV, nr, pGPR, pDS, bOverflow)
#define INSERT_INT8(pSV, nr, pGPR, pDS, bOverflow)
void MapReturn(long r3, long r4, double dret, typelib_TypeDescriptionReference *pReturnType, void *pRegisterReturn)
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
void fillUnoException(uno_Any *pUnoExc, uno_Mapping *pCpp2Uno)
static bool is_complex_struct(const typelib_TypeDescription *type)
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,...
OUString runtimeToOUString(char const *runtimeString)
bool return_in_hidden_param(typelib_TypeDescriptionReference *pTypeRef)
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()