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 switch (pReturnTypeDescr->eTypeClass)
49 case typelib_TypeClass_HYPER:
50 case typelib_TypeClass_UNSIGNED_HYPER:
51 case typelib_TypeClass_LONG:
52 case typelib_TypeClass_UNSIGNED_LONG:
53 case typelib_TypeClass_ENUM:
54 *pRegisterReturn = rRet.
r8;
56 case typelib_TypeClass_CHAR:
57 case typelib_TypeClass_SHORT:
58 case typelib_TypeClass_UNSIGNED_SHORT:
59 *pRegisterReturn = (
unsigned short)rRet.
r8;
61 case typelib_TypeClass_BOOLEAN:
62 case typelib_TypeClass_BYTE:
63 *pRegisterReturn = (
unsigned char)rRet.
r8;
65 case typelib_TypeClass_FLOAT:
66 *
reinterpret_cast<float *
>( pRegisterReturn ) = dret;
68 case typelib_TypeClass_DOUBLE:
69 *
reinterpret_cast<double *
>( pRegisterReturn ) = dret;
71 case typelib_TypeClass_STRUCT:
72 case typelib_TypeClass_EXCEPTION:
74 sal_uInt32 nRetSize = pReturnTypeDescr->nSize;
75 if (bSimpleReturn && nRetSize <= 32 && nRetSize > 0)
76 memcpy(pRegisterReturn, (
void*)&rRet, nRetSize);
88 const typelib_CompoundTypeDescription *
p
89 =
reinterpret_cast< const typelib_CompoundTypeDescription *
>(
type);
90 for (sal_Int32
i = 0;
i <
p->nMembers; ++
i)
92 if (
p->ppTypeRefs[
i]->eTypeClass == typelib_TypeClass_STRUCT ||
93 p->ppTypeRefs[
i]->eTypeClass == typelib_TypeClass_EXCEPTION)
96 TYPELIB_DANGER_GET(&
t,
p->ppTypeRefs[
i]);
98 TYPELIB_DANGER_RELEASE(
t);
106 if (
p->pBaseTypeDescription != 0)
113 if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
116 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
119 TYPELIB_DANGER_RELEASE( pTypeDescr );
128 if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
133 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
136 bool bRet = pTypeDescr->nSize > 32;
137 TYPELIB_DANGER_RELEASE( pTypeDescr );
147 else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
160 sal_uInt64 *pStack, sal_uInt32 nStack,
161 sal_uInt64 *pGPR, sal_uInt32 nGPR,
162 double *pFPR, sal_uInt32 nFPR)
166 nStack = ( nStack + 1 ) & ~1;
174#if OSL_DEBUG_LEVEL > 2
177 fprintf( stderr,
"= callVirtualMethod() =\nGPR's (%d): ", nGPR );
178 for (
unsigned int i = 0;
i < nGPR; ++
i )
179 fprintf( stderr,
"0x%lx, ", pGPR[i] );
180 fprintf( stderr,
"\nFPR's (%d): ", nFPR );
181 for (
unsigned int i = 0;
i < nFPR; ++
i )
182 fprintf( stderr,
"0x%lx (%f), ", pFPR[i], pFPR[i] );
183 fprintf( stderr,
"\nStack (%d): ", nStack );
184 for (
unsigned int i = 0;
i < nStack; ++
i )
185 fprintf( stderr,
"0x%lx, ", pStack[i] );
186 fprintf( stderr,
"\n" );
187 fprintf( stderr,
"pRegisterReturn is %p\n", pRegisterReturn);
192 sal_uInt64 *stack = (sal_uInt64 *) __builtin_alloca( nStack * 8 );
193 memcpy( stack, pStack, nStack * 8 );
197 sal_uInt64 pMethod = *((sal_uInt64 *)pThis);
200 pMethod += 16 * nVtableIndex;
202 typedef void (* FunctionCall )( sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64 );
203 FunctionCall pFunc = (FunctionCall)pMethod;
208 asm volatile(
"ldfd f15=%0" : :
"m"(pFPR[7]) :
"f15");
210 asm volatile(
"ldfd f14=%0" : :
"m"(pFPR[6]) :
"f14");
212 asm volatile(
"ldfd f13=%0" : :
"m"(pFPR[5]) :
"f13");
214 asm volatile(
"ldfd f12=%0" : :
"m"(pFPR[4]) :
"f12");
216 asm volatile(
"ldfd f11=%0" : :
"m"(pFPR[3]) :
"f11");
218 asm volatile(
"ldfd f10=%0" : :
"m"(pFPR[2]) :
"f10");
220 asm volatile(
"ldfd f9=%0" : :
"m"(pFPR[1]) :
"f9");
222 asm volatile(
"ldfd f8=%0" : :
"m"(pFPR[0]) :
"f8");
228 asm volatile(
"ld8 r8=%0" : :
"m"(pRegisterReturn) :
"r8");
230 (*pFunc)(pGPR[0], pGPR[1], pGPR[2], pGPR[3], pGPR[4], pGPR[5], pGPR[6], pGPR[7]);
232 register double f8
asm(
"f8");
235 register long r8
asm(
"r8"); ret.
r8 = r8;
236 register long r9
asm(
"r9"); ret.r9 = r9;
237 register long r10
asm(
"r10"); ret.r10 = r10;
238 register long r11
asm(
"r11"); ret.r11 = r11;
241 MapReturn(ret, f8, pReturnTypeDescr, bSimpleReturn, (sal_uInt64*)pRegisterReturn);
252#define INSERT_FLOAT( pSV, nfr, pFPR, ngr, pGPR, pDS, bOverflow ) \
253 if ( nfr < ia64::MAX_SSE_REGS && ngr < ia64::MAX_GPR_REGS ) \
254 pFPR[nfr++] = *reinterpret_cast<float *>( pSV ); \
255 if ( ngr < ia64::MAX_GPR_REGS ) \
256 pGPR[ngr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
260 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
262#define INSERT_DOUBLE( pSV, nfr, pFPR, ngr, pGPR, pDS, bOverflow ) \
263 if ( nfr < ia64::MAX_SSE_REGS && ngr < ia64::MAX_GPR_REGS ) \
264 pFPR[nfr++] = *reinterpret_cast<double *>( pSV ); \
265 if ( ngr < ia64::MAX_GPR_REGS ) \
266 pGPR[ngr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
270 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
272#define INSERT_INT64( pSV, nr, pGPR, pDS, bOverflow ) \
273 if ( nr < ia64::MAX_GPR_REGS ) \
274 pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
278 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
280#define INSERT_INT32( pSV, nr, pGPR, pDS, bOverflow ) \
281 if ( nr < ia64::MAX_GPR_REGS ) \
282 pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
286 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
288#define INSERT_INT16( pSV, nr, pGPR, pDS, bOverflow ) \
289 if ( nr < ia64::MAX_GPR_REGS ) \
290 pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
294 *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
296#define INSERT_INT8( pSV, nr, pGPR, pDS, bOverflow ) \
297 if ( nr < ia64::MAX_GPR_REGS ) \
298 pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
302 *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
307 typelib_TypeDescriptionReference * pReturnTypeRef,
308 sal_Int32 nParams, typelib_MethodParameter * pParams,
309 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
312 sal_uInt64 * pStack = (sal_uInt64 *)alloca( (nParams+3) *
sizeof(sal_Int64) );
313 sal_uInt64 * pStackStart = pStack;
323 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
324 assert(pReturnTypeDescr);
326 void * pCppReturn = 0;
328 bool bOverflow =
false;
330 bool bSimpleReturn =
true;
331 if (pReturnTypeDescr)
333#if OSL_DEBUG_LEVEL > 2
334 fprintf(stderr,
"return type is %d\n", pReturnTypeDescr->eTypeClass);
337 bSimpleReturn =
false;
341 pCppReturn = pUnoReturn;
342#if OSL_DEBUG_LEVEL > 2
343 fprintf(stderr,
"simple return\n");
350 ? alloca( pReturnTypeDescr->nSize ) : pUnoReturn);
351#if OSL_DEBUG_LEVEL > 2
352 fprintf(stderr,
"pCppReturn/pUnoReturn is %lx/%lx", pCppReturn, pUnoReturn);
355 INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack, bOverflow );
359 void * pAdjustedThisPtr =
reinterpret_cast< void **
>( pThis->
getCppI() ) + aVtableSlot.
offset;
361#
if OSL_DEBUG_LEVEL > 2
362 fprintf(stderr,
"this pointer is %p\n", pAdjustedThisPtr);
364 INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack, bOverflow );
367 void ** pCppArgs = (
void **)alloca( 3 *
sizeof(
void *) * nParams );
369 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
373 sal_Int32 nTempIndices = 0;
375#if OSL_DEBUG_LEVEL > 2
376 fprintf(stderr,
"n params is %d\n", nParams);
381 const typelib_MethodParameter & rParam = pParams[
nPos];
383 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
385#if OSL_DEBUG_LEVEL > 2
387 pParamTypeDescr->eTypeClass);
395 switch (pParamTypeDescr->eTypeClass)
397 case typelib_TypeClass_HYPER:
398 case typelib_TypeClass_UNSIGNED_HYPER:
399#if OSL_DEBUG_LEVEL > 2
400 fprintf(stderr,
"hyper is %lx\n", *(
unsigned long*)(pCppArgs[
nPos]));
404 case typelib_TypeClass_LONG:
405 case typelib_TypeClass_UNSIGNED_LONG:
406 case typelib_TypeClass_ENUM:
407#if OSL_DEBUG_LEVEL > 2
408 fprintf(stderr,
"long is %lx\n", *(
unsigned int*)(pCppArgs[
nPos]));
412 case typelib_TypeClass_SHORT:
413 case typelib_TypeClass_CHAR:
414 case typelib_TypeClass_UNSIGNED_SHORT:
415#if OSL_DEBUG_LEVEL > 2
416 fprintf(stderr,
"short is %x\n", *(
unsigned short*)(pCppArgs[
nPos]));
420 case typelib_TypeClass_BOOLEAN:
421 case typelib_TypeClass_BYTE:
422#if OSL_DEBUG_LEVEL > 2
423 fprintf(stderr,
"byte is %x\n", *(
unsigned char*)(pCppArgs[
nPos]));
427 case typelib_TypeClass_FLOAT:
428#if OSL_DEBUG_LEVEL > 2
429 fprintf(stderr,
"a float is %f\n", *(
float*)(pCppArgs[
nPos]));
430 fprintf(stderr,
"b float is %f\n", *(
double*)(pCppArgs[
nPos]));
434 case typelib_TypeClass_DOUBLE:
435#if OSL_DEBUG_LEVEL > 2
436 fprintf(stderr,
"double is %f\n", *(
double*)(pCppArgs[
nPos]));
445 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
450#if OSL_DEBUG_LEVEL > 2
451 fprintf(stderr,
"complex type again %d\n", rParam.bIn);
455#if OSL_DEBUG_LEVEL > 2
456 fprintf(stderr,
"complex size is %d\n", pParamTypeDescr->nSize );
460 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
462 pTempIndices[nTempIndices] =
nPos;
464 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
469#if OSL_DEBUG_LEVEL > 2
470 fprintf(stderr,
"this one\n");
473 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
476 pTempIndices[nTempIndices] =
nPos;
478 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
482#if OSL_DEBUG_LEVEL > 2
483 fprintf(stderr,
"that one, passing %lx through\n", pUnoArgs[
nPos]);
487 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
497 pAdjustedThisPtr, aVtableSlot.
index,
498 pCppReturn, pReturnTypeDescr, bSimpleReturn,
499 pStackStart, ( pStack - pStackStart ),
502 }
catch (css::uno::Exception &) {
504 }
catch (std::exception & e) {
505 throw css::uno::RuntimeException(
509 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
515 for ( ; nTempIndices--; )
517 sal_Int32
nIndex = pTempIndices[nTempIndices];
537 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
540 if (pCppReturn && pUnoReturn != pCppReturn)
553 for ( ; nTempIndices--; )
555 sal_Int32
nIndex = pTempIndices[nTempIndices];
558 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
561 if (pReturnTypeDescr)
562 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
572 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
578 switch (pMemberDescr->eTypeClass)
580 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
583 VtableSlot aVtableSlot(
586 typelib_InterfaceAttributeTypeDescription
const *
>(
594 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
596 pReturn, pArgs, ppException );
601 typelib_MethodParameter aParam;
603 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
607 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
608 OUString aVoidName(
"void");
610 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
613 aVtableSlot.index += 1;
618 pReturn, pArgs, ppException );
625 case typelib_TypeClass_INTERFACE_METHOD:
628 VtableSlot aVtableSlot(
631 typelib_InterfaceMethodTypeDescription
const *
>(
633 switch (aVtableSlot.index)
637 (*pUnoI->acquire)( pUnoI );
641 (*pUnoI->release)( pUnoI );
647 TYPELIB_DANGER_GET( &pTD,
reinterpret_cast< Type *
>( pArgs[0] )->getTypeLibType() );
650 uno_Interface * pInterface = 0;
653 (
void **)&pInterface, pThis->
oid.pData, (typelib_InterfaceTypeDescription *)pTD );
658 reinterpret_cast< uno_Any *
>( pReturn ),
659 &pInterface, pTD, 0 );
660 (*pInterface->release)( pInterface );
661 TYPELIB_DANGER_RELEASE( pTD );
665 TYPELIB_DANGER_RELEASE( pTD );
672 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
673 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
674 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
675 pReturn, pArgs, ppException );
681 ::com::sun::star::uno::RuntimeException aExc(
682 "illegal member type description!",
687 ::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()
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, nfr, pFPR, ngr, pGPR, 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)
#define INSERT_DOUBLE(pSV, nfr, pFPR, ngr, pGPR, pDS, bOverflow)
void MapReturn(const ia64::RegReturn &rRet, double dret, typelib_TypeDescription *pReturnTypeDescr, bool bSimpleReturn, sal_uInt64 *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)
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,...
bool is_complex_struct(const typelib_TypeDescription *type)
bool return_via_r8_buffer(typelib_TypeDescriptionReference *pTypeRef)
bool return_in_hidden_param(typelib_TypeDescriptionReference *pTypeRef)
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()