"John Bandhauer" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> shadows wrote:
> >
> > Hi,
> > I have the following C++ function:
> >
> > bool test(BYTE *bpBuffer,DWORD iBufferLength) {
> > // write into Buffer
> > // write new value into BufferLenght
> > }
> >
> > Is this XPIDL definition right?
> >
> > boolean test(out octet bBuffer, inout unsigned long bBufferLength)
> >
> > And how would I pass arguments from JavaScript?
> > I tryed:
> > ...
> > ...
> > var Buffer=new Object();
> > var BufferLength=new Object();
> > BufferLength.value=100;
> > test(Buffer,BufferLength);
> >
> > But I get a Memory Exception saying that "read" can't be executed in
memory
> > 0x0000004 or something like that...
> >
> > Thanx for any help
>
> I just added a bunch of old posting on arrays to the xpconnect
> faq...
> http://mozilla.org/scriptable/faq.html#i11
Thanx- will have a look. This might help!
>
> Why would bBuffer be 'out' while bBufferLength is 'inout'?
It is an existing DLL function. First you call the function with
bBuffer=NULL and the function will return bBufferLength as out to tell you
what Buffersize you should allocate depending on other parameters of the
function. Then you give a the function a pointer to a buffer and it's max
size... I didn't write this function, just trying to figure out how to make
it scriptable from JavaScript.
>
> What good is the bool result? Why not use the success or failure
> of the nsresult or one of the values already passed to indicate
> validity?
I am new to XPCOM- how would I do that?
>
> You need to use [array] and follow its rules if you want to call
> something like this from xpconnect. See the info above, write the
> idl, and make a C++ implementation to match the signature of the
> generated header - you'll end up with an extra pointer
> indirection that your code above does not have.
>
> John.