Example #1
0
 /// <summary>
 /// Process the input file using the supplied visitor
 /// </summary>
 /// <param name="visitorToUse">visitor to use</param>
 /// <param name="filePath">path to file</param>
 private static void ProcessModules(CppVisitorBase visitorToUse, String filePath)
 {
     setOutput = false;
     foreach (IModule module in compiler.TypeSystem.Modules)
     {
         if (module.IsMainModule)
         {
             foreach (ITypeDefinition typeDefinition in module.TopLevelTypeDefinitions)
             {
                 if (typeDefinition.Kind == TypeKind.Class || typeDefinition.Kind == TypeKind.Enum || typeDefinition.Kind == TypeKind.Struct)
                 {
                     // Skip modules starting with < or any from CppTranslatorSupport namespace because
                     // those are hand crafted for specific platforms
                     if (!typeDefinition.Name.StartsWith("<", StringComparison.InvariantCulture) && !typeDefinition.Namespace.Contains("CppTranslatorSupport", StringComparison.InvariantCulture))
                     {
                         if (!setOutput)
                         {
                             formatter.OutputName = filePath;
                             setOutput            = true;
                             visitorToUse.AddHeaders();
                         }
                         List <EntityHandle> entities = new List <EntityHandle>()
                         {
                             typeDefinition.MetadataToken
                         };
                         SyntaxTree syntaxTree = compiler.Decompile(entities);
                         syntaxTree.AcceptVisitor(visitorToUse);
                     }
                 }
             }
             visitorToUse.CreateHeaders();
         }
     }
     formatter.Close();
 }