From d461cbb05cfde45af9b5ce1ab7f6eef90d2f6691 Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Tue, 7 Nov 2023 23:55:35 +0800 Subject: [PATCH] :zap: add POST method to edit prop tree --- std/json.nas | 21 +++++-- tools/fgfs_props_getter.nas | 118 +++++++++++++++++++++++++++++------- 2 files changed, 111 insertions(+), 28 deletions(-) diff --git a/std/json.nas b/std/json.nas index 6e4d42b..0c31849 100644 --- a/std/json.nas +++ b/std/json.nas @@ -11,8 +11,9 @@ var ( _j_colon, _j_str, _j_num, - _j_id -) = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9); + _j_id, + _j_bool +) = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); var _j_content = [ "eof", @@ -24,7 +25,8 @@ var _j_content = [ "`:`", "string", "number", - "identifier" + "identifier", + "boolean" ]; var _parse_error = 0; @@ -133,7 +135,13 @@ var parse = func() { } elsif (isnum(c)) { var s = c; ptr += 1; - while(ptr2) { exit(-1); } -var getter = new_getter(arg[0], num(arg[1])); +var connect = connection.new(arg[0], num(arg[1])); +var count = 0; +var recursive_get_prop = func(path = "/") { + count += 1; + if (math.mod(count, 100)==0) { + println("get ", count," nodes, now: \"", path, "\""); + } + var props = connect.getprop(path); + var tree = {}; + tree.path = props.path; + if (!contains(props, "children")) { + return tree; + } -var get_props = func(path = "/") { - var props = getter.getprop(path); - dump(props); + tree.children = []; + foreach(var child; props.children) { + var node = {}; + node = recursive_get_prop(child.path); + append(tree.children, node); + } + return tree; } -get_props(); -get_props("/e-tron/dialog/config"); -get_props("/e-tron/dialog/config/a"); - -getter.close(); \ No newline at end of file +# takes about 5 min to get whole tree +var props = recursive_get_prop("/"); +dump(props);