mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-19 07:07:34 +00:00
Use identical XPath for signatures.xml and overrides.xml to unify and simplify their handlers.
This commit is contained in:
parent
47b16778ce
commit
94cd438166
|
@ -38,7 +38,7 @@ namespace Bind
|
||||||
{
|
{
|
||||||
class EnumProcessor
|
class EnumProcessor
|
||||||
{
|
{
|
||||||
const string Path = "/overrides/replace/enum[@name='{0}']";
|
const string Path = "/signatures/replace/enum[@name='{0}']";
|
||||||
XPathDocument Overrides { get; set; }
|
XPathDocument Overrides { get; set; }
|
||||||
|
|
||||||
public EnumProcessor(XPathDocument overrides)
|
public EnumProcessor(XPathDocument overrides)
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace Bind
|
||||||
{
|
{
|
||||||
class FuncProcessor
|
class FuncProcessor
|
||||||
{
|
{
|
||||||
const string Path = "/overrides/replace/function[@name='{0}' and @extension='{1}']";
|
const string Path = "/signatures/replace/function[@name='{0}' and @extension='{1}']";
|
||||||
static readonly Regex Endings =
|
static readonly Regex Endings =
|
||||||
new Regex(@"((((d|f|fi)|u?[isb])_?v?)|v)", RegexOptions.Compiled | RegexOptions.RightToLeft);
|
new Regex(@"((((d|f|fi)|u?[isb])_?v?)|v)", RegexOptions.Compiled | RegexOptions.RightToLeft);
|
||||||
static readonly Regex EndingsNotToTrim =
|
static readonly Regex EndingsNotToTrim =
|
||||||
|
@ -59,6 +59,9 @@ namespace Bind
|
||||||
{
|
{
|
||||||
Console.WriteLine("Processing delegates.");
|
Console.WriteLine("Processing delegates.");
|
||||||
var nav = Overrides.CreateNavigator();
|
var nav = Overrides.CreateNavigator();
|
||||||
|
ProcessDeleteOverrides(delegates, nav);
|
||||||
|
ProcessAddOverrides(delegates, nav);
|
||||||
|
|
||||||
foreach (var d in delegates.Values)
|
foreach (var d in delegates.Values)
|
||||||
{
|
{
|
||||||
TranslateReturnType(nav, d, enums);
|
TranslateReturnType(nav, d, enums);
|
||||||
|
@ -73,6 +76,26 @@ namespace Bind
|
||||||
return MarkCLSCompliance(wrappers);
|
return MarkCLSCompliance(wrappers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ProcessAddOverrides(DelegateCollection delegates, XPathNavigator nav)
|
||||||
|
{
|
||||||
|
var new_delegates = new XmlSpecReader().ReadDelegates(nav.SelectSingleNode("/signatures/add"));
|
||||||
|
Utilities.Merge(delegates, new_delegates);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ProcessDeleteOverrides(DelegateCollection delegates, XPathNavigator nav)
|
||||||
|
{
|
||||||
|
var del = nav.SelectSingleNode("/signatures/delete");
|
||||||
|
if (del != null)
|
||||||
|
{
|
||||||
|
foreach (XPathNavigator d in del.SelectChildren("function", String.Empty))
|
||||||
|
{
|
||||||
|
string name = d.GetAttribute("name", String.Empty);
|
||||||
|
if (delegates.ContainsKey(name))
|
||||||
|
delegates.Remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Trims unecessary suffices from the specified OpenGL function name.
|
// Trims unecessary suffices from the specified OpenGL function name.
|
||||||
static string TrimName(string name, bool keep_extension)
|
static string TrimName(string name, bool keep_extension)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<overrides>
|
<signatures>
|
||||||
|
|
||||||
<replace>
|
<replace>
|
||||||
<enum name="Unknown">
|
<enum name="Unknown">
|
||||||
|
@ -48,4 +48,4 @@
|
||||||
</function>
|
</function>
|
||||||
</replace>
|
</replace>
|
||||||
|
|
||||||
</overrides>
|
</signatures>
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<signatures>
|
<signatures>
|
||||||
|
<add>
|
||||||
<enum name="AddressingMode" type="int">
|
<enum name="AddressingMode" type="int">
|
||||||
<token name="ADDRESS_CLAMP" value="0x1132" />
|
<token name="ADDRESS_CLAMP" value="0x1132" />
|
||||||
<token name="ADDRESS_CLAMP_TO_EDGE" value="0x1131" />
|
<token name="ADDRESS_CLAMP_TO_EDGE" value="0x1131" />
|
||||||
|
@ -838,4 +839,5 @@
|
||||||
<param type="cl_uint" name="num_events" flow="in" />
|
<param type="cl_uint" name="num_events" flow="in" />
|
||||||
<param type="cl_event*" name="event_list" flow="in" />
|
<param type="cl_event*" name="event_list" flow="in" />
|
||||||
</function>
|
</function>
|
||||||
|
</add>
|
||||||
</signatures>
|
</signatures>
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<overrides>
|
<signatures>
|
||||||
|
|
||||||
<replace>
|
<replace>
|
||||||
<function name="GetString" extension="Core">
|
<function name="GetString" extension="Core">
|
||||||
|
@ -7,4 +7,4 @@
|
||||||
</function>
|
</function>
|
||||||
</replace>
|
</replace>
|
||||||
|
|
||||||
</overrides>
|
</signatures>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<signatures>
|
<signatures>
|
||||||
|
<add>
|
||||||
<enum name="AlphaFunction">
|
<enum name="AlphaFunction">
|
||||||
<token name="ALWAYS" value="0x0207" />
|
<token name="ALWAYS" value="0x0207" />
|
||||||
<token name="EQUAL" value="0x0202" />
|
<token name="EQUAL" value="0x0202" />
|
||||||
|
@ -921,4 +922,5 @@
|
||||||
<param type="GLsizei" name="width" flow="in" />
|
<param type="GLsizei" name="width" flow="in" />
|
||||||
<param type="GLsizei" name="height" flow="in" />
|
<param type="GLsizei" name="height" flow="in" />
|
||||||
</function>
|
</function>
|
||||||
|
</add>
|
||||||
</signatures>
|
</signatures>
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<overrides>
|
<signatures>
|
||||||
|
|
||||||
<replace>
|
<replace>
|
||||||
<function name="GetString" extension="Core">
|
<function name="GetString" extension="Core">
|
||||||
|
@ -7,4 +7,4 @@
|
||||||
</function>
|
</function>
|
||||||
</replace>
|
</replace>
|
||||||
|
|
||||||
</overrides>
|
</signatures>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<signatures>
|
<signatures>
|
||||||
|
<add>
|
||||||
<enum name="AlphaFunction">
|
<enum name="AlphaFunction">
|
||||||
<token name="ALWAYS" value="0x0207" />
|
<token name="ALWAYS" value="0x0207" />
|
||||||
<token name="EQUAL" value="0x0202" />
|
<token name="EQUAL" value="0x0202" />
|
||||||
|
@ -2092,4 +2093,5 @@
|
||||||
<param type="GLsizei*" name="length" flow="in" />
|
<param type="GLsizei*" name="length" flow="in" />
|
||||||
<param type="char*" name="driverControlString" flow="in" />
|
<param type="char*" name="driverControlString" flow="in" />
|
||||||
</function>
|
</function>
|
||||||
|
</add>
|
||||||
</signatures>
|
</signatures>
|
|
@ -1,5 +1,29 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<overrides>
|
<signatures>
|
||||||
|
|
||||||
|
<delete>
|
||||||
|
<function name="MultiDrawArraysEXT" />
|
||||||
|
<function name="MultiDrawElementsEXT" />
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<add>
|
||||||
|
<function name="MultiDrawArraysEXT" extension="EXT" profile="" category="2.0" version="2.0">
|
||||||
|
<returns type="void" />
|
||||||
|
<param type="GLenum" name="mode" flow="in" />
|
||||||
|
<param type="GLint*" name="first" flow="in" />
|
||||||
|
<param type="GLsizei*" name="count" flow="in" />
|
||||||
|
<param type="GLsizei" name="primcount" flow="in" />
|
||||||
|
</function>
|
||||||
|
|
||||||
|
<function name="MultiDrawElementsEXT" extension="EXT" profile="" category="2.0" version="2.0">
|
||||||
|
<returns type="void" />
|
||||||
|
<param type="GLenum" name="mode" flow="in" />
|
||||||
|
<param type="GLint*" name="first" flow="in" />
|
||||||
|
<param type="GLenum" name="type" flow="in" />
|
||||||
|
<param type="GLvoid**" name="indices" flow="in" />
|
||||||
|
<param type="GLsizei" name="primcount" flow="in" />
|
||||||
|
</function>
|
||||||
|
</add>
|
||||||
|
|
||||||
<replace>
|
<replace>
|
||||||
|
|
||||||
|
@ -805,4 +829,4 @@
|
||||||
|
|
||||||
</add>
|
</add>
|
||||||
|
|
||||||
</overrides>
|
</signatures>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<signatures>
|
<signatures>
|
||||||
|
<add>
|
||||||
<enum name="AMDCompressed3DCTexture" type="int">
|
<enum name="AMDCompressed3DCTexture" type="int">
|
||||||
<token name="3DC_X_AMD" value="0x87F9" />
|
<token name="3DC_X_AMD" value="0x87F9" />
|
||||||
<token name="3DC_XY_AMD" value="0x87FA" />
|
<token name="3DC_XY_AMD" value="0x87FA" />
|
||||||
|
@ -1933,4 +1934,5 @@
|
||||||
<param type="GLuint" name="height" flow="in" />
|
<param type="GLuint" name="height" flow="in" />
|
||||||
<param type="GLbitfield" name="preserveMask" flow="in" />
|
<param type="GLbitfield" name="preserveMask" flow="in" />
|
||||||
</function>
|
</function>
|
||||||
|
</add>
|
||||||
</signatures>
|
</signatures>
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<overrides>
|
<signatures>
|
||||||
|
|
||||||
<replace>
|
<replace>
|
||||||
|
|
||||||
|
@ -2875,4 +2875,4 @@
|
||||||
</enum>
|
</enum>
|
||||||
</add>
|
</add>
|
||||||
|
|
||||||
</overrides>
|
</signatures>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<signatures>
|
<signatures>
|
||||||
|
<add>
|
||||||
<enum name="3DFX_multisample">
|
<enum name="3DFX_multisample">
|
||||||
<token name="MULTISAMPLE_3DFX" value="0x86B2" />
|
<token name="MULTISAMPLE_3DFX" value="0x86B2" />
|
||||||
<token name="MULTISAMPLE_BIT_3DFX" value="0x20000000" />
|
<token name="MULTISAMPLE_BIT_3DFX" value="0x20000000" />
|
||||||
|
@ -21307,4 +21308,5 @@
|
||||||
<function name="FinishTextureSUNX" extension="SUNX" category="SUNX_constant_data" version="1.1">
|
<function name="FinishTextureSUNX" extension="SUNX" category="SUNX_constant_data" version="1.1">
|
||||||
<returns type="void" />
|
<returns type="void" />
|
||||||
</function>
|
</function>
|
||||||
|
</add>
|
||||||
</signatures>
|
</signatures>
|
|
@ -20,6 +20,8 @@ namespace Bind.Structures
|
||||||
public class Constant
|
public class Constant
|
||||||
{
|
{
|
||||||
static StringBuilder translator = new StringBuilder();
|
static StringBuilder translator = new StringBuilder();
|
||||||
|
static readonly int MaxReferenceDepth = 8;
|
||||||
|
static int CurrentReferenceDepth = 0;
|
||||||
|
|
||||||
#region PreviousName
|
#region PreviousName
|
||||||
|
|
||||||
|
@ -199,6 +201,9 @@ namespace Bind.Structures
|
||||||
if (enums == null)
|
if (enums == null)
|
||||||
throw new ArgumentNullException("enums");
|
throw new ArgumentNullException("enums");
|
||||||
|
|
||||||
|
if (++CurrentReferenceDepth >= MaxReferenceDepth)
|
||||||
|
throw new InvalidOperationException("Enum specification contains cycle");
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(c.Reference))
|
if (!String.IsNullOrEmpty(c.Reference))
|
||||||
{
|
{
|
||||||
Constant referenced_constant;
|
Constant referenced_constant;
|
||||||
|
@ -226,10 +231,14 @@ namespace Bind.Structures
|
||||||
if (reference.Reference == null)
|
if (reference.Reference == null)
|
||||||
referenced_constant = (enums[Settings.CompleteEnumName].ConstantCollection[c.Value]);
|
referenced_constant = (enums[Settings.CompleteEnumName].ConstantCollection[c.Value]);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
--CurrentReferenceDepth;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
--CurrentReferenceDepth;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//else throw new InvalidOperationException(String.Format("Unknown Enum \"{0}\" referenced by Constant \"{1}\"",
|
//else throw new InvalidOperationException(String.Format("Unknown Enum \"{0}\" referenced by Constant \"{1}\"",
|
||||||
|
@ -239,6 +248,7 @@ namespace Bind.Structures
|
||||||
c.Reference = null;
|
c.Reference = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--CurrentReferenceDepth;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,7 +396,7 @@ namespace Bind.Structures
|
||||||
// Make sure that enum parameters follow enum overrides, i.e.
|
// Make sure that enum parameters follow enum overrides, i.e.
|
||||||
// if enum ErrorCodes is overriden to ErrorCode, then parameters
|
// if enum ErrorCodes is overriden to ErrorCode, then parameters
|
||||||
// of type ErrorCodes should also be overriden to ErrorCode.
|
// of type ErrorCodes should also be overriden to ErrorCode.
|
||||||
XPathNavigator enum_override = overrides.SelectSingleNode(String.Format("/overrides/replace/enum[@name='{0}']/name", CurrentType));
|
XPathNavigator enum_override = overrides.SelectSingleNode(String.Format("/signatures/replace/enum[@name='{0}']/name", CurrentType));
|
||||||
if (enum_override != null)
|
if (enum_override != null)
|
||||||
{
|
{
|
||||||
// For consistency - many overrides use string instead of String.
|
// For consistency - many overrides use string instead of String.
|
||||||
|
|
|
@ -119,7 +119,16 @@ namespace Bind
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region internal static void Merge(EnumCollection enums, Bind.Structures.Enum t)
|
#region Merge
|
||||||
|
|
||||||
|
// Merges the specified enum collections.
|
||||||
|
internal static void Merge(EnumCollection enums, EnumCollection new_enums)
|
||||||
|
{
|
||||||
|
foreach (var e in new_enums)
|
||||||
|
{
|
||||||
|
Merge(enums, e.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Merges the given enum into the enum list. If an enum of the same name exists,
|
/// Merges the given enum into the enum list. If an enum of the same name exists,
|
||||||
|
@ -143,10 +152,6 @@ namespace Bind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region internal static Bind.Structures.Enum Merge(Bind.Structures.Enum s, Bind.Structures.Constant t)
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Places a new constant in the specified enum, if it doesn't already exist.
|
/// Places a new constant in the specified enum, if it doesn't already exist.
|
||||||
/// The existing constant is replaced iff the new has a numeric value and the old
|
/// The existing constant is replaced iff the new has a numeric value and the old
|
||||||
|
@ -176,23 +181,20 @@ namespace Bind
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
// Merges the specified enum collections.
|
||||||
|
internal static void Merge(DelegateCollection delegates, DelegateCollection new_delegates)
|
||||||
|
{
|
||||||
|
foreach (var d in new_delegates)
|
||||||
|
{
|
||||||
|
Merge(delegates, d.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region internal static void Merge(EnumCollection enums, Bind.Structures.Enum t)
|
// Merges the given delegate into the delegate list.
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Merges the given enum into the enum list. If an enum of the same name exists,
|
|
||||||
/// it merges their respective constants.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="enums"></param>
|
|
||||||
/// <param name="t"></param>
|
|
||||||
internal static void Merge(DelegateCollection delegates, Delegate t)
|
internal static void Merge(DelegateCollection delegates, Delegate t)
|
||||||
{
|
|
||||||
if (!delegates.ContainsKey(t.Name))
|
|
||||||
{
|
{
|
||||||
delegates.Add(t.Name, t);
|
delegates.Add(t.Name, t);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue