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.
This commit is contained in:
Roberto Ierusalimschy
2010-07-02 08:38:13 -03:00
parent a139e2e003
commit 7192afafee
14 changed files with 104 additions and 55 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lbaselib.c,v 1.244 2010/06/10 21:29:47 roberto Exp roberto $
** $Id: lbaselib.c,v 1.245 2010/06/13 19:41:34 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -496,7 +496,7 @@ LUAMOD_API int luaopen_base (lua_State *L) {
lua_pushglobaltable(L);
lua_setfield(L, -2, "_G");
/* open lib into global table */
luaL_register(L, "_G", base_funcs);
luaL_setfuncs(L, base_funcs, 0);
lua_pushliteral(L, LUA_VERSION);
lua_setfield(L, -2, "_VERSION"); /* set global _VERSION */
/* `newproxy' needs a weaktable as upvalue */