summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-01-08 17:20:59 -0500
committermidipix <writeonce@midipix.org>2016-01-09 05:32:50 -0500
commitf2e43d1d66a6455febcf06fd740d2369f296954c (patch)
treea7e5676d18fa0266b270737035479c7b7ee3c7b4 /src
parent43b7a222c0944f84a077f0a58d9566530630def2 (diff)
downloadapimagic-f2e43d1d66a6455febcf06fd740d2369f296954c.tar.bz2
apimagic-f2e43d1d66a6455febcf06fd740d2369f296954c.tar.xz
driver: --print-typedefs: initial implementation.
Diffstat (limited to 'src')
-rw-r--r--src/driver/amgc_driver_ctx.c9
-rw-r--r--src/driver/amgc_unit_action.c7
-rw-r--r--src/internal/apimagic_driver_impl.h1
-rw-r--r--src/skin/amgc_skin_default.c5
4 files changed, 22 insertions, 0 deletions
diff --git a/src/driver/amgc_driver_ctx.c b/src/driver/amgc_driver_ctx.c
index 2b33de4..1e92e74 100644
--- a/src/driver/amgc_driver_ctx.c
+++ b/src/driver/amgc_driver_ctx.c
@@ -8,6 +8,7 @@
#include <unistd.h>
#include <fcntl.h>
+#include <cparser/ast/type_t.h>
#include <cparser/driver/c_driver.h>
#include <cparser/driver/driver.h>
#include <cparser/driver/driver_t.h>
@@ -202,6 +203,14 @@ int amgc_get_driver_ctx(
ctx->actions[nactions].type = AMGC_ACTION_OUTPUT;
ctx->actions[nactions++].action = AMGC_LIST_ENUM;
break;
+
+ case TAG_PRINT_TYPEDEFS:
+ ctx->actions[nactions].type = AMGC_ACTION_OUTPUT;
+ ctx->actions[nactions].action = AMGC_OUTPUT_TYPEDEF;
+
+ if (!strcmp("primary",entry->arg))
+ ctx->actions[nactions++].subset = TYPE_ATOMIC;
+ break;
}
ctx->ctx.program = program;
diff --git a/src/driver/amgc_unit_action.c b/src/driver/amgc_unit_action.c
index 04cfb8f..0a07cb9 100644
--- a/src/driver/amgc_unit_action.c
+++ b/src/driver/amgc_unit_action.c
@@ -4,6 +4,8 @@
/* Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */
/**********************************************************/
+#include <cparser/ast/entity_t.h>
+
#include <apimagic/apimagic.h>
#include "apimagic_driver_impl.h"
@@ -25,6 +27,11 @@ int amgc_perform_unit_action(
return -1;
else
return amgc_list_unit_enums(uctx,0,stdout);
+
+ case AMGC_OUTPUT_TYPEDEF:
+ return amgc_output_unit_entities(
+ uctx,ENTITY_TYPEDEF,action->subset,
+ layout,fout);
}
return -1;
diff --git a/src/internal/apimagic_driver_impl.h b/src/internal/apimagic_driver_impl.h
index 5b599a9..b5d4ae4 100644
--- a/src/internal/apimagic_driver_impl.h
+++ b/src/internal/apimagic_driver_impl.h
@@ -16,6 +16,7 @@ enum app_tags {
TAG_VERSION,
TAG_PRINT_ENUMS,
TAG_LIST_ENUMS,
+ TAG_PRINT_TYPEDEFS,
TAG_LANG_STD,
};
diff --git a/src/skin/amgc_skin_default.c b/src/skin/amgc_skin_default.c
index 8444f66..80a003f 100644
--- a/src/skin/amgc_skin_default.c
+++ b/src/skin/amgc_skin_default.c
@@ -24,6 +24,11 @@ const struct argv_option amgc_default_options[] = {
"output forward declarations for "
"the translation unit's enums."},
+ {"print-typedefs",0,TAG_PRINT_TYPEDEFS,ARGV_OPTARG_REQUIRED,0,
+ "primary",0,
+ "output (a subset of) the translation unit's "
+ "type definitions"},
+
{"std", '\0',TAG_LANG_STD,ARGV_OPTARG_REQUIRED,
ARGV_OPTION_HYBRID_EQUAL,AMGC_LANG_STD_PARADIGM,0,
"set language standard"},