From 2dd61c6afde750b307f5198440e746a9de143c98 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Fri, 3 Dec 2010 09:02:55 +0000 Subject: [PATCH] Moved overrides file to Settings class. --- Source/Bind/ES/ESGenerator.cs | 2 +- Source/Bind/GL2/GL4Generator.cs | 2 +- Source/Bind/GL2/Generator.cs | 19 +++++++++---------- Source/Bind/Settings.cs | 1 + Source/Bind/XmlSpecReader.cs | 12 +++--------- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Source/Bind/ES/ESGenerator.cs b/Source/Bind/ES/ESGenerator.cs index 18e2c4ff..d607515f 100644 --- a/Source/Bind/ES/ESGenerator.cs +++ b/Source/Bind/ES/ESGenerator.cs @@ -25,7 +25,7 @@ namespace Bind.ES enumSpecExt = String.Empty; glSpec = dirName + "/signatures.xml"; glSpecExt = String.Empty; - functionOverridesFile = dirName + "/overrides.xml"; + Settings.OverridesFile = dirName + "/overrides.xml"; Settings.ImportsFile = "Core.cs"; Settings.DelegatesFile = "Delegates.cs"; diff --git a/Source/Bind/GL2/GL4Generator.cs b/Source/Bind/GL2/GL4Generator.cs index d1d0a1c3..4ba32357 100644 --- a/Source/Bind/GL2/GL4Generator.cs +++ b/Source/Bind/GL2/GL4Generator.cs @@ -44,7 +44,7 @@ namespace Bind.GL2 enumSpecExt = String.Empty; glSpec = "GL2/signatures.xml"; glSpecExt = String.Empty; - functionOverridesFile = "GL2/gloverrides.xml"; + Settings.OverridesFile = "GL2/gloverrides.xml"; Settings.ImportsFile = "GLCore.cs"; Settings.DelegatesFile = "GLDelegates.cs"; diff --git a/Source/Bind/GL2/Generator.cs b/Source/Bind/GL2/Generator.cs index 21cc38f1..611f0f0d 100644 --- a/Source/Bind/GL2/Generator.cs +++ b/Source/Bind/GL2/Generator.cs @@ -29,8 +29,6 @@ namespace Bind.GL2 protected static string glSpec = "GL2/gl.spec"; protected static string glSpecExt = ""; - protected static string functionOverridesFile = "GL2/gloverrides.xml"; - protected static string loadAllFuncName = "LoadAll"; protected static Regex enumToDotNet = new Regex("_[a-z|A-Z]?", RegexOptions.Compiled); @@ -38,7 +36,7 @@ namespace Bind.GL2 protected static readonly char[] numbers = "0123456789".ToCharArray(); //protected static readonly Dictionary doc_replacements; - protected ISpecReader SpecReader = new XmlSpecReader(functionOverridesFile); + protected ISpecReader SpecReader = new XmlSpecReader(); protected ISpecWriter SpecWriter = new CSharpSpecWriter(); #endregion @@ -69,19 +67,20 @@ namespace Bind.GL2 public virtual void Process() { - var overrides = new XPathDocument(Path.Combine(Settings.InputPath, functionOverridesFile)); + var overrides = new XPathDocument(Path.Combine(Settings.InputPath, Settings.OverridesFile)); using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glTypemap)) - { Type.GLTypes = SpecReader.ReadTypeMap(sr); - } using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, csTypemap)) - { Type.CSTypes = SpecReader.ReadCSTypeMap(sr); - } - var enums = SpecReader.ReadEnums(new StreamReader(Path.Combine(Settings.InputPath, enumSpec))); - var delegates = SpecReader.ReadDelegates(new StreamReader(Path.Combine(Settings.InputPath, glSpec))); + EnumCollection enums; + using (var sr = new StreamReader(Path.Combine(Settings.InputPath, enumSpec))) + enums = SpecReader.ReadEnums(sr); + + DelegateCollection delegates; + using (var sr = new StreamReader(Path.Combine(Settings.InputPath, glSpec))) + delegates = SpecReader.ReadDelegates(sr); enums = new EnumProcessor(overrides).Process(enums); var wrappers = new FuncProcessor(overrides).Process(delegates, enums); diff --git a/Source/Bind/Settings.cs b/Source/Bind/Settings.cs index 6209de01..383ea5a5 100644 --- a/Source/Bind/Settings.cs +++ b/Source/Bind/Settings.cs @@ -26,6 +26,7 @@ namespace Bind public static string DocPath = DefaultDocPath; public static string DocFile = DefaultDocFile; public static string LicenseFile = DefaultLicenseFile; + public static string OverridesFile = "GL2/gloverrides.xml"; public static string GLClass = "GL"; // Needed by Glu for the AuxEnumsClass. Can be set through -gl:"xxx". public static string OutputClass = "GL"; // The real output class. Can be set through -class:"xxx". diff --git a/Source/Bind/XmlSpecReader.cs b/Source/Bind/XmlSpecReader.cs index 75a7f266..3fae1000 100644 --- a/Source/Bind/XmlSpecReader.cs +++ b/Source/Bind/XmlSpecReader.cs @@ -40,19 +40,12 @@ namespace Bind class XmlSpecReader : ISpecReader { - readonly string functionOverridesFile; - - public XmlSpecReader(string functionOverridesFile) - { - this.functionOverridesFile = functionOverridesFile; - } - public DelegateCollection ReadDelegates(StreamReader specFile) { DelegateCollection delegates = new DelegateCollection(); XPathDocument specs = new XPathDocument(specFile); XPathDocument overrides = new XPathDocument(new StreamReader( - Path.Combine(Settings.InputPath, functionOverridesFile))); + Path.Combine(Settings.InputPath, Settings.OverridesFile))); foreach (XPathNavigator nav in new XPathNavigator[] { specs.CreateNavigator().SelectSingleNode("/signatures"), @@ -208,7 +201,8 @@ namespace Bind EnumCollection enums = new EnumCollection(); Enum all = new Enum() { Name = Settings.CompleteEnumName }; XPathDocument specs = new XPathDocument(specFile); - XPathDocument overrides = new XPathDocument(new StreamReader(Path.Combine(Settings.InputPath, functionOverridesFile))); + XPathDocument overrides = new XPathDocument(new StreamReader( + Path.Combine(Settings.InputPath, Settings.OverridesFile))); foreach (XPathNavigator nav in new XPathNavigator[] { specs.CreateNavigator().SelectSingleNode("/signatures"),