summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-07-09 11:29:29 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-07-09 11:29:29 -0300
commit31f6540fba010b941b44b2bd21672786d2e63e7f (patch)
tree2824e407b7c04099b7c7f11d47f025c5271f2905
parenteab1965c05f2ef71f715347e280733e7657993e4 (diff)
downloadlua-31f6540fba010b941b44b2bd21672786d2e63e7f.tar.gz
lua-31f6540fba010b941b44b2bd21672786d2e63e7f.tar.bz2
lua-31f6540fba010b941b44b2bd21672786d2e63e7f.zip
back with an "open all libs" function
-rw-r--r--linit.c33
-rw-r--r--ltests.h6
-rw-r--r--luaconf.h14
-rw-r--r--lualib.h14
4 files changed, 48 insertions, 19 deletions
diff --git a/linit.c b/linit.c
index e66a057b..0c483943 100644
--- a/linit.c
+++ b/linit.c
@@ -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
17static 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
29LUALIB_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
diff --git a/ltests.h b/ltests.h
index 009884a9..c2f3ec16 100644
--- a/ltests.h
+++ b/ltests.h
@@ -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
71int luaB_opentests (lua_State *L); 71int 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
diff --git a/luaconf.h b/luaconf.h
index a8bcec4a..2f337f96 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -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
diff --git a/lualib.h b/lualib.h
index 06428d77..6efe0e2d 100644
--- a/lualib.h
+++ b/lualib.h
@@ -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);
43LUALIB_API int luaopen_loadlib (lua_State *L); 38LUALIB_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 42LUALIB_API int luaopen_stdlibs (lua_State *L);
48#define lua_assert(c) /* empty */ 43
49#endif
50 44
51#endif 45#endif