Lua 5.1.4: lauxlib.h

This is the public interface of the "Auxiliary Library".
L0001 /* L0002 ** $Id: lauxlib.h,v 2007/12/27 13:02:25 roberto Exp $ L0003 ** Auxiliary functions for building Lua libraries L0004 ** See Copyright Notice in lua.h L0005 */ L0006 L0007 L0008 #ifndef lauxlib_h L0009 #define lauxlib_h L0010 L0011 L0012 #include <stddef.h> L0013 #include <stdio.h> L0014 L0015 #include "lua.h" L0016 L0017 L0018 #if defined(LUA_COMPAT_GETN) L0019 LUALIB_API int (luaL_getn) (lua_State *L, int t); L0020 LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); L0021 #else L0022 #define luaL_getn(L,i) ((int)lua_objlen(L, i)) L0023 #define luaL_setn(L,i,j) ((void)0) /* no op! */ L0024 #endif L0025 L0026 #if defined(LUA_COMPAT_OPENLIB) L0027 #define luaI_openlib luaL_openlib L0028 #endif L0029 L0030 L0031 /* extra error code for `luaL_load' */ L0032 #define LUA_ERRFILE (LUA_ERRERR+1) L0033 L0034 L0035 typedef struct luaL_Reg { L0036 const char *name; L0037 lua_CFunction func; L0038 } luaL_Reg; L0039 L0040 L0041 L0042 LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, L0043 const luaL_Reg *l, int nup); L0044 LUALIB_API void (luaL_register) (lua_State *L, const char *libname, L0045 const luaL_Reg *l); L0046 LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); L0047 LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); L0048 LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); L0049 LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); L0050 LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, L0051 size_t *l); L0052 LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, L0053 const char *def, size_t *l); L0054 LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); L0055 LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); L0056 L0057 LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); L0058 LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, L0059 lua_Integer def); L0060 L0061 LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); L0062 LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); L0063 LUALIB_API void (luaL_checkany) (lua_State *L, int narg); L0064 L0065 LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); L0066 LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); L0067 L0068 LUALIB_API void (luaL_where) (lua_State *L, int lvl); L0069 LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); L0070 L0071 LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, L0072 const char *const lst[]); L0073 L0074 LUALIB_API int (luaL_ref) (lua_State *L, int t); L0075 LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); L0076 L0077 LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); L0078 LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, L0079 const char *name); L0080 LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); L0081 L0082 LUALIB_API lua_State *(luaL_newstate) (void); L0083 L0084 L0085 LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, L0086 const char *r); L0087 L0088 LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, L0089 const char *fname, int szhint); L0090 L0091 L0092 L0093 L0094 /* L0095 ** =============================================================== L0096 ** some useful macros L0097 ** =============================================================== L0098 */ L0099 L0100 #define luaL_argcheck(L, cond,numarg,extramsg) \ L0101 ((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
void luaL_argcheck (lua_State *L, int cond, int narg, const char *extramsg); [-0, +0, v]
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) L0103 #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) L0104 #define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) L0105 #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) L0106 #define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) L0107 #define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) L0108 L0109 #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) L0110 L0111 #define luaL_dofile(L, fn) \ L0112 (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) L0113 L0114 #define luaL_dostring(L, s) \ L0115 (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) L0116 L0117 #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) L0118 L0119 #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) L0120 L0121 /* L0122 ** {====================================================== L0123 ** Generic Buffer manipulation L0124 ** ======================================================= L0125 */ L0126 L0127 L0128 L0129 typedef struct luaL_Buffer { L0130 char *p; /* current position in buffer */ L0131 int lvl; /* number of strings in the stack (level) */ L0132 lua_State *L; L0133 char buffer[LUAL_BUFFERSIZE]; L0134 } luaL_Buffer; L0135 L0136 #define luaL_addchar(B,c) \ L0137 ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ L0138 (*(B)->p++ = (char)(c))) L0139 L0140 /* compatibility only */ L0141 #define luaL_putchar(B,c) luaL_addchar(B,c) L0142 L0143 #define luaL_addsize(B,n) ((B)->p += (n)) L0144 L0145 LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); L0146 LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); L0147 LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); L0148 LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); L0149 LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); L0150 LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); L0151 L0152 L0153 /* }====================================================== */ L0154 L0155 L0156 /* compatibility with ref system */ L0157 L0158 /* pre-defined references */ L0159 #define LUA_NOREF (-2) L0160 #define LUA_REFNIL (-1) L0161 L0162 #define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ L0163 (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) L0164 L0165 #define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) L0166 L0167 #define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) L0168 L0169 L0170 #define luaL_reg luaL_Reg L0171 L0172 #endif L0173 L0174

Generated by