27#include <com/sun/star/uno/genfunc.hxx>
28#include <com/sun/star/uno/Exception.hpp>
29#include <com/sun/star/uno/RuntimeException.hpp>
49 typelib_TypeDescriptionReference * pReturnTypeRef,
50 sal_Int32 nParams, typelib_MethodParameter * pParams,
51 void * pUnoReturn,
void * pUnoArgs[],
uno_Any ** ppUnoExc )
55 static_cast<char *
>(alloca(
sizeof(sal_Int32) + ((nParams+2) *
sizeof(sal_Int64)) ));
56 char * pCppStackStart = pCppStack;
60 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
61 assert(pReturnTypeDescr);
63 void * pCppReturn =
nullptr;
64 bool bSimpleReturn =
true;
71 pCppReturn = pUnoReturn;
76 pCppReturn = *
reinterpret_cast<void **
>(pCppStack)
79 ? alloca( pReturnTypeDescr->nSize )
81 pCppStack +=
sizeof(
void *);
85 void * pAdjustedThisPtr =
reinterpret_cast< void **
>(pThis->
getCppI())
87 *
reinterpret_cast<void **
>(pCppStack) = pAdjustedThisPtr;
88 pCppStack +=
sizeof(
void* );
91 static_assert(
sizeof(
void *) ==
sizeof(sal_Int32),
"### unexpected size!");
93 void ** pCppArgs =
static_cast<void **
>(alloca( 3 *
sizeof(
void *) * nParams ));
95 sal_Int32 * pTempIndices =
reinterpret_cast<sal_Int32 *
>(pCppArgs + nParams);
99 sal_Int32 nTempIndices = 0;
101 for ( sal_Int32 nPos = 0;
nPos < nParams; ++
nPos )
103 const typelib_MethodParameter & rParam = pParams[
nPos];
105 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
113 switch (pParamTypeDescr->eTypeClass)
115 case typelib_TypeClass_HYPER:
116 case typelib_TypeClass_UNSIGNED_HYPER:
117 case typelib_TypeClass_DOUBLE:
118 pCppStack +=
sizeof(sal_Int32);
124 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
132 *
reinterpret_cast<void **
>(pCppStack) = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
134 pTempIndices[nTempIndices] =
nPos;
136 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
143 *
reinterpret_cast<void **
>(pCppStack) = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
144 pUnoArgs[nPos], pParamTypeDescr,
147 pTempIndices[nTempIndices] =
nPos;
149 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
153 *
reinterpret_cast<void **
>(pCppStack) = pCppArgs[nPos] = pUnoArgs[nPos];
155 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
158 pCppStack +=
sizeof(sal_Int32);
163 assert( !( (pCppStack - pCppStackStart ) & 3) &&
"UNALIGNED STACK !!! (Please DO panic)" );
166 pAdjustedThisPtr, aVtableSlot.
index,
167 pCppReturn, pReturnTypeDescr, bSimpleReturn,
168 reinterpret_cast<sal_Int32 *
>(pCppStackStart), (pCppStack - pCppStackStart) /
sizeof(sal_Int32) );
169 }
catch (css::uno::Exception &) {
171 }
catch (std::exception & e) {
172 throw css::uno::RuntimeException(
176 throw css::uno::RuntimeException(
"C++ code threw unknown exception");
182 for ( ; nTempIndices--; )
184 sal_Int32
nIndex = pTempIndices[nTempIndices];
187 if (pParams[nIndex].bIn)
189 if (pParams[nIndex].bOut)
204 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
207 if (pCppReturn && pUnoReturn != pCppReturn)
220 for ( ; nTempIndices--; )
222 sal_Int32
nIndex = pTempIndices[nTempIndices];
224 uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndices], cpp_release );
225 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
228 if (pReturnTypeDescr)
229 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
241#if defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) || \
242 defined(MACOSX) || defined(DRAGONFLY)
246 if (pTD->eTypeClass == typelib_TypeClass_STRUCT &&
247 (recursive || pTD->nSize <= 2 || pTD->nSize == 4 || pTD->nSize == 8))
249 typelib_CompoundTypeDescription *
const pCompTD =
250 (typelib_CompoundTypeDescription *) pTD;
251 for ( sal_Int32
pos = pCompTD->nMembers;
pos--; ) {
253 TYPELIB_DANGER_GET( &pMemberTD, pCompTD->ppTypeRefs[
pos] );
255 TYPELIB_DANGER_RELEASE( pMemberTD );
272 void * pReturn,
void * pArgs[],
uno_Any ** ppException )
278 switch (pMemberDescr->eTypeClass)
280 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
282 VtableSlot aVtableSlot(
285 typelib_InterfaceAttributeTypeDescription
const *
>(
292 reinterpret_cast<typelib_InterfaceAttributeTypeDescription
const *
>(pMemberDescr)->pAttributeTypeRef,
294 pReturn, pArgs, ppException );
299 typelib_MethodParameter aParam;
301 reinterpret_cast<typelib_InterfaceAttributeTypeDescription
const *
>(pMemberDescr)->pAttributeTypeRef;
305 typelib_TypeDescriptionReference * pReturnTypeRef =
nullptr;
306 OUString aVoidName(
"void");
308 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
311 aVtableSlot.
index += 1;
316 pReturn, pArgs, ppException );
323 case typelib_TypeClass_INTERFACE_METHOD:
325 VtableSlot aVtableSlot(
328 typelib_InterfaceMethodTypeDescription
const *
>(
330 switch (aVtableSlot.
index)
334 (*pUnoI->acquire)( pUnoI );
335 *ppException =
nullptr;
338 (*pUnoI->release)( pUnoI );
339 *ppException =
nullptr;
344 TYPELIB_DANGER_GET( &pTD,
static_cast< Type *
>( pArgs[0] )->getTypeLibType() );
347 uno_Interface * pInterface =
nullptr;
350 reinterpret_cast<void **
>(&pInterface), pThis->
oid.pData,
reinterpret_cast<typelib_InterfaceTypeDescription *
>(pTD) );
355 static_cast< uno_Any *
>( pReturn ),
356 &pInterface, pTD,
nullptr );
357 (*pInterface->release)( pInterface );
358 TYPELIB_DANGER_RELEASE( pTD );
359 *ppException =
nullptr;
362 TYPELIB_DANGER_RELEASE( pTD );
370 reinterpret_cast<typelib_InterfaceMethodTypeDescription
const *
>(pMemberDescr)->pReturnTypeRef,
371 reinterpret_cast<typelib_InterfaceMethodTypeDescription
const *
>(pMemberDescr)->nParams,
372 reinterpret_cast<typelib_InterfaceMethodTypeDescription
const *
>(pMemberDescr)->pParams,
373 pReturn, pArgs, ppException );
379 ::com::sun::star::uno::RuntimeException aExc(
380 "illegal member type description!",
385 ::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()
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()
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 callVirtualMethod(void *pAdjustedThisPtr, sal_Int32 nVtableIndex, void *pRegisterReturn, typelib_TypeDescription *pReturnTypeDescr, bool bSimpleReturn, sal_Int32 *pStackLongs, sal_Int32 nStackLongs)
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)
bool isSimpleReturnType(typelib_TypeDescription *pTD, bool recursive=false)
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()