summaryrefslogtreecommitdiff
path: root/src/driver/amgc_unit_action.c
blob: 3fa1f6d29caae8524bb0fb1f9e338f38b8de6bf7 (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
/**********************************************************/
/*  apimagic: cparser-based API normalization utility     */
/*  Copyright (C) 2015--2021  SysDeer Technologies, LLC   */
/*  Released under GPLv2 and GPLv3; see COPYING.APIMAGIC. */
/**********************************************************/

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

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

int amgc_perform_unit_action(
	const struct amgc_driver_ctx *	dctx,
	const struct amgc_unit_ctx *	uctx,
	const struct amgc_action *	action,
	const struct amgc_layout *	layout)
{
	switch (action->action) {
		case AMGC_OUTPUT_ENUM:
			if (action->symbol)
				return -1;
			else
				return amgc_output_unit_enums(dctx,uctx,0);

		case AMGC_LIST_ENUM:
			if (action->symbol)
				return -1;
			else
				return amgc_list_unit_enums(dctx,uctx,0);

		case AMGC_OUTPUT_TYPEDEF:
			return amgc_output_unit_entities(
				dctx,uctx,ENTITY_TYPEDEF,
				action->subset,layout);

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

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

	return -1;
}