diff options
-rw-r--r-- | lapi.c | 32 | ||||
-rw-r--r-- | lbaselib.c | 11 | ||||
-rw-r--r-- | lgc.c | 33 | ||||
-rw-r--r-- | liolib.c | 12 | ||||
-rw-r--r-- | lobject.h | 4 | ||||
-rw-r--r-- | lstate.c | 10 | ||||
-rw-r--r-- | lstate.h | 4 | ||||
-rw-r--r-- | lstring.c | 2 | ||||
-rw-r--r-- | ltable.c | 2 | ||||
-rw-r--r-- | ltests.c | 16 | ||||
-rw-r--r-- | ltm.c | 4 | ||||
-rw-r--r-- | lua.h | 4 | ||||
-rw-r--r-- | lvm.c | 4 |
13 files changed, 69 insertions, 69 deletions
@@ -402,25 +402,25 @@ LUA_API void lua_newtable (lua_State *L) { | |||
402 | } | 402 | } |
403 | 403 | ||
404 | 404 | ||
405 | LUA_API void lua_geteventtable (lua_State *L, int objindex) { | 405 | LUA_API void lua_getmetatable (lua_State *L, int objindex) { |
406 | StkId obj; | 406 | StkId obj; |
407 | Table *et; | 407 | Table *mt; |
408 | lua_lock(L); | 408 | lua_lock(L); |
409 | obj = luaA_indexAcceptable(L, objindex); | 409 | obj = luaA_indexAcceptable(L, objindex); |
410 | switch (ttype(obj)) { | 410 | switch (ttype(obj)) { |
411 | case LUA_TTABLE: | 411 | case LUA_TTABLE: |
412 | et = hvalue(obj)->eventtable; | 412 | mt = hvalue(obj)->metatable; |
413 | break; | 413 | break; |
414 | case LUA_TUSERDATA: | 414 | case LUA_TUSERDATA: |
415 | et = uvalue(obj)->uv.eventtable; | 415 | mt = uvalue(obj)->uv.metatable; |
416 | break; | 416 | break; |
417 | default: | 417 | default: |
418 | et = hvalue(defaultet(L)); | 418 | mt = hvalue(defaultmeta(L)); |
419 | } | 419 | } |
420 | if (et == hvalue(defaultet(L))) | 420 | if (mt == hvalue(defaultmeta(L))) |
421 | setnilvalue(L->top); | 421 | setnilvalue(L->top); |
422 | else | 422 | else |
423 | sethvalue(L->top, et); | 423 | sethvalue(L->top, mt); |
424 | api_incr_top(L); | 424 | api_incr_top(L); |
425 | lua_unlock(L); | 425 | lua_unlock(L); |
426 | } | 426 | } |
@@ -488,24 +488,24 @@ LUA_API void lua_setglobals (lua_State *L) { | |||
488 | } | 488 | } |
489 | 489 | ||
490 | 490 | ||
491 | LUA_API void lua_seteventtable (lua_State *L, int objindex) { | 491 | LUA_API void lua_setmetatable (lua_State *L, int objindex) { |
492 | StkId obj, et; | 492 | StkId obj, mt; |
493 | lua_lock(L); | 493 | lua_lock(L); |
494 | api_checknelems(L, 1); | 494 | api_checknelems(L, 1); |
495 | obj = luaA_indexAcceptable(L, objindex); | 495 | obj = luaA_indexAcceptable(L, objindex); |
496 | et = --L->top; | 496 | mt = --L->top; |
497 | if (ttype(et) == LUA_TNIL) | 497 | if (ttype(mt) == LUA_TNIL) |
498 | et = defaultet(L); | 498 | mt = defaultmeta(L); |
499 | api_check(L, ttype(et) == LUA_TTABLE); | 499 | api_check(L, ttype(mt) == LUA_TTABLE); |
500 | switch (ttype(obj)) { | 500 | switch (ttype(obj)) { |
501 | case LUA_TTABLE: | 501 | case LUA_TTABLE: |
502 | hvalue(obj)->eventtable = hvalue(et); | 502 | hvalue(obj)->metatable = hvalue(mt); |
503 | break; | 503 | break; |
504 | case LUA_TUSERDATA: | 504 | case LUA_TUSERDATA: |
505 | uvalue(obj)->uv.eventtable = hvalue(et); | 505 | uvalue(obj)->uv.metatable = hvalue(mt); |
506 | break; | 506 | break; |
507 | default: | 507 | default: |
508 | luaO_verror(L, "cannot change the event table of a %.20s", | 508 | luaO_verror(L, "cannot change the meta table of a %.20s", |
509 | luaT_typenames[ttype(obj)]); | 509 | luaT_typenames[ttype(obj)]); |
510 | } | 510 | } |
511 | lua_unlock(L); | 511 | lua_unlock(L); |
@@ -135,15 +135,15 @@ static int luaB_getglobal (lua_State *L) { | |||
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | static int luaB_eventtable (lua_State *L) { | 138 | static int luaB_metatable (lua_State *L) { |
139 | luaL_check_type(L, 1, LUA_TTABLE); | 139 | luaL_check_type(L, 1, LUA_TTABLE); |
140 | if (lua_isnone(L, 2)) | 140 | if (lua_isnone(L, 2)) |
141 | lua_geteventtable(L, 1); | 141 | lua_getmetatable(L, 1); |
142 | else { | 142 | else { |
143 | int t = lua_type(L, 2); | 143 | int t = lua_type(L, 2); |
144 | luaL_arg_check(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil/table expected"); | 144 | luaL_arg_check(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil/table expected"); |
145 | lua_settop(L, 2); | 145 | lua_settop(L, 2); |
146 | lua_seteventtable(L, 1); | 146 | lua_setmetatable(L, 1); |
147 | } | 147 | } |
148 | return 1; | 148 | return 1; |
149 | } | 149 | } |
@@ -447,7 +447,7 @@ static int luaB_coroutine (lua_State *L) { | |||
447 | lua_cobegin(NL, n-1); | 447 | lua_cobegin(NL, n-1); |
448 | lua_newuserdatabox(L, NL); | 448 | lua_newuserdatabox(L, NL); |
449 | lua_getstr(L, LUA_REGISTRYINDEX, "Coroutine"); | 449 | lua_getstr(L, LUA_REGISTRYINDEX, "Coroutine"); |
450 | lua_seteventtable(L, -2); | 450 | lua_setmetatable(L, -2); |
451 | lua_pushcclosure(L, luaB_resume, 1); | 451 | lua_pushcclosure(L, luaB_resume, 1); |
452 | return 1; | 452 | return 1; |
453 | } | 453 | } |
@@ -517,6 +517,7 @@ static int luaB_tinsert (lua_State *L) { | |||
517 | v = 3; /* function may be called with more than 3 args */ | 517 | v = 3; /* function may be called with more than 3 args */ |
518 | pos = luaL_check_int(L, 2); /* 2nd argument is the position */ | 518 | pos = luaL_check_int(L, 2); /* 2nd argument is the position */ |
519 | } | 519 | } |
520 | if (pos > n+1) n = pos-1; | ||
520 | aux_setn(L, 1, n+1); /* t.n = n+1 */ | 521 | aux_setn(L, 1, n+1); /* t.n = n+1 */ |
521 | for (; n>=pos; n--) { | 522 | for (; n>=pos; n--) { |
522 | lua_rawgeti(L, 1, n); | 523 | lua_rawgeti(L, 1, n); |
@@ -665,7 +666,7 @@ static const luaL_reg base_funcs[] = { | |||
665 | {"dofile", luaB_dofile}, | 666 | {"dofile", luaB_dofile}, |
666 | {"dostring", luaB_dostring}, | 667 | {"dostring", luaB_dostring}, |
667 | {"error", luaB_error}, | 668 | {"error", luaB_error}, |
668 | {"eventtable", luaB_eventtable}, | 669 | {"metatable", luaB_metatable}, |
669 | {"foreach", luaB_foreach}, | 670 | {"foreach", luaB_foreach}, |
670 | {"foreachi", luaB_foreachi}, | 671 | {"foreachi", luaB_foreachi}, |
671 | {"gcinfo", luaB_gcinfo}, | 672 | {"gcinfo", luaB_gcinfo}, |
@@ -122,13 +122,12 @@ static void markobject (GCState *st, TObject *o) { | |||
122 | } | 122 | } |
123 | 123 | ||
124 | 124 | ||
125 | static void checkstacksizes (lua_State *L, StkId lim) { | 125 | static void checkstacksizes (lua_State *L) { |
126 | int used = L->ci - L->base_ci; /* number of `ci' in use */ | 126 | int used = L->ci - L->base_ci; /* number of `ci' in use */ |
127 | if (4*used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) | 127 | if (4*used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) |
128 | luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ | 128 | luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ |
129 | if (lim < L->top) lim = L->top; | 129 | used = L->top - L->stack; /* part of stack in use */ |
130 | used = lim - L->stack; /* part of stack in use */ | 130 | if (2*(used+MAXSTACK) < L->stacksize && 2*BASIC_STACK_SIZE < L->stacksize) |
131 | if (3*used < L->stacksize && 2*BASIC_STACK_SIZE < L->stacksize) | ||
132 | luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ | 131 | luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ |
133 | } | 132 | } |
134 | 133 | ||
@@ -148,7 +147,7 @@ static void markstacks (GCState *st) { | |||
148 | lim = (L1->stack_last - L1->ci->base > MAXSTACK) ? L1->ci->base+MAXSTACK | 147 | lim = (L1->stack_last - L1->ci->base > MAXSTACK) ? L1->ci->base+MAXSTACK |
149 | : L1->stack_last; | 148 | : L1->stack_last; |
150 | for (; o<=lim; o++) setnilvalue(o); | 149 | for (; o<=lim; o++) setnilvalue(o); |
151 | checkstacksizes(L1, lim); | 150 | checkstacksizes(L1); |
152 | lua_assert(L1->previous->next == L1 && L1->next->previous == L1); | 151 | lua_assert(L1->previous->next == L1 && L1->next->previous == L1); |
153 | L1 = L1->next; | 152 | L1 = L1->next; |
154 | } while (L1 != st->L); | 153 | } while (L1 != st->L); |
@@ -158,9 +157,9 @@ static void markstacks (GCState *st) { | |||
158 | static void markudet (GCState *st) { | 157 | static void markudet (GCState *st) { |
159 | Udata *u; | 158 | Udata *u; |
160 | for (u = G(st->L)->rootudata; u; u = u->uv.next) | 159 | for (u = G(st->L)->rootudata; u; u = u->uv.next) |
161 | marktable(st, u->uv.eventtable); | 160 | marktable(st, u->uv.metatable); |
162 | for (u = G(st->L)->tmudata; u; u = u->uv.next) | 161 | for (u = G(st->L)->tmudata; u; u = u->uv.next) |
163 | marktable(st, u->uv.eventtable); | 162 | marktable(st, u->uv.metatable); |
164 | } | 163 | } |
165 | 164 | ||
166 | 165 | ||
@@ -176,8 +175,8 @@ static void traversetable (GCState *st, Table *h) { | |||
176 | const TObject *mode; | 175 | const TObject *mode; |
177 | int weakkey = 0; | 176 | int weakkey = 0; |
178 | int weakvalue = 0; | 177 | int weakvalue = 0; |
179 | marktable(st, h->eventtable); | 178 | marktable(st, h->metatable); |
180 | mode = fasttm(st->L, h->eventtable, TM_WEAKMODE); | 179 | mode = fasttm(st->L, h->metatable, TM_WEAKMODE); |
181 | if (mode) { /* weak table? must be cleared after GC... */ | 180 | if (mode) { /* weak table? must be cleared after GC... */ |
182 | h->mark = st->toclear; /* put in the appropriate list */ | 181 | h->mark = st->toclear; /* put in the appropriate list */ |
183 | st->toclear = h; | 182 | st->toclear = h; |
@@ -204,10 +203,10 @@ static void traversetable (GCState *st, Table *h) { | |||
204 | 203 | ||
205 | 204 | ||
206 | static void markall (GCState *st) { | 205 | static void markall (GCState *st) { |
207 | lua_assert(hvalue(defaultet(st->L))->flags == cast(unsigned short, ~0)); | 206 | lua_assert(hvalue(defaultmeta(st->L))->flags == cast(unsigned short, ~0)); |
208 | /* table is unchanged */ | 207 | /* table is unchanged */ |
209 | markstacks(st); /* mark all stacks */ | 208 | markstacks(st); /* mark all stacks */ |
210 | markudet(st); /* mark userdata's event tables */ | 209 | markudet(st); /* mark userdata's meta tables */ |
211 | while (st->tmark) { /* traverse marked tables */ | 210 | while (st->tmark) { /* traverse marked tables */ |
212 | Table *h = st->tmark; /* get first table from list */ | 211 | Table *h = st->tmark; /* get first table from list */ |
213 | st->tmark = h->mark; /* remove it from list */ | 212 | st->tmark = h->mark; /* remove it from list */ |
@@ -333,7 +332,7 @@ static void collectudata (lua_State *L) { | |||
333 | } | 332 | } |
334 | else { | 333 | else { |
335 | *p = curr->uv.next; | 334 | *p = curr->uv.next; |
336 | if (fasttm(L, curr->uv.eventtable, TM_GC) != NULL) { /* gc event? */ | 335 | if (fasttm(L, curr->uv.metatable, TM_GC) != NULL) { /* gc event? */ |
337 | curr->uv.next = NULL; /* link `curr' at the end of `collected' list */ | 336 | curr->uv.next = NULL; /* link `curr' at the end of `collected' list */ |
338 | *lastcollected = curr; | 337 | *lastcollected = curr; |
339 | lastcollected = &curr->uv.next; | 338 | lastcollected = &curr->uv.next; |
@@ -384,7 +383,7 @@ static void checkMbuffer (lua_State *L) { | |||
384 | 383 | ||
385 | 384 | ||
386 | static void do1gcTM (lua_State *L, Udata *udata) { | 385 | static void do1gcTM (lua_State *L, Udata *udata) { |
387 | const TObject *tm = fasttm(L, udata->uv.eventtable, TM_GC); | 386 | const TObject *tm = fasttm(L, udata->uv.metatable, TM_GC); |
388 | if (tm != NULL) { | 387 | if (tm != NULL) { |
389 | setobj(L->top, tm); | 388 | setobj(L->top, tm); |
390 | setuvalue(L->top+1, udata); | 389 | setuvalue(L->top+1, udata); |
@@ -405,8 +404,8 @@ static void unprotectedcallGCTM (lua_State *L, void *pu) { | |||
405 | udata->uv.next = G(L)->rootudata; /* resurect it */ | 404 | udata->uv.next = G(L)->rootudata; /* resurect it */ |
406 | G(L)->rootudata = udata; | 405 | G(L)->rootudata = udata; |
407 | do1gcTM(L, udata); | 406 | do1gcTM(L, udata); |
408 | /* mark udata as finalized (default event table) */ | 407 | /* mark udata as finalized (default meta table) */ |
409 | uvalue(L->top-1)->uv.eventtable = hvalue(defaultet(L)); | 408 | uvalue(L->top-1)->uv.metatable = hvalue(defaultmeta(L)); |
410 | unmarkud(uvalue(L->top-1)); | 409 | unmarkud(uvalue(L->top-1)); |
411 | } | 410 | } |
412 | L->top--; | 411 | L->top--; |
@@ -420,8 +419,8 @@ static void callGCTM (lua_State *L) { | |||
420 | Udata *udata; | 419 | Udata *udata; |
421 | if (luaD_runprotected(L, unprotectedcallGCTM, &udata) != 0) { | 420 | if (luaD_runprotected(L, unprotectedcallGCTM, &udata) != 0) { |
422 | /* `udata' generated an error during its gc */ | 421 | /* `udata' generated an error during its gc */ |
423 | /* mark it as finalized (default event table) */ | 422 | /* mark it as finalized (default meta table) */ |
424 | udata->uv.eventtable = hvalue(defaultet(L)); | 423 | udata->uv.metatable = hvalue(defaultmeta(L)); |
425 | } | 424 | } |
426 | } | 425 | } |
427 | L->allowhooks = oldah; /* restore hooks */ | 426 | L->allowhooks = oldah; /* restore hooks */ |
@@ -72,7 +72,7 @@ static int pushresult (lua_State *L, int i) { | |||
72 | 72 | ||
73 | static int checkfile (lua_State *L, int findex, const char *tname) { | 73 | static int checkfile (lua_State *L, int findex, const char *tname) { |
74 | int res; | 74 | int res; |
75 | lua_geteventtable(L, findex); | 75 | lua_getmetatable(L, findex); |
76 | lua_getstr(L, LUA_REGISTRYINDEX, tname); | 76 | lua_getstr(L, LUA_REGISTRYINDEX, tname); |
77 | res = lua_equal(L, -1, -2); | 77 | res = lua_equal(L, -1, -2); |
78 | lua_pop(L, 2); | 78 | lua_pop(L, 2); |
@@ -112,7 +112,7 @@ static FILE *getopthandle (lua_State *L, int inout) { | |||
112 | static void newfile (lua_State *L, FILE *f) { | 112 | static void newfile (lua_State *L, FILE *f) { |
113 | lua_newuserdatabox(L, f); | 113 | lua_newuserdatabox(L, f); |
114 | lua_getstr(L, LUA_REGISTRYINDEX, FILEHANDLE); | 114 | lua_getstr(L, LUA_REGISTRYINDEX, FILEHANDLE); |
115 | lua_seteventtable(L, -2); | 115 | lua_setmetatable(L, -2); |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
@@ -148,7 +148,7 @@ static int io_close (lua_State *L) { | |||
148 | if (f != stdin && f != stdout && f != stderr) { | 148 | if (f != stdin && f != stdout && f != stderr) { |
149 | lua_settop(L, 1); /* make sure file is on top */ | 149 | lua_settop(L, 1); /* make sure file is on top */ |
150 | lua_getstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE); | 150 | lua_getstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE); |
151 | lua_seteventtable(L, 1); | 151 | lua_setmetatable(L, 1); |
152 | status = (CLOSEFILE(L, f) == 0); | 152 | status = (CLOSEFILE(L, f) == 0); |
153 | } | 153 | } |
154 | return pushresult(L, status); | 154 | return pushresult(L, status); |
@@ -693,13 +693,13 @@ static const luaL_reg iolib[] = { | |||
693 | 693 | ||
694 | 694 | ||
695 | LUALIB_API int lua_iolibopen (lua_State *L) { | 695 | LUALIB_API int lua_iolibopen (lua_State *L) { |
696 | lua_newtable(L); /* event table for FILEHANDLE */ | 696 | lua_newtable(L); /* meta table for FILEHANDLE */ |
697 | /* close files when collected */ | 697 | /* close files when collected */ |
698 | lua_pushcfunction(L, file_collect); | 698 | lua_pushcfunction(L, file_collect); |
699 | lua_setstr(L, -2, "gc"); | 699 | lua_setstr(L, -2, "gc"); |
700 | /* put new eventtable into registry */ | 700 | /* put new metatable into registry */ |
701 | lua_setstr(L, LUA_REGISTRYINDEX, FILEHANDLE); | 701 | lua_setstr(L, LUA_REGISTRYINDEX, FILEHANDLE); |
702 | /* event table for CLOSEDFILEHANDLE */ | 702 | /* meta table for CLOSEDFILEHANDLE */ |
703 | lua_newtable(L); | 703 | lua_newtable(L); |
704 | lua_setstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE); | 704 | lua_setstr(L, LUA_REGISTRYINDEX, CLOSEDFILEHANDLE); |
705 | luaL_openl(L, iolib); | 705 | luaL_openl(L, iolib); |
@@ -120,7 +120,7 @@ typedef union TString { | |||
120 | typedef union Udata { | 120 | typedef union Udata { |
121 | union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ | 121 | union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ |
122 | struct { | 122 | struct { |
123 | struct Table *eventtable; | 123 | struct Table *metatable; |
124 | void *value; | 124 | void *value; |
125 | size_t len; /* least bit reserved for gc mark */ | 125 | size_t len; /* least bit reserved for gc mark */ |
126 | union Udata *next; /* chain for list of all udata */ | 126 | union Udata *next; /* chain for list of all udata */ |
@@ -221,7 +221,7 @@ typedef struct Node { | |||
221 | 221 | ||
222 | 222 | ||
223 | typedef struct Table { | 223 | typedef struct Table { |
224 | struct Table *eventtable; | 224 | struct Table *metatable; |
225 | TObject *array; /* array part */ | 225 | TObject *array; /* array part */ |
226 | Node *node; | 226 | Node *node; |
227 | int sizearray; /* size of `array' array */ | 227 | int sizearray; /* size of `array' array */ |
@@ -69,10 +69,10 @@ static void f_luaopen (lua_State *L, void *ud) { | |||
69 | G(L)->tmudata = NULL; | 69 | G(L)->tmudata = NULL; |
70 | G(L)->nblocks = sizeof(lua_State) + sizeof(global_State); | 70 | G(L)->nblocks = sizeof(lua_State) + sizeof(global_State); |
71 | stack_init(L, L, so->stacksize); /* init stack */ | 71 | stack_init(L, L, so->stacksize); /* init stack */ |
72 | /* create default event table with a dummy table, and then close the loop */ | 72 | /* create default meta table with a dummy table, and then close the loop */ |
73 | sethvalue(defaultet(L), NULL); | 73 | sethvalue(defaultmeta(L), NULL); |
74 | sethvalue(defaultet(L), luaH_new(L, 0, 4)); | 74 | sethvalue(defaultmeta(L), luaH_new(L, 0, 4)); |
75 | hvalue(defaultet(L))->eventtable = hvalue(defaultet(L)); | 75 | hvalue(defaultmeta(L))->metatable = hvalue(defaultmeta(L)); |
76 | sethvalue(gt(L), luaH_new(L, 0, 4)); /* table of globals */ | 76 | sethvalue(gt(L), luaH_new(L, 0, 4)); /* table of globals */ |
77 | sethvalue(registry(L), luaH_new(L, 0, 0)); /* registry */ | 77 | sethvalue(registry(L), luaH_new(L, 0, 0)); /* registry */ |
78 | luaS_resize(L, 4); /* initial size of string table */ | 78 | luaS_resize(L, 4); /* initial size of string table */ |
@@ -107,7 +107,7 @@ LUA_API lua_State *lua_newthread (lua_State *OL, int stacksize) { | |||
107 | OL->next = L; | 107 | OL->next = L; |
108 | L->previous = OL; | 108 | L->previous = OL; |
109 | stack_init(L, OL, stacksize); /* init stack */ | 109 | stack_init(L, OL, stacksize); /* init stack */ |
110 | setobj(defaultet(L), defaultet(OL)); /* share default event table */ | 110 | setobj(defaultmeta(L), defaultmeta(OL)); /* share default meta table */ |
111 | setobj(gt(L), gt(OL)); /* share table of globals */ | 111 | setobj(gt(L), gt(OL)); /* share table of globals */ |
112 | setobj(registry(L), registry(OL)); /* share registry */ | 112 | setobj(registry(L), registry(OL)); /* share registry */ |
113 | lua_unlock(OL); | 113 | lua_unlock(OL); |
@@ -53,8 +53,8 @@ struct lua_longjmp; /* defined in ldo.c */ | |||
53 | ** reserve init of stack to store some global values | 53 | ** reserve init of stack to store some global values |
54 | */ | 54 | */ |
55 | 55 | ||
56 | /* default event table (both for tables and udata) */ | 56 | /* default meta table (both for tables and udata) */ |
57 | #define defaultet(L) (L->stack) | 57 | #define defaultmeta(L) (L->stack) |
58 | 58 | ||
59 | /* table of globals */ | 59 | /* table of globals */ |
60 | #define gt(L) (L->stack + 1) | 60 | #define gt(L) (L->stack + 1) |
@@ -88,7 +88,7 @@ Udata *luaS_newudata (lua_State *L, size_t s) { | |||
88 | if (s & 1) s++; /* make sure size is even */ | 88 | if (s & 1) s++; /* make sure size is even */ |
89 | u = cast(Udata *, luaM_malloc(L, sizeudata(s))); | 89 | u = cast(Udata *, luaM_malloc(L, sizeudata(s))); |
90 | u->uv.len = s; | 90 | u->uv.len = s; |
91 | u->uv.eventtable = hvalue(defaultet(L)); | 91 | u->uv.metatable = hvalue(defaultmeta(L)); |
92 | u->uv.value = u + 1; | 92 | u->uv.value = u + 1; |
93 | /* chain it on udata list */ | 93 | /* chain it on udata list */ |
94 | u->uv.next = G(L)->rootudata; | 94 | u->uv.next = G(L)->rootudata; |
@@ -273,7 +273,7 @@ static void rehash (lua_State *L, Table *t) { | |||
273 | 273 | ||
274 | Table *luaH_new (lua_State *L, int narray, int lnhash) { | 274 | Table *luaH_new (lua_State *L, int narray, int lnhash) { |
275 | Table *t = luaM_new(L, Table); | 275 | Table *t = luaM_new(L, Table); |
276 | t->eventtable = hvalue(defaultet(L)); | 276 | t->metatable = hvalue(defaultmeta(L)); |
277 | t->next = G(L)->roottable; | 277 | t->next = G(L)->roottable; |
278 | G(L)->roottable = t; | 278 | G(L)->roottable = t; |
279 | t->mark = t; | 279 | t->mark = t; |
@@ -344,14 +344,14 @@ static int unref (lua_State *L) { | |||
344 | return 0; | 344 | return 0; |
345 | } | 345 | } |
346 | 346 | ||
347 | static int eventtable (lua_State *L) { | 347 | static int metatable (lua_State *L) { |
348 | luaL_check_any(L, 1); | 348 | luaL_check_any(L, 1); |
349 | if (lua_isnone(L, 2)) | 349 | if (lua_isnone(L, 2)) |
350 | lua_geteventtable(L, 1); | 350 | lua_getmetatable(L, 1); |
351 | else { | 351 | else { |
352 | lua_settop(L, 2); | 352 | lua_settop(L, 2); |
353 | luaL_check_type(L, 2, LUA_TTABLE); | 353 | luaL_check_type(L, 2, LUA_TTABLE); |
354 | lua_seteventtable(L, 1); | 354 | lua_setmetatable(L, 1); |
355 | } | 355 | } |
356 | return 1; | 356 | return 1; |
357 | } | 357 | } |
@@ -608,11 +608,11 @@ static int testC (lua_State *L) { | |||
608 | else if EQ("dostring") { | 608 | else if EQ("dostring") { |
609 | lua_dostring(L, luaL_check_string(L, getnum)); | 609 | lua_dostring(L, luaL_check_string(L, getnum)); |
610 | } | 610 | } |
611 | else if EQ("seteventtable") { | 611 | else if EQ("setmetatable") { |
612 | lua_seteventtable(L, getnum); | 612 | lua_setmetatable(L, getnum); |
613 | } | 613 | } |
614 | else if EQ("geteventtable") { | 614 | else if EQ("getmetatable") { |
615 | lua_geteventtable(L, getnum); | 615 | lua_getmetatable(L, getnum); |
616 | } | 616 | } |
617 | else if EQ("type") { | 617 | else if EQ("type") { |
618 | lua_pushstring(L, lua_typename(L, lua_type(L, getnum))); | 618 | lua_pushstring(L, lua_typename(L, lua_type(L, getnum))); |
@@ -642,7 +642,7 @@ static const struct luaL_reg tests_funcs[] = { | |||
642 | {"unref", unref}, | 642 | {"unref", unref}, |
643 | {"d2s", d2s}, | 643 | {"d2s", d2s}, |
644 | {"s2d", s2d}, | 644 | {"s2d", s2d}, |
645 | {"eventtable", eventtable}, | 645 | {"metatable", metatable}, |
646 | {"newuserdata", newuserdata}, | 646 | {"newuserdata", newuserdata}, |
647 | {"newuserdatabox", newuserdatabox}, | 647 | {"newuserdatabox", newuserdatabox}, |
648 | {"udataval", udataval}, | 648 | {"udataval", udataval}, |
@@ -57,9 +57,9 @@ const TObject *luaT_gettmbyobj (lua_State *L, const TObject *o, TMS event) { | |||
57 | TString *ename = G(L)->tmname[event]; | 57 | TString *ename = G(L)->tmname[event]; |
58 | switch (ttype(o)) { | 58 | switch (ttype(o)) { |
59 | case LUA_TTABLE: | 59 | case LUA_TTABLE: |
60 | return luaH_getstr(hvalue(o)->eventtable, ename); | 60 | return luaH_getstr(hvalue(o)->metatable, ename); |
61 | case LUA_TUSERDATA: | 61 | case LUA_TUSERDATA: |
62 | return luaH_getstr(uvalue(o)->uv.eventtable, ename); | 62 | return luaH_getstr(uvalue(o)->uv.metatable, ename); |
63 | default: | 63 | default: |
64 | return &luaO_nilobject; | 64 | return &luaO_nilobject; |
65 | } | 65 | } |
@@ -153,7 +153,7 @@ LUA_API void lua_gettable (lua_State *L, int index); | |||
153 | LUA_API void lua_rawget (lua_State *L, int index); | 153 | LUA_API void lua_rawget (lua_State *L, int index); |
154 | LUA_API void lua_rawgeti (lua_State *L, int index, int n); | 154 | LUA_API void lua_rawgeti (lua_State *L, int index, int n); |
155 | LUA_API void lua_newtable (lua_State *L); | 155 | LUA_API void lua_newtable (lua_State *L); |
156 | LUA_API void lua_geteventtable (lua_State *L, int objindex); | 156 | LUA_API void lua_getmetatable (lua_State *L, int objindex); |
157 | 157 | ||
158 | 158 | ||
159 | /* | 159 | /* |
@@ -164,7 +164,7 @@ LUA_API void lua_settable (lua_State *L, int index); | |||
164 | LUA_API void lua_rawset (lua_State *L, int index); | 164 | LUA_API void lua_rawset (lua_State *L, int index); |
165 | LUA_API void lua_rawseti (lua_State *L, int index, int n); | 165 | LUA_API void lua_rawseti (lua_State *L, int index, int n); |
166 | LUA_API void lua_setglobals (lua_State *L); | 166 | LUA_API void lua_setglobals (lua_State *L); |
167 | LUA_API void lua_seteventtable (lua_State *L, int objindex); | 167 | LUA_API void lua_setmetatable (lua_State *L, int objindex); |
168 | 168 | ||
169 | 169 | ||
170 | /* | 170 | /* |
@@ -125,7 +125,7 @@ void luaV_gettable (lua_State *L, StkId t, TObject *key, StkId res) { | |||
125 | const TObject *tm; | 125 | const TObject *tm; |
126 | init: | 126 | init: |
127 | if (ttype(t) == LUA_TTABLE) { /* `t' is a table? */ | 127 | if (ttype(t) == LUA_TTABLE) { /* `t' is a table? */ |
128 | Table *et = hvalue(t)->eventtable; | 128 | Table *et = hvalue(t)->metatable; |
129 | if ((tm = fasttm(L, et, TM_GETTABLE)) == NULL) { /* no gettable TM? */ | 129 | if ((tm = fasttm(L, et, TM_GETTABLE)) == NULL) { /* no gettable TM? */ |
130 | const TObject *h = luaH_get(hvalue(t), key); /* do a primitive get */ | 130 | const TObject *h = luaH_get(hvalue(t), key); /* do a primitive get */ |
131 | /* result is no nil or there is no `index' tag method? */ | 131 | /* 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) { | |||
158 | const TObject *tm; | 158 | const TObject *tm; |
159 | init: | 159 | init: |
160 | if (ttype(t) == LUA_TTABLE) { /* `t' is a table? */ | 160 | if (ttype(t) == LUA_TTABLE) { /* `t' is a table? */ |
161 | Table *et = hvalue(t)->eventtable; | 161 | Table *et = hvalue(t)->metatable; |
162 | if ((tm = fasttm(L, et, TM_SETTABLE)) == NULL) { /* no TM? */ | 162 | if ((tm = fasttm(L, et, TM_SETTABLE)) == NULL) { /* no TM? */ |
163 | luaH_set(L, hvalue(t), key, val); /* do a primitive set */ | 163 | luaH_set(L, hvalue(t), key, val); /* do a primitive set */ |
164 | return; | 164 | return; |