Commit 07189291 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Refactoring to enable implementation of renaming encoders/decoders.

parent 0db2f8ce
...@@ -528,7 +528,7 @@ aspect C_Decoder { ...@@ -528,7 +528,7 @@ aspect C_Decoder {
env.print(env.qualid + " = "); env.print(env.qualid + " = ");
switch (getToken()) { switch (getToken()) {
case LABCOMM_SAMPLE: { case LABCOMM_SAMPLE: {
env.println("labcomm2014_internal_decoder_index_to_signature(" + env.println("r->decoder->index_to_signature(" +
"r->decoder, labcomm2014_read_int(r));"); "r->decoder, labcomm2014_read_int(r));");
} break; } break;
default: { default: {
...@@ -691,7 +691,7 @@ aspect C_Decoder { ...@@ -691,7 +691,7 @@ aspect C_Decoder {
env.println(")"); env.println(")");
env.println("{"); env.println("{");
env.indent(); env.indent();
env.println("return labcomm2014_internal_decoder_register("); env.println("return d->register_sample(");
env.indent(); env.indent();
env.println("d,"); env.println("d,");
env.println("&signature_" + env.prefix + getName() + ","); env.println("&signature_" + env.prefix + getName() + ",");
...@@ -985,7 +985,7 @@ aspect C_DecoderIoctl { ...@@ -985,7 +985,7 @@ aspect C_DecoderIoctl {
env.println("int result;"); env.println("int result;");
env.println("va_list va;"); env.println("va_list va;");
env.println("va_start(va, ioctl_action);"); env.println("va_start(va, ioctl_action);");
env.println("result = labcomm2014_internal_decoder_ioctl("); env.println("result = d->ioctl(");
env.indent(); env.indent();
env.println("d, &signature_" + env.prefix + getName() + ", "); env.println("d, &signature_" + env.prefix + getName() + ", ");
env.println("ioctl_action, va);"); env.println("ioctl_action, va);");
...@@ -1038,7 +1038,7 @@ aspect C_Encoder { ...@@ -1038,7 +1038,7 @@ aspect C_Encoder {
env.println(")"); env.println(")");
env.println("{"); env.println("{");
env.indent(); env.indent();
env.println("return labcomm2014_internal_encode(e, &signature_" + env.println("return e->encode(e, &signature_" +
env.prefix + getName() + env.prefix + getName() +
", (labcomm2014_encoder_function)encode_" + ", (labcomm2014_encoder_function)encode_" +
env.prefix + getName() + env.prefix + getName() +
...@@ -1062,7 +1062,7 @@ aspect C_Encoder { ...@@ -1062,7 +1062,7 @@ aspect C_Encoder {
switch (getToken()) { switch (getToken()) {
case LABCOMM_SAMPLE: { case LABCOMM_SAMPLE: {
env.println("labcomm2014_write_int(w, " + env.println("labcomm2014_write_int(w, " +
"labcomm2014_internal_encoder_signature_to_index(w->encoder, " + "w->encoder->signature_to_index(w->encoder, " +
env.qualid + "));"); env.qualid + "));");
} break; } break;
default: { default: {
...@@ -1144,7 +1144,7 @@ aspect C_Encoder { ...@@ -1144,7 +1144,7 @@ aspect C_Encoder {
C_emitUserTypeDeps(env, null, true); C_emitUserTypeDeps(env, null, true);
if(!isSampleDecl() || hasDependencies()) { if(!isSampleDecl() || hasDependencies()) {
env.println("return labcomm2014_internal_encoder_type_register("); env.println("return e->type_register(");
env.indent(); env.indent();
env.println("e,"); env.println("e,");
env.println("&signature_" + env.prefix + getName() + ""); env.println("&signature_" + env.prefix + getName() + "");
...@@ -1174,7 +1174,7 @@ aspect C_Encoder { ...@@ -1174,7 +1174,7 @@ 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("int result = labcomm2014_internal_encoder_register("); env.println("int result = e->sample_register(");
env.indent(); env.indent();
env.println("e,"); env.println("e,");
env.println("&signature_" + env.prefix + getName() + ","); env.println("&signature_" + env.prefix + getName() + ",");
...@@ -1184,7 +1184,7 @@ aspect C_Encoder { ...@@ -1184,7 +1184,7 @@ aspect C_Encoder {
env.println("if(result >= 0) {\n"); env.println("if(result >= 0) {\n");
env.indent(); env.indent();
env.println("labcomm2014_encoder_type_register_" + env.prefix + getName()+"(e);"); env.println("labcomm2014_encoder_type_register_" + env.prefix + getName()+"(e);");
env.println("labcomm2014_internal_encoder_type_bind("); env.println("e->type_bind(");
env.indent(); env.indent();
env.println("e,"); env.println("e,");
env.println("&signature_" + env.prefix + getName() + ","); env.println("&signature_" + env.prefix + getName() + ",");
...@@ -1222,7 +1222,7 @@ aspect C_EncoderIoctl { ...@@ -1222,7 +1222,7 @@ aspect C_EncoderIoctl {
env.println("int result;"); env.println("int result;");
env.println("va_list va;"); env.println("va_list va;");
env.println("va_start(va, ioctl_action);"); env.println("va_start(va, ioctl_action);");
env.println("result = labcomm2014_internal_encoder_ioctl("); env.println("result = e->ioctl(");
env.indent(); env.indent();
env.println("e, &signature_" + env.prefix + getName() + ", "); env.println("e, &signature_" + env.prefix + getName() + ", ");
env.println("ioctl_action, va);"); env.println("ioctl_action, va);");
......
...@@ -46,82 +46,31 @@ struct sample_entry { ...@@ -46,82 +46,31 @@ struct sample_entry {
void *context; void *context;
}; };
struct labcomm2014_decoder { struct decoder {
struct labcomm2014_reader *reader; struct labcomm2014_decoder decoder;
int reader_allocated;
int version_ok;
struct labcomm2014_error_handler *error;
struct labcomm2014_memory *memory;
struct labcomm2014_scheduler *scheduler;
labcomm2014_error_handler_callback on_error;
labcomm2014_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 labcomm2014_signature *); LABCOMM_SIGNATURE_ARRAY_DEF(local_ref, const struct labcomm2014_signature *);
LABCOMM_SIGNATURE_ARRAY_DEF(remote_to_local_ref, int); LABCOMM_SIGNATURE_ARRAY_DEF(remote_to_local_ref, int);
}; };
struct labcomm2014_decoder *labcomm2014_decoder_new(
struct labcomm2014_reader *reader,
struct labcomm2014_error_handler *error,
struct labcomm2014_memory *memory,
struct labcomm2014_scheduler *scheduler)
{
struct labcomm2014_decoder *result;
result = labcomm2014_memory_alloc(memory, 0, sizeof(*result));
if (result) {
result->reader = reader;
result->reader->decoder = result;
result->reader->data = 0;
result->reader->data_size = 0;
result->reader->count = 0;
result->reader->pos = 0;
result->reader->error = 0;
result->reader_allocated = 0;
result->version_ok = 0;
result->error = error;
result->memory = memory;
result->scheduler = scheduler;
result->on_error = labcomm20142014_on_error_fprintf;
LABCOMM_SIGNATURE_ARRAY_INIT(result->local, struct sample_entry);
LABCOMM_SIGNATURE_ARRAY_INIT(result->remote_to_local, int);
LABCOMM_SIGNATURE_ARRAY_INIT(result->local_ref,
const struct labcomm2014_signature*);
LABCOMM_SIGNATURE_ARRAY_INIT(result->remote_to_local_ref, int);
}
return result;
}
void labcomm2014_decoder_free(struct labcomm2014_decoder* d)
{
struct labcomm2014_memory *memory = d->memory;
labcomm2014_reader_free(d->reader, d->reader->action_context);
LABCOMM_SIGNATURE_ARRAY_FREE(memory, d->local, struct sample_entry);
LABCOMM_SIGNATURE_ARRAY_FREE(memory, d->remote_to_local, int);
LABCOMM_SIGNATURE_ARRAY_FREE(memory, d->local_ref,
const struct labcomm2014_signature*);
LABCOMM_SIGNATURE_ARRAY_FREE(memory, d->remote_to_local_ref, int);
labcomm2014_memory_free(memory, 0, d);
}
static int handle_sample_def(struct labcomm2014_decoder *d, int remote_index, static int handle_sample_def(struct labcomm2014_decoder *d, int remote_index,
const struct labcomm2014_signature *signature) const struct labcomm2014_signature *signature)
{ {
struct decoder *id = d->context;
int result; int result;
int i; int i;
const struct labcomm2014_signature *local_signature = NULL; const struct labcomm2014_signature *local_signature = NULL;
int local_index = 0; int local_index = 0;
labcomm2014_scheduler_data_lock(d->scheduler); labcomm2014_scheduler_data_lock(d->scheduler);
LABCOMM_SIGNATURE_ARRAY_FOREACH(d->local, struct sample_entry, i) { LABCOMM_SIGNATURE_ARRAY_FOREACH(id->local, struct sample_entry, i) {
struct sample_entry *s; struct sample_entry *s;
int *remote_to_local; int *remote_to_local;
result = -ENOENT; result = -ENOENT;
s = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, s = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->local, struct sample_entry, i); id->local, struct sample_entry, i);
if (s->signature && if (s->signature &&
s->signature->size == signature->size && s->signature->size == signature->size &&
strcmp(s->signature->name, signature->name) == 0 && strcmp(s->signature->name, signature->name) == 0 &&
...@@ -131,7 +80,7 @@ static int handle_sample_def(struct labcomm2014_decoder *d, int remote_index, ...@@ -131,7 +80,7 @@ static int handle_sample_def(struct labcomm2014_decoder *d, int remote_index,
local_signature = s->signature; local_signature = s->signature;
local_index = i; local_index = i;
remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->remote_to_local, int, id->remote_to_local, int,
remote_index); remote_index);
*remote_to_local = i; *remote_to_local = i;
result = remote_index; result = remote_index;
...@@ -151,23 +100,26 @@ static int handle_sample_def(struct labcomm2014_decoder *d, int remote_index, ...@@ -151,23 +100,26 @@ static int handle_sample_def(struct labcomm2014_decoder *d, int remote_index,
static int handle_sample_ref(struct labcomm2014_decoder *d, int remote_index, static int handle_sample_ref(struct labcomm2014_decoder *d, int remote_index,
const struct labcomm2014_signature *signature) const struct labcomm2014_signature *signature)
{ {
struct decoder *id = d->context;
int result; int result;
int i; int i;
labcomm2014_scheduler_data_lock(d->scheduler); labcomm2014_scheduler_data_lock(d->scheduler);
LABCOMM_SIGNATURE_ARRAY_FOREACH(d->local_ref, const struct labcomm2014_signature *, i) { LABCOMM_SIGNATURE_ARRAY_FOREACH(id->local_ref,
const struct labcomm2014_signature *, i) {
const struct labcomm2014_signature *s; const struct labcomm2014_signature *s;
int *remote_to_local_ref; int *remote_to_local_ref;
result = -ENOENT; result = -ENOENT;
s = LABCOMM_SIGNATURE_ARRAY_GET(d->local_ref, const struct labcomm2014_signature *, i, 0); s = LABCOMM_SIGNATURE_ARRAY_GET(id->local_ref, const struct labcomm2014_signature *, i, 0);
if (s && if (s &&
s->signature && s->signature &&
s->size == signature->size && s->size == signature->size &&
strcmp(s->name, signature->name) == 0 && strcmp(s->name, signature->name) == 0 &&
memcmp((void*)s->signature, (void*)signature->signature, signature->size) == 0) { memcmp((void*)s->signature, (void*)signature->signature, signature->size) == 0) {
remote_to_local_ref = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, remote_to_local_ref = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->remote_to_local_ref, int, id->remote_to_local_ref,
int,
remote_index); remote_index);
*remote_to_local_ref = i; *remote_to_local_ref = i;
result = remote_index; result = remote_index;
...@@ -309,16 +261,17 @@ static labcomm2014_decoder_function lookup_h(struct labcomm2014_decoder *d, ...@@ -309,16 +261,17 @@ static labcomm2014_decoder_function lookup_h(struct labcomm2014_decoder *d,
int remote_index, int remote_index,
int **local_index) int **local_index)
{ {
struct decoder *id = d->context;
labcomm2014_decoder_function do_decode = NULL; labcomm2014_decoder_function do_decode = NULL;
labcomm2014_scheduler_data_lock(d->scheduler); labcomm2014_scheduler_data_lock(d->scheduler);
*local_index = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, *local_index = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->remote_to_local, int, id->remote_to_local, int,
remote_index); remote_index);
if (**local_index != 0) { if (**local_index != 0) {
struct sample_entry *entry; struct sample_entry *entry;
entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->local, struct sample_entry, id->local, struct sample_entry,
**local_index); **local_index);
wrap->local_index = **local_index; wrap->local_index = **local_index;
wrap->signature = entry->signature; wrap->signature = entry->signature;
...@@ -443,6 +396,7 @@ int labcomm2014_decoder_sample_ref_register( ...@@ -443,6 +396,7 @@ int labcomm2014_decoder_sample_ref_register(
struct labcomm2014_decoder *d, struct labcomm2014_decoder *d,
const struct labcomm2014_signature *signature) const struct labcomm2014_signature *signature)
{ {
struct decoder *id = d->context;
int local_index, *remote_to_local_ref; int local_index, *remote_to_local_ref;
const struct labcomm2014_signature **s; const struct labcomm2014_signature **s;
...@@ -450,13 +404,13 @@ int labcomm2014_decoder_sample_ref_register( ...@@ -450,13 +404,13 @@ int labcomm2014_decoder_sample_ref_register(
if (local_index <= 0) { goto out; } if (local_index <= 0) { goto out; }
labcomm2014_scheduler_data_lock(d->scheduler); labcomm2014_scheduler_data_lock(d->scheduler);
s = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, s = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->local_ref, id->local_ref,
const struct labcomm2014_signature*, local_index); const struct labcomm2014_signature*, local_index);
if (s == NULL) { local_index = -ENOMEM; goto unlock; }; if (s == NULL) { local_index = -ENOMEM; goto unlock; };
if (*s) { goto unlock; } if (*s) { goto unlock; }
*s = signature; *s = signature;
remote_to_local_ref = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, remote_to_local_ref = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->remote_to_local_ref, id->remote_to_local_ref,
int, local_index); int, local_index);
*remote_to_local_ref = 0; *remote_to_local_ref = 0;
unlock: unlock:
...@@ -465,17 +419,18 @@ out: ...@@ -465,17 +419,18 @@ out:
return local_index; return local_index;
} }
int labcomm2014_internal_decoder_ioctl(struct labcomm2014_decoder *d, static int do_ioctl(struct labcomm2014_decoder *d,
const struct labcomm2014_signature *signature, const struct labcomm2014_signature *signature,
uint32_t action, va_list va) uint32_t action, va_list va)
{ {
struct decoder *id = d->context;
int result; int result;
int local_index, remote_index; int local_index, remote_index;
local_index = labcomm2014_get_local_index(signature); local_index = labcomm2014_get_local_index(signature);
labcomm2014_scheduler_data_lock(d->scheduler); labcomm2014_scheduler_data_lock(d->scheduler);
remote_index = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, remote_index = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->local, id->local,
struct sample_entry, struct sample_entry,
local_index)->remote_index; local_index)->remote_index;
labcomm2014_scheduler_data_unlock(d->scheduler); labcomm2014_scheduler_data_unlock(d->scheduler);
...@@ -530,13 +485,14 @@ int labcomm2014_decoder_register_labcomm2014_type_def( ...@@ -530,13 +485,14 @@ int labcomm2014_decoder_register_labcomm2014_type_def(
void *context void *context
) )
{ {
struct decoder *id = d->context;
int tag = LABCOMM_TYPE_DEF; int tag = LABCOMM_TYPE_DEF;
struct sample_entry *entry; struct sample_entry *entry;
int *remote_to_local; int *remote_to_local;
labcomm2014_scheduler_data_lock(d->scheduler); labcomm2014_scheduler_data_lock(d->scheduler);
entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->local, struct sample_entry, id->local, struct sample_entry,
tag); tag);
if (entry == NULL) { tag = -ENOMEM; goto unlock; } if (entry == NULL) { tag = -ENOMEM; goto unlock; }
entry->remote_index = tag; entry->remote_index = tag;
...@@ -546,7 +502,7 @@ int labcomm2014_decoder_register_labcomm2014_type_def( ...@@ -546,7 +502,7 @@ int labcomm2014_decoder_register_labcomm2014_type_def(
entry->context = context; entry->context = context;
remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->remote_to_local, int, id->remote_to_local, int,
tag); tag);
*remote_to_local = tag; *remote_to_local = tag;
unlock: unlock:
...@@ -584,13 +540,14 @@ int labcomm2014_decoder_register_labcomm2014_type_binding( ...@@ -584,13 +540,14 @@ int labcomm2014_decoder_register_labcomm2014_type_binding(
void *context void *context
) )
{ {
struct decoder *id = d->context;
int tag = LABCOMM_TYPE_BINDING; int tag = LABCOMM_TYPE_BINDING;
struct sample_entry *entry; struct sample_entry *entry;
int *remote_to_local; int *remote_to_local;
labcomm2014_scheduler_data_lock(d->scheduler); labcomm2014_scheduler_data_lock(d->scheduler);
entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->local, struct sample_entry, id->local, struct sample_entry,
tag); tag);
if (entry == NULL) { tag = -ENOMEM; goto unlock; } if (entry == NULL) { tag = -ENOMEM; goto unlock; }
entry->remote_index = tag; entry->remote_index = tag;
...@@ -600,7 +557,7 @@ int labcomm2014_decoder_register_labcomm2014_type_binding( ...@@ -600,7 +557,7 @@ int labcomm2014_decoder_register_labcomm2014_type_binding(
entry->context = context; entry->context = context;
remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, remote_to_local = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->remote_to_local, int, id->remote_to_local, int,
tag); tag);
*remote_to_local = tag; *remote_to_local = tag;
unlock: unlock:
...@@ -612,13 +569,14 @@ unlock: ...@@ -612,13 +569,14 @@ unlock:
//// End type_def handling //// End type_def handling
#endif #endif
int labcomm2014_internal_decoder_register( static int do_register_sample(
struct labcomm2014_decoder *d, struct labcomm2014_decoder *d,
const struct labcomm2014_signature *signature, const struct labcomm2014_signature *signature,
labcomm2014_decoder_function decode, labcomm2014_decoder_function decode,
labcomm2014_handler_function handler, labcomm2014_handler_function handler,
void *context) void *context)
{ {
struct decoder *id = d->context;
int local_index; int local_index;
struct sample_entry *entry; struct sample_entry *entry;
...@@ -632,7 +590,7 @@ int labcomm2014_internal_decoder_register( ...@@ -632,7 +590,7 @@ int labcomm2014_internal_decoder_register(
labcomm2014_scheduler_data_lock(d->scheduler); labcomm2014_scheduler_data_lock(d->scheduler);
entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory, entry = LABCOMM_SIGNATURE_ARRAY_REF(d->memory,
d->local, struct sample_entry, id->local, struct sample_entry,
local_index); local_index);
if (entry == NULL) { local_index = -ENOMEM; goto unlock; } if (entry == NULL) { local_index = -ENOMEM; goto unlock; }
entry->remote_index = 0; entry->remote_index = 0;
...@@ -646,20 +604,72 @@ out: ...@@ -646,20 +604,72 @@ out:
return local_index; return local_index;
} }
const struct labcomm2014_signature *labcomm2014_internal_decoder_index_to_signature( static const struct labcomm2014_signature *do_index_to_signature(
struct labcomm2014_decoder *d, int index) struct labcomm2014_decoder *d, int index)
{ {
const struct labcomm2014_signature *result = 0; const struct labcomm2014_signature *result = 0;
struct decoder *id = d->context;
int local_index; int local_index;
labcomm2014_scheduler_data_lock(d->scheduler); labcomm2014_scheduler_data_lock(d->scheduler);
local_index = LABCOMM_SIGNATURE_ARRAY_GET(d->remote_to_local_ref, local_index = LABCOMM_SIGNATURE_ARRAY_GET(id->remote_to_local_ref,
int, index, 0); int, index, 0);
if (local_index) { if (local_index) {
result = LABCOMM_SIGNATURE_ARRAY_GET(d->local_ref, result = LABCOMM_SIGNATURE_ARRAY_GET(id->local_ref,
const struct labcomm2014_signature*, const struct labcomm2014_signature*,
local_index, 0); local_index, 0);
} }
labcomm2014_scheduler_data_unlock(d->scheduler); labcomm2014_scheduler_data_unlock(d->scheduler);
return result; return result;
} }
struct labcomm2014_decoder *labcomm2014_decoder_new(
struct labcomm2014_reader *reader,
struct labcomm2014_error_handler *error,
struct labcomm2014_memory *memory,
struct labcomm2014_scheduler *scheduler)
{
struct decoder *result;
result = labcomm2014_memory_alloc(memory, 0, sizeof(*result));
if (result) {
result->decoder.context = result;
result->decoder.reader = reader;
result->decoder.reader->decoder = &result->decoder;
result->decoder.reader->data = 0;
result->decoder.reader->data_size = 0;
result->decoder.reader->count = 0;
result->decoder.reader->pos = 0;
result->decoder.reader->error = 0;
result->decoder.reader_allocated = 0;
result->decoder.version_ok = 0;
result->decoder.error = error;
result->decoder.memory = memory;
result->decoder.scheduler = scheduler;
result->decoder.on_error = labcomm20142014_on_error_fprintf;
result->decoder.register_sample = do_register_sample;
result->decoder.ioctl = do_ioctl;
result->decoder.index_to_signature = do_index_to_signature;
LABCOMM_SIGNATURE_ARRAY_INIT(result->local, struct sample_entry);
LABCOMM_SIGNATURE_ARRAY_INIT(result->remote_to_local, int);
LABCOMM_SIGNATURE_ARRAY_INIT(result->local_ref,
const struct labcomm2014_signature*);
LABCOMM_SIGNATURE_ARRAY_INIT(result->remote_to_local_ref, int);
}
return &(result->decoder);
}
void labcomm2014_decoder_free(struct labcomm2014_decoder* d)
{
struct decoder *id = d->context;
struct labcomm2014_memory *memory = d->memory;
labcomm2014_reader_free(d->reader, d->reader->action_context);
LABCOMM_SIGNATURE_ARRAY_FREE(memory, id->local, struct sample_entry);
LABCOMM_SIGNATURE_ARRAY_FREE(memory, id->remote_to_local, int);
LABCOMM_SIGNATURE_ARRAY_FREE(memory, id->local_ref,
const struct labcomm2014_signature*);
LABCOMM_SIGNATURE_ARRAY_FREE(memory, id->remote_to_local_ref, int);
labcomm2014_memory_free(memory, 0, id);
}
...@@ -29,89 +29,26 @@ ...@@ -29,89 +29,26 @@
//define the following to disable encoding of typedefs //define the following to disable encoding of typedefs
#undef LABCOMM_WITHOUT_TYPE_DEFS #undef LABCOMM_WITHOUT_TYPE_DEFS
struct labcomm2014_encoder { struct encoder {
struct labcomm2014_writer *writer; struct labcomm2014_encoder encoder;
struct labcomm2014_error_handler *error;
struct labcomm2014_memory *memory;
struct labcomm2014_scheduler *scheduler;
LABCOMM_SIGNATURE_ARRAY_DEF(registered, int); LABCOMM_SIGNATURE_ARRAY_DEF(registered, int);
LABCOMM_SIGNATURE_ARRAY_DEF(sample_ref, int); LABCOMM_SIGNATURE_ARRAY_DEF(sample_ref, int);
LABCOMM_SIGNATURE_ARRAY_DEF(typedefs, int); LABCOMM_SIGNATURE_ARRAY_DEF(typedefs, int);
}; };
static struct labcomm2014_encoder *internal_encoder_new( static int do_sample_register(
struct labcomm2014_writer *writer,