aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-05-16 16:53:29 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-05-16 16:53:29 -0300
commit819bd51d87b799fdee029754c660dc9a5587ef57 (patch)
tree0b1ffb9a3fd591372992c72a27e4590b48236b71 /ltm.c
parentf8d30826dda6ee8e99200de57a1997734b853db2 (diff)
downloadlua-819bd51d87b799fdee029754c660dc9a5587ef57.tar.gz
lua-819bd51d87b799fdee029754c660dc9a5587ef57.tar.bz2
lua-819bd51d87b799fdee029754c660dc9a5587ef57.zip
Some cleaning in the new table API
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ltm.c b/ltm.c
index 07a06081..fce6245c 100644
--- a/ltm.c
+++ b/ltm.c
@@ -58,7 +58,7 @@ void luaT_init (lua_State *L) {
58** tag methods 58** tag methods
59*/ 59*/
60const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { 60const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
61 const TValue *tm = luaH_getshortstr(events, ename); 61 const TValue *tm = luaH_Hgetshortstr(events, ename);
62 lua_assert(event <= TM_EQ); 62 lua_assert(event <= TM_EQ);
63 if (notm(tm)) { /* no tag method? */ 63 if (notm(tm)) { /* no tag method? */
64 events->flags |= cast_byte(1u<<event); /* cache this fact */ 64 events->flags |= cast_byte(1u<<event); /* cache this fact */
@@ -80,7 +80,7 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
80 default: 80 default:
81 mt = G(L)->mt[ttype(o)]; 81 mt = G(L)->mt[ttype(o)];
82 } 82 }
83 return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : &G(L)->nilvalue); 83 return (mt ? luaH_Hgetshortstr(mt, G(L)->tmname[event]) : &G(L)->nilvalue);
84} 84}
85 85
86 86
@@ -92,9 +92,10 @@ const char *luaT_objtypename (lua_State *L, const TValue *o) {
92 Table *mt; 92 Table *mt;
93 if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) || 93 if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) ||
94 (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) { 94 (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) {
95 const TValue *name = luaH_getshortstr(mt, luaS_new(L, "__name")); 95 TValue name;
96 if (ttisstring(name)) /* is '__name' a string? */ 96 int hres = luaH_getshortstr(mt, luaS_new(L, "__name"), &name);
97 return getstr(tsvalue(name)); /* use it as type name */ 97 if (hres == HOK && ttisstring(&name)) /* is '__name' a string? */
98 return getstr(tsvalue(&name)); /* use it as type name */
98 } 99 }
99 return ttypename(ttype(o)); /* else use standard type name */ 100 return ttypename(ttype(o)); /* else use standard type name */
100} 101}