Browse Source

Fixed a crash when wrapping more than one header.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/600/head
Dimitar Dobrev 10 years ago
parent
commit
6e5a8e835d
  1. 16
      src/Core/Parser/Parser.cs

16
src/Core/Parser/Parser.cs

@ -1,4 +1,6 @@ @@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CppSharp.AST;
using CppSharp.Parser;
using ASTContext = CppSharp.Parser.AST.ASTContext;
@ -48,14 +50,16 @@ namespace CppSharp @@ -48,14 +50,16 @@ namespace CppSharp
/// <summary>
/// Parses a C++ source file to a translation unit.
/// </summary>
public void ParseSourceFile(SourceFile file)
public ParserResult ParseSourceFile(SourceFile file)
{
var options = file.Options;
options.ASTContext = ASTContext;
options.FileName = file.Path;
using (var result = Parser.ClangParser.ParseHeader(options))
SourceParsed(file, result);
var result = Parser.ClangParser.ParseHeader(options);
SourceParsed(file, result);
return result;
}
/// <summary>
@ -65,9 +69,9 @@ namespace CppSharp @@ -65,9 +69,9 @@ namespace CppSharp
{
// TODO: Search for cached AST trees on disk
// TODO: Do multi-threaded parsing of source files
foreach (var source in project.Sources)
ParseSourceFile(source);
foreach (var parserResult in project.Sources.Select(s => ParseSourceFile(s)).ToList())
parserResult.Dispose();
}
/// <summary>

Loading…
Cancel
Save