MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / CreateFromLua

Function CreateFromLua

CodeFormatLib/src/CodeFormatLib.cpp:615–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615InfoNode CreateFromLua(InfoTree &t, lua_State *L) {
616 if (lua_istable(L, -1)) {
617 // lua 不区分 数组和table, 太难了
618 auto len = luaL_len(L, -1);
619 if (len != 0) {
620 auto arr = t.CreateArray();
621 for (auto i = 1; i <= len; i++) {
622 if (lua_geti(L, -1, i)) {
623 arr.AddChild(CreateFromLua(t, L));
624 }
625 lua_pop(L, 1);
626 }
627 return arr;
628 } else {
629 auto object = t.CreateObject();
630 lua_pushnil(L);
631 while (lua_next(L, -2) != 0) {
632 if (lua_isstring(L, -2)) {
633 auto key = luaToString(L, -2);
634 object.AddChild(key, CreateFromLua(t, L));
635 }
636 lua_pop(L, 1);
637 }
638 return object;
639 }
640 } else if (lua_isnumber(L, -1)) {
641 return t.CreateNumber(lua_tonumber(L, -1));
642 } else if (lua_isstring(L, -1)) {
643 return t.CreateString(lua_tostring(L, -1));
644 } else if (lua_isboolean(L, -1)) {
645 return t.CreateBool(lua_toboolean(L, -1));
646 } else {
647 return t.CreateNone();
648 }
649}
650
651int update_name_style_config(lua_State *L) {
652 int top = lua_gettop(L);

Callers 1

update_name_style_configFunction · 0.85

Calls 15

luaL_lenFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
lua_isstringFunction · 0.85
luaToStringFunction · 0.85
lua_isnumberFunction · 0.85
lua_tobooleanFunction · 0.85
CreateArrayMethod · 0.80
AddChildMethod · 0.80
CreateObjectMethod · 0.80
CreateNumberMethod · 0.80
CreateStringMethod · 0.80

Tested by

no test coverage detected