summaryrefslogtreecommitdiff
path: root/bridges
diff options
context:
space:
mode:
authorThorsten Behrens <thorsten.behrens@allotropia.de>2021-09-25 18:03:31 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2022-01-19 14:26:09 +0100
commitc367a2781f99ed22d0f7d64184fb567aacc43f35 (patch)
tree7a12e0e485aeac4fae08dd9925310d7cbac95ed9 /bridges
parentcb65cf92b91873bfd13c96250c782998f1eef337 (diff)
WASM UNO: add a minimal dummy bridge
... and use the same fake exception rethrowing code then the mobile platforms. Change-Id: Ic90de1cfd1e0092d6064d041a613d60d9f5f76b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128596 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'bridges')
-rw-r--r--bridges/Library_cpp_uno.mk3
-rw-r--r--bridges/Module_bridges.mk2
-rw-r--r--bridges/source/cpp_uno/gcc3_wasm/cpp2uno.cxx47
-rw-r--r--bridges/source/cpp_uno/gcc3_wasm/except.cxx22
-rw-r--r--bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx93
5 files changed, 165 insertions, 2 deletions
diff --git a/bridges/Library_cpp_uno.mk b/bridges/Library_cpp_uno.mk
index 7c713f7ed1f4..e2de3c1678b4 100644
--- a/bridges/Library_cpp_uno.mk
+++ b/bridges/Library_cpp_uno.mk
@@ -85,6 +85,9 @@ else ifeq ($(COM),MSC)
bridges_SELECTED_BRIDGE := msvc_win32_intel
bridge_exception_objects := cpp2uno uno2cpp
bridge_noopt_objects := except
+else ifeq ($(OS),EMSCRIPTEN)
+bridges_SELECTED_BRIDGE := gcc3_wasm
+bridge_noopt_objects := cpp2uno except uno2cpp
endif
else ifeq ($(CPUNAME),M68K)
diff --git a/bridges/Module_bridges.mk b/bridges/Module_bridges.mk
index 1c7fb1789b8e..3016bf2c404f 100644
--- a/bridges/Module_bridges.mk
+++ b/bridges/Module_bridges.mk
@@ -9,7 +9,6 @@
$(eval $(call gb_Module_Module,bridges))
-ifneq ($(OS),EMSCRIPTEN)
$(eval $(call gb_Module_add_targets,bridges,\
Library_cpp_uno \
$(if $(ENABLE_JAVA),\
@@ -30,6 +29,5 @@ else ifneq ($(words $(bridges_SELECTED_BRIDGE)),1)
$(call gb_Output_error,multiple bridges selected for build: $(bridges_SELECTED_BRIDGE))
endif
endif
-endif
# vim: set noet sw=4 ts=4:
diff --git a/bridges/source/cpp_uno/gcc3_wasm/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_wasm/cpp2uno.cxx
new file mode 100644
index 000000000000..fd7fa817588a
--- /dev/null
+++ b/bridges/source/cpp_uno/gcc3_wasm/cpp2uno.cxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <typelib/typedescription.hxx>
+#include <vtablefactory.hxx>
+
+using namespace ::com::sun::star::uno;
+
+using bridges::cpp_uno::shared::VtableFactory;
+
+struct VtableFactory::Slot
+{
+};
+
+VtableFactory::Slot* VtableFactory::mapBlockToVtable(void* block)
+{
+ return static_cast<Slot*>(block) + 2;
+}
+
+std::size_t VtableFactory::getBlockSize(sal_Int32 slotCount)
+{
+ return (slotCount + 2) * sizeof(Slot);
+}
+
+VtableFactory::Slot* VtableFactory::initializeBlock(void* block, sal_Int32 slotCount, sal_Int32,
+ typelib_InterfaceTypeDescription*)
+{
+ Slot* slots = mapBlockToVtable(block);
+ return slots + slotCount;
+}
+
+unsigned char* VtableFactory::addLocalFunctions(Slot**, unsigned char*,
+ typelib_InterfaceTypeDescription const*, sal_Int32,
+ sal_Int32, sal_Int32)
+{
+ std::abort();
+}
+
+void VtableFactory::flushCode(unsigned char const*, unsigned char const*) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/bridges/source/cpp_uno/gcc3_wasm/except.cxx b/bridges/source/cpp_uno/gcc3_wasm/except.cxx
new file mode 100644
index 000000000000..36778c65a11a
--- /dev/null
+++ b/bridges/source/cpp_uno/gcc3_wasm/except.cxx
@@ -0,0 +1,22 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <cstdlib>
+
+#include <uno/mapping.h>
+#include <uno/any2.h>
+
+namespace CPPU_CURRENT_NAMESPACE
+{
+void raiseException(uno_Any*, uno_Mapping*) { std::abort(); }
+
+void fillUnoException(uno_Any*, uno_Mapping*) { std::abort(); }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx
new file mode 100644
index 000000000000..ddb51166b51e
--- /dev/null
+++ b/bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <com/sun/star/uno/RuntimeException.hpp>
+
+#include <bridge.hxx>
+#include <types.hxx>
+#include <unointerfaceproxy.hxx>
+#include <vtables.hxx>
+
+using namespace ::com::sun::star::uno;
+
+namespace bridges::cpp_uno::shared
+{
+void unoInterfaceProxyDispatch(uno_Interface* pUnoI, const typelib_TypeDescription* pMemberDescr,
+ void* pReturn, void* pArgs[], uno_Any** ppException)
+{
+ bridges::cpp_uno::shared::UnoInterfaceProxy* pThis
+ = static_cast<bridges::cpp_uno::shared::UnoInterfaceProxy*>(pUnoI);
+
+ switch (pMemberDescr->eTypeClass)
+ {
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ std::abort();
+ break;
+ }
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ VtableSlot aVtableSlot(getVtableSlot(
+ reinterpret_cast<typelib_InterfaceMethodTypeDescription const*>(pMemberDescr)));
+
+ switch (aVtableSlot.index)
+ {
+ case 1: // acquire uno interface
+ (*pUnoI->acquire)(pUnoI);
+ *ppException = 0;
+ break;
+ case 2: // release uno interface
+ (*pUnoI->release)(pUnoI);
+ *ppException = 0;
+ break;
+ case 0: // queryInterface() opt
+ {
+ typelib_TypeDescription* pTD = 0;
+ TYPELIB_DANGER_GET(&pTD, reinterpret_cast<Type*>(pArgs[0])->getTypeLibType());
+ if (pTD)
+ {
+ uno_Interface* pInterface = 0;
+ (*pThis->getBridge()->getUnoEnv()->getRegisteredInterface)(
+ pThis->getBridge()->getUnoEnv(), (void**)&pInterface, pThis->oid.pData,
+ (typelib_InterfaceTypeDescription*)pTD);
+
+ if (pInterface)
+ {
+ ::uno_any_construct(reinterpret_cast<uno_Any*>(pReturn), &pInterface,
+ pTD, 0);
+ (*pInterface->release)(pInterface);
+ TYPELIB_DANGER_RELEASE(pTD);
+ *ppException = 0;
+ break;
+ }
+ TYPELIB_DANGER_RELEASE(pTD);
+ }
+ } // else perform queryInterface()
+ [[fallthrough]];
+ default:
+ std::abort();
+ }
+ break;
+ }
+ default:
+ {
+ ::com::sun::star::uno::RuntimeException aExc(
+ "illegal member type description!",
+ ::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface>());
+
+ Type const& rExcType = cppu::UnoType<decltype(aExc)>::get();
+ // binary identical null reference
+ ::uno_type_any_construct(*ppException, &aExc, rExcType.getTypeLibType(), 0);
+ }
+ }
+}
+
+} // namespace bridges::cpp_uno::shared
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */