Finding a way to wrap a function call from C to LUA
Hello,
Has anybody found a way to wrap this?. I mean, you first have to do a lot of push_TYPE things and then call lua_call, and I would like to create a wrapper for example CallLuaFunction(fucntion name, ...), but this do not works because you have to call push for every type. Any Help?
Thanks in advance,
HexDump.
I have no idea how lua works but something like this maybe
void lua_push(lua_stack* stack, int i) { stack->pushint(i); }void lua_push(lua_stack* stack, float f) { stack->pushfloat(f); }int lua_function0(function name){ lua_call(name);}template <typename type1>int lua_function1(function name, lua_stack* stack, type1 arg1){ lua_push(stack, arg1); lua_call(name);}template <typename type1, typename type2>int lua_function2(function name, lua_stack* stack, type1 arg1, type2 arg2){ lua_push(stack, arg1); lua_push(stack, arg2); lua_call(name);}
There is a section on this in the Lua Reference Manual. Section 3.14 deals with calling Lua functions from C, and includes an example.
Fulby
Fulby
I know how to call a Lua func from C. This is not my question. What I wanted is a way to do this calls in a generic way from my wrapper. Anyway I found it. Thanks a lot for the answers.
Thanks in advance,
HexDump.
Thanks in advance,
HexDump.
The basic idea is to combine printf and scanf : A Generic Call Function
And while you're at it, read the rest of the book, it's very good.
And while you're at it, read the rest of the book, it's very good.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement