MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / checktab

Function checktab

ThirdParty/lua/lua/ltablib.c:36–52  ·  view source on GitHub ↗

** Check that 'arg' has a table and set access functions in 'ta' to raw ** or non-raw according to the presence of corresponding metamethods. */

Source from the content-addressed store, hash-verified

34** or non-raw according to the presence of corresponding metamethods.
35*/
36static void checktab (lua_State *L, int arg, TabA *ta) {
37 ta->geti = NULL; ta->seti = NULL;
38 if (lua_getmetatable(L, arg)) {
39 lua_pushliteral(L, "__index"); /* 'index' metamethod */
40 if (lua_rawget(L, -2) != LUA_TNIL)
41 ta->geti = lua_geti;
42 lua_pushliteral(L, "__newindex"); /* 'newindex' metamethod */
43 if (lua_rawget(L, -3) != LUA_TNIL)
44 ta->seti = lua_seti;
45 lua_pop(L, 3); /* pop metatable plus both metamethods */
46 }
47 if (ta->geti == NULL || ta->seti == NULL) {
48 luaL_checktype(L, arg, LUA_TTABLE); /* must be table for raw methods */
49 if (ta->geti == NULL) ta->geti = lua_rawgeti;
50 if (ta->seti == NULL) ta->seti = lua_rawseti;
51 }
52}
53
54
55#define aux_getn(L,n,ta) (checktab(L, n, ta), luaL_len(L, n))

Callers 2

tconcatFunction · 0.85
unpackFunction · 0.85

Calls 3

lua_getmetatableFunction · 0.85
lua_rawgetFunction · 0.85
luaL_checktypeFunction · 0.85

Tested by

no test coverage detected