mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-08-17 05:51:14 +00:00
Refactor apiname extraction
A dedicated function is now used for getting the apiname of an enum or command element. This reduces code duplication.
This commit is contained in:
parent
add848f32d
commit
cc8f9aae4f
|
@ -71,6 +71,44 @@ namespace CHeaderToXML
|
||||||
return elements.Values;
|
return elements.Values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string[] GetApiNames(XElement feature)
|
||||||
|
{
|
||||||
|
string[] apinames = null;
|
||||||
|
switch (feature.Name.LocalName)
|
||||||
|
{
|
||||||
|
case "feature":
|
||||||
|
{
|
||||||
|
string v = feature.Attribute("api") != null ? feature.Attribute("api").Value : "gl|glcore";
|
||||||
|
if (v == "gl")
|
||||||
|
{
|
||||||
|
// Add all gl features to both compatibility (gl) and core (glcore) profiles.
|
||||||
|
// Deprecated features will be explicitly marked or removed when parsing
|
||||||
|
// the <remove> elements.
|
||||||
|
v = "gl|glcore";
|
||||||
|
}
|
||||||
|
apinames = v.Split('|');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "extension":
|
||||||
|
{
|
||||||
|
string v = feature.Attribute("supported") != null ? feature.Attribute("supported").Value : "gl|glcore";
|
||||||
|
apinames = v.Split('|');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "group":
|
||||||
|
{
|
||||||
|
apinames = new string[] { "gl", "glcore" };
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new NotSupportedException("Unknown feature type");
|
||||||
|
}
|
||||||
|
return apinames;
|
||||||
|
}
|
||||||
|
|
||||||
IEnumerable<XElement> ParseEnums(XDocument input)
|
IEnumerable<XElement> ParseEnums(XDocument input)
|
||||||
{
|
{
|
||||||
var features = input.Root.Elements("feature");
|
var features = input.Root.Elements("feature");
|
||||||
|
@ -109,12 +147,7 @@ namespace CHeaderToXML
|
||||||
var category = TrimName(feature.Attribute("name").Value);
|
var category = TrimName(feature.Attribute("name").Value);
|
||||||
var extension = feature.Name == "extension" ? category.Substring(0, category.IndexOf("_")) : "Core";
|
var extension = feature.Name == "extension" ? category.Substring(0, category.IndexOf("_")) : "Core";
|
||||||
var version = feature.Attribute("number") != null ? feature.Attribute("number").Value : null;
|
var version = feature.Attribute("number") != null ? feature.Attribute("number").Value : null;
|
||||||
var apinames =
|
var apinames = GetApiNames(feature);
|
||||||
(//feature.Attribute("api") != null ? feature.Attribute("api").Value :
|
|
||||||
feature.Attribute("supported") != null ? feature.Attribute("supported").Value :
|
|
||||||
feature.Attribute("profile") != null ? feature.Attribute("profile").Value
|
|
||||||
.Replace("compatibility", "gl").Replace("core", "glcore") :
|
|
||||||
"gl|glcore").Split('|');
|
|
||||||
|
|
||||||
// An enum may belong to one or more APIs.
|
// An enum may belong to one or more APIs.
|
||||||
// Add it to all relevant ones.
|
// Add it to all relevant ones.
|
||||||
|
@ -216,12 +249,8 @@ namespace CHeaderToXML
|
||||||
foreach (var feature in features.Concat(extensions))
|
foreach (var feature in features.Concat(extensions))
|
||||||
{
|
{
|
||||||
var category = TrimName(feature.Attribute("name").Value);
|
var category = TrimName(feature.Attribute("name").Value);
|
||||||
var apinames =
|
var apinames = GetApiNames(feature);
|
||||||
(//feature.Attribute("api") != null ? feature.Attribute("api").Value :
|
|
||||||
feature.Attribute("supported") != null ? feature.Attribute("supported").Value :
|
|
||||||
feature.Attribute("profile") != null ? feature.Attribute("profile").Value
|
|
||||||
.Replace("compatibility", "gl").Replace("core", "glcore") :
|
|
||||||
"gl|glcore").Split('|');
|
|
||||||
var version =
|
var version =
|
||||||
(feature.Attribute("number") != null ? feature.Attribute("number").Value : "")
|
(feature.Attribute("number") != null ? feature.Attribute("number").Value : "")
|
||||||
.Split('|');
|
.Split('|');
|
||||||
|
|
Loading…
Reference in a new issue