* @brief Loads a file using Elua's own mmap-based IO.
*
* This function behaves identically to luaL_loadfile when it comes to
- * semantics. The loaded file remains on the Lua stack.
+ * semantics. The loaded file remains on the Lua stack. If the input
+ * state is NULL, the return value is -1 and nothing is left on the stack.
+ * On any different error, the error object is left on the stack and this
+ * returns a value larger than zero (LUA_ERR*). On success, zero is returned.
*
* @param[in] es The Elua state.
* @param[in] fname The file name.
* @brief Loads an application.
*
* This loads an app, respecting the app path set on state initialization.
- * Leaves the Lua stack clean. Actually runs the app.
+ * Actually runs the app. If the input state is NULL, the return value is -1
+ * nd nothing is left on the stack. On any different error, the error object
+ * is left on the stack and this returns 1. On success, zero is returned
+ * (and the return value from the app is left on the stack).
*
* @param[in] es The Elua state.
* @param[in] appname The application name.
- * @return EINA_TRUE on success, EINA_FALSE on failure.
+ * @return 0 for no errors, 1 on errors, -1 on null input.
*
* @ingroup Elua
*/
-EAPI Eina_Bool elua_util_app_load(Elua_State *es, const char *appname);
+EAPI int elua_util_app_load(Elua_State *es, const char *appname);
/**
* @brief Runs a script.
|| _elua_docall(es, 0, 0));
}
-EAPI Eina_Bool
+EAPI int
elua_util_app_load(Elua_State *es, const char *appname)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(es, EINA_FALSE);
- EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, EINA_FALSE);
- EINA_SAFETY_ON_FALSE_RETURN_VAL(elua_state_appload_ref_push(es), EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(es, -1);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(es->luastate, -1);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(elua_state_appload_ref_push(es), -1);
lua_pushstring(es->luastate, appname);
lua_call(es->luastate, 1, 2);
if (lua_isnil(es->luastate, -2))
{
lua_remove(es->luastate, -2);
- return EINA_FALSE;
+ return 1;
}
lua_pop(es->luastate, 1);
- return EINA_TRUE;
+ return 0;
}
EAPI Eina_Bool
status = elua_io_loadfile(es, fname);
}
else
- status = !elua_util_app_load(es, fname);
+ status = elua_util_app_load(es, fname);
}
else
status = elua_io_loadfile(es, fname);
fail_if(!elua_util_require(st, "util"));
fail_if(!elua_util_string_run(st, "return 1337", "foo"));
fail_if(elua_util_string_run(st, "foo bar", "foo")); /* invalid code */
- fail_if(!elua_util_app_load(st, "lualian"));
+ fail_if(elua_util_app_load(st, "lualian"));
fail_if(lua_type(lst, -1) != LUA_TFUNCTION);
lua_pop(lst, 1);
- fail_if(elua_util_app_load(st, "non_existent_app"));
+ fail_if(!elua_util_app_load(st, "non_existent_app"));
fail_if(lua_type(lst, -1) != LUA_TSTRING);
lua_pop(lst, 1);
fail_if(elua_io_loadfile(st, ELUA_CORE_DIR "/util.lua"));