Mercurial > vba-linux
diff src/lua/lua.h @ 11:27763b933818
raise lua sources up one level
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 11:07:39 -0600 |
parents | src/lua/src/lua.h@f9f4f1b99eed |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/lua/lua.h Sat Mar 03 11:07:39 2012 -0600 1.3 @@ -0,0 +1,388 @@ 1.4 +/* 1.5 +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ 1.6 +** Lua - An Extensible Extension Language 1.7 +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 1.8 +** See Copyright Notice at the end of this file 1.9 +*/ 1.10 + 1.11 + 1.12 +#ifndef lua_h 1.13 +#define lua_h 1.14 + 1.15 +#include <stdarg.h> 1.16 +#include <stddef.h> 1.17 + 1.18 + 1.19 +#include "luaconf.h" 1.20 + 1.21 + 1.22 +#define LUA_VERSION "Lua 5.1" 1.23 +#define LUA_RELEASE "Lua 5.1.4" 1.24 +#define LUA_VERSION_NUM 501 1.25 +#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" 1.26 +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" 1.27 + 1.28 + 1.29 +/* mark for precompiled code (`<esc>Lua') */ 1.30 +#define LUA_SIGNATURE "\033Lua" 1.31 + 1.32 +/* option for multiple returns in `lua_pcall' and `lua_call' */ 1.33 +#define LUA_MULTRET (-1) 1.34 + 1.35 + 1.36 +/* 1.37 +** pseudo-indices 1.38 +*/ 1.39 +#define LUA_REGISTRYINDEX (-10000) 1.40 +#define LUA_ENVIRONINDEX (-10001) 1.41 +#define LUA_GLOBALSINDEX (-10002) 1.42 +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) 1.43 + 1.44 + 1.45 +/* thread status; 0 is OK */ 1.46 +#define LUA_YIELD 1 1.47 +#define LUA_ERRRUN 2 1.48 +#define LUA_ERRSYNTAX 3 1.49 +#define LUA_ERRMEM 4 1.50 +#define LUA_ERRERR 5 1.51 + 1.52 + 1.53 +typedef struct lua_State lua_State; 1.54 + 1.55 +typedef int (*lua_CFunction) (lua_State *L); 1.56 + 1.57 + 1.58 +/* 1.59 +** functions that read/write blocks when loading/dumping Lua chunks 1.60 +*/ 1.61 +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); 1.62 + 1.63 +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); 1.64 + 1.65 + 1.66 +/* 1.67 +** prototype for memory-allocation functions 1.68 +*/ 1.69 +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); 1.70 + 1.71 + 1.72 +/* 1.73 +** basic types 1.74 +*/ 1.75 +#define LUA_TNONE (-1) 1.76 + 1.77 +#define LUA_TNIL 0 1.78 +#define LUA_TBOOLEAN 1 1.79 +#define LUA_TLIGHTUSERDATA 2 1.80 +#define LUA_TNUMBER 3 1.81 +#define LUA_TSTRING 4 1.82 +#define LUA_TTABLE 5 1.83 +#define LUA_TFUNCTION 6 1.84 +#define LUA_TUSERDATA 7 1.85 +#define LUA_TTHREAD 8 1.86 + 1.87 + 1.88 + 1.89 +/* minimum Lua stack available to a C function */ 1.90 +#define LUA_MINSTACK 20 1.91 + 1.92 + 1.93 +/* 1.94 +** generic extra include file 1.95 +*/ 1.96 +#if defined(LUA_USER_H) 1.97 +#include LUA_USER_H 1.98 +#endif 1.99 + 1.100 + 1.101 +/* type of numbers in Lua */ 1.102 +typedef LUA_NUMBER lua_Number; 1.103 + 1.104 + 1.105 +/* type for integer functions */ 1.106 +typedef LUA_INTEGER lua_Integer; 1.107 + 1.108 + 1.109 + 1.110 +/* 1.111 +** state manipulation 1.112 +*/ 1.113 +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); 1.114 +LUA_API void (lua_close) (lua_State *L); 1.115 +LUA_API lua_State *(lua_newthread) (lua_State *L); 1.116 + 1.117 +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); 1.118 + 1.119 + 1.120 +/* 1.121 +** basic stack manipulation 1.122 +*/ 1.123 +LUA_API int (lua_gettop) (lua_State *L); 1.124 +LUA_API void (lua_settop) (lua_State *L, int idx); 1.125 +LUA_API void (lua_pushvalue) (lua_State *L, int idx); 1.126 +LUA_API void (lua_remove) (lua_State *L, int idx); 1.127 +LUA_API void (lua_insert) (lua_State *L, int idx); 1.128 +LUA_API void (lua_replace) (lua_State *L, int idx); 1.129 +LUA_API int (lua_checkstack) (lua_State *L, int sz); 1.130 + 1.131 +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); 1.132 + 1.133 + 1.134 +/* 1.135 +** access functions (stack -> C) 1.136 +*/ 1.137 + 1.138 +LUA_API int (lua_isnumber) (lua_State *L, int idx); 1.139 +LUA_API int (lua_isstring) (lua_State *L, int idx); 1.140 +LUA_API int (lua_iscfunction) (lua_State *L, int idx); 1.141 +LUA_API int (lua_isuserdata) (lua_State *L, int idx); 1.142 +LUA_API int (lua_type) (lua_State *L, int idx); 1.143 +LUA_API const char *(lua_typename) (lua_State *L, int tp); 1.144 + 1.145 +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); 1.146 +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); 1.147 +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); 1.148 + 1.149 +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); 1.150 +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); 1.151 +LUA_API int (lua_toboolean) (lua_State *L, int idx); 1.152 +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); 1.153 +LUA_API size_t (lua_objlen) (lua_State *L, int idx); 1.154 +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); 1.155 +LUA_API void *(lua_touserdata) (lua_State *L, int idx); 1.156 +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); 1.157 +LUA_API const void *(lua_topointer) (lua_State *L, int idx); 1.158 + 1.159 + 1.160 +/* 1.161 +** push functions (C -> stack) 1.162 +*/ 1.163 +LUA_API void (lua_pushnil) (lua_State *L); 1.164 +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); 1.165 +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); 1.166 +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); 1.167 +LUA_API void (lua_pushstring) (lua_State *L, const char *s); 1.168 +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, 1.169 + va_list argp); 1.170 +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); 1.171 +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); 1.172 +LUA_API void (lua_pushboolean) (lua_State *L, int b); 1.173 +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); 1.174 +LUA_API int (lua_pushthread) (lua_State *L); 1.175 + 1.176 + 1.177 +/* 1.178 +** get functions (Lua -> stack) 1.179 +*/ 1.180 +LUA_API void (lua_gettable) (lua_State *L, int idx); 1.181 +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); 1.182 +LUA_API void (lua_rawget) (lua_State *L, int idx); 1.183 +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); 1.184 +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); 1.185 +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); 1.186 +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); 1.187 +LUA_API void (lua_getfenv) (lua_State *L, int idx); 1.188 + 1.189 + 1.190 +/* 1.191 +** set functions (stack -> Lua) 1.192 +*/ 1.193 +LUA_API void (lua_settable) (lua_State *L, int idx); 1.194 +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); 1.195 +LUA_API void (lua_rawset) (lua_State *L, int idx); 1.196 +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); 1.197 +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); 1.198 +LUA_API int (lua_setfenv) (lua_State *L, int idx); 1.199 + 1.200 + 1.201 +/* 1.202 +** `load' and `call' functions (load and run Lua code) 1.203 +*/ 1.204 +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); 1.205 +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); 1.206 +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); 1.207 +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, 1.208 + const char *chunkname); 1.209 + 1.210 +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); 1.211 + 1.212 + 1.213 +/* 1.214 +** coroutine functions 1.215 +*/ 1.216 +LUA_API int (lua_yield) (lua_State *L, int nresults); 1.217 +LUA_API int (lua_resume) (lua_State *L, int narg); 1.218 +LUA_API int (lua_status) (lua_State *L); 1.219 + 1.220 +/* 1.221 +** garbage-collection function and options 1.222 +*/ 1.223 + 1.224 +#define LUA_GCSTOP 0 1.225 +#define LUA_GCRESTART 1 1.226 +#define LUA_GCCOLLECT 2 1.227 +#define LUA_GCCOUNT 3 1.228 +#define LUA_GCCOUNTB 4 1.229 +#define LUA_GCSTEP 5 1.230 +#define LUA_GCSETPAUSE 6 1.231 +#define LUA_GCSETSTEPMUL 7 1.232 + 1.233 +LUA_API int (lua_gc) (lua_State *L, int what, int data); 1.234 + 1.235 + 1.236 +/* 1.237 +** miscellaneous functions 1.238 +*/ 1.239 + 1.240 +LUA_API int (lua_error) (lua_State *L); 1.241 + 1.242 +LUA_API int (lua_next) (lua_State *L, int idx); 1.243 + 1.244 +LUA_API void (lua_concat) (lua_State *L, int n); 1.245 + 1.246 +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); 1.247 +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); 1.248 + 1.249 + 1.250 + 1.251 +/* 1.252 +** =============================================================== 1.253 +** some useful macros 1.254 +** =============================================================== 1.255 +*/ 1.256 + 1.257 +#define lua_pop(L,n) lua_settop(L, -(n)-1) 1.258 + 1.259 +#define lua_newtable(L) lua_createtable(L, 0, 0) 1.260 + 1.261 +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) 1.262 + 1.263 +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) 1.264 + 1.265 +#define lua_strlen(L,i) lua_objlen(L, (i)) 1.266 + 1.267 +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) 1.268 +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) 1.269 +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) 1.270 +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) 1.271 +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) 1.272 +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) 1.273 +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) 1.274 +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) 1.275 + 1.276 +#define lua_pushliteral(L, s) \ 1.277 + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) 1.278 + 1.279 +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) 1.280 +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) 1.281 + 1.282 +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) 1.283 + 1.284 + 1.285 + 1.286 +/* 1.287 +** compatibility macros and functions 1.288 +*/ 1.289 + 1.290 +#define lua_open() luaL_newstate() 1.291 + 1.292 +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) 1.293 + 1.294 +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) 1.295 + 1.296 +#define lua_Chunkreader lua_Reader 1.297 +#define lua_Chunkwriter lua_Writer 1.298 + 1.299 + 1.300 +/* hack */ 1.301 +LUA_API void lua_setlevel (lua_State *from, lua_State *to); 1.302 + 1.303 + 1.304 +/* 1.305 +** {====================================================================== 1.306 +** Debug API 1.307 +** ======================================================================= 1.308 +*/ 1.309 + 1.310 + 1.311 +/* 1.312 +** Event codes 1.313 +*/ 1.314 +#define LUA_HOOKCALL 0 1.315 +#define LUA_HOOKRET 1 1.316 +#define LUA_HOOKLINE 2 1.317 +#define LUA_HOOKCOUNT 3 1.318 +#define LUA_HOOKTAILRET 4 1.319 + 1.320 + 1.321 +/* 1.322 +** Event masks 1.323 +*/ 1.324 +#define LUA_MASKCALL (1 << LUA_HOOKCALL) 1.325 +#define LUA_MASKRET (1 << LUA_HOOKRET) 1.326 +#define LUA_MASKLINE (1 << LUA_HOOKLINE) 1.327 +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) 1.328 + 1.329 +typedef struct lua_Debug lua_Debug; /* activation record */ 1.330 + 1.331 + 1.332 +/* Functions to be called by the debuger in specific events */ 1.333 +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); 1.334 + 1.335 + 1.336 +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); 1.337 +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); 1.338 +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); 1.339 +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); 1.340 +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); 1.341 +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); 1.342 + 1.343 +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); 1.344 +LUA_API lua_Hook lua_gethook (lua_State *L); 1.345 +LUA_API int lua_gethookmask (lua_State *L); 1.346 +LUA_API int lua_gethookcount (lua_State *L); 1.347 + 1.348 + 1.349 +struct lua_Debug { 1.350 + int event; 1.351 + const char *name; /* (n) */ 1.352 + const char *namewhat; /* (n) `global', `local', `field', `method' */ 1.353 + const char *what; /* (S) `Lua', `C', `main', `tail' */ 1.354 + const char *source; /* (S) */ 1.355 + int currentline; /* (l) */ 1.356 + int nups; /* (u) number of upvalues */ 1.357 + int linedefined; /* (S) */ 1.358 + int lastlinedefined; /* (S) */ 1.359 + char short_src[LUA_IDSIZE]; /* (S) */ 1.360 + /* private part */ 1.361 + int i_ci; /* active function */ 1.362 +}; 1.363 + 1.364 +/* }====================================================================== */ 1.365 + 1.366 + 1.367 +/****************************************************************************** 1.368 +* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. 1.369 +* 1.370 +* Permission is hereby granted, free of charge, to any person obtaining 1.371 +* a copy of this software and associated documentation files (the 1.372 +* "Software"), to deal in the Software without restriction, including 1.373 +* without limitation the rights to use, copy, modify, merge, publish, 1.374 +* distribute, sublicense, and/or sell copies of the Software, and to 1.375 +* permit persons to whom the Software is furnished to do so, subject to 1.376 +* the following conditions: 1.377 +* 1.378 +* The above copyright notice and this permission notice shall be 1.379 +* included in all copies or substantial portions of the Software. 1.380 +* 1.381 +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1.382 +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1.383 +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 1.384 +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 1.385 +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 1.386 +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 1.387 +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1.388 +******************************************************************************/ 1.389 + 1.390 + 1.391 +#endif