Re: question on nsIWeakReference
jml <[email protected]> Mon, 06 Jan 2003 09:16:06 +0800
| Newsgroups | gmane.comp.mozilla.devel.xpcom |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
I have read this manual, but it only tells how you can implement nsISupportsWeakRerence in C/C++, and how to create a nsIWeakReference, not explaining how it works. To me, I am implementing both nsISupportsWeakReference and nsIWeakReference in java, and in fact, in my nsIWeakReference implementation, I store a java WeakReference to the XPCOM object that the nsISupportsWeakReference represents. To me, there just have no real reason to have the nsISupportsWeakReference interface. It seemed to be an interface that only internally useful to the C/C++ nsWeakReference and nsSupportsWeakReference implementation. For the other module, for example, nsIWebBrowser, when I call addWebBrowserListener, I am already passing a nsIWeakReference to it, why inside nsIWebBrowser will again require the nsISupportsWeakReference be implemented? I just think that is not necessary and don't understand. jml John Bandhauer wrote: > [setting follow-ups to netscape.public.mozilla.xpcom] > > Did you read the fine manual? > > http://www.mozilla.org/projects/xpcom/weak_references.html > > Note that the code got moved to... > > http://lxr.mozilla.org/seamonkey/source/xpcom/glue/ > > ..and the lxr urls in the doc *ought* to get updated. > > John. > > jml wrote: > >> I have some question on nsIWeakReference and nsISupportsWeakReference. >> >> 1. How error code should nsIWeakReference.queryReferent() return if >> the corresponding xpcom object is disposed? > > > http://lxr.mozilla.org/seamonkey/source/xpcom/glue/nsWeakReference.cpp#149 > >> >> 2. For the whole design, why require the nsISupportsWeakReference >> interface? I don't see the necessary of the nsISupportsWeakReference >> interface, at least, if one can provide an nsIWeakReference, why care >> about nsISupportsWeakReference? >> >> 3. BTW, it is very easy to implement the nsIWeakReference in java, >> only need to use the java weakreference support. Can anyone explain >> how weakreference works in the C/C++ world? I noticed there are a lot >> of C/C++ macro for it, hard to understand for me :-) >> >> Thanks >> >> jml >> >> >