From d5d3baa60124003dae6e6d92d2856620a590f7c2 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Tue, 19 Feb 2002 19:46:44 +0000 Subject: [PATCH] 2002-02-19 Mike Kestner * generator/BoxedGen.cs : Add ctor and method generation. * generator/StructBase.cs : Switch to Raw syntax. * glib/Boxed.cs : Add Handle prop, make Raw protected, and add ctors. * glib/Object.cs : s/RawObject/Raw to simplify generation. svn path=/trunk/gtk-sharp/; revision=2518 --- ChangeLog | 7 +++++++ generator/BoxedGen.cs | 16 +++++++++++--- generator/ObjectGen.cs | 3 --- generator/StructBase.cs | 2 +- glib/Boxed.cs | 44 ++++++++++++++++++++++++++++++++++++++- glib/Object.cs | 46 ++++++++++++++++++++--------------------- 6 files changed, 87 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb640a9a3..1045e8f72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-02-19 Mike Kestner + + * generator/BoxedGen.cs : Add ctor and method generation. + * generator/StructBase.cs : Switch to Raw syntax. + * glib/Boxed.cs : Add Handle prop, make Raw protected, and add ctors. + * glib/Object.cs : s/RawObject/Raw to simplify generation. + 2002-02-19 Mike Kestner * generator/Statistics.cs : New. Gathers stats about generation. diff --git a/generator/BoxedGen.cs b/generator/BoxedGen.cs index 6a027ca5d..16f468c4c 100644 --- a/generator/BoxedGen.cs +++ b/generator/BoxedGen.cs @@ -7,6 +7,7 @@ namespace GtkSharp.Generation { using System; + using System.Collections; using System.IO; using System.Xml; @@ -23,7 +24,7 @@ namespace GtkSharp.Generation { public String CallByName (String var_name) { - return var_name + ".Raw"; + return var_name + ".Handle"; } public String FromNative(String var) @@ -57,6 +58,11 @@ namespace GtkSharp.Generation { sw.WriteLine ("\tpublic class " + Name + " : GtkSharp.Boxed {"); sw.WriteLine (); + sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}"); + sw.WriteLine(); + + Hashtable clash_map = new Hashtable(); + foreach (XmlNode node in elem.ChildNodes) { XmlElement member = (XmlElement) node; @@ -72,11 +78,15 @@ namespace GtkSharp.Generation { break; case "constructor": - Statistics.IgnoreCount++; + if (!GenCtor(member, table, sw, clash_map)) { + Console.WriteLine(" in boxed " + CName); + } break; case "method": - Statistics.IgnoreCount++; + if (!GenMethod(member, table, sw)) { + Console.WriteLine(" in boxed " + CName); + } break; default: diff --git a/generator/ObjectGen.cs b/generator/ObjectGen.cs index a0186b8cc..b8d175490 100644 --- a/generator/ObjectGen.cs +++ b/generator/ObjectGen.cs @@ -81,9 +81,6 @@ namespace GtkSharp.Generation { switch (node.Name) { case "field": Statistics.IgnoreCount++; - //if (!GenField(member, table, sw)) { - // Console.WriteLine("in object " + CName); - //} break; case "callback": diff --git a/generator/StructBase.cs b/generator/StructBase.cs index fc9301fc1..65c35ab42 100644 --- a/generator/StructBase.cs +++ b/generator/StructBase.cs @@ -94,7 +94,7 @@ namespace GtkSharp.Generation { } else { sw.WriteLine("\t\tpublic " + Name + sig); sw.WriteLine("\t\t{"); - sw.WriteLine("\t\t\tRawObject = " + cname + call + ";"); + sw.WriteLine("\t\t\tRaw = " + cname + call + ";"); } sw.WriteLine("\t\t}"); diff --git a/glib/Boxed.cs b/glib/Boxed.cs index 82b08c0e0..61cf7fdb9 100644 --- a/glib/Boxed.cs +++ b/glib/Boxed.cs @@ -29,6 +29,31 @@ namespace GtkSharp { Marshal.FreeHGlobal (_raw); } + /// + /// Boxed Constructor + /// + /// + /// + /// Dummy constructor needed for subclasses. + /// + + public Boxed() + { + } + + /// + /// Boxed Constructor + /// + /// + /// + /// Wraps a raw boxed type reference. + /// + + public Boxed(IntPtr raw) + { + Raw = raw; + } + /// /// Raw Property /// @@ -37,7 +62,7 @@ namespace GtkSharp { /// Gets a marshallable IntPtr. /// - public IntPtr Raw { + protected IntPtr Raw { get { if (_raw == IntPtr.Zero) { // FIXME: Ugly hack. @@ -46,6 +71,23 @@ namespace GtkSharp { } return _raw; } + set { + _raw = value; + } + } + + /// + /// Handle Property + /// + /// + /// + /// Gets a marshallable IntPtr. + /// + + public IntPtr Handle { + get { + return _raw; + } } /// diff --git a/glib/Object.cs b/glib/Object.cs index e908a91f7..8013c8c27 100644 --- a/glib/Object.cs +++ b/glib/Object.cs @@ -71,11 +71,11 @@ namespace GLib { public Object (IntPtr raw) { - RawObject = raw; + Raw = raw; } /// - /// RawObject Property + /// Raw Property /// /// /// @@ -85,7 +85,7 @@ namespace GLib { /// Handle property. /// - protected IntPtr RawObject { + protected IntPtr Raw { get { return _obj; } @@ -101,7 +101,7 @@ namespace GLib { /// /// /// The raw GObject reference associated with this object. - /// Subclasses can use RawObject property for read/write + /// Subclasses can use Raw property for read/write /// access. /// @@ -205,7 +205,7 @@ namespace GLib { public void GetProperty (String name, out String val) { IntPtr propval; - g_object_get (RawObject, + g_object_get (Raw, Marshal.StringToHGlobalAnsi (name), out propval, new IntPtr (0)); val = Marshal.PtrToStringAnsi (propval); @@ -226,7 +226,7 @@ namespace GLib { public void GetProperty (String name, out bool val) { - g_object_get (RawObject, + g_object_get (Raw, Marshal.StringToHGlobalAnsi (name), out val, new IntPtr (0)); } @@ -246,7 +246,7 @@ namespace GLib { public void GetProperty (String name, out double val) { - g_object_get (RawObject, + g_object_get (Raw, Marshal.StringToHGlobalAnsi (name), out val, new IntPtr (0)); } @@ -266,7 +266,7 @@ namespace GLib { public void GetProperty (String name, out float val) { - g_object_get (RawObject, + g_object_get (Raw, Marshal.StringToHGlobalAnsi (name), out val, new IntPtr (0)); } @@ -286,7 +286,7 @@ namespace GLib { public void GetProperty (String name, out int val) { - g_object_get (RawObject, + g_object_get (Raw, Marshal.StringToHGlobalAnsi (name), out val, new IntPtr (0)); } @@ -306,7 +306,7 @@ namespace GLib { public void GetProperty (String name, out uint val) { - g_object_get (RawObject, + g_object_get (Raw, Marshal.StringToHGlobalAnsi (name), out val, new IntPtr (0)); } @@ -322,7 +322,7 @@ namespace GLib { public void GetProperty (String name, out GLib.Object val) { IntPtr obj; - g_object_get (RawObject, + g_object_get (Raw, Marshal.StringToHGlobalAnsi (name), out obj, new IntPtr (0)); val = GLib.Object.GetObject (obj); @@ -339,7 +339,7 @@ namespace GLib { public void GetProperty (String name, out GtkSharp.Boxed val) { IntPtr raw; - g_object_get (RawObject, + g_object_get (Raw, Marshal.StringToHGlobalAnsi (name), out raw, new IntPtr (0)); val = GtkSharp.Boxed.GetBoxed (raw); @@ -358,7 +358,7 @@ namespace GLib { public void GetProperty (String name, out IntPtr val) { - g_object_get (RawObject, + g_object_get (Raw, Marshal.StringToHGlobalAnsi (name), out val, new IntPtr (0)); } @@ -381,7 +381,7 @@ namespace GLib { public void SetProperty (String name, String val) { - g_object_set (RawObject, + g_object_set (Raw, Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (val), new IntPtr (0)); @@ -402,7 +402,7 @@ namespace GLib { public void SetProperty (String name, int val) { - g_object_set (RawObject, + g_object_set (Raw, Marshal.StringToHGlobalAnsi (name), val, new IntPtr (0)); } @@ -422,7 +422,7 @@ namespace GLib { public void SetProperty (String name, uint val) { - g_object_set (RawObject, + g_object_set (Raw, Marshal.StringToHGlobalAnsi (name), val, new IntPtr (0)); } @@ -442,7 +442,7 @@ namespace GLib { public void SetProperty (String name, bool val) { - g_object_set (RawObject, + g_object_set (Raw, Marshal.StringToHGlobalAnsi (name), val, new IntPtr (0)); } @@ -462,7 +462,7 @@ namespace GLib { public void SetProperty (String name, double val) { - g_object_set (RawObject, + g_object_set (Raw, Marshal.StringToHGlobalAnsi (name), val, new IntPtr (0)); } @@ -482,7 +482,7 @@ namespace GLib { public void SetProperty (String name, float val) { - g_object_set (RawObject, + g_object_set (Raw, Marshal.StringToHGlobalAnsi (name), val, new IntPtr (0)); } @@ -497,7 +497,7 @@ namespace GLib { public void SetProperty (String name, IntPtr val) { - g_object_set (RawObject, + g_object_set (Raw, Marshal.StringToHGlobalAnsi (name), val, new IntPtr (0)); } @@ -512,7 +512,7 @@ namespace GLib { public void SetProperty (String name, GLib.Object val) { - g_object_set (RawObject, + g_object_set (Raw, Marshal.StringToHGlobalAnsi (name), val.Handle, new IntPtr (0)); } @@ -527,9 +527,9 @@ namespace GLib { public void SetProperty (String name, GtkSharp.Boxed val) { - g_object_set (RawObject, + g_object_set (Raw, Marshal.StringToHGlobalAnsi (name), - val.Raw, new IntPtr (0)); + val.Handle, new IntPtr (0)); }