** ensure that stack[idx][fname] has a table and push that table ** into the stack */
| 864 | ** into the stack |
| 865 | */ |
| 866 | LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { |
| 867 | lua_getfield(L, idx, fname); |
| 868 | if (lua_istable(L, -1)) return 1; /* table already there */ |
| 869 | else { |
| 870 | lua_pop(L, 1); /* remove previous result */ |
| 871 | idx = lua_absindex(L, idx); |
| 872 | lua_newtable(L); |
| 873 | lua_pushvalue(L, -1); /* copy to be left at top */ |
| 874 | lua_setfield(L, idx, fname); /* assign new table to field */ |
| 875 | return 0; /* false, because did not find table there */ |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | |
| 880 | /* |
no test coverage detected