luaa: remove luaA_toudata()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-11 13:38:20 +02:00
parent d728875969
commit 7da55e899b
2 changed files with 1 additions and 25 deletions

2
luaa.c
View file

@ -413,7 +413,7 @@ luaAe_type(lua_State *L)
luaL_checkany(L, 1);
#define CHECK_TYPE(type) \
do { \
if(luaA_toudata2(L, 1, #type) || luaA_toudata(L, 1, #type)) \
if(luaA_toudata2(L, 1, #type)) \
{ \
lua_pushliteral(L, #type); \
return 1; \

24
luaa.h
View file

@ -107,30 +107,6 @@ luaA_dumpstack(lua_State *L)
fprintf(stderr, "------- Lua stack dump end ------\n");
}
/** Convert a object to a udata if possible.
* \param L The Lua VM state.
* \param ud The index.
* \param tname The type name.
* \return A pointer to the object, NULL otherwise.
*/
static inline void *
luaA_toudata(lua_State *L, int ud, const char *tname)
{
void **p = lua_touserdata(L, ud);
if(p && *p) /* value is a userdata? */
if(lua_getmetatable(L, ud)) /* does it have a metatable? */
{
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
if(lua_rawequal(L, -1, -2)) /* does it have the correct mt? */
{
lua_pop(L, 2); /* remove both metatables */
return p;
}
lua_pop(L, 2); /* remove both metatables */
}
return NULL;
}
/** Convert a object to a udata if possible.
* \param L The Lua VM state.
* \param ud The index.