Преглед на файлове

[python] rename @:import to @:pythonImport

Dan Korostelev преди 11 години
родител
ревизия
11760627ef
променени са 44 файла, в които са добавени 54 реда и са изтрити 54 реда
  1. 1 1
      ast.ml
  2. 1 1
      common.ml
  3. 3 3
      genpy.ml
  4. 2 2
      std/python/Boot.hx
  5. 1 1
      std/python/_std/Math.hx
  6. 1 1
      std/python/_std/String.hx
  7. 1 1
      std/python/internal/HxBuiltin.hx
  8. 1 1
      std/python/lib/Builtin.hx
  9. 1 1
      std/python/lib/Bytes.hx
  10. 1 1
      std/python/lib/Codecs.hx
  11. 1 1
      std/python/lib/Dict.hx
  12. 1 1
      std/python/lib/FuncTools.hx
  13. 1 1
      std/python/lib/Glob.hx
  14. 1 1
      std/python/lib/Inspect.hx
  15. 1 1
      std/python/lib/Json.hx
  16. 1 1
      std/python/lib/Math.hx
  17. 1 1
      std/python/lib/Msvcrt.hx
  18. 1 1
      std/python/lib/Os.hx
  19. 1 1
      std/python/lib/PPrint.hx
  20. 1 1
      std/python/lib/Random.hx
  21. 1 1
      std/python/lib/Re.hx
  22. 1 1
      std/python/lib/Set.hx
  23. 1 1
      std/python/lib/ShUtil.hx
  24. 1 1
      std/python/lib/Subprocess.hx
  25. 1 1
      std/python/lib/Sys.hx
  26. 1 1
      std/python/lib/Tempfile.hx
  27. 1 1
      std/python/lib/Termios.hx
  28. 1 1
      std/python/lib/ThreadLowLevel.hx
  29. 1 1
      std/python/lib/Time.hx
  30. 1 1
      std/python/lib/Traceback.hx
  31. 1 1
      std/python/lib/Tty.hx
  32. 1 1
      std/python/lib/datetime/DateTime.hx
  33. 1 1
      std/python/lib/datetime/TimeDelta.hx
  34. 1 1
      std/python/lib/datetime/Timezone.hx
  35. 1 1
      std/python/lib/datetime/TzInfo.hx
  36. 1 1
      std/python/lib/io/BytesIO.hx
  37. 1 1
      std/python/lib/io/StringIO.hx
  38. 1 1
      std/python/lib/json/JSONEncoder.hx
  39. 2 2
      std/python/lib/net/Socket.hx
  40. 1 1
      std/python/lib/os/Path.hx
  41. 1 1
      std/python/lib/subprocess/Popen.hx
  42. 1 1
      std/python/lib/threading/Thread.hx
  43. 2 2
      std/python/lib/xml/etree/ElementTree.hx
  44. 6 6
      tests/unit/TestPython.hx

+ 1 - 1
ast.ml

@@ -83,7 +83,7 @@ module Meta = struct
 		| HxGen
 		| IfFeature
 		| Impl
-		| Import
+		| PythonImport
 		| Include
 		| InitPackage
 		| Internal

+ 1 - 1
common.ml

@@ -385,7 +385,7 @@ module MetaInfo = struct
 		| HxGen -> ":hxGen",("Annotates that an extern class was generated by Haxe",[Platforms [Java;Cs]; UsedOnEither [TClass;TEnum]])
 		| IfFeature -> ":ifFeature",("Causes a field to be kept by DCE if the given feature is part of the compilation",[HasParam "Feature name";UsedOn TClassField])
 		| Impl -> ":impl",("Used internally to mark abstract implementation fields",[UsedOn TAbstractField; Internal])
-		| Import -> ":import",("Generates python import statement for extern classes",[Platforms [Python]; UsedOn TClass])
+		| PythonImport -> ":pythonImport",("Generates python import statement for extern classes",[Platforms [Python]; UsedOn TClass])
 		| Include -> ":include",("",[Platform Cpp])
 		| InitPackage -> ":initPackage",("?",[])
 		| Meta.Internal -> ":internal",("Generates the annotated field/class with 'internal' access",[Platforms [Java;Cs]; UsedOnEither[TClass;TEnum;TClassField]])

+ 3 - 3
genpy.ml

@@ -1704,8 +1704,8 @@ module Generator = struct
 	let gen_import ctx c =
 		gen_pre_code_meta ctx c.cl_meta;
 
-		if Meta.has Meta.Import c.cl_meta then begin
-			let _, args, mp = Meta.get Meta.Import c.cl_meta in
+		if Meta.has Meta.PythonImport c.cl_meta then begin
+			let _, args, mp = Meta.get Meta.PythonImport c.cl_meta in
 
 			let class_name = match c.cl_path with
 				| [],name -> name
@@ -1727,7 +1727,7 @@ module Generator = struct
 				| [(EConst(String(module_name)), _); (EConst(String(object_name)), _); (EBinop(OpAssign, (EConst(Ident("ignoreError")),_), (EConst(Ident("true")),_)),_)] ->
 					IObject (module_name,object_name), true
 				| _ ->
-					error "Unsupported @:import format" mp
+					error "Unsupported @:pythonImport format" mp
 			in
 
 			let import = match import_type with

+ 2 - 2
std/python/Boot.hx

@@ -17,8 +17,8 @@ private extern class Set<T> {
 	}
 }
 
-@:import("math") private extern class Math {}
-@:import("inspect") private extern class Inspect {}
+@:pythonImport("math") private extern class Math {}
+@:pythonImport("inspect") private extern class Inspect {}
 
 typedef HxClassBase = {
     _hx_class:Dynamic,

+ 1 - 1
std/python/_std/Math.hx

@@ -27,7 +27,7 @@ import python.lib.Builtin;
 /**
 	This class defines mathematical functions and constants.
 **/
-@:import("math")
+@:pythonImport("math")
 @:coreApi
 extern class Math
 {

+ 1 - 1
std/python/_std/String.hx

@@ -34,7 +34,7 @@ package;
 #if !macro
 import python.internal.StringImpl;
 #end
-@:import("builtins", "str")
+@:pythonImport("builtins", "str")
 @:coreApi
 extern class String {
 

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

@@ -1,6 +1,6 @@
 
 package python.internal;
 
-@:import("builtins") extern class HxBuiltin {
+@:pythonImport("builtins") extern class HxBuiltin {
 	public static inline function instance ():Dynamic return HxBuiltin;
 }

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

@@ -7,7 +7,7 @@ import python.lib.Dict;
 import python.NativeIterable;
 import python.NativeIterator;
 
-@:import("builtins")
+@:pythonImport("builtins")
 extern class Builtin {
 
 

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

@@ -3,7 +3,7 @@ package python.lib;
 
 import python.lib.ByteArray;
 
-@:import("builtins", "bytes")
+@:pythonImport("builtins", "bytes")
 extern class Bytes extends ByteArray {
 
 	//public function decode(encoding:String="utf-8", errors:String="strict"):String;

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

@@ -43,7 +43,7 @@ extern class StreamReaderWriterText implements StreamReader implements StreamWri
 }
 
 
-@:import("codecs")
+@:pythonImport("codecs")
 extern class Codecs {
 
 	public static function open(filename:String, mode:String, ?encoding:String, ?errors:String, ?buffering:Bool):StreamReaderWriterText;

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

@@ -23,7 +23,7 @@ extern class DictView<T> {
 	}
 }
 
-@:import("builtins", "dict")
+@:pythonImport("builtins", "dict")
 extern class Dict <K, V>
 {
 	public function new ():Void;

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

@@ -2,7 +2,7 @@
 package python.lib;
 
 
-@:import("functools")
+@:pythonImport("functools")
 extern class FuncTools {
 
 	public static function cmp_to_key<A>(f:A->A->Int):Dynamic;

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

@@ -4,7 +4,7 @@ package python.lib;
 
 import python.NativeIterator;
 
-@:import("glob")
+@:pythonImport("glob")
 extern class Glob {
 
 	public static function glob (pathname:String):Array<String>;

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

@@ -3,7 +3,7 @@ package python.lib;
 
 import python.Syntax;
 
-@:import("inspect")
+@:pythonImport("inspect")
 extern class Inspect {
 
 	static function getmembers (value:Dynamic, ?filter:Dynamic->Bool):Bool;

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

@@ -5,7 +5,7 @@ import python.KwArgs;
 import python.lib.Dict;
 import python.lib.Tuple.Tup2;
 
-@:import("json")
+@:pythonImport("json")
 extern class Json {
 
 

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

@@ -1,6 +1,6 @@
 package python.lib;
 
-@:import("math")
+@:pythonImport("math")
 extern class Math {
 
 	public static function isnan (f:Float):Bool;

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

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

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

@@ -30,7 +30,7 @@ extern class Stat {
 	@:optional public var st_type:Int;
 }
 
-@:import("os")
+@:pythonImport("os")
 extern class Os {
 
 	public static var environ : Dict<String, String>;

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

@@ -1,7 +1,7 @@
 
 package python.lib;
 
-@:import("pprint")
+@:pythonImport("pprint")
 extern class PPrint {
 
 

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

@@ -2,7 +2,7 @@
 package python.lib;
 
 
-@:import("random")
+@:pythonImport("random")
 extern class Random {
 
 	public static function random ():Float;

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

@@ -115,7 +115,7 @@ extern class Regex
 }
 
 
-@:import("re")
+@:pythonImport("re")
 extern class Re
 {
 

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

@@ -4,7 +4,7 @@ package python.lib;
 import python.NativeIterator;
 import python.NativeIterable;
 
-@:import("builtins", "set")
+@:pythonImport("builtins", "set")
 extern class Set <T>
 {
 	@:overload(function (?array:Array<T>):Void {})

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

@@ -2,7 +2,7 @@
 package python.lib;
 
 
-@:import("shutil")
+@:pythonImport("shutil")
 extern class ShUtil {
 
 	public static function rmtree(path:String, ?ignore_errors:Bool=false, ?onerror:python.lib.Exceptions.BaseException->Void):Void;

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

@@ -8,7 +8,7 @@ extern class StartupInfo {
 
 }
 
-@:import("subprocess")
+@:pythonImport("subprocess")
 extern class Subprocess {
 
 	public static function STARTUPINFO():StartupInfo;

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

@@ -10,7 +10,7 @@ import python.lib.Tuple.Tup3;
 extern class TB {}
 extern class Frame {}
 
-@:import("sys")
+@:pythonImport("sys")
 extern class Sys {
 
 	public static var argv(default, never):Array<String>;

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

@@ -1,7 +1,7 @@
 
 package python.lib;
 
-@:import("tempfile")
+@:pythonImport("tempfile")
 extern class Tempfile {
 
 	public static function gettempdir():String;

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

@@ -3,7 +3,7 @@ package python.lib;
 
 abstract TermiosSettings(Dynamic) {}
 
-@:import("termios", ignoreError=true)
+@:pythonImport("termios", ignoreError=true)
 extern class Termios {
 
 	public static var TCSADRAIN : Int;

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

@@ -5,7 +5,7 @@ import python.lib.Tuple;
 
 private typedef TODO = Dynamic;
 
-@:import("_thread")
+@:pythonImport("_thread")
 extern class ThreadLowLevel {
 
 	public static function start_new_thread(f:Void->Void, args:Tuple<Dynamic>):TODO;

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

@@ -1,7 +1,7 @@
 
 package python.lib;
 
-@:import("time")
+@:pythonImport("time")
 extern class Time {
 
 	public static function time ():Float;

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

@@ -4,7 +4,7 @@ import python.lib.Sys;
 import python.lib.Sys.Frame;
 import python.lib.Tuple;
 
-@:import("traceback")
+@:pythonImport("traceback")
 extern class Traceback {
 
 	public static function extract_stack(?f:Frame, ?limit:Int):Array<StackItem>;

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

@@ -1,7 +1,7 @@
 
 package python.lib;
 
-@:import("tty", ignoreError=true)
+@:pythonImport("tty", ignoreError=true)
 extern class Tty {
 	public static function setraw (fileNo:Int):Void;
 }

+ 1 - 1
std/python/lib/datetime/DateTime.hx

@@ -2,7 +2,7 @@
 package python.lib.datetime;
 
 
-@:import("datetime", "datetime")
+@:pythonImport("datetime", "datetime")
 extern class DateTime {
 
 	public function new (year:Int, month:Int, day:Int, hour:Int=0, minute:Int=0, second:Int=0, microsecond:Int=0, tzinfo:TzInfo=null);

+ 1 - 1
std/python/lib/datetime/TimeDelta.hx

@@ -1,7 +1,7 @@
 
 package python.lib.datetime;
 
-@:import("datetime", "timedelta")
+@:pythonImport("datetime", "timedelta")
 extern class TimeDelta {
 
 	public static var min : TimeDelta;

+ 1 - 1
std/python/lib/datetime/Timezone.hx

@@ -1,7 +1,7 @@
 
 package python.lib.datetime;
 
-@:import("datetime", "timezone")
+@:pythonImport("datetime", "timezone")
 extern class Timezone extends TzInfo {
 
 	public static var utc(default, never):TzInfo;

+ 1 - 1
std/python/lib/datetime/TzInfo.hx

@@ -1,6 +1,6 @@
 
 package python.lib.datetime;
 
-@:import("datetime", "tzinfo")
+@:pythonImport("datetime", "tzinfo")
 extern class TzInfo {
 }

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

@@ -1,7 +1,7 @@
 
 package python.lib.io;
 
-@:import("io", "BytesIO")
+@:pythonImport("io", "BytesIO")
 extern class BytesIO extends python.lib.io.BufferedIOBase {
 
 	public function new (base:python.lib.io.IOBase);

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

@@ -4,7 +4,7 @@ package python.lib.io;
 import python.lib.io.TextIOBase;
 import python.Syntax;
 
-@:import("io", "StringIO")
+@:pythonImport("io", "StringIO")
 extern class StringIO extends TextIOBase
 {
 	public function new (?s:String):Void;

+ 1 - 1
std/python/lib/json/JSONEncoder.hx

@@ -1,6 +1,6 @@
 
 package python.lib.json;
 
-@:import("json", "JSONEncoder")
+@:pythonImport("json", "JSONEncoder")
 extern class JSONEncoder {
 }

+ 2 - 2
std/python/lib/net/Socket.hx

@@ -33,14 +33,14 @@ typedef Selectable = {
 }
 
 @:native("select")
-@:import("select")
+@:pythonImport("select")
 extern class Select {
 
     static function select<T>(reads:Array<T>,writes:Array<T>,xs:Array<T>,timeout:Float):Tup3<Array<T>,Array<T>,Array<T>>;
 
 }
 
-@:import("socket", "socket")
+@:pythonImport("socket", "socket")
 extern class Socket {
 
     static var AF_APPLETALK:Int;

+ 1 - 1
std/python/lib/os/Path.hx

@@ -3,7 +3,7 @@ package python.lib.os;
 
 import python.lib.Tuple;
 
-@:import("os", "path")
+@:pythonImport("os", "path")
 extern class Path {
 
 	public static var sep : String;

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

@@ -22,7 +22,7 @@ typedef PopenOptions = {
 	?creationflags : Int,
 }
 
-@:import("subprocess", "Popen")
+@:pythonImport("subprocess", "Popen")
 extern class Popen {
 
 	public static inline function create (args:Array<String>, o:PopenOptions):Popen {

+ 1 - 1
std/python/lib/threading/Thread.hx

@@ -1,6 +1,6 @@
 
 package python.lib.threading;
 
-@:import("threading", "Thread")
+@:pythonImport("threading", "Thread")
 extern class Thread {
 }

+ 2 - 2
std/python/lib/xml/etree/ElementTree.hx

@@ -10,7 +10,7 @@ extern class XMLParser {
 
 }
 
-@:import("xml.etree.ElementTree", "Element")
+@:pythonImport("xml.etree.ElementTree", "Element")
 extern class Element {
 	public function getroot ():ElementTree;
 	public var tag:String;
@@ -32,7 +32,7 @@ extern class Element {
 	public function findall (match:String, namespaces:Dict<String,String> = null):Array<Element>;
 }
 
-@:import("xml.etree.ElementTree")
+@:pythonImport("xml.etree.ElementTree")
 extern class ElementTree {
 
 

+ 6 - 6
tests/unit/TestPython.hx

@@ -84,30 +84,30 @@ private class B extends A {
     public function new() {}
 }
 
-@:import("native_python.sample", "A")
+@:pythonImport("native_python.sample", "A")
 extern class ExternClass {
 	function new();
 	function f(v:Int):Int;
 }
 
-@:import("native_python.sample", "A.Nested")
+@:pythonImport("native_python.sample", "A.Nested")
 extern class ExternNestedClass {
 	function new();
 	function f(v:Int):Int;
 }
 
-@:import("native_python.sample")
+@:pythonImport("native_python.sample")
 extern class ExternModule {
 	static function f(v:Int):Int;
 }
 
-@:import("inexistant", "AZAZA", ignoreError=true)
+@:pythonImport("inexistant", "AZAZA", ignoreError=true)
 extern class InexistantExtern1 {}
 
-@:import("inexistant", "AZAZA.ZAZA", ignoreError=true)
+@:pythonImport("inexistant", "AZAZA.ZAZA", ignoreError=true)
 extern class InexistantExtern2 {}
 
-@:import("inexistant", ignoreError=true)
+@:pythonImport("inexistant", ignoreError=true)
 extern class InexistantExtern3 {}
 
 class TestPython extends Test {