23#include <com/sun/star/uno/genfunc.hxx>
24#include <com/sun/star/uno/Exception.hpp>
25#include "com/sun/star/uno/RuntimeException.hpp"
45 sal_uInt32 *pStack, sal_uInt32 nStack, sal_uInt32 *pGPR,
double *pFPR);
47#define INSERT_INT32( pSV, nr, pGPR, pDS, bOverflow )\
48 if (nr < hppa::MAX_WORDS_IN_REGS) \
50 pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
55 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
57#define INSERT_INT64( pSV, nr, pGPR, pDS, pStart, bOverflow )\
58 if ( (nr < hppa::MAX_WORDS_IN_REGS) && (nr % 2) ) \
62 if ( nr < hppa::MAX_WORDS_IN_REGS ) \
64 pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
65 pGPR[nr++] = *(reinterpret_cast<sal_uInt32 *>( pSV ) + 1); \
71 if ( (pDS - pStart) % 2) \
73 *pDS++ = reinterpret_cast<sal_uInt32 *>( pSV )[1]; \
74 *pDS++ = reinterpret_cast<sal_uInt32 *>( pSV )[0]; \
77#define INSERT_FLOAT( pSV, nr, pFPR, pDS, bOverflow ) \
78 if (nr < hppa::MAX_WORDS_IN_REGS) \
80 sal_uInt32 *pDouble = (sal_uInt32 *)&(pFPR[nr++]); \
81 pDouble[0] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
86 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
88#define INSERT_DOUBLE( pSV, nr, pFPR, pDS, pStart, bOverflow ) \
89 if ( (nr < hppa::MAX_WORDS_IN_REGS) && (nr % 2) ) \
93 if ( nr < hppa::MAX_WORDS_IN_REGS ) \
95 sal_uInt32 *pDouble = (sal_uInt32 *)&(pFPR[nr+1]); \
96 pDouble[0] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
97 pDouble[1] = *(reinterpret_cast<sal_uInt32 *>( pSV ) + 1); \
104 if ( (pDS - pStart) % 2) \
106 *pDS++ = reinterpret_cast<sal_uInt32 *>( pSV )[1]; \
107 *pDS++ = reinterpret_cast<sal_uInt32 *>( pSV )[0]; \
110#define INSERT_INT16( pSV, nr, pGPR, pDS, bOverflow ) \
111 if ( nr < hppa::MAX_WORDS_IN_REGS ) \
112 pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
116 *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
118#define INSERT_INT8( pSV, nr, pGPR, pDS, bOverflow ) \
119 if ( nr < hppa::MAX_WORDS_IN_REGS ) \
120 pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
124 *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
130 const typelib_CompoundTypeDescription *
p
131 =
reinterpret_cast< const typelib_CompoundTypeDescription *
>(
type);
132 for (sal_Int32
i = 0;
i <
p->nMembers; ++
i)
134 if (
p->ppTypeRefs[
i]->eTypeClass == typelib_TypeClass_STRUCT ||
135 p->ppTypeRefs[
i]->eTypeClass == typelib_TypeClass_EXCEPTION)
138 TYPELIB_DANGER_GET(&
t,
p->ppTypeRefs[
i]);
140 TYPELIB_DANGER_RELEASE(
t);
148 if (
p->pBaseTypeDescription != 0)
157 else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
160 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
165 TYPELIB_DANGER_RELEASE( pTypeDescr );
178 typelib_TypeDescriptionReference * pReturnTypeRef,
179 sal_Int32 nParams, typelib_MethodParameter * pParams,
180 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
183 sal_uInt32 * pStack = (sal_uInt32 *)__builtin_alloca(
184 sizeof(sal_Int32) + ((nParams+2) *
sizeof(sal_Int64)) );
185 sal_uInt32 * pStackStart = pStack;
193 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
194 assert(pReturnTypeDescr);
196 void * pCppReturn = 0;
197 bool bOverflow =
false;
198 bool bRegisterReturn =
true;
200 if (pReturnTypeDescr)
205 pCppReturn = pUnoReturn;
210 ? __builtin_alloca( pReturnTypeDescr->nSize )
215 void * pAdjustedThisPtr =
reinterpret_cast< void **
>(pThis->
getCppI())
217 INSERT_INT32( &pAdjustedThisPtr, nRegs, pGPR, pStack, bOverflow );
220 static_assert(
sizeof(
void *) ==
sizeof(sal_Int32),
"### unexpected size!");
222 void ** pCppArgs = (
void **)alloca( 3 *
sizeof(
void *) * nParams );
224 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
228 sal_Int32 nTempIndices = 0;
230 for ( sal_Int32 nPos = 0;
nPos < nParams; ++
nPos )
232 const typelib_MethodParameter & rParam = pParams[
nPos];
234 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
241 switch (pParamTypeDescr->eTypeClass)
243 case typelib_TypeClass_HYPER:
244 case typelib_TypeClass_UNSIGNED_HYPER:
245#if OSL_DEBUG_LEVEL > 2
246 fprintf(stderr,
"hyper is %llx\n", *((
long long*)pCppArgs[nPos]));
248 INSERT_INT64( pCppArgs[nPos], nRegs, pGPR, pStack, pStackStart, bOverflow );
250 case typelib_TypeClass_LONG:
251 case typelib_TypeClass_UNSIGNED_LONG:
252 case typelib_TypeClass_ENUM:
253#if OSL_DEBUG_LEVEL > 2
254 fprintf(stderr,
"long is %x\n", pCppArgs[nPos]);
256 INSERT_INT32( pCppArgs[nPos], nRegs, pGPR, pStack, bOverflow );
258 case typelib_TypeClass_SHORT:
259 case typelib_TypeClass_CHAR:
260 case typelib_TypeClass_UNSIGNED_SHORT:
261 INSERT_INT16( pCppArgs[nPos], nRegs, pGPR, pStack, bOverflow );
263 case typelib_TypeClass_BOOLEAN:
264 case typelib_TypeClass_BYTE:
265 INSERT_INT8( pCppArgs[nPos], nRegs, pGPR, pStack, bOverflow );
267 case typelib_TypeClass_FLOAT:
268 INSERT_FLOAT( pCppArgs[nPos], nRegs, pFPR, pStack, bOverflow );
270 case typelib_TypeClass_DOUBLE:
271 INSERT_DOUBLE( pCppArgs[nPos], nRegs, pFPR, pStack, pStackStart, bOverflow );
277 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
285 pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
287 pTempIndices[nTempIndices] =
nPos;
289 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
295 pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
298 pTempIndices[nTempIndices] =
nPos;
300 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
306 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
308 INSERT_INT32( &(pCppArgs[nPos]), nRegs, pGPR, pStack, bOverflow );
316 pAdjustedThisPtr, aVtableSlot.
index,
317 pCppReturn, pReturnTypeDescr, bRegisterReturn,
319 (pStack - pStackStart), pGPR, pFPR);
320 }
catch (css::uno::Exception &) {
322 }
catch (std::exception & e) {
323 throw css::uno::RuntimeException(
327 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
334 for ( ; nTempIndices--; )
336 sal_Int32
nIndex = pTempIndices[nTempIndices];
339 if (pParams[nIndex].bIn)
341 if (pParams[nIndex].bOut)
356 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
359 if (pCppReturn && pUnoReturn != pCppReturn)
372 for ( ; nTempIndices--; )
374 sal_Int32
nIndex = pTempIndices[nTempIndices];
376 uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndices], cpp_release );
377 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
381 if (pReturnTypeDescr)
382 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
391 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
396#if OSL_DEBUG_LEVEL > 0
397 typelib_InterfaceTypeDescription * pTypeDescr = pThis->
pTypeDescr;
400 switch (pMemberDescr->eTypeClass)
402 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
404#if OSL_DEBUG_LEVEL > 0
406 sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
407 assert(nMemberPos < pTypeDescr->nAllMembers);
410 VtableSlot aVtableSlot(
412 reinterpret_cast<typelib_InterfaceAttributeTypeDescription
const *
>
420 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
422 pReturn, pArgs, ppException );
427 typelib_MethodParameter aParam;
429 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
433 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
434 OUString aVoidName(
"void");
436 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
439 aVtableSlot.
index += 1;
444 pReturn, pArgs, ppException );
451 case typelib_TypeClass_INTERFACE_METHOD:
453#if OSL_DEBUG_LEVEL > 0
455 sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
456 assert(nMemberPos < pTypeDescr->nAllMembers);
459 VtableSlot aVtableSlot(
461 reinterpret_cast<typelib_InterfaceMethodTypeDescription
const *
>
464 switch (aVtableSlot.
index)
468 (*pUnoI->acquire)( pUnoI );
472 (*pUnoI->release)( pUnoI );
478 TYPELIB_DANGER_GET( &pTD,
reinterpret_cast< Type *
>( pArgs[0] )->getTypeLibType() );
481 uno_Interface * pInterface = 0;
484 (
void **)&pInterface, pThis->
oid.pData, (typelib_InterfaceTypeDescription *)pTD );
489 reinterpret_cast< uno_Any *
>( pReturn ),
490 &pInterface, pTD, 0 );
491 (*pInterface->release)( pInterface );
492 TYPELIB_DANGER_RELEASE( pTD );
497 TYPELIB_DANGER_RELEASE( pTD );
504 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
505 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
506 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
507 pReturn, pArgs, ppException );
513 ::com::sun::star::uno::RuntimeException aExc(
514 "illegal member type description!",
519 ::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()
#define INSERT_INT32(pSV, nr, pGPR, pDS, bOverflow)
#define INSERT_INT64(pSV, nr, pGPR, pDS, pStart, bOverflow)
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)
#define INSERT_FLOAT(pSV, nr, pFPR, pDS, bOverflow)
#define INSERT_INT16(pSV, nr, pGPR, pDS, bOverflow)
#define INSERT_DOUBLE(pSV, nr, pFPR, pDS, pStart, bOverflow)
#define INSERT_INT8( pSV, nr, pGPR, pDS, bOverflow)
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 isRegisterReturn(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()