[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Inverted _gc
- From: Mark Hamburg <mhamburg@...>
- Date: Thu, 10 Jul 2003 15:46:32 -0700
This won't take care of the Lua side of the object -- for that you need to
wait for Lua GC -- but you could have a Lua heavy userdata proxy object
reference your real object indirectly. If the real object and the proxy know
about one another, then you can NULL the pointer in the proxy object when
the real object goes away. The proxy then needs to be prepared to deal with
this case (and should probably provide a way to test for it from Lua). This
approach is based on having the proxy be a heavy user data.
Mark
There's no problem in computer science that can't be solved with an extra
level of indirection.
"Abstractions = page-faults" - Richard Gabriel
on 7/10/03 2:33 PM, Deneb aka Alpha Cygnus at alpha_cygnus@mtu-net.ru wrote:
> Suppose I have an object that is allocated (created) in Delphi (or C++ ro
> whatever). I don't (can't) want to give Lua full control on the object's life,
> I just want to give access to its properties via properly set callback
> functions in metatable of a heavy user data, that I wrap this object into for
> Lua.
> Now the object gets destroyed (in Delphi), that brings the possibility of
> calling property access function with a pointer to already freed object if I
> have some heavydata references to this object left in Lua.
> Any ideas if I can somehow avoid this? Ideally would be me being able to track
> down all userdata that points to this object and nil them out in Lua, but I
> can't think of the way how to make it automatically, without thorough keeping
> track of references by hand. Or maybe I can do it some other way around?
>