There is no reason why the calling JS code won't work with the
idl declared method as you've described it.

As others have said...

You wrote: 
 NS_METHOD GetVersion(char * _retval)
I'm sure it was really more like...
 NS_IMETHODIMP Foo::GetVersion(char **_retval)

nhodgson had the implementation of the method almost right..
It should be 'nsMemory' where he has 'nsAllocator'.

The call goes through xpconnect and it deals with remapping the
result to look more like the idl declaration and what you expect
in your JS code.

John.

Patrick McHale wrote:
> 
> Hello,
> 
> Thanks for the responding to our query.  This is the original Javascript
> that is shipped to our users.
> 
> function GetVersion(theSession) {
>     alert(theSession.GetVersion());
> }
> 
> We don't want to have to declare a string variable and pass it.
> This is the glue code we have added to the original Javascript which we
> would NOT like to have to implement for each of our functions.
> 
> var str = new Object();
> function _GetVersion(theSession) {
>         theSession.GetVersion(str);
>         return str;
> }
> 
> function GetVersion(theSession) {
>     var str = _GetVersion(theSession);
>     alert(str.value);
> }
> 
> Thanks in advance
> 
> Patrick McHale
> Paul Baxter
> 
> "Neil Hodgson" <[EMAIL PROTECTED]> wrote in message
> 9emmhd$[EMAIL PROTECTED]">news:9emmhd$[EMAIL PROTECTED]...
> >    I would expect the same char ** parameter as Rick mentioned.
> >    To allocate and return the string the implementation should be like:
> >
> > NS_IMETHODIMP X::GetVersion(char **_retval) {
> >  char *version = "X 1.1";
> >  *_retval = reinterpret_cast<char*>(
> >     nsAllocator::Clone(version, strlen(version)+1));
> >  return (*_retval) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
> > }
> >
> >    Neil
> >
> >
> >

Reply via email to