Revert "Merge branch 'lightmemedata' into 'next'"
This reverts commitd4c08a8410
, reversing changes made toe100f21dda
.
This commit is contained in:
parent
f97dc1093a
commit
ed5a7f51e8
|
@ -242,16 +242,10 @@ static const char *GetUserdataUType(lua_State *L)
|
||||||
// or players[0].powers -> "player_t.powers"
|
// or players[0].powers -> "player_t.powers"
|
||||||
static int lib_userdataType(lua_State *L)
|
static int lib_userdataType(lua_State *L)
|
||||||
{
|
{
|
||||||
int type;
|
|
||||||
lua_settop(L, 1); // pop everything except arg 1 (in case somebody decided to add more)
|
lua_settop(L, 1); // pop everything except arg 1 (in case somebody decided to add more)
|
||||||
type = lua_type(L, 1);
|
luaL_checktype(L, 1, LUA_TUSERDATA);
|
||||||
if (type == LUA_TLIGHTUSERDATA || type == LUA_TUSERDATA)
|
|
||||||
{
|
|
||||||
lua_pushstring(L, GetUserdataUType(L));
|
lua_pushstring(L, GetUserdataUType(L));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
else
|
|
||||||
return luaL_typerror(L, 1, "userdata");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes a metatable as first and only argument
|
// Takes a metatable as first and only argument
|
||||||
|
|
|
@ -440,8 +440,22 @@ static int lib_cvRegisterVar(lua_State *L)
|
||||||
|
|
||||||
static int lib_cvFindVar(lua_State *L)
|
static int lib_cvFindVar(lua_State *L)
|
||||||
{
|
{
|
||||||
LUA_PushLightUserdata(L, CV_FindVar(luaL_checkstring(L,1)), META_CVAR);
|
consvar_t *cv;
|
||||||
|
if (( cv = CV_FindVar(luaL_checkstring(L,1)) ))
|
||||||
|
{
|
||||||
|
lua_settop(L,1);/* We only want one argument in the stack. */
|
||||||
|
lua_pushlightuserdata(L, cv);/* Now the second value on stack. */
|
||||||
|
luaL_getmetatable(L, META_CVAR);
|
||||||
|
/*
|
||||||
|
The metatable is the last value on the stack, so this
|
||||||
|
applies it to the second value, which is the cvar.
|
||||||
|
*/
|
||||||
|
lua_setmetatable(L,2);
|
||||||
|
lua_pushvalue(L,2);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CVarSetFunction
|
static int CVarSetFunction
|
||||||
|
|
|
@ -714,27 +714,6 @@ fixed_t LUA_EvalMath(const char *word)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
LUA_PushUserdata but no userdata is created.
|
|
||||||
You can't invalidate it therefore.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void LUA_PushLightUserdata (lua_State *L, void *data, const char *meta)
|
|
||||||
{
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
lua_pushlightuserdata(L, data);
|
|
||||||
luaL_getmetatable(L, meta);
|
|
||||||
/*
|
|
||||||
The metatable is the last value on the stack, so this
|
|
||||||
applies it to the second value, which is the userdata.
|
|
||||||
*/
|
|
||||||
lua_setmetatable(L, -2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Takes a pointer, any pointer, and a metatable name
|
// Takes a pointer, any pointer, and a metatable name
|
||||||
// Creates a userdata for that pointer with the given metatable
|
// Creates a userdata for that pointer with the given metatable
|
||||||
// Pushes it to the stack and stores it in the registry.
|
// Pushes it to the stack and stores it in the registry.
|
||||||
|
|
|
@ -87,7 +87,6 @@ typedef enum {
|
||||||
LPUSHED_EXISTING,
|
LPUSHED_EXISTING,
|
||||||
} lpushed_t;
|
} lpushed_t;
|
||||||
|
|
||||||
void LUA_PushLightUserdata(lua_State *L, void *data, const char *meta);
|
|
||||||
void LUA_PushUserdata(lua_State *L, void *data, const char *meta);
|
void LUA_PushUserdata(lua_State *L, void *data, const char *meta);
|
||||||
lpushed_t LUA_RawPushUserdata(lua_State *L, void *data);
|
lpushed_t LUA_RawPushUserdata(lua_State *L, void *data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue