2002-07-26 06:08:52 +00:00
|
|
|
// GtkSharp.Generation.BoxedGen.cs - The Boxed Generatable.
|
2002-01-17 00:26:46 +00:00
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
2004-06-25 16:35:15 +00:00
|
|
|
// Copyright (c) 2001-2003 Mike Kestner
|
|
|
|
// Copyright (c) 2003-2004 Novell, Inc.
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of version 2 of the GNU General Public
|
|
|
|
// License as published by the Free Software Foundation.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public
|
|
|
|
// License along with this program; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
// Boston, MA 02111-1307, USA.
|
2002-01-17 00:26:46 +00:00
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
public class BoxedGen : StructBase, IGeneratable {
|
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
public BoxedGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
2002-01-17 00:26:46 +00:00
|
|
|
|
2003-10-05 00:20:17 +00:00
|
|
|
public void Generate ()
|
2002-02-08 23:56:27 +00:00
|
|
|
{
|
2003-10-05 00:20:17 +00:00
|
|
|
GenerationInfo gen_info = new GenerationInfo (NSElem);
|
|
|
|
Generate (gen_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Generate (GenerationInfo gen_info)
|
|
|
|
{
|
2003-10-28 15:45:35 +00:00
|
|
|
StreamWriter sw = gen_info.Writer = gen_info.OpenStream (Name);
|
2003-10-05 00:20:17 +00:00
|
|
|
base.Generate (gen_info);
|
2004-12-07 19:03:55 +00:00
|
|
|
sw.WriteLine ("\t\t[DllImport(\"glibsharpglue-2\")]");
|
2004-05-05 20:14:14 +00:00
|
|
|
sw.WriteLine ("\t\tstatic extern IntPtr glibsharp_value_get_boxed (ref GLib.Value val);");
|
2003-10-28 15:45:35 +00:00
|
|
|
sw.WriteLine ();
|
2004-12-07 19:03:55 +00:00
|
|
|
sw.WriteLine ("\t\t[DllImport(\"glibsharpglue-2\")]");
|
2004-05-05 20:14:14 +00:00
|
|
|
sw.WriteLine ("\t\tstatic extern void glibsharp_value_set_boxed (ref GLib.Value val, ref " + QualifiedName + " boxed);");
|
2003-10-28 15:45:35 +00:00
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\t\tpublic static explicit operator GLib.Value (" + QualifiedName + " boxed)");
|
|
|
|
sw.WriteLine ("\t\t{");
|
|
|
|
|
2004-04-12 15:54:57 +00:00
|
|
|
sw.WriteLine ("\t\t\tGLib.Value val = GLib.Value.Empty;");
|
2004-05-05 20:14:14 +00:00
|
|
|
sw.WriteLine ("\t\t\tval.Init (" + QualifiedName + ".GType);");
|
|
|
|
sw.WriteLine ("\t\t\tglibsharp_value_set_boxed (ref val, ref boxed);");
|
2004-04-12 15:54:57 +00:00
|
|
|
sw.WriteLine ("\t\t\treturn val;");
|
2003-10-28 15:45:35 +00:00
|
|
|
sw.WriteLine ("\t\t}");
|
2004-01-27 22:06:24 +00:00
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\t\tpublic static explicit operator " + QualifiedName + " (GLib.Value val)");
|
|
|
|
sw.WriteLine ("\t\t{");
|
|
|
|
|
2004-05-05 20:14:14 +00:00
|
|
|
sw.WriteLine ("\t\t\tIntPtr boxed_ptr = glibsharp_value_get_boxed (ref val);");
|
2004-01-27 22:06:24 +00:00
|
|
|
sw.WriteLine ("\t\t\treturn New (boxed_ptr);");
|
|
|
|
sw.WriteLine ("\t\t}");
|
2003-10-28 15:45:35 +00:00
|
|
|
|
|
|
|
sw.WriteLine ("#endregion");
|
|
|
|
AppendCustom(sw, gen_info.CustomDir);
|
|
|
|
sw.WriteLine ("\t}");
|
|
|
|
sw.WriteLine ("}");
|
|
|
|
sw.Close ();
|
|
|
|
gen_info.Writer = null;
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.BoxedCount++;
|
2002-01-17 00:26:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|