summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-01-08 15:09:12 -0500
committermidipix <writeonce@midipix.org>2016-01-09 05:32:50 -0500
commitbbff09033370ecee3ed999fe094494463c338add (patch)
tree3b655b7e312c697ce4c331b82672b7427f48cb21
parentd4478bf2f9538f5ddb95dedae51d884bb428fcb5 (diff)
downloadapimagic-bbff09033370ecee3ed999fe094494463c338add.tar.bz2
apimagic-bbff09033370ecee3ed999fe094494463c338add.tar.xz
amgc_perform_unit_action(): initial implementation and integration.
-rw-r--r--include/apimagic/apimagic.h2
-rw-r--r--project/common.mk1
-rw-r--r--src/apimagic.c16
-rw-r--r--src/driver/amgc_unit_action.c31
4 files changed, 35 insertions, 15 deletions
diff --git a/include/apimagic/apimagic.h b/include/apimagic/apimagic.h
index 8ea0b36..c6da7e2 100644
--- a/include/apimagic/apimagic.h
+++ b/include/apimagic/apimagic.h
@@ -182,6 +182,8 @@ amgc_api int amgc_output_unit_unions (const struct amgc_unit_ctx *, const struc
amgc_api int amgc_output_unit_functions(const struct amgc_unit_ctx *, const struct amgc_layout *, FILE *);
/* utility helper api */
+amgc_api int amgc_perform_unit_action (const struct amgc_unit_ctx *, const struct amgc_action *, const struct amgc_layout *, FILE *);
+
amgc_api int amgc_get_entity_index (const struct amgc_entity[], const char *);
amgc_api int amgc_get_define_index (const struct amgc_unit_ctx *, const char *);
amgc_api int amgc_get_enum_index (const struct amgc_unit_ctx *, const char *);
diff --git a/project/common.mk b/project/common.mk
index 8a14c46..8de8d05 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -1,6 +1,7 @@
COMMON_SRCS = \
src/driver/amgc_driver_ctx.c \
src/driver/amgc_paradigm_meta.c \
+ src/driver/amgc_unit_action.c \
src/driver/amgc_unit_ctx.c \
src/logic/amgc_enum_members.c \
src/logic/amgc_init_unit_meta.c \
diff --git a/src/apimagic.c b/src/apimagic.c
index f89df43..6d92db6 100644
--- a/src/apimagic.c
+++ b/src/apimagic.c
@@ -26,21 +26,7 @@ static void apimagic_perform_unit_actions(struct amgc_unit_ctx * uctx)
const struct amgc_action * action;
for (action=uctx->cctx->actions; action->type; action++)
- switch (action->action) {
- case AMGC_OUTPUT_ENUM:
- if (action->symbol)
- (void)0;
- else
- amgc_output_unit_enums(uctx,0,stdout);
- break;
-
- case AMGC_LIST_ENUM:
- if (action->symbol)
- (void)0;
- else
- amgc_list_unit_enums(uctx,0,stdout);
- break;
- }
+ amgc_perform_unit_action(uctx,action,0,stdout);
}
static int apimagic_exit(struct amgc_driver_ctx * dctx, int nerrors)
diff --git a/src/driver/amgc_unit_action.c b/src/driver/amgc_unit_action.c
new file mode 100644
index 0000000..04cfb8f
--- /dev/null
+++ b/src/driver/amgc_unit_action.c
@@ -0,0 +1,31 @@
+/**********************************************************/
+/* apimagic: cparser-based API normalization utility */
+/* Copyright (C) 2015--2016 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */
+/**********************************************************/
+
+#include <apimagic/apimagic.h>
+#include "apimagic_driver_impl.h"
+
+int amgc_perform_unit_action(
+ const struct amgc_unit_ctx * uctx,
+ const struct amgc_action * action,
+ const struct amgc_layout * layout,
+ FILE * fout)
+{
+ switch (action->action) {
+ case AMGC_OUTPUT_ENUM:
+ if (action->symbol)
+ return -1;
+ else
+ return amgc_output_unit_enums(uctx,0,stdout);
+
+ case AMGC_LIST_ENUM:
+ if (action->symbol)
+ return -1;
+ else
+ return amgc_list_unit_enums(uctx,0,stdout);
+ }
+
+ return -1;
+}