Commit 1562625c authored by Sven Robertz's avatar Sven Robertz
Browse files

more cleanup and some documentation

parent 07b21d7b
This directory contains an embryo of an example of how to
generate and compile a labcomm endpoint on the fly.
NB! There is currently no connection between the files StaticPart.java, DynamicPart.java, and
TestLabCommCompiler.java
NB! There is currently no connection to the StaticPart.java
the runme.sh script builds and runs the TestLabCommGen, which illustrates the
on-the-fly compilation to RAM, reading the labcomm declarations and handlers from file
The handlers declaration (in handlers.txt) is experimental, and has the following format:
<sample name>:handler(<data type> <variable name>) {
<handler method code>
}###
where the end marker (}###) is a kludge to avoid having to parse the method body while still allowing
it to contain blocks. Thus, having the sequence "}###" in the method body breaks this. Caveat hacker!
An example handlers declaration:
foo:handler(foo value) {
System.out.println("foo handler from handlers.txt");
System.out.println(value.x);
System.out.println(value.y);
System.out.println(value.z);
for(int i=0; i<value.x; i++){
System.out.print("."+(value.x-i));
}
System.out.println();
}###
bar:handler(int value) {
System.out.println(value);
}###
the runme.sh script builds and runs the TestLabCommCompiler, which illustrates the
on-the-fly compilation to RAM, reading the labcomm declarations from file but with the
handlers hard coded in the test program.
......@@ -103,9 +103,9 @@ public class TestLabcommGen {
} else {
System.out.println("expeced handler decl:\n"+srcStr.substring(pos));
}
int bodyEnd = srcStr.indexOf('}', pos); // HERE BE DRAGONS! too brittle
int bodyEnd = srcStr.indexOf("}###", pos); // HERE BE DRAGONS! a bit brittle
String body = srcStr.substring(pos, bodyEnd+1);
pos = bodyEnd+2;
pos = bodyEnd+5;
// System.out.println("body:");
// System.out.println(body);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment