[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Getting the name of a function
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 1 Feb 2002 13:26:26 -0200
>How can I do the following:
>
>lua_register( L, "aFunction", func );
>lua_register( L, "anotherFunction", func );
>lua_register( L, "aThirdFunction", func );
>
>static int func (lua_State *L)
>{
> // How do I check which function that was actually called?
>}
Push the name as an upvalue:
#define lua_registerwithname(L,name,f) \
lua_pushstring(L,name); lua_pushcclosure(L,f,1); lua_setglobal(L,name)
Then check upvalue #1 in func.
>... I also want to know how to "trap" those tags (or what they are called).
>So I can do this in Lua:
>
>func[ "aFunction" ] = 3
>func[ "anotherFunction" ] = 8
>func[ "aThirdFunction" ] = 1
You lost me here.
--lhf