mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 19:55:29 +00:00
Add apiname parameter to ISpecReader
This allows us to reuse the same ISpecReader implementation to parse different APIs (GL and GLES).
This commit is contained in:
parent
2e435f97bb
commit
7f9041417e
|
@ -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);
|
||||
|
|
|
@ -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<string, string> ReadTypeMap(string file);
|
||||
Dictionary<string, string> ReadCSTypeMap(string file);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue