Пример #1
0
        public void GenerateCommands(RegistryContext ctx, string path, CommandFilterDelegate filter)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            if ((filter != null) && (_Registry.Commands.FindIndex(delegate(Command item) { return(filter(item)); }) < 0))
            {
                return;
            }

            GenerateCommands(ctx, path, (CommandSerializerDelegate) delegate(RegistryContext cctx, SourceStreamWriter sw)
            {
                foreach (Command command in _Registry.Commands)
                {
                    if ((filter != null) && (filter(command) == false))
                    {
                        continue;
                    }

                    command.GenerateImplementations(sw, cctx);
                    sw.WriteLine();
                }
            });
        }
Пример #2
0
        public void GenerateCommandsDelegates(RegistryContext ctx, string path, CommandFilterDelegate filter)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            using (SourceStreamWriter sw = new SourceStreamWriter(path, false)) {
                GenerateLicensePreamble(sw);

                sw.WriteLine("#pragma warning disable 649, 1572, 1573");
                sw.WriteLine();

                sw.WriteLine("using System;");
                sw.WriteLine("using System.Security;");
                sw.WriteLine("using System.Runtime.InteropServices;");
                sw.WriteLine("using System.Text;");
                sw.WriteLine();

                sw.WriteLine("namespace {0}", Namespace);
                sw.WriteLine("{");
                sw.Indent();

                sw.WriteLine("public unsafe partial class {0}", ctx.Class);
                sw.WriteLine("{");
                sw.Indent();

                #region Function Delegates

                // Write delegates
                sw.WriteLine("internal unsafe static partial class Delegates");
                sw.WriteLine("{");
                sw.Indent();

                foreach (Command command in _Registry.Commands)
                {
                    if ((filter != null) && (filter(command) == false))
                    {
                        continue;
                    }

                    if ((command.Flags & CommandFlags.Disable) == 0)
                    {
                        command.GenerateDelegate(sw, ctx);
                        sw.WriteLine();
                    }
                }

                sw.Unindent();
                sw.WriteLine("}");

                #endregion

                sw.Unindent();
                sw.WriteLine("}");
                sw.Unindent();

                sw.WriteLine();
                sw.WriteLine("}");
            }
        }
Пример #3
0
        public void GenerateCommandsImports(RegistryContext ctx, string path, CommandFilterDelegate filter)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            using (SourceStreamWriter sw = new SourceStreamWriter(path, false)) {
                GenerateLicensePreamble(sw);

                sw.WriteLine("using System;");
                sw.WriteLine("using System.Security;");
                sw.WriteLine("using System.Runtime.InteropServices;");
                sw.WriteLine();

                sw.WriteLine("namespace {0}", Namespace);
                sw.WriteLine("{");
                sw.Indent();

                sw.WriteLine("public unsafe partial class {0}", ctx.Class);
                sw.WriteLine("{");
                sw.Indent();

                #region Function Imports

                // Write delegates
                switch (ctx.Class)
                {
                // Glx and Wgl classes exposes public unsafe native methods: let UnsafeNativeMethods be public (note: automatically
                // generated members have internal scope)
                case "Glx":
                case "Wgl":
                    sw.WriteLine("public unsafe static partial class UnsafeNativeMethods");
                    break;

                default:
                    sw.WriteLine("internal unsafe static partial class UnsafeNativeMethods");
                    break;
                }

                sw.WriteLine("{");
                sw.Indent();

                foreach (Command command in _Registry.Commands)
                {
                    if ((filter != null) && (filter(command) == false))
                    {
                        continue;
                    }

                    if ((command.Flags & CommandFlags.Disable) == 0)
                    {
                        command.GenerateImport(sw, ctx);
                        sw.WriteLine();
                    }
                }

                sw.Unindent();
                sw.WriteLine("}");

                #endregion

                sw.Unindent();
                sw.WriteLine("}");
                sw.Unindent();

                sw.WriteLine();
                sw.WriteLine("}");
            }
        }
Пример #4
0
		public void GenerateCommandsDelegates(RegistryContext ctx, string path, CommandFilterDelegate filter)
		{
			if (path == null)
				throw new ArgumentNullException("path");

			using (SourceStreamWriter sw = new SourceStreamWriter(path, false)) {
				GenerateLicensePreamble(sw);

				sw.WriteLine("#pragma warning disable 649, 1572, 1573");
				sw.WriteLine();

				sw.WriteLine("using System;");
				sw.WriteLine("using System.Security;");
				sw.WriteLine("using System.Runtime.InteropServices;");
				sw.WriteLine("using System.Text;");
				sw.WriteLine();

				sw.WriteLine("namespace OpenGL");
				sw.WriteLine("{");
				sw.Indent();

				sw.WriteLine("public unsafe partial class {0}", ctx.Class);
				sw.WriteLine("{");
				sw.Indent();

				#region Function Delegates

				// Write delegates
				sw.WriteLine("internal unsafe static partial class Delegates");
				sw.WriteLine("{");
				sw.Indent();

				foreach (Command command in mRegistry.Commands) {
					if ((filter != null) && (filter(command) == false))
						continue;

					if ((command.Flags & CommandFlags.Disable) == 0) {
						command.GenerateDelegate(sw, ctx);
						sw.WriteLine();
					}
				}

				sw.Unindent();
				sw.WriteLine("}");

				#endregion

				sw.Unindent();
				sw.WriteLine("}");
				sw.Unindent();

				sw.WriteLine();
				sw.WriteLine("}");
			}
		}
Пример #5
0
		public void GenerateCommandsImports(RegistryContext ctx, string path, CommandFilterDelegate filter)
		{
			if (path == null)
				throw new ArgumentNullException("path");

			using (SourceStreamWriter sw = new SourceStreamWriter(path, false)) {
				GenerateLicensePreamble(sw);

				sw.WriteLine("using System;");
				sw.WriteLine("using System.Security;");
				sw.WriteLine("using System.Runtime.InteropServices;");
				sw.WriteLine();

				sw.WriteLine("namespace OpenGL");
				sw.WriteLine("{");
				sw.Indent();

				sw.WriteLine("public unsafe partial class {0}", ctx.Class);
				sw.WriteLine("{");
				sw.Indent();

				#region Function Imports

				// Write delegates
				switch (ctx.Class) {
					// Glx and Wgl classes exposes public unsafe native methods: let UnsafeNativeMethods be public (note: automatically
					// generated members have internal scope)
					case "Glx":
					case "Wgl":
						sw.WriteLine("public unsafe static partial class UnsafeNativeMethods");
						break;
					default:
						sw.WriteLine("internal unsafe static partial class UnsafeNativeMethods");
						break;
				}
				
				sw.WriteLine("{");
				sw.Indent();

				foreach (Command command in mRegistry.Commands) {
					if ((filter != null) && (filter(command) == false))
						continue;

					if ((command.Flags & CommandFlags.Disable) == 0) {
						command.GenerateImport(sw, ctx);
						sw.WriteLine();
					}
				}

				sw.Unindent();
				sw.WriteLine("}");

				#endregion

				sw.Unindent();
				sw.WriteLine("}");
				sw.Unindent();

				sw.WriteLine();
				sw.WriteLine("}");
			}
		}
Пример #6
0
		public void GenerateCommands(RegistryContext ctx, string path, CommandFilterDelegate filter)
		{
			if (path == null)
				throw new ArgumentNullException("path");

			if ((filter != null) && (mRegistry.Commands.FindIndex(delegate(Command item) { return (filter(item)); }) < 0))
				return;

			GenerateCommands(ctx, path, (CommandSerializerDelegate)delegate(RegistryContext cctx, SourceStreamWriter sw)
			{
				foreach (Command command in mRegistry.Commands)
				{
					if ((filter != null) && (filter(command) == false))
						continue;

					command.GenerateImplementations(sw, cctx);
					sw.WriteLine();
				}
			});
			
		}