diff options
author | Thijs <thijs@thijsschreijer.nl> | 2024-05-23 08:51:31 +0200 |
---|---|---|
committer | Thijs <thijs@thijsschreijer.nl> | 2024-05-23 09:05:07 +0200 |
commit | 9f6958c429627190917f742f46a3ae60ed6e7ca0 (patch) | |
tree | 9c2e6fb0a4bb952de1d66a851bbfcb34cfddf4c1 /src/compat.c | |
parent | 7e9447c98588730738724176d9acc595be6299e6 (diff) | |
download | luasystem-9f6958c429627190917f742f46a3ae60ed6e7ca0.tar.gz luasystem-9f6958c429627190917f742f46a3ae60ed6e7ca0.tar.bz2 luasystem-9f6958c429627190917f742f46a3ae60ed6e7ca0.zip |
Windows fixes, some manual tests
Diffstat (limited to '')
-rw-r--r-- | src/compat.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/compat.c b/src/compat.c index 6f98854..2d2bec9 100644 --- a/src/compat.c +++ b/src/compat.c | |||
@@ -14,4 +14,20 @@ void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) { | |||
14 | } | 14 | } |
15 | lua_pop(L, nup); /* remove upvalues */ | 15 | lua_pop(L, nup); /* remove upvalues */ |
16 | } | 16 | } |
17 | |||
18 | void *luaL_testudata(lua_State *L, int ud, const char *tname) { | ||
19 | void *p = lua_touserdata(L, ud); | ||
20 | if (p != NULL) { /* Check for userdata */ | ||
21 | if (lua_getmetatable(L, ud)) { /* Does it have a metatable? */ | ||
22 | lua_getfield(L, LUA_REGISTRYINDEX, tname); /* Get metatable we're looking for */ | ||
23 | if (lua_rawequal(L, -1, -2)) { /* Compare metatables */ | ||
24 | lua_pop(L, 2); /* Remove metatables from stack */ | ||
25 | return p; | ||
26 | } | ||
27 | lua_pop(L, 2); /* Remove metatables from stack */ | ||
28 | } | ||
29 | } | ||
30 | return NULL; /* Return NULL if check fails */ | ||
31 | } | ||
32 | |||
17 | #endif | 33 | #endif |