mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 06:05:29 +00:00
* XmlSpecReader.cs:
* EnumProcessor.cs: * GL2/Generator.cs: * FuncProcessor.cs: Fixed handling of overrides file: we now add signatures as requested and reset the stream after we are done reading the file.
This commit is contained in:
parent
029957c03a
commit
5b40433350
|
@ -26,22 +26,23 @@
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml.XPath;
|
using System.Xml.XPath;
|
||||||
using Bind.Structures;
|
using Bind.Structures;
|
||||||
using Enum = Bind.Structures.Enum;
|
using Enum = Bind.Structures.Enum;
|
||||||
using System.Globalization;
|
|
||||||
|
|
||||||
namespace Bind
|
namespace Bind
|
||||||
{
|
{
|
||||||
class EnumProcessor
|
class EnumProcessor
|
||||||
{
|
{
|
||||||
const string Path = "/signatures/replace/enum[@name='{0}']";
|
const string Path = "/signatures/replace/enum[@name='{0}']";
|
||||||
XPathDocument Overrides { get; set; }
|
StreamReader Overrides { get; set; }
|
||||||
|
|
||||||
public EnumProcessor(XPathDocument overrides)
|
public EnumProcessor(StreamReader overrides)
|
||||||
{
|
{
|
||||||
if (overrides == null)
|
if (overrides == null)
|
||||||
throw new ArgumentNullException("overrides");
|
throw new ArgumentNullException("overrides");
|
||||||
|
@ -51,9 +52,10 @@ namespace Bind
|
||||||
|
|
||||||
public EnumCollection Process(EnumCollection enums)
|
public EnumCollection Process(EnumCollection enums)
|
||||||
{
|
{
|
||||||
var nav = Overrides.CreateNavigator();
|
var nav = new XPathDocument(Overrides).CreateNavigator();
|
||||||
enums = ProcessNames(enums, nav);
|
enums = ProcessNames(enums, nav);
|
||||||
enums = ProcessConstants(enums, nav);
|
enums = ProcessConstants(enums, nav);
|
||||||
|
Overrides.BaseStream.Seek(0, SeekOrigin.Begin);
|
||||||
return enums;
|
return enums;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml.XPath;
|
using System.Xml.XPath;
|
||||||
|
@ -45,9 +46,9 @@ namespace Bind
|
||||||
new Regex("(ib|[tdrey]s|[eE]n[vd]|bled|Flag|Tess|Status|Pixels|Instanced|Indexed|Varyings|Boolean|IDs)", RegexOptions.Compiled | RegexOptions.RightToLeft);
|
new Regex("(ib|[tdrey]s|[eE]n[vd]|bled|Flag|Tess|Status|Pixels|Instanced|Indexed|Varyings|Boolean|IDs)", RegexOptions.Compiled | RegexOptions.RightToLeft);
|
||||||
static readonly Regex EndingsAddV = new Regex("^0", RegexOptions.Compiled);
|
static readonly Regex EndingsAddV = new Regex("^0", RegexOptions.Compiled);
|
||||||
|
|
||||||
XPathDocument Overrides { get; set; }
|
StreamReader Overrides { get; set; }
|
||||||
|
|
||||||
public FuncProcessor(XPathDocument overrides)
|
public FuncProcessor(StreamReader overrides)
|
||||||
{
|
{
|
||||||
if (overrides == null)
|
if (overrides == null)
|
||||||
throw new ArgumentNullException("overrides");
|
throw new ArgumentNullException("overrides");
|
||||||
|
@ -58,7 +59,7 @@ namespace Bind
|
||||||
public FunctionCollection Process(DelegateCollection delegates, EnumCollection enums)
|
public FunctionCollection Process(DelegateCollection delegates, EnumCollection enums)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Processing delegates.");
|
Console.WriteLine("Processing delegates.");
|
||||||
var nav = Overrides.CreateNavigator();
|
var nav = new XPathDocument(Overrides).CreateNavigator();
|
||||||
foreach (var d in delegates.Values)
|
foreach (var d in delegates.Values)
|
||||||
{
|
{
|
||||||
TranslateReturnType(nav, d, enums);
|
TranslateReturnType(nav, d, enums);
|
||||||
|
@ -70,6 +71,8 @@ namespace Bind
|
||||||
Console.WriteLine("Creating CLS compliant overloads.");
|
Console.WriteLine("Creating CLS compliant overloads.");
|
||||||
wrappers = CreateCLSCompliantWrappers(wrappers, enums);
|
wrappers = CreateCLSCompliantWrappers(wrappers, enums);
|
||||||
Console.WriteLine("Removing non-CLS compliant duplicates.");
|
Console.WriteLine("Removing non-CLS compliant duplicates.");
|
||||||
|
|
||||||
|
Overrides.BaseStream.Seek(0, SeekOrigin.Begin);
|
||||||
return MarkCLSCompliance(wrappers);
|
return MarkCLSCompliance(wrappers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,20 +70,27 @@ namespace Bind.GL2
|
||||||
|
|
||||||
public virtual void Process()
|
public virtual void Process()
|
||||||
{
|
{
|
||||||
var overrides = new XPathDocument(Path.Combine(Settings.InputPath, Settings.OverridesFile));
|
using (var overrides = new StreamReader(Path.Combine(Settings.InputPath, Settings.OverridesFile)))
|
||||||
|
{
|
||||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glTypemap))
|
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glTypemap))
|
||||||
Type.GLTypes = SpecReader.ReadTypeMap(sr);
|
Type.GLTypes = SpecReader.ReadTypeMap(sr);
|
||||||
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, csTypemap))
|
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, csTypemap))
|
||||||
Type.CSTypes = SpecReader.ReadCSTypeMap(sr);
|
Type.CSTypes = SpecReader.ReadCSTypeMap(sr);
|
||||||
using (var sr = new StreamReader(Path.Combine(Settings.InputPath, enumSpec)))
|
using (var sr = new StreamReader(Path.Combine(Settings.InputPath, enumSpec)))
|
||||||
|
{
|
||||||
Enums = SpecReader.ReadEnums(sr);
|
Enums = SpecReader.ReadEnums(sr);
|
||||||
|
Utilities.Merge(Enums, SpecReader.ReadEnums(overrides));
|
||||||
|
}
|
||||||
using (var sr = new StreamReader(Path.Combine(Settings.InputPath, glSpec)))
|
using (var sr = new StreamReader(Path.Combine(Settings.InputPath, glSpec)))
|
||||||
|
{
|
||||||
Delegates = SpecReader.ReadDelegates(sr);
|
Delegates = SpecReader.ReadDelegates(sr);
|
||||||
|
Utilities.Merge(Delegates, SpecReader.ReadDelegates(overrides));
|
||||||
|
}
|
||||||
|
|
||||||
Enums = new EnumProcessor(overrides).Process(Enums);
|
Enums = new EnumProcessor(overrides).Process(Enums);
|
||||||
Wrappers = new FuncProcessor(overrides).Process(Delegates, Enums);
|
Wrappers = new FuncProcessor(overrides).Process(Delegates, Enums);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,9 @@ namespace Bind
|
||||||
public DelegateCollection ReadDelegates(StreamReader specFile)
|
public DelegateCollection ReadDelegates(StreamReader specFile)
|
||||||
{
|
{
|
||||||
XPathDocument specs = new XPathDocument(specFile);
|
XPathDocument specs = new XPathDocument(specFile);
|
||||||
return ReadDelegates(specs.CreateNavigator().SelectSingleNode("/signatures/add"));
|
var delegates = ReadDelegates(specs.CreateNavigator().SelectSingleNode("/signatures/add"));
|
||||||
|
specFile.BaseStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
return delegates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, string> ReadTypeMap(StreamReader specFile)
|
public Dictionary<string, string> ReadTypeMap(StreamReader specFile)
|
||||||
|
@ -201,8 +203,6 @@ namespace Bind
|
||||||
|
|
||||||
EnumCollection enums = new EnumCollection();
|
EnumCollection enums = new EnumCollection();
|
||||||
XPathDocument specs = new XPathDocument(specFile);
|
XPathDocument specs = new XPathDocument(specFile);
|
||||||
XPathDocument overrides = new XPathDocument(new StreamReader(
|
|
||||||
Path.Combine(Settings.InputPath, Settings.OverridesFile)));
|
|
||||||
|
|
||||||
foreach (XPathNavigator nav in specs.CreateNavigator().Select("/signatures/add"))
|
foreach (XPathNavigator nav in specs.CreateNavigator().Select("/signatures/add"))
|
||||||
{
|
{
|
||||||
|
@ -210,6 +210,7 @@ namespace Bind
|
||||||
Utilities.Merge(enums, new_enums);
|
Utilities.Merge(enums, new_enums);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
specFile.BaseStream.Seek(0, SeekOrigin.Begin);
|
||||||
return enums;
|
return enums;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue