Browse Source

move Bytes and Bytearray into python package, fix #3983

frabbit 10 years ago
parent
commit
5f89970863

+ 1 - 1
genpy.ml

@@ -80,7 +80,7 @@ module KeywordHandler = struct
 		List.iter (fun s -> Hashtbl.add h s ()) [
 		List.iter (fun s -> Hashtbl.add h s ()) [
 			"len"; "int"; "float"; "list"; "bool"; "str"; "isinstance"; "print"; "min"; "max";
 			"len"; "int"; "float"; "list"; "bool"; "str"; "isinstance"; "print"; "min"; "max";
 			"hasattr"; "getattr"; "setattr"; "delattr"; "callable"; "type"; "ord"; "chr"; "iter"; "map"; "filter";
 			"hasattr"; "getattr"; "setattr"; "delattr"; "callable"; "type"; "ord"; "chr"; "iter"; "map"; "filter";
-			"tuple"; "dict"; "set";
+			"tuple"; "dict"; "set"; "bytes"; "bytearray"
 		];
 		];
 		h
 		h
 
 

+ 2 - 2
std/haxe/io/Bytes.hx

@@ -474,7 +474,7 @@ class Bytes {
 		#elseif java
 		#elseif java
 		return new Bytes(length, new java.NativeArray(length));
 		return new Bytes(length, new java.NativeArray(length));
 		#elseif python
 		#elseif python
-		return new Bytes(length, new python.lib.Bytearray(length));
+		return new Bytes(length, new python.Bytearray(length));
 		#else
 		#else
 		var a = new Array();
 		var a = new Array();
 		for( i in 0...length )
 		for( i in 0...length )
@@ -509,7 +509,7 @@ class Bytes {
 		catch (e:Dynamic) throw e;
 		catch (e:Dynamic) throw e;
 
 
 		#elseif python
 		#elseif python
-			var b:BytesData = new python.lib.Bytearray(s, "UTF-8");
+			var b:BytesData = new python.Bytearray(s, "UTF-8");
 			return new Bytes(b.length, b);
 			return new Bytes(b.length, b);
 
 
 		#else
 		#else

+ 1 - 1
std/haxe/io/BytesBuffer.hx

@@ -204,7 +204,7 @@ class BytesBuffer {
 		var buf = b.toByteArray();
 		var buf = b.toByteArray();
 		var bytes = new Bytes(buf.length, buf);
 		var bytes = new Bytes(buf.length, buf);
 		#elseif python
 		#elseif python
-		var buf = new python.lib.Bytearray(b);
+		var buf = new python.Bytearray(b);
 		var bytes = new Bytes(buf.length, buf);
 		var bytes = new Bytes(buf.length, buf);
 		#elseif js
 		#elseif js
 		var bytes = new Bytes(new js.html.Uint8Array(b).buffer);
 		var bytes = new Bytes(new js.html.Uint8Array(b).buffer);

+ 1 - 1
std/haxe/io/BytesData.hx

@@ -35,7 +35,7 @@ package haxe.io;
 #elseif cs
 #elseif cs
 	typedef BytesData = cs.NativeArray<cs.StdTypes.UInt8>;
 	typedef BytesData = cs.NativeArray<cs.StdTypes.UInt8>;
 #elseif python
 #elseif python
-	typedef BytesData = python.lib.Bytearray;
+	typedef BytesData = python.Bytearray;
 #elseif js
 #elseif js
 	typedef BytesData = js.html.ArrayBuffer;
 	typedef BytesData = js.html.ArrayBuffer;
 #else
 #else

+ 2 - 2
std/python/lib/Bytearray.hx → std/python/Bytearray.hx

@@ -19,11 +19,11 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  * DEALINGS IN THE SOFTWARE.
  */
  */
-package python.lib;
+package python;
 
 
 import python.Syntax;
 import python.Syntax;
 
 
-@:pythonImport("builtins", "bytearray")
+@:native("bytearray")
 extern class Bytearray implements ArrayAccess<Int> {
 extern class Bytearray implements ArrayAccess<Int> {
 
 
 	public var length(get,never):Int;
 	public var length(get,never):Int;

+ 3 - 3
std/python/lib/Bytes.hx → std/python/Bytes.hx

@@ -19,11 +19,11 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  * DEALINGS IN THE SOFTWARE.
  */
  */
-package python.lib;
+package python;
 
 
-import python.lib.Bytearray;
+import python.Bytearray;
 
 
-@:pythonImport("builtins", "bytes")
+@:native("bytes")
 extern class Bytes extends Bytearray {
 extern class Bytes extends Bytearray {
 
 
 	//public function decode(encoding:String="utf-8", errors:String="strict"):String;
 	//public function decode(encoding:String="utf-8", errors:String="strict"):String;

+ 1 - 1
std/python/NativeStringTools.hx

@@ -21,7 +21,7 @@
  */
  */
 package python;
 package python;
 
 
-import python.lib.Bytes;
+import python.Bytes;
 import python.Tuple;
 import python.Tuple;
 
 
 class NativeStringTools {
 class NativeStringTools {

+ 1 - 1
std/python/io/NativeBytesInput.hx

@@ -26,7 +26,7 @@ import haxe.io.Input;
 
 
 import python.io.IInput;
 import python.io.IInput;
 import python.io.IoTools;
 import python.io.IoTools;
-import python.lib.Bytearray;
+import python.Bytearray;
 import python.lib.io.RawIOBase;
 import python.lib.io.RawIOBase;
 import python.lib.io.IOBase.SeekSet;
 import python.lib.io.IOBase.SeekSet;
 
 

+ 1 - 1
std/python/io/NativeBytesOutput.hx

@@ -23,7 +23,7 @@ package python.io;
 
 
 import haxe.io.Output;
 import haxe.io.Output;
 
 
-import python.lib.Bytearray;
+import python.Bytearray;
 import python.lib.io.IOBase;
 import python.lib.io.IOBase;
 import python.lib.io.RawIOBase;
 import python.lib.io.RawIOBase;
 
 

+ 1 - 1
std/python/io/NativeInput.hx

@@ -23,7 +23,7 @@ package python.io;
 
 
 import haxe.io.Eof;
 import haxe.io.Eof;
 import haxe.io.Input;
 import haxe.io.Input;
-import python.lib.Bytearray;
+import python.Bytearray;
 import python.lib.io.IOBase;
 import python.lib.io.IOBase;
 import python.lib.io.RawIOBase;
 import python.lib.io.RawIOBase;
 
 

+ 1 - 1
std/python/io/NativeTextInput.hx

@@ -27,7 +27,7 @@ import haxe.io.Input;
 import python.io.IInput;
 import python.io.IInput;
 import python.io.IoTools;
 import python.io.IoTools;
 import python.io.NativeInput;
 import python.io.NativeInput;
-import python.lib.Bytearray;
+import python.Bytearray;
 import python.lib.io.RawIOBase;
 import python.lib.io.RawIOBase;
 import python.lib.io.IOBase.SeekSet;
 import python.lib.io.IOBase.SeekSet;
 import python.lib.io.TextIOBase;
 import python.lib.io.TextIOBase;

+ 4 - 4
std/python/lib/Builtins.hx

@@ -101,10 +101,10 @@ extern class Builtins {
 
 
 	public static function type():Void;
 	public static function type():Void;
 	/*
 	/*
-	@:overload(function (it:Array<Int>):python.lib.ByteArray {})
-	@:overload(function (it:NativeIterable<Int>):python.lib.ByteArray {})
-	@:overload(function (size:Int):python.lib.ByteArray {})
-	public static function bytearray(source:String,encoding:String,?errors:Dynamic):python.lib.ByteArray;
+	@:overload(function (it:Array<Int>):python.Bytearray {})
+	@:overload(function (it:NativeIterable<Int>):python.Bytearray {})
+	@:overload(function (size:Int):python.Bytearray {})
+	public static function bytearray(source:String,encoding:String,?errors:Dynamic):python.Bytearray;
 	*/
 	*/
 	public static function float(x:Dynamic):Float;
 	public static function float(x:Dynamic):Float;
 
 

+ 1 - 1
std/python/lib/Codecs.hx

@@ -21,7 +21,7 @@
  */
  */
 package python.lib;
 package python.lib;
 
 
-import python.lib.Bytes;
+import python.Bytes;
 import python.lib.codecs.StreamReaderWriter;
 import python.lib.codecs.StreamReaderWriter;
 
 
 @:pythonImport("codecs")
 @:pythonImport("codecs")

+ 1 - 1
std/python/lib/Msvcrt.hx

@@ -24,6 +24,6 @@ package python.lib;
 @:pythonImport("msvcrt", ignoreError=true)
 @:pythonImport("msvcrt", ignoreError=true)
 extern class Msvcrt {
 extern class Msvcrt {
 
 
-	public static function getch ():python.lib.Bytes;
+	public static function getch ():python.Bytes;
 
 
 }
 }

+ 1 - 1
std/python/lib/codecs/Codec.hx

@@ -21,7 +21,7 @@
  */
  */
 package python.lib.codecs;
 package python.lib.codecs;
 
 
-import python.lib.Bytes;
+import python.Bytes;
 import python.Tuple.Tuple2;
 import python.Tuple.Tuple2;
 
 
 @:pythonImport("codecs", "Codec")
 @:pythonImport("codecs", "Codec")

+ 1 - 1
std/python/lib/io/BufferedIOBase.hx

@@ -24,7 +24,7 @@ package python.lib.io;
 import python.lib.io.IOBase;
 import python.lib.io.IOBase;
 
 
 import python.lib.io.RawIOBase;
 import python.lib.io.RawIOBase;
-import python.lib.Bytearray;
+import python.Bytearray;
 
 
 @:pythonImport("io", "BufferedIOBase")
 @:pythonImport("io", "BufferedIOBase")
 extern class BufferedIOBase extends IOBase implements IBufferedIOBase {
 extern class BufferedIOBase extends IOBase implements IBufferedIOBase {

+ 1 - 1
std/python/lib/io/BufferedReader.hx

@@ -21,7 +21,7 @@
  */
  */
 package python.lib.io;
 package python.lib.io;
 
 
-import python.lib.Bytes;
+import python.Bytes;
 import python.lib.io.BufferedIOBase;
 import python.lib.io.BufferedIOBase;
 
 
 @:pythonImport("io", "BufferedReader")
 @:pythonImport("io", "BufferedReader")

+ 1 - 1
std/python/lib/io/BufferedWriter.hx

@@ -21,7 +21,7 @@
  */
  */
 package python.lib.io;
 package python.lib.io;
 
 
-import python.lib.Bytearray;
+import python.Bytearray;
 import python.lib.io.BufferedIOBase;
 import python.lib.io.BufferedIOBase;
 
 
 @:pythonImport("io", "BufferedWriter")
 @:pythonImport("io", "BufferedWriter")