Christopher Lenz wrote:Christian Biesinger wrote:The GetInterfaces implementation of GenericFactory looks into its moduleinfo structure for a getinterfaces pointer. However, very few components really implement nsIClassInfo, and thus this pointer is null, and hence this function does what it does.
That is too bad :-(
So the alternative to this would be to QueryInterface every component to
every known interface, right? IIUC that is what the XPCOM Component
Viewer[1] does/did. I just hoped there would be a cleaner way to accomplish
this.
Classinfo is mainly used by xpconnect so that it can "predictively" flatten the interfaces on an object. Thus, the vast majority of XPCOM components don't implement classinfo.
Okay. Maybe I'm totally misunderstanding something here, but AFAICT most components I've tried actually *do* implement nsIClassInfo (or at least, the component factory supports nsIClassInfo):
js> var cls = Components.manager.getClassObjectByContractID(
"@mozilla.org/addressbook;1",
Components.interfaces.nsISupports);
js> var clsInfo = cls.QueryInterface(Components.interfaces.nsIClassInfo);
js> clsInfo.classDescription
Address Book
js> clsInfo.implementationLanguage
1
js> clsInfo.contractID
@mozilla.org/addressbook;1
js> clsInfo.classID
{d60b84f2-2a8c-11d3-9e07-00a0c92b5f0d}*However*, not one of these components returns a non-empty array when getInterfaces() is invoked:
js> var cnt = { value: 0 };
js> var interfaces = clsInfo.getInterfaces(cnt);
js> print(cnt.value);
0
js> print(interfaces.length);
0So what am I missing? The component factory does seem to support nsIClassInfo, but it just doesn't implement the GetInterfaces hook?
I guess I'm wondering *why* you want to enumerate the interfaces that every component supports. Is it curiosity or is it meant to actually accomplish something? Note that it is not a good way to figure out all of the XPCOM objects that might be floating around, because some/many objects are not available directly from XPCOM through factories, but are only available through "getter" functions on other objects.
Well, on the one hand I'm just playing around and trying to get a better understanding of XPCOM. On the other hand, I'm working on something very similar to the "XPCOM Component Viewer" I mentioned in a previous post. Think a tool to aid in development.
Cheers, Chris _______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
