Skip to content

Commit

Permalink
[js] guard against including js.html.compat stuff when -D nodejs (see H…
Browse files Browse the repository at this point in the history
  • Loading branch information
nadako authored and delahee committed Nov 8, 2015
1 parent a309bd2 commit aa3747d
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 5 deletions.
4 changes: 4 additions & 0 deletions std/js/_std/haxe/io/ArrayBufferView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ abstract ArrayBufferView(ArrayBufferViewData) {

public static var EMULATED(get,never) : Bool;
static inline function get_EMULATED() {
#if nodejs
return false;
#else
return (cast js.html.ArrayBuffer) == js.html.compat.ArrayBuffer;
#end
}

public var buffer(get,never) : haxe.io.Bytes;
Expand Down
3 changes: 3 additions & 0 deletions std/js/_std/haxe/io/Bytes.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
* DEALINGS IN THE SOFTWARE.
*/
package haxe.io;

#if !nodejs
import js.html.compat.Uint8Array;
import js.html.compat.DataView;
#end

@:coreApi
class Bytes {
Expand Down
2 changes: 2 additions & 0 deletions std/js/_std/haxe/io/Float32Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
*/
package haxe.io;

#if !nodejs
import js.html.compat.Float32Array;
#end

typedef Float32ArrayData = js.html.Float32Array;

Expand Down
2 changes: 2 additions & 0 deletions std/js/_std/haxe/io/Float64Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
*/
package haxe.io;

#if !nodejs
import js.html.compat.Float64Array;
#end

typedef Float64ArrayData = js.html.Float64Array;

Expand Down
4 changes: 3 additions & 1 deletion std/js/html/compat/ArrayBuffer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
package js.html.compat;

#if !nodejs
@:keep
class ArrayBuffer {

Expand Down Expand Up @@ -56,4 +57,5 @@ class ArrayBuffer {
var ArrayBuffer = js.Lib.global.ArrayBuffer || js.html.compat.ArrayBuffer;
if( ArrayBuffer.prototype.slice == null ) ArrayBuffer.prototype.slice = sliceImpl; // IE10
}
}
}
#end
5 changes: 4 additions & 1 deletion std/js/html/compat/DataView.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*/
package js.html.compat;

#if !nodejs
import haxe.io.Error;

@:ifFeature("haxe.io.Float32Array.*", "haxe.io.Float64Array.*")
Expand Down Expand Up @@ -141,4 +143,5 @@ class DataView {
var DataView = untyped js.Lib.global.DataView || js.html.compat.DataView;
}

}
}
#end
4 changes: 3 additions & 1 deletion std/js/html/compat/Float32Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
package js.html.compat;

#if !nodejs
@:keep
class Float32Array {

Expand Down Expand Up @@ -106,4 +107,5 @@ class Float32Array {
var Float32Array = untyped js.Lib.global.Float32Array || _new;
}

}
}
#end
4 changes: 3 additions & 1 deletion std/js/html/compat/Float64Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
package js.html.compat;

#if !nodejs
@:keep
class Float64Array {

Expand Down Expand Up @@ -113,4 +114,5 @@ class Float64Array {
var Float64Array = untyped js.Lib.global.Float64Array || (js.Lib.global.Float32Array ? 'notsupported' : null) || _new;
}

}
}
#end
4 changes: 3 additions & 1 deletion std/js/html/compat/Uint8Array.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
package js.html.compat;

#if !nodejs
@:keep
class Uint8Array {

Expand Down Expand Up @@ -97,4 +98,5 @@ class Uint8Array {
var Uint8Array = untyped js.Lib.global.Uint8Array || _new;
}

}
}
#end

0 comments on commit aa3747d

Please sign in to comment.