23#include <com/sun/star/uno/genfunc.hxx>
24#include <com/sun/star/uno/Exception.hpp>
25#include "com/sun/star/uno/RuntimeException.hpp"
43void MapReturn(
long d0,
long d1, typelib_TypeClass eReturnType,
long *pRegisterReturn)
45 register float fret
asm(
"fp0");
46 register double dret
asm(
"fp0");
50 case typelib_TypeClass_HYPER:
51 case typelib_TypeClass_UNSIGNED_HYPER:
52 pRegisterReturn[1] = d1;
53 case typelib_TypeClass_LONG:
54 case typelib_TypeClass_UNSIGNED_LONG:
55 case typelib_TypeClass_ENUM:
56 case typelib_TypeClass_CHAR:
57 case typelib_TypeClass_SHORT:
58 case typelib_TypeClass_UNSIGNED_SHORT:
59 case typelib_TypeClass_BOOLEAN:
60 case typelib_TypeClass_BYTE:
61 pRegisterReturn[0] = d0;
63 case typelib_TypeClass_FLOAT:
64 *(
float*)pRegisterReturn = fret;
66 case typelib_TypeClass_DOUBLE:
67 *(
double*)pRegisterReturn = dret;
79 sal_Int32 nVtableIndex,
80 void * pRegisterReturn,
81 typelib_TypeClass eReturnType,
87 sal_Int32 nVtableIndex,
88 void * pRegisterReturn,
89 typelib_TypeClass eReturnType,
101 sal_uInt32 nStackBytes = nStack *
sizeof(sal_uInt32);
102 sal_uInt32 *stack = (sal_uInt32 *) __builtin_alloca( nStackBytes );
103 memcpy( stack, pStack, nStackBytes );
106#if OSL_DEBUG_LEVEL > 2
109 fprintf( stderr,
"\nStack (%d): ", nStack );
110 for (
unsigned int i = 0;
i < nStack; ++
i )
111 fprintf( stderr,
"0x%lx, ", pStack[i] );
112 fprintf( stderr,
"\n" );
113 fprintf( stderr,
"pRegisterReturn is %p\n", pRegisterReturn);
117 sal_uInt32 pMethod = *((sal_uInt32*)pThis);
118 pMethod += 4 * nVtableIndex;
119 pMethod = *((sal_uInt32 *)pMethod);
121 typedef long (*FunctionCall )();
122 FunctionCall pFunc = (FunctionCall)pMethod;
125 asm volatile(
"movel %0,%%a1" : :
"m"(pRegisterReturn) : );
127 long d0 = (*pFunc)();
129 register long d1
asm(
"d1");
131 MapReturn(d0, d1, eReturnType, (
long*)pRegisterReturn);
135#define INSERT_INT32( pSV, pDS )\
136 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
138#define INSERT_INT64( pSV, pDS )\
139 INSERT_INT32( pSV, pDS ) \
140 INSERT_INT32( ((sal_uInt32*)pSV)+1, pDS )
142#define INSERT_FLOAT( pSV, pDS ) \
143 INSERT_INT32( pSV, pDS )
145#define INSERT_DOUBLE( pSV, pDS ) \
146 INSERT_INT64( pSV, pDS )
148#define INSERT_INT16( pSV, pDS ) \
149 *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
151#define INSERT_INT8( pSV, pDS ) \
152 *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
159 typelib_TypeDescriptionReference * pReturnTypeRef,
160 sal_Int32 nParams, typelib_MethodParameter * pParams,
161 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
165 sal_uInt32 * pStack = (sal_uInt32 *)__builtin_alloca(
166 sizeof(sal_Int32) + ((nParams+2) *
sizeof(sal_Int64)) );
167 sal_uInt32 * pStackStart = pStack;
171 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
172 assert(pReturnTypeDescr);
174 void * pCppReturn = 0;
176 if (pReturnTypeDescr)
181 pCppReturn = pUnoReturn;
187 ? __builtin_alloca( pReturnTypeDescr->nSize )
194 void * pAdjustedThisPtr =
reinterpret_cast< void **
>(pThis->
getCppI())
199 static_assert(
sizeof(
void *) ==
sizeof(sal_Int32),
"### unexpected size!");
201 void ** pCppArgs = (
void **)alloca( 3 *
sizeof(
void *) * nParams );
203 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
207 sal_Int32 nTempIndices = 0;
211 const typelib_MethodParameter & rParam = pParams[
nPos];
213 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
221 switch (pParamTypeDescr->eTypeClass)
223 case typelib_TypeClass_HYPER:
224 case typelib_TypeClass_UNSIGNED_HYPER:
225#if OSL_DEBUG_LEVEL > 2
226 fprintf(stderr,
"hyper is %lx\n", pCppArgs[
nPos]);
230 case typelib_TypeClass_LONG:
231 case typelib_TypeClass_UNSIGNED_LONG:
232 case typelib_TypeClass_ENUM:
233#if OSL_DEBUG_LEVEL > 2
234 fprintf(stderr,
"long is %x\n", pCppArgs[
nPos]);
238 case typelib_TypeClass_SHORT:
239 case typelib_TypeClass_CHAR:
240 case typelib_TypeClass_UNSIGNED_SHORT:
243 case typelib_TypeClass_BOOLEAN:
244 case typelib_TypeClass_BYTE:
247 case typelib_TypeClass_FLOAT:
250 case typelib_TypeClass_DOUBLE:
255 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
263 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
265 pTempIndices[nTempIndices] =
nPos;
267 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
273 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
276 pTempIndices[nTempIndices] =
nPos;
278 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
284 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
294 pAdjustedThisPtr, aVtableSlot.
index,
295 pCppReturn, pReturnTypeDescr->eTypeClass,
297 (pStack - pStackStart));
298 }
catch (css::uno::Exception &) {
300 }
catch (std::exception & e) {
301 throw css::uno::RuntimeException(
305 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
312 for ( ; nTempIndices--; )
314 sal_Int32
nIndex = pTempIndices[nTempIndices];
334 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
337 if (pCppReturn && pUnoReturn != pCppReturn)
350 for ( ; nTempIndices--; )
352 sal_Int32
nIndex = pTempIndices[nTempIndices];
355 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
359 if (pReturnTypeDescr)
360 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
369 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
374 typelib_InterfaceTypeDescription * pTypeDescr = pThis->
pTypeDescr;
376 switch (pMemberDescr->eTypeClass)
378 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
381 sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
382 assert(nMemberPos < pTypeDescr->nAllMembers);
384 VtableSlot aVtableSlot(
386 reinterpret_cast<typelib_InterfaceAttributeTypeDescription
const *
>
394 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
396 pReturn, pArgs, ppException );
401 typelib_MethodParameter aParam;
403 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
407 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
408 OUString aVoidName(
"void");
410 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
413 aVtableSlot.index += 1;
418 pReturn, pArgs, ppException );
425 case typelib_TypeClass_INTERFACE_METHOD:
428 sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
429 assert(nMemberPos < pTypeDescr->nAllMembers);
431 VtableSlot aVtableSlot(
433 reinterpret_cast<typelib_InterfaceMethodTypeDescription
const *
>
436 switch (aVtableSlot.index)
440 (*pUnoI->acquire)( pUnoI );
444 (*pUnoI->release)( pUnoI );
450 TYPELIB_DANGER_GET( &pTD,
reinterpret_cast< Type *
>( pArgs[0] )->getTypeLibType() );
453 uno_Interface * pInterface = 0;
456 (
void **)&pInterface, pThis->
oid.pData, (typelib_InterfaceTypeDescription *)pTD );
461 reinterpret_cast< uno_Any *
>( pReturn ),
462 &pInterface, pTD, 0 );
463 (*pInterface->release)( pInterface );
464 TYPELIB_DANGER_RELEASE( pTD );
468 TYPELIB_DANGER_RELEASE( pTD );
475 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
476 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
477 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
478 pReturn, pArgs, ppException );
484 ::com::sun::star::uno::RuntimeException aExc(
485 "illegal member type description!",
490 ::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()
typelib_InterfaceTypeDescription * pTypeDescr
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_FLOAT(pSV, pDS)
#define INSERT_DOUBLE(pSV, pDS)
#define INSERT_INT64(pSV, pDS)
#define INSERT_INT8(pSV, pDS)
#define INSERT_INT16(pSV, pDS)
void MapReturn(long d0, long d1, typelib_TypeClass eReturnType, long *pRegisterReturn)
#define INSERT_INT32(pSV, 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 dummy_can_throw_anything(char const *)
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()
unsigned _Unwind_Word __attribute__((__mode__(__word__)))