2007-08-10 11:27:13 +02:00
|
|
|
#region --- License ---
|
|
|
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
|
|
|
* See license.txt for license info
|
|
|
|
*/
|
|
|
|
#endregion
|
2007-07-23 02:15:18 +02:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Text;
|
|
|
|
using System.IO;
|
|
|
|
using System.Security;
|
|
|
|
using System.Security.Permissions;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.CodeDom;
|
2007-08-01 11:27:57 +02:00
|
|
|
using System.Diagnostics;
|
2007-07-23 02:15:18 +02:00
|
|
|
|
2007-08-01 11:27:57 +02:00
|
|
|
namespace Bind
|
2007-07-23 02:15:18 +02:00
|
|
|
{
|
2007-08-01 11:27:57 +02:00
|
|
|
enum GeneratorMode
|
|
|
|
{
|
2007-09-02 09:50:46 +02:00
|
|
|
Unknown,
|
2007-08-01 11:27:57 +02:00
|
|
|
GL2,
|
|
|
|
GL3,
|
|
|
|
Wgl,
|
|
|
|
Glx,
|
2007-09-02 09:50:46 +02:00
|
|
|
Glu,
|
2007-08-01 11:27:57 +02:00
|
|
|
}
|
|
|
|
|
2007-07-23 02:15:18 +02:00
|
|
|
static class MainClass
|
|
|
|
{
|
2007-08-01 11:27:57 +02:00
|
|
|
static GeneratorMode mode;
|
|
|
|
|
2007-08-01 23:14:39 +02:00
|
|
|
static internal IBind Generator;
|
|
|
|
|
2007-07-23 02:15:18 +02:00
|
|
|
static void Main(string[] arguments)
|
|
|
|
{
|
2007-08-01 11:27:57 +02:00
|
|
|
Debug.Listeners.Clear();
|
|
|
|
Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
|
|
|
Debug.AutoFlush = true;
|
|
|
|
Trace.Listeners.Clear();
|
|
|
|
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
|
|
|
|
Trace.AutoFlush = true;
|
|
|
|
|
2007-07-23 02:15:18 +02:00
|
|
|
Console.WriteLine("OpenGL binding generator {0} for OpenTK.",
|
|
|
|
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
|
|
|
|
Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net");
|
|
|
|
//Console.WriteLine(" - the OpenTK team ;-)");
|
|
|
|
Console.WriteLine();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
foreach (string a in arguments)
|
|
|
|
{
|
|
|
|
if (a.StartsWith("--") || a.StartsWith("-") || a.StartsWith("/"))
|
|
|
|
{
|
|
|
|
string[] b = a.Split(new char[] { '-', '/', ':', '=' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
switch (b[0])
|
|
|
|
{
|
|
|
|
case "?":
|
|
|
|
case "help":
|
|
|
|
Console.WriteLine("Help not implemented yet.");
|
|
|
|
return;
|
|
|
|
case "in":
|
|
|
|
case "input":
|
|
|
|
Settings.InputPath = b[1];
|
|
|
|
break;
|
|
|
|
case "out":
|
2007-08-01 11:27:57 +02:00
|
|
|
case "output":
|
2007-07-23 02:15:18 +02:00
|
|
|
Settings.OutputPath = b[1];
|
|
|
|
break;
|
2007-08-01 11:27:57 +02:00
|
|
|
case "mode":
|
2007-08-05 01:39:56 +02:00
|
|
|
string arg = b[1].ToLower();
|
2007-09-03 00:52:00 +02:00
|
|
|
mode =
|
|
|
|
arg == "gl" ? GeneratorMode.GL2 :
|
2007-08-05 01:39:56 +02:00
|
|
|
arg == "gl2" ? GeneratorMode.GL2 :
|
|
|
|
arg == "gl3" ? GeneratorMode.GL3 :
|
2007-09-02 02:40:43 +02:00
|
|
|
arg == "wgl" ? GeneratorMode.Wgl :
|
2007-09-02 09:50:46 +02:00
|
|
|
arg == "glu" ? GeneratorMode.Glu :
|
|
|
|
arg == "glx" ? GeneratorMode.Glx : GeneratorMode.Unknown;
|
|
|
|
if (mode == GeneratorMode.Unknown)
|
|
|
|
{
|
|
|
|
throw new ArgumentException(String.Format("Mode {0} unknown.", arg));
|
|
|
|
}
|
2007-08-01 11:27:57 +02:00
|
|
|
break;
|
|
|
|
case "namespace":
|
|
|
|
case "ns":
|
|
|
|
Settings.OutputNamespace = b[1];
|
|
|
|
break;
|
2007-07-23 02:15:18 +02:00
|
|
|
case "class":
|
2007-08-20 14:25:48 +02:00
|
|
|
Settings.OutputClass = b[1];
|
2007-07-23 02:15:18 +02:00
|
|
|
break;
|
2007-10-21 17:48:52 +02:00
|
|
|
case "gl":
|
|
|
|
Settings.GLClass = b[1];
|
|
|
|
break;
|
|
|
|
case "legacy":
|
|
|
|
Settings.Compatibility |= b[1].ToLower().Contains("tao") ? Settings.Legacy.Tao : Settings.Legacy.None;
|
|
|
|
Settings.Compatibility |= b[1].ToLower().Contains("enums") ? Settings.Legacy.NoAdvancedEnumProcessing : Settings.Legacy.None;
|
|
|
|
Settings.Compatibility |= b[1].ToLower().Contains("safe") ? Settings.Legacy.NoPublicUnsafeFunctions : Settings.Legacy.None;
|
|
|
|
//Settings.Compatibility |= b[1].ToLower().Contains("novoid") ? Settings.Legacy.TurnVoidPointersToIntPtr : Settings.Legacy.None;
|
|
|
|
break;
|
|
|
|
case "enum":
|
|
|
|
Settings.NestedEnumsClass = b[1];
|
|
|
|
break;
|
2007-07-23 02:15:18 +02:00
|
|
|
default:
|
2007-08-01 11:27:57 +02:00
|
|
|
throw new ArgumentException(
|
|
|
|
String.Format("Argument {0} not recognized. Use the '/?' switch for help.", a)
|
|
|
|
);
|
2007-07-23 02:15:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (NullReferenceException e)
|
|
|
|
{
|
|
|
|
Console.WriteLine("Argument error ({0}). Please use the '/?' switch for help.", e.ToString());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
catch (ArgumentException e)
|
|
|
|
{
|
|
|
|
Console.WriteLine("Argument error ({0}). Please use the '/?' switch for help.", e.ToString());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
long ticks = System.DateTime.Now.Ticks;
|
|
|
|
|
2007-08-01 11:27:57 +02:00
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case GeneratorMode.GL2:
|
2007-08-20 14:25:48 +02:00
|
|
|
Generator = new Bind.GL2.Generator();
|
2007-08-01 11:27:57 +02:00
|
|
|
break;
|
2007-07-23 02:15:18 +02:00
|
|
|
|
2007-08-05 01:39:56 +02:00
|
|
|
case GeneratorMode.Wgl:
|
2007-08-20 14:25:48 +02:00
|
|
|
Generator = new Bind.Wgl.Generator();
|
2007-08-05 01:39:56 +02:00
|
|
|
break;
|
|
|
|
|
2007-09-02 02:40:43 +02:00
|
|
|
case GeneratorMode.Glu:
|
2007-09-02 09:50:46 +02:00
|
|
|
Generator = new Bind.Glu.Generator();
|
2007-09-02 02:40:43 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GeneratorMode.Glx:
|
2007-09-02 09:50:46 +02:00
|
|
|
Generator = new Bind.Glx.Generator();
|
2007-09-02 02:40:43 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GeneratorMode.GL3:
|
2007-08-01 11:27:57 +02:00
|
|
|
throw new NotImplementedException(String.Format("Mode {0} not implemented.", mode));
|
2007-09-05 21:59:54 +02:00
|
|
|
|
|
|
|
case GeneratorMode.Unknown:
|
|
|
|
default:
|
|
|
|
Console.WriteLine("Please specify a generator mode (use '-mode:gl2/gl3/glu/wgl/glx])'");
|
|
|
|
return;
|
|
|
|
|
2007-08-01 11:27:57 +02:00
|
|
|
}
|
2007-07-23 02:15:18 +02:00
|
|
|
|
2007-08-01 23:14:39 +02:00
|
|
|
Generator.Process();
|
2007-07-23 02:15:18 +02:00
|
|
|
|
|
|
|
ticks = System.DateTime.Now.Ticks - ticks;
|
|
|
|
|
2007-08-01 11:27:57 +02:00
|
|
|
Console.WriteLine();
|
2007-07-23 02:15:18 +02:00
|
|
|
Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
|
|
|
|
Console.WriteLine();
|
2007-08-01 11:27:57 +02:00
|
|
|
Console.WriteLine("Press any key to continue...");
|
|
|
|
Console.ReadKey(true);
|
2007-07-23 02:15:18 +02:00
|
|
|
}
|
|
|
|
catch (SecurityException e)
|
|
|
|
{
|
|
|
|
Console.WriteLine("Security violation \"{0}\" in method \"{1}\".", e.Message, e.Method);
|
|
|
|
Console.WriteLine("This application does not have permission to take the requested actions.");
|
|
|
|
}
|
2007-08-01 11:27:57 +02:00
|
|
|
catch (NotImplementedException e)
|
|
|
|
{
|
|
|
|
Console.WriteLine(e.Message);
|
|
|
|
Console.WriteLine("The requested functionality is not implemented yet.");
|
|
|
|
}
|
2007-07-23 02:15:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|