Hi Vasu, I don't have time to help you debug your addon - sorry :-(. There are lots of examples in the tree (like the test component I pointed you to) that you can look at and play with to figure out how to make things work.
Cheers, bholley On Thu, Oct 17, 2013 at 8:00 PM, Vasu Yadav <vasuyadavkri...@gmail.com> wrote: > On Wednesday, October 16, 2013 1:53:24 PM UTC+5:30, Bobby Holley wrote: >> As you've discovered, there's a lot of magic and boilerpate that's >> >> easy to get wrong. You can find some simple test XPCOM components in >> >> js/xpconnect/components. Try grabbing one of those, making sure that >> >> it works, and then iterating on it to turn it into what you need. >> >> >> >> bholley >> >> >> >> On Wed, Oct 16, 2013 at 10:16 AM, Vasu Yadav <vasuyadavkri...@gmail.com> >> wrote: >> >> > 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 > > > > I truly thankful for your help. > As you suggest I had gone through XPCOM components of js/xpconnect/components. > > Now I am able to Instantiate helloword JS-XPCOM component, when I am trying > to return object to nsISupports interface pointer. but not same when > directly tried to return object to nsIHelloWorld interface pointer. > > nsCOMPtr<nsISupports> iSupports1 = > do_CreateInstance("@vasu.com/helloworld;1",&rv1); > In that case I m able to instantiate. > > nsCOMPtr<nsIHelloWorld> hello = > do_CreateInstance("@vasu.com/firefox/helloworld;1",&rv2); > do_CreateInstance function is always returning null when I try to return > object directly to nsIHelloWorld interface pointer. > > > Trying to call hello() function of JS-XPCOM from C++XPCOM code. I tried to > confirm Hello() function got call or not? For that reason I added alert and > console log message inside a function of hello(), but none them work. > > > Can we pass XPCOM Interface pointer(i.e. nsIDOMWindow, nsIDocShell..) from > C++ XPCOM component to JavaScript XPCOM component? If yes then how? > > Please share some useful post, data regarding communication between C++ XPCOM > component to JavaScript XPCOM component. > > Regards > Vasu > _______________________________________________ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform