mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 17:25:28 +00:00
4966896f1e
api.xml file from CVS with this commit. It can be downloaded from http://sf.net/projects/gtk-sharp. I will be uploading new versions of the file, now named gtkapi.xml, to the project download area from now on. 2002-02-08 Mike Kestner <mkestner@speakeasy.net> * README : Some updates. * generator/BoxedGen.cs : Add FromNative method. * generator/CallbackGen.cs : Add FromNative method. * generator/EnumGen.cs : Add FromNative method. * generator/IGeneratable.cs : Add FromNative method. * generator/InterfaceGen.cs : Add FromNative method. * generator/ObjectGen.cs : Add FromNative method. Hook in GenMethod. * generator/StructBase.cs : Revamp param handling. Add GenMethod. * generator/StructGen.cs : Add FromNative method. * generator/SymbolTable.cs : Add FromNative method. * parser/gapi2xml.pl : Detect ctors before methods. Fix method names. * sample/HelloWorld.cs : uncomment the Show call. svn path=/trunk/gtk-sharp/; revision=2277
113 lines
2.3 KiB
C#
113 lines
2.3 KiB
C#
// GtkSharp.Generation.EnumGen.cs - The Enumeration Generatable.
|
|
//
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
//
|
|
// (c) 2001 Mike Kestner
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Xml;
|
|
|
|
public class EnumGen : IGeneratable {
|
|
|
|
private String ns;
|
|
private XmlElement elem;
|
|
|
|
public EnumGen (String ns, XmlElement elem) {
|
|
|
|
this.ns = ns;
|
|
this.elem = elem;
|
|
}
|
|
|
|
public String Name {
|
|
get
|
|
{
|
|
return elem.GetAttribute("name");
|
|
}
|
|
}
|
|
|
|
public String CName {
|
|
get
|
|
{
|
|
return elem.GetAttribute("cname");
|
|
}
|
|
}
|
|
|
|
public String QualifiedName {
|
|
get
|
|
{
|
|
return ns + "." + elem.GetAttribute("name");
|
|
}
|
|
}
|
|
|
|
public String MarshalType {
|
|
get
|
|
{
|
|
return "int";
|
|
}
|
|
}
|
|
|
|
public String CallByName (String var_name)
|
|
{
|
|
return "(int) " + var_name;
|
|
}
|
|
|
|
public String FromNative(String var)
|
|
{
|
|
return "(" + QualifiedName + ")" + var;
|
|
}
|
|
|
|
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 Mike Kestner");
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("namespace " + ns + " {");
|
|
sw.WriteLine ();
|
|
|
|
if (elem.GetAttribute("type") == "flags") {
|
|
sw.WriteLine ("\tusing System;");
|
|
sw.WriteLine ();
|
|
sw.WriteLine ("\t[Flags]");
|
|
}
|
|
|
|
sw.WriteLine ("\tpublic enum " + Name + " {");
|
|
sw.WriteLine ();
|
|
|
|
foreach (XmlNode node in elem.ChildNodes) {
|
|
if (node.Name != "member") {
|
|
continue;
|
|
}
|
|
|
|
XmlElement member = (XmlElement) node;
|
|
sw.Write ("\t\t" + member.GetAttribute("name"));
|
|
if (member.HasAttribute("value")) {
|
|
sw.WriteLine (" = " + member.GetAttribute("value") + ",");
|
|
} else {
|
|
sw.WriteLine (",");
|
|
}
|
|
}
|
|
|
|
sw.WriteLine ("\t}");
|
|
sw.WriteLine ();
|
|
sw.WriteLine ("}");
|
|
|
|
sw.Flush();
|
|
sw.Close();
|
|
}
|
|
|
|
}
|
|
}
|
|
|