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>
499950
#include "apimagic_dprintf_impl.h"
2a9902
#include "argv/argv.h"
383aa6
7b509c
#ifndef AMGC_TAB_WIDTH
7b509c
#define AMGC_TAB_WIDTH	8
7b509c
#endif
7b509c
a6ad51
#define AMGC_OPTV_ELEMENTS 64
a6ad51
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;
abf923
	struct amgc_fd_ctx		fdctx;
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 {
8fca74
	const struct amgc_driver_ctx *	dctx;
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
abf923
static inline int amgc_driver_fdin(const struct amgc_driver_ctx * dctx)
abf923
{
abf923
	struct amgc_fd_ctx fdctx;
abf923
	amgc_get_driver_fdctx(dctx,&fdctx);
abf923
	return fdctx.fdin;
abf923
}
abf923
abf923
static inline int amgc_driver_fdout(const struct amgc_driver_ctx * dctx)
abf923
{
abf923
	struct amgc_fd_ctx fdctx;
abf923
	amgc_get_driver_fdctx(dctx,&fdctx);
abf923
	return fdctx.fdout;
abf923
}
abf923
abf923
static inline int amgc_driver_fderr(const struct amgc_driver_ctx * dctx)
abf923
{
abf923
	struct amgc_fd_ctx fdctx;
abf923
	amgc_get_driver_fdctx(dctx,&fdctx);
abf923
	return fdctx.fderr;
abf923
}
abf923
abf923
static inline int amgc_driver_fdlog(const struct amgc_driver_ctx * dctx)
abf923
{
abf923
	struct amgc_fd_ctx fdctx;
abf923
	amgc_get_driver_fdctx(dctx,&fdctx);
abf923
	return fdctx.fdlog;
abf923
}
abf923
abf923
static inline int amgc_driver_fdcwd(const struct amgc_driver_ctx * dctx)
abf923
{
abf923
	struct amgc_fd_ctx fdctx;
abf923
	amgc_get_driver_fdctx(dctx,&fdctx);
abf923
	return fdctx.fdcwd;
abf923
}
abf923
abf923
static inline int amgc_driver_fddst(const struct amgc_driver_ctx * dctx)
abf923
{
abf923
	struct amgc_fd_ctx fdctx;
abf923
	amgc_get_driver_fdctx(dctx,&fdctx);
abf923
	return fdctx.fddst;
abf923
}
abf923
383aa6
#endif