MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaT_objtypename

Function luaT_objtypename

depends/lua/src/ltm.c:90–99  ·  view source on GitHub ↗

** Return the name of the type of an object. For tables and userdata ** with metatable, use their '__name' metafield, if present. */

Source from the content-addressed store, hash-verified

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

Callers 2

luaG_typeerrorFunction · 0.85
luaG_ordererrorFunction · 0.85

Calls 2

luaH_getshortstrFunction · 0.85
luaS_newFunction · 0.85

Tested by

no test coverage detected