summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2018-09-12 22:06:18 +0300
committerTor Lillqvist <tml@collabora.com>2018-09-15 07:54:03 +0200
commit7d6be61a62ca3724c67ab3fb93e60a2748d8a67e (patch)
tree732347351ca62a21f676d65cb659cc25269a841c /ios
parente005ab5d40d358adb75a64e140d46f4bf605647d (diff)
Re-think cppu::throwException() and the C++/UNO bridge on iOS
It seems that on iOS, 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 we have used some manually written assembler to handle it instead. We used to have a Perl script to generate a set of code snippets for different cases, different numbers of parameters of the called function and whatnot, but that went away at some stage some year ago. (It is unclear whether that broke the C++/UNO bridge on iOS, or whether the stuff continued to work even after that.) Anyway, this handwritten assembly, or the manual construction of internal data structures for exceptions, or something else, seemed to have bit-rotten. Exceptions thrown with cppu::throwException() were not catchable properly any longer. Instead of digging in and trying to understand what is wrong, I chose another solution. 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. Sadly the cppu::getCaughtException() API still needs some inline assembly in the C++/UNO brige. That seems to work though, knock on wood. This commit also adds a small "unit test" for iOS, copied from cppuhelperm to ImplSVMain(). Ideally we should not copy code around of course, but have a separate unit test app for iOS that would somehow include relevant unit tests from source files all over the place. Later. Change-Id: Ib6d9d5b6fb8cc684ec15c97a312ca2f720e87069 Reviewed-on: https://gerrit.libreoffice.org/60506 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'ios')
-rw-r--r--ios/Module_ios.mk1
-rw-r--r--ios/StaticLibrary_ios.mk20
-rw-r--r--ios/source/ios.cxx35
3 files changed, 56 insertions, 0 deletions
diff --git a/ios/Module_ios.mk b/ios/Module_ios.mk
index b70f48264a80..97823c9784f1 100644
--- a/ios/Module_ios.mk
+++ b/ios/Module_ios.mk
@@ -11,6 +11,7 @@ $(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
new file mode 100644
index 000000000000..36baff4e064b
--- /dev/null
+++ b/ios/StaticLibrary_ios.mk
@@ -0,0 +1,20 @@
+# -*- 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
new file mode 100644
index 000000000000..60b455d287ee
--- /dev/null
+++ b/ios/source/ios.cxx
@@ -0,0 +1,35 @@
+/* -*- 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 "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/ucb/InteractiveAugmentedIOException.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);
+
+ assert(false);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */