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

Loading…
Cancel
Save