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