26#include <com/sun/star/uno/Exception.hpp>
27#include <com/sun/star/uno/RuntimeException.hpp>
28#include <com/sun/star/uno/genfunc.hxx>
52 void * pAdjustedThisPtr,
53 sal_Int32 nVtableIndex,
54 void * pRegisterReturn,
55 typelib_TypeClass eReturnType,
57 sal_Int32 * pStackLongs,
64 unsigned long * mfunc;
76 fprintf(stderr,
"in CallVirtualMethod\n");
90 "addiu $2,$29,-512\n\t"
92 :
"=r"(
p): :
"$2",
"$29" );
95 if (nStackLongs * 4 > 512 )
96 fprintf(stderr,
"too many arguments");
108 fprintf(stderr,
"overflow area pointer p=%p\n",
p);
111 fprintf(stderr,
"callVirtualMethod parameters string is %s\n",pPT);
113 long * q = (
long *)pStackLongs;
115 fprintf(stderr,
"uno stack is: %x\n",(
unsigned int)*q);
122 while (*pPT !=
'X') {
131 gpr[nw++] = *pStackLongs;
132 gpr[nw++] = *(pStackLongs+1);
137 *
p++ = *(pStackLongs+1);
144 gpr[nw++] = *((
unsigned short*)pStackLongs);
146 *
p++ = *((
unsigned short *)pStackLongs);
153 gpr[nw++] = *((
char *)pStackLongs);
155 *
p++ = *((
char *)pStackLongs);
162 gpr[nw++] = *pStackLongs;
175 mfunc = *((
unsigned long **)pAdjustedThisPtr);
176 mfunc = (
unsigned long *)((
char *)mfunc + off);
177 mfunc = *((
unsigned long **)mfunc);
178 ptr = (void (*)())mfunc;
181 fprintf(stderr,
"calling function %p\n",mfunc);
192 :
"$4",
"$5",
"$6",
"$7"
195 __asm__ __volatile__ (
"addiu $29,$29,-528\r\n":::
"$29");
199 __asm__ __volatile__ (
"addiu $29,$29,528\r\n":::
"$29");
204 :
"=m" (iret),
"=m" (iret2) : );
205 register float fret
asm(
"$f0");
206 register double dret
asm(
"$f0");
208 switch( eReturnType )
210 case typelib_TypeClass_HYPER:
211 case typelib_TypeClass_UNSIGNED_HYPER:
212 ((
long*)pRegisterReturn)[1] = iret2;
213 case typelib_TypeClass_LONG:
214 case typelib_TypeClass_UNSIGNED_LONG:
215 case typelib_TypeClass_ENUM:
216 ((
long*)pRegisterReturn)[0] = iret;
218 case typelib_TypeClass_CHAR:
219 case typelib_TypeClass_SHORT:
220 case typelib_TypeClass_UNSIGNED_SHORT:
221 *(
unsigned short*)pRegisterReturn = (
unsigned short)iret;
223 case typelib_TypeClass_BOOLEAN:
224 case typelib_TypeClass_BYTE:
225 *(
unsigned char*)pRegisterReturn = (
unsigned char)iret;
227 case typelib_TypeClass_FLOAT:
228 *(
float*)pRegisterReturn = fret;
230 case typelib_TypeClass_DOUBLE:
231 *(
double*)pRegisterReturn = dret;
242 typelib_TypeDescriptionReference * pReturnTypeRef,
243 sal_Int32 nParams, typelib_MethodParameter * pParams,
244 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
248 (
char *)alloca(
sizeof(sal_Int32) + ((nParams+2) *
sizeof(sal_Int64)) );
249 char * pCppStackStart = pCppStack;
252 char * pParamType = (
char *) alloca(nParams+2);
253 char * pPT = pParamType;
256 fprintf(stderr,
"in cpp_call\n");
261 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
264 void * pCppReturn = 0;
266 if (pReturnTypeDescr)
270 pCppReturn = pUnoReturn;
275 pCppReturn = *(
void **)pCppStack =
277 ? alloca( pReturnTypeDescr->nSize ): pUnoReturn);
279 pCppStack +=
sizeof(
void *);
283 void* pAdjustedThisPtr =
reinterpret_cast< void **
>(pThis->
getCppI()) + aVtableSlot.
offset;
284 *(
void**)pCppStack = pAdjustedThisPtr;
285 pCppStack +=
sizeof(
void* );
291 void ** pCppArgs = (
void **)alloca( 3 *
sizeof(
void *) * nParams );
293 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
297 sal_Int32 nTempIndices = 0;
299 for ( sal_Int32 nPos = 0;
nPos < nParams; ++
nPos )
301 const typelib_MethodParameter & rParam = pParams[
nPos];
303 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
310 switch (pParamTypeDescr->eTypeClass)
323 case typelib_TypeClass_LONG:
324 case typelib_TypeClass_UNSIGNED_LONG:
325 case typelib_TypeClass_ENUM:
328 case typelib_TypeClass_SHORT:
329 case typelib_TypeClass_CHAR:
330 case typelib_TypeClass_UNSIGNED_SHORT:
333 case typelib_TypeClass_BOOLEAN:
334 case typelib_TypeClass_BYTE:
337 case typelib_TypeClass_FLOAT:
340 case typelib_TypeClass_DOUBLE:
342 pCppStack +=
sizeof(sal_Int32);
344 case typelib_TypeClass_HYPER:
345 case typelib_TypeClass_UNSIGNED_HYPER:
347 pCppStack +=
sizeof(sal_Int32);
354 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
362 *(
void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
364 pTempIndices[nTempIndices] =
nPos;
366 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
372 *(
void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
373 pUnoArgs[nPos], pParamTypeDescr,
376 pTempIndices[nTempIndices] =
nPos;
378 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
382 *(
void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
384 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
389 pCppStack +=
sizeof(sal_Int32);
398 assert( !( (pCppStack - pCppStackStart ) & 3) &&
"UNALIGNED STACK !!! (Please DO panic)" );
401 pAdjustedThisPtr, aVtableSlot.
index,
402 pCppReturn, pReturnTypeDescr->eTypeClass, pParamType,
403 (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) /
sizeof(sal_Int32) );
404 }
catch (css::uno::Exception &) {
406 }
catch (std::exception & e) {
407 throw css::uno::RuntimeException(
411 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
417 for ( ; nTempIndices--; )
419 sal_Int32
nIndex = pTempIndices[nTempIndices];
422 if (pParams[nIndex].bIn)
424 if (pParams[nIndex].bOut)
439 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
442 if (pCppReturn && pUnoReturn != pCppReturn)
455 for ( ; nTempIndices--; )
457 sal_Int32
nIndex = pTempIndices[nTempIndices];
459 uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndices], cpp_release );
460 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
463 if (pReturnTypeDescr)
464 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
475 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
483 fprintf(stderr,
"in dispatch\n");
486 switch (pMemberDescr->eTypeClass)
488 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
491 VtableSlot aVtableSlot(
494 typelib_InterfaceAttributeTypeDescription
const *
>(
502 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
504 pReturn, pArgs, ppException );
509 typelib_MethodParameter aParam;
511 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
515 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
516 OUString aVoidName(
"void");
518 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
521 aVtableSlot.
index += 1;
526 pReturn, pArgs, ppException );
533 case typelib_TypeClass_INTERFACE_METHOD:
536 VtableSlot aVtableSlot(
539 typelib_InterfaceMethodTypeDescription
const *
>(
541 switch (aVtableSlot.
index)
545 (*pUnoI->acquire)( pUnoI );
549 (*pUnoI->release)( pUnoI );
555 TYPELIB_DANGER_GET( &pTD,
reinterpret_cast< Type *
>( pArgs[0] )->getTypeLibType() );
558 uno_Interface * pInterface = 0;
561 (
void **)&pInterface, pThis->
oid.pData, (typelib_InterfaceTypeDescription *)pTD );
566 reinterpret_cast< uno_Any *
>( pReturn ),
567 &pInterface, pTD, 0 );
568 (*pInterface->release)( pInterface );
569 TYPELIB_DANGER_RELEASE( pTD );
573 TYPELIB_DANGER_RELEASE( pTD );
580 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
581 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
582 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
583 pReturn, pArgs, ppException );
589 ::com::sun::star::uno::RuntimeException aExc(
590 "illegal member type description!",
595 ::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 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()