Blame src/logic/amgc_init_unit_meta.c

9c2028
/**********************************************************/
9c2028
/*  apimagic: cparser-based API normalization utility     */
9c2028
/*  Copyright (C) 2015--2016  Z. Gilboa                   */
9c2028
/*  Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */
9c2028
/**********************************************************/
9c2028
9c2028
#include <cparser/ast/ast_t.h>
9c2028
#include <cparser/ast/entity_t.h>
9c2028
9c2028
#include <apimagic/apimagic.h>
9c2028
9c2028
int amgc_init_unit_meta(
9c2028
	const struct amgc_unit_ctx *	uctx,
9c2028
	struct amgc_unit_meta *		meta)
9c2028
{
9c2028
	union entity_t * entity;
9c2028
9c2028
	entity = uctx->ccunit->ast->scope.first_entity;
9c2028
9c2028
	for (; entity; entity=entity->base.next) {
9c2028
		if (strcmp(*uctx->path,entity->base.pos.input_name))
9c2028
			continue;
9c2028
9c2028
		if ((is_declaration(entity)) &&  (entity->declaration.implicit))
9c2028
				meta->ngenerated++;
9c2028
9c2028
		else {
9c2028
			switch (entity->kind) {
9c2028
				case ENTITY_ENUM:
9c2028
					meta->nenums++;
9c2028
					break;
9c2028
9c2028
				case ENTITY_ENUM_VALUE:
9c2028
					meta->nenumvals++;
9c2028
					break;
9c2028
9c2028
				case ENTITY_TYPEDEF:
9c2028
					meta->ntypedefs++;
9c2028
					break;
9c2028
9c2028
				case ENTITY_STRUCT:
9c2028
					if (entity->base.symbol || entity->compound.alias)
9c2028
						meta->nstructs++;
9c2028
					break;
9c2028
9c2028
				case ENTITY_UNION:
9c2028
					if (entity->base.symbol || entity->compound.alias)
9c2028
						meta->nunions++;
9c2028
					break;
9c2028
9c2028
				case ENTITY_FUNCTION:
9c2028
					meta->nfunctions++;
9c2028
					break;
9c2028
9c2028
				default:
9c2028
					break;
9c2028
			}
9c2028
		}
9c2028
	}
9c2028
9c2028
	return 0;
9c2028
}