mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 12:05:34 +00:00
88175147cf
* generator/BoxedGen.cs : New boxed type generatable. * generator/ObjectGen.cs : Add boxed type property generation and stub off interface properties for now. * generator/Parser.cs : Add boxed element parsing. * generator/SymbolTable.cs : Add IsBoxed and IsInterface methods. * glib/Boxed.cs : New base class for deriving boxed types. * glib/Object.cs : Add boxed GetProp/SetProp methods. * parser/gapi2xml.pl : Add boxed type element formatting. * parser/gapi_pp.pl : Add preprocessing of the generated sourcefiles. Handle the builtins and make them identifiable to the xml generator. svn path=/trunk/gtk-sharp/; revision=2012
110 lines
2.3 KiB
C#
110 lines
2.3 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.IO;
|
|
using System.Xml;
|
|
|
|
public class BoxedGen : StructBase, IGeneratable {
|
|
|
|
public BoxedGen (String ns, XmlElement elem) : base (ns, elem) {}
|
|
|
|
public String Name {
|
|
get
|
|
{
|
|
return elem.GetAttribute("name");
|
|
}
|
|
}
|
|
|
|
public String QualifiedName {
|
|
get
|
|
{
|
|
return ns + "." + elem.GetAttribute("name");
|
|
}
|
|
}
|
|
|
|
public String CName {
|
|
get
|
|
{
|
|
return elem.GetAttribute("cname");
|
|
}
|
|
}
|
|
|
|
public String MarshalType {
|
|
get
|
|
{
|
|
return QualifiedName;
|
|
}
|
|
}
|
|
|
|
public String CallByName (String var_name)
|
|
{
|
|
return var_name + ".Raw";
|
|
}
|
|
|
|
public void Generate (SymbolTable table)
|
|
{
|
|
if (!Directory.Exists("..\\" + ns.ToLower() + "\\generated")) {
|
|
Directory.CreateDirectory("..\\"+ns.ToLower()+"\\generated");
|
|
}
|
|
String filename = "..\\" + ns.ToLower() + "\\generated\\" + 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 + " : GtkSharp.Boxed {");
|
|
sw.WriteLine ();
|
|
|
|
foreach (XmlNode node in elem.ChildNodes) {
|
|
|
|
XmlElement member = (XmlElement) node;
|
|
|
|
switch (node.Name) {
|
|
case "field":
|
|
// GenField(member, table, sw);
|
|
break;
|
|
|
|
case "callback":
|
|
break;
|
|
|
|
case "constructor":
|
|
break;
|
|
|
|
case "method":
|
|
break;
|
|
|
|
default:
|
|
Console.WriteLine ("Unexpected node");
|
|
break;
|
|
}
|
|
}
|
|
|
|
sw.WriteLine ("\t}");
|
|
sw.WriteLine ();
|
|
sw.WriteLine ("}");
|
|
|
|
sw.Flush();
|
|
sw.Close();
|
|
}
|
|
}
|
|
}
|
|
|