예제 #1
0
        static void Main(string[] arguments)
        {
            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;

            Console.WriteLine("OpenGL binding generator {0} for OpenTK.",
                Assembly.GetExecutingAssembly().GetName().Version.ToString());
            Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net");
            Console.WriteLine();

            string dirName =  null;

            try
            {
                var split = new Regex(@"-\w+", RegexOptions.Compiled);
                foreach (var argument in arguments)
                {
                    string a = argument.Replace("--", "-").Trim();
                    var match = split.Match(a);
                    if (match.Success)
                    {
                        string opt = match.Value.Substring(1).Trim();
                        string val = a.Substring(match.Value.Length + 1).Trim();
                        switch (opt)
                        {
                            case "?":
                            case "help":
                                ShowHelp();
                                return;
                            case "in":
                            case "input":
                                Settings.InputPath = val;
                                break;
                            case "out":
                            case "output":
                                Settings.OutputPath = val;
                                break;
                            case "include":
                                Settings.IncludePath = val;
                                break;
                            case "l":
                            case "lang":
                            case "language":
                                {
                                    string arg = val.ToLower();
                                    if (arg == "cpp" || arg == "c++" || arg == "c")
                                    {
                                        Settings.Language = GeneratorLanguage.Cpp;
                                        Settings.DefaultOutputPath = "gl";
                                        Settings.DefaultOutputNamespace = "OpenTK";
                                        // Settings.DefaultLanguageTypeMapFile = "cpp.tm"; // Todo: create this file!
                                        Settings.EnumsNamespace = "";
                                        Settings.NamespaceSeparator = "::";
                                        Settings.DefaultKeywordEscapeCharacter = "_";
                                    }
                                    else if (arg == "java")
                                    {
                                        Settings.Language = GeneratorLanguage.Java;
                                        Settings.DefaultOutputPath = "gl";
                                        Settings.DefaultOutputNamespace = "com.opentk";
                                        Settings.DefaultLanguageTypeMapFile = "java.tm";
                                        Settings.EnumsNamespace = "";
                                        Settings.NamespaceSeparator = ".";
                                        Settings.DefaultKeywordEscapeCharacter = "_";
                                    }
                                    break;
                                }
                            case "mode":
                                {
                                    string[] parts = val.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                                    if (parts.Length < 1)
                                       throw new NotImplementedException();
                                    dirName = parts.Length > 1 ? parts[1] : "";
                                    SetGeneratorMode(dirName, parts[0]);
                                    break;
                                }
                            case "namespace":
                            case "ns":
                                Settings.OutputNamespace = val;
                                break;
                            case "class":
                                Settings.OutputClass = val;
                                break;
                            case "gl":
                                Settings.GLClass = val;
                                break;
                            case "legacy":
                            case "o":
                            case "option":
                                Settings.Compatibility |= val.ToLower() == "tao" ? Settings.Legacy.Tao : Settings.Legacy.None;
                                Settings.Compatibility |= val.ToLower() == "simple_enums" ? Settings.Legacy.NoAdvancedEnumProcessing : Settings.Legacy.None;
                                Settings.Compatibility |= val.ToLower() == "safe" ? Settings.Legacy.NoPublicUnsafeFunctions : Settings.Legacy.None;
                                //Settings.Compatibility |= b[1].ToLower().Contains("novoid") ? Settings.Legacy.TurnVoidPointersToIntPtr : Settings.Legacy.None;
                                Settings.Compatibility |= val.ToLower() == "permutations" ? Settings.Legacy.GenerateAllPermutations : Settings.Legacy.None;
                                Settings.Compatibility |= val.ToLower() == "enums_in_class" ? Settings.Legacy.NestedEnums : Settings.Legacy.None;
                                Settings.Compatibility |= val.ToLower() == "nodocs" ? Settings.Legacy.NoDocumentation : Settings.Legacy.None;
                                Settings.Compatibility |= val.ToLower() == "keep_untyped_enums" ? Settings.Legacy.KeepUntypedEnums : Settings.Legacy.None;
                                break;
                            default:
                                throw new ArgumentException(
                                    String.Format("Argument {0} not recognized. Use the '/?' switch for help.", a)
                                );
                        }
                    }
                }
            }
            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 = DateTime.Now.Ticks;

                switch (mode)
                {
                    case GeneratorMode.GL3:
                    case GeneratorMode.GL2:
                        Generator = new GL4Generator("OpenGL", dirName);
                        break;

                    case GeneratorMode.ES10:
                        Generator = new ESGenerator("ES10", dirName);
                        break;
                    
                    case GeneratorMode.ES11:
                        Generator = new ESGenerator("ES11", dirName);
                        break;
                    
                    case GeneratorMode.ES20:
                        Generator = new ESGenerator("ES20", dirName);
                        break;

                    case GeneratorMode.ES30:
                        Generator = new ESGenerator("ES30", dirName);
                        break;

                    case GeneratorMode.ES31:
                        Generator = new ESGenerator("ES31", dirName);
                        break;

                    case GeneratorMode.CL10:
                        Generator = new CLGenerator("CL10", dirName);
                        break;
                    
                    case GeneratorMode.Unknown:
                    default:
                        Console.WriteLine("Please specify a generator mode (use '-mode:gl2/gl3/glu/wgl/glx])'");
                        return;
                }

                Generator.Process();
                ISpecWriter writer = null;
                switch (Settings.Language)
                {
                    case GeneratorLanguage.Cpp:
                        writer = new CppSpecWriter();
                        break;

                    case GeneratorLanguage.Java:
                        writer = new JavaSpecWriter();
                        break;

                    case GeneratorLanguage.CSharp:
                    default:
                        writer = new CSharpSpecWriter();
                        break;
                }
                writer.WriteBindings(Generator);

                ticks = DateTime.Now.Ticks - ticks;

                Console.WriteLine();
                Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
                Console.WriteLine();
                if (Debugger.IsAttached)
                {
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey(true);
                }
            }
            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.");
            }
            catch (NotImplementedException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("The requested functionality is not implemented yet.");
            }
        }
예제 #2
0
        static void Main(string[] arguments)
        {
            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;

            Console.WriteLine("OpenGL binding generator {0} for OpenTK.",
                              Assembly.GetExecutingAssembly().GetName().Version.ToString());
            Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net");
            Console.WriteLine();

            string dirName = "GL2";

            try
            {
                var split = new Regex(@"-\w+", RegexOptions.Compiled);
                foreach (var argument in arguments)
                {
                    string a     = argument.Replace("--", "-").Trim();
                    var    match = split.Match(a);
                    if (match.Success)
                    {
                        string opt = match.Value.Substring(1).Trim();
                        string val = a.Substring(match.Value.Length + 1).Trim();
                        switch (opt)
                        {
                        case "?":
                        case "help":
                            ShowHelp();
                            return;

                        case "in":
                        case "input":
                            Settings.InputPath = val;
                            break;

                        case "out":
                        case "output":
                            Settings.OutputPath = val;
                            break;

                        case "l":
                        case "lang":
                        case "language":
                        {
                            string arg = val.ToLower();
                            if (arg == "cpp" || arg == "c++" || arg == "c")
                            {
                                Settings.Language               = GeneratorLanguage.Cpp;
                                Settings.DefaultOutputPath      = "gl";
                                Settings.DefaultOutputNamespace = "OpenTK";
                                // Settings.DefaultLanguageTypeMapFile = "cpp.tm"; // Todo: create this file!
                                Settings.EnumsNamespace                = "";
                                Settings.NamespaceSeparator            = "::";
                                Settings.DefaultKeywordEscapeCharacter = "_";
                            }
                            else if (arg == "java")
                            {
                                Settings.Language                      = GeneratorLanguage.Java;
                                Settings.DefaultOutputPath             = "gl";
                                Settings.DefaultOutputNamespace        = "com.opentk";
                                Settings.DefaultLanguageTypeMapFile    = "java.tm";
                                Settings.EnumsNamespace                = "";
                                Settings.NamespaceSeparator            = ".";
                                Settings.DefaultKeywordEscapeCharacter = "_";
                            }
                            break;
                        }

                        case "mode":
                        {
                            string arg = val.ToLower();
                            SetGeneratorMode(dirName, arg);
                            break;
                        }

                        case "namespace":
                        case "ns":
                            Settings.OutputNamespace = val;
                            break;

                        case "class":
                            Settings.OutputClass = val;
                            break;

                        case "gl":
                            Settings.GLClass = val;
                            break;

                        case "legacy":
                        case "o":
                        case "option":
                        {
                            val = val.ToLower();
                            bool enable = !opt.StartsWith("-");
                            if (val.StartsWith("+") || val.StartsWith("-"))
                            {
                                val = val.Substring(1);
                            }

                            var settings = Settings.Legacy.None;
                            switch (val)
                            {
                            case "tao": settings |= Settings.Legacy.Tao; break;

                            case "simple_enums": settings |= Settings.Legacy.NoAdvancedEnumProcessing; break;

                            case "safe": settings |= Settings.Legacy.NoPublicUnsafeFunctions; break;

                            case "permutations": settings |= Settings.Legacy.GenerateAllPermutations; break;

                            case "enums_in_class": settings |= Settings.Legacy.NestedEnums; break;

                            case "nodocs": settings |= Settings.Legacy.NoDocumentation; break;

                            case "keep_untyped_enums": settings |= Settings.Legacy.KeepUntypedEnums; break;
                            }

                            if (enable)
                            {
                                Settings.Compatibility |= settings;
                            }
                            else
                            {
                                Settings.Compatibility &= ~settings;
                            }

                            break;
                        }

                        default:
                            throw new ArgumentException(
                                      String.Format("Argument {0} not recognized. Use the '/?' switch for help.", a)
                                      );
                        }
                    }
                }
            }
            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
            {
                switch (mode)
                {
                case GeneratorMode.All:
                    Console.WriteLine("Using 'all' generator mode.");
                    Console.WriteLine("Use '-mode:all/gl2/gl4/es10/es11/es20/es30' to select a specific mode.");
                    Generators.Add(new Generator(Settings, dirName));
                    Generators.Add(new GL4Generator(Settings, dirName));
                    Generators.Add(new ESGenerator(Settings, dirName));
                    Generators.Add(new ES2Generator(Settings, dirName));
                    Generators.Add(new ES3Generator(Settings, dirName));
                    break;

                case GeneratorMode.GL2:
                    Generators.Add(new Generator(Settings, dirName));
                    break;

                case GeneratorMode.GL3:
                case GeneratorMode.GL4:
                    Generators.Add(new GL4Generator(Settings, dirName));
                    break;

                case GeneratorMode.ES10:
                    Generators.Add(new ESGenerator(Settings, dirName));
                    break;

                case GeneratorMode.ES11:
                    Generators.Add(new ESGenerator(Settings, dirName));
                    break;

                case GeneratorMode.ES20:
                    Generators.Add(new ES2Generator(Settings, dirName));
                    break;

                case GeneratorMode.ES30:
                    Generators.Add(new ES3Generator(Settings, dirName));
                    break;

                case GeneratorMode.CL10:
                    Generators.Add(new CLGenerator(Settings, dirName));
                    break;

                default:
                    Console.WriteLine("Please specify a generator mode (use '-mode:gl2/gl4/es10/es11/es20/es30')");
                    return;
                }

                foreach (var generator in Generators)
                {
                    long ticks = DateTime.Now.Ticks;

                    generator.Process();

                    ISpecWriter writer = null;
                    switch (generator.Settings.Language)
                    {
                    case GeneratorLanguage.Cpp:
                        writer = new CppSpecWriter();
                        break;

                    case GeneratorLanguage.Java:
                        writer = new JavaSpecWriter();
                        break;

                    case GeneratorLanguage.CSharp:
                    default:
                        writer = new CSharpSpecWriter();
                        break;
                    }
                    writer.WriteBindings(generator);

                    ticks = DateTime.Now.Ticks - ticks;

                    Console.WriteLine();
                    Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
                }

                Console.WriteLine();
                if (Debugger.IsAttached)
                {
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey(true);
                }
            }
            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.");
            }
            catch (NotImplementedException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("The requested functionality is not implemented yet.");
            }
        }
예제 #3
0
파일: Main.cs 프로젝트: BrainSlugs83/opentk
        static void Main(string[] arguments)
        {
            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;

            Console.WriteLine("OpenGL binding generator {0} for OpenTK.",
                Assembly.GetExecutingAssembly().GetName().Version.ToString());
            Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net");
            Console.WriteLine();

            string dirName =  "GL2";

            try
            {
                var split = new Regex(@"-\w+", RegexOptions.Compiled);
                foreach (var argument in arguments)
                {
                    string a = argument.Replace("--", "-").Trim();
                    var match = split.Match(a);
                    if (match.Success)
                    {
                        string opt = match.Value.Substring(1).Trim();
                        string val = a.Substring(match.Value.Length + 1).Trim();
                        switch (opt)
                        {
                            case "?":
                            case "help":
                                ShowHelp();
                                return;
                            case "in":
                            case "input":
                                Settings.InputPath = val;
                                break;
                            case "out":
                            case "output":
                                Settings.OutputPath = val;
                                break;
                            case "l":
                            case "lang":
                            case "language":
                                {
                                    string arg = val.ToLower();
                                    if (arg == "cpp" || arg == "c++" || arg == "c")
                                    {
                                        Settings.Language = GeneratorLanguage.Cpp;
                                        Settings.DefaultOutputPath = "gl";
                                        Settings.DefaultOutputNamespace = "OpenTK";
                                        // Settings.DefaultLanguageTypeMapFile = "cpp.tm"; // Todo: create this file!
                                        Settings.EnumsNamespace = "";
                                        Settings.NamespaceSeparator = "::";
                                        Settings.DefaultKeywordEscapeCharacter = "_";
                                    }
                                    else if (arg == "java")
                                    {
                                        Settings.Language = GeneratorLanguage.Java;
                                        Settings.DefaultOutputPath = "gl";
                                        Settings.DefaultOutputNamespace = "com.opentk";
                                        Settings.DefaultLanguageTypeMapFile = "java.tm";
                                        Settings.EnumsNamespace = "";
                                        Settings.NamespaceSeparator = ".";
                                        Settings.DefaultKeywordEscapeCharacter = "_";
                                    }
                                    break;
                                }
                            case "mode":
                                {
                                    string arg = val.ToLower();
                                    SetGeneratorMode(dirName, arg);
                                    break;
                                }
                            case "namespace":
                            case "ns":
                                Settings.OutputNamespace = val;
                                break;
                            case "class":
                                Settings.OutputClass = val;
                                break;
                            case "gl":
                                Settings.GLClass = val;
                                break;
                            case "legacy":
                            case "o":
                            case "option":
                            {
                                string option = val.ToLower();
                                bool enable = !opt.StartsWith("-");
                                if (option.StartsWith("+") || option.StartsWith("-"))
                                    option = option.Substring(1);

                                var settings = Settings.Legacy.None;
                                switch (opt)
                                {
                                    case "tao": settings |= Settings.Legacy.Tao; break;
                                    case "simple_enums": settings |= Settings.Legacy.NoAdvancedEnumProcessing; break;
                                    case "safe": settings |= Settings.Legacy.NoPublicUnsafeFunctions; break;
                                    case "permutations": settings |= Settings.Legacy.GenerateAllPermutations; break;
                                    case "enums_in_class": settings |= Settings.Legacy.NestedEnums; break;
                                    case "nodocs": settings |= Settings.Legacy.NoDocumentation; break;
                                    case "keep_untyped_enums": settings |= Settings.Legacy.KeepUntypedEnums; break;
                                }

                                if (enable)
                                {
                                    Settings.Compatibility |= settings;
                                }
                                else
                                {
                                    Settings.Compatibility &= ~settings;
                                }

                                break;
                            }
                            default:
                                throw new ArgumentException(
                                    String.Format("Argument {0} not recognized. Use the '/?' switch for help.", a)
                                );
                        }
                    }
                }
            }
            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
            {
                switch (mode)
                {
                    case GeneratorMode.All:
                        Console.WriteLine("Using 'all' generator mode.");
                        Console.WriteLine("Use '-mode:all/gl2/gl4/es10/es11/es20/es30' to select a specific mode.");
                        Generators.Add(new Generator(Settings, dirName));
                        Generators.Add(new GL4Generator(Settings, dirName));
                        Generators.Add(new ESGenerator(Settings, dirName));
                        Generators.Add(new ES2Generator(Settings, dirName));
                        Generators.Add(new ES3Generator(Settings, dirName));
                        break;

                    case GeneratorMode.GL2:
                        Generators.Add(new Generator(Settings, dirName));
                        break;

                    case GeneratorMode.GL3:
                    case GeneratorMode.GL4:
                        Generators.Add(new GL4Generator(Settings, dirName));
                        break;

                    case GeneratorMode.ES10:
                        Generators.Add(new ESGenerator(Settings, dirName));
                        break;
                    
                    case GeneratorMode.ES11:
                        Generators.Add(new ESGenerator(Settings, dirName));
                        break;
                    
                    case GeneratorMode.ES20:
                        Generators.Add(new ES2Generator(Settings, dirName));
                        break;

                    case GeneratorMode.ES30:
                        Generators.Add(new ES3Generator(Settings, dirName));
                        break;

                    case GeneratorMode.CL10:
                        Generators.Add(new CLGenerator(Settings, dirName));
                        break;
                    
                    default:
                        Console.WriteLine("Please specify a generator mode (use '-mode:gl2/gl4/es10/es11/es20/es30')");
                        return;
                }

                foreach (var generator in Generators)
                {
                    long ticks = DateTime.Now.Ticks;

                    generator.Process();

                    ISpecWriter writer = null;
                    switch (generator.Settings.Language)
                    {
                        case GeneratorLanguage.Cpp:
                            writer = new CppSpecWriter();
                            break;

                        case GeneratorLanguage.Java:
                            writer = new JavaSpecWriter();
                            break;

                        case GeneratorLanguage.CSharp:
                        default:
                            writer = new CSharpSpecWriter();
                            break;
                    }
                    writer.WriteBindings(generator);

                    ticks = DateTime.Now.Ticks - ticks;

                    Console.WriteLine();
                    Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
                }
                
                Console.WriteLine();
                if (Debugger.IsAttached)
                {
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey(true);
                }
            }
            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.");
            }
            catch (NotImplementedException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("The requested functionality is not implemented yet.");
            }
        }
예제 #4
0
        static void Main(string[] arguments)
        {
            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;

            Console.WriteLine("OpenGL binding generator {0} for OpenTK.",
                              Assembly.GetExecutingAssembly().GetName().Version.ToString());
            Console.WriteLine("For comments, bugs and suggestions visit http://opentk.sourceforge.net");
            Console.WriteLine();

            string dirName = null;

            try
            {
                var split = new Regex(@"-\w+", RegexOptions.Compiled);
                foreach (var argument in arguments)
                {
                    string a     = argument.Replace("--", "-").Trim();
                    var    match = split.Match(a);
                    if (match.Success)
                    {
                        string opt = match.Value.Substring(1).Trim();
                        string val = a.Substring(match.Value.Length + 1).Trim();
                        switch (opt)
                        {
                        case "?":
                        case "help":
                            ShowHelp();
                            return;

                        case "in":
                        case "input":
                            Settings.InputPath = val;
                            break;

                        case "out":
                        case "output":
                            Settings.OutputPath = val;
                            break;

                        case "include":
                            Settings.IncludePath = val;
                            break;

                        case "l":
                        case "lang":
                        case "language":
                        {
                            string arg = val.ToLower();
                            if (arg == "cpp" || arg == "c++" || arg == "c")
                            {
                                Settings.Language               = GeneratorLanguage.Cpp;
                                Settings.DefaultOutputPath      = "gl";
                                Settings.DefaultOutputNamespace = "OpenTK";
                                // Settings.DefaultLanguageTypeMapFile = "cpp.tm"; // Todo: create this file!
                                Settings.EnumsNamespace                = "";
                                Settings.NamespaceSeparator            = "::";
                                Settings.DefaultKeywordEscapeCharacter = "_";
                            }
                            else if (arg == "java")
                            {
                                Settings.Language                      = GeneratorLanguage.Java;
                                Settings.DefaultOutputPath             = "gl";
                                Settings.DefaultOutputNamespace        = "com.opentk";
                                Settings.DefaultLanguageTypeMapFile    = "java.tm";
                                Settings.EnumsNamespace                = "";
                                Settings.NamespaceSeparator            = ".";
                                Settings.DefaultKeywordEscapeCharacter = "_";
                            }
                            break;
                        }

                        case "mode":
                        {
                            string[] parts = val.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                            if (parts.Length < 1)
                            {
                                throw new NotImplementedException();
                            }
                            dirName = parts.Length > 1 ? parts[1] : "";
                            SetGeneratorMode(dirName, parts[0]);
                            break;
                        }

                        case "namespace":
                        case "ns":
                            Settings.OutputNamespace = val;
                            break;

                        case "class":
                            Settings.OutputClass = val;
                            break;

                        case "gl":
                            Settings.GLClass = val;
                            break;

                        case "legacy":
                        case "o":
                        case "option":
                            Settings.Compatibility |= val.ToLower() == "tao" ? Settings.Legacy.Tao : Settings.Legacy.None;
                            Settings.Compatibility |= val.ToLower() == "simple_enums" ? Settings.Legacy.NoAdvancedEnumProcessing : Settings.Legacy.None;
                            Settings.Compatibility |= val.ToLower() == "safe" ? Settings.Legacy.NoPublicUnsafeFunctions : Settings.Legacy.None;
                            //Settings.Compatibility |= b[1].ToLower().Contains("novoid") ? Settings.Legacy.TurnVoidPointersToIntPtr : Settings.Legacy.None;
                            Settings.Compatibility |= val.ToLower() == "permutations" ? Settings.Legacy.GenerateAllPermutations : Settings.Legacy.None;
                            Settings.Compatibility |= val.ToLower() == "enums_in_class" ? Settings.Legacy.NestedEnums : Settings.Legacy.None;
                            Settings.Compatibility |= val.ToLower() == "nodocs" ? Settings.Legacy.NoDocumentation : Settings.Legacy.None;
                            Settings.Compatibility |= val.ToLower() == "keep_untyped_enums" ? Settings.Legacy.KeepUntypedEnums : Settings.Legacy.None;
                            break;

                        default:
                            throw new ArgumentException(
                                      String.Format("Argument {0} not recognized. Use the '/?' switch for help.", a)
                                      );
                        }
                    }
                }
            }
            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 = DateTime.Now.Ticks;

                switch (mode)
                {
                case GeneratorMode.GL3:
                case GeneratorMode.GL2:
                    Generator = new GL4Generator("OpenGL", dirName);
                    break;

                case GeneratorMode.ES10:
                    Generator = new ESGenerator("ES10", dirName);
                    break;

                case GeneratorMode.ES11:
                    Generator = new ESGenerator("ES11", dirName);
                    break;

                case GeneratorMode.ES20:
                    Generator = new ESGenerator("ES20", dirName);
                    break;

                case GeneratorMode.ES30:
                    Generator = new ESGenerator("ES30", dirName);
                    break;

                case GeneratorMode.ES31:
                    Generator = new ESGenerator("ES31", dirName);
                    break;

                case GeneratorMode.CL10:
                    Generator = new CLGenerator("CL10", dirName);
                    break;

                case GeneratorMode.Unknown:
                default:
                    Console.WriteLine("Please specify a generator mode (use '-mode:gl2/gl3/glu/wgl/glx])'");
                    return;
                }

                Generator.Process();
                ISpecWriter writer = null;
                switch (Settings.Language)
                {
                case GeneratorLanguage.Cpp:
                    writer = new CppSpecWriter();
                    break;

                case GeneratorLanguage.Java:
                    writer = new JavaSpecWriter();
                    break;

                case GeneratorLanguage.CSharp:
                default:
                    writer = new CSharpSpecWriter();
                    break;
                }
                writer.WriteBindings(Generator);

                ticks = DateTime.Now.Ticks - ticks;

                Console.WriteLine();
                Console.WriteLine("Bindings generated in {0} seconds.", ticks / (double)10000000.0);
                Console.WriteLine();
                if (Debugger.IsAttached)
                {
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey(true);
                }
            }
            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.");
            }
            catch (NotImplementedException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("The requested functionality is not implemented yet.");
            }
        }