android: Avoid throwing exceptions through the bridges.
From some reason it does not work, so let's do the same we are doing on iOS; at least for now. Change-Id: I915f8683a112548fc3defc1114f9dce3aa7be30e Reviewed-on: https://gerrit.libreoffice.org/84067 Reviewed-by: Tor Lillqvist <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/84204 Tested-by: Jenkins Reviewed-by: Jan Holesovsky <kendy@collabora.com>
This commit is contained in:
@@ -457,10 +457,14 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
|
||||
void bridges::cpp_uno::shared::VtableFactory::flushCode(
|
||||
unsigned char const * begin, unsigned char const * end)
|
||||
{
|
||||
#ifndef ANDROID
|
||||
static void (*clear_cache)(unsigned char const *, unsigned char const *)
|
||||
= (void (*)(unsigned char const *, unsigned char const *)) dlsym(
|
||||
RTLD_DEFAULT, "__clear_cache");
|
||||
(*clear_cache)(begin, end);
|
||||
#else
|
||||
__builtin___clear_cache((char*)begin, (char*)end);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -15,6 +15,7 @@ $(eval $(call gb_Library_set_soversion_script,cppuhelper,$(SRCDIR)/cppuhelper/so
|
||||
$(eval $(call gb_Library_use_internal_comprehensive_api,cppuhelper,\
|
||||
cppuhelper \
|
||||
udkapi \
|
||||
offapi \
|
||||
))
|
||||
|
||||
$(eval $(call gb_Library_add_defs,cppuhelper,\
|
||||
|
||||
@@ -17,21 +17,22 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include <config_features.h>
|
||||
|
||||
#include <rtl/instance.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
#include <osl/doublecheckedlocking.h>
|
||||
#include <sal/log.hxx>
|
||||
#include <uno/dispatcher.hxx>
|
||||
#include <uno/lbnames.h>
|
||||
#include <uno/mapping.hxx>
|
||||
#include <cppuhelper/detail/XExceptionThrower.hpp>
|
||||
#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
|
||||
#include <com/sun/star/ucb/NameClashException.hpp>
|
||||
#include <com/sun/star/uno/RuntimeException.hpp>
|
||||
|
||||
#include <cppuhelper/exc_hlp.hxx>
|
||||
|
||||
#ifdef IOS
|
||||
#include <ios/ios.hxx>
|
||||
#endif
|
||||
|
||||
using namespace ::osl;
|
||||
using namespace ::cppu;
|
||||
using namespace ::com::sun::star;
|
||||
@@ -172,6 +173,46 @@ ExceptionThrower::ExceptionThrower()
|
||||
|
||||
class theExceptionThrower : public rtl::Static<ExceptionThrower, theExceptionThrower> {};
|
||||
|
||||
#if defined(IOS) || HAVE_FEATURE_ANDROID_LOK
|
||||
// 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().
|
||||
//
|
||||
// codeSnippet() is part of what corresponds to the code that uses
|
||||
// run-time-generated machine code on other platforms. We can't generate code
|
||||
// at run-time on iOS, that has been known forever.
|
||||
//
|
||||
// Instead of digging in and trying to understand what is wrong, another
|
||||
// solution was chosen. It turns out that the number of types of exception
|
||||
// objects thrown by cppu::throwException() is fairly small. During startup of
|
||||
// the LibreOffice code, and loading of an .odt document, only one kind of
|
||||
// exception is thrown this way... (The lovely
|
||||
// css::ucb:InteractiveAugmentedIOException.)
|
||||
//
|
||||
// So we can simply have code that checks what the type of object being thrown
|
||||
// is, and explicitgly throws such an object then with a normal C++ throw
|
||||
// statement. Seems to work.
|
||||
template <class E> void tryThrow(css::uno::Any const& aException)
|
||||
{
|
||||
E aSpecificException;
|
||||
if (aException >>= aSpecificException)
|
||||
throw aSpecificException;
|
||||
}
|
||||
|
||||
void lo_mobile_throwException(css::uno::Any const& aException)
|
||||
{
|
||||
assert(aException.getValueTypeClass() == css::uno::TypeClass_EXCEPTION);
|
||||
|
||||
tryThrow<css::ucb::InteractiveAugmentedIOException>(aException);
|
||||
tryThrow<css::ucb::NameClashException>(aException);
|
||||
tryThrow<css::uno::RuntimeException>(aException);
|
||||
|
||||
SAL_WARN("cppuhelper", "lo_mobile_throwException: Unhandled exception type: " << aException.getValueTypeName());
|
||||
|
||||
assert(false);
|
||||
}
|
||||
#endif // defined(IOS) || HAVE_FEATURE_ANDROID_LOK
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
@@ -188,8 +229,8 @@ void SAL_CALL throwException( Any const & exc )
|
||||
"(must be derived from com::sun::star::uno::Exception)!" );
|
||||
}
|
||||
|
||||
#ifdef IOS
|
||||
lo_ios_throwException(exc);
|
||||
#if defined(IOS) || HAVE_FEATURE_ANDROID_LOK
|
||||
lo_mobile_throwException(exc);
|
||||
#else
|
||||
Mapping uno2cpp(Environment(UNO_LB_UNO), Environment::getCurrent());
|
||||
if (! uno2cpp.is())
|
||||
@@ -211,6 +252,9 @@ void SAL_CALL throwException( Any const & exc )
|
||||
|
||||
Any SAL_CALL getCaughtException()
|
||||
{
|
||||
#if HAVE_FEATURE_ANDROID_LOK
|
||||
return Any();
|
||||
#else
|
||||
Mapping cpp2uno(Environment::getCurrent(), Environment(UNO_LB_UNO));
|
||||
if (! cpp2uno.is())
|
||||
{
|
||||
@@ -258,6 +302,7 @@ Any SAL_CALL getCaughtException()
|
||||
&ret, exc->pData, exc->pType, uno2cpp.get() );
|
||||
uno_any_destruct( exc, nullptr );
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_IOS_IOS_HXX
|
||||
#define INCLUDED_IOS_IOS_HXX
|
||||
|
||||
#include "com/sun/star/uno/Any.hxx"
|
||||
|
||||
extern void lo_ios_throwException(css::uno::Any const& aException);
|
||||
|
||||
#endif // INCLUDED_IOS_IOS_HXX
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -11,7 +11,6 @@ $(eval $(call gb_Module_Module,ios))
|
||||
ifeq ($(OS),iOS)
|
||||
|
||||
$(eval $(call gb_Module_add_targets,ios,\
|
||||
StaticLibrary_ios \
|
||||
CustomTarget_iOS_setup \
|
||||
))
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||
#
|
||||
# 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/.
|
||||
|
||||
$(eval $(call gb_StaticLibrary_StaticLibrary,ios))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_use_api,ios,\
|
||||
udkapi \
|
||||
offapi \
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_exception_objects,ios,\
|
||||
ios/source/ios \
|
||||
))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
@@ -1,42 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
||||
/*
|
||||
* 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 <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include "com/sun/star/uno/Any.hxx"
|
||||
#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
|
||||
#include "com/sun/star/ucb/NameClashException.hpp"
|
||||
#include "ios/ios.hxx"
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class E> void tryThrow(css::uno::Any const& aException)
|
||||
{
|
||||
E aSpecificException;
|
||||
if (aException >>= aSpecificException)
|
||||
throw aSpecificException;
|
||||
}
|
||||
}
|
||||
|
||||
void lo_ios_throwException(css::uno::Any const& aException)
|
||||
{
|
||||
assert(aException.getValueTypeClass() == css::uno::TypeClass_EXCEPTION);
|
||||
|
||||
tryThrow<css::ucb::InteractiveAugmentedIOException>(aException);
|
||||
tryThrow<css::ucb::NameClashException>(aException);
|
||||
tryThrow<css::uno::RuntimeException>(aException);
|
||||
|
||||
std::cerr << "lo_ios_throwException: Unhandled exception type " << aException.getValueTypeName()
|
||||
<< std::endl;
|
||||
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
Reference in New Issue
Block a user