** ensure that stack[idx][fname] has a table and push that table ** into the stack */
| 961 | ** into the stack |
| 962 | */ |
| 963 | LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { |
| 964 | if (lua_getfield(L, idx, fname) == LUA_TTABLE) |
| 965 | return 1; /* table already there */ |
| 966 | else { |
| 967 | lua_pop(L, 1); /* remove previous result */ |
| 968 | idx = lua_absindex(L, idx); |
| 969 | lua_newtable(L); |
| 970 | lua_pushvalue(L, -1); /* copy to be left at top */ |
| 971 | lua_setfield(L, idx, fname); /* assign new table to field */ |
| 972 | return 0; /* false, because did not find table there */ |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | |
| 977 | /* |
no test coverage detected