bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx |    4 +
 cppuhelper/Library_cppuhelper.mk                      |    1 
 cppuhelper/source/exc_thrower.cxx                     |   57 ++++++++++++++++--
 include/ios/ios.hxx                                   |   19 ------
 ios/Module_ios.mk                                     |    1 
 ios/StaticLibrary_ios.mk                              |   20 ------
 ios/source/ios.cxx                                    |   42 -------------
 7 files changed, 56 insertions(+), 88 deletions(-)

New commits:
commit eb15ac837e06087fb8148330e9171d6697d89ee6
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Fri Nov 29 16:03:27 2019 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Thu Dec 5 11:02:01 2019 +0100

    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 <t...@collabora.com>
    Tested-by: Tor Lillqvist <t...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/84204
    Tested-by: Jenkins
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx 
b/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx
index aaf48deb67ca..d11a11b0c965 100644
--- a/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx
@@ -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: */
diff --git a/cppuhelper/Library_cppuhelper.mk b/cppuhelper/Library_cppuhelper.mk
index 67413f711cd2..5741eea6476f 100644
--- a/cppuhelper/Library_cppuhelper.mk
+++ b/cppuhelper/Library_cppuhelper.mk
@@ -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,\
diff --git a/cppuhelper/source/exc_thrower.cxx 
b/cppuhelper/source/exc_thrower.cxx
index 5e029feae982..a0e7fb32b046 100644
--- a/cppuhelper/source/exc_thrower.cxx
+++ b/cppuhelper/source/exc_thrower.cxx
@@ -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
 }
 
 }
diff --git a/include/ios/ios.hxx b/include/ios/ios.hxx
deleted file mode 100644
index d8fe4d7bd6e1..000000000000
--- a/include/ios/ios.hxx
+++ /dev/null
@@ -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: */
diff --git a/ios/Module_ios.mk b/ios/Module_ios.mk
index ea9c44644f2c..259c34ba3416 100644
--- a/ios/Module_ios.mk
+++ b/ios/Module_ios.mk
@@ -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 \
 ))
 
diff --git a/ios/StaticLibrary_ios.mk b/ios/StaticLibrary_ios.mk
deleted file mode 100644
index 36baff4e064b..000000000000
--- a/ios/StaticLibrary_ios.mk
+++ /dev/null
@@ -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:
diff --git a/ios/source/ios.cxx b/ios/source/ios.cxx
deleted file mode 100644
index bc89150e7ed6..000000000000
--- a/ios/source/ios.cxx
+++ /dev/null
@@ -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: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to