[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Returning arrays via tolua-4.0a
- From: Waldemar Celes <celes@...>
- Date: Mon, 05 Feb 2001 13:30:31 -0200
> Given a C function that returns a pointer to an array
> of values, what sort of trickery is needed to get at
> the elements of that array from within lua?
> A simple example function recieves a single integer
> argument and returns a pointer to an array and a pointer
> to the length of the array:
> int get_float_array( int arg,
> float** ret_array,
> int* ret_array_length );
> Solutions, workarounds, and/or hints appreciated!
tolua does not provide support for this automatically.
one solution would be to map the vector as a usertype,
and then to provide a function to access vector elements,
binding both functions with tolua.
MyVector* get_array (int arg);
int get_element (MyVector* v, int index);
you can also overload the indexing operator to access the elements.