From 7ef98a9806076818023419643e11e9135e111e98 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Tue, 14 Oct 2014 18:56:22 +0200 Subject: [PATCH] Major C# rename spree. --- compiler/CS_CodeGen.jrag | 20 +++++++------- examples/robot/Program.cs | 2 +- lib/csharp/Makefile | 22 ++++++++-------- .../labcomm/{LabComm.cs => Constant.cs} | 2 +- .../labcomm/{LabCommDecoder.cs => Decoder.cs} | 6 ++--- ...ommDecoderChannel.cs => DecoderChannel.cs} | 22 ++++++++-------- ...mDecoderRegistry.cs => DecoderRegistry.cs} | 26 +++++++++---------- .../labcomm/{LabCommEncoder.cs => Encoder.cs} | 4 +-- ...ommEncoderChannel.cs => EncoderChannel.cs} | 14 +++++----- ...mEncoderRegistry.cs => EncoderRegistry.cs} | 14 +++++----- .../se/lth/control/labcomm/LabCommSample.cs | 3 --- .../se/lth/control/labcomm/LabCommType.cs | 3 --- lib/csharp/se/lth/control/labcomm/Sample.cs | 3 +++ ...bCommDispatcher.cs => SampleDispatcher.cs} | 6 ++--- .../{LabCommHandler.cs => SampleHandler.cs} | 2 +- .../se/lth/control/labcomm/SampleType.cs | 3 +++ test/relay_gen_cs.py | 6 ++--- 17 files changed, 79 insertions(+), 79 deletions(-) rename lib/csharp/se/lth/control/labcomm/{LabComm.cs => Constant.cs} (97%) rename lib/csharp/se/lth/control/labcomm/{LabCommDecoder.cs => Decoder.cs} (71%) rename lib/csharp/se/lth/control/labcomm/{LabCommDecoderChannel.cs => DecoderChannel.cs} (85%) rename lib/csharp/se/lth/control/labcomm/{LabCommDecoderRegistry.cs => DecoderRegistry.cs} (84%) rename lib/csharp/se/lth/control/labcomm/{LabCommEncoder.cs => Encoder.cs} (83%) rename lib/csharp/se/lth/control/labcomm/{LabCommEncoderChannel.cs => EncoderChannel.cs} (87%) rename lib/csharp/se/lth/control/labcomm/{LabCommEncoderRegistry.cs => EncoderRegistry.cs} (72%) delete mode 100644 lib/csharp/se/lth/control/labcomm/LabCommSample.cs delete mode 100644 lib/csharp/se/lth/control/labcomm/LabCommType.cs create mode 100644 lib/csharp/se/lth/control/labcomm/Sample.cs rename lib/csharp/se/lth/control/labcomm/{LabCommDispatcher.cs => SampleDispatcher.cs} (57%) rename lib/csharp/se/lth/control/labcomm/{LabCommHandler.cs => SampleHandler.cs} (53%) create mode 100644 lib/csharp/se/lth/control/labcomm/SampleType.cs diff --git a/compiler/CS_CodeGen.jrag b/compiler/CS_CodeGen.jrag index c147dc6..a4a42e0 100644 --- a/compiler/CS_CodeGen.jrag +++ b/compiler/CS_CodeGen.jrag @@ -268,7 +268,7 @@ aspect CS_Class { pp(env.getPrintStream()); env.println("*/"); env.println(); - env.println("public class " + getName() + " : LabCommType {"); + env.println("public class " + getName() + " : SampleType {"); env.println(); env.indent(); getType().CS_emitInstance(env); @@ -284,11 +284,11 @@ aspect CS_Class { pp(env.getPrintStream()); env.println("*/"); env.println(); - env.println("public class " + getName() + " : LabCommSample {"); + env.println("public class " + getName() + " : Sample {"); env.println(); env.indent(); getType().CS_emitInstance(env); - env.println("public interface Handler : LabCommHandler {"); + env.println("public interface Handler : SampleHandler {"); env.print(" void handle("); if (!isVoid()) { getType().CS_emitType(env); @@ -297,21 +297,21 @@ aspect CS_Class { env.println(");"); env.println("}"); env.println(); - env.println("public static void register(LabCommDecoder d, Handler h) {"); + env.println("public static void register(Decoder d, Handler h) {"); env.indent(); env.println("d.register(new Dispatcher(), h);"); env.unindent(); env.println("}"); env.println(); - env.println("public static void register(LabCommEncoder e) {"); + env.println("public static void register(Encoder e) {"); env.indent(); env.println("e.register(new Dispatcher());"); env.unindent(); env.println("}"); env.println(); - env.println("private class Dispatcher : LabCommDispatcher {"); + env.println("private class Dispatcher : SampleDispatcher {"); env.indent(); env.println(); env.println("public Type getSampleClass() {"); @@ -332,7 +332,7 @@ aspect CS_Class { env.unindent(); env.println("}"); env.println(); - env.println("public void decodeAndHandle(LabCommDecoder d, LabCommHandler h) {"); + env.println("public void decodeAndHandle(Decoder d, SampleHandler h) {"); env.indent(); if (isVoid()) { env.println(getName() + ".decode(d);"); @@ -374,7 +374,7 @@ aspect CS_Class { } public void TypeDecl.CS_emitEncoder(CS_env env) { - env.print("public static void encode(LabCommEncoder e"); + env.print("public static void encode(Encoder e"); if (!isVoid()) { env.print(", "); getType().CS_emitType(env); @@ -389,7 +389,7 @@ aspect CS_Class { } public void SampleDecl.CS_emitEncoder(CS_env env) { - env.print("public static void encode(LabCommEncoder e"); + env.print("public static void encode(Encoder e"); if (!isVoid()) { env.print(", "); getType().CS_emitType(env); @@ -485,7 +485,7 @@ aspect CS_Class { public void Decl.CS_emitDecoder(CS_env env) { env.print("public static "); getType().CS_emitType(env); - env.println(" decode(LabCommDecoder d) {"); + env.println(" decode(Decoder d) {"); env.indent(); if (!isVoid()) { getType().CS_emitType(env); diff --git a/examples/robot/Program.cs b/examples/robot/Program.cs index 28fddc2..56cfb27 100644 --- a/examples/robot/Program.cs +++ b/examples/robot/Program.cs @@ -24,7 +24,7 @@ namespace RobotCtrl try { client.Connect(serverEndPoint); - LabCommEncoder enc = new LabCommEncoderChannel(client.GetStream(), true); + Encoder enc = new EncoderChannel(client.GetStream(), true); jointtarget.register(enc); jointtarget.encode(enc, val); for (int i = 0; i < 10; i++) diff --git a/lib/csharp/Makefile b/lib/csharp/Makefile index 9a7d581..370c77e 100644 --- a/lib/csharp/Makefile +++ b/lib/csharp/Makefile @@ -1,14 +1,14 @@ -MODULES=LabCommDispatcher \ - LabCommDecoderRegistry \ - LabComm \ - LabCommSample \ - LabCommHandler \ - LabCommEncoderRegistry \ - LabCommDecoder \ - LabCommType \ - LabCommEncoderChannel \ - LabCommEncoder \ - LabCommDecoderChannel \ +MODULES=Constant\ + Decoder \ + DecoderChannel \ + DecoderRegistry \ + Encoder \ + EncoderChannel \ + EncoderRegistry \ + Sample \ + SampleDispatcher \ + SampleHandler \ + SampleType all: labcomm.dll diff --git a/lib/csharp/se/lth/control/labcomm/LabComm.cs b/lib/csharp/se/lth/control/labcomm/Constant.cs similarity index 97% rename from lib/csharp/se/lth/control/labcomm/LabComm.cs rename to lib/csharp/se/lth/control/labcomm/Constant.cs index 32ec6cf..e2f39a4 100644 --- a/lib/csharp/se/lth/control/labcomm/LabComm.cs +++ b/lib/csharp/se/lth/control/labcomm/Constant.cs @@ -1,6 +1,6 @@ namespace se.lth.control.labcomm { - public class LabComm { + public class Constant { public const string VERSION = "LabComm20141009"; diff --git a/lib/csharp/se/lth/control/labcomm/LabCommDecoder.cs b/lib/csharp/se/lth/control/labcomm/Decoder.cs similarity index 71% rename from lib/csharp/se/lth/control/labcomm/LabCommDecoder.cs rename to lib/csharp/se/lth/control/labcomm/Decoder.cs index bcb9dea..6f2086b 100644 --- a/lib/csharp/se/lth/control/labcomm/LabCommDecoder.cs +++ b/lib/csharp/se/lth/control/labcomm/Decoder.cs @@ -2,10 +2,10 @@ using System; namespace se.lth.control.labcomm { - public interface LabCommDecoder { + public interface Decoder { - void register(LabCommDispatcher dispatcher, - LabCommHandler handler); + void register(SampleDispatcher dispatcher, + SampleHandler handler); bool decodeBoolean(); byte decodeByte(); diff --git a/lib/csharp/se/lth/control/labcomm/LabCommDecoderChannel.cs b/lib/csharp/se/lth/control/labcomm/DecoderChannel.cs similarity index 85% rename from lib/csharp/se/lth/control/labcomm/LabCommDecoderChannel.cs rename to lib/csharp/se/lth/control/labcomm/DecoderChannel.cs index 0464977..493f10d 100644 --- a/lib/csharp/se/lth/control/labcomm/LabCommDecoderChannel.cs +++ b/lib/csharp/se/lth/control/labcomm/DecoderChannel.cs @@ -5,18 +5,18 @@ namespace se.lth.control.labcomm { using System.Runtime.InteropServices; using System.Text; - public class LabCommDecoderChannel : LabCommDecoder { + public class DecoderChannel : Decoder { private Stream stream; - private LabCommDecoderRegistry registry = new LabCommDecoderRegistry(); + private DecoderRegistry registry = new DecoderRegistry(); byte[] buf = new byte[8]; - public LabCommDecoderChannel(Stream stream) { + public DecoderChannel(Stream stream) { this.stream = stream; String version = decodeString(); - if (version != LabComm.VERSION) { + if (version != Constant.VERSION) { throw new IOException("LabComm version mismatch " + - version + " != " + LabComm.VERSION); + version + " != " + Constant.VERSION); } } @@ -26,7 +26,7 @@ namespace se.lth.control.labcomm { int tag = decodePacked32(); int length = decodePacked32(); switch (tag) { - case LabComm.SAMPLE: { + case Constant.SAMPLE: { int index = decodePacked32(); String name = decodeString(); int signature_length = decodePacked32(); @@ -35,15 +35,15 @@ namespace se.lth.control.labcomm { registry.add(index, name, signature); } break; default: { - LabCommDecoderRegistry.Entry e = registry.get(tag); + DecoderRegistry.Entry e = registry.get(tag); if (e == null) { throw new IOException("Unhandled tag " + tag); } - LabCommDispatcher d = e.getDispatcher(); + SampleDispatcher d = e.getSampleDispatcher(); if (d == null) { throw new IOException("No dispatcher for '" + e.getName() + "'" + e.getSignature()); } - LabCommHandler h = e.getHandler(); + SampleHandler h = e.getHandler(); if (h == null) { throw new IOException("No handler for '" + e.getName() +"'"); } @@ -60,8 +60,8 @@ namespace se.lth.control.labcomm { } } - public void register(LabCommDispatcher dispatcher, - LabCommHandler handler) { + public void register(SampleDispatcher dispatcher, + SampleHandler handler) { registry.add(dispatcher, handler); } diff --git a/lib/csharp/se/lth/control/labcomm/LabCommDecoderRegistry.cs b/lib/csharp/se/lth/control/labcomm/DecoderRegistry.cs similarity index 84% rename from lib/csharp/se/lth/control/labcomm/LabCommDecoderRegistry.cs rename to lib/csharp/se/lth/control/labcomm/DecoderRegistry.cs index ed522e0..132e37b 100644 --- a/lib/csharp/se/lth/control/labcomm/LabCommDecoderRegistry.cs +++ b/lib/csharp/se/lth/control/labcomm/DecoderRegistry.cs @@ -3,18 +3,18 @@ namespace se.lth.control.labcomm { using System; using System.Collections.Generic; - public class LabCommDecoderRegistry { + public class DecoderRegistry { public class Entry { - private LabCommDispatcher dispatcher; - private LabCommHandler handler; + private SampleDispatcher dispatcher; + private SampleHandler handler; private int index; private String name; private byte[] signature; - public Entry(LabCommDispatcher dispatcher, - LabCommHandler handler) { + public Entry(SampleDispatcher dispatcher, + SampleHandler handler) { this.dispatcher = dispatcher; this.name = dispatcher.getName(); this.signature = dispatcher.getSignature(); @@ -27,19 +27,19 @@ namespace se.lth.control.labcomm { this.signature = signature; } - public LabCommDispatcher getDispatcher() { + public SampleDispatcher getSampleDispatcher() { return dispatcher; } - public void setDispatcher(LabCommDispatcher dispatcher) { + public void setSampleDispatcher(SampleDispatcher dispatcher) { this.dispatcher = dispatcher; } - public LabCommHandler getHandler() { + public SampleHandler getHandler() { return handler; } - public void setHandler(LabCommHandler handler) { + public void setHandler(SampleHandler handler) { this.handler = handler; } @@ -93,13 +93,13 @@ namespace se.lth.control.labcomm { private Dictionary<Type, Entry> byClass; private Dictionary<int, Entry> byIndex; - public LabCommDecoderRegistry() { + public DecoderRegistry() { byClass = new Dictionary<Type, Entry>(); byIndex = new Dictionary<int, Entry>(); } - public void add(LabCommDispatcher dispatcher, - LabCommHandler handler) { + public void add(SampleDispatcher dispatcher, + SampleHandler handler) { lock(this) { Entry e; byClass.TryGetValue(dispatcher.getSampleClass(), out e); @@ -109,7 +109,7 @@ namespace se.lth.control.labcomm { } else { foreach (Entry e2 in byIndex.Values) { if (e2.match(dispatcher.getName(), dispatcher.getSignature())) { - e2.setDispatcher(dispatcher); + e2.setSampleDispatcher(dispatcher); e2.setHandler(handler); e = e2; break; diff --git a/lib/csharp/se/lth/control/labcomm/LabCommEncoder.cs b/lib/csharp/se/lth/control/labcomm/Encoder.cs similarity index 83% rename from lib/csharp/se/lth/control/labcomm/LabCommEncoder.cs rename to lib/csharp/se/lth/control/labcomm/Encoder.cs index aadc98e..f33af17 100644 --- a/lib/csharp/se/lth/control/labcomm/LabCommEncoder.cs +++ b/lib/csharp/se/lth/control/labcomm/Encoder.cs @@ -2,9 +2,9 @@ namespace se.lth.control.labcomm { using System; - public interface LabCommEncoder { + public interface Encoder { - void register(LabCommDispatcher dispatcher); + void register(SampleDispatcher dispatcher); void begin(Type c); void end(Type c); diff --git a/lib/csharp/se/lth/control/labcomm/LabCommEncoderChannel.cs b/lib/csharp/se/lth/control/labcomm/EncoderChannel.cs similarity index 87% rename from lib/csharp/se/lth/control/labcomm/LabCommEncoderChannel.cs rename to lib/csharp/se/lth/control/labcomm/EncoderChannel.cs index 6dc6b66..92c9070 100644 --- a/lib/csharp/se/lth/control/labcomm/LabCommEncoderChannel.cs +++ b/lib/csharp/se/lth/control/labcomm/EncoderChannel.cs @@ -5,30 +5,30 @@ namespace se.lth.control.labcomm { using System.Text; using System.Runtime.InteropServices; - public class LabCommEncoderChannel : LabCommEncoder { + public class EncoderChannel : Encoder { private Stream writer; private MemoryStream bytes = new MemoryStream(); - private LabCommEncoderRegistry registry = new LabCommEncoderRegistry(); + private EncoderRegistry registry = new EncoderRegistry(); byte[] buf = new byte[8]; private int current_tag; - public LabCommEncoderChannel(Stream writer, bool emitVersion) { + public EncoderChannel(Stream writer, bool emitVersion) { this.writer = writer; if (emitVersion) { - encodeString(LabComm.VERSION); + encodeString(Constant.VERSION); bytes.WriteTo(writer); bytes.SetLength(0); writer.Flush(); } } - public LabCommEncoderChannel(Stream writer) : this(writer, true) { + public EncoderChannel(Stream writer) : this(writer, true) { } - public void register(LabCommDispatcher dispatcher) { + public void register(SampleDispatcher dispatcher) { int index = registry.add(dispatcher); - begin(LabComm.SAMPLE); + begin(Constant.SAMPLE); encodePacked32(index); encodeString(dispatcher.getName()); byte[] signature = dispatcher.getSignature(); diff --git a/lib/csharp/se/lth/control/labcomm/LabCommEncoderRegistry.cs b/lib/csharp/se/lth/control/labcomm/EncoderRegistry.cs similarity index 72% rename from lib/csharp/se/lth/control/labcomm/LabCommEncoderRegistry.cs rename to lib/csharp/se/lth/control/labcomm/EncoderRegistry.cs index 6bc5d40..9c40028 100644 --- a/lib/csharp/se/lth/control/labcomm/LabCommEncoderRegistry.cs +++ b/lib/csharp/se/lth/control/labcomm/EncoderRegistry.cs @@ -3,19 +3,19 @@ namespace se.lth.control.labcomm { using System; using System.Collections.Generic; - public class LabCommEncoderRegistry { + public class EncoderRegistry { public class Entry { - private LabCommDispatcher dispatcher; + private SampleDispatcher dispatcher; private int index; - public Entry(LabCommDispatcher dispatcher, int index) { + public Entry(SampleDispatcher dispatcher, int index) { this.dispatcher = dispatcher; this.index = index; } - public LabCommDispatcher getDispatcher() { + public SampleDispatcher getSampleDispatcher() { return dispatcher; } @@ -25,14 +25,14 @@ namespace se.lth.control.labcomm { } - private int userIndex = LabComm.FIRST_USER_INDEX; + private int userIndex = Constant.FIRST_USER_INDEX; private Dictionary<Type, Entry> byClass; - public LabCommEncoderRegistry() { + public EncoderRegistry() { byClass = new Dictionary<Type, Entry>(); } - public int add(LabCommDispatcher dispatcher) { + public int add(SampleDispatcher dispatcher) { lock(this) { Entry e; byClass.TryGetValue(dispatcher.getSampleClass(), out e); diff --git a/lib/csharp/se/lth/control/labcomm/LabCommSample.cs b/lib/csharp/se/lth/control/labcomm/LabCommSample.cs deleted file mode 100644 index 235d97d..0000000 --- a/lib/csharp/se/lth/control/labcomm/LabCommSample.cs +++ /dev/null @@ -1,3 +0,0 @@ -public interface LabCommSample { - -} diff --git a/lib/csharp/se/lth/control/labcomm/LabCommType.cs b/lib/csharp/se/lth/control/labcomm/LabCommType.cs deleted file mode 100644 index 1004681..0000000 --- a/lib/csharp/se/lth/control/labcomm/LabCommType.cs +++ /dev/null @@ -1,3 +0,0 @@ -public interface LabCommType { - -} diff --git a/lib/csharp/se/lth/control/labcomm/Sample.cs b/lib/csharp/se/lth/control/labcomm/Sample.cs new file mode 100644 index 0000000..ac56229 --- /dev/null +++ b/lib/csharp/se/lth/control/labcomm/Sample.cs @@ -0,0 +1,3 @@ +public interface Sample { + +} diff --git a/lib/csharp/se/lth/control/labcomm/LabCommDispatcher.cs b/lib/csharp/se/lth/control/labcomm/SampleDispatcher.cs similarity index 57% rename from lib/csharp/se/lth/control/labcomm/LabCommDispatcher.cs rename to lib/csharp/se/lth/control/labcomm/SampleDispatcher.cs index 75b0652..23d39ed 100644 --- a/lib/csharp/se/lth/control/labcomm/LabCommDispatcher.cs +++ b/lib/csharp/se/lth/control/labcomm/SampleDispatcher.cs @@ -2,7 +2,7 @@ namespace se.lth.control.labcomm { using System; - public interface LabCommDispatcher { + public interface SampleDispatcher { Type getSampleClass(); @@ -10,8 +10,8 @@ namespace se.lth.control.labcomm { byte[] getSignature(); - void decodeAndHandle(LabCommDecoder decoder, - LabCommHandler handler); + void decodeAndHandle(Decoder decoder, + SampleHandler handler); } diff --git a/lib/csharp/se/lth/control/labcomm/LabCommHandler.cs b/lib/csharp/se/lth/control/labcomm/SampleHandler.cs similarity index 53% rename from lib/csharp/se/lth/control/labcomm/LabCommHandler.cs rename to lib/csharp/se/lth/control/labcomm/SampleHandler.cs index 3d7f293..d30cd26 100644 --- a/lib/csharp/se/lth/control/labcomm/LabCommHandler.cs +++ b/lib/csharp/se/lth/control/labcomm/SampleHandler.cs @@ -1,6 +1,6 @@ namespace se.lth.control.labcomm { - public interface LabCommHandler { + public interface SampleHandler { } } \ No newline at end of file diff --git a/lib/csharp/se/lth/control/labcomm/SampleType.cs b/lib/csharp/se/lth/control/labcomm/SampleType.cs new file mode 100644 index 0000000..42bd601 --- /dev/null +++ b/lib/csharp/se/lth/control/labcomm/SampleType.cs @@ -0,0 +1,3 @@ +public interface SampleType { + +} diff --git a/test/relay_gen_cs.py b/test/relay_gen_cs.py index 68fdc4d..669f5f5 100755 --- a/test/relay_gen_cs.py +++ b/test/relay_gen_cs.py @@ -35,7 +35,7 @@ if __name__ == '__main__': result.append(' %s.Handler' % sample[-1][0]) result.extend(split_match('^[^|]*\|(.*)$', """ |{ - | LabCommEncoderChannel encoder; + | EncoderChannel encoder; """)) for func,arg in sample: if arg == 'void': @@ -58,11 +58,11 @@ if __name__ == '__main__': | FileStream InFile = new FileStream(InName, | FileMode.Open, | FileAccess.Read); - | LabCommDecoderChannel d = new LabCommDecoderChannel(InFile); + | DecoderChannel d = new DecoderChannel(InFile); | FileStream OutFile = new FileStream(OutName, | FileMode.OpenOrCreate, | FileAccess.Write); - | encoder = new LabCommEncoderChannel(OutFile); + | encoder = new EncoderChannel(OutFile); | """)) for func,arg in sample: -- GitLab