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

Function luaL_testudata

other_src/lua/src/lauxlib.cpp:140–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138
139
140LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { /*BZ*/
141 void *p = lua_touserdata(L, ud);
142 if (p == NULL) { /* value is a userdata? */
143 return NULL;
144 }
145
146 if (!lua_getmetatable(L, ud)) { /* does it have a metatable? */
147 lua_pop(L, 1);
148 return NULL;
149 }
150
151 /* get type metatable */
152 lua_getfield(L, LUA_REGISTRYINDEX, tname);
153
154 /* does it have the type's metatable */
155 if (lua_rawequal(L, -1, -2)) {
156 lua_pop(L, 2); /* remove both metatables */
157 return p;
158 }
159
160 lua_pop(L, 2); /* remove both metatables */
161 return NULL;
162}
163
164
165LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {

Callers 2

TestHTTPMethod · 0.85
GetURLMethod · 0.85

Calls 4

lua_touserdataFunction · 0.70
lua_getmetatableFunction · 0.70
lua_getfieldFunction · 0.70
lua_rawequalFunction · 0.70

Tested by 1

TestHTTPMethod · 0.68