lua-users home
lua-l archive

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


>> Nice thought.
>
> So far I got away without this trick by controlling the order of
> construction (just require an argument of type B in the constructor of A
> and put it in A's uservalue table, and all is set), so I haven't tried
> it, but I think it should work.
>

If I understand this correctly, this is what I originally tried, but
it wasn't sufficient. It keeps the reference alive, but during
collection they get reaped in the order mentioned in this thread. I
needed the luaL_ref/luaL_unref trick (which handles it except but
lua_close).

I think this always works for the SDL case because you always need to
create the renderer first. But I have another library with a similar
problem (physics library) where you need to add bodies to the world.
The world doesn't like bodies being deleted out from under it simular
to the renderer case. But unfortunately, worlds can be created after
bodies (because bodies can be put in different worlds in this case).

Thanks,
Eric
-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/