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 r0, typelib_TypeClass eTypeClass, sal_uInt64* pRegisterReturn)
47 register float fret
asm(
"$f0");
48 register double dret
asm(
"$f0");
50#if OSL_DEBUG_LEVEL > 2
51 fprintf(stderr,
"Mapping Return with %lx %ld %f\n", r0, r0, dret);
55 case typelib_TypeClass_HYPER:
56 case typelib_TypeClass_UNSIGNED_HYPER:
57 *pRegisterReturn = r0;
59 case typelib_TypeClass_LONG:
60 case typelib_TypeClass_UNSIGNED_LONG:
61 case typelib_TypeClass_ENUM:
62 *(
unsigned int*)pRegisterReturn = (
unsigned int)r0;
64 case typelib_TypeClass_CHAR:
65 case typelib_TypeClass_SHORT:
66 case typelib_TypeClass_UNSIGNED_SHORT:
67 *(
unsigned short*)pRegisterReturn = (
unsigned short)r0;
69 case typelib_TypeClass_BOOLEAN:
70 case typelib_TypeClass_BYTE:
71 *(
unsigned char*)pRegisterReturn = (
unsigned char)r0;
73 case typelib_TypeClass_FLOAT:
74 *
reinterpret_cast<float *
>( pRegisterReturn ) = fret;
76 case typelib_TypeClass_DOUBLE:
77 *
reinterpret_cast<double *
>( pRegisterReturn ) = dret;
82#if OSL_DEBUG_LEVEL > 2
83 fprintf(stderr,
"end of MapReturn with %x\n", pRegisterReturn ? *pRegisterReturn : 0);
87#define INSERT_FLOAT( pSV, nr, pFPR, pDS ) \
89 if ( nr < axp::MAX_WORDS_IN_REGS ) \
91 pFPR[nr++] = *reinterpret_cast<float *>( pSV ); \
94 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); \
97#define INSERT_DOUBLE( pSV, nr, pFPR, pDS ) \
98 if ( nr < axp::MAX_WORDS_IN_REGS ) \
99 pFPR[nr++] = *reinterpret_cast<double *>( pSV ); \
101 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
103#define INSERT_INT64( pSV, nr, pGPR, pDS ) \
104 if ( nr < axp::MAX_WORDS_IN_REGS ) \
105 pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
107 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
109#define INSERT_INT32( pSV, nr, pGPR, pDS ) \
110 if ( nr < axp::MAX_WORDS_IN_REGS ) \
111 pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
113 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
115#define INSERT_INT16( pSV, nr, pGPR, pDS ) \
116 if ( nr < axp::MAX_WORDS_IN_REGS ) \
117 pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
119 *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
121#define INSERT_INT8( pSV, nr, pGPR, pDS ) \
122 if ( nr < axp::MAX_WORDS_IN_REGS ) \
123 pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
125 *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
131 void * pThis, sal_Int32 nVtableIndex,
133 sal_uInt64 *pStack, sal_uInt32 nStack,
134 sal_uInt64 *pGPR, sal_uInt32 nGPR,
135 double *pFPR, sal_uInt32 nFPR)
143#if OSL_DEBUG_LEVEL > 2
146 fprintf( stderr,
"= nStack is %d\n", nStack );
147 fprintf( stderr,
"= callVirtualMethod() =\nGPR's (%d): ", nGPR );
148 for (
unsigned int i = 0;
i < nGPR; ++
i )
149 fprintf( stderr,
"0x%lx, ", pGPR[
i] );
150 fprintf( stderr,
"\nFPR's (%d): ", nFPR );
151 for (
unsigned int i = 0;
i < nFPR; ++
i )
152 fprintf( stderr,
"0x%lx (%f), ", pFPR[
i], pFPR[
i] );
153 fprintf( stderr,
"\nStack (%d): ", nStack );
154 for (
unsigned int i = 0;
i < nStack; ++
i )
155 fprintf( stderr,
"0x%lx, ", pStack[
i] );
156 fprintf( stderr,
"\n" );
157 fprintf( stderr,
"pRegisterReturn is %p\n", pRegisterReturn);
163 sal_uInt64 *stack = (sal_uInt64 *) __builtin_alloca( nStack * 8 );
164 memcpy( stack, pStack, nStack * 8 );
168 sal_uInt64 pMethod = *((sal_uInt64 *)pThis);
170 pMethod += 8 * nVtableIndex;
171 pMethod = *((sal_uInt64 *)pMethod);
173 typedef void (* FunctionCall )( sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64 );
174 FunctionCall pFunc = (FunctionCall)pMethod;
179 asm volatile(
"ldt $f16,%0" ::
"m"(pFPR[5]) :
"$f16");
181 asm volatile(
"ldt $f17,%0" ::
"m"(pFPR[4]) :
"$f17");
183 asm volatile(
"ldt $f18,%0" ::
"m"(pFPR[3]) :
"$f18");
185 asm volatile(
"ldt $f19,%0" ::
"m"(pFPR[2]) :
"$f19");
187 asm volatile(
"ldt $f20,%0" ::
"m"(pFPR[1]) :
"$f20");
189 asm volatile(
"ldt $f21,%0" ::
"m"(pFPR[0]) :
"$f21");
194 (*pFunc)(pGPR[0], pGPR[1], pGPR[2], pGPR[3], pGPR[4], pGPR[5]);
195 register sal_uInt64 r0
__asm__(
"$0");
196 MapReturn(r0, pReturnTypeDescr->eTypeClass, (sal_uInt64*)pRegisterReturn);
203 typelib_TypeDescriptionReference * pReturnTypeRef,
204 sal_Int32 nParams, typelib_MethodParameter * pParams,
205 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
208 sal_uInt64 * pStack = (sal_uInt64 *)alloca( (nParams+3) *
sizeof(sal_Int64) );
209 sal_uInt64 * pStackStart = pStack;
213 sal_uInt32 nRegs = 0;
217 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
218 assert(pReturnTypeDescr);
220 void * pCppReturn = 0;
222 if (pReturnTypeDescr)
226 pCppReturn = pUnoReturn;
232 ? alloca( pReturnTypeDescr->nSize )
238 void * pAdjustedThisPtr =
reinterpret_cast< void **
>( pThis->getCppI() ) + aVtableSlot.
offset;
243 static_assert(
sizeof(
void *) ==
sizeof(sal_Int64),
"### unexpected size!");
245 void ** pCppArgs = (
void **)alloca( 3 *
sizeof(
void *) * nParams );
247 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
251 sal_Int32 nTempIndices = 0;
255 const typelib_MethodParameter & rParam = pParams[
nPos];
257 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
262 pThis->getBridge()->getUno2Cpp() );
264 switch (pParamTypeDescr->eTypeClass)
266 case typelib_TypeClass_HYPER:
267 case typelib_TypeClass_UNSIGNED_HYPER:
270 case typelib_TypeClass_LONG:
271 case typelib_TypeClass_UNSIGNED_LONG:
272 case typelib_TypeClass_ENUM:
275 case typelib_TypeClass_SHORT:
276 case typelib_TypeClass_CHAR:
277 case typelib_TypeClass_UNSIGNED_SHORT:
280 case typelib_TypeClass_BOOLEAN:
281 case typelib_TypeClass_BYTE:
284 case typelib_TypeClass_FLOAT:
287 case typelib_TypeClass_DOUBLE:
295 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
303 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
305 pTempIndices[nTempIndices] =
nPos;
307 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
313 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
314 pUnoArgs[
nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() );
316 pTempIndices[nTempIndices] =
nPos;
318 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
324 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
334 pAdjustedThisPtr, aVtableSlot.
index,
335 pCppReturn, pReturnTypeDescr,
336 pStackStart, (pStack - pStackStart),
339 }
catch (css::uno::Exception &) {
341 }
catch (std::exception & e) {
342 throw css::uno::RuntimeException(
346 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
352 for ( ; nTempIndices--; )
354 sal_Int32
nIndex = pTempIndices[nTempIndices];
363 pThis->getBridge()->getCpp2Uno() );
369 pThis->getBridge()->getCpp2Uno() );
374 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
377 if (pCppReturn && pUnoReturn != pCppReturn)
380 pThis->getBridge()->getCpp2Uno() );
391 for ( ; nTempIndices--; )
393 sal_Int32
nIndex = pTempIndices[nTempIndices];
396 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
399 if (pReturnTypeDescr)
400 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
409 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
411#if OSL_DEBUG_LEVEL > 2
412 fprintf(stderr,
"unoInterfaceProxyDispatch\n");
420 switch (pMemberDescr->eTypeClass)
422 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
428 typelib_InterfaceAttributeTypeDescription
const *
>(
436 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
438 pReturn, pArgs, ppException );
443 typelib_MethodParameter aParam;
445 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
449 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
450 OUString aVoidName(
"void");
452 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
455 aVtableSlot.
index += 1;
460 pReturn, pArgs, ppException );
467 case typelib_TypeClass_INTERFACE_METHOD:
473 typelib_InterfaceMethodTypeDescription
const *
>(
475 switch (aVtableSlot.
index)
479 (*pUnoI->acquire)( pUnoI );
483 (*pUnoI->release)( pUnoI );
489 TYPELIB_DANGER_GET( &pTD,
reinterpret_cast< Type *
>( pArgs[0] )->getTypeLibType() );
492 uno_Interface * pInterface = 0;
495 (
void **)&pInterface, pThis->
oid.pData, (typelib_InterfaceTypeDescription *)pTD );
500 reinterpret_cast< uno_Any *
>( pReturn ),
501 &pInterface, pTD, 0 );
502 (*pInterface->release)( pInterface );
503 TYPELIB_DANGER_RELEASE( pTD );
507 TYPELIB_DANGER_RELEASE( pTD );
514 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
515 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
516 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
517 pReturn, pArgs, ppException );
523 ::com::sun::star::uno::RuntimeException aExc(
524 "illegal member type description!",
529 ::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()
#define INSERT_INT32(pSV, nr, pGPR, pDS)
void MapReturn(long r0, typelib_TypeClass eTypeClass, sal_uInt64 *pRegisterReturn)
#define INSERT_INT8(pSV, nr, pGPR, pDS)
#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)
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
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()