[Libreoffice-commits] .: sal/cppunittester sal/inc sal/osl

Tor Lillqvist tml at kemper.freedesktop.org
Sat Jul 9 03:51:27 PDT 2011


 sal/cppunittester/makefile.mk |    4 ++
 sal/inc/sal/main.h            |   57 ++++++++++++++++++++++++++++++++++++++++++
 sal/osl/unx/salinit.cxx       |    1 
 3 files changed, 61 insertions(+), 1 deletion(-)

New commits:
commit 6b766372929f0b2fd5c0769074b72c5d045ac468
Author: Tor Lillqvist <tml at iki.fi>
Date:   Thu Jul 7 07:58:56 2011 +0300

    iOS hacking for cppunittester
    
    We don't need sal/main.h in salinit.cxx as far as I can see.
    
    Add stuff to sal/main.h so that we can link an iOS executable that
    actually will run, and hack the makefile so that cppunittester builds
    successfully.
    
    Of course, a cppunittester executable built here won't be usable for
    anything interesting as we don't build any dynamic libraries of
    LibreOffice code for iOS, so there is nothing to pass on the command
    line to load. But hey, baby steps, experimentation, doing work in the
    public, commit often, etc...

diff --git a/sal/cppunittester/makefile.mk b/sal/cppunittester/makefile.mk
index 938b63d..7c43bab 100644
--- a/sal/cppunittester/makefile.mk
+++ b/sal/cppunittester/makefile.mk
@@ -35,6 +35,10 @@ ENABLE_EXCEPTIONS = TRUE
 
 CFLAGSCXX += $(CPPUNIT_CFLAGS)
 
+.IF "$(OS)" == "IOS"
+CFLAGSCXX += -x objective-c++ -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40300
+.ENDIF
+
 OBJFILES = $(APP1OBJS)
 
 APP1OBJS = $(OBJ)/cppunittester.obj
diff --git a/sal/inc/sal/main.h b/sal/inc/sal/main.h
index bf7a828..190aaed 100644
--- a/sal/inc/sal/main.h
+++ b/sal/inc/sal/main.h
@@ -41,6 +41,60 @@ extern "C" {
 void SAL_CALL sal_detail_initialize(int argc, char ** argv);
 void SAL_CALL sal_detail_deinitialize();
 
+#ifdef IOS
+
+#include <premac.h>
+#import <UIKit/UIKit.h>
+#include <postmac.h>
+
+static int sal_argc;
+static char **sal_argv;
+
+#define SAL_MAIN_WITH_ARGS_IMPL \
+int SAL_CALL main(int argc, char ** argv) \
+{ \
+    sal_argc = argc; \
+    sal_argv = argv; \
+    sal_detail_initialize(argc, argv);   \
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; \
+    int retVal = UIApplicationMain (argc, argv, @"UIApplication", @"salAppDelegate"); \
+ \
+    [pool release]; \
+ \
+    sal_detail_deinitialize(); \
+    return retVal; \
+}
+
+#define SAL_MAIN_IMPL \
+SAL_MAIN_WITH_ARGS_IMPL \
+ \
+int \
+sal_main_with_args(int argc, char ** argv) \
+{ \
+    return sal_main(); \
+}
+
+ at interface salAppDelegate : NSObject <UIApplicationDelegate> {
+}
+ at end
+
+int sal_main_with_args(int argc, char **argv);
+
+ at implementation salAppDelegate
+
+- (BOOL)application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions
+{
+  UIWindow *uiw = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+  uiw.backgroundColor = [UIColor redColor];
+  [uiw release];
+
+  sal_main_with_args(sal_argc, sal_argv);
+}
+
+ at end
+
+#else
+
 #define SAL_MAIN_WITH_ARGS_IMPL \
 int SAL_CALL main(int argc, char ** argv) \
 { \
@@ -61,6 +115,9 @@ int SAL_CALL main(int argc, char ** argv) \
     return ret; \
 }
 
+#endif
+
+
 /* Definition macros for CRT entries */
 
 #ifdef SAL_W32
diff --git a/sal/osl/unx/salinit.cxx b/sal/osl/unx/salinit.cxx
index dd12d2f..9503443 100644
--- a/sal/osl/unx/salinit.cxx
+++ b/sal/osl/unx/salinit.cxx
@@ -30,7 +30,6 @@
 #include "sal/config.h"
 
 #include "osl/process.h"
-#include "sal/main.h"
 #include "sal/types.h"
 
 extern "C" {


More information about the Libreoffice-commits mailing list