Blame src/output/amgc_output_entities.c

43b7a2
/**********************************************************/
43b7a2
/*  apimagic: cparser-based API normalization utility     */
84312f
/*  Copyright (C) 2015--2021  SysDeer Technologies, LLC   */
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(
b8225b
	const struct amgc_driver_ctx *	dctx,
43b7a2
	const struct amgc_unit_ctx *	uctx,
43b7a2
	int				subset,
b8225b
	const struct amgc_layout *	layout)
43b7a2
{
43b7a2
	struct amgc_entity * aentity;
43b7a2
43b7a2
	for (aentity=uctx->entities->typedefs; aentity->entity; aentity++)
43b7a2
		if (aentity->reftype->kind == subset)
b8225b
			if (amgc_output_typedef(dctx,uctx,aentity,layout) < 0)
43b7a2
				return -1;
43b7a2
	return 0;
43b7a2
}
43b7a2
43b7a2
int amgc_output_unit_entities(
b8225b
	const struct amgc_driver_ctx *	dctx,
43b7a2
	const struct amgc_unit_ctx *	uctx,
43b7a2
	int				kind,
43b7a2
	int				subset,
b8225b
	const struct amgc_layout *	layout)
43b7a2
{
43b7a2
	switch (kind) {
43b7a2
		case ENTITY_ENUM:
b8225b
			return amgc_output_unit_enums(dctx,uctx,layout);
43b7a2
43b7a2
		case ENTITY_TYPEDEF:
b8225b
			return output_typedefs(dctx,uctx,subset,layout);
0c91ec
0c91ec
		case ENTITY_STRUCT:
b8225b
			return amgc_output_unit_structs(dctx,uctx,layout);
0c91ec
0c91ec
		case ENTITY_UNION:
b8225b
			return amgc_output_unit_unions(dctx,uctx,layout);
43b7a2
	}
43b7a2
43b7a2
	return -1;
43b7a2
}