mirror of https://github.com/mono/CppSharp.git
c-sharpdotnetmonobindingsbridgecclangcpluspluscppsharpglueinteropparserparsingpinvokeswigsyntax-treevisitorsxamarinxamarin-bindings
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.
53 lines
1.6 KiB
53 lines
1.6 KiB
using System.Collections.Generic; |
|
using CppSharp.AST; |
|
|
|
namespace CppSharp.Generators.CLI |
|
{ |
|
/// <summary> |
|
/// C++/CLI generator responsible for driving the generation of |
|
/// source and header files. |
|
/// </summary> |
|
public class CLIGenerator : Generator |
|
{ |
|
private readonly CLITypePrinter typePrinter; |
|
|
|
public CLIGenerator(BindingContext context) : base(context) |
|
{ |
|
typePrinter = new CLITypePrinter(context); |
|
} |
|
|
|
public override List<CodeGenerator> Generate(IEnumerable<TranslationUnit> units) |
|
{ |
|
var outputs = new List<CodeGenerator>(); |
|
|
|
var header = new CLIHeaders(Context, units); |
|
outputs.Add(header); |
|
|
|
var source = new CLISources(Context, units); |
|
outputs.Add(source); |
|
|
|
return outputs; |
|
} |
|
|
|
public override bool SetupPasses() |
|
{ |
|
// Note: The ToString override will only work if this pass runs |
|
// after the MoveOperatorToCallPass. |
|
if (Context.Options.GenerateObjectOverrides) |
|
Context.TranslationUnitPasses.AddPass(new ObjectOverridesPass(this)); |
|
return true; |
|
} |
|
|
|
public static bool ShouldGenerateClassNativeField(Class @class) |
|
{ |
|
if (@class.IsStatic) |
|
return false; |
|
return @class.IsRefType && (!@class.HasBase || !@class.HasRefBase()); |
|
} |
|
|
|
protected override string TypePrinterDelegate(Type type) |
|
{ |
|
return type.Visit(typePrinter).ToString(); |
|
} |
|
} |
|
} |