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.
43 lines
1.2 KiB
43 lines
1.2 KiB
using System; |
|
using System.IO; |
|
using Cxxi.Passes; |
|
using Cxxi.Types; |
|
|
|
namespace Cxxi.Generators.CLI |
|
{ |
|
public class CLIGenerator : Generator |
|
{ |
|
private readonly ITypePrinter typePrinter; |
|
|
|
public CLIGenerator(Driver driver) : base(driver) |
|
{ |
|
typePrinter = new CLITypePrinter(driver.TypeDatabase, driver.Library); |
|
Type.TypePrinter = typePrinter; |
|
} |
|
|
|
void WriteTemplate(TextTemplate template) |
|
{ |
|
var file = Path.GetFileNameWithoutExtension(template.unit.FileName) |
|
+ Driver.Options.WrapperSuffix + "." |
|
+ template.FileExtension; |
|
|
|
var path = Path.Combine(Driver.Options.OutputDir, file); |
|
|
|
template.Generate(); |
|
|
|
Console.WriteLine(" Generated '" + file + "'."); |
|
File.WriteAllText(Path.GetFullPath(path), template.ToString()); |
|
} |
|
|
|
public override bool Generate(TranslationUnit unit) |
|
{ |
|
var header = new CLIHeadersTemplate(Driver, unit); |
|
WriteTemplate(header); |
|
|
|
var source = new CLISourcesTemplate(Driver, unit); |
|
WriteTemplate(source); |
|
|
|
return true; |
|
} |
|
} |
|
} |