Skip to content

Commit 2a81f68

Browse files
authored
[hl/std] Fix compilation with hl_legacy32 / hl ver 1.12 (#12401)
1 parent efa61f2 commit 2a81f68

File tree

6 files changed

+88
-10
lines changed

6 files changed

+88
-10
lines changed

std/haxe/ds/Int64Map.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Int64Map<T> implements haxe.Constraints.IMap<haxe.Int64, T> {
3434
var m : Map<String,T>;
3535

3636
/**
37-
Creates a new IntMap.
37+
Creates a new Int64Map.
3838
**/
3939
public function new():Void {
4040
m = new Map();

std/hl/_std/haxe/Int64.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ abstract Int64(__Int64) from __Int64 to __Int64 {
312312
public static inline function toStr(x:Int64):String
313313
return x.toString();
314314

315-
function toString():String {
315+
public function toString():String {
316316
var i:Int64 = cast this;
317317
if (i == 0)
318318
return "0";

std/hl/_std/haxe/ds/Int64Map.hx

Lines changed: 74 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
package haxe.ds;
2424

25+
#if (hl_ver >= version("1.13.0") && !hl_legacy32)
26+
2527
@:coreApi
2628
class Int64Map<T> implements haxe.Constraints.IMap<haxe.Int64, T> {
2729
var h:hl.types.Int64Map;
@@ -82,18 +84,82 @@ class Int64Map<T> implements haxe.Constraints.IMap<haxe.Int64, T> {
8284
}
8385

8486
public function clear():Void {
85-
#if (hl_ver >= version("1.11.0"))
8687
@:privateAccess h.clear();
87-
#else
88-
h = new hl.types.Int64Map();
89-
#end
9088
}
9189

9290
public function size():Int {
93-
#if (hl_ver >= version("1.12.0"))
9491
return h.size();
95-
#else
96-
return h.keysArray().length;
97-
#end
9892
}
9993
}
94+
95+
#else
96+
97+
// Same as haxe.ds.Int64Map
98+
class Int64Map<T> implements haxe.Constraints.IMap<haxe.Int64, T> {
99+
var m : Map<String,T>;
100+
101+
public function new():Void {
102+
m = new Map();
103+
}
104+
105+
public function set(key:Int64, value:T):Void {
106+
m.set(key.toString(),value);
107+
}
108+
109+
public function get(key:Int64):Null<T> {
110+
return m.get(key.toString());
111+
}
112+
113+
public function exists(key:Int64):Bool {
114+
return m.exists(key.toString());
115+
}
116+
117+
public function remove(key:Int64):Bool {
118+
return m.remove(key.toString());
119+
}
120+
121+
public function keys():Iterator<Int64> {
122+
var it = m.keys();
123+
return {
124+
hasNext : () -> it.hasNext(),
125+
next: () -> {
126+
return haxe.Int64.parseString(it.next());
127+
}
128+
};
129+
}
130+
131+
public function iterator():Iterator<T> {
132+
return m.iterator();
133+
}
134+
135+
public function keyValueIterator():KeyValueIterator<Int64, T> {
136+
var it = m.keyValueIterator();
137+
return {
138+
hasNext : () -> it.hasNext(),
139+
next : () -> {
140+
var v = it.next();
141+
return { key : haxe.Int64.parseString(v.key), value : v.value };
142+
}
143+
};
144+
}
145+
146+
public function copy():Int64Map<T> {
147+
var v = new Int64Map();
148+
v.m = m.copy();
149+
return v;
150+
}
151+
152+
public function toString():String {
153+
return m.toString();
154+
}
155+
156+
public function clear():Void {
157+
m.clear();
158+
}
159+
160+
public function size():Int {
161+
return m.size();
162+
}
163+
}
164+
165+
#end

std/hl/types/ArrayDyn.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class ArrayDyn extends ArrayAccess {
228228
allowReinterpret = false;
229229
return arr;
230230
}
231+
#if (hl_ver >= version("1.13.0") && !hl_legacy32)
231232
if (t == Type.get((null : ArrayBytes.ArrayI64))) {
232233
var a:BytesAccess<I64> = null;
233234
a = new Bytes(array.length << a.sizeBits);
@@ -238,6 +239,7 @@ class ArrayDyn extends ArrayAccess {
238239
allowReinterpret = false;
239240
return arr;
240241
}
242+
#end
241243
return null;
242244
}
243245

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Main {
2+
static function main() {
3+
var m = new Map();
4+
m.set("a", 0);
5+
trace(m);
6+
}
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--main Main
2+
-D hl_ver=1.12.0
3+
--hl out/main.hl

0 commit comments

Comments
 (0)