frabbit 11 years ago
parent
commit
be1a146001
2 changed files with 14 additions and 22 deletions
  1. 3 3
      genpy.ml
  2. 11 19
      std/python/internal/HxOverrides.hx

+ 3 - 3
genpy.ml

@@ -995,9 +995,9 @@ module Printer = struct
 			| TBinop(OpMod,e1,e2) when (is_type1 "" "Int")(e1.etype) && (is_type1 "" "Int")(e2.etype) ->
 				Printf.sprintf "%s %% %s" (print_expr pctx e1) (print_expr pctx e2)
 			| TBinop(OpMod,e1,e2) ->
-				Printf.sprintf "HxOverrides.hx_modf(%s, %s)" (print_expr pctx e1) (print_expr pctx e2)
+				Printf.sprintf "HxOverrides.modf(%s, %s)" (print_expr pctx e1) (print_expr pctx e2)
 			| TBinop(OpUShr,e1,e2) ->
-				Printf.sprintf "HxOverrides.hx_rshift(%s, %s)" (print_expr pctx e1) (print_expr pctx e2)
+				Printf.sprintf "HxOverrides.rshift(%s, %s)" (print_expr pctx e1) (print_expr pctx e2)
 			| TBinop(OpAdd,e1,e2) when (is_type1 "" "String")(e.etype) || is_underlying_string e.etype ->
 				let safe_string ex =
 					match ex.eexpr with
@@ -1268,7 +1268,7 @@ module Printer = struct
 	and print_call pctx e1 el =
 		match e1.eexpr with
 			| TField(e1,((FAnon {cf_name = ("toUpperCase" | "toLowerCase" as s)}) | FDynamic ("toUpperCase" | "toLowerCase" as s))) ->
-				Printf.sprintf "HxOverrides.hx_%s(%s)" s (print_expr pctx e1)
+				Printf.sprintf "HxOverrides.%s(%s)" s (print_expr pctx e1)
 			| _ ->
 				print_call2 pctx e1 el
 

+ 11 - 19
std/python/internal/HxOverrides.hx

@@ -11,19 +11,26 @@ class HxOverrides {
 	// this two cases iterator and shift are like all methods in String and Array and are already handled in Reflect
 	// we need to modify the transformer to call Reflect directly
 
-	static public function iterator(x) {
+	inline static public function iterator(x) {
 		return Reflect.callMethod(null, Reflect.field(x, "iterator"), []);
 	}
 
-	static public function shift(x) {
+	inline static public function shift(x) {
 		return Reflect.callMethod(null, Reflect.field(x, "shift"), []);
 	}
+	inline static public function toUpperCase(x) {
+		return Reflect.callMethod(null, Reflect.field(x, "toUpperCase"), []);
+	}
+
+	inline static public function toLowerCase(x) {
+		return Reflect.callMethod(null, Reflect.field(x, "toLowerCase"), []);
+	}
 
-	static public function hx_rshift(val:Int, n:Int) {
+	static public function rshift(val:Int, n:Int) {
 		return Syntax.binop(Syntax.binop(val, "%", Syntax.untypedPython("0x100000000")), ">>", n);
 	}
 
-	static public function hx_modf(a:Float, b:Float) {
+	static public function modf(a:Float, b:Float) {
 		return Syntax.untypedPython("float('nan') if (b == 0.0) else a % b if a > 0 else -(-a % b)");
 	}
 
@@ -56,19 +63,4 @@ class HxOverrides {
 		}
 	}
 
-	static public function hx_toUpperCase(x) {
-		if (Std.is(x, String)) {
-			return (x:String).toUpperCase();
-		} else {
-			return x.toUpperCase();
-		}
-	}
-
-	static public function hx_toLowerCase(x) {
-		if (Std.is(x, String)) {
-			return (x:String).toLowerCase();
-		} else {
-			return x.toLowerCase();
-		}
-	}
 }