mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 06:45:31 +00:00
Handle multiple /signatures/add statements in the same file.
Trim enum and constant names before adding them to the relevant collection. Fixed handling of extensions in enum names.
This commit is contained in:
parent
c4b50469c8
commit
057dfb9448
|
@ -52,11 +52,37 @@ namespace Bind
|
||||||
public EnumCollection Process(EnumCollection enums)
|
public EnumCollection Process(EnumCollection enums)
|
||||||
{
|
{
|
||||||
var nav = Overrides.CreateNavigator();
|
var nav = Overrides.CreateNavigator();
|
||||||
|
ProcessDeleteOverrides(enums, nav);
|
||||||
|
ProcessAddOverrides(enums, nav);
|
||||||
|
|
||||||
enums = ProcessNames(enums, nav);
|
enums = ProcessNames(enums, nav);
|
||||||
enums = ProcessConstants(enums, nav);
|
enums = ProcessConstants(enums, nav);
|
||||||
return enums;
|
return enums;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProcessAddOverrides(EnumCollection enums, XPathNavigator nav)
|
||||||
|
{
|
||||||
|
foreach (XPathNavigator add_node in nav.Select("/signatures/add"))
|
||||||
|
{
|
||||||
|
var new_enums = new XmlSpecReader().ReadEnums(add_node);
|
||||||
|
Utilities.Merge(enums, new_enums);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcessDeleteOverrides(EnumCollection enums, 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 (enums.ContainsKey(name))
|
||||||
|
enums.Remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static EnumCollection ProcessNames(EnumCollection enums, XPathNavigator nav)
|
static EnumCollection ProcessNames(EnumCollection enums, XPathNavigator nav)
|
||||||
{
|
{
|
||||||
EnumCollection processed_enums = new EnumCollection();
|
EnumCollection processed_enums = new EnumCollection();
|
||||||
|
@ -99,9 +125,16 @@ namespace Bind
|
||||||
StringBuilder translator = new StringBuilder(name.Length);
|
StringBuilder translator = new StringBuilder(name.Length);
|
||||||
|
|
||||||
// Process according to these rules:
|
// Process according to these rules:
|
||||||
|
// 0. If name starts with a vendor name, make the first letter after that uppercase.
|
||||||
// 1. if current char is '_', '-' remove it and make next char uppercase
|
// 1. if current char is '_', '-' remove it and make next char uppercase
|
||||||
// 2. if current char is or '0-9' keep it and make next char uppercase.
|
// 2. if current char is or '0-9' keep it and make next char uppercase.
|
||||||
// 3. if current character is uppercase make next char lowercase.
|
// 3. if current character is uppercase make next char lowercase.
|
||||||
|
var ext = Utilities.GetGL2Extension(name);
|
||||||
|
if (ext != String.Empty)
|
||||||
|
{
|
||||||
|
name = name.Replace(ext.ToUpper(), ext);
|
||||||
|
}
|
||||||
|
|
||||||
bool is_after_underscore_or_number = true;
|
bool is_after_underscore_or_number = true;
|
||||||
bool is_previous_uppercase = false;
|
bool is_previous_uppercase = false;
|
||||||
foreach (char c in name)
|
foreach (char c in name)
|
||||||
|
@ -141,7 +174,7 @@ namespace Bind
|
||||||
translator.Replace("AttribIp", "AttribIP");
|
translator.Replace("AttribIp", "AttribIP");
|
||||||
translator.Replace("SRgb", "Srgb");
|
translator.Replace("SRgb", "Srgb");
|
||||||
|
|
||||||
name = translator.ToString();
|
name = translator.ToString().Trim();
|
||||||
if (name.StartsWith(Settings.EnumPrefix))
|
if (name.StartsWith(Settings.EnumPrefix))
|
||||||
name = name.Substring(Settings.EnumPrefix.Length);
|
name = name.Substring(Settings.EnumPrefix.Length);
|
||||||
|
|
||||||
|
@ -152,7 +185,7 @@ namespace Bind
|
||||||
{
|
{
|
||||||
foreach (var e in enums.Values)
|
foreach (var e in enums.Values)
|
||||||
{
|
{
|
||||||
var processed_constants = new Dictionary<string, Constant>(e.ConstantCollection.Count);
|
var processed_constants = new SortedDictionary<string, Constant>();
|
||||||
foreach (Constant c in e.ConstantCollection.Values)
|
foreach (Constant c in e.ConstantCollection.Values)
|
||||||
{
|
{
|
||||||
c.Name = TranslateConstantName(c.Name, false);
|
c.Name = TranslateConstantName(c.Name, false);
|
||||||
|
@ -245,7 +278,7 @@ namespace Bind
|
||||||
else
|
else
|
||||||
translator.Append(s);
|
translator.Append(s);
|
||||||
|
|
||||||
return translator.ToString();
|
return translator.ToString().Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string TranslateConstantValue(string value)
|
public static string TranslateConstantValue(string value)
|
||||||
|
|
|
@ -76,13 +76,16 @@ namespace Bind
|
||||||
return MarkCLSCompliance(wrappers);
|
return MarkCLSCompliance(wrappers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessAddOverrides(DelegateCollection delegates, XPathNavigator nav)
|
void ProcessAddOverrides(DelegateCollection delegates, XPathNavigator nav)
|
||||||
{
|
{
|
||||||
var new_delegates = new XmlSpecReader().ReadDelegates(nav.SelectSingleNode("/signatures/add"));
|
foreach (XPathNavigator add_node in nav.Select("/signatures/add"))
|
||||||
Utilities.Merge(delegates, new_delegates);
|
{
|
||||||
|
var new_delegates = new XmlSpecReader().ReadDelegates(add_node);
|
||||||
|
Utilities.Merge(delegates, new_delegates);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessDeleteOverrides(DelegateCollection delegates, XPathNavigator nav)
|
void ProcessDeleteOverrides(DelegateCollection delegates, XPathNavigator nav)
|
||||||
{
|
{
|
||||||
var del = nav.SelectSingleNode("/signatures/delete");
|
var del = nav.SelectSingleNode("/signatures/delete");
|
||||||
if (del != null)
|
if (del != null)
|
||||||
|
|
Loading…
Reference in a new issue