dbd/common.h

changeset 1
408291a6eb3e
child 2
c4f02fc67e5a
equal deleted inserted replaced
0:4ff31a4ea1fb 1:408291a6eb3e
1 #include <string.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 #include <lua.h>
6 #include <lauxlib.h>
7 #include <lualib.h>
8
9 #if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM < 501)
10 #include <compat-5.1.h>
11 #endif
12
13
14
15 #define LUA_PUSH_ATTRIB_INT(n, v) \
16 lua_pushstring(L, n); \
17 lua_pushinteger(L, v); \
18 lua_rawset(L, -3);
19
20 #define LUA_PUSH_ATTRIB_FLOAT(n, v) \
21 lua_pushstring(L, n); \
22 lua_pushnumber(L, v); \
23 lua_rawset(L, -3);
24
25 #define LUA_PUSH_ATTRIB_STRING(n, v) \
26 lua_pushstring(L, n); \
27 lua_pushstring(L, v); \
28 lua_rawset(L, -3);
29
30 #define LUA_PUSH_ATTRIB_BOOL(n, v) \
31 lua_pushstring(L, n); \
32 lua_pushboolean(L, v); \
33 lua_rawset(L, -3);
34
35 #define LUA_PUSH_ATTRIB_NIL(n) \
36 lua_pushstring(L, n); \
37 lua_pushnil(L); \
38 lua_rawset(L, -3);
39
40
41
42 #define LUA_PUSH_ARRAY_INT(n, v) \
43 lua_pushinteger(L, v); \
44 lua_rawseti(L, -2, n); \
45 n++;
46
47 #define LUA_PUSH_ARRAY_FLOAT(n, v) \
48 lua_pushnumber(L, v); \
49 lua_rawseti(L, -2, n); \
50 n++;
51
52 #define LUA_PUSH_ARRAY_STRING(n, v) \
53 lua_pushstring(L, v); \
54 lua_rawseti(L, -2, n); \
55 n++;
56
57 #define LUA_PUSH_ARRAY_BOOL(n, v) \
58 lua_pushboolean(L, v); \
59 lua_rawseti(L, -2, n); \
60 n++;
61
62 #define LUA_PUSH_ARRAY_NIL(n) \
63 lua_pushnil(L); \
64 lua_rawseti(L, -2, n); \
65 n++;
66
67
68
69 typedef enum lua_push_type {
70 LUA_PUSH_NIL = 0,
71 LUA_PUSH_INTEGER,
72 LUA_PUSH_NUMBER,
73 LUA_PUSH_STRING,
74 LUA_PUSH_BOOLEAN,
75
76 LUA_PUSH_MAX
77 } lua_push_type_t;
78

mercurial