summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lua/src/ltm.c
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2016-09-03 14:34:39 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2016-09-03 14:34:39 +0200
commita6409d692ef748e6b8f7980d6bcb74a0a466d9cb (patch)
tree5895172f768b53aa78e2d0f64057a847b8da4ac5 /3rdparty/lua/src/ltm.c
parent9a8964d5d0de712465b99de1ea3ef6d8042c4ddd (diff)
Update LUA to 5.3.3 (nw)
Diffstat (limited to '3rdparty/lua/src/ltm.c')
-rw-r--r--3rdparty/lua/src/ltm.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/3rdparty/lua/src/ltm.c b/3rdparty/lua/src/ltm.c
index 22b4df39df7..4650cc29313 100644
--- a/3rdparty/lua/src/ltm.c
+++ b/3rdparty/lua/src/ltm.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 2.36 2015/11/03 15:47:30 roberto Exp $
+** $Id: ltm.c,v 2.37 2016/02/26 19:20:15 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -83,6 +83,22 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
}
+/*
+** Return the name of the type of an object. For tables and userdata
+** with metatable, use their '__name' metafield, if present.
+*/
+const char *luaT_objtypename (lua_State *L, const TValue *o) {
+ Table *mt;
+ if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) ||
+ (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) {
+ const TValue *name = luaH_getshortstr(mt, luaS_new(L, "__name"));
+ if (ttisstring(name)) /* is '__name' a string? */
+ return getstr(tsvalue(name)); /* use it as type name */
+ }
+ return ttypename(ttnov(o)); /* else use standard type name */
+}
+
+
void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
const TValue *p2, TValue *p3, int hasres) {
ptrdiff_t result = savestack(L, p3);