** ensure that stack[idx][fname] has a table and push that table ** into the stack */
| 921 | ** into the stack |
| 922 | */ |
| 923 | LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { |
| 924 | if (lua_getfield(L, idx, fname) == LUA_TTABLE) |
| 925 | return 1; /* table already there */ |
| 926 | else { |
| 927 | lua_pop(L, 1); /* remove previous result */ |
| 928 | idx = lua_absindex(L, idx); |
| 929 | lua_newtable(L); |
| 930 | lua_pushvalue(L, -1); /* copy to be left at top */ |
| 931 | lua_setfield(L, idx, fname); /* assign new table to field */ |
| 932 | return 0; /* false, because did not find table there */ |
| 933 | } |
| 934 | } |
| 935 | |
| 936 | |
| 937 | /* |
no test coverage detected