diff options
author | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-07-10 14:26:55 +0200 |
---|---|---|
committer | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-07-10 17:39:24 +0200 |
commit | 0c2e0ea495b5f6317d8f7459d3af5f35b2a4b962 (patch) | |
tree | 25a8fc6c383d26119267b1c35b8fe31113951ee3 /bridges/source/cpp_uno | |
parent | 62a0eb9b088818239c4d2fa16f84e356a63389b1 (diff) |
Consolidate common code
Change-Id: Ic24163970fd5b97c2426f0786d9b7d97a1796f87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170309
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
Diffstat (limited to 'bridges/source/cpp_uno')
-rw-r--r-- | bridges/source/cpp_uno/gcc3_wasm/abi.cxx | 43 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_wasm/abi.hxx | 13 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_wasm/cpp2uno.cxx | 66 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx | 67 |
4 files changed, 71 insertions, 118 deletions
diff --git a/bridges/source/cpp_uno/gcc3_wasm/abi.cxx b/bridges/source/cpp_uno/gcc3_wasm/abi.cxx index 49d7762ea3c2..c2a1e9059c9d 100644 --- a/bridges/source/cpp_uno/gcc3_wasm/abi.cxx +++ b/bridges/source/cpp_uno/gcc3_wasm/abi.cxx @@ -16,12 +16,55 @@ #include <com/sun/star/uno/RuntimeException.hpp> #include <cppu/unotype.hxx> #include <rtl/ustring.hxx> +#include <typelib/typeclass.h> #include <typelib/typedescription.h> #include <uno/any2.h> #include <uno/mapping.h> #include "abi.hxx" +abi_wasm::StructKind abi_wasm::getKind(typelib_CompoundTypeDescription const* type) +{ + if (type->nMembers > 1) + { + return StructKind::General; + } + auto k = StructKind::Empty; + if (type->pBaseTypeDescription != nullptr) + { + k = getKind(type->pBaseTypeDescription); + } + if (type->nMembers == 0) + { + return k; + } + if (k != StructKind::Empty) + { + return StructKind::General; + } + switch (type->ppTypeRefs[0]->eTypeClass) + { + case typelib_TypeClass_BOOLEAN: + case typelib_TypeClass_BYTE: + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_CHAR: + case typelib_TypeClass_ENUM: + return StructKind::I32; + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + return StructKind::I64; + case typelib_TypeClass_FLOAT: + return StructKind::F32; + case typelib_TypeClass_DOUBLE: + return StructKind::F64; + default: + return StructKind::General; + } +} + void abi_wasm::mapException(__cxxabiv1::__cxa_exception* exception, std::type_info const* type, uno_Any* any, uno_Mapping* mapping) { diff --git a/bridges/source/cpp_uno/gcc3_wasm/abi.hxx b/bridges/source/cpp_uno/gcc3_wasm/abi.hxx index b60f6383fd1a..bc3637a55968 100644 --- a/bridges/source/cpp_uno/gcc3_wasm/abi.hxx +++ b/bridges/source/cpp_uno/gcc3_wasm/abi.hxx @@ -18,6 +18,7 @@ #include <bridges/emscriptencxxabi/cxxabi.hxx> #include <config_cxxabi.h> +#include <typelib/typedescription.h> #include <uno/any2.h> #include <uno/mapping.h> @@ -121,6 +122,18 @@ extern "C" __cxa_eh_globals* __cxa_get_globals(); namespace abi_wasm { +enum class StructKind +{ + Empty, + I32, + I64, + F32, + F64, + General +}; + +StructKind getKind(typelib_CompoundTypeDescription const* type); + void mapException(__cxxabiv1::__cxa_exception* exception, std::type_info const* type, uno_Any* any, uno_Mapping* mapping); } diff --git a/bridges/source/cpp_uno/gcc3_wasm/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_wasm/cpp2uno.cxx index 2877a706a67a..921e2f23b551 100644 --- a/bridges/source/cpp_uno/gcc3_wasm/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_wasm/cpp2uno.cxx @@ -73,58 +73,6 @@ VtableFactory::Slot* VtableFactory::initializeBlock(void* block, sal_Int32 slotC namespace { -enum class StructKind -{ - Empty, - I32, - I64, - F32, - F64, - General -}; - -StructKind getKind(typelib_CompoundTypeDescription const* type) -{ - if (type->nMembers > 1) - { - return StructKind::General; - } - auto k = StructKind::Empty; - if (type->pBaseTypeDescription != nullptr) - { - k = getKind(type->pBaseTypeDescription); - } - if (type->nMembers == 0) - { - return k; - } - if (k != StructKind::Empty) - { - return StructKind::General; - } - switch (type->ppTypeRefs[0]->eTypeClass) - { - case typelib_TypeClass_BOOLEAN: - case typelib_TypeClass_BYTE: - case typelib_TypeClass_SHORT: - case typelib_TypeClass_UNSIGNED_SHORT: - case typelib_TypeClass_LONG: - case typelib_TypeClass_UNSIGNED_LONG: - case typelib_TypeClass_CHAR: - case typelib_TypeClass_ENUM: - return StructKind::I32; - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - return StructKind::I64; - case typelib_TypeClass_FLOAT: - return StructKind::F32; - case typelib_TypeClass_DOUBLE: - return StructKind::F64; - default: - return StructKind::General; - } -} - class Rtti { public: @@ -499,24 +447,24 @@ unsigned char* VtableFactory::addLocalFunctions(Slot** slots, unsigned char* cod case typelib_TypeClass_STRUCT: { css::uno::TypeDescription rtd(mtd->pReturnTypeRef); - switch (getKind( + switch (abi_wasm::getKind( reinterpret_cast<typelib_CompoundTypeDescription const*>(rtd.get()))) { - case StructKind::Empty: + case abi_wasm::StructKind::Empty: break; - case StructKind::I32: + case abi_wasm::StructKind::I32: sig.append('i'); break; - case StructKind::I64: + case abi_wasm::StructKind::I64: sig.append('j'); break; - case StructKind::F32: + case abi_wasm::StructKind::F32: sig.append('f'); break; - case StructKind::F64: + case abi_wasm::StructKind::F64: sig.append('d'); break; - case StructKind::General: + case abi_wasm::StructKind::General: sig.append('I'); break; } diff --git a/bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx index 7f83e2312c35..f3467c497460 100644 --- a/bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx @@ -39,58 +39,6 @@ namespace { -enum class StructKind -{ - Empty, - I32, - I64, - F32, - F64, - General -}; - -StructKind getKind(typelib_CompoundTypeDescription const* type) -{ - if (type->nMembers > 1) - { - return StructKind::General; - } - auto k = StructKind::Empty; - if (type->pBaseTypeDescription != nullptr) - { - k = getKind(type->pBaseTypeDescription); - } - if (type->nMembers == 0) - { - return k; - } - if (k != StructKind::Empty) - { - return StructKind::General; - } - switch (type->ppTypeRefs[0]->eTypeClass) - { - case typelib_TypeClass_BOOLEAN: - case typelib_TypeClass_BYTE: - case typelib_TypeClass_SHORT: - case typelib_TypeClass_UNSIGNED_SHORT: - case typelib_TypeClass_LONG: - case typelib_TypeClass_UNSIGNED_LONG: - case typelib_TypeClass_CHAR: - case typelib_TypeClass_ENUM: - return StructKind::I32; - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - return StructKind::I64; - case typelib_TypeClass_FLOAT: - return StructKind::F32; - case typelib_TypeClass_DOUBLE: - return StructKind::F64; - default: - return StructKind::General; - } -} - void call(bridges::cpp_uno::shared::UnoInterfaceProxy* proxy, bridges::cpp_uno::shared::VtableSlot slot, typelib_TypeDescriptionReference* returnType, sal_Int32 count, typelib_MethodParameter* parameters, void* returnValue, void** arguments, @@ -136,23 +84,24 @@ void call(bridges::cpp_uno::shared::UnoInterfaceProxy* proxy, break; case typelib_TypeClass_STRUCT: { - switch (getKind(reinterpret_cast<typelib_CompoundTypeDescription const*>(rtd.get()))) + switch (abi_wasm::getKind( + reinterpret_cast<typelib_CompoundTypeDescription const*>(rtd.get()))) { - case StructKind::Empty: + case abi_wasm::StructKind::Empty: break; - case StructKind::I32: + case abi_wasm::StructKind::I32: sig.append('i'); break; - case StructKind::I64: + case abi_wasm::StructKind::I64: sig.append('j'); break; - case StructKind::F32: + case abi_wasm::StructKind::F32: sig.append('f'); break; - case StructKind::F64: + case abi_wasm::StructKind::F64: sig.append('d'); break; - case StructKind::General: + case abi_wasm::StructKind::General: sig.append("vi"); args.push_back(reinterpret_cast<sal_uInt32>(ret)); break; |