mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-03-28 06:16:59 +00:00
Move Enum/FuncPrefix and TrimName to base Parser object
Doesn't seem to be that useful alone but a Vulkan parser is different enough to OpenGL to need a new Parser object but name trimming is pretty much the same.
This commit is contained in:
parent
be5712d85b
commit
803ceefbc1
|
@ -47,8 +47,6 @@ namespace OpenTK.Convert
|
|||
static readonly Regex ExtensionRegex = new Regex(
|
||||
@"3DFX|(?!(?<=[1-4])D)[A-Z]{2,}$",
|
||||
RegexOptions.Compiled);
|
||||
string EnumPrefix { get { return Prefix.ToUpper() + "_"; } }
|
||||
string FuncPrefix { get { return Prefix; } }
|
||||
|
||||
public GLXmlParser()
|
||||
{
|
||||
|
@ -448,16 +446,6 @@ namespace OpenTK.Convert
|
|||
return ret;
|
||||
}
|
||||
|
||||
string TrimName(string name)
|
||||
{
|
||||
if (name.StartsWith(EnumPrefix))
|
||||
return name.Remove(0, EnumPrefix.Length);
|
||||
else if (name.StartsWith(FuncPrefix))
|
||||
return name.Remove(0, FuncPrefix.Length);
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
static string Join(string left, string right)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(left) && !String.IsNullOrEmpty(right))
|
||||
|
|
|
@ -33,6 +33,8 @@ namespace OpenTK.Convert
|
|||
{
|
||||
// Defines a prefix that should be removed from methods and tokens in the XML files, e.g. "gl", "cl", etc.
|
||||
public string Prefix { get; set; }
|
||||
public string EnumPrefix { get { return Prefix.ToUpper() + "_"; } }
|
||||
public string FuncPrefix { get { return Prefix; } }
|
||||
|
||||
// Implements the parsing logic for a specific input file.
|
||||
public abstract IEnumerable<XElement> Parse(string[] lines);
|
||||
|
@ -79,5 +81,15 @@ namespace OpenTK.Convert
|
|||
|
||||
return Parse(contents);
|
||||
}
|
||||
|
||||
public string TrimName(string name)
|
||||
{
|
||||
if (name.StartsWith(EnumPrefix))
|
||||
return name.Remove(0, EnumPrefix.Length);
|
||||
else if (name.StartsWith(FuncPrefix))
|
||||
return name.Remove(0, FuncPrefix.Length);
|
||||
else
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue