* ES/ESGenerator.cs: Set enum Type property.
* Structures/Enum.cs: Added enum Type property. Removed Enum(string) constructor in favor of C# 3.0 syntax (new Enum() { Name = ... }).
This commit is contained in:
parent
5e95ec9fc4
commit
76dcd00b9f
2 changed files with 20 additions and 10 deletions
|
@ -97,7 +97,7 @@ namespace Bind.ES
|
|||
public override EnumCollection ReadEnums(StreamReader specFile)
|
||||
{
|
||||
EnumCollection enums = new EnumCollection();
|
||||
Enum all = new Enum(Settings.CompleteEnumName);
|
||||
Enum all = new Enum() { Name = Settings.CompleteEnumName };
|
||||
XPathDocument doc = new XPathDocument(specFile);
|
||||
XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("/signatures");
|
||||
|
||||
|
@ -105,7 +105,11 @@ namespace Bind.ES
|
|||
|
||||
foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty))
|
||||
{
|
||||
Enum e = new Enum(node.GetAttribute("name", String.Empty));
|
||||
Enum e = new Enum()
|
||||
{
|
||||
Name = node.GetAttribute("name", String.Empty),
|
||||
Type = node.GetAttribute("type", String.Empty)
|
||||
};
|
||||
if (String.IsNullOrEmpty(e.Name))
|
||||
throw new InvalidOperationException(String.Format("Empty name for enum element {0}", node.ToString()));
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Bind.Structures
|
|||
internal static EnumCollection AuxEnums = new EnumCollection();
|
||||
|
||||
static StringBuilder translator = new StringBuilder();
|
||||
string _name;
|
||||
string _name, _type;
|
||||
static bool enumsLoaded;
|
||||
|
||||
#region Initialize
|
||||
|
@ -69,12 +69,8 @@ namespace Bind.Structures
|
|||
#region Constructors
|
||||
|
||||
public Enum()
|
||||
{ }
|
||||
|
||||
public Enum(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -96,9 +92,16 @@ namespace Bind.Structures
|
|||
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
get { return _name ?? ""; }
|
||||
set { _name = value; }
|
||||
}
|
||||
|
||||
// Typically 'long' or 'int'. Default is 'int'.
|
||||
public string Type
|
||||
{
|
||||
get { return String.IsNullOrEmpty(_type) ? "int" : _type; }
|
||||
set { _type = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -182,7 +185,10 @@ namespace Bind.Structures
|
|||
|
||||
if (IsFlagCollection)
|
||||
sb.AppendLine("[Flags]");
|
||||
sb.AppendLine("public enum " + Name);
|
||||
sb.Append("public enum ");
|
||||
sb.Append(Name);
|
||||
sb.Append(" : ");
|
||||
sb.AppendLine(Type);
|
||||
sb.AppendLine("{");
|
||||
|
||||
foreach (Constant c in constants)
|
||||
|
|
Loading…
Reference in a new issue