Author: miguel
Date: 2005-03-24 20:27:17 -0500 (Thu, 24 Mar 2005)
New Revision: 42243

Modified:
   trunk/mcs/class/corlib/System.Reflection.Emit/ChangeLog
   trunk/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs
   trunk/mcs/class/corlib/System/ChangeLog
   trunk/mcs/class/corlib/System/Delegate.cs
Log:
2005-03-24  Miguel de Icaza  <[EMAIL PROTECTED]>

        * DynamicMethod.cs (CreateDelegate): Add second overload based on
        the first one that allows for a `target' argument.

2005-03-24  Miguel de Icaza  <[EMAIL PROTECTED]>

        * Delegate.cs: Add CreateDelegate with a target option, currently
        internal as it is not exposed by the framework yet.




Modified: trunk/mcs/class/corlib/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System/ChangeLog     2005-03-25 00:35:30 UTC (rev 
42242)
+++ trunk/mcs/class/corlib/System/ChangeLog     2005-03-25 01:27:17 UTC (rev 
42243)
@@ -1,3 +1,8 @@
+2005-03-24  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * Delegate.cs: Add CreateDelegate with a target option, currently
+       internal as it is not exposed by the framework yet.
+
 2005-03-24  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * String.cs: Add some 2.0 methods.

Modified: trunk/mcs/class/corlib/System/Delegate.cs
===================================================================
--- trunk/mcs/class/corlib/System/Delegate.cs   2005-03-25 00:35:30 UTC (rev 
42242)
+++ trunk/mcs/class/corlib/System/Delegate.cs   2005-03-25 01:27:17 UTC (rev 
42243)
@@ -107,7 +107,7 @@
                                throw new ArgumentNullException ("method");
 
                        if (!type.IsSubclassOf (typeof (MulticastDelegate)))
-                               throw new ArgumentException ("type");
+                               throw new ArgumentException ("type is not a 
subclass of Multicastdelegate");
 
                        if (!method.IsStatic)
                                throw new ArgumentException ("The method should 
be static.", "method");
@@ -116,16 +116,35 @@
                        ParameterInfo[] args = method.GetParameters ();
 
                        if (args.Length != delargs.Length)
-                               throw new ArgumentException ("method");
+                               throw new ArgumentException ("method argument 
length mismatch");
                        
                        int length = delargs.Length;
                        for (int i = 0; i < length; i++)
                                if (delargs [i].ParameterType != args 
[i].ParameterType)
-                                       throw new ArgumentException ("method");
+                                       throw new ArgumentException ("method 
arguments are incompatible");
 
                        return CreateDelegate_internal (type, null, method);
                }
 
+               //
+               // This method is internal because this exact signature does 
+               // not exist on the framework.
+               //
+               internal static Delegate CreateDelegate (Type type, object 
target, MethodInfo method)
+               {
+                       if (type == null)
+                               throw new ArgumentNullException ("type");
+
+                       if (method == null)
+                               throw new ArgumentNullException ("method");
+
+                       if (!type.IsSubclassOf (typeof (MulticastDelegate)))
+                               throw new ArgumentException ("type is not a 
subclass of Multicastdelegate");
+
+                       return CreateDelegate_internal (type, target, method);
+
+               }
+               
                public static Delegate CreateDelegate (Type type, object 
target, string method)
                {
                        return CreateDelegate(type, target, method, false);

Modified: trunk/mcs/class/corlib/System.Reflection.Emit/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Reflection.Emit/ChangeLog     2005-03-25 
00:35:30 UTC (rev 42242)
+++ trunk/mcs/class/corlib/System.Reflection.Emit/ChangeLog     2005-03-25 
01:27:17 UTC (rev 42243)
@@ -1,3 +1,8 @@
+2005-03-24  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * DynamicMethod.cs (CreateDelegate): Add second overload based on
+       the first one that allows for a `target' argument.
+
 2005-03-24  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * MethodRental.cs: Added Demand for UnmanagedCode on SwapMethodBody 
@@ -10,8 +15,8 @@
 
 2005-03-09  Marek Safar  <[EMAIL PROTECTED]>
 
-       * ILGenerator.cs (DeclareLocal): Throw an exception for null argument.
-
+       * ILGenerator.cs (DeclareLocal): Throw an exception for null argument.
+
 2005-03-01  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * CustomAttributeBuilder.cs UnmanagedMarshal.cs: Allow sizeConst and

Modified: trunk/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs
===================================================================
--- trunk/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs      
2005-03-25 00:35:30 UTC (rev 42242)
+++ trunk/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs      
2005-03-25 01:27:17 UTC (rev 42243)
@@ -110,7 +110,8 @@
                                create_dynamic_method (this);
                }
 
-               public Delegate CreateDelegate (Type delegateType) {
+               public Delegate CreateDelegate (Type delegateType)
+               {
                        if (delegateType == null)
                                throw new ArgumentNullException 
("delegateType");
                        if (deleg != null)
@@ -122,6 +123,19 @@
                        return deleg;
                }
 
+               public Delegate CreateDelegate (Type delegateType, object 
target)
+               {
+                       if (delegateType == null)
+                               throw new ArgumentNullException 
("delegateType");
+                       if (deleg != null)
+                               return deleg;
+
+                       CreateDynMethod ();
+
+                       deleg = Delegate.CreateDelegate (delegateType, target, 
this);
+                       return deleg;
+               }
+               
                [MonoTODO]
                public ParameterBuilder DefineParameter (int position, 
ParameterAttributes attributes, string strParamName)
                {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to