asn1: Make templating less fragile: test it more
`lib/asn1/check-gen.c` almost works with templates, and is a pretty extensive test. The only thing that fails is everything to do with IMPLICIT tags (so, `test_implicit()`). So now we compile `lib/asn1/test.asn1` both, w/ and w/o templating, and we build two programs from `lib/asn1/check-gen.c`: `check-gen` and `check-gen-template`, respectively linking with the non-templated and the templated compilation of `lib/asn1/test.asn1`. Because the template compiler still doesn't support IMPLICIT tagging well, we disable testing of IMPLICIT tags in `check-gen-template`. This will make it much harder to break the template compiler in the future.
This commit is contained in:
@@ -35,6 +35,14 @@
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
static FILE *
|
||||
get_code_file(void)
|
||||
{
|
||||
if (!one_code_file && templatefile)
|
||||
return templatefile;
|
||||
return codefile;
|
||||
}
|
||||
|
||||
void
|
||||
generate_type_seq (const Symbol *s)
|
||||
{
|
||||
@@ -72,12 +80,12 @@ generate_type_seq (const Symbol *s)
|
||||
s->gen_name, s->gen_name, subname,
|
||||
s->gen_name, s->gen_name);
|
||||
|
||||
fprintf (codefile, "int ASN1CALL\n"
|
||||
fprintf (get_code_file(), "int ASN1CALL\n"
|
||||
"add_%s(%s *data, const %s *element)\n"
|
||||
"{\n",
|
||||
s->gen_name, s->gen_name, subname);
|
||||
|
||||
fprintf (codefile,
|
||||
fprintf (get_code_file(),
|
||||
"int ret;\n"
|
||||
"void *ptr;\n"
|
||||
"\n"
|
||||
@@ -91,14 +99,14 @@ generate_type_seq (const Symbol *s)
|
||||
"return 0;\n",
|
||||
subname);
|
||||
|
||||
fprintf (codefile, "}\n\n");
|
||||
fprintf (get_code_file(), "}\n\n");
|
||||
|
||||
fprintf (codefile, "int ASN1CALL\n"
|
||||
fprintf (get_code_file(), "int ASN1CALL\n"
|
||||
"remove_%s(%s *data, unsigned int element)\n"
|
||||
"{\n",
|
||||
s->gen_name, s->gen_name);
|
||||
|
||||
fprintf (codefile,
|
||||
fprintf (get_code_file(),
|
||||
"void *ptr;\n"
|
||||
"\n"
|
||||
"if (data->len == 0 || element >= data->len)\n"
|
||||
@@ -115,5 +123,5 @@ generate_type_seq (const Symbol *s)
|
||||
"return 0;\n",
|
||||
subname);
|
||||
|
||||
fprintf (codefile, "}\n\n");
|
||||
fprintf (get_code_file(), "}\n\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user