2002-02-19 Mike Kestner <mkestner@speakeasy.net>

* 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
This commit is contained in:
Mike Kestner 2002-02-19 19:46:44 +00:00
parent ede9016e25
commit d5d3baa601
6 changed files with 87 additions and 31 deletions

View file

@ -1,3 +1,10 @@
2002-02-19 Mike Kestner <mkestner@speakeasy.net>
* 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 <mkestner@speakeasy.net> 2002-02-19 Mike Kestner <mkestner@speakeasy.net>
* generator/Statistics.cs : New. Gathers stats about generation. * generator/Statistics.cs : New. Gathers stats about generation.

View file

@ -7,6 +7,7 @@
namespace GtkSharp.Generation { namespace GtkSharp.Generation {
using System; using System;
using System.Collections;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
@ -23,7 +24,7 @@ namespace GtkSharp.Generation {
public String CallByName (String var_name) public String CallByName (String var_name)
{ {
return var_name + ".Raw"; return var_name + ".Handle";
} }
public String FromNative(String var) public String FromNative(String var)
@ -57,6 +58,11 @@ namespace GtkSharp.Generation {
sw.WriteLine ("\tpublic class " + Name + " : GtkSharp.Boxed {"); sw.WriteLine ("\tpublic class " + Name + " : GtkSharp.Boxed {");
sw.WriteLine (); sw.WriteLine ();
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
sw.WriteLine();
Hashtable clash_map = new Hashtable();
foreach (XmlNode node in elem.ChildNodes) { foreach (XmlNode node in elem.ChildNodes) {
XmlElement member = (XmlElement) node; XmlElement member = (XmlElement) node;
@ -72,11 +78,15 @@ namespace GtkSharp.Generation {
break; break;
case "constructor": case "constructor":
Statistics.IgnoreCount++; if (!GenCtor(member, table, sw, clash_map)) {
Console.WriteLine(" in boxed " + CName);
}
break; break;
case "method": case "method":
Statistics.IgnoreCount++; if (!GenMethod(member, table, sw)) {
Console.WriteLine(" in boxed " + CName);
}
break; break;
default: default:

View file

@ -81,9 +81,6 @@ namespace GtkSharp.Generation {
switch (node.Name) { switch (node.Name) {
case "field": case "field":
Statistics.IgnoreCount++; Statistics.IgnoreCount++;
//if (!GenField(member, table, sw)) {
// Console.WriteLine("in object " + CName);
//}
break; break;
case "callback": case "callback":

View file

@ -94,7 +94,7 @@ namespace GtkSharp.Generation {
} else { } else {
sw.WriteLine("\t\tpublic " + Name + sig); sw.WriteLine("\t\tpublic " + Name + sig);
sw.WriteLine("\t\t{"); sw.WriteLine("\t\t{");
sw.WriteLine("\t\t\tRawObject = " + cname + call + ";"); sw.WriteLine("\t\t\tRaw = " + cname + call + ";");
} }
sw.WriteLine("\t\t}"); sw.WriteLine("\t\t}");

View file

@ -29,6 +29,31 @@ namespace GtkSharp {
Marshal.FreeHGlobal (_raw); Marshal.FreeHGlobal (_raw);
} }
/// <summary>
/// Boxed Constructor
/// </summary>
///
/// <remarks>
/// Dummy constructor needed for subclasses.
/// </remarks>
public Boxed()
{
}
/// <summary>
/// Boxed Constructor
/// </summary>
///
/// <remarks>
/// Wraps a raw boxed type reference.
/// </remarks>
public Boxed(IntPtr raw)
{
Raw = raw;
}
/// <summary> /// <summary>
/// Raw Property /// Raw Property
/// </summary> /// </summary>
@ -37,7 +62,7 @@ namespace GtkSharp {
/// Gets a marshallable IntPtr. /// Gets a marshallable IntPtr.
/// </remarks> /// </remarks>
public IntPtr Raw { protected IntPtr Raw {
get { get {
if (_raw == IntPtr.Zero) { if (_raw == IntPtr.Zero) {
// FIXME: Ugly hack. // FIXME: Ugly hack.
@ -46,6 +71,23 @@ namespace GtkSharp {
} }
return _raw; return _raw;
} }
set {
_raw = value;
}
}
/// <summary>
/// Handle Property
/// </summary>
///
/// <remarks>
/// Gets a marshallable IntPtr.
/// </remarks>
public IntPtr Handle {
get {
return _raw;
}
} }
/// <summary> /// <summary>

View file

@ -71,11 +71,11 @@ namespace GLib {
public Object (IntPtr raw) public Object (IntPtr raw)
{ {
RawObject = raw; Raw = raw;
} }
/// <summary> /// <summary>
/// RawObject Property /// Raw Property
/// </summary> /// </summary>
/// ///
/// <remarks> /// <remarks>
@ -85,7 +85,7 @@ namespace GLib {
/// Handle property. /// Handle property.
/// </remarks> /// </remarks>
protected IntPtr RawObject { protected IntPtr Raw {
get { get {
return _obj; return _obj;
} }
@ -101,7 +101,7 @@ namespace GLib {
/// ///
/// <remarks> /// <remarks>
/// The raw GObject reference associated with this object. /// 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. /// access.
/// </remarks> /// </remarks>
@ -205,7 +205,7 @@ namespace GLib {
public void GetProperty (String name, out String val) public void GetProperty (String name, out String val)
{ {
IntPtr propval; IntPtr propval;
g_object_get (RawObject, g_object_get (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
out propval, new IntPtr (0)); out propval, new IntPtr (0));
val = Marshal.PtrToStringAnsi (propval); val = Marshal.PtrToStringAnsi (propval);
@ -226,7 +226,7 @@ namespace GLib {
public void GetProperty (String name, out bool val) public void GetProperty (String name, out bool val)
{ {
g_object_get (RawObject, g_object_get (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0)); out val, new IntPtr (0));
} }
@ -246,7 +246,7 @@ namespace GLib {
public void GetProperty (String name, out double val) public void GetProperty (String name, out double val)
{ {
g_object_get (RawObject, g_object_get (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0)); out val, new IntPtr (0));
} }
@ -266,7 +266,7 @@ namespace GLib {
public void GetProperty (String name, out float val) public void GetProperty (String name, out float val)
{ {
g_object_get (RawObject, g_object_get (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0)); out val, new IntPtr (0));
} }
@ -286,7 +286,7 @@ namespace GLib {
public void GetProperty (String name, out int val) public void GetProperty (String name, out int val)
{ {
g_object_get (RawObject, g_object_get (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0)); out val, new IntPtr (0));
} }
@ -306,7 +306,7 @@ namespace GLib {
public void GetProperty (String name, out uint val) public void GetProperty (String name, out uint val)
{ {
g_object_get (RawObject, g_object_get (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0)); out val, new IntPtr (0));
} }
@ -322,7 +322,7 @@ namespace GLib {
public void GetProperty (String name, out GLib.Object val) public void GetProperty (String name, out GLib.Object val)
{ {
IntPtr obj; IntPtr obj;
g_object_get (RawObject, g_object_get (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
out obj, new IntPtr (0)); out obj, new IntPtr (0));
val = GLib.Object.GetObject (obj); val = GLib.Object.GetObject (obj);
@ -339,7 +339,7 @@ namespace GLib {
public void GetProperty (String name, out GtkSharp.Boxed val) public void GetProperty (String name, out GtkSharp.Boxed val)
{ {
IntPtr raw; IntPtr raw;
g_object_get (RawObject, g_object_get (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
out raw, new IntPtr (0)); out raw, new IntPtr (0));
val = GtkSharp.Boxed.GetBoxed (raw); val = GtkSharp.Boxed.GetBoxed (raw);
@ -358,7 +358,7 @@ namespace GLib {
public void GetProperty (String name, out IntPtr val) public void GetProperty (String name, out IntPtr val)
{ {
g_object_get (RawObject, g_object_get (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
out val, new IntPtr (0)); out val, new IntPtr (0));
} }
@ -381,7 +381,7 @@ namespace GLib {
public void SetProperty (String name, String val) public void SetProperty (String name, String val)
{ {
g_object_set (RawObject, g_object_set (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
Marshal.StringToHGlobalAnsi (val), Marshal.StringToHGlobalAnsi (val),
new IntPtr (0)); new IntPtr (0));
@ -402,7 +402,7 @@ namespace GLib {
public void SetProperty (String name, int val) public void SetProperty (String name, int val)
{ {
g_object_set (RawObject, g_object_set (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0)); val, new IntPtr (0));
} }
@ -422,7 +422,7 @@ namespace GLib {
public void SetProperty (String name, uint val) public void SetProperty (String name, uint val)
{ {
g_object_set (RawObject, g_object_set (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0)); val, new IntPtr (0));
} }
@ -442,7 +442,7 @@ namespace GLib {
public void SetProperty (String name, bool val) public void SetProperty (String name, bool val)
{ {
g_object_set (RawObject, g_object_set (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0)); val, new IntPtr (0));
} }
@ -462,7 +462,7 @@ namespace GLib {
public void SetProperty (String name, double val) public void SetProperty (String name, double val)
{ {
g_object_set (RawObject, g_object_set (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0)); val, new IntPtr (0));
} }
@ -482,7 +482,7 @@ namespace GLib {
public void SetProperty (String name, float val) public void SetProperty (String name, float val)
{ {
g_object_set (RawObject, g_object_set (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0)); val, new IntPtr (0));
} }
@ -497,7 +497,7 @@ namespace GLib {
public void SetProperty (String name, IntPtr val) public void SetProperty (String name, IntPtr val)
{ {
g_object_set (RawObject, g_object_set (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
val, new IntPtr (0)); val, new IntPtr (0));
} }
@ -512,7 +512,7 @@ namespace GLib {
public void SetProperty (String name, GLib.Object val) public void SetProperty (String name, GLib.Object val)
{ {
g_object_set (RawObject, g_object_set (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
val.Handle, new IntPtr (0)); val.Handle, new IntPtr (0));
} }
@ -527,9 +527,9 @@ namespace GLib {
public void SetProperty (String name, GtkSharp.Boxed val) public void SetProperty (String name, GtkSharp.Boxed val)
{ {
g_object_set (RawObject, g_object_set (Raw,
Marshal.StringToHGlobalAnsi (name), Marshal.StringToHGlobalAnsi (name),
val.Raw, new IntPtr (0)); val.Handle, new IntPtr (0));
} }