diff options
author | katherine <k@airen-no-jikken.icu> | 2019-05-30 04:05:29 -0700 |
---|---|---|
committer | katherine <k@airen-no-jikken.icu> | 2019-05-30 04:05:29 -0700 |
commit | 00d99b082162e287d481577915be73d5bf1dc483 (patch) | |
tree | 9d5fa7e28b6d9dcf959a6d3884bc62a6b3d9d9d5 /src/gen.c | |
parent | 58e3054794cde4148267d81c80cc3109fbd19298 (diff) | |
download | confconf-00d99b082162e287d481577915be73d5bf1dc483.tar.gz |
add enum defined types
Diffstat (limited to 'src/gen.c')
-rw-r--r-- | src/gen.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -67,15 +67,27 @@ void gen(FILE *f, struct parse_result_s pr, struct analyse_result_s ar) pr.suffix, pr.suffix ); - /* structs */ + /* types */ HASH_ITER(hh, pr.deftypes, dcur, dtmp) { if (!dcur->is_used) continue; - fprintf(f, "struct confconf_type_%s_%s {\n", + fprintf(f, "%s confconf_type_%s_%s {\n", + (dcur->type == PARSE_DEFTYPE_ENUM ? "enum" : + (dcur->type == PARSE_DEFTYPE_UNION ? + "union" : "struct") + ), dcur->name, pr.suffix); for (i = 0; i < dcur->member_list_len; i++) { + if (dcur->type == PARSE_DEFTYPE_ENUM) { + fprintf(f, " CONFCONF_TYPE_%s_%s_%s,\n", + dcur->name, + dcur->member_name_list[i], + pr.suffix); + continue; + } + switch (dcur->member_type_list[i]) { case PARSE_TYPE_BOOL: fprintf(f, " bool "); @@ -160,7 +172,10 @@ void gen(FILE *f, struct parse_result_s pr, struct analyse_result_s ar) HASH_ITER(hh, pr.deftypes, dcur, dtmp) { if (dcur->is_used && dcur->is_in_hash) { fprintf(f, " %s confconf_type_%s_%s type_%s;\n", - (dcur->is_union ? "union" : "struct"), + (dcur->type == PARSE_DEFTYPE_ENUM ? "enum" : + (dcur->type == PARSE_DEFTYPE_UNION ? + "union" : "struct") + ), dcur->name, pr.suffix, dcur->name); } } |