[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: function name
- From: "Brett Bibby" <research@...>
- Date: Fri, 5 Mar 2004 13:36:33 +0800
It does indeed work, thanks for the tip! I thought I needed to call getstack to get it initialized, but I saw the example in the manual used the function already on the stack. Anyway, does what I need and if it isn't fast enough I can always patch into the piece I want directly now that I have something working.
----- Original Message -----
From: "Brett Bibby" <firstname.lastname@example.org>
To: "Lua list" <email@example.com>
Sent: Friday, March 05, 2004 12:52 PM
Subject: Re: function name
> I'll give your suggestion a try. We need to do this because in our game all scripts are objects and when called as functions they execute as you would expect in Lua, but when they are used as parameters they always represent object ids to our engine. I need the name of the function to resolve its object id in our engine.
> ----- Original Message -----
> From: "Ashwin Hirschi" <firstname.lastname@example.org>
> To: "Lua list" <email@example.com>
> Sent: Friday, March 05, 2004 11:38 AM
> Subject: Re: function name
> > > Thanks for your note.
> > You're welcome.
> > > I read the debug stuff before posting but assumed it wasn't meant for runtime use.
> > Well, I guess it depends on what makes something suitable for runtime use. But I have been using the debug interface for an integrated light-weight profiler and can testify it works quite well. Obviously, there is some overhead. You should probably run some tests to see if it suits your situation.
> > From your example I understand you need to resolve the names of functions passed as arguments [and not functions in the *call stack*]. I may be stating the obvious, but I believe lua_getinfo should work here as well (though I've never used it for this particular purpose). You'll need push the function (using lua_pushvalue, for instance) and prepend a ">" to the 'what' argument before calling lua_getinfo.
> > Keep in mind an arbitrary Lua function may not have a name. An example would be a closure created a runtime. If you have a specific (managed) set of functions that you need to recognise, you might try to build an index table to perform quick function-to-name lookup. I suspect that'll be quicker than using lua_getinfo.
> > I'm curious: what type of situation would require you to actually retrieve the names of functions so often?
> > Ashwin.
> > --
> > no signature is a signature