23#include <com/sun/star/uno/genfunc.hxx>
24#include <com/sun/star/uno/Exception.hpp>
25#include <com/sun/star/uno/RuntimeException.hpp>
51#if !defined(__ARM_EABI__) && !defined(__SOFTFP__)
64#define HWCAP_ARM_VFP 64
68 int fd = open (
"/proc/self/auxv", O_RDONLY);
74 Elf32_auxv_t buf[128];
76 while ((ret == -1) && ((
n = read(fd, buf,
sizeof (buf))) > 0))
78 for (
int i = 0;
i < 128; ++
i)
80 if (buf[
i].a_type == AT_HWCAP)
85 else if (buf[
i].a_type == AT_NULL)
105 const typelib_CompoundTypeDescription *
p
106 =
reinterpret_cast< const typelib_CompoundTypeDescription *
>(
type);
107 for (sal_Int32
i = 0;
i <
p->nMembers; ++
i)
109 if (
p->ppTypeRefs[
i]->eTypeClass == typelib_TypeClass_STRUCT ||
110 p->ppTypeRefs[
i]->eTypeClass == typelib_TypeClass_EXCEPTION)
113 TYPELIB_DANGER_GET(&
t,
p->ppTypeRefs[
i]);
115 TYPELIB_DANGER_RELEASE(
t);
123 if (
p->pBaseTypeDescription !=
nullptr)
131 const typelib_CompoundTypeDescription *
p
132 =
reinterpret_cast< const typelib_CompoundTypeDescription *
>(
type);
133 for (sal_Int32 i = 0;
i <
p->nMembers; ++
i)
135 if (
p->ppTypeRefs[i]->eTypeClass != typelib_TypeClass_FLOAT &&
136 p->ppTypeRefs[i]->eTypeClass != typelib_TypeClass_DOUBLE)
146 else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
149 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
157 if( pTypeDescr->nSize <= 16 && is_float_only_struct(pTypeDescr))
161 TYPELIB_DANGER_RELEASE( pTypeDescr );
168static void MapReturn(sal_uInt32 r0, sal_uInt32 r1, typelib_TypeDescriptionReference * pReturnType, sal_uInt32* pRegisterReturn)
170 switch( pReturnType->eTypeClass )
172 case typelib_TypeClass_HYPER:
173 case typelib_TypeClass_UNSIGNED_HYPER:
174 pRegisterReturn[1] = r1;
176 case typelib_TypeClass_LONG:
177 case typelib_TypeClass_UNSIGNED_LONG:
178 case typelib_TypeClass_ENUM:
179 case typelib_TypeClass_CHAR:
180 case typelib_TypeClass_SHORT:
181 case typelib_TypeClass_UNSIGNED_SHORT:
182 case typelib_TypeClass_BOOLEAN:
183 case typelib_TypeClass_BYTE:
184 pRegisterReturn[0] = r0;
186 case typelib_TypeClass_FLOAT:
187#if !defined(__ARM_PCS_VFP) && (defined(__ARM_EABI__) || defined(__SOFTFP__))
188 pRegisterReturn[0] = r0;
191#pragma clang diagnostic push
192#pragma clang diagnostic ignored "-Wuninitialized"
194 register float fret
asm(
"s0");
195 *
reinterpret_cast<float *
>(pRegisterReturn) = fret;
197#pragma clang diagnostic pop
201 case typelib_TypeClass_DOUBLE:
202#if !defined(__ARM_PCS_VFP) && (defined(__ARM_EABI__) || defined(__SOFTFP__))
203 pRegisterReturn[1] = r1;
204 pRegisterReturn[0] = r0;
207#pragma clang diagnostic push
208#pragma clang diagnostic ignored "-Wuninitialized"
210 register double dret
asm(
"d0");
211 *
reinterpret_cast<double *
>(pRegisterReturn) = dret;
213#pragma clang diagnostic pop
217 case typelib_TypeClass_STRUCT:
218 case typelib_TypeClass_EXCEPTION:
221 pRegisterReturn[0] = r0;
234 sal_Int32 nVtableIndex,
235 void * pRegisterReturn,
236 typelib_TypeDescriptionReference * pReturnType,
245 sal_Int32 nVtableIndex,
246 void * pRegisterReturn,
247 typelib_TypeDescriptionReference * pReturnType,
261 sal_uInt32 nStackBytes = ( ( nStack + 1 ) >> 1 ) * 8;
262 sal_uInt32 *stack =
static_cast<sal_uInt32 *
>(__builtin_alloca( nStackBytes ));
263 memcpy( stack, pStack, nStackBytes );
270 sal_uInt32 pMethod = *
static_cast<sal_uInt32 *
>(pThis);
271 pMethod += 4 * nVtableIndex;
272 pMethod = *
reinterpret_cast<sal_uInt32 *
>(pMethod);
280 "ldr r4, %[pgpr]\n\t"
281 "ldmia r4, {r0-r3}\n\t"
285 "ldr r4, %[pfpr]\n\t"
286 "vldmia r4, {d0-d7}\n\t"
289 "ldr r5, %[pmethod]\n\t"
290#ifndef __ARM_ARCH_4T__
293 "mov lr, pc ; bx r5\n\t"
299 : [r0]
"=r" (r0), [r1]
"=r" (r1)
300 : [pmethod]
"m" (pMethod), [pgpr]
"m" (pGPR), [pfpr]
"m" (pFPR)
301 :
"r0",
"r1",
"r2",
"r3",
"r4",
"r5");
303 MapReturn(r0, r1, pReturnType,
static_cast<sal_uInt32*
>(pRegisterReturn));
307#define INSERT_INT32( pSV, nr, pGPR, pDS ) \
308 if ( nr < arm::MAX_GPR_REGS ) \
309 pGPR[nr++] = *reinterpret_cast<const sal_uInt32*>( pSV ); \
311 *pDS++ = *reinterpret_cast<const sal_uInt32*>( pSV );
314#define INSERT_INT64( pSV, nr, pGPR, pDS, pStart ) \
315 if ( (nr < arm::MAX_GPR_REGS) && (nr % 2) ) \
319 if ( nr < arm::MAX_GPR_REGS ) \
321 pGPR[nr++] = *static_cast<const sal_uInt32 *>( pSV ); \
322 pGPR[nr++] = *(static_cast<const sal_uInt32 *>( pSV ) + 1); \
326 if ( (pDS - pStart) % 2) \
330 *pDS++ = static_cast<sal_uInt32 *>( pSV )[0]; \
331 *pDS++ = static_cast<sal_uInt32 *>( pSV )[1]; \
334#define INSERT_INT64( pSV, nr, pGPR, pDS, pStart ) \
335 INSERT_INT32( pSV, nr, pGPR, pDS ) \
336 INSERT_INT32( ((sal_uInt32*)pSV)+1, nr, pGPR, pDS )
349#define INSERT_FLOAT( pSV, nr, pGPR, pDS ) \
353 if ( nSR < arm::MAX_FPR_REGS*2 ) {\
354 pSPR[nSR++] = *static_cast<float const *>( pSV ); \
355 if ((nSR % 2 == 1) && (nSR > 2*nDR)) {\
361 *pDS++ = *static_cast<float const *>( pSV );\
363#define INSERT_DOUBLE( pSV, nr, pGPR, pDS, pStart ) \
364 if ( nDR < arm::MAX_FPR_REGS ) { \
365 pFPR[nDR++] = *static_cast<double const *>( pSV ); \
369 if ( (pDS - pStart) % 2) \
373 *reinterpret_cast<double *>(pDS) = *static_cast<double const *>( pSV );\
377#define INSERT_FLOAT( pSV, nr, pFPR, pDS ) \
378 INSERT_INT32( pSV, nr, pGPR, pDS )
380#define INSERT_DOUBLE( pSV, nr, pFPR, pDS, pStart ) \
381 INSERT_INT64( pSV, nr, pGPR, pDS, pStart )
384#define INSERT_INT16( pSV, nr, pGPR, pDS ) \
385 if ( nr < arm::MAX_GPR_REGS ) \
386 pGPR[nr++] = *static_cast<sal_uInt16 const *>( pSV ); \
388 *pDS++ = *static_cast<sal_uInt16 const *>( pSV );
390#define INSERT_INT8( pSV, nr, pGPR, pDS ) \
391 if ( nr < arm::MAX_GPR_REGS ) \
392 pGPR[nr++] = *static_cast<sal_uInt8 const *>( pSV ); \
394 *pDS++ = *static_cast<sal_uInt8 const *>( pSV );
401 typelib_TypeDescriptionReference * pReturnTypeRef,
402 sal_Int32 nParams, typelib_MethodParameter * pParams,
403 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
406 sal_uInt32 * pStack =
static_cast<sal_uInt32 *
>(__builtin_alloca(
407 sizeof(sal_Int32) + ((nParams+2) *
sizeof(sal_Int64)) ));
408 sal_uInt32 * pStackStart = pStack;
417 float *pSPR =
reinterpret_cast< float *
>(&pFPR);
423 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
424 assert(pReturnTypeDescr);
426 void * pCppReturn =
nullptr;
428 if (pReturnTypeDescr)
433 pCppReturn = pUnoReturn;
438 ? __builtin_alloca( pReturnTypeDescr->nSize )
445 void * pAdjustedThisPtr =
reinterpret_cast< void **
>(pThis->
getCppI())
450 static_assert(
sizeof(
void *) ==
sizeof(sal_Int32),
"### unexpected size!");
452 void ** pCppArgs =
static_cast<void **
>(alloca( 3 *
sizeof(
void *) * nParams ));
454 sal_Int32 * pTempIndices =
reinterpret_cast<sal_Int32 *
>(pCppArgs + nParams);
458 sal_Int32 nTempIndices = 0;
462 const typelib_MethodParameter & rParam = pParams[
nPos];
464 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
472 switch (pParamTypeDescr->eTypeClass)
474 case typelib_TypeClass_HYPER:
475 case typelib_TypeClass_UNSIGNED_HYPER:
476#if OSL_DEBUG_LEVEL > 2
477 fprintf(stderr,
"hyper is %p\n", pCppArgs[
nPos]);
481 case typelib_TypeClass_LONG:
482 case typelib_TypeClass_UNSIGNED_LONG:
483 case typelib_TypeClass_ENUM:
484#if OSL_DEBUG_LEVEL > 2
485 fprintf(stderr,
"long is %p\n", pCppArgs[
nPos]);
489 case typelib_TypeClass_SHORT:
490 case typelib_TypeClass_CHAR:
491 case typelib_TypeClass_UNSIGNED_SHORT:
494 case typelib_TypeClass_BOOLEAN:
495 case typelib_TypeClass_BYTE:
498 case typelib_TypeClass_FLOAT:
501 case typelib_TypeClass_DOUBLE:
508 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
516 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
518 pTempIndices[nTempIndices] =
nPos;
520 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
526 pCppArgs[
nPos] = alloca( pParamTypeDescr->nSize ),
529 pTempIndices[nTempIndices] =
nPos;
531 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
537 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
547 pAdjustedThisPtr, aVtableSlot.
index,
548 pCppReturn, pReturnTypeRef,
550 (pStack - pStackStart),
553 }
catch (css::uno::Exception &) {
555 }
catch (std::exception & e) {
556 throw css::uno::RuntimeException(
560 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
567 for ( ; nTempIndices--; )
569 sal_Int32
nIndex = pTempIndices[nTempIndices];
589 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
592 if (pCppReturn && pUnoReturn != pCppReturn)
605 for ( ; nTempIndices--; )
607 sal_Int32
nIndex = pTempIndices[nTempIndices];
610 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
614 if (pReturnTypeDescr)
615 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
624 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
629#if OSL_DEBUG_LEVEL > 0
630 typelib_InterfaceTypeDescription * pTypeDescr = pThis->
pTypeDescr;
633 switch (pMemberDescr->eTypeClass)
635 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
637#if OSL_DEBUG_LEVEL > 0
639 sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
640 assert(nMemberPos < pTypeDescr->nAllMembers);
643 VtableSlot aVtableSlot(
645 reinterpret_cast<typelib_InterfaceAttributeTypeDescription
const *
>
653 reinterpret_cast<typelib_InterfaceAttributeTypeDescription
const *
>(pMemberDescr)->pAttributeTypeRef,
655 pReturn, pArgs, ppException );
660 typelib_MethodParameter aParam;
662 reinterpret_cast<typelib_InterfaceAttributeTypeDescription
const *
>(pMemberDescr)->pAttributeTypeRef;
666 typelib_TypeDescriptionReference * pReturnTypeRef =
nullptr;
667 OUString aVoidName(
"void");
669 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
672 aVtableSlot.index += 1;
677 pReturn, pArgs, ppException );
684 case typelib_TypeClass_INTERFACE_METHOD:
686#if OSL_DEBUG_LEVEL > 0
688 sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
689 assert(nMemberPos < pTypeDescr->nAllMembers);
692 VtableSlot aVtableSlot(
694 reinterpret_cast<typelib_InterfaceMethodTypeDescription
const *
>
697 switch (aVtableSlot.index)
701 (*pUnoI->acquire)( pUnoI );
702 *ppException =
nullptr;
705 (*pUnoI->release)( pUnoI );
706 *ppException =
nullptr;
711 TYPELIB_DANGER_GET( &pTD,
static_cast< Type *
>( pArgs[0] )->getTypeLibType() );
714 uno_Interface * pInterface =
nullptr;
717 reinterpret_cast<void **
>(&pInterface), pThis->
oid.pData,
reinterpret_cast<typelib_InterfaceTypeDescription *
>(pTD) );
722 static_cast< uno_Any *
>( pReturn ),
723 &pInterface, pTD,
nullptr );
724 (*pInterface->release)( pInterface );
725 TYPELIB_DANGER_RELEASE( pTD );
726 *ppException =
nullptr;
729 TYPELIB_DANGER_RELEASE( pTD );
736 reinterpret_cast<typelib_InterfaceMethodTypeDescription
const *
>(pMemberDescr)->pReturnTypeRef,
737 reinterpret_cast<typelib_InterfaceMethodTypeDescription
const *
>(pMemberDescr)->nParams,
738 reinterpret_cast<typelib_InterfaceMethodTypeDescription
const *
>(pMemberDescr)->pParams,
739 pReturn, pArgs, ppException );
745 ::com::sun::star::uno::RuntimeException aExc(
746 "illegal member type description!",
751 ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(),
nullptr );
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_DOUBLE(pSV, nr, pFPR, pDS, pStart)
#define INSERT_INT32(pSV, nr, pGPR, pDS)
#define INSERT_INT8(pSV, nr, pGPR, pDS)
#define INSERT_FLOAT(pSV, nr, pFPR, pDS)
#define INSERT_INT16(pSV, nr, pGPR, pDS)
#define INSERT_INT64(pSV, nr, pGPR, pDS, pStart)
static void MapReturn(sal_uInt32 r0, sal_uInt32 r1, typelib_TypeDescriptionReference *pReturnType, sal_uInt32 *pRegisterReturn)
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 dummy_can_throw_anything(char const *)
void fillUnoException(uno_Any *pUnoExc, uno_Mapping *pCpp2Uno)
static bool is_complex_struct(const typelib_TypeDescription *type)
bool return_in_hidden_param(typelib_TypeDescriptionReference *pTypeRef)
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__)))