Using XPCOM Objects

Using XPCOM Objects

Instanciating XPCOM Objects

An instance of XPCOM component can be obtained by XPCOM.instance methods.

file = XPCOM.instance("@mozilla.org/file/local;1", "nsILocalFile")
    

You can also ask a service for the ServiceManager.

category_manager =
      XPCOM::ServiceManager.getService("@mozilla.org/categorymanager;1",
                                       "nsICategoryManager")
    
XPCOM::ServiceManager is reference to the global service manager. It support nsIServiceManager interface. getServiceManager method is wrapped, specially so that it accept an interface name as well as IID.

nsISupports

Methods defined nsISupports are treated specially.

QueryInterface

QueryInterface accepts interface name as well as iid. It returns nil if the reciever does not support specified interface (rather than raising an exception).

AddRef

not visible from Ruby

Release

not visible from Ruby