Support adding new enum definitions through overrides.xml.

This commit is contained in:
the_fiddler 2009-10-14 22:50:25 +00:00
parent eb2d1c3c91
commit 04f2ba433a

View file

@ -96,13 +96,19 @@ namespace Bind.ES
public override EnumCollection ReadEnums(StreamReader specFile) public override EnumCollection ReadEnums(StreamReader specFile)
{ {
// First, read all enum definitions from spec and override file.
// Afterwards, read all token/enum overrides from overrides file.
// Every single enum is merged into
EnumCollection enums = new EnumCollection(); EnumCollection enums = new EnumCollection();
Enum all = new Enum() { Name = Settings.CompleteEnumName }; Enum all = new Enum() { Name = Settings.CompleteEnumName };
XPathDocument doc = new XPathDocument(specFile); XPathDocument specs = new XPathDocument(specFile);
XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("/signatures");
XPathDocument overrides = new XPathDocument(new StreamReader(Path.Combine(Settings.InputPath, functionOverridesFile))); XPathDocument overrides = new XPathDocument(new StreamReader(Path.Combine(Settings.InputPath, functionOverridesFile)));
foreach (XPathNavigator nav in new XPathNavigator[] {
specs.CreateNavigator().SelectSingleNode("/signatures"),
overrides.CreateNavigator().SelectSingleNode("/overrides") })
{
foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty)) foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty))
{ {
Enum e = new Enum() Enum e = new Enum()
@ -122,6 +128,7 @@ namespace Bind.ES
Utilities.Merge(enums, e); Utilities.Merge(enums, e);
} }
}
Utilities.Merge(enums, all); Utilities.Merge(enums, all);
enums.Translate(overrides); enums.Translate(overrides);