Applied Barlog's 02_Bind_2172_ShortenQualifierReferences patch.

This commit is contained in:
the_fiddler 2009-08-21 20:28:14 +00:00
parent 6581d66007
commit 41f4adb09e
17 changed files with 126 additions and 103 deletions

View file

@ -7,13 +7,15 @@
using System; using System;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Bind.Structures;
using Enum=Bind.Structures.Enum;
namespace Bind namespace Bind
{ {
class BindStreamWriter : StreamWriter class BindStreamWriter : StreamWriter
{ {
int indent_level = 0; int indent_level = 0;
Regex splitLines = new Regex(System.Environment.NewLine, RegexOptions.Compiled); Regex splitLines = new Regex(Environment.NewLine, RegexOptions.Compiled);
//Regex splitLines = new Regex("(\r\n|\n\r|\n|\r)", RegexOptions.Compiled); //Regex splitLines = new Regex("(\r\n|\n\r|\n|\r)", RegexOptions.Compiled);
public BindStreamWriter(string file) public BindStreamWriter(string file)
@ -59,13 +61,13 @@ namespace Bind
base.WriteLine(value); base.WriteLine(value);
} }
public void Write(Bind.Structures.Enum e) public void Write(Enum e)
{ {
foreach (string s in splitLines.Split(e.ToString())) foreach (string s in splitLines.Split(e.ToString()))
WriteLine(s.TrimEnd('\r', '\n')); WriteLine(s.TrimEnd('\r', '\n'));
} }
public void Write(Bind.Structures.Function f) public void Write(Function f)
{ {
foreach (string s in splitLines.Split(f.ToString())) foreach (string s in splitLines.Split(f.ToString()))
WriteLine(s); WriteLine(s);

View file

@ -2,11 +2,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Xml.XPath; using System.Xml.XPath;
using Bind.GL2;
using Bind.Structures; using Bind.Structures;
using Delegate=Bind.Structures.Delegate;
using Enum=Bind.Structures.Enum;
namespace Bind.CL namespace Bind.CL
{ {
class CLGenerator : Bind.GL2.Generator class CLGenerator : Generator
{ {
public CLGenerator(string name) public CLGenerator(string name)
{ {
@ -41,7 +44,7 @@ namespace Bind.CL
Settings.Compatibility |= Settings.Legacy.NoDebugHelpers; Settings.Compatibility |= Settings.Legacy.NoDebugHelpers;
} }
public override Bind.Structures.DelegateCollection ReadDelegates(System.IO.StreamReader specFile) public override DelegateCollection ReadDelegates(StreamReader specFile)
{ {
DelegateCollection delegates = new DelegateCollection(); DelegateCollection delegates = new DelegateCollection();
@ -51,7 +54,7 @@ namespace Bind.CL
foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty)) foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty))
{ {
Bind.Structures.Delegate d = new Bind.Structures.Delegate(); Delegate d = new Delegate();
d.Name = node.GetAttribute("name", String.Empty); d.Name = node.GetAttribute("name", String.Empty);
//d.Extension = node.GetAttribute("extension"); //d.Extension = node.GetAttribute("extension");
d.Version = node.GetAttribute("version", String.Empty); d.Version = node.GetAttribute("version", String.Empty);
@ -96,18 +99,18 @@ namespace Bind.CL
return base.ReadCSTypeMap(specFile); return base.ReadCSTypeMap(specFile);
} }
public override Bind.Structures.EnumCollection ReadEnums(StreamReader specFile) public override EnumCollection ReadEnums(StreamReader specFile)
{ {
XPathDocument overrides = new XPathDocument(new StreamReader(Path.Combine(Settings.InputPath, functionOverridesFile))); XPathDocument overrides = new XPathDocument(new StreamReader(Path.Combine(Settings.InputPath, functionOverridesFile)));
EnumCollection enums = new EnumCollection(); EnumCollection enums = new EnumCollection();
Bind.Structures.Enum all = new Bind.Structures.Enum(Settings.CompleteEnumName); Enum all = new Enum(Settings.CompleteEnumName);
XPathDocument doc = new XPathDocument(specFile); XPathDocument doc = new XPathDocument(specFile);
XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("/signatures"); XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("/signatures");
foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty)) foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty))
{ {
Bind.Structures.Enum e = new Bind.Structures.Enum(node.GetAttribute("name", String.Empty)); Enum e = new Enum(node.GetAttribute("name", String.Empty));
if (String.IsNullOrEmpty(e.Name)) if (String.IsNullOrEmpty(e.Name))
throw new InvalidOperationException(String.Format("Empty name for enum element {0}", node.ToString())); throw new InvalidOperationException(String.Format("Empty name for enum element {0}", node.ToString()));

View file

@ -11,7 +11,7 @@ namespace Bind
static readonly Regex remove_mathml = new Regex(@"<(mml:math)[^>]*?>(?:.|\n)*?</\s*\1\s*>", static readonly Regex remove_mathml = new Regex(@"<(mml:math)[^>]*?>(?:.|\n)*?</\s*\1\s*>",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);
static readonly XslCompiledTransform xslt = new System.Xml.Xsl.XslCompiledTransform(); static readonly XslCompiledTransform xslt = new XslCompiledTransform();
static readonly XmlReaderSettings settings = new XmlReaderSettings(); static readonly XmlReaderSettings settings = new XmlReaderSettings();
public DocProcessor(string transform_file) public DocProcessor(string transform_file)

View file

@ -2,11 +2,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Xml.XPath; using System.Xml.XPath;
using Bind.GL2;
using Bind.Structures; using Bind.Structures;
using Delegate=Bind.Structures.Delegate;
using Enum=Bind.Structures.Enum;
namespace Bind.ES namespace Bind.ES
{ {
class ESGenerator : Bind.GL2.Generator class ESGenerator : Generator
{ {
public ESGenerator(string name) public ESGenerator(string name)
{ {
@ -34,7 +37,7 @@ namespace Bind.ES
Settings.OutputPath = Path.Combine(Directory.GetParent(Settings.OutputPath).FullName, name); Settings.OutputPath = Path.Combine(Directory.GetParent(Settings.OutputPath).FullName, name);
} }
public override Bind.Structures.DelegateCollection ReadDelegates(System.IO.StreamReader specFile) public override DelegateCollection ReadDelegates(StreamReader specFile)
{ {
DelegateCollection delegates = new DelegateCollection(); DelegateCollection delegates = new DelegateCollection();
@ -44,7 +47,7 @@ namespace Bind.ES
foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty)) foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty))
{ {
Bind.Structures.Delegate d = new Bind.Structures.Delegate(); Delegate d = new Delegate();
d.Name = node.GetAttribute("name", String.Empty); d.Name = node.GetAttribute("name", String.Empty);
//d.Extension = node.GetAttribute("extension"); //d.Extension = node.GetAttribute("extension");
d.Version = node.GetAttribute("version", String.Empty); d.Version = node.GetAttribute("version", String.Empty);
@ -89,10 +92,10 @@ namespace Bind.ES
return base.ReadCSTypeMap(specFile); return base.ReadCSTypeMap(specFile);
} }
public override Bind.Structures.EnumCollection ReadEnums(StreamReader specFile) public override EnumCollection ReadEnums(StreamReader specFile)
{ {
EnumCollection enums = new EnumCollection(); EnumCollection enums = new EnumCollection();
Bind.Structures.Enum all = new Bind.Structures.Enum(Settings.CompleteEnumName); Enum all = new Enum(Settings.CompleteEnumName);
XPathDocument doc = new XPathDocument(specFile); XPathDocument doc = new XPathDocument(specFile);
XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("/signatures"); XPathNavigator nav = doc.CreateNavigator().SelectSingleNode("/signatures");
@ -100,7 +103,7 @@ namespace Bind.ES
foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty)) foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty))
{ {
Bind.Structures.Enum e = new Bind.Structures.Enum(node.GetAttribute("name", String.Empty)); Enum e = new Enum(node.GetAttribute("name", String.Empty));
if (String.IsNullOrEmpty(e.Name)) if (String.IsNullOrEmpty(e.Name))
throw new InvalidOperationException(String.Format("Empty name for enum element {0}", node.ToString())); throw new InvalidOperationException(String.Format("Empty name for enum element {0}", node.ToString()));

View file

@ -11,6 +11,9 @@ using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Xml.XPath; using System.Xml.XPath;
using Bind.Structures; using Bind.Structures;
using Delegate=Bind.Structures.Delegate;
using Enum=Bind.Structures.Enum;
using Type=Bind.Structures.Type;
namespace Bind.GL2 namespace Bind.GL2
{ {
@ -67,16 +70,16 @@ namespace Bind.GL2
// new Regex(@"(Coord1|Attrib(I?)1(u?)|Stream1|Uniform2(u?)|(Point|Convolution|Transform|Sprite|List|Combiner|Tex)Parameter|Fog(Coord)?.*|VertexWeight|(Fragment)?Light(Model)?|Material|ReplacementCodeu?b?|Tex(Gen|Env)|Indexu?|TextureParameter.v)", // new Regex(@"(Coord1|Attrib(I?)1(u?)|Stream1|Uniform2(u?)|(Point|Convolution|Transform|Sprite|List|Combiner|Tex)Parameter|Fog(Coord)?.*|VertexWeight|(Fragment)?Light(Model)?|Material|ReplacementCodeu?b?|Tex(Gen|Env)|Indexu?|TextureParameter.v)",
// RegexOptions.Compiled); // RegexOptions.Compiled);
Bind.Structures.Type.Initialize(glTypemap, csTypemap); Type.Initialize(glTypemap, csTypemap);
Bind.Structures.Enum.Initialize(enumSpec, enumSpecExt); Enum.Initialize(enumSpec, enumSpecExt);
Bind.Structures.Enum.GLEnums.Translate(new XPathDocument(Path.Combine(Settings.InputPath, functionOverridesFile))); Enum.GLEnums.Translate(new XPathDocument(Path.Combine(Settings.InputPath, functionOverridesFile)));
Bind.Structures.Function.Initialize(); Function.Initialize();
Bind.Structures.Delegate.Initialize(glSpec, glSpecExt); Delegate.Initialize(glSpec, glSpecExt);
this.WriteBindings( this.WriteBindings(
Bind.Structures.Delegate.Delegates, Delegate.Delegates,
Bind.Structures.Function.Wrappers, Function.Wrappers,
Bind.Structures.Enum.GLEnums); Enum.GLEnums);
} }
#endregion #endregion
@ -112,7 +115,7 @@ namespace Bind.GL2
{ {
// Get next OpenGL function // Get next OpenGL function
Bind.Structures.Delegate d = new Bind.Structures.Delegate(); Delegate d = new Delegate();
// Get function name: // Get function name:
d.Name = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries)[0]; d.Name = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries)[0];
@ -184,7 +187,7 @@ namespace Bind.GL2
EnumCollection enums = new EnumCollection(); EnumCollection enums = new EnumCollection();
// complete_enum contains all opengl enumerants. // complete_enum contains all opengl enumerants.
Bind.Structures.Enum complete_enum = new Bind.Structures.Enum(); Enum complete_enum = new Enum();
complete_enum.Name = Settings.CompleteEnumName; complete_enum.Name = Settings.CompleteEnumName;
do do
@ -203,7 +206,7 @@ namespace Bind.GL2
continue; continue;
// Declare a new enumerant // Declare a new enumerant
Bind.Structures.Enum e = new Bind.Structures.Enum(); Enum e = new Enum();
e.Name = Char.IsDigit(words[0][0]) ? Settings.ConstantPrefix + words[0] : words[0]; e.Name = Char.IsDigit(words[0][0]) ? Settings.ConstantPrefix + words[0] : words[0];
// And fill in the values for this enumerant // And fill in the values for this enumerant
@ -393,7 +396,7 @@ namespace Bind.GL2
#region private string NextValidLine(StreamReader sr) #region private string NextValidLine(StreamReader sr)
private string NextValidLine(System.IO.StreamReader sr) private string NextValidLine(StreamReader sr)
{ {
string line; string line;
@ -471,7 +474,7 @@ namespace Bind.GL2
sw.WriteLine("{"); sw.WriteLine("{");
sw.Indent(); sw.Indent();
WriteEnums(sw, Bind.Structures.Enum.GLEnums); WriteEnums(sw, Enum.GLEnums);
sw.Unindent(); sw.Unindent();
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None) if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
@ -495,7 +498,7 @@ namespace Bind.GL2
sw.WriteLine("using System.Runtime.InteropServices;"); sw.WriteLine("using System.Runtime.InteropServices;");
sw.WriteLine("#pragma warning disable 0649"); sw.WriteLine("#pragma warning disable 0649");
WriteDelegates(sw, Bind.Structures.Delegate.Delegates); WriteDelegates(sw, Delegate.Delegates);
sw.Unindent(); sw.Unindent();
sw.WriteLine("}"); sw.WriteLine("}");
@ -512,7 +515,7 @@ namespace Bind.GL2
sw.WriteLine("using System;"); sw.WriteLine("using System;");
sw.WriteLine("using System.Runtime.InteropServices;"); sw.WriteLine("using System.Runtime.InteropServices;");
WriteImports(sw, Bind.Structures.Delegate.Delegates); WriteImports(sw, Delegate.Delegates);
sw.Unindent(); sw.Unindent();
sw.WriteLine("}"); sw.WriteLine("}");
@ -529,7 +532,7 @@ namespace Bind.GL2
sw.WriteLine("using System;"); sw.WriteLine("using System;");
sw.WriteLine("using System.Runtime.InteropServices;"); sw.WriteLine("using System.Runtime.InteropServices;");
WriteWrappers(sw, Bind.Structures.Function.Wrappers, Bind.Structures.Type.CSTypes); WriteWrappers(sw, Function.Wrappers, Type.CSTypes);
sw.Unindent(); sw.Unindent();
sw.WriteLine("}"); sw.WriteLine("}");
@ -571,7 +574,7 @@ namespace Bind.GL2
sw.WriteLine("{"); sw.WriteLine("{");
sw.Indent(); sw.Indent();
foreach (Bind.Structures.Delegate d in delegates.Values) foreach (Delegate d in delegates.Values)
{ {
sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]"); sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]");
sw.WriteLine("internal {0};", d.ToString()); sw.WriteLine("internal {0};", d.ToString());
@ -609,7 +612,7 @@ namespace Bind.GL2
sw.Indent(); sw.Indent();
//sw.WriteLine("static {0}() {1} {2}", Settings.ImportsClass, "{", "}"); // Disable BeforeFieldInit //sw.WriteLine("static {0}() {1} {2}", Settings.ImportsClass, "{", "}"); // Disable BeforeFieldInit
sw.WriteLine(); sw.WriteLine();
foreach (Bind.Structures.Delegate d in delegates.Values) foreach (Delegate d in delegates.Values)
{ {
sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]"); sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]");
sw.WriteLine( sw.WriteLine(
@ -753,7 +756,7 @@ namespace Bind.GL2
sw.Indent(); sw.Indent();
} }
foreach (Bind.Structures.Enum @enum in enums.Values) foreach (Enum @enum in enums.Values)
{ {
sw.Write(@enum); sw.Write(@enum);
sw.WriteLine(); sw.WriteLine();
@ -769,7 +772,7 @@ namespace Bind.GL2
else else
{ {
// Tao legacy mode: dump all enums as constants in GLClass. // Tao legacy mode: dump all enums as constants in GLClass.
foreach (Bind.Structures.Constant c in enums[Settings.CompleteEnumName].ConstantCollection.Values) foreach (Constant c in enums[Settings.CompleteEnumName].ConstantCollection.Values)
{ {
// Print constants avoiding circular definitions // Print constants avoiding circular definitions
if (c.Name != c.Value) if (c.Name != c.Value)

View file

@ -5,10 +5,11 @@
#endregion #endregion
using System.Diagnostics; using System.Diagnostics;
using Bind.Structures;
namespace Bind.Glu namespace Bind.Glu
{ {
class Generator : Bind.GL2.Generator class Generator : GL2.Generator
{ {
string enumSpecAux = null;// = "GL2\\enum.spec"; string enumSpecAux = null;// = "GL2\\enum.spec";
@ -50,19 +51,19 @@ namespace Bind.Glu
public override void Process() public override void Process()
{ {
Bind.Structures.Type.Initialize(glTypemap, csTypemap); Type.Initialize(glTypemap, csTypemap);
Bind.Structures.Enum.Initialize(enumSpec, enumSpecExt, enumSpecAux); Enum.Initialize(enumSpec, enumSpecExt, enumSpecAux);
Bind.Structures.Function.Initialize(); Function.Initialize();
Bind.Structures.Delegate.Initialize(glSpec, glSpecExt); Delegate.Initialize(glSpec, glSpecExt);
// Process enums and delegates - create wrappers. // Process enums and delegates - create wrappers.
Trace.WriteLine("Processing specs, please wait..."); Trace.WriteLine("Processing specs, please wait...");
//this.Translate(); //this.Translate();
this.WriteBindings( this.WriteBindings(
Bind.Structures.Delegate.Delegates, Delegate.Delegates,
Bind.Structures.Function.Wrappers, Function.Wrappers,
Bind.Structures.Enum.GLEnums); Enum.GLEnums);
} }
} }
} }

View file

@ -5,10 +5,11 @@
#endregion #endregion
using System.Diagnostics; using System.Diagnostics;
using Bind.Structures;
namespace Bind.Glx namespace Bind.Glx
{ {
class Generator : Bind.GL2.Generator class Generator : GL2.Generator
{ {
#region --- Constructors --- #region --- Constructors ---
@ -47,19 +48,19 @@ namespace Bind.Glx
public override void Process() public override void Process()
{ {
Bind.Structures.Type.Initialize(glTypemap, csTypemap); Type.Initialize(glTypemap, csTypemap);
Bind.Structures.Enum.Initialize(enumSpec, enumSpecExt); Enum.Initialize(enumSpec, enumSpecExt);
Bind.Structures.Function.Initialize(); Function.Initialize();
Bind.Structures.Delegate.Initialize(glSpec, glSpecExt); Delegate.Initialize(glSpec, glSpecExt);
// Process enums and delegates - create wrappers. // Process enums and delegates - create wrappers.
Trace.WriteLine("Processing specs, please wait..."); Trace.WriteLine("Processing specs, please wait...");
//this.Translate(); //this.Translate();
this.WriteBindings( this.WriteBindings(
Bind.Structures.Delegate.Delegates, Delegate.Delegates,
Bind.Structures.Function.Wrappers, Function.Wrappers,
Bind.Structures.Enum.GLEnums); Enum.GLEnums);
} }
} }
} }

View file

@ -6,13 +6,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Bind.Structures;
namespace Bind namespace Bind
{ {
interface ISpecReader interface ISpecReader
{ {
Bind.Structures.DelegateCollection ReadDelegates(StreamReader specFile); DelegateCollection ReadDelegates(StreamReader specFile);
Bind.Structures.EnumCollection ReadEnums(StreamReader specFile); EnumCollection ReadEnums(StreamReader specFile);
Dictionary<string, string> ReadTypeMap(StreamReader specFile); Dictionary<string, string> ReadTypeMap(StreamReader specFile);
Dictionary<string, string> ReadCSTypeMap(StreamReader specFile); Dictionary<string, string> ReadCSTypeMap(StreamReader specFile);
} }

View file

@ -6,7 +6,11 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Reflection;
using System.Security; using System.Security;
using Bind.CL;
using Bind.ES;
using Bind.GL2;
namespace Bind namespace Bind
{ {
@ -40,7 +44,7 @@ namespace Bind
Trace.AutoFlush = true; Trace.AutoFlush = true;
Console.WriteLine("OpenGL binding generator {0} for OpenTK.", Console.WriteLine("OpenGL binding generator {0} for OpenTK.",
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); Assembly.GetExecutingAssembly().GetName().Version.ToString());
Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net"); Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net");
//Console.WriteLine(" - the OpenTK team ;-)"); //Console.WriteLine(" - the OpenTK team ;-)");
Console.WriteLine(); Console.WriteLine();
@ -122,40 +126,40 @@ namespace Bind
try try
{ {
long ticks = System.DateTime.Now.Ticks; long ticks = DateTime.Now.Ticks;
switch (mode) switch (mode)
{ {
case GeneratorMode.GL2: case GeneratorMode.GL2:
Generator = new Bind.GL2.Generator(); Generator = new Generator();
break; break;
case GeneratorMode.ES10: case GeneratorMode.ES10:
Generator = new Bind.ES.ESGenerator("ES10"); Generator = new ESGenerator("ES10");
break; break;
case GeneratorMode.ES11: case GeneratorMode.ES11:
Generator = new Bind.ES.ESGenerator("ES11"); Generator = new ESGenerator("ES11");
break; break;
case GeneratorMode.ES20: case GeneratorMode.ES20:
Generator = new Bind.ES.ESGenerator("ES20"); Generator = new ESGenerator("ES20");
break; break;
case GeneratorMode.CL10: case GeneratorMode.CL10:
Generator = new Bind.CL.CLGenerator("CL10"); Generator = new CLGenerator("CL10");
break; break;
case GeneratorMode.Wgl: case GeneratorMode.Wgl:
Generator = new Bind.Wgl.Generator(); Generator = new Wgl.Generator();
break; break;
case GeneratorMode.Glu: case GeneratorMode.Glu:
Generator = new Bind.Glu.Generator(); Generator = new Glu.Generator();
break; break;
case GeneratorMode.Glx: case GeneratorMode.Glx:
Generator = new Bind.Glx.Generator(); Generator = new Glx.Generator();
break; break;
case GeneratorMode.GL3: case GeneratorMode.GL3:
@ -170,7 +174,7 @@ namespace Bind
Generator.Process(); Generator.Process();
ticks = System.DateTime.Now.Ticks - ticks; ticks = DateTime.Now.Ticks - ticks;
Console.WriteLine(); Console.WriteLine();
Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0); Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);

View file

@ -57,7 +57,7 @@ namespace Bind
{ {
get get
{ {
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None) if ((Compatibility & Legacy.NestedEnums) != Legacy.None)
return OutputNamespace + "." + OutputClass + "." + NestedEnumsClass; return OutputNamespace + "." + OutputClass + "." + NestedEnumsClass;
else else
return String.IsNullOrEmpty(EnumsNamespace) ? OutputNamespace : OutputNamespace + "." + EnumsNamespace; return String.IsNullOrEmpty(EnumsNamespace) ? OutputNamespace : OutputNamespace + "." + EnumsNamespace;
@ -68,7 +68,7 @@ namespace Bind
{ {
get get
{ {
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None) if ((Compatibility & Legacy.NestedEnums) != Legacy.None)
return OutputNamespace + "." + GLClass + "." + NestedEnumsClass; return OutputNamespace + "." + GLClass + "." + NestedEnumsClass;
else else
return OutputNamespace + "." + EnumsNamespace; return OutputNamespace + "." + EnumsNamespace;
@ -143,8 +143,8 @@ namespace Bind
/// <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 static bool DropMultipleTokens
{ {
get { return (Settings.Compatibility & Legacy.NoDropMultipleTokens) == Legacy.None; } get { return (Compatibility & Legacy.NoDropMultipleTokens) == Legacy.None; }
set { if (value) Settings.Compatibility |= Legacy.NoDropMultipleTokens; else Settings.Compatibility &= ~Legacy.NoDropMultipleTokens; } set { if (value) Compatibility |= Legacy.NoDropMultipleTokens; else Compatibility &= ~Legacy.NoDropMultipleTokens; }
} }
public static string WindowsGDI = "OpenTK.Platform.Windows.API"; public static string WindowsGDI = "OpenTK.Platform.Windows.API";

View file

@ -5,6 +5,8 @@
#endregion #endregion
using System; using System;
using System.Diagnostics;
using System.Globalization;
using System.Text; using System.Text;
namespace Bind.Structures namespace Bind.Structures
@ -73,7 +75,7 @@ namespace Bind.Structures
{ {
value = value.Trim(); value = value.Trim();
if (value.ToLower() == " 0xffffffffffffffff") System.Diagnostics.Debugger.Break(); if (value.ToLower() == " 0xffffffffffffffff") Debugger.Break();
// Check whether this value is a number and make sure the Unchecked property is set correctly. // Check whether this value is a number and make sure the Unchecked property is set correctly.
ulong number; ulong number;
if (value.ToLower().StartsWith("0x")) if (value.ToLower().StartsWith("0x"))
@ -84,7 +86,7 @@ namespace Bind.Structures
if (value.ToLower().EndsWith("u")) if (value.ToLower().EndsWith("u"))
value = value.Substring(0, value.Length - 1); value = value.Substring(0, value.Length - 1);
} }
if (UInt64.TryParse(value.ToLower().Replace("0x", String.Empty), System.Globalization.NumberStyles.AllowHexSpecifier, null, out number)) if (UInt64.TryParse(value.ToLower().Replace("0x", String.Empty), NumberStyles.AllowHexSpecifier, null, out number))
{ {
// The value is a number, check if it should be unchecked. // The value is a number, check if it should be unchecked.
if (number > 0x7FFFFFFF) if (number > 0x7FFFFFFF)

View file

@ -42,14 +42,14 @@ namespace Bind.Structures
{ {
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glSpec)) using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glSpec))
{ {
Delegates = Bind.MainClass.Generator.ReadDelegates(sr); Delegates = MainClass.Generator.ReadDelegates(sr);
} }
if (!String.IsNullOrEmpty(glSpecExt)) if (!String.IsNullOrEmpty(glSpecExt))
{ {
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glSpecExt)) using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glSpecExt))
{ {
foreach (Delegate d in Bind.MainClass.Generator.ReadDelegates(sr).Values) foreach (Delegate d in MainClass.Generator.ReadDelegates(sr).Values)
{ {
Utilities.Merge(Delegates, d); Utilities.Merge(Delegates, d);
} }
@ -436,7 +436,7 @@ namespace Bind.Structures
// to avoid redefinitions. // to avoid redefinitions.
foreach (Function f in wrappers) foreach (Function f in wrappers)
{ {
Bind.Structures.Function.Wrappers.AddChecked(f); Function.Wrappers.AddChecked(f);
if (!f.CLSCompliant) if (!f.CLSCompliant)
{ {
@ -454,7 +454,7 @@ namespace Bind.Structures
} }
if (somethingChanged) if (somethingChanged)
Bind.Structures.Function.Wrappers.AddChecked(cls); Function.Wrappers.AddChecked(cls);
} }
} }
} }

View file

@ -30,9 +30,9 @@ namespace Bind.Structures
Initialize(enumFile, enumextFile); Initialize(enumFile, enumextFile);
if (!String.IsNullOrEmpty(auxFile)) if (!String.IsNullOrEmpty(auxFile))
using (System.IO.StreamReader sr = new System.IO.StreamReader(Path.Combine(Settings.InputPath, auxFile))) using (StreamReader sr = new StreamReader(Path.Combine(Settings.InputPath, auxFile)))
{ {
AuxEnums = Bind.MainClass.Generator.ReadEnums(sr); AuxEnums = MainClass.Generator.ReadEnums(sr);
} }
} }
@ -44,7 +44,7 @@ namespace Bind.Structures
{ {
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, enumFile)) using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, enumFile))
{ {
GLEnums = Bind.MainClass.Generator.ReadEnums(sr); GLEnums = MainClass.Generator.ReadEnums(sr);
} }
} }
@ -52,7 +52,7 @@ namespace Bind.Structures
{ {
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, enumextFile)) using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, enumextFile))
{ {
foreach (Bind.Structures.Enum e in Bind.MainClass.Generator.ReadEnums(sr).Values) foreach (Enum e in MainClass.Generator.ReadEnums(sr).Values)
{ {
//enums.Add(e.Name, e); //enums.Add(e.Name, e);
Utilities.Merge(GLEnums, e); Utilities.Merge(GLEnums, e);

View file

@ -686,27 +686,27 @@ namespace Bind.Structures
/// <param name="f">The Function to add.</param> /// <param name="f">The Function to add.</param>
public void AddChecked(Function f) public void AddChecked(Function f)
{ {
if (Bind.Structures.Function.Wrappers.ContainsKey(f.Extension)) if (Function.Wrappers.ContainsKey(f.Extension))
{ {
int index = Bind.Structures.Function.Wrappers[f.Extension].IndexOf(f); int index = Function.Wrappers[f.Extension].IndexOf(f);
if (index == -1) if (index == -1)
{ {
Bind.Structures.Function.Wrappers.Add(f); Function.Wrappers.Add(f);
} }
else else
{ {
Function existing = Bind.Structures.Function.Wrappers[f.Extension][index]; Function existing = Function.Wrappers[f.Extension][index];
if ((existing.Parameters.HasUnsignedParameters && !unsignedFunctions.IsMatch(existing.Name) && unsignedFunctions.IsMatch(f.Name)) || if ((existing.Parameters.HasUnsignedParameters && !unsignedFunctions.IsMatch(existing.Name) && unsignedFunctions.IsMatch(f.Name)) ||
(!existing.Parameters.HasUnsignedParameters && unsignedFunctions.IsMatch(existing.Name) && !unsignedFunctions.IsMatch(f.Name))) (!existing.Parameters.HasUnsignedParameters && unsignedFunctions.IsMatch(existing.Name) && !unsignedFunctions.IsMatch(f.Name)))
{ {
Bind.Structures.Function.Wrappers[f.Extension].RemoveAt(index); Function.Wrappers[f.Extension].RemoveAt(index);
Bind.Structures.Function.Wrappers[f.Extension].Add(f); Function.Wrappers[f.Extension].Add(f);
} }
} }
} }
else else
{ {
Bind.Structures.Function.Wrappers.Add(f); Function.Wrappers.Add(f);
} }
} }
} }

View file

@ -28,14 +28,14 @@ namespace Bind.Structures
{ {
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glTypes)) using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glTypes))
{ {
GLTypes = Bind.MainClass.Generator.ReadTypeMap(sr); GLTypes = MainClass.Generator.ReadTypeMap(sr);
} }
} }
if (CSTypes == null) if (CSTypes == null)
{ {
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, csTypes)) using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, csTypes))
{ {
CSTypes = Bind.MainClass.Generator.ReadCSTypeMap(sr); CSTypes = MainClass.Generator.ReadCSTypeMap(sr);
} }
} }
typesLoaded = true; typesLoaded = true;
@ -378,8 +378,8 @@ namespace Bind.Structures
} }
CurrentType = CurrentType =
Bind.Structures.Type.CSTypes.ContainsKey(CurrentType) ? CSTypes.ContainsKey(CurrentType) ?
Bind.Structures.Type.CSTypes[CurrentType] : CurrentType; CSTypes[CurrentType] : CurrentType;
// Make sure that enum parameters follow enum overrides, i.e. // Make sure that enum parameters follow enum overrides, i.e.
// if enum ErrorCodes is overriden to ErrorCode, then parameters // if enum ErrorCodes is overriden to ErrorCode, then parameters

View file

@ -9,6 +9,8 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Bind.Structures; using Bind.Structures;
using Delegate=Bind.Structures.Delegate;
using Enum=Bind.Structures.Enum;
namespace Bind namespace Bind
{ {
@ -125,7 +127,7 @@ namespace Bind
/// </summary> /// </summary>
/// <param name="enums"></param> /// <param name="enums"></param>
/// <param name="t"></param> /// <param name="t"></param>
internal static void Merge(EnumCollection enums, Bind.Structures.Enum t) internal static void Merge(EnumCollection enums, Enum t)
{ {
if (!enums.ContainsKey(t.Name)) if (!enums.ContainsKey(t.Name))
{ {
@ -133,8 +135,8 @@ namespace Bind
} }
else else
{ {
Bind.Structures.Enum e = enums[t.Name]; Enum e = enums[t.Name];
foreach (Bind.Structures.Constant c in t.ConstantCollection.Values) foreach (Constant c in t.ConstantCollection.Values)
{ {
Merge(e, c); Merge(e, c);
} }
@ -153,7 +155,7 @@ namespace Bind
/// <param name="s"></param> /// <param name="s"></param>
/// <param name="t"></param> /// <param name="t"></param>
/// <returns></returns> /// <returns></returns>
internal static Bind.Structures.Enum Merge(Bind.Structures.Enum s, Bind.Structures.Constant t) internal static Enum Merge(Enum s, Constant t)
{ {
if (!s.ConstantCollection.ContainsKey(t.Name)) if (!s.ConstantCollection.ContainsKey(t.Name))
{ {
@ -184,7 +186,7 @@ namespace Bind
/// </summary> /// </summary>
/// <param name="enums"></param> /// <param name="enums"></param>
/// <param name="t"></param> /// <param name="t"></param>
internal static void Merge(DelegateCollection delegates, Bind.Structures.Delegate t) internal static void Merge(DelegateCollection delegates, Delegate t)
{ {
if (!delegates.ContainsKey(t.Name)) if (!delegates.ContainsKey(t.Name))
{ {

View file

@ -5,10 +5,11 @@
#endregion #endregion
using System.Diagnostics; using System.Diagnostics;
using Bind.Structures;
namespace Bind.Wgl namespace Bind.Wgl
{ {
class Generator : Bind.GL2.Generator class Generator : GL2.Generator
{ {
#region --- Constructors --- #region --- Constructors ---
@ -46,19 +47,19 @@ namespace Bind.Wgl
public override void Process() public override void Process()
{ {
Bind.Structures.Type.Initialize(glTypemap, csTypemap); Type.Initialize(glTypemap, csTypemap);
Bind.Structures.Enum.Initialize(enumSpec, enumSpecExt); Enum.Initialize(enumSpec, enumSpecExt);
Bind.Structures.Function.Initialize(); Function.Initialize();
Bind.Structures.Delegate.Initialize(glSpec, glSpecExt); Delegate.Initialize(glSpec, glSpecExt);
// Process enums and delegates - create wrappers. // Process enums and delegates - create wrappers.
Trace.WriteLine("Processing specs, please wait..."); Trace.WriteLine("Processing specs, please wait...");
//this.Translate(); //this.Translate();
this.WriteBindings( this.WriteBindings(
Bind.Structures.Delegate.Delegates, Delegate.Delegates,
Bind.Structures.Function.Wrappers, Function.Wrappers,
Bind.Structures.Enum.GLEnums); Enum.GLEnums);
} }
} }
} }