[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: (no subject)
- From: Benoit Germain <bnt.germain@...>
- Date: Fri, 13 Jan 2012 11:57:29 +0100
2012/1/12 Dirk Laurie
<dirk.laurie@gmail.com>
The reference manual says:
void *luaL_checkudata (lua_State *L, int narg, const char *tname);
Checks whether the function argument narg is a userdata of the
type tname ...
Is there any way to find out from Lua what the registry type of a
userdata is, short
of giving it a `type` method?
I often use the __metatable field of the metatable for this. A side effect of the protection it offers is that it can store a type too. I set it to some string that I'll get when calling getmetatable(o). Of course this works only for the metatables I populated that way.
--
Benoit.