summaryrefslogtreecommitdiff
path: root/src/lib/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-13 16:21:25 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:20 +0100
commitd8890209afc702643e1a066279eb8eda09b1119b (patch)
treeadaa6f3d66dbffff87e637eb750455ff9ef3cb39 /src/lib/elua
parenteea537ded38c546d5c3500c711e5f6d61c968355 (diff)
elua lib: unify API conventions
Diffstat (limited to 'src/lib/elua')
-rw-r--r--src/lib/elua/Elua.h10
-rw-r--r--src/lib/elua/cache.c7
-rw-r--r--src/lib/elua/elua.c18
3 files changed, 18 insertions, 17 deletions
diff --git a/src/lib/elua/Elua.h b/src/lib/elua/Elua.h
index e9bd6eeee9..8d00e67464 100644
--- a/src/lib/elua/Elua.h
+++ b/src/lib/elua/Elua.h
@@ -87,15 +87,15 @@ EAPI Eina_Bool elua_state_appload_ref_push(Elua_State *es);
87 87
88EAPI lua_State *elua_state_lua_state_get(const Elua_State *es); 88EAPI lua_State *elua_state_lua_state_get(const Elua_State *es);
89 89
90EAPI int elua_report_error(const Elua_State *es, const char *pname, int status); 90EAPI int elua_error_report(const Elua_State *es, const char *pname, int status);
91 91
92EAPI Eina_Bool elua_state_setup_i18n(const Elua_State *es); 92EAPI Eina_Bool elua_state_i18n_setup(const Elua_State *es);
93EAPI Eina_Bool elua_state_setup_modules(const Elua_State *es); 93EAPI Eina_Bool elua_state_modules_setup(const Elua_State *es);
94EAPI Eina_Bool elua_state_io_setup(const Elua_State *es);
94 95
95EAPI int elua_io_loadfile(const Elua_State *es, const char *fname); 96EAPI int elua_io_loadfile(const Elua_State *es, const char *fname);
96EAPI void elua_io_register(const Elua_State *es);
97
98EAPI int elua_io_popen(lua_State *L); 97EAPI int elua_io_popen(lua_State *L);
98
99EAPI int elua_module_init(lua_State *L); 99EAPI int elua_module_init(lua_State *L);
100EAPI int elua_module_system_init(lua_State *L); 100EAPI int elua_module_system_init(lua_State *L);
101 101
diff --git a/src/lib/elua/cache.c b/src/lib/elua/cache.c
index 8cd1617f61..ae5cf93716 100644
--- a/src/lib/elua/cache.c
+++ b/src/lib/elua/cache.c
@@ -208,10 +208,11 @@ loadfile(lua_State *L)
208 return 2; 208 return 2;
209} 209}
210 210
211EAPI void 211EAPI Eina_Bool
212elua_io_register(const Elua_State *es) 212elua_state_io_setup(const Elua_State *es)
213{ 213{
214 EINA_SAFETY_ON_FALSE_RETURN(es && es->luastate); 214 EINA_SAFETY_ON_FALSE_RETURN_VAL(es && es->luastate, EINA_FALSE);
215 lua_pushcfunction(es->luastate, loadfile); 215 lua_pushcfunction(es->luastate, loadfile);
216 lua_setglobal(es->luastate, "loadfile"); 216 lua_setglobal(es->luastate, "loadfile");
217 return EINA_TRUE;
217} 218}
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index c124b20afc..0207681947 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -237,7 +237,7 @@ _elua_errmsg(const char *pname, const char *msg)
237} 237}
238 238
239EAPI int 239EAPI int
240elua_report_error(const Elua_State *es, const char *pname, int status) 240elua_error_report(const Elua_State *es, const char *pname, int status)
241{ 241{
242 EINA_SAFETY_ON_FALSE_RETURN_VAL(es && es->luastate, status); 242 EINA_SAFETY_ON_FALSE_RETURN_VAL(es && es->luastate, status);
243 if (status && !lua_isnil(es->luastate, -1)) 243 if (status && !lua_isnil(es->luastate, -1))
@@ -284,7 +284,7 @@ const luaL_reg gettextlib[] =
284}; 284};
285 285
286EAPI Eina_Bool 286EAPI Eina_Bool
287elua_state_setup_i18n(const Elua_State *es) 287elua_state_i18n_setup(const Elua_State *es)
288{ 288{
289#ifdef ENABLE_NLS 289#ifdef ENABLE_NLS
290 char *(*dgettextp)(const char*, const char*) = dgettext; 290 char *(*dgettextp)(const char*, const char*) = dgettext;
@@ -297,7 +297,7 @@ elua_state_setup_i18n(const Elua_State *es)
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 EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE);
299 snprintf(buf, sizeof(buf), "%s/gettext.lua", es->coredir); 299 snprintf(buf, sizeof(buf), "%s/gettext.lua", es->coredir);
300 if (elua_report_error(es, es->progname, elua_io_loadfile(es, buf))) 300 if (elua_error_report(es, es->progname, 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);
@@ -319,7 +319,7 @@ const luaL_reg _elua_cutillib[] =
319}; 319};
320 320
321EAPI Eina_Bool 321EAPI Eina_Bool
322elua_state_setup_modules(const Elua_State *es) 322elua_state_modules_setup(const Elua_State *es)
323{ 323{
324 char buf[PATH_MAX]; 324 char buf[PATH_MAX];
325 EINA_SAFETY_ON_NULL_RETURN_VAL(es, EINA_FALSE); 325 EINA_SAFETY_ON_NULL_RETURN_VAL(es, EINA_FALSE);
@@ -327,7 +327,7 @@ elua_state_setup_modules(const Elua_State *es)
327 EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE); 327 EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE);
328 EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE); 328 EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE);
329 snprintf(buf, sizeof(buf), "%s/module.lua", es->coredir); 329 snprintf(buf, sizeof(buf), "%s/module.lua", es->coredir);
330 if (elua_report_error(es, es->progname, elua_io_loadfile(es, buf))) 330 if (elua_error_report(es, es->progname, elua_io_loadfile(es, buf)))
331 return EINA_FALSE; 331 return EINA_FALSE;
332 lua_pushcfunction(es->luastate, elua_module_system_init); 332 lua_pushcfunction(es->luastate, elua_module_system_init);
333 lua_createtable(es->luastate, 0, 0); 333 lua_createtable(es->luastate, 0, 0);
@@ -453,7 +453,7 @@ elua_util_require(Elua_State *es, const char *libname)
453 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); 453 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1);
454 EINA_SAFETY_ON_FALSE_RETURN_VAL(elua_state_require_ref_push(es), -1); 454 EINA_SAFETY_ON_FALSE_RETURN_VAL(elua_state_require_ref_push(es), -1);
455 lua_pushstring(es->luastate, libname); 455 lua_pushstring(es->luastate, libname);
456 return elua_report_error(es, es->progname, 456 return elua_error_report(es, es->progname,
457 lua_pcall(es->luastate, 1, 0, 0)); 457 lua_pcall(es->luastate, 1, 0, 0));
458} 458}
459 459
@@ -462,7 +462,7 @@ elua_util_file_run(Elua_State *es, const char *fname)
462{ 462{
463 EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1); 463 EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1);
464 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); 464 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1);
465 return elua_report_error(es, es->progname, 465 return elua_error_report(es, es->progname,
466 elua_io_loadfile(es, fname) 466 elua_io_loadfile(es, fname)
467 || _elua_docall(es, 0, 1)); 467 || _elua_docall(es, 0, 1));
468} 468}
@@ -472,7 +472,7 @@ elua_util_string_run(Elua_State *es, const char *chunk, const char *chname)
472{ 472{
473 EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1); 473 EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1);
474 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); 474 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1);
475 return elua_report_error(es, es->progname, 475 return elua_error_report(es, es->progname,
476 luaL_loadbuffer(es->luastate, chunk, strlen(chunk), 476 luaL_loadbuffer(es->luastate, chunk, strlen(chunk),
477 chname) 477 chname)
478 || _elua_docall(es, 0, 0)); 478 || _elua_docall(es, 0, 0));
@@ -531,5 +531,5 @@ elua_util_script_run(Elua_State *es, int argc, char **argv, int n, int *quit)
531 *quit = lua_toboolean(es->luastate, -1); 531 *quit = lua_toboolean(es->luastate, -1);
532 lua_pop(es->luastate, 1); 532 lua_pop(es->luastate, 1);
533 } 533 }
534 return elua_report_error(es, es->progname, status); 534 return elua_error_report(es, es->progname, status);
535} 535}