Ryujinx-GtkSharp/generator/BoxedGen.cs
Mike Kestner cd73a17587 2002-05-02 Mike Kestner <mkestner@speakeasy.net>
* README : Describe the new make procedure.
	* configure.in : Add the new Makefile generation.
	* makefile : add the glue dir, make linux the default build,
	  add an install target
	* */makefile.win32 : temp build files for win32
	* */Makefile.in : new configurable make system
	* */makefile : killed
	* generator/BoxedGen.cs : Now uses GLib.Boxed
	* generator/ObjectGen.cs : Use Values for Props.
	* generator/SymbolTable.cs : Add IsEnum method.
	* glib/Boxed.cs : Major overhaul.
	* glib/Object.cs : Remove type specific (Get|Set)Property. Now
	  use GValue based property accessors.
	* glib/TypeFundamentals.cs : Update to current values.
	* glib/Value.cs : Refactor to use glue.

svn path=/trunk/gtk-sharp/; revision=4236
2002-05-02 21:57:41 +00:00

111 lines
2.6 KiB
C#

// GtkSharp.Generation.BoxedGen.cs - The Boxed Type 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 BoxedGen : StructBase, IGeneratable {
public BoxedGen (String ns, XmlElement elem) : base (ns, elem) {}
public String MarshalType {
get
{
return "IntPtr";
}
}
public String CallByName (String var_name)
{
return var_name + ".Handle";
}
public String FromNative(String var)
{
return "(" + QualifiedName + ") GLib.Boxed.FromNative(" + var + ")";
}
public void Generate (SymbolTable table)
{
char sep = Path.DirectorySeparatorChar;
string dir = ".." + sep + ns.ToLower() + sep + "generated";
if (!Directory.Exists(dir)) {
Directory.CreateDirectory(dir);
}
String filename = dir + sep + Name + ".cs";
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter (stream);
sw.WriteLine ("// Generated File. Do not modify.");
sw.WriteLine ("// <c> 2001-2002 Mike Kestner");
sw.WriteLine ();
sw.WriteLine ("namespace " + ns + " {");
sw.WriteLine ();
sw.WriteLine ("\tusing System;");
sw.WriteLine ("\tusing System.Collections;");
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
sw.WriteLine ();
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
sw.WriteLine ("\tpublic class " + Name + " : GLib.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;
switch (node.Name) {
case "field":
Statistics.IgnoreCount++;
// GenField(member, table, sw);
break;
case "callback":
Statistics.IgnoreCount++;
break;
case "constructor":
if (!GenCtor(member, table, sw, clash_map)) {
Console.WriteLine(" in boxed " + CName);
}
break;
case "method":
if (!GenMethod(member, table, sw)) {
Console.WriteLine(" in boxed " + CName);
}
break;
default:
Console.WriteLine ("Unexpected node");
break;
}
}
sw.WriteLine ("\t}");
sw.WriteLine ();
sw.WriteLine ("}");
sw.Flush();
sw.Close();
Statistics.BoxedCount++;
}
}
}