On Friday, October 4, 2013 6:16:36 PM UTC+5:30, Bobby Holley wrote: > On Fri, Oct 4, 2013 at 2:36 PM, <vasuyadavkri...@gmail.com> wrote: > > > > > Based on my understanding, I need to create a JS XPCOM component apart > > > from the existing C++ XPCOM component I already have. All the JavaScript > > > function calls need to be made from JS XPCOM component. > > > > > > > Precisely. > > > > > > > How will the C++ XPCOM and JS XPCOM communicate to each other? Can we > > > instantiate JS XPCOM component from C++ XPCOM Component? > > > > > > > Yes. The great the about XPCOM components is that they can be instantiated > > and manipulated in either C++ or JS - the language of the implementation > > doesn't matter. > > > > > > > > I want to deliver only one .xpi to my customers. I hope it is possible to > > > package both C++ XPCOM and JS XPCOM components in the same .xpi file. > > > Please let me know if this is possible and whether you see any problems in > > > this approach. > > > > > > > Yep, that should work just fine. > > > > Here are some links that might be useful: > > > > https://developer.mozilla.org/en/docs/How_to_Build_an_XPCOM_Component_in_Javascript > > http://kb.mozillazine.org/Implementing_XPCOM_components_in_JavaScript > > > > bholley
Sorry for troubling you again. I am trying to create one sample JavaScript XPCOM component.But not able to instantiate JavaScript XPCOM component from C++ code. Steps to create JavaScript XPCOM component- 1) Create nsIHelloWorld.idl file for nsIHelloWorld interface. 2) Create nsIHelloWorld.js file 3) Generating .xpt and header file using Python22.0. 4) Instantiate JavaScript XPCOM component from C++ code. Code- nsIHelloWorld.idl ---------------------------------------------------------- #include "nsISupports.idl" [scriptable, uuid(8e001740-322b-11e3-aa6e-0800200c9a66)] interface nsIHelloWorld : nsISupports { string Hellovasu(); }; ---------------------------------------------------------- nsIHelloWorld.js ----------------------------------------------------------------------------------------------------- Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); function HelloWorld() { } HelloWorld.prototype = { classDescription: "My Hello World Javascript XPCOM Component", classID: Components.ID("{031572f4-3629-11e3-98fd-ce3f5508acd9}"), contractID: "@keynote.com/firefox/helloworld;1", QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIHelloWorld]), Hellovasu: function() { return "Hello World!"; } }; var components = [HelloWorld]; if (XPCOMUtils.generateNSGetFactory) this.NSGetFactory = XPCOMUtils.generateNSGetFactory([components]); // Firefox 4.0 and higher else var NSGetModule = XPCOMUtils.generateNSGetModule([components]); // Firefox 3.x ---------------------------------------------------------------------------------------------------- chrome.manifest ---------------------------------------------------------------------------------- interfaces components/nsIHelloWorld.xpt component 031572f4-3629-11e3-98fd-ce3f5508acd9 nsIHelloWorld.js contract @keynote.com/firefox/helloworld;1 {031572f4-3629-11e3-98fd-ce3f5508acd9} application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} ----------------------------------------------------------------------------------- Instantiate JavaScript XPCOM compnent from C++ code ----------------------------------------------------------------------------------------------- #include "nsComponentManagerUtils.h" #include "nsIHelloWorld.h" nsCOMPtr<nsISupports> iSupports = do_CreateInstance("@keynote.com/Firefox/helloworld;1",&rv1); or nsCOMPtr<nsIHelloWorld> ihello = do_CreateInstance("@keynote.com/Firefox/helloworld;1",&rv1); Not able to instantiate helloworld component. ----------------------------------------------------------------------------------------------- Logs value for IHello and rv1 in hexa formet- IHello=0 rv1=80040154 Do you fell anything missing or wrong in this code? If you have any better approach or solution please suggest me. I am completely stuck here. Regards Vasu _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform