* generator/ChildProperty.cs:

* generator/Property.cs: Fix child property names.

svn path=/trunk/gtk-sharp/; revision=35835
This commit is contained in:
Dan Winship 2004-11-08 17:48:27 +00:00
parent cb30686a86
commit 9084ce3133
3 changed files with 31 additions and 15 deletions

View file

@ -1,3 +1,8 @@
2004-11-08 Dan Winship <danw@novell.com>
* generator/ChildProperty.cs:
* generator/Property.cs: Fix child property names.
2004-11-07 Jeroen Zwartepoorte <jeroen@xs4all.nl> 2004-11-07 Jeroen Zwartepoorte <jeroen@xs4all.nl>
* gtk/Gtk.metadata: Fix some TreeModelFilter stuff (similar to * gtk/Gtk.metadata: Fix some TreeModelFilter stuff (similar to

View file

@ -28,24 +28,31 @@ namespace GtkSharp.Generation {
public ChildProperty (XmlElement elem, ClassBase container_type) : base (elem, container_type) {} public ChildProperty (XmlElement elem, ClassBase container_type) : base (elem, container_type) {}
protected override string QuotedPropertyName (string cname) {
if (cname.StartsWith ("child_"))
return "\"" + cname.Substring (6) + "\"";
else
return "\"" + cname + "\"";
}
protected override string PropertyHeader (ref string indent, string modifiers, string cs_type, string name) { protected override string PropertyHeader (ref string indent, string modifiers, string cs_type, string name) {
return ""; return "";
} }
protected override string GetterHeader (string modifiers, string cs_type, string name) { protected override string GetterHeader (string modifiers, string cs_type, string name) {
return "public " + modifiers + cs_type + " Get" + name + " (Widget w)"; return "public " + modifiers + cs_type + " Get" + name + " (Widget child)";
} }
protected override string RawGetter (string cname) { protected override string RawGetter (string qpname) {
return "ChildGetProperty (w, " + cname + ")"; return "ChildGetProperty (child, " + qpname + ")";
} }
protected override string SetterHeader (string modifiers, string cs_type, string name) { protected override string SetterHeader (string modifiers, string cs_type, string name) {
return "public " + modifiers + "void Set" + name + " (Widget w, " + cs_type + " value)"; return "public " + modifiers + "void Set" + name + " (Widget child, " + cs_type + " value)";
} }
protected override string RawSetter (string cname) { protected override string RawSetter (string qpname) {
return "ChildSetProperty(w, " + cname + ", val)"; return "ChildSetProperty(child, " + qpname + ", val)";
} }
protected override string PropertyFooter (string indent) { protected override string PropertyFooter (string indent) {

View file

@ -66,6 +66,10 @@ namespace GtkSharp.Generation {
return true; return true;
} }
protected virtual string QuotedPropertyName (string cname) {
return "\"" + cname + "\"";
}
protected virtual string PropertyHeader (ref string indent, string modifiers, string cs_type, string name) { protected virtual string PropertyHeader (ref string indent, string modifiers, string cs_type, string name) {
string header; string header;
@ -78,16 +82,16 @@ namespace GtkSharp.Generation {
return "get"; return "get";
} }
protected virtual string RawGetter (string cname) { protected virtual string RawGetter (string qpname) {
return "GetProperty (" + cname + ")"; return "GetProperty (" + qpname + ")";
} }
protected virtual string SetterHeader (string modifiers, string cs_type, string name) { protected virtual string SetterHeader (string modifiers, string cs_type, string name) {
return "set"; return "set";
} }
protected virtual string RawSetter (string cname) { protected virtual string RawSetter (string qpname) {
return "SetProperty(" + cname + ", val)"; return "SetProperty(" + qpname + ", val)";
} }
protected virtual string PropertyFooter (string indent) { protected virtual string PropertyFooter (string indent) {
@ -111,7 +115,7 @@ namespace GtkSharp.Generation {
if (name == container_type.Name) { if (name == container_type.Name) {
name += "Prop"; name += "Prop";
} }
string cname = "\"" + elem.GetAttribute("cname") + "\""; string qpname = QuotedPropertyName (elem.GetAttribute("cname"));
string v_type = ""; string v_type = "";
if (table.IsEnum(c_type)) { if (table.IsEnum(c_type)) {
@ -177,7 +181,7 @@ namespace GtkSharp.Generation {
sw.WriteLine(); sw.WriteLine();
} else if (elem.HasAttribute("readable")) { } else if (elem.HasAttribute("readable")) {
sw.WriteLine(indent + GetterHeader (modifiers, cs_type, name) + " {"); sw.WriteLine(indent + GetterHeader (modifiers, cs_type, name) + " {");
sw.WriteLine(indent + "\tGLib.Value val = " + RawGetter (cname) + ";"); sw.WriteLine(indent + "\tGLib.Value val = " + RawGetter (qpname) + ";");
if (table.IsObject (c_type)) { if (table.IsObject (c_type)) {
sw.WriteLine(indent + "\tSystem.IntPtr raw_ret = (System.IntPtr) {0} val;", v_type); sw.WriteLine(indent + "\tSystem.IntPtr raw_ret = (System.IntPtr) {0} val;", v_type);
sw.WriteLine(indent + "\t" + cs_type + " ret = " + table.FromNativeReturn(c_type, "raw_ret") + ";"); sw.WriteLine(indent + "\t" + cs_type + " ret = " + table.FromNativeReturn(c_type, "raw_ret") + ";");
@ -207,11 +211,11 @@ namespace GtkSharp.Generation {
sw.WriteLine(indent + SetterHeader (modifiers, cs_type, name) + " {"); sw.WriteLine(indent + SetterHeader (modifiers, cs_type, name) + " {");
sw.Write(indent + "\tGLib.Value val = "); sw.Write(indent + "\tGLib.Value val = ");
if (table.IsEnum(c_type)) { if (table.IsEnum(c_type)) {
sw.WriteLine("new GLib.Value(this, " + cname + ", new GLib.EnumWrapper ((int) value, {0}));", table.IsEnumFlags (c_type) ? "true" : "false"); sw.WriteLine("new GLib.Value(this, " + qpname + ", new GLib.EnumWrapper ((int) value, {0}));", table.IsEnumFlags (c_type) ? "true" : "false");
} else if (table.IsBoxed (c_type)) { } else if (table.IsBoxed (c_type)) {
sw.WriteLine("(GLib.Value) value;"); sw.WriteLine("(GLib.Value) value;");
} else if (table.IsOpaque (c_type)) { } else if (table.IsOpaque (c_type)) {
sw.WriteLine("new GLib.Value(Handle, " + cname + ", value);"); sw.WriteLine("new GLib.Value(Handle, " + qpname + ", value);");
} else { } else {
sw.Write("new GLib.Value("); sw.Write("new GLib.Value(");
if (v_type != "" && !(table.IsObject (c_type) || table.IsOpaque (c_type))) { if (v_type != "" && !(table.IsObject (c_type) || table.IsOpaque (c_type))) {
@ -219,7 +223,7 @@ namespace GtkSharp.Generation {
} }
sw.WriteLine("value);"); sw.WriteLine("value);");
} }
sw.WriteLine(indent + "\t" + RawSetter (cname) + ";"); sw.WriteLine(indent + "\t" + RawSetter (qpname) + ";");
sw.WriteLine(indent + "\tval.Dispose ();"); sw.WriteLine(indent + "\tval.Dispose ();");
sw.WriteLine(indent + "}"); sw.WriteLine(indent + "}");
} }