Your SlideShare is downloading. ×
0
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Pcom xpcom
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Pcom xpcom

116

Published on

Cross Platform Component Object Model

Cross Platform Component Object Model

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
116
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. XPCO M CROSS PLATFORM COMPONENT OBJECT MODELING A Brief Overview
  • 2. Catalogue  Introduction  Benefits  Drawbacks  Concepts  Example Code  Working  References
  • 3. Introduction     XPCOM is a cross platform component object model, similar to Microsoft COM. It has multiple language bindings, allowing XPCOM components to be used and implemented in JavaScript, Java, and Python in addition to C++. Interfaces in XPCOM are defined in a dialect of IDL called XPIDL. XPCOM itself provides a set of core components and classes, e.g. file and memory management, threads, basic data structures (strings, arrays, variants), etc.
  • 4. Benefits  XPCOM components can be used by any programming language Mozilla supports.  Objects implemented as XPCOM can be global to an application, and are not dependent on the scope of any one window. You can use an XPCOM service to share data between windows.  XPCOM encourages modular programming - programming logic can be encapsulated within a component.
  • 5. Drawbacks  Objects must be accessed from their defined interfaces. Javascript shortcuts such as the global window object cannot be accessed.   The only exception to this rule, is if you set a magical property wrappedJSObject on your component implemented in JavaScript, the object this property refers to will be accessible from the calling side. You can set ”this.wrappedJSObject = this” in your component's constructor and avoid writing any interfaces altogether. It is easier to have memory leaks.
  • 6. Concepts  Components:   A component is simply an object that implements interfaces, and is registered with the component manager. Interfaces:  Interfaces are used to define what functions and attributes an XPCOM component provides. nsISupports is an interface that all classes must implement. It provides a function to request the interfaces on a class.
  • 7. Concepts  Factories:   (Cont.) Factories are objects used to instantiate components. Each factory object implements the nsIFactory interface. Modules:  Multiple classes can be defined in a file. A module is an object that is used to register, unregister and provide factories for classes. It implements the nsIModule interface.
  • 8. Example Code
  • 9. Example Code (Cont.)
  • 10. Example Code (Cont.)
  • 11. Working  I. Startup & Registration  During the startup process if the file compreg.dat is missing or the file .autoreg exists, the application knows that it needs to register components. It then loads files from each of the components folders, including the components folder in each extension directory. It then calls the function NSGetModule on each file to get the object that implements the nsIModule Interface. The module object is then used to register your module. This is used to simplify the process of retrieving the module later in class creation. The registerSelf function is called to do the actual registering. When removing a class, the unregisterSelf function is called.
  • 12. Working  II. Class Creation    (Cont.) The code calls getClassObject on your module. This returns a class factory. The factory then has a method called createInstance which is used to create the actual class object. III. Accessing the component   You can now access your component by the code written. Mozilla also provides a component construction process to easy creation with JavaScript.
  • 13. References  http://kb.mozillazine.org  http://en.wikipedia.org/wiki/XPCOM  https://developer.mozilla.org/en/docs/XPCOM  http://www.ibm.com/developerworks/webservices/library/coxpcom/index.html
  • 14. Thank You Jay Patel (M.Sc. IT - Part 1)

×