summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-10 17:10:08 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:20 +0100
commit02de415312b185aa79ef9cc4f80c7f98932579e6 (patch)
tree5587252c35c0e7aab2f2e23b7e1cdaaeeab86cab /src/bin
parent24a694026a77170d1e8b14b9d6b23411f0e832c5 (diff)
elua: cleanup main runtime
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elua/main.c40
1 files changed, 14 insertions, 26 deletions
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 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5/* The Lua runtime component of the EFL */
6
7#include <stdio.h> 5#include <stdio.h>
8#include <stdlib.h> 6#include <stdlib.h>
9#include <getopt.h> 7#include <getopt.h>
@@ -21,8 +19,7 @@
21 19
22#include "Elua.h" 20#include "Elua.h"
23 21
24static Elua_State *elua_state = NULL; 22static int _el_log_domain = -1;
25static int _el_log_domain = -1;
26 23
27#define DBG(...) EINA_LOG_DOM_DBG(_el_log_domain, __VA_ARGS__) 24#define DBG(...) EINA_LOG_DOM_DBG(_el_log_domain, __VA_ARGS__)
28#define INF(...) EINA_LOG_DOM_INFO(_el_log_domain, __VA_ARGS__) 25#define INF(...) EINA_LOG_DOM_INFO(_el_log_domain, __VA_ARGS__)
@@ -84,20 +81,19 @@ static struct option lopt[] =
84static int 81static int
85elua_main(lua_State *L) 82elua_main(lua_State *L)
86{ 83{
87 Eina_Bool noenv = EINA_FALSE, 84 Eina_Bool noenv = EINA_FALSE;
88 hasexec = EINA_FALSE;
89 Eina_List *largs = NULL; 85 Eina_List *largs = NULL;
90 const char *coredir = NULL, *moddir = NULL, *appsdir = NULL; 86 const char *coredir = NULL, *moddir = NULL, *appsdir = NULL;
91 char *data = NULL; 87 char *data = NULL;
92 88
93 int ch; 89 struct Main_Data *m = (struct Main_Data*)lua_touserdata(L, 1);
94 90 Elua_State *es = m->es;
95 struct Main_Data *m = (struct Main_Data*)lua_touserdata(L, 1);
96 Elua_State *es = m->es;
97 91
98 int argc = m->argc; 92 int argc = m->argc;
99 char **argv = m->argv; 93 char **argv = m->argv;
100 94
95 int ch;
96
101 while ((ch = getopt_long(argc, argv, "+LhC:M:A:l:I:E", lopt, NULL)) != -1) 97 while ((ch = getopt_long(argc, argv, "+LhC:M:A:l:I:E", lopt, NULL)) != -1)
102 { 98 {
103 switch (ch) 99 switch (ch)
@@ -140,32 +136,26 @@ elua_main(lua_State *L)
140 goto error; 136 goto error;
141 137
142 elua_io_register(es); 138 elua_io_register(es);
139
143 lua_gc(L, LUA_GCRESTART, 0); 140 lua_gc(L, LUA_GCRESTART, 0);
144 141
145 INF("elua lua state initialized"); 142 INF("elua lua state initialized");
146 143
147 /* load all the things */
148 EINA_LIST_FREE(largs, data) 144 EINA_LIST_FREE(largs, data)
149 { 145 if (elua_util_require(es, data)) goto error;
150 if (elua_util_require(es, data))
151 goto error;
152 }
153 146
154 /* run script or execute stdin as file */
155 if (optind < argc) 147 if (optind < argc)
156 { 148 {
157 int quit = 0; 149 int quit = 0;
158 if ((m->status = elua_util_script_run(es, argc, argv, optind, &quit))) 150 if (elua_util_script_run(es, argc, argv, optind, &quit))
151 goto error;
152 if (quit)
159 return 0; 153 return 0;
160 if (quit) return 0;
161 } 154 }
162 else if (!hasexec) 155 else
163 { 156 {
164 int quit; 157 ERR("nothing to run");
165 if ((m->status = elua_util_file_run(es, NULL))) return 0; 158 goto error;
166 quit = lua_toboolean(L, -1);
167 lua_pop(L, 1);
168 if (quit) return 0;
169 } 159 }
170 160
171 ecore_main_loop_begin(); 161 ecore_main_loop_begin();
@@ -208,8 +198,6 @@ main(int argc, char **argv)
208 elua_bin_shutdown(es, 1); 198 elua_bin_shutdown(es, 1);
209 } 199 }
210 200
211 elua_state = es;
212
213 INF("elua lua state created"); 201 INF("elua lua state created");
214 202
215 m.es = es; 203 m.es = es;