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

merge in the sending of hierarchical typedefs from branch typedefs

parents 8735f633 e5e3b844
...@@ -57,3 +57,10 @@ doc/tech_report.bbl ...@@ -57,3 +57,10 @@ doc/tech_report.bbl
doc/tech_report.log doc/tech_report.log
doc/tech_report.pdf doc/tech_report.pdf
doc/tech_report.fdb_latexmk doc/tech_report.fdb_latexmk
examples/user_types/encoded_data_c
examples/user_types/encoded_data_j
examples/user_types/example_decoder
examples/user_types/example_encoder
doc/tech_report.fls
examples/dynamic/encoded_data
examples/dynamic/gen
...@@ -1130,11 +1130,39 @@ aspect C_Encoder { ...@@ -1130,11 +1130,39 @@ aspect C_Encoder {
" not declared"); " not declared");
} }
protected void Decl.C_emitEncoderTypeRegister(C_env env) {
env.println("int labcomm"+env.verStr+"_encoder_type_register_" +
env.prefix + getName() + "(");
env.indent();
env.println("struct labcomm"+env.verStr+"_encoder *e");
env.unindent();
env.println(")");
env.println("{");
env.indent();
env.println("//TODO: add error handling for dependencies");
C_emitUserTypeDeps(env, null, true);
if(!isSampleDecl() || hasDependencies()) {
env.println("return labcomm"+env.verStr+"_internal_encoder_type_register(");
env.indent();
env.println("e,");
env.println("&signature_" + env.prefix + getName() + "");
env.unindent();
env.println(");");
} else {
env.println("// the type has no dependencies, do nothing");
env.println("return 0;");
}
env.unindent();
env.println("}");
}
public void TypeDecl.C_emitEncoderRegisterHandler(C_env env) { public void TypeDecl.C_emitEncoderRegisterHandler(C_env env) {
// do nothing for type decls C_emitEncoderTypeRegister(env);
} }
public void SampleDecl.C_emitEncoderRegisterHandler(C_env env) { public void SampleDecl.C_emitEncoderRegisterHandler(C_env env) {
C_emitEncoderTypeRegister(env);
env.println("int labcomm"+env.verStr+"_encoder_register_" + env.println("int labcomm"+env.verStr+"_encoder_register_" +
env.prefix + getName() + "("); env.prefix + getName() + "(");
env.indent(); env.indent();
...@@ -1146,17 +1174,28 @@ aspect C_Encoder { ...@@ -1146,17 +1174,28 @@ aspect C_Encoder {
C_emitUserTypeDeps(env, null, false); //XXX HERE BE DRAGONS C_emitUserTypeDeps(env, null, false); //XXX HERE BE DRAGONS
//currently set to false to turn off //currently set to false to turn off
//outputting of code //outputting of code
env.println("return labcomm"+env.verStr+"_internal_encoder_register("); env.println("int result = labcomm"+env.verStr+"_internal_encoder_register(");
env.indent(); env.indent();
env.println("e,"); env.println("e,");
env.println("&signature_" + env.prefix + getName() + ","); env.println("&signature_" + env.prefix + getName() + ",");
env.println("(labcomm"+env.verStr+"_encoder_function)encode_" + env.prefix + getName()); env.println("(labcomm"+env.verStr+"_encoder_function)encode_" + env.prefix + getName());
env.unindent(); env.unindent();
env.println(");"); env.println(");");
env.println("if(result >= 0) {\n");
env.indent();
env.println("labcomm"+env.verStr+"_encoder_type_register_" + env.prefix + getName()+"(e);");
env.println("labcomm"+env.verStr+"_internal_encoder_type_bind(");
env.indent();
env.println("e,");
env.println("&signature_" + env.prefix + getName() + ",");
env.println( (hasDependencies() ? "1" : "0") + ");");
env.unindent();
env.println("}");
env.unindent();
env.println("return result;");
env.unindent(); env.unindent();
env.println("}"); env.println("}");
} }
} }
aspect C_EncoderIoctl { aspect C_EncoderIoctl {
...@@ -1206,7 +1245,7 @@ aspect C_TypeDependencies { ...@@ -1206,7 +1245,7 @@ aspect C_TypeDependencies {
t.C_emitUserTypeDeps(env, t.getName(), outputCode); t.C_emitUserTypeDeps(env, t.getName(), outputCode);
if(outputCode) { if(outputCode) {
System.out.println("Decl.C_emitUserTypeDeps registering "+t.getName()); System.out.println("Decl.C_emitUserTypeDeps registering "+t.getName());
env.println("labcomm"+env.verStr+"_encoder_register_"+env.prefix + t.getName()+"(e);"); env.println("labcomm"+env.verStr+"_encoder_type_register_"+env.prefix + t.getName()+"(e);");
} else { // Just output a comment } else { // Just output a comment
String refpath = (via == null) ? "directly" : "indirectly via "+via; String refpath = (via == null) ? "directly" : "indirectly via "+via;
env.println(" //Depends ("+refpath+") on "+t.getName() ); env.println(" //Depends ("+refpath+") on "+t.getName() );
...@@ -1222,7 +1261,7 @@ aspect C_TypeDependencies { ...@@ -1222,7 +1261,7 @@ aspect C_TypeDependencies {
t.C_emitUserTypeRefs(env, t.getName(), outputCode); t.C_emitUserTypeRefs(env, t.getName(), outputCode);
if(outputCode) { if(outputCode) {
env.println("labcomm"+env.verStr+"_encoder_register_"+env.prefix + t.getName()+"(e);"); env.println("labcomm"+env.verStr+"_encoder_type_register_"+env.prefix + t.getName()+"(e);");
} else { // Just output a comment } else { // Just output a comment
String refpath = (via == null) ? "directly" : "indirectly via "+via; String refpath = (via == null) ? "directly" : "indirectly via "+via;
env.println(" //Is referenced ("+refpath+") by "+t.getName() ); env.println(" //Is referenced ("+refpath+") by "+t.getName() );
...@@ -1245,14 +1284,15 @@ aspect C_Signature { ...@@ -1245,14 +1284,15 @@ aspect C_Signature {
eq TypeDecl.C_DeclTypeString() = "LABCOMM_TYPEDEF"; eq TypeDecl.C_DeclTypeString() = "LABCOMM_TYPEDEF";
public void Decl.C_emitSignature(C_env env) { public void Decl.C_emitSignature(C_env env) {
C_emitFlatSignature(env); if( (isReferenced() || isSampleDecl())){
// Signature signature = getSignature();
// if( false && (isReferenced() || isSampleDecl())){ signature.C_emitSignature(env, !isSampleDecl());
// Signature signature = getSignature(); } else {
// signature.C_emitSignature(env, !isSampleDecl()); env.println("// not emitting signature for "+getName()+isReferenced()+isSampleDecl());
// } else { }
// env.println("// not emitting signature for "+getName()+isReferenced()+isSampleDecl()); C_emitFlatSignature(env);
// }
// if(env.versionHasMetaData()) { // if(env.versionHasMetaData()) {
// if(isReferenced() || isSampleDecl()){ // if(isReferenced() || isSampleDecl()){
// env.println("(int (*)(void *))labcomm"+env.verStr+"_signature_" + // env.println("(int (*)(void *))labcomm"+env.verStr+"_signature_" +
...@@ -1274,6 +1314,24 @@ aspect C_Signature { ...@@ -1274,6 +1314,24 @@ aspect C_Signature {
} }
public void Decl.C_emitFlatSignature(C_env env) { public void Decl.C_emitFlatSignature(C_env env) {
C_emitSizeofValue(env);
env.println("static struct labcomm"+env.verStr+"_signature " +
"signature_" + env.prefix + getName() + " = {");
env.indent();
env.println("\"" + getName() + "\",");
//env.println("sizeof_" + env.prefix + getName() + ",");
//HERE BE DRAGONS? do we need sizeof for typedefs?
env.println("NULL,");
env.println("0,");
env.println("NULL,");
env.println("0,"); // index
env.println("sizeof(signature_tree_" + env.prefix + getName() + "),");
env.println("signature_tree_" + env.prefix + getName() + "");
env.unindent();
env.println(" };");
env.println("const struct labcomm"+env.verStr+"_signature " +
"*labcomm"+env.verStr+"_signature_" + env.prefix + getName() +
" = &signature_" + env.prefix + getName() + ";");
} }
public void SampleDecl.C_emitFlatSignature(C_env env){ public void SampleDecl.C_emitFlatSignature(C_env env){
...@@ -1304,7 +1362,9 @@ aspect C_Signature { ...@@ -1304,7 +1362,9 @@ aspect C_Signature {
env.println("sizeof_" + env.prefix + getName() + ","); env.println("sizeof_" + env.prefix + getName() + ",");
env.println("sizeof(signature_bytes_" + env.prefix + getName() + "),"); env.println("sizeof(signature_bytes_" + env.prefix + getName() + "),");
env.println("signature_bytes_" + env.prefix + getName() + ","); env.println("signature_bytes_" + env.prefix + getName() + ",");
env.println("0"); env.println("0,"); // index
env.println("sizeof(signature_tree_" + env.prefix + getName() + "),");
env.println("signature_tree_" + env.prefix + getName() + "");
env.unindent(); env.unindent();
env.println(" };"); env.println(" };");
env.println("const struct labcomm"+env.verStr+"_signature " + env.println("const struct labcomm"+env.verStr+"_signature " +
...@@ -1319,28 +1379,29 @@ aspect C_Signature { ...@@ -1319,28 +1379,29 @@ aspect C_Signature {
public abstract void SignatureLine.C_emitSignature(C_env env, boolean decl); public abstract void SignatureLine.C_emitSignature(C_env env, boolean decl);
public void TypeRefSignatureLine.C_emitSignature(C_env env, boolean isDecl){ public void TypeRefSignatureLine.C_emitSignature(C_env env, boolean isDecl){
//env.print(getIndentString()); env.print(getIndentString());
//env.println("LABCOMM_SIGDEF_SIGNATURE(labcomm"+env.verStr+"_signature_" + env.prefix + decl.getName() +"),"); // env.println("LABCOMM_SIGDEF_SIGNATURE(labcomm"+env.verStr+"_signature_" + env.prefix + decl.getName() +"),");
env.println("LABCOMM_SIGDEF_SIGNATURE(signature_" + env.prefix + decl.getName() +"),");
} }
public void DataSignatureLine.C_emitSignature(C_env env, boolean decl){ public void DataSignatureLine.C_emitSignature(C_env env, boolean decl){
// String comment = getComment(); String comment = getComment();
// if (comment != null && comment.length() > 0) { if (comment != null && comment.length() > 0) {
// env.println(getIndentString() + "// " + comment); env.println(getIndentString() + "// " + comment);
// } }
// byte[] data = getData(env.version); byte[] data = getData(env.version);
// if (data != null && data.length > 0) { if (data != null && data.length > 0) {
// env.print(getIndentString()); env.print(getIndentString());
// env.print("LABCOMM_SIGDEF_BYTES("+data.length+", \""); env.print("LABCOMM_SIGDEF_BYTES("+data.length+", \"");
// for (int j = 0 ; j < data.length ; j++) { for (int j = 0 ; j < data.length ; j++) {
// byte d = data[j]; byte d = data[j];
// //if(d>='a'&&d<='z' || d>='A'&&d<='Z'|| d>='0'&&d<='9' ) //if(d>='a'&&d<='z' || d>='A'&&d<='Z'|| d>='0'&&d<='9' )
// // env.print(""+(char)d); // env.print(""+(char)d);
// //else //else
// env.print("\\x"+Integer.toHexString(d)); env.print("\\x"+Integer.toHexString(d));
// } }
// env.println("\"),"); env.println("\"),");
// } }
} }
// //
// //
...@@ -1357,18 +1418,18 @@ aspect C_Signature { ...@@ -1357,18 +1418,18 @@ aspect C_Signature {
// //
//} //}
public void SignatureList.C_emitSignature(C_env env, boolean decl) { public void SignatureList.C_emitSignature(C_env env, boolean decl) {
// env.println("static struct labcomm_signature_data signature_tree_" + env.println("static struct labcomm_signature_data signature_tree_" +
// env.prefix + parentDecl().getName() + "[] = {"); env.prefix + parentDecl().getName() + "[] = {");
// env.indent(); env.indent();
// for (int i = 0 ; i < size() ; i++) { for (int i = 0 ; i < size() ; i++) {
// SignatureLine l = getSignatureLine(i); SignatureLine l = getSignatureLine(i);
// l.C_emitSignature(env, decl); l.C_emitSignature(env, decl);
// } }
//
// env.println("LABCOMM_SIGDEF_END"); env.println("LABCOMM_SIGDEF_END");
// env.println("};"); env.println("};");
// env.unindent(); env.unindent();
// env.println(); env.println();
} }
...@@ -1432,9 +1493,9 @@ aspect C_Constructor { ...@@ -1432,9 +1493,9 @@ aspect C_Constructor {
} }
public void Decl.C_emitConstructor(C_env env) { public void Decl.C_emitConstructor(C_env env) {
} // }
//XXX //XXX
public void SampleDecl.C_emitConstructor(C_env env) { // public void SampleDecl.C_emitConstructor(C_env env) {
env.println("labcomm"+env.verStr+"_set_local_index(&signature_" + env.println("labcomm"+env.verStr+"_set_local_index(&signature_" +
env.prefix + getName() + ");"); env.prefix + getName() + ");");
} }
......
...@@ -21,9 +21,9 @@ aspect FlatSignature { ...@@ -21,9 +21,9 @@ aspect FlatSignature {
getType().flatSignature(list); getType().flatSignature(list);
} }
public void SampleRefType.flatSignature(SignatureList list) { // public void SampleRefType.flatSignature(SignatureList list) {
list.addInt(LABCOMM_SAMPLE_REF, "sample"); // list.addInt(LABCOMM_SAMPLE_REF, "sample");
} // }
public void VoidType.flatSignature(SignatureList list) { public void VoidType.flatSignature(SignatureList list) {
list.addInt(LABCOMM_STRUCT, "void"); list.addInt(LABCOMM_STRUCT, "void");
...@@ -96,9 +96,9 @@ aspect FlatSignature { ...@@ -96,9 +96,9 @@ aspect FlatSignature {
return getType().signatureComment() + " '" + getName() +"'"; return getType().signatureComment() + " '" + getName() +"'";
} }
public String SampleRefType.signatureComment() { // public String SampleRefType.signatureComment() {
return "sample"; // return "sample";
} // }
public String PrimType.signatureComment() { public String PrimType.signatureComment() {
return getName(); return getName();
......
...@@ -454,10 +454,10 @@ aspect Java_Class { ...@@ -454,10 +454,10 @@ aspect Java_Class {
env.println(); env.println();
} }
//public void TypeDecl.Java_emitSignature(Java_env env) { public void TypeDecl.Java_emitSignature(Java_env env) {
// Signature signature = getSignature(); Signature signature = getSignature();
// signature.Java_emitSignature(env, true); signature.Java_emitSignature(env, true);
//} }
public void Decl.Java_emitSignature(Java_env env) { public void Decl.Java_emitSignature(Java_env env) {
//always emit the flat signature, as it is needed //always emit the flat signature, as it is needed
...@@ -465,10 +465,10 @@ aspect Java_Class { ...@@ -465,10 +465,10 @@ aspect Java_Class {
//the type_ids of dependent types. Therefore, flat sigs //the type_ids of dependent types. Therefore, flat sigs
//are used for matching //are used for matching
Java_emitFlatSignature(env); Java_emitFlatSignature(env);
//if(isReferenced() || isSampleDecl()){ if(isReferenced() || (isSampleDecl() && hasDependencies() )){
// Signature signature = getSignature(); Signature signature = getSignature();
// signature.Java_emitSignature(env, !isSampleDecl()); signature.Java_emitSignature(env, !isSampleDecl());
//} }
} }
public void Decl.Java_emitFlatSignature(Java_env env){ public void Decl.Java_emitFlatSignature(Java_env env){
...@@ -497,7 +497,8 @@ aspect Java_Class { ...@@ -497,7 +497,8 @@ aspect Java_Class {
//XXX TODO: refactor: split into a static class ("TypeDefSingleton"?)and a (smaller) dispatcher //XXX TODO: refactor: split into a static class ("TypeDefSingleton"?)and a (smaller) dispatcher
public void Decl.Java_emitDispatcher(Java_env env, boolean isSample) { public void Decl.Java_emitDispatcher(Java_env env, boolean isSample) {
String genericStr = ""; //env.versionHasMetaData()?"<"+getName()+">":""; // String genericStr = ""; //env.versionHasMetaData()?"<"+getName()+">":"";
String genericStr = "<"+getName()+">";
env.println("private static Dispatcher dispatcher = new Dispatcher();"); env.println("private static Dispatcher dispatcher = new Dispatcher();");
env.println(); env.println();
env.println("public SampleDispatcher getDispatcher() {"); env.println("public SampleDispatcher getDispatcher() {");
...@@ -544,16 +545,20 @@ aspect Java_Class { ...@@ -544,16 +545,20 @@ aspect Java_Class {
env.println("return "+isSample+";"); env.println("return "+isSample+";");
env.unindent(); env.unindent();
env.println("}"); env.println("}");
// env.println("public boolean hasStaticSignature() {"); env.println("public boolean hasDependencies() {");
// env.indent(); env.indent();
// env.println("return "+!hasDependencies()+";"); env.println("return "+hasDependencies()+";");
// env.unindent(); env.unindent();
// env.println("}"); env.println("}");
env.println(); env.println();
env.println("/** return the flat signature. */"); env.println("/** return the flat signature. */");
env.println("public byte[] getSignature() {"); env.println("public byte[] getSignature() {");
env.indent(); env.indent();
env.println("return signature;"); if(isSample) {
env.println("return signature;");
} else {
env.println("throw new Error(\"a TYPE_DEF has no flat signature\");");
}
env.unindent(); env.unindent();
env.println("}"); env.println("}");
env.println(); env.println();
...@@ -563,15 +568,16 @@ aspect Java_Class { ...@@ -563,15 +568,16 @@ aspect Java_Class {
// env.unindent(); // env.unindent();
// env.println("}"); // env.println("}");
// env.println(); // env.println();
// env.println("public void encodeSignatureMetadata(Encoder e, int index) throws IOException{"); env.println("public void encodeTypeDef(Encoder e, int index) throws IOException{");
// env.indent(); env.indent();
// env.println("e.encodePacked32(Constant.TYPE_DEF);"); if(!isSample || hasDependencies()) {
// env.println("e.encodePacked32(index);"); env.println("emitSignature(e);");
// env.println("e.encodeString(getName());"); } else {
// env.println("emitSignature(e);"); env.println("// the type has no dependencies, do nothing");
// env.unindent(); }
// env.println("}"); env.unindent();
// env.println(); env.println("}");
env.println();
env.println("public boolean canDecodeAndHandle() {"); env.println("public boolean canDecodeAndHandle() {");
env.indent(); env.indent();
env.println("return "+isSample+";"); env.println("return "+isSample+";");
......
Program ::= Decl*; Program ::= Decl*;
//TODO: Add signatures to the abstract grammar, so that
//they can be extended and refined by more than one aspect.
//sketch:
Signature ::= SignatureList FlatSignatureList:SignatureList;
SignatureList ::= SignatureLine*;
abstract SignatureLine ::= <Indent:int> <Comment:String>;
abstract DataSignatureLine : SignatureLine;
ByteArraySignatureLine : DataSignatureLine ::= <Data:byte[]>;
IntSignatureLine : DataSignatureLine ::= <Data:int>;
StringSignatureLine : DataSignatureLine ::= <Data:String>;
TypeRefSignatureLine : SignatureLine ::= Decl;
//abstract Decl ::= Type <Name:String>;
// the signature list be defined as a non-terminal attribute:
abstract Decl ::= Type <Name:String> /Signature/; abstract Decl ::= Type <Name:String> /Signature/;
TypeDecl : Decl;
TypeDecl : Decl;
SampleDecl : Decl; SampleDecl : Decl;
//Signatures are in the abstract grammar, so that
//they can be extended and refined by aspects.
Signature ::= SignatureList FlatSignatureList:SignatureList;
SignatureList ::= SignatureLine*;
abstract SignatureLine ::= <Indent:int> <Comment:String>;
abstract DataSignatureLine : SignatureLine;
ByteArraySignatureLine : DataSignatureLine ::= <Data:byte[]>;
IntSignatureLine : DataSignatureLine ::= <Data:int>;
StringSignatureLine : DataSignatureLine ::= <Data:String>;
TypeRefSignatureLine : SignatureLine ::= Decl;
Field ::= Type <Name:String>; Field ::= Type <Name:String>;
abstract Type; abstract Type;
VoidType : Type; VoidType : Type;
SampleRefType : Type; //SampleRefType : Type;
PrimType : Type ::= <Name:String> <Token:int>; PrimType : Type ::= <Name:String> <Token:int>;
UserType : Type ::= <Name:String>; UserType : Type ::= <Name:String>;
StructType : Type ::= Field*; StructType : Type ::= Field*;
ParseArrayType : Type ::= Type Dim*; ParseArrayType : Type ::= Type Dim*;
abstract ArrayType :Type ::= Type Exp*; abstract ArrayType : Type ::= Type Exp*;
VariableArrayType : ArrayType; VariableArrayType : ArrayType;
FixedArrayType : ArrayType; FixedArrayType : ArrayType;
Dim ::= Exp*; Dim ::= Exp*;
abstract Exp; abstract Exp;
IntegerLiteral : Exp ::= <Value:String>; IntegerLiteral : Exp ::= <Value:String>;
VariableSize : Exp; VariableSize : Exp;
...@@ -68,9 +68,9 @@ aspect PrettyPrint { ...@@ -68,9 +68,9 @@ aspect PrettyPrint {
out.print("void"); out.print("void");
} }
public void SampleRefType.ppPrefix(PrintStream out) { // public void SampleRefType.ppPrefix(PrintStream out) {
out.print("sample"); // out.print("sample");
} // }
public void PrimType.ppPrefix(PrintStream out) { public void PrimType.ppPrefix(PrintStream out) {
out.print(getName()); out.print(getName());
......
...@@ -158,7 +158,6 @@ aspect Signature { ...@@ -158,7 +158,6 @@ aspect Signature {
} }
public void TypeDecl.genSigLineForDecl(SignatureList list, boolean decl) { public void TypeDecl.genSigLineForDecl(SignatureList list, boolean decl) {
//System.out.println("************ TypeDecl.genSigLine("+decl+").... for "+getName());
if(decl){ if(decl){
getType().genSigLineForDecl(list, decl); getType().genSigLineForDecl(list, decl);
}else{ }else{
...@@ -167,7 +166,6 @@ aspect Signature { ...@@ -167,7 +166,6 @@ aspect Signature {
} }
public void SampleDecl.genSigLineForDecl(SignatureList list, boolean decl) { public void SampleDecl.genSigLineForDecl(SignatureList list, boolean decl) {
//System.out.println("************ SampleDecl.genSigLine("+decl+").... for "+getName());
getType().genSigLineForDecl(list, decl); getType().genSigLineForDecl(list, decl);
} }
...@@ -176,25 +174,20 @@ aspect Signature { ...@@ -176,25 +174,20 @@ aspect Signature {
list.addInt(0, null); list.addInt(0, null);
} }
public void SampleRefType.genSigLineForDecl(SignatureList list, boolean decl) { // public void SampleRefType.genSigLineForDecl(SignatureList list, boolean decl) {
list.addInt(LABCOMM_SAMPLE_REF, "sample"); // list.addInt(LABCOMM_SAMPLE_REF, "sample");
} // }
public void PrimType.genSigLineForDecl(SignatureList list, boolean decl) { public void PrimType.genSigLineForDecl(SignatureList list, boolean decl) {
list.addInt(getToken(), null); list.addInt(getToken(), null);
} }
/* For UserType, the decl parameter is ignored, as a UserType
* will always be a TypeRef
*/
public void UserType.genSigLineForDecl(SignatureList list, boolean decl) { public void UserType.genSigLineForDecl(SignatureList list, boolean decl) {
if(decl){
//System.out.println("************ UserType.genSigLine("+decl+").... for "+getName());
TypeDecl thet=lookupType(getName());
//System.out.println("************ thet: "+thet.getName() +":"+thet.getType());
thet.genSigLineForDecl(list, decl);
}else{
//System.out.println("************ UserType.genSigLine("+decl+").... for "+getName());
TypeDecl thet = lookupType(getName()); TypeDecl thet = lookupType(getName());
// System.out.println("************ thet: "+thet.getName() +":"+thet.getType());
list.addTypeRef(thet, null); list.addTypeRef(thet, null);
}
} }
public void ArrayType.genSigLineForDecl(SignatureList list, boolean decl) { public void ArrayType.genSigLineForDecl(SignatureList list, boolean decl) {
......
...@@ -437,6 +437,11 @@ come from two independent number series. To identify which ...@@ -437,6 +437,11 @@ come from two independent number series. To identify which
\verb+TYPE_DECL+ a particular \verb+SAMPLE_DECL+ corresponds to, the \verb+TYPE_DECL+ a particular \verb+SAMPLE_DECL+ corresponds to, the
\verb+TYPE_BINDING+ packet is used. \verb+TYPE_BINDING+ packet is used.
For sample types that do not depend on any typedefs, no \verb+TYPE_DECL+
is sent, and the \verb+TYPE_BINDING+ binds the sample id to the special
value zero to indicate that the type definition is identical to the
flattened signature.
\subsection{Example} \subsection{Example}
The labcomm declaration The labcomm declaration
...@@ -484,6 +489,42 @@ not required to do so. However, if multiple \verb+TYPE_DECL+ packets are ...@@ -484,6 +489,42 @@ not required to do so. However, if multiple \verb+TYPE_DECL+ packets are
sent for the same \verb+typedef+, the encoder must use the same sent for the same \verb+typedef+, the encoder must use the same
\verb+type_id+. \verb+type_id+.
\subsection{Decoding in-band type descriptions}
In LabComm, the in-band data descriptions are equivalent to \footnote{in
the sense that they contain all information needed to recreate} the data
description source (i.e., the ``.lc-file'').
%
As the type declarations (a.k.a. \emph{signatures}) are written before
sample data on every channel, they can be used to interpret data with
an unknown (by the receiver) format.