From: Daniel Kolesa Date: Fri, 10 Apr 2015 16:10:08 +0000 (+0100) Subject: elua: cleanup main runtime X-Git-Tag: v1.15.0-alpha1~752^2~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02de415312b185aa79ef9cc4f80c7f98932579e6;p=platform%2Fupstream%2Fefl.git elua: cleanup main runtime --- diff --git a/src/bin/elua/main.c b/src/bin/elua/main.c index 062ddf678f..be4748653d 100644 --- a/src/bin/elua/main.c +++ b/src/bin/elua/main.c @@ -2,8 +2,6 @@ # include #endif -/* The Lua runtime component of the EFL */ - #include #include #include @@ -21,8 +19,7 @@ #include "Elua.h" -static Elua_State *elua_state = NULL; -static int _el_log_domain = -1; +static int _el_log_domain = -1; #define DBG(...) EINA_LOG_DOM_DBG(_el_log_domain, __VA_ARGS__) #define INF(...) EINA_LOG_DOM_INFO(_el_log_domain, __VA_ARGS__) @@ -84,20 +81,19 @@ static struct option lopt[] = static int elua_main(lua_State *L) { - Eina_Bool noenv = EINA_FALSE, - hasexec = EINA_FALSE; + Eina_Bool noenv = EINA_FALSE; Eina_List *largs = NULL; const char *coredir = NULL, *moddir = NULL, *appsdir = NULL; char *data = NULL; - int ch; - - struct Main_Data *m = (struct Main_Data*)lua_touserdata(L, 1); - Elua_State *es = m->es; + struct Main_Data *m = (struct Main_Data*)lua_touserdata(L, 1); + Elua_State *es = m->es; int argc = m->argc; char **argv = m->argv; + int ch; + while ((ch = getopt_long(argc, argv, "+LhC:M:A:l:I:E", lopt, NULL)) != -1) { switch (ch) @@ -140,32 +136,26 @@ elua_main(lua_State *L) goto error; elua_io_register(es); + lua_gc(L, LUA_GCRESTART, 0); INF("elua lua state initialized"); - /* load all the things */ EINA_LIST_FREE(largs, data) - { - if (elua_util_require(es, data)) - goto error; - } + if (elua_util_require(es, data)) goto error; - /* run script or execute stdin as file */ if (optind < argc) { int quit = 0; - if ((m->status = elua_util_script_run(es, argc, argv, optind, &quit))) + if (elua_util_script_run(es, argc, argv, optind, &quit)) + goto error; + if (quit) return 0; - if (quit) return 0; } - else if (!hasexec) + else { - int quit; - if ((m->status = elua_util_file_run(es, NULL))) return 0; - quit = lua_toboolean(L, -1); - lua_pop(L, 1); - if (quit) return 0; + ERR("nothing to run"); + goto error; } ecore_main_loop_begin(); @@ -208,8 +198,6 @@ main(int argc, char **argv) elua_bin_shutdown(es, 1); } - elua_state = es; - INF("elua lua state created"); m.es = es;