slight tweaks to nexus_lua, use error_t and no need to pop the loaded chunk ourselv - lua_pcall will always do that
--- a/src/nexus_lua.c Wed May 20 22:49:03 2009 +0300
+++ b/src/nexus_lua.c Wed May 20 22:52:01 2009 +0300
@@ -91,16 +91,11 @@
// build the error_info
nexus_lua_error(lua->st, ret, err);
- // pop it
+ // pop the error message
// XXX: err points at GC:able memory
lua_pop(lua->st, 1);
}
- if (loaded) {
- // pop off the chunk
- lua_pop(lua->st, 1);
- }
-
return ERROR_CODE(err);
}
--- a/src/nexus_lua.h Wed May 20 22:49:03 2009 +0300
+++ b/src/nexus_lua.h Wed May 20 22:52:01 2009 +0300
@@ -19,7 +19,7 @@
/** The nexus we are operating on */
struct nexus *nexus;
- /** The lua state */
+ /** The main lua state */
lua_State *st;
};
@@ -38,8 +38,10 @@
*
* This operation is equally valid for both textual and binary chunks, but this is intended for textual chunks, and
* hence accepts a NUL-terminated string.
+ *
+ * This runs the chunk in the main lua state, so this will fail for any coroutine functions.
*/
-err_t nexus_lua_eval (struct nexus_lua *lua, const char *chunk, struct error_info *err);
+err_t nexus_lua_eval (struct nexus_lua *lua, const char *chunk, error_t *err);
/**
* Handle a Lua error by converting the given error code into a ERR_LUA_* code, inspecting the error object at
@@ -48,6 +50,6 @@
* Please note that the resulting error_info points into strings inside the lua stack - once you pop the error, the
* error_info might not be valid anymore after the next GC cycle.
*/
-err_t nexus_lua_error (lua_State *L, int ret, struct error_info *err);
+err_t nexus_lua_error (lua_State *L, int ret, error_t *err);
#endif /* NEXUS_LUA_H */