diff --git a/src/tink/pure/List.hx b/src/tink/pure/List.hx index 4fa5f84..e78cf38 100644 --- a/src/tink/pure/List.hx +++ b/src/tink/pure/List.hx @@ -2,7 +2,7 @@ package tink.pure; using tink.CoreApi; -@:enum abstract FilterResult(Int) { +enum abstract FilterResult(Int) { var ExcludeAndStop = -3; var Exclude = 0; var Include = 1; diff --git a/src/tink/pure/Mapping.hx b/src/tink/pure/Mapping.hx index 996800a..020826e 100644 --- a/src/tink/pure/Mapping.hx +++ b/src/tink/pure/Mapping.hx @@ -12,9 +12,9 @@ private typedef MapEntry = { } @:pure abstract Mapping(List>) from List> to List> { - - @:extern public inline function new(?init:HaxeMap) this = init == null ? null : ofMutable(init); - + + extern public inline function new(?init:HaxeMap) this = init == null ? null : ofMutable(init); + /** Returns true if `key` has a mapping, false otherwise. **/ @@ -51,37 +51,37 @@ private typedef MapEntry = { public function with(key:K, value:V):Mapping return this.prepend({ key: key, isset: true, value: value, condensed: null }); - @:extern inline function alloc():HaxeMap return new HaxeMap(); + extern inline function alloc():HaxeMap return new HaxeMap(); //Everything beyond this point is for the brave /** * Returns an Iterator over the values of `this` Mapping. */ - @:extern inline public function iterator() + extern inline public function iterator() return getCondensed().or(alloc).iterator(); #if haxe4 /** * Returns an KeyValueIterator over the values of `this` Mapping. */ - @:extern inline public function keyValueIterator() + extern inline public function keyValueIterator() return getCondensed().or(alloc).keyValueIterator(); #end /** * Returns an Iterator over the keys of `this` Mapping. */ - @:extern inline public function keys() + extern inline public function keys() return getCondensed().or(alloc).keys(); - @:to @:extern inline public function condensed():Mapping + @:to extern inline public function condensed():Mapping return switch getCondensed() { case None: null; case Some(v): v; } - @:to @:extern inline function getCondensed() { + @:to extern inline function getCondensed() { return switch this.first() { case None: None; case Some({ condensed: c }) if (c != null): Some(c); @@ -106,13 +106,13 @@ private typedef MapEntry = { } } - @:to @:extern inline function toMutable():HaxeMap + @:to extern inline function toMutable():HaxeMap return getCondensed().map(function (m) return merge([m])).or(alloc); - @:extern inline static function merge(a:Array>) + extern inline static function merge(a:Array>) return [for (m in a) for (k in m.keys()) k => m[k]]; - @:from @:extern inline static function ofMutable(v:HaxeMap):Mapping { + @:from extern inline static function ofMutable(v:HaxeMap):Mapping { var ret = new List>(); return @@ -121,18 +121,18 @@ private typedef MapEntry = { else ret; } - @:op(a + b) @:extern inline static function rAddMutable(m:Mapping, other:HaxeMap):Mapping + @:op(a + b) extern inline static function rAddMutable(m:Mapping, other:HaxeMap):Mapping return merge([m, other]); - @:op(a + b) @:extern inline static function lAddMutable(other:HaxeMap, m:Mapping):Mapping + @:op(a + b) extern inline static function lAddMutable(other:HaxeMap, m:Mapping):Mapping return merge([other, m]); #if tink_json - @:extern @:to inline function toRepresentation():tink.json.Representation> + @:to extern inline function toRepresentation():tink.json.Representation> return new tink.json.Representation(toMutable()); - @:extern @:from inline static function ofRepresentation(rep:tink.json.Representation>):Mapping { + @:from extern inline static function ofRepresentation(rep:tink.json.Representation>):Mapping { var v = rep.get(); // The following is actually a copy of `ofMutable`, using `ofMutable` directly will cause a invalid reference because the function is actually not generated var ret = new List>(); diff --git a/src/tink/pure/Slice.hx b/src/tink/pure/Slice.hx index bae9eb9..5648192 100644 --- a/src/tink/pure/Slice.hx +++ b/src/tink/pure/Slice.hx @@ -6,7 +6,7 @@ import tink.Slice as MSlice; @:pure @:jsonParse(a -> tink.pure.Slice.ofArray(a)) @:jsonStringify(slice -> [for (x in slice) x]) -abstract Slice(MSlice) to MSlice to Iterable { +abstract Slice(MSlice) to MSlice { inline function new(v:MSlice) this = v; @@ -32,4 +32,5 @@ abstract Slice(MSlice) to MSlice to Iterable { @:from static public inline function ofVector(v:haxe.ds.Vector) return make(v); + @:to inline function toIterable() return (this: Iterable); }