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.
 
 
 
 
 

45 lines
1.4 KiB

using System.Collections.Generic;
using CppSharp.AST;
using CppSharp.Passes;
namespace CppSharp.Generators.CSharp
{
public class CSharpGenerator : Generator
{
private readonly CSharpTypePrinter typePrinter;
private readonly CSharpExpressionPrinter expressionPrinter;
public CSharpGenerator(BindingContext context) : base(context)
{
typePrinter = new CSharpTypePrinter(context);
expressionPrinter = new CSharpExpressionPrinter(typePrinter);
}
public override List<CodeTemplate> Generate(IEnumerable<TranslationUnit> units)
{
var outputs = new List<CodeTemplate>();
var template = new CSharpSources(Context, units, typePrinter, expressionPrinter);
outputs.Add(template);
return outputs;
}
public override bool SetupPasses()
{
// Both the CheckOperatorsOverloadsPass and CheckAbiParameters can
// create and and new parameters to functions and methods. Make sure
// CheckAbiParameters runs last because hidden structure parameters
// should always occur first.
Context.TranslationUnitPasses.AddPass(new CheckAbiParameters());
return true;
}
protected override string TypePrinterDelegate(Type type)
{
return type.Visit(typePrinter).Type;
}
}
}