lua-users home
lua-l archive

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


I got it working!  Just tell me if this is an acceptable way to do it.

I had to trick Tolua :) to think that I was using an indexed array instead
of a pointer, so in my package file, I did this:

extern int num_vectors;
extern vec3 vectors[1];

Then after I tolua created the binding, I changed the header file back to:

extern int num_vectors;
extern vec3 *vectors;

And in the binding code, I removed all array range checking code:

#ifndef TOLUA_RELEASE
if (tolua_index<0 || tolua_index>=1)
tolua_error(tolua_S,"array indexing out of range.",NULL);
#endif


My Lua test script now works.  Does this hack sound acceptable?


From: "R. Frazier" <rtdoger@hotmail.com>
Reply-To: Lua list <lua@bazar2.conectiva.com.br>
To: lua@bazar2.conectiva.com.br
Subject: Re: Tolua and indexed array pointers
Date: Thu, 17 Mar 2005 13:15:31 -0500

Ok, but that doesn't answer my question. I already have my own vector class that I want to use. And I would like to use Tolua to convert it. How can I get tolua to create a binding so I can access those variables using a indexed array pointer (e.g. vectors[5].x = 10.0).


From: Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
Reply-To: Lua list <lua@bazar2.conectiva.com.br>
To: Lua list <lua@bazar2.conectiva.com.br>
Subject: Re: Tolua and indexed array pointers
Date: Wed, 16 Mar 2005 23:37:18 -0300

On Wed, Mar 16, 2005 at 09:25:35PM -0500, R. Frazier wrote:
> How can I set the variables of a data structure using an indexed array
> pointer?
>
> class vec3 {

See http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lv3 .
--lhf

_________________________________________________________________
Designer Mail isn't just fun to send, it's fun to receive. Use special stationery, fonts and colors. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.


_________________________________________________________________
Designer Mail isn't just fun to send, it's fun to receive. Use special stationery, fonts and colors. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.