The main thought was for things like xhr.response which is ArrayBuffer and
can be used directly.
That could be changed if it was preferred. I kept it the same as it was the
native 'bytearray' implementation for the target platform and that seemed
to correspond more to ArrayBuffer than Uint8Array. But those two are very
easily interchanged I think - ArrayBuffer just seemed the more base level
implementation.
anyway, as I have it now, writeBinaryData is basically doing the same thing:
COMPILE::JS
{
writeBytes(bytes.ba as ArrayBuffer)
}
with @royaleignorecoercion ArrayBuffer
More caution is obviously needed for using the readBytes method because
these things in js are fixed length compared to ByteArray which grows as
needed.
On Fri, Feb 22, 2019 at 6:03 AM Harbs <[email protected]> wrote:
> What’s the reason you are using ArrayBuffer instead of Uint8Array on the
> JS side?
>
> If you’d use Uint8Array instead, the method could be used like so:
>
> bd2.writeData(bd1.array);
>
>
> > On Feb 21, 2019, at 6:40 PM, Greg Dove <[email protected]> wrote:
> >
> > Hi Harbs,
> >
> > Part of the reason for posting this was to surface any concerns early.
> > This is my fault because when I added these methods a few years back I
> > thought it seemed ok to use BinaryData as the 'bytes' argument type in
> them
> > at the time. But the issue there is that it breaks compatibility with swf
> > interfaces for IExternalizable, because that becomes incompatible for
> > readBytes/writeBytes in the IDataInput/IDataOutput interfaces.
> > I guess it could be avoidable in other ways, but it seems better to go
> for
> > the consistency and provide the writeBytes/readBytes methods as the
> native
> > platform variants.
> >
> > The change however is quite trivial:
> >
> > what was
> > function writeBytes(bytes:BinaryData, offset:uint = 0, length:uint =
> 0):void
> >
> > will become
> >
> > COMPILE::SWF
> > public function writeBytes(bytes:ByteArray, offset:uint = 0, length:uint
> =
> > 0):void
> >
> > and
> > COMPILE::JS
> > public function writeBytes(bytes:ArrayBuffer, offset:uint = 0,
> length:uint
> > = 0):void
> >
> > and the original method signature will remain available as:
> > public function writeBinaryData(bytes:BinaryData, offset:uint = 0,
> > length:uint = 0):void
> >
> > Likewise for the corresponding read methods. And although the code has
> > changed slightly, it works as before.
> >
> > So it is a simple search and replace in files
> >
> >
> > On Thu, Feb 21, 2019 at 9:15 PM Harbs <[email protected]> wrote:
> >
> >> What did you change? I’m using these methods, so it’s significant to me.
> >>
> >>> On Feb 21, 2019, at 7:20 AM, Greg Dove <[email protected]> wrote:
> >>>
> >>> I had to change the writeBytes/readBytes method signatures.
> >>> The original method signature is still available but will become
> >>> writeBinaryData/readBinaryData
> >>
> >>
>
>