mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 17:25:28 +00:00
6d30cf0c3e
2002-05-23 Mike Kestner <mkestner@speakeasy.net> * generator/BoxedGen.cs : Update for Static SymbolTable * generator/CallbackGen.cs : Use GenBase and Parameters classes * generator/CodeGenerator.cs : Update for Static SymbolTable * generator/Ctor.cs : code from StructBase using Parameters class * generator/EnumGen.cs : Use GenBase * generator/GenBase.cs : Abstract Stream Writer creation, stream boilerplate, and common *Name properties * generator/IGeneratable.cs : Update for Static SymbolTable * generator/InterfaceGen.cs : Use GenBase * generator/Method.cs : code from StructBase using Parameters class * generator/ObjectGen.cs : Major refactoring. Use GenBase. Build tables of Member generatables at construct time to facilitate future name collision resolution logic. * generator/Parameters.cs : new generatable to abstract duplicated parameter parsing logic. * generator/Parser.cs : Update for Static SymbolTable * generator/Property.cs : code from ObjectGen * generator/Signal.cs : code from ObjectGen * generator/SignalHandler.cs : Update for Static SymbolTable * generator/StructBase.cs : Update for Static SymbolTable * generator/StructGen.cs : Update for Static SymbolTable * generator/SymbolTable.cs : Make all methods and private members static. There is no reason to ever have multiple tables. svn path=/trunk/gtk-sharp/; revision=4895
69 lines
1.4 KiB
C#
69 lines
1.4 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 : GenBase, IGeneratable {
|
|
|
|
public EnumGen (String ns, XmlElement elem) : base (ns, elem) {}
|
|
|
|
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 ()
|
|
{
|
|
StreamWriter sw = CreateWriter ();
|
|
|
|
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}");
|
|
CloseWriter (sw);
|
|
Statistics.EnumCount++;
|
|
}
|
|
|
|
}
|
|
}
|
|
|