Bläddra i källkod

rewrite FileInput and FileOutput

frabbit 11 år sedan
förälder
incheckning
fbd40276db

+ 3 - 3
std/python/_std/Sys.hx

@@ -122,15 +122,15 @@ class Sys {
 	}
 
 	public static function stdin() : haxe.io.Input {
-		return new FileInput(cast python.lib.Sys.stdin.buffer);
+		return python.io.IoTools.createFileInputFromText(python.lib.Sys.stdin);
 	}
 
 	public static function stdout() : haxe.io.Output {
-		return new FileOutput(cast python.lib.Sys.stdout.buffer);
+		return python.io.IoTools.createFileOutputFromText(python.lib.Sys.stdout);
 	}
 
 	public static function stderr() : haxe.io.Output {
-		return new FileOutput(cast python.lib.Sys.stderr.buffer);
+		return python.io.IoTools.createFileOutputFromText(python.lib.Sys.stderr);
 	}
 
 

+ 10 - 7
std/python/_std/sys/io/File.hx

@@ -21,6 +21,7 @@
  */
 package sys.io;
 
+import python.io.IoTools;
 import sys.io.FileInput;
 
 /**
@@ -60,23 +61,25 @@ class File {
 	}
 
 	public static function read( path : String, binary : Bool = true ) : FileInput {
-		var mode = "rb";
-		var f:python.lib.io.RawIOBase = cast python.lib.Builtin.open(path, mode, -1);
-		return new FileInput(f);
+		var mode = if (binary) "rb" else "r";
+
+		var f = python.lib.Builtin.open(path, mode, -1);
+
+		return if (binary) IoTools.createFileInputFromBytes(cast f) else IoTools.createFileInputFromText(cast f);
 	}
 
 	public static function write( path : String, binary : Bool = true ) : FileOutput {
 		var mode = "wb";
-		var f:python.lib.io.RawIOBase = cast python.lib.Builtin.open(path, mode, -1);
+		var f = python.lib.Builtin.open(path, mode, -1);
 
-		return new FileOutput(f);
+		return if (binary) IoTools.createFileOutputFromBytes(cast f) else IoTools.createFileOutputFromText(cast f);
 	}
 
 	public static function append( path : String, binary : Bool = true ) : FileOutput {
 		var mode = "ab";
-		var f:python.lib.io.RawIOBase = cast python.lib.Builtin.open(path, mode, -1);
+		var f = python.lib.Builtin.open(path, mode, -1);
 
-		return new FileOutput(f);
+		return if (binary) IoTools.createFileOutputFromBytes(cast f) else IoTools.createFileOutputFromText(cast f);
 	}
 
 	public static function copy( srcPath : String, dstPath : String ) : Void

+ 96 - 8
std/python/_std/sys/io/FileInput.hx

@@ -1,17 +1,105 @@
 
 package sys.io;
 
-import python.io.NativeInput;
-import python.lib.io.RawIOBase;
-import python.lib.io.IOBase.SeekSet;
+import haxe.io.Bytes;
+import haxe.io.Input;
+import python.io.IFileInput;
 
-class FileInput extends NativeInput {
 
-	public function new (stream:RawIOBase) {
-		super(stream);
+
+class FileInput extends Input
+{
+	var impl:IFileInput;
+
+
+
+	public function new (impl:IFileInput) {
+		this.impl = impl;
+	}
+
+	override public function set_bigEndian(b:Bool) {
+		return impl.bigEndian = b;
+	}
+
+	public function seek( p : Int, pos : FileSeek ) : Void {
+		return impl.seek(p, pos);
+	}
+	public function tell() : Int {
+		return impl.tell();
+	}
+	public function eof() : Bool {
+		return impl.eof();
+	}
+
+	override public function readByte() : Int {
+		return impl.readByte();
+	}
+
+	override public function readBytes( s : Bytes, pos : Int, len : Int ) : Int {
+		return impl.readBytes(s, pos, len);
+	}
+
+	override public function close():Void {
+		impl.close();
+	}
+
+	override public function readAll( ?bufsize : Int ) : Bytes {
+		return impl.readAll(bufsize);
+	}
+
+	override public function readFullBytes( s : Bytes, pos : Int, len : Int ):Void {
+		impl.readFullBytes(s, pos, len);
+	}
+
+	override public function read( nbytes : Int ) : Bytes {
+		return impl.read(nbytes);
+	}
+
+	override public function readUntil( end : Int ) : String {
+		return impl.readUntil(end);
+	}
+
+	override public function readLine() : String {
+		return impl.readLine();
+	}
+
+	override public function readFloat() : Float {
+		return impl.readFloat();
+	}
+
+	override public function readDouble() : Float {
+		return impl.readDouble();
+	}
+
+	override public function readInt8():Int {
+		return impl.readInt8();
 	}
 
-	public function eof() {
-		return wasEof;
+	override public function readInt16():Int {
+		return impl.readInt16();
 	}
+
+	override public function readUInt16():Int {
+		return impl.readUInt16();
+	}
+
+	override public function readInt24():Int {
+		return impl.readInt24();
+	}
+
+	override public function readUInt24():Int {
+		return impl.readUInt24();
+	}
+
+	override public function readInt32():Int {
+		return impl.readInt32();
+	}
+
+	override public function readString( len : Int ) : String {
+		return impl.readString(len);
+	}
+
+
+
+
 }

+ 89 - 5
std/python/_std/sys/io/FileOutput.hx

@@ -1,11 +1,95 @@
-
 package sys.io;
 
-import python.lib.io.RawIOBase;
+import haxe.io.Bytes;
+import haxe.io.Input;
+import haxe.io.Output;
+import python.io.IFileOutput;
+
+class FileOutput extends Output {
+
+	var impl:IFileOutput;
+
+	public function new (impl:IFileOutput) {
+		this.impl = impl;
+	}
+
+	public function seek( p : Int, pos : FileSeek ) : Void {
+		return impl.seek(p, pos);
+	}
+
+	public function tell() : Int {
+		return impl.tell();
+	}
+
+	override public function set_bigEndian(b:Bool) {
+		return impl.bigEndian = b;
+	}
+
+	override public function writeByte( c : Int ) : Void {
+		impl.writeByte(c);
+	}
+
+	override public function writeBytes( s : Bytes, pos : Int, len : Int ):Int {
+		return impl.writeBytes(s,pos,len);
+	}
+
+	override public function flush():Void {
+		impl.flush();
+	}
+
+	override public function close():Void {
+		impl.close();
+	}
+
+	override public function write( s : Bytes ) : Void {
+		impl.write(s);
+	}
+
+	override public function writeFullBytes( s : Bytes, pos : Int, len : Int ):Void {
+		impl.writeFullBytes(s,pos,len);
+	}
+
+	override public function writeFloat( x : Float ):Void {
+		impl.writeFloat(x);
+	}
+
+	override public function writeDouble( x : Float ):Void {
+		impl.writeDouble(x);
+	}
 
-class FileOutput extends python.io.NativeOutput {
+	override public function writeInt8( x : Int ):Void {
+		impl.writeInt8(x);
+	}
+
+	override public function writeInt16( x : Int ):Void {
+		impl.writeInt16(x);
+	}
+
+	override public function writeUInt16( x : Int ):Void {
+		impl.writeUInt16(x);
+	}
+
+	override public function writeInt24( x : Int ):Void {
+		impl.writeInt24(x);
+	}
+
+	override public function writeUInt24( x : Int ):Void {
+		impl.writeUInt24(x);
+	}
+
+	override public function writeInt32( x : Int ):Void {
+		impl.writeInt32(x);
+	}
+
+	override public function prepare( nbytes : Int ):Void {
+		impl.prepare(nbytes);
+	}
+
+	override public function writeInput( i : Input, ?bufsize : Int ):Void {
+		impl.writeInput(i,bufsize);
+	}
 
-	public function new (stream:RawIOBase) {
-		super(stream);
+	override public function writeString( s : String ):Void {
+		impl.writeString(s);
 	}
 }

+ 14 - 0
std/python/io/FileBytesInput.hx

@@ -0,0 +1,14 @@
+
+package python.io;
+
+import python.io.NativeBytesInput;
+import python.io.NativeTextInput;
+import python.lib.io.RawIOBase;
+import python.lib.io.IOBase.SeekSet;
+import python.lib.io.TextIOBase;
+
+class FileBytesInput extends NativeBytesInput implements IFileInput {
+	public function new (stream:RawIOBase) {
+		super(stream);
+	}
+}

+ 12 - 0
std/python/io/FileBytesOutput.hx

@@ -0,0 +1,12 @@
+
+package python.io;
+
+import python.io.IFileOutput;
+import python.io.NativeBytesOutput;
+import python.lib.io.RawIOBase;
+
+class FileBytesOutput extends NativeBytesOutput implements IFileOutput {
+	public function new (stream:RawIOBase) {
+		super(stream);
+	}
+}

+ 13 - 0
std/python/io/FileTextInput.hx

@@ -0,0 +1,13 @@
+package python.io;
+
+import python.io.NativeBytesInput;
+import python.io.NativeTextInput;
+import python.lib.io.RawIOBase;
+import python.lib.io.IOBase.SeekSet;
+import python.lib.io.TextIOBase;
+
+class FileTextInput extends NativeTextInput implements IFileInput {
+	public function new (stream:TextIOBase) {
+		super(stream);
+	}
+}

+ 12 - 0
std/python/io/FileTextOutput.hx

@@ -0,0 +1,12 @@
+
+package python.io;
+
+import python.io.IFileOutput;
+import python.io.NativeBytesOutput;
+import python.lib.io.TextIOBase;
+
+class FileTextOutput extends NativeTextOutput implements IFileOutput {
+	public function new (stream:TextIOBase) {
+		super(stream);
+	}
+}

+ 14 - 0
std/python/io/IFileInput.hx

@@ -0,0 +1,14 @@
+
+package python.io;
+
+import python.io.IInput;
+import sys.io.FileSeek;
+
+
+
+interface IFileInput extends IInput {
+	public function seek( p : Int, pos : FileSeek ) : Void;
+
+	public function tell() : Int;
+	public function eof() : Bool;
+}

+ 12 - 0
std/python/io/IFileOutput.hx

@@ -0,0 +1,12 @@
+
+package python.io;
+
+import python.io.IOutput;
+import sys.io.FileSeek;
+
+interface IFileOutput extends IOutput {
+
+	public function seek( p : Int, pos : FileSeek ) : Void;
+	public function tell() : Int;
+
+}

+ 43 - 0
std/python/io/IInput.hx

@@ -0,0 +1,43 @@
+
+package python.io;
+
+import haxe.io.Bytes;
+
+interface IInput
+{
+	public var bigEndian(default,set) : Bool;
+
+	public function readByte() : Int;
+
+	public function readBytes( s : Bytes, pos : Int, len : Int ) : Int;
+
+	public function close():Void;
+
+	public function readAll( ?bufsize : Int ) : Bytes;
+
+	public function readFullBytes( s : Bytes, pos : Int, len : Int ):Void;
+
+	public function read( nbytes : Int ) : Bytes;
+
+	public function readUntil( end : Int ) : String;
+
+	public function readLine() : String;
+
+	public function readFloat() : Float;
+
+	public function readDouble() : Float;
+
+	public function readInt8():Int;
+
+	public function readInt16():Int;
+
+	public function readUInt16():Int;
+
+	public function readInt24():Int;
+
+	public function readUInt24():Int;
+
+	public function readInt32():Int;
+
+	public function readString( len : Int ) : String;
+}

+ 44 - 0
std/python/io/IOutput.hx

@@ -0,0 +1,44 @@
+
+package python.io;
+
+import haxe.io.Bytes;
+import haxe.io.Input;
+
+interface IOutput {
+
+	public var bigEndian(default, set) : Bool;
+
+	public function writeByte( c : Int ) : Void;
+
+	public function writeBytes( s : Bytes, pos : Int, len : Int ):Int;
+
+	public function flush():Void;
+
+	public function close():Void;
+
+	public function write( s : Bytes ) : Void;
+
+	public function writeFullBytes( s : Bytes, pos : Int, len : Int ):Void;
+
+	public function writeFloat( x : Float ):Void;
+
+	public function writeDouble( x : Float ):Void;
+
+	public function writeInt8( x : Int ):Void;
+
+	public function writeInt16( x : Int ):Void;
+
+	public function writeUInt16( x : Int ):Void;
+
+	public function writeInt24( x : Int ):Void;
+
+	public function writeUInt24( x : Int ):Void;
+
+	public function writeInt32( x : Int ):Void;
+
+	public function prepare( nbytes : Int ):Void;
+
+	public function writeInput( i : Input, ?bufsize : Int ):Void;
+
+	public function writeString( s : String ):Void;
+}

+ 31 - 0
std/python/io/IoTools.hx

@@ -0,0 +1,31 @@
+
+package python.io;
+
+import python.io.FileBytesInput;
+import python.io.FileTextInput;
+import python.io.FileTextOutput;
+import python.io.FileBytesOutput;
+import python.lib.io.RawIOBase;
+import python.lib.io.TextIOBase;
+import sys.io.FileInput;
+import sys.io.FileOutput;
+
+class IoTools {
+
+	public static function createFileInputFromText (t:TextIOBase) {
+		return new FileInput(new FileTextInput(t));
+	}
+
+	public static function createFileInputFromBytes (t:RawIOBase) {
+		return new FileInput(new FileBytesInput(t));
+	}
+
+	public static function createFileOutputFromText (t:TextIOBase) {
+		return new FileOutput(new FileTextOutput(t));
+	}
+
+	public static function createFileOutputFromBytes (t:RawIOBase) {
+		return new FileOutput(new FileBytesOutput(t));
+	}
+
+}

+ 59 - 0
std/python/io/NativeBytesInput.hx

@@ -0,0 +1,59 @@
+
+package python.io;
+
+import haxe.io.Eof;
+import haxe.io.Input;
+
+import python.io.IInput;
+import python.lib.Builtin;
+import python.lib.io.RawIOBase;
+import python.lib.io.IOBase.SeekSet;
+
+
+class NativeBytesInput extends NativeInput<RawIOBase> implements IInput {
+
+
+	public function new (stream:RawIOBase) {
+		super(stream);
+
+	}
+
+	override public function readByte():Int
+	{
+
+		var ret = stream.read(1);
+
+		if (ret.length == 0) throwEof();
+
+		return ret.get(0);
+	}
+
+	public function seek( p : Int, pos : sys.io.FileSeek ) : Void
+	{
+		var pos = switch(pos)
+		{
+			case SeekBegin: SeekSet.SeekSet;
+			case SeekCur: SeekSet.SeekCur;
+			case SeekEnd: SeekSet.SeekEnd;
+		};
+		wasEof = false;
+		stream.seek(p, pos);
+	}
+
+
+	override public function readBytes(s:haxe.io.Bytes, pos:Int, len:Int):Int
+	{
+		if( pos < 0 || len < 0 || pos + len > s.length )
+			throw haxe.io.Error.OutsideBounds;
+
+		stream.seek(pos, python.lib.io.IOBase.SeekSet.SeekCur);
+		var ba = Builtin.bytearray(len);
+		var ret = stream.readinto(ba);
+		s.blit(pos, haxe.io.Bytes.ofData(ba) ,0,len);
+		if (ret == 0)
+			throwEof();
+		return ret;
+	}
+
+
+}

+ 53 - 0
std/python/io/NativeBytesOutput.hx

@@ -0,0 +1,53 @@
+
+package python.io;
+
+import haxe.io.Output;
+
+import python.lib.Builtin;
+import python.lib.io.IOBase;
+import python.lib.io.RawIOBase;
+
+class NativeBytesOutput extends NativeOutput<RawIOBase>{
+
+	public function new (stream:RawIOBase) {
+		super(stream);
+	}
+
+	public function seek( p : Int, pos : sys.io.FileSeek ) : Void
+	{
+		var pos = switch(pos)
+		{
+			case SeekBegin: SeekSet.SeekSet;
+			case SeekCur: SeekSet.SeekCur;
+			case SeekEnd: SeekSet.SeekEnd;
+		};
+		stream.seek(p, pos);
+	}
+
+	override public function prepare(nbytes:Int):Void
+	{
+		stream.truncate(nbytes);
+	}
+
+	override public function writeByte(c:Int):Void
+	{
+		stream.write(Builtin.bytearray([c]));
+	}
+
+	/*
+	** TODO not sure if this implementation is working
+
+	override public function writeBytes( s : haxe.io.Bytes, pos : Int, len : Int ) : Int
+	{
+		if( pos < 0 || len < 0 || pos + len > s.length )
+			throw haxe.io.Error.OutsideBounds;
+
+		var ba = s.sub(pos, len).getData();
+
+		var ret = stream.write(ba);
+
+		return ret;
+	}
+	*/
+
+}

+ 11 - 48
std/python/io/NativeInput.hx

@@ -3,25 +3,21 @@ package python.io;
 
 import haxe.io.Eof;
 import haxe.io.Input;
+import python.lib.io.IOBase;
 
-import python.lib.Builtin;
-import python.lib.io.RawIOBase;
-import python.lib.io.IOBase.SeekSet;
+class NativeInput<T:IOBase> extends Input{
 
-
-class NativeInput extends Input{
-
-	var stream:RawIOBase;
+	var stream:T;
 	var wasEof:Bool;
 
-	public var canSeek(get_canSeek, null):Bool;
-
-	public function new (stream:RawIOBase) {
-		this.stream = stream;
+	function new (s:T) {
+		this.stream = s;
 		wasEof = false;
 		if (!stream.readable()) throw "Write-only stream";
 	}
 
+	public var canSeek(get_canSeek, null):Bool;
+
 	private function get_canSeek():Bool
 	{
 		return stream.seekable();
@@ -37,45 +33,12 @@ class NativeInput extends Input{
 		return stream.tell();
 	}
 
-	override public function readByte():Int
-	{
-
-		var ret = stream.read(1);
-
-		if (ret.length == 0) throwEof();
-
-		return ret.get(0);
-	}
-
-	public function seek( p : Int, pos : sys.io.FileSeek ) : Void
-	{
-		var pos = switch(pos)
-		{
-			case SeekBegin: SeekSet.SeekSet;
-			case SeekCur: SeekSet.SeekCur;
-			case SeekEnd: SeekSet.SeekEnd;
-		};
-		wasEof = false;
-		stream.seek(p, pos);
-	}
-
-
-	override public function readBytes(s:haxe.io.Bytes, pos:Int, len:Int):Int
-	{
-		if( pos < 0 || len < 0 || pos + len > s.length )
-			throw haxe.io.Error.OutsideBounds;
-
-		stream.seek(pos, python.lib.io.IOBase.SeekSet.SeekCur);
-		var ba = Builtin.bytearray(len);
-		var ret = stream.readinto(ba);
-		s.blit(pos, haxe.io.Bytes.ofData(ba) ,0,len);
-		if (ret == 0)
-			throwEof();
-		return ret;
-	}
-
 	function throwEof() {
 		wasEof = true;
 		throw new Eof();
 	}
+
+	public function eof() {
+		return wasEof;
+	}
 }

+ 7 - 41
std/python/io/NativeOutput.hx

@@ -7,43 +7,25 @@ import python.lib.Builtin;
 import python.lib.io.IOBase;
 import python.lib.io.RawIOBase;
 
-class NativeOutput extends Output{
+class NativeOutput<T:IOBase> extends Output {
 
-	var stream:RawIOBase;
+	var stream:T;
 
 	public var canSeek(get_canSeek, null):Bool;
 
-	public function new (stream:RawIOBase) {
+	public function new (stream:T) {
 		this.stream = stream;
 		if (!stream.writable()) throw "Read only stream";
 	}
 
-	private function get_canSeek():Bool
-	{
-		return stream.seekable();
-	}
-
 	override public function close():Void
 	{
 		stream.close();
 	}
 
-	public function tell() : Int
-	{
-		return stream.tell();
-	}
-
-
-
-	public function seek( p : Int, pos : sys.io.FileSeek ) : Void
+	private function get_canSeek():Bool
 	{
-		var pos = switch(pos)
-		{
-			case SeekBegin: SeekSet.SeekSet;
-			case SeekCur: SeekSet.SeekCur;
-			case SeekEnd: SeekSet.SeekEnd;
-		};
-		stream.seek(p, pos);
+		return stream.seekable();
 	}
 
 	override public function prepare(nbytes:Int):Void
@@ -56,25 +38,9 @@ class NativeOutput extends Output{
 		stream.flush();
 	}
 
-	override public function writeByte(c:Int):Void
-	{
-		stream.write(Builtin.bytearray([c]));
-	}
-
-	/*
-	** TODO not sure if this implementation is working
 
-	override public function writeBytes( s : haxe.io.Bytes, pos : Int, len : Int ) : Int
+	public function tell() : Int
 	{
-		if( pos < 0 || len < 0 || pos + len > s.length )
-			throw haxe.io.Error.OutsideBounds;
-
-		var ba = s.sub(pos, len).getData();
-
-		var ret = stream.write(ba);
-
-		return ret;
+		return stream.tell();
 	}
-	*/
-
 }

+ 68 - 0
std/python/io/NativeTextInput.hx

@@ -0,0 +1,68 @@
+
+package python.io;
+
+import haxe.io.Eof;
+import haxe.io.Input;
+
+import python.io.IInput;
+import python.io.NativeInput;
+import python.lib.Builtin;
+import python.lib.io.RawIOBase;
+import python.lib.io.IOBase.SeekSet;
+import python.lib.io.TextIOBase;
+
+
+class NativeTextInput extends NativeInput<TextIOBase> implements IInput {
+
+	public function new (stream:TextIOBase) {
+		super(stream);
+	}
+
+	override public function readByte():Int
+	{
+		var ret = stream.read(1);
+
+		if (ret.length == 0) throwEof();
+
+		return ret.charCodeAt(0);
+	}
+
+	public function seek( p : Int, pos : sys.io.FileSeek ) : Void
+	{
+		wasEof = false;
+
+
+ 		var pos = switch (pos) {
+ 			case SeekBegin:
+ 				SeekSet.SeekSet;
+ 			case SeekCur:
+ 				p = tell() + p;
+ 				SeekSet.SeekSet;
+ 			case SeekEnd :
+ 				stream.seek(0, SeekSet.SeekEnd);
+ 				p = tell() + p;
+ 				SeekSet.SeekSet;
+ 		}
+ 		stream.seek(p, pos);
+
+	}
+
+
+	override public function readBytes(s:haxe.io.Bytes, pos:Int, len:Int):Int
+	{
+		throw "not implemented";
+		/*
+		if( pos < 0 || len < 0 || pos + len > s.length )
+			throw haxe.io.Error.OutsideBounds;
+
+		stream.seek(pos, python.lib.io.IOBase.SeekSet.SeekCur);
+		var ba = Builtin.bytearray(len);
+		var ret = stream.readinto(ba);
+		s.blit(pos, haxe.io.Bytes.ofData(ba) ,0,len);
+		if (ret == 0)
+			throwEof();
+		return ret;
+		*/
+	}
+
+}

+ 50 - 0
std/python/io/NativeTextOutput.hx

@@ -0,0 +1,50 @@
+
+package python.io;
+
+import haxe.io.Output;
+
+import python.lib.Builtin;
+import python.lib.io.IOBase;
+import python.lib.io.RawIOBase;
+import python.lib.io.TextIOBase;
+
+class NativeTextOutput extends NativeOutput<TextIOBase> {
+
+	public function new (stream:TextIOBase) {
+		super(stream);
+		if (!stream.writable()) throw "Read only stream";
+	}
+
+	public function seek( p : Int, pos : sys.io.FileSeek ) : Void
+	{
+		var pos = switch(pos)
+		{
+			case SeekBegin: SeekSet.SeekSet;
+			case SeekCur: SeekSet.SeekCur;
+			case SeekEnd: SeekSet.SeekEnd;
+		};
+		stream.seek(p, pos);
+	}
+
+	override public function writeByte(c:Int):Void
+	{
+		stream.write(String.fromCharCode(c));
+	}
+
+	/*
+	** TODO not sure if this implementation is working
+
+	override public function writeBytes( s : haxe.io.Bytes, pos : Int, len : Int ) : Int
+	{
+		if( pos < 0 || len < 0 || pos + len > s.length )
+			throw haxe.io.Error.OutsideBounds;
+
+		var ba = s.sub(pos, len).getData();
+
+		var ret = stream.write(ba);
+
+		return ret;
+	}
+	*/
+
+}

+ 7 - 2
std/python/lib/io/BytesIO.hx

@@ -1,8 +1,13 @@
 
 package python.lib.io;
 
-extern class BytesIO {
+extern class BytesIO extends python.lib.io.BufferedIOBase {
 
-	
+	public function new (base:python.lib.io.IOBase);
+
+	static function __init__ ():Void
+	{
+		python.Syntax.importFromAs("io", "BytesIO", "python.lib.io.BytesIO");
+	}
 
 }

+ 2 - 0
std/python/lib/io/TextIOBase.hx

@@ -6,6 +6,8 @@ import python.lib.io.IOBase;
 
 extern class TextIOBase extends IOBase {
 
+	function new (buffer:BufferedIOBase):Void;
+
 	public var encoding:String;
 
 	public function write (s:String):Int;