From 43b7a222c0944f84a077f0a58d9566530630def2 Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 8 Jan 2016 16:41:14 -0500 Subject: amgc_output_unit_entities(): initial implementation. --- include/apimagic/apimagic.h | 1 + project/common.mk | 1 + src/output/amgc_output_entities.c | 46 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/output/amgc_output_entities.c diff --git a/include/apimagic/apimagic.h b/include/apimagic/apimagic.h index c6da7e2..6968d66 100644 --- a/include/apimagic/apimagic.h +++ b/include/apimagic/apimagic.h @@ -183,6 +183,7 @@ amgc_api int amgc_output_unit_functions(const struct amgc_unit_ctx *, const str /* 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_output_unit_entities (const struct amgc_unit_ctx *, int kind, int subset, 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 *); diff --git a/project/common.mk b/project/common.mk index 8de8d05..744b856 100644 --- a/project/common.mk +++ b/project/common.mk @@ -7,6 +7,7 @@ COMMON_SRCS = \ src/logic/amgc_init_unit_meta.c \ src/logic/amgc_map_input.c \ src/logic/amgc_unit_entities.c \ + src/output/amgc_output_entities.c \ src/output/amgc_output_enum.c \ src/output/amgc_output_pad_symbol.c \ src/output/amgc_output_typedef.c \ diff --git a/src/output/amgc_output_entities.c b/src/output/amgc_output_entities.c new file mode 100644 index 0000000..9d8d017 --- /dev/null +++ b/src/output/amgc_output_entities.c @@ -0,0 +1,46 @@ +/**********************************************************/ +/* apimagic: cparser-based API normalization utility */ +/* Copyright (C) 2015--2016 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */ +/**********************************************************/ + +#include + +#include +#include + +#include +#include "apimagic_driver_impl.h" + +static int output_typedefs( + const struct amgc_unit_ctx * uctx, + int subset, + const struct amgc_layout * layout, + FILE * fout) +{ + struct amgc_entity * aentity; + + for (aentity=uctx->entities->typedefs; aentity->entity; aentity++) + if (aentity->reftype->kind == subset) + if (amgc_output_typedef(uctx,aentity,layout,fout) < 0) + return -1; + return 0; +} + +int amgc_output_unit_entities( + const struct amgc_unit_ctx * uctx, + int kind, + int subset, + const struct amgc_layout * layout, + FILE * fout) +{ + switch (kind) { + case ENTITY_ENUM: + return amgc_output_unit_enums(uctx,layout,fout); + + case ENTITY_TYPEDEF: + return output_typedefs(uctx,subset,layout,fout); + } + + return -1; +} -- cgit v1.2.3