[Mono-list] More changes in corlib

Tim Coleman tim@timcoleman.com
Tue, 6 Aug 2002 17:11:41 -0400


--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Here's a patch for some more changes that I would like to make in
corlib.  These are required for my Xml serialization that I'm working
on.

The two classes affected are System.MonoType and
System.Reflection.MonoProperty.

I implemented the GetMethodImpl () method in MonoType and 
in MonoProperty I added support for indexed parameters to the
GetValue method.

The patch is attached.  Yea or nay?

Thanks

-- 
Tim Coleman <tim@timcoleman.com>                       [43.28 N 80.31 W]
BMath, Honours Combinatorics and Optimization, University of Waterloo
"Under capitalism, man exploits man.  Under communism, it's just the
 opposite." -- J.K. Galbraith

--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

? library-deps.stamp
Index: System/MonoType.cs
===================================================================
RCS file: /cvs/public/mcs/class/corlib/System/MonoType.cs,v
retrieving revision 1.24
diff -u -u -r1.24 MonoType.cs
--- System/MonoType.cs	6 Aug 2002 16:59:01 -0000	1.24
+++ System/MonoType.cs	6 Aug 2002 21:11:23 -0000
@@ -110,13 +110,49 @@
 		[MethodImplAttribute(MethodImplOptions.InternalCall)]
 		public extern override MethodInfo[] GetMethods (BindingFlags bindingAttr);
 
+		[MonoTODO ("Complete this method.")]
 		protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr,
 							     Binder binder,
 							     CallingConventions callConvention,
 							     Type[] types, ParameterModifier[] modifiers)
 		{
-			// FIXME
-			throw new NotImplementedException ();
+			// fixme: needs to use the binder, and send the modifiers to that binder
+			if (null == name || types == null)
+				throw new ArgumentNullException ();
+			
+			MethodInfo ret = null;
+			MethodInfo [] methods = GetMethods(bindingAttr);
+
+			foreach (MethodInfo info in methods) {
+					if (info.Name != name) 
+						continue;
+
+					if (types.Length > 0) {
+						ParameterInfo[] parameterInfo = info.GetParameters ();
+
+						if (parameterInfo.Length != types.Length)
+							continue;
+
+						int i;
+						bool match = true;
+
+						for (i = 0; i < types.Length; i ++)
+							if (parameterInfo [i].ParameterType != types [i]) {
+								match = false;
+								break;
+							}
+
+						if (!match)
+							continue;
+					}
+
+					if (null != ret)
+						throw new AmbiguousMatchException();
+
+					ret = info;
+			}
+
+			return ret;
 		}
 		
 		public override Type GetNestedType( string name, BindingFlags bindingAttr)
Index: System.Reflection/MonoProperty.cs
===================================================================
RCS file: /cvs/public/mcs/class/corlib/System.Reflection/MonoProperty.cs,v
retrieving revision 1.8
diff -u -u -r1.8 MonoProperty.cs
--- System.Reflection/MonoProperty.cs	1 Jul 2002 16:02:45 -0000	1.8
+++ System.Reflection/MonoProperty.cs	6 Aug 2002 21:11:23 -0000
@@ -142,13 +142,13 @@
 		public override object GetValue( object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) {
 			object ret = null;
 			
-			if (index == null || index.Length == 0) {
-				MethodInfo method = GetGetMethod(false);
+			MethodInfo method = GetGetMethod(false);
+			ret = method.Invoke(obj, invokeAttr, binder, index, culture);
 
+			if (index == null || index.Length == 0) 
 				ret = method.Invoke(obj, invokeAttr, binder, null, culture);
-			}
-
-			// fixme: support indexed parameters..
+			else 
+				ret = method.Invoke(obj, invokeAttr, binder, index, culture);
 
 			return ret;
 		}

--xHFwDpU9dbj6ez1V--