diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-07-09 11:29:29 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-07-09 11:29:29 -0300 |
commit | 31f6540fba010b941b44b2bd21672786d2e63e7f (patch) | |
tree | 2824e407b7c04099b7c7f11d47f025c5271f2905 | |
parent | eab1965c05f2ef71f715347e280733e7657993e4 (diff) | |
download | lua-31f6540fba010b941b44b2bd21672786d2e63e7f.tar.gz lua-31f6540fba010b941b44b2bd21672786d2e63e7f.tar.bz2 lua-31f6540fba010b941b44b2bd21672786d2e63e7f.zip |
back with an "open all libs" function
-rw-r--r-- | linit.c | 33 | ||||
-rw-r--r-- | ltests.h | 6 | ||||
-rw-r--r-- | luaconf.h | 14 | ||||
-rw-r--r-- | lualib.h | 14 |
4 files changed, 48 insertions, 19 deletions
@@ -1,8 +1,37 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: linit.c,v 1.5 2000/06/16 17:22:43 roberto Exp roberto $ | 2 | ** $Id: linit.c,v 1.6 2000/08/09 14:50:13 roberto Exp roberto $ |
3 | ** Initialization of libraries for lua.c | 3 | ** Initialization of libraries for lua.c |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
6 | 6 | ||
7 | >>>>>>> This module is now obsolete, and is not part of Lua. <<<<<<<<< | 7 | |
8 | #define linit_c | ||
9 | #define LUA_LIB | ||
10 | |||
11 | #include "lua.h" | ||
12 | |||
13 | #include "lualib.h" | ||
14 | #include "lauxlib.h" | ||
15 | |||
16 | |||
17 | static const luaL_reg lualibs[] = { | ||
18 | {"", luaopen_base}, | ||
19 | {LUA_TABLIBNAME, luaopen_table}, | ||
20 | {LUA_IOLIBNAME, luaopen_io}, | ||
21 | {LUA_STRLIBNAME, luaopen_string}, | ||
22 | {LUA_MATHLIBNAME, luaopen_math}, | ||
23 | {LUA_DBLIBNAME, luaopen_debug}, | ||
24 | {"", luaopen_loadlib}, | ||
25 | {NULL, NULL} | ||
26 | }; | ||
27 | |||
28 | |||
29 | LUALIB_API int luaopen_stdlibs (lua_State *L) { | ||
30 | const luaL_reg *lib = lualibs; | ||
31 | for (; lib->func; lib++) { | ||
32 | lib->func(L); /* open library */ | ||
33 | lua_settop(L, 0); /* discard any results */ | ||
34 | } | ||
35 | return 0; | ||
36 | } | ||
8 | 37 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.h,v 2.6 2004/06/02 19:09:21 roberto Exp roberto $ | 2 | ** $Id: ltests.h,v 2.7 2004/06/29 16:57:24 roberto Exp roberto $ |
3 | ** Internal Header for Debugging of the Lua Implementation | 3 | ** Internal Header for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -70,8 +70,8 @@ extern int islocked; | |||
70 | 70 | ||
71 | int luaB_opentests (lua_State *L); | 71 | int luaB_opentests (lua_State *L); |
72 | 72 | ||
73 | #undef LUA_EXTRALIBS | 73 | #undef lua_userinit |
74 | #define LUA_EXTRALIBS { "tests", luaB_opentests }, | 74 | #define lua_userinit(L) { luaopen_stdlibs(L); luaB_opentests(L); } |
75 | 75 | ||
76 | 76 | ||
77 | 77 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.7 2004/06/23 15:57:29 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.8 2004/06/29 16:57:56 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -84,9 +84,15 @@ | |||
84 | #define PROGNAME "lua" | 84 | #define PROGNAME "lua" |
85 | 85 | ||
86 | 86 | ||
87 | #define LUA_EXTRALIBS /* empty */ | 87 | /* |
88 | 88 | ** this macro allows you to open other libraries when starting the | |
89 | #define lua_userinit(L) openstdlibs(L) | 89 | ** stand-alone interpreter |
90 | */ | ||
91 | #define lua_userinit(L) luaopen_stdlibs(L) | ||
92 | /* | ||
93 | ** #define lua_userinit(L) { int luaopen_mylibs(lua_State *L); \ | ||
94 | ** luaopen_stdlibs(L); luaopen_mylibs(L); } | ||
95 | */ | ||
90 | 96 | ||
91 | 97 | ||
92 | 98 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lualib.h,v 1.29 2004/03/24 15:46:49 roberto Exp roberto $ | 2 | ** $Id: lualib.h,v 1.30 2004/05/28 18:35:05 roberto Exp roberto $ |
3 | ** Lua standard libraries | 3 | ** Lua standard libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -11,11 +11,6 @@ | |||
11 | #include "lua.h" | 11 | #include "lua.h" |
12 | 12 | ||
13 | 13 | ||
14 | #ifndef LUALIB_API | ||
15 | #define LUALIB_API LUA_API | ||
16 | #endif | ||
17 | |||
18 | |||
19 | /* Key to file-handle type */ | 14 | /* Key to file-handle type */ |
20 | #define LUA_FILEHANDLE "FILE*" | 15 | #define LUA_FILEHANDLE "FILE*" |
21 | 16 | ||
@@ -43,9 +38,8 @@ LUALIB_API int luaopen_debug (lua_State *L); | |||
43 | LUALIB_API int luaopen_loadlib (lua_State *L); | 38 | LUALIB_API int luaopen_loadlib (lua_State *L); |
44 | 39 | ||
45 | 40 | ||
46 | /* to help testing the libraries */ | 41 | /* open all previous libraries */ |
47 | #ifndef lua_assert | 42 | LUALIB_API int luaopen_stdlibs (lua_State *L); |
48 | #define lua_assert(c) /* empty */ | 43 | |
49 | #endif | ||
50 | 44 | ||
51 | #endif | 45 | #endif |