If you want to pass a JS Object as parameter for a XPCOM interface, I think that you must write at least a QueryInterface method for your JS Object, that is make it an object implementing an XPCOM interface!

for example:
youObject.prototype={
QueryInterface: function(aIID) {
    if  ( !aIID.equals(Components.interfaces.nsISupports)) {
      throw Components.results.NS_ERROR_NO_INTERFACE;
    }
    return this;
}
}

let you pass the JS Object as nsISupports parameter to your interface function (Tanks to XPConnent).
Unless you want save a JS object reference in your XPCOM component the declaration above is useless!!!! If you want do something with you JS Object in XPCOM function it must implement a interface other than nsISupports.
If you pass a string or a JS Array to XPCOM interface you can find information how to do this directly without QueryInterface blah blah on Mozilla web site (I don't remember the link of page of interest... sorry :'(  )

On 10/7/05, Jan Odvarko <[EMAIL PROTECTED]> wrote:
Hi All,
I would like to pass a _javascript_ object to an XPCOM interface.
What type should I use for the parameter?

Similarly I would like to use the type as a return type of a method.

See an example:

interface nsIMyInterface : nsISupports
{
    void MyFunc(in nsISupport aJavaScriptObject);
    nsISupport GetJSObject();
}

Within the example I have used nsISupports as a type. Not sure
if it's correct...

Thanks for any ideas!

Honza


_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom



--
...und ich sah die sieben Engel, die da stehen vor Gott, und ihnen wurden sieben Posaunen gegeben... - aus der Offenbarung des Johannes (Apokalypse)

Reply via email to