Prechádzať zdrojové kódy

don't handle keywords if function is extern, add keyword test

frabbit 11 rokov pred
rodič
commit
0c8f0569bc
2 zmenil súbory, kde vykonal 10 pridanie a 1 odobranie
  1. 6 1
      genpy.ml
  2. 4 0
      tests/unit/TestPython.hx

+ 6 - 1
genpy.ml

@@ -1007,8 +1007,13 @@ module Printer = struct
 			| _ -> print_expr pctx e1
 			| _ -> print_expr pctx e1
 		in
 		in
 		let name = field_name fa in
 		let name = field_name fa in
+		let is_extern = (match fa with
+		| FInstance(c,_) -> c.cl_extern
+		| FStatic(c,_) -> c.cl_extern
+		| _ -> false)
+		in
 		let do_default () =
 		let do_default () =
-			Printf.sprintf "%s.%s" obj (handle_keywords name)
+			Printf.sprintf "%s.%s" obj (if is_extern then name else (handle_keywords name))
 		in
 		in
 		match fa with
 		match fa with
 			| FInstance(c,{cf_name = "length" | "get_length"}) when (is_type "" "list")(TClassDecl c) ->
 			| FInstance(c,{cf_name = "length" | "get_length"}) when (is_type "" "list")(TClassDecl c) ->

+ 4 - 0
tests/unit/TestPython.hx

@@ -14,4 +14,8 @@ class TestPython extends Test {
 		eq(3, x);
 		eq(3, x);
 	}
 	}
 
 
+	public function testKeywords () {
+		var list = new Array();
+	}
+
 }
 }