aboutsummaryrefslogtreecommitdiff
path: root/src/compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat.c')
-rw-r--r--src/compat.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/compat.c b/src/compat.c
index c2d99cb..988fa68 100644
--- a/src/compat.c
+++ b/src/compat.c
@@ -16,4 +16,22 @@ void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
16 } 16 }
17 lua_pop(L, nup); /* remove upvalues */ 17 lua_pop(L, nup); /* remove upvalues */
18} 18}
19
20/*
21** Duplicated from Lua 5.2
22*/
23void *luaL_testudata (lua_State *L, int ud, const char *tname) {
24 void *p = lua_touserdata(L, ud);
25 if (p != NULL) { /* value is a userdata? */
26 if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
27 luaL_getmetatable(L, tname); /* get correct metatable */
28 if (!lua_rawequal(L, -1, -2)) /* not the same? */
29 p = NULL; /* value is a userdata with wrong metatable */
30 lua_pop(L, 2); /* remove both metatables */
31 return p;
32 }
33 }
34 return NULL; /* value is not a userdata with a metatable */
35}
36
19#endif 37#endif