Re: Reference variables in jawin?

Morten Andersen <[email protected]>
Newsgroups gmane.comp.windows.devel.jawin
Organization Arosii Information Systems A/S
Message-ID <[email protected]>
Hi Jonas

Jonas Lindén wrote:
> Hello, and thanks (Morten) for the lengthy response. I have not have time
> to try you suggestions until this weekend. I think I understand it but
> except for one thing I am still not sure about what a "NakedByteStream"
> is. I cant seem to find any information about that variable type.
>

The org.jawin.io.NakedByteStream is actually just a subclass of the
java.io.ByteArrayOutputStream, allowing access to the embedded internal
byte-array without making a copy of it.

The explanation for the below code-snippet (taken from my last mail):

   NakedByteStream nbs = new NakedByteStream();
   LittleEndianOutputStream leos = new LittleEndianOutputStream(nbs);
   leos.writeInt(boardNum);
   leos.writeInt(channel);
   leos.writeInt(range);

   // call the function with three ints and 4 bytes allocated for
   // the datavalue - see explanation of the instructionstring below
   byte[] result = fp.invoke("IIIA:I:L4L4L4n4", 16, nbs, null,
     ReturnFlags.CHECK_NONE);

is:
1) create a NakedByteStream (wrapping a byte array).
2) create a LittleEndianOutputStream for serializing the input variables
that should be passed to the dll-function. The variables will be
serialized to the nbs NakedByteStream.
3) write the 3 input variables to the outputstream (which "under the
hood" serializes the 3 ints to the nbs byte array).
4) invoke the dll-function giving the nbs NakedByteStream as one of the
parameters ("under the hood" again, this sends the byte array, wrapped
by the nbs NakedByteStream, to the native Jawin code, which uses the
instruction string for deserializing the byte array into 3 native int's
(and a newly allocated int* used for the out parameter).
5) the result (and any [out]-parameters) are then returned as a new byte
array. This byte-array should then be deserialized by wrapping it in a
LittleEndianInputStream as shown in my last mail.

Hope this answers your question?, otherwise please feel free to email again.

Best Regards
Morten
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.