mirror of
https://github.com/lua/lua
synced 2024-12-24 03:16:50 +03:00
new #define LUA_COMPAT2_5 to select "compatibility mode".
This commit is contained in:
parent
3e43275308
commit
e81f184164
@ -3,7 +3,7 @@
|
||||
** TecCGraf - PUC-Rio
|
||||
*/
|
||||
|
||||
char *rcs_fallback="$Id: fallback.c,v 2.7 1997/06/16 18:43:19 roberto Exp roberto $";
|
||||
char *rcs_fallback="$Id: fallback.c,v 2.8 1997/06/17 17:27:07 roberto Exp roberto $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -281,7 +281,7 @@ char *luaI_travfallbacks (int (*fn)(TObject *))
|
||||
* ===================================================================
|
||||
* compatibility with old fallback system
|
||||
*/
|
||||
|
||||
#if LUA_COMPAT2_5
|
||||
|
||||
static void errorFB (void)
|
||||
{
|
||||
@ -310,6 +310,7 @@ static void fillvalids (IMS e, TObject *func)
|
||||
*luaI_getim(t, e) = *func;
|
||||
}
|
||||
|
||||
|
||||
void luaI_setfallback (void)
|
||||
{
|
||||
static char *oldnames [] = {"error", "getglobal", "arith", "order", NULL};
|
||||
@ -364,4 +365,4 @@ void luaI_setfallback (void)
|
||||
else
|
||||
lua_pushcfunction(replace);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
4
inout.c
4
inout.c
@ -5,7 +5,7 @@
|
||||
** Also provides some predefined lua functions.
|
||||
*/
|
||||
|
||||
char *rcs_inout="$Id: inout.c,v 2.65 1997/06/19 18:49:40 roberto Exp roberto $";
|
||||
char *rcs_inout="$Id: inout.c,v 2.66 1997/06/20 19:19:09 roberto Exp roberto $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -377,7 +377,9 @@ static struct {
|
||||
{"rawsetglobal", luaI_rawsetglobal},
|
||||
{"rawsettable", rawsettable},
|
||||
{"seterrormethod", luaI_seterrormethod},
|
||||
#if LUA_COMPAT2_5
|
||||
{"setfallback", luaI_setfallback},
|
||||
#endif
|
||||
{"setglobal", luaI_setglobal},
|
||||
{"settagmethod", luaI_settagmethod},
|
||||
{"gettagmethod", luaI_gettagmethod},
|
||||
|
17
lua.h
17
lua.h
@ -2,7 +2,7 @@
|
||||
** LUA - An Extensible Extension Language
|
||||
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
|
||||
** e-mail: lua@tecgraf.puc-rio.br
|
||||
** $Id: lua.h,v 4.9 1997/06/18 21:20:45 roberto Exp roberto $
|
||||
** $Id: lua.h,v 4.10 1997/06/19 18:03:04 roberto Exp roberto $
|
||||
*/
|
||||
|
||||
|
||||
@ -102,13 +102,18 @@ long lua_collectgarbage (long limit);
|
||||
|
||||
|
||||
|
||||
/* If your program has no compatibility problems, you can change
|
||||
** this to 0
|
||||
/* ==========================================================================
|
||||
** for compatibility with old versions. Avoid using these macros/functions
|
||||
** If your program does not use any of these, define LUA_COMPAT2_5 to 0
|
||||
*/
|
||||
#if 1
|
||||
|
||||
/* =============================================================== */
|
||||
/* for compatibility with old versions. Avoid using these macros/functions */
|
||||
#ifndef LUA_COMPAT2_5
|
||||
#define LUA_COMPAT2_5 1
|
||||
#endif
|
||||
|
||||
|
||||
#if LUA_COMPAT2_5
|
||||
|
||||
|
||||
lua_Object lua_setfallback (char *event, lua_CFunction fallback);
|
||||
|
||||
|
4
makefile
4
makefile
@ -1,4 +1,4 @@
|
||||
# $Id: makefile,v 1.34 1997/06/11 18:57:00 roberto Exp roberto $
|
||||
# $Id: makefile,v 1.35 1997/06/16 16:50:22 roberto Exp roberto $
|
||||
|
||||
#configuration
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
# define (undefine) _POSIX_SOURCE if your system is (not) POSIX compliant
|
||||
#define (undefine) NOSTRERROR if your system does NOT have function "strerror"
|
||||
# (although this is ANSI, SunOS does not comply; so, add "-DNOSTRERROR" on SunOS)
|
||||
# define LUA_COMPAT2_5=0 if yous system does not need to be compatible with
|
||||
# version 2.5 (or older)
|
||||
CONFIG = -DPOPEN -D_POSIX_SOURCE
|
||||
# Compilation parameters
|
||||
CC = gcc
|
||||
|
28
opcode.c
28
opcode.c
@ -3,7 +3,7 @@
|
||||
** TecCGraf - PUC-Rio
|
||||
*/
|
||||
|
||||
char *rcs_opcode="$Id: opcode.c,v 4.12 1997/06/19 17:46:12 roberto Exp roberto $";
|
||||
char *rcs_opcode="$Id: opcode.c,v 4.13 1997/06/19 18:03:04 roberto Exp roberto $";
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
@ -325,7 +325,7 @@ static void do_call (StkId base, int nResults)
|
||||
firstResult = lua_execute(func->value.tf->code, base);
|
||||
}
|
||||
else { /* func is not a function */
|
||||
/* Check the fallback for invalid functions */
|
||||
/* Check the tag method for invalid functions */
|
||||
TObject *im = luaI_getimbyObj(func, IM_FUNCTION);
|
||||
if (ttype(im) == LUA_T_NIL)
|
||||
lua_error("call expression not a function");
|
||||
@ -635,17 +635,6 @@ int lua_callfunction (lua_Object function)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** API: set a function as a fallback
|
||||
*/
|
||||
lua_Object lua_setfallback (char *name, lua_CFunction fallback)
|
||||
{
|
||||
lua_pushstring(name);
|
||||
lua_pushcfunction(fallback);
|
||||
do_unprotectedrun(luaI_setfallback, 2, 1);
|
||||
return put_luaObjectonTop();
|
||||
}
|
||||
|
||||
lua_Object lua_gettagmethod (int tag, char *event)
|
||||
{
|
||||
lua_pushnumber(tag);
|
||||
@ -1471,3 +1460,16 @@ static StkId lua_execute (Byte *pc, StkId base)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if COMPAT2_5
|
||||
/*
|
||||
** API: set a function as a fallback
|
||||
*/
|
||||
lua_Object lua_setfallback (char *name, lua_CFunction fallback)
|
||||
{
|
||||
lua_pushstring(name);
|
||||
lua_pushcfunction(fallback);
|
||||
do_unprotectedrun(luaI_setfallback, 2, 1);
|
||||
return put_luaObjectonTop();
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user