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
Sven Gestegård Robertz
LabComm
Commits
1562625c
Commit
1562625c
authored
Jul 09, 2013
by
Sven Robertz
Browse files
more cleanup and some documentation
parent
07b21d7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/dynamic/README
View file @
1562625c
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.
examples/dynamic/TestLabcommGen.java
View file @
1562625c
...
...
@@ -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);
...
...
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