Skip to content

Commit 01153db

Browse files
author
Misha Vakulich
committed
fix for haxe 3.1
1 parent 1937340 commit 01153db

File tree

6 files changed

+27
-18
lines changed

6 files changed

+27
-18
lines changed

src/Dynamics.hx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import thx.culture.Culture;
22
import thx.error.Error;
3+
import haxe.Constraints;
34

45
/**
56
* ...
@@ -266,10 +267,10 @@ class Dynamics
266267
return untyped a.getTime() == b.getTime();
267268

268269
// hash, inthash
269-
if (Std.is(a, Hash) || Std.is(a, IntHash))
270+
if (Std.is(a, IMap))
270271
{
271-
var ha : Hash<Dynamic> = cast a,
272-
hb : Hash<Dynamic> = cast b;
272+
var ha : Map<Dynamic, Dynamic> = cast a,
273+
hb : Map<Dynamic, Dynamic> = cast b;
273274
var ka = Iterators.array(ha.keys()),
274275
kb = Iterators.array(hb.keys());
275276
if (ka.length != kb.length)

src/Ints.hx

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,5 @@ class Ints
109109
return Std.parseInt(s);
110110
}
111111

112-
inline public static function compare(a : Int, b : Int) return a - b
112+
inline public static function compare(a : Int, b : Int) return a - b;
113113
}

src/Objects.hx

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ class Objects
5959
return ob;
6060
}
6161

62-
public static function toHash<T>(ob : {}) : Hash<T>
62+
public static function toHash<T>(ob : {}) : Map<String, T>
6363
{
64-
var hash = new Hash();
64+
var hash = new Map<String, T>();
6565
return copyToHash(ob, hash);
6666
}
6767

68-
public static function copyToHash<T>(ob : {}, hash : Hash<T>) : Hash<T>
68+
public static function copyToHash<T>(ob : {}, hash : Map<String, T>) : Map<String, T>
6969
{
7070
for (field in Reflect.fields(ob))
7171
hash.set(field, Reflect.field(ob, field));
@@ -123,7 +123,7 @@ class Objects
123123
return dst;
124124
}
125125

126-
public static function clone<T>(src : T) : T
126+
public static function clone<T:{}>(src : T) : T
127127
{
128128
var dst = { };
129129
return cast copyTo(src, dst);

src/Strings.hx

+7-7
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ C Concats the elements of the list
107107
Other things to do. Nested placeholders
108108
</pre>
109109
*/
110-
public static function format(pattern : String, values : Array<Dynamic>, nullstring = 'null', ?culture : Culture) {
110+
public static function format(pattern : String, values : Array<Dynamic>, nullstring = 'null', ?culture : Culture): String {
111111
if (null == values || 0 == values.length)
112112
return pattern;
113113
return formatf(pattern, nullstring, culture)(values);
@@ -140,14 +140,14 @@ Other things to do. Nested placeholders
140140
var left = _reFormat.matchedLeft();
141141
buf.push(function(_) return left);
142142
var df = Dynamics.formatf(format, params, nullstring, culture);
143-
buf.push(callback(function(i : Int, v : Array<Dynamic>) return df(v[i]), pos));
143+
buf.push((function(i : Int, v : Array<Dynamic>):String return df(v[i])).bind(pos, _));
144144
pattern = _reFormat.matchedRight();
145145
}
146-
return function(values : Array<Dynamic>)
146+
return function(values : Array<Dynamic>) : String
147147
{
148148
if (null == values)
149149
values = [];
150-
return buf.map(function(df,_) return df(values)).join("");
150+
return buf.map(function(df) return df(values)).join("");
151151
}
152152
}
153153

@@ -287,7 +287,7 @@ Other things to do. Nested placeholders
287287

288288
public static function ucwords(value : String) : String
289289
{
290-
return __ucwordsPattern.customReplace(ucfirst(value), __upperMatch);
290+
return __ucwordsPattern.map(ucfirst(value), __upperMatch);
291291
}
292292

293293
/**
@@ -300,7 +300,7 @@ Other things to do. Nested placeholders
300300
#if php
301301
return untyped __call__("ucwords", value);
302302
#else
303-
return __ucwordswsPattern.customReplace(ucfirst(value), __upperMatch);
303+
return __ucwordswsPattern.map(ucfirst(value), __upperMatch);
304304
#end
305305
}
306306

@@ -561,5 +561,5 @@ Other things to do. Nested placeholders
561561
}
562562
}
563563

564-
public static function compare(a : String, b : String) return a < b ? -1 : a > b ? 1 : 0
564+
public static function compare(a : String, b : String) return a < b ? -1 : a > b ? 1 : 0;
565565
}

src/thx/culture/FormatParams.hx

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package thx.culture;
2-
2+
import Lambda;
33
/**
44
* ...
55
* @author Franco Ponticelli
@@ -29,8 +29,16 @@ class FormatParams
2929
return [alt];
3030
if (null == ps || ps.length == 0)
3131
{
32+
3233
var parts = p.split(":");
33-
return [parts[0]].concat(parts.length == 1 ? [] : parts[1].split(",").map(function(s, i) if (0 == i) return s else return cleanQuotes(s)));
34+
if (parts.length > 1) {
35+
var mapFunc = (function(i, s): String if (0 == i) return s else return cleanQuotes(s));
36+
var rest = Lambda.mapi(parts[1].split(","), mapFunc);
37+
return [parts[0]].concat(Lambda.array(rest));
38+
} else {
39+
return [parts[0]];
40+
}
41+
3442
}
3543
return ps;
3644
}

src/thx/translation/ITranslation.hx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package thx.translation;
22

33
interface ITranslation
44
{
5-
public var domain(getDomain, setDomain) : String;
5+
public var domain(get_domain, set_domain) : String;
66
public function singular(id : String, ?domain : String) : String;
77
public function plural(ids : String, idp : String, quantifier : Int, ?domain : String) : String;
88
}

0 commit comments

Comments
 (0)