diff --git a/Source/Bind/DocProcessor.cs b/Source/Bind/DocProcessor.cs index 582b8d40..45f63178 100644 --- a/Source/Bind/DocProcessor.cs +++ b/Source/Bind/DocProcessor.cs @@ -11,7 +11,6 @@ namespace Bind { class DocProcessor { - static readonly Regex remove_doctype = new Regex("", RegexOptions.Compiled | RegexOptions.Multiline); static readonly Regex remove_mathml = new Regex(@"<(mml:math)[^>]*?>(?:.|\n)*?", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); static readonly StreamWriter output_stream = new StreamWriter(new MemoryStream()); @@ -26,6 +25,10 @@ namespace Bind settings.XmlResolver = null; } + // Strips MathML tags from the source and replaces the equations with the content + // found in the comments in the docs. + // Todo: Some simple MathML tags do not include comments, find a solution. + // Todo: Some files include more than 1 function - find a way to map these extra functions. public string ProcessFile(string file) { string text = File.ReadAllText(file); @@ -33,19 +36,37 @@ namespace Bind Match m = remove_mathml.Match(text); while (m.Length > 0) { + string removed = text.Substring(m.Index, m.Length); text = text.Remove(m.Index, m.Length); + int equation = removed.IndexOf("eqn"); + if (equation > 0) + { + text = text.Insert(m.Index, + "") - equation - 4) + + "]]>"); + } m = remove_mathml.Match(text); } - //text = remove_doctype.Replace(sb.ToString(), String.Empty, 1), String.Empty); - // The pure XmlReader is ~20x faster than the XmlTextReader. - var doc = XmlReader.Create(new StringReader(text), settings); - //var doc = new XmlTextReader(new StringReader(text)); - - using (StringWriter sw = new StringWriter()) + XmlReader doc = null; + try { - xslt.Transform(doc, null, sw); - return sw.ToString(); + // The pure XmlReader is ~20x faster than the XmlTextReader. + doc = XmlReader.Create(new StringReader(text), settings); + //doc = new XmlTextReader(new StringReader(text)); + + using (StringWriter sw = new StringWriter()) + { + xslt.Transform(doc, null, sw); + return sw.ToString(); + } + } + catch (XmlException e) + { + Console.WriteLine(e.ToString()); + Console.WriteLine(doc.ToString()); + return String.Empty; } } } diff --git a/Source/Bind/GL2/Generator.cs b/Source/Bind/GL2/Generator.cs index 4080d74a..5381f8b4 100644 --- a/Source/Bind/GL2/Generator.cs +++ b/Source/Bind/GL2/Generator.cs @@ -19,11 +19,11 @@ namespace Bind.GL2 { #region --- Fields --- - protected static string glTypemap = "GL2\\gl.tm"; + protected static string glTypemap = "GL2/gl.tm"; protected static string csTypemap = "csharp.tm"; - protected static string enumSpec = "GL2\\enum.spec"; - protected static string enumSpecExt = "GL2\\enumext.spec"; - protected static string glSpec = "GL2\\gl.spec"; + 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 static string importsFile = "GLCore.cs"; @@ -455,13 +455,14 @@ namespace Bind.GL2 public void WriteBindings(DelegateCollection delegates, FunctionCollection functions, EnumCollection enums) { + Console.WriteLine("Writing bindings to {0}", Settings.OutputPath); if (!Directory.Exists(Settings.OutputPath)) Directory.CreateDirectory(Settings.OutputPath); // Enums using (BindStreamWriter sw = new BindStreamWriter(Path.Combine(Settings.OutputPath, enumsFile))) { - WriteLicense(sw, Resources.License); + WriteLicense(sw); if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None) { sw.WriteLine("namespace {0}", Settings.OutputNamespace); @@ -490,7 +491,7 @@ namespace Bind.GL2 // Delegates using (BindStreamWriter sw = new BindStreamWriter(Path.Combine(Settings.OutputPath, delegatesFile))) { - WriteLicense(sw, Resources.License); + WriteLicense(sw); sw.WriteLine("namespace {0}", Settings.OutputNamespace); sw.WriteLine("{"); sw.Indent(); @@ -508,7 +509,7 @@ namespace Bind.GL2 // Core using (BindStreamWriter sw = new BindStreamWriter(Path.Combine(Settings.OutputPath, importsFile))) { - WriteLicense(sw, Resources.License); + WriteLicense(sw); sw.WriteLine("namespace {0}", Settings.OutputNamespace); sw.WriteLine("{"); sw.Indent(); @@ -525,7 +526,7 @@ namespace Bind.GL2 // Wrappers using (BindStreamWriter sw = new BindStreamWriter(Path.Combine(Settings.OutputPath, wrappersFile))) { - WriteLicense(sw, Resources.License); + WriteLicense(sw); sw.WriteLine("namespace {0}", Settings.OutputNamespace); sw.WriteLine("{"); sw.Indent(); @@ -770,9 +771,9 @@ namespace Bind.GL2 #region void WriteLicense - public void WriteLicense(BindStreamWriter sw, string license) + public void WriteLicense(BindStreamWriter sw) { - sw.WriteLine(Resources.License); + sw.WriteLine(File.ReadAllText(Path.Combine(Settings.InputPath, Settings.LicenseFile))); sw.WriteLine(); } diff --git a/Source/Bind/ISpecWriter.cs b/Source/Bind/ISpecWriter.cs index 4f005c72..9d3781b6 100644 --- a/Source/Bind/ISpecWriter.cs +++ b/Source/Bind/ISpecWriter.cs @@ -20,6 +20,6 @@ namespace Bind void WriteWrappers(BindStreamWriter sw, FunctionCollection wrappers, Dictionary CSTypes); void WriteEnums(BindStreamWriter sw, EnumCollection enums); void WriteTypes(BindStreamWriter sw, Dictionary CSTypes); - void WriteLicense(BindStreamWriter sw, string license); + void WriteLicense(BindStreamWriter sw); } } diff --git a/Source/Bind/Settings.cs b/Source/Bind/Settings.cs index e1513346..6f6c5e84 100644 --- a/Source/Bind/Settings.cs +++ b/Source/Bind/Settings.cs @@ -15,17 +15,19 @@ namespace Bind // Disable BeforeFieldInit. static Settings() { } - public const string DefaultInputPath = "..\\..\\..\\Source\\Bind\\Specifications"; - public const string DefaultOutputPath = "..\\..\\..\\Source\\OpenTK\\OpenGL\\Bindings"; + public const string DefaultInputPath = "../../../Source/Bind/Specifications"; + public const string DefaultOutputPath = "../../../Source/OpenTK/OpenGL/Bindings"; public const string DefaultOutputNamespace = "OpenTK.Graphics"; - public static string DefaultDocPath = "..\\..\\..\\Source\\Bind\\Specifications\\Docs"; - public static string DefaultDocFile = "ToInlineDocs.xslt"; + public const string DefaultDocPath = "../../../Source/Bind/Specifications/Docs"; + public const string DefaultDocFile = "ToInlineDocs.xslt"; + public const string DefaultLicenseFile = "License.txt"; public static string InputPath = DefaultInputPath; public static string OutputPath = DefaultOutputPath; public static string OutputNamespace = DefaultOutputNamespace; public static string DocPath = DefaultDocPath; public static string DocFile = DefaultDocFile; + public static string LicenseFile = DefaultLicenseFile; 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". diff --git a/Source/Bind/Specifications/Docs/ToInlineDocs.xslt b/Source/Bind/Specifications/Docs/ToInlineDocs.xslt index 77aea929..fe39f5a6 100644 --- a/Source/Bind/Specifications/Docs/ToInlineDocs.xslt +++ b/Source/Bind/Specifications/Docs/ToInlineDocs.xslt @@ -13,22 +13,22 @@ -/// -/// -/// + /// -/// + /// -/// -/// -/// + /// + /// + /// -/// + /// diff --git a/Source/Bind/Specifications/License.txt b/Source/Bind/Specifications/License.txt new file mode 100644 index 00000000..6bfc459d --- /dev/null +++ b/Source/Bind/Specifications/License.txt @@ -0,0 +1,26 @@ +#region License +// +// The Open Toolkit Library License +// +// Copyright (c) 2006 - 2008 the Open Toolkit library, except where noted. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +#endregion \ No newline at end of file diff --git a/Source/Bind/Utilities.cs b/Source/Bind/Utilities.cs index 7056bb9c..31a84f92 100644 --- a/Source/Bind/Utilities.cs +++ b/Source/Bind/Utilities.cs @@ -76,7 +76,10 @@ namespace Bind internal static StreamReader OpenSpecFile(string folder, string file) { + Console.WriteLine(folder); + Console.WriteLine(file); string path = Path.Combine(folder, file); + Console.WriteLine(path); return new StreamReader(path); } diff --git a/Source/Bind/Wgl/Generator.cs b/Source/Bind/Wgl/Generator.cs index b5ae0d71..cff3a852 100644 --- a/Source/Bind/Wgl/Generator.cs +++ b/Source/Bind/Wgl/Generator.cs @@ -20,12 +20,12 @@ namespace Bind.Wgl public Generator() : base() { - glTypemap = "Wgl\\wgl.tm"; + glTypemap = "Wgl/wgl.tm"; csTypemap = "csharp.tm"; - enumSpec = "Wgl\\wglenum.spec"; - enumSpecExt = "Wgl\\wglenumext.spec"; - glSpec = "Wgl\\wgl.spec"; - glSpecExt = "Wgl\\wglext.spec"; + enumSpec = "Wgl/wglenum.spec"; + enumSpecExt = "Wgl/wglenumext.spec"; + glSpec = "Wgl/wgl.spec"; + glSpecExt = "Wgl/wglext.spec"; importsFile = "WglCore.cs"; delegatesFile = "WglDelegates.cs";