コード例 #1
0
        /// <summary>
        /// Generates the platform-agnostic IDL file from the given UTinyProject.
        /// </summary>
        public static void GenerateIDL(UTinyProject project, FileInfo destination)
        {
            var writer = new UTinyCodeWriter
            {
                CodeStyle = CodeStyle.CSharp
            };

            writer.Line("using UTiny;");

            var mainModule = project.Module.Dereference(project.Registry);

            foreach (var dep in mainModule.EnumerateDependencies())
            {
                if (dep.Equals(mainModule))
                {
                    continue;
                }
                writer.Line($"using {dep.Name};");
            }

            project.Visit(new GenerateIDLVisitor {
                Writer = writer
            });
            File.WriteAllText(destination.FullName, writer.ToString(), Encoding.UTF8);
        }
コード例 #2
0
        /// <summary>
        /// Generates the platform-agnostic IDL file from the given UTinyProject.
        /// </summary>
        public static void GenerateIDL(UTinyProject project, FileInfo destination)
        {
            var writer = new UTinyCodeWriter
            {
                CodeStyle = CodeStyle.CSharp
            };

            writer.Line("using UTiny;");
            writer.Line("using UTiny.Shared;");

            var mainModule = project.Module.Dereference(project.Registry);

            foreach (var dep in mainModule.EnumerateDependencies())
            {
                if (dep.Equals(mainModule))
                {
                    continue;
                }
                if (dep.Name == "UTiny.Core") // Hack: The Core module does not actually generate a Core namespace, but Core namespace is the UTiny/ut namespace.
                {
                    continue;
                }
                if (dep.IsRuntimeIncluded)
                {
                    writer.Line($"using {dep.Name};"); // Core namespaces are of form "UTiny.Core2D".
                }
                else
                {
                    writer.Line($"using {dep.Namespace.Replace("UTiny.", "ut.")};"); // Runtime generated namespaces are of form "ut.tween".
                }
            }

            project.Visit(new GenerateIDLVisitor {
                Writer = writer
            });
            File.WriteAllText(destination.FullName, writer.ToString(), Encoding.UTF8);
        }