ref: 794e2ee40b0345746539fbd41ad0eda122f8603e
dir: /nate_construct.h/
#include "nate.h"
void nc_push(Nelem*);
void nc_pop(void);
Nelem* nc_get(void);
// #define N_TYPE in your implementation
#define COND(N) (N->type == N_TYPE)
#define GUARD(N) assert(COND(N))
// create with benefits
Nelem *makenelem(long size, char *type, Nelemfunctions *funcs, char *name);
#define MakeNelem(Type, Char, F, N) ((Type*)makenelem(sizeof(Type), Char, F, N));
// internal stuff
void nc_init(void);
// trace hits
extern int nctracehitlevel;
void nctracehit(Nelem *el, int passthrough);
// default functionality
Nelem* nd_checkhit(Nelem* nelem, Image* screen, Mouse m);
// syntactic sugar: default accessors
#define DEF_ACCESSOR_OneParam(Type, Func, T1, N1) \
static Type* \
Func(T1 N1) \
{ \
Type *b = (Type*)nc_get(); \
GUARD(b); \
b->N1 = N1; \
return b; \
}
#define DEF_ACCESSOR_TwoParams(Type, Func, T1, N1, T2, N2) \
static Type* \
Func(T1 N1, T2 N2) \
{ \
Type *b = (Type*)nc_get(); \
GUARD(b); \
b->N1 = N1; \
b->N2 = N2; \
return b; \
}
#define DEF_ACCESSOR_ThreeParams(Type, Func, T1, N1, T2, N2, T3, N3) \
static Type* \
Func(T1 N1, T2 N2, T3 N3) \
{ \
Type *b = (Type*)nc_get(); \
GUARD(b); \
b->N1 = N1; \
b->N2 = N2; \
b->N3 = N3; \
return b; \
}