aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-02-04 17:12:35 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-02-04 17:12:35 -0200
commit76179a1014430f42148822ac2db23a9491817a0b (patch)
tree9a16baa96e998e5e8c130ee6e8c2334fc78a581e
parentbdfab46c220681f4dc0663bbce4026f4bbada00b (diff)
downloadlua-76179a1014430f42148822ac2db23a9491817a0b.tar.gz
lua-76179a1014430f42148822ac2db23a9491817a0b.tar.bz2
lua-76179a1014430f42148822ac2db23a9491817a0b.zip
compile option EXTRALIB for builtin functions that can be written in Lua.
-rw-r--r--lbuiltin.c24
-rw-r--r--makefile11
2 files changed, 21 insertions, 14 deletions
diff --git a/lbuiltin.c b/lbuiltin.c
index 44b3bf23..a307e883 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.47 1999/01/25 12:30:11 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.48 1999/01/26 15:38:01 roberto Exp roberto $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -71,11 +71,6 @@ static Hash *gethash (int arg) {
71 return avalue(luaA_Address(luaL_tablearg(arg))); 71 return avalue(luaA_Address(luaL_tablearg(arg)));
72} 72}
73 73
74
75static void luaB_getn (void) {
76 lua_pushnumber(getnarg(gethash(1)));
77}
78
79/* }====================================================== */ 74/* }====================================================== */
80 75
81 76
@@ -306,6 +301,7 @@ static void luaB_call (void) {
306/* }====================================================== */ 301/* }====================================================== */
307 302
308 303
304#ifdef EXTRALIB
309/* 305/*
310** {====================================================== 306** {======================================================
311** "Extra" functions 307** "Extra" functions
@@ -385,6 +381,11 @@ static void luaB_foreachvar (void) {
385} 381}
386 382
387 383
384static void luaB_getn (void) {
385 lua_pushnumber(getnarg(gethash(1)));
386}
387
388
388static void luaB_tinsert (void) { 389static void luaB_tinsert (void) {
389 Hash *a = gethash(1); 390 Hash *a = gethash(1);
390 lua_Object v = lua_getparam(3); 391 lua_Object v = lua_getparam(3);
@@ -500,6 +501,7 @@ static void luaB_sort (void) {
500} 501}
501 502
502/* }}===================================================== */ 503/* }}===================================================== */
504#endif
503 505
504 506
505/* 507/*
@@ -685,7 +687,6 @@ static struct luaL_reg builtin_funcs[] = {
685 {"dostring", luaB_dostring}, 687 {"dostring", luaB_dostring},
686 {"error", luaB_error}, 688 {"error", luaB_error},
687 {"getglobal", luaB_getglobal}, 689 {"getglobal", luaB_getglobal},
688 {"getn", luaB_getn},
689 {"gettagmethod", luaB_gettagmethod}, 690 {"gettagmethod", luaB_gettagmethod},
690 {"newtag", luaB_newtag}, 691 {"newtag", luaB_newtag},
691 {"next", luaB_next}, 692 {"next", luaB_next},
@@ -702,15 +703,18 @@ static struct luaL_reg builtin_funcs[] = {
702 {"tag", luaB_luatag}, 703 {"tag", luaB_luatag},
703 {"tonumber", luaB_tonumber}, 704 {"tonumber", luaB_tonumber},
704 {"tostring", luaB_tostring}, 705 {"tostring", luaB_tostring},
705 {"type", luaB_type}, 706 {"type", luaB_type}
706/* "Extra" functions */ 707#ifdef EXTRALIB
707 {"assert", luaB_assert}, 708 /* "Extra" functions */
709 ,{"assert", luaB_assert},
708 {"foreach", luaB_foreach}, 710 {"foreach", luaB_foreach},
709 {"foreachi", luaB_foreachi}, 711 {"foreachi", luaB_foreachi},
710 {"foreachvar", luaB_foreachvar}, 712 {"foreachvar", luaB_foreachvar},
713 {"getn", luaB_getn},
711 {"sort", luaB_sort}, 714 {"sort", luaB_sort},
712 {"tinsert", luaB_tinsert}, 715 {"tinsert", luaB_tinsert},
713 {"tremove", luaB_tremove} 716 {"tremove", luaB_tremove}
717#endif
714}; 718};
715 719
716 720
diff --git a/makefile b/makefile
index 2e0046c7..289bf037 100644
--- a/makefile
+++ b/makefile
@@ -1,5 +1,5 @@
1# 1#
2## $Id: makefile,v 1.15 1999/01/11 20:23:54 roberto Exp roberto $ 2## $Id: makefile,v 1.16 1999/02/04 16:37:41 roberto Exp roberto $
3## Makefile 3## Makefile
4## See Copyright Notice in lua.h 4## See Copyright Notice in lua.h
5# 5#
@@ -12,16 +12,19 @@
12# define (undefine) _POSIX_SOURCE if your system is (not) POSIX compliant 12# define (undefine) _POSIX_SOURCE if your system is (not) POSIX compliant
13# 13#
14# define (undefine) OLD_ANSI if your system does NOT have some new ANSI 14# define (undefine) OLD_ANSI if your system does NOT have some new ANSI
15# facilities (e.g. strerror, locale.h, memmove). Although they are ANSI, 15# facilities (e.g. strerror, locale.h, memmove). SunOS does not comply;
16# SunOS does not comply; so, add "-DOLD_ANSI" on SunOS 16# so, add "-DOLD_ANSI" on SunOS
17# 17#
18# define LUA_COMPAT2_5 if yous system does need to be compatible with 18# define LUA_COMPAT2_5 if yous system does need to be compatible with
19# version 2.5 (or older) 19# version 2.5 (or older)
20# 20#
21# define LUA_NUM_TYPE if you need numbers to be different from double 21# define LUA_NUM_TYPE if you need numbers to be different from double
22# (for instance, -DLUA_NUM_TYPE=float) 22# (for instance, -DLUA_NUM_TYPE=float)
23#
24# undefine EXTRALIB if you do not want builtin functions that can be
25# written in Lua (sort, tinsert, tremove, assert, foreach*)
23 26
24CONFIG = -DPOPEN -D_POSIX_SOURCE 27CONFIG = -DPOPEN -D_POSIX_SOURCE -DEXTRALIB
25#CONFIG = -DLUA_COMPAT2_5 -DOLD_ANSI -DDEBUG 28#CONFIG = -DLUA_COMPAT2_5 -DOLD_ANSI -DDEBUG
26 29
27 30