Skip to content

Inconsistent behaviour new BytesOutput().getBytes().getData() in standard library #8974

@polygonal

Description

@polygonal
//swf,cpp:
var output = new haxe.io.BytesOutput();
for (i in 0...256) output.writeInt16(1);

var bytes = output.getBytes();
trace(bytes.length); // 512

var data = bytes.getData();
trace(data.length); // 512;
//js:
var output = new haxe.io.BytesOutput();
for (i in 0...256) output.writeInt16(1);

var bytes = output.getBytes();
trace(bytes.length); // 512

var data = bytes.getData();
trace(data.length); // ERROR: haxe.io.BytesData has no field length

trace(data.byteLength); // 609, should be 512

How to reproduce (Haxe 4.0.2):

  • Compile first example with -swf or -cpp
    • both bytes.length and data.length are correct
  • Compile second example with -js
    • first problem: length property is not defined
    • second problem: switching to byteLength, it seems the internal buffer is returned instead of the actual written bytes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions