JS compilation of xpcom implementation

Source: Internet
Author: User
Tags seamonkey

For a long time ago, share the document. However, gecko2.0 is now available, so some details may change. Currently, gecko2.0 has not been studied. To be continued.

Objective: To understand the idea of JS implementing XPCOM.

The JS-implemented XPCOM and xpt must be placed in a folder, that is, the components folder.
(Similarly, the C ++-implemented XPCOM (DLL file) must be placed in the same folder as xpt, which is also under the components folder ).

Document URL:

Http://developer.mozilla.org/en/How_to_Build_an_XPCOM_Component_in_Javascript

Compile command settings:
{Sdk_dir}/bin/xpidl-M typelib-w-v-I {sdk_dir}/IDL-e helloworld. xpt helloworld. IDL

Example of compiling command:
D:/sourcecode/xulrunner-SDK/xulrunner-sdk-1.9/SeaMonkey-xulrunner-SDK/bin/xpidl
-M typelib-w-v-I
D:/sourcecode/xulrunner-SDK/xulrunner-sdk-1.9/SeaMonkey-xulrunner-SDK/IDL
-E
D:/log/imservice. xpt

D:/imservice. IDL

 

Problems encountered during compilation:
1. coding problem: xp idl does not recognize UTF-8. A little dizzy.
2. The path cannot contain spaces.

Add instances with multiple interfaces to a component:

IMService. idl

# Include "nsISupports. idl"
[Scriptable, uuid (EED9537B-E056-4f0d-834A-6AEDF8E5B14A)]
Interface ceopIIMService: nsISupports {
};

[Scriptable, uuid (3CBED3C4-A0D8-11DD-AF3E-E43F56D89593)]
Interface ceopIIMAccountService: nsISupports {
};

IMService. js

Components. utils. import ("resource: // gre/modules/XPCOMUtils. jsm ");
// Utils
Const Cc = Components. classes;
Const Ci = Components. interfaces;

/*************************************** ********************
Class definition
**************************************** *******************/

// Class constructor
Function IMService (){}

// Class definition
IMService. prototype = {
// Properties required for XPCOM registration:
Classdescription: "ce imservice ",
Classid: components. ID ("{AD3F34D6-9688-11DD-B0C5-F7CC56D89593 }"),
Contractid: "@ c.cn/imservice1_1 ",

QueryInterface: xpcomutils. generateqi ([CI. ceopiimservice, CI. ceopiimaccountservice
]),

.....
};

VaR components = [imservice];

Function nsgetmodule (compmgr, filespec ){
Return xpcomutils. generatemodule (components );
}

(Haha, a component that contains multiple interfaces is complete .)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.