diff --git a/examples/simple/Decoder.java b/examples/simple/Decoder.java index b4947f88d32595ffc82f308b9434ecb8eae00774..266b895251b6237ee53777dbc05fb8636e13dfff 100644 --- a/examples/simple/Decoder.java +++ b/examples/simple/Decoder.java @@ -5,7 +5,7 @@ import java.io.InputStream; import se.lth.control.labcomm.LabCommDecoderChannel; public class Decoder - implements TwoInts.Handler, IntString.Handler, TwoArrays.Handler, TwoFixedArrays.Handler + implements theTwoInts.Handler, anotherTwoInts.Handler, IntString.Handler, TwoArrays.Handler, TwoFixedArrays.Handler { @@ -15,7 +15,8 @@ public class Decoder throws Exception { decoder = new LabCommDecoderChannel(in); - TwoInts.register(decoder, this); + theTwoInts.register(decoder, this); + anotherTwoInts.register(decoder, this); IntString.register(decoder, this); TwoArrays.register(decoder, this); TwoFixedArrays.register(decoder, this); @@ -28,8 +29,18 @@ public class Decoder } } - public void handle_TwoInts(TwoInts d) throws java.io.IOException { - System.out.println("Got TwoInts, a="+d.a+", b="+d.b); + public void printTwoInts(TwoInts d) throws java.io.IOException { + System.out.println("a="+d.a+", b="+d.b); + } + + public void handle_theTwoInts(TwoInts d) throws java.io.IOException { + System.out.print("Got theTwoInts: "); + printTwoInts(d); + } + + public void handle_anotherTwoInts(TwoInts d) throws java.io.IOException { + System.out.print("Got anotherheTwoInts: "); + printTwoInts(d); } public void handle_IntString(IntString d) throws java.io.IOException { diff --git a/examples/simple/Encoder.java b/examples/simple/Encoder.java index 3209f7a830e717c757e6a2aa10e8853016bcac78..2da41c781b89c8d789e7eca8a1c957d60bf09ad3 100644 --- a/examples/simple/Encoder.java +++ b/examples/simple/Encoder.java @@ -16,7 +16,7 @@ public class Encoder throws Exception { encoder = new LabCommEncoderChannel(out); - TwoInts.register(encoder); + theTwoInts.register(encoder); IntString.register(encoder); } @@ -29,8 +29,8 @@ public class Encoder y.x = 37; y.s = "Testing, testing"; - System.out.println("Encoding TwoInts, a="+x.a+", b="+x.b); - TwoInts.encode(encoder, x); + System.out.println("Encoding theTwoInts, a="+x.a+", b="+x.b); + theTwoInts.encode(encoder, x); System.out.println("Encoding IntString, x="+y.x+", s="+y.s); IntString.encode(encoder, y); diff --git a/examples/simple/example_decoder.c b/examples/simple/example_decoder.c index 50d2530282adad3747014f8ac41e3d7bc1693dbd..6774808efec297e0163eb8531599457a47a6d163 100644 --- a/examples/simple/example_decoder.c +++ b/examples/simple/example_decoder.c @@ -4,8 +4,12 @@ #include <labcomm_fd_reader_writer.h> #include "gen/simple.h" -static void handle_simple_TwoInts(simple_TwoInts *v,void *context) { - printf("Got TwoInts. a=%d, b=%d\n", v->a, v->b); +static void handle_simple_theTwoInts(simple_TwoInts *v,void *context) { + printf("Got theTwoInts. a=%d, b=%d\n", v->a, v->b); +} + +static void handle_simple_anotherTwoInts(simple_TwoInts *v,void *context) { + printf("Got anotherTwoInts. a=%d, b=%d\n", v->a, v->b); } static void handle_simple_IntString(simple_IntString *v,void *context) { @@ -55,7 +59,8 @@ int main(int argc, char *argv[]) { return 1; } - labcomm_decoder_register_simple_TwoInts(decoder, handle_simple_TwoInts, context); + labcomm_decoder_register_simple_theTwoInts(decoder, handle_simple_theTwoInts, context); + labcomm_decoder_register_simple_anotherTwoInts(decoder, handle_simple_anotherTwoInts, context); labcomm_decoder_register_simple_IntString(decoder, handle_simple_IntString, context); labcomm_decoder_register_simple_TwoArrays(decoder, handle_simple_TwoArrays, context); labcomm_decoder_register_simple_TwoFixedArrays(decoder, handle_simple_TwoFixedArrays, context); diff --git a/examples/simple/example_encoder.c b/examples/simple/example_encoder.c index 8192f56497c1424dd44c8a831cedcfc663923db0..5ce76eaaf87c7affb2c5dd0410e4ef179662dc25 100644 --- a/examples/simple/example_encoder.c +++ b/examples/simple/example_encoder.c @@ -13,7 +13,8 @@ int main(int argc, char *argv[]) { printf("C encoder writing to %s\n", filename); fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644); encoder = labcomm_encoder_new(labcomm_fd_writer, &fd); - labcomm_encoder_register_simple_TwoInts(encoder); + labcomm_encoder_register_simple_theTwoInts(encoder); + labcomm_encoder_register_simple_anotherTwoInts(encoder); labcomm_encoder_register_simple_IntString(encoder); simple_IntString is; is.x = 24; @@ -21,11 +22,17 @@ int main(int argc, char *argv[]) { printf("Encoding IntString, x=%d, s=%s\n", is.x, is.s); labcomm_encode_simple_IntString(encoder, &is); - simple_TwoInts ti; + simple_theTwoInts ti; ti.a = 13; ti.b = 37; - printf("Encoding TwoInts, a=%d, b=%d\n", ti.a, ti.b); - labcomm_encode_simple_TwoInts(encoder, &ti); + printf("Encoding theTwoInts, a=%d, b=%d\n", ti.a, ti.b); + labcomm_encode_simple_theTwoInts(encoder, &ti); + + simple_anotherTwoInts ati; + ati.a = 23; + ati.b = 47; + printf("Encoding anotherTwoInts, a=%d, b=%d\n", ati.a, ati.b); + labcomm_encode_simple_anotherTwoInts(encoder, &ati); int foo[20]; @@ -47,8 +54,8 @@ int main(int argc, char *argv[]) { ti.a = 23; ti.b = 47; - printf("Encoding TwoInts, a=%d, b=%d\n", ti.a, ti.b); - labcomm_encode_simple_TwoInts(encoder, &ti); + printf("Encoding theTwoInts, a=%d, b=%d\n", ti.a, ti.b); + labcomm_encode_simple_theTwoInts(encoder, &ti); simple_TwoFixedArrays tfa; diff --git a/examples/simple/simple.lc b/examples/simple/simple.lc index 9bb352f22845ef88226a11c7537f7cd9f64c5cea..518395755eda152f137213ae8ab86fed14434f16 100644 --- a/examples/simple/simple.lc +++ b/examples/simple/simple.lc @@ -1,8 +1,11 @@ -sample struct { +typedef struct { int a; int b; } TwoInts; +sample TwoInts theTwoInts; +sample TwoInts anotherTwoInts; + sample struct { int x; string s;