MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / checktab

Function checktab

third-party/lua-5.5.0/src/ltablib.c:47–59  ·  view source on GitHub ↗

** Check that 'arg' either is a table or can behave like one (that is, ** has a metatable with the required metamethods) */

Source from the content-addressed store, hash-verified

45** has a metatable with the required metamethods)
46*/
47static void checktab (lua_State *L, int arg, int what) {
48 if (lua_type(L, arg) != LUA_TTABLE) { /* is it not a table? */
49 int n = 1; /* number of elements to pop */
50 if (lua_getmetatable(L, arg) && /* must have metatable */
51 (!(what & TAB_R) || checkfield(L, "__index", ++n)) &&
52 (!(what & TAB_W) || checkfield(L, "__newindex", ++n)) &&
53 (!(what & TAB_L) || checkfield(L, "__len", ++n))) {
54 lua_pop(L, n); /* pop metatable and tested metamethods */
55 }
56 else
57 luaL_checktype(L, arg, LUA_TTABLE); /* force an error */
58 }
59}
60
61
62static int tcreate (lua_State *L) {

Callers 1

tmoveFunction · 0.70

Calls 4

lua_typeFunction · 0.70
lua_getmetatableFunction · 0.70
checkfieldFunction · 0.70
luaL_checktypeFunction · 0.70

Tested by

no test coverage detected