Commit 7ef98a98 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Major C# rename spree.

parent a42235a0
......@@ -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);
......
......@@ -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++)
......
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
......
namespace se.lth.control.labcomm {
public class LabComm {
public class Constant {
public const string VERSION = "LabComm20141009";
......
......@@ -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();
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -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();
......
......@@ -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);
......
......@@ -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);
}
......
namespace se.lth.control.labcomm {
public interface LabCommHandler {
public interface SampleHandler {
}
}
\ No newline at end of file
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment