diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-20 09:54:08 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-20 09:54:08 -0300 |
commit | 88c9bf99de50df5575cce13e8e6c278b9f1dc0d0 (patch) | |
tree | 3cfe2080f0a2595b62b74752c84ffa763e83f8e6 /lauxlib.c | |
parent | 63a614e1453b6b03b89b5d47efa476acd5f9d1d2 (diff) | |
download | lua-88c9bf99de50df5575cce13e8e6c278b9f1dc0d0.tar.gz lua-88c9bf99de50df5575cce13e8e6c278b9f1dc0d0.tar.bz2 lua-88c9bf99de50df5575cce13e8e6c278b9f1dc0d0.zip |
standard libraries in packages
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.60 2002/02/14 21:41:53 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.61 2002/03/07 18:15:10 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 | */ |
@@ -116,10 +116,21 @@ LUALIB_API lua_Number luaL_opt_number (lua_State *L, int narg, lua_Number def) { | |||
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l, int n) { | 119 | LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l) { |
120 | int i; | 120 | for (; l->name; l++) { |
121 | for (i=0; i<n; i++) | 121 | lua_pushstring(L, l->name); |
122 | lua_register(L, l[i].name, l[i].func); | 122 | lua_pushcfunction(L, l->func); |
123 | lua_settable(L, -3); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | |||
128 | LUALIB_API void luaL_opennamedlib (lua_State *L, const char *libname, | ||
129 | const luaL_reg *l) { | ||
130 | lua_pushstring(L, libname); | ||
131 | lua_newtable(L); | ||
132 | luaL_openlib(L, l); | ||
133 | lua_settable(L, LUA_GLOBALSINDEX); | ||
123 | } | 134 | } |
124 | 135 | ||
125 | 136 | ||