Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js] move typed array classes from js.html to js.lib #7894

Merged
merged 1 commit into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion std/haxe/io/BytesBuffer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class BytesBuffer {
var buf = new python.Bytearray(b);
var bytes = new Bytes(buf.length, buf);
#elseif js
var bytes = new Bytes(new js.html.Uint8Array(b).buffer);
var bytes = new Bytes(new js.lib.Uint8Array(b).buffer);
#else
var bytes = new Bytes(b.length,b);
#end
Expand Down
2 changes: 1 addition & 1 deletion std/haxe/io/BytesData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ package haxe.io;
#elseif python
typedef BytesData = python.Bytearray;
#elseif js
typedef BytesData = js.html.ArrayBuffer;
typedef BytesData = js.lib.ArrayBuffer;
#elseif hl
class BytesDataImpl {
public var bytes : hl.Bytes;
Expand Down
2 changes: 1 addition & 1 deletion std/haxe/io/BytesInput.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
package haxe.io;

class BytesInput extends Input {
var b : #if js js.html.Uint8Array #elseif hl hl.Bytes #else BytesData #end;
var b : #if js js.lib.Uint8Array #elseif hl hl.Bytes #else BytesData #end;
#if !flash
var pos : Int;
var len : Int;
Expand Down
2 changes: 1 addition & 1 deletion std/haxe/io/FPHelper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class FPHelper {
b;
}
#elseif js
static var helper = new js.html.DataView(new js.html.ArrayBuffer(8));
static var helper = new js.lib.DataView(new js.lib.ArrayBuffer(8));
#end

#if neko_v21 inline #end
Expand Down
6 changes: 3 additions & 3 deletions std/js/_std/haxe/io/ArrayBufferView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.io;

typedef ArrayBufferViewData = js.html.ArrayBufferView;
typedef ArrayBufferViewData = js.lib.ArrayBufferView;

abstract ArrayBufferView(ArrayBufferViewData) {

Expand All @@ -30,7 +30,7 @@ abstract ArrayBufferView(ArrayBufferViewData) {
public var byteLength(get, never) : Int;

public inline function new( size : Int ) {
this = new js.html.Uint8Array(size);
this = new js.lib.Uint8Array(size);
}

inline function get_byteOffset() return this.byteOffset;
Expand All @@ -40,7 +40,7 @@ abstract ArrayBufferView(ArrayBufferViewData) {
}

public inline function sub( begin : Int, ?length : Int ) {
return fromData(new js.html.Uint8Array(this.buffer.slice(begin, length == null ? null : begin+length)));
return fromData(new js.lib.Uint8Array(this.buffer.slice(begin, length == null ? null : begin+length)));
}

public inline function getData() : ArrayBufferViewData {
Expand Down
14 changes: 7 additions & 7 deletions std/js/_std/haxe/io/Bytes.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ package haxe.io;
class Bytes {

public var length(default,null) : Int;
var b : js.html.Uint8Array;
var data : js.html.DataView;
var b : js.lib.Uint8Array;
var data : js.lib.DataView;

function new(data:BytesData) {
this.length = data.byteLength;
this.b = new js.html.Uint8Array(data);
this.b = new js.lib.Uint8Array(data);
untyped {
b.bufferValue = data; // some impl does not return the same instance in .buffer
data.hxBytes = this;
Expand Down Expand Up @@ -75,7 +75,7 @@ class Bytes {
}

inline function initData() : Void {
if( data == null ) data = new js.html.DataView(b.buffer, b.byteOffset, b.byteLength);
if( data == null ) data = new js.lib.DataView(b.buffer, b.byteOffset, b.byteLength);
}

public function getDouble( pos : Int ) : Float {
Expand Down Expand Up @@ -198,7 +198,7 @@ class Bytes {

public static function ofString( s : String, ?encoding : Encoding ) : Bytes {
if( encoding == RawNative ) {
var buf = new js.html.Uint8Array(s.length << 1);
var buf = new js.lib.Uint8Array(s.length << 1);
for( i in 0...s.length ) {
var c : Int = StringTools.fastCodeAt(s,i);
buf[i << 1] = c & 0xFF;
Expand Down Expand Up @@ -230,7 +230,7 @@ class Bytes {
a.push( 0x80 | (c & 63) );
}
}
return new Bytes(new js.html.Uint8Array(a).buffer);
return new Bytes(new js.lib.Uint8Array(a).buffer);
}

public static function ofData( b : BytesData ) : Bytes {
Expand All @@ -253,7 +253,7 @@ class Bytes {
i++;
}

return new Bytes(new js.html.Uint8Array(a).buffer);
return new Bytes(new js.lib.Uint8Array(a).buffer);
}

public inline static function fastGet( b : BytesData, pos : Int ) : Int {
Expand Down
16 changes: 8 additions & 8 deletions std/js/_std/haxe/io/BytesBuffer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ package haxe.io;
@:coreApi
class BytesBuffer {

var buffer : js.html.ArrayBuffer;
var view : js.html.DataView;
var u8 : js.html.Uint8Array;
var buffer : js.lib.ArrayBuffer;
var view : js.lib.DataView;
var u8 : js.lib.Uint8Array;
var pos : Int;
var size : Int;

Expand All @@ -49,7 +49,7 @@ class BytesBuffer {
public function add( src : Bytes ) : Void {
if( pos + src.length > size ) grow(src.length);
if( size == 0 ) return;
var sub = new js.html.Uint8Array(@:privateAccess src.b.buffer, @:privateAccess src.b.byteOffset, src.length);
var sub = new js.lib.Uint8Array(@:privateAccess src.b.buffer, @:privateAccess src.b.byteOffset, src.length);
u8.set(sub, pos);
pos += src.length;
}
Expand Down Expand Up @@ -87,7 +87,7 @@ class BytesBuffer {
if( pos < 0 || len < 0 || pos + len > src.length ) throw Error.OutsideBounds;
if( this.pos + len > size ) grow(len);
if( size == 0 ) return;
var sub = new js.html.Uint8Array(@:privateAccess src.b.buffer, @:privateAccess src.b.byteOffset + pos, len);
var sub = new js.lib.Uint8Array(@:privateAccess src.b.buffer, @:privateAccess src.b.byteOffset + pos, len);
u8.set(sub, this.pos);
this.pos += len;
}
Expand All @@ -97,14 +97,14 @@ class BytesBuffer {
var nsize = size == 0 ? 16 : size;
while( nsize < req )
nsize = (nsize * 3) >> 1;
var nbuf = new js.html.ArrayBuffer(nsize);
var nu8 = new js.html.Uint8Array(nbuf);
var nbuf = new js.lib.ArrayBuffer(nsize);
var nu8 = new js.lib.Uint8Array(nbuf);
if( size > 0 )
nu8.set(u8);
size = nsize;
buffer = nbuf;
u8 = nu8;
view = new js.html.DataView(buffer);
view = new js.lib.DataView(buffer);
}

public function getBytes() : Bytes @:privateAccess {
Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/haxe/io/Float32Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.io;

typedef Float32ArrayData = js.html.Float32Array;
typedef Float32ArrayData = js.lib.Float32Array;

@:coreApi
abstract Float32Array(Float32ArrayData) {
Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/haxe/io/Float64Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.io;

typedef Float64ArrayData = js.html.Float64Array;
typedef Float64ArrayData = js.lib.Float64Array;

@:coreApi
abstract Float64Array(Float64ArrayData) {
Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/haxe/io/Int32Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.io;

typedef Int32ArrayData = js.html.Int32Array;
typedef Int32ArrayData = js.lib.Int32Array;

@:coreApi
abstract Int32Array(Int32ArrayData) {
Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/haxe/io/UInt16Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.io;

typedef UInt16ArrayData = js.html.Uint16Array;
typedef UInt16ArrayData = js.lib.Uint16Array;

@:coreApi
abstract UInt16Array(UInt16ArrayData) {
Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/haxe/io/UInt32Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.io;

typedef UInt32ArrayData = js.html.Uint32Array;
typedef UInt32ArrayData = js.lib.Uint32Array;

@:coreApi
abstract UInt32Array(UInt32ArrayData) {
Expand Down
2 changes: 1 addition & 1 deletion std/js/_std/haxe/io/UInt8Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
package haxe.io;

typedef UInt8ArrayData = js.html.Uint8Array;
typedef UInt8ArrayData = js.lib.Uint8Array;

@:coreApi
abstract UInt8Array(UInt8ArrayData) {
Expand Down
31 changes: 1 addition & 30 deletions std/js/html/ArrayBuffer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,6 @@
* DEALINGS IN THE SOFTWARE.
*/

// This file is generated from typedarray.webidl. Do not edit!

package js.html;

@:native("ArrayBuffer")
extern class ArrayBuffer {
static function isView( value : Dynamic ) : Bool;
var byteLength(default,null) : Int;

/** @throws DOMError */
function new( length : Int ) : Void;
function slice( begin : Int, ?end : Int ) : ArrayBuffer;
}

#if (js_es <= 5)
@:ifFeature('js.html.ArrayBuffer.slice')
private class ArrayBufferCompat {

static function sliceImpl(begin, ?end) {
var u = new js.html.Uint8Array(js.Lib.nativeThis, begin, end == null ? null : (end - begin));
var resultArray = new js.html.Uint8Array(u.byteLength);
resultArray.set(u);
return resultArray.buffer;
}

static function __init__(): Void untyped {
// IE10 ArrayBuffer.slice polyfill
if( __js__("ArrayBuffer").prototype.slice == null ) __js__("ArrayBuffer").prototype.slice = sliceImpl;
}

}
#end
@:deprecated typedef ArrayBuffer = js.lib.ArrayBuffer;
16 changes: 1 addition & 15 deletions std/js/html/ArrayBufferView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@
* DEALINGS IN THE SOFTWARE.
*/

// This file is generated from typedarray.webidl. Do not edit!

package js.html;

/**
`ArrayBufferView` is a helper type representing any of the following JavaScript `TypedArray` types:

Documentation [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).

@see <https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView>
**/
extern interface ArrayBufferView {
var buffer(default,null) : ArrayBuffer;
var byteOffset(default,null) : Int;
var byteLength(default,null) : Int;

}
@:deprecated typedef ArrayBufferView = js.lib.ArrayBufferView;
2 changes: 1 addition & 1 deletion std/js/html/Blob.hx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extern class Blob
var type(default,null) : String;

/** @throws DOMError */
function new( ?blobParts : Array<haxe.extern.EitherType<ArrayBuffer,haxe.extern.EitherType<ArrayBufferView,haxe.extern.EitherType<Blob,String>>>>, ?options : BlobPropertyBag ) : Void;
function new( ?blobParts : Array<haxe.extern.EitherType<js.lib.ArrayBuffer,haxe.extern.EitherType<js.lib.ArrayBufferView,haxe.extern.EitherType<Blob,String>>>>, ?options : BlobPropertyBag ) : Void;

/**
Returns a new `Blob` object containing the data in the specified range of bytes of the source `Blob`.
Expand Down
2 changes: 1 addition & 1 deletion std/js/html/Crypto.hx
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ extern class Crypto {
Fills the passed `TypedArray` with cryptographically sound random values.
@throws DOMError
**/
function getRandomValues( array : ArrayBufferView ) : ArrayBufferView;
function getRandomValues( array : js.lib.ArrayBufferView ) : js.lib.ArrayBufferView;
}
4 changes: 2 additions & 2 deletions std/js/html/DOMMatrix.hx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ extern class DOMMatrix extends DOMMatrixReadOnly {
@:overload( function() : Void {} )
@:overload( function( transformList : String ) : Void {} )
@:overload( function( other : DOMMatrixReadOnly ) : Void {} )
@:overload( function( array32 : Float32Array ) : Void {} )
@:overload( function( array64 : Float64Array ) : Void {} )
@:overload( function( array32 : js.lib.Float32Array ) : Void {} )
@:overload( function( array64 : js.lib.Float64Array ) : Void {} )
function new( numberSequence : Array<Float> ) : Void;
function multiplySelf( other : DOMMatrix ) : DOMMatrix;
function preMultiplySelf( other : DOMMatrix ) : DOMMatrix;
Expand Down
4 changes: 2 additions & 2 deletions std/js/html/DOMMatrixReadOnly.hx
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ extern class DOMMatrixReadOnly {
Returns a `Float32Array` containing the 6 components (`a`, `b`, `c`, `d`, `e`, `f`) in the case of a 2D matrix or the 16 components (`m11`, `m12`, `m13`, `m14`, `m21`, `m22`, `m23`, `m24`, `m31`, `m32`, `m33`, `m34`, `m41`, `m42`, `m43`, `m44`) for a 3D matrix.
@throws DOMError
**/
function toFloat32Array() : Float32Array;
function toFloat32Array() : js.lib.Float32Array;

/**
Returns a `Float64Array` containing the 6 components (`a`, `b`, `c`, `d`, `e`, `f`) in the case of a 2D matrix or the 16 components (`m11`, `m12`, `m13`, `m14`, `m21`, `m22`, `m23`, `m24`, `m31`, `m32`, `m33`, `m34`, `m41`, `m42`, `m43`, `m44`) for a 3D matrix.
@throws DOMError
**/
function toFloat64Array() : Float64Array;
function toFloat64Array() : js.lib.Float64Array;

/**
Returns a JSON representation of the `DOMMatrixReadOnly` object.
Expand Down
36 changes: 1 addition & 35 deletions std/js/html/DataView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,6 @@
* DEALINGS IN THE SOFTWARE.
*/

// This file is generated from typedarray.webidl. Do not edit!

package js.html;

@:native("DataView")
extern class DataView implements ArrayBufferView {
var buffer(default,null) : ArrayBuffer;
var byteOffset(default,null) : Int;
var byteLength(default,null) : Int;

/** @throws DOMError */
function new( buffer : ArrayBuffer, ?byteOffset : Int, ?byteLength : Int ) : Void;
@:pure
function getInt8( byteOffset : Int ) : Int;
@:pure
function getUint8( byteOffset : Int ) : Int;
@:pure
function getInt16( byteOffset : Int, ?littleEndian : Bool ) : Int;
@:pure
function getUint16( byteOffset : Int, ?littleEndian : Bool ) : Int;
@:pure
function getInt32( byteOffset : Int, ?littleEndian : Bool ) : Int;
@:pure
function getUint32( byteOffset : Int, ?littleEndian : Bool ) : Int;
@:pure
function getFloat32( byteOffset : Int, ?littleEndian : Bool ) : Float;
@:pure
function getFloat64( byteOffset : Int, ?littleEndian : Bool ) : Float;
function setInt8( byteOffset : Int, value : Int ) : Void;
function setUint8( byteOffset : Int, value : Int ) : Void;
function setInt16( byteOffset : Int, value : Int, ?littleEndian : Bool ) : Void;
function setUint16( byteOffset : Int, value : Int, ?littleEndian : Bool ) : Void;
function setInt32( byteOffset : Int, value : Int, ?littleEndian : Bool ) : Void;
function setUint32( byteOffset : Int, value : Int, ?littleEndian : Bool ) : Void;
function setFloat32( byteOffset : Int, value : Float, ?littleEndian : Bool ) : Void;
function setFloat64( byteOffset : Int, value : Float, ?littleEndian : Bool ) : Void;
}
@:deprecated typedef DataView = js.lib.DataView;
2 changes: 1 addition & 1 deletion std/js/html/File.hx
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ extern class File extends Blob {
var lastModified(default,null) : Int;

/** @throws DOMError */
function new( fileBits : Array<haxe.extern.EitherType<haxe.extern.EitherType<ArrayBufferView,ArrayBuffer>,haxe.extern.EitherType<Blob,String>>>, fileName : String, ?options : FilePropertyBag ) : Void;
function new( fileBits : Array<haxe.extern.EitherType<haxe.extern.EitherType<js.lib.ArrayBufferView,js.lib.ArrayBuffer>,haxe.extern.EitherType<Blob,String>>>, fileName : String, ?options : FilePropertyBag ) : Void;
}
2 changes: 1 addition & 1 deletion std/js/html/FileReaderSync.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern class FileReaderSync {
/** @throws DOMError */
function new() : Void;
/** @throws DOMError */
function readAsArrayBuffer( blob : Blob ) : ArrayBuffer;
function readAsArrayBuffer( blob : Blob ) : js.lib.ArrayBuffer;
/** @throws DOMError */
function readAsBinaryString( blob : Blob ) : String;
/** @throws DOMError */
Expand Down
Loading