compile option EXTRALIB for builtin functions that can be written in Lua.

This commit is contained in:
Roberto Ierusalimschy 1999-02-04 17:12:35 -02:00
parent bdfab46c22
commit 76179a1014
2 changed files with 21 additions and 14 deletions

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lbuiltin.c,v 1.47 1999/01/25 12:30:11 roberto Exp roberto $ ** $Id: lbuiltin.c,v 1.48 1999/01/26 15:38:01 roberto Exp roberto $
** Built-in functions ** Built-in functions
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -71,11 +71,6 @@ static Hash *gethash (int arg) {
return avalue(luaA_Address(luaL_tablearg(arg))); return avalue(luaA_Address(luaL_tablearg(arg)));
} }
static void luaB_getn (void) {
lua_pushnumber(getnarg(gethash(1)));
}
/* }====================================================== */ /* }====================================================== */
@ -306,6 +301,7 @@ static void luaB_call (void) {
/* }====================================================== */ /* }====================================================== */
#ifdef EXTRALIB
/* /*
** {====================================================== ** {======================================================
** "Extra" functions ** "Extra" functions
@ -385,6 +381,11 @@ static void luaB_foreachvar (void) {
} }
static void luaB_getn (void) {
lua_pushnumber(getnarg(gethash(1)));
}
static void luaB_tinsert (void) { static void luaB_tinsert (void) {
Hash *a = gethash(1); Hash *a = gethash(1);
lua_Object v = lua_getparam(3); lua_Object v = lua_getparam(3);
@ -500,6 +501,7 @@ static void luaB_sort (void) {
} }
/* }}===================================================== */ /* }}===================================================== */
#endif
/* /*
@ -685,7 +687,6 @@ static struct luaL_reg builtin_funcs[] = {
{"dostring", luaB_dostring}, {"dostring", luaB_dostring},
{"error", luaB_error}, {"error", luaB_error},
{"getglobal", luaB_getglobal}, {"getglobal", luaB_getglobal},
{"getn", luaB_getn},
{"gettagmethod", luaB_gettagmethod}, {"gettagmethod", luaB_gettagmethod},
{"newtag", luaB_newtag}, {"newtag", luaB_newtag},
{"next", luaB_next}, {"next", luaB_next},
@ -702,15 +703,18 @@ static struct luaL_reg builtin_funcs[] = {
{"tag", luaB_luatag}, {"tag", luaB_luatag},
{"tonumber", luaB_tonumber}, {"tonumber", luaB_tonumber},
{"tostring", luaB_tostring}, {"tostring", luaB_tostring},
{"type", luaB_type}, {"type", luaB_type}
/* "Extra" functions */ #ifdef EXTRALIB
{"assert", luaB_assert}, /* "Extra" functions */
,{"assert", luaB_assert},
{"foreach", luaB_foreach}, {"foreach", luaB_foreach},
{"foreachi", luaB_foreachi}, {"foreachi", luaB_foreachi},
{"foreachvar", luaB_foreachvar}, {"foreachvar", luaB_foreachvar},
{"getn", luaB_getn},
{"sort", luaB_sort}, {"sort", luaB_sort},
{"tinsert", luaB_tinsert}, {"tinsert", luaB_tinsert},
{"tremove", luaB_tremove} {"tremove", luaB_tremove}
#endif
}; };

View File

@ -1,5 +1,5 @@
# #
## $Id: makefile,v 1.15 1999/01/11 20:23:54 roberto Exp roberto $ ## $Id: makefile,v 1.16 1999/02/04 16:37:41 roberto Exp roberto $
## Makefile ## Makefile
## See Copyright Notice in lua.h ## See Copyright Notice in lua.h
# #
@ -12,16 +12,19 @@
# define (undefine) _POSIX_SOURCE if your system is (not) POSIX compliant # define (undefine) _POSIX_SOURCE if your system is (not) POSIX compliant
# #
# define (undefine) OLD_ANSI if your system does NOT have some new ANSI # define (undefine) OLD_ANSI if your system does NOT have some new ANSI
# facilities (e.g. strerror, locale.h, memmove). Although they are ANSI, # facilities (e.g. strerror, locale.h, memmove). SunOS does not comply;
# SunOS does not comply; so, add "-DOLD_ANSI" on SunOS # so, add "-DOLD_ANSI" on SunOS
# #
# define LUA_COMPAT2_5 if yous system does need to be compatible with # define LUA_COMPAT2_5 if yous system does need to be compatible with
# version 2.5 (or older) # version 2.5 (or older)
# #
# define LUA_NUM_TYPE if you need numbers to be different from double # define LUA_NUM_TYPE if you need numbers to be different from double
# (for instance, -DLUA_NUM_TYPE=float) # (for instance, -DLUA_NUM_TYPE=float)
#
# undefine EXTRALIB if you do not want builtin functions that can be
# written in Lua (sort, tinsert, tremove, assert, foreach*)
CONFIG = -DPOPEN -D_POSIX_SOURCE CONFIG = -DPOPEN -D_POSIX_SOURCE -DEXTRALIB
#CONFIG = -DLUA_COMPAT2_5 -DOLD_ANSI -DDEBUG #CONFIG = -DLUA_COMPAT2_5 -DOLD_ANSI -DDEBUG