diff --git a/Source/Bind/GL2/Generator.cs b/Source/Bind/GL2/Generator.cs index a1357c2a..e0a974d1 100644 --- a/Source/Bind/GL2/Generator.cs +++ b/Source/Bind/GL2/Generator.cs @@ -77,10 +77,12 @@ namespace Bind.GL2 string overrides = Path.Combine(Settings.InputPath, Settings.OverridesFile); Type.GLTypes = SpecReader.ReadTypeMap(Path.Combine(Settings.InputPath, glTypemap)); Type.CSTypes = SpecReader.ReadCSTypeMap(Path.Combine(Settings.InputPath, csTypemap)); - SpecReader.ReadEnums(Path.Combine(Settings.InputPath, enumSpec), Enums); - SpecReader.ReadEnums(overrides, Enums); - SpecReader.ReadDelegates(Path.Combine(Settings.InputPath, glSpec), Delegates); - SpecReader.ReadDelegates(overrides, Delegates); + SpecReader.ReadEnums(Path.Combine(Settings.InputPath, enumSpec), Enums, "gl"); + SpecReader.ReadEnums(Path.Combine(Settings.InputPath, enumSpec), Enums, "glcore"); + SpecReader.ReadEnums(overrides, Enums, ""); + SpecReader.ReadDelegates(Path.Combine(Settings.InputPath, glSpec), Delegates, "gl"); + SpecReader.ReadDelegates(Path.Combine(Settings.InputPath, glSpec), Delegates, "glcore"); + SpecReader.ReadDelegates(overrides, Delegates, ""); var enum_processor = new EnumProcessor(overrides); var func_processor = new FuncProcessor(overrides); diff --git a/Source/Bind/ISpecReader.cs b/Source/Bind/ISpecReader.cs index fbcd351d..355b1645 100644 --- a/Source/Bind/ISpecReader.cs +++ b/Source/Bind/ISpecReader.cs @@ -12,8 +12,8 @@ namespace Bind { interface ISpecReader { - void ReadDelegates(string file, DelegateCollection delegates); - void ReadEnums(string file, EnumCollection enums); + void ReadDelegates(string file, DelegateCollection delegates, string apiname); + void ReadEnums(string file, EnumCollection enums, string apiname); Dictionary ReadTypeMap(string file); Dictionary ReadCSTypeMap(string file); } diff --git a/Source/Bind/XmlSpecReader.cs b/Source/Bind/XmlSpecReader.cs index 4e462fd0..71ab0457 100644 --- a/Source/Bind/XmlSpecReader.cs +++ b/Source/Bind/XmlSpecReader.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; +using System.Xml.Linq; using System.Xml.XPath; using Bind.Structures; @@ -42,15 +43,21 @@ namespace Bind { #region ISpecReader Members - public void ReadDelegates(string file, DelegateCollection delegates) + public void ReadDelegates(string file, DelegateCollection delegates, string apiname) { var specs = new XPathDocument(file); - foreach (XPathNavigator nav in specs.CreateNavigator().Select("/signatures/delete")) + foreach (XPathNavigator nav in specs.CreateNavigator().Select( + !String.IsNullOrEmpty(apiname) ? + String.Format("/signatures/delete|/signatures/add/delete[@name='{0}']", apiname) : + String.Format("/signatures/delete|/signatures/add/delete"))) { foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty)) delegates.Remove(node.GetAttribute("name", String.Empty)); } - foreach (XPathNavigator nav in specs.CreateNavigator().Select("/signatures/add")) + foreach (XPathNavigator nav in specs.CreateNavigator().Select( + !String.IsNullOrEmpty(apiname) ? + String.Format("/signatures/add|/signatures/add/api[@name='{0}']", apiname) : + String.Format("/signatures/add|/signatures/add/api"))) { Utilities.Merge(delegates, ReadDelegates(nav)); } @@ -125,19 +132,25 @@ namespace Bind return delegates; } - public void ReadEnums(string file, EnumCollection enums) + public void ReadEnums(string file, EnumCollection enums, string apiname) { // 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 var specs = new XPathDocument(file); - foreach (XPathNavigator nav in specs.CreateNavigator().Select("/signatures/delete")) + foreach (XPathNavigator nav in specs.CreateNavigator().Select( + !String.IsNullOrEmpty(apiname) ? + String.Format("/signatures/delete|/signatures/delete/api[@name='{0}']", apiname) : + String.Format("/signatures/delete|/signatures/delete/api"))) { foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty)) enums.Remove(node.GetAttribute("name", String.Empty)); } - foreach (XPathNavigator nav in specs.CreateNavigator().Select("/signatures/add")) + foreach (XPathNavigator nav in specs.CreateNavigator().Select( + !String.IsNullOrEmpty(apiname) ? + String.Format("/signatures/add|/signatures/add/api[@name='{0}']", apiname) : + String.Format("/signatures/add|/signatures/add/api"))) { Utilities.Merge(enums, ReadEnums(nav)); }