[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Features you would like to see
- From: "Duncan Cross" <duncan.cross@...>
- Date: Fri, 17 Aug 2007 12:38:32 +0100
Take a look at the auxiliary library functions luaL_newmetatable and
luaL_getmetatable. First call luaL_newmetatable with the name of your
class in the initialization of your program, then luaL_getmetatable
(note its entirely separate functionality to lua_getmetatable) with
the class name whenever you need it. Internally these functions are
creating and using the registry mapping, but you shouldn't need to
understand all that to use them (though it would probably be useful
anyway).
On 8/17/07, Stephen Kellett <lua@objmedia.demon.co.uk> wrote:
> Rob Kendrick wrote:
> > Stephen Kellett wrote:
> >
> >> I'd like to see the ability to actually get a class name for a class
> >> object. Currently when you query an object for its type (from C) you
> >> just get "Table", which is not very useful. Its much more useful to
> >> know that a "Weeble" object is possibly leaking (look there are 10,000
> >> of the critters!) rather than noticing the Table count has increased
> >> by 10,000.
> >
> > Isn't the usual way of solving this problem to keep a mapping in the
> > registry between the meta-table and type name?
>
> I don't know. I'm not the most skilled Lua user going. I know a fair bit
> about Lua internals (and various other scripting languages) but I'm not
> that experienced at actually using Lua (most of my work is in C++ and
> assembly).
>
> How would I check that from C?
>
> Now that you've pointed me in direction I'll get out Roberto's book and
> have a read about Tables and the registry.
>
> Stephen
>