diff options
author | midipix <writeonce@midipix.org> | 2016-01-02 12:33:54 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-01-02 12:33:54 -0500 |
commit | 6b0a2b107c62845cd457d0a3a060e38006b8630f (patch) | |
tree | 9560daa6b7bb6db7f447c51618be4df377c10653 /src/output | |
parent | 5590ea75cc108ae620a47c072fcbd95c1dc74add (diff) | |
download | apimagic-6b0a2b107c62845cd457d0a3a060e38006b8630f.tar.bz2 apimagic-6b0a2b107c62845cd457d0a3a060e38006b8630f.tar.xz |
amgc_output_unit_enum(), amgc_output_custom_enum(): support anonymous enums.
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/amgc_output_enum.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/output/amgc_output_enum.c b/src/output/amgc_output_enum.c index c69d49f..be399df 100644 --- a/src/output/amgc_output_enum.c +++ b/src/output/amgc_output_enum.c @@ -89,6 +89,7 @@ int amgc_output_unit_enum( FILE * fout) { struct amgc_entity * enumvals; + const char * symbol; int ret; if (entity->base.kind != ENTITY_ENUM) @@ -96,7 +97,12 @@ int amgc_output_unit_enum( else if (amgc_get_enum_members(uctx,entity,&enumvals)) return -1; - ret = output_enum(entity->base.symbol->string,enumvals,layout,fout); + if (entity->base.symbol) + symbol = entity->base.symbol->string; + else + symbol = ""; + + ret = output_enum(symbol,enumvals,layout,fout); amgc_free_enum_members(enumvals); return ret; @@ -108,7 +114,8 @@ int amgc_output_custom_enum( const struct amgc_layout * layout, FILE * fout) { - const struct amgc_entity * aentity; + const struct amgc_entity * aentity; + const char * symbol; if (penum->entity && penum->entity->base.kind != ENTITY_ENUM) return -1; @@ -119,10 +126,14 @@ int amgc_output_custom_enum( if (aentity->entity && aentity->entity->base.kind != ENTITY_ENUM_VALUE) return -1; - return output_enum(penum->entity - ? penum->entity->base.symbol->string - : penum->altname, - enumvals,layout,fout); + if (!penum->entity) + symbol = penum->altname; + else if (penum->entity->base.symbol) + symbol = penum->entity->base.symbol->string; + else + symbol = ""; + + return output_enum(symbol,enumvals,layout,fout); } int amgc_output_unit_enums( |