2009-05-28 Aaron Bockover <abockover@novell.com>

* generator/EnumGen.cs: Fix enum generator to properly parse integer
    values with type modifier suffixes (UL, L, U), and not accidentally
    munge named values that happen to end in one of these suffixes


svn path=/trunk/gtk-sharp/; revision=134980
This commit is contained in:
Aaron Bockover 2009-05-28 18:49:11 +00:00
parent 6ee95063ab
commit 9d215affce
2 changed files with 18 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2009-05-28 Aaron Bockover <abockover@novell.com>
* generator/EnumGen.cs: Fix enum generator to properly parse integer
values with type modifier suffixes (UL, L, U), and not accidentally
munge named values that happen to end in one of these suffixes
2009-05-18 Stephane Delcroix <sdelcroix@novell.com>
* configure.in.in:

View File

@ -24,7 +24,8 @@ namespace GtkSharp.Generation {
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml;
using System.Text.RegularExpressions;
public class EnumGen : GenBase {
@ -38,21 +39,21 @@ namespace GtkSharp.Generation {
continue;
string result = "\t\t" + member.GetAttribute("name");
if (member.HasAttribute("value")) {
string value = member.GetAttribute("value");
if (value.EndsWith("U")) {
enum_type = " : uint";
value = value.TrimEnd('U');
} else if (value.EndsWith("L")) {
enum_type = " : long";
value = value.TrimEnd('L');
}
if (member.HasAttribute ("value")) {
string value = member.GetAttribute ("value").Trim ();
foreach (Match match in Regex.Matches (value, "[0-9]+([UL]{1,2})", RegexOptions.IgnoreCase)) {
switch (match.Groups[1].Value.ToUpper ()) {
case "U": enum_type = " : uint"; break;
case "L": enum_type = " : long"; break;
case "UL": enum_type = " : ulong"; break;
}
}
result += " = " + value;
}
members.Add (result + ",");
}
if (elem.HasAttribute ("enum_type"))
enum_type = ": " + elem.GetAttribute ("enum_type");
enum_type = " : " + elem.GetAttribute ("enum_type");
}
public override bool Validate ()