| 613 | } |
| 614 | |
| 615 | InfoNode 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 | |
| 651 | int update_name_style_config(lua_State *L) { |
| 652 | int top = lua_gettop(L); |
no test coverage detected