summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-12-30 05:27:21 -0500
committermidipix <writeonce@midipix.org>2016-01-01 22:50:24 -0500
commit9c202860ad2bc391a0ac8bc2e99b3e5624d2b472 (patch)
tree29e6995f8b40a2b019c71cea9b707f4d2d2385b9 /src/logic
parentf0e1b6834ba12762c51f2f1430238fac62ab47ef (diff)
downloadapimagic-9c202860ad2bc391a0ac8bc2e99b3e5624d2b472.tar.bz2
apimagic-9c202860ad2bc391a0ac8bc2e99b3e5624d2b472.tar.xz
amgc_init_unit_meta(): initial implementation and integration.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/amgc_init_unit_meta.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/logic/amgc_init_unit_meta.c b/src/logic/amgc_init_unit_meta.c
new file mode 100644
index 0000000..fec660d
--- /dev/null
+++ b/src/logic/amgc_init_unit_meta.c
@@ -0,0 +1,62 @@
+/**********************************************************/
+/* apimagic: cparser-based API normalization utility */
+/* Copyright (C) 2015--2016 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */
+/**********************************************************/
+
+#include <cparser/ast/ast_t.h>
+#include <cparser/ast/entity_t.h>
+
+#include <apimagic/apimagic.h>
+
+int amgc_init_unit_meta(
+ const struct amgc_unit_ctx * uctx,
+ struct amgc_unit_meta * meta)
+{
+ union entity_t * entity;
+
+ entity = uctx->ccunit->ast->scope.first_entity;
+
+ for (; entity; entity=entity->base.next) {
+ if (strcmp(*uctx->path,entity->base.pos.input_name))
+ continue;
+
+ if ((is_declaration(entity)) && (entity->declaration.implicit))
+ meta->ngenerated++;
+
+ else {
+ switch (entity->kind) {
+ case ENTITY_ENUM:
+ meta->nenums++;
+ break;
+
+ case ENTITY_ENUM_VALUE:
+ meta->nenumvals++;
+ break;
+
+ case ENTITY_TYPEDEF:
+ meta->ntypedefs++;
+ break;
+
+ case ENTITY_STRUCT:
+ if (entity->base.symbol || entity->compound.alias)
+ meta->nstructs++;
+ break;
+
+ case ENTITY_UNION:
+ if (entity->base.symbol || entity->compound.alias)
+ meta->nunions++;
+ break;
+
+ case ENTITY_FUNCTION:
+ meta->nfunctions++;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ return 0;
+}