From 9283a0917dc29aba1e89bf40bc59f255f73cec48 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 26 Jul 2018 16:02:44 +0300 Subject: Refactored proto C compiler to enable cross directory messages. Refactored tech motors and dispensers to use types from hardware. --- .../Tango.Protobuf/Compilers/CCompiler.cs | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'Software/Visual_Studio/Tango.Protobuf/Compilers') diff --git a/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs b/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs index 1a8dc632f..91f8d1502 100644 --- a/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs +++ b/Software/Visual_Studio/Tango.Protobuf/Compilers/CCompiler.cs @@ -67,13 +67,29 @@ namespace Tango.Protobuf.Compilers { String str = File.ReadAllText(file); - foreach (String dir in directories.Select(x => Path.GetFileName(x))) + var lines = str.ToLines(); + + lines.RemoveAll(x => x.Contains("package ")); + + for (int i = 0; i < lines.Count; i++) { - str = str.Replace(dir + ".", ""); + if (!lines[i].Contains("import ") || lines[i].StartsWith("//")) + { + string[] wordsAndComments = lines[i].Split('/'); + + string lineWords = wordsAndComments.FirstOrDefault(); + + string[] words = lineWords.Split(' '); + + for (int j = 0; j < words.Length; j++) + { + words[j] = words[j].Split('.').LastOrDefault(); + } + + lines[i] = String.Join(" ", words); + } } - var lines = str.ToLines(); - lines.RemoveAll(x => x.Contains("package ")); str = String.Join(Environment.NewLine, lines); File.WriteAllText(file, str); } -- cgit v1.3.1