From 581919cb1cbc3cc8c8f26a2ba34ec25796a4964f Mon Sep 17 00:00:00 2001 From: thefiddler Date: Mon, 21 Oct 2013 18:28:01 +0200 Subject: [PATCH] Initial work on new gl xml spec support. --- OpenTK.sln | 40 +------------------- Source/Converter/GLXmlParser.cs | 46 +++++++++++++++++++++++ Source/Converter/Generator.Convert.csproj | 2 + Source/Converter/Main.cs | 4 +- 4 files changed, 52 insertions(+), 40 deletions(-) create mode 100644 Source/Converter/GLXmlParser.cs diff --git a/OpenTK.sln b/OpenTK.sln index b021fde9..fe52ed4d 100644 --- a/OpenTK.sln +++ b/OpenTK.sln @@ -2,62 +2,24 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK", "Source\OpenTK\OpenTK.csproj", "{A37A7E14-0000-0000-0000-000000000000}" - ProjectSection(ProjectDependencies) = postProject - {75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.Compatibility", "Source\Compatibility\OpenTK.Compatibility.csproj", "{62C0DB35-0000-0000-0000-000000000000}" - ProjectSection(ProjectDependencies) = postProject - {75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.Examples", "Source\Examples\OpenTK.Examples.csproj", "{868E37B3-0000-0000-0000-000000000000}" - ProjectSection(ProjectDependencies) = postProject - {75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK.GLControl", "Source\GLControl\OpenTK.GLControl.csproj", "{A625BE88-0000-0000-0000-000000000000}" - ProjectSection(ProjectDependencies) = postProject - {75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build.Installer.Nsis", "Installers\Nsis\Build.Installer.Nsis.csproj", "{ADC34399-7613-44D2-90B2-19250F06FE7A}" - ProjectSection(ProjectDependencies) = postProject - {A37A7E14-0000-0000-0000-000000000000} = {A37A7E14-0000-0000-0000-000000000000} - {31D19132-0000-0000-0000-000000000000} = {31D19132-0000-0000-0000-000000000000} - {62C0DB35-0000-0000-0000-000000000000} = {62C0DB35-0000-0000-0000-000000000000} - {650C6F3D-33B5-4216-9536-956AB42C0624} = {650C6F3D-33B5-4216-9536-956AB42C0624} - {A625BE88-0000-0000-0000-000000000000} = {A625BE88-0000-0000-0000-000000000000} - {75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8} - {868E37B3-0000-0000-0000-000000000000} = {868E37B3-0000-0000-0000-000000000000} - {5FDFF4B6-0000-0000-0000-000000000000} = {5FDFF4B6-0000-0000-0000-000000000000} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build.Docs", "Documentation\Build.Docs.csproj", "{650C6F3D-33B5-4216-9536-956AB42C0624}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator.Bind", "Source\Bind\Generator.Bind.csproj", "{31D19132-0000-0000-0000-000000000000}" - ProjectSection(ProjectDependencies) = postProject - {75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator.Convert", "Source\Converter\Generator.Convert.csproj", "{5FDFF4B6-0000-0000-0000-000000000000}" - ProjectSection(ProjectDependencies) = postProject - {75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8} - EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build.UpdateVersion", "Source\Build.UpdateVersion\Build.UpdateVersion.csproj", "{75DC22B1-113F-4A66-96B9-2FF8208C10E8}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build.Installer.Zip", "Installers\Zip\Build.Installer.Zip.csproj", "{ADC34399-7613-44D2-90B2-19250F06FE7B}" - ProjectSection(ProjectDependencies) = postProject - {A37A7E14-0000-0000-0000-000000000000} = {A37A7E14-0000-0000-0000-000000000000} - {31D19132-0000-0000-0000-000000000000} = {31D19132-0000-0000-0000-000000000000} - {62C0DB35-0000-0000-0000-000000000000} = {62C0DB35-0000-0000-0000-000000000000} - {650C6F3D-33B5-4216-9536-956AB42C0624} = {650C6F3D-33B5-4216-9536-956AB42C0624} - {A625BE88-0000-0000-0000-000000000000} = {A625BE88-0000-0000-0000-000000000000} - {75DC22B1-113F-4A66-96B9-2FF8208C10E8} = {75DC22B1-113F-4A66-96B9-2FF8208C10E8} - {868E37B3-0000-0000-0000-000000000000} = {868E37B3-0000-0000-0000-000000000000} - {5FDFF4B6-0000-0000-0000-000000000000} = {5FDFF4B6-0000-0000-0000-000000000000} - EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -132,7 +94,7 @@ Global {ADC34399-7613-44D2-90B2-19250F06FE7B}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = Source\Examples\OpenTK.Examples.csproj + StartupItem = Source\Converter\Generator.Convert.csproj EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source/Converter/GLXmlParser.cs b/Source/Converter/GLXmlParser.cs new file mode 100644 index 00000000..6a75c45d --- /dev/null +++ b/Source/Converter/GLXmlParser.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Xml.Linq; + +namespace CHeaderToXML +{ + class GLXmlParser : Parser + { + public GLXmlParser() + { + + } + + public override IEnumerable Parse(string[] lines) + { + var input = XDocument.Parse(String.Join(" ", lines)); + + // Enumerations + var groups = input.Root + .Elements("groups") + .Elements("group"); + foreach (var group in groups) + { + var e = new XElement("enum"); + e.Name = group.Attribute("name").Value; + foreach (var token in group.Elements("enum")) + { + if (token.Attribute("value") != null) + { + e.Add(new XElement("token", + new XAttribute("name", token.Attribute("name")), + new XAttribute("value", token.Attribute("value")))); + } + else + { + e.Add(new XElement("use", + new XAttribute("token", token.Attribute("name")))); + } + } + + yield return e; + } + } + } +} + diff --git a/Source/Converter/Generator.Convert.csproj b/Source/Converter/Generator.Convert.csproj index c32542ab..d2d605cd 100644 --- a/Source/Converter/Generator.Convert.csproj +++ b/Source/Converter/Generator.Convert.csproj @@ -56,6 +56,7 @@ 4 AllRules.ruleset full + -p:gl -v:44 -t:xml -o:gl4.xml gl.xml 285212672 @@ -161,6 +162,7 @@ + diff --git a/Source/Converter/Main.cs b/Source/Converter/Main.cs index acad3991..b4e983e2 100644 --- a/Source/Converter/Main.cs +++ b/Source/Converter/Main.cs @@ -63,7 +63,8 @@ namespace CHeaderToXML enum HeaderType { Header, - Spec + Spec, + Xml } class EntryPoint @@ -112,6 +113,7 @@ namespace CHeaderToXML Parser parser = 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 } : (Parser)null; var sigs = headers.Select(h => parser.Parse(h)).ToList();