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>
50 typelib_TypeClass typeclass,
51 sal_Int32 *
const subsp,
53 unsigned long value,
unsigned long *
const stack, sal_Int32 *
const sp,
54 unsigned long *
const regs, sal_Int32 *
const nregs)
59 regs[(*nregs)++] =
value;
64 case typelib_TypeClass_BOOLEAN:
65 case typelib_TypeClass_BYTE:
66 *
reinterpret_cast<uint8_t*
>(
reinterpret_cast<uintptr_t
>(stack + *sp) + *subsp) =
value;
74 case typelib_TypeClass_SHORT:
75 case typelib_TypeClass_UNSIGNED_SHORT:
76 case typelib_TypeClass_CHAR:
77 *subsp = (*subsp + 1) & ~0x1;
83 *
reinterpret_cast<uint16_t*
>(
reinterpret_cast<uintptr_t
>(stack + *sp) + *subsp) =
value;
91 case typelib_TypeClass_LONG:
92 case typelib_TypeClass_UNSIGNED_LONG:
93 case typelib_TypeClass_ENUM:
94 case typelib_TypeClass_FLOAT:
95 *subsp = (*subsp + 3) & ~0x3;
101 *
reinterpret_cast<uint32_t*
>(
reinterpret_cast<uintptr_t
>(stack + *sp) + *subsp) =
value;
109 case typelib_TypeClass_HYPER:
110 case typelib_TypeClass_UNSIGNED_HYPER:
123 (*nregs != 8 ? regs[(*nregs)++] : stack[(*sp)++]) = value;
130 typelib_TypeDescriptionReference * returnType, sal_Int32 count,
131 typelib_MethodParameter * parameters,
void * returnValue,
void ** arguments,
135 TYPELIB_DANGER_GET(&rtd, returnType);
138 void * ret = retConv ? alloca(rtd->nSize) : returnValue;
139 unsigned long ** thisPtr
140 =
reinterpret_cast<unsigned long **
>(proxy->
getCppI()) + slot.
offset;
141 unsigned long * stack =
static_cast<unsigned long *
>(
142 alloca(count *
sizeof (
unsigned long)));
147 unsigned long gpr[8];
149 unsigned long fpr[8];
151 gpr[ngpr++] =
reinterpret_cast<unsigned long>(thisPtr);
152 void ** cppArgs =
static_cast<void **
>(alloca(count *
sizeof (
void *)));
156 for (sal_Int32 i = 0;
i !=
count; ++
i) {
157 if (!parameters[i].bOut &&
160 cppArgs[
i] =
nullptr;
161 switch (parameters[i].pTypeRef->eTypeClass) {
162 case typelib_TypeClass_BOOLEAN:
165 parameters[i].pTypeRef->eTypeClass, &subsp,
167 static_cast<unsigned long>(*
static_cast<sal_Bool *
>(arguments[i])), stack, &sp,
170 case typelib_TypeClass_BYTE:
173 parameters[i].pTypeRef->eTypeClass, &subsp,
175 *
static_cast<sal_Int8 *
>(arguments[i]), stack, &sp, gpr,
178 case typelib_TypeClass_SHORT:
181 parameters[i].pTypeRef->eTypeClass, &subsp,
183 *
static_cast<sal_Int16 *
>(arguments[i]), stack, &sp, gpr,
186 case typelib_TypeClass_UNSIGNED_SHORT:
189 parameters[i].pTypeRef->eTypeClass, &subsp,
191 *
static_cast<sal_uInt16 *
>(arguments[i]), stack, &sp, gpr,
194 case typelib_TypeClass_LONG:
195 case typelib_TypeClass_ENUM:
198 parameters[i].pTypeRef->eTypeClass, &subsp,
200 *
static_cast<sal_Int32 *
>(arguments[i]), stack, &sp, gpr,
203 case typelib_TypeClass_UNSIGNED_LONG:
206 parameters[i].pTypeRef->eTypeClass, &subsp,
208 *
static_cast<sal_uInt32 *
>(arguments[i]), stack, &sp, gpr,
211 case typelib_TypeClass_HYPER:
214 parameters[i].pTypeRef->eTypeClass, &subsp,
216 *
static_cast<sal_Int64 *
>(arguments[i]), stack, &sp, gpr,
219 case typelib_TypeClass_UNSIGNED_HYPER:
222 parameters[i].pTypeRef->eTypeClass, &subsp,
224 *
static_cast<sal_uInt64 *
>(arguments[i]), stack, &sp, gpr,
227 case typelib_TypeClass_FLOAT:
230 parameters[i].pTypeRef->eTypeClass, &subsp,
232 *
static_cast<unsigned int *
>(arguments[i]), stack, &sp, fpr,
235 case typelib_TypeClass_DOUBLE:
238 parameters[i].pTypeRef->eTypeClass, &subsp,
240 *
static_cast<unsigned long *
>(arguments[i]), stack, &sp,
243 case typelib_TypeClass_CHAR:
246 parameters[i].pTypeRef->eTypeClass, &subsp,
248 *
static_cast<sal_Unicode *
>(arguments[i]), stack, &sp, gpr,
256 TYPELIB_DANGER_GET(&ptd, parameters[i].pTypeRef);
257 if (!parameters[i].bIn) {
258 cppArgs[
i] = alloca(ptd->nSize);
263 typelib_TypeClass_HYPER, &subsp,
265 reinterpret_cast<unsigned long>(cppArgs[i]), stack, &sp,
268 cppArgs[
i] = alloca(ptd->nSize);
270 cppArgs[i], arguments[i], ptd,
275 typelib_TypeClass_HYPER, &subsp,
277 reinterpret_cast<unsigned long>(cppArgs[i]), stack, &sp,
280 cppArgs[
i] =
nullptr;
283 typelib_TypeClass_HYPER, &subsp,
285 reinterpret_cast<unsigned long>(arguments[i]), stack, &sp,
287 TYPELIB_DANGER_RELEASE(ptd);
294 (*thisPtr)[slot.
index], gpr, fpr, stack, sp, ret);
295 }
catch (css::uno::Exception &) {
297 }
catch (std::exception & e) {
298 throw css::uno::RuntimeException(
300 + OStringToOUString(
typeid(e).
name(), RTL_TEXTENCODING_UTF8)
301 +
": " + OStringToOUString(e.what(), RTL_TEXTENCODING_UTF8));
303 throw css::uno::RuntimeException(
304 "C++ code threw unknown exception");
306 }
catch (css::uno::Exception &) {
309#if !defined MACOSX && defined _LIBCPPABI_VERSION
332 if (*
reinterpret_cast<void **
>(header) ==
nullptr) {
334 reinterpret_cast<void **
>(
header) + 1);
341 for (sal_Int32 i = 0;
i !=
count; ++
i) {
342 if (cppArgs[i] !=
nullptr) {
345 reinterpret_cast<uno_ReleaseFunc
>(css::uno::cpp_release));
346 TYPELIB_DANGER_RELEASE(ptds[i]);
349 TYPELIB_DANGER_RELEASE(rtd);
352 *exception =
nullptr;
353 for (sal_Int32 i = 0;
i !=
count; ++
i) {
354 if (cppArgs[i] !=
nullptr) {
355 if (parameters[i].bOut) {
356 if (parameters[i].bIn) {
360 arguments[i], cppArgs[i], ptds[i],
365 reinterpret_cast<uno_ReleaseFunc
>(css::uno::cpp_release));
366 TYPELIB_DANGER_RELEASE(ptds[i]);
371 switch (rtd->eTypeClass) {
372 case typelib_TypeClass_VOID:
374 case typelib_TypeClass_BOOLEAN:
375 case typelib_TypeClass_BYTE:
376 case typelib_TypeClass_SHORT:
377 case typelib_TypeClass_UNSIGNED_SHORT:
378 case typelib_TypeClass_LONG:
379 case typelib_TypeClass_UNSIGNED_LONG:
380 case typelib_TypeClass_HYPER:
381 case typelib_TypeClass_UNSIGNED_HYPER:
382 case typelib_TypeClass_CHAR:
383 case typelib_TypeClass_ENUM:
384 case typelib_TypeClass_STRUCT:
385 std::memcpy(ret, gpr, rtd->nSize);
387 case typelib_TypeClass_FLOAT:
388 case typelib_TypeClass_DOUBLE:
389 std::memcpy(ret, fpr, rtd->nSize);
396 switch (rtd->nSize) {
398 std::memcpy(
static_cast<char *
>(ret) + 12, fpr + 3, 4);
401 std::memcpy(
static_cast<char *
>(ret) + 8, fpr + 2, 4);
404 std::memcpy(
static_cast<char *
>(ret) + 4, fpr + 1, 4);
407 std::memcpy(ret, fpr, 4);
414 std::memcpy(ret, fpr, rtd->nSize);
423 ret, rtd,
reinterpret_cast<uno_ReleaseFunc
>(css::uno::cpp_release));
425 TYPELIB_DANGER_RELEASE(rtd);
434 void * pReturn,
void ** pArgs,
uno_Any ** ppException)
437 switch (pMemberDescr->eTypeClass) {
438 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
440 typelib_InterfaceAttributeTypeDescription
const * atd
442 typelib_InterfaceAttributeTypeDescription
const *
>(
445 if (pReturn !=
nullptr) {
447 proxy, slot, atd->pAttributeTypeRef, 0,
nullptr, pReturn, pArgs,
450 typelib_MethodParameter param = {
451 nullptr, atd->pAttributeTypeRef,
true,
false };
452 typelib_TypeDescriptionReference * rtd =
nullptr;
454 &rtd, typelib_TypeClass_VOID, OUString(
"void").
pData);
456 call(proxy, slot, rtd, 1, ¶m, pReturn, pArgs, ppException);
461 case typelib_TypeClass_INTERFACE_METHOD:
463 typelib_InterfaceMethodTypeDescription
const * mtd
465 typelib_InterfaceMethodTypeDescription
const *
>(
468 switch (slot.
index) {
470 pUnoI->acquire(pUnoI);
471 *ppException =
nullptr;
474 pUnoI->release(pUnoI);
475 *ppException =
nullptr;
482 (
static_cast<css::uno::Type *
>(pArgs[0])
483 ->getTypeLibType()));
485 uno_Interface * ifc =
nullptr;
488 reinterpret_cast<void **
>(&ifc), proxy->
oid.pData,
490 typelib_InterfaceTypeDescription *
>(td));
491 if (ifc !=
nullptr) {
493 static_cast<uno_Any *
>(pReturn), &ifc, td,
496 TYPELIB_DANGER_RELEASE(td);
497 *ppException =
nullptr;
500 TYPELIB_DANGER_RELEASE(td);
506 proxy, slot, mtd->pReturnTypeRef, mtd->nParams,
507 mtd->pParams, pReturn, pArgs, ppException);
constexpr sal_Int8 header[]
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_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()
std::unique_ptr< sal_Int32[]> pData
struct _typelib_TypeDescription typelib_TypeDescription
__cxa_eh_globals * __cxa_get_globals()
std::type_info * __cxa_current_exception_type()
ReturnKind getReturnKind(typelib_TypeDescription const *type)
void mapException(__cxxabiv1::__cxa_exception *exception, std::type_info const *type, uno_Any *any, uno_Mapping *mapping)
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()