├── .gitattributes ├── .gitignore ├── README.md ├── contrib ├── .gitignore ├── Lua51 │ ├── include │ │ ├── lauxlib.h │ │ ├── lua.h │ │ ├── lua.hpp │ │ ├── luaconf.h │ │ └── lualib.h │ └── lib │ │ ├── x32 │ │ └── qlua.lib │ │ └── x64 │ │ └── qlua.lib ├── Lua53 │ ├── include │ │ ├── lauxlib.h │ │ ├── lua.h │ │ ├── lua.hpp │ │ ├── luaconf.h │ │ └── lualib.h │ └── lib │ │ └── x64 │ │ └── lua53.lib └── Lua54 │ ├── include │ ├── lauxlib.h │ ├── lua.h │ ├── lua.hpp │ ├── luaconf.h │ └── lualib.h │ └── lib │ └── x64 │ └── lua54.lib ├── lua-sample └── luacdll-test1.lua ├── luacdll.vcxproj ├── luacdll.vcxproj.filters ├── make-arc.cmd └── src ├── luacdll.cpp └── luacdll.def /.gitattributes: -------------------------------------------------------------------------------- 1 | *.cpp working-tree-encoding=CP1251 eol=CRLF 2 | *.c working-tree-encoding=CP1251 eol=CRLF 3 | *.h working-tree-encoding=CP1251 eol=CRLF 4 | *.cmd working-tree-encoding=CP1251 eol=CRLF 5 | *.lua working-tree-encoding=CP1251 eol=CRLF 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | *.zip 3 | *.7z 4 | .bin 5 | .tmp 6 | .Build 7 | 8 | #VS temp files 9 | *.suo 10 | *.idb 11 | *.pdb 12 | *.exp 13 | *.VC.db 14 | *.vcxproj.user 15 | *.sln 16 | 17 | # Prerequisites 18 | *.d 19 | 20 | # Compiled Object files 21 | *.slo 22 | *.lo 23 | *.o 24 | *.obj 25 | 26 | # Precompiled Headers 27 | *.gch 28 | *.pch 29 | 30 | # Compiled Dynamic libraries 31 | *.so 32 | *.dylib 33 | *.dll 34 | 35 | # Fortran module files 36 | *.mod 37 | *.smod 38 | 39 | # Compiled Static libraries 40 | *.lai 41 | *.la 42 | *.a 43 | *.lib 44 | 45 | # Executables 46 | *.exe 47 | *.out 48 | *.app 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Пример библиотеки на C++ для Lua 2 | Адаптировано для использования в торговом терминале QUIK. 3 | Проект для Visual Studio содержит готовые варианты сборки для разных версий QUIK. 4 | 5 | Подробное описание: 6 | https://quik2dde.ru/viewtopic.php?id=18 7 | 8 | ## Варианты сборки 9 | 10 | - Release / Debug | Win32 - для QUIK 6.x / 7.x (x32, Lua5.1) 11 | - Release / Debug | x64 - для QUIK 8.0...8.4 (x64, Lua5.1) 12 | - Release-Lua53 / Debug-Lua53 | x64 - для QUIK 8.5 и далее (x64, Lua5.3) 13 | - Release-Lua54 / Debug-Lua54 | x64 - для QUIK 8.11 и далее (x64, Lua5.4) 14 | -------------------------------------------------------------------------------- /contrib/.gitignore: -------------------------------------------------------------------------------- 1 | !qlua.lib 2 | !lua53.lib 3 | !lua54.lib 4 | -------------------------------------------------------------------------------- /contrib/Lua51/include/lauxlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions for building Lua libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lauxlib_h 9 | #define lauxlib_h 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | 18 | #if defined(LUA_COMPAT_GETN) 19 | LUALIB_API int (luaL_getn) (lua_State *L, int t); 20 | LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); 21 | #else 22 | #define luaL_getn(L,i) ((int)lua_objlen(L, i)) 23 | #define luaL_setn(L,i,j) ((void)0) /* no op! */ 24 | #endif 25 | 26 | #if defined(LUA_COMPAT_OPENLIB) 27 | #define luaI_openlib luaL_openlib 28 | #endif 29 | 30 | 31 | /* extra error code for `luaL_load' */ 32 | #define LUA_ERRFILE (LUA_ERRERR+1) 33 | 34 | 35 | typedef struct luaL_Reg { 36 | const char *name; 37 | lua_CFunction func; 38 | } luaL_Reg; 39 | 40 | 41 | 42 | LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, 43 | const luaL_Reg *l, int nup); 44 | LUALIB_API void (luaL_register) (lua_State *L, const char *libname, 45 | const luaL_Reg *l); 46 | LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); 47 | LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); 48 | LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); 49 | LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); 50 | LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, 51 | size_t *l); 52 | LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, 53 | const char *def, size_t *l); 54 | LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); 55 | LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); 56 | 57 | LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); 58 | LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, 59 | lua_Integer def); 60 | 61 | LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); 62 | LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); 63 | LUALIB_API void (luaL_checkany) (lua_State *L, int narg); 64 | 65 | LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); 66 | LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); 67 | 68 | LUALIB_API void (luaL_where) (lua_State *L, int lvl); 69 | LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); 70 | 71 | LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, 72 | const char *const lst[]); 73 | 74 | LUALIB_API int (luaL_ref) (lua_State *L, int t); 75 | LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); 76 | 77 | LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); 78 | LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, 79 | const char *name); 80 | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); 81 | 82 | LUALIB_API lua_State *(luaL_newstate) (void); 83 | 84 | 85 | LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, 86 | const char *r); 87 | 88 | LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, 89 | const char *fname, int szhint); 90 | 91 | 92 | 93 | 94 | /* 95 | ** =============================================================== 96 | ** some useful macros 97 | ** =============================================================== 98 | */ 99 | 100 | #define luaL_argcheck(L, cond,numarg,extramsg) \ 101 | ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) 102 | #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) 103 | #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) 104 | #define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) 105 | #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) 106 | #define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) 107 | #define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) 108 | 109 | #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) 110 | 111 | #define luaL_dofile(L, fn) \ 112 | (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) 113 | 114 | #define luaL_dostring(L, s) \ 115 | (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) 116 | 117 | #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) 118 | 119 | #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) 120 | 121 | /* 122 | ** {====================================================== 123 | ** Generic Buffer manipulation 124 | ** ======================================================= 125 | */ 126 | 127 | 128 | 129 | typedef struct luaL_Buffer { 130 | char *p; /* current position in buffer */ 131 | int lvl; /* number of strings in the stack (level) */ 132 | lua_State *L; 133 | char buffer[LUAL_BUFFERSIZE]; 134 | } luaL_Buffer; 135 | 136 | #define luaL_addchar(B,c) \ 137 | ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ 138 | (*(B)->p++ = (char)(c))) 139 | 140 | /* compatibility only */ 141 | #define luaL_putchar(B,c) luaL_addchar(B,c) 142 | 143 | #define luaL_addsize(B,n) ((B)->p += (n)) 144 | 145 | LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); 146 | LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); 147 | LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); 148 | LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); 149 | LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); 150 | LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); 151 | 152 | 153 | /* }====================================================== */ 154 | 155 | 156 | /* compatibility with ref system */ 157 | 158 | /* pre-defined references */ 159 | #define LUA_NOREF (-2) 160 | #define LUA_REFNIL (-1) 161 | 162 | #define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ 163 | (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) 164 | 165 | #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) 166 | 167 | #define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) 168 | 169 | 170 | #define luaL_reg luaL_Reg 171 | 172 | #endif 173 | 174 | 175 | -------------------------------------------------------------------------------- /contrib/Lua51/include/lua.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ 3 | ** Lua - An Extensible Extension Language 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 5 | ** See Copyright Notice at the end of this file 6 | */ 7 | 8 | 9 | #ifndef lua_h 10 | #define lua_h 11 | 12 | #include 13 | #include 14 | 15 | 16 | #include "luaconf.h" 17 | 18 | 19 | #define LUA_VERSION "Lua 5.1" 20 | #define LUA_RELEASE "Lua 5.1.4" 21 | #define LUA_VERSION_NUM 501 22 | #define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" 23 | #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" 24 | 25 | 26 | /* mark for precompiled code (`Lua') */ 27 | #define LUA_SIGNATURE "\033Lua" 28 | 29 | /* option for multiple returns in `lua_pcall' and `lua_call' */ 30 | #define LUA_MULTRET (-1) 31 | 32 | 33 | /* 34 | ** pseudo-indices 35 | */ 36 | #define LUA_REGISTRYINDEX (-10000) 37 | #define LUA_ENVIRONINDEX (-10001) 38 | #define LUA_GLOBALSINDEX (-10002) 39 | #define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) 40 | 41 | 42 | /* thread status; 0 is OK */ 43 | #define LUA_YIELD 1 44 | #define LUA_ERRRUN 2 45 | #define LUA_ERRSYNTAX 3 46 | #define LUA_ERRMEM 4 47 | #define LUA_ERRERR 5 48 | 49 | 50 | typedef struct lua_State lua_State; 51 | 52 | typedef int (*lua_CFunction) (lua_State *L); 53 | 54 | 55 | /* 56 | ** functions that read/write blocks when loading/dumping Lua chunks 57 | */ 58 | typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); 59 | 60 | typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); 61 | 62 | 63 | /* 64 | ** prototype for memory-allocation functions 65 | */ 66 | typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); 67 | 68 | 69 | /* 70 | ** basic types 71 | */ 72 | #define LUA_TNONE (-1) 73 | 74 | #define LUA_TNIL 0 75 | #define LUA_TBOOLEAN 1 76 | #define LUA_TLIGHTUSERDATA 2 77 | #define LUA_TNUMBER 3 78 | #define LUA_TSTRING 4 79 | #define LUA_TTABLE 5 80 | #define LUA_TFUNCTION 6 81 | #define LUA_TUSERDATA 7 82 | #define LUA_TTHREAD 8 83 | 84 | 85 | 86 | /* minimum Lua stack available to a C function */ 87 | #define LUA_MINSTACK 20 88 | 89 | 90 | /* 91 | ** generic extra include file 92 | */ 93 | #if defined(LUA_USER_H) 94 | #include LUA_USER_H 95 | #endif 96 | 97 | 98 | /* type of numbers in Lua */ 99 | typedef LUA_NUMBER lua_Number; 100 | 101 | 102 | /* type for integer functions */ 103 | typedef LUA_INTEGER lua_Integer; 104 | 105 | 106 | 107 | /* 108 | ** state manipulation 109 | */ 110 | LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); 111 | LUA_API void (lua_close) (lua_State *L); 112 | LUA_API lua_State *(lua_newthread) (lua_State *L); 113 | 114 | LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); 115 | 116 | 117 | /* 118 | ** basic stack manipulation 119 | */ 120 | LUA_API int (lua_gettop) (lua_State *L); 121 | LUA_API void (lua_settop) (lua_State *L, int idx); 122 | LUA_API void (lua_pushvalue) (lua_State *L, int idx); 123 | LUA_API void (lua_remove) (lua_State *L, int idx); 124 | LUA_API void (lua_insert) (lua_State *L, int idx); 125 | LUA_API void (lua_replace) (lua_State *L, int idx); 126 | LUA_API int (lua_checkstack) (lua_State *L, int sz); 127 | 128 | LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); 129 | 130 | 131 | /* 132 | ** access functions (stack -> C) 133 | */ 134 | 135 | LUA_API int (lua_isnumber) (lua_State *L, int idx); 136 | LUA_API int (lua_isstring) (lua_State *L, int idx); 137 | LUA_API int (lua_iscfunction) (lua_State *L, int idx); 138 | LUA_API int (lua_isuserdata) (lua_State *L, int idx); 139 | LUA_API int (lua_type) (lua_State *L, int idx); 140 | LUA_API const char *(lua_typename) (lua_State *L, int tp); 141 | 142 | LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); 143 | LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); 144 | LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); 145 | 146 | LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); 147 | LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); 148 | LUA_API int (lua_toboolean) (lua_State *L, int idx); 149 | LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); 150 | LUA_API size_t (lua_objlen) (lua_State *L, int idx); 151 | LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); 152 | LUA_API void *(lua_touserdata) (lua_State *L, int idx); 153 | LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); 154 | LUA_API const void *(lua_topointer) (lua_State *L, int idx); 155 | 156 | 157 | /* 158 | ** push functions (C -> stack) 159 | */ 160 | LUA_API void (lua_pushnil) (lua_State *L); 161 | LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); 162 | LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); 163 | LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); 164 | LUA_API void (lua_pushstring) (lua_State *L, const char *s); 165 | LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, 166 | va_list argp); 167 | LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); 168 | LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); 169 | LUA_API void (lua_pushboolean) (lua_State *L, int b); 170 | LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); 171 | LUA_API int (lua_pushthread) (lua_State *L); 172 | 173 | 174 | /* 175 | ** get functions (Lua -> stack) 176 | */ 177 | LUA_API void (lua_gettable) (lua_State *L, int idx); 178 | LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); 179 | LUA_API void (lua_rawget) (lua_State *L, int idx); 180 | LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); 181 | LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); 182 | LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); 183 | LUA_API int (lua_getmetatable) (lua_State *L, int objindex); 184 | LUA_API void (lua_getfenv) (lua_State *L, int idx); 185 | 186 | 187 | /* 188 | ** set functions (stack -> Lua) 189 | */ 190 | LUA_API void (lua_settable) (lua_State *L, int idx); 191 | LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); 192 | LUA_API void (lua_rawset) (lua_State *L, int idx); 193 | LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); 194 | LUA_API int (lua_setmetatable) (lua_State *L, int objindex); 195 | LUA_API int (lua_setfenv) (lua_State *L, int idx); 196 | 197 | 198 | /* 199 | ** `load' and `call' functions (load and run Lua code) 200 | */ 201 | LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); 202 | LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); 203 | LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); 204 | LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, 205 | const char *chunkname); 206 | 207 | LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); 208 | 209 | 210 | /* 211 | ** coroutine functions 212 | */ 213 | LUA_API int (lua_yield) (lua_State *L, int nresults); 214 | LUA_API int (lua_resume) (lua_State *L, int narg); 215 | LUA_API int (lua_status) (lua_State *L); 216 | 217 | /* 218 | ** garbage-collection function and options 219 | */ 220 | 221 | #define LUA_GCSTOP 0 222 | #define LUA_GCRESTART 1 223 | #define LUA_GCCOLLECT 2 224 | #define LUA_GCCOUNT 3 225 | #define LUA_GCCOUNTB 4 226 | #define LUA_GCSTEP 5 227 | #define LUA_GCSETPAUSE 6 228 | #define LUA_GCSETSTEPMUL 7 229 | 230 | LUA_API int (lua_gc) (lua_State *L, int what, int data); 231 | 232 | 233 | /* 234 | ** miscellaneous functions 235 | */ 236 | 237 | LUA_API int (lua_error) (lua_State *L); 238 | 239 | LUA_API int (lua_next) (lua_State *L, int idx); 240 | 241 | LUA_API void (lua_concat) (lua_State *L, int n); 242 | 243 | LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); 244 | LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); 245 | 246 | 247 | 248 | /* 249 | ** =============================================================== 250 | ** some useful macros 251 | ** =============================================================== 252 | */ 253 | 254 | #define lua_pop(L,n) lua_settop(L, -(n)-1) 255 | 256 | #define lua_newtable(L) lua_createtable(L, 0, 0) 257 | 258 | #define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) 259 | 260 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) 261 | 262 | #define lua_strlen(L,i) lua_objlen(L, (i)) 263 | 264 | #define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) 265 | #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) 266 | #define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) 267 | #define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) 268 | #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) 269 | #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) 270 | #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) 271 | #define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) 272 | 273 | #define lua_pushliteral(L, s) \ 274 | lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) 275 | 276 | #define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) 277 | #define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) 278 | 279 | #define lua_tostring(L,i) lua_tolstring(L, (i), NULL) 280 | 281 | 282 | 283 | /* 284 | ** compatibility macros and functions 285 | */ 286 | 287 | #define lua_open() luaL_newstate() 288 | 289 | #define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) 290 | 291 | #define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) 292 | 293 | #define lua_Chunkreader lua_Reader 294 | #define lua_Chunkwriter lua_Writer 295 | 296 | 297 | /* hack */ 298 | LUA_API void lua_setlevel (lua_State *from, lua_State *to); 299 | 300 | 301 | /* 302 | ** {====================================================================== 303 | ** Debug API 304 | ** ======================================================================= 305 | */ 306 | 307 | 308 | /* 309 | ** Event codes 310 | */ 311 | #define LUA_HOOKCALL 0 312 | #define LUA_HOOKRET 1 313 | #define LUA_HOOKLINE 2 314 | #define LUA_HOOKCOUNT 3 315 | #define LUA_HOOKTAILRET 4 316 | 317 | 318 | /* 319 | ** Event masks 320 | */ 321 | #define LUA_MASKCALL (1 << LUA_HOOKCALL) 322 | #define LUA_MASKRET (1 << LUA_HOOKRET) 323 | #define LUA_MASKLINE (1 << LUA_HOOKLINE) 324 | #define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) 325 | 326 | typedef struct lua_Debug lua_Debug; /* activation record */ 327 | 328 | 329 | /* Functions to be called by the debuger in specific events */ 330 | typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); 331 | 332 | 333 | LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); 334 | LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); 335 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); 336 | LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); 337 | LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); 338 | LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); 339 | 340 | LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); 341 | LUA_API lua_Hook lua_gethook (lua_State *L); 342 | LUA_API int lua_gethookmask (lua_State *L); 343 | LUA_API int lua_gethookcount (lua_State *L); 344 | 345 | 346 | struct lua_Debug { 347 | int event; 348 | const char *name; /* (n) */ 349 | const char *namewhat; /* (n) `global', `local', `field', `method' */ 350 | const char *what; /* (S) `Lua', `C', `main', `tail' */ 351 | const char *source; /* (S) */ 352 | int currentline; /* (l) */ 353 | int nups; /* (u) number of upvalues */ 354 | int linedefined; /* (S) */ 355 | int lastlinedefined; /* (S) */ 356 | char short_src[LUA_IDSIZE]; /* (S) */ 357 | /* private part */ 358 | int i_ci; /* active function */ 359 | }; 360 | 361 | /* }====================================================================== */ 362 | 363 | 364 | /****************************************************************************** 365 | * Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. 366 | * 367 | * Permission is hereby granted, free of charge, to any person obtaining 368 | * a copy of this software and associated documentation files (the 369 | * "Software"), to deal in the Software without restriction, including 370 | * without limitation the rights to use, copy, modify, merge, publish, 371 | * distribute, sublicense, and/or sell copies of the Software, and to 372 | * permit persons to whom the Software is furnished to do so, subject to 373 | * the following conditions: 374 | * 375 | * The above copyright notice and this permission notice shall be 376 | * included in all copies or substantial portions of the Software. 377 | * 378 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 379 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 380 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 381 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 382 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 383 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 384 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 385 | ******************************************************************************/ 386 | 387 | 388 | #endif 389 | -------------------------------------------------------------------------------- /contrib/Lua51/include/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /contrib/Lua51/include/luaconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ 3 | ** Configuration file for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lconfig_h 9 | #define lconfig_h 10 | 11 | #include 12 | #include 13 | 14 | 15 | /* 16 | ** ================================================================== 17 | ** Search for "@@" to find all configurable definitions. 18 | ** =================================================================== 19 | */ 20 | 21 | 22 | /* 23 | @@ LUA_ANSI controls the use of non-ansi features. 24 | ** CHANGE it (define it) if you want Lua to avoid the use of any 25 | ** non-ansi feature or library. 26 | */ 27 | #if defined(__STRICT_ANSI__) 28 | #define LUA_ANSI 29 | #endif 30 | 31 | 32 | #if !defined(LUA_ANSI) && defined(_WIN32) 33 | #define LUA_WIN 34 | #endif 35 | 36 | #if defined(LUA_USE_LINUX) 37 | #define LUA_USE_POSIX 38 | #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ 39 | #define LUA_USE_READLINE /* needs some extra libraries */ 40 | #endif 41 | 42 | #if defined(LUA_USE_MACOSX) 43 | #define LUA_USE_POSIX 44 | #define LUA_DL_DYLD /* does not need extra library */ 45 | #endif 46 | 47 | 48 | 49 | /* 50 | @@ LUA_USE_POSIX includes all functionallity listed as X/Open System 51 | @* Interfaces Extension (XSI). 52 | ** CHANGE it (define it) if your system is XSI compatible. 53 | */ 54 | #if defined(LUA_USE_POSIX) 55 | #define LUA_USE_MKSTEMP 56 | #define LUA_USE_ISATTY 57 | #define LUA_USE_POPEN 58 | #define LUA_USE_ULONGJMP 59 | #endif 60 | 61 | 62 | /* 63 | @@ LUA_PATH and LUA_CPATH are the names of the environment variables that 64 | @* Lua check to set its paths. 65 | @@ LUA_INIT is the name of the environment variable that Lua 66 | @* checks for initialization code. 67 | ** CHANGE them if you want different names. 68 | */ 69 | #define LUA_PATH "LUA_PATH" 70 | #define LUA_CPATH "LUA_CPATH" 71 | #define LUA_INIT "LUA_INIT" 72 | 73 | 74 | /* 75 | @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for 76 | @* Lua libraries. 77 | @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for 78 | @* C libraries. 79 | ** CHANGE them if your machine has a non-conventional directory 80 | ** hierarchy or if you want to install your libraries in 81 | ** non-conventional directories. 82 | */ 83 | #if defined(_WIN32) 84 | /* 85 | ** In Windows, any exclamation mark ('!') in the path is replaced by the 86 | ** path of the directory of the executable file of the current process. 87 | */ 88 | #define LUA_LDIR "!\\lua\\" 89 | #define LUA_CDIR "!\\" 90 | #define LUA_PATH_DEFAULT \ 91 | ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ 92 | LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" 93 | #define LUA_CPATH_DEFAULT \ 94 | ".\\?.dll;" ".\\?51.dll;" LUA_CDIR"?.dll;" LUA_CDIR"?51.dll;" LUA_CDIR"clibs\\?.dll;" LUA_CDIR"clibs\\?51.dll;" LUA_CDIR"loadall.dll;" LUA_CDIR"clibs\\loadall.dll" 95 | 96 | #else 97 | #define LUA_ROOT "/usr/local/" 98 | #define LUA_LDIR LUA_ROOT "share/lua/5.1/" 99 | #define LUA_CDIR LUA_ROOT "lib/lua/5.1/" 100 | #define LUA_PATH_DEFAULT \ 101 | "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ 102 | LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" 103 | #define LUA_CPATH_DEFAULT \ 104 | "./?.so;" "./lib?51.so;" LUA_CDIR"?.so;" LUA_CDIR"lib?51.so;" LUA_CDIR"loadall.so" 105 | #endif 106 | 107 | 108 | /* 109 | @@ LUA_DIRSEP is the directory separator (for submodules). 110 | ** CHANGE it if your machine does not use "/" as the directory separator 111 | ** and is not Windows. (On Windows Lua automatically uses "\".) 112 | */ 113 | #if defined(_WIN32) 114 | #define LUA_DIRSEP "\\" 115 | #else 116 | #define LUA_DIRSEP "/" 117 | #endif 118 | 119 | 120 | /* 121 | @@ LUA_PATHSEP is the character that separates templates in a path. 122 | @@ LUA_PATH_MARK is the string that marks the substitution points in a 123 | @* template. 124 | @@ LUA_EXECDIR in a Windows path is replaced by the executable's 125 | @* directory. 126 | @@ LUA_IGMARK is a mark to ignore all before it when bulding the 127 | @* luaopen_ function name. 128 | ** CHANGE them if for some reason your system cannot use those 129 | ** characters. (E.g., if one of those characters is a common character 130 | ** in file/directory names.) Probably you do not need to change them. 131 | */ 132 | #define LUA_PATHSEP ";" 133 | #define LUA_PATH_MARK "?" 134 | #define LUA_EXECDIR "!" 135 | #define LUA_IGMARK "-" 136 | 137 | 138 | /* 139 | @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. 140 | ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most 141 | ** machines, ptrdiff_t gives a good choice between int or long.) 142 | */ 143 | #define LUA_INTEGER ptrdiff_t 144 | 145 | 146 | /* 147 | @@ LUA_API is a mark for all core API functions. 148 | @@ LUALIB_API is a mark for all standard library functions. 149 | ** CHANGE them if you need to define those functions in some special way. 150 | ** For instance, if you want to create one Windows DLL with the core and 151 | ** the libraries, you may want to use the following definition (define 152 | ** LUA_BUILD_AS_DLL to get it). 153 | */ 154 | #if defined(LUA_BUILD_AS_DLL) 155 | 156 | #if defined(LUA_CORE) || defined(LUA_LIB) 157 | #define LUA_API __declspec(dllexport) 158 | #else 159 | #define LUA_API __declspec(dllimport) 160 | #endif 161 | 162 | #else 163 | 164 | #define LUA_API extern 165 | 166 | #endif 167 | 168 | /* more often than not the libs go together with the core */ 169 | #define LUALIB_API LUA_API 170 | 171 | 172 | /* 173 | @@ LUAI_FUNC is a mark for all extern functions that are not to be 174 | @* exported to outside modules. 175 | @@ LUAI_DATA is a mark for all extern (const) variables that are not to 176 | @* be exported to outside modules. 177 | ** CHANGE them if you need to mark them in some special way. Elf/gcc 178 | ** (versions 3.2 and later) mark them as "hidden" to optimize access 179 | ** when Lua is compiled as a shared library. 180 | */ 181 | #if defined(luaall_c) 182 | #define LUAI_FUNC static 183 | #define LUAI_DATA /* empty */ 184 | 185 | #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ 186 | defined(__ELF__) 187 | #define LUAI_FUNC __attribute__((visibility("hidden"))) extern 188 | #define LUAI_DATA LUAI_FUNC 189 | 190 | #else 191 | #define LUAI_FUNC extern 192 | #define LUAI_DATA extern 193 | #endif 194 | 195 | 196 | 197 | /* 198 | @@ LUA_QL describes how error messages quote program elements. 199 | ** CHANGE it if you want a different appearance. 200 | */ 201 | #define LUA_QL(x) "'" x "'" 202 | #define LUA_QS LUA_QL("%s") 203 | 204 | 205 | /* 206 | @@ LUA_IDSIZE gives the maximum size for the description of the source 207 | @* of a function in debug information. 208 | ** CHANGE it if you want a different size. 209 | */ 210 | #define LUA_IDSIZE 60 211 | 212 | 213 | /* 214 | ** {================================================================== 215 | ** Stand-alone configuration 216 | ** =================================================================== 217 | */ 218 | 219 | #if defined(lua_c) || defined(luaall_c) 220 | 221 | /* 222 | @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that 223 | @* is, whether we're running lua interactively). 224 | ** CHANGE it if you have a better definition for non-POSIX/non-Windows 225 | ** systems. 226 | */ 227 | #if defined(LUA_USE_ISATTY) 228 | #include 229 | #define lua_stdin_is_tty() isatty(0) 230 | #elif defined(LUA_WIN) 231 | #include 232 | #include 233 | #define lua_stdin_is_tty() _isatty(_fileno(stdin)) 234 | #else 235 | #define lua_stdin_is_tty() 1 /* assume stdin is a tty */ 236 | #endif 237 | 238 | 239 | /* 240 | @@ LUA_PROMPT is the default prompt used by stand-alone Lua. 241 | @@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. 242 | ** CHANGE them if you want different prompts. (You can also change the 243 | ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) 244 | */ 245 | #define LUA_PROMPT "> " 246 | #define LUA_PROMPT2 ">> " 247 | 248 | 249 | /* 250 | @@ LUA_PROGNAME is the default name for the stand-alone Lua program. 251 | ** CHANGE it if your stand-alone interpreter has a different name and 252 | ** your system is not able to detect that name automatically. 253 | */ 254 | #define LUA_PROGNAME "lua" 255 | 256 | 257 | /* 258 | @@ LUA_MAXINPUT is the maximum length for an input line in the 259 | @* stand-alone interpreter. 260 | ** CHANGE it if you need longer lines. 261 | */ 262 | #define LUA_MAXINPUT 512 263 | 264 | 265 | /* 266 | @@ lua_readline defines how to show a prompt and then read a line from 267 | @* the standard input. 268 | @@ lua_saveline defines how to "save" a read line in a "history". 269 | @@ lua_freeline defines how to free a line read by lua_readline. 270 | ** CHANGE them if you want to improve this functionality (e.g., by using 271 | ** GNU readline and history facilities). 272 | */ 273 | #if defined(LUA_USE_READLINE) 274 | #include 275 | #include 276 | #include 277 | #define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) 278 | #define lua_saveline(L,idx) \ 279 | if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ 280 | add_history(lua_tostring(L, idx)); /* add it to history */ 281 | #define lua_freeline(L,b) ((void)L, free(b)) 282 | #else 283 | #define lua_readline(L,b,p) \ 284 | ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ 285 | fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ 286 | #define lua_saveline(L,idx) { (void)L; (void)idx; } 287 | #define lua_freeline(L,b) { (void)L; (void)b; } 288 | #endif 289 | 290 | #endif 291 | 292 | /* }================================================================== */ 293 | 294 | 295 | /* 296 | @@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles 297 | @* as a percentage. 298 | ** CHANGE it if you want the GC to run faster or slower (higher values 299 | ** mean larger pauses which mean slower collection.) You can also change 300 | ** this value dynamically. 301 | */ 302 | #define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ 303 | 304 | 305 | /* 306 | @@ LUAI_GCMUL defines the default speed of garbage collection relative to 307 | @* memory allocation as a percentage. 308 | ** CHANGE it if you want to change the granularity of the garbage 309 | ** collection. (Higher values mean coarser collections. 0 represents 310 | ** infinity, where each step performs a full collection.) You can also 311 | ** change this value dynamically. 312 | */ 313 | #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ 314 | 315 | 316 | 317 | /* 318 | @@ LUA_COMPAT_GETN controls compatibility with old getn behavior. 319 | ** CHANGE it (define it) if you want exact compatibility with the 320 | ** behavior of setn/getn in Lua 5.0. 321 | */ 322 | #undef LUA_COMPAT_GETN 323 | 324 | /* 325 | @@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. 326 | ** CHANGE it to undefined as soon as you do not need a global 'loadlib' 327 | ** function (the function is still available as 'package.loadlib'). 328 | */ 329 | #undef LUA_COMPAT_LOADLIB 330 | 331 | /* 332 | @@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. 333 | ** CHANGE it to undefined as soon as your programs use only '...' to 334 | ** access vararg parameters (instead of the old 'arg' table). 335 | */ 336 | #define LUA_COMPAT_VARARG 337 | 338 | /* 339 | @@ LUA_COMPAT_MOD controls compatibility with old math.mod function. 340 | ** CHANGE it to undefined as soon as your programs use 'math.fmod' or 341 | ** the new '%' operator instead of 'math.mod'. 342 | */ 343 | #define LUA_COMPAT_MOD 344 | 345 | /* 346 | @@ LUA_COMPAT_LSTR controls compatibility with old long string nesting 347 | @* facility. 348 | ** CHANGE it to 2 if you want the old behaviour, or undefine it to turn 349 | ** off the advisory error when nesting [[...]]. 350 | */ 351 | #define LUA_COMPAT_LSTR 1 352 | 353 | /* 354 | @@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. 355 | ** CHANGE it to undefined as soon as you rename 'string.gfind' to 356 | ** 'string.gmatch'. 357 | */ 358 | #define LUA_COMPAT_GFIND 359 | 360 | /* 361 | @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' 362 | @* behavior. 363 | ** CHANGE it to undefined as soon as you replace to 'luaL_register' 364 | ** your uses of 'luaL_openlib' 365 | */ 366 | #define LUA_COMPAT_OPENLIB 367 | 368 | 369 | 370 | /* 371 | @@ luai_apicheck is the assert macro used by the Lua-C API. 372 | ** CHANGE luai_apicheck if you want Lua to perform some checks in the 373 | ** parameters it gets from API calls. This may slow down the interpreter 374 | ** a bit, but may be quite useful when debugging C code that interfaces 375 | ** with Lua. A useful redefinition is to use assert.h. 376 | */ 377 | #if defined(LUA_USE_APICHECK) 378 | #include 379 | #define luai_apicheck(L,o) { (void)L; assert(o); } 380 | #else 381 | #define luai_apicheck(L,o) { (void)L; } 382 | #endif 383 | 384 | 385 | /* 386 | @@ LUAI_BITSINT defines the number of bits in an int. 387 | ** CHANGE here if Lua cannot automatically detect the number of bits of 388 | ** your machine. Probably you do not need to change this. 389 | */ 390 | /* avoid overflows in comparison */ 391 | #if INT_MAX-20 < 32760 392 | #define LUAI_BITSINT 16 393 | #elif INT_MAX > 2147483640L 394 | /* int has at least 32 bits */ 395 | #define LUAI_BITSINT 32 396 | #else 397 | #error "you must define LUA_BITSINT with number of bits in an integer" 398 | #endif 399 | 400 | 401 | /* 402 | @@ LUAI_UINT32 is an unsigned integer with at least 32 bits. 403 | @@ LUAI_INT32 is an signed integer with at least 32 bits. 404 | @@ LUAI_UMEM is an unsigned integer big enough to count the total 405 | @* memory used by Lua. 406 | @@ LUAI_MEM is a signed integer big enough to count the total memory 407 | @* used by Lua. 408 | ** CHANGE here if for some weird reason the default definitions are not 409 | ** good enough for your machine. (The definitions in the 'else' 410 | ** part always works, but may waste space on machines with 64-bit 411 | ** longs.) Probably you do not need to change this. 412 | */ 413 | #if LUAI_BITSINT >= 32 414 | #define LUAI_UINT32 unsigned int 415 | #define LUAI_INT32 int 416 | #define LUAI_MAXINT32 INT_MAX 417 | #define LUAI_UMEM size_t 418 | #define LUAI_MEM ptrdiff_t 419 | #else 420 | /* 16-bit ints */ 421 | #define LUAI_UINT32 unsigned long 422 | #define LUAI_INT32 long 423 | #define LUAI_MAXINT32 LONG_MAX 424 | #define LUAI_UMEM unsigned long 425 | #define LUAI_MEM long 426 | #endif 427 | 428 | 429 | /* 430 | @@ LUAI_MAXCALLS limits the number of nested calls. 431 | ** CHANGE it if you need really deep recursive calls. This limit is 432 | ** arbitrary; its only purpose is to stop infinite recursion before 433 | ** exhausting memory. 434 | */ 435 | #define LUAI_MAXCALLS 20000 436 | 437 | 438 | /* 439 | @@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function 440 | @* can use. 441 | ** CHANGE it if you need lots of (Lua) stack space for your C 442 | ** functions. This limit is arbitrary; its only purpose is to stop C 443 | ** functions to consume unlimited stack space. (must be smaller than 444 | ** -LUA_REGISTRYINDEX) 445 | */ 446 | #define LUAI_MAXCSTACK 8000 447 | 448 | 449 | 450 | /* 451 | ** {================================================================== 452 | ** CHANGE (to smaller values) the following definitions if your system 453 | ** has a small C stack. (Or you may want to change them to larger 454 | ** values if your system has a large C stack and these limits are 455 | ** too rigid for you.) Some of these constants control the size of 456 | ** stack-allocated arrays used by the compiler or the interpreter, while 457 | ** others limit the maximum number of recursive calls that the compiler 458 | ** or the interpreter can perform. Values too large may cause a C stack 459 | ** overflow for some forms of deep constructs. 460 | ** =================================================================== 461 | */ 462 | 463 | 464 | /* 465 | @@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and 466 | @* syntactical nested non-terminals in a program. 467 | */ 468 | #define LUAI_MAXCCALLS 200 469 | 470 | 471 | /* 472 | @@ LUAI_MAXVARS is the maximum number of local variables per function 473 | @* (must be smaller than 250). 474 | */ 475 | #define LUAI_MAXVARS 200 476 | 477 | 478 | /* 479 | @@ LUAI_MAXUPVALUES is the maximum number of upvalues per function 480 | @* (must be smaller than 250). 481 | */ 482 | #define LUAI_MAXUPVALUES 60 483 | 484 | 485 | /* 486 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. 487 | */ 488 | #define LUAL_BUFFERSIZE BUFSIZ 489 | 490 | /* }================================================================== */ 491 | 492 | 493 | 494 | 495 | /* 496 | ** {================================================================== 497 | @@ LUA_NUMBER is the type of numbers in Lua. 498 | ** CHANGE the following definitions only if you want to build Lua 499 | ** with a number type different from double. You may also need to 500 | ** change lua_number2int & lua_number2integer. 501 | ** =================================================================== 502 | */ 503 | 504 | #define LUA_NUMBER_DOUBLE 505 | #define LUA_NUMBER double 506 | 507 | /* 508 | @@ LUAI_UACNUMBER is the result of an 'usual argument conversion' 509 | @* over a number. 510 | */ 511 | #define LUAI_UACNUMBER double 512 | 513 | 514 | /* 515 | @@ LUA_NUMBER_SCAN is the format for reading numbers. 516 | @@ LUA_NUMBER_FMT is the format for writing numbers. 517 | @@ lua_number2str converts a number to a string. 518 | @@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. 519 | @@ lua_str2number converts a string to a number. 520 | */ 521 | #define LUA_NUMBER_SCAN "%lf" 522 | #define LUA_NUMBER_FMT "%.14g" 523 | #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) 524 | #define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ 525 | #define lua_str2number(s,p) strtod((s), (p)) 526 | 527 | 528 | /* 529 | @@ The luai_num* macros define the primitive operations over numbers. 530 | */ 531 | #if defined(LUA_CORE) 532 | #include 533 | #define luai_numadd(a,b) ((a)+(b)) 534 | #define luai_numsub(a,b) ((a)-(b)) 535 | #define luai_nummul(a,b) ((a)*(b)) 536 | #define luai_numdiv(a,b) ((a)/(b)) 537 | #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) 538 | #define luai_numpow(a,b) (pow(a,b)) 539 | #define luai_numunm(a) (-(a)) 540 | #define luai_numeq(a,b) ((a)==(b)) 541 | #define luai_numlt(a,b) ((a)<(b)) 542 | #define luai_numle(a,b) ((a)<=(b)) 543 | #define luai_numisnan(a) (!luai_numeq((a), (a))) 544 | #endif 545 | 546 | 547 | /* 548 | @@ lua_number2int is a macro to convert lua_Number to int. 549 | @@ lua_number2integer is a macro to convert lua_Number to lua_Integer. 550 | ** CHANGE them if you know a faster way to convert a lua_Number to 551 | ** int (with any rounding method and without throwing errors) in your 552 | ** system. In Pentium machines, a naive typecast from double to int 553 | ** in C is extremely slow, so any alternative is worth trying. 554 | */ 555 | 556 | /* On a Pentium, resort to a trick */ 557 | #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ 558 | (defined(__i386) || defined (_M_IX86) || defined(__i386__)) 559 | 560 | /* On a Microsoft compiler, use assembler */ 561 | #if defined(_MSC_VER) 562 | 563 | #define lua_number2int(i,d) __asm fld d __asm fistp i 564 | #define lua_number2integer(i,n) lua_number2int(i, n) 565 | 566 | /* the next trick should work on any Pentium, but sometimes clashes 567 | with a DirectX idiosyncrasy */ 568 | #else 569 | 570 | union luai_Cast { double l_d; long l_l; }; 571 | #define lua_number2int(i,d) \ 572 | { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } 573 | #define lua_number2integer(i,n) lua_number2int(i, n) 574 | 575 | #endif 576 | 577 | 578 | /* this option always works, but may be slow */ 579 | #else 580 | #define lua_number2int(i,d) ((i)=(int)(d)) 581 | #define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) 582 | 583 | #endif 584 | 585 | /* }================================================================== */ 586 | 587 | 588 | /* 589 | @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. 590 | ** CHANGE it if your system requires alignments larger than double. (For 591 | ** instance, if your system supports long doubles and they must be 592 | ** aligned in 16-byte boundaries, then you should add long double in the 593 | ** union.) Probably you do not need to change this. 594 | */ 595 | #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } 596 | 597 | 598 | /* 599 | @@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. 600 | ** CHANGE them if you prefer to use longjmp/setjmp even with C++ 601 | ** or if want/don't to use _longjmp/_setjmp instead of regular 602 | ** longjmp/setjmp. By default, Lua handles errors with exceptions when 603 | ** compiling as C++ code, with _longjmp/_setjmp when asked to use them, 604 | ** and with longjmp/setjmp otherwise. 605 | */ 606 | #if defined(__cplusplus) 607 | /* C++ exceptions */ 608 | #define LUAI_THROW(L,c) throw(c) 609 | #define LUAI_TRY(L,c,a) try { a } catch(...) \ 610 | { if ((c)->status == 0) (c)->status = -1; } 611 | #define luai_jmpbuf int /* dummy variable */ 612 | 613 | #elif defined(LUA_USE_ULONGJMP) 614 | /* in Unix, try _longjmp/_setjmp (more efficient) */ 615 | #define LUAI_THROW(L,c) _longjmp((c)->b, 1) 616 | #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } 617 | #define luai_jmpbuf jmp_buf 618 | 619 | #else 620 | /* default handling with long jumps */ 621 | #define LUAI_THROW(L,c) longjmp((c)->b, 1) 622 | #define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } 623 | #define luai_jmpbuf jmp_buf 624 | 625 | #endif 626 | 627 | 628 | /* 629 | @@ LUA_MAXCAPTURES is the maximum number of captures that a pattern 630 | @* can do during pattern-matching. 631 | ** CHANGE it if you need more captures. This limit is arbitrary. 632 | */ 633 | #define LUA_MAXCAPTURES 32 634 | 635 | 636 | /* 637 | @@ lua_tmpnam is the function that the OS library uses to create a 638 | @* temporary name. 639 | @@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. 640 | ** CHANGE them if you have an alternative to tmpnam (which is considered 641 | ** insecure) or if you want the original tmpnam anyway. By default, Lua 642 | ** uses tmpnam except when POSIX is available, where it uses mkstemp. 643 | */ 644 | #if defined(loslib_c) || defined(luaall_c) 645 | 646 | #if defined(LUA_USE_MKSTEMP) 647 | #include 648 | #define LUA_TMPNAMBUFSIZE 32 649 | #define lua_tmpnam(b,e) { \ 650 | strcpy(b, "/tmp/lua_XXXXXX"); \ 651 | e = mkstemp(b); \ 652 | if (e != -1) close(e); \ 653 | e = (e == -1); } 654 | 655 | #else 656 | #define LUA_TMPNAMBUFSIZE L_tmpnam 657 | #define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } 658 | #endif 659 | 660 | #endif 661 | 662 | 663 | /* 664 | @@ lua_popen spawns a new process connected to the current one through 665 | @* the file streams. 666 | ** CHANGE it if you have a way to implement it in your system. 667 | */ 668 | #if defined(LUA_USE_POPEN) 669 | 670 | #define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) 671 | #define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) 672 | 673 | #elif defined(LUA_WIN) 674 | 675 | #define lua_popen(L,c,m) ((void)L, _popen(c,m)) 676 | #define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) 677 | 678 | #else 679 | 680 | #define lua_popen(L,c,m) ((void)((void)c, m), \ 681 | luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) 682 | #define lua_pclose(L,file) ((void)((void)L, file), 0) 683 | 684 | #endif 685 | 686 | /* 687 | @@ LUA_DL_* define which dynamic-library system Lua should use. 688 | ** CHANGE here if Lua has problems choosing the appropriate 689 | ** dynamic-library system for your platform (either Windows' DLL, Mac's 690 | ** dyld, or Unix's dlopen). If your system is some kind of Unix, there 691 | ** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for 692 | ** it. To use dlopen you also need to adapt the src/Makefile (probably 693 | ** adding -ldl to the linker options), so Lua does not select it 694 | ** automatically. (When you change the makefile to add -ldl, you must 695 | ** also add -DLUA_USE_DLOPEN.) 696 | ** If you do not want any kind of dynamic library, undefine all these 697 | ** options. 698 | ** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. 699 | */ 700 | #if defined(LUA_USE_DLOPEN) 701 | #define LUA_DL_DLOPEN 702 | #endif 703 | 704 | #if defined(LUA_WIN) 705 | #define LUA_DL_DLL 706 | #endif 707 | 708 | 709 | /* 710 | @@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State 711 | @* (the data goes just *before* the lua_State pointer). 712 | ** CHANGE (define) this if you really need that. This value must be 713 | ** a multiple of the maximum alignment required for your machine. 714 | */ 715 | #define LUAI_EXTRASPACE 0 716 | 717 | 718 | /* 719 | @@ luai_userstate* allow user-specific actions on threads. 720 | ** CHANGE them if you defined LUAI_EXTRASPACE and need to do something 721 | ** extra when a thread is created/deleted/resumed/yielded. 722 | */ 723 | #define luai_userstateopen(L) ((void)L) 724 | #define luai_userstateclose(L) ((void)L) 725 | #define luai_userstatethread(L,L1) ((void)L) 726 | #define luai_userstatefree(L) ((void)L) 727 | #define luai_userstateresume(L,n) ((void)L) 728 | #define luai_userstateyield(L,n) ((void)L) 729 | 730 | 731 | /* 732 | @@ LUA_INTFRMLEN is the length modifier for integer conversions 733 | @* in 'string.format'. 734 | @@ LUA_INTFRM_T is the integer type correspoding to the previous length 735 | @* modifier. 736 | ** CHANGE them if your system supports long long or does not support long. 737 | */ 738 | 739 | #if defined(LUA_USELONGLONG) 740 | 741 | #define LUA_INTFRMLEN "ll" 742 | #define LUA_INTFRM_T long long 743 | 744 | #else 745 | 746 | #define LUA_INTFRMLEN "l" 747 | #define LUA_INTFRM_T long 748 | 749 | #endif 750 | 751 | 752 | 753 | /* =================================================================== */ 754 | 755 | /* 756 | ** Local configuration. You can use this space to add your redefinitions 757 | ** without modifying the main part of the file. 758 | */ 759 | 760 | 761 | 762 | #endif 763 | 764 | -------------------------------------------------------------------------------- /contrib/Lua51/include/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* Key to file-handle type */ 15 | #define LUA_FILEHANDLE "FILE*" 16 | 17 | 18 | #define LUA_COLIBNAME "coroutine" 19 | LUALIB_API int (luaopen_base) (lua_State *L); 20 | 21 | #define LUA_TABLIBNAME "table" 22 | LUALIB_API int (luaopen_table) (lua_State *L); 23 | 24 | #define LUA_IOLIBNAME "io" 25 | LUALIB_API int (luaopen_io) (lua_State *L); 26 | 27 | #define LUA_OSLIBNAME "os" 28 | LUALIB_API int (luaopen_os) (lua_State *L); 29 | 30 | #define LUA_STRLIBNAME "string" 31 | LUALIB_API int (luaopen_string) (lua_State *L); 32 | 33 | #define LUA_MATHLIBNAME "math" 34 | LUALIB_API int (luaopen_math) (lua_State *L); 35 | 36 | #define LUA_DBLIBNAME "debug" 37 | LUALIB_API int (luaopen_debug) (lua_State *L); 38 | 39 | #define LUA_LOADLIBNAME "package" 40 | LUALIB_API int (luaopen_package) (lua_State *L); 41 | 42 | 43 | /* open all previous libraries */ 44 | LUALIB_API void (luaL_openlibs) (lua_State *L); 45 | 46 | 47 | 48 | #ifndef lua_assert 49 | #define lua_assert(x) ((void)0) 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /contrib/Lua51/lib/x32/qlua.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swerg/simple-lua-c-dll/29aff73595a967ac899d5452db15740df465d3b6/contrib/Lua51/lib/x32/qlua.lib -------------------------------------------------------------------------------- /contrib/Lua51/lib/x64/qlua.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swerg/simple-lua-c-dll/29aff73595a967ac899d5452db15740df465d3b6/contrib/Lua51/lib/x64/qlua.lib -------------------------------------------------------------------------------- /contrib/Lua53/include/lauxlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lauxlib.h,v 1.131.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Auxiliary functions for building Lua libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lauxlib_h 9 | #define lauxlib_h 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | 18 | 19 | /* extra error code for 'luaL_loadfilex' */ 20 | #define LUA_ERRFILE (LUA_ERRERR+1) 21 | 22 | 23 | /* key, in the registry, for table of loaded modules */ 24 | #define LUA_LOADED_TABLE "_LOADED" 25 | 26 | 27 | /* key, in the registry, for table of preloaded loaders */ 28 | #define LUA_PRELOAD_TABLE "_PRELOAD" 29 | 30 | 31 | typedef struct luaL_Reg { 32 | const char *name; 33 | lua_CFunction func; 34 | } luaL_Reg; 35 | 36 | 37 | #define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number)) 38 | 39 | LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz); 40 | #define luaL_checkversion(L) \ 41 | luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES) 42 | 43 | LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); 44 | LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); 45 | LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); 46 | LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg); 47 | LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg, 48 | size_t *l); 49 | LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg, 50 | const char *def, size_t *l); 51 | LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg); 52 | LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def); 53 | 54 | LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg); 55 | LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg, 56 | lua_Integer def); 57 | 58 | LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); 59 | LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t); 60 | LUALIB_API void (luaL_checkany) (lua_State *L, int arg); 61 | 62 | LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); 63 | LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); 64 | LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); 65 | LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); 66 | 67 | LUALIB_API void (luaL_where) (lua_State *L, int lvl); 68 | LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); 69 | 70 | LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def, 71 | const char *const lst[]); 72 | 73 | LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); 74 | LUALIB_API int (luaL_execresult) (lua_State *L, int stat); 75 | 76 | /* predefined references */ 77 | #define LUA_NOREF (-2) 78 | #define LUA_REFNIL (-1) 79 | 80 | LUALIB_API int (luaL_ref) (lua_State *L, int t); 81 | LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); 82 | 83 | LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, 84 | const char *mode); 85 | 86 | #define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) 87 | 88 | LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, 89 | const char *name, const char *mode); 90 | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); 91 | 92 | LUALIB_API lua_State *(luaL_newstate) (void); 93 | 94 | LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); 95 | 96 | LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, 97 | const char *r); 98 | 99 | LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); 100 | 101 | LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); 102 | 103 | LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, 104 | const char *msg, int level); 105 | 106 | LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, 107 | lua_CFunction openf, int glb); 108 | 109 | /* 110 | ** =============================================================== 111 | ** some useful macros 112 | ** =============================================================== 113 | */ 114 | 115 | 116 | #define luaL_newlibtable(L,l) \ 117 | lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) 118 | 119 | #define luaL_newlib(L,l) \ 120 | (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) 121 | 122 | #define luaL_argcheck(L, cond,arg,extramsg) \ 123 | ((void)((cond) || luaL_argerror(L, (arg), (extramsg)))) 124 | #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) 125 | #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) 126 | 127 | #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) 128 | 129 | #define luaL_dofile(L, fn) \ 130 | (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) 131 | 132 | #define luaL_dostring(L, s) \ 133 | (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) 134 | 135 | #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) 136 | 137 | #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) 138 | 139 | #define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) 140 | 141 | 142 | /* 143 | ** {====================================================== 144 | ** Generic Buffer manipulation 145 | ** ======================================================= 146 | */ 147 | 148 | typedef struct luaL_Buffer { 149 | char *b; /* buffer address */ 150 | size_t size; /* buffer size */ 151 | size_t n; /* number of characters in buffer */ 152 | lua_State *L; 153 | char initb[LUAL_BUFFERSIZE]; /* initial buffer */ 154 | } luaL_Buffer; 155 | 156 | 157 | #define luaL_addchar(B,c) \ 158 | ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ 159 | ((B)->b[(B)->n++] = (c))) 160 | 161 | #define luaL_addsize(B,s) ((B)->n += (s)) 162 | 163 | LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); 164 | LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); 165 | LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); 166 | LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); 167 | LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); 168 | LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); 169 | LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); 170 | LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); 171 | 172 | #define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) 173 | 174 | /* }====================================================== */ 175 | 176 | 177 | 178 | /* 179 | ** {====================================================== 180 | ** File handles for IO library 181 | ** ======================================================= 182 | */ 183 | 184 | /* 185 | ** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and 186 | ** initial structure 'luaL_Stream' (it may contain other fields 187 | ** after that initial structure). 188 | */ 189 | 190 | #define LUA_FILEHANDLE "FILE*" 191 | 192 | 193 | typedef struct luaL_Stream { 194 | FILE *f; /* stream (NULL for incompletely created streams) */ 195 | lua_CFunction closef; /* to close stream (NULL for closed streams) */ 196 | } luaL_Stream; 197 | 198 | /* }====================================================== */ 199 | 200 | 201 | 202 | /* compatibility with old module system */ 203 | #if defined(LUA_COMPAT_MODULE) 204 | 205 | LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, 206 | int sizehint); 207 | LUALIB_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 | /* 216 | ** {================================================================== 217 | ** "Abstraction Layer" for basic report of messages and errors 218 | ** =================================================================== 219 | */ 220 | 221 | /* print a string */ 222 | #if !defined(lua_writestring) 223 | #define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) 224 | #endif 225 | 226 | /* print a newline and flush the output */ 227 | #if !defined(lua_writeline) 228 | #define lua_writeline() (lua_writestring("\n", 1), fflush(stdout)) 229 | #endif 230 | 231 | /* print an error message */ 232 | #if !defined(lua_writestringerror) 233 | #define lua_writestringerror(s,p) \ 234 | (fprintf(stderr, (s), (p)), fflush(stderr)) 235 | #endif 236 | 237 | /* }================================================================== */ 238 | 239 | 240 | /* 241 | ** {============================================================ 242 | ** Compatibility with deprecated conversions 243 | ** ============================================================= 244 | */ 245 | #if defined(LUA_COMPAT_APIINTCASTS) 246 | 247 | #define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a)) 248 | #define luaL_optunsigned(L,a,d) \ 249 | ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d))) 250 | 251 | #define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) 252 | #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) 253 | 254 | #define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) 255 | #define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) 256 | 257 | #endif 258 | /* }============================================================ */ 259 | 260 | 261 | 262 | #endif 263 | 264 | 265 | -------------------------------------------------------------------------------- /contrib/Lua53/include/lua.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lua.h,v 1.332.1.2 2018/06/13 16:58:17 roberto Exp $ 3 | ** Lua - A Scripting Language 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 5 | ** See Copyright Notice at the end of this file 6 | */ 7 | 8 | 9 | #ifndef lua_h 10 | #define lua_h 11 | 12 | #include 13 | #include 14 | 15 | 16 | #include "luaconf.h" 17 | 18 | 19 | #define LUA_VERSION_MAJOR "5" 20 | #define LUA_VERSION_MINOR "3" 21 | #define LUA_VERSION_NUM 503 22 | #define LUA_VERSION_RELEASE "5" 23 | 24 | #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR 25 | #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE 26 | #define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2018 Lua.org, PUC-Rio" 27 | #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" 28 | 29 | 30 | /* mark for precompiled code ('Lua') */ 31 | #define LUA_SIGNATURE "\x1bLua" 32 | 33 | /* option for multiple returns in 'lua_pcall' and 'lua_call' */ 34 | #define LUA_MULTRET (-1) 35 | 36 | 37 | /* 38 | ** Pseudo-indices 39 | ** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty 40 | ** space after that to help overflow detection) 41 | */ 42 | #define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000) 43 | #define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) 44 | 45 | 46 | /* thread status */ 47 | #define LUA_OK 0 48 | #define LUA_YIELD 1 49 | #define LUA_ERRRUN 2 50 | #define LUA_ERRSYNTAX 3 51 | #define LUA_ERRMEM 4 52 | #define LUA_ERRGCMM 5 53 | #define LUA_ERRERR 6 54 | 55 | 56 | typedef struct lua_State lua_State; 57 | 58 | 59 | /* 60 | ** basic types 61 | */ 62 | #define LUA_TNONE (-1) 63 | 64 | #define LUA_TNIL 0 65 | #define LUA_TBOOLEAN 1 66 | #define LUA_TLIGHTUSERDATA 2 67 | #define LUA_TNUMBER 3 68 | #define LUA_TSTRING 4 69 | #define LUA_TTABLE 5 70 | #define LUA_TFUNCTION 6 71 | #define LUA_TUSERDATA 7 72 | #define LUA_TTHREAD 8 73 | 74 | #define LUA_NUMTAGS 9 75 | 76 | 77 | 78 | /* minimum Lua stack available to a C function */ 79 | #define LUA_MINSTACK 20 80 | 81 | 82 | /* predefined values in the registry */ 83 | #define LUA_RIDX_MAINTHREAD 1 84 | #define LUA_RIDX_GLOBALS 2 85 | #define LUA_RIDX_LAST LUA_RIDX_GLOBALS 86 | 87 | 88 | /* type of numbers in Lua */ 89 | typedef LUA_NUMBER lua_Number; 90 | 91 | 92 | /* type for integer functions */ 93 | typedef LUA_INTEGER lua_Integer; 94 | 95 | /* unsigned integer type */ 96 | typedef LUA_UNSIGNED lua_Unsigned; 97 | 98 | /* type for continuation-function contexts */ 99 | typedef LUA_KCONTEXT lua_KContext; 100 | 101 | 102 | /* 103 | ** Type for C functions registered with Lua 104 | */ 105 | typedef int (*lua_CFunction) (lua_State *L); 106 | 107 | /* 108 | ** Type for continuation functions 109 | */ 110 | typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); 111 | 112 | 113 | /* 114 | ** Type for functions that read/write blocks when loading/dumping Lua chunks 115 | */ 116 | typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); 117 | 118 | typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud); 119 | 120 | 121 | /* 122 | ** Type for memory-allocation functions 123 | */ 124 | typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); 125 | 126 | 127 | 128 | /* 129 | ** generic extra include file 130 | */ 131 | #if defined(LUA_USER_H) 132 | #include LUA_USER_H 133 | #endif 134 | 135 | 136 | /* 137 | ** RCS ident string 138 | */ 139 | extern const char lua_ident[]; 140 | 141 | 142 | /* 143 | ** state manipulation 144 | */ 145 | LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); 146 | LUA_API void (lua_close) (lua_State *L); 147 | LUA_API lua_State *(lua_newthread) (lua_State *L); 148 | 149 | LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); 150 | 151 | 152 | LUA_API const lua_Number *(lua_version) (lua_State *L); 153 | 154 | 155 | /* 156 | ** basic stack manipulation 157 | */ 158 | LUA_API int (lua_absindex) (lua_State *L, int idx); 159 | LUA_API int (lua_gettop) (lua_State *L); 160 | LUA_API void (lua_settop) (lua_State *L, int idx); 161 | LUA_API void (lua_pushvalue) (lua_State *L, int idx); 162 | LUA_API void (lua_rotate) (lua_State *L, int idx, int n); 163 | LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); 164 | LUA_API int (lua_checkstack) (lua_State *L, int n); 165 | 166 | LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); 167 | 168 | 169 | /* 170 | ** access functions (stack -> C) 171 | */ 172 | 173 | LUA_API int (lua_isnumber) (lua_State *L, int idx); 174 | LUA_API int (lua_isstring) (lua_State *L, int idx); 175 | LUA_API int (lua_iscfunction) (lua_State *L, int idx); 176 | LUA_API int (lua_isinteger) (lua_State *L, int idx); 177 | LUA_API int (lua_isuserdata) (lua_State *L, int idx); 178 | LUA_API int (lua_type) (lua_State *L, int idx); 179 | LUA_API const char *(lua_typename) (lua_State *L, int tp); 180 | 181 | LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); 182 | LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); 183 | LUA_API int (lua_toboolean) (lua_State *L, int idx); 184 | LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); 185 | LUA_API size_t (lua_rawlen) (lua_State *L, int idx); 186 | LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); 187 | LUA_API void *(lua_touserdata) (lua_State *L, int idx); 188 | LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); 189 | LUA_API const void *(lua_topointer) (lua_State *L, int idx); 190 | 191 | 192 | /* 193 | ** Comparison and arithmetic functions 194 | */ 195 | 196 | #define LUA_OPADD 0 /* ORDER TM, ORDER OP */ 197 | #define LUA_OPSUB 1 198 | #define LUA_OPMUL 2 199 | #define LUA_OPMOD 3 200 | #define LUA_OPPOW 4 201 | #define LUA_OPDIV 5 202 | #define LUA_OPIDIV 6 203 | #define LUA_OPBAND 7 204 | #define LUA_OPBOR 8 205 | #define LUA_OPBXOR 9 206 | #define LUA_OPSHL 10 207 | #define LUA_OPSHR 11 208 | #define LUA_OPUNM 12 209 | #define LUA_OPBNOT 13 210 | 211 | LUA_API void (lua_arith) (lua_State *L, int op); 212 | 213 | #define LUA_OPEQ 0 214 | #define LUA_OPLT 1 215 | #define LUA_OPLE 2 216 | 217 | LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); 218 | LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); 219 | 220 | 221 | /* 222 | ** push functions (C -> stack) 223 | */ 224 | LUA_API void (lua_pushnil) (lua_State *L); 225 | LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); 226 | LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); 227 | LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len); 228 | LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); 229 | LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, 230 | va_list argp); 231 | LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); 232 | LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); 233 | LUA_API void (lua_pushboolean) (lua_State *L, int b); 234 | LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); 235 | LUA_API int (lua_pushthread) (lua_State *L); 236 | 237 | 238 | /* 239 | ** get functions (Lua -> stack) 240 | */ 241 | LUA_API int (lua_getglobal) (lua_State *L, const char *name); 242 | LUA_API int (lua_gettable) (lua_State *L, int idx); 243 | LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k); 244 | LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n); 245 | LUA_API int (lua_rawget) (lua_State *L, int idx); 246 | LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n); 247 | LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p); 248 | 249 | LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); 250 | LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); 251 | LUA_API int (lua_getmetatable) (lua_State *L, int objindex); 252 | LUA_API int (lua_getuservalue) (lua_State *L, int idx); 253 | 254 | 255 | /* 256 | ** set functions (stack -> Lua) 257 | */ 258 | LUA_API void (lua_setglobal) (lua_State *L, const char *name); 259 | LUA_API void (lua_settable) (lua_State *L, int idx); 260 | LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); 261 | LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n); 262 | LUA_API void (lua_rawset) (lua_State *L, int idx); 263 | LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n); 264 | LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); 265 | LUA_API int (lua_setmetatable) (lua_State *L, int objindex); 266 | LUA_API void (lua_setuservalue) (lua_State *L, int idx); 267 | 268 | 269 | /* 270 | ** 'load' and 'call' functions (load and run Lua code) 271 | */ 272 | LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, 273 | lua_KContext ctx, lua_KFunction k); 274 | #define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) 275 | 276 | LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, 277 | lua_KContext ctx, lua_KFunction k); 278 | #define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) 279 | 280 | LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, 281 | const char *chunkname, const char *mode); 282 | 283 | LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip); 284 | 285 | 286 | /* 287 | ** coroutine functions 288 | */ 289 | LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx, 290 | lua_KFunction k); 291 | LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg); 292 | LUA_API int (lua_status) (lua_State *L); 293 | LUA_API int (lua_isyieldable) (lua_State *L); 294 | 295 | #define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) 296 | 297 | 298 | /* 299 | ** garbage-collection function and options 300 | */ 301 | 302 | #define LUA_GCSTOP 0 303 | #define LUA_GCRESTART 1 304 | #define LUA_GCCOLLECT 2 305 | #define LUA_GCCOUNT 3 306 | #define LUA_GCCOUNTB 4 307 | #define LUA_GCSTEP 5 308 | #define LUA_GCSETPAUSE 6 309 | #define LUA_GCSETSTEPMUL 7 310 | #define LUA_GCISRUNNING 9 311 | 312 | LUA_API int (lua_gc) (lua_State *L, int what, int data); 313 | 314 | 315 | /* 316 | ** miscellaneous functions 317 | */ 318 | 319 | LUA_API int (lua_error) (lua_State *L); 320 | 321 | LUA_API int (lua_next) (lua_State *L, int idx); 322 | 323 | LUA_API void (lua_concat) (lua_State *L, int n); 324 | LUA_API void (lua_len) (lua_State *L, int idx); 325 | 326 | LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s); 327 | 328 | LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); 329 | LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); 330 | 331 | 332 | 333 | /* 334 | ** {============================================================== 335 | ** some useful macros 336 | ** =============================================================== 337 | */ 338 | 339 | #define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE)) 340 | 341 | #define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) 342 | #define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) 343 | 344 | #define lua_pop(L,n) lua_settop(L, -(n)-1) 345 | 346 | #define lua_newtable(L) lua_createtable(L, 0, 0) 347 | 348 | #define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) 349 | 350 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) 351 | 352 | #define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) 353 | #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) 354 | #define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) 355 | #define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) 356 | #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) 357 | #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) 358 | #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) 359 | #define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) 360 | 361 | #define lua_pushliteral(L, s) lua_pushstring(L, "" s) 362 | 363 | #define lua_pushglobaltable(L) \ 364 | ((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)) 365 | 366 | #define lua_tostring(L,i) lua_tolstring(L, (i), NULL) 367 | 368 | 369 | #define lua_insert(L,idx) lua_rotate(L, (idx), 1) 370 | 371 | #define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1)) 372 | 373 | #define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1)) 374 | 375 | /* }============================================================== */ 376 | 377 | 378 | /* 379 | ** {============================================================== 380 | ** compatibility macros for unsigned conversions 381 | ** =============================================================== 382 | */ 383 | #if defined(LUA_COMPAT_APIINTCASTS) 384 | 385 | #define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) 386 | #define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is)) 387 | #define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) 388 | 389 | #endif 390 | /* }============================================================== */ 391 | 392 | /* 393 | ** {====================================================================== 394 | ** Debug API 395 | ** ======================================================================= 396 | */ 397 | 398 | 399 | /* 400 | ** Event codes 401 | */ 402 | #define LUA_HOOKCALL 0 403 | #define LUA_HOOKRET 1 404 | #define LUA_HOOKLINE 2 405 | #define LUA_HOOKCOUNT 3 406 | #define LUA_HOOKTAILCALL 4 407 | 408 | 409 | /* 410 | ** Event masks 411 | */ 412 | #define LUA_MASKCALL (1 << LUA_HOOKCALL) 413 | #define LUA_MASKRET (1 << LUA_HOOKRET) 414 | #define LUA_MASKLINE (1 << LUA_HOOKLINE) 415 | #define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) 416 | 417 | typedef struct lua_Debug lua_Debug; /* activation record */ 418 | 419 | 420 | /* Functions to be called by the debugger in specific events */ 421 | typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); 422 | 423 | 424 | LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); 425 | LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); 426 | LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n); 427 | LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n); 428 | LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n); 429 | LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n); 430 | 431 | LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); 432 | LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, 433 | int fidx2, int n2); 434 | 435 | LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); 436 | LUA_API lua_Hook (lua_gethook) (lua_State *L); 437 | LUA_API int (lua_gethookmask) (lua_State *L); 438 | LUA_API int (lua_gethookcount) (lua_State *L); 439 | 440 | 441 | struct lua_Debug { 442 | int event; 443 | const char *name; /* (n) */ 444 | const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */ 445 | const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */ 446 | const char *source; /* (S) */ 447 | int currentline; /* (l) */ 448 | int linedefined; /* (S) */ 449 | int lastlinedefined; /* (S) */ 450 | unsigned char nups; /* (u) number of upvalues */ 451 | unsigned char nparams;/* (u) number of parameters */ 452 | char isvararg; /* (u) */ 453 | char istailcall; /* (t) */ 454 | char short_src[LUA_IDSIZE]; /* (S) */ 455 | /* private part */ 456 | struct CallInfo *i_ci; /* active function */ 457 | }; 458 | 459 | /* }====================================================================== */ 460 | 461 | 462 | /****************************************************************************** 463 | * Copyright (C) 1994-2018 Lua.org, PUC-Rio. 464 | * 465 | * Permission is hereby granted, free of charge, to any person obtaining 466 | * a copy of this software and associated documentation files (the 467 | * "Software"), to deal in the Software without restriction, including 468 | * without limitation the rights to use, copy, modify, merge, publish, 469 | * distribute, sublicense, and/or sell copies of the Software, and to 470 | * permit persons to whom the Software is furnished to do so, subject to 471 | * the following conditions: 472 | * 473 | * The above copyright notice and this permission notice shall be 474 | * included in all copies or substantial portions of the Software. 475 | * 476 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 477 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 478 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 479 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 480 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 481 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 482 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 483 | ******************************************************************************/ 484 | 485 | 486 | #endif 487 | -------------------------------------------------------------------------------- /contrib/Lua53/include/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /contrib/Lua53/include/luaconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: luaconf.h,v 1.259.1.1 2017/04/19 17:29:57 roberto Exp $ 3 | ** Configuration file for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef luaconf_h 9 | #define luaconf_h 10 | 11 | #include 12 | #include 13 | 14 | 15 | /* 16 | ** =================================================================== 17 | ** Search for "@@" to find all configurable definitions. 18 | ** =================================================================== 19 | */ 20 | 21 | 22 | /* 23 | ** {==================================================================== 24 | ** System Configuration: macros to adapt (if needed) Lua to some 25 | ** particular platform, for instance compiling it with 32-bit numbers or 26 | ** restricting it to C89. 27 | ** ===================================================================== 28 | */ 29 | 30 | /* 31 | @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You 32 | ** can also define LUA_32BITS in the make file, but changing here you 33 | ** ensure that all software connected to Lua will be compiled with the 34 | ** same configuration. 35 | */ 36 | /* #define LUA_32BITS */ 37 | 38 | 39 | /* 40 | @@ LUA_USE_C89 controls the use of non-ISO-C89 features. 41 | ** Define it if you want Lua to avoid the use of a few C99 features 42 | ** or Windows-specific features on Windows. 43 | */ 44 | /* #define LUA_USE_C89 */ 45 | 46 | 47 | /* 48 | ** By default, Lua on Windows use (some) specific Windows features 49 | */ 50 | #if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE) 51 | #define LUA_USE_WINDOWS /* enable goodies for regular Windows */ 52 | #endif 53 | 54 | 55 | #if defined(LUA_USE_WINDOWS) 56 | #define LUA_DL_DLL /* enable support for DLL */ 57 | #define LUA_USE_C89 /* broadly, Windows is C89 */ 58 | #endif 59 | 60 | 61 | #if defined(LUA_USE_LINUX) 62 | #define LUA_USE_POSIX 63 | #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ 64 | #define LUA_USE_READLINE /* needs some extra libraries */ 65 | #endif 66 | 67 | 68 | #if defined(LUA_USE_MACOSX) 69 | #define LUA_USE_POSIX 70 | #define LUA_USE_DLOPEN /* MacOS does not need -ldl */ 71 | #define LUA_USE_READLINE /* needs an extra library: -lreadline */ 72 | #endif 73 | 74 | 75 | /* 76 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for 77 | ** C89 ('long' and 'double'); Windows always has '__int64', so it does 78 | ** not need to use this case. 79 | */ 80 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) 81 | #define LUA_C89_NUMBERS 82 | #endif 83 | 84 | 85 | 86 | /* 87 | @@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. 88 | */ 89 | /* avoid undefined shifts */ 90 | #if ((INT_MAX >> 15) >> 15) >= 1 91 | #define LUAI_BITSINT 32 92 | #else 93 | /* 'int' always must have at least 16 bits */ 94 | #define LUAI_BITSINT 16 95 | #endif 96 | 97 | 98 | /* 99 | @@ LUA_INT_TYPE defines the type for Lua integers. 100 | @@ LUA_FLOAT_TYPE defines the type for Lua floats. 101 | ** Lua should work fine with any mix of these options (if supported 102 | ** by your C compiler). The usual configurations are 64-bit integers 103 | ** and 'double' (the default), 32-bit integers and 'float' (for 104 | ** restricted platforms), and 'long'/'double' (for C compilers not 105 | ** compliant with C99, which may not have support for 'long long'). 106 | */ 107 | 108 | /* predefined options for LUA_INT_TYPE */ 109 | #define LUA_INT_INT 1 110 | #define LUA_INT_LONG 2 111 | #define LUA_INT_LONGLONG 3 112 | 113 | /* predefined options for LUA_FLOAT_TYPE */ 114 | #define LUA_FLOAT_FLOAT 1 115 | #define LUA_FLOAT_DOUBLE 2 116 | #define LUA_FLOAT_LONGDOUBLE 3 117 | 118 | #if defined(LUA_32BITS) /* { */ 119 | /* 120 | ** 32-bit integers and 'float' 121 | */ 122 | #if LUAI_BITSINT >= 32 /* use 'int' if big enough */ 123 | #define LUA_INT_TYPE LUA_INT_INT 124 | #else /* otherwise use 'long' */ 125 | #define LUA_INT_TYPE LUA_INT_LONG 126 | #endif 127 | #define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT 128 | 129 | #elif defined(LUA_C89_NUMBERS) /* }{ */ 130 | /* 131 | ** largest types available for C89 ('long' and 'double') 132 | */ 133 | #define LUA_INT_TYPE LUA_INT_LONG 134 | #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE 135 | 136 | #endif /* } */ 137 | 138 | 139 | /* 140 | ** default configuration for 64-bit Lua ('long long' and 'double') 141 | */ 142 | #if !defined(LUA_INT_TYPE) 143 | #define LUA_INT_TYPE LUA_INT_LONGLONG 144 | #endif 145 | 146 | #if !defined(LUA_FLOAT_TYPE) 147 | #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE 148 | #endif 149 | 150 | /* }================================================================== */ 151 | 152 | 153 | 154 | 155 | /* 156 | ** {================================================================== 157 | ** Configuration for Paths. 158 | ** =================================================================== 159 | */ 160 | 161 | /* 162 | ** LUA_PATH_SEP is the character that separates templates in a path. 163 | ** LUA_PATH_MARK is the string that marks the substitution points in a 164 | ** template. 165 | ** LUA_EXEC_DIR in a Windows path is replaced by the executable's 166 | ** directory. 167 | */ 168 | #define LUA_PATH_SEP ";" 169 | #define LUA_PATH_MARK "?" 170 | #define LUA_EXEC_DIR "!" 171 | 172 | 173 | /* 174 | @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for 175 | ** Lua libraries. 176 | @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for 177 | ** C libraries. 178 | ** CHANGE them if your machine has a non-conventional directory 179 | ** hierarchy or if you want to install your libraries in 180 | ** non-conventional directories. 181 | */ 182 | #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR 183 | #if defined(_WIN32) /* { */ 184 | /* 185 | ** In Windows, any exclamation mark ('!') in the path is replaced by the 186 | ** path of the directory of the executable file of the current process. 187 | */ 188 | #define LUA_LDIR "!\\lua\\" 189 | #define LUA_CDIR "!\\" 190 | #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" 191 | #define LUA_PATH_DEFAULT \ 192 | LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ 193 | LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ 194 | LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ 195 | ".\\?.lua;" ".\\?\\init.lua" 196 | #define LUA_CPATH_DEFAULT \ 197 | LUA_CDIR"?.dll;" \ 198 | LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ 199 | LUA_CDIR"loadall.dll;" ".\\?.dll;" \ 200 | LUA_CDIR"?53.dll;" ".\\?53.dll" 201 | 202 | #else /* }{ */ 203 | 204 | #define LUA_ROOT "/usr/local/" 205 | #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" 206 | #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" 207 | #define LUA_PATH_DEFAULT \ 208 | LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ 209 | LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ 210 | "./?.lua;" "./?/init.lua" 211 | #define LUA_CPATH_DEFAULT \ 212 | LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so;" \ 213 | LUA_CDIR"lib?53.so;" "./lib?53.so" 214 | #endif /* } */ 215 | 216 | 217 | /* 218 | @@ LUA_DIRSEP is the directory separator (for submodules). 219 | ** CHANGE it if your machine does not use "/" as the directory separator 220 | ** and is not Windows. (On Windows Lua automatically uses "\".) 221 | */ 222 | #if defined(_WIN32) 223 | #define LUA_DIRSEP "\\" 224 | #else 225 | #define LUA_DIRSEP "/" 226 | #endif 227 | 228 | /* }================================================================== */ 229 | 230 | 231 | /* 232 | ** {================================================================== 233 | ** Marks for exported symbols in the C code 234 | ** =================================================================== 235 | */ 236 | 237 | /* 238 | @@ LUA_API is a mark for all core API functions. 239 | @@ LUALIB_API is a mark for all auxiliary library functions. 240 | @@ LUAMOD_API is a mark for all standard library opening functions. 241 | ** CHANGE them if you need to define those functions in some special way. 242 | ** For instance, if you want to create one Windows DLL with the core and 243 | ** the libraries, you may want to use the following definition (define 244 | ** LUA_BUILD_AS_DLL to get it). 245 | */ 246 | #if defined(LUA_BUILD_AS_DLL) /* { */ 247 | 248 | #if defined(LUA_CORE) || defined(LUA_LIB) /* { */ 249 | #define LUA_API __declspec(dllexport) 250 | #else /* }{ */ 251 | #define LUA_API __declspec(dllimport) 252 | #endif /* } */ 253 | 254 | #else /* }{ */ 255 | 256 | #define LUA_API extern 257 | 258 | #endif /* } */ 259 | 260 | 261 | /* more often than not the libs go together with the core */ 262 | #define LUALIB_API LUA_API 263 | #define LUAMOD_API LUALIB_API 264 | 265 | 266 | /* 267 | @@ LUAI_FUNC is a mark for all extern functions that are not to be 268 | ** exported to outside modules. 269 | @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables 270 | ** that are not to be exported to outside modules (LUAI_DDEF for 271 | ** definitions and LUAI_DDEC for declarations). 272 | ** CHANGE them if you need to mark them in some special way. Elf/gcc 273 | ** (versions 3.2 and later) mark them as "hidden" to optimize access 274 | ** when Lua is compiled as a shared library. Not all elf targets support 275 | ** this attribute. Unfortunately, gcc does not offer a way to check 276 | ** whether the target offers that support, and those without support 277 | ** give a warning about it. To avoid these warnings, change to the 278 | ** default definition. 279 | */ 280 | #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ 281 | defined(__ELF__) /* { */ 282 | #define LUAI_FUNC __attribute__((visibility("hidden"))) extern 283 | #else /* }{ */ 284 | #define LUAI_FUNC extern 285 | #endif /* } */ 286 | 287 | #define LUAI_DDEC LUAI_FUNC 288 | #define LUAI_DDEF /* empty */ 289 | 290 | /* }================================================================== */ 291 | 292 | 293 | /* 294 | ** {================================================================== 295 | ** Compatibility with previous versions 296 | ** =================================================================== 297 | */ 298 | 299 | /* 300 | @@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2. 301 | @@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1. 302 | ** You can define it to get all options, or change specific options 303 | ** to fit your specific needs. 304 | */ 305 | #if defined(LUA_COMPAT_5_2) /* { */ 306 | 307 | /* 308 | @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated 309 | ** functions in the mathematical library. 310 | */ 311 | #define LUA_COMPAT_MATHLIB 312 | 313 | /* 314 | @@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. 315 | */ 316 | #define LUA_COMPAT_BITLIB 317 | 318 | /* 319 | @@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod. 320 | */ 321 | #define LUA_COMPAT_IPAIRS 322 | 323 | /* 324 | @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for 325 | ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, 326 | ** luaL_checkint, luaL_checklong, etc.) 327 | */ 328 | #define LUA_COMPAT_APIINTCASTS 329 | 330 | #endif /* } */ 331 | 332 | 333 | #if defined(LUA_COMPAT_5_1) /* { */ 334 | 335 | /* Incompatibilities from 5.2 -> 5.3 */ 336 | #define LUA_COMPAT_MATHLIB 337 | #define LUA_COMPAT_APIINTCASTS 338 | 339 | /* 340 | @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. 341 | ** You can replace it with 'table.unpack'. 342 | */ 343 | #define LUA_COMPAT_UNPACK 344 | 345 | /* 346 | @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. 347 | ** You can replace it with 'package.searchers'. 348 | */ 349 | #define LUA_COMPAT_LOADERS 350 | 351 | /* 352 | @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. 353 | ** You can call your C function directly (with light C functions). 354 | */ 355 | #define lua_cpcall(L,f,u) \ 356 | (lua_pushcfunction(L, (f)), \ 357 | lua_pushlightuserdata(L,(u)), \ 358 | lua_pcall(L,1,0,0)) 359 | 360 | 361 | /* 362 | @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. 363 | ** You can rewrite 'log10(x)' as 'log(x, 10)'. 364 | */ 365 | #define LUA_COMPAT_LOG10 366 | 367 | /* 368 | @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base 369 | ** library. You can rewrite 'loadstring(s)' as 'load(s)'. 370 | */ 371 | #define LUA_COMPAT_LOADSTRING 372 | 373 | /* 374 | @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. 375 | */ 376 | #define LUA_COMPAT_MAXN 377 | 378 | /* 379 | @@ The following macros supply trivial compatibility for some 380 | ** changes in the API. The macros themselves document how to 381 | ** change your code to avoid using them. 382 | */ 383 | #define lua_strlen(L,i) lua_rawlen(L, (i)) 384 | 385 | #define lua_objlen(L,i) lua_rawlen(L, (i)) 386 | 387 | #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) 388 | #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) 389 | 390 | /* 391 | @@ LUA_COMPAT_MODULE controls compatibility with previous 392 | ** module functions 'module' (Lua) and 'luaL_register' (C). 393 | */ 394 | #define LUA_COMPAT_MODULE 395 | 396 | #endif /* } */ 397 | 398 | 399 | /* 400 | @@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a 401 | @@ a float mark ('.0'). 402 | ** This macro is not on by default even in compatibility mode, 403 | ** because this is not really an incompatibility. 404 | */ 405 | /* #define LUA_COMPAT_FLOATSTRING */ 406 | 407 | /* }================================================================== */ 408 | 409 | 410 | 411 | /* 412 | ** {================================================================== 413 | ** Configuration for Numbers. 414 | ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* 415 | ** satisfy your needs. 416 | ** =================================================================== 417 | */ 418 | 419 | /* 420 | @@ LUA_NUMBER is the floating-point type used by Lua. 421 | @@ LUAI_UACNUMBER is the result of a 'default argument promotion' 422 | @@ over a floating number. 423 | @@ l_mathlim(x) corrects limit name 'x' to the proper float type 424 | ** by prefixing it with one of FLT/DBL/LDBL. 425 | @@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. 426 | @@ LUA_NUMBER_FMT is the format for writing floats. 427 | @@ lua_number2str converts a float to a string. 428 | @@ l_mathop allows the addition of an 'l' or 'f' to all math operations. 429 | @@ l_floor takes the floor of a float. 430 | @@ lua_str2number converts a decimal numeric string to a number. 431 | */ 432 | 433 | 434 | /* The following definitions are good for most cases here */ 435 | 436 | #define l_floor(x) (l_mathop(floor)(x)) 437 | 438 | #define lua_number2str(s,sz,n) \ 439 | l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n)) 440 | 441 | /* 442 | @@ lua_numbertointeger converts a float number to an integer, or 443 | ** returns 0 if float is not within the range of a lua_Integer. 444 | ** (The range comparisons are tricky because of rounding. The tests 445 | ** here assume a two-complement representation, where MININTEGER always 446 | ** has an exact representation as a float; MAXINTEGER may not have one, 447 | ** and therefore its conversion to float may have an ill-defined value.) 448 | */ 449 | #define lua_numbertointeger(n,p) \ 450 | ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ 451 | (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ 452 | (*(p) = (LUA_INTEGER)(n), 1)) 453 | 454 | 455 | /* now the variable definitions */ 456 | 457 | #if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ 458 | 459 | #define LUA_NUMBER float 460 | 461 | #define l_mathlim(n) (FLT_##n) 462 | 463 | #define LUAI_UACNUMBER double 464 | 465 | #define LUA_NUMBER_FRMLEN "" 466 | #define LUA_NUMBER_FMT "%.7g" 467 | 468 | #define l_mathop(op) op##f 469 | 470 | #define lua_str2number(s,p) strtof((s), (p)) 471 | 472 | 473 | #elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */ 474 | 475 | #define LUA_NUMBER long double 476 | 477 | #define l_mathlim(n) (LDBL_##n) 478 | 479 | #define LUAI_UACNUMBER long double 480 | 481 | #define LUA_NUMBER_FRMLEN "L" 482 | #define LUA_NUMBER_FMT "%.19Lg" 483 | 484 | #define l_mathop(op) op##l 485 | 486 | #define lua_str2number(s,p) strtold((s), (p)) 487 | 488 | #elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */ 489 | 490 | #define LUA_NUMBER double 491 | 492 | #define l_mathlim(n) (DBL_##n) 493 | 494 | #define LUAI_UACNUMBER double 495 | 496 | #define LUA_NUMBER_FRMLEN "" 497 | #define LUA_NUMBER_FMT "%.14g" 498 | 499 | #define l_mathop(op) op 500 | 501 | #define lua_str2number(s,p) strtod((s), (p)) 502 | 503 | #else /* }{ */ 504 | 505 | #error "numeric float type not defined" 506 | 507 | #endif /* } */ 508 | 509 | 510 | 511 | /* 512 | @@ LUA_INTEGER is the integer type used by Lua. 513 | ** 514 | @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. 515 | ** 516 | @@ LUAI_UACINT is the result of a 'default argument promotion' 517 | @@ over a lUA_INTEGER. 518 | @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. 519 | @@ LUA_INTEGER_FMT is the format for writing integers. 520 | @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. 521 | @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. 522 | @@ lua_integer2str converts an integer to a string. 523 | */ 524 | 525 | 526 | /* The following definitions are good for most cases here */ 527 | 528 | #define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" 529 | 530 | #define LUAI_UACINT LUA_INTEGER 531 | 532 | #define lua_integer2str(s,sz,n) \ 533 | l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n)) 534 | 535 | /* 536 | ** use LUAI_UACINT here to avoid problems with promotions (which 537 | ** can turn a comparison between unsigneds into a signed comparison) 538 | */ 539 | #define LUA_UNSIGNED unsigned LUAI_UACINT 540 | 541 | 542 | /* now the variable definitions */ 543 | 544 | #if LUA_INT_TYPE == LUA_INT_INT /* { int */ 545 | 546 | #define LUA_INTEGER int 547 | #define LUA_INTEGER_FRMLEN "" 548 | 549 | #define LUA_MAXINTEGER INT_MAX 550 | #define LUA_MININTEGER INT_MIN 551 | 552 | #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ 553 | 554 | #define LUA_INTEGER long 555 | #define LUA_INTEGER_FRMLEN "l" 556 | 557 | #define LUA_MAXINTEGER LONG_MAX 558 | #define LUA_MININTEGER LONG_MIN 559 | 560 | #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ 561 | 562 | /* use presence of macro LLONG_MAX as proxy for C99 compliance */ 563 | #if defined(LLONG_MAX) /* { */ 564 | /* use ISO C99 stuff */ 565 | 566 | #define LUA_INTEGER long long 567 | #define LUA_INTEGER_FRMLEN "ll" 568 | 569 | #define LUA_MAXINTEGER LLONG_MAX 570 | #define LUA_MININTEGER LLONG_MIN 571 | 572 | #elif defined(LUA_USE_WINDOWS) /* }{ */ 573 | /* in Windows, can use specific Windows types */ 574 | 575 | #define LUA_INTEGER __int64 576 | #define LUA_INTEGER_FRMLEN "I64" 577 | 578 | #define LUA_MAXINTEGER _I64_MAX 579 | #define LUA_MININTEGER _I64_MIN 580 | 581 | #else /* }{ */ 582 | 583 | #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ 584 | or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" 585 | 586 | #endif /* } */ 587 | 588 | #else /* }{ */ 589 | 590 | #error "numeric integer type not defined" 591 | 592 | #endif /* } */ 593 | 594 | /* }================================================================== */ 595 | 596 | 597 | /* 598 | ** {================================================================== 599 | ** Dependencies with C99 and other C details 600 | ** =================================================================== 601 | */ 602 | 603 | /* 604 | @@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89. 605 | ** (All uses in Lua have only one format item.) 606 | */ 607 | #if !defined(LUA_USE_C89) 608 | #define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i) 609 | #else 610 | #define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i)) 611 | #endif 612 | 613 | 614 | /* 615 | @@ lua_strx2number converts an hexadecimal numeric string to a number. 616 | ** In C99, 'strtod' does that conversion. Otherwise, you can 617 | ** leave 'lua_strx2number' undefined and Lua will provide its own 618 | ** implementation. 619 | */ 620 | #if !defined(LUA_USE_C89) 621 | #define lua_strx2number(s,p) lua_str2number(s,p) 622 | #endif 623 | 624 | 625 | /* 626 | @@ lua_pointer2str converts a pointer to a readable string in a 627 | ** non-specified way. 628 | */ 629 | #define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p) 630 | 631 | 632 | /* 633 | @@ lua_number2strx converts a float to an hexadecimal numeric string. 634 | ** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. 635 | ** Otherwise, you can leave 'lua_number2strx' undefined and Lua will 636 | ** provide its own implementation. 637 | */ 638 | #if !defined(LUA_USE_C89) 639 | #define lua_number2strx(L,b,sz,f,n) \ 640 | ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n))) 641 | #endif 642 | 643 | 644 | /* 645 | ** 'strtof' and 'opf' variants for math functions are not valid in 646 | ** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the 647 | ** availability of these variants. ('math.h' is already included in 648 | ** all files that use these macros.) 649 | */ 650 | #if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF)) 651 | #undef l_mathop /* variants not available */ 652 | #undef lua_str2number 653 | #define l_mathop(op) (lua_Number)op /* no variant */ 654 | #define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) 655 | #endif 656 | 657 | 658 | /* 659 | @@ LUA_KCONTEXT is the type of the context ('ctx') for continuation 660 | ** functions. It must be a numerical type; Lua will use 'intptr_t' if 661 | ** available, otherwise it will use 'ptrdiff_t' (the nearest thing to 662 | ** 'intptr_t' in C89) 663 | */ 664 | #define LUA_KCONTEXT ptrdiff_t 665 | 666 | #if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ 667 | __STDC_VERSION__ >= 199901L 668 | #include 669 | #if defined(INTPTR_MAX) /* even in C99 this type is optional */ 670 | #undef LUA_KCONTEXT 671 | #define LUA_KCONTEXT intptr_t 672 | #endif 673 | #endif 674 | 675 | 676 | /* 677 | @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). 678 | ** Change that if you do not want to use C locales. (Code using this 679 | ** macro must include header 'locale.h'.) 680 | */ 681 | #if !defined(lua_getlocaledecpoint) 682 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) 683 | #endif 684 | 685 | /* }================================================================== */ 686 | 687 | 688 | /* 689 | ** {================================================================== 690 | ** Language Variations 691 | ** ===================================================================== 692 | */ 693 | 694 | /* 695 | @@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some 696 | ** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from 697 | ** numbers to strings. Define LUA_NOCVTS2N to turn off automatic 698 | ** coercion from strings to numbers. 699 | */ 700 | /* #define LUA_NOCVTN2S */ 701 | /* #define LUA_NOCVTS2N */ 702 | 703 | 704 | /* 705 | @@ LUA_USE_APICHECK turns on several consistency checks on the C API. 706 | ** Define it as a help when debugging C code. 707 | */ 708 | #if defined(LUA_USE_APICHECK) 709 | #include 710 | #define luai_apicheck(l,e) assert(e) 711 | #endif 712 | 713 | /* }================================================================== */ 714 | 715 | 716 | /* 717 | ** {================================================================== 718 | ** Macros that affect the API and must be stable (that is, must be the 719 | ** same when you compile Lua and when you compile code that links to 720 | ** Lua). You probably do not want/need to change them. 721 | ** ===================================================================== 722 | */ 723 | 724 | /* 725 | @@ LUAI_MAXSTACK limits the size of the Lua stack. 726 | ** CHANGE it if you need a different limit. This limit is arbitrary; 727 | ** its only purpose is to stop Lua from consuming unlimited stack 728 | ** space (and to reserve some numbers for pseudo-indices). 729 | */ 730 | #if LUAI_BITSINT >= 32 731 | #define LUAI_MAXSTACK 1000000 732 | #else 733 | #define LUAI_MAXSTACK 15000 734 | #endif 735 | 736 | 737 | /* 738 | @@ LUA_EXTRASPACE defines the size of a raw memory area associated with 739 | ** a Lua state with very fast access. 740 | ** CHANGE it if you need a different size. 741 | */ 742 | #define LUA_EXTRASPACE (sizeof(void *)) 743 | 744 | 745 | /* 746 | @@ LUA_IDSIZE gives the maximum size for the description of the source 747 | @@ of a function in debug information. 748 | ** CHANGE it if you want a different size. 749 | */ 750 | #define LUA_IDSIZE 60 751 | 752 | 753 | /* 754 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. 755 | ** CHANGE it if it uses too much C-stack space. (For long double, 756 | ** 'string.format("%.99f", -1e4932)' needs 5034 bytes, so a 757 | ** smaller buffer would force a memory allocation for each call to 758 | ** 'string.format'.) 759 | */ 760 | #if LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE 761 | #define LUAL_BUFFERSIZE 8192 762 | #else 763 | #define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer))) 764 | #endif 765 | 766 | /* }================================================================== */ 767 | 768 | 769 | /* 770 | @@ LUA_QL describes how error messages quote program elements. 771 | ** Lua does not use these macros anymore; they are here for 772 | ** compatibility only. 773 | */ 774 | #define LUA_QL(x) "'" x "'" 775 | #define LUA_QS LUA_QL("%s") 776 | 777 | 778 | 779 | 780 | /* =================================================================== */ 781 | 782 | /* 783 | ** Local configuration. You can use this space to add your redefinitions 784 | ** without modifying the main part of the file. 785 | */ 786 | 787 | 788 | 789 | 790 | 791 | #endif 792 | 793 | -------------------------------------------------------------------------------- /contrib/Lua53/include/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_BITLIBNAME "bit32" 39 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 40 | 41 | #define LUA_MATHLIBNAME "math" 42 | LUAMOD_API int (luaopen_math) (lua_State *L); 43 | 44 | #define LUA_DBLIBNAME "debug" 45 | LUAMOD_API int (luaopen_debug) (lua_State *L); 46 | 47 | #define LUA_LOADLIBNAME "package" 48 | LUAMOD_API int (luaopen_package) (lua_State *L); 49 | 50 | 51 | /* open all previous libraries */ 52 | LUALIB_API void (luaL_openlibs) (lua_State *L); 53 | 54 | 55 | 56 | #if !defined(lua_assert) 57 | #define lua_assert(x) ((void)0) 58 | #endif 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /contrib/Lua53/lib/x64/lua53.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swerg/simple-lua-c-dll/29aff73595a967ac899d5452db15740df465d3b6/contrib/Lua53/lib/x64/lua53.lib -------------------------------------------------------------------------------- /contrib/Lua54/include/lauxlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lauxlib.h $ 3 | ** Auxiliary functions for building Lua libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lauxlib_h 9 | #define lauxlib_h 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | 18 | /* global table */ 19 | #define LUA_GNAME "_G" 20 | 21 | 22 | typedef struct luaL_Buffer luaL_Buffer; 23 | 24 | 25 | /* extra error code for 'luaL_loadfilex' */ 26 | #define LUA_ERRFILE (LUA_ERRERR+1) 27 | 28 | 29 | /* key, in the registry, for table of loaded modules */ 30 | #define LUA_LOADED_TABLE "_LOADED" 31 | 32 | 33 | /* key, in the registry, for table of preloaded loaders */ 34 | #define LUA_PRELOAD_TABLE "_PRELOAD" 35 | 36 | 37 | typedef struct luaL_Reg { 38 | const char *name; 39 | lua_CFunction func; 40 | } luaL_Reg; 41 | 42 | 43 | #define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number)) 44 | 45 | LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz); 46 | #define luaL_checkversion(L) \ 47 | luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES) 48 | 49 | LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); 50 | LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); 51 | LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); 52 | LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg); 53 | LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname); 54 | LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg, 55 | size_t *l); 56 | LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg, 57 | const char *def, size_t *l); 58 | LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg); 59 | LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def); 60 | 61 | LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg); 62 | LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg, 63 | lua_Integer def); 64 | 65 | LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); 66 | LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t); 67 | LUALIB_API void (luaL_checkany) (lua_State *L, int arg); 68 | 69 | LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); 70 | LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); 71 | LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); 72 | LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); 73 | 74 | LUALIB_API void (luaL_where) (lua_State *L, int lvl); 75 | LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); 76 | 77 | LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def, 78 | const char *const lst[]); 79 | 80 | LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); 81 | LUALIB_API int (luaL_execresult) (lua_State *L, int stat); 82 | 83 | 84 | /* predefined references */ 85 | #define LUA_NOREF (-2) 86 | #define LUA_REFNIL (-1) 87 | 88 | LUALIB_API int (luaL_ref) (lua_State *L, int t); 89 | LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); 90 | 91 | LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, 92 | const char *mode); 93 | 94 | #define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) 95 | 96 | LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, 97 | const char *name, const char *mode); 98 | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); 99 | 100 | LUALIB_API lua_State *(luaL_newstate) (void); 101 | 102 | LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); 103 | 104 | LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s, 105 | const char *p, const char *r); 106 | LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, 107 | const char *p, const char *r); 108 | 109 | LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); 110 | 111 | LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); 112 | 113 | LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, 114 | const char *msg, int level); 115 | 116 | LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, 117 | lua_CFunction openf, int glb); 118 | 119 | /* 120 | ** =============================================================== 121 | ** some useful macros 122 | ** =============================================================== 123 | */ 124 | 125 | 126 | #define luaL_newlibtable(L,l) \ 127 | lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) 128 | 129 | #define luaL_newlib(L,l) \ 130 | (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) 131 | 132 | #define luaL_argcheck(L, cond,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 | 138 | #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) 139 | #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) 140 | 141 | #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) 142 | 143 | #define luaL_dofile(L, fn) \ 144 | (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) 145 | 146 | #define luaL_dostring(L, s) \ 147 | (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) 148 | 149 | #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) 150 | 151 | #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) 152 | 153 | #define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) 154 | 155 | 156 | /* push the value used to represent failure/error */ 157 | #define luaL_pushfail(L) lua_pushnil(L) 158 | 159 | 160 | /* 161 | ** {====================================================== 162 | ** Generic Buffer manipulation 163 | ** ======================================================= 164 | */ 165 | 166 | struct luaL_Buffer { 167 | char *b; /* buffer address */ 168 | size_t size; /* buffer size */ 169 | size_t n; /* number of characters in buffer */ 170 | lua_State *L; 171 | union { 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) 180 | 181 | 182 | #define luaL_addchar(B,c) \ 183 | ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ 184 | ((B)->b[(B)->n++] = (c))) 185 | 186 | #define luaL_addsize(B,s) ((B)->n += (s)) 187 | 188 | #define luaL_buffsub(B,s) ((B)->n -= (s)) 189 | 190 | LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); 191 | LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); 192 | LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); 193 | LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); 194 | LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); 195 | LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); 196 | LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); 197 | LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); 198 | 199 | #define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) 200 | 201 | /* }====================================================== */ 202 | 203 | 204 | 205 | /* 206 | ** {====================================================== 207 | ** File handles for IO library 208 | ** ======================================================= 209 | */ 210 | 211 | /* 212 | ** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and 213 | ** initial structure 'luaL_Stream' (it may contain other fields 214 | ** after that initial structure). 215 | */ 216 | 217 | #define LUA_FILEHANDLE "FILE*" 218 | 219 | 220 | typedef struct luaL_Stream { 221 | FILE *f; /* stream (NULL for incompletely created streams) */ 222 | lua_CFunction closef; /* to close stream (NULL for closed streams) */ 223 | } luaL_Stream; 224 | 225 | /* }====================================================== */ 226 | 227 | /* 228 | ** {================================================================== 229 | ** "Abstraction Layer" for basic report of messages and errors 230 | ** =================================================================== 231 | */ 232 | 233 | /* print a string */ 234 | #if !defined(lua_writestring) 235 | #define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) 236 | #endif 237 | 238 | /* print a newline and flush the output */ 239 | #if !defined(lua_writeline) 240 | #define lua_writeline() (lua_writestring("\n", 1), fflush(stdout)) 241 | #endif 242 | 243 | /* print an error message */ 244 | #if !defined(lua_writestringerror) 245 | #define lua_writestringerror(s,p) \ 246 | (fprintf(stderr, (s), (p)), fflush(stderr)) 247 | #endif 248 | 249 | /* }================================================================== */ 250 | 251 | 252 | /* 253 | ** {============================================================ 254 | ** Compatibility with deprecated conversions 255 | ** ============================================================= 256 | */ 257 | #if defined(LUA_COMPAT_APIINTCASTS) 258 | 259 | #define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a)) 260 | #define luaL_optunsigned(L,a,d) \ 261 | ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d))) 262 | 263 | #define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) 264 | #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) 265 | 266 | #define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) 267 | #define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) 268 | 269 | #endif 270 | /* }============================================================ */ 271 | 272 | 273 | 274 | #endif 275 | 276 | 277 | -------------------------------------------------------------------------------- /contrib/Lua54/include/lua.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lua.h $ 3 | ** Lua - A Scripting Language 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 5 | ** See Copyright Notice at the end of this file 6 | */ 7 | 8 | 9 | #ifndef lua_h 10 | #define lua_h 11 | 12 | #include 13 | #include 14 | 15 | 16 | #include "luaconf.h" 17 | 18 | 19 | #define LUA_VERSION_MAJOR "5" 20 | #define LUA_VERSION_MINOR "4" 21 | #define LUA_VERSION_RELEASE "2" 22 | 23 | #define LUA_VERSION_NUM 504 24 | #define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 0) 25 | 26 | #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR 27 | #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE 28 | #define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2020 Lua.org, PUC-Rio" 29 | #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" 30 | 31 | 32 | /* mark for precompiled code ('Lua') */ 33 | #define LUA_SIGNATURE "\x1bLua" 34 | 35 | /* option for multiple returns in 'lua_pcall' and 'lua_call' */ 36 | #define LUA_MULTRET (-1) 37 | 38 | 39 | /* 40 | ** Pseudo-indices 41 | ** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty 42 | ** space after that to help overflow detection) 43 | */ 44 | #define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000) 45 | #define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) 46 | 47 | 48 | /* thread status */ 49 | #define LUA_OK 0 50 | #define LUA_YIELD 1 51 | #define LUA_ERRRUN 2 52 | #define LUA_ERRSYNTAX 3 53 | #define LUA_ERRMEM 4 54 | #define LUA_ERRERR 5 55 | 56 | 57 | typedef struct lua_State lua_State; 58 | 59 | 60 | /* 61 | ** basic types 62 | */ 63 | #define LUA_TNONE (-1) 64 | 65 | #define LUA_TNIL 0 66 | #define LUA_TBOOLEAN 1 67 | #define LUA_TLIGHTUSERDATA 2 68 | #define LUA_TNUMBER 3 69 | #define LUA_TSTRING 4 70 | #define LUA_TTABLE 5 71 | #define LUA_TFUNCTION 6 72 | #define LUA_TUSERDATA 7 73 | #define LUA_TTHREAD 8 74 | 75 | #define LUA_NUMTYPES 9 76 | 77 | 78 | 79 | /* minimum Lua stack available to a C function */ 80 | #define LUA_MINSTACK 20 81 | 82 | 83 | /* predefined values in the registry */ 84 | #define LUA_RIDX_MAINTHREAD 1 85 | #define LUA_RIDX_GLOBALS 2 86 | #define LUA_RIDX_LAST LUA_RIDX_GLOBALS 87 | 88 | 89 | /* type of numbers in Lua */ 90 | typedef LUA_NUMBER lua_Number; 91 | 92 | 93 | /* type for integer functions */ 94 | typedef LUA_INTEGER lua_Integer; 95 | 96 | /* unsigned integer type */ 97 | typedef LUA_UNSIGNED lua_Unsigned; 98 | 99 | /* type for continuation-function contexts */ 100 | typedef LUA_KCONTEXT lua_KContext; 101 | 102 | 103 | /* 104 | ** Type for C functions registered with Lua 105 | */ 106 | typedef int (*lua_CFunction) (lua_State *L); 107 | 108 | /* 109 | ** Type for continuation functions 110 | */ 111 | typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); 112 | 113 | 114 | /* 115 | ** Type for functions that read/write blocks when loading/dumping Lua chunks 116 | */ 117 | typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); 118 | 119 | typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud); 120 | 121 | 122 | /* 123 | ** Type for memory-allocation functions 124 | */ 125 | typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); 126 | 127 | 128 | /* 129 | ** Type for warning functions 130 | */ 131 | typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont); 132 | 133 | 134 | 135 | 136 | /* 137 | ** generic extra include file 138 | */ 139 | #if defined(LUA_USER_H) 140 | #include LUA_USER_H 141 | #endif 142 | 143 | 144 | /* 145 | ** RCS ident string 146 | */ 147 | extern const char lua_ident[]; 148 | 149 | 150 | /* 151 | ** state manipulation 152 | */ 153 | LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); 154 | LUA_API void (lua_close) (lua_State *L); 155 | LUA_API lua_State *(lua_newthread) (lua_State *L); 156 | LUA_API int (lua_resetthread) (lua_State *L); 157 | 158 | LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); 159 | 160 | 161 | LUA_API lua_Number (lua_version) (lua_State *L); 162 | 163 | 164 | /* 165 | ** basic stack manipulation 166 | */ 167 | LUA_API int (lua_absindex) (lua_State *L, int idx); 168 | LUA_API int (lua_gettop) (lua_State *L); 169 | LUA_API void (lua_settop) (lua_State *L, int idx); 170 | LUA_API void (lua_pushvalue) (lua_State *L, int idx); 171 | LUA_API void (lua_rotate) (lua_State *L, int idx, int n); 172 | LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); 173 | LUA_API int (lua_checkstack) (lua_State *L, int n); 174 | 175 | LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); 176 | 177 | 178 | /* 179 | ** access functions (stack -> C) 180 | */ 181 | 182 | LUA_API int (lua_isnumber) (lua_State *L, int idx); 183 | LUA_API int (lua_isstring) (lua_State *L, int idx); 184 | LUA_API int (lua_iscfunction) (lua_State *L, int idx); 185 | LUA_API int (lua_isinteger) (lua_State *L, int idx); 186 | LUA_API int (lua_isuserdata) (lua_State *L, int idx); 187 | LUA_API int (lua_type) (lua_State *L, int idx); 188 | LUA_API const char *(lua_typename) (lua_State *L, int tp); 189 | 190 | LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); 191 | LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); 192 | LUA_API int (lua_toboolean) (lua_State *L, int idx); 193 | LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); 194 | LUA_API lua_Unsigned (lua_rawlen) (lua_State *L, int idx); 195 | LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); 196 | LUA_API void *(lua_touserdata) (lua_State *L, int idx); 197 | LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); 198 | LUA_API const void *(lua_topointer) (lua_State *L, int idx); 199 | 200 | 201 | /* 202 | ** Comparison and arithmetic functions 203 | */ 204 | 205 | #define LUA_OPADD 0 /* ORDER TM, ORDER OP */ 206 | #define LUA_OPSUB 1 207 | #define LUA_OPMUL 2 208 | #define LUA_OPMOD 3 209 | #define LUA_OPPOW 4 210 | #define LUA_OPDIV 5 211 | #define LUA_OPIDIV 6 212 | #define LUA_OPBAND 7 213 | #define LUA_OPBOR 8 214 | #define LUA_OPBXOR 9 215 | #define LUA_OPSHL 10 216 | #define LUA_OPSHR 11 217 | #define LUA_OPUNM 12 218 | #define LUA_OPBNOT 13 219 | 220 | LUA_API void (lua_arith) (lua_State *L, int op); 221 | 222 | #define LUA_OPEQ 0 223 | #define LUA_OPLT 1 224 | #define LUA_OPLE 2 225 | 226 | LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); 227 | LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); 228 | 229 | 230 | /* 231 | ** push functions (C -> stack) 232 | */ 233 | LUA_API void (lua_pushnil) (lua_State *L); 234 | LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); 235 | LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); 236 | LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len); 237 | LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); 238 | LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, 239 | va_list argp); 240 | LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); 241 | LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); 242 | LUA_API void (lua_pushboolean) (lua_State *L, int b); 243 | LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); 244 | LUA_API int (lua_pushthread) (lua_State *L); 245 | 246 | 247 | /* 248 | ** get functions (Lua -> stack) 249 | */ 250 | LUA_API int (lua_getglobal) (lua_State *L, const char *name); 251 | LUA_API int (lua_gettable) (lua_State *L, int idx); 252 | LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k); 253 | LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n); 254 | LUA_API int (lua_rawget) (lua_State *L, int idx); 255 | LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n); 256 | LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p); 257 | 258 | LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); 259 | LUA_API void *(lua_newuserdatauv) (lua_State *L, size_t sz, int nuvalue); 260 | LUA_API int (lua_getmetatable) (lua_State *L, int objindex); 261 | LUA_API int (lua_getiuservalue) (lua_State *L, int idx, int n); 262 | 263 | 264 | /* 265 | ** set functions (stack -> Lua) 266 | */ 267 | LUA_API void (lua_setglobal) (lua_State *L, const char *name); 268 | LUA_API void (lua_settable) (lua_State *L, int idx); 269 | LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); 270 | LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n); 271 | LUA_API void (lua_rawset) (lua_State *L, int idx); 272 | LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n); 273 | LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); 274 | LUA_API int (lua_setmetatable) (lua_State *L, int objindex); 275 | LUA_API int (lua_setiuservalue) (lua_State *L, int idx, int n); 276 | 277 | 278 | /* 279 | ** 'load' and 'call' functions (load and run Lua code) 280 | */ 281 | LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, 282 | lua_KContext ctx, lua_KFunction k); 283 | #define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) 284 | 285 | LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, 286 | lua_KContext ctx, lua_KFunction k); 287 | #define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) 288 | 289 | LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, 290 | const char *chunkname, const char *mode); 291 | 292 | LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip); 293 | 294 | 295 | /* 296 | ** coroutine functions 297 | */ 298 | LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx, 299 | lua_KFunction k); 300 | LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg, 301 | int *nres); 302 | LUA_API int (lua_status) (lua_State *L); 303 | LUA_API int (lua_isyieldable) (lua_State *L); 304 | 305 | #define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) 306 | 307 | 308 | /* 309 | ** Warning-related functions 310 | */ 311 | LUA_API void (lua_setwarnf) (lua_State *L, lua_WarnFunction f, void *ud); 312 | LUA_API void (lua_warning) (lua_State *L, const char *msg, int tocont); 313 | 314 | 315 | /* 316 | ** garbage-collection function and options 317 | */ 318 | 319 | #define LUA_GCSTOP 0 320 | #define LUA_GCRESTART 1 321 | #define LUA_GCCOLLECT 2 322 | #define LUA_GCCOUNT 3 323 | #define LUA_GCCOUNTB 4 324 | #define LUA_GCSTEP 5 325 | #define LUA_GCSETPAUSE 6 326 | #define LUA_GCSETSTEPMUL 7 327 | #define LUA_GCISRUNNING 9 328 | #define LUA_GCGEN 10 329 | #define LUA_GCINC 11 330 | 331 | LUA_API int (lua_gc) (lua_State *L, int what, ...); 332 | 333 | 334 | /* 335 | ** miscellaneous functions 336 | */ 337 | 338 | LUA_API int (lua_error) (lua_State *L); 339 | 340 | LUA_API int (lua_next) (lua_State *L, int idx); 341 | 342 | LUA_API void (lua_concat) (lua_State *L, int n); 343 | LUA_API void (lua_len) (lua_State *L, int idx); 344 | 345 | LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s); 346 | 347 | LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); 348 | LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); 349 | 350 | LUA_API void (lua_toclose) (lua_State *L, int idx); 351 | 352 | 353 | /* 354 | ** {============================================================== 355 | ** some useful macros 356 | ** =============================================================== 357 | */ 358 | 359 | #define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE)) 360 | 361 | #define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) 362 | #define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) 363 | 364 | #define lua_pop(L,n) lua_settop(L, -(n)-1) 365 | 366 | #define lua_newtable(L) lua_createtable(L, 0, 0) 367 | 368 | #define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) 369 | 370 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) 371 | 372 | #define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) 373 | #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) 374 | #define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) 375 | #define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) 376 | #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) 377 | #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) 378 | #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) 379 | #define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) 380 | 381 | #define lua_pushliteral(L, s) lua_pushstring(L, "" s) 382 | 383 | #define lua_pushglobaltable(L) \ 384 | ((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)) 385 | 386 | #define lua_tostring(L,i) lua_tolstring(L, (i), NULL) 387 | 388 | 389 | #define lua_insert(L,idx) lua_rotate(L, (idx), 1) 390 | 391 | #define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1)) 392 | 393 | #define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1)) 394 | 395 | /* }============================================================== */ 396 | 397 | 398 | /* 399 | ** {============================================================== 400 | ** compatibility macros 401 | ** =============================================================== 402 | */ 403 | #if defined(LUA_COMPAT_APIINTCASTS) 404 | 405 | #define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) 406 | #define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is)) 407 | #define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) 408 | 409 | #endif 410 | 411 | #define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1) 412 | #define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1) 413 | #define lua_setuservalue(L,idx) lua_setiuservalue(L,idx,1) 414 | 415 | #define LUA_NUMTAGS LUA_NUMTYPES 416 | 417 | /* }============================================================== */ 418 | 419 | /* 420 | ** {====================================================================== 421 | ** Debug API 422 | ** ======================================================================= 423 | */ 424 | 425 | 426 | /* 427 | ** Event codes 428 | */ 429 | #define LUA_HOOKCALL 0 430 | #define LUA_HOOKRET 1 431 | #define LUA_HOOKLINE 2 432 | #define LUA_HOOKCOUNT 3 433 | #define LUA_HOOKTAILCALL 4 434 | 435 | 436 | /* 437 | ** Event masks 438 | */ 439 | #define LUA_MASKCALL (1 << LUA_HOOKCALL) 440 | #define LUA_MASKRET (1 << LUA_HOOKRET) 441 | #define LUA_MASKLINE (1 << LUA_HOOKLINE) 442 | #define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) 443 | 444 | typedef struct lua_Debug lua_Debug; /* activation record */ 445 | 446 | 447 | /* Functions to be called by the debugger in specific events */ 448 | typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); 449 | 450 | 451 | LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); 452 | LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); 453 | LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n); 454 | LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n); 455 | LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n); 456 | LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n); 457 | 458 | LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); 459 | LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, 460 | int fidx2, int n2); 461 | 462 | LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); 463 | LUA_API lua_Hook (lua_gethook) (lua_State *L); 464 | LUA_API int (lua_gethookmask) (lua_State *L); 465 | LUA_API int (lua_gethookcount) (lua_State *L); 466 | 467 | LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit); 468 | 469 | struct lua_Debug { 470 | int event; 471 | const char *name; /* (n) */ 472 | const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */ 473 | const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */ 474 | const char *source; /* (S) */ 475 | size_t srclen; /* (S) */ 476 | int currentline; /* (l) */ 477 | int linedefined; /* (S) */ 478 | int lastlinedefined; /* (S) */ 479 | unsigned char nups; /* (u) number of upvalues */ 480 | unsigned char nparams;/* (u) number of parameters */ 481 | char isvararg; /* (u) */ 482 | char istailcall; /* (t) */ 483 | unsigned short ftransfer; /* (r) index of first value transferred */ 484 | unsigned short ntransfer; /* (r) number of transferred values */ 485 | char short_src[LUA_IDSIZE]; /* (S) */ 486 | /* private part */ 487 | struct CallInfo *i_ci; /* active function */ 488 | }; 489 | 490 | /* }====================================================================== */ 491 | 492 | 493 | /****************************************************************************** 494 | * Copyright (C) 1994-2020 Lua.org, PUC-Rio. 495 | * 496 | * Permission is hereby granted, free of charge, to any person obtaining 497 | * a copy of this software and associated documentation files (the 498 | * "Software"), to deal in the Software without restriction, including 499 | * without limitation the rights to use, copy, modify, merge, publish, 500 | * distribute, sublicense, and/or sell copies of the Software, and to 501 | * permit persons to whom the Software is furnished to do so, subject to 502 | * the following conditions: 503 | * 504 | * The above copyright notice and this permission notice shall be 505 | * included in all copies or substantial portions of the Software. 506 | * 507 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 508 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 509 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 510 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 511 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 512 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 513 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 514 | ******************************************************************************/ 515 | 516 | 517 | #endif 518 | -------------------------------------------------------------------------------- /contrib/Lua54/include/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /contrib/Lua54/include/luaconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: luaconf.h $ 3 | ** Configuration file for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef luaconf_h 9 | #define luaconf_h 10 | 11 | #include 12 | #include 13 | 14 | 15 | /* 16 | ** =================================================================== 17 | ** General Configuration File for Lua 18 | ** 19 | ** Some definitions here can be changed externally, through the 20 | ** compiler (e.g., with '-D' options). Those are protected by 21 | ** '#if !defined' guards. However, several other definitions should 22 | ** be changed directly here, either because they affect the Lua 23 | ** ABI (by making the changes here, you ensure that all software 24 | ** connected to Lua, such as C libraries, will be compiled with the 25 | ** same configuration); or because they are seldom changed. 26 | ** 27 | ** Search for "@@" to find all configurable definitions. 28 | ** =================================================================== 29 | */ 30 | 31 | 32 | /* 33 | ** {==================================================================== 34 | ** System Configuration: macros to adapt (if needed) Lua to some 35 | ** particular platform, for instance restricting it to C89. 36 | ** ===================================================================== 37 | */ 38 | 39 | /* 40 | @@ LUA_USE_C89 controls the use of non-ISO-C89 features. 41 | ** Define it if you want Lua to avoid the use of a few C99 features 42 | ** or Windows-specific features on Windows. 43 | */ 44 | /* #define LUA_USE_C89 */ 45 | 46 | 47 | /* 48 | ** By default, Lua on Windows use (some) specific Windows features 49 | */ 50 | #if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE) 51 | #define LUA_USE_WINDOWS /* enable goodies for regular Windows */ 52 | #endif 53 | 54 | 55 | #if defined(LUA_USE_WINDOWS) 56 | #define LUA_DL_DLL /* enable support for DLL */ 57 | #define LUA_USE_C89 /* broadly, Windows is C89 */ 58 | #endif 59 | 60 | 61 | #if defined(LUA_USE_LINUX) 62 | #define LUA_USE_POSIX 63 | #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ 64 | #endif 65 | 66 | 67 | #if defined(LUA_USE_MACOSX) 68 | #define LUA_USE_POSIX 69 | #define LUA_USE_DLOPEN /* MacOS does not need -ldl */ 70 | #endif 71 | 72 | 73 | /* 74 | @@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits. 75 | */ 76 | #define LUAI_IS32INT ((UINT_MAX >> 30) >= 3) 77 | 78 | /* }================================================================== */ 79 | 80 | 81 | 82 | /* 83 | ** {================================================================== 84 | ** Configuration for Number types. 85 | ** =================================================================== 86 | */ 87 | 88 | /* 89 | @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. 90 | */ 91 | /* #define LUA_32BITS */ 92 | 93 | 94 | /* 95 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for 96 | ** C89 ('long' and 'double'); Windows always has '__int64', so it does 97 | ** not need to use this case. 98 | */ 99 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) 100 | #define LUA_C89_NUMBERS 101 | #endif 102 | 103 | 104 | /* 105 | @@ LUA_INT_TYPE defines the type for Lua integers. 106 | @@ LUA_FLOAT_TYPE defines the type for Lua floats. 107 | ** Lua should work fine with any mix of these options supported 108 | ** by your C compiler. The usual configurations are 64-bit integers 109 | ** and 'double' (the default), 32-bit integers and 'float' (for 110 | ** restricted platforms), and 'long'/'double' (for C compilers not 111 | ** compliant with C99, which may not have support for 'long long'). 112 | */ 113 | 114 | /* predefined options for LUA_INT_TYPE */ 115 | #define LUA_INT_INT 1 116 | #define LUA_INT_LONG 2 117 | #define LUA_INT_LONGLONG 3 118 | 119 | /* predefined options for LUA_FLOAT_TYPE */ 120 | #define LUA_FLOAT_FLOAT 1 121 | #define LUA_FLOAT_DOUBLE 2 122 | #define LUA_FLOAT_LONGDOUBLE 3 123 | 124 | #if defined(LUA_32BITS) /* { */ 125 | /* 126 | ** 32-bit integers and 'float' 127 | */ 128 | #if LUAI_IS32INT /* use 'int' if big enough */ 129 | #define LUA_INT_TYPE LUA_INT_INT 130 | #else /* otherwise use 'long' */ 131 | #define LUA_INT_TYPE LUA_INT_LONG 132 | #endif 133 | #define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT 134 | 135 | #elif defined(LUA_C89_NUMBERS) /* }{ */ 136 | /* 137 | ** largest types available for C89 ('long' and 'double') 138 | */ 139 | #define LUA_INT_TYPE LUA_INT_LONG 140 | #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE 141 | 142 | #endif /* } */ 143 | 144 | 145 | /* 146 | ** default configuration for 64-bit Lua ('long long' and 'double') 147 | */ 148 | #if !defined(LUA_INT_TYPE) 149 | #define LUA_INT_TYPE LUA_INT_LONGLONG 150 | #endif 151 | 152 | #if !defined(LUA_FLOAT_TYPE) 153 | #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE 154 | #endif 155 | 156 | /* }================================================================== */ 157 | 158 | 159 | 160 | /* 161 | ** {================================================================== 162 | ** Configuration for Paths. 163 | ** =================================================================== 164 | */ 165 | 166 | /* 167 | ** LUA_PATH_SEP is the character that separates templates in a path. 168 | ** LUA_PATH_MARK is the string that marks the substitution points in a 169 | ** template. 170 | ** LUA_EXEC_DIR in a Windows path is replaced by the executable's 171 | ** directory. 172 | */ 173 | #define LUA_PATH_SEP ";" 174 | #define LUA_PATH_MARK "?" 175 | #define LUA_EXEC_DIR "!" 176 | 177 | 178 | /* 179 | @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for 180 | ** Lua libraries. 181 | @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for 182 | ** C libraries. 183 | ** CHANGE them if your machine has a non-conventional directory 184 | ** hierarchy or if you want to install your libraries in 185 | ** non-conventional directories. 186 | */ 187 | 188 | #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR 189 | #if defined(_WIN32) /* { */ 190 | /* 191 | ** In Windows, any exclamation mark ('!') in the path is replaced by the 192 | ** path of the directory of the executable file of the current process. 193 | */ 194 | #define LUA_LDIR "!\\lua\\" 195 | #define LUA_CDIR "!\\" 196 | #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" 197 | 198 | #if !defined(LUA_PATH_DEFAULT) 199 | #define LUA_PATH_DEFAULT \ 200 | LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ 201 | LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ 202 | LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ 203 | ".\\?.lua;" ".\\?\\init.lua" 204 | #endif 205 | 206 | #if !defined(LUA_CPATH_DEFAULT) 207 | #define LUA_CPATH_DEFAULT \ 208 | LUA_CDIR"?.dll;" \ 209 | LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ 210 | LUA_CDIR"loadall.dll;" ".\\?.dll" 211 | #endif 212 | 213 | #else /* }{ */ 214 | 215 | #define LUA_ROOT "/usr/local/" 216 | #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" 217 | #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" 218 | 219 | #if !defined(LUA_PATH_DEFAULT) 220 | #define LUA_PATH_DEFAULT \ 221 | LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ 222 | LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ 223 | "./?.lua;" "./?/init.lua" 224 | #endif 225 | 226 | #if !defined(LUA_CPATH_DEFAULT) 227 | #define LUA_CPATH_DEFAULT \ 228 | LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" 229 | #endif 230 | 231 | #endif /* } */ 232 | 233 | 234 | /* 235 | @@ LUA_DIRSEP is the directory separator (for submodules). 236 | ** CHANGE it if your machine does not use "/" as the directory separator 237 | ** and is not Windows. (On Windows Lua automatically uses "\".) 238 | */ 239 | #if !defined(LUA_DIRSEP) 240 | 241 | #if defined(_WIN32) 242 | #define LUA_DIRSEP "\\" 243 | #else 244 | #define LUA_DIRSEP "/" 245 | #endif 246 | 247 | #endif 248 | 249 | /* }================================================================== */ 250 | 251 | 252 | /* 253 | ** {================================================================== 254 | ** Marks for exported symbols in the C code 255 | ** =================================================================== 256 | */ 257 | 258 | /* 259 | @@ LUA_API is a mark for all core API functions. 260 | @@ LUALIB_API is a mark for all auxiliary library functions. 261 | @@ LUAMOD_API is a mark for all standard library opening functions. 262 | ** CHANGE them if you need to define those functions in some special way. 263 | ** For instance, if you want to create one Windows DLL with the core and 264 | ** the libraries, you may want to use the following definition (define 265 | ** LUA_BUILD_AS_DLL to get it). 266 | */ 267 | #if defined(LUA_BUILD_AS_DLL) /* { */ 268 | 269 | #if defined(LUA_CORE) || defined(LUA_LIB) /* { */ 270 | #define LUA_API __declspec(dllexport) 271 | #else /* }{ */ 272 | #define LUA_API __declspec(dllimport) 273 | #endif /* } */ 274 | 275 | #else /* }{ */ 276 | 277 | #define LUA_API extern 278 | 279 | #endif /* } */ 280 | 281 | 282 | /* 283 | ** More often than not the libs go together with the core. 284 | */ 285 | #define LUALIB_API LUA_API 286 | #define LUAMOD_API LUA_API 287 | 288 | 289 | /* 290 | @@ LUAI_FUNC is a mark for all extern functions that are not to be 291 | ** exported to outside modules. 292 | @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables, 293 | ** none of which to be exported to outside modules (LUAI_DDEF for 294 | ** definitions and LUAI_DDEC for declarations). 295 | ** CHANGE them if you need to mark them in some special way. Elf/gcc 296 | ** (versions 3.2 and later) mark them as "hidden" to optimize access 297 | ** when Lua is compiled as a shared library. Not all elf targets support 298 | ** this attribute. Unfortunately, gcc does not offer a way to check 299 | ** whether the target offers that support, and those without support 300 | ** give a warning about it. To avoid these warnings, change to the 301 | ** default definition. 302 | */ 303 | #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ 304 | defined(__ELF__) /* { */ 305 | #define LUAI_FUNC __attribute__((visibility("internal"))) extern 306 | #else /* }{ */ 307 | #define LUAI_FUNC extern 308 | #endif /* } */ 309 | 310 | #define LUAI_DDEC(dec) LUAI_FUNC dec 311 | #define LUAI_DDEF /* empty */ 312 | 313 | /* }================================================================== */ 314 | 315 | 316 | /* 317 | ** {================================================================== 318 | ** Compatibility with previous versions 319 | ** =================================================================== 320 | */ 321 | 322 | /* 323 | @@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3. 324 | ** You can define it to get all options, or change specific options 325 | ** to fit your specific needs. 326 | */ 327 | #if defined(LUA_COMPAT_5_3) /* { */ 328 | 329 | /* 330 | @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated 331 | ** functions in the mathematical library. 332 | ** (These functions were already officially removed in 5.3; 333 | ** nevertheless they are still available here.) 334 | */ 335 | #define LUA_COMPAT_MATHLIB 336 | 337 | /* 338 | @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for 339 | ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, 340 | ** luaL_checkint, luaL_checklong, etc.) 341 | ** (These macros were also officially removed in 5.3, but they are still 342 | ** available here.) 343 | */ 344 | #define LUA_COMPAT_APIINTCASTS 345 | 346 | 347 | /* 348 | @@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod 349 | ** using '__lt'. 350 | */ 351 | #define LUA_COMPAT_LT_LE 352 | 353 | 354 | /* 355 | @@ The following macros supply trivial compatibility for some 356 | ** changes in the API. The macros themselves document how to 357 | ** change your code to avoid using them. 358 | ** (Once more, these macros were officially removed in 5.3, but they are 359 | ** still available here.) 360 | */ 361 | #define lua_strlen(L,i) lua_rawlen(L, (i)) 362 | 363 | #define lua_objlen(L,i) lua_rawlen(L, (i)) 364 | 365 | #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) 366 | #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) 367 | 368 | #endif /* } */ 369 | 370 | /* }================================================================== */ 371 | 372 | 373 | 374 | /* 375 | ** {================================================================== 376 | ** Configuration for Numbers. 377 | ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* 378 | ** satisfy your needs. 379 | ** =================================================================== 380 | */ 381 | 382 | /* 383 | @@ LUA_NUMBER is the floating-point type used by Lua. 384 | @@ LUAI_UACNUMBER is the result of a 'default argument promotion' 385 | @@ over a floating number. 386 | @@ l_floatatt(x) corrects float attribute 'x' to the proper float type 387 | ** by prefixing it with one of FLT/DBL/LDBL. 388 | @@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. 389 | @@ LUA_NUMBER_FMT is the format for writing floats. 390 | @@ lua_number2str converts a float to a string. 391 | @@ l_mathop allows the addition of an 'l' or 'f' to all math operations. 392 | @@ l_floor takes the floor of a float. 393 | @@ lua_str2number converts a decimal numeral to a number. 394 | */ 395 | 396 | 397 | /* The following definitions are good for most cases here */ 398 | 399 | #define l_floor(x) (l_mathop(floor)(x)) 400 | 401 | #define lua_number2str(s,sz,n) \ 402 | l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n)) 403 | 404 | /* 405 | @@ lua_numbertointeger converts a float number with an integral value 406 | ** to an integer, or returns 0 if float is not within the range of 407 | ** a lua_Integer. (The range comparisons are tricky because of 408 | ** rounding. The tests here assume a two-complement representation, 409 | ** where MININTEGER always has an exact representation as a float; 410 | ** MAXINTEGER may not have one, and therefore its conversion to float 411 | ** may have an ill-defined value.) 412 | */ 413 | #define lua_numbertointeger(n,p) \ 414 | ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ 415 | (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ 416 | (*(p) = (LUA_INTEGER)(n), 1)) 417 | 418 | 419 | /* now the variable definitions */ 420 | 421 | #if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ 422 | 423 | #define LUA_NUMBER float 424 | 425 | #define l_floatatt(n) (FLT_##n) 426 | 427 | #define LUAI_UACNUMBER double 428 | 429 | #define LUA_NUMBER_FRMLEN "" 430 | #define LUA_NUMBER_FMT "%.7g" 431 | 432 | #define l_mathop(op) op##f 433 | 434 | #define lua_str2number(s,p) strtof((s), (p)) 435 | 436 | 437 | #elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */ 438 | 439 | #define LUA_NUMBER long double 440 | 441 | #define l_floatatt(n) (LDBL_##n) 442 | 443 | #define LUAI_UACNUMBER long double 444 | 445 | #define LUA_NUMBER_FRMLEN "L" 446 | #define LUA_NUMBER_FMT "%.19Lg" 447 | 448 | #define l_mathop(op) op##l 449 | 450 | #define lua_str2number(s,p) strtold((s), (p)) 451 | 452 | #elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */ 453 | 454 | #define LUA_NUMBER double 455 | 456 | #define l_floatatt(n) (DBL_##n) 457 | 458 | #define LUAI_UACNUMBER double 459 | 460 | #define LUA_NUMBER_FRMLEN "" 461 | #define LUA_NUMBER_FMT "%.14g" 462 | 463 | #define l_mathop(op) op 464 | 465 | #define lua_str2number(s,p) strtod((s), (p)) 466 | 467 | #else /* }{ */ 468 | 469 | #error "numeric float type not defined" 470 | 471 | #endif /* } */ 472 | 473 | 474 | 475 | /* 476 | @@ LUA_INTEGER is the integer type used by Lua. 477 | ** 478 | @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. 479 | ** 480 | @@ LUAI_UACINT is the result of a 'default argument promotion' 481 | @@ over a LUA_INTEGER. 482 | @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. 483 | @@ LUA_INTEGER_FMT is the format for writing integers. 484 | @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. 485 | @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. 486 | @@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED. 487 | @@ LUA_UNSIGNEDBITS is the number of bits in a LUA_UNSIGNED. 488 | @@ lua_integer2str converts an integer to a string. 489 | */ 490 | 491 | 492 | /* The following definitions are good for most cases here */ 493 | 494 | #define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" 495 | 496 | #define LUAI_UACINT LUA_INTEGER 497 | 498 | #define lua_integer2str(s,sz,n) \ 499 | l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n)) 500 | 501 | /* 502 | ** use LUAI_UACINT here to avoid problems with promotions (which 503 | ** can turn a comparison between unsigneds into a signed comparison) 504 | */ 505 | #define LUA_UNSIGNED unsigned LUAI_UACINT 506 | 507 | 508 | #define LUA_UNSIGNEDBITS (sizeof(LUA_UNSIGNED) * CHAR_BIT) 509 | 510 | 511 | /* now the variable definitions */ 512 | 513 | #if LUA_INT_TYPE == LUA_INT_INT /* { int */ 514 | 515 | #define LUA_INTEGER int 516 | #define LUA_INTEGER_FRMLEN "" 517 | 518 | #define LUA_MAXINTEGER INT_MAX 519 | #define LUA_MININTEGER INT_MIN 520 | 521 | #define LUA_MAXUNSIGNED UINT_MAX 522 | 523 | #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ 524 | 525 | #define LUA_INTEGER long 526 | #define LUA_INTEGER_FRMLEN "l" 527 | 528 | #define LUA_MAXINTEGER LONG_MAX 529 | #define LUA_MININTEGER LONG_MIN 530 | 531 | #define LUA_MAXUNSIGNED ULONG_MAX 532 | 533 | #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ 534 | 535 | /* use presence of macro LLONG_MAX as proxy for C99 compliance */ 536 | #if defined(LLONG_MAX) /* { */ 537 | /* use ISO C99 stuff */ 538 | 539 | #define LUA_INTEGER long long 540 | #define LUA_INTEGER_FRMLEN "ll" 541 | 542 | #define LUA_MAXINTEGER LLONG_MAX 543 | #define LUA_MININTEGER LLONG_MIN 544 | 545 | #define LUA_MAXUNSIGNED ULLONG_MAX 546 | 547 | #elif defined(LUA_USE_WINDOWS) /* }{ */ 548 | /* in Windows, can use specific Windows types */ 549 | 550 | #define LUA_INTEGER __int64 551 | #define LUA_INTEGER_FRMLEN "I64" 552 | 553 | #define LUA_MAXINTEGER _I64_MAX 554 | #define LUA_MININTEGER _I64_MIN 555 | 556 | #define LUA_MAXUNSIGNED _UI64_MAX 557 | 558 | #else /* }{ */ 559 | 560 | #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ 561 | or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" 562 | 563 | #endif /* } */ 564 | 565 | #else /* }{ */ 566 | 567 | #error "numeric integer type not defined" 568 | 569 | #endif /* } */ 570 | 571 | /* }================================================================== */ 572 | 573 | 574 | /* 575 | ** {================================================================== 576 | ** Dependencies with C99 and other C details 577 | ** =================================================================== 578 | */ 579 | 580 | /* 581 | @@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89. 582 | ** (All uses in Lua have only one format item.) 583 | */ 584 | #if !defined(LUA_USE_C89) 585 | #define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i) 586 | #else 587 | #define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i)) 588 | #endif 589 | 590 | 591 | /* 592 | @@ lua_strx2number converts a hexadecimal numeral to a number. 593 | ** In C99, 'strtod' does that conversion. Otherwise, you can 594 | ** leave 'lua_strx2number' undefined and Lua will provide its own 595 | ** implementation. 596 | */ 597 | #if !defined(LUA_USE_C89) 598 | #define lua_strx2number(s,p) lua_str2number(s,p) 599 | #endif 600 | 601 | 602 | /* 603 | @@ lua_pointer2str converts a pointer to a readable string in a 604 | ** non-specified way. 605 | */ 606 | #define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p) 607 | 608 | 609 | /* 610 | @@ lua_number2strx converts a float to a hexadecimal numeral. 611 | ** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. 612 | ** Otherwise, you can leave 'lua_number2strx' undefined and Lua will 613 | ** provide its own implementation. 614 | */ 615 | #if !defined(LUA_USE_C89) 616 | #define lua_number2strx(L,b,sz,f,n) \ 617 | ((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n))) 618 | #endif 619 | 620 | 621 | /* 622 | ** 'strtof' and 'opf' variants for math functions are not valid in 623 | ** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the 624 | ** availability of these variants. ('math.h' is already included in 625 | ** all files that use these macros.) 626 | */ 627 | #if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF)) 628 | #undef l_mathop /* variants not available */ 629 | #undef lua_str2number 630 | #define l_mathop(op) (lua_Number)op /* no variant */ 631 | #define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) 632 | #endif 633 | 634 | 635 | /* 636 | @@ LUA_KCONTEXT is the type of the context ('ctx') for continuation 637 | ** functions. It must be a numerical type; Lua will use 'intptr_t' if 638 | ** available, otherwise it will use 'ptrdiff_t' (the nearest thing to 639 | ** 'intptr_t' in C89) 640 | */ 641 | #define LUA_KCONTEXT ptrdiff_t 642 | 643 | #if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ 644 | __STDC_VERSION__ >= 199901L 645 | #include 646 | #if defined(INTPTR_MAX) /* even in C99 this type is optional */ 647 | #undef LUA_KCONTEXT 648 | #define LUA_KCONTEXT intptr_t 649 | #endif 650 | #endif 651 | 652 | 653 | /* 654 | @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). 655 | ** Change that if you do not want to use C locales. (Code using this 656 | ** macro must include the header 'locale.h'.) 657 | */ 658 | #if !defined(lua_getlocaledecpoint) 659 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) 660 | #endif 661 | 662 | /* }================================================================== */ 663 | 664 | 665 | /* 666 | ** {================================================================== 667 | ** Language Variations 668 | ** ===================================================================== 669 | */ 670 | 671 | /* 672 | @@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some 673 | ** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from 674 | ** numbers to strings. Define LUA_NOCVTS2N to turn off automatic 675 | ** coercion from strings to numbers. 676 | */ 677 | /* #define LUA_NOCVTN2S */ 678 | /* #define LUA_NOCVTS2N */ 679 | 680 | 681 | /* 682 | @@ LUA_USE_APICHECK turns on several consistency checks on the C API. 683 | ** Define it as a help when debugging C code. 684 | */ 685 | #if defined(LUA_USE_APICHECK) 686 | #include 687 | #define luai_apicheck(l,e) assert(e) 688 | #endif 689 | 690 | /* }================================================================== */ 691 | 692 | 693 | /* 694 | ** {================================================================== 695 | ** Macros that affect the API and must be stable (that is, must be the 696 | ** same when you compile Lua and when you compile code that links to 697 | ** Lua). 698 | ** ===================================================================== 699 | */ 700 | 701 | /* 702 | @@ LUAI_MAXSTACK limits the size of the Lua stack. 703 | ** CHANGE it if you need a different limit. This limit is arbitrary; 704 | ** its only purpose is to stop Lua from consuming unlimited stack 705 | ** space (and to reserve some numbers for pseudo-indices). 706 | ** (It must fit into max(size_t)/32.) 707 | */ 708 | #if LUAI_IS32INT 709 | #define LUAI_MAXSTACK 1000000 710 | #else 711 | #define LUAI_MAXSTACK 15000 712 | #endif 713 | 714 | 715 | /* 716 | @@ LUA_EXTRASPACE defines the size of a raw memory area associated with 717 | ** a Lua state with very fast access. 718 | ** CHANGE it if you need a different size. 719 | */ 720 | #define LUA_EXTRASPACE (sizeof(void *)) 721 | 722 | 723 | /* 724 | @@ LUA_IDSIZE gives the maximum size for the description of the source 725 | @@ of a function in debug information. 726 | ** CHANGE it if you want a different size. 727 | */ 728 | #define LUA_IDSIZE 60 729 | 730 | 731 | /* 732 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. 733 | */ 734 | #define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number))) 735 | 736 | 737 | /* 738 | @@ LUAI_MAXALIGN defines fields that, when used in a union, ensure 739 | ** maximum alignment for the other items in that union. 740 | */ 741 | #define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l 742 | 743 | /* }================================================================== */ 744 | 745 | 746 | 747 | 748 | 749 | /* =================================================================== */ 750 | 751 | /* 752 | ** Local configuration. You can use this space to add your redefinitions 753 | ** without modifying the main part of the file. 754 | */ 755 | 756 | 757 | 758 | 759 | 760 | #endif 761 | 762 | -------------------------------------------------------------------------------- /contrib/Lua54/include/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_MATHLIBNAME "math" 39 | LUAMOD_API int (luaopen_math) (lua_State *L); 40 | 41 | #define LUA_DBLIBNAME "debug" 42 | LUAMOD_API int (luaopen_debug) (lua_State *L); 43 | 44 | #define LUA_LOADLIBNAME "package" 45 | LUAMOD_API int (luaopen_package) (lua_State *L); 46 | 47 | 48 | /* open all previous libraries */ 49 | LUALIB_API void (luaL_openlibs) (lua_State *L); 50 | 51 | 52 | 53 | #if !defined(lua_assert) 54 | #define lua_assert(x) ((void)0) 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /contrib/Lua54/lib/x64/lua54.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swerg/simple-lua-c-dll/29aff73595a967ac899d5452db15740df465d3b6/contrib/Lua54/lib/x64/lua54.lib -------------------------------------------------------------------------------- /lua-sample/luacdll-test1.lua: -------------------------------------------------------------------------------- 1 | package.cpath = package.cpath .. ";" .. getWorkingFolder() .. "\\lib5" .. _VERSION:sub(_VERSION:len()) .. "\\?.dll" 2 | 3 | luacdll = require("luacdll") 4 | 5 | OutText = "" 6 | 7 | OutText = OutText .. "GetCurrentThreadId() = " .. tostring(luacdll.GetCurrentThreadId()) .. "\n" 8 | 9 | r = luacdll.MultTwoNumbers(5.6, 2.17) 10 | OutText = OutText .. "MultTwoNumbers(5.6, 2.17) = " .. tostring(r) .. "\n" 11 | 12 | r = luacdll.MultAllNumbers(6, 3, "23423", {2.17}, 1.1) 13 | OutText = OutText .. 'MultAllNumbers(6, 3, "23423", {2.17}, 1.1) = ' .. tostring(r) .. "\n" 14 | 15 | message (OutText, 1) 16 | -------------------------------------------------------------------------------- /luacdll.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug-Lua53 6 | Win32 7 | 8 | 9 | Debug-Lua53 10 | x64 11 | 12 | 13 | Debug-Lua54 14 | Win32 15 | 16 | 17 | Debug-Lua54 18 | x64 19 | 20 | 21 | Debug 22 | Win32 23 | 24 | 25 | Debug 26 | x64 27 | 28 | 29 | Release-Lua53 30 | Win32 31 | 32 | 33 | Release-Lua53 34 | x64 35 | 36 | 37 | Release-Lua54 38 | Win32 39 | 40 | 41 | Release-Lua54 42 | x64 43 | 44 | 45 | Release 46 | Win32 47 | 48 | 49 | Release 50 | x64 51 | 52 | 53 | 54 | {46FAFD1A-37B2-46ED-AC3A-5BD9D507A95F} 55 | simpleluacdll 56 | Win32Proj 57 | 8.1 58 | 59 | 60 | 61 | DynamicLibrary 62 | v140 63 | MultiByte 64 | true 65 | 66 | 67 | DynamicLibrary 68 | v140 69 | MultiByte 70 | true 71 | 72 | 73 | DynamicLibrary 74 | v140 75 | MultiByte 76 | true 77 | 78 | 79 | DynamicLibrary 80 | v140 81 | MultiByte 82 | true 83 | 84 | 85 | DynamicLibrary 86 | v140 87 | MultiByte 88 | true 89 | 90 | 91 | DynamicLibrary 92 | v140 93 | MultiByte 94 | true 95 | 96 | 97 | DynamicLibrary 98 | v140 99 | MultiByte 100 | 101 | 102 | DynamicLibrary 103 | v140 104 | MultiByte 105 | 106 | 107 | DynamicLibrary 108 | v140 109 | MultiByte 110 | 111 | 112 | DynamicLibrary 113 | v140 114 | MultiByte 115 | 116 | 117 | DynamicLibrary 118 | v140 119 | MultiByte 120 | 121 | 122 | DynamicLibrary 123 | v140 124 | MultiByte 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 | <_ProjectFileVersion>14.0.25431.1 168 | 169 | 170 | true 171 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 172 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 173 | 174 | 175 | true 176 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 177 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 178 | 179 | 180 | true 181 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 182 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 183 | 184 | 185 | true 186 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 187 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 188 | 189 | 190 | true 191 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 192 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 193 | 194 | 195 | true 196 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 197 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 198 | 199 | 200 | false 201 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 202 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 203 | 204 | 205 | false 206 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 207 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 208 | 209 | 210 | false 211 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 212 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 213 | 214 | 215 | false 216 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 217 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 218 | 219 | 220 | false 221 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 222 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 223 | 224 | 225 | false 226 | $(SolutionDir).Build\$(Platform)\$(Configuration)\ 227 | $(SolutionDir).Build\$(Platform)\$(Configuration)\int\ 228 | 229 | 230 | 231 | Disabled 232 | WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 233 | true 234 | EnableFastChecks 235 | MultiThreaded 236 | 237 | Level3 238 | EditAndContinue 239 | .\contrib\Lua51\include\ 240 | 241 | 242 | .\contrib\Lua51\lib\x32\qlua.lib;%(AdditionalDependencies) 243 | true 244 | Windows 245 | MachineX86 246 | 247 | 248 | 249 | 250 | Disabled 251 | WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 252 | true 253 | EnableFastChecks 254 | MultiThreaded 255 | 256 | 257 | Level3 258 | EditAndContinue 259 | 260 | 261 | 262 | 263 | %(AdditionalDependencies) 264 | true 265 | Windows 266 | MachineX86 267 | 268 | 269 | 270 | 271 | Disabled 272 | WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 273 | true 274 | EnableFastChecks 275 | MultiThreaded 276 | 277 | 278 | Level3 279 | EditAndContinue 280 | 281 | 282 | 283 | 284 | %(AdditionalDependencies) 285 | true 286 | Windows 287 | MachineX86 288 | 289 | 290 | 291 | 292 | Disabled 293 | WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 294 | EnableFastChecks 295 | MultiThreaded 296 | 297 | 298 | Level3 299 | ProgramDatabase 300 | .\contrib\Lua51\include\ 301 | 302 | 303 | .\contrib\Lua51\lib\x64\qlua.lib;%(AdditionalDependencies) 304 | true 305 | Windows 306 | 307 | 308 | 309 | 310 | Disabled 311 | WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 312 | EnableFastChecks 313 | MultiThreaded 314 | 315 | 316 | Level3 317 | ProgramDatabase 318 | .\contrib\Lua53\include\ 319 | 320 | 321 | .\contrib\Lua53\lib\x64\lua53.lib;%(AdditionalDependencies) 322 | true 323 | Windows 324 | 325 | 326 | 327 | 328 | Disabled 329 | WIN32;_DEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 330 | EnableFastChecks 331 | MultiThreaded 332 | 333 | 334 | Level3 335 | ProgramDatabase 336 | .\contrib\Lua54\include\ 337 | 338 | 339 | .\contrib\Lua54\lib\x64\lua54.lib;%(AdditionalDependencies) 340 | true 341 | Windows 342 | 343 | 344 | 345 | 346 | MaxSpeed 347 | true 348 | WIN32;NDEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 349 | MultiThreaded 350 | true 351 | 352 | Level3 353 | ProgramDatabase 354 | Cdecl 355 | Default 356 | .\contrib\Lua51\include\ 357 | 358 | 359 | .\contrib\Lua51\lib\x32\qlua.lib;%(AdditionalDependencies) 360 | true 361 | Windows 362 | true 363 | true 364 | MachineX86 365 | 366 | 367 | 368 | 369 | MaxSpeed 370 | true 371 | WIN32;NDEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 372 | MultiThreaded 373 | true 374 | 375 | 376 | Level3 377 | ProgramDatabase 378 | Cdecl 379 | Default 380 | 381 | 382 | 383 | 384 | %(AdditionalDependencies) 385 | true 386 | Windows 387 | true 388 | true 389 | MachineX86 390 | 391 | 392 | 393 | 394 | MaxSpeed 395 | true 396 | WIN32;NDEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 397 | MultiThreaded 398 | true 399 | 400 | 401 | Level3 402 | ProgramDatabase 403 | Cdecl 404 | Default 405 | 406 | 407 | 408 | 409 | %(AdditionalDependencies) 410 | true 411 | Windows 412 | true 413 | true 414 | MachineX86 415 | 416 | 417 | 418 | 419 | MaxSpeed 420 | true 421 | WIN32;NDEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 422 | MultiThreaded 423 | true 424 | 425 | 426 | Level3 427 | ProgramDatabase 428 | Cdecl 429 | Default 430 | .\contrib\Lua51\include\ 431 | 432 | 433 | .\contrib\Lua51\lib\x64\qlua.lib;%(AdditionalDependencies) 434 | true 435 | Windows 436 | true 437 | true 438 | 439 | 440 | 441 | 442 | MaxSpeed 443 | true 444 | WIN32;NDEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 445 | MultiThreaded 446 | true 447 | 448 | 449 | Level3 450 | ProgramDatabase 451 | Cdecl 452 | Default 453 | .\contrib\Lua53\include\ 454 | 455 | 456 | .\contrib\Lua53\lib\x64\lua53.lib;%(AdditionalDependencies) 457 | true 458 | Windows 459 | true 460 | true 461 | 462 | 463 | 464 | 465 | MaxSpeed 466 | true 467 | WIN32;NDEBUG;_WINDOWS;_USRDLL;SIMPLELUACDLL_EXPORTS;%(PreprocessorDefinitions) 468 | MultiThreaded 469 | true 470 | 471 | 472 | Level3 473 | ProgramDatabase 474 | Cdecl 475 | Default 476 | .\contrib\Lua54\include\ 477 | 478 | 479 | .\contrib\Lua54\lib\x64\lua54.lib;%(AdditionalDependencies) 480 | true 481 | Windows 482 | true 483 | true 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | -------------------------------------------------------------------------------- /luacdll.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {954c60f4-b3b3-4620-ac48-f1dca9d0e0f1} 14 | 15 | 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Source Files 24 | 25 | 26 | 27 | 28 | Header Files\contrib 29 | 30 | 31 | Header Files\contrib 32 | 33 | 34 | Header Files\contrib 35 | 36 | 37 | -------------------------------------------------------------------------------- /make-arc.cmd: -------------------------------------------------------------------------------- 1 | md .bin\x32 2 | md .bin\x64-Lua51 3 | md .bin\x64-Lua53 4 | md .bin\x64-Lua54 5 | 6 | copy .Build\Win32\Release\*.dll .bin\x32 7 | copy .Build\x64\Release\*.dll .bin\x64-Lua51 8 | copy .Build\x64\Release-Lua53\*.dll .bin\x64-Lua53 9 | copy .Build\x64\Release-Lua54\*.dll .bin\x64-Lua54 10 | 11 | del /Q simple-lua-c-dll.zip 12 | 13 | "C:\Program Files\7-Zip\7z.exe" a -r -tZip simple-lua-c-dll.zip .bin\*.dll src\*.cpp src\*.h contrib\*.lib lua-sample\*.lua src\*.def luacdll.vcxproj luacdll.vcxproj.filters README.md 14 | 15 | rd /S /Q .bin -------------------------------------------------------------------------------- /src/luacdll.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swerg/simple-lua-c-dll/29aff73595a967ac899d5452db15740df465d3b6/src/luacdll.cpp -------------------------------------------------------------------------------- /src/luacdll.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | luaopen_luacdll 3 | --------------------------------------------------------------------------------