Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
LabComm
Commits
7ef98a98
Commit
7ef98a98
authored
Oct 14, 2014
by
Anders Blomdell
Browse files
Major C# rename spree.
parent
a42235a0
Changes
17
Hide whitespace changes
Inline
Side-by-side
compiler/CS_CodeGen.jrag
View file @
7ef98a98
...
...
@@ -268,7 +268,7 @@ aspect CS_Class {
pp(env.getPrintStream());
env.println("*/");
env.println();
env.println("public class " + getName() + " :
LabComm
Type {");
env.println("public class " + getName() + " :
Sample
Type {");
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() + " :
LabComm
Sample {");
env.println("public class " + getName() + " : Sample {");
env.println();
env.indent();
getType().CS_emitInstance(env);
env.println("public interface Handler :
LabComm
Handler {");
env.println("public interface Handler :
Sample
Handler {");
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(
LabComm
Decoder 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(
LabComm
Encoder 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 :
LabComm
Dispatcher {");
env.println("private class Dispatcher :
Sample
Dispatcher {");
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(
LabComm
Decoder d,
LabComm
Handler h) {");
env.println("public void decodeAndHandle(Decoder d,
Sample
Handler 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(
LabComm
Encoder 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(
LabComm
Encoder 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(
LabComm
Decoder d) {");
env.println(" decode(Decoder d) {");
env.indent();
if (!isVoid()) {
getType().CS_emitType(env);
...
...
examples/robot/Program.cs
View file @
7ef98a98
...
...
@@ -24,7 +24,7 @@ namespace RobotCtrl
try
{
client
.
Connect
(
serverEndPoint
);
LabComm
Encoder
enc
=
new
LabComm
EncoderChannel
(
client
.
GetStream
(),
true
);
Encoder
enc
=
new
EncoderChannel
(
client
.
GetStream
(),
true
);
jointtarget
.
register
(
enc
);
jointtarget
.
encode
(
enc
,
val
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
...
...
lib/csharp/Makefile
View file @
7ef98a98
MODULES
=
LabCommDispatcher
\
LabCommDecoderRegistry
\
LabComm
\
LabCommSample
\
LabCommHandl
er
\
LabCommEncoderRegistry
\
LabCommDecoder
\
LabCommTyp
e
\
LabCommEncoderChannel
\
LabCommEncod
er
\
LabCommDecoderChannel
\
MODULES
=
Constant
\
Decoder
\
DecoderChannel
\
DecoderRegistry
\
Encod
er
\
EncoderChannel
\
EncoderRegistry
\
Sampl
e
\
SampleDispatcher
\
SampleHandl
er
\
SampleType
all
:
labcomm.dll
...
...
lib/csharp/se/lth/control/labcomm/
LabComm
.cs
→
lib/csharp/se/lth/control/labcomm/
Constant
.cs
View file @
7ef98a98
namespace
se.lth.control.labcomm
{
public
class
LabComm
{
public
class
Constant
{
public
const
string
VERSION
=
"LabComm20141009"
;
...
...
lib/csharp/se/lth/control/labcomm/
LabComm
Decoder.cs
→
lib/csharp/se/lth/control/labcomm/Decoder.cs
View file @
7ef98a98
...
...
@@ -2,10 +2,10 @@ using System;
namespace
se.lth.control.labcomm
{
public
interface
LabComm
Decoder
{
public
interface
Decoder
{
void
register
(
LabComm
Dispatcher
dispatcher
,
LabComm
Handler
handler
);
void
register
(
Sample
Dispatcher
dispatcher
,
Sample
Handler
handler
);
bool
decodeBoolean
();
byte
decodeByte
();
...
...
lib/csharp/se/lth/control/labcomm/
LabComm
DecoderChannel.cs
→
lib/csharp/se/lth/control/labcomm/DecoderChannel.cs
View file @
7ef98a98
...
...
@@ -5,18 +5,18 @@ namespace se.lth.control.labcomm {
using
System.Runtime.InteropServices
;
using
System.Text
;
public
class
LabComm
DecoderChannel
:
LabComm
Decoder
{
public
class
DecoderChannel
:
Decoder
{
private
Stream
stream
;
private
LabComm
DecoderRegistry
registry
=
new
LabComm
DecoderRegistry
();
private
DecoderRegistry
registry
=
new
DecoderRegistry
();
byte
[]
buf
=
new
byte
[
8
];
public
LabComm
DecoderChannel
(
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
:
{
LabComm
DecoderRegistry
.
Entry
e
=
registry
.
get
(
tag
);
DecoderRegistry
.
Entry
e
=
registry
.
get
(
tag
);
if
(
e
==
null
)
{
throw
new
IOException
(
"Unhandled tag "
+
tag
);
}
LabComm
Dispatcher
d
=
e
.
getDispatcher
();
Sample
Dispatcher
d
=
e
.
get
Sample
Dispatcher
();
if
(
d
==
null
)
{
throw
new
IOException
(
"No dispatcher for '"
+
e
.
getName
()
+
"'"
+
e
.
getSignature
());
}
LabComm
Handler
h
=
e
.
getHandler
();
Sample
Handler
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
(
LabComm
Dispatcher
dispatcher
,
LabComm
Handler
handler
)
{
public
void
register
(
Sample
Dispatcher
dispatcher
,
Sample
Handler
handler
)
{
registry
.
add
(
dispatcher
,
handler
);
}
...
...
lib/csharp/se/lth/control/labcomm/
LabComm
DecoderRegistry.cs
→
lib/csharp/se/lth/control/labcomm/DecoderRegistry.cs
View file @
7ef98a98
...
...
@@ -3,18 +3,18 @@ namespace se.lth.control.labcomm {
using
System
;
using
System.Collections.Generic
;
public
class
LabComm
DecoderRegistry
{
public
class
DecoderRegistry
{
public
class
Entry
{
private
LabComm
Dispatcher
dispatcher
;
private
LabComm
Handler
handler
;
private
Sample
Dispatcher
dispatcher
;
private
Sample
Handler
handler
;
private
int
index
;
private
String
name
;
private
byte
[]
signature
;
public
Entry
(
LabComm
Dispatcher
dispatcher
,
LabComm
Handler
handler
)
{
public
Entry
(
Sample
Dispatcher
dispatcher
,
Sample
Handler
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
LabComm
Dispatcher
getDispatcher
()
{
public
Sample
Dispatcher
get
Sample
Dispatcher
()
{
return
dispatcher
;
}
public
void
setDispatcher
(
LabComm
Dispatcher
dispatcher
)
{
public
void
set
Sample
Dispatcher
(
Sample
Dispatcher
dispatcher
)
{
this
.
dispatcher
=
dispatcher
;
}
public
LabComm
Handler
getHandler
()
{
public
Sample
Handler
getHandler
()
{
return
handler
;
}
public
void
setHandler
(
LabComm
Handler
handler
)
{
public
void
setHandler
(
Sample
Handler
handler
)
{
this
.
handler
=
handler
;
}
...
...
@@ -93,13 +93,13 @@ namespace se.lth.control.labcomm {
private
Dictionary
<
Type
,
Entry
>
byClass
;
private
Dictionary
<
int
,
Entry
>
byIndex
;
public
LabComm
DecoderRegistry
()
{
public
DecoderRegistry
()
{
byClass
=
new
Dictionary
<
Type
,
Entry
>();
byIndex
=
new
Dictionary
<
int
,
Entry
>();
}
public
void
add
(
LabComm
Dispatcher
dispatcher
,
LabComm
Handler
handler
)
{
public
void
add
(
Sample
Dispatcher
dispatcher
,
Sample
Handler
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
.
set
Sample
Dispatcher
(
dispatcher
);
e2
.
setHandler
(
handler
);
e
=
e2
;
break
;
...
...
lib/csharp/se/lth/control/labcomm/
LabComm
Encoder.cs
→
lib/csharp/se/lth/control/labcomm/Encoder.cs
View file @
7ef98a98
...
...
@@ -2,9 +2,9 @@ namespace se.lth.control.labcomm {
using
System
;
public
interface
LabComm
Encoder
{
public
interface
Encoder
{
void
register
(
LabComm
Dispatcher
dispatcher
);
void
register
(
Sample
Dispatcher
dispatcher
);
void
begin
(
Type
c
);
void
end
(
Type
c
);
...
...
lib/csharp/se/lth/control/labcomm/
LabComm
EncoderChannel.cs
→
lib/csharp/se/lth/control/labcomm/EncoderChannel.cs
View file @
7ef98a98
...
...
@@ -5,30 +5,30 @@ namespace se.lth.control.labcomm {
using
System.Text
;
using
System.Runtime.InteropServices
;
public
class
LabComm
EncoderChannel
:
LabComm
Encoder
{
public
class
EncoderChannel
:
Encoder
{
private
Stream
writer
;
private
MemoryStream
bytes
=
new
MemoryStream
();
private
LabComm
EncoderRegistry
registry
=
new
LabComm
EncoderRegistry
();
private
EncoderRegistry
registry
=
new
EncoderRegistry
();
byte
[]
buf
=
new
byte
[
8
];
private
int
current_tag
;
public
LabComm
EncoderChannel
(
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
LabComm
EncoderChannel
(
Stream
writer
)
:
this
(
writer
,
true
)
{
public
EncoderChannel
(
Stream
writer
)
:
this
(
writer
,
true
)
{
}
public
void
register
(
LabComm
Dispatcher
dispatcher
)
{
public
void
register
(
Sample
Dispatcher
dispatcher
)
{
int
index
=
registry
.
add
(
dispatcher
);
begin
(
LabComm
.
SAMPLE
);
begin
(
Constant
.
SAMPLE
);
encodePacked32
(
index
);
encodeString
(
dispatcher
.
getName
());
byte
[]
signature
=
dispatcher
.
getSignature
();
...
...
lib/csharp/se/lth/control/labcomm/
LabComm
EncoderRegistry.cs
→
lib/csharp/se/lth/control/labcomm/EncoderRegistry.cs
View file @
7ef98a98
...
...
@@ -3,19 +3,19 @@ namespace se.lth.control.labcomm {
using
System
;
using
System.Collections.Generic
;
public
class
LabComm
EncoderRegistry
{
public
class
EncoderRegistry
{
public
class
Entry
{
private
LabComm
Dispatcher
dispatcher
;
private
Sample
Dispatcher
dispatcher
;
private
int
index
;
public
Entry
(
LabComm
Dispatcher
dispatcher
,
int
index
)
{
public
Entry
(
Sample
Dispatcher
dispatcher
,
int
index
)
{
this
.
dispatcher
=
dispatcher
;
this
.
index
=
index
;
}
public
LabComm
Dispatcher
getDispatcher
()
{
public
Sample
Dispatcher
get
Sample
Dispatcher
()
{
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
LabComm
EncoderRegistry
()
{
public
EncoderRegistry
()
{
byClass
=
new
Dictionary
<
Type
,
Entry
>();
}
public
int
add
(
LabComm
Dispatcher
dispatcher
)
{
public
int
add
(
Sample
Dispatcher
dispatcher
)
{
lock
(
this
)
{
Entry
e
;
byClass
.
TryGetValue
(
dispatcher
.
getSampleClass
(),
out
e
);
...
...
lib/csharp/se/lth/control/labcomm/LabCommSample.cs
deleted
100644 → 0
View file @
a42235a0
public
interface
LabCommSample
{
}
lib/csharp/se/lth/control/labcomm/LabCommType.cs
deleted
100644 → 0
View file @
a42235a0
public
interface
LabCommType
{
}
lib/csharp/se/lth/control/labcomm/Sample.cs
0 → 100644
View file @
7ef98a98
public
interface
Sample
{
}
lib/csharp/se/lth/control/labcomm/
LabComm
Dispatcher.cs
→
lib/csharp/se/lth/control/labcomm/
Sample
Dispatcher.cs
View file @
7ef98a98
...
...
@@ -2,7 +2,7 @@ namespace se.lth.control.labcomm {
using
System
;
public
interface
LabComm
Dispatcher
{
public
interface
Sample
Dispatcher
{
Type
getSampleClass
();
...
...
@@ -10,8 +10,8 @@ namespace se.lth.control.labcomm {
byte
[]
getSignature
();
void
decodeAndHandle
(
LabComm
Decoder
decoder
,
LabComm
Handler
handler
);
void
decodeAndHandle
(
Decoder
decoder
,
Sample
Handler
handler
);
}
...
...
lib/csharp/se/lth/control/labcomm/
LabComm
Handler.cs
→
lib/csharp/se/lth/control/labcomm/
Sample
Handler.cs
View file @
7ef98a98
namespace
se.lth.control.labcomm
{
public
interface
LabComm
Handler
{
public
interface
Sample
Handler
{
}
}
\ No newline at end of file
lib/csharp/se/lth/control/labcomm/SampleType.cs
0 → 100644
View file @
7ef98a98
public
interface
SampleType
{
}
test/relay_gen_cs.py
View file @
7ef98a98
...
...
@@ -35,7 +35,7 @@ if __name__ == '__main__':
result
.
append
(
' %s.Handler'
%
sample
[
-
1
][
0
])
result
.
extend
(
split_match
(
'^[^|]*\|(.*)$'
,
"""
|{
|
LabComm
EncoderChannel 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);
|
LabComm
DecoderChannel d = new
LabComm
DecoderChannel(InFile);
| DecoderChannel d = new DecoderChannel(InFile);
| FileStream OutFile = new FileStream(OutName,
| FileMode.OpenOrCreate,
| FileAccess.Write);
| encoder = new
LabComm
EncoderChannel(OutFile);
| encoder = new EncoderChannel(OutFile);
|
"""
))
for
func
,
arg
in
sample
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment