mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-24 16:05:35 +00:00
1f4ff5bb86
* glib/EnumWrapper.cs: New class which holds an enum int. * glib/Value.cs: Add support for glib enum types. We needed to use EnumWrapper for this because otherwise the int operator wouldn't know which glib function to use. * generator/BoxedGen.cs, ClassBase.cs, Ctor.cs, EnumGen.cs, InterfaceGen.cs, Method.cs, ObjectGen.cs, Signal.cs, StructGen.cs: Create more doc stubs. * generator/Property.cs: Generate enum values correctly. * generator/Ctor.cs: Refactor generation to honor metadata-specified collision preference. * parser/Gtk.metadata: Added constructor collision preferences to all known clashes. * parse/Gdk.metadata: Added (for Pixbuf clashes). svn path=/trunk/gtk-sharp/; revision=5437
80 lines
1.7 KiB
C#
80 lines
1.7 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 (XmlElement 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\t/// <summary> " + Name + " enumeration </summary>");
|
|
sw.WriteLine("\t\t/// <remarks>");
|
|
sw.WriteLine("\t\t/// </remarks>");
|
|
|
|
if (Elem.GetAttribute("type") == "flags")
|
|
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.WriteLine("\t\t/// <summary />");
|
|
sw.WriteLine("\t\t/// <remarks>");
|
|
sw.WriteLine("\t\t/// </remarks>");
|
|
|
|
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++;
|
|
}
|
|
|
|
}
|
|
}
|
|
|