MozillaZine

Implementing XPCOM components in JavaScript

From MozillaZine Knowledge Base

(Difference between revisions)
Revision as of 21:35, 2 February 2006
Richwklein (Talk | contribs)

<-- Previous diff
Revision as of 21:37, 2 February 2006
Richwklein (Talk | contribs)
(About XPCOM)
Next diff -->
Line 1: Line 1:
== About XPCOM == == About XPCOM ==
-Mozilla applications are built from a collection of XPCOM (Cross-platform Component Object Model) objects. They are used to perform certain tasks or to get specific functionality. For example, there is a directory service component that can be used to access files on your file system. Components can be constructed using several programming languages, including: javascript, c++, and python. Mozilla then uses "interfaces" to describe what a component can do. The most basic interface [http://lxr.mozilla.org/mozilla/source/xpcom/base/nsISupports.idl nsISupports] give components a way to expose what interfaces they implement.+Mozilla applications are built from a collection of XPCOM (Cross-platform Component Object Model) objects. They are used to perform certain tasks or to get specific functionality. For example, there is a directory service component that can be used to access files on your file system. Components can be constructed using several programming languages, including: javascript, c++, and python. Mozilla then uses "interfaces" to describe what a component can do. The most basic interface [http://lxr.mozilla.org/mozilla/source/xpcom/base/nsISupports.idl nsISupports] is used to get different interfaces that a component implements.
* Benifits of XPCOM * Benifits of XPCOM

Revision as of 21:37, 2 February 2006

About XPCOM

Mozilla applications are built from a collection of XPCOM (Cross-platform Component Object Model) objects. They are used to perform certain tasks or to get specific functionality. For example, there is a directory service component that can be used to access files on your file system. Components can be constructed using several programming languages, including: javascript, c++, and python. Mozilla then uses "interfaces" to describe what a component can do. The most basic interface nsISupports is used to get different interfaces that a component implements.

  • Benifits of XPCOM
    • XPCOM objects can be used by any programming language mozilla supports.
    • Objects implemented as XPCOM are global to an application, and are not dependent on the scope of any one window.
    • Programming logic can be encapsulated within an object.
  • XPCOM Drawbacks
    • Objects must be accessed from their defined interfaces. Javascript shortcuts such as the global window object annot be accessed.
      • The only exception to this rules, is if you set a magical property wrappedJSObject equal to your component, then the underlining javascript object can be accessed.
    • It is easier to have memory leaks