Blame src/internal/apimagic_driver_impl.h

383aa6
#ifndef APIMAGIC_DRIVER_IMPL_H
383aa6
#define APIMAGIC_DRIVER_IMPL_H
383aa6
383aa6
#include <stdint.h>
383aa6
#include <stdio.h>
383aa6
#include <sys/types.h>
383aa6
383aa6
#include <apimagic/apimagic.h>
2a9902
#include "argv/argv.h"
383aa6
7b509c
#ifndef AMGC_TAB_WIDTH
7b509c
#define AMGC_TAB_WIDTH	8
7b509c
#endif
7b509c
2a9902
extern const struct argv_option amgc_default_options[];
2a9902
383aa6
enum app_tags {
383aa6
	TAG_HELP,
383aa6
	TAG_VERSION,
6adb90
	TAG_PRINT_ENUMS,
2e879c
	TAG_LIST_ENUMS,
f2e43d
	TAG_PRINT_TYPEDEFS,
0c91ec
	TAG_PRINT_STRUCTS,
0c91ec
	TAG_PRINT_UNIONS,
fd0662
	TAG_LANG_STD,
383aa6
};
383aa6
383aa6
struct amgc_driver_ctx_impl {
f0e1b6
	struct amgc_common_ctx		cctx;
f0e1b6
	struct amgc_driver_ctx		ctx;
6adb90
	struct amgc_action *		actions;
43c8c9
	struct compilation_env_t	ccenv;
f0e1b6
	int				fdtmpin;
5334b1
	const  struct amgc_unit_ctx *   euctx;
5334b1
	const  char *                   eunit;
5334b1
	struct amgc_error_info **       errinfp;
5334b1
	struct amgc_error_info **       erricap;
5334b1
	struct amgc_error_info *        erriptr[64];
5334b1
	struct amgc_error_info	        erribuf[64];
5334b1
383aa6
};
383aa6
383aa6
struct amgc_unit_ctx_impl {
f0e1b6
	const char *			path;
f0e1b6
	struct amgc_input		map;
f0e1b6
	struct amgc_common_ctx		cctx;
f0e1b6
	struct amgc_unit_ctx		uctx;
9c2028
	struct amgc_unit_meta		meta;
7a622c
	struct amgc_unit_entities *	entities;
43c8c9
	struct compilation_unit_t	ccunit;
383aa6
};
383aa6
2c7a16
2c7a16
static inline struct amgc_driver_ctx_impl * amgc_get_driver_ictx(
2c7a16
	const struct amgc_driver_ctx * dctx)
2c7a16
{
2c7a16
        uintptr_t addr;
2c7a16
2c7a16
        if (dctx) {
2c7a16
                addr = (uintptr_t)dctx - offsetof(struct amgc_driver_ctx_impl,ctx);
2c7a16
                return (struct amgc_driver_ctx_impl *)addr;
2c7a16
        }
2c7a16
2c7a16
        return 0;
2c7a16
}
2c7a16
a55d22
static inline void amgc_driver_set_ectx(
a55d22
	const struct amgc_driver_ctx * dctx,
a55d22
	const struct amgc_unit_ctx *   uctx,
a55d22
	const char *                   unit)
a55d22
{
a55d22
	struct amgc_driver_ctx_impl *  ictx;
a55d22
a55d22
	ictx        = amgc_get_driver_ictx(dctx);
a55d22
	ictx->euctx = uctx;
a55d22
	ictx->eunit = unit;
a55d22
}
a55d22
383aa6
#endif