mirror of
https://github.com/lua/lua
synced 2025-03-24 22:52:51 +03:00
"lua_open": now lua has an explicit open operation.
This commit is contained in:
parent
dad5a01fb0
commit
45cad43c3f
15
lapi.c
15
lapi.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lapi.c,v 1.2 1997/09/26 15:02:26 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 1.3 1997/10/24 17:17:24 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -10,9 +10,11 @@
|
||||
|
||||
#include "lapi.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lbuiltin.h"
|
||||
#include "ldo.h"
|
||||
#include "lfunc.h"
|
||||
#include "lgc.h"
|
||||
#include "llex.h"
|
||||
#include "lmem.h"
|
||||
#include "lobject.h"
|
||||
#include "lstring.h"
|
||||
@ -544,6 +546,17 @@ lua_Object lua_getref (int ref)
|
||||
}
|
||||
|
||||
|
||||
void lua_open (void)
|
||||
{
|
||||
static int firsttime = 1;
|
||||
if (!firsttime) return;
|
||||
firsttime = 0;
|
||||
luaS_init();
|
||||
luaX_init();
|
||||
luaT_init();
|
||||
luaD_init();
|
||||
luaB_predefine();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lauxlib.c,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
|
||||
** $Id: lauxlib.c,v 1.2 1997/09/26 15:02:26 roberto Exp roberto $
|
||||
** Auxiliar functions for building Lua libraries
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -67,6 +67,7 @@ lua_Object luaL_nonnullarg (int numArg)
|
||||
void luaL_openlib (struct luaL_reg *l, int n)
|
||||
{
|
||||
int i;
|
||||
lua_open(); /* make sure lua is already open */
|
||||
for (i=0; i<n; i++)
|
||||
lua_register(l[i].name, l[i].func);
|
||||
}
|
||||
|
20
lbuiltin.c
20
lbuiltin.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lbuiltin.c,v 1.4 1997/10/23 16:28:48 roberto Exp roberto $
|
||||
** $Id: lbuiltin.c,v 1.5 1997/10/24 17:17:24 roberto Exp roberto $
|
||||
** Built-in functions
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -455,23 +455,11 @@ static struct luaL_reg int_funcs[] = {
|
||||
|
||||
void luaB_predefine (void)
|
||||
{
|
||||
int i;
|
||||
TaggedString *ts;
|
||||
TObject o;
|
||||
/* pre-register mem error messages, to avoid loop when error arises */
|
||||
luaS_newfixedstring(tableEM);
|
||||
luaS_newfixedstring(memEM);
|
||||
for (i=0; i<INTFUNCSIZE; i++) {
|
||||
ts = luaS_new(int_funcs[i].name);
|
||||
fvalue(&o) = int_funcs[i].func;
|
||||
ttype(&o) = LUA_T_CPROTO;
|
||||
luaF_simpleclosure(&o);
|
||||
luaS_rawsetglobal(ts, &o);
|
||||
}
|
||||
ts = luaS_new("_VERSION");
|
||||
ttype(&o) = LUA_T_STRING;
|
||||
tsvalue(&o) = luaS_new(LUA_VERSION);
|
||||
luaS_rawsetglobal(ts, &o);
|
||||
luaL_openlib(int_funcs, (sizeof(int_funcs)/sizeof(int_funcs[0])));
|
||||
lua_pushstring(LUA_VERSION);
|
||||
lua_setglobal("_VERSION");
|
||||
}
|
||||
|
||||
|
||||
|
22
ldo.c
22
ldo.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldo.c,v 1.5 1997/10/24 17:17:24 roberto Exp roberto $
|
||||
** $Id: ldo.c,v 1.6 1997/11/03 21:00:23 roberto Exp roberto $
|
||||
** Stack and Call structure of Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -9,7 +9,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lbuiltin.h"
|
||||
#include "ldo.h"
|
||||
#include "lfunc.h"
|
||||
#include "lgc.h"
|
||||
@ -30,9 +29,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
static TObject initial_stack;
|
||||
|
||||
struct Stack luaD_stack = {&initial_stack, &initial_stack, &initial_stack};
|
||||
struct Stack luaD_stack;
|
||||
|
||||
|
||||
struct C_Lua_Stack luaD_Cstack = {0, 0, 0};
|
||||
@ -64,24 +61,21 @@ static void initCfunc (TObject *o, lua_CFunction f)
|
||||
|
||||
|
||||
#define STACK_EXTRA 32
|
||||
#define INIT_STACK_SIZE 32
|
||||
|
||||
static void initstack (int n)
|
||||
|
||||
void luaD_init (void)
|
||||
{
|
||||
int maxstack = STACK_EXTRA+n;
|
||||
luaD_stack.stack = luaM_newvector(maxstack, TObject);
|
||||
luaD_stack.last = luaD_stack.stack+(maxstack-1);
|
||||
luaD_stack.stack = luaM_newvector(INIT_STACK_SIZE, TObject);
|
||||
luaD_stack.top = luaD_stack.stack;
|
||||
*luaD_stack.stack = initial_stack;
|
||||
luaB_predefine();
|
||||
luaD_stack.last = luaD_stack.stack+(INIT_STACK_SIZE-1);
|
||||
initCfunc(&luaD_errorim, stderrorim);
|
||||
}
|
||||
|
||||
|
||||
void luaD_checkstack (int n)
|
||||
{
|
||||
if (luaD_stack.stack == &initial_stack)
|
||||
initstack(n);
|
||||
else if (luaD_stack.last-luaD_stack.top <= n) {
|
||||
if (luaD_stack.last-luaD_stack.top <= n) {
|
||||
static int limit = STACK_LIMIT;
|
||||
StkId top = luaD_stack.top-luaD_stack.stack;
|
||||
int stacksize = (luaD_stack.last-luaD_stack.stack)+1+STACK_EXTRA+n;
|
||||
|
4
ldo.h
4
ldo.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: $
|
||||
** $Id: ldo.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
|
||||
** Stack and Call structure of Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -47,6 +47,8 @@ extern TObject luaD_errorim;
|
||||
#define Address(lo) ((lo)+luaD_stack.stack-1)
|
||||
#define Ref(st) ((st)-luaD_stack.stack+1)
|
||||
|
||||
|
||||
void luaD_init (void);
|
||||
void luaD_adjusttop (StkId newtop);
|
||||
void luaD_openstack (int nelems);
|
||||
void luaD_lineHook (int line);
|
||||
|
4
liolib.c
4
liolib.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: liolib.c,v 1.2 1997/09/23 14:12:44 roberto Exp roberto $
|
||||
** $Id: liolib.c,v 1.3 1997/10/30 20:29:09 roberto Exp roberto $
|
||||
** Standard I/O (and system) library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -372,6 +372,7 @@ static struct luaL_reg iolib[] = {
|
||||
|
||||
void lua_iolibopen (void)
|
||||
{
|
||||
luaL_openlib(iolib, (sizeof(iolib)/sizeof(iolib[0])));
|
||||
lua_tagio = lua_newtag();
|
||||
closedtag = lua_newtag();
|
||||
setfile(stdin, "_INPUT");
|
||||
@ -379,7 +380,6 @@ void lua_iolibopen (void)
|
||||
setfile(stdin, "_STDIN");
|
||||
setfile(stdout, "_STDOUT");
|
||||
setfile(stderr, "_STDERR");
|
||||
luaL_openlib(iolib, (sizeof(iolib)/sizeof(iolib[0])));
|
||||
lua_pushcfunction(errorfb);
|
||||
lua_seterrormethod();
|
||||
}
|
||||
|
17
llex.c
17
llex.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: llex.c,v 1.2 1997/09/26 15:02:26 roberto Exp roberto $
|
||||
** $Id: llex.c,v 1.3 1997/10/13 22:10:45 roberto Exp roberto $
|
||||
** Lexical Analizer
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -30,7 +30,7 @@ int lua_debug=0;
|
||||
|
||||
|
||||
|
||||
static void addReserved (void)
|
||||
void luaX_init (void)
|
||||
{
|
||||
static struct {
|
||||
char *name;
|
||||
@ -41,14 +41,10 @@ static void addReserved (void)
|
||||
{"nil", NIL}, {"not", NOT}, {"or", OR}, {"repeat", REPEAT},
|
||||
{"return", RETURN}, {"then", THEN}, {"until", UNTIL}, {"while", WHILE}
|
||||
};
|
||||
static int firsttime = 1;
|
||||
if (firsttime) {
|
||||
int i;
|
||||
firsttime = 0;
|
||||
for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++) {
|
||||
TaggedString *ts = luaS_new(reserved[i].name);
|
||||
ts->head.marked = reserved[i].token; /* reserved word (always > 255) */
|
||||
}
|
||||
int i;
|
||||
for (i=0; i<(sizeof(reserved)/sizeof(reserved[0])); i++) {
|
||||
TaggedString *ts = luaS_new(reserved[i].name);
|
||||
ts->head.marked = reserved[i].token; /* reserved word (always > 255) */
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +81,6 @@ static void firstline (void)
|
||||
|
||||
void luaX_setinput (ZIO *z)
|
||||
{
|
||||
addReserved();
|
||||
current = '\n';
|
||||
luaX_linenumber = 0;
|
||||
iflevel = 0;
|
||||
|
4
llex.h
4
llex.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: $
|
||||
** $Id: llex.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
|
||||
** Lexical Analizer
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -13,6 +13,8 @@
|
||||
|
||||
extern int luaX_linenumber;
|
||||
|
||||
|
||||
void luaX_init (void);
|
||||
int luaY_lex (void);
|
||||
void luaX_setinput (ZIO *z);
|
||||
char *luaX_lasttoken (void);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lmathlib.c,v 1.2 1997/10/24 17:44:22 roberto Exp roberto $
|
||||
** $Id: lmathlib.c,v 1.3 1997/11/03 21:11:44 roberto Exp roberto $
|
||||
** Lua standard mathematical library
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -202,8 +202,8 @@ static struct luaL_reg mathlib[] = {
|
||||
*/
|
||||
void lua_mathlibopen (void)
|
||||
{
|
||||
lua_pushstring("deg"); lua_setglobal("_TRIGMODE");
|
||||
luaL_openlib(mathlib, (sizeof(mathlib)/sizeof(mathlib[0])));
|
||||
lua_pushstring("deg"); lua_setglobal("_TRIGMODE");
|
||||
lua_pushcfunction(math_pow);
|
||||
lua_pushnumber(0); /* to get its tag */
|
||||
lua_settagmethod(lua_tag(lua_pop()), "pow");
|
||||
|
28
lstring.c
28
lstring.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstring.c,v 1.2 1997/09/26 15:02:26 roberto Exp roberto $
|
||||
** $Id: lstring.c,v 1.3 1997/10/23 16:26:37 roberto Exp roberto $
|
||||
** String table (keep all strings handled by Lua)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -29,26 +29,22 @@ typedef struct {
|
||||
} stringtable;
|
||||
|
||||
|
||||
static stringtable string_root[NUM_HASHS] = {
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL}, {0, 0, NULL},
|
||||
{0, 0, NULL}
|
||||
};
|
||||
static stringtable string_root[NUM_HASHS];
|
||||
|
||||
|
||||
static TaggedString EMPTY = {{NULL, 2}, 0, 0L, {{LUA_T_NIL, {NULL}}}, {0}};
|
||||
|
||||
|
||||
void luaS_init (void)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<NUM_HASHS; i++) {
|
||||
string_root[i].size = 0;
|
||||
string_root[i].nuse = 0;
|
||||
string_root[i].hash = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static unsigned long hash (char *s, int tag)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstring.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
|
||||
** $Id: lstring.h,v 1.2 1997/09/26 15:02:26 roberto Exp roberto $
|
||||
** String table (keep all strings handled by Lua)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -12,6 +12,8 @@
|
||||
|
||||
extern GCnode luaS_root;
|
||||
|
||||
|
||||
void luaS_init (void);
|
||||
TaggedString *luaS_createudata (void *udata, int tag);
|
||||
TaggedString *luaS_collector (void);
|
||||
void luaS_free (TaggedString *l);
|
||||
|
83
ltm.c
83
ltm.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ltm.c,v 1.4 1997/10/24 17:17:24 roberto Exp roberto $
|
||||
** $Id: ltm.c,v 1.5 1997/11/03 20:45:23 roberto Exp roberto $
|
||||
** Tag methods
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -14,53 +14,6 @@
|
||||
#include "lobject.h"
|
||||
#include "ltm.h"
|
||||
|
||||
static struct IM init_IM[NUM_TAGS] = {
|
||||
{{{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}}},
|
||||
{{{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}}},
|
||||
{{{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}}},
|
||||
{{{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}}},
|
||||
{{{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}}},
|
||||
{{{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}}},
|
||||
{{{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}},
|
||||
{LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}, {LUA_T_NIL, {NULL}}}}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
char *luaT_eventname[] = { /* ORDER IM */
|
||||
"gettable", "settable", "index", "getglobal", "setglobal", "add",
|
||||
@ -78,11 +31,9 @@ static int luaI_checkevent (char *name, char *list[])
|
||||
}
|
||||
|
||||
|
||||
struct IM *luaT_IMtable = init_IM;
|
||||
|
||||
static int IMtable_size = NUM_TAGS;
|
||||
|
||||
static int last_tag = -(NUM_TAGS-1);
|
||||
struct IM *luaT_IMtable;
|
||||
static int IMtable_size;
|
||||
static int last_tag;
|
||||
|
||||
|
||||
/* events in LUA_T_NIL are all allowed, since this is used as a
|
||||
@ -98,6 +49,7 @@ static char validevents[NUM_TAGS][IM_N] = { /* ORDER LUA_T, ORDER IM */
|
||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} /* LUA_T_NIL */
|
||||
};
|
||||
|
||||
|
||||
static int validevent (lua_Type t, int e)
|
||||
{ /* ORDER LUA_T */
|
||||
return (t < LUA_T_NIL) ? 1 : validevents[-t][e];
|
||||
@ -111,19 +63,24 @@ static void init_entry (int tag)
|
||||
ttype(luaT_getim(tag, i)) = LUA_T_NIL;
|
||||
}
|
||||
|
||||
|
||||
void luaT_init (void)
|
||||
{
|
||||
int t;
|
||||
IMtable_size = NUM_TAGS;
|
||||
last_tag = -(NUM_TAGS-1);
|
||||
luaT_IMtable = luaM_newvector(IMtable_size, struct IM);
|
||||
for (t=last_tag; t<=0; t++)
|
||||
init_entry(t);
|
||||
}
|
||||
|
||||
|
||||
int lua_newtag (void)
|
||||
{
|
||||
--last_tag;
|
||||
if ((-last_tag) >= IMtable_size) {
|
||||
if (luaT_IMtable == init_IM) { /* fist time? */
|
||||
IMtable_size *= 2;
|
||||
luaT_IMtable = luaM_newvector(IMtable_size, struct IM);
|
||||
memcpy(luaT_IMtable, init_IM, sizeof(init_IM));
|
||||
}
|
||||
else
|
||||
IMtable_size = luaM_growvector(&luaT_IMtable, IMtable_size,
|
||||
struct IM, memEM, MAX_INT);
|
||||
}
|
||||
if ((-last_tag) >= IMtable_size)
|
||||
IMtable_size = luaM_growvector(&luaT_IMtable, IMtable_size,
|
||||
struct IM, memEM, MAX_INT);
|
||||
init_entry(last_tag);
|
||||
return last_tag;
|
||||
}
|
||||
|
3
ltm.h
3
ltm.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: $
|
||||
** $Id: ltm.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
|
||||
** Tag methods
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -49,6 +49,7 @@ extern struct IM {
|
||||
extern char *luaT_eventname[];
|
||||
|
||||
|
||||
void luaT_init (void);
|
||||
void luaT_settag (int tag, TObject *o);
|
||||
void luaT_realtag (int tag);
|
||||
int luaT_efectivetag (TObject *o);
|
||||
|
9
lua.h
9
lua.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lua.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
|
||||
** $Id: lua.h,v 1.2 1997/10/24 17:17:24 roberto Exp roberto $
|
||||
** LUA - An Extensible Extension Language
|
||||
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
|
||||
** e-mail: lua@tecgraf.puc-rio.br
|
||||
@ -53,9 +53,12 @@
|
||||
typedef void (*lua_CFunction) (void);
|
||||
typedef unsigned int lua_Object;
|
||||
|
||||
lua_Object lua_settagmethod (int tag, char *event); /* In: luaM_new method */
|
||||
|
||||
void lua_open (void);
|
||||
|
||||
lua_Object lua_settagmethod (int tag, char *event); /* In: new method */
|
||||
lua_Object lua_gettagmethod (int tag, char *event);
|
||||
lua_Object lua_seterrormethod (void); /* In: luaM_new method */
|
||||
lua_Object lua_seterrormethod (void); /* In: new method */
|
||||
|
||||
int lua_newtag (void);
|
||||
void lua_settag (int tag); /* In: object */
|
||||
|
Loading…
x
Reference in New Issue
Block a user