21 #include <momemta/ILuaCallback.h> 24 #include <ExecutionPath.h> 34 static const luaL_Reg functions[] = {
38 luaL_setfuncs(L, functions, 0);
43 lua_pushlightuserdata(L, ptr);
45 lua_setglobal(L, LUA_PATH_TYPE_NAME);
50 int n = lua_gettop(L);
52 luaL_error(L,
"invalid number of arguments: at least 1 expected, got 0");
55 std::vector<std::string> module_names;
56 for (
size_t i = 1; i <= (size_t) n; i++) {
57 std::string module_name = luaL_checkstring(L, i);
58 module_names.push_back(module_name);
64 luaL_getmetatable(L, LUA_PATH_TYPE_NAME);
65 lua_setmetatable(L, -2);
67 (*pPath)->elements = module_names;
70 void* cfg_ptr = lua_touserdata(L, lua_upvalueindex(1));
78 delete *
static_cast<ExecutionPath**
>(luaL_checkudata(L, 1, LUA_PATH_TYPE_NAME));
84 luaL_checktype(L, index, LUA_TUSERDATA);
87 const char *msg = lua_pushfstring(L,
"%s expected, got %s",
88 LUA_PATH_TYPE_NAME, luaL_typename(L, index));
89 luaL_argerror(L, index, msg);
int path_free(lua_State *L)
Free an instance of Path.
Notification callback used for communication between the lua file and MoMEMta.
int path_new(lua_State *L)
Create a new instance of Path.
Lua binding of C++ Path class.
ExecutionPath * path_get(lua_State *L, int index)
Retrieve an instance of Path from the lua stack.
void push_type_metatable(lua_State *L, const char *name)
Push a new metatable on the stack.
Generic functions to deal with custom lua types.
virtual void onNewPath(const ExecutionPath &path)=0
A new path is declared in the configuration file.
void path_register(lua_State *L, void *ptr)
Register Path into lua runtime.