]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/Include/Lua/lua.h
AppPkg: Add the Lua interpreter and library.
[mirror_edk2.git] / StdLib / Include / Lua / lua.h
diff --git a/StdLib/Include/Lua/lua.h b/StdLib/Include/Lua/lua.h
new file mode 100644 (file)
index 0000000..bf3a2e2
--- /dev/null
@@ -0,0 +1,444 @@
+/*\r
+** $Id: lua.h,v 1.285.1.2 2013/11/11 12:09:16 roberto Exp $\r
+** Lua - A Scripting Language\r
+** Lua.org, PUC-Rio, Brazil (http://www.lua.org)\r
+** See Copyright Notice at the end of this file\r
+*/\r
+\r
+\r
+#ifndef lua_h\r
+#define lua_h\r
+\r
+#include <stdarg.h>\r
+#include <stddef.h>\r
+\r
+\r
+#include <Lua/luaconf.h>\r
+\r
+\r
+#define LUA_VERSION_MAJOR   "5"\r
+#define LUA_VERSION_MINOR   "2"\r
+#define LUA_VERSION_NUM     502\r
+#define LUA_VERSION_RELEASE "3"\r
+\r
+#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR\r
+#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE\r
+#define LUA_COPYRIGHT   LUA_RELEASE "  Copyright (C) 1994-2013 Lua.org, PUC-Rio"\r
+#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"\r
+\r
+\r
+/* mark for precompiled code ('<esc>Lua') */\r
+#define LUA_SIGNATURE   "\033Lua"\r
+\r
+/* option for multiple returns in 'lua_pcall' and 'lua_call' */\r
+#define LUA_MULTRET (-1)\r
+\r
+\r
+/*\r
+** pseudo-indices\r
+*/\r
+#define LUA_REGISTRYINDEX   LUAI_FIRSTPSEUDOIDX\r
+#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i))\r
+\r
+\r
+/* thread status */\r
+#define LUA_OK      0\r
+#define LUA_YIELD   1\r
+#define LUA_ERRRUN  2\r
+#define LUA_ERRSYNTAX   3\r
+#define LUA_ERRMEM  4\r
+#define LUA_ERRGCMM 5\r
+#define LUA_ERRERR  6\r
+\r
+\r
+typedef struct lua_State lua_State;\r
+\r
+typedef int (*lua_CFunction) (lua_State *L);\r
+\r
+\r
+/*\r
+** functions that read/write blocks when loading/dumping Lua chunks\r
+*/\r
+typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);\r
+\r
+typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);\r
+\r
+\r
+/*\r
+** prototype for memory-allocation functions\r
+*/\r
+typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);\r
+\r
+\r
+/*\r
+** basic types\r
+*/\r
+#define LUA_TNONE       (-1)\r
+\r
+#define LUA_TNIL        0\r
+#define LUA_TBOOLEAN        1\r
+#define LUA_TLIGHTUSERDATA  2\r
+#define LUA_TNUMBER     3\r
+#define LUA_TSTRING     4\r
+#define LUA_TTABLE      5\r
+#define LUA_TFUNCTION       6\r
+#define LUA_TUSERDATA       7\r
+#define LUA_TTHREAD     8\r
+\r
+#define LUA_NUMTAGS     9\r
+\r
+\r
+\r
+/* minimum Lua stack available to a C function */\r
+#define LUA_MINSTACK    20\r
+\r
+\r
+/* predefined values in the registry */\r
+#define LUA_RIDX_MAINTHREAD 1\r
+#define LUA_RIDX_GLOBALS    2\r
+#define LUA_RIDX_LAST       LUA_RIDX_GLOBALS\r
+\r
+\r
+/* type of numbers in Lua */\r
+typedef LUA_NUMBER lua_Number;\r
+\r
+\r
+/* type for integer functions */\r
+typedef LUA_INTEGER lua_Integer;\r
+\r
+/* unsigned integer type */\r
+typedef LUA_UNSIGNED lua_Unsigned;\r
+\r
+\r
+\r
+/*\r
+** generic extra include file\r
+*/\r
+#if defined(LUA_USER_H)\r
+#include LUA_USER_H\r
+#endif\r
+\r
+\r
+/*\r
+** RCS ident string\r
+*/\r
+extern const char lua_ident[];\r
+\r
+\r
+/*\r
+** state manipulation\r
+*/\r
+LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);\r
+LUA_API void       (lua_close) (lua_State *L);\r
+LUA_API lua_State *(lua_newthread) (lua_State *L);\r
+\r
+LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);\r
+\r
+\r
+LUA_API const lua_Number *(lua_version) (lua_State *L);\r
+\r
+\r
+/*\r
+** basic stack manipulation\r
+*/\r
+LUA_API int   (lua_absindex) (lua_State *L, int idx);\r
+LUA_API int   (lua_gettop) (lua_State *L);\r
+LUA_API void  (lua_settop) (lua_State *L, int idx);\r
+LUA_API void  (lua_pushvalue) (lua_State *L, int idx);\r
+LUA_API void  (lua_remove) (lua_State *L, int idx);\r
+LUA_API void  (lua_insert) (lua_State *L, int idx);\r
+LUA_API void  (lua_replace) (lua_State *L, int idx);\r
+LUA_API void  (lua_copy) (lua_State *L, int fromidx, int toidx);\r
+LUA_API int   (lua_checkstack) (lua_State *L, int sz);\r
+\r
+LUA_API void  (lua_xmove) (lua_State *from, lua_State *to, int n);\r
+\r
+\r
+/*\r
+** access functions (stack -> C)\r
+*/\r
+\r
+LUA_API int             (lua_isnumber) (lua_State *L, int idx);\r
+LUA_API int             (lua_isstring) (lua_State *L, int idx);\r
+LUA_API int             (lua_iscfunction) (lua_State *L, int idx);\r
+LUA_API int             (lua_isuserdata) (lua_State *L, int idx);\r
+LUA_API int             (lua_type) (lua_State *L, int idx);\r
+LUA_API const char     *(lua_typename) (lua_State *L, int tp);\r
+\r
+LUA_API lua_Number      (lua_tonumberx) (lua_State *L, int idx, int *isnum);\r
+LUA_API lua_Integer     (lua_tointegerx) (lua_State *L, int idx, int *isnum);\r
+LUA_API lua_Unsigned    (lua_tounsignedx) (lua_State *L, int idx, int *isnum);\r
+LUA_API int             (lua_toboolean) (lua_State *L, int idx);\r
+LUA_API const char     *(lua_tolstring) (lua_State *L, int idx, size_t *len);\r
+LUA_API size_t          (lua_rawlen) (lua_State *L, int idx);\r
+LUA_API lua_CFunction   (lua_tocfunction) (lua_State *L, int idx);\r
+LUA_API void           *(lua_touserdata) (lua_State *L, int idx);\r
+LUA_API lua_State      *(lua_tothread) (lua_State *L, int idx);\r
+LUA_API const void     *(lua_topointer) (lua_State *L, int idx);\r
+\r
+\r
+/*\r
+** Comparison and arithmetic functions\r
+*/\r
+\r
+#define LUA_OPADD   0   /* ORDER TM */\r
+#define LUA_OPSUB   1\r
+#define LUA_OPMUL   2\r
+#define LUA_OPDIV   3\r
+#define LUA_OPMOD   4\r
+#define LUA_OPPOW   5\r
+#define LUA_OPUNM   6\r
+\r
+LUA_API void  (lua_arith) (lua_State *L, int op);\r
+\r
+#define LUA_OPEQ    0\r
+#define LUA_OPLT    1\r
+#define LUA_OPLE    2\r
+\r
+LUA_API int   (lua_rawequal) (lua_State *L, int idx1, int idx2);\r
+LUA_API int   (lua_compare) (lua_State *L, int idx1, int idx2, int op);\r
+\r
+\r
+/*\r
+** push functions (C -> stack)\r
+*/\r
+LUA_API void        (lua_pushnil) (lua_State *L);\r
+LUA_API void        (lua_pushnumber) (lua_State *L, lua_Number n);\r
+LUA_API void        (lua_pushinteger) (lua_State *L, lua_Integer n);\r
+LUA_API void        (lua_pushunsigned) (lua_State *L, lua_Unsigned n);\r
+LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);\r
+LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);\r
+LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,\r
+                                                      va_list argp);\r
+LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);\r
+LUA_API void  (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);\r
+LUA_API void  (lua_pushboolean) (lua_State *L, int b);\r
+LUA_API void  (lua_pushlightuserdata) (lua_State *L, void *p);\r
+LUA_API int   (lua_pushthread) (lua_State *L);\r
+\r
+\r
+/*\r
+** get functions (Lua -> stack)\r
+*/\r
+LUA_API void  (lua_getglobal) (lua_State *L, const char *var);\r
+LUA_API void  (lua_gettable) (lua_State *L, int idx);\r
+LUA_API void  (lua_getfield) (lua_State *L, int idx, const char *k);\r
+LUA_API void  (lua_rawget) (lua_State *L, int idx);\r
+LUA_API void  (lua_rawgeti) (lua_State *L, int idx, int n);\r
+LUA_API void  (lua_rawgetp) (lua_State *L, int idx, const void *p);\r
+LUA_API void  (lua_createtable) (lua_State *L, int narr, int nrec);\r
+LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);\r
+LUA_API int   (lua_getmetatable) (lua_State *L, int objindex);\r
+LUA_API void  (lua_getuservalue) (lua_State *L, int idx);\r
+\r
+\r
+/*\r
+** set functions (stack -> Lua)\r
+*/\r
+LUA_API void  (lua_setglobal) (lua_State *L, const char *var);\r
+LUA_API void  (lua_settable) (lua_State *L, int idx);\r
+LUA_API void  (lua_setfield) (lua_State *L, int idx, const char *k);\r
+LUA_API void  (lua_rawset) (lua_State *L, int idx);\r
+LUA_API void  (lua_rawseti) (lua_State *L, int idx, int n);\r
+LUA_API void  (lua_rawsetp) (lua_State *L, int idx, const void *p);\r
+LUA_API int   (lua_setmetatable) (lua_State *L, int objindex);\r
+LUA_API void  (lua_setuservalue) (lua_State *L, int idx);\r
+\r
+\r
+/*\r
+** 'load' and 'call' functions (load and run Lua code)\r
+*/\r
+LUA_API void  (lua_callk) (lua_State *L, int nargs, int nresults, int ctx,\r
+                           lua_CFunction k);\r
+#define lua_call(L,n,r)     lua_callk(L, (n), (r), 0, NULL)\r
+\r
+LUA_API int   (lua_getctx) (lua_State *L, int *ctx);\r
+\r
+LUA_API int   (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,\r
+                            int ctx, lua_CFunction k);\r
+#define lua_pcall(L,n,r,f)  lua_pcallk(L, (n), (r), (f), 0, NULL)\r
+\r
+LUA_API int   (lua_load) (lua_State *L, lua_Reader reader, void *dt,\r
+                                        const char *chunkname,\r
+                                        const char *mode);\r
+\r
+LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);\r
+\r
+\r
+/*\r
+** coroutine functions\r
+*/\r
+LUA_API int  (lua_yieldk) (lua_State *L, int nresults, int ctx,\r
+                           lua_CFunction k);\r
+#define lua_yield(L,n)      lua_yieldk(L, (n), 0, NULL)\r
+LUA_API int  (lua_resume) (lua_State *L, lua_State *from, int narg);\r
+LUA_API int  (lua_status) (lua_State *L);\r
+\r
+/*\r
+** garbage-collection function and options\r
+*/\r
+\r
+#define LUA_GCSTOP      0\r
+#define LUA_GCRESTART       1\r
+#define LUA_GCCOLLECT       2\r
+#define LUA_GCCOUNT     3\r
+#define LUA_GCCOUNTB        4\r
+#define LUA_GCSTEP      5\r
+#define LUA_GCSETPAUSE      6\r
+#define LUA_GCSETSTEPMUL    7\r
+#define LUA_GCSETMAJORINC   8\r
+#define LUA_GCISRUNNING     9\r
+#define LUA_GCGEN       10\r
+#define LUA_GCINC       11\r
+\r
+LUA_API int (lua_gc) (lua_State *L, int what, int data);\r
+\r
+\r
+/*\r
+** miscellaneous functions\r
+*/\r
+\r
+LUA_API int (lua_error) (lua_State *L);\r
+\r
+LUA_API int   (lua_next) (lua_State *L, int idx);\r
+\r
+LUA_API void  (lua_concat) (lua_State *L, int n);\r
+LUA_API void  (lua_len)    (lua_State *L, int idx);\r
+\r
+LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);\r
+LUA_API void      (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud);\r
+\r
+\r
+\r
+/*\r
+** ===============================================================\r
+** some useful macros\r
+** ===============================================================\r
+*/\r
+\r
+#define lua_tonumber(L,i)   lua_tonumberx(L,i,NULL)\r
+#define lua_tointeger(L,i)  lua_tointegerx(L,i,NULL)\r
+#define lua_tounsigned(L,i) lua_tounsignedx(L,i,NULL)\r
+\r
+#define lua_pop(L,n)        lua_settop(L, -(n)-1)\r
+\r
+#define lua_newtable(L)     lua_createtable(L, 0, 0)\r
+\r
+#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))\r
+\r
+#define lua_pushcfunction(L,f)  lua_pushcclosure(L, (f), 0)\r
+\r
+#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)\r
+#define lua_istable(L,n)    (lua_type(L, (n)) == LUA_TTABLE)\r
+#define lua_islightuserdata(L,n)    (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)\r
+#define lua_isnil(L,n)      (lua_type(L, (n)) == LUA_TNIL)\r
+#define lua_isboolean(L,n)  (lua_type(L, (n)) == LUA_TBOOLEAN)\r
+#define lua_isthread(L,n)   (lua_type(L, (n)) == LUA_TTHREAD)\r
+#define lua_isnone(L,n)     (lua_type(L, (n)) == LUA_TNONE)\r
+#define lua_isnoneornil(L, n)   (lua_type(L, (n)) <= 0)\r
+\r
+#define lua_pushliteral(L, s)   \\r
+    lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)\r
+\r
+#define lua_pushglobaltable(L)  \\r
+    lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS)\r
+\r
+#define lua_tostring(L,i)   lua_tolstring(L, (i), NULL)\r
+\r
+\r
+\r
+/*\r
+** {======================================================================\r
+** Debug API\r
+** =======================================================================\r
+*/\r
+\r
+\r
+/*\r
+** Event codes\r
+*/\r
+#define LUA_HOOKCALL    0\r
+#define LUA_HOOKRET 1\r
+#define LUA_HOOKLINE    2\r
+#define LUA_HOOKCOUNT   3\r
+#define LUA_HOOKTAILCALL 4\r
+\r
+\r
+/*\r
+** Event masks\r
+*/\r
+#define LUA_MASKCALL    (1 << LUA_HOOKCALL)\r
+#define LUA_MASKRET (1 << LUA_HOOKRET)\r
+#define LUA_MASKLINE    (1 << LUA_HOOKLINE)\r
+#define LUA_MASKCOUNT   (1 << LUA_HOOKCOUNT)\r
+\r
+typedef struct lua_Debug lua_Debug;  /* activation record */\r
+\r
+\r
+/* Functions to be called by the debugger in specific events */\r
+typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);\r
+\r
+\r
+LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar);\r
+LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar);\r
+LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n);\r
+LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n);\r
+LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n);\r
+LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n);\r
+\r
+LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n);\r
+LUA_API void  (lua_upvaluejoin) (lua_State *L, int fidx1, int n1,\r
+                                               int fidx2, int n2);\r
+\r
+LUA_API int (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count);\r
+LUA_API lua_Hook (lua_gethook) (lua_State *L);\r
+LUA_API int (lua_gethookmask) (lua_State *L);\r
+LUA_API int (lua_gethookcount) (lua_State *L);\r
+\r
+\r
+struct lua_Debug {\r
+  int event;\r
+  const char *name; /* (n) */\r
+  const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */\r
+  const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */\r
+  const char *source;   /* (S) */\r
+  int currentline;  /* (l) */\r
+  int linedefined;  /* (S) */\r
+  int lastlinedefined;  /* (S) */\r
+  unsigned char nups;   /* (u) number of upvalues */\r
+  unsigned char nparams;/* (u) number of parameters */\r
+  char isvararg;        /* (u) */\r
+  char istailcall;  /* (t) */\r
+  char short_src[LUA_IDSIZE]; /* (S) */\r
+  /* private part */\r
+  struct CallInfo *i_ci;  /* active function */\r
+};\r
+\r
+/* }====================================================================== */\r
+\r
+\r
+/******************************************************************************\r
+* Copyright (C) 1994-2013 Lua.org, PUC-Rio.\r
+*\r
+* Permission is hereby granted, free of charge, to any person obtaining\r
+* a copy of this software and associated documentation files (the\r
+* "Software"), to deal in the Software without restriction, including\r
+* without limitation the rights to use, copy, modify, merge, publish,\r
+* distribute, sublicense, and/or sell copies of the Software, and to\r
+* permit persons to whom the Software is furnished to do so, subject to\r
+* the following conditions:\r
+*\r
+* The above copyright notice and this permission notice shall be\r
+* included in all copies or substantial portions of the Software.\r
+*\r
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\r
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\r
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r
+* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+******************************************************************************/\r
+\r
+\r
+#endif\r