浏览代码

[gen-hx-classes] Generate real field name

Cauê Waneck 10 年之前
父节点
当前提交
55926c3e06
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 10 2
      genxml.ml

+ 10 - 2
genxml.ml

@@ -441,9 +441,17 @@ let generate_type com t =
 		p "\t";
 		print_meta f.cf_meta;
 		if stat then p "static ";
+		let name = try (match Meta.get Meta.RealPath f.cf_meta with
+				| (Meta.RealPath, [EConst( String s ), _], _) ->
+					s
+				| _ ->
+					raise Not_found)
+			with Not_found ->
+				f.cf_name
+		in
 		(match f.cf_kind with
 		| Var v ->
-			p "var %s" f.cf_name;
+			p "var %s" name;
 			if v.v_read <> AccNormal || v.v_write <> AccNormal then p "(%s,%s)" (access true v.v_read) (access false v.v_write);
 			p " : %s" (stype f.cf_type);
 		| Method m ->
@@ -473,7 +481,7 @@ let generate_type com t =
 					assert false
 			) in
 			let tparams = (match f.cf_params with [] -> "" | l -> "<" ^ String.concat "," (List.map fst l) ^ ">") in
-			p "function %s%s(%s) : %s" f.cf_name tparams (String.concat ", " (List.map sparam params)) (stype ret);
+			p "function %s%s(%s) : %s" name tparams (String.concat ", " (List.map sparam params)) (stype ret);
 		);
 		p ";\n";
 		if Meta.has Meta.Overload f.cf_meta then List.iter (fun f -> print_field stat f) f.cf_overloads