mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-20 14:48:31 +00:00
Settings is no longer a singleton
Multiple Settings instances can now be created and used in the same process.
This commit is contained in:
parent
ffc79a749b
commit
832db0da0d
|
@ -5,53 +5,57 @@
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
|
|
||||||
namespace Bind
|
namespace Bind
|
||||||
{
|
{
|
||||||
static class Settings
|
[Serializable]
|
||||||
|
class Settings
|
||||||
{
|
{
|
||||||
// Disable BeforeFieldInit.
|
// Disable BeforeFieldInit.
|
||||||
static Settings() { }
|
public Settings() { }
|
||||||
|
|
||||||
public static string DefaultInputPath = "../../../Source/Bind/Specifications";
|
public string DefaultInputPath = "../../../Source/Bind/Specifications";
|
||||||
public static string DefaultOutputPath = "../../../Source/OpenTK/Graphics/OpenGL";
|
public string DefaultOutputPath = "../../../Source/OpenTK/Graphics/OpenGL";
|
||||||
public static string DefaultOutputNamespace = "OpenTK.Graphics.OpenGL";
|
public string DefaultOutputNamespace = "OpenTK.Graphics.OpenGL";
|
||||||
public static string DefaultDocPath = "../../../Source/Bind/Specifications/Docs";
|
public string DefaultDocPath = "../../../Source/Bind/Specifications/Docs";
|
||||||
public static string DefaultDocFile = "ToInlineDocs.xslt";
|
public string DefaultDocFile = "ToInlineDocs.xslt";
|
||||||
public static string DefaultLicenseFile = "License.txt";
|
public string DefaultLicenseFile = "License.txt";
|
||||||
public static string DefaultOverridesFile = "GL2/gloverrides.xml";
|
public string DefaultOverridesFile = "GL2/gloverrides.xml";
|
||||||
public static string DefaultLanguageTypeMapFile = "csharp.tm";
|
public string DefaultLanguageTypeMapFile = "csharp.tm";
|
||||||
public static string DefaultKeywordEscapeCharacter = "@";
|
public string DefaultKeywordEscapeCharacter = "@";
|
||||||
|
|
||||||
static string inputPath, outputPath, outputNamespace, docPath, docFile, licenseFile, overridesFile,
|
string inputPath, outputPath, outputNamespace, docPath, docFile, licenseFile, overridesFile,
|
||||||
languageTypeMapFile, keywordEscapeCharacter;
|
languageTypeMapFile, keywordEscapeCharacter;
|
||||||
public static string InputPath { get { return inputPath ?? DefaultInputPath; } set { inputPath = value; } }
|
public string InputPath { get { return inputPath ?? DefaultInputPath; } set { inputPath = value; } }
|
||||||
public static string OutputPath { get { return outputPath ?? DefaultOutputPath; } set { outputPath = value; } }
|
public string OutputPath { get { return outputPath ?? DefaultOutputPath; } set { outputPath = value; } }
|
||||||
public static string OutputNamespace { get { return outputNamespace ?? DefaultOutputNamespace; } set { outputNamespace = value; } }
|
public string OutputNamespace { get { return outputNamespace ?? DefaultOutputNamespace; } set { outputNamespace = value; } }
|
||||||
public static string DocPath { get { return docPath ?? DefaultDocPath; } set { docPath = value; } }
|
public string DocPath { get { return docPath ?? DefaultDocPath; } set { docPath = value; } }
|
||||||
public static string DocFile { get { return docFile ?? DefaultDocFile; } set { docFile = value; } }
|
public string DocFile { get { return docFile ?? DefaultDocFile; } set { docFile = value; } }
|
||||||
public static string LicenseFile { get { return licenseFile ?? DefaultLicenseFile; } set { licenseFile = value; } }
|
public string LicenseFile { get { return licenseFile ?? DefaultLicenseFile; } set { licenseFile = value; } }
|
||||||
public static string OverridesFile { get { return overridesFile ?? DefaultOverridesFile; } set { overridesFile = value; } }
|
public string OverridesFile { get { return overridesFile ?? DefaultOverridesFile; } set { overridesFile = value; } }
|
||||||
public static string LanguageTypeMapFile { get { return languageTypeMapFile ?? DefaultLanguageTypeMapFile; } set { languageTypeMapFile = value; } }
|
public string LanguageTypeMapFile { get { return languageTypeMapFile ?? DefaultLanguageTypeMapFile; } set { languageTypeMapFile = value; } }
|
||||||
public static string KeywordEscapeCharacter { get { return keywordEscapeCharacter ?? DefaultKeywordEscapeCharacter; } set { keywordEscapeCharacter = 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 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 string OutputClass = "GL"; // The real output class. Can be set through -class:"xxx".
|
||||||
public static string FunctionPrefix = "gl";
|
public string FunctionPrefix = "gl";
|
||||||
public static string ConstantPrefix = "GL_";
|
public string ConstantPrefix = "GL_";
|
||||||
public static string EnumPrefix = "";
|
public string EnumPrefix = "";
|
||||||
public static string NamespaceSeparator = ".";
|
public string NamespaceSeparator = ".";
|
||||||
|
|
||||||
public static string ImportsFile = "Core.cs";
|
public string ImportsFile = "Core.cs";
|
||||||
public static string DelegatesFile = "Delegates.cs";
|
public string DelegatesFile = "Delegates.cs";
|
||||||
public static string EnumsFile = "Enums.cs";
|
public string EnumsFile = "Enums.cs";
|
||||||
public static string WrappersFile = "GL.cs";
|
public string WrappersFile = "GL.cs";
|
||||||
|
|
||||||
// TODO: This code is too fragile.
|
// TODO: This code is too fragile.
|
||||||
// Old enums code:
|
// Old enums code:
|
||||||
public static string normalEnumsClassOverride = null;
|
public string normalEnumsClassOverride = null;
|
||||||
public static string NestedEnumsClass = "Enums";
|
public string NestedEnumsClass = "Enums";
|
||||||
public static string NormalEnumsClass
|
public string NormalEnumsClass
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -62,12 +66,12 @@ namespace Bind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string AuxEnumsClass
|
public string AuxEnumsClass
|
||||||
{
|
{
|
||||||
get { return GLClass + NamespaceSeparator + NestedEnumsClass; }
|
get { return GLClass + NamespaceSeparator + NestedEnumsClass; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string EnumsOutput
|
public string EnumsOutput
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -78,7 +82,7 @@ namespace Bind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string EnumsAuxOutput
|
public string EnumsAuxOutput
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -90,17 +94,17 @@ namespace Bind
|
||||||
}
|
}
|
||||||
|
|
||||||
// New enums namespace (don't use a nested class).
|
// 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 string DelegatesClass = "Delegates";
|
||||||
public static string ImportsClass = "Core";
|
public string ImportsClass = "Core";
|
||||||
|
|
||||||
public static Legacy Compatibility = Legacy.NoDropMultipleTokens;
|
public Legacy Compatibility = Legacy.NoDropMultipleTokens;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the C# enum which holds every single OpenGL enum (for compatibility purposes).
|
/// The name of the C# enum which holds every single OpenGL enum (for compatibility purposes).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string CompleteEnumName = "All";
|
public string CompleteEnumName = "All";
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum Legacy
|
public enum Legacy
|
||||||
{
|
{
|
||||||
|
@ -159,32 +163,43 @@ namespace Bind
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if flag is enabled.
|
// Returns true if flag is enabled.
|
||||||
public static bool IsEnabled(Legacy flag)
|
public bool IsEnabled(Legacy flag)
|
||||||
{
|
{
|
||||||
return (Compatibility & flag) != (Legacy)0;
|
return (Compatibility & flag) != (Legacy)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enables the specified flag.
|
// Enables the specified flag.
|
||||||
public static void Enable(Legacy flag)
|
public void Enable(Legacy flag)
|
||||||
{
|
{
|
||||||
Compatibility |= flag;
|
Compatibility |= flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disables the specified flag.
|
// Disables the specified flag.
|
||||||
public static void Disable(Legacy flag)
|
public void Disable(Legacy flag)
|
||||||
{
|
{
|
||||||
Compatibility &= ~flag;
|
Compatibility &= ~flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>True if multiple tokens should be dropped (e.g. FooARB, FooEXT and FooSGI).</summary>
|
/// <summary>True if multiple tokens should be dropped (e.g. FooARB, FooEXT and FooSGI).</summary>
|
||||||
public static bool DropMultipleTokens
|
public bool DropMultipleTokens
|
||||||
{
|
{
|
||||||
get { return (Compatibility & Legacy.NoDropMultipleTokens) == Legacy.None; }
|
get { return (Compatibility & Legacy.NoDropMultipleTokens) == Legacy.None; }
|
||||||
set { if (value) Compatibility |= Legacy.NoDropMultipleTokens; else Compatibility &= ~Legacy.NoDropMultipleTokens; }
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue