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
Sven Gestegård Robertz
LabComm
Commits
825efef0
Commit
825efef0
authored
Dec 02, 2013
by
Sven Gestegård Robertz
Browse files
added var array and string
parent
06f3a09b
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/tcp/Makefile
View file @
825efef0
LCDIR
=
../..
LCCJAR
=
${LCDIR}
/compiler/labComm.jar
LCLJAR
=
${LCDIR}
/lib/java/labcomm.jar
LCCJAR
=
${LCDIR}
/compiler/labComm.jar
# the LabComm compiler
LCLJAR
=
${LCDIR}
/lib/java/labcomm.jar
# the LabComm library
JAVA_PKG
=
labcommTCPtest
.PHONY
:
clean run runserver runOSserver runclient
...
...
@@ -26,7 +26,7 @@ ${LCLJAR} :
${JAVA_PKG}/gen/FooSample.java
:
test.lc ${LCCJAR}
${LCC}
--javapackage
=
${JAVA_PKG}
.gen
--java
=
${JAVA_PKG}
/gen
$<
${JAVA_PKG}/gen/FooSample.class
:
${JAVA_PKG}/gen/FooSample.java ${LCLJAR}
${JAVA_PKG}/gen/FooSample.class
:
${JAVA_PKG}/gen/FooSample.java
test.lc
${LCLJAR}
javac
-cp
${CLASSPATH}
$<
${JAVA_PKG}/Example.class
:
${JAVA_PKG}/Example.java ${JAVA_PKG}/gen/FooSample.class ${LCLJAR}
...
...
examples/tcp/labcommTCPtest/client/TestClient.java
View file @
825efef0
...
...
@@ -28,8 +28,15 @@ public class TestClient implements Handler {
LabCommEncoderChannel
e
=
new
LabCommEncoderChannel
(
out
);
FooSample
.
register
(
e
);
FooSample
sample
=
new
FooSample
();
int
a
[]
=
new
int
[
3
];
a
[
0
]
=
1
;
a
[
1
]
=
2
;
a
[
2
]
=
3
;
sample
.
s
=
"Some random values"
;
sample
.
x
=
17
;
sample
.
y
=
42
;
sample
.
a
=
a
;
sample
.
t
=
1717
;
sample
.
d
=
0.42
;
printSample
(
"Client sending"
,
sample
);
...
...
@@ -57,8 +64,22 @@ public class TestClient implements Handler {
}
}
private
String
formatArray
(
int
a
[])
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"["
);
for
(
int
i
=
0
;
i
<
a
.
length
;
i
++)
{
sb
.
append
(
a
[
i
]);
if
(
i
<
a
.
length
-
1
)
{
sb
.
append
(
", "
);
}
}
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
private
void
printSample
(
String
header
,
FooSample
sample2
)
throws
Exception
{
System
.
out
.
format
(
"[TestClient] %s: (%d, %d, %d, %f)\n"
,
header
,
sample2
.
x
,
sample2
.
y
,
sample2
.
t
,
sample2
.
d
);
System
.
out
.
format
(
"[TestClient] %s: (
%s,
%d, %d,
%s,
%d, %f
)\n"
,
header
,
sample2
.
s
,
sample2
.
x
,
sample2
.
y
,
formatArray
(
sample2
.
a
),
sample2
.
t
,
sample2
.
d
);
}
public
void
handle_FooSample
(
FooSample
sample2
)
throws
Exception
{
...
...
examples/tcp/labcommTCPtest/server/TestServer.java
View file @
825efef0
...
...
@@ -49,9 +49,16 @@ public class TestServer implements Handler {
public
void
handle_FooSample
(
FooSample
sample
)
throws
Exception
{
LabCommEncoderChannel
e
=
new
LabCommEncoderChannel
(
out
);
FooSample
.
register
(
e
);
System
.
out
.
println
(
"TestServer.handle_FooSample..."
);
System
.
out
.
println
(
"TestServer.handle_FooSample: "
+
sample
.
s
);
int
tmp
[]
=
new
int
[
2
*
sample
.
a
.
length
];
for
(
int
i
=
0
;
i
<
sample
.
a
.
length
;
i
++)
{
tmp
[
2
*
i
]
=
tmp
[
2
*
i
+
1
]
=
sample
.
a
[
i
];
}
sample
.
s
=
"double!"
;
sample
.
x
*=
2
;
sample
.
y
*=
2
;
sample
.
a
=
tmp
;
sample
.
t
*=
2
;
sample
.
d
*=
2
;
FooSample
.
encode
(
e
,
sample
);
...
...
examples/tcp/test.lc
View file @
825efef0
sample struct {
string s;
int x;
int y;
int a[_];
long t;
double d;
} FooSample;
Write
Preview
Markdown
is supported
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