first stange of asn1 table driven compiler
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* All rights reserved.
|
||||
*
|
||||
* Portions Copyright (c) 2009 Apple Inc. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -70,7 +72,8 @@ generate_int2 (const Type *t, const char *gen_name)
|
||||
fprintf (codefile,
|
||||
"%s int2%s(unsigned n)\n"
|
||||
"{\n"
|
||||
"\t%s flags;\n\n",
|
||||
"\t%s flags;\n\n"
|
||||
"\tmemset(&flags, 0, sizeof(flags));\n\n",
|
||||
gen_name, gen_name, gen_name);
|
||||
|
||||
if(t->members) {
|
||||
@@ -92,9 +95,17 @@ generate_units (const Type *t, const char *gen_name)
|
||||
{
|
||||
Member *m;
|
||||
|
||||
fprintf (headerfile,
|
||||
"const struct units * asn1_%s_units(void);",
|
||||
gen_name);
|
||||
if (template_flag) {
|
||||
fprintf (headerfile,
|
||||
"extern const struct units *asn1_%s_table_units;\n",
|
||||
gen_name);
|
||||
fprintf (headerfile, "#define asn1_%s_units() (asn1_%s_table_units)\n",
|
||||
gen_name, gen_name);
|
||||
} else {
|
||||
fprintf (headerfile,
|
||||
"const struct units * asn1_%s_units(void);",
|
||||
gen_name);
|
||||
}
|
||||
|
||||
fprintf (codefile,
|
||||
"static struct units %s_units[] = {\n",
|
||||
@@ -111,11 +122,16 @@ generate_units (const Type *t, const char *gen_name)
|
||||
"\t{NULL,\t0}\n"
|
||||
"};\n\n");
|
||||
|
||||
fprintf (codefile,
|
||||
"const struct units * asn1_%s_units(void){\n"
|
||||
"return %s_units;\n"
|
||||
"}\n\n",
|
||||
gen_name, gen_name);
|
||||
if (template_flag)
|
||||
fprintf (codefile,
|
||||
"const struct units * asn1_%s_table_units = %s_units;\n",
|
||||
gen_name, gen_name);
|
||||
else
|
||||
fprintf (codefile,
|
||||
"const struct units * asn1_%s_units(void){\n"
|
||||
"return %s_units;\n"
|
||||
"}\n\n",
|
||||
gen_name, gen_name);
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user