mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-09-13 18:57:11 +00:00
Remove spec support from converter
Khronos stopped supporting .spec files in 2013. They're now over a year old without support. As such it's not worth us continuing to support them either.
This commit is contained in:
parent
7e903d6c0b
commit
d7c21bd3f5
|
@ -1,213 +0,0 @@
|
||||||
#region License
|
|
||||||
//
|
|
||||||
// The Open Toolkit Library License
|
|
||||||
//
|
|
||||||
// Copyright (c) 2006 - 2010 the Open Toolkit library.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||||
// in the Software without restriction, including without limitation the rights to
|
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do
|
|
||||||
// so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
// OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
|
|
||||||
namespace CHeaderToXML
|
|
||||||
{
|
|
||||||
class GLParser : Parser
|
|
||||||
{
|
|
||||||
static readonly Regex extensions = new Regex(
|
|
||||||
@"3DFX|(?!(?<=[1-4])D)[A-Z]{2,}$",
|
|
||||||
RegexOptions.Compiled);
|
|
||||||
static readonly char[] splitters = new char[] { ' ', '\t', ',', '(', ')', ';', '\n', '\r' };
|
|
||||||
|
|
||||||
enum ParserModes { None, Enum, Func };
|
|
||||||
ParserModes CurrentMode;
|
|
||||||
|
|
||||||
enum EntryModes { Core, Compatibility };
|
|
||||||
|
|
||||||
public override IEnumerable<XElement> Parse(string[] lines)
|
|
||||||
{
|
|
||||||
XElement current = null;
|
|
||||||
|
|
||||||
foreach (string l in lines)
|
|
||||||
{
|
|
||||||
// Clean up line for further processing and skip invalid lines.
|
|
||||||
string line = l.Replace('\t', ' ').Trim();
|
|
||||||
if (!IsValid(line))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
string[] words = SplitWords(line);
|
|
||||||
if (line.Contains("enum:"))
|
|
||||||
{
|
|
||||||
// This is a new enum definition
|
|
||||||
if (current != null)
|
|
||||||
yield return current;
|
|
||||||
|
|
||||||
current = new XElement("enum",
|
|
||||||
new XAttribute("name", words[0]));
|
|
||||||
|
|
||||||
CurrentMode = ParserModes.Enum;
|
|
||||||
}
|
|
||||||
else if (line.StartsWith(words[0] + "("))
|
|
||||||
{
|
|
||||||
// This is a new function definition
|
|
||||||
if (current != null)
|
|
||||||
yield return current;
|
|
||||||
|
|
||||||
var match = extensions.Match(words[0]);
|
|
||||||
string extension = match != null && String.IsNullOrEmpty(match.Value) ? "Core" : match.Value;
|
|
||||||
current = new XElement("function",
|
|
||||||
new XAttribute("name", words[0]),
|
|
||||||
new XAttribute("extension", extension));
|
|
||||||
|
|
||||||
CurrentMode = ParserModes.Func;
|
|
||||||
}
|
|
||||||
else if (current != null)
|
|
||||||
{
|
|
||||||
// This is an addition to the current element (enum or function)
|
|
||||||
switch (CurrentMode)
|
|
||||||
{
|
|
||||||
case ParserModes.Enum:
|
|
||||||
if (words[0] == "use")
|
|
||||||
{
|
|
||||||
current.Add(new XElement("use",
|
|
||||||
new XAttribute("enum", words[1]),
|
|
||||||
new XAttribute("token", words[2])));
|
|
||||||
}
|
|
||||||
else if (words[1] == "=")
|
|
||||||
{
|
|
||||||
current.Add(new XElement("token",
|
|
||||||
new XAttribute("name", words[0]),
|
|
||||||
new XAttribute("value", words[2])));
|
|
||||||
}
|
|
||||||
else if (words[0] == "profile:")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (words[0].Contains("future_use"))
|
|
||||||
{
|
|
||||||
// This is a bug in the 4.3 specs. Unfortunately,
|
|
||||||
// Khronos is no longer accepting bug reports for
|
|
||||||
// the .spec files.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Typical cause is hand-editing the specs and forgetting to add an '=' sign.
|
|
||||||
throw new InvalidOperationException(String.Format(
|
|
||||||
"[Error] Invalid constant definition: \"{0}\"", line));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ParserModes.Func:
|
|
||||||
switch (words[0])
|
|
||||||
{
|
|
||||||
case "return": // Line denotes return value
|
|
||||||
current.Add(new XElement("returns",
|
|
||||||
new XAttribute("type", words[1])));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "param": // Line denotes parameter
|
|
||||||
int pointer = words[4].Contains("array") ? 1 : 0;
|
|
||||||
pointer += words[4].Contains("reference") ? 1 : 0;
|
|
||||||
|
|
||||||
var elem = new XElement("param",
|
|
||||||
new XAttribute("name", words[1]),
|
|
||||||
new XAttribute("type", words[2] + PointerLevel(pointer)),
|
|
||||||
new XAttribute("flow", words[3] == "in" ? "in" : "out"));
|
|
||||||
if (pointer > 0 && words.Length > 5 && words[5].Contains("[1]"))
|
|
||||||
elem.Add(new XAttribute("count", 1));
|
|
||||||
|
|
||||||
current.Add(elem);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "version": // Line denotes function version (i.e. 1.0, 1.2, 1.5)
|
|
||||||
// GetTexParameterIivEXT and GetTexParameterIuivEXT define two(!) versions (why?)
|
|
||||||
var version = current.Attribute("version");
|
|
||||||
if (version == null)
|
|
||||||
current.Add(new XAttribute("version", words[1]));
|
|
||||||
else
|
|
||||||
version.Value = words[1];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "category":
|
|
||||||
current.Add(new XAttribute("category", words[1]));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "deprecated":
|
|
||||||
current.Add(new XAttribute("deprecated", words[1]));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current != null)
|
|
||||||
{
|
|
||||||
yield return current;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string[] SplitWords(string line)
|
|
||||||
{
|
|
||||||
return line.Split(splitters, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsValid(string line)
|
|
||||||
{
|
|
||||||
return !(String.IsNullOrEmpty(line) ||
|
|
||||||
line.StartsWith("#") || // Disregard comments.
|
|
||||||
line.StartsWith("passthru") || // Disregard passthru statements.
|
|
||||||
line.StartsWith("required-props:") ||
|
|
||||||
line.StartsWith("param:") ||
|
|
||||||
line.StartsWith("dlflags:") ||
|
|
||||||
line.StartsWith("glxflags:") ||
|
|
||||||
line.StartsWith("vectorequiv:") ||
|
|
||||||
//line.StartsWith("category:") ||
|
|
||||||
line.StartsWith("version:") ||
|
|
||||||
line.StartsWith("glxsingle:") ||
|
|
||||||
line.StartsWith("glxropcode:") ||
|
|
||||||
line.StartsWith("glxvendorpriv:") ||
|
|
||||||
line.StartsWith("glsflags:") ||
|
|
||||||
line.StartsWith("glsopcode:") ||
|
|
||||||
line.StartsWith("glsalias:") ||
|
|
||||||
line.StartsWith("wglflags:") ||
|
|
||||||
line.StartsWith("extension:") ||
|
|
||||||
line.StartsWith("alias:") ||
|
|
||||||
line.StartsWith("offset:"));
|
|
||||||
}
|
|
||||||
|
|
||||||
string PointerLevel(int pointer)
|
|
||||||
{
|
|
||||||
switch (pointer)
|
|
||||||
{
|
|
||||||
case 0: return String.Empty;
|
|
||||||
case 1: return "*";
|
|
||||||
case 2: return "**";
|
|
||||||
case 3: return "***";
|
|
||||||
case 4: return "****";
|
|
||||||
case 5: return "*****";
|
|
||||||
default: throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -130,7 +130,6 @@
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="GLParser.cs" />
|
|
||||||
<None Include="..\..\OpenTK.snk">
|
<None Include="..\..\OpenTK.snk">
|
||||||
<Link>OpenTK.snk</Link>
|
<Link>OpenTK.snk</Link>
|
||||||
</None>
|
</None>
|
||||||
|
|
|
@ -63,7 +63,6 @@ namespace CHeaderToXML
|
||||||
enum HeaderType
|
enum HeaderType
|
||||||
{
|
{
|
||||||
Header,
|
Header,
|
||||||
Spec,
|
|
||||||
Xml
|
Xml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +111,6 @@ namespace CHeaderToXML
|
||||||
}
|
}
|
||||||
Parser parser =
|
Parser parser =
|
||||||
type == HeaderType.Header ? new ESCLParser { Prefix = prefix, Version = version } :
|
type == HeaderType.Header ? new ESCLParser { Prefix = prefix, Version = version } :
|
||||||
type == HeaderType.Spec ? new GLParser { Prefix = prefix, Version = version } :
|
|
||||||
type == HeaderType.Xml ? new GLXmlParser { Prefix = prefix, Version = version } :
|
type == HeaderType.Xml ? new GLXmlParser { Prefix = prefix, Version = version } :
|
||||||
(Parser)null;
|
(Parser)null;
|
||||||
|
|
||||||
|
|
|
@ -5,25 +5,21 @@ This is a simple tool to convert C headers to XML files. It works using simple p
|
||||||
|
|
||||||
[Examples]
|
[Examples]
|
||||||
|
|
||||||
To download and convert the new XML API registry from Khronos:
|
To download and convert the XML API registry from Khronos:
|
||||||
Convert.exe -p:gl -t:xml -o:../../../Source/Bind/Specifications/GL2/signatures.xml https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml
|
Convert.exe -p:gl -t:xml -o:../../../Source/Bind/Specifications/GL2/signatures.xml https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/api/gl.xml
|
||||||
|
|
||||||
To download and convert the old .spec files from Khronos:
|
The line above will download the latest .xml files from the public Khronos repository and update signatures.xml for the binding generator.
|
||||||
Convert.exe -p:gl -t:spec -o:../../../Source/Bind/Specifications/GL2/signatures.xml https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/oldspecs/gl.spec https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/oldspecs/enum.spec https://cvs.khronos.org/svn/repos/ogl/trunk/doc/registry/public/oldspecs/enumext.spec
|
|
||||||
|
|
||||||
The line above will download the latest .spec files from the public Khronos repository and update signatures.xml for the binding generator.
|
|
||||||
|
|
||||||
[Usage]
|
[Usage]
|
||||||
|
|
||||||
Convert.exe -p:{PREFIX} -v:{VERSION} -t:{TYPE} -o:{OUT} {INPUT1} ... {INPUTn}
|
Convert.exe -p:{PREFIX} -v:{VERSION} -t:{TYPE} -o:{OUT} {INPUT1} ... {INPUTn}
|
||||||
{PREFIX} is a simple string that defines the a common prefix for functions and constants in this header. This prefix will be removed from the generated XML file.
|
{PREFIX} is a simple string that defines the a common prefix for functions and constants in this header. This prefix will be removed from the generated XML file.
|
||||||
{VERSION} is a string that defines that version that will be used for functions in the generated XML file. Specific input files may override this setting.
|
{VERSION} is a string that defines that version that will be used for functions in the generated XML file. Specific input files may override this setting.
|
||||||
{TYPE} can be either 'spec' or 'header' to indicate whether the input files are OpenGL .spec files or C headers.
|
{TYPE} can be either 'xml' or 'header' to indicate whether the input files are OpenGL .xml files or C headers.
|
||||||
{OUT} is the output filename (optional). If no output file is specified, output will be directed to the console.
|
{OUT} is the output filename (optional). If no output file is specified, output will be directed to the console.
|
||||||
{INPUT1..n} is a space-separated list of input files (headers).
|
{INPUT1..n} is a space-separated list of input files (headers).
|
||||||
|
|
||||||
Despite what the help says, all three parameters are necessary at the moment.
|
Despite what the help says, prefix, version and type parameters are necessary at the moment.
|
||||||
|
|
||||||
|
|
||||||
[Support]
|
[Support]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue