diff --git a/ChangeLog b/ChangeLog index 680c4418e..919950db3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-11-22 Dan Winship + + * generator/ClassBase.cs: + * generator/ObjectGen.cs: Move child property handling from + ClassBase to ObjectGen (as suggested by Mike) since it's only + used there + 2004-11-18 Mike Kestner * generator/InterfaceGen.cs : beginnings of a real diff --git a/generator/ClassBase.cs b/generator/ClassBase.cs index cdaa11410..1fc7e7cf3 100644 --- a/generator/ClassBase.cs +++ b/generator/ClassBase.cs @@ -31,7 +31,6 @@ namespace GtkSharp.Generation { public class ClassBase : GenBase { protected Hashtable props = new Hashtable(); - protected Hashtable childprops = new Hashtable(); protected Hashtable sigs = new Hashtable(); protected Hashtable methods = new Hashtable(); protected ArrayList interfaces = null; @@ -94,13 +93,6 @@ namespace GtkSharp.Generation { props.Add (name, new Property (member, this)); break; - case "childprop": - name = member.GetAttribute("name"); - while (props.ContainsKey(name)) - name += "mangled"; - childprops.Add (name, new ChildProperty (member, this)); - break; - case "signal": name = member.GetAttribute("name"); while (sigs.ContainsKey(name)) @@ -139,7 +131,6 @@ namespace GtkSharp.Generation { switch (name) { case "method": case "property": - case "childprop": case "signal": case "implements": case "constructor": @@ -214,36 +205,6 @@ namespace GtkSharp.Generation { } } - protected void GenChildProperties (GenerationInfo gen_info) - { - if (childprops.Count == 0) - return; - - StreamWriter sw = gen_info.Writer; - - sw.WriteLine ("\t\tpublic class " + Name + "Child : Gtk.Container.ContainerChild {"); - sw.WriteLine ("\t\t\tinternal " + Name + "Child (Gtk.Container parent, Gtk.Widget child) : base (parent, child) {}"); - sw.WriteLine (""); - - foreach (ChildProperty prop in childprops.Values) { - if (prop.Validate ()) - prop.Generate (gen_info, "\t\t\t"); - else - Console.WriteLine("in Object " + QualifiedName); - } - - sw.WriteLine ("\t\t}"); - sw.WriteLine (""); - - sw.WriteLine ("\t\tpublic override Gtk.Container.ContainerChild this [Gtk.Widget child] {"); - sw.WriteLine ("\t\t\tget {"); - sw.WriteLine ("\t\t\t\treturn new " + Name + "Child (this, child);"); - sw.WriteLine ("\t\t\t}"); - sw.WriteLine ("\t\t}"); - sw.WriteLine (""); - - } - public void GenSignals (GenerationInfo gen_info, ClassBase implementor) { if (sigs == null) diff --git a/generator/ObjectGen.cs b/generator/ObjectGen.cs index 22b5ab772..f42df0f31 100644 --- a/generator/ObjectGen.cs +++ b/generator/ObjectGen.cs @@ -32,11 +32,13 @@ namespace GtkSharp.Generation { private ArrayList strings = new ArrayList(); private ArrayList vm_nodes = new ArrayList(); + private Hashtable childprops = new Hashtable(); private static Hashtable dirs = new Hashtable (); public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem) { foreach (XmlNode node in elem.ChildNodes) { + string name; if (!(node is XmlElement)) continue; XmlElement member = (XmlElement) node; @@ -55,6 +57,13 @@ namespace GtkSharp.Generation { strings.Add (node); break; + case "childprop": + name = member.GetAttribute ("name"); + while (childprops.ContainsKey (name)) + name += "mangled"; + childprops.Add (name, new ChildProperty (member, this)); + break; + default: if (!IsNodeNameHandled (node.Name)) Console.WriteLine ("Unexpected node " + node.Name + " in " + CName); @@ -247,6 +256,36 @@ namespace GtkSharp.Generation { base.GenCtors (gen_info); } + protected void GenChildProperties (GenerationInfo gen_info) + { + if (childprops.Count == 0) + return; + + StreamWriter sw = gen_info.Writer; + + sw.WriteLine ("\t\tpublic class " + Name + "Child : Gtk.Container.ContainerChild {"); + sw.WriteLine ("\t\t\tinternal " + Name + "Child (Gtk.Container parent, Gtk.Widget child) : base (parent, child) {}"); + sw.WriteLine (""); + + foreach (ChildProperty prop in childprops.Values) { + if (prop.Validate ()) + prop.Generate (gen_info, "\t\t\t"); + else + Console.WriteLine("in Object " + QualifiedName); + } + + sw.WriteLine ("\t\t}"); + sw.WriteLine (""); + + sw.WriteLine ("\t\tpublic override Gtk.Container.ContainerChild this [Gtk.Widget child] {"); + sw.WriteLine ("\t\t\tget {"); + sw.WriteLine ("\t\t\t\treturn new " + Name + "Child (this, child);"); + sw.WriteLine ("\t\t\t}"); + sw.WriteLine ("\t\t}"); + sw.WriteLine (""); + + } + private void GenVMGlue (GenerationInfo gen_info, XmlElement elem) { StreamWriter sw = gen_info.GlueWriter;