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.
 
 
 
 
 

42 lines
1.1 KiB

using System;
using System.IO;
using Cxxi;
using Cxxi.Types;
namespace Generator.Tests
{
public class HeaderTestFixture
{
protected Library library;
protected TypeMapDatabase database;
private const string TestsDirectory = @"..\..\..\tests\Native";
protected void ParseLibrary(string file)
{
ParseLibrary(TestsDirectory, file);
}
protected void ParseLibrary(string dir, string file)
{
database = new TypeMapDatabase();
database.SetupTypeMaps();
var options = new DriverOptions();
var path = Path.Combine(Directory.GetCurrentDirectory(), dir);
options.IncludeDirs.Add(path);
var parser = new Parser(options);
var result = parser.ParseHeader(file);
if (result.Kind != ParserResultKind.Success)
throw new Exception("Could not parse file: " + file);
library = result.Library;
foreach (var diag in result.Diagnostics)
Console.WriteLine(diag.Message);
}
}
}