diff --git a/src/generators/genhl.ml b/src/generators/genhl.ml index 06b29a4d7d0..9037d329d63 100644 --- a/src/generators/genhl.ml +++ b/src/generators/genhl.ml @@ -2056,6 +2056,11 @@ and eval_expr ctx e = op ctx (ONullCheck a); op ctx (OField (r,a,1)); r + | TAbstract ({ a_path = ["hl"],"NativeArray" },[t]) when is_number (to_type ctx t) -> + let a = eval_expr ctx a in + let r = alloc_tmp ctx HBytes in + op ctx (OUnsafeCast(r,a)); + r | t -> abort ("Invalid array type " ^ s_type (print_context()) t) a.epos) | "$ref", [v] -> diff --git a/std/haxe/ds/Vector.hx b/std/haxe/ds/Vector.hx index f361b715556..4b130c61863 100644 --- a/std/haxe/ds/Vector.hx +++ b/std/haxe/ds/Vector.hx @@ -232,7 +232,7 @@ abstract Vector(VectorData) { #else var a = new Array(); var len = length; - #if (neko) + #if (neko || hl) // prealloc good size if (len > 0) a[len - 1] = get(0); diff --git a/std/hl/Bytes.hx b/std/hl/Bytes.hx index cfd85305642..b18d1c02b4c 100644 --- a/std/hl/Bytes.hx +++ b/std/hl/Bytes.hx @@ -211,6 +211,10 @@ package hl; return untyped $abytes(a); } + extern public static inline function getNativeArray(a:hl.NativeArray):Bytes { + return untyped $abytes(a); + } + @:from public static inline function fromBytes(bytes:haxe.io.Bytes) { return @:privateAccess bytes.b;