diff --git a/Source/Bind/Settings.cs b/Source/Bind/Settings.cs
index 1e020cbd..5ebb5c09 100644
--- a/Source/Bind/Settings.cs
+++ b/Source/Bind/Settings.cs
@@ -5,53 +5,57 @@
#endregion
using System;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
namespace Bind
{
- static class Settings
+ [Serializable]
+ class Settings
{
// Disable BeforeFieldInit.
- static Settings() { }
+ public Settings() { }
- public static string DefaultInputPath = "../../../Source/Bind/Specifications";
- public static string DefaultOutputPath = "../../../Source/OpenTK/Graphics/OpenGL";
- public static string DefaultOutputNamespace = "OpenTK.Graphics.OpenGL";
- public static string DefaultDocPath = "../../../Source/Bind/Specifications/Docs";
- public static string DefaultDocFile = "ToInlineDocs.xslt";
- public static string DefaultLicenseFile = "License.txt";
- public static string DefaultOverridesFile = "GL2/gloverrides.xml";
- public static string DefaultLanguageTypeMapFile = "csharp.tm";
- public static string DefaultKeywordEscapeCharacter = "@";
+ public string DefaultInputPath = "../../../Source/Bind/Specifications";
+ public string DefaultOutputPath = "../../../Source/OpenTK/Graphics/OpenGL";
+ public string DefaultOutputNamespace = "OpenTK.Graphics.OpenGL";
+ public string DefaultDocPath = "../../../Source/Bind/Specifications/Docs";
+ public string DefaultDocFile = "ToInlineDocs.xslt";
+ public string DefaultLicenseFile = "License.txt";
+ public string DefaultOverridesFile = "GL2/gloverrides.xml";
+ public string DefaultLanguageTypeMapFile = "csharp.tm";
+ public string DefaultKeywordEscapeCharacter = "@";
- static string inputPath, outputPath, outputNamespace, docPath, docFile, licenseFile, overridesFile,
+ string inputPath, outputPath, outputNamespace, docPath, docFile, licenseFile, overridesFile,
languageTypeMapFile, keywordEscapeCharacter;
- public static string InputPath { get { return inputPath ?? DefaultInputPath; } set { inputPath = value; } }
- public static string OutputPath { get { return outputPath ?? DefaultOutputPath; } set { outputPath = value; } }
- public static string OutputNamespace { get { return outputNamespace ?? DefaultOutputNamespace; } set { outputNamespace = value; } }
- public static string DocPath { get { return docPath ?? DefaultDocPath; } set { docPath = value; } }
- public static string DocFile { get { return docFile ?? DefaultDocFile; } set { docFile = value; } }
- public static string LicenseFile { get { return licenseFile ?? DefaultLicenseFile; } set { licenseFile = value; } }
- public static string OverridesFile { get { return overridesFile ?? DefaultOverridesFile; } set { overridesFile = value; } }
- public static string LanguageTypeMapFile { get { return languageTypeMapFile ?? DefaultLanguageTypeMapFile; } set { languageTypeMapFile = value; } }
- public static string KeywordEscapeCharacter { get { return keywordEscapeCharacter ?? DefaultKeywordEscapeCharacter; } set { keywordEscapeCharacter = value; } }
+ public string InputPath { get { return inputPath ?? DefaultInputPath; } set { inputPath = value; } }
+ public string OutputPath { get { return outputPath ?? DefaultOutputPath; } set { outputPath = value; } }
+ public string OutputNamespace { get { return outputNamespace ?? DefaultOutputNamespace; } set { outputNamespace = value; } }
+ public string DocPath { get { return docPath ?? DefaultDocPath; } set { docPath = value; } }
+ public string DocFile { get { return docFile ?? DefaultDocFile; } set { docFile = value; } }
+ public string LicenseFile { get { return licenseFile ?? DefaultLicenseFile; } set { licenseFile = value; } }
+ public string OverridesFile { get { return overridesFile ?? DefaultOverridesFile; } set { overridesFile = value; } }
+ public string LanguageTypeMapFile { get { return languageTypeMapFile ?? DefaultLanguageTypeMapFile; } set { languageTypeMapFile = value; } }
+ public string KeywordEscapeCharacter { get { return keywordEscapeCharacter ?? DefaultKeywordEscapeCharacter; } set { keywordEscapeCharacter = value; } }
- public static string GLClass = "GL"; // Needed by Glu for the AuxEnumsClass. Can be set through -gl:"xxx".
- public static string OutputClass = "GL"; // The real output class. Can be set through -class:"xxx".
- public static string FunctionPrefix = "gl";
- public static string ConstantPrefix = "GL_";
- public static string EnumPrefix = "";
- public static string NamespaceSeparator = ".";
+ public string GLClass = "GL"; // Needed by Glu for the AuxEnumsClass. Can be set through -gl:"xxx".
+ public string OutputClass = "GL"; // The real output class. Can be set through -class:"xxx".
+ public string FunctionPrefix = "gl";
+ public string ConstantPrefix = "GL_";
+ public string EnumPrefix = "";
+ public string NamespaceSeparator = ".";
- public static string ImportsFile = "Core.cs";
- public static string DelegatesFile = "Delegates.cs";
- public static string EnumsFile = "Enums.cs";
- public static string WrappersFile = "GL.cs";
+ public string ImportsFile = "Core.cs";
+ public string DelegatesFile = "Delegates.cs";
+ public string EnumsFile = "Enums.cs";
+ public string WrappersFile = "GL.cs";
// TODO: This code is too fragile.
// Old enums code:
- public static string normalEnumsClassOverride = null;
- public static string NestedEnumsClass = "Enums";
- public static string NormalEnumsClass
+ public string normalEnumsClassOverride = null;
+ public string NestedEnumsClass = "Enums";
+ public string NormalEnumsClass
{
get
{
@@ -62,12 +66,12 @@ namespace Bind
}
}
- public static string AuxEnumsClass
+ public string AuxEnumsClass
{
get { return GLClass + NamespaceSeparator + NestedEnumsClass; }
}
- public static string EnumsOutput
+ public string EnumsOutput
{
get
{
@@ -78,7 +82,7 @@ namespace Bind
}
}
- public static string EnumsAuxOutput
+ public string EnumsAuxOutput
{
get
{
@@ -90,17 +94,17 @@ namespace Bind
}
// New enums namespace (don't use a nested class).
- public static string EnumsNamespace = null;// = "Enums";
+ public string EnumsNamespace = null;// = "Enums";
- public static string DelegatesClass = "Delegates";
- public static string ImportsClass = "Core";
+ public string DelegatesClass = "Delegates";
+ public string ImportsClass = "Core";
- public static Legacy Compatibility = Legacy.NoDropMultipleTokens;
+ public Legacy Compatibility = Legacy.NoDropMultipleTokens;
///
/// The name of the C# enum which holds every single OpenGL enum (for compatibility purposes).
///
- public static string CompleteEnumName = "All";
+ public string CompleteEnumName = "All";
[Flags]
public enum Legacy
{
@@ -159,32 +163,43 @@ namespace Bind
}
// Returns true if flag is enabled.
- public static bool IsEnabled(Legacy flag)
+ public bool IsEnabled(Legacy flag)
{
return (Compatibility & flag) != (Legacy)0;
}
// Enables the specified flag.
- public static void Enable(Legacy flag)
+ public void Enable(Legacy flag)
{
Compatibility |= flag;
}
// Disables the specified flag.
- public static void Disable(Legacy flag)
+ public void Disable(Legacy flag)
{
Compatibility &= ~flag;
}
/// True if multiple tokens should be dropped (e.g. FooARB, FooEXT and FooSGI).
- public static bool DropMultipleTokens
+ public bool DropMultipleTokens
{
get { return (Compatibility & Legacy.NoDropMultipleTokens) == Legacy.None; }
set { if (value) Compatibility |= Legacy.NoDropMultipleTokens; else Compatibility &= ~Legacy.NoDropMultipleTokens; }
}
- public static string WindowsGDI = "OpenTK.Platform.Windows.API";
+ public string WindowsGDI = "OpenTK.Platform.Windows.API";
- public static GeneratorLanguage Language { get; set; }
+ public GeneratorLanguage Language { get; set; }
+
+ public Settings Clone()
+ {
+ IFormatter formatter = new BinaryFormatter();
+ using (var stream = new MemoryStream())
+ {
+ formatter.Serialize(stream, this);
+ stream.Seek(0, SeekOrigin.Begin);
+ return (Settings)formatter.Deserialize(stream);
+ }
+ }
}
}