summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-04-23 16:02:58 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:23 +0100
commit88faba813c7c0369f4e5c1fd521d41f439c8cfe0 (patch)
treebcc02a18a15b7c1aea45b532023d93b2dfbe9e7b /src/bin
parent0d8b38a2acd8fc52a87826f30f56d025794ecf21 (diff)
elua lib: merge the 3 setup funcs into one
This allows simpler initialization and elua_util_require can now queue up modules before full initialization is done.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elua/main.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/bin/elua/main.c b/src/bin/elua/main.c
index c24951c64c..6b55120067 100644
--- a/src/bin/elua/main.c
+++ b/src/bin/elua/main.c
@@ -54,9 +54,7 @@ static int
54elua_main(lua_State *L) 54elua_main(lua_State *L)
55{ 55{
56 Eina_Bool noenv = EINA_FALSE; 56 Eina_Bool noenv = EINA_FALSE;
57 Eina_List *largs = NULL;
58 const char *coredir = NULL, *moddir = NULL, *appsdir = NULL; 57 const char *coredir = NULL, *moddir = NULL, *appsdir = NULL;
59 char *data = NULL;
60 58
61 struct Main_Data *m = (struct Main_Data*)lua_touserdata(L, 1); 59 struct Main_Data *m = (struct Main_Data*)lua_touserdata(L, 1);
62 Elua_State *es = m->es; 60 Elua_State *es = m->es;
@@ -70,7 +68,7 @@ elua_main(lua_State *L)
70 switch (ch) 68 switch (ch)
71 { 69 {
72 case 'h': 70 case 'h':
73 elua_print_help(elua_state_prog_name_get(es), stdout); goto success; 71 elua_print_help(elua_state_prog_name_get(es), stdout); return 0;
74 case 'C': 72 case 'C':
75 coredir = optarg; break; 73 coredir = optarg; break;
76 case 'M': 74 case 'M':
@@ -81,7 +79,7 @@ elua_main(lua_State *L)
81 case 'I': 79 case 'I':
82 if (!optarg[0]) continue; 80 if (!optarg[0]) continue;
83 if (ch == 'l') 81 if (ch == 'l')
84 largs = eina_list_append(largs, optarg); 82 elua_util_require(es, optarg);
85 else 83 else
86 elua_state_include_path_add(es, optarg); 84 elua_state_include_path_add(es, optarg);
87 break; 85 break;
@@ -96,39 +94,36 @@ elua_main(lua_State *L)
96 elua_state_dirs_set(es, coredir, moddir, appsdir); 94 elua_state_dirs_set(es, coredir, moddir, appsdir);
97 elua_state_dirs_fill(es, noenv); 95 elua_state_dirs_fill(es, noenv);
98 96
99 if (!elua_state_modules_setup(es) || !elua_state_i18n_setup(es) 97 if (!elua_state_setup(es))
100 || !elua_state_io_setup(es)) 98 {
101 goto error; 99 m->status = 1;
100 return 0;
101 }
102 102
103 lua_gc(L, LUA_GCRESTART, 0); 103 lua_gc(L, LUA_GCRESTART, 0);
104 104
105 INF("elua lua state initialized"); 105 INF("elua lua state initialized");
106 106
107 EINA_LIST_FREE(largs, data)
108 if (elua_util_require(es, data)) goto error;
109
110 if (optind < argc) 107 if (optind < argc)
111 { 108 {
112 int quit = 0; 109 int quit = 0;
113 if (elua_util_script_run(es, argc, argv, optind, &quit)) 110 if (elua_util_script_run(es, argc, argv, optind, &quit))
114 goto error; 111 {
112 m->status = 1;
113 return 0;
114 }
115 if (quit) 115 if (quit)
116 goto success; 116 return 0;
117 } 117 }
118 else 118 else
119 { 119 {
120 ERR("nothing to run"); 120 ERR("nothing to run");
121 goto error; 121 m->status = 1;
122 return 0;
122 } 123 }
123 124
124 ecore_main_loop_begin(); 125 ecore_main_loop_begin();
125 126
126 goto success;
127
128error:
129 m->status = 1;
130success:
131 if (largs) eina_list_free(largs);
132 return 0; 127 return 0;
133} 128}
134 129