* outline.cs: Friendly display of ifaces on -d
authorBen Maurer <benm@mono-cvs.ximian.com>
Sat, 9 Jul 2005 21:50:07 +0000 (21:50 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Sat, 9 Jul 2005 21:50:07 +0000 (21:50 -0000)
svn path=/trunk/mcs/; revision=47148

mcs/tools/monop/ChangeLog
mcs/tools/monop/outline.cs

index cf3fdeeb7b269cf5bf15f9046852941bd9057a95..ec083afdf14cb1bd0cc1d7d0ff6873801072c0f6 100644 (file)
@@ -1,5 +1,7 @@
 2005-07-09  Ben Maurer  <bmaurer@ximian.com>
 
+       * outline.cs: Friendly display of ifaces on -d
+       
        * outline.cs: Always show explicit interface impls. Don't display
        the wrong flags for them.
 
index 2af016b8d32f85935565c3128c01086c5459fcce..ea89eb079620dc02a7bea0689702389222488bcd 100644 (file)
@@ -67,7 +67,7 @@ public class Outline {
                o.Write (GetTypeKind (t));
                o.Write (" ");
                
-               Type [] interfaces = (Type []) Comparer.Sort (t.GetInterfaces ());
+               Type [] interfaces = (Type []) Comparer.Sort (TypeGetInterfaces (t, options.DeclaredOnly));
                Type parent = t.BaseType;
 
                if (t.IsSubclassOf (typeof (System.MulticastDelegate))) {
@@ -669,8 +669,7 @@ public class Outline {
 
                foreach (Type t in args) {
                        bool first = true;
-                       Type[] ifaces = t.GetInterfaces();
-                       ifaces = Array.FindAll<Type> (ifaces, delegate (Type iface) { return !iface.IsAssignableFrom (t.BaseType); });
+                       Type[] ifaces = TypeGetInterfaces (t, true);
                        
                        GenericParameterAttributes attrs = t.GenericParameterAttributes & GenericParameterAttributes.SpecialConstraintMask;
                        GenericParameterAttributes [] interesting = {
@@ -822,6 +821,25 @@ public class Outline {
                // What am I !!!
                return true;
        }
+
+       static Type [] TypeGetInterfaces (Type t, bool declonly)
+       {
+               Type [] ifaces = t.GetInterfaces ();
+               if (! declonly)
+                       return ifaces;
+
+               // Handle Object. Also, optimize for no interfaces
+               if (t.BaseType == null || ifaces.Length == 0)
+                       return ifaces;
+
+               ArrayList ar = new ArrayList ();
+
+               foreach (Type i in ifaces)
+                       if (! i.IsAssignableFrom (t.BaseType))
+                               ar.Add (i);
+
+               return (Type []) ar.ToArray (typeof (Type));
+       }
 }
 
 public class Comparer : IComparer  {