Blame src/output/amgc_output_entities.c

43b7a2
/**********************************************************/
43b7a2
/*  apimagic: cparser-based API normalization utility     */
43b7a2
/*  Copyright (C) 2015--2016  Z. Gilboa                   */
43b7a2
/*  Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */
43b7a2
/**********************************************************/
43b7a2
43b7a2
#include <stdio.h>
43b7a2
43b7a2
#include <cparser/ast/entity_t.h>
43b7a2
#include <cparser/ast/type_t.h>
43b7a2
43b7a2
#include <apimagic/apimagic.h>
43b7a2
#include "apimagic_driver_impl.h"
43b7a2
43b7a2
static int output_typedefs(
43b7a2
	const struct amgc_unit_ctx *	uctx,
43b7a2
	int				subset,
43b7a2
	const struct amgc_layout *	layout,
43b7a2
	FILE *				fout)
43b7a2
{
43b7a2
	struct amgc_entity * aentity;
43b7a2
43b7a2
	for (aentity=uctx->entities->typedefs; aentity->entity; aentity++)
43b7a2
		if (aentity->reftype->kind == subset)
43b7a2
			if (amgc_output_typedef(uctx,aentity,layout,fout) < 0)
43b7a2
				return -1;
43b7a2
	return 0;
43b7a2
}
43b7a2
43b7a2
int amgc_output_unit_entities(
43b7a2
	const struct amgc_unit_ctx *	uctx,
43b7a2
	int				kind,
43b7a2
	int				subset,
43b7a2
	const struct amgc_layout *	layout,
43b7a2
	FILE *				fout)
43b7a2
{
43b7a2
	switch (kind) {
43b7a2
		case ENTITY_ENUM:
43b7a2
			return amgc_output_unit_enums(uctx,layout,fout);
43b7a2
43b7a2
		case ENTITY_TYPEDEF:
43b7a2
			return output_typedefs(uctx,subset,layout,fout);
0c91ec
0c91ec
		case ENTITY_STRUCT:
0c91ec
			return amgc_output_unit_structs(uctx,layout,fout);
0c91ec
0c91ec
		case ENTITY_UNION:
0c91ec
			return amgc_output_unit_unions(uctx,layout,fout);
43b7a2
	}
43b7a2
43b7a2
	return -1;
43b7a2
}