2009-08-12 10:12:16 +00:00
|
|
|
#region --- License ---
|
2009-02-22 10:43:35 +00:00
|
|
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
|
|
|
* See license.txt for license info
|
|
|
|
*/
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Diagnostics;
|
2009-08-17 12:28:22 +00:00
|
|
|
using System.IO;
|
2009-10-27 22:37:05 +00:00
|
|
|
using System.Linq;
|
2009-02-22 10:43:35 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2009-05-29 15:57:01 +00:00
|
|
|
using System.Xml.XPath;
|
2009-08-17 12:28:22 +00:00
|
|
|
using Bind.Structures;
|
2009-08-21 20:28:14 +00:00
|
|
|
using Delegate=Bind.Structures.Delegate;
|
|
|
|
using Enum=Bind.Structures.Enum;
|
|
|
|
using Type=Bind.Structures.Type;
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
namespace Bind.GL2
|
|
|
|
{
|
|
|
|
class Generator : IBind
|
|
|
|
{
|
2010-12-02 21:36:05 +00:00
|
|
|
#region Fields
|
2009-02-22 10:43:35 +00:00
|
|
|
|
2009-03-08 18:08:35 +00:00
|
|
|
protected static string glTypemap = "GL2/gl.tm";
|
2009-02-22 10:43:35 +00:00
|
|
|
protected static string csTypemap = "csharp.tm";
|
2009-03-08 18:08:35 +00:00
|
|
|
protected static string enumSpec = "GL2/enum.spec";
|
|
|
|
protected static string enumSpecExt = "GL2/enumext.spec";
|
|
|
|
protected static string glSpec = "GL2/gl.spec";
|
2009-02-22 10:43:35 +00:00
|
|
|
protected static string glSpecExt = "";
|
2009-02-28 19:29:34 +00:00
|
|
|
|
2009-02-22 10:43:35 +00:00
|
|
|
protected static string loadAllFuncName = "LoadAll";
|
|
|
|
|
|
|
|
protected static Regex enumToDotNet = new Regex("_[a-z|A-Z]?", RegexOptions.Compiled);
|
|
|
|
|
2009-03-21 21:44:07 +00:00
|
|
|
protected static readonly char[] numbers = "0123456789".ToCharArray();
|
|
|
|
//protected static readonly Dictionary<string, string> doc_replacements;
|
2010-12-02 21:36:05 +00:00
|
|
|
|
2010-12-03 09:02:55 +00:00
|
|
|
protected ISpecReader SpecReader = new XmlSpecReader();
|
2010-12-02 21:36:05 +00:00
|
|
|
|
2009-02-22 10:43:35 +00:00
|
|
|
#endregion
|
|
|
|
|
2010-12-02 21:36:05 +00:00
|
|
|
#region Constructors
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
public Generator()
|
|
|
|
{
|
|
|
|
if (Settings.Compatibility == Settings.Legacy.Tao)
|
|
|
|
{
|
|
|
|
Settings.OutputNamespace = "Tao.OpenGl";
|
|
|
|
Settings.OutputClass = "Gl";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Defaults
|
|
|
|
}
|
2010-12-02 21:58:49 +00:00
|
|
|
|
|
|
|
Settings.ImportsFile = "GLCore.cs";
|
|
|
|
Settings.DelegatesFile = "GLDelegates.cs";
|
|
|
|
Settings.EnumsFile = "GLEnums.cs";
|
|
|
|
Settings.WrappersFile = "GL.cs";
|
2009-02-22 10:43:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2010-12-03 10:21:50 +00:00
|
|
|
#region IBind Members
|
|
|
|
|
|
|
|
public DelegateCollection Delegates { get; private set; }
|
|
|
|
public EnumCollection Enums { get; private set; }
|
|
|
|
public FunctionCollection Wrappers { get; private set; }
|
2009-02-22 10:43:35 +00:00
|
|
|
|
|
|
|
public virtual void Process()
|
|
|
|
{
|
2010-12-06 12:29:18 +00:00
|
|
|
using (var overrides = new StreamReader(Path.Combine(Settings.InputPath, Settings.OverridesFile)))
|
|
|
|
{
|
|
|
|
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, glTypemap))
|
|
|
|
Type.GLTypes = SpecReader.ReadTypeMap(sr);
|
|
|
|
using (StreamReader sr = Utilities.OpenSpecFile(Settings.InputPath, csTypemap))
|
|
|
|
Type.CSTypes = SpecReader.ReadCSTypeMap(sr);
|
|
|
|
using (var sr = new StreamReader(Path.Combine(Settings.InputPath, enumSpec)))
|
|
|
|
{
|
|
|
|
Enums = SpecReader.ReadEnums(sr);
|
|
|
|
Utilities.Merge(Enums, SpecReader.ReadEnums(overrides));
|
|
|
|
}
|
|
|
|
using (var sr = new StreamReader(Path.Combine(Settings.InputPath, glSpec)))
|
|
|
|
{
|
|
|
|
Delegates = SpecReader.ReadDelegates(sr);
|
|
|
|
Utilities.Merge(Delegates, SpecReader.ReadDelegates(overrides));
|
|
|
|
}
|
|
|
|
|
|
|
|
Enums = new EnumProcessor(overrides).Process(Enums);
|
|
|
|
Wrappers = new FuncProcessor(overrides).Process(Delegates, Enums);
|
|
|
|
}
|
2009-02-28 19:29:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2009-02-22 10:43:35 +00:00
|
|
|
}
|
|
|
|
}
|