mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
ui/app,cmd/gio: move running of main from driver to GioAppDelegate
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -139,11 +139,8 @@ func exeIOS(tmpDir, target, app string, bi *buildInfo) error {
|
||||
const mainmSrc = `@import UIKit;
|
||||
@import Gio;
|
||||
|
||||
void gio_runMain(void);
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
@autoreleasepool {
|
||||
gio_runMain();
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([GioAppDelegate class]));
|
||||
}
|
||||
}`
|
||||
|
||||
@@ -34,6 +34,8 @@ static void redraw(CFTypeRef viewRef, BOOL sync) {
|
||||
|
||||
@implementation GioAppDelegate
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
gio_runMain();
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
GioViewController *controller = [[GioViewController alloc] initWithNibName:nil bundle:nil];
|
||||
controller.screen = self.window.screen;
|
||||
|
||||
+9
-4
@@ -7,16 +7,21 @@ package app
|
||||
// library mode. To make Gio programs simpler and uniform, we'll
|
||||
// link to the main function here and call it from Java.
|
||||
|
||||
import _ "unsafe" // for go:linkname
|
||||
import (
|
||||
"sync"
|
||||
_ "unsafe" // for go:linkname
|
||||
)
|
||||
|
||||
//go:linkname mainMain main.main
|
||||
func mainMain()
|
||||
|
||||
var runMainOnce sync.Once
|
||||
|
||||
func runMain() {
|
||||
go func() {
|
||||
runMainOnce.Do(func() {
|
||||
// Indirect call, since the linker does not know the address of main when
|
||||
// laying down this package.
|
||||
fn := mainMain
|
||||
fn()
|
||||
}()
|
||||
go fn()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user