Forráskód Böngészése

[python] move python.lib.Dict to python.Dict, don't import dict from builtins module

Dan Korostelev 10 éve
szülő
commit
3d54020fdb

+ 3 - 2
genpy.ml

@@ -79,7 +79,8 @@ module KeywordHandler = struct
 		let h = Hashtbl.create 0 in
 		List.iter (fun s -> Hashtbl.add h s ()) [
 			"len"; "int"; "float"; "list"; "bool"; "str"; "isinstance"; "print"; "min"; "max";
-			"hasattr"; "getattr"; "setattr"; "callable"; "type"; "ord"; "chr"; "iter"; "map"; "filter"; "tuple";
+			"hasattr"; "getattr"; "setattr"; "callable"; "type"; "ord"; "chr"; "iter"; "map"; "filter";
+			"tuple"; "dict";
 		];
 		h
 
@@ -2297,7 +2298,7 @@ module Generator = struct
 			newline ctx;
 			spr ctx "class _hx_AnonObject:\n";
 			if with_body then begin
-				spr ctx "\tdef __init__(self,fields):\n";
+				spr ctx "\tdef __init__(self, fields):\n";
 				spr ctx "\t\tself.__dict__ = fields"
 			end else
 				spr ctx "\tpass";

+ 5 - 6
std/python/lib/Dict.hx → std/python/Dict.hx

@@ -1,5 +1,5 @@
 /*
- * Copyright (C)2005-2012 Haxe Foundation
+ * Copyright (C)2005-2015 Haxe Foundation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -19,7 +19,7 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-package python.lib;
+package python;
 
 import python.internal.UBuiltins;
 import python.Tuple;
@@ -44,9 +44,8 @@ extern class DictView<T> {
 	}
 }
 
-@:pythonImport("builtins", "dict")
-extern class Dict <K, V>
-{
+@:native("dict")
+extern class Dict<K,V> {
 	public function new ():Void;
 
 	public inline function length ():Int
@@ -98,4 +97,4 @@ class DictImpl {
 	public static inline function set <K,V>(d:Dict<K, V>, key:K, val:V) {
 		Syntax.arraySet(d, key, val);
 	}
-}
+}

+ 1 - 1
std/python/KwArgs.hx

@@ -21,7 +21,7 @@
  */
 package python;
 
-import python.lib.Dict;
+import python.Dict;
 
 /**
 	This type represents python `**kwargs` feature, supporting

+ 1 - 1
std/python/Lib.hx

@@ -22,7 +22,7 @@
 package python;
 
 import python.internal.AnonObject;
-import python.lib.Dict;
+import python.Dict;
 import python.NativeStringTools;
 
 typedef PySys = python.lib.Sys;

+ 2 - 2
std/python/_std/haxe/Resource.hx

@@ -26,9 +26,9 @@ import haxe.io.BytesData;
 
 @:coreApi class Resource {
 
-	static var content : python.lib.Dict<String, BytesData> = null;
+	static var content:python.Dict<String,BytesData>;
 
-	static function getContent ():python.lib.Dict<String, BytesData> {
+	static function getContent():python.Dict<String,BytesData> {
 		if (content == null) content = untyped _hx_resources__();
 		return content;
 	}

+ 1 - 1
std/python/_std/haxe/ds/IntMap.hx

@@ -21,7 +21,7 @@
  */
 package haxe.ds;
 
-import python.lib.Dict;
+import python.Dict;
 import python.Syntax;
 
 class IntMap<T> implements haxe.Constraints.IMap<Int, T> {

+ 1 - 1
std/python/_std/haxe/ds/ObjectMap.hx

@@ -21,7 +21,7 @@
  */
 package haxe.ds;
 
-import python.lib.Dict;
+import python.Dict;
 
 class ObjectMap<K:{},V> implements haxe.Constraints.IMap<K, V> {
 

+ 1 - 1
std/python/_std/haxe/ds/StringMap.hx

@@ -23,7 +23,7 @@ package haxe.ds;
 
 
 import python.Syntax;
-import python.lib.Dict;
+import python.Dict;
 
 class StringMap<T> implements haxe.Constraints.IMap<String, T> {
 	private var h : Dict<String,T>;

+ 1 - 1
std/python/internal/AnonObject.hx

@@ -23,5 +23,5 @@ package python.internal;
 
 @:native("_hx_AnonObject")
 class AnonObject {
-	public function new(fields:python.lib.Dict<String, Dynamic>) {}
+	public function new(fields:python.Dict<String, Dynamic>) {}
 }

+ 1 - 1
std/python/internal/Internal.hx

@@ -78,7 +78,7 @@ class Internal {
 	}
 
 	macro public static function classRegistry ():Expr {
-		return macro (untyped __define_feature__($v{"python." + _classes}, python.Syntax.pythonCode($v{_classes})) : python.lib.Dict<String, Class<Dynamic>>);
+		return macro (untyped __define_feature__($v{"python." + _classes}, python.Syntax.pythonCode($v{_classes})) : python.Dict<String, Class<Dynamic>>);
 	}
 
 	macro public static function callFieldPrefixed (o:Expr, x:String, params:Array<Expr>):Expr {

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

@@ -23,7 +23,7 @@ package python.lib;
 
 
 import python.lib.io.FileIO;
-import python.lib.Dict;
+import python.Dict;
 import python.lib.io.IOBase;
 import python.NativeIterable;
 import python.NativeIterator;

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

@@ -22,7 +22,7 @@
 package python.lib;
 
 import python.KwArgs;
-import python.lib.Dict;
+import python.Dict;
 import python.Tuple.Tuple2;
 
 @:pythonImport("json")

+ 1 - 0
std/python/lib/Os.hx

@@ -24,6 +24,7 @@ package python.lib;
 
 import python.lib.Exceptions.OSError;
 import python.Tuple;
+import python.Dict;
 
 extern class Stat {
 	public var st_mode:Int;

+ 1 - 0
std/python/lib/subprocess/Popen.hx

@@ -26,6 +26,7 @@ import python.lib.io.FileIO;
 import python.lib.io.TextIOBase;
 import python.lib.Subprocess.StartupInfo;
 import python.Tuple;
+import python.Dict;
 
 typedef PopenOptions = {
 	?bufsize : Int,

+ 1 - 0
std/python/lib/xml/etree/ElementTree.hx

@@ -25,6 +25,7 @@ import python.Tuple.Tuple2;
 
 import python.NativeIterable;
 import python.NativeIterator;
+import python.Dict;
 
 extern class XMLParser {