Commit 7670af15 authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

updated test cases to leaving out value parameter for void samples

parent a0dfc2fa
...@@ -776,13 +776,15 @@ aspect CS_Info { ...@@ -776,13 +776,15 @@ aspect CS_Info {
public void TypeDecl.CS_info(CS_env env, String namespace) { public void TypeDecl.CS_info(CS_env env, String namespace) {
env.print(";C#;typedef;" + namespace + getName() + ";"); env.print(";C#;typedef;" + namespace + getName() + ";");
getType().CS_emitType(env); getType().CS_emitType(env) ;
env.print(";not_applicable_for_Java");
env.println(); env.println();
} }
public void SampleDecl.CS_info(CS_env env, String namespace) { public void SampleDecl.CS_info(CS_env env, String namespace) {
env.print(";C#;sample;" + namespace + getName() + ";"); env.print(";C#;sample;" + namespace + getName() + ";");
getType().CS_emitType(env); getType().CS_emitType(env);
env.print(";not_applicable_for_Java");
env.println(); env.println();
} }
......
...@@ -1163,12 +1163,23 @@ aspect C_Info { ...@@ -1163,12 +1163,23 @@ aspect C_Info {
public void TypeDecl.C_info(C_env env) { public void TypeDecl.C_info(C_env env) {
env.println(",C,typedef," + env.prefix + getName() + "," + env.println(",C,typedef," + env.prefix + getName() + "," +
env.prefix + getName()); env.prefix + getName() + "," +
C_info_type_or_void(env.prefix));
} }
public void SampleDecl.C_info(C_env env) { public void SampleDecl.C_info(C_env env) {
env.println(",C,sample," + env.prefix + getName() + "," + env.println(",C,sample," + env.prefix + getName() + "," +
env.prefix + getName()); env.prefix + getName() + "," +
C_info_type_or_void(env.prefix));
} }
// make void types explicitly as they require special treatment
// in encoder/decoder calls
protected String Decl.C_info_type_or_void(String prefix) {
if(isVoid() ) {
return "void";
} else {
return prefix + getName() ;
}
}
} }
...@@ -869,13 +869,15 @@ aspect Java_Info { ...@@ -869,13 +869,15 @@ aspect Java_Info {
public void TypeDecl.Java_info(Java_env env) { public void TypeDecl.Java_info(Java_env env) {
env.print(",Java,typedef," + getName() + ","); env.print(",Java,typedef," + getName() + ",");
getType().Java_emitType(env); getType().Java_emitType(env);
env.print(",not_applicable_for_Java");
env.println(); env.println();
} }
public void SampleDecl.Java_info(Java_env env) { public void SampleDecl.Java_info(Java_env env) {
env.print(",Java,sample," + getName() + ","); env.print(",Java,sample," + getName() + ",");
getType().Java_emitType(env); getType().Java_emitType(env);
env.print(",not_applicable_for_Java");
env.println(); env.println();
} }
......
...@@ -179,7 +179,8 @@ void dump_encoder(struct labcomm_encoder *encoder) ...@@ -179,7 +179,8 @@ void dump_encoder(struct labcomm_encoder *encoder)
int main(void) int main(void)
{ {
generated_encoding_V V; //no longer used
//generated_encoding_V V;
generated_encoding_B B = 1; generated_encoding_B B = 1;
struct labcomm_encoder *encoder = labcomm_encoder_new( struct labcomm_encoder *encoder = labcomm_encoder_new(
...@@ -199,7 +200,8 @@ int main(void) ...@@ -199,7 +200,8 @@ int main(void)
EXPECT({0x02, -1, 0x01, 'B', 0x21}); EXPECT({0x02, -1, 0x01, 'B', 0x21});
labcomm_encoder_ioctl(encoder, IOCTL_WRITER_RESET); labcomm_encoder_ioctl(encoder, IOCTL_WRITER_RESET);
labcomm_encode_generated_encoding_V(encoder, &V); // was: labcomm_encode_generated_encoding_V(encoder, &V);
labcomm_encode_generated_encoding_V(encoder);
EXPECT({-1}); EXPECT({-1});
labcomm_encoder_ioctl(encoder, IOCTL_WRITER_RESET); labcomm_encoder_ioctl(encoder, IOCTL_WRITER_RESET);
......
...@@ -16,13 +16,14 @@ if __name__ == '__main__': ...@@ -16,13 +16,14 @@ if __name__ == '__main__':
f = open(sys.argv[1]) f = open(sys.argv[1])
sample = [] sample = []
for l in map(lambda s: s.strip(), f): for l in map(lambda s: s.strip(), f):
lang,kind,func,arg = l[1:].split(l[0]) lang,kind,func,arg,stype = l[1:].split(l[0])
if lang == 'C' and kind == 'sample': if lang == 'C' and kind == 'sample':
sample.append((func, arg)) sample.append((func, arg, stype))
pass pass
pass pass
result = [] result = []
result.extend(split_match('^[^|]*\|(.*)$', """ result.extend(split_match('^[^|]*\|(.*)$', """
|// generated by relay_gen_c.py
|#include <sys/types.h> |#include <sys/types.h>
|#include <sys/stat.h> |#include <sys/stat.h>
|#include <fcntl.h> |#include <fcntl.h>
...@@ -34,13 +35,19 @@ if __name__ == '__main__': ...@@ -34,13 +35,19 @@ if __name__ == '__main__':
|#include <labcomm_fd_writer.h> |#include <labcomm_fd_writer.h>
|#include "c_code.h" |#include "c_code.h"
""")) """))
for func,arg in sample: for func,arg,stype in sample:
result.extend(split_match('^[^|]*\|(.*)$', """ result.extend(split_match('^[^|]*\|(.*)$', """
|void handle_%(func)s(%(arg)s *v, void *context) |void handle_%(func)s(%(arg)s *v, void *context)
|{ |{
| struct labcomm_encoder *e = context; | struct labcomm_encoder *e = context;
| labcomm_encode_%(func)s(e, v); | labcomm_encode_%(func)s(e%(valargstr)s);
|}""" % { 'func': func, 'arg': arg })) |}""" % { 'func': func, 'arg': arg, 'valargstr': '' if stype == "void" else', v' }))
# result.extend(split_match('^[^|]*\|(.*)$', """
# |void handle_%(func)s(%(arg)s *v, void *context)
# |{
# | struct labcomm_encoder *e = context;
# | labcomm_encode_%(func)s(e, v);
# |}""" % { 'func': func, 'arg': arg }))
pass pass
result.extend(split_match('^[^|]*\|(.*)$', """ result.extend(split_match('^[^|]*\|(.*)$', """
|int main(int argc, char *argv[]) { |int main(int argc, char *argv[]) {
...@@ -64,7 +71,7 @@ if __name__ == '__main__': ...@@ -64,7 +71,7 @@ if __name__ == '__main__':
| labcomm_default_memory, | labcomm_default_memory,
| labcomm_default_scheduler); | labcomm_default_scheduler);
""")) """))
for func,arg in sample: for func,arg,stype in sample:
result.extend(split_match('^[^|]*\|(.*)$', """ result.extend(split_match('^[^|]*\|(.*)$', """
| labcomm_encoder_register_%(func)s(e); | labcomm_encoder_register_%(func)s(e);
| labcomm_decoder_register_%(func)s(d, handle_%(func)s, e); | labcomm_decoder_register_%(func)s(d, handle_%(func)s, e);
......
...@@ -16,7 +16,7 @@ if __name__ == '__main__': ...@@ -16,7 +16,7 @@ if __name__ == '__main__':
f = open(sys.argv[1]) f = open(sys.argv[1])
sample = [] sample = []
for l in map(lambda s: s.strip(), f): for l in map(lambda s: s.strip(), f):
lang,kind,func,arg = l[1:].split(l[0]) lang,kind,func,arg,dummy = l[1:].split(l[0])
if lang == 'C#' and kind == 'sample': if lang == 'C#' and kind == 'sample':
sample.append((func, arg)) sample.append((func, arg))
pass pass
......
...@@ -16,7 +16,7 @@ if __name__ == '__main__': ...@@ -16,7 +16,7 @@ if __name__ == '__main__':
f = open(sys.argv[1]) f = open(sys.argv[1])
sample = [] sample = []
for l in map(lambda s: s.strip(), f): for l in map(lambda s: s.strip(), f):
lang,kind,func,arg = l[1:].split(l[0]) lang,kind,func,arg,dummy = l[1:].split(l[0])
if lang == 'Java' and kind == 'sample': if lang == 'Java' and kind == 'sample':
sample.append((func, arg)) sample.append((func, arg))
pass pass
......
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