Commit 8973c6d7 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

First implementation of sample references, only for C this far.

parent 1f9f6437
...@@ -275,6 +275,9 @@ aspect C_Type { ...@@ -275,6 +275,9 @@ aspect C_Type {
getType().C_emitType(env, env.prefix + getName()); getType().C_emitType(env, env.prefix + getName());
env.println(";"); env.println(";");
env.println("#endif"); env.println("#endif");
env.println("extern const struct labcomm"+env.verStr+"_signature " +
"*labcomm"+env.verStr+"_signature_" + env.prefix + getName() +
";");
} }
public void Type.C_emitType(C_env env, String name) { public void Type.C_emitType(C_env env, String name) {
...@@ -287,6 +290,10 @@ aspect C_Type { ...@@ -287,6 +290,10 @@ aspect C_Type {
env.print("char " + name); env.print("char " + name);
} }
public void SampleRefType.C_emitType(C_env env, String name) {
env.print("const struct labcomm_signature *" + name);
}
public void PrimType.C_emitType(C_env env, String name) { public void PrimType.C_emitType(C_env env, String name) {
switch (getToken()) { switch (getToken()) {
case LABCOMM_BOOLEAN: { env.print("uint8_t"); } break; case LABCOMM_BOOLEAN: { env.print("uint8_t"); } break;
...@@ -508,6 +515,10 @@ aspect C_Decoder { ...@@ -508,6 +515,10 @@ aspect C_Decoder {
public void VoidType.C_emitDecoder(C_env env) { public void VoidType.C_emitDecoder(C_env env) {
} }
public void SampleRefType.C_emitDecoder(C_env env) {
env.println(env.qualid + " = labcomm_internal_decoder_index_to_signature(" +
"r->decoder, labcomm"+env.verStr+"_read_int(r));");
}
public void PrimType.C_emitDecoder(C_env env) { public void PrimType.C_emitDecoder(C_env env) {
env.println(env.qualid + " = labcomm"+env.verStr+"_read_" + getName() + "(r);"); env.println(env.qualid + " = labcomm"+env.verStr+"_read_" + getName() + "(r);");
} }
...@@ -585,6 +596,9 @@ aspect C_Decoder { ...@@ -585,6 +596,9 @@ aspect C_Decoder {
" not declared"); " not declared");
} }
public void SampleRefType.C_emitDecoderDeallocation(C_env env) {
}
public void PrimType.C_emitDecoderDeallocation(C_env env) { public void PrimType.C_emitDecoderDeallocation(C_env env) {
if (C_isDynamic()) { if (C_isDynamic()) {
env.println("labcomm"+env.verStr+"_memory_free(r->memory, 1, " + env.println("labcomm"+env.verStr+"_memory_free(r->memory, 1, " +
...@@ -669,7 +683,7 @@ aspect C_Decoder { ...@@ -669,7 +683,7 @@ aspect C_Decoder {
env.println("return labcomm"+env.verStr+"_internal_decoder_register("); env.println("return labcomm"+env.verStr+"_internal_decoder_register(");
env.indent(); env.indent();
env.println("d,"); env.println("d,");
env.println("&labcomm"+env.verStr+"_signature_" + env.prefix + getName() + ","); env.println("&signature_" + env.prefix + getName() + ",");
env.println("(labcomm"+env.verStr+"_decoder_function)decode_" + env.prefix + getName() + ","); env.println("(labcomm"+env.verStr+"_decoder_function)decode_" + env.prefix + getName() + ",");
env.println("(labcomm"+env.verStr+"_handler_function)handler,"); env.println("(labcomm"+env.verStr+"_handler_function)handler,");
env.println("context"); env.println("context");
...@@ -737,6 +751,12 @@ aspect C_copy { ...@@ -737,6 +751,12 @@ aspect C_copy {
public void VoidType.C_emitCopy(C_env env_src, C_env env_dst) { public void VoidType.C_emitCopy(C_env env_src, C_env env_dst) {
} }
public void SampleRefType.C_emitCopy(C_env env_src, C_env env_dst) {
env_src.println(env_dst.accessor() + env_dst.qualid + " = " +
env_src.accessor() + env_src.qualid + ";");
}
public void PrimType.C_emitCopy(C_env env_src, C_env env_dst) { public void PrimType.C_emitCopy(C_env env_src, C_env env_dst) {
if (C_isDynamic()) { if (C_isDynamic()) {
env_src.println(String.format( env_src.println(String.format(
...@@ -880,6 +900,9 @@ aspect C_copy { ...@@ -880,6 +900,9 @@ aspect C_copy {
public void VoidType.C_emitCopyDeallocation(C_env env) { public void VoidType.C_emitCopyDeallocation(C_env env) {
} }
public void SampleRefType.C_emitCopyDeallocation(C_env env) {
}
public void PrimType.C_emitCopyDeallocation(C_env env) { public void PrimType.C_emitCopyDeallocation(C_env env) {
if (C_isDynamic()) { if (C_isDynamic()) {
env.println("labcomm" + env.verStr + "_memory_free(mem, 1, " + env.println("labcomm" + env.verStr + "_memory_free(mem, 1, " +
...@@ -964,7 +987,7 @@ aspect C_DecoderIoctl { ...@@ -964,7 +987,7 @@ aspect C_DecoderIoctl {
env.println("va_start(va, ioctl_action);"); env.println("va_start(va, ioctl_action);");
env.println("result = labcomm"+env.verStr+"_internal_decoder_ioctl("); env.println("result = labcomm"+env.verStr+"_internal_decoder_ioctl(");
env.indent(); env.indent();
env.println("d, &labcomm"+env.verStr+"_signature_" + env.prefix + getName() + ", "); env.println("d, &signature_" + env.prefix + getName() + ", ");
env.println("ioctl_action, va);"); env.println("ioctl_action, va);");
env.unindent(); env.unindent();
env.println("va_end(va);"); env.println("va_end(va);");
...@@ -1014,7 +1037,7 @@ aspect C_Encoder { ...@@ -1014,7 +1037,7 @@ aspect C_Encoder {
env.println(")"); env.println(")");
env.println("{"); env.println("{");
env.indent(); env.indent();
env.println("return labcomm"+env.verStr+"_internal_encode(e, &labcomm"+env.verStr+"_signature_" + env.println("return labcomm"+env.verStr+"_internal_encode(e, &signature_" +
env.prefix + getName() + env.prefix + getName() +
", (labcomm"+env.verStr+"_encoder_function)encode_" + ", (labcomm"+env.verStr+"_encoder_function)encode_" +
env.prefix + getName() + env.prefix + getName() +
...@@ -1033,6 +1056,13 @@ aspect C_Encoder { ...@@ -1033,6 +1056,13 @@ aspect C_Encoder {
env.println("result = 0;"); env.println("result = 0;");
} }
public void SampleRefType.C_emitEncoder(C_env env) {
env.println("result = labcomm"+env.verStr+"_write_int(w, " +
"labcomm_internal_encoder_signature_to_index(w->encoder, " +
env.qualid + "));");
env.println("if (result != 0) { return result; }");
}
public void PrimType.C_emitEncoder(C_env env) { public void PrimType.C_emitEncoder(C_env env) {
env.println("result = labcomm"+env.verStr+"_write_" + getName() + env.println("result = labcomm"+env.verStr+"_write_" + getName() +
"(w, " + env.qualid + ");"); "(w, " + env.qualid + ");");
...@@ -1111,7 +1141,7 @@ aspect C_Encoder { ...@@ -1111,7 +1141,7 @@ aspect C_Encoder {
env.println("return labcomm"+env.verStr+"_internal_encoder_register("); env.println("return labcomm"+env.verStr+"_internal_encoder_register(");
env.indent(); env.indent();
env.println("e,"); env.println("e,");
env.println("&labcomm"+env.verStr+"_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(");");
...@@ -1147,7 +1177,7 @@ aspect C_EncoderIoctl { ...@@ -1147,7 +1177,7 @@ aspect C_EncoderIoctl {
env.println("va_start(va, ioctl_action);"); env.println("va_start(va, ioctl_action);");
env.println("result = labcomm"+env.verStr+"_internal_encoder_ioctl("); env.println("result = labcomm"+env.verStr+"_internal_encoder_ioctl(");
env.indent(); env.indent();
env.println("e, &labcomm"+env.verStr+"_signature_" + env.prefix + getName() + ", "); env.println("e, &signature_" + env.prefix + getName() + ", ");
env.println("ioctl_action, va);"); env.println("ioctl_action, va);");
env.unindent(); env.unindent();
env.println("va_end(va);"); env.println("va_end(va);");
...@@ -1189,8 +1219,8 @@ aspect C_Signature { ...@@ -1189,8 +1219,8 @@ aspect C_Signature {
} }
env.println("};"); env.println("};");
C_emitSizeofValue(env); C_emitSizeofValue(env);
env.println("struct labcomm"+env.verStr+"_signature labcomm"+env.verStr+"_signature_" + env.println("static struct labcomm"+env.verStr+"_signature " +
env.prefix + getName() + " = {"); "signature_" + env.prefix + getName() + " = {");
env.indent(); env.indent();
env.println("\"" + getName() + "\","); env.println("\"" + getName() + "\",");
env.println("sizeof_" + env.prefix + getName() + ","); env.println("sizeof_" + env.prefix + getName() + ",");
...@@ -1199,6 +1229,9 @@ aspect C_Signature { ...@@ -1199,6 +1229,9 @@ aspect C_Signature {
env.println("0"); env.println("0");
env.unindent(); env.unindent();
env.println(" };"); env.println(" };");
env.println("const struct labcomm"+env.verStr+"_signature " +
"*labcomm"+env.verStr+"_signature_" + env.prefix + getName() +
" = &signature_" + env.prefix + getName() + ";");
} }
public void ASTNode.C_emitConstructor(C_env env) { public void ASTNode.C_emitConstructor(C_env env) {
...@@ -1229,7 +1262,7 @@ aspect C_Signature { ...@@ -1229,7 +1262,7 @@ aspect C_Signature {
} }
public void SampleDecl.C_emitConstructor(C_env env) { public void SampleDecl.C_emitConstructor(C_env env) {
env.println("labcomm"+env.verStr+"_set_local_index(&labcomm"+env.verStr+"_signature_" + env.println("labcomm"+env.verStr+"_set_local_index(&signature_" +
env.prefix + getName() + ");"); env.prefix + getName() + ");");
} }
...@@ -1270,7 +1303,7 @@ aspect C_Sizeof { ...@@ -1270,7 +1303,7 @@ aspect C_Sizeof {
env.println("{"); env.println("{");
env.indent(); env.indent();
env.println("return labcomm"+env.verStr+"_internal_sizeof(" + env.println("return labcomm"+env.verStr+"_internal_sizeof(" +
"&labcomm" + env.verStr+"_signature_" + env.prefix + getName() + "&signature_" + env.prefix + getName() +
", v);"); ", v);");
env.unindent(); env.unindent();
env.println("}"); env.println("}");
...@@ -1286,6 +1319,10 @@ aspect C_Sizeof { ...@@ -1286,6 +1319,10 @@ aspect C_Sizeof {
return 0; return 0;
} }
public int SampleRefType.C_fixedSizeof() {
return 4;
}
public int PrimType.C_fixedSizeof() { public int PrimType.C_fixedSizeof() {
switch (getToken()) { switch (getToken()) {
case LABCOMM_BOOLEAN: { return 1; } case LABCOMM_BOOLEAN: { return 1; }
......
...@@ -8,6 +8,7 @@ Field ::= Type <Name:String>; ...@@ -8,6 +8,7 @@ Field ::= Type <Name:String>;
abstract Type; abstract Type;
VoidType : Type; VoidType : 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*;
......
...@@ -33,7 +33,7 @@ public class LabComm { ...@@ -33,7 +33,7 @@ public class LabComm {
println("[ RAPID options ]"); println("[ RAPID options ]");
println(" --rapid Generates RAPID code in FILE.sys"); println(" --rapid Generates RAPID code in FILE.sys");
println("[ Misc options ]"); println("[ Misc options ]");
println(" --pretty Pretty prints on standard output"); println(" --pretty=PFILE Pretty prints to PFILE");
println(" --typeinfo=TIFILE Generates typeinfo in TIFILE"); println(" --typeinfo=TIFILE Generates typeinfo in TIFILE");
} }
......
...@@ -77,6 +77,7 @@ Type type = ...@@ -77,6 +77,7 @@ Type type =
| user_type.u {: return u; :} | user_type.u {: return u; :}
| struct_type.s {: return s; :} | struct_type.s {: return s; :}
| void_type.v {: return v; :} | void_type.v {: return v; :}
| sample_ref_type.s {: return s; :}
; ;
PrimType prim_type = PrimType prim_type =
...@@ -110,6 +111,10 @@ VoidType void_type = ...@@ -110,6 +111,10 @@ VoidType void_type =
VOID {: return new VoidType(); :} VOID {: return new VoidType(); :}
; ;
SampleRefType sample_ref_type =
SAMPLE {: return new SampleRefType(); :}
;
List dim_list = List dim_list =
dim.d {: return new List().add(d); :} dim.d {: return new List().add(d); :}
| dim_list.l dim.d {: return l.add(d); :} | dim_list.l dim.d {: return l.add(d); :}
......
aspect LabCommTokens { aspect LabCommTokens {
public static final int ASTNode.LABCOMM_TYPEDEF = 0x01; public static final int ASTNode.LABCOMM_SAMPLE_DEF = 0x02;
public static final int ASTNode.LABCOMM_SAMPLE = 0x02; public static final int ASTNode.LABCOMM_SAMPLE_REF = 0x03;
public static final int ASTNode.LABCOMM_ARRAY = 0x10; public static final int ASTNode.LABCOMM_ARRAY = 0x10;
public static final int ASTNode.LABCOMM_STRUCT = 0x11; public static final int ASTNode.LABCOMM_STRUCT = 0x11;
......
...@@ -68,6 +68,10 @@ aspect PrettyPrint { ...@@ -68,6 +68,10 @@ aspect PrettyPrint {
out.print("void"); out.print("void");
} }
public void SampleRefType.ppPrefix(PrintStream out) {
out.print("sample");
}
public void PrimType.ppPrefix(PrintStream out) { public void PrimType.ppPrefix(PrintStream out) {
out.print(getName()); out.print(getName());
} }
......
...@@ -134,6 +134,10 @@ aspect Signature { ...@@ -134,6 +134,10 @@ aspect Signature {
list.addInt(0, null); list.addInt(0, null);
} }
public void SampleRefType.flatSignature(SignatureList list) {
list.addInt(LABCOMM_SAMPLE_REF, "sample");
}
public void PrimType.flatSignature(SignatureList list) { public void PrimType.flatSignature(SignatureList list) {
list.addInt(getToken(), null); list.addInt(getToken(), null);
} }
...@@ -200,6 +204,10 @@ aspect Signature { ...@@ -200,6 +204,10 @@ aspect Signature {
return getType().signatureComment() + " '" + getName() +"'"; return getType().signatureComment() + " '" + getName() +"'";
} }
public String SampleRefType.signatureComment() {
return "sample";
}
public String PrimType.signatureComment() { public String PrimType.signatureComment() {
return getName(); return getName();
} }
......
...@@ -106,7 +106,7 @@ static void enqueue_decimation(struct decimating_private *decimating, ...@@ -106,7 +106,7 @@ static void enqueue_decimation(struct decimating_private *decimating,
static int wrap_reader_start( static int wrap_reader_start(
struct labcomm_reader *r, struct labcomm_reader *r,
struct labcomm_reader_action_context *action_context, struct labcomm_reader_action_context *action_context,
int local_index, int remote_index, struct labcomm_signature *signature, int local_index, int remote_index, const struct labcomm_signature *signature,
void *value) void *value)
{ {
struct decimating_private *decimating = action_context->context; struct decimating_private *decimating = action_context->context;
...@@ -133,7 +133,7 @@ static int wrap_reader_ioctl( ...@@ -133,7 +133,7 @@ static int wrap_reader_ioctl(
struct labcomm_reader *r, struct labcomm_reader *r,
struct labcomm_reader_action_context *action_context, struct labcomm_reader_action_context *action_context,
int local_index, int remote_index, int local_index, int remote_index,
struct labcomm_signature *signature, const struct labcomm_signature *signature,
uint32_t action, va_list args) uint32_t action, va_list args)
{ {
struct decimating_private *decimating = action_context->context; struct decimating_private *decimating = action_context->context;
...@@ -197,7 +197,7 @@ static int wrap_writer_alloc( ...@@ -197,7 +197,7 @@ static int wrap_writer_alloc(
static int wrap_writer_start( static int wrap_writer_start(
struct labcomm_writer *w, struct labcomm_writer *w,
struct labcomm_writer_action_context *action_context, struct labcomm_writer_action_context *action_context,
int index, struct labcomm_signature *signature, int index, const struct labcomm_signature *signature,
void *value) void *value)
{ {
struct decimating_private *decimating = action_context->context; struct decimating_private *decimating = action_context->context;
......
...@@ -44,13 +44,13 @@ struct introspecting_private { ...@@ -44,13 +44,13 @@ struct introspecting_private {
LABCOMM_SIGNATURE_ARRAY_DEF(local, LABCOMM_SIGNATURE_ARRAY_DEF(local,
struct local { struct local {
enum introspecting_status status; enum introspecting_status status;
struct labcomm_signature *signature; const struct labcomm_signature *signature;
}); });
}; };
static struct local *get_local(struct introspecting_private *introspecting, static struct local *get_local(struct introspecting_private *introspecting,
int index, int index,
struct labcomm_signature *signature) const struct labcomm_signature *signature)
{ {
/* Called with data_lock held */ /* Called with data_lock held */
struct local *local; struct local *local;
...@@ -137,7 +137,7 @@ static int wrap_reader_alloc( ...@@ -137,7 +137,7 @@ static int wrap_reader_alloc(
struct handles_signature { struct handles_signature {
struct introspecting_private *introspecting; struct introspecting_private *introspecting;
int index; int index;
struct labcomm_signature *signature; const struct labcomm_signature *signature;
}; };
static void send_handles_signature(void *arg) static void send_handles_signature(void *arg)
...@@ -156,7 +156,7 @@ static void send_handles_signature(void *arg) ...@@ -156,7 +156,7 @@ static void send_handles_signature(void *arg)
static int wrap_reader_start( static int wrap_reader_start(
struct labcomm_reader *r, struct labcomm_reader *r,
struct labcomm_reader_action_context *action_context, struct labcomm_reader_action_context *action_context,
int local_index, int remote_index, struct labcomm_signature *signature, int local_index, int remote_index, const struct labcomm_signature *signature,
void *value) void *value)
{ {
struct introspecting_private *introspecting = action_context->context; struct introspecting_private *introspecting = action_context->context;
...@@ -180,7 +180,7 @@ static int wrap_reader_start( ...@@ -180,7 +180,7 @@ static int wrap_reader_start(
struct labcomm_encoder *encoder, struct labcomm_encoder *encoder,
void *context) void *context)
{ {
struct labcomm_signature *signature = context; const struct labcomm_signature *signature = context;
introspecting_messages_handles_signature handles_signature; introspecting_messages_handles_signature handles_signature;
int index = 0; int index = 0;
...@@ -224,7 +224,7 @@ static int wrap_writer_alloc( ...@@ -224,7 +224,7 @@ static int wrap_writer_alloc(
static int wrap_writer_start( static int wrap_writer_start(
struct labcomm_writer *w, struct labcomm_writer *w,
struct labcomm_writer_action_context *action_context, struct labcomm_writer_action_context *action_context,
int index, struct labcomm_signature *signature, int index, const struct labcomm_signature *signature,
void *value) void *value)
{ {
struct introspecting_private *introspecting = action_context->context; struct introspecting_private *introspecting = action_context->context;
...@@ -243,7 +243,7 @@ static int wrap_writer_start( ...@@ -243,7 +243,7 @@ static int wrap_writer_start(
static int wrap_writer_ioctl( static int wrap_writer_ioctl(
struct labcomm_writer *w, struct labcomm_writer *w,
struct labcomm_writer_action_context *action_context, struct labcomm_writer_action_context *action_context,
int index, struct labcomm_signature *signature, int index, const struct labcomm_signature *signature,
uint32_t ioctl_action, va_list args) uint32_t ioctl_action, va_list args)
{ {
struct introspecting_private *introspecting = action_context->context; struct introspecting_private *introspecting = action_context->context;
......
...@@ -64,7 +64,7 @@ int labcomm_reader_free(struct labcomm_reader *r, ...@@ -64,7 +64,7 @@ int labcomm_reader_free(struct labcomm_reader *r,
int labcomm_reader_start(struct labcomm_reader *r, int labcomm_reader_start(struct labcomm_reader *r,
struct labcomm_reader_action_context *action_context, struct labcomm_reader_action_context *action_context,
int local_index, int remote_index, int local_index, int remote_index,
struct labcomm_signature *signature, const struct labcomm_signature *signature,
void *value) void *value)
{ {
UNWRAP(start, r, action_context, local_index, remote_index, signature, value); UNWRAP(start, r, action_context, local_index, remote_index, signature, value);
...@@ -85,7 +85,7 @@ int labcomm_reader_fill(struct labcomm_reader *r, ...@@ -85,7 +85,7 @@ int labcomm_reader_fill(struct labcomm_reader *r,
int labcomm_reader_ioctl(struct labcomm_reader *r, int labcomm_reader_ioctl(struct labcomm_reader *r,
struct labcomm_reader_action_context *action_context, struct labcomm_reader_action_context *action_context,
int local_index, int remote_index, int local_index, int remote_index,
struct labcomm_signature *signature, const struct labcomm_signature *signature,
uint32_t ioctl_action, va_list args) uint32_t ioctl_action, va_list args)
{ {
UNWRAP(ioctl, r, action_context, UNWRAP(ioctl, r, action_context,
...@@ -106,7 +106,7 @@ int labcomm_writer_free(struct labcomm_writer *w, ...@@ -106,7 +106,7 @@ int labcomm_writer_free(struct labcomm_writer *w,
int labcomm_writer_start(struct labcomm_writer *w, int labcomm_writer_start(struct labcomm_writer *w,
struct labcomm_writer_action_context *action_context, struct labcomm_writer_action_context *action_context,
int index, struct labcomm_signature *signature, int index, const struct labcomm_signature *signature,
void *value) void *value)
{ {
UNWRAP(start, w, action_context, index, signature, value); UNWRAP(start, w, action_context, index, signature, value);
...@@ -127,7 +127,7 @@ int labcomm_writer_flush(struct labcomm_writer *w, ...@@ -127,7 +127,7 @@ int labcomm_writer_flush(struct labcomm_writer *w,
int labcomm_writer_ioctl(struct labcomm_writer *w, int labcomm_writer_ioctl(struct labcomm_writer *w,
struct labcomm_writer_action_context *action_context, struct labcomm_writer_action_context *action_context,
int index, int index,
struct labcomm_signature *signature, const struct labcomm_signature *signature,
uint32_t ioctl_action, va_list args) uint32_t ioctl_action, va_list args)
{ {
UNWRAP(ioctl, w, action_context, index, signature, ioctl_action, args); UNWRAP(ioctl, w, action_context, index, signature, ioctl_action, args);
...@@ -250,7 +250,7 @@ void labcomm_set_local_index(struct labcomm_signature *signature) ...@@ -250,7 +250,7 @@ void labcomm_set_local_index(struct labcomm_signature *signature)
local_index++; local_index++;
} }
int labcomm_get_local_index(struct labcomm_signature *signature) int labcomm_get_local_index(const struct labcomm_signature *signature)
{ {
if (signature->index == 0) { if (signature->index == 0) {
labcomm_error_fatal_global(LABCOMM_ERROR_SIGNATURE_NOT_SET, labcomm_error_fatal_global(LABCOMM_ERROR_SIGNATURE_NOT_SET,
...@@ -259,7 +259,7 @@ int labcomm_get_local_index(struct labcomm_signature *signature) ...@@ -259,7 +259,7 @@ int labcomm_get_local_index(struct labcomm_signature *signature)
return signature->index; return signature->index;
} }
int labcomm_internal_sizeof(struct labcomm_signature *signature, int labcomm_internal_sizeof(const struct labcomm_signature *signature,
void *v) void *v)
{ {
int length = signature->encoded_size(v); int length = signature->encoded_size(v);
......
...@@ -119,6 +119,9 @@ int labcomm_decoder_decode_one( ...@@ -119,6 +119,9 @@ int labcomm_decoder_decode_one(
struct labcomm_decoder *decoder); struct labcomm_decoder *decoder);
void labcomm_decoder_run( void labcomm_decoder_run(
struct labcomm_decoder *decoder); struct labcomm_decoder *decoder);
int labcomm_decoder_sample_ref_register(
struct labcomm_decoder *decoder,
const struct labcomm_signature *signature);
/* See labcomm_ioctl.h for predefined ioctl_action values */ /* See labcomm_ioctl.h for predefined ioctl_action values */
int labcomm_decoder_ioctl(struct labcomm_decoder *decoder, int labcomm_decoder_ioctl(struct labcomm_decoder *decoder,
...@@ -137,6 +140,9 @@ struct labcomm_encoder *labcomm_encoder_new( ...@@ -137,6 +140,9 @@ struct labcomm_encoder *labcomm_encoder_new(
struct labcomm_scheduler *scheduler); struct labcomm_scheduler *scheduler);
void labcomm_encoder_free( void labcomm_encoder_free(
struct labcomm_encoder *encoder); struct labcomm_encoder *encoder);
int labcomm_encoder_sample_ref_register(
struct labcomm_encoder *encoder,
const struct labcomm_signature *signature);
/* See labcomm_ioctl.h for predefined ioctl_action values */ /* See labcomm_ioctl.h for predefined ioctl_action values */
int labcomm_encoder_ioctl(struct labcomm_encoder *encoder, int labcomm_encoder_ioctl(struct labcomm_encoder *encoder,
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
struct sample_entry { struct sample_entry {
int remote_index; int remote_index;
struct labcomm_signature *signature; const struct labcomm_signature *signature;
labcomm_decoder_function decode; labcomm_decoder_function decode;
labcomm_handler_function handler; labcomm_handler_function handler;
void *context; void *context;
...@@ -45,6 +45,8 @@ struct labcomm_decoder { ...@@ -45,6 +45,8 @@ struct labcomm_decoder {
labcomm_handle_new_datatype_callback on_new_datatype; labcomm_handle_new_datatype_callback on_new_datatype;
LABCOMM_SIGNATURE_ARRAY_DEF(local, struct sample_entry); LABCOMM_SIGNATURE_ARRAY_DEF(local, struct sample_entry);
LABCOMM_SIGNATURE_ARRAY_DEF(remote_to_local, int); LABCOMM_SIGNATURE_ARRAY_DEF(remote_to_local, int);
LABCOMM_SIGNATURE_ARRAY_DEF(local_ref, const struct labcomm_signature *);
LABCOMM_SIGNATURE_ARRAY_DEF(remote_to_local_ref, int);
}; };