summaryrefslogtreecommitdiff
path: root/src/output/amgc_output_entities.c
blob: c23924932b88d4d019befc452331670da81049db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**********************************************************/
/*  apimagic: cparser-based API normalization utility     */
/*  Copyright (C) 2015--2016  Z. Gilboa                   */
/*  Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */
/**********************************************************/

#include <stdio.h>

#include <cparser/ast/entity_t.h>
#include <cparser/ast/type_t.h>

#include <apimagic/apimagic.h>
#include "apimagic_driver_impl.h"

static int output_typedefs(
	const struct amgc_driver_ctx *	dctx,
	const struct amgc_unit_ctx *	uctx,
	int				subset,
	const struct amgc_layout *	layout)
{
	struct amgc_entity * aentity;

	for (aentity=uctx->entities->typedefs; aentity->entity; aentity++)
		if (aentity->reftype->kind == subset)
			if (amgc_output_typedef(dctx,uctx,aentity,layout) < 0)
				return -1;
	return 0;
}

int amgc_output_unit_entities(
	const struct amgc_driver_ctx *	dctx,
	const struct amgc_unit_ctx *	uctx,
	int				kind,
	int				subset,
	const struct amgc_layout *	layout)
{
	switch (kind) {
		case ENTITY_ENUM:
			return amgc_output_unit_enums(dctx,uctx,layout);

		case ENTITY_TYPEDEF:
			return output_typedefs(dctx,uctx,subset,layout);

		case ENTITY_STRUCT:
			return amgc_output_unit_structs(dctx,uctx,layout);

		case ENTITY_UNION:
			return amgc_output_unit_unions(dctx,uctx,layout);
	}

	return -1;
}