diff options
Diffstat (limited to '')
| -rw-r--r-- | lauxlib.h | 23 |
1 files changed, 20 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.h,v 1.79 2005/05/31 14:34:02 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.80 2005/07/13 19:02:42 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -20,6 +20,10 @@ | |||
| 20 | #define luaL_setn(L,i,j) ((void)0) /* no op! */ | 20 | #define luaL_setn(L,i,j) ((void)0) /* no op! */ |
| 21 | #endif | 21 | #endif |
| 22 | 22 | ||
| 23 | #if defined(LUA_COMPAT_OPENLIB) | ||
| 24 | #define luaI_openlib luaL_openlib | ||
| 25 | #endif | ||
| 26 | |||
| 23 | 27 | ||
| 24 | /* extra error code for `luaL_load' */ | 28 | /* extra error code for `luaL_load' */ |
| 25 | #define LUA_ERRFILE (LUA_ERRERR+1) | 29 | #define LUA_ERRFILE (LUA_ERRERR+1) |
| @@ -31,8 +35,11 @@ typedef struct luaL_reg { | |||
| 31 | } luaL_reg; | 35 | } luaL_reg; |
| 32 | 36 | ||
| 33 | 37 | ||
| 34 | LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, | 38 | |
| 39 | LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, | ||
| 35 | const luaL_reg *l, int nup); | 40 | const luaL_reg *l, int nup); |
| 41 | LUALIB_API void (luaL_register) (lua_State *L, const char *libname, | ||
| 42 | const luaL_reg *l); | ||
| 36 | LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); | 43 | LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); |
| 37 | LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); | 44 | LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); |
| 38 | LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); | 45 | LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); |
| @@ -71,6 +78,7 @@ LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); | |||
| 71 | LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); | 78 | LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); |
| 72 | LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, | 79 | LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, |
| 73 | const char *name); | 80 | const char *name); |
| 81 | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); | ||
| 74 | 82 | ||
| 75 | LUALIB_API lua_State *(luaL_newstate) (void); | 83 | LUALIB_API lua_State *(luaL_newstate) (void); |
| 76 | 84 | ||
| @@ -84,6 +92,7 @@ LUALIB_API const char *(luaL_setfield) (lua_State *L, int idx, | |||
| 84 | 92 | ||
| 85 | 93 | ||
| 86 | 94 | ||
| 95 | |||
| 87 | /* | 96 | /* |
| 88 | ** =============================================================== | 97 | ** =============================================================== |
| 89 | ** some useful macros | 98 | ** some useful macros |
| @@ -101,6 +110,11 @@ LUALIB_API const char *(luaL_setfield) (lua_State *L, int idx, | |||
| 101 | 110 | ||
| 102 | #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) | 111 | #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) |
| 103 | 112 | ||
| 113 | #define luaL_dofile(L, fn) (luaL_loadfile(L, fn) || lua_pcall(L, 0, 0, 0)) | ||
| 114 | |||
| 115 | #define luaL_dostring(L, s) (luaL_loadstring(L, s) || lua_pcall(L, 0, 0, 0)) | ||
| 116 | |||
| 117 | |||
| 104 | /* | 118 | /* |
| 105 | ** {====================================================== | 119 | ** {====================================================== |
| 106 | ** Generic Buffer manipulation | 120 | ** Generic Buffer manipulation |
| @@ -116,10 +130,13 @@ typedef struct luaL_Buffer { | |||
| 116 | char buffer[LUAL_BUFFERSIZE]; | 130 | char buffer[LUAL_BUFFERSIZE]; |
| 117 | } luaL_Buffer; | 131 | } luaL_Buffer; |
| 118 | 132 | ||
| 119 | #define luaL_putchar(B,c) \ | 133 | #define luaL_addchar(B,c) \ |
| 120 | ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ | 134 | ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ |
| 121 | (*(B)->p++ = (char)(c))) | 135 | (*(B)->p++ = (char)(c))) |
| 122 | 136 | ||
| 137 | /* compatibility only */ | ||
| 138 | #define luaL_putchar(B,c) luaL_addchar(B,c) | ||
| 139 | |||
| 123 | #define luaL_addsize(B,n) ((B)->p += (n)) | 140 | #define luaL_addsize(B,n) ((B)->p += (n)) |
| 124 | 141 | ||
| 125 | LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); | 142 | LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); |
