Thanks for the ideas Harbs. I'll suggest that it will be easier to discuss
these after I push to a remote branch and you can take a look. My aim was
to keep the writeData ('writeBinaryData') and readData ('readBinaryData')
signatures the same as the originals (original readBytes/writeBytes) for
now. My interpretation of your last comments is that you are suggesting
possible changes to those original method signatures.

I think that could be done on the write side, but the reading side would
not be the same without reference to the target BinaryData, because it
needs access to the target BinaryData to support 'growing' its ArrayBuffer
if needed (in which case it would be a different ArrayBuffer instance).

Anyway, I will put this all in a branch with the compiler changes and as-js
changes aligned so you can check things first. It may still be a day or two
before I get there.



On Fri, Feb 22, 2019 at 6:27 AM Harbs <harbs.li...@gmail.com> wrote:

> Maybe the type of “data” should be platform specific?
>
> Then you could use: bd2.writeData(bd1.data);
>
> > On Feb 21, 2019, at 7:18 PM, Greg Dove <greg.d...@gmail.com> wrote:
> >
> > 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 <harbs.li...@gmail.com> 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 <greg.d...@gmail.com> 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 <harbs.li...@gmail.com> 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 <greg.d...@gmail.com> wrote:
> >>>>>
> >>>>> I had to change the writeBytes/readBytes method signatures.
> >>>>> The original method signature is still available but will become
> >>>>> writeBinaryData/readBinaryData
> >>>>
> >>>>
> >>
> >>
>
>

Reply via email to