示例#1
0
        private ManagedHeader GetManagedHeader(HeaderDefinition header)
        {
            ManagedHeader managedHeader;

            if (!Headers.TryGetValue(header.Filename, out managedHeader))
            {
                managedHeader            = new ManagedHeader(header, GetManagedHeaderName(header));
                Headers[header.Filename] = managedHeader;
            }
            return(managedHeader);
        }
        // Return condition unless type is already used under the same condition.
        private string GetTypeConditional(TypeRefDefinition type, ManagedHeader header)
        {
            string typeConditional = GetTypeConditional(type);

            if (typeConditional != null && headerConditionals.ContainsKey(header.Name))
            {
                if (headerConditionals[header.Name].Equals(typeConditional))
                {
                    return(null);
                }
            }
            return(typeConditional);
        }
示例#3
0
        void WriteHeader(ManagedHeader header, string sourceRootFolder)
        {
            // Entirely skip headers that have no classes
            // TODO: parse C++ methods outside of classes
            if (header.Native.AllClasses.All(@class => @class.IsExcluded))
            {
                return;
            }

            // C# source file
            string csPath     = header.Name + ".cs";
            string csFullPath = Path.Combine(Project.CsProjectPathFull, csPath);

            OpenFile(csFullPath, WriteTo.CS);
            WriteLine("using System;");
            if (RequiresInterop(header.Native))
            {
                WriteLine("using System.Runtime.InteropServices;");
                WriteLine("using System.Security;");
            }
            if (RequiresMathNamespace(header.Native))
            {
                WriteLine("using BulletSharp.Math;");
            }
            WriteLine();


            WriteLine($"namespace {Project.NamespaceName}");
            WriteLine("{");
            hasCSWhiteSpace = true;

            var enums = GetEnums(header.Classes)
                        .OrderBy(e => e.Name).ToList();

            foreach (var @enum in enums)
            {
                WriteEnumClass(@enum, 1);
            }

            foreach (var @class in header.Classes
                     .Where(c => !IsExcludedClass(c)))
            {
                WriteClass(@class, 1);
            }

            WriteLine('}', WriteTo.CS);

            CloseFile(WriteTo.CS);
        }
        void WriteHeader(ManagedHeader header, string sourceRootFolder)
        {
            // Entirely skip headers that have no classes
            // TODO: parse C++ methods outside of classes
            if (header.Native.AllClasses.All(@class => @class.IsExcluded)) return;

            // C# source file
            string csPath = header.Name + ".cs";
            string csFullPath = Path.Combine(Project.CsProjectPathFull, csPath);
            OpenFile(csFullPath, WriteTo.CS);
            WriteLine("using System;");
            if (RequiresInterop(header.Native))
            {
                WriteLine("using System.Runtime.InteropServices;");
                WriteLine("using System.Security;");
            }
            if (RequiresMathNamespace(header.Native))
            {
                WriteLine("using BulletSharp.Math;");
            }
            WriteLine();


            WriteLine($"namespace {Project.NamespaceName}");
            WriteLine("{");
            hasCSWhiteSpace = true;

            var enums = GetEnums(header.Classes)
                .OrderBy(e => e.Name).ToList();
            foreach (var @enum in enums)
            {
                WriteEnumClass(@enum, 1);
            }

            foreach (var @class in header.Classes
                .Where(c => !IsExcludedClass(c)))
            {
                WriteClass(@class, 1);
            }

            WriteLine('}', WriteTo.CS);

            CloseFile(WriteTo.CS);
        }
 // Return condition unless type is already used under the same condition.
 private string GetTypeConditional(TypeRefDefinition type, ManagedHeader header)
 {
     string typeConditional = GetTypeConditional(type);
     if (typeConditional != null && headerConditionals.ContainsKey(header.Name))
     {
         if (headerConditionals[header.Name].Equals(typeConditional))
         {
             return null;
         }
     }
     return typeConditional;
 }
 private ManagedHeader GetManagedHeader(HeaderDefinition header)
 {
     ManagedHeader managedHeader;
     if (!Headers.TryGetValue(header.Filename, out managedHeader))
     {
         managedHeader = new ManagedHeader(header, GetManagedHeaderName(header));
         Headers[header.Filename] = managedHeader;
     }
     return managedHeader;
 }