diff options
author | Daniel Kolesa <d.kolesa@samsung.com> | 2015-04-14 16:14:51 +0100 |
---|---|---|
committer | Daniel Kolesa <d.kolesa@osg.samsung.com> | 2015-05-06 15:05:20 +0100 |
commit | 7f05cfc0e6795f4dee66c0b9175c658f40d14ab4 (patch) | |
tree | ac2a7b06b9e0f0c35f4ffe186582bdbb7b93da1d | |
parent | f8f9cc14a798a4e760e09c6c3a2d54eea02e40ee (diff) | |
download | efl-7f05cfc0e6795f4dee66c0b9175c658f40d14ab4.tar.gz |
elua lib: error_report is now in util namespace
-rw-r--r-- | src/lib/elua/Elua.h | 5 | ||||
-rw-r--r-- | src/lib/elua/elua.c | 50 |
2 files changed, 28 insertions, 27 deletions
diff --git a/src/lib/elua/Elua.h b/src/lib/elua/Elua.h index 1d45e1c5cb..880c7736a2 100644 --- a/src/lib/elua/Elua.h +++ b/src/lib/elua/Elua.h @@ -87,8 +87,6 @@ EAPI Eina_Bool elua_state_appload_ref_push(Elua_State *es); EAPI lua_State *elua_state_lua_state_get(const Elua_State *es); -EAPI int elua_error_report(const Elua_State *es, const char *pname, int status); - EAPI Eina_Bool elua_state_i18n_setup(const Elua_State *es); EAPI Eina_Bool elua_state_modules_setup(const Elua_State *es); EAPI Eina_Bool elua_state_io_setup(const Elua_State *es); @@ -107,6 +105,9 @@ EAPI Eina_Bool elua_util_app_load(Elua_State *es, const char *appname); EAPI int elua_util_script_run(Elua_State *es, int argc, char **argv, int n, int *quit); +EAPI int elua_util_error_report(const Elua_State *es, const char *pname, + int status); + #endif #ifdef __cplusplus diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c index 229eb65a12..799dd07ee2 100644 --- a/src/lib/elua/elua.c +++ b/src/lib/elua/elua.c @@ -230,25 +230,6 @@ elua_state_from_lua_state_get(lua_State *L) return NULL; } -static void -_elua_errmsg(const char *pname, const char *msg) -{ - ERR("%s%s%s", pname ? pname : "", pname ? ": " : "", msg); -} - -EAPI int -elua_error_report(const Elua_State *es, const char *pname, int status) -{ - EINA_SAFETY_ON_FALSE_RETURN_VAL(es && es->luastate, status); - if (status && !lua_isnil(es->luastate, -1)) - { - const char *msg = lua_tostring(es->luastate, -1); - _elua_errmsg(pname, msg ? msg : "(non-string error)"); - lua_pop(es->luastate, 1); - } - return status; -} - static int _elua_gettext_bind_textdomain(lua_State *L) { @@ -297,7 +278,7 @@ elua_state_i18n_setup(const Elua_State *es) EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE); snprintf(buf, sizeof(buf), "%s/gettext.lua", es->coredir); - if (elua_error_report(es, es->progname, elua_io_loadfile(es, buf))) + if (elua_util_error_report(es, es->progname, elua_io_loadfile(es, buf))) return EINA_FALSE; lua_createtable(es->luastate, 0, 0); luaL_register(es->luastate, NULL, gettextlib); @@ -327,7 +308,7 @@ elua_state_modules_setup(const Elua_State *es) EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE); snprintf(buf, sizeof(buf), "%s/module.lua", es->coredir); - if (elua_error_report(es, es->progname, elua_io_loadfile(es, buf))) + if (elua_util_error_report(es, es->progname, elua_io_loadfile(es, buf))) return EINA_FALSE; lua_pushcfunction(es->luastate, elua_module_system_init); lua_createtable(es->luastate, 0, 0); @@ -453,7 +434,7 @@ elua_util_require(Elua_State *es, const char *libname) EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); EINA_SAFETY_ON_FALSE_RETURN_VAL(elua_state_require_ref_push(es), -1); lua_pushstring(es->luastate, libname); - return elua_error_report(es, es->progname, + return elua_util_error_report(es, es->progname, lua_pcall(es->luastate, 1, 0, 0)); } @@ -462,7 +443,7 @@ elua_util_file_run(Elua_State *es, const char *fname) { EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1); EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); - return elua_error_report(es, es->progname, + return elua_util_error_report(es, es->progname, elua_io_loadfile(es, fname) || _elua_docall(es, 0, 1)); } @@ -472,7 +453,7 @@ elua_util_string_run(Elua_State *es, const char *chunk, const char *chname) { EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1); EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); - return elua_error_report(es, es->progname, + return elua_util_error_report(es, es->progname, luaL_loadbuffer(es->luastate, chunk, strlen(chunk), chname) || _elua_docall(es, 0, 0)); @@ -531,5 +512,24 @@ elua_util_script_run(Elua_State *es, int argc, char **argv, int n, int *quit) *quit = lua_toboolean(es->luastate, -1); lua_pop(es->luastate, 1); } - return elua_error_report(es, es->progname, status); + return elua_util_error_report(es, es->progname, status); +} + +static void +_elua_errmsg(const char *pname, const char *msg) +{ + ERR("%s%s%s", pname ? pname : "", pname ? ": " : "", msg); +} + +EAPI int +elua_util_error_report(const Elua_State *es, const char *pname, int status) +{ + EINA_SAFETY_ON_FALSE_RETURN_VAL(es && es->luastate, status); + if (status && !lua_isnil(es->luastate, -1)) + { + const char *msg = lua_tostring(es->luastate, -1); + _elua_errmsg(pname, msg ? msg : "(non-string error)"); + lua_pop(es->luastate, 1); + } + return status; } |