summaryrefslogtreecommitdiff
path: root/src/bin/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-08 14:14:49 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:18 +0100
commite0066ca9e7d7ad1c667d17d7d7a6e84f29f1a546 (patch)
treeb4ae3fb63c00356db169348621d8dde698e03938 /src/bin/elua
parentbf4837dbbfdb300372b9fe7a57378e580e4dad23 (diff)
elua: use elua_state_new/free
Diffstat (limited to 'src/bin/elua')
-rw-r--r--src/bin/elua/main.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/bin/elua/main.c b/src/bin/elua/main.c
index 3716a51984..7b63461522 100644
--- a/src/bin/elua/main.c
+++ b/src/bin/elua/main.c
@@ -269,37 +269,37 @@ elua_doscript(lua_State *L, int argc, char **argv, int n, int *quit)
269} 269}
270 270
271void 271void
272elua_bin_shutdown(lua_State *L, int c) 272elua_bin_shutdown(Elua_State *es, int c)
273{ 273{
274 void *data; 274 void *data;
275 INF("elua shutdown"); 275 INF("elua shutdown");
276 276
277 EINA_LIST_FREE(elua_modlist, data) 277 if (es) EINA_LIST_FREE(elua_modlist, data)
278 { 278 {
279 lua_rawgeti(L, LUA_REGISTRYINDEX, (size_t)data); 279 lua_rawgeti(es->luastate, LUA_REGISTRYINDEX, (size_t)data);
280 lua_call(L, 0, 0); 280 lua_call(es->luastate, 0, 0);
281 } 281 }
282 282
283 if (elua_prefix) eina_prefix_free(elua_prefix); 283 if (elua_prefix) eina_prefix_free(elua_prefix);
284 284
285 if (L) lua_close(L); 285 if (es) elua_state_free(es);
286 if (_el_log_domain != EINA_LOG_DOMAIN_GLOBAL) 286 if (_el_log_domain != EINA_LOG_DOMAIN_GLOBAL)
287 eina_log_domain_unregister(_el_log_domain); 287 eina_log_domain_unregister(_el_log_domain);
288 elua_shutdown(); 288 elua_shutdown();
289 exit(c); 289 exit(c);
290} 290}
291 291
292static int elua_cb_ref = LUA_REFNIL; 292static int elua_cb_ref = LUA_REFNIL;
293static lua_State *elua_state = NULL; 293static Elua_State *elua_state = NULL;
294 294
295static void 295static void
296elua_smart_cb_wrapper(void *data, void *obj EINA_UNUSED, void *einfo EINA_UNUSED) 296elua_smart_cb_wrapper(void *data, void *obj EINA_UNUSED, void *einfo EINA_UNUSED)
297{ 297{
298 int idx = (size_t)data; 298 int idx = (size_t)data;
299 lua_rawgeti(elua_state, LUA_REGISTRYINDEX, elua_cb_ref); 299 lua_rawgeti(elua_state->luastate, LUA_REGISTRYINDEX, elua_cb_ref);
300 lua_rawgeti(elua_state, -1, idx); 300 lua_rawgeti(elua_state->luastate, -1, idx);
301 lua_call(elua_state, 0, 0); 301 lua_call(elua_state->luastate, 0, 0);
302 lua_pop(elua_state, 1); 302 lua_pop(elua_state->luastate, 1);
303} 303}
304 304
305static int 305static int
@@ -530,7 +530,7 @@ int
530main(int argc, char **argv) 530main(int argc, char **argv)
531{ 531{
532 struct Main_Data m; 532 struct Main_Data m;
533 lua_State *L = NULL; 533 Elua_State *es = NULL;
534 534
535#ifdef ENABLE_NLS 535#ifdef ENABLE_NLS
536 setlocale(LC_ALL, ""); 536 setlocale(LC_ALL, "");
@@ -550,13 +550,13 @@ main(int argc, char **argv)
550 550
551 INF("elua logging initialized: %d", _el_log_domain); 551 INF("elua logging initialized: %d", _el_log_domain);
552 552
553 if (!(L = luaL_newstate())) 553 if (!(es = elua_state_new()))
554 { 554 {
555 ERR("could not initialize elua state."); 555 ERR("could not initialize elua state.");
556 elua_bin_shutdown(L, 1); 556 elua_bin_shutdown(es, 1);
557 } 557 }
558 558
559 elua_state = L; 559 elua_state = es;
560 560
561 INF("elua lua state created"); 561 INF("elua lua state created");
562 562
@@ -564,7 +564,7 @@ main(int argc, char **argv)
564 m.argv = argv; 564 m.argv = argv;
565 m.status = 0; 565 m.status = 0;
566 566
567 elua_bin_shutdown(L, !!(lua_cpcall(L, elua_main, &m) || m.status)); 567 elua_bin_shutdown(es, !!(lua_cpcall(es->luastate, elua_main, &m) || m.status));
568 568
569 return 0; /* never gets here */ 569 return 0; /* never gets here */
570} 570}