diff --git a/ChangeLog b/ChangeLog index d6763f18e..eb640a9a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-02-19 Mike Kestner + + * generator/Statistics.cs : New. Gathers stats about generation. + * generator/*.cs : Hook in the stat counters. + 2002-02-18 Mike Kestner * generator/StructBase.cs (GenCtor): StudCapsify static method names. diff --git a/generator/BoxedGen.cs b/generator/BoxedGen.cs index 1bdf30111..6a027ca5d 100644 --- a/generator/BoxedGen.cs +++ b/generator/BoxedGen.cs @@ -63,16 +63,20 @@ namespace GtkSharp.Generation { switch (node.Name) { case "field": + Statistics.IgnoreCount++; // GenField(member, table, sw); break; case "callback": + Statistics.IgnoreCount++; break; case "constructor": + Statistics.IgnoreCount++; break; case "method": + Statistics.IgnoreCount++; break; default: @@ -87,6 +91,7 @@ namespace GtkSharp.Generation { sw.Flush(); sw.Close(); + Statistics.BoxedCount++; } } } diff --git a/generator/CallbackGen.cs b/generator/CallbackGen.cs index 75fb1560a..9fab6f3e3 100644 --- a/generator/CallbackGen.cs +++ b/generator/CallbackGen.cs @@ -86,13 +86,14 @@ namespace GtkSharp.Generation { if (node.Name != "member") { continue; } - //FIXME: Generate the methods. + //FIXME: Generate the method. XmlElement member = (XmlElement) node; } sw.WriteLine ("}"); sw.Flush(); sw.Close(); + Statistics.CBCount++; } } diff --git a/generator/CodeGenerator.cs b/generator/CodeGenerator.cs index b720ba91c..7ad954cbb 100644 --- a/generator/CodeGenerator.cs +++ b/generator/CodeGenerator.cs @@ -29,6 +29,7 @@ namespace GtkSharp.Generation { gen.Generate (table); } + Statistics.Report(); return 0; } diff --git a/generator/EnumGen.cs b/generator/EnumGen.cs index b8380c95a..a9058342f 100644 --- a/generator/EnumGen.cs +++ b/generator/EnumGen.cs @@ -105,6 +105,7 @@ namespace GtkSharp.Generation { sw.Flush(); sw.Close(); + Statistics.EnumCount++; } } diff --git a/generator/InterfaceGen.cs b/generator/InterfaceGen.cs index b61fb057d..e9ddd1e3f 100644 --- a/generator/InterfaceGen.cs +++ b/generator/InterfaceGen.cs @@ -95,6 +95,7 @@ namespace GtkSharp.Generation { sw.Flush(); sw.Close(); + Statistics.IFaceCount++; } } diff --git a/generator/ObjectGen.cs b/generator/ObjectGen.cs index 143721b54..a0186b8cc 100644 --- a/generator/ObjectGen.cs +++ b/generator/ObjectGen.cs @@ -80,12 +80,14 @@ namespace GtkSharp.Generation { switch (node.Name) { case "field": + Statistics.IgnoreCount++; //if (!GenField(member, table, sw)) { // Console.WriteLine("in object " + CName); //} break; case "callback": + Statistics.IgnoreCount++; break; case "constructor": @@ -150,6 +152,7 @@ namespace GtkSharp.Generation { sw.Flush(); sw.Close(); + Statistics.ObjectCount++; } public bool GenProperty (XmlElement prop, SymbolTable table, StreamWriter sw, out String name) @@ -174,6 +177,7 @@ namespace GtkSharp.Generation { } else if (table.IsInterface(c_type)) { // FIXME: Handle interface props properly. Console.Write("Interface property detected "); + Statistics.ThrottledCount++; return true; } else { m_type = table.GetMarshalType(c_type); @@ -181,6 +185,7 @@ namespace GtkSharp.Generation { if ((cs_type == "") || (m_type == "")) { Console.Write("Property has unknown Type {0} ", c_type); + Statistics.ThrottledCount++; return false; } @@ -210,6 +215,7 @@ namespace GtkSharp.Generation { sw.WriteLine("\t\t}"); sw.WriteLine(); + Statistics.PropCount++; return true; } @@ -220,6 +226,7 @@ namespace GtkSharp.Generation { String marsh = SignalHandler.GetName(sig, table); if (marsh == "") { + Statistics.ThrottledCount++; return false; } @@ -245,6 +252,7 @@ namespace GtkSharp.Generation { sw.WriteLine("\t\t}"); sw.WriteLine(); + Statistics.SignalCount++; return true; } } diff --git a/generator/Statistics.cs b/generator/Statistics.cs new file mode 100644 index 000000000..490070e6c --- /dev/null +++ b/generator/Statistics.cs @@ -0,0 +1,153 @@ +// Statistics.cs : Generation statistics class implementation +// +// Author: Mike Kestner +// +// 2002 Mike Kestner + +namespace GtkSharp.Generation { + + using System; + using System.Collections; + + public class Statistics { + + static int cbs = 0; + static int enums = 0; + static int objects = 0; + static int structs = 0; + static int boxed = 0; + static int interfaces = 0; + static int methods = 0; + static int ctors = 0; + static int props = 0; + static int sigs = 0; + static int throttled = 0; + static int ignored = 0; + + public static int CBCount { + get { + return cbs; + } + set { + cbs = value; + } + } + + public static int EnumCount { + get { + return enums; + } + set { + enums = value; + } + } + + public static int ObjectCount { + get { + return objects; + } + set { + objects = value; + } + } + + public static int StructCount { + get { + return structs; + } + set { + structs = value; + } + } + + public static int BoxedCount { + get { + return boxed; + } + set { + boxed = value; + } + } + + public static int CtorCount { + get { + return ctors; + } + set { + ctors = value; + } + } + + public static int MethodCount { + get { + return methods; + } + set { + methods = value; + } + } + + public static int PropCount { + get { + return props; + } + set { + props = value; + } + } + + public static int SignalCount { + get { + return sigs; + } + set { + sigs = value; + } + } + + public static int IFaceCount { + get { + return interfaces; + } + set { + interfaces = value; + } + } + + public static int ThrottledCount { + get { + return throttled; + } + set { + throttled = value; + } + } + + public static int IgnoreCount { + get { + return ignored; + } + set { + ignored = value; + } + } + + public static void Report() + { + Console.WriteLine("Generation Summary:"); + Console.WriteLine("\tEnums: " + enums); + Console.WriteLine("\tStructs: " + structs); + Console.WriteLine("\tBoxed: " + boxed); + Console.WriteLine("\tInterfaces: " + interfaces); + Console.WriteLine("\tCallbacks: " + cbs); + Console.WriteLine("\tObjects: " + objects); + Console.WriteLine("\tProperties: " + props); + Console.WriteLine("\tSignals: " + sigs); + Console.WriteLine("\tMethods: " + methods); + Console.WriteLine("\tConstructors: " + ctors); + Console.WriteLine("\tThrottled: " + throttled); + Console.WriteLine("\tIgnored: " + ignored); + Console.WriteLine("Total Nodes: " + (enums+structs+boxed+interfaces+cbs+objects+props+sigs+methods+ctors+throttled+ignored)); + } + } +} diff --git a/generator/StructBase.cs b/generator/StructBase.cs index 148b5c40c..fc9301fc1 100644 --- a/generator/StructBase.cs +++ b/generator/StructBase.cs @@ -62,6 +62,7 @@ namespace GtkSharp.Generation { call = "(" + call + ")"; } else { Console.Write("ctor "); + Statistics.ThrottledCount++; return false; } @@ -99,6 +100,7 @@ namespace GtkSharp.Generation { sw.WriteLine("\t\t}"); sw.WriteLine(); + Statistics.CtorCount++; return true; } @@ -117,6 +119,7 @@ namespace GtkSharp.Generation { if (cs_type == "") { Console.WriteLine ("Field has unknown Type {0}", c_type); + Statistics.ThrottledCount++; return false; } @@ -146,12 +149,14 @@ namespace GtkSharp.Generation { call = "(Handle, " + call + ")"; } else { Console.Write("method "); + Statistics.ThrottledCount++; return false; } XmlElement ret_elem = method["return-type"]; if (ret_elem == null) { Console.Write("Missing return type in method "); + Statistics.ThrottledCount++; return false; } @@ -161,6 +166,7 @@ namespace GtkSharp.Generation { String s_ret = table.GetCSType(rettype); if (m_ret == "" || s_ret == "") { Console.Write("rettype: " + rettype + " method "); + Statistics.ThrottledCount++; return false; } @@ -184,6 +190,7 @@ namespace GtkSharp.Generation { sw.WriteLine("\t\t}"); sw.WriteLine(); + Statistics.MethodCount++; return true; } diff --git a/generator/StructGen.cs b/generator/StructGen.cs index 142b372c4..755537d18 100644 --- a/generator/StructGen.cs +++ b/generator/StructGen.cs @@ -63,16 +63,20 @@ namespace GtkSharp.Generation { switch (node.Name) { case "field": + Statistics.IgnoreCount++; // GenField(member, table, sw); break; case "callback": + Statistics.IgnoreCount++; break; case "constructor": + Statistics.IgnoreCount++; break; case "method": + Statistics.IgnoreCount++; break; default: @@ -87,6 +91,7 @@ namespace GtkSharp.Generation { sw.Flush(); sw.Close(); + Statistics.StructCount++; } } }