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

Function c_lua_settable_bypath

WebGLPlugins/xlua.c:275–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275static int c_lua_settable_bypath(lua_State* L) {
276 size_t len = 0;
277 const char * pos = NULL;
278 const char * path = lua_tolstring(L, 2, &len);
279 lua_pushvalue(L, 1);
280 do {
281 pos = strchr(path, '.');
282 if (NULL == pos) { // last
283 lua_pushlstring(L, path, len);
284 lua_pushvalue(L, 3);
285 lua_settable(L, -3);
286 lua_pop(L, 1);
287 break;
288 } else {
289 lua_pushlstring(L, path, pos - path);
290 len = len - (pos - path + 1);
291 path = pos + 1;
292 }
293 lua_gettable(L, -2);
294 if (lua_type(L, -1) != LUA_TTABLE) {
295 return luaL_error(L, "can not set value to %s", lua_tostring(L, 2));
296 }
297 lua_remove(L, -2);
298 } while(pos);
299 return 0;
300}
301
302LUA_API int xlua_psettable_bypath(lua_State* L, int idx, const char *path) {
303 int top = lua_gettop(L);

Callers

nothing calls this directly

Calls 8

lua_tolstringFunction · 0.85
lua_pushvalueFunction · 0.85
lua_pushlstringFunction · 0.85
lua_settableFunction · 0.85
lua_gettableFunction · 0.85
lua_typeFunction · 0.85
luaL_errorFunction · 0.85
lua_removeFunction · 0.85

Tested by

no test coverage detected