Selaa lähdekoodia

change String handling again

Simon Krajewski 11 vuotta sitten
vanhempi
commit
38ed941b31
3 muutettua tiedostoa jossa 10 lisäystä ja 9 poistoa
  1. 8 6
      genpy.ml
  2. 0 1
      std/python/_std/String.hx
  3. 2 2
      std/python/internal/StringImpl.hx

+ 8 - 6
genpy.ml

@@ -856,7 +856,7 @@ module Printer = struct
 		)
 
 	let is_underlying_string t = match follow t with
-		| TAbstract(a,tl) -> (is_type1 "" "_hx_c_String")(Codegen.Abstract.get_underlying_type a tl)
+		| TAbstract(a,tl) -> (is_type1 "" "String")(Codegen.Abstract.get_underlying_type a tl)
 		| _ -> false
 
 	let handle_keywords s =
@@ -1004,7 +1004,7 @@ module Printer = struct
 				Printf.sprintf "_hx_modf(%s, %s)" (print_expr pctx e1) (print_expr pctx e2)
 			| TBinop(OpUShr,e1,e2) ->
 				Printf.sprintf "_hx_rshift(%s, %s)" (print_expr pctx e1) (print_expr pctx e2)
-			| TBinop(OpAdd,e1,e2) when (is_type1 "" "_hx_c_String")(e.etype) || is_underlying_string e.etype ->
+			| TBinop(OpAdd,e1,e2) when (is_type1 "" "String")(e.etype) || is_underlying_string e.etype ->
 				let safe_string ex =
 					match ex.eexpr with
 						| TConst(TString _) -> print_expr pctx ex
@@ -1108,12 +1108,14 @@ module Printer = struct
 		match fa with
 			| FInstance(c,{cf_name = "length" | "get_length"}) when (is_type "" "list")(TClassDecl c) ->
 				Printf.sprintf "_hx_builtin.len(%s)" (print_expr pctx e1)
-			| FInstance(c,{cf_name = "toUpperCase"}) when (is_type "" "_hx_c_String")(TClassDecl c) ->
+			| FInstance(c,{cf_name = "toUpperCase"}) when (is_type "" "String")(TClassDecl c) ->
 				Printf.sprintf "%s.toUpper" (print_expr pctx e1)
-			| FInstance(c,{cf_name = "toLowerCase"}) when (is_type "" "_hx_c_String")(TClassDecl c) ->
+			| FInstance(c,{cf_name = "toLowerCase"}) when (is_type "" "String")(TClassDecl c) ->
 				Printf.sprintf "%s.toLower" (print_expr pctx e1)
-			| FInstance(c,{cf_name = "length"}) when (is_type "" "_hx_c_String")(TClassDecl c) ->
+			| FInstance(c,{cf_name = "length"}) when (is_type "" "String")(TClassDecl c) ->
 				Printf.sprintf "_hx_builtin.len(%s)" (print_expr pctx e1)
+			| FStatic(c,{cf_name = "fromCharCode"}) when (is_type "" "String")(TClassDecl c) ->
+				Printf.sprintf "HxString.fromCharCode"
 			| FInstance _ | FStatic _ ->
 				do_default ()
 			| FAnon cf when name = "iterator" && not is_assign ->
@@ -1148,7 +1150,7 @@ module Printer = struct
 			let indent = pctx.pc_indent in
 			let handle_base_type bt =
 				let t = print_base_type bt in
-				let res = if t = "_hx_c_String" then
+				let res = if t = "String" then
 					Printf.sprintf "if isinstance(_hx_e1, str):\n%s\t%s = _hx_e1\n%s\t%s" indent v.v_name indent (print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} e)
 				else
 					Printf.sprintf "if isinstance(_hx_e1, %s):\n%s\t%s = _hx_e1\n%s\t%s" t indent v.v_name indent (print_expr {pctx with pc_indent = "\t" ^ pctx.pc_indent} e)

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

@@ -36,7 +36,6 @@ import python.internal.StringImpl;
 import python.lib.Builtin;
 #end
 @:coreApi
-@:native("_hx_c_String")
 extern class String extends StringImpl {
 
 

+ 2 - 2
std/python/internal/StringImpl.hx

@@ -4,7 +4,7 @@ package python.internal;
 import python.lib.Builtin;
 
 @:keep
-@:native("_hx_c_String")
+@:native("HxString")
 class StringImpl {
 
 	public static function split (s:String, d:String) {
@@ -36,7 +36,7 @@ class StringImpl {
 	}
 
 	public static inline function fromCharCode( code : Int ) : String {
-		#if doc_gen 
+		#if doc_gen
 		return "";
 		#else
 		var c = code;