Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sven Gestegård Robertz
LabComm
Commits
e5533fce
Commit
e5533fce
authored
11 years ago
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Added java to tests
parent
46cfde75
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/Makefile
+13
-5
13 additions, 5 deletions
test/Makefile
test/relay_gen_java.py
+84
-0
84 additions, 0 deletions
test/relay_gen_java.py
with
97 additions
and
5 deletions
test/Makefile
+
13
−
5
View file @
e5533fce
...
@@ -11,17 +11,18 @@ clean:
...
@@ -11,17 +11,18 @@ clean:
rm
-rf
gen
rm
-rf
gen
.PHONY
:
test_%
.PHONY
:
test_%
test_%
:
gen/%/
c_rela
y
\
test_%
:
gen/%/
signatures.p
y
\
gen/%/c
s_code.cs
\
gen/%/c
_relay
\
gen/%/cs_relay.exe
\
gen/%/cs_relay.exe
\
gen/%/
signatures.py
\
gen/%/
java_relay.class
\
gen/%/java_code
gen/%/java_code
PYTHONPATH
=
../lib/python ./test_encoder_decoder.py
\
PYTHONPATH
=
../lib/python ./test_encoder_decoder.py
\
--signatures
=
gen/
$*
/signatures.py
\
--signatures
=
gen/
$*
/signatures.py
\
--test
/bin/tee gen/
$*
/testdata
\
--test
/bin/tee gen/
$*
/testdata
\
--test
gen/
$*
/c_relay /dev/stdin /dev/stdout
\
--test
gen/
$*
/c_relay /dev/stdin /dev/stdout
\
--test
mono gen/
$*
/cs_relay.exe /dev/stdin /dev/stdout
--test
mono gen/
$*
/cs_relay.exe /dev/stdin /dev/stdout
\
--test
java
\\
-cp
gen/
$*
:../lib/java/labcomm.jar java_relay
\
/dev/stdin /dev/stdout
.PRECIOUS
:
gen/%/
.PRECIOUS
:
gen/%/
gen/%/
:
gen/%/
:
mkdir
-p
$@
mkdir
-p
$@
...
@@ -77,3 +78,10 @@ gen/%/java_code: %.lc | gen/%/
...
@@ -77,3 +78,10 @@ gen/%/java_code: %.lc | gen/%/
mkdir
-p
$@
mkdir
-p
$@
$(
LABCOMM
)
--java
=
$@
$<
$(
LABCOMM
)
--java
=
$@
$<
.PRECIOUS
:
gen/%/java_relay.java
gen/%/java_relay.java
:
gen/%/typeinfo relay_gen_java.py Makefile
./relay_gen_java.py
$<
>
$@
.PRECIOUS
:
gen/%/java_relay.class
gen/%/java_relay.class
:
gen/%/java_relay.java gen/%/java_code Makefile
javac
-d
gen/
$*
-cp
../lib/java/labcomm.jar:gen/
$*
/java_code
$<
This diff is collapsed.
Click to expand it.
test/relay_gen_java.py
0 → 100755
+
84
−
0
View file @
e5533fce
#!/usr/bin/python
import
re
import
sys
def
split_match
(
pattern
,
multiline
):
def
match
(
s
):
m
=
re
.
match
(
pattern
,
s
)
if
m
:
return
m
.
group
(
1
)
pass
return
filter
(
lambda
s
:
s
!=
None
,
map
(
match
,
multiline
.
split
(
'
\n
'
)))
if
__name__
==
'
__main__
'
:
f
=
open
(
sys
.
argv
[
1
])
sample
=
[]
for
l
in
map
(
lambda
s
:
s
.
strip
(),
f
):
lang
,
kind
,
func
,
arg
=
l
[
1
:].
split
(
l
[
0
])
if
lang
==
'
Java
'
and
kind
==
'
sample
'
:
sample
.
append
((
func
,
arg
))
pass
pass
result
=
[]
result
.
extend
(
split_match
(
'
^[^|]*\|(.*)$
'
,
"""
|import java.io.FileInputStream;
|import java.io.FileOutputStream;
|import java.io.IOException;
|import se.lth.control.labcomm.LabCommDecoderChannel;
|import se.lth.control.labcomm.LabCommEncoderChannel;
|
|public class java_relay implements
"""
))
for
func
,
arg
in
sample
[
0
:
-
1
]:
result
.
append
(
'
%s.Handler,
'
%
func
)
pass
result
.
append
(
'
%s.Handler
'
%
sample
[
-
1
][
0
])
result
.
extend
(
split_match
(
'
^[^|]*\|(.*)$
'
,
"""
|{
| LabCommEncoderChannel encoder;
"""
))
for
func
,
arg
in
sample
:
if
arg
==
'
void
'
:
result
.
extend
(
split_match
(
'
^[^|]*\|(.*)$
'
,
"""
| public void handle_%(func)s() throws IOException {
| %(func)s.encode(encoder);
| }
"""
%
{
'
func
'
:
func
}))
pass
else
:
result
.
extend
(
split_match
(
'
^[^|]*\|(.*)$
'
,
"""
| public void handle_%(func)s(%(arg)s data) throws IOException {
| %(func)s.encode(encoder, data);
| }
"""
%
{
'
func
'
:
func
,
'
arg
'
:
arg
}))
pass
pass
result
.
extend
(
split_match
(
'
^[^|]*\|(.*)$
'
,
"""
| public java_relay(String InName, String OutName) throws Exception {
| FileInputStream InFile = new FileInputStream(InName);
| LabCommDecoderChannel d = new LabCommDecoderChannel(InFile);
| FileOutputStream OutFile = new FileOutputStream(OutName);
| encoder = new LabCommEncoderChannel(OutFile);
|
"""
))
for
func
,
arg
in
sample
:
result
.
append
(
'
%s.register(d, this);
'
%
func
)
pass
for
func
,
arg
in
sample
:
result
.
append
(
'
%s.register(encoder);
'
%
func
)
pass
result
.
extend
(
split_match
(
'
^[^|]*\|(.*)$
'
,
"""
| try {
| d.run();
| } catch (java.io.EOFException e) {
| }
| }
| public static void main(String[] arg) throws Exception {
| new java_relay(arg[0], arg[1]);
| }
|}
"""
))
print
"
\n
"
.
join
(
result
)
pass
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment