Exemplo n.º 1
0
 private static void WriteFileHeader(CodeWriter writer, GLSpec spec)
 {
     writer.WriteLine("// This file was autogenerated by GLCSGen on {0} UTC", DateTime.UtcNow);
     writer.WriteLine("// Original copyright from gl.xml:");
     foreach (var l in spec.HeaderComment.Split('\n', '\r'))
     {
         writer.WriteLine("// {0}", l);
     }
     writer.WriteLine();
     writer.WriteLine("using System;");
     writer.WriteLine("using System.Diagnostics;");
     writer.WriteLine("using System.Reflection;");
     writer.WriteLine("using System.Runtime.InteropServices;");
     writer.WriteLine();
     writer.WriteLine("namespace OpenGL");
 }
Exemplo n.º 2
0
        private static void CreateGLInterop(GLSpec spec, DirectoryInfo outDir, string api)
        {
            // Get the unique list of all commands
            List<GLCommand> commands = new List<GLCommand>();
            foreach (var version in spec.Versions)
            {
                if (version.Api != api)
                {
                    continue;
                }

                foreach (var c in version.Commands)
                {
                    if (commands.Find(c2 => c2.Name == c.Name) == null)
                    {
                        commands.Add(c);
                    }
                }
            }

            // Just to be pretty, sort them by name :)
            commands.Sort((c1, c2) => c1.Name.CompareTo(c2.Name));

            // Create the interop file containing all of the delegate types and instances
            using (var writer = new CodeWriter(Path.Combine(outDir.FullName, api + "Interop.cs")))
            {
                WriteFileHeader(writer, spec);
                writer.WriteOpenBrace();
                writer.WriteLine("internal static class {0}Interop", api);
                writer.WriteOpenBrace();
                WriteDelegates(writer, "public", commands);
                writer.WriteCloseBrace();
                writer.WriteCloseBrace();
            }
        }