DEIV wrote:
there are some difficulties with using IXPCScriptable::Construct()...
I have a XPCOM class with constructor with one parameter. I would like
to write in my java scpirt something like this
var obj = new MyXPCOM(122);

how I should implement this function to provide this functionality?

  NS_IMETHOD Construct(nsIXPConnectWrappedNative *wrapper, JSContext *
cx, JSObject * obj, PRUint32 argc, jsval * argv, jsval * vp, PRBool
*_retval)
{
???

return NS_OK;
}


Did you figure out how to do this?

There are a few instances of this that can be found in the mozilla tree using lxr.mozilla.org.

You might look at:
http://lxr.mozilla.org/seamonkey/source/js/src/xpconnect/src/xpccomponents.cpp#1207

This is nsXPCComponents_Exception::Construct. It is part of the internals of xpconnect. So, it has some aspects that would not make sense for other components. But, it is something to look at.

Basically, you: convert your JS argument(s). create your C++ object with whatever constructor or init method you need to call, use xpconnect to create a wrapper, get the JSObject* of the wrapper, return the JSObject*.

That code I referenced has things you would not want...

The " XPCCallContext" is an xpconnect internal thing. you would not need it.

You wouldn't need the nsIXPCSecurityManager either.

You can get a pointer to the nsIXPConnect object used for making the new wrapper from the 'XPConnect' attribute on the wrapper passed into the constructor.

As I said, there are other examples you might look at. I believe the DOM code uses IXPCScriptable::Construct too.

John.

Thanks

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to