From 1e301dd23a0f3957274dd72d3bd3b2aab7291342 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 14 Jul 2011 11:19:15 +0300 Subject: iOS hacking, intermediate commit --- sal/inc/sal/main.h | 58 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/sal/inc/sal/main.h b/sal/inc/sal/main.h index 3ddfe0f38..370cba4db 100644 --- a/sal/inc/sal/main.h +++ b/sal/inc/sal/main.h @@ -47,31 +47,46 @@ void SAL_CALL sal_detail_deinitialize(); #import #include -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; \ +} \ + \ +static int sal_main_with_args(int argc, char **argv); \ + \ +static int \ +sal_main(void) \ +{ \ + char *argv[] = { NULL }; \ + return sal_main_with_args(0, argv); \ } #define SAL_MAIN_IMPL \ -SAL_MAIN_WITH_ARGS_IMPL \ - \ -static int \ -sal_main_with_args(int argc, char ** argv) \ +int SAL_CALL main(int argc, char ** argv) \ { \ - return sal_main(); \ + 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_WITH_GUI_IMPL \ +int SAL_CALL main(int argc, char ** argv) \ +{ \ + sal_detail_initialize(argc, argv); \ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; \ + int retVal = sal_main(); \ + [pool release]; \ + sal_detail_deinitialize(); \ + return retVal; \ } @interface salAppDelegate : NSObject { @@ -79,7 +94,7 @@ sal_main_with_args(int argc, char ** argv) \ @property (nonatomic, retain) UIWindow *window; @end -static int sal_main_with_args(int argc, char **argv); +static int sal_main(void); @implementation salAppDelegate @@ -92,7 +107,7 @@ static int sal_main_with_args(int argc, char **argv); self.window = uiw; [uiw release]; - sal_main_with_args(sal_argc, sal_argv); + sal_main(); [self.window makeKeyAndVisible]; return YES; @@ -122,6 +137,8 @@ int SAL_CALL main(int argc, char ** argv) \ return ret; \ } +#define SAL_MAIN_WITH_GUI_IMPL SAL_MAIN_IMPL + #endif @@ -182,6 +199,19 @@ int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nsh SAL_WIN_WinMain \ static int SAL_CALL sal_main(void) +/* Use SAL_IMPLEMENT_MAIN_WITH_GUI in programs that actually have a + * VCL GUI. The difference is meaningful only for iOS support, which + * of course is a highly experimental work in progress. So actually, + * don't bother, just let developers who care for iOS take care of it + * when/if necessary. + */ + +#define SAL_IMPLEMENT_MAIN_WITH_GUI() \ + static int SAL_CALL sal_main(void); \ + SAL_MAIN_WITH_GUI_IMPL \ + SAL_WIN_WinMain \ + static int SAL_CALL sal_main(void) + /* "How to use" Examples: -- cgit v1.2.3