diff --git a/Json_parser/Program.cs b/Json_parser/Program.cs index 9488dea..1abb690 100644 --- a/Json_parser/Program.cs +++ b/Json_parser/Program.cs @@ -56,7 +56,6 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path) Console.WriteLine(cmdList.First()); var outStr = "---@meta\n\n"; int MAX_DEPT = 10; - var nodeTable = new HashSet(); Dictionary>[] instrTable = new Dictionary>[MAX_DEPT]; for (int i = 0; i < MAX_DEPT; i++) { @@ -87,21 +86,7 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path) { string s = cmd.name; var tSplit = s.Contains(".") ? s.Trim().Split('.') : s.Trim().Split(':'); - if (cmd.tsplink_supported.Contains("Yes")) - { - //if (tSplit[0] == "bufferVar") - //continue; - if (tSplit.Length > 1) - { - nodeTable.Add(tSplit[0] + " = " + tSplit[0]); - } - else - { - nodeTable.Add(s.Contains('(') ? s.Split('(')[0] + " = " + s.Split('(')[0] : s + " = " + s); - } - } - - + for (int i = 0; i < tSplit.Length - 1; i++) {//ignore functions string attr = null; @@ -123,7 +108,7 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path) outStr += "---@class io_object\nlocal io_object={}\n---@class scriptVar\nlocal scriptVar={}\n---@class eventID\n\n---@class file_object\nlocal file_object ={}\n\n"; //PRIV outStr += "---@class bufferVar\nlocal bufferVar={}\n"; - outStr += "---@class digio\n digio = {}\n\n---@class tsplink\n tsplink = {}\n\n---@class lan\n lan = {}\n\n---@class tspnetConnectionID\nlocal tspnetConnectionID = {}\n\n ---@class promptID\nlocal promptID = {}\n\n"; + outStr += "---@class digio\n local digio = {}\n\n---@class tsplink\n local tsplink = {}\n\n---@class lan\n local lan = {}\n\n---@class tspnetConnectionID\nlocal tspnetConnectionID = {}\n\n ---@class promptID\nlocal promptID = {}\n\n"; var tsplinkStr = ""; tsplinkStr = outStr; @@ -168,11 +153,7 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path) } - nodeTable.Remove("node[N] = node[N]"); // for now removing this command from nodeTable because its creating problem in lua definitions - nodeTable.Remove("slot[slot] = slot[slot]"); // for now removing this command from nodeTable because its creating problem in lua definition - - - + if (file_name.Contains("26")) { @@ -184,35 +165,28 @@ static void parse_commands_josn(string base_lib_dir, string json_file_path) else // for tti models { - nodeTable.Add("defbuffer1 = defbuffer1"); - nodeTable.Add("defbuffer2 = defbuffer2"); } - var nodeTable_str = @"{" + string.Join(",\n ", nodeTable) + "\n}"; - var node_class_name = Regex.Replace(file_name, @"[^a-zA-Z0-9_]", ""); - var nodeTableDetails = $"---@meta\n\n---@class model{node_class_name}\nmodel{node_class_name} = {nodeTable_str}" + - $"\n--#region node details\n--#endregion"; + var node_class_name = Regex.Replace(file_name, @"[^a-zA-Z0-9_]", ""); + Directory.CreateDirectory(Path.Combine(base_lib_dir, model)); Directory.CreateDirectory(Path.Combine(base_lib_dir, model, "tspLinkSupportedCommands")); Directory.CreateDirectory(Path.Combine(base_lib_dir, model, "AllTspCommands")); Directory.CreateDirectory(Path.Combine(base_lib_dir, model, "Helper")); - var nodeTableFilePath = $"{base_lib_dir}/{model}/tspLinkSupportedCommands/nodeTable.lua"; - var AllTspCommandsFilePath = $"{base_lib_dir}/{model}/AllTspCommands/" + file_name + ".lua"; - var tspLinkSupportedCommandsFilePath = $"{base_lib_dir}/{model}/tspLinkSupportedCommands/" + file_name + "_TSPLink.lua"; + var AllTspCommandsFilePath = $"{base_lib_dir}/{model}/AllTspCommands/definitions.lua"; + var tspLinkSupportedCommandsFilePath = $"{base_lib_dir}/{model}/tspLinkSupportedCommands/definitions.txt"; var static_folder_Path = Path.Combine(base_lib_dir, model, "Helper"); Utility.CopyStaticFiles(model, static_folder_Path); - Utility.write_to_file(nodeTableFilePath, nodeTableDetails); Utility.write_to_file(AllTspCommandsFilePath, outStr); Utility.write_to_file(tspLinkSupportedCommandsFilePath, tsplinkStr); - Utility.SetFileReadOnly(nodeTableFilePath); Utility.SetFileReadOnly(AllTspCommandsFilePath); Utility.SetFileReadOnly(tspLinkSupportedCommandsFilePath); diff --git a/Json_parser/Utility.cs b/Json_parser/Utility.cs index a33c928..f059176 100644 --- a/Json_parser/Utility.cs +++ b/Json_parser/Utility.cs @@ -137,9 +137,9 @@ public static string PrintFields(int depth, string file_name, Dictionary com var function_name = command.Key.Replace("(", "").Replace(")", ""); - command_help += $"function {function_name}({cmd.signature.Substring(start, end - start)}) end\n"; + command_help += $"local function {function_name}({cmd.signature.Substring(start, end - start)}) end\n"; command_help += $"{table}.{function_name} = { function_name}\n"; } @@ -777,7 +777,7 @@ public static string create_tspLinkNode_enum_alias_type(ParamInfo param) command_help += $"\n---@alias {NODE_ALIAS_STR}{aliasName}\n"; foreach (var data in enum_data) { - command_help += $"---|`{NODE_STR}{data.Split(' ')[0]}`\n "; + command_help += $"---|`{NODE_STR}{data.Split(' ')[0]}`\n"; } command_help += "\n";