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
ee498fe7
Commit
ee498fe7
authored
Jan 30, 2015
by
Sven Gestegård Robertz
Browse files
added typedefs of primitive types to examples/user_types
parent
7df66f2d
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/user_types/Decoder.java
View file @
ee498fe7
...
...
@@ -6,7 +6,9 @@ import se.lth.control.labcomm.DecoderChannel;
public
class
Decoder
implements
twoLines
.
Handler
,
twoInts
.
Handler
twoInts
.
Handler
,
theFirstInt
.
Handler
,
theSecondInt
.
Handler
{
...
...
@@ -18,6 +20,8 @@ public class Decoder
decoder
=
new
DecoderChannel
(
in
);
twoInts
.
register
(
decoder
,
this
);
twoLines
.
register
(
decoder
,
this
);
theFirstInt
.
register
(
decoder
,
this
);
theSecondInt
.
register
(
decoder
,
this
);
try
{
System
.
out
.
println
(
"Running decoder."
);
...
...
@@ -40,6 +44,14 @@ public class Decoder
System
.
out
.
println
(
d
.
a
+
", "
+
d
.
b
);
}
public
void
handle_theFirstInt
(
int
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
println
(
"Got theFirstInt: "
+
d
);
}
public
void
handle_theSecondInt
(
int
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
println
(
"Got theSecondInt: "
+
d
);
}
public
void
handle_twoLines
(
twoLines
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
print
(
"Got twoLines: "
);
System
.
out
.
println
(
"Line l1: "
+
genLine
(
d
.
l1
));
...
...
examples/user_types/Encoder.java
View file @
ee498fe7
...
...
@@ -18,6 +18,8 @@ public class Encoder
encoder
=
new
EncoderChannel
(
out
);
twoInts
.
register
(
encoder
);
twoLines
.
register
(
encoder
);
theFirstInt
.
register
(
encoder
);
theSecondInt
.
register
(
encoder
);
}
public
void
doEncode
()
throws
java
.
io
.
IOException
{
...
...
@@ -28,6 +30,10 @@ public class Encoder
System
.
out
.
println
(
"Encoding twoInts"
);
twoInts
.
encode
(
encoder
,
ti
);
System
.
out
.
println
(
"Encoding the Ints"
);
theFirstInt
.
encode
(
encoder
,
71
);
theSecondInt
.
encode
(
encoder
,
24
);
twoLines
x
=
new
twoLines
();
line
l1
=
new
line
();
point
p11
=
new
point
();
...
...
examples/user_types/example_decoder.c
View file @
ee498fe7
...
...
@@ -12,6 +12,14 @@ static void handle_test_twoInts(test_twoInts *v,void *context) {
printf
(
"Got twoInts. (%d,%d)
\n
"
,
v
->
a
,
v
->
b
);
}
static
void
handle_test_theFirstInt
(
int
*
v
,
void
*
context
)
{
printf
(
"Got theFirstInt. (%d)
\n
"
,
*
v
);
}
static
void
handle_test_theSecondInt
(
int
*
v
,
void
*
context
)
{
printf
(
"Got theSecondInt. (%d)
\n
"
,
*
v
);
}
static
void
handle_test_twoLines
(
test_twoLines
*
v
,
void
*
context
)
{
printf
(
"Got twoLines. (%d,%d) -> (%d,%d), (%d,%d) -> (%d,%d)
\n
"
,
v
->
l1
.
start
.
x
.
val
,
v
->
l1
.
start
.
y
.
val
,
v
->
l1
.
end
.
x
.
val
,
v
->
l1
.
end
.
y
.
val
,
...
...
@@ -38,6 +46,8 @@ int main(int argc, char *argv[]) {
}
labcomm_decoder_register_test_twoInts
(
decoder
,
handle_test_twoInts
,
context
);
labcomm_decoder_register_test_theFirstInt
(
decoder
,
handle_test_theFirstInt
,
context
);
labcomm_decoder_register_test_theSecondInt
(
decoder
,
handle_test_theSecondInt
,
context
);
labcomm_decoder_register_test_twoLines
(
decoder
,
handle_test_twoLines
,
context
);
printf
(
"Decoding:
\n
"
);
...
...
examples/user_types/test.lc
View file @
ee498fe7
...
...
@@ -2,6 +2,8 @@ typedef struct {
int val;
} coord;
typedef int anInt;
typedef struct {
coord x;
coord y;
...
...
@@ -28,3 +30,6 @@ sample struct {
int a;
int b;
} twoInts;
sample anInt theFirstInt;
sample anInt theSecondInt;
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