[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua and references to C/C++ data...
- From: Michael Cuddy <mcuddy@...>
- Date: Thu, 09 Aug 2001 21:47:46 -0700
> >The way I do this is in the table handler for the GraphicsObj, I return
> >a userdata pointing to &(obj.pos). The problem is, that the userdata
> >I create will eventually be GC'ed .. since it's a pointer to field of
> >another strucutre, this will cause free() to have fits.
>
> Lua does not call free for userdata. It's up to the host program to do that.
True, but it calls the GC method. My point is that I do this:
lua_pushuserdata(L, &(obj.vec), Point::getTag());
And the problem is that the GC method defined for the Point tag does
something akin to:
Point *obj = lua_touserdata(L,1);
delete obj;
I'm going to give tolua a try, as several have suggested.
--
Mike Cuddy (mcuddy@FensEnde.com, MC312), Programmer, Daddy, Human.
Fen's Ende Software, Redwood City, CA, USA, Earth, Sol System, Milky Way.
Now I lay me down to sleep / CVS, I pray, my code to keep.
If disks crash before I wake: / format, newfs, cvs up, make.
Join CAUCE: The Coalition Against Unsolicited Commercial E-mail.
<http://www.cauce.org/>