From be5712d85be160cb009784faf6b99c50ef9517dc Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Sun, 2 Jul 2017 23:03:34 +0100 Subject: [PATCH 1/2] Remove unused property Version in Converter The property Version on the Parser class was never used. Removed it and the command line argument in main that was used to set it. --- src/Generator.Converter/Main.cs | 7 ++----- src/Generator.Converter/Parser.cs | 3 --- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Generator.Converter/Main.cs b/src/Generator.Converter/Main.cs index 6ccdb10d..9f3dec20 100644 --- a/src/Generator.Converter/Main.cs +++ b/src/Generator.Converter/Main.cs @@ -68,15 +68,12 @@ namespace OpenTK.Convert { bool showHelp = false; string prefix = "gl"; - string version = null; string path = null; OptionSet opts = new OptionSet { { "p=", "The {PREFIX} to remove from parsed functions and constants. " + "Defaults to \"" + prefix + "\".", v => prefix = v }, - { "v:", "The {VERSION} of the specification being parsed.", - v => version = v }, { "o:", "The {PATH} to the output file.", v => path = v }, { "?|h|help", "Show this message and exit.", @@ -86,7 +83,7 @@ namespace OpenTK.Convert var app = Path.GetFileName(Environment.GetCommandLineArgs()[0]); if (showHelp) { - Console.WriteLine("usage: {0} -p:PREFIX -v:VERSION SPECIFICATIONS", app); + Console.WriteLine("usage: {0} -p:PREFIX SPECIFICATIONS", app); Console.WriteLine(); Console.WriteLine("Options:"); opts.WriteOptionDescriptions(Console.Out); @@ -101,7 +98,7 @@ namespace OpenTK.Convert return; } - Parser parser = new GLXmlParser { Prefix = prefix, Version = version }; + Parser parser = new GLXmlParser { Prefix = prefix }; var sigs = headers.Select(h => parser.Parse(h)).ToList(); diff --git a/src/Generator.Converter/Parser.cs b/src/Generator.Converter/Parser.cs index 6f955cae..fe007ced 100644 --- a/src/Generator.Converter/Parser.cs +++ b/src/Generator.Converter/Parser.cs @@ -33,9 +33,6 @@ 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; } - - // Defines the version of the spec files (optional). - public string Version { get; set; } // Implements the parsing logic for a specific input file. public abstract IEnumerable Parse(string[] lines); From 803ceefbc11df5c4d2d6ff4491795ddabb4c8bfa Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Sun, 2 Jul 2017 23:11:05 +0100 Subject: [PATCH 2/2] 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. --- src/Generator.Converter/GLXmlParser.cs | 12 ------------ src/Generator.Converter/Parser.cs | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Generator.Converter/GLXmlParser.cs b/src/Generator.Converter/GLXmlParser.cs index 5cbfdd52..3798f969 100644 --- a/src/Generator.Converter/GLXmlParser.cs +++ b/src/Generator.Converter/GLXmlParser.cs @@ -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)) diff --git a/src/Generator.Converter/Parser.cs b/src/Generator.Converter/Parser.cs index fe007ced..0bf5c899 100644 --- a/src/Generator.Converter/Parser.cs +++ b/src/Generator.Converter/Parser.cs @@ -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 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; + } } }