lua-users home
lua-l archive

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


2011/10/18 Oskar Forsslund <matrixsmurfen@googlemail.com>:
> let me clarify. I do it like this:
> lua_cfunction func = lua_tocfunction(L, -1);
> func(L);

IMHO that's an abuse of lua_CFunction. Calling them that way you're
losing upvalues, the called function doesn't get a clean input stack,
and its output stack won't be trimmed like it would if it went through
a lua_call. To store function pointers used like that you should use
light userdata. But that's not the issue.

> that shouldn't need any lua involvement right?

No, Lua shouldn't be involved, and provided you don't use upvalues
from C and you keep the stack balanced, there shouldn't be any speed
loss.

Can you provide a full but minimal working example? I would bet that
in creating one you will find the root cause of your problem, but even
if you don't we will for sure.