new names for functions that open C libraries

This commit is contained in:
Roberto Ierusalimschy
2003-03-11 09:24:34 -03:00
parent 430d6db928
commit 034de1fe73
9 changed files with 43 additions and 34 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lbaselib.c,v 1.125 2003/03/06 19:36:16 roberto Exp roberto $
** $Id: lbaselib.c,v 1.126 2003/03/11 12:08:13 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -668,7 +668,7 @@ static void base_open (lua_State *L) {
}
LUALIB_API int lua_baselibopen (lua_State *L) {
LUALIB_API int luaopen_base (lua_State *L) {
base_open(L);
luaL_openlib(L, LUA_COLIBNAME, co_funcs, 0);
lua_newtable(L);

View File

@@ -1,5 +1,5 @@
/*
** $Id: ldblib.c,v 1.77 2002/12/20 10:26:33 roberto Exp roberto $
** $Id: ldblib.c,v 1.78 2003/02/27 11:52:30 roberto Exp roberto $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -288,7 +288,7 @@ static const luaL_reg dblib[] = {
};
LUALIB_API int lua_dblibopen (lua_State *L) {
LUALIB_API int luaopen_debug (lua_State *L) {
luaL_openlib(L, LUA_DBLIBNAME, dblib, 0);
lua_pushliteral(L, "_TRACEBACK");
lua_pushcfunction(L, errorfb);

View File

@@ -1,5 +1,5 @@
/*
** $Id: liolib.c,v 2.33 2003/02/27 12:39:05 roberto Exp roberto $
** $Id: liolib.c,v 2.34 2003/03/06 19:36:44 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -749,7 +749,7 @@ static const luaL_reg syslib[] = {
LUALIB_API int lua_iolibopen (lua_State *L) {
LUALIB_API int luaopen_io (lua_State *L) {
createmeta(L);
luaL_openlib(L, LUA_OSLIBNAME, syslib, 0);
lua_pushliteral(L, FILEHANDLE);

View File

@@ -1,5 +1,5 @@
/*
** $Id: lmathlib.c,v 1.53 2002/12/04 17:38:31 roberto Exp roberto $
** $Id: lmathlib.c,v 1.54 2002/12/20 10:26:33 roberto Exp roberto $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -233,7 +233,7 @@ static const luaL_reg mathlib[] = {
/*
** Open math library
*/
LUALIB_API int lua_mathlibopen (lua_State *L) {
LUALIB_API int luaopen_math (lua_State *L) {
luaL_openlib(L, LUA_MATHLIBNAME, mathlib, 0);
lua_pushliteral(L, "pi");
lua_pushnumber(L, PI);

View File

@@ -1,5 +1,5 @@
/*
** $Id: lstrlib.c,v 1.93 2002/12/20 10:26:33 roberto Exp roberto $
** $Id: lstrlib.c,v 1.94 2003/02/12 09:10:41 roberto Exp roberto $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -762,7 +762,7 @@ static const luaL_reg strlib[] = {
/*
** Open string library
*/
LUALIB_API int lua_strlibopen (lua_State *L) {
LUALIB_API int luaopen_string (lua_State *L) {
luaL_openlib(L, LUA_STRLIBNAME, strlib, 0);
return 1;
}

View File

@@ -1,5 +1,5 @@
/*
** $Id: ltablib.c,v 1.18 2002/12/20 10:26:33 roberto Exp roberto $
** $Id: ltablib.c,v 1.19 2003/01/27 13:46:16 roberto Exp roberto $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@@ -243,7 +243,7 @@ static const luaL_reg tab_funcs[] = {
};
LUALIB_API int lua_tablibopen (lua_State *L) {
LUALIB_API int luaopen_table (lua_State *L) {
luaL_openlib(L, LUA_TABLIBNAME, tab_funcs, 0);
return 1;
}

View File

@@ -1,5 +1,5 @@
/*
** $Id: ltests.c,v 1.153 2003/02/18 16:02:56 roberto Exp roberto $
** $Id: ltests.c,v 1.154 2003/02/27 12:33:07 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@@ -460,12 +460,12 @@ static int newstate (lua_State *L) {
static int loadlib (lua_State *L) {
static const luaL_reg libs[] = {
{"mathlibopen", lua_mathlibopen},
{"strlibopen", lua_strlibopen},
{"iolibopen", lua_iolibopen},
{"tablibopen", lua_tablibopen},
{"dblibopen", lua_dblibopen},
{"baselibopen", lua_baselibopen},
{"mathlibopen", luaopen_math},
{"strlibopen", luaopen_string},
{"iolibopen", luaopen_io},
{"tablibopen", luaopen_table},
{"dblibopen", luaopen_debug},
{"baselibopen", luaopen_base},
{NULL, NULL}
};
lua_State *L1 = cast(lua_State *,

16
lua.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lua.c,v 1.116 2003/01/29 13:23:45 roberto Exp roberto $
** $Id: lua.c,v 1.117 2003/03/07 13:21:31 roberto Exp roberto $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -67,12 +67,12 @@ static const char *progname = PROGNAME;
static const luaL_reg lualibs[] = {
{"baselib", lua_baselibopen},
{"tablib", lua_tablibopen},
{"iolib", lua_iolibopen},
{"strlib", lua_strlibopen},
{"mathlib", lua_mathlibopen},
{"dblib", lua_dblibopen},
{"base", luaopen_base},
{"table", luaopen_table},
{"io", luaopen_io},
{"string", luaopen_string},
{"math", luaopen_math},
{"debug", luaopen_debug},
/* add your libraries here */
LUA_EXTRALIBS
{NULL, NULL}
@@ -372,7 +372,7 @@ static int handle_argv (char *argv[], int *interactive) {
static void openstdlibs (lua_State *l) {
const luaL_reg *lib = lualibs;
for (; lib->name; lib++) {
for (; lib->func; lib++) {
lib->func(l); /* open library */
lua_settop(l, 0); /* discard any results */
}

View File

@@ -1,5 +1,5 @@
/*
** $Id: lualib.h,v 1.24 2002/06/18 17:42:52 roberto Exp roberto $
** $Id: lualib.h,v 1.25 2002/07/09 18:49:13 roberto Exp roberto $
** Lua standard libraries
** See Copyright Notice in lua.h
*/
@@ -17,23 +17,23 @@
#define LUA_COLIBNAME "coroutine"
LUALIB_API int lua_baselibopen (lua_State *L);
LUALIB_API int luaopen_base (lua_State *L);
#define LUA_TABLIBNAME "table"
LUALIB_API int lua_tablibopen (lua_State *L);
LUALIB_API int luaopen_table (lua_State *L);
#define LUA_IOLIBNAME "io"
#define LUA_OSLIBNAME "os"
LUALIB_API int lua_iolibopen (lua_State *L);
LUALIB_API int luaopen_io (lua_State *L);
#define LUA_STRLIBNAME "string"
LUALIB_API int lua_strlibopen (lua_State *L);
LUALIB_API int luaopen_string (lua_State *L);
#define LUA_MATHLIBNAME "math"
LUALIB_API int lua_mathlibopen (lua_State *L);
LUALIB_API int luaopen_math (lua_State *L);
#define LUA_DBLIBNAME "debug"
LUALIB_API int lua_dblibopen (lua_State *L);
LUALIB_API int luaopen_debug (lua_State *L);
/* to help testing the libraries */
@@ -41,4 +41,13 @@ LUALIB_API int lua_dblibopen (lua_State *L);
#define lua_assert(c) /* empty */
#endif
/* compatibility code */
#define lua_baselibopen luaopen_base
#define lua_tablibopen luaopen_table
#define lua_iolibopen luaopen_io
#define lua_strlibopen luaopen_string
#define lua_mathlibopen luaopen_math
#define lua_dblibopen luaopen_debug
#endif