CLuaInstance: Add additional tableLookup for get userdata

This commit is contained in:
M. Liebmann
2014-03-16 11:56:48 +01:00
parent 623efecc2f
commit f4c70c96a5
2 changed files with 13 additions and 0 deletions

View File

@@ -677,6 +677,18 @@ bool CLuaInstance::tableLookup(lua_State *L, const char *what, int &value)
return res;
}
bool CLuaInstance::tableLookup(lua_State *L, const char *what, void** value)
{
bool res = false;
lua_pushstring(L, what);
lua_gettable(L, -2);
res = lua_isuserdata(L, -1);
if (res)
*value = lua_unboxpointer(L, -1);
lua_pop(L, 1);
return res;
}
bool CLuaMenuChangeObserver::changeNotify(lua_State *L, const std::string &luaAction, const std::string &luaId, void *Data)
{
const char *optionValue = (const char *) Data;

View File

@@ -218,6 +218,7 @@ private:
static bool tableLookup(lua_State*, const char*, std::string&);
static bool tableLookup(lua_State*, const char*, int&);
static bool tableLookup(lua_State*, const char*, void**);
};
#endif /* _LUAINSTANCE_H */