aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-07-02 08:38:13 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-07-02 08:38:13 -0300
commit7192afafeeb1a96b3de60af90a72cd8762b09d94 (patch)
treed1e7e061822f755c33cc497d98ea451c7e7e32e8 /lauxlib.h
parenta139e2e003e0b62b7d34eeda20dd2354e74885f9 (diff)
downloadlua-7192afafeeb1a96b3de60af90a72cd8762b09d94.tar.gz
lua-7192afafeeb1a96b3de60af90a72cd8762b09d94.tar.bz2
lua-7192afafeeb1a96b3de60af90a72cd8762b09d94.zip
new module policy: C modules do not create globals and do not register
themselves with 'require' (let 'require' do its work); new auxiliary functions luaL_newlib/luaL_newlibtable/luaL_setfuncs/luaL_requiref. Old luaL_register will be deprecated.
Diffstat (limited to 'lauxlib.h')
-rw-r--r--lauxlib.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/lauxlib.h b/lauxlib.h
index d5728b58..4d762886 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.106 2010/05/31 16:34:19 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.107 2010/06/30 17:40:27 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*/
@@ -29,10 +29,6 @@ typedef struct luaL_Reg {
29LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver); 29LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver);
30#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM) 30#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM)
31 31
32LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
33 int sizehint);
34LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
35 const luaL_Reg *l, int nup);
36LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); 32LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
37LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); 33LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
38LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); 34LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
@@ -78,11 +74,15 @@ LUALIB_API int (luaL_len) (lua_State *L, int idx);
78LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, 74LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
79 const char *r); 75 const char *r);
80 76
77LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup);
78
81LUALIB_API void (luaL_findtable) (lua_State *L, int idx, const char *fname); 79LUALIB_API void (luaL_findtable) (lua_State *L, int idx, const char *fname);
82 80
83LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, 81LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
84 const char *msg, int level); 82 const char *msg, int level);
85 83
84LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
85 lua_CFunction openf, int glb);
86 86
87/* 87/*
88** =============================================================== 88** ===============================================================
@@ -90,6 +90,12 @@ LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1,
90** =============================================================== 90** ===============================================================
91*/ 91*/
92 92
93
94#define luaL_newlibtable(L,l) \
95 lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
96
97#define luaL_newlib(L,l) (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
98
93#define luaL_argcheck(L, cond,numarg,extramsg) \ 99#define luaL_argcheck(L, cond,numarg,extramsg) \
94 ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) 100 ((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
95#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) 101#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
@@ -149,6 +155,12 @@ LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
149/* }====================================================== */ 155/* }====================================================== */
150 156
151 157
158LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
159 int sizehint);
160LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
161 const luaL_Reg *l, int nup);
162
163
152/* compatibility with ref system */ 164/* compatibility with ref system */
153 165
154/* pre-defined references */ 166/* pre-defined references */