diff --git a/compiler/2014/C_CodeGen.jrag b/compiler/2014/C_CodeGen.jrag index 0b68620d45d45e8a25e37cc51f6949c46cfe062a..31b64477703ea43aef659826a37b53ef22b3b8a6 100644 --- a/compiler/2014/C_CodeGen.jrag +++ b/compiler/2014/C_CodeGen.jrag @@ -1309,8 +1309,10 @@ aspect C_Signature { env.println("0,"); env.println("NULL,"); env.println("0,"); // index + env.println("#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS"); env.println("sizeof(signature_tree_" + env.prefix + getName() + "),"); env.println("signature_tree_" + env.prefix + getName() + ""); + env.println("#endif"); env.unindent(); env.println(" };"); env.println("const struct labcomm2014_signature " + @@ -1347,9 +1349,11 @@ aspect C_Signature { env.println("sizeof(signature_bytes_" + env.prefix + getName() + "),"); env.println("signature_bytes_" + env.prefix + getName() + ","); env.println("0,"); // index + env.println("#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS"); env.println("sizeof(signature_tree_" + env.prefix + getName() + "),"); env.println("signature_tree_" + env.prefix + getName() + ""); env.unindent(); + env.println("#endif"); env.println(" };"); env.println("const struct labcomm2014_signature " + "*labcomm2014_signature_" + env.prefix + getName() + @@ -1402,6 +1406,7 @@ aspect C_Signature { // //} public void SignatureList.C_emitSignature(C_env env, boolean decl) { + env.println("#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS"); env.println("static struct labcomm2014_signature_data signature_tree_" + env.prefix + parentDecl().getName() + "[] = {"); env.indent(); @@ -1413,6 +1418,7 @@ aspect C_Signature { env.println("LABCOMM_SIGDEF_END"); env.println("};"); env.unindent(); + env.println("#endif"); env.println(); } diff --git a/examples/user_types/example_decoder.c b/examples/user_types/example_decoder.c index 18743734114520de2c291dda4e88cb2b6a42373b..0237b76b91ff0c8a70f45f00edab82c42dc1ff5f 100644 --- a/examples/user_types/example_decoder.c +++ b/examples/user_types/example_decoder.c @@ -28,6 +28,7 @@ static void handle_test_theSecondInt(int *v,void *context) { printf("Got theSecondInt. (%d) \n", *v); } +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS static void handle_type_def(struct labcomm2014_raw_type_def *v,void *context) { printf("Got type_def. (0x%x) %s\n", v->index, v->name); } @@ -35,6 +36,7 @@ static void handle_type_def(struct labcomm2014_raw_type_def *v,void *context) { static void handle_type_binding(struct labcomm2014_type_binding *v,void *context) { printf("Got type binding. 0x%x --> 0x%x\n", v->sample_index, v->type_index); } +#endif static void handle_test_twoLines(test_twoLines *v,void *context) { printf("Got twoLines. (%d,%d) -> (%d,%d), (%d,%d) -> (%d,%d)\n", v->l1.start.x.val, v->l1.start.y.val, @@ -69,9 +71,11 @@ int main(int argc, char *argv[]) { labcomm2014_decoder_register_test_theFirstInt(decoder, handle_test_theFirstInt, context); labcomm2014_decoder_register_test_theSecondInt(decoder, handle_test_theSecondInt, context); labcomm2014_decoder_register_test_twoLines(decoder, handle_test_twoLines, context); +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS labcomm2014_decoder_register_labcomm2014_type_def(decoder, handle_type_def, context); labcomm2014_decoder_register_labcomm2014_type_binding(decoder, handle_type_binding, context); - +#endif + printf("Decoding:\n"); labcomm2014_decoder_run(decoder); printf("--- End Of File ---:\n"); diff --git a/lib/c/2014/labcomm2014_decoder.c b/lib/c/2014/labcomm2014_decoder.c index e270afc4a464d1f3b4752d639165ddd75192bdc6..a4cae4d66527674e526cf12f18e1d606c5161f4b 100644 --- a/lib/c/2014/labcomm2014_decoder.c +++ b/lib/c/2014/labcomm2014_decoder.c @@ -471,7 +471,7 @@ static int do_ioctl(struct labcomm2014_decoder *d, return result; } -#ifndef LABCOMM_NO_TYPEDECL +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS //// Code for allowing user code to handle type_defs //// (should perhaps be moved to another file) diff --git a/lib/c/2014/labcomm2014_encoder.c b/lib/c/2014/labcomm2014_encoder.c index 59a34ef2f25ad063f6caf23737fb0b76510847f8..70a2f9c3a14b44471ef7c895f1a3e744e1fe33fb 100644 --- a/lib/c/2014/labcomm2014_encoder.c +++ b/lib/c/2014/labcomm2014_encoder.c @@ -27,7 +27,7 @@ #include "labcomm2014_dynamic_buffer_writer.h" //define the following to disable encoding of typedefs -#undef LABCOMM_WITHOUT_TYPE_DEFS +#undef LABCOMM_USE_UNSUPPORTED_TYPEDEFS struct encoder { struct labcomm2014_encoder encoder; @@ -216,7 +216,7 @@ static int do_sample_ref_to_index( * Start of code related to sending (hierarchical) * typedefs. Define LABCOMM_WITHOUT_TYPEDEFS to disable **********************************************************/ -#ifndef LABCOMM_WITHOUT_TYPE_DEFS +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS static void write_sig_tree_byte(char b, const struct labcomm2014_signature *signature, void *context) @@ -307,7 +307,7 @@ static int do_type_register( struct labcomm2014_encoder *e, const struct labcomm2014_signature *signature) { -#ifndef LABCOMM_WITHOUT_TYPE_DEFS +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS return internal_reg_type(e, signature, LABCOMM2014_FALSE); #else return 0; @@ -319,7 +319,7 @@ static int do_type_bind( const struct labcomm2014_signature *signature, char has_deps) { -#ifndef LABCOMM_WITHOUT_TYPE_DEFS +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS int result = -EINVAL; int err; int sindex = labcomm2014_get_local_index(signature); diff --git a/lib/c/2014/labcomm2014_renaming_registry.c b/lib/c/2014/labcomm2014_renaming_registry.c index 03949e0a4500532b4628dbd6947497b3fc1281f4..c26c89d3bffe06764f87eefebed9f108c1d3a731 100644 --- a/lib/c/2014/labcomm2014_renaming_registry.c +++ b/lib/c/2014/labcomm2014_renaming_registry.c @@ -40,7 +40,9 @@ struct labcomm2014_renaming_rename { int use_count; struct registry *base; struct labcomm2014_signature signature; +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS struct labcomm2014_signature_data s_treedata[2]; +#endif }; struct labcomm2014_renaming_registry { @@ -152,7 +154,7 @@ struct labcomm2014_renaming_rename *labcomm2014_renaming_rename_new( entry->signature.size = base->signature->size; entry->signature.signature = base->signature->signature; entry->signature.index = 0; -#ifndef LABCOMM_NO_TYPEDECL +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS struct labcomm2014_signature_data s_treedata[2] = { LABCOMM_SIGDEF_SIGNATURE(*base->signature), LABCOMM_SIGDEF_END diff --git a/lib/c/2014/labcomm2014_type_signature.c b/lib/c/2014/labcomm2014_type_signature.c index dce1836199fd47e30bf53f8f4766dd81cf3c7b43..c1944d5bdf05f63a196cff7330fa2c67c913a8d7 100644 --- a/lib/c/2014/labcomm2014_type_signature.c +++ b/lib/c/2014/labcomm2014_type_signature.c @@ -2,6 +2,8 @@ #include <string.h> // for memcmp #include <stdio.h> // for debug printf +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS + /* Dump signature bytes on stdout */ @@ -126,3 +128,4 @@ void map_signature( void(*f)(char, const struct labcomm2014_signature *, void *) p+=1; } } +#endif diff --git a/lib/c/2014/labcomm2014_type_signature.h b/lib/c/2014/labcomm2014_type_signature.h index dfb79342a30f5996437fd44b6e8d4df704bc6c16..3bc10d286650938e2d2f9602a8af4d49d15c65c4 100644 --- a/lib/c/2014/labcomm2014_type_signature.h +++ b/lib/c/2014/labcomm2014_type_signature.h @@ -11,7 +11,7 @@ /* * Signature entry */ -#ifndef LABCOMM_NO_TYPEDECL +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS #ifdef USE_UNIONS /* Useful for C99 and up (or GCC without -pedantic) */ @@ -54,7 +54,7 @@ struct labcomm2014_signature { int size; unsigned char *signature; int index; -#ifndef LABCOMM_NO_TYPEDECL +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS int tdsize; struct labcomm2014_signature_data *treedata; #endif @@ -63,6 +63,7 @@ struct labcomm2014_signature { #endif }; +#ifdef LABCOMM_USE_UNSUPPORTED_TYPEDEFS /* a struct for "raw" type_defs, to be used as an intermediate representation * between decoder and signature parser */ @@ -137,5 +138,6 @@ labcomm2014_bool labcomm2014_signature_dump(struct labcomm2014_signature_data *s void map_signature( void(*f)(char, const struct labcomm2014_signature *, void *), void *context, const struct labcomm2014_signature *signature, labcomm2014_bool flatten); +#endif #endif