Yup, you are certainly asking in the wrong group. The classes you are
talking about now are very tied to the DOM.
Everything is made clear in...
http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsDOMClassInfo.cpp
... :)
I *think* that the JS ctor for XMLHttpRequest uses that file's generic
nsDOMConstructor class - which is used for constructing many types and
does construction without taking arguments.
Since you keep citing different classes in each posting it is hard to
know if this is the class you actually care about or not.
Why you would want to add (what I assume are) non-standard extensions
to XMLHttpRequest is a mystery to me. But, nsDOMClassInfo.cpp is where
the fun happens. You'd need to do something specialized for your class
in or around that code.
Good luck.
John.
DEIV wrote:
Hi
Thanks!
Let's go another way.
I have XMLHttpRequest XPCOM component in
..\mozilla\extensions\xmlextras\base\src\nsXMLHttpRequest.*
I can create this object as
var obj = new XMLHttpRequest()
from the <script> section.
I would like to add one more possibility to create this class
var obj = new XMLHttpRequest("something here")
The question is - how to do it?
My wayis to try to use IXPCSriptable interface.
but I don't know how!
I didn't find any good examle.
Thanks
Regards,
Denis
"John Bandhauer" <[EMAIL PROTECTED]> ???????/???????? ? ????????
?????????: news:[EMAIL PROTECTED]
It is not really that clear to me from your question exactly what it is
that you are asking.
nsDOMClassInfo is pretty much an internal DOM class. If you want to mess
around with that stuff you should probably be talking to people on the DOM
newsgroup.
The way to get xpconnect to call your Construct method on an
implementation of nsIXPCScriptable is to OR the
nsIXPCScriptable::WANT_CONSTRUCT with the other flags returned by your
GetScriptableFlags method.
If you were not messing with the DOM stuff I'd suggest you use the macros
in xpc_map_end.h to do this for you. There are plenty of examples of that.
But, the DOM code has it's own way of managing the nsIXPCScriptable stuff.
And, FWIW, the most simple and generic way to expose a constructor method
into JS is to execute a one line JS script using Components.Constructor to
build the constructor method for you.
John.
DEIV wrote:
Thanks for your comments.
It looks like I was too busy with my question because now I have a
problem
how to make JS-engine invoke method IXPCScriptable::Construct().
Actually I have helper class
class nsIntArraySH : public nsDOMClassInfo
with public method
NS_IMETHODIMP
Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRUint32 argc, jsval *argv,
jsval *vp, PRBool *_retval)
The question is what is the right way to register this one?
Thanks
"John Bandhauer" <[EMAIL PROTECTED]> ???????/???????? ?
???????? ?????????: news:[EMAIL PROTECTED]
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