* generator/ClassBase.cs:

* generator/ObjectGen.cs: Move child property handling from
        ClassBase to ObjectGen (as suggested by Mike) since it's only
        used there

svn path=/trunk/gtk-sharp/; revision=36398
This commit is contained in:
Dan Winship 2004-11-22 17:52:17 +00:00
parent 69eabbd1a3
commit 30cc0b8109
3 changed files with 46 additions and 39 deletions

View file

@ -1,3 +1,10 @@
2004-11-22 Dan Winship <danw@novell.com>
* 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 <mkestner@novell.com> 2004-11-18 Mike Kestner <mkestner@novell.com>
* generator/InterfaceGen.cs : beginnings of a real * generator/InterfaceGen.cs : beginnings of a real

View file

@ -31,7 +31,6 @@ namespace GtkSharp.Generation {
public class ClassBase : GenBase { public class ClassBase : GenBase {
protected Hashtable props = new Hashtable(); protected Hashtable props = new Hashtable();
protected Hashtable childprops = new Hashtable();
protected Hashtable sigs = new Hashtable(); protected Hashtable sigs = new Hashtable();
protected Hashtable methods = new Hashtable(); protected Hashtable methods = new Hashtable();
protected ArrayList interfaces = null; protected ArrayList interfaces = null;
@ -94,13 +93,6 @@ namespace GtkSharp.Generation {
props.Add (name, new Property (member, this)); props.Add (name, new Property (member, this));
break; break;
case "childprop":
name = member.GetAttribute("name");
while (props.ContainsKey(name))
name += "mangled";
childprops.Add (name, new ChildProperty (member, this));
break;
case "signal": case "signal":
name = member.GetAttribute("name"); name = member.GetAttribute("name");
while (sigs.ContainsKey(name)) while (sigs.ContainsKey(name))
@ -139,7 +131,6 @@ namespace GtkSharp.Generation {
switch (name) { switch (name) {
case "method": case "method":
case "property": case "property":
case "childprop":
case "signal": case "signal":
case "implements": case "implements":
case "constructor": 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) public void GenSignals (GenerationInfo gen_info, ClassBase implementor)
{ {
if (sigs == null) if (sigs == null)

View file

@ -32,11 +32,13 @@ namespace GtkSharp.Generation {
private ArrayList strings = new ArrayList(); private ArrayList strings = new ArrayList();
private ArrayList vm_nodes = new ArrayList(); private ArrayList vm_nodes = new ArrayList();
private Hashtable childprops = new Hashtable();
private static Hashtable dirs = new Hashtable (); private static Hashtable dirs = new Hashtable ();
public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem) public ObjectGen (XmlElement ns, XmlElement elem) : base (ns, elem)
{ {
foreach (XmlNode node in elem.ChildNodes) { foreach (XmlNode node in elem.ChildNodes) {
string name;
if (!(node is XmlElement)) continue; if (!(node is XmlElement)) continue;
XmlElement member = (XmlElement) node; XmlElement member = (XmlElement) node;
@ -55,6 +57,13 @@ namespace GtkSharp.Generation {
strings.Add (node); strings.Add (node);
break; break;
case "childprop":
name = member.GetAttribute ("name");
while (childprops.ContainsKey (name))
name += "mangled";
childprops.Add (name, new ChildProperty (member, this));
break;
default: default:
if (!IsNodeNameHandled (node.Name)) if (!IsNodeNameHandled (node.Name))
Console.WriteLine ("Unexpected node " + node.Name + " in " + CName); Console.WriteLine ("Unexpected node " + node.Name + " in " + CName);
@ -247,6 +256,36 @@ namespace GtkSharp.Generation {
base.GenCtors (gen_info); 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) private void GenVMGlue (GenerationInfo gen_info, XmlElement elem)
{ {
StreamWriter sw = gen_info.GlueWriter; StreamWriter sw = gen_info.GlueWriter;