aboutsummaryrefslogtreecommitdiffstats
path: root/src/gen.c
diff options
context:
space:
mode:
authorkatherine <k@airen-no-jikken.icu>2019-05-30 04:05:29 -0700
committerkatherine <k@airen-no-jikken.icu>2019-05-30 04:05:29 -0700
commit00d99b082162e287d481577915be73d5bf1dc483 (patch)
tree9d5fa7e28b6d9dcf959a6d3884bc62a6b3d9d9d5 /src/gen.c
parent58e3054794cde4148267d81c80cc3109fbd19298 (diff)
downloadconfconf-00d99b082162e287d481577915be73d5bf1dc483.tar.gz
add enum defined types
Diffstat (limited to 'src/gen.c')
-rw-r--r--src/gen.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/gen.c b/src/gen.c
index b35ed62..e427b7c 100644
--- a/src/gen.c
+++ b/src/gen.c
@@ -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);
}
}