Przeglądaj źródła

[python] clean up NativeIterable/NativeIterator stuff (nonsense type params, static @:to, inlines)

Dan Korostelev 11 lat temu
rodzic
commit
c29a90d239
2 zmienionych plików z 7 dodań i 10 usunięć
  1. 4 6
      std/python/NativeIterable.hx
  2. 3 4
      std/python/NativeIterator.hx

+ 4 - 6
std/python/NativeIterable.hx

@@ -5,14 +5,12 @@ import python.HaxeIterable;
 import python.NativeIterator;
 
 abstract NativeIterable <T>(NativeIterableRaw<T>) to NativeIterableRaw<T> from NativeIterableRaw<T> {
-	@:to public static inline function toHaxeIterable <T>(p:NativeIterableRaw<T>):HaxeIterable<T> return new HaxeIterable(p);
+	@:to public inline function toHaxeIterable():HaxeIterable<T> return new HaxeIterable(this);
 
-	//@:from public static inline function fromArray <T>(p:Array<T>):PyIterable<T> return cast p;
+	public inline function iterator():HaxeIterator<T> return toHaxeIterable().iterator();
 
-	public inline function iterator <T>():HaxeIterator<T> return toHaxeIterable().iterator();
-
-	public function getNativeIterable <T>():NativeIterableRaw<T> return this;
-	public function getNativeIterator <T>():NativeIteratorRaw<T> return this.__iter__();
+	public inline function getNativeIterable():NativeIterableRaw<T> return this;
+	public inline function getNativeIterator():NativeIteratorRaw<T> return this.__iter__();
 
 }
 typedef NativeIterableRaw<T> = {

+ 3 - 4
std/python/NativeIterator.hx

@@ -6,14 +6,13 @@ import python.NativeIterable.NativeIterableRaw;
 abstract NativeIterator <T>(NativeIteratorRaw<T>) to NativeIteratorRaw<T> to NativeIterable<T> {
 	public inline function new (p:NativeIteratorRaw<T>) this = p;
 
-	@:to public static inline function toHaxeIterator <T>(p:NativeIteratorRaw<T>):HaxeIterator<T> return new HaxeIterator(p);
-	@:to public static inline function toNativeIterable <T>(p:NativeIteratorRaw<T>):NativeIterable<T> return p;
+	@:to public inline function toHaxeIterator():HaxeIterator<T> return new HaxeIterator(this);
+	@:to public inline function toNativeIterable():NativeIterable<T> return this;
 
-	public function getNativeIteratorRaw <T>():NativeIteratorRaw<T> return this;
+	public inline function getNativeIteratorRaw():NativeIteratorRaw<T> return this;
 }
 
 typedef NativeIteratorRaw<T> = {
 	> NativeIterableRaw<T>,
 	function __next__ ():T;
-	//function __iter__ ():NativeIterator<T>;
 }