** ensure that stack[idx][fname] has a table and push that table ** into the stack */
| 984 | ** into the stack |
| 985 | */ |
| 986 | LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { |
| 987 | if (lua_getfield(L, idx, fname) == LUA_TTABLE) |
| 988 | return 1; /* table already there */ |
| 989 | else { |
| 990 | lua_pop(L, 1); /* remove previous result */ |
| 991 | idx = lua_absindex(L, idx); |
| 992 | lua_newtable(L); |
| 993 | lua_pushvalue(L, -1); /* copy to be left at top */ |
| 994 | lua_setfield(L, idx, fname); /* assign new table to field */ |
| 995 | return 0; /* false, because did not find table there */ |
| 996 | } |
| 997 | } |
| 998 | |
| 999 | |
| 1000 | /* |
no test coverage detected