[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Gets function name from the stack
- From: "Nicolas ANTONIAZZI" <nicolas.antoniazzi@...>
- Date: Fri, 28 Mar 2008 02:24:46 +0100
Hi,
I'm trying to integrate LUA script engine in my program for the first time. I would like to create a "generic" way to access C code from LUA. To do this, I have a global C array that contains all informations that I need (list of function names, function pointers, function parameters type).
I have registered all those functions to a lua_Cfunction callback :
static int generic_func(lua_State *L)
{
// gets arguments count
int arg_count = lua_gettop(L);
// gets called function name
char func_name[255];
// --- TODO : --- GET THE FUNCTION NAME ?? -- MY PROBLEM IS HERE ---
// Debug
printf("args count = %d - function name = %s\n", arg_count, func_name);
return 0;
}
---------------------
Now, I would like to register exported function to this generic function.
lua_pushcfunction(L, generic_func);
lua_setglobal(L, "my_func1");
lua_pushcfunction(L, generic_func);
lua_setglobal(L, "my_func2");
lua_pushcfunction(L, generic_func);
lua_setglobal(L, "my_func3");
--------------------
Do you have an idea about how i could get the name of the function called by LUA ?
for instance, if I do : my_func2("test"); from lua,
I would like to receive : args count = 1 - function name = my_func2
I know how to get the arguments count, but I did not find a way to get the function name.
Is it possible ?
Thanks a lot,
Nicolas.