Use identical XPath for signatures.xml and overrides.xml to unify and simplify their handlers.

This commit is contained in:
the_fiddler 2010-12-03 09:45:20 +00:00
parent 47b16778ce
commit 94cd438166
15 changed files with 27192 additions and 27123 deletions

View file

@ -38,7 +38,7 @@ namespace Bind
{
class EnumProcessor
{
const string Path = "/overrides/replace/enum[@name='{0}']";
const string Path = "/signatures/replace/enum[@name='{0}']";
XPathDocument Overrides { get; set; }
public EnumProcessor(XPathDocument overrides)

View file

@ -38,7 +38,7 @@ namespace Bind
{
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 =
new Regex(@"((((d|f|fi)|u?[isb])_?v?)|v)", RegexOptions.Compiled | RegexOptions.RightToLeft);
static readonly Regex EndingsNotToTrim =
@ -59,6 +59,9 @@ namespace Bind
{
Console.WriteLine("Processing delegates.");
var nav = Overrides.CreateNavigator();
ProcessDeleteOverrides(delegates, nav);
ProcessAddOverrides(delegates, nav);
foreach (var d in delegates.Values)
{
TranslateReturnType(nav, d, enums);
@ -73,6 +76,26 @@ namespace Bind
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.
static string TrimName(string name, bool keep_extension)
{

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<overrides>
<signatures>
<replace>
<enum name="Unknown">
@ -48,4 +48,4 @@
</function>
</replace>
</overrides>
</signatures>

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<overrides>
<signatures>
<replace>
<function name="GetString" extension="Core">
@ -7,4 +7,4 @@
</function>
</replace>
</overrides>
</signatures>

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<overrides>
<signatures>
<replace>
<function name="GetString" extension="Core">
@ -7,4 +7,4 @@
</function>
</replace>
</overrides>
</signatures>

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,29 @@
<?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>
@ -720,7 +744,7 @@
<token name="AliasedLineWidthRange" value="0X846e" />
<token name="SampleCoverageValue" value="0X80aa" />
<token name="ColorClearValue" value="0X0c22" />
<token name="BlendEquation" value="0X8009" />
<token name="BlendEquation" value="0X8009" />
<token name="BlendEquationRgb" value="0X8009" />
<token name="BlendEquationAlpha" value="0X883d" />
<token name="ImplementationColorReadType" value="0X8b9a" />
@ -805,4 +829,4 @@
</add>
</overrides>
</signatures>

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<overrides>
<signatures>
<replace>
@ -2875,4 +2875,4 @@
</enum>
</add>
</overrides>
</signatures>

File diff suppressed because it is too large Load diff

View file

@ -20,6 +20,8 @@ namespace Bind.Structures
public class Constant
{
static StringBuilder translator = new StringBuilder();
static readonly int MaxReferenceDepth = 8;
static int CurrentReferenceDepth = 0;
#region PreviousName
@ -199,6 +201,9 @@ namespace Bind.Structures
if (enums == null)
throw new ArgumentNullException("enums");
if (++CurrentReferenceDepth >= MaxReferenceDepth)
throw new InvalidOperationException("Enum specification contains cycle");
if (!String.IsNullOrEmpty(c.Reference))
{
Constant referenced_constant;
@ -226,10 +231,14 @@ namespace Bind.Structures
if (reference.Reference == null)
referenced_constant = (enums[Settings.CompleteEnumName].ConstantCollection[c.Value]);
else
{
--CurrentReferenceDepth;
return false;
}
}
else
{
--CurrentReferenceDepth;
return false;
}
//else throw new InvalidOperationException(String.Format("Unknown Enum \"{0}\" referenced by Constant \"{1}\"",
@ -239,6 +248,7 @@ namespace Bind.Structures
c.Reference = null;
}
--CurrentReferenceDepth;
return true;
}

View file

@ -396,7 +396,7 @@ namespace Bind.Structures
// Make sure that enum parameters follow enum overrides, i.e.
// if enum ErrorCodes is overriden to ErrorCode, then parameters
// 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)
{
// For consistency - many overrides use string instead of String.

View file

@ -119,7 +119,16 @@ namespace Bind
#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>
/// 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>
/// 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
@ -176,22 +181,19 @@ namespace Bind
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)
/// <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>
// Merges the given delegate into the delegate list.
internal static void Merge(DelegateCollection delegates, Delegate t)
{
if (!delegates.ContainsKey(t.Name))
{
delegates.Add(t.Name, t);
}
delegates.Add(t.Name, t);
}
#endregion