diff --git a/Source/Bind/CL/CLGenerator.cs b/Source/Bind/CL/CLGenerator.cs index e0067e23..20868f0f 100644 --- a/Source/Bind/CL/CLGenerator.cs +++ b/Source/Bind/CL/CLGenerator.cs @@ -11,12 +11,12 @@ namespace Bind.CL { class CLGenerator : ES.ESGenerator { - public CLGenerator(string name, string dirname) - : base(name, dirname) + public CLGenerator(Settings settings, string name, string dirname) + : base(settings, name, dirname) { glTypemap = null; - Settings.WrappersFile = "CL.cs"; + Settings.WrappersFile = "CL.cs"; Settings.FunctionPrefix = "cl"; Settings.ConstantPrefix = "CL_"; diff --git a/Source/Bind/ES/ESGenerator.cs b/Source/Bind/ES/ESGenerator.cs index 0e680511..16a65eef 100644 --- a/Source/Bind/ES/ESGenerator.cs +++ b/Source/Bind/ES/ESGenerator.cs @@ -11,13 +11,13 @@ namespace Bind.ES { class ESGenerator : Generator { - public ESGenerator(string nsName, string dirName) - : base(nsName, dirName) + public ESGenerator(Settings settings, string nsName, string dirName) + : base(settings, nsName, dirName) { - Settings.ImportsFile = "Core.cs"; - Settings.DelegatesFile = "Delegates.cs"; - Settings.EnumsFile = "Enums.cs"; - Settings.WrappersFile = "ES.cs"; + Settings.ImportsFile = nsName + "Core.cs"; + Settings.DelegatesFile = nsName + "Delegates.cs"; + Settings.EnumsFile = nsName + "Enums.cs"; + Settings.WrappersFile = nsName + ".cs"; } } } diff --git a/Source/Bind/GL2/GL4Generator.cs b/Source/Bind/GL2/GL4Generator.cs index ef0da80e..5898e2e0 100644 --- a/Source/Bind/GL2/GL4Generator.cs +++ b/Source/Bind/GL2/GL4Generator.cs @@ -35,10 +35,13 @@ namespace Bind.GL2 { class GL4Generator : Generator { - public GL4Generator(string name, string dirname) - : base(name, dirname) + public GL4Generator(Settings settings, string name, string dirname) + : base(settings, name, dirname) { - Settings.OverridesFile = Path.Combine(dirname, "gloverrides.xml"); + Settings.ImportsFile = "GL4Core.cs"; + Settings.DelegatesFile = "GL4Delegates.cs"; + Settings.EnumsFile = "GL4Enums.cs"; + Settings.WrappersFile = "GL4.cs"; Profile = "glcore"; } diff --git a/Source/Bind/GL2/Generator.cs b/Source/Bind/GL2/Generator.cs index 0ae62d6e..f99a3adf 100644 --- a/Source/Bind/GL2/Generator.cs +++ b/Source/Bind/GL2/Generator.cs @@ -22,34 +22,39 @@ namespace Bind.GL2 { #region Fields - protected static string glTypemap = "GL2/gl.tm"; - protected static string csTypemap = Settings.LanguageTypeMapFile; - protected static string enumSpec = "GL2/enum.spec"; - protected static string enumSpecExt = "GL2/enumext.spec"; - protected static string glSpec = "GL2/gl.spec"; - protected static string glSpecExt = ""; + protected string glTypemap = "GL2/gl.tm"; + protected string csTypemap = "csharp.tm"; + protected string enumSpec = "GL2/enum.spec"; + protected string enumSpecExt = "GL2/enumext.spec"; + protected string glSpec = "GL2/gl.spec"; + protected string glSpecExt = ""; - protected static string loadAllFuncName = "LoadAll"; + protected string loadAllFuncName = "LoadAll"; - protected static Regex enumToDotNet = new Regex("_[a-z|A-Z]?", RegexOptions.Compiled); + protected Regex enumToDotNet = new Regex("_[a-z|A-Z]?", RegexOptions.Compiled); - protected static readonly char[] numbers = "0123456789".ToCharArray(); + protected readonly char[] numbers = "0123456789".ToCharArray(); //protected static readonly Dictionary doc_replacements; - protected ISpecReader SpecReader = new XmlSpecReader(); + protected ISpecReader SpecReader { get; set; } protected string Profile = "gl"; + public Settings Settings { get; protected set; } #endregion #region Constructors - public Generator(string nsName, string dirName) + public Generator(Settings settings, string nsName, string dirName) { + if (settings == null) + throw new ArgumentNullException("settings"); if (String.IsNullOrEmpty(nsName)) throw new ArgumentNullException("nsName"); if (dirName == null) dirName = "GL2"; + Settings = settings.Clone(); + glTypemap = "GL2/gl.tm"; csTypemap = Settings.LanguageTypeMapFile; @@ -61,8 +66,8 @@ namespace Bind.GL2 Settings.ImportsClass = "Core"; Settings.DelegatesClass = "Delegates"; - Settings.OutputClass = "GL"; + Settings.OutputNamespace = nsName; if (Settings.Compatibility == Settings.Legacy.Tao) { @@ -82,6 +87,8 @@ namespace Bind.GL2 Delegates = new DelegateCollection(); Enums = new EnumCollection(); Wrappers = new FunctionCollection(); + + SpecReader = new XmlSpecReader(Settings); } #endregion @@ -91,19 +98,23 @@ namespace Bind.GL2 public DelegateCollection Delegates { get; private set; } public EnumCollection Enums { get; private set; } public FunctionCollection Wrappers { get; private set; } + public IDictionary GLTypes { get; private set; } + public IDictionary CSTypes { get; private set; } public virtual void Process() { string overrides = Path.Combine(Settings.InputPath, Settings.OverridesFile); - Type.GLTypes = SpecReader.ReadTypeMap(Path.Combine(Settings.InputPath, glTypemap)); - Type.CSTypes = SpecReader.ReadCSTypeMap(Path.Combine(Settings.InputPath, csTypemap)); + + 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, ""); - var enum_processor = new EnumProcessor(overrides); - var func_processor = new FuncProcessor(overrides); + 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);