summaryrefslogtreecommitdiff
path: root/src/lib/elua/elua.c
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-10 17:04:07 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:20 +0100
commit24a694026a77170d1e8b14b9d6b23411f0e832c5 (patch)
treee56970009968e979014958314f846e76685c49a0 /src/lib/elua/elua.c
parent8041b042fe8e105fd82dee860a8a91b822307915 (diff)
elua lib: add elua_state_setup_modules + use
Diffstat (limited to 'src/lib/elua/elua.c')
-rw-r--r--src/lib/elua/elua.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index 3bda98b30f..c124b20afc 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -295,9 +295,9 @@ elua_state_setup_i18n(const Elua_State *es)
295 EINA_SAFETY_ON_NULL_RETURN_VAL(es, EINA_FALSE); 295 EINA_SAFETY_ON_NULL_RETURN_VAL(es, EINA_FALSE);
296 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, EINA_FALSE); 296 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, EINA_FALSE);
297 EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE); 297 EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE);
298 EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE);
298 snprintf(buf, sizeof(buf), "%s/gettext.lua", es->coredir); 299 snprintf(buf, sizeof(buf), "%s/gettext.lua", es->coredir);
299 if (elua_report_error(es, elua_state_prog_name_get(es), 300 if (elua_report_error(es, es->progname, elua_io_loadfile(es, buf)))
300 elua_io_loadfile(es, buf)))
301 return EINA_FALSE; 301 return EINA_FALSE;
302 lua_createtable(es->luastate, 0, 0); 302 lua_createtable(es->luastate, 0, 0);
303 luaL_register(es->luastate, NULL, gettextlib); 303 luaL_register(es->luastate, NULL, gettextlib);
@@ -311,6 +311,31 @@ elua_state_setup_i18n(const Elua_State *es)
311 return EINA_TRUE; 311 return EINA_TRUE;
312} 312}
313 313
314const luaL_reg _elua_cutillib[] =
315{
316 { "init_module", elua_module_init },
317 { "popenv" , elua_io_popen },
318 { NULL , NULL }
319};
320
321EAPI Eina_Bool
322elua_state_setup_modules(const Elua_State *es)
323{
324 char buf[PATH_MAX];
325 EINA_SAFETY_ON_NULL_RETURN_VAL(es, EINA_FALSE);
326 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, EINA_FALSE);
327 EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE);
328 EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE);
329 snprintf(buf, sizeof(buf), "%s/module.lua", es->coredir);
330 if (elua_report_error(es, es->progname, elua_io_loadfile(es, buf)))
331 return EINA_FALSE;
332 lua_pushcfunction(es->luastate, elua_module_system_init);
333 lua_createtable(es->luastate, 0, 0);
334 luaL_register(es->luastate, NULL, _elua_cutillib);
335 lua_call(es->luastate, 2, 0);
336 return EINA_TRUE;
337}
338
314EAPI int 339EAPI int
315elua_module_init(lua_State *L) 340elua_module_init(lua_State *L)
316{ 341{