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

Re: Destructors



Rob Myers <robmyers@cwcom.net> writes:

> I agree the block approach is elegant, for file handles I'd definitely do
> it, but I'm talking about objects with a lifespan beyond the function that
> instantiates them: wrappers for an OS-managed window object that needs
> deallocation.

In BeOS I have to do similar types of things when doing GUI
programming with Dylan. In that case I did all the OS-managed window
object allocation in C++. The Dylan object held a pointer to a
structure that held all the OS-managed window stuff - a kind of handle
to allow Dylan and C++ to talk to each other.

When the window died, the close event captured on the C++ side would
call back to Dylan and tell it to release all references to the Dylan
window objects (It held objects in a table to prevent them from being
GC'd if only the C++ side knew the window was around). The C++ side
when then free up all resources. I didn't have to do finalization. It
probably depends on what your windowing framework gives you.

The following article is one I posted to comp.sys.be.programmer in a
discussion about how to access the BeOS C++ GUI API from other
languages outlining a little of the approach I took at the time. 

http://www.deja.com/article/527799453

It probably doesn't help much in what you want to do though :-). 

Chris.
-- 
http://www.double.co.nz/dylan



References: