2002-05-23 23:43:25 +00:00
|
|
|
// GtkSharp.Generation.Property.cs - The Property Generatable.
|
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
|
|
|
// (c) 2001-2002 Mike Kestner
|
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.IO;
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
public class Property {
|
|
|
|
|
|
|
|
private XmlElement elem;
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
private ClassBase container_type;
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
public string Name {
|
|
|
|
get {
|
|
|
|
return elem.GetAttribute ("name");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Property (XmlElement elem, ClassBase container_type)
|
2002-05-23 23:43:25 +00:00
|
|
|
{
|
|
|
|
this.elem = elem;
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
this.container_type = container_type;
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool Validate ()
|
|
|
|
{
|
|
|
|
string c_type = elem.GetAttribute("type");
|
|
|
|
string cs_type = SymbolTable.GetCSType(c_type);
|
|
|
|
|
|
|
|
if (cs_type == "") {
|
|
|
|
Console.Write("Property has unknown Type {0} ", c_type);
|
|
|
|
Statistics.ThrottledCount++;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SymbolTable.IsInterface(c_type)) {
|
|
|
|
// FIXME: Handle interface props properly.
|
|
|
|
Console.Write("Interface property detected ");
|
|
|
|
Statistics.ThrottledCount++;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Generate (StreamWriter sw)
|
|
|
|
{
|
|
|
|
string c_type = elem.GetAttribute("type");
|
|
|
|
string cs_type = SymbolTable.GetCSType(c_type);
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
string modifiers = "";
|
|
|
|
|
|
|
|
if (elem.HasAttribute("new_flag") || (container_type.Parent != null && container_type.Parent.GetPropertyRecursively (Name) != null))
|
|
|
|
modifiers = "new ";
|
2002-05-23 23:43:25 +00:00
|
|
|
|
|
|
|
XmlElement parent = (XmlElement) elem.ParentNode;
|
|
|
|
string name = elem.GetAttribute("name");
|
|
|
|
if (name == parent.GetAttribute("name")) {
|
|
|
|
name += "Prop";
|
|
|
|
}
|
2002-06-05 21:59:10 +00:00
|
|
|
string cname = "\"" + elem.GetAttribute("cname") + "\"";
|
2002-05-23 23:43:25 +00:00
|
|
|
|
|
|
|
string v_type = "";
|
|
|
|
if (SymbolTable.IsEnum(c_type)) {
|
2002-06-24 22:04:10 +00:00
|
|
|
v_type = "(int) (GLib.EnumWrapper)";
|
2002-05-23 23:43:25 +00:00
|
|
|
} else if (SymbolTable.IsInterface(c_type)) {
|
|
|
|
// FIXME: Handle interface props properly.
|
|
|
|
Console.Write("Interface property detected ");
|
|
|
|
Statistics.ThrottledCount++;
|
|
|
|
return;
|
|
|
|
} else if (SymbolTable.IsObject(c_type)) {
|
2002-06-24 22:04:10 +00:00
|
|
|
v_type = "(GLib.Object)";
|
2002-06-10 12:34:09 +00:00
|
|
|
} else if (SymbolTable.IsBoxed (c_type)) {
|
2002-06-24 22:04:10 +00:00
|
|
|
v_type = "(GLib.Boxed)";
|
2002-07-26 06:08:52 +00:00
|
|
|
} else if (SymbolTable.IsOpaque (c_type)) {
|
|
|
|
v_type = "(GLib.Opaque)";
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (elem.HasAttribute("construct-only") && !elem.HasAttribute("readable")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-24 22:04:10 +00:00
|
|
|
sw.WriteLine();
|
|
|
|
sw.WriteLine("\t\t/// <summary> " + name + " Property </summary>");
|
|
|
|
sw.WriteLine("\t\t/// <remarks>");
|
|
|
|
sw.WriteLine("\t\t/// </remarks>");
|
|
|
|
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
sw.WriteLine("\t\tpublic " + modifiers + cs_type + " " + name + " {");
|
2002-05-23 23:43:25 +00:00
|
|
|
if (elem.HasAttribute("readable")) {
|
|
|
|
sw.WriteLine("\t\t\tget {");
|
2002-06-05 21:59:10 +00:00
|
|
|
sw.WriteLine("\t\t\t\tGLib.Value val = new GLib.Value (Handle, " + cname + ");");
|
|
|
|
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
2002-07-26 06:08:52 +00:00
|
|
|
if (SymbolTable.IsObject (c_type) || SymbolTable.IsOpaque (c_type)) {
|
2002-06-24 23:38:51 +00:00
|
|
|
sw.WriteLine("\t\t\t\tSystem.IntPtr raw_ret = (System.IntPtr) (GLib.UnwrappedObject) val;");
|
2002-07-26 06:08:52 +00:00
|
|
|
sw.WriteLine("\t\t\t\t" + cs_type + " ret = " + SymbolTable.FromNativeReturn(c_type, "raw_ret") + ";");
|
2002-06-24 23:38:51 +00:00
|
|
|
sw.WriteLine("\t\t\t\tif (ret == null) ret = new " + cs_type + "(raw_ret);");
|
2002-07-26 06:08:52 +00:00
|
|
|
} else {
|
2002-06-24 23:38:51 +00:00
|
|
|
sw.Write("\t\t\t\t" + cs_type + " ret = ");
|
2002-07-26 06:08:52 +00:00
|
|
|
if (SymbolTable.IsBoxed (c_type)) {
|
|
|
|
sw.WriteLine ("({0}) (({1} val).Obj);", cs_type, v_type);
|
|
|
|
} else {
|
|
|
|
sw.Write ("(" + cs_type + ") ");
|
|
|
|
if (v_type != "") {
|
|
|
|
sw.Write(v_type + " ");
|
|
|
|
}
|
|
|
|
sw.WriteLine("val;");
|
2002-06-24 23:38:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sw.WriteLine("\t\t\t\treturn ret;");
|
2002-05-23 23:43:25 +00:00
|
|
|
sw.WriteLine("\t\t\t}");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (elem.HasAttribute("writeable") && !elem.HasAttribute("construct-only")) {
|
|
|
|
sw.WriteLine("\t\t\tset {");
|
2002-06-05 21:59:10 +00:00
|
|
|
sw.Write("\t\t\t\tSetProperty(" + cname + ", new GLib.Value(");
|
2002-06-24 22:04:10 +00:00
|
|
|
if (SymbolTable.IsEnum(c_type)) {
|
|
|
|
sw.WriteLine("Handle, " + cname + ", new GLib.EnumWrapper ((int) value)));");
|
2002-07-26 06:08:52 +00:00
|
|
|
} else if (SymbolTable.IsBoxed (c_type)) {
|
|
|
|
sw.WriteLine("Handle, " + cname + ", new GLib.Boxed (value)));");
|
2002-06-24 22:04:10 +00:00
|
|
|
} else {
|
|
|
|
if (v_type != "") {
|
|
|
|
sw.Write(v_type + " ");
|
|
|
|
}
|
|
|
|
sw.WriteLine("value));");
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
|
|
|
sw.WriteLine("\t\t\t}");
|
|
|
|
}
|
|
|
|
|
|
|
|
sw.WriteLine("\t\t}");
|
|
|
|
sw.WriteLine();
|
|
|
|
|
|
|
|
Statistics.PropCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|