diff --git a/src/Generator/Parser.cs b/src/Generator/Parser.cs index ea9ab84d..6b4b42ab 100644 --- a/src/Generator/Parser.cs +++ b/src/Generator/Parser.cs @@ -16,7 +16,8 @@ namespace Cxxi public bool ParseHeaders(IEnumerable headers) { - bool hasErrors = false; + var hasErrors = false; + foreach (var header in headers) { var result = ParseHeader(header); @@ -48,12 +49,54 @@ namespace Cxxi ToolSetToUse = options.ToolsetToUse }; - var result = ClangParser.Parse(parserOptions); - HeaderParsed(file, result); + var result = ClangParser.ParseHeader(parserOptions); + OnHeaderParsed(file, result); + + return result; + } + + public bool ParseLibraries(IEnumerable libraries) + { + var hasErrors = false; + + foreach (var lib in libraries) + { + var result = ParseLibrary(lib); + + // If we have some error, report to end-user. + if (!options.IgnoreErrors) + { + foreach (var diag in result.Diagnostics) + { + if (diag.Level == ParserDiagnosticLevel.Error || + diag.Level == ParserDiagnosticLevel.Fatal) + hasErrors = true; + } + } + } + + return !hasErrors; + } + + public ParserResult ParseLibrary(string file) + { + var parserOptions = new ParserOptions + { + Library = Library, + FileName = file, + Verbose = false, + LibraryDirs = options.LibraryDirs, + ToolSetToUse = options.ToolsetToUse + }; + + var result = ClangParser.ParseLibrary(parserOptions); + OnLibraryParsed(file, result); return result; } - public Action HeaderParsed = delegate {}; + public Action OnHeaderParsed = delegate {}; + public Action OnLibraryParsed = delegate { }; + } }