Browse Source

Split building source file parse options from parsing code.

pull/291/head
triton 11 years ago
parent
commit
a62ea33d64
  1. 1
      src/Generator.Tests/ASTTestFixture.cs
  2. 17
      src/Generator/Driver.cs

1
src/Generator.Tests/ASTTestFixture.cs

@ -20,6 +20,7 @@ namespace CppSharp.Generator.Tests
Options.Headers.AddRange(files); Options.Headers.AddRange(files);
Driver = new Driver(Options, new TextDiagnosticPrinter()); Driver = new Driver(Options, new TextDiagnosticPrinter());
Driver.BuildParseOptions();
if (!Driver.ParseCode()) if (!Driver.ParseCode())
throw new Exception("Error parsing the code"); throw new Exception("Error parsing the code");

17
src/Generator/Driver.cs

@ -167,12 +167,6 @@ namespace CppSharp
public bool ParseCode() public bool ParseCode()
{ {
foreach (var header in Options.Headers)
{
var source = Project.AddFile(header);
source.Options = BuildParseOptions(source);
}
var parser = new ClangParser(new Parser.AST.ASTContext()); var parser = new ClangParser(new Parser.AST.ASTContext());
parser.SourceParsed += OnSourceFileParsed; parser.SourceParsed += OnSourceFileParsed;
@ -185,6 +179,15 @@ namespace CppSharp
return true; return true;
} }
public void BuildParseOptions()
{
foreach (var header in Options.Headers)
{
var source = Project.AddFile(header);
source.Options = BuildParseOptions(source);
}
}
public ParserTargetInfo TargetInfo { get; set; } public ParserTargetInfo TargetInfo { get; set; }
public bool ParseLibraries() public bool ParseLibraries()
@ -389,6 +392,8 @@ namespace CppSharp
if (!options.Quiet) if (!options.Quiet)
Log.EmitMessage("Parsing code..."); Log.EmitMessage("Parsing code...");
driver.BuildParseOptions();
if (!driver.ParseCode()) if (!driver.ParseCode())
return; return;

Loading…
Cancel
Save