mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
luaa: remove luaA_toudata()
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
d728875969
commit
7da55e899b
2 changed files with 1 additions and 25 deletions
2
luaa.c
2
luaa.c
|
@ -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
24
luaa.h
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue