[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: (no subject)
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 12 Jan 2012 18:16:23 -0200
> Is there any way to find out from Lua what the registry type of a
> userdata is, short
> of giving it a `type` method?
If you used luaL_newmetatable to assign a metatable to the udata,
then you can search the registry for an entry whose value is that
metatable. The key is then the "type" you seek.
This example print "FILE*":
t=getmetatable(io.stdin)
for k,v in pairs(debug.getregistry()) do
if v==t then print(k) end
end