2009-02-22 11:43:35 +01:00
|
|
|
#region --- License ---
|
|
|
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
|
|
|
* See license.txt for license info
|
|
|
|
*/
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
using System;
|
2013-11-01 09:07:34 +01:00
|
|
|
using System.IO;
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
namespace Bind
|
|
|
|
{
|
2013-11-01 09:07:34 +01:00
|
|
|
[Serializable]
|
|
|
|
class Settings
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
2009-03-08 01:46:58 +01:00
|
|
|
// Disable BeforeFieldInit.
|
2013-11-03 01:25:27 +01:00
|
|
|
public Settings()
|
|
|
|
{
|
|
|
|
}
|
2013-11-01 09:07:34 +01:00
|
|
|
|
|
|
|
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";
|
2014-03-31 17:40:15 +02:00
|
|
|
public string DefaultFallbackDocPath = "../../../Source/Bind/Specifications/Docs/GL";
|
2013-11-01 09:07:34 +01:00
|
|
|
public string DefaultLicenseFile = "License.txt";
|
|
|
|
public string DefaultOverridesFile = "GL2/gloverrides.xml";
|
|
|
|
public string DefaultLanguageTypeMapFile = "csharp.tm";
|
|
|
|
public string DefaultKeywordEscapeCharacter = "@";
|
2013-11-03 01:25:27 +01:00
|
|
|
public string DefaultImportsFile = "Core.cs";
|
|
|
|
public string DefaultDelegatesFile = "Delegates.cs";
|
|
|
|
public string DefaultEnumsFile = "Enums.cs";
|
|
|
|
public string DefaultWrappersFile = "GL.cs";
|
2013-11-11 10:01:30 +01:00
|
|
|
public Legacy DefaultCompatibility = Legacy.NoDropMultipleTokens;
|
2013-11-01 09:07:34 +01:00
|
|
|
|
2014-03-31 17:40:15 +02:00
|
|
|
string inputPath, outputPath, outputNamespace, docPath, fallbackDocPath, licenseFile, overridesFile,
|
2013-11-03 01:25:27 +01:00
|
|
|
languageTypeMapFile, keywordEscapeCharacter, importsFile, delegatesFile, enumsFile,
|
|
|
|
wrappersFile;
|
2013-11-11 10:01:30 +01:00
|
|
|
Nullable<Legacy> compatibility;
|
2013-11-01 09:07:34 +01:00
|
|
|
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; } }
|
2014-03-31 17:40:15 +02:00
|
|
|
public string FallbackDocPath { get { return fallbackDocPath ?? DefaultFallbackDocPath; } set { fallbackDocPath = value; } }
|
2013-11-01 09:07:34 +01:00
|
|
|
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; } }
|
2013-11-03 01:25:27 +01:00
|
|
|
public string ImportsFile { get { return importsFile ?? DefaultImportsFile; } set { importsFile = value; } }
|
|
|
|
public string DelegatesFile { get { return delegatesFile ?? DefaultDelegatesFile; } set { delegatesFile = value; } }
|
|
|
|
public string EnumsFile { get { return enumsFile ?? DefaultEnumsFile; } set { enumsFile = value; } }
|
|
|
|
public string WrappersFile { get { return wrappersFile ?? DefaultWrappersFile; } set { wrappersFile = value; } }
|
2013-11-11 10:01:30 +01:00
|
|
|
public Legacy Compatibility { get { return compatibility ?? DefaultCompatibility; } set { compatibility = value; } }
|
2013-11-01 09:07:34 +01:00
|
|
|
|
|
|
|
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 = ".";
|
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
// TODO: This code is too fragile.
|
|
|
|
// Old enums code:
|
2013-11-01 09:07:34 +01:00
|
|
|
public string normalEnumsClassOverride = null;
|
|
|
|
public string NestedEnumsClass = "Enums";
|
|
|
|
public string NormalEnumsClass
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return
|
|
|
|
normalEnumsClassOverride == null ?
|
2010-12-05 16:45:23 +01:00
|
|
|
String.IsNullOrEmpty(NestedEnumsClass) ? OutputClass : OutputClass + NamespaceSeparator + NestedEnumsClass :
|
2009-02-22 11:43:35 +01:00
|
|
|
normalEnumsClassOverride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-01 09:07:34 +01:00
|
|
|
public string AuxEnumsClass
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
2010-12-05 16:45:23 +01:00
|
|
|
get { return GLClass + NamespaceSeparator + NestedEnumsClass; }
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
|
2013-11-01 09:07:34 +01:00
|
|
|
public string EnumsOutput
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2009-08-21 22:28:14 +02:00
|
|
|
if ((Compatibility & Legacy.NestedEnums) != Legacy.None)
|
2010-12-05 16:45:23 +01:00
|
|
|
return OutputNamespace + NamespaceSeparator + OutputClass + NamespaceSeparator + NestedEnumsClass;
|
2009-02-22 11:43:35 +01:00
|
|
|
else
|
2010-12-05 16:45:23 +01:00
|
|
|
return String.IsNullOrEmpty(EnumsNamespace) ? OutputNamespace : OutputNamespace + NamespaceSeparator + EnumsNamespace;
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-01 09:07:34 +01:00
|
|
|
public string EnumsAuxOutput
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2009-08-21 22:28:14 +02:00
|
|
|
if ((Compatibility & Legacy.NestedEnums) != Legacy.None)
|
2010-12-05 16:45:23 +01:00
|
|
|
return OutputNamespace + NamespaceSeparator + GLClass + NamespaceSeparator + NestedEnumsClass;
|
2009-02-22 11:43:35 +01:00
|
|
|
else
|
2010-12-05 16:45:23 +01:00
|
|
|
return OutputNamespace + NamespaceSeparator + EnumsNamespace;
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-28 19:50:16 +01:00
|
|
|
// New enums namespace (don't use a nested class).
|
2013-11-01 09:07:34 +01:00
|
|
|
public string EnumsNamespace = null;// = "Enums";
|
2009-02-22 11:43:35 +01:00
|
|
|
|
2013-11-01 09:07:34 +01:00
|
|
|
public string DelegatesClass = "Delegates";
|
|
|
|
public string ImportsClass = "Core";
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The name of the C# enum which holds every single OpenGL enum (for compatibility purposes).
|
|
|
|
/// </summary>
|
2013-11-01 09:07:34 +01:00
|
|
|
public string CompleteEnumName = "All";
|
2009-02-22 11:43:35 +01:00
|
|
|
[Flags]
|
|
|
|
public enum Legacy
|
|
|
|
{
|
|
|
|
/// <summary>Default value.</summary>
|
|
|
|
None = 0x00,
|
|
|
|
/// <summary>Leave enums as plain const ints.</summary>
|
|
|
|
ConstIntEnums = 0x01,
|
|
|
|
/// <summary>Leave enums in the default STRANGE_capitalization.ALL_CAPS form.</summary>
|
|
|
|
NoAdvancedEnumProcessing = 0x02,
|
|
|
|
/// <summary>Don't allow unsafe wrappers in the interface.</summary>
|
|
|
|
NoPublicUnsafeFunctions = 0x04,
|
|
|
|
/// <summary>Don't trim the [fdisub]v? endings from functions.</summary>
|
|
|
|
NoTrimFunctionEnding = NoPublicUnsafeFunctions,
|
|
|
|
/// <summary>Don't trim the [gl|wgl|glx|glu] prefixes from functions.</summary>
|
|
|
|
NoTrimFunctionPrefix = 0x08,
|
|
|
|
/// <summary>
|
|
|
|
/// Don't spearate functions in different namespaces, according to their extension category
|
|
|
|
/// (e.g. GL.Arb, GL.Ext etc).
|
|
|
|
/// </summary>
|
|
|
|
NoSeparateFunctionNamespaces = 0x10,
|
|
|
|
/// <summary>
|
|
|
|
/// No public void* parameters (should always be enabled. Disable at your own risk. Disabling
|
|
|
|
/// means that BitmapData.Scan0 and other .Net properties/functions must be cast to (void*)
|
|
|
|
/// explicitly, to avoid the 'object' overload from being called.)
|
|
|
|
/// </summary>
|
|
|
|
TurnVoidPointersToIntPtr = 0x20,
|
|
|
|
/// <summary>Generate all possible permutations for ref/array/pointer parameters.</summary>
|
|
|
|
GenerateAllPermutations = 0x40,
|
|
|
|
/// <summary>Nest enums inside the GL class.</summary>
|
|
|
|
NestedEnums = 0x80,
|
|
|
|
/// <summary>Turn GLboolean to int (Boolean enum), not bool.</summary>
|
|
|
|
NoBoolParameters = 0x100,
|
|
|
|
/// <summary>Keep all enum tokens, even if same value (e.g. FooARB, FooEXT and FooSGI).</summary>
|
|
|
|
NoDropMultipleTokens = 0x200,
|
2009-03-08 01:46:58 +01:00
|
|
|
/// <summary>Do not emit inline documentation.</summary>
|
|
|
|
NoDocumentation = 0x400,
|
2009-08-11 16:03:55 +02:00
|
|
|
/// <summary>Disables ErrorHelper generation.</summary>
|
|
|
|
NoDebugHelpers = 0x800,
|
2009-10-27 23:37:05 +01:00
|
|
|
/// <summary>Generate both typed and untyped ("All") signatures for enum parameters.</summary>
|
|
|
|
KeepUntypedEnums = 0x1000,
|
2010-10-10 14:28:27 +02:00
|
|
|
/// <summary>Marks deprecated functions as [Obsolete]</summary>
|
|
|
|
AddDeprecationWarnings = 0x2000,
|
2014-03-16 19:40:49 +01:00
|
|
|
/// <summary>Use DllImport declaration for core functions (do not generate entry point slots)</summary>
|
|
|
|
UseDllImports = 0x4000,
|
2014-04-02 13:19:41 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Use in conjuction with UseDllImports, to create
|
|
|
|
/// bindings that are compatible with opengl32.dll on Windows.
|
|
|
|
/// This uses DllImports up to GL 1.1 and function pointers
|
|
|
|
/// for higher versions.
|
|
|
|
/// </summary>
|
|
|
|
UseWindowsCompatibleGL = 0x8000,
|
2009-02-22 11:43:35 +01:00
|
|
|
Tao = ConstIntEnums |
|
|
|
|
NoAdvancedEnumProcessing |
|
|
|
|
NoPublicUnsafeFunctions |
|
|
|
|
NoTrimFunctionEnding |
|
|
|
|
NoTrimFunctionPrefix |
|
|
|
|
NoSeparateFunctionNamespaces |
|
|
|
|
TurnVoidPointersToIntPtr |
|
|
|
|
NestedEnums |
|
|
|
|
NoBoolParameters |
|
2009-03-08 01:46:58 +01:00
|
|
|
NoDropMultipleTokens |
|
2014-03-16 19:40:49 +01:00
|
|
|
NoDocumentation |
|
|
|
|
NoDebugHelpers,
|
|
|
|
/*GenerateAllPermutations,*/
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
|
2010-10-10 14:28:27 +02:00
|
|
|
// Returns true if flag is enabled.
|
2013-11-01 09:07:34 +01:00
|
|
|
public bool IsEnabled(Legacy flag)
|
2010-10-10 14:28:27 +02:00
|
|
|
{
|
|
|
|
return (Compatibility & flag) != (Legacy)0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enables the specified flag.
|
2013-11-01 09:07:34 +01:00
|
|
|
public void Enable(Legacy flag)
|
2010-10-10 14:28:27 +02:00
|
|
|
{
|
|
|
|
Compatibility |= flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disables the specified flag.
|
2013-11-01 09:07:34 +01:00
|
|
|
public void Disable(Legacy flag)
|
2010-10-10 14:28:27 +02:00
|
|
|
{
|
|
|
|
Compatibility &= ~flag;
|
|
|
|
}
|
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
/// <summary>True if multiple tokens should be dropped (e.g. FooARB, FooEXT and FooSGI).</summary>
|
2013-11-01 09:07:34 +01:00
|
|
|
public bool DropMultipleTokens
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
2009-08-21 22:28:14 +02:00
|
|
|
get { return (Compatibility & Legacy.NoDropMultipleTokens) == Legacy.None; }
|
|
|
|
set { if (value) Compatibility |= Legacy.NoDropMultipleTokens; else Compatibility &= ~Legacy.NoDropMultipleTokens; }
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
|
2013-11-01 09:07:34 +01:00
|
|
|
public string WindowsGDI = "OpenTK.Platform.Windows.API";
|
2010-12-05 12:24:05 +01:00
|
|
|
|
2013-11-01 09:07:34 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
}
|