generator/EnumGen.cs: Added support for different types. Useful for the

GtkMozEmbed headers.

svn path=/trunk/gtk-sharp/; revision=11696
This commit is contained in:
Mark Crichton 2003-02-18 17:28:51 +00:00
parent 6b913229ea
commit ff931046db
2 changed files with 32 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2003-02-18 Mark Crichton <crichton@gimp.org>
* generator/EnumGen.cs: Handle different enum types.
2003-02-14 Duncan Mak <duncan@ximian.com>
* api/gtk-api.xml:

View File

@ -61,9 +61,35 @@ namespace GtkSharp.Generation {
if (Elem.GetAttribute("type") == "flags")
sw.WriteLine ("\t[Flags]");
// Ok, this is obscene. We need to go through the enums first
// to find "large" values. If we find some, we need to change
// the base type of the enum.
string enum_type = null;
foreach (XmlNode node in Elem.ChildNodes) {
if (!(node is XmlElement) || node.Name != "member") {
continue;
}
XmlElement member = (XmlElement) node;
if (member.HasAttribute("value")) {
string value = member.GetAttribute("value");
if (value.EndsWith("U")) {
enum_type = "uint";
member.SetAttribute("value", value.TrimEnd('U'));
}
}
}
sw.WriteLine ("#region Autogenerated code");
sw.WriteLine ("\tpublic enum " + Name + " {");
if (enum_type != null)
sw.WriteLine ("\tpublic enum " + Name + " : " + enum_type + " {");
else
sw.WriteLine ("\tpublic enum " + Name + " {");
sw.WriteLine ();
foreach (XmlNode node in Elem.ChildNodes) {