eventtable' renamed to metatable'

This commit is contained in:
Roberto Ierusalimschy 2002-01-30 15:26:44 -02:00
parent 50e2952593
commit d6fd33e76f
13 changed files with 69 additions and 69 deletions

32
lapi.c
View File

@ -402,25 +402,25 @@ LUA_API void lua_newtable (lua_State *L) {
} }
LUA_API void lua_geteventtable (lua_State *L, int objindex) { LUA_API void lua_getmetatable (lua_State *L, int objindex) {
StkId obj; StkId obj;
Table *et; Table *mt;
lua_lock(L); lua_lock(L);
obj = luaA_indexAcceptable(L, objindex); obj = luaA_indexAcceptable(L, objindex);
switch (ttype(obj)) { switch (ttype(obj)) {
case LUA_TTABLE: case LUA_TTABLE:
et = hvalue(obj)->eventtable; mt = hvalue(obj)->metatable;
break; break;
case LUA_TUSERDATA: case LUA_TUSERDATA:
et = uvalue(obj)->uv.eventtable; mt = uvalue(obj)->uv.metatable;
break; break;
default: default:
et = hvalue(defaultet(L)); mt = hvalue(defaultmeta(L));
} }
if (et == hvalue(defaultet(L))) if (mt == hvalue(defaultmeta(L)))
setnilvalue(L->top); setnilvalue(L->top);
else else
sethvalue(L->top, et); sethvalue(L->top, mt);
api_incr_top(L); api_incr_top(L);
lua_unlock(L); lua_unlock(L);
} }
@ -488,24 +488,24 @@ LUA_API void lua_setglobals (lua_State *L) {
} }
LUA_API void lua_seteventtable (lua_State *L, int objindex) { LUA_API void lua_setmetatable (lua_State *L, int objindex) {
StkId obj, et; StkId obj, mt;
lua_lock(L); lua_lock(L);
api_checknelems(L, 1); api_checknelems(L, 1);
obj = luaA_indexAcceptable(L, objindex); obj = luaA_indexAcceptable(L, objindex);
et = --L->top; mt = --L->top;
if (ttype(et) == LUA_TNIL) if (ttype(mt) == LUA_TNIL)
et = defaultet(L); mt = defaultmeta(L);
api_check(L, ttype(et) == LUA_TTABLE); api_check(L, ttype(mt) == LUA_TTABLE);
switch (ttype(obj)) { switch (ttype(obj)) {
case LUA_TTABLE: case LUA_TTABLE:
hvalue(obj)->eventtable = hvalue(et); hvalue(obj)->metatable = hvalue(mt);
break; break;
case LUA_TUSERDATA: case LUA_TUSERDATA:
uvalue(obj)->uv.eventtable = hvalue(et); uvalue(obj)->uv.metatable = hvalue(mt);
break; break;
default: default:
luaO_verror(L, "cannot change the event table of a %.20s", luaO_verror(L, "cannot change the meta table of a %.20s",
luaT_typenames[ttype(obj)]); luaT_typenames[ttype(obj)]);
} }
lua_unlock(L); lua_unlock(L);

View File

@ -135,15 +135,15 @@ static int luaB_getglobal (lua_State *L) {
} }
static int luaB_eventtable (lua_State *L) { static int luaB_metatable (lua_State *L) {
luaL_check_type(L, 1, LUA_TTABLE); luaL_check_type(L, 1, LUA_TTABLE);
if (lua_isnone(L, 2)) if (lua_isnone(L, 2))
lua_geteventtable(L, 1); lua_getmetatable(L, 1);
else { else {
int t = lua_type(L, 2); int t = lua_type(L, 2);
luaL_arg_check(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil/table expected"); luaL_arg_check(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil/table expected");
lua_settop(L, 2); lua_settop(L, 2);
lua_seteventtable(L, 1); lua_setmetatable(L, 1);
} }
return 1; return 1;
} }
@ -447,7 +447,7 @@ static int luaB_coroutine (lua_State *L) {
lua_cobegin(NL, n-1); lua_cobegin(NL, n-1);
lua_newuserdatabox(L, NL); lua_newuserdatabox(L, NL);
lua_getstr(L, LUA_REGISTRYINDEX, "Coroutine"); lua_getstr(L, LUA_REGISTRYINDEX, "Coroutine");
lua_seteventtable(L, -2); lua_setmetatable(L, -2);
lua_pushcclosure(L, luaB_resume, 1); lua_pushcclosure(L, luaB_resume, 1);
return 1; return 1;
} }
@ -517,6 +517,7 @@ static int luaB_tinsert (lua_State *L) {
v = 3; /* function may be called with more than 3 args */ v = 3; /* function may be called with more than 3 args */
pos = luaL_check_int(L, 2); /* 2nd argument is the position */ pos = luaL_check_int(L, 2); /* 2nd argument is the position */
} }
if (pos > n+1) n = pos-1;
aux_setn(L, 1, n+1); /* t.n = n+1 */ aux_setn(L, 1, n+1); /* t.n = n+1 */
for (; n>=pos; n--) { for (; n>=pos; n--) {
lua_rawgeti(L, 1, n); lua_rawgeti(L, 1, n);
@ -665,7 +666,7 @@ static const luaL_reg base_funcs[] = {
{"dofile", luaB_dofile}, {"dofile", luaB_dofile},
{"dostring", luaB_dostring}, {"dostring", luaB_dostring},
{"error", luaB_error}, {"error", luaB_error},
{"eventtable", luaB_eventtable}, {"metatable", luaB_metatable},
{"foreach", luaB_foreach}, {"foreach", luaB_foreach},
{"foreachi", luaB_foreachi}, {"foreachi", luaB_foreachi},
{"gcinfo", luaB_gcinfo}, {"gcinfo", luaB_gcinfo},

33
lgc.c
View File

@ -122,13 +122,12 @@ static void markobject (GCState *st, TObject *o) {
} }
static void checkstacksizes (lua_State *L, StkId lim) { static void checkstacksizes (lua_State *L) {
int used = L->ci - L->base_ci; /* number of `ci' in use */ int used = L->ci - L->base_ci; /* number of `ci' in use */
if (4*used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) if (4*used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci)
luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ luaD_reallocCI(L, L->size_ci/2); /* still big enough... */
if (lim < L->top) lim = L->top; used = L->top - L->stack; /* part of stack in use */
used = lim - L->stack; /* part of stack in use */ if (2*(used+MAXSTACK) < L->stacksize && 2*BASIC_STACK_SIZE < L->stacksize)
if (3*used < L->stacksize && 2*BASIC_STACK_SIZE < L->stacksize)
luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ luaD_reallocstack(L, L->stacksize/2); /* still big enough... */
} }
@ -148,7 +147,7 @@ static void markstacks (GCState *st) {
lim = (L1->stack_last - L1->ci->base > MAXSTACK) ? L1->ci->base+MAXSTACK lim = (L1->stack_last - L1->ci->base > MAXSTACK) ? L1->ci->base+MAXSTACK
: L1->stack_last; : L1->stack_last;
for (; o<=lim; o++) setnilvalue(o); for (; o<=lim; o++) setnilvalue(o);
checkstacksizes(L1, lim); checkstacksizes(L1);
lua_assert(L1->previous->next == L1 && L1->next->previous == L1); lua_assert(L1->previous->next == L1 && L1->next->previous == L1);
L1 = L1->next; L1 = L1->next;
} while (L1 != st->L); } while (L1 != st->L);
@ -158,9 +157,9 @@ static void markstacks (GCState *st) {
static void markudet (GCState *st) { static void markudet (GCState *st) {
Udata *u; Udata *u;
for (u = G(st->L)->rootudata; u; u = u->uv.next) for (u = G(st->L)->rootudata; u; u = u->uv.next)
marktable(st, u->uv.eventtable); marktable(st, u->uv.metatable);
for (u = G(st->L)->tmudata; u; u = u->uv.next) for (u = G(st->L)->tmudata; u; u = u->uv.next)
marktable(st, u->uv.eventtable); marktable(st, u->uv.metatable);
} }
@ -176,8 +175,8 @@ static void traversetable (GCState *st, Table *h) {
const TObject *mode; const TObject *mode;
int weakkey = 0; int weakkey = 0;
int weakvalue = 0; int weakvalue = 0;
marktable(st, h->eventtable); marktable(st, h->metatable);
mode = fasttm(st->L, h->eventtable, TM_WEAKMODE); mode = fasttm(st->L, h->metatable, TM_WEAKMODE);
if (mode) { /* weak table? must be cleared after GC... */ if (mode) { /* weak table? must be cleared after GC... */
h->mark = st->toclear; /* put in the appropriate list */ h->mark = st->toclear; /* put in the appropriate list */
st->toclear = h; st->toclear = h;
@ -204,10 +203,10 @@ static void traversetable (GCState *st, Table *h) {
static void markall (GCState *st) { static void markall (GCState *st) {
lua_assert(hvalue(defaultet(st->L))->flags == cast(unsigned short, ~0)); lua_assert(hvalue(defaultmeta(st->L))->flags == cast(unsigned short, ~0));
/* table is unchanged */ /* table is unchanged */
markstacks(st); /* mark all stacks */ markstacks(st); /* mark all stacks */
markudet(st); /* mark userdata's event tables */ markudet(st); /* mark userdata's meta tables */
while (st->tmark) { /* traverse marked tables */ while (st->tmark) { /* traverse marked tables */
Table *h = st->tmark; /* get first table from list */ Table *h = st->tmark; /* get first table from list */
st->tmark = h->mark; /* remove it from list */ st->tmark = h->mark; /* remove it from list */
@ -333,7 +332,7 @@ static void collectudata (lua_State *L) {
} }
else { else {
*p = curr->uv.next; *p = curr->uv.next;
if (fasttm(L, curr->uv.eventtable, TM_GC) != NULL) { /* gc event? */ if (fasttm(L, curr->uv.metatable, TM_GC) != NULL) { /* gc event? */
curr->uv.next = NULL; /* link `curr' at the end of `collected' list */ curr->uv.next = NULL; /* link `curr' at the end of `collected' list */
*lastcollected = curr; *lastcollected = curr;
lastcollected = &curr->uv.next; lastcollected = &curr->uv.next;
@ -384,7 +383,7 @@ static void checkMbuffer (lua_State *L) {
static void do1gcTM (lua_State *L, Udata *udata) { static void do1gcTM (lua_State *L, Udata *udata) {
const TObject *tm = fasttm(L, udata->uv.eventtable, TM_GC); const TObject *tm = fasttm(L, udata->uv.metatable, TM_GC);
if (tm != NULL) { if (tm != NULL) {
setobj(L->top, tm); setobj(L->top, tm);
setuvalue(L->top+1, udata); setuvalue(L->top+1, udata);
@ -405,8 +404,8 @@ static void unprotectedcallGCTM (lua_State *L, void *pu) {
udata->uv.next = G(L)->rootudata; /* resurect it */ udata->uv.next = G(L)->rootudata; /* resurect it */
G(L)->rootudata = udata; G(L)->rootudata = udata;
do1gcTM(L, udata); do1gcTM(L, udata);
/* mark udata as finalized (default event table) */ /* mark udata as finalized (default meta table) */
uvalue(L->top-1)->uv.eventtable = hvalue(defaultet(L)); uvalue(L->top-1)->uv.metatable = hvalue(defaultmeta(L));
unmarkud(uvalue(L->top-1)); unmarkud(uvalue(L->top-1));
} }
L->top--; L->top--;
@ -420,8 +419,8 @@ static void callGCTM (lua_State *L) {
Udata *udata; Udata *udata;
if (luaD_runprotected(L, unprotectedcallGCTM, &udata) != 0) { if (luaD_runprotected(L, unprotectedcallGCTM, &udata) != 0) {
/* `udata' generated an error during its gc */ /* `udata' generated an error during its gc */
/* mark it as finalized (default event table) */ /* mark it as finalized (default meta table) */
udata->uv.eventtable = hvalue(defaultet(L)); udata->uv.metatable = hvalue(defaultmeta(L));
} }
} }
L->allowhooks = oldah; /* restore hooks */ L->allowhooks = oldah; /* restore hooks */

View File

@ -72,7 +72,7 @@ static int pushresult (lua_State *L, int i) {
static int checkfile (lua_State *L, int findex, const char *tname) { static int checkfile (lua_State *L, int findex, const char *tname) {
int res; int res;
lua_geteventtable(L, findex); lua_getmetatable(L, findex);
lua_getstr(L, LUA_REGISTRYINDEX, tname); lua_getstr(L, LUA_REGISTRYINDEX, tname);
res = lua_equal(L, -1, -2); res = lua_equal(L, -1, -2);
lua_pop(L, 2); lua_pop(L, 2);
@ -112,7 +112,7 @@ static FILE *getopthandle (lua_State *L, int inout) {
static void newfile (lua_State *L, FILE *f) { static void newfile (lua_State *L, FILE *f) {
lua_newuserdatabox(L, f); lua_newuserdatabox(L, f);
lua_getstr(L, LUA_REGISTRYINDEX, FILEHANDLE); lua_getstr(L, LUA_REGISTRYINDEX, FILEHANDLE);
lua_seteventtable(L, -2); lua_setmetatable(L, -2);
} }
@ -148,7 +148,7 @@ static int io_close (lua_State *L) {
if (f != stdin && f != stdout && f != stderr) { if (f != stdin && f != stdout && f != stderr) {
lua_settop(L, 1); /* make sure file is on top */ lua_settop(L, 1); /* make sure file is on top */
lua_getstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE); lua_getstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE);
lua_seteventtable(L, 1); lua_setmetatable(L, 1);
status = (CLOSEFILE(L, f) == 0); status = (CLOSEFILE(L, f) == 0);
} }
return pushresult(L, status); return pushresult(L, status);
@ -693,13 +693,13 @@ static const luaL_reg iolib[] = {
LUALIB_API int lua_iolibopen (lua_State *L) { LUALIB_API int lua_iolibopen (lua_State *L) {
lua_newtable(L); /* event table for FILEHANDLE */ lua_newtable(L); /* meta table for FILEHANDLE */
/* close files when collected */ /* close files when collected */
lua_pushcfunction(L, file_collect); lua_pushcfunction(L, file_collect);
lua_setstr(L, -2, "gc"); lua_setstr(L, -2, "gc");
/* put new eventtable into registry */ /* put new metatable into registry */
lua_setstr(L, LUA_REGISTRYINDEX, FILEHANDLE); lua_setstr(L, LUA_REGISTRYINDEX, FILEHANDLE);
/* event table for CLOSEDFILEHANDLE */ /* meta table for CLOSEDFILEHANDLE */
lua_newtable(L); lua_newtable(L);
lua_setstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE); lua_setstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE);
luaL_openl(L, iolib); luaL_openl(L, iolib);

View File

@ -120,7 +120,7 @@ typedef union TString {
typedef union Udata { typedef union Udata {
union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
struct { struct {
struct Table *eventtable; struct Table *metatable;
void *value; void *value;
size_t len; /* least bit reserved for gc mark */ size_t len; /* least bit reserved for gc mark */
union Udata *next; /* chain for list of all udata */ union Udata *next; /* chain for list of all udata */
@ -221,7 +221,7 @@ typedef struct Node {
typedef struct Table { typedef struct Table {
struct Table *eventtable; struct Table *metatable;
TObject *array; /* array part */ TObject *array; /* array part */
Node *node; Node *node;
int sizearray; /* size of `array' array */ int sizearray; /* size of `array' array */

View File

@ -69,10 +69,10 @@ static void f_luaopen (lua_State *L, void *ud) {
G(L)->tmudata = NULL; G(L)->tmudata = NULL;
G(L)->nblocks = sizeof(lua_State) + sizeof(global_State); G(L)->nblocks = sizeof(lua_State) + sizeof(global_State);
stack_init(L, L, so->stacksize); /* init stack */ stack_init(L, L, so->stacksize); /* init stack */
/* create default event table with a dummy table, and then close the loop */ /* create default meta table with a dummy table, and then close the loop */
sethvalue(defaultet(L), NULL); sethvalue(defaultmeta(L), NULL);
sethvalue(defaultet(L), luaH_new(L, 0, 4)); sethvalue(defaultmeta(L), luaH_new(L, 0, 4));
hvalue(defaultet(L))->eventtable = hvalue(defaultet(L)); hvalue(defaultmeta(L))->metatable = hvalue(defaultmeta(L));
sethvalue(gt(L), luaH_new(L, 0, 4)); /* table of globals */ sethvalue(gt(L), luaH_new(L, 0, 4)); /* table of globals */
sethvalue(registry(L), luaH_new(L, 0, 0)); /* registry */ sethvalue(registry(L), luaH_new(L, 0, 0)); /* registry */
luaS_resize(L, 4); /* initial size of string table */ luaS_resize(L, 4); /* initial size of string table */
@ -107,7 +107,7 @@ LUA_API lua_State *lua_newthread (lua_State *OL, int stacksize) {
OL->next = L; OL->next = L;
L->previous = OL; L->previous = OL;
stack_init(L, OL, stacksize); /* init stack */ stack_init(L, OL, stacksize); /* init stack */
setobj(defaultet(L), defaultet(OL)); /* share default event table */ setobj(defaultmeta(L), defaultmeta(OL)); /* share default meta table */
setobj(gt(L), gt(OL)); /* share table of globals */ setobj(gt(L), gt(OL)); /* share table of globals */
setobj(registry(L), registry(OL)); /* share registry */ setobj(registry(L), registry(OL)); /* share registry */
lua_unlock(OL); lua_unlock(OL);

View File

@ -53,8 +53,8 @@ struct lua_longjmp; /* defined in ldo.c */
** reserve init of stack to store some global values ** reserve init of stack to store some global values
*/ */
/* default event table (both for tables and udata) */ /* default meta table (both for tables and udata) */
#define defaultet(L) (L->stack) #define defaultmeta(L) (L->stack)
/* table of globals */ /* table of globals */
#define gt(L) (L->stack + 1) #define gt(L) (L->stack + 1)

View File

@ -88,7 +88,7 @@ Udata *luaS_newudata (lua_State *L, size_t s) {
if (s & 1) s++; /* make sure size is even */ if (s & 1) s++; /* make sure size is even */
u = cast(Udata *, luaM_malloc(L, sizeudata(s))); u = cast(Udata *, luaM_malloc(L, sizeudata(s)));
u->uv.len = s; u->uv.len = s;
u->uv.eventtable = hvalue(defaultet(L)); u->uv.metatable = hvalue(defaultmeta(L));
u->uv.value = u + 1; u->uv.value = u + 1;
/* chain it on udata list */ /* chain it on udata list */
u->uv.next = G(L)->rootudata; u->uv.next = G(L)->rootudata;

View File

@ -273,7 +273,7 @@ static void rehash (lua_State *L, Table *t) {
Table *luaH_new (lua_State *L, int narray, int lnhash) { Table *luaH_new (lua_State *L, int narray, int lnhash) {
Table *t = luaM_new(L, Table); Table *t = luaM_new(L, Table);
t->eventtable = hvalue(defaultet(L)); t->metatable = hvalue(defaultmeta(L));
t->next = G(L)->roottable; t->next = G(L)->roottable;
G(L)->roottable = t; G(L)->roottable = t;
t->mark = t; t->mark = t;

View File

@ -344,14 +344,14 @@ static int unref (lua_State *L) {
return 0; return 0;
} }
static int eventtable (lua_State *L) { static int metatable (lua_State *L) {
luaL_check_any(L, 1); luaL_check_any(L, 1);
if (lua_isnone(L, 2)) if (lua_isnone(L, 2))
lua_geteventtable(L, 1); lua_getmetatable(L, 1);
else { else {
lua_settop(L, 2); lua_settop(L, 2);
luaL_check_type(L, 2, LUA_TTABLE); luaL_check_type(L, 2, LUA_TTABLE);
lua_seteventtable(L, 1); lua_setmetatable(L, 1);
} }
return 1; return 1;
} }
@ -608,11 +608,11 @@ static int testC (lua_State *L) {
else if EQ("dostring") { else if EQ("dostring") {
lua_dostring(L, luaL_check_string(L, getnum)); lua_dostring(L, luaL_check_string(L, getnum));
} }
else if EQ("seteventtable") { else if EQ("setmetatable") {
lua_seteventtable(L, getnum); lua_setmetatable(L, getnum);
} }
else if EQ("geteventtable") { else if EQ("getmetatable") {
lua_geteventtable(L, getnum); lua_getmetatable(L, getnum);
} }
else if EQ("type") { else if EQ("type") {
lua_pushstring(L, lua_typename(L, lua_type(L, getnum))); lua_pushstring(L, lua_typename(L, lua_type(L, getnum)));
@ -642,7 +642,7 @@ static const struct luaL_reg tests_funcs[] = {
{"unref", unref}, {"unref", unref},
{"d2s", d2s}, {"d2s", d2s},
{"s2d", s2d}, {"s2d", s2d},
{"eventtable", eventtable}, {"metatable", metatable},
{"newuserdata", newuserdata}, {"newuserdata", newuserdata},
{"newuserdatabox", newuserdatabox}, {"newuserdatabox", newuserdatabox},
{"udataval", udataval}, {"udataval", udataval},

4
ltm.c
View File

@ -57,9 +57,9 @@ const TObject *luaT_gettmbyobj (lua_State *L, const TObject *o, TMS event) {
TString *ename = G(L)->tmname[event]; TString *ename = G(L)->tmname[event];
switch (ttype(o)) { switch (ttype(o)) {
case LUA_TTABLE: case LUA_TTABLE:
return luaH_getstr(hvalue(o)->eventtable, ename); return luaH_getstr(hvalue(o)->metatable, ename);
case LUA_TUSERDATA: case LUA_TUSERDATA:
return luaH_getstr(uvalue(o)->uv.eventtable, ename); return luaH_getstr(uvalue(o)->uv.metatable, ename);
default: default:
return &luaO_nilobject; return &luaO_nilobject;
} }

4
lua.h
View File

@ -153,7 +153,7 @@ LUA_API void lua_gettable (lua_State *L, int index);
LUA_API void lua_rawget (lua_State *L, int index); LUA_API void lua_rawget (lua_State *L, int index);
LUA_API void lua_rawgeti (lua_State *L, int index, int n); LUA_API void lua_rawgeti (lua_State *L, int index, int n);
LUA_API void lua_newtable (lua_State *L); LUA_API void lua_newtable (lua_State *L);
LUA_API void lua_geteventtable (lua_State *L, int objindex); LUA_API void lua_getmetatable (lua_State *L, int objindex);
/* /*
@ -164,7 +164,7 @@ LUA_API void lua_settable (lua_State *L, int index);
LUA_API void lua_rawset (lua_State *L, int index); LUA_API void lua_rawset (lua_State *L, int index);
LUA_API void lua_rawseti (lua_State *L, int index, int n); LUA_API void lua_rawseti (lua_State *L, int index, int n);
LUA_API void lua_setglobals (lua_State *L); LUA_API void lua_setglobals (lua_State *L);
LUA_API void lua_seteventtable (lua_State *L, int objindex); LUA_API void lua_setmetatable (lua_State *L, int objindex);
/* /*

4
lvm.c
View File

@ -125,7 +125,7 @@ void luaV_gettable (lua_State *L, StkId t, TObject *key, StkId res) {
const TObject *tm; const TObject *tm;
init: init:
if (ttype(t) == LUA_TTABLE) { /* `t' is a table? */ if (ttype(t) == LUA_TTABLE) { /* `t' is a table? */
Table *et = hvalue(t)->eventtable; Table *et = hvalue(t)->metatable;
if ((tm = fasttm(L, et, TM_GETTABLE)) == NULL) { /* no gettable TM? */ if ((tm = fasttm(L, et, TM_GETTABLE)) == NULL) { /* no gettable TM? */
const TObject *h = luaH_get(hvalue(t), key); /* do a primitive get */ const TObject *h = luaH_get(hvalue(t), key); /* do a primitive get */
/* result is no nil or there is no `index' tag method? */ /* result is no nil or there is no `index' tag method? */
@ -158,7 +158,7 @@ void luaV_settable (lua_State *L, StkId t, TObject *key, StkId val) {
const TObject *tm; const TObject *tm;
init: init:
if (ttype(t) == LUA_TTABLE) { /* `t' is a table? */ if (ttype(t) == LUA_TTABLE) { /* `t' is a table? */
Table *et = hvalue(t)->eventtable; Table *et = hvalue(t)->metatable;
if ((tm = fasttm(L, et, TM_SETTABLE)) == NULL) { /* no TM? */ if ((tm = fasttm(L, et, TM_SETTABLE)) == NULL) { /* no TM? */
luaH_set(L, hvalue(t), key, val); /* do a primitive set */ luaH_set(L, hvalue(t), key, val); /* do a primitive set */
return; return;