summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/ltm.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lua/ltm.c')
-rw-r--r--apps/plugins/lua/ltm.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/apps/plugins/lua/ltm.c b/apps/plugins/lua/ltm.c
index c27f0f6fab..69b4ed7727 100644
--- a/apps/plugins/lua/ltm.c
+++ b/apps/plugins/lua/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 2** $Id: ltm.c,v 2.14.1.1 2013/04/12 18:48:47 roberto Exp $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -19,20 +19,22 @@
19#include "ltm.h" 19#include "ltm.h"
20 20
21 21
22static const char udatatypename[] = "userdata";
22 23
23const char *const luaT_typenames[] = { 24LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = {
24 "nil", "boolean", "userdata", "number", 25 "no value",
25 "string", "table", "function", "userdata", "thread", 26 "nil", "boolean", udatatypename, "number",
26 "proto", "upval" 27 "string", "table", "function", udatatypename, "thread",
28 "proto", "upval" /* these last two cases are used for tests only */
27}; 29};
28 30
29 31
30void luaT_init (lua_State *L) { 32void luaT_init (lua_State *L) {
31 static const char *const luaT_eventname[] = { /* ORDER TM */ 33 static const char *const luaT_eventname[] = { /* ORDER TM */
32 "__index", "__newindex", 34 "__index", "__newindex",
33 "__gc", "__mode", "__eq", 35 "__gc", "__mode", "__len", "__eq",
34 "__add", "__sub", "__mul", "__div", "__mod", 36 "__add", "__sub", "__mul", "__div", "__mod",
35 "__pow", "__unm", "__len", "__lt", "__le", 37 "__pow", "__unm", "__lt", "__le",
36 "__concat", "__call" 38 "__concat", "__call"
37 }; 39 };
38 int i; 40 int i;
@@ -60,7 +62,7 @@ const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
60 62
61const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { 63const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
62 Table *mt; 64 Table *mt;
63 switch (ttype(o)) { 65 switch (ttypenv(o)) {
64 case LUA_TTABLE: 66 case LUA_TTABLE:
65 mt = hvalue(o)->metatable; 67 mt = hvalue(o)->metatable;
66 break; 68 break;
@@ -68,7 +70,7 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
68 mt = uvalue(o)->metatable; 70 mt = uvalue(o)->metatable;
69 break; 71 break;
70 default: 72 default:
71 mt = G(L)->mt[ttype(o)]; 73 mt = G(L)->mt[ttypenv(o)];
72 } 74 }
73 return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); 75 return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
74} 76}