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
|
#ifndef XLUA_H
#define XLUA_H
#include <stdbool.h>
struct key {
enum key_type {
KT_NULL,
KT_STRING,
KT_NUMBER,
} type;
union {
const char *str;
double num;
} key;
enum value_type {
VT_STRING,
VT_NUMBER,
VT_BOOLEAN,
} vtype;
};
#define _STR(s) #s
#define STR(s) _STR(s)
#define KEY_STR(k, vt) (struct key){ .type = KT_STRING, .key.str = _STR(k), .vtype = (vt)}
#define KEY_NUM(k, vt) (struct key){ .type = KT_NUMBER, .key.mum = (k), .vtype = (vt)}
#define KEY_END (struct key){ .type = KT_NULL }
void pushtable(lua_State *L, const struct key *keys, ...);
void pushsetmember(lua_State *L, int index, const char *name, bool in_set);
#endif /* !XLUA_H */
|