From 37fb1da81b1fe9ea4327d8adf31100c127fe0402 Mon Sep 17 00:00:00 2001 From: Sven Gestegard Robertz <sven.robertz@cs.lth.se> Date: Tue, 10 Feb 2015 10:41:28 +0100 Subject: [PATCH] added void type to examples/user_types --- examples/user_types/Decoder.java | 8 +++++++- examples/user_types/Encoder.java | 4 ++++ examples/user_types/ExampleDecoder.cs | 9 ++++++++- examples/user_types/TDDecoder.java | 8 +++++++- examples/user_types/example_decoder.c | 5 +++++ examples/user_types/test.lc | 3 +++ 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/examples/user_types/Decoder.java b/examples/user_types/Decoder.java index 1cff15b..9d15143 100644 --- a/examples/user_types/Decoder.java +++ b/examples/user_types/Decoder.java @@ -15,7 +15,8 @@ public class Decoder TypeDefParser.TypeDefListener, twoInts.Handler, theFirstInt.Handler, - theSecondInt.Handler + theSecondInt.Handler, + doavoid.Handler { private DecoderChannel decoder; @@ -25,6 +26,7 @@ public class Decoder throws Exception { decoder = new DecoderChannel(in); + doavoid.register(decoder, this); twoInts.register(decoder, this); twoLines.register(decoder, this); theFirstInt.register(decoder, this); @@ -73,6 +75,10 @@ public class Decoder //} catch(IOException ex) { ex.printStackTrace();} } + public void handle_doavoid() throws java.io.IOException { + System.out.println("Got a void."); + } + public void handle_twoInts(twoInts d) throws java.io.IOException { System.out.print("Got twoInts: "); System.out.println(d.a +", "+d.b); diff --git a/examples/user_types/Encoder.java b/examples/user_types/Encoder.java index 335bc4f..ac8add6 100644 --- a/examples/user_types/Encoder.java +++ b/examples/user_types/Encoder.java @@ -16,6 +16,7 @@ public class Encoder throws Exception { encoder = new EncoderChannel(out); + doavoid.register(encoder); twoInts.register(encoder); twoLines.register(encoder); theFirstInt.register(encoder); @@ -27,6 +28,9 @@ public class Encoder ti.a = 12; ti.b = 21; + System.out.println("Encoding doavoid"); + doavoid.encode(encoder); + System.out.println("Encoding twoInts"); twoInts.encode(encoder, ti); diff --git a/examples/user_types/ExampleDecoder.cs b/examples/user_types/ExampleDecoder.cs index 7f22a9e..ec0f096 100644 --- a/examples/user_types/ExampleDecoder.cs +++ b/examples/user_types/ExampleDecoder.cs @@ -10,7 +10,8 @@ namespace user_types class Decoder : twoLines.Handler, twoInts.Handler, theFirstInt.Handler, - theSecondInt.Handler + theSecondInt.Handler, + doavoid.Handler { DecoderChannel dec; @@ -21,6 +22,7 @@ namespace user_types twoInts.register(dec, this); theFirstInt.register(dec, this); theSecondInt.register(dec, this); + doavoid.register(dec, this); try { Console.WriteLine("Running decoder."); @@ -64,6 +66,11 @@ namespace user_types Console.WriteLine("Got theSecondInt: "+d); } + void doavoid.Handler.handle() + { + Console.WriteLine("Got a void."); + } + static void Main(string[] args) { new Decoder(new FileStream(args[0], FileMode.Open)); diff --git a/examples/user_types/TDDecoder.java b/examples/user_types/TDDecoder.java index 2f1e4f7..a689842 100644 --- a/examples/user_types/TDDecoder.java +++ b/examples/user_types/TDDecoder.java @@ -25,7 +25,8 @@ public class TDDecoder TypeDefParser.TypeDefListener, twoInts.Handler, theFirstInt.Handler, - theSecondInt.Handler + theSecondInt.Handler, + doavoid.Handler { private DecoderChannel decoder; @@ -39,6 +40,7 @@ public class TDDecoder twoLines.register(decoder, this); theFirstInt.register(decoder, this); theSecondInt.register(decoder, this); + doavoid.register(decoder, this); this.tdp = TypeDefParser.registerTypeDefParser(decoder); // TypeDef.register(decoder, this); // TypeBinding.register(decoder, this); @@ -119,6 +121,10 @@ public class TDDecoder System.out.println("Got theSecondInt: "+d); } + public void handle_doavoid() throws java.io.IOException { + System.out.println("Got a void."); + } + public void handle_twoLines(twoLines d) throws java.io.IOException { System.out.print("Got twoLines: "); System.out.println("Line l1: "+genLine(d.l1)); diff --git a/examples/user_types/example_decoder.c b/examples/user_types/example_decoder.c index 2386564..2728158 100644 --- a/examples/user_types/example_decoder.c +++ b/examples/user_types/example_decoder.c @@ -8,6 +8,10 @@ #include "gen/test.h" #include <stdio.h> +static void handle_test_doavoid(test_doavoid *v,void *context) { + printf("Got a void.\n"); +} + static void handle_test_twoInts(test_twoInts *v,void *context) { printf("Got twoInts. (%d,%d) \n", v->a, v->b); } @@ -53,6 +57,7 @@ int main(int argc, char *argv[]) { return 1; } + labcomm_decoder_register_test_doavoid(decoder, handle_test_doavoid, context); 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); diff --git a/examples/user_types/test.lc b/examples/user_types/test.lc index b232512..f882abb 100644 --- a/examples/user_types/test.lc +++ b/examples/user_types/test.lc @@ -4,6 +4,9 @@ typedef struct { typedef int anInt; +typedef void avoid; +sample avoid doavoid; + typedef struct { coord x; coord y; -- GitLab