From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx | 93 ++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx (limited to 'bridges/source/cpp_uno/gcc3_wasm/uno2cpp.cxx') 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 0000000000..ddb51166b5 --- /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: */ -- cgit v1.2.3