Skip to content
Snippets Groups Projects
Commit 37fb1da8 authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

added void type to examples/user_types

parent 541bc230
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,8 @@ public class Decoder ...@@ -15,7 +15,8 @@ public class Decoder
TypeDefParser.TypeDefListener, TypeDefParser.TypeDefListener,
twoInts.Handler, twoInts.Handler,
theFirstInt.Handler, theFirstInt.Handler,
theSecondInt.Handler theSecondInt.Handler,
doavoid.Handler
{ {
private DecoderChannel decoder; private DecoderChannel decoder;
...@@ -25,6 +26,7 @@ public class Decoder ...@@ -25,6 +26,7 @@ public class Decoder
throws Exception throws Exception
{ {
decoder = new DecoderChannel(in); decoder = new DecoderChannel(in);
doavoid.register(decoder, this);
twoInts.register(decoder, this); twoInts.register(decoder, this);
twoLines.register(decoder, this); twoLines.register(decoder, this);
theFirstInt.register(decoder, this); theFirstInt.register(decoder, this);
...@@ -73,6 +75,10 @@ public class Decoder ...@@ -73,6 +75,10 @@ public class Decoder
//} catch(IOException ex) { ex.printStackTrace();} //} 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 { public void handle_twoInts(twoInts d) throws java.io.IOException {
System.out.print("Got twoInts: "); System.out.print("Got twoInts: ");
System.out.println(d.a +", "+d.b); System.out.println(d.a +", "+d.b);
......
...@@ -16,6 +16,7 @@ public class Encoder ...@@ -16,6 +16,7 @@ public class Encoder
throws Exception throws Exception
{ {
encoder = new EncoderChannel(out); encoder = new EncoderChannel(out);
doavoid.register(encoder);
twoInts.register(encoder); twoInts.register(encoder);
twoLines.register(encoder); twoLines.register(encoder);
theFirstInt.register(encoder); theFirstInt.register(encoder);
...@@ -27,6 +28,9 @@ public class Encoder ...@@ -27,6 +28,9 @@ public class Encoder
ti.a = 12; ti.a = 12;
ti.b = 21; ti.b = 21;
System.out.println("Encoding doavoid");
doavoid.encode(encoder);
System.out.println("Encoding twoInts"); System.out.println("Encoding twoInts");
twoInts.encode(encoder, ti); twoInts.encode(encoder, ti);
......
...@@ -10,7 +10,8 @@ namespace user_types ...@@ -10,7 +10,8 @@ namespace user_types
class Decoder : twoLines.Handler, class Decoder : twoLines.Handler,
twoInts.Handler, twoInts.Handler,
theFirstInt.Handler, theFirstInt.Handler,
theSecondInt.Handler theSecondInt.Handler,
doavoid.Handler
{ {
DecoderChannel dec; DecoderChannel dec;
...@@ -21,6 +22,7 @@ namespace user_types ...@@ -21,6 +22,7 @@ namespace user_types
twoInts.register(dec, this); twoInts.register(dec, this);
theFirstInt.register(dec, this); theFirstInt.register(dec, this);
theSecondInt.register(dec, this); theSecondInt.register(dec, this);
doavoid.register(dec, this);
try try
{ {
Console.WriteLine("Running decoder."); Console.WriteLine("Running decoder.");
...@@ -64,6 +66,11 @@ namespace user_types ...@@ -64,6 +66,11 @@ namespace user_types
Console.WriteLine("Got theSecondInt: "+d); Console.WriteLine("Got theSecondInt: "+d);
} }
void doavoid.Handler.handle()
{
Console.WriteLine("Got a void.");
}
static void Main(string[] args) static void Main(string[] args)
{ {
new Decoder(new FileStream(args[0], FileMode.Open)); new Decoder(new FileStream(args[0], FileMode.Open));
......
...@@ -25,7 +25,8 @@ public class TDDecoder ...@@ -25,7 +25,8 @@ public class TDDecoder
TypeDefParser.TypeDefListener, TypeDefParser.TypeDefListener,
twoInts.Handler, twoInts.Handler,
theFirstInt.Handler, theFirstInt.Handler,
theSecondInt.Handler theSecondInt.Handler,
doavoid.Handler
{ {
private DecoderChannel decoder; private DecoderChannel decoder;
...@@ -39,6 +40,7 @@ public class TDDecoder ...@@ -39,6 +40,7 @@ public class TDDecoder
twoLines.register(decoder, this); twoLines.register(decoder, this);
theFirstInt.register(decoder, this); theFirstInt.register(decoder, this);
theSecondInt.register(decoder, this); theSecondInt.register(decoder, this);
doavoid.register(decoder, this);
this.tdp = TypeDefParser.registerTypeDefParser(decoder); this.tdp = TypeDefParser.registerTypeDefParser(decoder);
// TypeDef.register(decoder, this); // TypeDef.register(decoder, this);
// TypeBinding.register(decoder, this); // TypeBinding.register(decoder, this);
...@@ -119,6 +121,10 @@ public class TDDecoder ...@@ -119,6 +121,10 @@ public class TDDecoder
System.out.println("Got theSecondInt: "+d); 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 { public void handle_twoLines(twoLines d) throws java.io.IOException {
System.out.print("Got twoLines: "); System.out.print("Got twoLines: ");
System.out.println("Line l1: "+genLine(d.l1)); System.out.println("Line l1: "+genLine(d.l1));
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#include "gen/test.h" #include "gen/test.h"
#include <stdio.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) { static void handle_test_twoInts(test_twoInts *v,void *context) {
printf("Got twoInts. (%d,%d) \n", v->a, v->b); printf("Got twoInts. (%d,%d) \n", v->a, v->b);
} }
...@@ -53,6 +57,7 @@ int main(int argc, char *argv[]) { ...@@ -53,6 +57,7 @@ int main(int argc, char *argv[]) {
return 1; 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_twoInts(decoder, handle_test_twoInts, context);
labcomm_decoder_register_test_theFirstInt(decoder, handle_test_theFirstInt, 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_theSecondInt(decoder, handle_test_theSecondInt, context);
......
...@@ -4,6 +4,9 @@ typedef struct { ...@@ -4,6 +4,9 @@ typedef struct {
typedef int anInt; typedef int anInt;
typedef void avoid;
sample avoid doavoid;
typedef struct { typedef struct {
coord x; coord x;
coord y; coord y;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment