[mono-vb] Patch for mbas for ByRef parameters from a DLL

Bernie Solomon bernard@ugsolutions.com
Wed, 28 Jul 2004 10:37:33 -0700


This is a multi-part message in MIME format.

------=_NextPart_000_03EC_01C4748E.E42B5680
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

I attach a patch so that you can call methods in a referenced DLL that take
reference parameters and things compile. To do this I have made
ReflectionParameters return similar data to InternalParameters for ByRef
parameters - and also use them when GetFullParameters doesn't return
anything (presumably currently you can't call a method with optional
parameters in a different DLL).

Since I haven't done anything inside mbas before I may not have done this in
the right way. But if it is OK I can commit this.

Presumably a test case might be good but I am not quite sure where to add
this.

Bernie Solomon


------=_NextPart_000_03EC_01C4748E.E42B5680
Content-Type: text/plain;
	name="mbas.diffs.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="mbas.diffs.txt"

Index: expression.cs=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mcs/mbas/expression.cs,v=0A=
retrieving revision 1.53=0A=
diff -u -p -r1.53 expression.cs=0A=
--- expression.cs	22 Jul 2004 05:30:20 -0000	1.53=0A=
+++ expression.cs	28 Jul 2004 16:26:36 -0000=0A=
@@ -3651,6 +3651,7 @@ namespace Mono.MonoBASIC {=0A=
 					}=0A=
 					else {=0A=
 						param_type =3D pd.ParameterType (i);=0A=
+						Parameter.Modifier mod;=0A=
 						if (ps !=3D null) {=0A=
 							Parameter p =3D (Parameter) ps.FixedParameters[i];=0A=
 							bool IsDelegate =3D TypeManager.IsDelegateType (param_type);=0A=
@@ -3680,11 +3681,14 @@ namespace Mono.MonoBASIC {=0A=
 									return false;=0A=
 							}=0A=
 =0A=
-							if ((p.ModFlags & Parameter.Modifier.REF) !=3D 0) {=0A=
-								a =3D new Argument (a.Expr, Argument.AType.Ref);=0A=
-								if (!a.Resolve(ec,Location.Null))=0A=
-									return false;=0A=
-							}=0A=
+							mod =3D p.ModFlags;=0A=
+						} else=0A=
+							mod =3D pd.ParameterModifier (i);=0A=
+=0A=
+						if ((mod & Parameter.Modifier.REF) !=3D 0) {=0A=
+							a =3D new Argument (a.Expr, Argument.AType.Ref);=0A=
+							if (!a.Resolve(ec,Location.Null))=0A=
+								return false;=0A=
 						}=0A=
 					}	=0A=
=20
@@ -3757,6 +3761,9 @@ namespace Mono.MonoBASIC {=0A=
 				if ((p !=3D null) && ((p.ModFlags & Parameter.Modifier.REF) !=3D =
0)) {=0A=
 					a.ArgType =3D Argument.AType.Ref;=0A=
 					a.Resolve(ec, Location.Null);=0A=
+				} else if ((pd.ParameterModifier (i) & Parameter.Modifier.REF) !=3D =
0) {=0A=
+					a.ArgType =3D Argument.AType.Ref;=0A=
+					a.Resolve(ec, Location.Null);=0A=
 				}	=0A=
 				newarglist.Add(a);=0A=
 				int n =3D pd_count - arg_count;=0A=
@@ -3972,7 +3979,6 @@ namespace Mono.MonoBASIC {=0A=
 				if (pd.ParameterModifier (j) =3D=3D Parameter.Modifier.PARAMS &&=0A=
 			    	chose_params_expanded)=0A=
 					parameter_type =3D TypeManager.TypeToCoreType =
(parameter_type.GetElementType ());=0A=
-=0A=
 				if (a.Type !=3D parameter_type){=0A=
 					Expression conv;=0A=
 					=0A=
Index: support.cs=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/public/mcs/mbas/support.cs,v=0A=
retrieving revision 1.8=0A=
diff -u -p -r1.8 support.cs=0A=
--- support.cs	10 Nov 2003 20:56:33 -0000	1.8=0A=
+++ support.cs	28 Jul 2004 16:26:36 -0000=0A=
@@ -57,8 +57,12 @@ namespace Mono.MonoBASIC {=0A=
 			else=0A=
 				if (pos >=3D pi.Length)=0A=
 					return null;=0A=
-				else=0A=
-					return pi [pos].ParameterType;=0A=
+				else {=0A=
+					Type pt =3D pi [pos].ParameterType;=0A=
+                              		if (pt.IsByRef)=0A=
+						pt =3D pt.GetElementType();=0A=
+					return pt;=0A=
+				}=0A=
 		}=0A=
 =0A=
 		public string ParameterName (int pos)=0A=
@@ -98,7 +102,7 @@ namespace Mono.MonoBASIC {=0A=
 			=0A=
 			Type t =3D pi [pos].ParameterType;=0A=
 			if (t.IsByRef)=0A=
-				return Parameter.Modifier.ISBYREF;=0A=
+				return Parameter.Modifier.ISBYREF | Parameter.Modifier.REF;=0A=
 			=0A=
 			return Parameter.Modifier.NONE;=0A=
 		}=0A=

------=_NextPart_000_03EC_01C4748E.E42B5680--