aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-06-23 15:27:53 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-06-23 15:27:53 -0300
commite81f1841644405845e7de6bd70a0f074cced3d81 (patch)
treefaa59463440da831f60846d4c689289d3fbdcaf9
parent3e4327530835f65d3bc089688bd46f44efcddb57 (diff)
downloadlua-e81f1841644405845e7de6bd70a0f074cced3d81.tar.gz
lua-e81f1841644405845e7de6bd70a0f074cced3d81.tar.bz2
lua-e81f1841644405845e7de6bd70a0f074cced3d81.zip
new #define LUA_COMPAT2_5 to select "compatibility mode".
-rw-r--r--fallback.c7
-rw-r--r--inout.c4
-rw-r--r--lua.h17
-rw-r--r--makefile4
-rw-r--r--opcode.c28
5 files changed, 36 insertions, 24 deletions
diff --git a/fallback.c b/fallback.c
index 0902c25e..da7ed923 100644
--- a/fallback.c
+++ b/fallback.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_fallback="$Id: fallback.c,v 2.7 1997/06/16 18:43:19 roberto Exp roberto $"; 6char *rcs_fallback="$Id: fallback.c,v 2.8 1997/06/17 17:27:07 roberto Exp roberto $";
7 7
8#include <stdio.h> 8#include <stdio.h>
9#include <string.h> 9#include <string.h>
@@ -281,7 +281,7 @@ char *luaI_travfallbacks (int (*fn)(TObject *))
281* =================================================================== 281* ===================================================================
282* compatibility with old fallback system 282* compatibility with old fallback system
283*/ 283*/
284 284#if LUA_COMPAT2_5
285 285
286static void errorFB (void) 286static void errorFB (void)
287{ 287{
@@ -310,6 +310,7 @@ static void fillvalids (IMS e, TObject *func)
310 *luaI_getim(t, e) = *func; 310 *luaI_getim(t, e) = *func;
311} 311}
312 312
313
313void luaI_setfallback (void) 314void luaI_setfallback (void)
314{ 315{
315 static char *oldnames [] = {"error", "getglobal", "arith", "order", NULL}; 316 static char *oldnames [] = {"error", "getglobal", "arith", "order", NULL};
@@ -364,4 +365,4 @@ void luaI_setfallback (void)
364 else 365 else
365 lua_pushcfunction(replace); 366 lua_pushcfunction(replace);
366} 367}
367 368#endif
diff --git a/inout.c b/inout.c
index 64e018d7..8ad00b4e 100644
--- a/inout.c
+++ b/inout.c
@@ -5,7 +5,7 @@
5** Also provides some predefined lua functions. 5** Also provides some predefined lua functions.
6*/ 6*/
7 7
8char *rcs_inout="$Id: inout.c,v 2.65 1997/06/19 18:49:40 roberto Exp roberto $"; 8char *rcs_inout="$Id: inout.c,v 2.66 1997/06/20 19:19:09 roberto Exp roberto $";
9 9
10#include <stdio.h> 10#include <stdio.h>
11#include <string.h> 11#include <string.h>
@@ -377,7 +377,9 @@ static struct {
377 {"rawsetglobal", luaI_rawsetglobal}, 377 {"rawsetglobal", luaI_rawsetglobal},
378 {"rawsettable", rawsettable}, 378 {"rawsettable", rawsettable},
379 {"seterrormethod", luaI_seterrormethod}, 379 {"seterrormethod", luaI_seterrormethod},
380#if LUA_COMPAT2_5
380 {"setfallback", luaI_setfallback}, 381 {"setfallback", luaI_setfallback},
382#endif
381 {"setglobal", luaI_setglobal}, 383 {"setglobal", luaI_setglobal},
382 {"settagmethod", luaI_settagmethod}, 384 {"settagmethod", luaI_settagmethod},
383 {"gettagmethod", luaI_gettagmethod}, 385 {"gettagmethod", luaI_gettagmethod},
diff --git a/lua.h b/lua.h
index cc5ed897..0b6b1868 100644
--- a/lua.h
+++ b/lua.h
@@ -2,7 +2,7 @@
2** LUA - An Extensible Extension Language 2** LUA - An Extensible Extension Language
3** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil 3** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
4** e-mail: lua@tecgraf.puc-rio.br 4** e-mail: lua@tecgraf.puc-rio.br
5** $Id: lua.h,v 4.9 1997/06/18 21:20:45 roberto Exp roberto $ 5** $Id: lua.h,v 4.10 1997/06/19 18:03:04 roberto Exp roberto $
6*/ 6*/
7 7
8 8
@@ -102,13 +102,18 @@ long lua_collectgarbage (long limit);
102 102
103 103
104 104
105/* If your program has no compatibility problems, you can change 105/* ==========================================================================
106** this to 0 106** for compatibility with old versions. Avoid using these macros/functions
107** If your program does not use any of these, define LUA_COMPAT2_5 to 0
107*/ 108*/
108#if 1
109 109
110/* =============================================================== */ 110#ifndef LUA_COMPAT2_5
111/* for compatibility with old versions. Avoid using these macros/functions */ 111#define LUA_COMPAT2_5 1
112#endif
113
114
115#if LUA_COMPAT2_5
116
112 117
113lua_Object lua_setfallback (char *event, lua_CFunction fallback); 118lua_Object lua_setfallback (char *event, lua_CFunction fallback);
114 119
diff --git a/makefile b/makefile
index 7fe53d50..9723ef09 100644
--- a/makefile
+++ b/makefile
@@ -1,4 +1,4 @@
1# $Id: makefile,v 1.34 1997/06/11 18:57:00 roberto Exp roberto $ 1# $Id: makefile,v 1.35 1997/06/16 16:50:22 roberto Exp roberto $
2 2
3#configuration 3#configuration
4 4
@@ -6,6 +6,8 @@
6# define (undefine) _POSIX_SOURCE if your system is (not) POSIX compliant 6# define (undefine) _POSIX_SOURCE if your system is (not) POSIX compliant
7#define (undefine) NOSTRERROR if your system does NOT have function "strerror" 7#define (undefine) NOSTRERROR if your system does NOT have function "strerror"
8# (although this is ANSI, SunOS does not comply; so, add "-DNOSTRERROR" on SunOS) 8# (although this is ANSI, SunOS does not comply; so, add "-DNOSTRERROR" on SunOS)
9# define LUA_COMPAT2_5=0 if yous system does not need to be compatible with
10# version 2.5 (or older)
9CONFIG = -DPOPEN -D_POSIX_SOURCE 11CONFIG = -DPOPEN -D_POSIX_SOURCE
10# Compilation parameters 12# Compilation parameters
11CC = gcc 13CC = gcc
diff --git a/opcode.c b/opcode.c
index 982b1da9..7675c159 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 4.12 1997/06/19 17:46:12 roberto Exp roberto $"; 6char *rcs_opcode="$Id: opcode.c,v 4.13 1997/06/19 18:03:04 roberto Exp roberto $";
7 7
8#include <setjmp.h> 8#include <setjmp.h>
9#include <stdio.h> 9#include <stdio.h>
@@ -325,7 +325,7 @@ static void do_call (StkId base, int nResults)
325 firstResult = lua_execute(func->value.tf->code, base); 325 firstResult = lua_execute(func->value.tf->code, base);
326 } 326 }
327 else { /* func is not a function */ 327 else { /* func is not a function */
328 /* Check the fallback for invalid functions */ 328 /* Check the tag method for invalid functions */
329 TObject *im = luaI_getimbyObj(func, IM_FUNCTION); 329 TObject *im = luaI_getimbyObj(func, IM_FUNCTION);
330 if (ttype(im) == LUA_T_NIL) 330 if (ttype(im) == LUA_T_NIL)
331 lua_error("call expression not a function"); 331 lua_error("call expression not a function");
@@ -635,17 +635,6 @@ int lua_callfunction (lua_Object function)
635} 635}
636 636
637 637
638/*
639** API: set a function as a fallback
640*/
641lua_Object lua_setfallback (char *name, lua_CFunction fallback)
642{
643 lua_pushstring(name);
644 lua_pushcfunction(fallback);
645 do_unprotectedrun(luaI_setfallback, 2, 1);
646 return put_luaObjectonTop();
647}
648
649lua_Object lua_gettagmethod (int tag, char *event) 638lua_Object lua_gettagmethod (int tag, char *event)
650{ 639{
651 lua_pushnumber(tag); 640 lua_pushnumber(tag);
@@ -1471,3 +1460,16 @@ static StkId lua_execute (Byte *pc, StkId base)
1471 } 1460 }
1472} 1461}
1473 1462
1463
1464#if COMPAT2_5
1465/*
1466** API: set a function as a fallback
1467*/
1468lua_Object lua_setfallback (char *name, lua_CFunction fallback)
1469{
1470 lua_pushstring(name);
1471 lua_pushcfunction(fallback);
1472 do_unprotectedrun(luaI_setfallback, 2, 1);
1473 return put_luaObjectonTop();
1474}
1475#endif