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

renamed typedef to be consistent with type_binding

parent 9b875283
...@@ -3,7 +3,7 @@ import java.io.FileInputStream; ...@@ -3,7 +3,7 @@ import java.io.FileInputStream;
import java.io.InputStream; import java.io.InputStream;
import se.lth.control.labcomm.DecoderChannel; import se.lth.control.labcomm.DecoderChannel;
import se.lth.control.labcomm.Typedef; import se.lth.control.labcomm.TypeDef;
import se.lth.control.labcomm.TypeBinding; import se.lth.control.labcomm.TypeBinding;
public class Decoder public class Decoder
...@@ -11,7 +11,7 @@ public class Decoder ...@@ -11,7 +11,7 @@ public class Decoder
twoInts.Handler, twoInts.Handler,
theFirstInt.Handler, theFirstInt.Handler,
theSecondInt.Handler, theSecondInt.Handler,
Typedef.Handler, TypeDef.Handler,
TypeBinding.Handler TypeBinding.Handler
{ {
...@@ -26,7 +26,7 @@ public class Decoder ...@@ -26,7 +26,7 @@ public class Decoder
twoLines.register(decoder, this); twoLines.register(decoder, this);
theFirstInt.register(decoder, this); theFirstInt.register(decoder, this);
theSecondInt.register(decoder, this); theSecondInt.register(decoder, this);
Typedef.register(decoder, this); TypeDef.register(decoder, this);
TypeBinding.register(decoder, this); TypeBinding.register(decoder, this);
try { try {
...@@ -45,8 +45,8 @@ public class Decoder ...@@ -45,8 +45,8 @@ public class Decoder
return "Line from "+genPoint(l.start)+" to "+genPoint(l.end); return "Line from "+genPoint(l.start)+" to "+genPoint(l.end);
} }
public void handle_Typedef(Typedef d) throws java.io.IOException { public void handle_TypeDef(TypeDef d) throws java.io.IOException {
System.out.println("Got Typedef: "+d.getName()+"("+d.getIndex()+")"); System.out.println("Got TypeDef: "+d.getName()+"("+d.getIndex()+")");
} }
public void handle_TypeBinding(TypeBinding d) throws java.io.IOException { public void handle_TypeBinding(TypeBinding d) throws java.io.IOException {
......
...@@ -20,8 +20,8 @@ static void handle_test_theSecondInt(int *v,void *context) { ...@@ -20,8 +20,8 @@ static void handle_test_theSecondInt(int *v,void *context) {
printf("Got theSecondInt. (%d) \n", *v); printf("Got theSecondInt. (%d) \n", *v);
} }
static void handle_typedef(struct labcomm_raw_typedef *v,void *context) { static void handle_type_def(struct labcomm_raw_type_def *v,void *context) {
printf("Got typedef. (0x%x) %s\n", v->index, v->name); printf("Got type_def. (0x%x) %s\n", v->index, v->name);
} }
static void handle_type_binding(struct labcomm_type_binding *v,void *context) { static void handle_type_binding(struct labcomm_type_binding *v,void *context) {
...@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) { ...@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
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);
labcomm_decoder_register_test_twoLines(decoder, handle_test_twoLines, context); labcomm_decoder_register_test_twoLines(decoder, handle_test_twoLines, context);
labcomm_decoder_register_labcomm_typedef(decoder, handle_typedef, context); labcomm_decoder_register_labcomm_type_def(decoder, handle_type_def, context);
labcomm_decoder_register_labcomm_type_binding(decoder, handle_type_binding, context); labcomm_decoder_register_labcomm_type_binding(decoder, handle_type_binding, context);
printf("Decoding:\n"); printf("Decoding:\n");
......
...@@ -182,7 +182,7 @@ static int decoder_skip(struct labcomm_decoder *d, int len, int tag) ...@@ -182,7 +182,7 @@ static int decoder_skip(struct labcomm_decoder *d, int len, int tag)
return tag; return tag;
} }
#ifdef OLD_TYPEDEF_DECODING_TEST_CODE #ifdef OLD_type_def_DECODING_TEST_CODE
static int decode_type_binding(struct labcomm_decoder *d, int kind) static int decode_type_binding(struct labcomm_decoder *d, int kind)
{ {
int result; int result;
...@@ -191,12 +191,12 @@ static int decode_type_binding(struct labcomm_decoder *d, int kind) ...@@ -191,12 +191,12 @@ static int decode_type_binding(struct labcomm_decoder *d, int kind)
result = d->reader->error; result = d->reader->error;
goto out; goto out;
} }
int typedef_index = labcomm_read_packed32(d->reader); int type_def_index = labcomm_read_packed32(d->reader);
if(d->reader->error < 0 ) { if(d->reader->error < 0 ) {
result = d->reader->error; result = d->reader->error;
goto out; goto out;
} }
printf("type_binding: 0x%x -> 0x%x\n", sample_index, typedef_index); printf("type_binding: 0x%x -> 0x%x\n", sample_index, type_def_index);
out: out:
return result; return result;
} }
...@@ -221,7 +221,7 @@ static int decode_type_def(struct labcomm_decoder *d, int kind){ ...@@ -221,7 +221,7 @@ static int decode_type_def(struct labcomm_decoder *d, int kind){
result = d->reader->error; result = d->reader->error;
goto free_signature_name; goto free_signature_name;
} }
//printf("got typedef 0x%x : %s, skipping %d signature bytes", remote_index, name, size); //printf("got type_def 0x%x : %s, skipping %d signature bytes", remote_index, name, size);
#if 0 #if 0
signature.signature = labcomm_memory_alloc(d->memory, 1, signature.size); signature.signature = labcomm_memory_alloc(d->memory, 1, signature.size);
if (d->reader->error < 0) { if (d->reader->error < 0) {
...@@ -448,8 +448,8 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d) ...@@ -448,8 +448,8 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
} else if (remote_index == LABCOMM_TYPE_DEF) { } else if (remote_index == LABCOMM_TYPE_DEF) {
result = decode_and_handle(d, d, remote_index); result = decode_and_handle(d, d, remote_index);
if(result == -ENOENT) { if(result == -ENOENT) {
//No handler for typedefs, skip //No handler for type_defs, skip
#ifdef OLD_TYPEDEF_DECODING_TEST_CODE #ifdef OLD_type_def_DECODING_TEST_CODE
result = decode_type_def(d, LABCOMM_TYPE_DEF); result = decode_type_def(d, LABCOMM_TYPE_DEF);
#else #else
result = decoder_skip(d, length, remote_index); result = decoder_skip(d, length, remote_index);
...@@ -459,7 +459,7 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d) ...@@ -459,7 +459,7 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
result = decode_and_handle(d, d, remote_index); result = decode_and_handle(d, d, remote_index);
if(result == -ENOENT) { if(result == -ENOENT) {
//No handler for type_bindings, skip //No handler for type_bindings, skip
#ifdef OLD_TYPEDEF_DECODING_TEST_CODE #ifdef OLD_type_def_DECODING_TEST_CODE
result = decode_type_binding(d, LABCOMM_TYPE_BINDING); result = decode_type_binding(d, LABCOMM_TYPE_BINDING);
#else #else
result = decoder_skip(d, length, remote_index); result = decoder_skip(d, length, remote_index);
...@@ -545,19 +545,19 @@ int labcomm_internal_decoder_ioctl(struct labcomm_decoder *d, ...@@ -545,19 +545,19 @@ int labcomm_internal_decoder_ioctl(struct labcomm_decoder *d,
} }
#ifndef LABCOMM_NO_TYPEDECL #ifndef LABCOMM_NO_TYPEDECL
//// Code for allowing user code to handle typedefs //// Code for allowing user code to handle type_defs
//// (should perhaps be moved to another file) //// (should perhaps be moved to another file)
static void decode_raw_typedef( static void decode_raw_type_def(
struct labcomm_reader *r, struct labcomm_reader *r,
void (*handle)( void (*handle)(
struct labcomm_raw_typedef *v, struct labcomm_raw_type_def *v,
void *context void *context
), ),
void *context void *context
) )
{ {
struct labcomm_raw_typedef v; struct labcomm_raw_type_def v;
v.index = labcomm_read_packed32(r); v.index = labcomm_read_packed32(r);
if (r->error < 0) { goto out; } if (r->error < 0) { goto out; }
v.name = labcomm_read_string(r); v.name = labcomm_read_string(r);
...@@ -580,10 +580,10 @@ free_name: ...@@ -580,10 +580,10 @@ free_name:
out: out:
return; return;
} }
int labcomm_decoder_register_labcomm_typedef( int labcomm_decoder_register_labcomm_type_def(
struct labcomm_decoder *d, struct labcomm_decoder *d,
void (*handler)( void (*handler)(
struct labcomm_raw_typedef *v, struct labcomm_raw_type_def *v,
void *context void *context
), ),
void *context void *context
...@@ -600,7 +600,7 @@ int labcomm_decoder_register_labcomm_typedef( ...@@ -600,7 +600,7 @@ int labcomm_decoder_register_labcomm_typedef(
if (entry == NULL) { tag = -ENOMEM; goto unlock; } if (entry == NULL) { tag = -ENOMEM; goto unlock; }
entry->remote_index = tag; entry->remote_index = tag;
entry->signature = NULL; entry->signature = NULL;
entry->decode = (labcomm_decoder_function) decode_raw_typedef; entry->decode = (labcomm_decoder_function) decode_raw_type_def;
entry->handler =(labcomm_handler_function) handler; entry->handler =(labcomm_handler_function) handler;
entry->context = context; entry->context = context;
...@@ -668,7 +668,7 @@ unlock: ...@@ -668,7 +668,7 @@ unlock:
return tag; return tag;
} }
//// End typedef handling //// End type_def handling
#endif #endif
int labcomm_internal_decoder_register( int labcomm_internal_decoder_register(
......
...@@ -61,11 +61,11 @@ struct labcomm_signature { ...@@ -61,11 +61,11 @@ struct labcomm_signature {
#endif #endif
}; };
/* a struct for "raw" typedefs, to be used as an intermediate representation /* a struct for "raw" type_defs, to be used as an intermediate representation
* between decoder and signature parser * between decoder and signature parser
*/ */
struct labcomm_raw_typedef { struct labcomm_raw_type_def {
char *name; char *name;
int index; int index;
int length; int length;
...@@ -85,13 +85,13 @@ struct labcomm_type_binding { ...@@ -85,13 +85,13 @@ struct labcomm_type_binding {
*/ */
/* register a handler for typedefs and type bindings /* register a handler for type_defs and type bindings
*/ */
int labcomm_decoder_register_labcomm_typedef( int labcomm_decoder_register_labcomm_type_def(
struct labcomm_decoder *d, struct labcomm_decoder *d,
void (*handler)( void (*handler)(
struct labcomm_raw_typedef *v, struct labcomm_raw_type_def *v,
void *context void *context
), ),
void *context void *context
......
...@@ -10,7 +10,7 @@ MODULES=Constant \ ...@@ -10,7 +10,7 @@ MODULES=Constant \
SampleDispatcher \ SampleDispatcher \
SampleHandler \ SampleHandler \
SampleType \ SampleType \
Typedef \ TypeDef \
TypeBinding \ TypeBinding \
Writer \ Writer \
WriterWrapper WriterWrapper
......
...@@ -97,7 +97,7 @@ public class DecoderRegistry { ...@@ -97,7 +97,7 @@ public class DecoderRegistry {
public synchronized void add(SampleDispatcher dispatcher, public synchronized void add(SampleDispatcher dispatcher,
SampleHandler handler) throws IOException{ SampleHandler handler) throws IOException{
//XXX kludge: special handling of predefined types //XXX kludge: special handling of predefined types
if(dispatcher.getSampleClass() == Typedef.class){ if(dispatcher.getSampleClass() == TypeDef.class){
Entry e = new Entry(dispatcher, handler); Entry e = new Entry(dispatcher, handler);
e.setIndex(Constant.TYPE_DEF); e.setIndex(Constant.TYPE_DEF);
byClass.put(dispatcher.getSampleClass(), e); byClass.put(dispatcher.getSampleClass(), e);
......
...@@ -8,7 +8,7 @@ import se.lth.control.labcomm.DecoderChannel; ...@@ -8,7 +8,7 @@ import se.lth.control.labcomm.DecoderChannel;
import se.lth.control.labcomm.SampleDispatcher; import se.lth.control.labcomm.SampleDispatcher;
import se.lth.control.labcomm.SampleHandler; import se.lth.control.labcomm.SampleHandler;
public class Typedef implements SampleType { public class TypeDef implements SampleType {
private int index; private int index;
private String name; private String name;
private byte signature[]; private byte signature[];
...@@ -22,14 +22,14 @@ public class Typedef implements SampleType { ...@@ -22,14 +22,14 @@ public class Typedef implements SampleType {
} }
public void dump() { public void dump() {
System.out.print("=== Typedef "+getName()+"( "+Integer.toHexString(getIndex())+") : "); System.out.print("=== TypeDef "+getName()+"( "+Integer.toHexString(getIndex())+") : ");
for (byte b : signature) { for (byte b : signature) {
System.out.print(String.format("0x%02X ", b)); System.out.print(String.format("0x%02X ", b));
} }
System.out.println(); System.out.println();
} }
public interface Handler extends SampleHandler { public interface Handler extends SampleHandler {
public void handle_Typedef(Typedef value) throws Exception; public void handle_TypeDef(TypeDef value) throws Exception;
} }
public static void register(Decoder d, Handler h) throws IOException { public static void register(Decoder d, Handler h) throws IOException {
...@@ -44,7 +44,7 @@ public class Typedef implements SampleType { ...@@ -44,7 +44,7 @@ public class Typedef implements SampleType {
throw new IOException("cannot send TypeDefs"); throw new IOException("cannot send TypeDefs");
} }
static class Dispatcher implements SampleDispatcher<Typedef> { static class Dispatcher implements SampleDispatcher<TypeDef> {
private static Dispatcher singleton; private static Dispatcher singleton;
...@@ -53,12 +53,12 @@ public class Typedef implements SampleType { ...@@ -53,12 +53,12 @@ public class Typedef implements SampleType {
return singleton; return singleton;
} }
public Class<Typedef> getSampleClass() { public Class<TypeDef> getSampleClass() {
return Typedef.class; return TypeDef.class;
} }
public String getName() { public String getName() {
return "Typedef"; return "TypeDef";
} }
public byte getTypeDeclTag() { public byte getTypeDeclTag() {
...@@ -87,7 +87,7 @@ public class Typedef implements SampleType { ...@@ -87,7 +87,7 @@ public class Typedef implements SampleType {
public void decodeAndHandle(Decoder d, public void decodeAndHandle(Decoder d,
SampleHandler h) throws Exception { SampleHandler h) throws Exception {
((Handler)h).handle_Typedef(Typedef.decode(d)); ((Handler)h).handle_TypeDef(TypeDef.decode(d));
} }
public boolean hasDependencies() { public boolean hasDependencies() {
...@@ -95,18 +95,18 @@ public class Typedef implements SampleType { ...@@ -95,18 +95,18 @@ public class Typedef implements SampleType {
} }
} }
public static void encode(Encoder e, Typedef value) throws IOException { public static void encode(Encoder e, TypeDef value) throws IOException {
throw new Error("Should not be called"); throw new Error("Should not be called");
} }
public Typedef(int index, String name, byte sig[]) { public TypeDef(int index, String name, byte sig[]) {
this.index = index; this.index = index;
this.name = name; this.name = name;
this.signature = sig; this.signature = sig;
} }
public static Typedef decode(Decoder d) throws IOException { public static TypeDef decode(Decoder d) throws IOException {
Typedef result; TypeDef result;
int index = d.decodePacked32(); int index = d.decodePacked32();
String name = d.decodeString(); String name = d.decodeString();
int siglen= d.decodePacked32(); int siglen= d.decodePacked32();
...@@ -114,7 +114,7 @@ public class Typedef implements SampleType { ...@@ -114,7 +114,7 @@ public class Typedef implements SampleType {
for(int i=0; i<siglen;i++){ for(int i=0; i<siglen;i++){
sig[i] = d.decodeByte(); sig[i] = d.decodeByte();
} }
result = new Typedef(index, name, sig); result = new TypeDef(index, name, sig);
return result; return result;
} }
} }
......
public class Typedef { public class TypeDef {
} }
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