** Return the name of the type of an object. For tables and userdata ** with metatable, use their '__name' metafield, if present. */
| 89 | ** with metatable, use their '__name' metafield, if present. |
| 90 | */ |
| 91 | const char *luaT_objtypename (lua_State *L, const TValue *o) { |
| 92 | Table *mt; |
| 93 | if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) || |
| 94 | (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) { |
| 95 | const TValue *name = luaH_getshortstr(mt, luaS_new(L, "__name")); |
| 96 | if (ttisstring(name)) /* is '__name' a string? */ |
| 97 | return getstr(tsvalue(name)); /* use it as type name */ |
| 98 | } |
| 99 | return ttypename(ttype(o)); /* else use standard type name */ |
| 100 | } |
| 101 | |
| 102 | |
| 103 | void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, |
no test coverage detected