lua-users home
lua-l archive

Re: getting the functionC name?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Mar 12, 2009 at 2:28 PM, Guilherme <cox@mamute.org> wrote:
> Is there possible to get the function name (lua object) in the
> functionC scope when a Lua call is invoked to a Cfunction?
Use code closer to the following:
lua_pushliteral( _sLua, "test1"); // or any other, more useful push
lua_pushcclosure( _sLUA, luaCFunc, 1 );
lua_setglobal( _sLUA, "test1" );
lua_pushliteral( _sLua, "test2"); // or any other, more useful push
lua_pushcclosure( _sLUA, luaCFunc, 1 );
lua_setglobal( _sLUA, "test2" );
And then if you then call lua_tostring( _sLua, lua_upvalueindex(1) )
from the function, you'll get "test1" or "test2".

AltStyle によって変換されたページ (->オリジナル) /