Warning, file /include/lauxlib.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef lauxlib_h
0009 #define lauxlib_h
0010
0011
0012 #include <stddef.h>
0013 #include <stdio.h>
0014
0015 #include "luaconf.h"
0016 #include "lua.h"
0017
0018
0019
0020 #define LUA_GNAME "_G"
0021
0022
0023 typedef struct luaL_Buffer luaL_Buffer;
0024
0025
0026
0027 #define LUA_ERRFILE (LUA_ERRERR+1)
0028
0029
0030
0031 #define LUA_LOADED_TABLE "_LOADED"
0032
0033
0034
0035 #define LUA_PRELOAD_TABLE "_PRELOAD"
0036
0037
0038 typedef struct luaL_Reg {
0039 const char *name;
0040 lua_CFunction func;
0041 } luaL_Reg;
0042
0043
0044 #define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number))
0045
0046 LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz);
0047 #define luaL_checkversion(L) \
0048 luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES)
0049
0050 LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
0051 LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
0052 LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
0053 LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);
0054 LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname);
0055 LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,
0056 size_t *l);
0057 LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
0058 const char *def, size_t *l);
0059 LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg);
0060 LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def);
0061
0062 LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg);
0063 LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg,
0064 lua_Integer def);
0065
0066 LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
0067 LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t);
0068 LUALIB_API void (luaL_checkany) (lua_State *L, int arg);
0069
0070 LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
0071 LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname);
0072 LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname);
0073 LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
0074
0075 LUALIB_API void (luaL_where) (lua_State *L, int lvl);
0076 LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
0077
0078 LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
0079 const char *const lst[]);
0080
0081 LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
0082 LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
0083
0084
0085
0086 #define LUA_NOREF (-2)
0087 #define LUA_REFNIL (-1)
0088
0089 LUALIB_API int (luaL_ref) (lua_State *L, int t);
0090 LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
0091
0092 LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename,
0093 const char *mode);
0094
0095 #define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL)
0096
0097 LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz,
0098 const char *name, const char *mode);
0099 LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
0100
0101 LUALIB_API lua_State *(luaL_newstate) (void);
0102
0103 LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
0104
0105 LUALIB_API void (luaL_addgsub) (luaL_Buffer *b, const char *s,
0106 const char *p, const char *r);
0107 LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s,
0108 const char *p, const char *r);
0109
0110 LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
0111
0112 LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname);
0113
0114 LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
0115 const char *msg, int level);
0116
0117 LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
0118 lua_CFunction openf, int glb);
0119
0120
0121
0122
0123
0124
0125
0126
0127 #define luaL_newlibtable(L,l) \
0128 lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
0129
0130 #define luaL_newlib(L,l) \
0131 (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
0132
0133 #define luaL_argcheck(L, cond,arg,extramsg) \
0134 ((void)(luai_likely(cond) || luaL_argerror(L, (arg), (extramsg))))
0135
0136 #define luaL_argexpected(L,cond,arg,tname) \
0137 ((void)(luai_likely(cond) || luaL_typeerror(L, (arg), (tname))))
0138
0139 #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
0140 #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
0141
0142 #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
0143
0144 #define luaL_dofile(L, fn) \
0145 (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
0146
0147 #define luaL_dostring(L, s) \
0148 (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
0149
0150 #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
0151
0152 #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
0153
0154 #define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL)
0155
0156
0157
0158
0159
0160
0161 #define luaL_intop(op,v1,v2) \
0162 ((lua_Integer)((lua_Unsigned)(v1) op (lua_Unsigned)(v2)))
0163
0164
0165
0166 #define luaL_pushfail(L) lua_pushnil(L)
0167
0168
0169
0170
0171
0172 #if !defined(lua_assert)
0173
0174 #if defined LUAI_ASSERT
0175 #include <assert.h>
0176 #define lua_assert(c) assert(c)
0177 #else
0178 #define lua_assert(c) ((void)0)
0179 #endif
0180
0181 #endif
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191 struct luaL_Buffer {
0192 char *b;
0193 size_t size;
0194 size_t n;
0195 lua_State *L;
0196 union {
0197 LUAI_MAXALIGN;
0198 char b[LUAL_BUFFERSIZE];
0199 } init;
0200 };
0201
0202
0203 #define luaL_bufflen(bf) ((bf)->n)
0204 #define luaL_buffaddr(bf) ((bf)->b)
0205
0206
0207 #define luaL_addchar(B,c) \
0208 ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
0209 ((B)->b[(B)->n++] = (c)))
0210
0211 #define luaL_addsize(B,s) ((B)->n += (s))
0212
0213 #define luaL_buffsub(B,s) ((B)->n -= (s))
0214
0215 LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
0216 LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
0217 LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
0218 LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
0219 LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
0220 LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
0221 LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);
0222 LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
0223
0224 #define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242 #define LUA_FILEHANDLE "FILE*"
0243
0244
0245 typedef struct luaL_Stream {
0246 FILE *f;
0247 lua_CFunction closef;
0248 } luaL_Stream;
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259 #if !defined(lua_writestring)
0260 #define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
0261 #endif
0262
0263
0264 #if !defined(lua_writeline)
0265 #define lua_writeline() (lua_writestring("\n", 1), fflush(stdout))
0266 #endif
0267
0268
0269 #if !defined(lua_writestringerror)
0270 #define lua_writestringerror(s,p) \
0271 (fprintf(stderr, (s), (p)), fflush(stderr))
0272 #endif
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282 #if defined(LUA_COMPAT_APIINTCASTS)
0283
0284 #define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))
0285 #define luaL_optunsigned(L,a,d) \
0286 ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
0287
0288 #define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
0289 #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
0290
0291 #define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
0292 #define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
0293
0294 #endif
0295
0296
0297
0298
0299 #endif
0300
0301