20 #include <sys/types.h>
21 #include <sys/malloc.h>
23 #include <com/sun/star/uno/Exception.hxx>
24 #include <com/sun/star/uno/RuntimeException.hxx>
25 #include <com/sun/star/uno/genfunc.hxx>
46 void MapReturn(sal_uInt32 r3, sal_uInt32 r4,
double dret, typelib_TypeClass eReturnType,
void *pRegisterReturn)
50 case typelib_TypeClass_HYPER:
51 case typelib_TypeClass_UNSIGNED_HYPER:
52 ((
long*)pRegisterReturn)[1] = r4;
54 case typelib_TypeClass_LONG:
55 case typelib_TypeClass_UNSIGNED_LONG:
56 case typelib_TypeClass_ENUM:
57 ((
long*)pRegisterReturn)[0] = r3;
59 case typelib_TypeClass_CHAR:
60 case typelib_TypeClass_SHORT:
61 case typelib_TypeClass_UNSIGNED_SHORT:
62 *(
unsigned short*)pRegisterReturn = (
unsigned short)r3;
64 case typelib_TypeClass_BOOLEAN:
65 case typelib_TypeClass_BYTE:
66 *(
unsigned char*)pRegisterReturn = (
unsigned char)r3;
68 case typelib_TypeClass_FLOAT:
69 *(
float*)pRegisterReturn = (
float)dret;
71 case typelib_TypeClass_DOUBLE:
72 *(
double*)pRegisterReturn = dret;
79 #define DISPLACEMENT -2
83 sal_uInt32 nVtableIndex,
84 void * pRegisterReturn,
85 typelib_TypeClass eReturnType,
91 sal_uInt32 nStackWords = nStack;
97 nStackWords = ( nStackWords + 1) & ~1;
98 sal_uInt32 *stack = (sal_uInt32*)__builtin_alloca( nStackWords *
sizeof(sal_uInt32) );
102 sal_uInt32 pMethod = *((sal_uInt32 *)pThis);
103 pMethod += 4 * nVtableIndex;
104 pMethod = *((sal_uInt32 *)pMethod);
106 typedef void (* FunctionCall )( sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32 );
107 FunctionCall pFunc = (FunctionCall)pMethod;
109 register double d0
asm(
"fr1"); d0 = pFPR[0];
110 register double d1
asm(
"fr2"); d1 = pFPR[1];
111 register double d2
asm(
"fr3"); d2 = pFPR[2];
112 register double d3
asm(
"fr4"); d3 = pFPR[3];
113 register double d4
asm(
"fr5"); d4 = pFPR[4];
114 register double d5
asm(
"fr6"); d5 = pFPR[5];
115 register double d6
asm(
"fr7"); d6 = pFPR[6];
116 register double d7
asm(
"fr8"); d7 = pFPR[7];
117 register double d8
asm(
"fr9"); d8 = pFPR[8];
118 register double d9
asm(
"fr10"); d9 = pFPR[9];
119 register double d10
asm(
"fr11"); d10 = pFPR[10];
120 register double d11
asm(
"fr12"); d11 = pFPR[11];
121 register double d12
asm(
"fr13"); d12 = pFPR[12];
123 (*pFunc)(pStack[0], pStack[1], pStack[2], pStack[3], pStack[4], pStack[5], pStack[6], pStack[7]);
125 register sal_uInt32 r3
asm(
"r3");
126 register sal_uInt32 r4
asm(
"r4");
127 MapReturn(r3, r4, d0, eReturnType, pRegisterReturn);
130 #define INSERT_INT32(pSV, pDS) \
132 *pDS++ = *reinterpret_cast<sal_uInt32 *>(pSV); \
135 #define INSERT_INT16(pSV, pDS) \
137 *pDS++ = *reinterpret_cast<sal_uInt16 *>(pSV); \
140 #define INSERT_INT8(pSV, pDS) \
142 *pDS++ = *reinterpret_cast<sal_uInt8 *>(pSV); \
145 #define INSERT_FLOAT(pSV, nr, pFPR, pDS) \
147 if (nr < ppc::MAX_SSE_REGS) \
149 sal_uInt32 *pDouble = (sal_uInt32 *)&(pFPR[nr++]); \
150 pDouble[0] = *reinterpret_cast<sal_uInt32 *>(pSV); \
152 *pDS++ = *reinterpret_cast<sal_uInt32 *>(pSV); \
155 #define INSERT_DOUBLE(pSV, nr, pFPR, pDS) \
157 if (nr < ppc::MAX_SSE_REGS) \
159 pFPR[nr++] = *reinterpret_cast<double *>(pSV); \
161 *pDS++ = reinterpret_cast<sal_uInt32 *>(pSV)[1]; \
162 *pDS++ = reinterpret_cast<sal_uInt32 *>(pSV)[0]; \
165 #define INSERT_INT64(pSV, pDS) \
167 INSERT_INT32(pSV, pDS) \
168 INSERT_INT32(((sal_uInt32*)pSV)+1, pDS) \
174 typelib_TypeDescriptionReference * pReturnTypeRef,
175 sal_Int32 nParams, typelib_MethodParameter * pParams,
176 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
179 sal_uInt32 * pStack = (sal_uInt32*)__builtin_alloca(
sizeof(sal_Int32) + ((nParams+2) *
sizeof(sal_Int64)) );
180 sal_uInt32 * pStackStart = pStack;
187 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
188 assert(pReturnTypeDescr &&
"### expected return type description!");
190 void * pCppReturn = 0;
192 if (pReturnTypeDescr)
196 pCppReturn = pUnoReturn;
202 ? __builtin_alloca( pReturnTypeDescr->nSize )
208 void * pAdjustedThisPtr =
reinterpret_cast< void **
>(pThis->
getCppI()) + aVtableSlot.
offset;
212 static_assert(
sizeof(
void *) ==
sizeof(sal_Int32),
"### unexpected size!" );
214 void ** pCppArgs = (
void **)__builtin_alloca( 3 *
sizeof(
void *) * nParams );
216 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
220 sal_Int32 nTempIndices = 0;
224 const typelib_MethodParameter & rParam = pParams[
nPos];
226 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
234 switch (pParamTypeDescr->eTypeClass)
236 case typelib_TypeClass_LONG:
237 case typelib_TypeClass_UNSIGNED_LONG:
238 case typelib_TypeClass_ENUM:
241 case typelib_TypeClass_SHORT:
242 case typelib_TypeClass_CHAR:
243 case typelib_TypeClass_UNSIGNED_SHORT:
246 case typelib_TypeClass_BOOLEAN:
247 case typelib_TypeClass_BYTE:
250 case typelib_TypeClass_FLOAT:
253 case typelib_TypeClass_DOUBLE:
256 case typelib_TypeClass_HYPER:
257 case typelib_TypeClass_UNSIGNED_HYPER:
265 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
273 pCppArgs[
nPos] = __builtin_alloca( pParamTypeDescr->nSize ),
275 pTempIndices[nTempIndices] =
nPos;
277 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
283 pCppArgs[
nPos] = __builtin_alloca( pParamTypeDescr->nSize ),
286 pTempIndices[nTempIndices] = nPos;
288 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
294 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
302 assert( !( (pCppStack - pCppStackStart ) & 3) &&
"UNALIGNED STACK !!! (Please DO panic)" );
305 pAdjustedThisPtr, aVtableSlot.
index,
306 pCppReturn, pReturnTypeDescr->eTypeClass,
307 pStackStart, (pStack - pStackStart), pFPR, nFPR );
308 }
catch (css::uno::Exception &) {
310 }
catch (std::exception & e) {
311 throw css::uno::RuntimeException(
315 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
321 for ( ; nTempIndices--; )
323 sal_Int32
nIndex = pTempIndices[nTempIndices];
326 if (pParams[nIndex].bIn)
328 if (pParams[nIndex].bOut)
343 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
346 if (pCppReturn && pUnoReturn != pCppReturn)
359 for ( ; nTempIndices--; )
361 sal_Int32
nIndex = pTempIndices[nTempIndices];
363 uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndices], cpp_release );
364 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
367 if (pReturnTypeDescr)
368 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
378 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
385 switch (pMemberDescr->eTypeClass)
387 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
393 typelib_InterfaceAttributeTypeDescription
const *
>(
401 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
403 pReturn, pArgs, ppException );
408 typelib_MethodParameter aParam;
410 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
414 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
415 OUString aVoidName(
"void");
417 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
420 aVtableSlot.
index += 1;
425 pReturn, pArgs, ppException );
432 case typelib_TypeClass_INTERFACE_METHOD:
438 typelib_InterfaceMethodTypeDescription
const *
>(
440 switch (aVtableSlot.
index)
444 (*pUnoI->acquire)( pUnoI );
448 (*pUnoI->release)( pUnoI );
454 TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
457 uno_Interface * pInterface = 0;
460 (
void **)&pInterface, pThis->
oid.pData, (typelib_InterfaceTypeDescription *)pTD );
465 reinterpret_cast< uno_Any * >( pReturn ),
466 &pInterface, pTD, 0 );
467 (*pInterface->release)( pInterface );
468 TYPELIB_DANGER_RELEASE( pTD );
472 TYPELIB_DANGER_RELEASE( pTD );
479 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
480 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
481 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
482 pReturn, pArgs, ppException );
488 ::com::sun::star::uno::RuntimeException aExc(
489 "illegal member type description!",
494 ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
void SAL_CALL uno_destructData(void *pValue, typelib_TypeDescription *pTypeDescr, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Represents a vtable slot of a C++ class.
void fillUnoException(uno_Any *pExc, uno_Mapping *pCpp2Uno)
bool isSimpleType(typelib_TypeClass typeClass)
Determines whether a type is a "simple" type (VOID, BOOLEAN, BYTE, SHORT, UNSIGNED SHORT...
#define INSERT_INT32(pSV, pDS)
sal_Int32 index
The index within the vtable.
A uno proxy wrapping a cpp interface.
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))
bool relatesToInterfaceType(typelib_TypeDescription const *type)
Determines whether a type relates to an interface type (is itself an interface type, or might contain entities of interface type).
void unoInterfaceProxyDispatch(uno_Interface *pUnoI, const typelib_TypeDescription *pMemberDescr, void *pReturn, void *pArgs[], uno_Any **ppException)
uno_ExtEnvironment * getUnoEnv()
uno_Mapping * getUno2Cpp()
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)
#define INSERT_INT8(pSV, pDS)
sal_Int32 offset
The offset of the vtable.
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()
void SAL_CALL typelib_typedescriptionreference_release(typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
#define INSERT_INT64(pSV, pDS)
struct _typelib_TypeDescription typelib_TypeDescription
uno_Mapping * getCpp2Uno()
void MapReturn(long r0, typelib_TypeClass eTypeClass, sal_uInt64 *pRegisterReturn)
VtableSlot getVtableSlot(typelib_InterfaceAttributeTypeDescription const *ifcMember)
Calculates the vtable slot associated with an interface attribute member.
void SAL_CALL typelib_typedescriptionreference_new(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, rtl_uString *pTypeName) SAL_THROW_EXTERN_C()
OUString runtimeToOUString(char const *runtimeString)
#define INSERT_FLOAT(pSV, nr, pFPR, pDS)
#define INSERT_INT16(pSV, pDS)
#define INSERT_DOUBLE(pSV, nr, pFPR, pDS)
com::sun::star::uno::XInterface * getCppI()