aboutsummaryrefslogtreecommitdiff
path: root/src/lua/lauxlib.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lua/lauxlib.h (renamed from src/lua-5.3/lauxlib.h)54
1 files changed, 33 insertions, 21 deletions
diff --git a/src/lua-5.3/lauxlib.h b/src/lua/lauxlib.h
index 9857d3a..59fef6a 100644
--- a/src/lua-5.3/lauxlib.h
+++ b/src/lua/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.131.1.1 2017/04/19 17:20:42 roberto Exp $ 2** $Id: lauxlib.h $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -15,6 +15,12 @@
15#include "lua.h" 15#include "lua.h"
16 16
17 17
18/* global table */
19#define LUA_GNAME "_G"
20
21
22typedef struct luaL_Buffer luaL_Buffer;
23
18 24
19/* extra error code for 'luaL_loadfilex' */ 25/* extra error code for 'luaL_loadfilex' */
20#define LUA_ERRFILE (LUA_ERRERR+1) 26#define LUA_ERRFILE (LUA_ERRERR+1)
@@ -44,6 +50,7 @@ LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
44LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); 50LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
45LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); 51LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
46LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg); 52LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);
53LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname);
47LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg, 54LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,
48 size_t *l); 55 size_t *l);
49LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg, 56LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
@@ -73,6 +80,7 @@ LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
73LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); 80LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
74LUALIB_API int (luaL_execresult) (lua_State *L, int stat); 81LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
75 82
83
76/* predefined references */ 84/* predefined references */
77#define LUA_NOREF (-2) 85#define LUA_NOREF (-2)
78#define LUA_REFNIL (-1) 86#define LUA_REFNIL (-1)
@@ -93,8 +101,10 @@ LUALIB_API lua_State *(luaL_newstate) (void);
93 101
94LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); 102LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
95 103
96LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, 104LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s,
97 const char *r); 105 const char *p, const char *r);
106LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s,
107 const char *p, const char *r);
98 108
99LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); 109LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
100 110
@@ -121,6 +131,10 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
121 131
122#define luaL_argcheck(L, cond,arg,extramsg) \ 132#define luaL_argcheck(L, cond,arg,extramsg) \
123 ((void)((cond) || luaL_argerror(L, (arg), (extramsg)))) 133 ((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
134
135#define luaL_argexpected(L,cond,arg,tname) \
136 ((void)((cond) || luaL_typeerror(L, (arg), (tname))))
137
124#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) 138#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
125#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) 139#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
126 140
@@ -139,19 +153,30 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
139#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) 153#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL)
140 154
141 155
156/* push the value used to represent failure/error */
157#define luaL_pushfail(L) lua_pushnil(L)
158
159
142/* 160/*
143** {====================================================== 161** {======================================================
144** Generic Buffer manipulation 162** Generic Buffer manipulation
145** ======================================================= 163** =======================================================
146*/ 164*/
147 165
148typedef struct luaL_Buffer { 166struct luaL_Buffer {
149 char *b; /* buffer address */ 167 char *b; /* buffer address */
150 size_t size; /* buffer size */ 168 size_t size; /* buffer size */
151 size_t n; /* number of characters in buffer */ 169 size_t n; /* number of characters in buffer */
152 lua_State *L; 170 lua_State *L;
153 char initb[LUAL_BUFFERSIZE]; /* initial buffer */ 171 union {
154} luaL_Buffer; 172 LUAI_MAXALIGN; /* ensure maximum alignment for buffer */
173 char b[LUAL_BUFFERSIZE]; /* initial buffer */
174 } init;
175};
176
177
178#define luaL_bufflen(bf) ((bf)->n)
179#define luaL_buffaddr(bf) ((bf)->b)
155 180
156 181
157#define luaL_addchar(B,c) \ 182#define luaL_addchar(B,c) \
@@ -160,6 +185,8 @@ typedef struct luaL_Buffer {
160 185
161#define luaL_addsize(B,s) ((B)->n += (s)) 186#define luaL_addsize(B,s) ((B)->n += (s))
162 187
188#define luaL_buffsub(B,s) ((B)->n -= (s))
189
163LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); 190LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
164LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); 191LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
165LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); 192LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
@@ -197,21 +224,6 @@ typedef struct luaL_Stream {
197 224
198/* }====================================================== */ 225/* }====================================================== */
199 226
200
201
202/* compatibility with old module system */
203#if defined(LUA_COMPAT_MODULE)
204
205LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
206 int sizehint);
207LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
208 const luaL_Reg *l, int nup);
209
210#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0))
211
212#endif
213
214
215/* 227/*
216** {================================================================== 228** {==================================================================
217** "Abstraction Layer" for basic report of messages and errors 229** "Abstraction Layer" for basic report of messages and errors