GtkSharp/generator/BoxedGen.cs
Mike Kestner 0cdee479e2 2003-10-28 Mike Kestner <mkestner@ximian.com>
* generator/BoxedGen.cs : generate GLib.Value ctors. [fixes #47168]
	* generator/Property.cs : use new Boxed value ctors.
	* generator/StructBase.cs : use existing Writer if available.

svn path=/trunk/gtk-sharp/; revision=19433
2003-10-28 15:45:35 +00:00

52 lines
1.7 KiB
C#

// GtkSharp.Generation.BoxedGen.cs - The Boxed Generatable.
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2001 Mike Kestner
namespace GtkSharp.Generation {
using System;
using System.IO;
using System.Xml;
public class BoxedGen : StructBase, IGeneratable {
public BoxedGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
public void Generate ()
{
GenerationInfo gen_info = new GenerationInfo (NSElem);
Generate (gen_info);
}
public override void Generate (GenerationInfo gen_info)
{
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
base.Generate (gen_info);
sw.WriteLine ("\t\t[DllImport(\"gtksharpglue\")]");
sw.WriteLine ("\t\tstatic extern IntPtr gtksharp_value_create (uint gtype);");
sw.WriteLine ();
sw.WriteLine ("\t\t[DllImport(\"libgobject-2.0-0.dll\")]");
sw.WriteLine ("\t\tstatic extern void g_value_set_boxed (IntPtr handle, ref " + QualifiedName + " boxed);");
sw.WriteLine ();
sw.WriteLine ("\t\tpublic static explicit operator GLib.Value (" + QualifiedName + " boxed)");
sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\tIntPtr handle = gtksharp_value_create (" + QualifiedName + ".GType);");
sw.WriteLine ("\t\t\tg_value_set_boxed (handle, ref boxed);");
sw.WriteLine ("\t\t\treturn new GLib.Value (handle, IntPtr.Zero);");
sw.WriteLine ("\t\t}");
sw.WriteLine ("#endregion");
AppendCustom(sw, gen_info.CustomDir);
sw.WriteLine ("\t}");
sw.WriteLine ("}");
sw.Close ();
gen_info.Writer = null;
Statistics.BoxedCount++;
}
}
}