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 void * pAdjustedThisPtr,
48 sal_Int32 nVtableIndex,
49 void * pRegisterReturn,
50 typelib_TypeClass eReturnType,
52 sal_Int32 * pStackLongs,
53 sal_Int32 nStackLongs)
64 unsigned long * mfunc;
98 "rlwinm %0,%0,3,3,28\n\t"
100 "rlwinm %0,%0,0,4,28\n\t"
104 : :
"r" (nStackLongs) :
"0" );
106 __asm__ __volatile__ (
"addi %0,1,8" :
"=r" (
p) : );
125 fprintf(stderr,
"callVirtualMethod parameters string is %s\n",pPT);
127 long * q = (
long *)pStackLongs;
129 fprintf(stderr,
"uno stack is: %x\n",*q);
136 while (*pPT !=
'X') {
142 fpr[f++] = *((
double *)pStackLongs);
147 gpr[
n++] = *pStackLongs;
148 gpr[
n++] = *(pStackLongs+1);
154 *
p++ = *(pStackLongs + 1);
170 fpr[f++] = *((
float *)pStackLongs);
173 gpr[
n++] = *pStackLongs;
179 *((
double *)
p) = *((
float *)pStackLongs);
182 *((
float *)
p) = *((
float *)pStackLongs);
193 gpr[
n++] = *pStackLongs;
194 gpr[
n++] = *(pStackLongs+1);
199 *
p++ = *(pStackLongs+1);
206 gpr[
n++] = *((
unsigned short*)pStackLongs);
208 *
p++ = *((
unsigned short *)pStackLongs);
215 gpr[
n++] = *((
char *)pStackLongs);
217 *
p++ = *((
char *)pStackLongs);
224 gpr[
n++] = *pStackLongs;
237 mfunc = *((
unsigned long **)pAdjustedThisPtr);
238 mfunc = (
unsigned long *)((
char *)mfunc + off);
239 mfunc = *((
unsigned long **)mfunc);
240 typedef void (*FunctionCall)(sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32);
241 FunctionCall ptr = (FunctionCall)mfunc;
263 : :
"r" (gpr),
"r" (fpr)
267 :
"0",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12"
271 register sal_uInt32 r3
__asm__(
"r3");
272 register sal_uInt32 r4
__asm__(
"r4");
273 register sal_uInt32 r5
__asm__(
"r5");
274 register sal_uInt32 r6
__asm__(
"r6");
275 register sal_uInt32 r7
__asm__(
"r7");
276 register sal_uInt32 r8
__asm__(
"r8");
277 register sal_uInt32 r9
__asm__(
"r9");
278 register sal_uInt32 r10
__asm__(
"r10");
280 (*ptr)(r3, r4, r5, r6, r7, r8, r9, r10);
287 :
"=r" (iret),
"=r" (iret2),
"=f" (dret)
289 :
"=r" (iret),
"=r" (iret2)
293 switch( eReturnType )
295 case typelib_TypeClass_HYPER:
296 case typelib_TypeClass_UNSIGNED_HYPER:
297 ((
long*)pRegisterReturn)[0] = iret;
298 ((
long*)pRegisterReturn)[1] = iret2;
299 case typelib_TypeClass_LONG:
300 case typelib_TypeClass_UNSIGNED_LONG:
301 case typelib_TypeClass_ENUM:
302 ((
long*)pRegisterReturn)[0] = iret;
304 case typelib_TypeClass_CHAR:
305 case typelib_TypeClass_SHORT:
306 case typelib_TypeClass_UNSIGNED_SHORT:
307 *(
unsigned short*)pRegisterReturn = (
unsigned short)iret;
309 case typelib_TypeClass_BOOLEAN:
310 case typelib_TypeClass_BYTE:
311 *(
unsigned char*)pRegisterReturn = (
unsigned char)iret;
313 case typelib_TypeClass_FLOAT:
315 *(
float*)pRegisterReturn = (
float)dret;
317 ((
unsigned int*)pRegisterReturn)[0] = iret;
320 case typelib_TypeClass_DOUBLE:
322 *(
double*)pRegisterReturn = dret;
324 ((
unsigned int*)pRegisterReturn)[0] = iret;
325 ((
unsigned int*)pRegisterReturn)[1] = iret2;
337 typelib_TypeDescriptionReference * pReturnTypeRef,
338 sal_Int32 nParams, typelib_MethodParameter * pParams,
339 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
343 (
char *)alloca(
sizeof(sal_Int32) + ((nParams+2) *
sizeof(sal_Int64)) );
344 char * pCppStackStart = pCppStack;
347 char * pParamType = (
char *) alloca(nParams+2);
348 char * pPT = pParamType;
352 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
355 void * pCppReturn = 0;
357 if (pReturnTypeDescr)
361 pCppReturn = pUnoReturn;
366 pCppReturn = *(
void **)pCppStack =
368 ? alloca( pReturnTypeDescr->nSize ): pUnoReturn);
370 pCppStack +=
sizeof(
void *);
374 void* pAdjustedThisPtr =
reinterpret_cast< void **
>(pThis->
getCppI()) + aVtableSlot.
offset;
375 *(
void**)pCppStack = pAdjustedThisPtr;
376 pCppStack +=
sizeof(
void* );
382 void ** pCppArgs = (
void **)alloca( 3 *
sizeof(
void *) * nParams );
384 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
388 sal_Int32 nTempIndices = 0;
390 for ( sal_Int32 nPos = 0;
nPos < nParams; ++
nPos )
392 const typelib_MethodParameter & rParam = pParams[
nPos];
394 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
401 switch (pParamTypeDescr->eTypeClass)
414 case typelib_TypeClass_LONG:
415 case typelib_TypeClass_UNSIGNED_LONG:
416 case typelib_TypeClass_ENUM:
419 case typelib_TypeClass_SHORT:
420 case typelib_TypeClass_CHAR:
421 case typelib_TypeClass_UNSIGNED_SHORT:
424 case typelib_TypeClass_BOOLEAN:
425 case typelib_TypeClass_BYTE:
428 case typelib_TypeClass_FLOAT:
431 case typelib_TypeClass_DOUBLE:
433 pCppStack +=
sizeof(sal_Int32);
435 case typelib_TypeClass_HYPER:
436 case typelib_TypeClass_UNSIGNED_HYPER:
438 pCppStack +=
sizeof(sal_Int32);
444 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
452 *(
void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
454 pTempIndices[nTempIndices] =
nPos;
456 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
462 *(
void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
463 pUnoArgs[nPos], pParamTypeDescr,
466 pTempIndices[nTempIndices] =
nPos;
468 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
472 *(
void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
474 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
479 pCppStack +=
sizeof(sal_Int32);
488 assert( !( (pCppStack - pCppStackStart ) & 3) &&
"UNALIGNED STACK !!! (Please DO panic)");
491 pAdjustedThisPtr, aVtableSlot.
index,
492 pCppReturn, pReturnTypeDescr->eTypeClass, pParamType,
493 (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) /
sizeof(sal_Int32) );
494 }
catch (css::uno::Exception &) {
496 }
catch (std::exception & e) {
497 throw css::uno::RuntimeException(
501 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
507 for ( ; nTempIndices--; )
509 sal_Int32
nIndex = pTempIndices[nTempIndices];
512 if (pParams[nIndex].bIn)
514 if (pParams[nIndex].bOut)
529 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
532 if (pCppReturn && pUnoReturn != pCppReturn)
545 for ( ; nTempIndices--; )
547 sal_Int32
nIndex = pTempIndices[nTempIndices];
549 uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndices], cpp_release );
550 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
553 if (pReturnTypeDescr)
554 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
564 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
570 switch (pMemberDescr->eTypeClass)
572 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
575 VtableSlot aVtableSlot(
578 typelib_InterfaceAttributeTypeDescription
const *
>(
586 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
588 pReturn, pArgs, ppException );
593 typelib_MethodParameter aParam;
595 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
599 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
600 OUString aVoidName(
"void");
602 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
605 aVtableSlot.
index += 1;
610 pReturn, pArgs, ppException );
617 case typelib_TypeClass_INTERFACE_METHOD:
620 VtableSlot aVtableSlot(
623 typelib_InterfaceMethodTypeDescription
const *
>(
625 switch (aVtableSlot.
index)
629 (*pUnoI->acquire)( pUnoI );
633 (*pUnoI->release)( pUnoI );
639 TYPELIB_DANGER_GET( &pTD,
reinterpret_cast< Type *
>( pArgs[0] )->getTypeLibType() );
642 uno_Interface * pInterface = 0;
645 (
void **)&pInterface, pThis->
oid.pData, (typelib_InterfaceTypeDescription *)pTD );
650 reinterpret_cast< uno_Any *
>( pReturn ),
651 &pInterface, pTD, 0 );
652 (*pInterface->release)( pInterface );
653 TYPELIB_DANGER_RELEASE( pTD );
657 TYPELIB_DANGER_RELEASE( pTD );
664 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
665 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
666 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
667 pReturn, pArgs, ppException );
673 ::com::sun::star::uno::RuntimeException aExc(
674 "illegal member type description!",
679 ::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
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()