lib/app: move stuff from `App::init` to a new function, `App::sepup`
authorJean Privat <jean@pryen.org>
Mon, 9 Jun 2014 14:03:20 +0000 (10:03 -0400)
committerJean Privat <jean@pryen.org>
Tue, 10 Jun 2014 15:55:19 +0000 (11:55 -0400)
Because of the `app` method is a `once new App`, the result of the `new`
is not stored until the `new` returns.
Therefore, suggests to doing stuff during the construction of App might
invoke something that use `app` as a global symbol, thus causing an
infinite recursions.

lib/android/native_app_glue.nit
lib/app.nit
lib/mnit_linux/linux_app.nit
lib/mnit_linux/linux_assets.nit

index 8b622f3..6090450 100644 (file)
@@ -123,7 +123,7 @@ extern class NativeActivity in "Java" `{ android.app.NativeActivity `}
 end
 
 redef class App
-       redef init
+       redef fun setup
        do
                var native_app_glue = native_app_glue
                native_app_glue.user_data = self
index bd74daa..3e2d737 100644 (file)
@@ -27,6 +27,10 @@ module app
 class App
        protected init do end
 
+       # Starts the internal setup of graphical and other stuff
+       # Is called just before run
+       protected fun setup do end
+
        # Main entry point of your application
        fun run do end
 
@@ -49,4 +53,5 @@ class App
 end
 
 protected fun app: App do return once new App
+app.setup
 app.run
index 5534d5a..4b599ed 100644 (file)
@@ -29,7 +29,7 @@ redef class App
        redef type D: Opengles1Display
        redef type I: Opengles1Image
 
-       redef init
+       redef fun setup
        do
                display = new Opengles1Display
 
index 9247991..2c75bb5 100644 (file)
@@ -22,7 +22,7 @@ import linux_app
 redef class App
        var assets_dir: String
 
-       redef init
+       redef fun setup
        do
                assets_dir = sys.program_name.dirname + "/../assets/"