Parcourir la source

[cs] add -D unity46-line-numbers (closes #3759)

Dan Korostelev il y a 10 ans
Parent
commit
6edf775eda
2 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 3 0
      common.ml
  2. 2 1
      gencs.ml

+ 3 - 0
common.ml

@@ -234,6 +234,7 @@ module Define = struct
 		| SwfUseDoAbc
 		| SwfUseDoAbc
 		| Sys
 		| Sys
 		| UnityStdTarget
 		| UnityStdTarget
+		| Unity46LineNumbers
 		| Unsafe
 		| Unsafe
 		| UseNekoc
 		| UseNekoc
 		| UseRttiDoc
 		| UseRttiDoc
@@ -314,6 +315,8 @@ module Define = struct
 		| SwfUseDoAbc -> ("swf_use_doabc", "Use DoAbc swf-tag instead of DoAbcDefine")
 		| SwfUseDoAbc -> ("swf_use_doabc", "Use DoAbc swf-tag instead of DoAbcDefine")
 		| Sys -> ("sys","Defined for all system platforms")
 		| Sys -> ("sys","Defined for all system platforms")
 		| UnityStdTarget -> ("unity_std_target", "Changes C# sources location so that each generated C# source is relative to the Haxe source location. If the location is outside the current directory, the value set here will be used")
 		| UnityStdTarget -> ("unity_std_target", "Changes C# sources location so that each generated C# source is relative to the Haxe source location. If the location is outside the current directory, the value set here will be used")
+		(* see https://github.com/HaxeFoundation/haxe/issues/3759 *)
+		| Unity46LineNumbers -> ("unity46_line_numbers", "Fixes line numbers in generated C# files for Unity 4.6 Mono compiler")
 		| Unsafe -> ("unsafe","Allow unsafe code when targeting C#")
 		| Unsafe -> ("unsafe","Allow unsafe code when targeting C#")
 		| UseNekoc -> ("use_nekoc","Use nekoc compiler instead of internal one")
 		| UseNekoc -> ("use_nekoc","Use nekoc compiler instead of internal one")
 		| UseRttiDoc -> ("use_rtti_doc","Allows access to documentation during compilation")
 		| UseRttiDoc -> ("use_rtti_doc","Allows access to documentation during compilation")

+ 2 - 1
gencs.ml

@@ -1109,7 +1109,8 @@ let configure gen =
 		else fun w p ->
 		else fun w p ->
 			let cur_line = Lexer.get_error_line p in
 			let cur_line = Lexer.get_error_line p in
 			let file = Common.get_full_path p.pfile in
 			let file = Common.get_full_path p.pfile in
-			if cur_line <> ((!last_line)+1) then begin print w "#line %d \"%s\"" cur_line (Ast.s_escape file); newline w end;
+			let line = if Common.defined gen.gcon Define.Unity46LineNumbers then cur_line - 1 else cur_line in
+			if cur_line <> ((!last_line)+1) then begin print w "#line %d \"%s\"" line (Ast.s_escape file); newline w end;
 			last_line := cur_line
 			last_line := cur_line
 	in
 	in