2001-10-27 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Sat, 27 Oct 2001 19:39:42 +0000 (19:39 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sat, 27 Oct 2001 19:39:42 +0000 (19:39 -0000)
* Delegate.cs (Delegate.CombineImpl): Implement.
(Delegate.Combine): Implement.

* MulticastDelegate.cs (MulticastDelegate.Equals): Implement.

(MulticastDelegate.CombineImpl): This was not as trivial as I
thought.

* ContextStaticAttribute.cs: Added AttributeUsage to
ContextStaticAttribute.

* FlagsAttribute.cs: Add AttributeUsage to FlagsAttribute

svn path=/trunk/mcs/; revision=1216

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/ContextStaticAttribute.cs
mcs/class/corlib/System/Delegate.cs
mcs/class/corlib/System/FlagsAttribute.cs
mcs/class/corlib/System/MulticastDelegate.cs

index 4554de0e5c0044457840add20f6d2d121a0e66a3..ccd6aed0c5769f4dcd4cb85b820aa200c24e39ba 100644 (file)
@@ -1,3 +1,18 @@
+2001-10-27  Miguel de Icaza  <miguel@ximian.com>
+
+       * Delegate.cs (Delegate.CombineImpl): Implement.
+       (Delegate.Combine): Implement.
+
+       * MulticastDelegate.cs (MulticastDelegate.Equals): Implement.
+
+       (MulticastDelegate.CombineImpl): This was not as trivial as I
+       thought. 
+
+       * ContextStaticAttribute.cs: Added AttributeUsage to
+       ContextStaticAttribute. 
+
+       * FlagsAttribute.cs: Add AttributeUsage to FlagsAttribute
+
 2001-10-15  Martin Weindel <martin.weindel@t-online.de>
         * added Decimal.cs
         * added DecimalFormatter.cs (internal class used from System.Decimal)
index 5cde02b2befae5001c58077d187f40153cc9d9b7..bce04a4d58464871f5cc694579f952b14a5e457b 100755 (executable)
@@ -16,7 +16,8 @@ namespace System {
        /// <remarks>
        ///   
        /// </remarks>
-       public class ContextStatic : Attribute {
+       [AttributeUsage (AttributeTargets.Field)]
+       public class ContextStaticAttribute : Attribute {
 
                // No methods.
                
index efdaee459f042a5b1ac96b481f77c325700a3550..2143468f3b62f2f33ae5ebeea4e899c43eb68138 100644 (file)
@@ -19,7 +19,7 @@ namespace System {
                protected object target;
                protected string method;
                protected IntPtr method_ptr;
-               
+
                protected Delegate (object target, string method)
                {
                        if (target == null)
@@ -94,6 +94,26 @@ namespace System {
                {
                        // TODO: IMPLEMENT ME
                }
-               
+
+               public static Delegate Combine (Delegate a, Delegate b)
+               {
+                       if (a == null){
+                               if (b == null)
+                                       return null;
+                               return b;
+                       } else 
+                               if (b == null)
+                                       return a;
+
+                       if (a.GetType () != b.GetType ())
+                               throw new ArgumentException ("Incompatible Delegate Types");
+                       
+                       return a.CombineImpl (b);
+               }
+
+               protected virtual Delegate CombineImpl (Delegate d)
+               {
+                       throw new MulticastNotSupportedException ("");
+               }
        }
 }
index 26e3525f1d4e7c7dd54a57f5f87986003c7501d4..91cc4581bc619331b157dd145f4ef56f0b720731 100755 (executable)
@@ -18,6 +18,8 @@ namespace System {
        ///   a bit field.  This will allow the compiler and visual tools
        ///   to treat the bits in an enumeration as a set of flags.
        /// </remarks>
+
+       [AttributeUsage (AttributeTargets.Enum)]
        public class FlagsAttribute : Attribute {
 
                // No methods.
index 41a2dec7087b44d47f0510b37d3d69bbc5454169..2d31a7f994fc122a55db433e7fcaba4ae71c98f1 100644 (file)
@@ -13,16 +13,26 @@ namespace System {
 
        public abstract class MulticastDelegate : Delegate {
 
+               Delegate [] invocation_list;
+               
                protected MulticastDelegate (object target, string method)
                        : base (target, method)
                {
+                       invocation_list = null;
                }
 
                protected MulticastDelegate (Type target_type, string method)
                        : base (target_type, method)
                {
+                       invocation_list = null;
                }
 
+               private MulticastDelegate (Type target_type, string method, Delegate [] list)
+                       : base (target_type, method)
+               {
+                       invocation_list = list;
+               }
+               
 #if NOTYET
                public MethodInfo Method {
                        get {
@@ -31,22 +41,57 @@ namespace System {
                }
 #endif
 
-               //
-               // Methods
-               //
+               // <remarks>
+               //   Equals: two multicast delegates are equal if their base is equal
+               //   and their invocations list is equal.
+               // </remarks>
                public override bool Equals (object o)
                {
                        if (!(o is System.MulticastDelegate))
                                return false;
 
-                       return base.Equals (o);
+                       if (!base.Equals (o))
+                               return false;
+
+                       MulticastDelegate d = (MulticastDelegate) o;
+
+                       if (d.invocation_list == null){
+                               if (invocation_list == null)
+                                       return true;
+                               return false;
+                       } else if (invocation_list == null)
+                               return false;
+
+                       int i = 0;
+                       foreach (Delegate del in invocation_list){
+                               if (del != d.invocation_list [i++])
+                                       return false;
+                       }
+                       
+                       return true;
                }
 
+               //
+               // FIXME: This could use some improvements.
+               //
                public override int GetHashCode ()
                {
                        return base.GetHashCode ();
                }
 
-               
+               // <summary>
+               //   Combines this MulticastDelegate with the Delegate `follow'.
+               //   This can combine MulticastDelegates and Delegates
+               // </summary>
+               protected override Delegate CombineImpl (Delegate follow)
+               {
+                       throw new Exception ("IMPLEMENT ME");
+
+                       // FIXME: Implement me.
+                       // This is not as simple to implement, as we can
+                       // not create an instance of MulticastDelegate.
+                       //
+                       // Got to think more about this.
+               }
        }
 }