Tools and libraries to glue C/C++ APIs to high-level languages
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

59 lines
1.7 KiB

using System;
using System.Collections.Generic;
namespace Cxxi
{
public class Parser
{
public Library Library { get; private set; }
private readonly DriverOptions options;
public Parser(DriverOptions options)
{
this.options = options;
Library = new Library(options.OutputNamespace, options.LibraryName);
}
public bool ParseHeaders(IEnumerable<string> headers)
{
bool hasErrors = false;
foreach (var header in headers)
{
var result = ParseHeader(header);
// 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 ParseHeader(string file)
{
var parserOptions = new ParserOptions
{
Library = Library,
FileName = file,
Verbose = false,
IncludeDirs = options.IncludeDirs,
Defines = options.Defines,
ToolSetToUse = options.ToolsetToUse
};
var result = ClangParser.Parse(parserOptions);
HeaderParsed(file, result);
return result;
}
public Action<string, ParserResult> HeaderParsed = delegate {};
}
}