From e8f46c87f6b1717a1bfaf6b3ca0f2feb118570be Mon Sep 17 00:00:00 2001 From: Stefanos A Date: Sun, 3 Nov 2013 01:27:10 +0100 Subject: [PATCH] Do not override user defined output files The generator will now change the default output files to match its bindings (e.g. GL vs ES), but the user is now able to override this option. --- Source/Bind/CL/CLGenerator.cs | 12 ++++++---- Source/Bind/ES/ESGenerator.cs | 20 +++++++++++----- Source/Bind/GL2/GL4Generator.cs | 13 +++++----- Source/Bind/GL2/Generator.cs | 42 ++++++++++++++++++++++----------- 4 files changed, 57 insertions(+), 30 deletions(-) diff --git a/Source/Bind/CL/CLGenerator.cs b/Source/Bind/CL/CLGenerator.cs index 20868f0f..29ad934f 100644 --- a/Source/Bind/CL/CLGenerator.cs +++ b/Source/Bind/CL/CLGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Xml.XPath; @@ -11,8 +11,8 @@ namespace Bind.CL { class CLGenerator : ES.ESGenerator { - public CLGenerator(Settings settings, string name, string dirname) - : base(settings, name, dirname) + public CLGenerator(Settings settings, string dirname) + : base(settings, dirname) { glTypemap = null; @@ -23,10 +23,14 @@ namespace Bind.CL Settings.EnumPrefix = "Cl"; Settings.OutputClass = "CL"; - Settings.OutputNamespace = "OpenTK.Compute." + name; //Settings.Compatibility &= ~Settings.Legacy.TurnVoidPointersToIntPtr; Settings.Compatibility |= Settings.Legacy.NoDebugHelpers; + + Settings.DefaultImportsFile = "CLCore.cs"; + Settings.DefaultDelegatesFile = "CLDelegates.cs"; + Settings.DefaultEnumsFile = "CLEnums.cs"; + Settings.DefaultWrappersFile = "CL.cs"; } } } diff --git a/Source/Bind/ES/ESGenerator.cs b/Source/Bind/ES/ESGenerator.cs index 16a65eef..849061e2 100644 --- a/Source/Bind/ES/ESGenerator.cs +++ b/Source/Bind/ES/ESGenerator.cs @@ -9,15 +9,23 @@ using Enum=Bind.Structures.Enum; namespace Bind.ES { + // Generator implementation for OpenGL ES 1.0 and 1.1 class ESGenerator : Generator { - public ESGenerator(Settings settings, string nsName, string dirName) - : base(settings, nsName, dirName) + public ESGenerator(Settings settings, string dirName) + : base(settings, dirName) { - Settings.ImportsFile = nsName + "Core.cs"; - Settings.DelegatesFile = nsName + "Delegates.cs"; - Settings.EnumsFile = nsName + "Enums.cs"; - Settings.WrappersFile = nsName + ".cs"; + Settings.DefaultOutputNamespace = "OpenTK.Graphics.ES11"; + Settings.DefaultImportsFile = "ES11Core.cs"; + Settings.DefaultDelegatesFile = "ES11Delegates.cs"; + Settings.DefaultEnumsFile = "ES11Enums.cs"; + Settings.DefaultWrappersFile = "ES11.cs"; + + // Khronos releases a combined 1.0+1.1 specification, + // so we cannot distinguish between the two. + // Todo: add support for common and light profiles. + Profile = "gles1"; + Version = "1.1"; } } } diff --git a/Source/Bind/GL2/GL4Generator.cs b/Source/Bind/GL2/GL4Generator.cs index 5898e2e0..f8171042 100644 --- a/Source/Bind/GL2/GL4Generator.cs +++ b/Source/Bind/GL2/GL4Generator.cs @@ -35,13 +35,14 @@ namespace Bind.GL2 { class GL4Generator : Generator { - public GL4Generator(Settings settings, string name, string dirname) - : base(settings, name, dirname) + public GL4Generator(Settings settings, string dirname) + : base(settings, dirname) { - Settings.ImportsFile = "GL4Core.cs"; - Settings.DelegatesFile = "GL4Delegates.cs"; - Settings.EnumsFile = "GL4Enums.cs"; - Settings.WrappersFile = "GL4.cs"; + Settings.DefaultOutputNamespace = "OpenTK.Graphics.OpenGL4"; + Settings.DefaultImportsFile = "GL4Core.cs"; + Settings.DefaultDelegatesFile = "GL4Delegates.cs"; + Settings.DefaultEnumsFile = "GL4Enums.cs"; + Settings.DefaultWrappersFile = "GL4.cs"; Profile = "glcore"; } diff --git a/Source/Bind/GL2/Generator.cs b/Source/Bind/GL2/Generator.cs index f99a3adf..31102710 100644 --- a/Source/Bind/GL2/Generator.cs +++ b/Source/Bind/GL2/Generator.cs @@ -37,19 +37,33 @@ namespace Bind.GL2 //protected static readonly Dictionary doc_replacements; protected ISpecReader SpecReader { get; set; } + + /// + /// The Profile field corresponds to the "profile" attribute + /// in the OpenGL registry. We use this to distinguish between + /// different profiles (e.g. "gl", "glcore", "gles1", "gles2"). + /// protected string Profile = "gl"; + + /// + /// The Version field corresponds to the "number" attribute + /// in the OpenGL registry. We use this to distinguish between + /// OpenGL ES 2.0 and 3.0, which share the same profile "gles2". + /// If empty, then all elements of a profile will be parsed, and + /// their version number will be ignored. + /// + protected string Version = String.Empty; + public Settings Settings { get; protected set; } #endregion #region Constructors - public Generator(Settings settings, string nsName, string dirName) + public Generator(Settings settings, string dirName) { if (settings == null) throw new ArgumentNullException("settings"); - if (String.IsNullOrEmpty(nsName)) - throw new ArgumentNullException("nsName"); if (dirName == null) dirName = "GL2"; @@ -67,7 +81,6 @@ namespace Bind.GL2 Settings.ImportsClass = "Core"; Settings.DelegatesClass = "Delegates"; Settings.OutputClass = "GL"; - Settings.OutputNamespace = nsName; if (Settings.Compatibility == Settings.Legacy.Tao) { @@ -79,10 +92,11 @@ namespace Bind.GL2 // Defaults } - Settings.ImportsFile = "GLCore.cs"; - Settings.DelegatesFile = "GLDelegates.cs"; - Settings.EnumsFile = "GLEnums.cs"; - Settings.WrappersFile = "GL.cs"; + Settings.DefaultOutputNamespace = "OpenTK.Graphics.OpenGL"; + Settings.DefaultImportsFile = "GLCore.cs"; + Settings.DefaultDelegatesFile = "GLDelegates.cs"; + Settings.DefaultEnumsFile = "GLEnums.cs"; + Settings.DefaultWrappersFile = "GL.cs"; Delegates = new DelegateCollection(); Enums = new EnumCollection(); @@ -108,16 +122,16 @@ namespace Bind.GL2 GLTypes = SpecReader.ReadTypeMap(Path.Combine(Settings.InputPath, glTypemap)); CSTypes = SpecReader.ReadCSTypeMap(Path.Combine(Settings.InputPath, csTypemap)); - SpecReader.ReadEnums(Path.Combine(Settings.InputPath, enumSpec), Enums, Profile); - SpecReader.ReadEnums(overrides, Enums, ""); - SpecReader.ReadDelegates(Path.Combine(Settings.InputPath, glSpec), Delegates, Profile); - SpecReader.ReadDelegates(overrides, Delegates, ""); + SpecReader.ReadEnums(Path.Combine(Settings.InputPath, enumSpec), Enums, Profile, Version); + SpecReader.ReadEnums(overrides, Enums, Profile, Version); + SpecReader.ReadDelegates(Path.Combine(Settings.InputPath, glSpec), Delegates, Profile, Version); + SpecReader.ReadDelegates(overrides, Delegates, Profile, Version); var enum_processor = new EnumProcessor(this, overrides); var func_processor = new FuncProcessor(this, overrides); - Enums = enum_processor.Process(Enums); - Wrappers = func_processor.Process(enum_processor, Delegates, Enums); + Enums = enum_processor.Process(Enums, Profile); + Wrappers = func_processor.Process(enum_processor, Delegates, Enums, Profile); } #endregion