** ensure that stack[idx][fname] has a table and push that table ** into the stack */
| 720 | ** into the stack |
| 721 | */ |
| 722 | LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { |
| 723 | lua_getfield(L, idx, fname); |
| 724 | if (lua_istable(L, -1)) return 1; /* table already there */ |
| 725 | else { |
| 726 | lua_pop(L, 1); /* remove previous result */ |
| 727 | idx = lua_absindex(L, idx); |
| 728 | lua_newtable(L); |
| 729 | lua_pushvalue(L, -1); /* copy to be left at top */ |
| 730 | lua_setfield(L, idx, fname); /* assign new table to field */ |
| 731 | return 0; /* false, because did not find table there */ |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | |
| 736 | /* |
no test coverage detected