Hi
Could you please help me " Instantiate JavaScript XPCOM Component from C++
XPCOM Component/ C++ Code"
I have tried one same code given below.
HellowWorld.js
------------------------------------
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function HelloWorld()
{
}
HelloWorld.prototype = {
classDescription: "My Hello World Javascript XPCOM Component",
classID: Components.ID("{1b635320-30a8-11e3-aa6e-0800200c9a66}"),
contractID: "@keynote.com/firefox/helloworld;1",
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIHelloWorld]),
Hellovasu: function() {
//alert(" Welcome to JS -XPCOM");
return "Hello World!"; }
};
var components = [HelloWorld];
if ("generateNSGetFactory" in XPCOMUtils)
var NSGetFactory = XPCOMUtils.generateNSGetFactory(components); // Firefox
4.0 and higher
else
var NSGetModule = XPCOMUtils.generateNSGetModule(components); // Firefox
3.x
--------------------------------------------------------------------------------
HelloWorld.idl
----------------------------------------------------
#include "nsISupports.idl"
[scriptable, uuid(1b635320-30a8-11e3-aa6e-0800200c9a66)]
interface nsIHelloWorld : nsISupports
{
string Hellovasu();
};
--------------------------------------------------------------------
I create header and .xpt file using python.
Instantiate JavaScript XPCOM Component from C++ code.
nsresult rvp;
nsCOMPtr<nsIHelloWorld> hello =
do_CreateInstance("@keynote.com/Firefox/helloworld;1", &rvp));
Not able to instantiate nsIHelloWorld component. do you fell anything wrong or
incorrect in code?
why is it generating string Hellovasu () function to Hellovasu(char * *_retval)
in header file.
/* string Hellovasu (); */
NS_IMETHODIMP nsHelloWorld::Hellovasu(char * *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
Regards
Vasu
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform