31#include <com/sun/star/uno/Exception.hpp>
32#include <com/sun/star/uno/RuntimeException.hpp>
33#include <com/sun/star/uno/genfunc.hxx>
34#include <rtl/textenc.h>
35#include <rtl/ustring.hxx>
38#include <typelib/typeclass.h>
39#include <typelib/typedescription.h>
48extern "C" void callVirtualFunction(sal_uInt64* stack, sal_uInt64* frame, sal_uInt64 function,
51void pushArgument(sal_uInt64 value, sal_uInt64* stack, sal_Int32& sp, sal_uInt64* regs,
54 (nregs != 8 ? regs[nregs++] : stack[sp++]) = value;
59 const sal_Int32 count, typelib_MethodParameter* parameters,
void* returnValue,
60 void** arguments,
uno_Any** exception)
62 static_assert(
sizeof(sal_uInt64) ==
sizeof(
void*));
64 TYPELIB_DANGER_GET(&aReturnTD, returnType);
67 void* ret = retConv ? alloca(aReturnTD->nSize) : returnValue;
69 sal_uInt64** thisPtr =
reinterpret_cast<sal_uInt64**
>(pProxy->
getCppI()) + slot.
offset;
71 sal_uInt64* gpr =
static_cast<sal_uInt64*
>(alloca((count + 16) *
sizeof(sal_uInt64) + 32));
72 sal_uInt64* fpr = &gpr[8];
73 sal_uInt64* stack = &gpr[16];
74 sal_uInt64* frame = &gpr[16 +
count];
75 void** cppArgs =
static_cast<void**
>(alloca(count *
sizeof(
void*)));
82 gpr[nGPR++] =
reinterpret_cast<sal_uInt64
>(thisPtr);
84 for (sal_Int32 i = 0;
i !=
count; ++
i)
89 switch (parameters[i].pTypeRef->eTypeClass)
91 case typelib_TypeClass_BOOLEAN:
92 pushArgument(*
static_cast<sal_Bool*
>(arguments[i]), stack, sp, gpr, nGPR);
94 case typelib_TypeClass_BYTE:
95 pushArgument(*
static_cast<sal_Int8*
>(arguments[i]), stack, sp, gpr, nGPR);
97 case typelib_TypeClass_SHORT:
98 pushArgument(*
static_cast<sal_Int16*
>(arguments[i]), stack, sp, gpr, nGPR);
100 case typelib_TypeClass_UNSIGNED_SHORT:
101 pushArgument(*
static_cast<sal_uInt16*
>(arguments[i]), stack, sp, gpr, nGPR);
103 case typelib_TypeClass_LONG:
104 case typelib_TypeClass_ENUM:
105 pushArgument(*
static_cast<sal_Int32*
>(arguments[i]), stack, sp, gpr, nGPR);
107 case typelib_TypeClass_UNSIGNED_LONG:
108 pushArgument(*
static_cast<sal_uInt32*
>(arguments[i]), stack, sp, gpr, nGPR);
110 case typelib_TypeClass_HYPER:
111 pushArgument(*
static_cast<sal_Int64*
>(arguments[i]), stack, sp, gpr, nGPR);
113 case typelib_TypeClass_UNSIGNED_HYPER:
114 pushArgument(*
static_cast<sal_uInt64*
>(arguments[i]), stack, sp, gpr, nGPR);
116 case typelib_TypeClass_FLOAT:
117 pushArgument(*
static_cast<sal_uInt32*
>(arguments[i]), stack, sp, fpr, nFPR);
119 case typelib_TypeClass_DOUBLE:
120 pushArgument(*
static_cast<sal_uInt64*
>(arguments[i]), stack, sp, fpr, nFPR);
122 case typelib_TypeClass_CHAR:
123 pushArgument(*
static_cast<sal_Unicode*
>(arguments[i]), stack, sp, gpr, nGPR);
132 TYPELIB_DANGER_GET(&ptd, parameters[i].pTypeRef);
133 if (!parameters[i].bIn)
135 cppArgs[
i] = alloca(ptd->nSize);
138 pushArgument(
reinterpret_cast<sal_uInt64
>(cppArgs[i]), stack, sp, gpr, nGPR);
142 cppArgs[
i] = alloca(ptd->nSize);
146 pushArgument(
reinterpret_cast<sal_uInt64
>(cppArgs[i]), stack, sp, gpr, nGPR);
151 pushArgument(
reinterpret_cast<sal_uInt64
>(arguments[i]), stack, sp, gpr, nGPR);
152 TYPELIB_DANGER_RELEASE(ptd);
164 for (sal_Int32 i = 0;
i !=
count; ++
i)
169 reinterpret_cast<uno_ReleaseFunc
>(css::uno::cpp_release));
170 TYPELIB_DANGER_RELEASE(ptds[i]);
173 TYPELIB_DANGER_RELEASE(aReturnTD);
178 for (sal_Int32 i = 0;
i !=
count; ++
i)
182 if (parameters[i].bOut)
184 if (parameters[i].bIn)
192 reinterpret_cast<uno_ReleaseFunc
>(css::uno::cpp_release));
193 TYPELIB_DANGER_RELEASE(ptds[i]);
200 switch (aReturnTD->eTypeClass)
202 case typelib_TypeClass_VOID:
204 case typelib_TypeClass_BOOLEAN:
205 case typelib_TypeClass_BYTE:
206 case typelib_TypeClass_SHORT:
207 case typelib_TypeClass_UNSIGNED_SHORT:
208 case typelib_TypeClass_LONG:
209 case typelib_TypeClass_UNSIGNED_LONG:
210 case typelib_TypeClass_HYPER:
211 case typelib_TypeClass_UNSIGNED_HYPER:
212 case typelib_TypeClass_CHAR:
213 case typelib_TypeClass_ENUM:
214 case typelib_TypeClass_STRUCT:
215 std::memcpy(ret, gpr, aReturnTD->nSize);
217 case typelib_TypeClass_FLOAT:
218 case typelib_TypeClass_DOUBLE:
219 std::memcpy(ret, fpr, aReturnTD->nSize);
226 switch (aReturnTD->nSize)
229 std::memcpy(
static_cast<char*
>(ret) + 12, fpr + 3, 4);
232 std::memcpy(
static_cast<char*
>(ret) + 8, fpr + 2, 4);
235 std::memcpy(
static_cast<char*
>(ret) + 4, fpr + 1, 4);
238 std::memcpy(ret, fpr, 4);
245 std::memcpy(ret, fpr, aReturnTD->nSize);
254 uno_destructData(ret, aReturnTD,
reinterpret_cast<uno_ReleaseFunc
>(css::uno::cpp_release));
256 TYPELIB_DANGER_RELEASE(aReturnTD);
263 void* pReturn,
void** pArgs,
uno_Any** ppException)
265 UnoInterfaceProxy* pProxy =
static_cast<UnoInterfaceProxy*
>(pUnoI);
266 switch (pMemberDescr->eTypeClass)
268 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
270 typelib_InterfaceAttributeTypeDescription
const* atd
271 =
reinterpret_cast<typelib_InterfaceAttributeTypeDescription const*
>(pMemberDescr);
275 call(pProxy, slot, atd->pAttributeTypeRef, 0, 0, pReturn, pArgs, ppException);
279 typelib_MethodParameter param = { 0, atd->pAttributeTypeRef,
true,
false };
280 typelib_TypeDescriptionReference* pReturnTD =
nullptr;
282 OUString(
"void").pData);
284 call(pProxy, slot, pReturnTD, 1, ¶m, pReturn, pArgs, ppException);
289 case typelib_TypeClass_INTERFACE_METHOD:
291 typelib_InterfaceMethodTypeDescription
const* mtd
292 =
reinterpret_cast<typelib_InterfaceMethodTypeDescription const*
>(pMemberDescr);
297 pUnoI->acquire(pUnoI);
301 pUnoI->release(pUnoI);
308 &td, (
reinterpret_cast<css::uno::Type*
>(pArgs[0])->getTypeLibType()));
311 uno_Interface* ifc = 0;
312 pProxy->pBridge->getUnoEnv()->getRegisteredInterface(
313 pProxy->pBridge->getUnoEnv(),
reinterpret_cast<void**
>(&ifc),
315 reinterpret_cast<typelib_InterfaceTypeDescription*
>(td));
320 TYPELIB_DANGER_RELEASE(td);
324 TYPELIB_DANGER_RELEASE(td);
329 call(pProxy, slot, mtd->pReturnTypeRef, mtd->nParams, mtd->pParams, pReturn,
void SAL_CALL uno_any_construct(uno_Any *pDest, void *pSource, typelib_TypeDescription *pTypeDescr, uno_AcquireFunc acquire) SAL_THROW_EXTERN_C()
void callVirtualFunction(unsigned long function, unsigned long *gpr, unsigned long *fpr, unsigned long *stack, sal_Int32 sp, void *ret)
uno_Mapping * getUno2Cpp()
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()
struct _typelib_TypeDescription typelib_TypeDescription
int msvc_filterCppException(EXCEPTION_POINTERS *pPointers, uno_Any *pUnoExc, uno_Mapping *pCpp2Uno)
ReturnKind getReturnKind(typelib_TypeDescription const *type)
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.
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()