MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaL_testudata

Function luaL_testudata

src/Chain/libraries/glua/lauxlib.cpp:326–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324
325
326LUALIB_API void *luaL_testudata(lua_State *L, int ud, const char *tname) {
327 void *p = lua_touserdata(L, ud);
328 if (p != nullptr) { /* value is a userdata? */
329 if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
330 luaL_getmetatable(L, tname); /* get correct metatable */
331 if (!lua_rawequal(L, -1, -2)) /* not the same? */
332 p = nullptr; /* value is a userdata with wrong metatable */
333 lua_pop(L, 2); /* remove both metatables */
334 return p;
335 }
336 }
337 return nullptr; /* value is not a userdata with a metatable */
338}
339
340
341LUALIB_API void *luaL_checkudata(lua_State *L, int ud, const char *tname) {

Callers 2

io_typeFunction · 0.85
luaL_checkudataFunction · 0.85

Calls 3

lua_touserdataFunction · 0.85
lua_getmetatableFunction · 0.85
lua_rawequalFunction · 0.85

Tested by

no test coverage detected