Browse Source

[cs] Fixed recognition on -net-lib. Closes #3574

Cauê Waneck 10 years ago
parent
commit
b922885b72
3 changed files with 22 additions and 1 deletions
  1. 3 1
      gencs.ml
  2. 10 0
      tests/unit/native_cs/src/haxe/test/MyClass.cs
  3. 9 0
      tests/unit/src/unit/TestCSharp.hx

+ 3 - 1
gencs.ml

@@ -3350,7 +3350,9 @@ let convert_ilmethod ctx p m is_explicit_impl =
 		let args = List.map (fun (name,flag,s) ->
 			let t = match s.snorm with
 				| LManagedPointer s ->
-					mk_type_path ctx (["cs"],[],"Ref") [ TPType (convert_signature ctx p s) ]
+					let is_out = List.mem POut flag.pf_io && not (List.mem PIn flag.pf_io) in
+					let name = if is_out then "Out" else "Ref" in
+					mk_type_path ctx (["cs"],[],name) [ TPType (convert_signature ctx p s) ]
 				| _ ->
 					convert_signature ctx p (change_sig s.snorm)
 			in

+ 10 - 0
tests/unit/native_cs/src/haxe/test/MyClass.cs

@@ -47,6 +47,16 @@ public class MyClass
 	{
 	}
 
+	public void outTest(out int i)
+	{
+		i = 42;
+	}
+
+	public void refTest(ref int i)
+	{
+		i *= 42;
+	}
+
 	public void dispatch()
 	{
 		if (voidvoid != null)

+ 9 - 0
tests/unit/src/unit/TestCSharp.hx

@@ -327,6 +327,11 @@ class TestCSharp extends Test
 		cl.test = 100;
 		cl.refTest(cl.test);
 		eq(cl.test,400);
+
+		i = 10;
+		var cl = new haxe.test.MyClass();
+		cl.refTest(i);
+		eq(i,420);
 	}
 
 	public function testOut()
@@ -342,6 +347,10 @@ class TestCSharp extends Test
 		cl.test = 20;
 		cl.outTest(cl.test, 10);
 		eq(cl.test,40);
+
+		var cl = new haxe.test.MyClass();
+		cl.outTest(i);
+		eq(i,42);
 	}
 
 	public function testChecked()