BAsh wrote:
What I understand: I can simply get this class to implement the interface of nsIXPCScriptable.

You want its classinfo to do that. And it already does. See nsHTMLAppletElementSH and see nsHTMLExternalObjSH::GetProperty. You might want to implement nsHTMLAppletElementSH::GetProperty if you want to expose this for <applet> but not Java <object>s.

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.

|wrapper| is the wrapper in question, and |obj| is the JSObject that the property get is being done on. The JSObject of |wrapper| could be on the prototype chain of |obj| -- it need not be |obj| itself.

|id| could be a number, not a string. But other than those minor nits, your analysis is spot-on.

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.

Yep.  Sounds about right.

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.

Actually, I think you just return NS_OK or call you superclass GetProperty method. If you return NS_ERROR_NOT_IMPLEMENTED XPConnect will bail on the property get altogether.

Why can't they simply create a new class/interface that simply lets you stick a JSObject into javascript.

Because it's never really been needed before?

Would it be possible to make such a class so people don't stumble upon the same problem?

It'd be possible to write XPConnect glue code for this, for sure.

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

Reply via email to