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 /src/lib/elua/elua.c | |
parent | f8f9cc14a798a4e760e09c6c3a2d54eea02e40ee (diff) |
elua lib: error_report is now in util namespace
Diffstat (limited to 'src/lib/elua/elua.c')
-rw-r--r-- | src/lib/elua/elua.c | 50 |
1 files changed, 25 insertions, 25 deletions
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) | |||
230 | return NULL; | 230 | return NULL; |
231 | } | 231 | } |
232 | 232 | ||
233 | static void | ||
234 | _elua_errmsg(const char *pname, const char *msg) | ||
235 | { | ||
236 | ERR("%s%s%s", pname ? pname : "", pname ? ": " : "", msg); | ||
237 | } | ||
238 | |||
239 | EAPI int | ||
240 | elua_error_report(const Elua_State *es, const char *pname, int status) | ||
241 | { | ||
242 | EINA_SAFETY_ON_FALSE_RETURN_VAL(es && es->luastate, status); | ||
243 | if (status && !lua_isnil(es->luastate, -1)) | ||
244 | { | ||
245 | const char *msg = lua_tostring(es->luastate, -1); | ||
246 | _elua_errmsg(pname, msg ? msg : "(non-string error)"); | ||
247 | lua_pop(es->luastate, 1); | ||
248 | } | ||
249 | return status; | ||
250 | } | ||
251 | |||
252 | static int | 233 | static int |
253 | _elua_gettext_bind_textdomain(lua_State *L) | 234 | _elua_gettext_bind_textdomain(lua_State *L) |
254 | { | 235 | { |
@@ -297,7 +278,7 @@ elua_state_i18n_setup(const Elua_State *es) | |||
297 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE); | 278 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE); |
298 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE); | 279 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE); |
299 | snprintf(buf, sizeof(buf), "%s/gettext.lua", es->coredir); | 280 | snprintf(buf, sizeof(buf), "%s/gettext.lua", es->coredir); |
300 | if (elua_error_report(es, es->progname, elua_io_loadfile(es, buf))) | 281 | if (elua_util_error_report(es, es->progname, elua_io_loadfile(es, buf))) |
301 | return EINA_FALSE; | 282 | return EINA_FALSE; |
302 | lua_createtable(es->luastate, 0, 0); | 283 | lua_createtable(es->luastate, 0, 0); |
303 | luaL_register(es->luastate, NULL, gettextlib); | 284 | luaL_register(es->luastate, NULL, gettextlib); |
@@ -327,7 +308,7 @@ elua_state_modules_setup(const Elua_State *es) | |||
327 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE); | 308 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE); |
328 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE); | 309 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE); |
329 | snprintf(buf, sizeof(buf), "%s/module.lua", es->coredir); | 310 | snprintf(buf, sizeof(buf), "%s/module.lua", es->coredir); |
330 | if (elua_error_report(es, es->progname, elua_io_loadfile(es, buf))) | 311 | if (elua_util_error_report(es, es->progname, elua_io_loadfile(es, buf))) |
331 | return EINA_FALSE; | 312 | return EINA_FALSE; |
332 | lua_pushcfunction(es->luastate, elua_module_system_init); | 313 | lua_pushcfunction(es->luastate, elua_module_system_init); |
333 | lua_createtable(es->luastate, 0, 0); | 314 | lua_createtable(es->luastate, 0, 0); |
@@ -453,7 +434,7 @@ elua_util_require(Elua_State *es, const char *libname) | |||
453 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); | 434 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); |
454 | EINA_SAFETY_ON_FALSE_RETURN_VAL(elua_state_require_ref_push(es), -1); | 435 | EINA_SAFETY_ON_FALSE_RETURN_VAL(elua_state_require_ref_push(es), -1); |
455 | lua_pushstring(es->luastate, libname); | 436 | lua_pushstring(es->luastate, libname); |
456 | return elua_error_report(es, es->progname, | 437 | return elua_util_error_report(es, es->progname, |
457 | lua_pcall(es->luastate, 1, 0, 0)); | 438 | lua_pcall(es->luastate, 1, 0, 0)); |
458 | } | 439 | } |
459 | 440 | ||
@@ -462,7 +443,7 @@ elua_util_file_run(Elua_State *es, const char *fname) | |||
462 | { | 443 | { |
463 | EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1); | 444 | EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1); |
464 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); | 445 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); |
465 | return elua_error_report(es, es->progname, | 446 | return elua_util_error_report(es, es->progname, |
466 | elua_io_loadfile(es, fname) | 447 | elua_io_loadfile(es, fname) |
467 | || _elua_docall(es, 0, 1)); | 448 | || _elua_docall(es, 0, 1)); |
468 | } | 449 | } |
@@ -472,7 +453,7 @@ elua_util_string_run(Elua_State *es, const char *chunk, const char *chname) | |||
472 | { | 453 | { |
473 | EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1); | 454 | EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1); |
474 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); | 455 | EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); |
475 | return elua_error_report(es, es->progname, | 456 | return elua_util_error_report(es, es->progname, |
476 | luaL_loadbuffer(es->luastate, chunk, strlen(chunk), | 457 | luaL_loadbuffer(es->luastate, chunk, strlen(chunk), |
477 | chname) | 458 | chname) |
478 | || _elua_docall(es, 0, 0)); | 459 | || _elua_docall(es, 0, 0)); |
@@ -531,5 +512,24 @@ elua_util_script_run(Elua_State *es, int argc, char **argv, int n, int *quit) | |||
531 | *quit = lua_toboolean(es->luastate, -1); | 512 | *quit = lua_toboolean(es->luastate, -1); |
532 | lua_pop(es->luastate, 1); | 513 | lua_pop(es->luastate, 1); |
533 | } | 514 | } |
534 | return elua_error_report(es, es->progname, status); | 515 | return elua_util_error_report(es, es->progname, status); |
516 | } | ||
517 | |||
518 | static void | ||
519 | _elua_errmsg(const char *pname, const char *msg) | ||
520 | { | ||
521 | ERR("%s%s%s", pname ? pname : "", pname ? ": " : "", msg); | ||
522 | } | ||
523 | |||
524 | EAPI int | ||
525 | elua_util_error_report(const Elua_State *es, const char *pname, int status) | ||
526 | { | ||
527 | EINA_SAFETY_ON_FALSE_RETURN_VAL(es && es->luastate, status); | ||
528 | if (status && !lua_isnil(es->luastate, -1)) | ||
529 | { | ||
530 | const char *msg = lua_tostring(es->luastate, -1); | ||
531 | _elua_errmsg(pname, msg ? msg : "(non-string error)"); | ||
532 | lua_pop(es->luastate, 1); | ||
533 | } | ||
534 | return status; | ||
535 | } | 535 | } |