Boris Zbarsky wrote:
Oh.  Hmm.

You could try creating a small nsISupports implementation whose classinfo implements nsIXPCScriptable and has a PostCreate hook that puts the jobject into the prototype chain...

That's the only thing I can think of offhand. Or you could do the same and have a getProperty hook that just reports the jobject's JSObject.

Either way, you can't really do this through XPConnect, unfortunately.

-Boris

What I am eventually trying to do is get the applet jobject of an <applet> tag 
- nsHTMLAppletElement.

What I understand: I can simply get this class to implement the interface of 
nsIXPCScriptable. The only method that I actually need to write is this:

PRBool getProperty ( nsIXPConnectWrappedNative wrapper , JSContextPtr* cx , 
JSObjectPtr* obj , JSVal id , JSValPtr* vp )

The documentation is practically nonexistent so i think wrapper is the wrapped 
nsHTMLAppletElement - the class I am a part of. cx is the JSContext. obj is 
another pointer to our class. id is the property that we are looking for, as a 
string. While vp is where I return a jsval.

Under that assumption: I check id to see if it equals "getApplet" or similar. 
If not I return NS_OK. If so I get the jobject, wrap it with liveconnect, convert it to 
jsval and store it in vp. I then return NS_SUCCESS_I_DID_SOMETHING.

For all the other methods that come with the interface I return 
NS_ERROR_NOT_IMPLEMENTED and let xpconnect handle it - functioning just like it 
did before.

Am I right in saying this?

Why can't they simply create a new class/interface that simply lets you stick a 
JSObject into javascript. Why all this pain?? Would it be possible to make such 
a class so people don't stumble upon the same problem?

For people who want to implement nsIXPCScriptable, you might want to look at 
this:

Info:          http://www.mozilla.org/scriptable/scriptable-proposal.html
Example:       
http://lxr.mozilla.org/mozilla1.8/source/calendar/base/src/calDateTime.cpp#720
The Interface: 
http://www.xulplanet.com/references/xpcomref/ifaces/nsIXPCScriptable.html
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to