[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Returning data from C functions called using "loadlib".
- From: "Kevin Baca" <lualist@...>
- Date: Mon, 30 Aug 2004 16:03:45 -0700
Multiple return values can achieve an equivalent result:
local a, b, c = 1, 2, 3
a, b, c = cfunction( a, b, c )
Alternatively, put the args in a table:
local t = { a = 1, b = 2, c = 3 }
cfunction( t )
-Kevin
> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br
> [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Rici Lake
> Sent: Monday, August 30, 2004 3:40 PM
> To: Lua list
> Subject: Re: Returning data from C functions called using "loadlib".
>
>
> If what you mean is:
>
> local a = 3
> cfunction(a)
> -- now a has magically become 5
>
> Then you can't do it, in Lua or any sensible language ;)
> (Well, we all have our biases.)
> In Lua, all arguments are passed by value.
>
> Do this:
>
> a = cfunction()
>
>
>
> On 30-Aug-04, at 5:32 PM, Aaron Newell wrote:
>
> > Ok, I have a problem.
> >
> > I am calling functions in an external library that
> > i've written in C. I initalise this library using the
> > "loadlib" function in lua.
> >
> > I call these C functions fine, and pass data to them
> > fine.
> >
> > However what i want is to send data to the C functions
> > via params to the C functions (i can do this already),
> > then the C functions to manipulate that data so that
> > the original data passed from the lua script is
> > changed.
> >
> > I am really out of ideas.
> >
> > Thanks, I hope you can help,
> > Aaron
> >
> >
> >
> >
> >
> > ___________________________________________________________ALL-NEW
> > Yahoo! Messenger - all new features - even more fun!
> > http://uk.messenger.yahoo.com
>