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 HONEY_UTIL_H
#define HONEY_UTIL_H
#include <lua.h>
struct honey_tbl_t {
const char *key;
int type;
union {
lua_Integer integer;
lua_Number number;
lua_CFunction function;
const char *string;
} value;
};
#define H_INT(k, v) { .key=k, .type=LUA_TNUMBER, .value.integer=v }
#define H_ENUM(v) { .key=#v, .type=LUA_TNUMBER, .value.integer=v }
#define H_FUNC(k, v) { .key=k, .type=LUA_TFUNCTION, .value.function=v }
#define H_STR(k, v) { .key=k, .type=LUA_TSTRING, .value.string=v }
#define H_NUM(k, v) { .key=k, .type=LUA_TNUMBER, .value.number=v }
#define H_END { .key=NULL, .type=LUA_TNIL, .value.integer=0 }
void setup_util(lua_State *L, int honey_tbl);
void create_table(lua_State *L, struct honey_tbl_t *tbl);
void append_table(lua_State *L, int tbl_a, int tbl_b);
int h_call(lua_State *L, int nargs, int nret);
#endif
|