summaryrefslogtreecommitdiff
path: root/src/lib/elua/elua.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/elua/elua.c')
-rw-r--r--src/lib/elua/elua.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index 488438ab0d..234674dfd9 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -278,7 +278,7 @@ elua_state_i18n_setup(const Elua_State *es)
278 EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE); 278 EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE);
279 EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE); 279 EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE);
280 snprintf(buf, sizeof(buf), "%s/gettext.lua", es->coredir); 280 snprintf(buf, sizeof(buf), "%s/gettext.lua", es->coredir);
281 if (elua_util_error_report(es, es->progname, elua_io_loadfile(es, buf))) 281 if (elua_util_error_report(es, elua_io_loadfile(es, buf)))
282 return EINA_FALSE; 282 return EINA_FALSE;
283 lua_createtable(es->luastate, 0, 0); 283 lua_createtable(es->luastate, 0, 0);
284 luaL_register(es->luastate, NULL, gettextlib); 284 luaL_register(es->luastate, NULL, gettextlib);
@@ -311,7 +311,7 @@ elua_state_modules_setup(const Elua_State *es)
311 EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE); 311 EINA_SAFETY_ON_NULL_RETURN_VAL(es->coredir, EINA_FALSE);
312 EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE); 312 EINA_SAFETY_ON_NULL_RETURN_VAL(es->progname, EINA_FALSE);
313 snprintf(buf, sizeof(buf), "%s/module.lua", es->coredir); 313 snprintf(buf, sizeof(buf), "%s/module.lua", es->coredir);
314 if (elua_util_error_report(es, es->progname, elua_io_loadfile(es, buf))) 314 if (elua_util_error_report(es, elua_io_loadfile(es, buf)))
315 return EINA_FALSE; 315 return EINA_FALSE;
316 lua_pushcfunction(es->luastate, _elua_module_system_init); 316 lua_pushcfunction(es->luastate, _elua_module_system_init);
317 lua_createtable(es->luastate, 0, 0); 317 lua_createtable(es->luastate, 0, 0);
@@ -437,8 +437,7 @@ elua_util_require(Elua_State *es, const char *libname)
437 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); 437 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1);
438 EINA_SAFETY_ON_FALSE_RETURN_VAL(elua_state_require_ref_push(es), -1); 438 EINA_SAFETY_ON_FALSE_RETURN_VAL(elua_state_require_ref_push(es), -1);
439 lua_pushstring(es->luastate, libname); 439 lua_pushstring(es->luastate, libname);
440 return elua_util_error_report(es, es->progname, 440 return elua_util_error_report(es, lua_pcall(es->luastate, 1, 0, 0));
441 lua_pcall(es->luastate, 1, 0, 0));
442} 441}
443 442
444EAPI int 443EAPI int
@@ -446,9 +445,8 @@ elua_util_file_run(Elua_State *es, const char *fname)
446{ 445{
447 EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1); 446 EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1);
448 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); 447 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1);
449 return elua_util_error_report(es, es->progname, 448 return elua_util_error_report(es, elua_io_loadfile(es, fname)
450 elua_io_loadfile(es, fname) 449 || _elua_docall(es, 0, 1));
451 || _elua_docall(es, 0, 1));
452} 450}
453 451
454EAPI int 452EAPI int
@@ -456,10 +454,9 @@ elua_util_string_run(Elua_State *es, const char *chunk, const char *chname)
456{ 454{
457 EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1); 455 EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1);
458 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1); 456 EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1);
459 return elua_util_error_report(es, es->progname, 457 return elua_util_error_report(es, luaL_loadbuffer(es->luastate, chunk,
460 luaL_loadbuffer(es->luastate, chunk, strlen(chunk), 458 strlen(chunk), chname)
461 chname) 459 || _elua_docall(es, 0, 0));
462 || _elua_docall(es, 0, 0));
463} 460}
464 461
465EAPI Eina_Bool 462EAPI Eina_Bool
@@ -515,7 +512,7 @@ elua_util_script_run(Elua_State *es, int argc, char **argv, int n, int *quit)
515 *quit = lua_toboolean(es->luastate, -1); 512 *quit = lua_toboolean(es->luastate, -1);
516 lua_pop(es->luastate, 1); 513 lua_pop(es->luastate, 1);
517 } 514 }
518 return elua_util_error_report(es, es->progname, status); 515 return elua_util_error_report(es, status);
519} 516}
520 517
521static void 518static void
@@ -525,13 +522,13 @@ _elua_errmsg(const char *pname, const char *msg)
525} 522}
526 523
527EAPI int 524EAPI int
528elua_util_error_report(const Elua_State *es, const char *pname, int status) 525elua_util_error_report(const Elua_State *es, int status)
529{ 526{
530 EINA_SAFETY_ON_FALSE_RETURN_VAL(es && es->luastate, status); 527 EINA_SAFETY_ON_FALSE_RETURN_VAL(es && es->luastate, status);
531 if (status && !lua_isnil(es->luastate, -1)) 528 if (status && !lua_isnil(es->luastate, -1))
532 { 529 {
533 const char *msg = lua_tostring(es->luastate, -1); 530 const char *msg = lua_tostring(es->luastate, -1);
534 _elua_errmsg(pname, msg ? msg : "(non-string error)"); 531 _elua_errmsg(es->progname, msg ? msg : "(non-string error)");
535 lua_pop(es->luastate, 1); 532 lua_pop(es->luastate, 1);
536 } 533 }
537 return status; 534 return status;