diff --git a/Repository.mk b/Repository.mk index 895d99fbadc2..fd83898e9426 100644 --- a/Repository.mk +++ b/Repository.mk @@ -572,13 +572,11 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_URE,ure, \ )) $(eval $(call gb_Helper_register_plugins_for_install,PLAINLIBS_URE,ure, \ - $(if $(filter EMSCRIPTEN,$(OS)),, \ $(if $(filter MSC,$(COM)), \ $(if $(filter INTEL,$(CPUNAME)),msci_uno) \ $(if $(filter X86_64,$(CPUNAME)),mscx_uno) \ $(if $(filter AARCH64,$(CPUNAME)),msca_uno) \ , gcc3_uno) \ - ) \ )) $(eval $(call gb_Helper_register_libraries_for_install,PRIVATELIBS_URE,ure, \ 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 +#include + +using namespace ::com::sun::star::uno; + +using bridges::cpp_uno::shared::VtableFactory; + +struct VtableFactory::Slot +{ +}; + +VtableFactory::Slot* VtableFactory::mapBlockToVtable(void* block) +{ + return static_cast(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 + +#include +#include + +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 + +#include +#include +#include +#include + +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(pUnoI); + + switch (pMemberDescr->eTypeClass) + { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + { + std::abort(); + break; + } + case typelib_TypeClass_INTERFACE_METHOD: + { + VtableSlot aVtableSlot(getVtableSlot( + reinterpret_cast(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(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(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::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: */ diff --git a/cppu/source/uno/lbmap.cxx b/cppu/source/uno/lbmap.cxx index 585082ac1d06..43818eb85025 100644 --- a/cppu/source/uno/lbmap.cxx +++ b/cppu/source/uno/lbmap.cxx @@ -421,6 +421,7 @@ static Mapping loadExternalMapping( OSL_ASSERT( aExt.is() ); if (aExt.is()) return aExt; + SAL_INFO("cppu", "Could not load external mapping for " << aName); } #else // find proper lib diff --git a/cppuhelper/source/exc_thrower.cxx b/cppuhelper/source/exc_thrower.cxx index 1bb8bfab13b3..c0d441fcd48b 100644 --- a/cppuhelper/source/exc_thrower.cxx +++ b/cppuhelper/source/exc_thrower.cxx @@ -168,9 +168,15 @@ ExceptionThrower::ExceptionThrower() uno_Interface::pDispatcher = ExceptionThrower_dispatch; } +#if defined(IOS) || (defined(__aarch64__) && defined(ANDROID)) || defined(EMSCRIPTEN) +#define RETHROW_FAKE_EXCEPTIONS 1 +#else +#define RETHROW_FAKE_EXCEPTIONS 0 +#endif + class theExceptionThrower : public rtl::Static {}; -#if defined(IOS) || (defined(__aarch64__) && defined(ANDROID)) +#if RETHROW_FAKE_EXCEPTIONS // In the native iOS / Android app, where we don't have any Java, Python, // BASIC, or other scripting, the only thing that would use the C++/UNO bridge // functionality that invokes codeSnippet() was cppu::throwException(). @@ -208,7 +214,7 @@ void lo_mobile_throwException(css::uno::Any const& aException) assert(false); } -#endif // defined(IOS) || (defined(__aarch64__) && defined(ANDROID)) +#endif // RETHROW_FAKE_EXCEPTIONS } // anonymous namespace @@ -226,7 +232,7 @@ void SAL_CALL throwException( Any const & exc ) "(must be derived from com::sun::star::uno::Exception)!" ); } -#if defined(IOS) || (defined(__aarch64__) && defined(ANDROID)) +#if RETHROW_FAKE_EXCEPTIONS lo_mobile_throwException(exc); #else Mapping uno2cpp(Environment(UNO_LB_UNO), Environment::getCurrent()); @@ -243,13 +249,14 @@ void SAL_CALL throwException( Any const & exc ) ExceptionThrower::getCppuType() ); OSL_ASSERT( xThrower.is() ); xThrower->throwException( exc ); -#endif +#endif // !RETHROW_FAKE_EXCEPTIONS } Any SAL_CALL getCaughtException() { -#if defined(__aarch64__) && defined(ANDROID) + // why does this differ from RETHROW_FAKE_EXCEPTIONS? +#if (defined(__aarch64__) && defined(ANDROID)) || defined(EMSCRIPTEN) // FIXME This stuff works on 32bit ARM, let's use the shortcut only for // the 64bit ARM. return Any(); diff --git a/cppuhelper/source/paths.cxx b/cppuhelper/source/paths.cxx index 785fa452d30b..d2f37bb549a7 100644 --- a/cppuhelper/source/paths.cxx +++ b/cppuhelper/source/paths.cxx @@ -33,7 +33,7 @@ namespace { -#ifndef ANDROID +#if !(defined ANDROID || defined EMSCRIPTEN) OUString get_this_libpath() { static OUString s_uri = []() { OUString uri; @@ -52,7 +52,7 @@ OUString get_this_libpath() { } OUString cppu::getUnoIniUri() { -#if defined ANDROID +#if defined ANDROID || defined EMSCRIPTEN // Wouldn't it be lovely to avoid this ugly hard-coding. // The problem is that the 'create_bootstrap_macro_expander_factory()' // required for bootstrapping services, calls cppu::get_unorc directly