26#include <com/sun/star/uno/Exception.hpp>
27#include <com/sun/star/uno/RuntimeException.hpp>
28#include <com/sun/star/uno/genfunc.hxx>
45void MapReturn(
long r2,
double f0, typelib_TypeClass eTypeClass, sal_uInt64* pRegisterReturn)
47#if OSL_DEBUG_LEVEL > 2
48 fprintf(stderr,
"Mapping Return with %lx %ld %f\n", r2, r2, f0);
52 case typelib_TypeClass_HYPER:
53 case typelib_TypeClass_UNSIGNED_HYPER:
54 *pRegisterReturn = r2;
56 case typelib_TypeClass_LONG:
57 case typelib_TypeClass_UNSIGNED_LONG:
58 case typelib_TypeClass_ENUM:
59 *(
unsigned int*)pRegisterReturn = (
unsigned int)r2;
61 case typelib_TypeClass_CHAR:
62 case typelib_TypeClass_SHORT:
63 case typelib_TypeClass_UNSIGNED_SHORT:
64 *(
unsigned short*)pRegisterReturn = (
unsigned short)r2;
66 case typelib_TypeClass_BOOLEAN:
67 case typelib_TypeClass_BYTE:
68 *(
unsigned char*)pRegisterReturn = (
unsigned char)r2;
70 case typelib_TypeClass_FLOAT:
71 *
reinterpret_cast<float *
>( pRegisterReturn ) = f0;
73 case typelib_TypeClass_DOUBLE:
74 *
reinterpret_cast<double *
>( pRegisterReturn ) = f0;
79#if OSL_DEBUG_LEVEL > 2
80 fprintf(stderr,
"end of MapReturn with %x\n", pRegisterReturn ? *pRegisterReturn : 0);
84#define INSERT_FLOAT( pSV, nr, pFPR, pDS ) \
86 if ( nr < s390x::MAX_SSE_REGS ) \
88 pFPR[nr++] = *reinterpret_cast<float *>( pSV ); \
91 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); \
94#define INSERT_DOUBLE( pSV, nr, pFPR, pDS ) \
95 if ( nr < s390x::MAX_SSE_REGS ) \
96 pFPR[nr++] = *reinterpret_cast<double *>( pSV ); \
98 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
100#define INSERT_INT64( pSV, nr, pGPR, pDS ) \
101 if ( nr < s390x::MAX_GPR_REGS ) \
102 pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
104 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
106#define INSERT_INT32( pSV, nr, pGPR, pDS ) \
107 if ( nr < s390x::MAX_GPR_REGS ) \
108 pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
110 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
112#define INSERT_INT16( pSV, nr, pGPR, pDS ) \
113 if ( nr < s390x::MAX_GPR_REGS ) \
114 pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
116 *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
118#define INSERT_INT8( pSV, nr, pGPR, pDS ) \
119 if ( nr < s390x::MAX_GPR_REGS ) \
120 pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
122 *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
128 void * pThis, sal_Int32 nVtableIndex,
130 sal_uInt64 *pStack, sal_uInt32 nStack,
131 sal_uInt64 *pGPR, sal_uInt32 nGPR,
132 double *pFPR, sal_uInt32 nFPR)
140#if OSL_DEBUG_LEVEL > 2
143 fprintf( stderr,
"= nStack is %d\n", nStack );
144 fprintf( stderr,
"= callVirtualMethod() =\nGPR's (%d): ", nGPR );
145 for (
unsigned int i = 0;
i < nGPR; ++
i )
146 fprintf( stderr,
"0x%lx, ", pGPR[
i] );
147 fprintf( stderr,
"\nFPR's (%d): ", nFPR );
148 for (
unsigned int i = 0;
i < nFPR; ++
i )
149 fprintf( stderr,
"0x%lx (%f), ", pFPR[
i], pFPR[
i] );
150 fprintf( stderr,
"\nStack (%d): ", nStack );
151 for (
unsigned int i = 0;
i < nStack; ++
i )
152 fprintf( stderr,
"0x%lx, ", pStack[
i] );
153 fprintf( stderr,
"\n" );
154 fprintf( stderr,
"pRegisterReturn is %p\n", pRegisterReturn);
160 sal_uInt64 *stack = (sal_uInt64 *) __builtin_alloca( nStack * 8 );
161 memcpy( stack, pStack, nStack * 8 );
165 sal_uInt64 pMethod = *((sal_uInt64 *)pThis);
167 pMethod += 8 * nVtableIndex;
168 pMethod = *((sal_uInt64 *)pMethod);
170 typedef void (* FunctionCall )( sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64 );
171 FunctionCall pFunc = (FunctionCall)pMethod;
176 asm volatile(
"ld 6,%0" ::
"m"(pFPR[3]) :
"16");
178 asm volatile(
"ld 4,%0" ::
"m"(pFPR[2]) :
"16");
180 asm volatile(
"ld 2,%0" ::
"m"(pFPR[1]) :
"16");
182 asm volatile(
"ld 0,%0" ::
"m"(pFPR[0]) :
"16");
190 (*pFunc)(pGPR[0], pGPR[1], pGPR[2], pGPR[3], pGPR[4]);
195 :
"=r" (r2),
"=f" (f0)
199 MapReturn(r2, f0, pReturnTypeDescr->eTypeClass, (sal_uInt64*)pRegisterReturn);
206 typelib_TypeDescriptionReference * pReturnTypeRef,
207 sal_Int32 nParams, typelib_MethodParameter * pParams,
208 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
211 sal_uInt64 * pStack = (sal_uInt64 *)alloca( (nParams+3) *
sizeof(sal_Int64) );
212 sal_uInt64 * pStackStart = pStack;
222 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
223 assert(pReturnTypeDescr);
225 void * pCppReturn = 0;
227 if (pReturnTypeDescr)
231 pCppReturn = pUnoReturn;
237 ? alloca( pReturnTypeDescr->nSize )
243 void * pAdjustedThisPtr =
reinterpret_cast< void **
>( pThis->getCppI() ) + aVtableSlot.
offset;
248 static_assert(
sizeof(
void *) ==
sizeof(sal_Int64),
"### unexpected size!");
250 void ** pCppArgs = (
void **)alloca( 3 *
sizeof(
void *) * nParams );
252 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
256 sal_Int32 nTempIndices = 0;
260 const typelib_MethodParameter & rParam = pParams[
nPos];
262 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
267 pThis->getBridge()->getUno2Cpp() );
269 switch (pParamTypeDescr->eTypeClass)
271 case typelib_TypeClass_HYPER:
272 case typelib_TypeClass_UNSIGNED_HYPER:
275 case typelib_TypeClass_LONG:
276 case typelib_TypeClass_UNSIGNED_LONG:
277 case typelib_TypeClass_ENUM:
280 case typelib_TypeClass_SHORT:
281 case typelib_TypeClass_CHAR:
282 case typelib_TypeClass_UNSIGNED_SHORT:
285 case typelib_TypeClass_BOOLEAN:
286 case typelib_TypeClass_BYTE:
289 case typelib_TypeClass_FLOAT:
292 case typelib_TypeClass_DOUBLE:
300 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
308 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
310 pTempIndices[nTempIndices] =
nPos;
312 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
318 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
319 pUnoArgs[
nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() );
321 pTempIndices[nTempIndices] =
nPos;
323 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
329 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
339 pAdjustedThisPtr, aVtableSlot.
index,
340 pCppReturn, pReturnTypeDescr,
341 pStackStart, (pStack - pStackStart),
344 }
catch (css::uno::Exception &) {
346 }
catch (std::exception & e) {
347 throw css::uno::RuntimeException(
351 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
357 for ( ; nTempIndices--; )
359 sal_Int32
nIndex = pTempIndices[nTempIndices];
368 pThis->getBridge()->getCpp2Uno() );
374 pThis->getBridge()->getCpp2Uno() );
379 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
382 if (pCppReturn && pUnoReturn != pCppReturn)
385 pThis->getBridge()->getCpp2Uno() );
396 for ( ; nTempIndices--; )
398 sal_Int32
nIndex = pTempIndices[nTempIndices];
401 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
404 if (pReturnTypeDescr)
405 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
414 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
416#if OSL_DEBUG_LEVEL > 2
417 fprintf(stderr,
"unoInterfaceProxyDispatch\n");
425 switch (pMemberDescr->eTypeClass)
427 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
430 VtableSlot aVtableSlot(
433 typelib_InterfaceAttributeTypeDescription
const *
>(
441 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
443 pReturn, pArgs, ppException );
448 typelib_MethodParameter aParam;
450 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
454 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
455 OUString aVoidName(
"void");
457 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
460 aVtableSlot.index += 1;
465 pReturn, pArgs, ppException );
472 case typelib_TypeClass_INTERFACE_METHOD:
475 VtableSlot aVtableSlot(
478 typelib_InterfaceMethodTypeDescription
const *
>(
480 switch (aVtableSlot.index)
484 (*pUnoI->acquire)( pUnoI );
488 (*pUnoI->release)( pUnoI );
494 TYPELIB_DANGER_GET( &pTD,
reinterpret_cast< Type *
>( pArgs[0] )->getTypeLibType() );
497 uno_Interface * pInterface = 0;
500 (
void **)&pInterface, pThis->
oid.pData, (typelib_InterfaceTypeDescription *)pTD );
505 reinterpret_cast< uno_Any *
>( pReturn ),
506 &pInterface, pTD, 0 );
507 (*pInterface->release)( pInterface );
508 TYPELIB_DANGER_RELEASE( pTD );
512 TYPELIB_DANGER_RELEASE( pTD );
519 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
520 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
521 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
522 pReturn, pArgs, ppException );
528 ::com::sun::star::uno::RuntimeException aExc(
529 "illegal member type description!",
534 ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
uno_ExtEnvironment * getUnoEnv()
A uno proxy wrapping a cpp interface.
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)
#define INSERT_INT8(pSV, nr, pGPR, pDS)
void MapReturn(long r2, double f0, typelib_TypeClass eTypeClass, sal_uInt64 *pRegisterReturn)
#define INSERT_FLOAT(pSV, nr, pFPR, pDS)
#define INSERT_INT16(pSV, nr, pGPR, pDS)
#define INSERT_INT64(pSV, nr, pGPR, pDS)
#define INSERT_DOUBLE(pSV, nr, pFPR, pDS)
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)
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)
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()