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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "../lua.h"
#include "../lauxlib.h"
#include "../lualib.h"
#if !defined(LUA_VERSION_NUM)
/* Lua 5.0 */
#define LUA_QL(x) "'" x "'"
#define LUA_QS LUA_QL("%s")
#define luaL_Reg luaL_reg
#define luaL_opt(L, f, n, d) \
(lua_isnoneornil(L, n) ? (d) : f(L, n))
#define luaL_addchar(B,c) \
((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
(*(B)->p++ = (char)(c)))
#endif /* Lua 5.0 */
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
/* Lua 5.1 */
/* PUC-Rio Lua uses lconfig_h as include guard for luaconf.h,
* LuaJIT uses luaconf_h. If you use PUC-Rio's include files
* but LuaJIT's library, you will need to define the macro
* COMPAT52_IS_LUAJIT yourself! */
#if !defined(COMPAT52_IS_LUAJIT) && defined(luaconf_h)
#define COMPAT52_IS_LUAJIT
#endif
/* LuaJIT doesn't define these unofficial macros ... */
#if !defined(LUAI_INT32)
#include <limits.h>
#if INT_MAX-20 < 32760
#define LUAI_INT32 long
#define LUAI_UINT32 unsigned long
#elif INT_MAX > 2147483640L
#define LUAI_INT32 int
#define LUAI_UINT32 unsigned int
#else
#error "could not detect suitable lua_Unsigned datatype"
#endif
#endif
#define LUA_OPADD 0
#define LUA_OPSUB 1
#define LUA_OPMUL 2
#define LUA_OPDIV 3
#define LUA_OPMOD 4
#define LUA_OPPOW 5
#define LUA_OPUNM 6
#define LUA_OPEQ 0
#define LUA_OPLT 1
#define LUA_OPLE 2
typedef LUAI_UINT32 lua_Unsigned;
typedef struct luaL_Buffer_52 {
luaL_Buffer b; /* make incorrect code crash! */
char *ptr;
size_t nelems;
size_t capacity;
lua_State *L2;
} luaL_Buffer_52;
#define luaL_Buffer luaL_Buffer_52
typedef struct luaL_Stream {
FILE *f;
/* The following field is for LuaJIT which adds a uint32_t field
* to file handles. */
lua_Unsigned type;
lua_CFunction closef;
} luaL_Stream;
#define lua_tounsigned(L, i) lua_tounsignedx(L, i, NULL)
#define lua_rawlen(L, i) lua_objlen(L, i)
void lua_arith (lua_State *L, int op);
int lua_compare (lua_State *L, int idx1, int idx2, int op);
void lua_pushunsigned (lua_State *L, lua_Unsigned n);
lua_Unsigned luaL_checkunsigned (lua_State *L, int i);
lua_Unsigned lua_tounsignedx (lua_State *L, int i, int *isnum);
lua_Unsigned luaL_optunsigned (lua_State *L, int i, lua_Unsigned def);
lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum);
void lua_len (lua_State *L, int i);
int luaL_len (lua_State *L, int i);
const char *luaL_tolstring (lua_State *L, int idx, size_t *len);
void luaL_requiref (lua_State *L, char const* modname, lua_CFunction openf, int glb);
#define luaL_buffinit luaL_buffinit_52
void luaL_buffinit (lua_State *L, luaL_Buffer_52 *B);
#define luaL_prepbuffsize luaL_prepbuffsize_52
char *luaL_prepbuffsize (luaL_Buffer_52 *B, size_t s);
#define luaL_addlstring luaL_addlstring_52
void luaL_addlstring (luaL_Buffer_52 *B, const char *s, size_t l);
#define luaL_addvalue luaL_addvalue_52
void luaL_addvalue (luaL_Buffer_52 *B);
#define luaL_pushresult luaL_pushresult_52
void luaL_pushresult (luaL_Buffer_52 *B);
#undef luaL_buffinitsize
#define luaL_buffinitsize(L, B, s) \
(luaL_buffinit(L, B), luaL_prepbuffsize(B, s))
#undef luaL_prepbuffer
#define luaL_prepbuffer(B) \
luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
#undef luaL_addchar
#define luaL_addchar(B, c) \
((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize(B, 1)), \
((B)->ptr[(B)->nelems++] = (c)))
#undef luaL_addsize
#define luaL_addsize(B, s) \
((B)->nelems += (s))
#undef luaL_addstring
#define luaL_addstring(B, s) \
luaL_addlstring(B, s, strlen(s))
#undef luaL_pushresultsize
#define luaL_pushresultsize(B, s) \
(luaL_addsize(B, s), luaL_pushresult(B))
#endif /* Lua 5.1 */
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501
/* Lua 5.0 *or* 5.1 */
#define LUA_OK 0
#define lua_pushglobaltable(L) \
lua_pushvalue(L, LUA_GLOBALSINDEX)
#define luaL_newlib(L, l) \
(lua_newtable((L)),luaL_setfuncs((L), (l), 0))
void luaL_checkversion (lua_State *L);
#endif /* Lua 5.0 *or* 5.1 */
int lua_absindex (lua_State *L, int i);
void lua_copy (lua_State *L, int from, int to);
void lua_rawgetp (lua_State *L, int i, const void *p);
void lua_rawsetp (lua_State *L, int i, const void *p);
void *luaL_testudata (lua_State *L, int i, const char *tname);
lua_Number lua_tonumberx (lua_State *L, int i, int *isnum);
void lua_getuservalue (lua_State *L, int i);
void lua_setuservalue (lua_State *L, int i);
void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
void luaL_setmetatable (lua_State *L, const char *tname);
int luaL_getsubtable (lua_State *L, int i, const char *name);
void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, int level);
int luaL_fileresult (lua_State *L, int stat, const char *fname);
|