MCPcopy Create free account
hub / github.com/Tencent/xLua / c_lua_gettable_bypath

Function c_lua_gettable_bypath

WebGLPlugins/xlua.c:224–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224static int c_lua_gettable_bypath(lua_State* L) {
225 size_t len = 0;
226 const char * pos = NULL;
227 const char * path = lua_tolstring(L, 2, &len);
228 lua_pushvalue(L, 1);
229 do {
230 pos = strchr(path, '.');
231 if (NULL == pos) {
232 lua_pushlstring(L, path, len);
233 } else {
234 lua_pushlstring(L, path, pos - path);
235 len = len - (pos - path + 1);
236 path = pos + 1;
237 }
238 lua_gettable(L, -2);
239 if (lua_type(L, -1) != LUA_TTABLE) {
240 if (NULL != pos) { // not found in path
241 lua_pushnil(L);
242 }
243 break;
244 }
245 lua_remove(L, -2);
246 } while(pos);
247 return 1;
248}
249
250LUA_API int xlua_pgettable_bypath(lua_State* L, int idx, const char *path) {
251 idx = lua_absindex(L, idx);

Callers

nothing calls this directly

Calls 7

lua_tolstringFunction · 0.85
lua_pushvalueFunction · 0.85
lua_pushlstringFunction · 0.85
lua_gettableFunction · 0.85
lua_typeFunction · 0.85
lua_pushnilFunction · 0.85
lua_removeFunction · 0.85

Tested by

no test coverage detected