2005-07-07 Ben Maurer <bmaurer@ximian.com>
authorBen Maurer <benm@mono-cvs.ximian.com>
Thu, 7 Jul 2005 05:39:38 +0000 (05:39 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Thu, 7 Jul 2005 05:39:38 +0000 (05:39 -0000)
* outline.cs:
   - Print out static for fields (how the hell did I let myself
   not put this in earlier!!!!!)
   - To print out const fields, we might need to quote
   things. This logic is not complete yet (for example, a string
   with \n will have a literal new line)
   - Try some smarter logic to get less verbosity by printing out
   fewer namespaces
   - Do a nicer sorting for methods. It sorts things by param
   type, then from fewest params to most. This makes overloads
   get sorted out cleanly.

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

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

index df64ccbe7fd107e3490f0571bf5f1480ddf09fe9..defcca1481fdc700ec3811bcc89dbaeb25fc0e45 100644 (file)
@@ -1,3 +1,17 @@
+2005-07-07  Ben Maurer  <bmaurer@ximian.com>
+
+       * outline.cs:
+          - Print out static for fields (how the hell did I let myself
+          not put this in earlier!!!!!)
+          - To print out const fields, we might need to quote
+          things. This logic is not complete yet (for example, a string
+          with \n will have a literal new line)
+          - Try some smarter logic to get less verbosity by printing out
+          fewer namespaces
+          - Do a nicer sorting for methods. It sorts things by param
+          type, then from fewest params to most. This makes overloads
+          get sorted out cleanly.
+
 2005-07-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * outline.cs: prevent nullref for non-public events.
index 765195b4fca714ed988b449dcd4ebbc10ae1862b..19cbc98f22298fcccb80121f39feb26a062f8953 100644 (file)
@@ -424,15 +424,23 @@ public class Outline {
                if (fi.IsPrivate)  o.Write ("private ");
                if (fi.IsAssembly) o.Write ("internal ");
                if (fi.IsLiteral)  o.Write ("const ");
+               else if (fi.IsStatic) o.Write ("static ");
                if (fi.IsInitOnly) o.Write ("readonly ");
 
                o.Write (FormatType (fi.FieldType));
                o.Write (" ");
                o.Write (fi.Name);
-               if (fi.IsLiteral)
-               {
+               if (fi.IsLiteral) { 
+                       object v = fi.GetValue (this);
+
+                       // TODO: Escape values here
                        o.Write (" = ");
-                       o.Write (fi.GetValue (this));
+                       if (v is char)
+                               o.Write ("'{0}'", v);
+                       else if (v is string)
+                               o.Write ("\"{0}\"", v);
+                       else
+                               o.Write (fi.GetValue (this));
                }
                o.Write (";");
        }
@@ -515,6 +523,8 @@ public class Outline {
                return sb.ToString ();
        }
        
+       // TODO: fine tune this so that our output is less verbose. We need to figure
+       // out a way to do this while not making things confusing.
        string FormatType (Type t)
        {
                string type = GetFullName (t);
@@ -559,7 +569,17 @@ public class Outline {
        
                if (type.LastIndexOf(".") == 6)
                        return type.Substring(7);
-               
+
+               //
+               // If the namespace of the type is the namespace of what
+               // we are printing (or is a member of one if its children
+               // don't print it. This basically means that in C# we would
+               // automatically get the namespace imported by virtue of the
+               // namespace {} block.
+               //      
+               if (t.Namespace.StartsWith (this.t.Namespace))
+                       return type.Substring (t.Namespace.Length + 1);
+       
                return type;
        }
 
@@ -822,9 +842,27 @@ public class Comparer : IComparer  {
        {
                MethodBase aa = (MethodBase) a, bb = (MethodBase) b;
                
-               if (aa.IsStatic == bb.IsStatic)
-                       return CompareMemberInfo (a, b);
-               
+               if (aa.IsStatic == bb.IsStatic) {
+                       int c = CompareMemberInfo (a, b);
+                       if (c != 0)
+                               return c;
+                       ParameterInfo [] ap, bp;
+
+                       //
+                       // Sort overloads by the names of their types
+                       // put methods with fewer params first.
+                       //
+                       
+                       ap = aa.GetParameters ();
+                       bp = bb.GetParameters ();
+                       int n = Math.Min (ap.Length, bp.Length);
+
+                       for (int i = 0; i < n; i ++)
+                               if ((c = CompareType (ap [i].ParameterType, bp [i].ParameterType)) != 0)
+                                       return c;
+
+                       return ap.Length.CompareTo (bp.Length);
+               }
                if (aa.IsStatic)
                        return -1;