summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-01-06 14:05:29 -0500
committermidipix <writeonce@midipix.org>2016-01-06 14:05:29 -0500
commit2e879cef83189bf50789ea3e3d144738222e828c (patch)
treed52a47d89815a2636ced615d3990cdb962cc63fa /src
parentd27fb44885209a32848465e1abe5fd76f26c780e (diff)
downloadapimagic-2e879cef83189bf50789ea3e3d144738222e828c.tar.bz2
apimagic-2e879cef83189bf50789ea3e3d144738222e828c.tar.xz
amgc_list_unit_enums(): initial implementation and integration.
Diffstat (limited to 'src')
-rw-r--r--src/apimagic.c6
-rw-r--r--src/driver/amgc_driver_ctx.c5
-rw-r--r--src/internal/apimagic_driver_impl.h1
-rw-r--r--src/output/amgc_output_enum.c23
-rw-r--r--src/skin/amgc_skin_default.c4
5 files changed, 39 insertions, 0 deletions
diff --git a/src/apimagic.c b/src/apimagic.c
index dd0d893..77ae2a2 100644
--- a/src/apimagic.c
+++ b/src/apimagic.c
@@ -32,6 +32,12 @@ static void apimagic_perform_unit_actions(struct amgc_unit_ctx * uctx)
(void)0;
else
amgc_output_unit_enums(uctx,0,stdout);
+
+ case AMGC_LIST_ENUM:
+ if (action->symbol)
+ (void)0;
+ else
+ amgc_list_unit_enums(uctx,0,stdout);
}
}
diff --git a/src/driver/amgc_driver_ctx.c b/src/driver/amgc_driver_ctx.c
index c25be55..2b33de4 100644
--- a/src/driver/amgc_driver_ctx.c
+++ b/src/driver/amgc_driver_ctx.c
@@ -197,6 +197,11 @@ int amgc_get_driver_ctx(
ctx->actions[nactions].type = AMGC_ACTION_OUTPUT;
ctx->actions[nactions++].action = AMGC_OUTPUT_ENUM;
break;
+
+ case TAG_LIST_ENUMS:
+ ctx->actions[nactions].type = AMGC_ACTION_OUTPUT;
+ ctx->actions[nactions++].action = AMGC_LIST_ENUM;
+ break;
}
ctx->ctx.program = program;
diff --git a/src/internal/apimagic_driver_impl.h b/src/internal/apimagic_driver_impl.h
index d070c19..5b599a9 100644
--- a/src/internal/apimagic_driver_impl.h
+++ b/src/internal/apimagic_driver_impl.h
@@ -15,6 +15,7 @@ enum app_tags {
TAG_HELP,
TAG_VERSION,
TAG_PRINT_ENUMS,
+ TAG_LIST_ENUMS,
TAG_LANG_STD,
};
diff --git a/src/output/amgc_output_enum.c b/src/output/amgc_output_enum.c
index be399df..3c8288b 100644
--- a/src/output/amgc_output_enum.c
+++ b/src/output/amgc_output_enum.c
@@ -149,3 +149,26 @@ int amgc_output_unit_enums(
return 0;
}
+
+int amgc_list_unit_enums(
+ const struct amgc_unit_ctx * uctx,
+ const struct amgc_layout * layout,
+ FILE * fout)
+{
+ const struct amgc_entity * aentity;
+
+ if (layout && layout->header && (fputs(layout->header,fout) < 0))
+ return -1;
+
+ for (aentity=uctx->entities->enums; aentity->entity; aentity++)
+ if ((fprintf(fout,"enum %s;\n",
+ aentity->entity && aentity->entity->base.symbol
+ ? aentity->entity->base.symbol->string
+ : aentity->altname) < 0))
+ return -1;
+
+ if (layout && layout->footer && (fputs(layout->footer,fout) < 0))
+ return -1;
+
+ return 0;
+}
diff --git a/src/skin/amgc_skin_default.c b/src/skin/amgc_skin_default.c
index 407bad1..8444f66 100644
--- a/src/skin/amgc_skin_default.c
+++ b/src/skin/amgc_skin_default.c
@@ -20,6 +20,10 @@ const struct argv_option amgc_default_options[] = {
{"print-enums", 0,TAG_PRINT_ENUMS,ARGV_OPTARG_NONE,0,0,0,
"output the translation unit's enums."},
+ {"list-enums", 0,TAG_LIST_ENUMS,ARGV_OPTARG_NONE,0,0,0,
+ "output forward declarations for "
+ "the translation unit's enums."},
+
{"std", '\0',TAG_LANG_STD,ARGV_OPTARG_REQUIRED,
ARGV_OPTION_HYBRID_EQUAL,AMGC_LANG_STD_PARADIGM,0,
"set language standard"},