lua-users home
lua-l archive

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


No need to reset the stack.

While it's always good to restrict stack growth, lua does clean up the
stack after function calls.

The return value 4 tells lua to take the 4 top-most stack values as the
return values of the function, no matter how large the stack has grown.

Not sure about the context surrounding lua_tonumber(this, 1).

What is "this"?  Where is the call made?

-Kevin


> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br 
> [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of 
> mark greenlancer
> Sent: Wednesday, August 11, 2004 12:51 PM
> To: Lua list
> Subject: c args to lus?
> 
> 
> hello,
> 
> I know how to "transfer" arguments from lua  to a c function
> with the stack. But how to transfer  args. from a called fn to lua?
> 
> If I reset the stack and put 4 numbers on the stack and return
> 4, lua throws an error when I call lua_tonumber(this, 1) and ff
> 
> How to do this?
> 
> I've tried it in this way.
> 
> lua_settop(l, 0);
> lua_pushnumber(l, c_val+1);
> lua_pushnumber(l, c_val+2);
> lua_pushnumber(l, c_val+3);
> lua_pushnumber(l, c_val+4);
> return 4;
> 
> 
> mark
>