void GenerateCode(AstBuilder astBuilder, ITextOutput output) { var syntaxTree = astBuilder.SyntaxTree; syntaxTree.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }); // generate AST var transform = new CSharpToCpp(); transform.Run(syntaxTree); var include = new IncludeVisitor(); syntaxTree.AcceptVisitor(include); // generate include string include_name = include.typename + ".h"; output.WriteLine("#include <QuantKit/Event/" + include_name + ">"); output.WriteLine("#include <QuantKit/EventType.h>"); output.WriteLine("#include \"../Event_p.h\""); output.WriteLine("#include \"DataObject_p.h\""); output.WriteLine("#include \"Tick_p.h\""); output.WriteLine(); //Generate cpp Code var outputFormatter = new TextOutputFormatter(output) { FoldBraces = true }; var formattingPolicy = FormattingOptionsFactory.CreateAllman(); syntaxTree.AcceptVisitor(new PrivateHppOutputVisitor(outputFormatter, formattingPolicy)); syntaxTree.AcceptVisitor(new PrivateCppOutputVisitor(outputFormatter, formattingPolicy)); syntaxTree.AcceptVisitor(new CppOutputVisitor(outputFormatter, formattingPolicy)); // generate endif output.WriteLine(); }