26#include <com/sun/star/uno/genfunc.hxx>
36#if OSL_DEBUG_LEVEL > 1
48 typelib_TypeDescriptionReference * pReturnTypeRef,
50 typelib_MethodParameter * pParams,
55 const int MAXPARAMS = 32;
57 if ( nParams > MAXPARAMS )
71 } aCppArgs[MAXPARAMS+2], uRetVal;
72 int nCppParamIndex = 0;
76 TYPELIB_DANGER_GET( &pReturnTD, pReturnTypeRef );
80 void * pAdjustedThisPtr =
reinterpret_cast<void **
>( pThis->getCppI() ) + aVtableSlot.offset;
81 aCppArgs[nCppParamIndex++].p = pAdjustedThisPtr;
83 enum class ReturnKind { Void, Simple, Complex, ComplexConvert };
85 if (pUnoReturn ==
nullptr) {
86 retKind = ReturnKind::Void;
88 assert(pReturnTD !=
nullptr);
90 retKind = ReturnKind::Simple;
93 retKind = ReturnKind::ComplexConvert;
94 aCppArgs[nCppParamIndex++].p = alloca(pReturnTD->nSize);
96 retKind = ReturnKind::Complex;
97 aCppArgs[nCppParamIndex++].p = pUnoReturn;
102 int pTempCppIndexes[MAXPARAMS];
103 int pTempIndexes[MAXPARAMS];
104 int nTempIndexes = 0;
109 for (
int nPos = 0;
nPos < nParams; ++
nPos, ++nCppParamIndex)
111 const typelib_MethodParameter & rParam = pParams[
nPos];
113 TYPELIB_DANGER_GET( &pParamTD, rParam.pTypeRef );
117 ::uno_copyAndConvertData(
118 &aCppArgs[nCppParamIndex], pUnoArgs[nPos], pParamTD,
119 pThis->getBridge()->getUno2Cpp() );
122 TYPELIB_DANGER_RELEASE( pParamTD );
130 aCppArgs[nCppParamIndex].
p = alloca( pParamTD->nSize ),
133 pTempCppIndexes[nTempIndexes] = nCppParamIndex;
136 pTempIndexes[nTempIndexes] =
nPos;
139 pTempParamTD[nTempIndexes++] = pParamTD;
144 ::uno_copyAndConvertData(
145 aCppArgs[nCppParamIndex].
p = alloca( pParamTD->nSize ),
146 pUnoArgs[nPos], pParamTD,
147 pThis->getBridge()->getUno2Cpp() );
149 pTempCppIndexes[nTempIndexes] = nCppParamIndex;
152 pTempIndexes[nTempIndexes] =
nPos;
155 pTempParamTD[nTempIndexes++] = pParamTD;
159 aCppArgs[nCppParamIndex].p = pUnoArgs[
nPos];
161 TYPELIB_DANGER_RELEASE( pParamTD );
188 sal_Int64 (*pIMethod)(sal_Int64, ...) =
189 reinterpret_cast<sal_Int64 (*)(sal_Int64, ...)
>(
190 (*
static_cast<sal_uInt64 **
>(pAdjustedThisPtr))[aVtableSlot.index]);
192 double (*pFMethod)(sal_Int64, ...) =
193 reinterpret_cast<double (*)(sal_Int64, ...)
>(
194 (*
static_cast<sal_uInt64 **
>(pAdjustedThisPtr))[aVtableSlot.index]);
202 (pReturnTD->eTypeClass == typelib_TypeClass_FLOAT ||
203 pReturnTD->eTypeClass == typelib_TypeClass_DOUBLE) )
205 pFMethod (aCppArgs[0].i, aCppArgs[1].
d, aCppArgs[2].
d, aCppArgs[3].
d,
206 aCppArgs[4].i, aCppArgs[5].i, aCppArgs[6].i, aCppArgs[7].i,
207 aCppArgs[8].i, aCppArgs[9].i, aCppArgs[10].i, aCppArgs[11].i,
208 aCppArgs[12].i, aCppArgs[13].i, aCppArgs[14].i, aCppArgs[15].i,
209 aCppArgs[16].i, aCppArgs[17].i, aCppArgs[18].i, aCppArgs[19].i,
210 aCppArgs[20].i, aCppArgs[21].i, aCppArgs[22].i, aCppArgs[23].i,
211 aCppArgs[24].i, aCppArgs[25].i, aCppArgs[26].i, aCppArgs[27].i,
212 aCppArgs[28].i, aCppArgs[29].i, aCppArgs[30].i, aCppArgs[31].i );
215 pIMethod (aCppArgs[0].i, aCppArgs[1].
d, aCppArgs[2].
d, aCppArgs[3].
d,
216 aCppArgs[4].i, aCppArgs[5].i, aCppArgs[6].i, aCppArgs[7].i,
217 aCppArgs[8].i, aCppArgs[9].i, aCppArgs[10].i, aCppArgs[11].i,
218 aCppArgs[12].i, aCppArgs[13].i, aCppArgs[14].i, aCppArgs[15].i,
219 aCppArgs[16].i, aCppArgs[17].i, aCppArgs[18].i, aCppArgs[19].i,
220 aCppArgs[20].i, aCppArgs[21].i, aCppArgs[22].i, aCppArgs[23].i,
221 aCppArgs[24].i, aCppArgs[25].i, aCppArgs[26].i, aCppArgs[27].i,
222 aCppArgs[28].i, aCppArgs[29].i, aCppArgs[30].i, aCppArgs[31].i );
225 GetExceptionInformation(),
226 *ppUnoExc, pThis->getBridge()->getCpp2Uno() ))
230 while (nTempIndexes--)
232 int nCppIndex = pTempCppIndexes[nTempIndexes];
235 aCppArgs[nCppIndex].
p, pTempParamTD[nTempIndexes],
237 TYPELIB_DANGER_RELEASE( pTempParamTD[nTempIndexes] );
242 TYPELIB_DANGER_RELEASE( pReturnTD );
251 while (nTempIndexes--)
253 int nCppIndex = pTempCppIndexes[nTempIndexes];
254 int nIndex = pTempIndexes[nTempIndexes];
256 pTempParamTD[nTempIndexes];
258 if (pParams[nIndex].bIn)
260 if (pParams[nIndex].bOut)
263 pUnoArgs[nIndex], pParamTD,
nullptr );
264 ::uno_copyAndConvertData(
265 pUnoArgs[nIndex], aCppArgs[nCppIndex].
p, pParamTD,
266 pThis->getBridge()->getCpp2Uno() );
271 ::uno_copyAndConvertData(
272 pUnoArgs[nIndex], aCppArgs[nCppIndex].
p, pParamTD,
273 pThis->getBridge()->getCpp2Uno() );
278 aCppArgs[nCppIndex].
p, pParamTD, uno::cpp_release );
280 TYPELIB_DANGER_RELEASE( pParamTD );
285 case ReturnKind::Void:
287 case ReturnKind::Simple:
288 *
static_cast<sal_Int64*
>(pUnoReturn) = uRetVal.i;
290 case ReturnKind::Complex:
291 assert(uRetVal.p == pUnoReturn);
293 case ReturnKind::ComplexConvert:
294 assert(uRetVal.p == aCppArgs[1].p);
295 ::uno_copyAndConvertData(
296 pUnoReturn, uRetVal.p, pReturnTD,
297 pThis->getBridge()->getCpp2Uno() );
299 uRetVal.p, pReturnTD, uno::cpp_release );
305 TYPELIB_DANGER_RELEASE( pReturnTD );
315 uno_Interface * pUnoI,
324#if OSL_DEBUG_LEVEL > 0
325 typelib_InterfaceTypeDescription * pTypeDescr = pThis->
pTypeDescr;
328 switch (pMemberTD->eTypeClass)
330 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
332#if OSL_DEBUG_LEVEL > 0
334 sal_Int32 nMemberPos =
reinterpret_cast<typelib_InterfaceMemberTypeDescription
const *
>(pMemberTD)->nPosition;
335 assert(nMemberPos < pTypeDescr->nAllMembers);
337 VtableSlot aVtableSlot(
340 typelib_InterfaceAttributeTypeDescription
const *
>(
347 reinterpret_cast<typelib_InterfaceAttributeTypeDescription
const *
>(pMemberTD)->pAttributeTypeRef,
349 pReturn, pArgs, ppException );
354 typelib_MethodParameter aParam;
356 reinterpret_cast<typelib_InterfaceAttributeTypeDescription
const *
>(pMemberTD)->pAttributeTypeRef;
360 typelib_TypeDescriptionReference * pReturnTypeRef =
nullptr;
361 OUString aVoidName(
"void");
363 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
365 aVtableSlot.index += 1;
370 pReturn, pArgs, ppException );
377 case typelib_TypeClass_INTERFACE_METHOD:
379#if OSL_DEBUG_LEVEL > 0
381 sal_Int32 nMemberPos =
reinterpret_cast<typelib_InterfaceMemberTypeDescription
const *
>(pMemberTD)->nPosition;
382 assert(nMemberPos < pTypeDescr->nAllMembers);
384 VtableSlot aVtableSlot(
387 typelib_InterfaceMethodTypeDescription
const *
>(
390 switch (aVtableSlot.index)
393 (*pUnoI->acquire)( pUnoI );
394 *ppException =
nullptr;
397 (*pUnoI->release)( pUnoI );
398 *ppException =
nullptr;
403 TYPELIB_DANGER_GET( &pTD,
static_cast< uno::Type *
>( pArgs[0] )->getTypeLibType() );
407 uno_Interface * pInterface =
nullptr;
410 reinterpret_cast<void **
>(&pInterface), pThis->
oid.pData,
reinterpret_cast<typelib_InterfaceTypeDescription *
>(pTD) );
415 static_cast< uno_Any *
>( pReturn ),
416 &pInterface, pTD,
nullptr );
417 (*pInterface->release)( pInterface );
418 TYPELIB_DANGER_RELEASE( pTD );
419 *ppException =
nullptr;
422 TYPELIB_DANGER_RELEASE( pTD );
427 typelib_InterfaceMethodTypeDescription
const* pMethodTD
428 =
reinterpret_cast<typelib_InterfaceMethodTypeDescription
const *
>(pMemberTD);
430 if (!
cpp_call(pThis, aVtableSlot, pMethodTD->pReturnTypeRef, pMethodTD->nParams,
431 pMethodTD->pParams, pReturn, pArgs, ppException))
433 uno::RuntimeException aExc(
"Too many parameters!" );
436 ::uno_type_any_construct(*ppException, &aExc, rExcType.getTypeLibType(),
nullptr);
443 uno::RuntimeException aExc(
"Illegal member type description!", uno::Reference<uno::XInterface>());
447 ::uno_type_any_construct(*ppException, &aExc, rExcType.getTypeLibType(),
nullptr);
uno_ExtEnvironment * getUnoEnv()
A uno proxy wrapping a cpp interface.
typelib_InterfaceTypeDescription * pTypeDescr
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
int msvc_filterCppException(EXCEPTION_POINTERS *pPointers, 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,...
Represents a vtable slot of a C++ class.
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()