NativeIterator.hx 681 B

123456789101112131415161718192021222324
  1. package python;
  2. import python.NativeIterable.NativeIterableRaw;
  3. /**
  4. This type represents native python iterators.
  5. It supports automatic conversion to haxe `Iterator` by creating wrapper object.
  6. **/
  7. abstract NativeIterator<T>(NativeIteratorRaw<T>) to NativeIteratorRaw<T> to NativeIterable<T> {
  8. public inline function new(p:NativeIteratorRaw<T>) this = p;
  9. /**
  10. Return haxe `Iterator` object by wrapping `this` native iterator.
  11. **/
  12. @:to public inline function toHaxeIterator():HaxeIterator<T> return new HaxeIterator(this);
  13. }
  14. /**
  15. Native python iterator protocol.
  16. **/
  17. typedef NativeIteratorRaw<T> = {
  18. >NativeIterableRaw<T>,
  19. function __next__():T;
  20. }