diff --git a/compiler/CS_CodeGen.jrag b/compiler/CS_CodeGen.jrag index c147dc6da26ea3a57bab97c551c31a64aad1a78e..a4a42e03e44a1ce651c15299ddfb800fc77f07b2 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 28fddc27a50c93ec91d9db5ced4ab3d58a215a01..56cfb271d07a42885f8e5790b2eed23adebbc894 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 9a7d581e2594e79c0480ca0b9d26b9138e295187..370c77e2fce1d12e48fa99ff3ce766feab2748b7 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 32ec6cfdafc359001f2ddb956d4b15749f531dbb..e2f39a4dc68a2103f995ce254d09959a82ac1e39 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 bcb9dea3ba2de20d94ad76b0826048b605156ab4..6f2086b8aa4a6b622998f4ef043dbd765dac61a7 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 0464977cfece1c0f09e58bd85164fdd598522b27..493f10d4480e48beb010534907055c957b994e6e 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 ed522e0d76f5a2935d401e2b55fcbf9ab559c4ce..132e37b1849c965a51093fc403f277b1bc615394 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 aadc98ebfc4c2cd00844ade06ae5a1dd13f19043..f33af1718bdbb7ad1e5523659be86a8f6d0ff920 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 6dc6b66b7b007858e2c206e8b91fe8bb192e1fb4..92c9070c65b5af2897226902eb1af0d3f4664218 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 6bc5d4056459eccac4db6ea586ccfc7ed826c554..9c40028567ac2d3df3080e6d2fd88d7e796a6d4f 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 235d97d1e48443e290428df905531ef63402a377..0000000000000000000000000000000000000000 --- 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 10046819f059d114af4de5f3a15a4a35da5017c5..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..ac562293a0e369a7996099068b5d7b94473a7f84 --- /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 75b06522be195d6337bf132221aff045bd71406c..23d39ed510ac07653c753e201f452788a97a901f 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 3d7f293d471b439d373a215f663b83c62d132781..d30cd2623c954dcb22917225d46ed79a4d6dc3f3 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 0000000000000000000000000000000000000000..42bd601cb74a9516e3fdd2ff631f9340077802c5 --- /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 68fdc4de6db96a45ae1d75fc263fd3ebc498aafe..669f5f5b131a01b2161a77d6f04a3f102bb83f56 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: