summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-01-30 20:15:20 -0500
committermidipix <writeonce@midipix.org>2016-01-31 12:43:50 -0500
commit0c91ec9d3ffdcc3a978eaa3bc02470462d34df7a (patch)
tree80dfa07bdd841d63d13f8871b31cc32922b5d5a3 /src
parentca3de486debc160722d02cbd969a7796894ecd56 (diff)
downloadapimagic-0c91ec9d3ffdcc3a978eaa3bc02470462d34df7a.tar.bz2
apimagic-0c91ec9d3ffdcc3a978eaa3bc02470462d34df7a.tar.xz
driver: --print-structs and --print-unions: initial integration.
Diffstat (limited to 'src')
-rw-r--r--src/driver/amgc_driver_ctx.c10
-rw-r--r--src/driver/amgc_unit_action.c6
-rw-r--r--src/internal/apimagic_driver_impl.h2
-rw-r--r--src/output/amgc_output_compound.c28
-rw-r--r--src/output/amgc_output_entities.c6
-rw-r--r--src/skin/amgc_skin_default.c6
6 files changed, 58 insertions, 0 deletions
diff --git a/src/driver/amgc_driver_ctx.c b/src/driver/amgc_driver_ctx.c
index 4489109..ffe319d 100644
--- a/src/driver/amgc_driver_ctx.c
+++ b/src/driver/amgc_driver_ctx.c
@@ -209,6 +209,16 @@ int amgc_get_driver_ctx(
if (!strcmp("primary",entry->arg))
ctx->actions[nactions++].subset = TYPE_ATOMIC;
break;
+
+ case TAG_PRINT_STRUCTS:
+ ctx->actions[nactions].type = AMGC_ACTION_OUTPUT;
+ ctx->actions[nactions++].action = AMGC_OUTPUT_STRUCT;
+ break;
+
+ case TAG_PRINT_UNIONS:
+ ctx->actions[nactions].type = AMGC_ACTION_OUTPUT;
+ ctx->actions[nactions++].action = AMGC_OUTPUT_UNION;
+ break;
}
ctx->ctx.program = program;
diff --git a/src/driver/amgc_unit_action.c b/src/driver/amgc_unit_action.c
index b1d018a..29bc446 100644
--- a/src/driver/amgc_unit_action.c
+++ b/src/driver/amgc_unit_action.c
@@ -33,6 +33,12 @@ int amgc_perform_unit_action(
return amgc_output_unit_entities(
uctx,ENTITY_TYPEDEF,action->subset,
layout,fout);
+
+ case AMGC_OUTPUT_STRUCT:
+ return amgc_output_unit_structs(uctx,layout,fout);
+
+ case AMGC_OUTPUT_UNION:
+ return amgc_output_unit_unions(uctx,layout,fout);
}
return -1;
diff --git a/src/internal/apimagic_driver_impl.h b/src/internal/apimagic_driver_impl.h
index c3aa6a6..27f1f15 100644
--- a/src/internal/apimagic_driver_impl.h
+++ b/src/internal/apimagic_driver_impl.h
@@ -21,6 +21,8 @@ enum app_tags {
TAG_PRINT_ENUMS,
TAG_LIST_ENUMS,
TAG_PRINT_TYPEDEFS,
+ TAG_PRINT_STRUCTS,
+ TAG_PRINT_UNIONS,
TAG_LANG_STD,
};
diff --git a/src/output/amgc_output_compound.c b/src/output/amgc_output_compound.c
index 07bd730..fc95af7 100644
--- a/src/output/amgc_output_compound.c
+++ b/src/output/amgc_output_compound.c
@@ -346,3 +346,31 @@ int amgc_output_union(
else
return -1;
}
+
+int amgc_output_unit_structs(
+ const struct amgc_unit_ctx * uctx,
+ const struct amgc_layout * layout,
+ FILE * fout)
+{
+ const struct amgc_entity * aentity;
+
+ for (aentity=uctx->entities->structs; aentity->entity; aentity++)
+ if (output_compound_entity(uctx,aentity,layout,fout))
+ return -1;
+
+ return 0;
+}
+
+int amgc_output_unit_unions(
+ const struct amgc_unit_ctx * uctx,
+ const struct amgc_layout * layout,
+ FILE * fout)
+{
+ const struct amgc_entity * aentity;
+
+ for (aentity=uctx->entities->unions; aentity->entity; aentity++)
+ if (output_compound_entity(uctx,aentity,layout,fout))
+ return -1;
+
+ return 0;
+}
diff --git a/src/output/amgc_output_entities.c b/src/output/amgc_output_entities.c
index 9d8d017..c1618c2 100644
--- a/src/output/amgc_output_entities.c
+++ b/src/output/amgc_output_entities.c
@@ -40,6 +40,12 @@ int amgc_output_unit_entities(
case ENTITY_TYPEDEF:
return output_typedefs(uctx,subset,layout,fout);
+
+ case ENTITY_STRUCT:
+ return amgc_output_unit_structs(uctx,layout,fout);
+
+ case ENTITY_UNION:
+ return amgc_output_unit_unions(uctx,layout,fout);
}
return -1;
diff --git a/src/skin/amgc_skin_default.c b/src/skin/amgc_skin_default.c
index 80a003f..804985b 100644
--- a/src/skin/amgc_skin_default.c
+++ b/src/skin/amgc_skin_default.c
@@ -24,6 +24,12 @@ const struct argv_option amgc_default_options[] = {
"output forward declarations for "
"the translation unit's enums."},
+ {"print-structs",0,TAG_PRINT_STRUCTS,ARGV_OPTARG_NONE,0,0,0,
+ "output the translation unit's structs."},
+
+ {"print-unions",0,TAG_PRINT_UNIONS,ARGV_OPTARG_NONE,0,0,0,
+ "output the translation unit's unions."},
+
{"print-typedefs",0,TAG_PRINT_TYPEDEFS,ARGV_OPTARG_REQUIRED,0,
"primary",0,
"output (a subset of) the translation unit's "