[Mono-list] [Repost] [Patch] More changes in corlib

Tim Coleman tim@timcoleman.com
Tue, 6 Aug 2002 20:12:20 -0400


This is a multi-part message in MIME format.

--Multipart_Tue__6_Aug_2002_20:12:20_-0400_0837e940
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

I thought I would be a little more explicit in the subject for this one.

Begin forwarded message:

Date: Tue, 6 Aug 2002 17:11:41 -0400
From: Tim Coleman <tim@timcoleman.com>
To: mono-list@ximian.com
Subject: [Mono-list] More changes in corlib


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



-- 
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

--Multipart_Tue__6_Aug_2002_20:12:20_-0400_0837e940
Content-Type: text/plain;
 name="diff"
Content-Disposition: attachment;
 filename="diff"
Content-Transfer-Encoding: 7bit

? 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;
 		}


--Multipart_Tue__6_Aug_2002_20:12:20_-0400_0837e940--