Move Enum/FuncPrefix and TrimName to base Parser object
authorFraser Waters <frassle@gmail.com>
Sun, 2 Jul 2017 22:11:05 +0000 (23:11 +0100)
committerFraser Waters <fraser.waters@arm.com>
Mon, 3 Jul 2017 15:23:28 +0000 (16:23 +0100)
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
src/Generator.Converter/Parser.cs

index 5cbfdd5..3798f96 100644 (file)
@@ -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))
index fe007ce..0bf5c89 100644 (file)
@@ -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;
+        }
     }
 }