|
|
@ -113,54 +113,39 @@ namespace CppSharp |
|
|
|
|
|
|
|
|
|
|
|
public void ProcessCode() |
|
|
|
public void ProcessCode() |
|
|
|
{ |
|
|
|
{ |
|
|
|
TypeDatabase.SetupTypeMaps(); |
|
|
|
foreach (var pass in Passes.Passes) |
|
|
|
var passes = new PassBuilder(this); |
|
|
|
pass.VisitLibrary(Library); |
|
|
|
passes.CleanUnit(Options); |
|
|
|
} |
|
|
|
passes.SortDeclarations(); |
|
|
|
|
|
|
|
passes.ResolveIncompleteDecls(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Transform != null) |
|
|
|
|
|
|
|
Transform.SetupPasses(this, passes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
passes.CleanInvalidDeclNames(); |
|
|
|
|
|
|
|
passes.CheckIgnoredDecls(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
passes.CheckTypeReferences(); |
|
|
|
|
|
|
|
passes.CheckFlagEnums(); |
|
|
|
|
|
|
|
passes.CheckAmbiguousOverloads(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Generator.SetupPasses(passes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
passes.RunPasses(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Transform != null) |
|
|
|
public List<GeneratorOutput> GenerateCode() |
|
|
|
Transform.Postprocess(Library); |
|
|
|
{ |
|
|
|
|
|
|
|
var outputs = Generator.Generate(); |
|
|
|
|
|
|
|
return outputs; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void GenerateCode() |
|
|
|
public void WriteCode(List<GeneratorOutput> outputs) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (Library.TranslationUnits.Count <= 0) |
|
|
|
var outputPath = Options.OutputDir ?? Directory.GetCurrentDirectory(); |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var unit in Library.TranslationUnits) |
|
|
|
if (!Directory.Exists(outputPath)) |
|
|
|
{ |
|
|
|
Directory.CreateDirectory(outputPath); |
|
|
|
if (unit.Ignore || !unit.HasDeclarations) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (unit.IsSystemHeader) |
|
|
|
foreach (var output in outputs) |
|
|
|
continue; |
|
|
|
{ |
|
|
|
|
|
|
|
var fileBase = output.TranslationUnit.FileNameWithoutExtension; |
|
|
|
|
|
|
|
|
|
|
|
var outputs = new List<GeneratorOutput>(); |
|
|
|
if (Options.GenerateName != null) |
|
|
|
if (!Generator.Generate(unit, outputs)) |
|
|
|
fileBase = Options.GenerateName(output.TranslationUnit); |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var output in outputs) |
|
|
|
foreach (var template in output.Templates) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Diagnostics.EmitMessage(DiagnosticId.FileGenerated, |
|
|
|
var fileName = string.Format("{0}.{1}", fileBase, template.FileExtension); |
|
|
|
"Generated '{0}'", Path.GetFileName(output.OutputPath)); |
|
|
|
Diagnostics.EmitMessage(DiagnosticId.FileGenerated, "Generated '{0}'", fileName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var filePath = Path.Combine(outputPath, fileName); |
|
|
|
|
|
|
|
|
|
|
|
var text = output.Template.ToString(); |
|
|
|
var text = template.GenerateText(); |
|
|
|
File.WriteAllText(output.OutputPath, text); |
|
|
|
File.WriteAllText(Path.GetFullPath(filePath), text); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -296,7 +281,8 @@ namespace CppSharp |
|
|
|
library.Postprocess(driver.Library); |
|
|
|
library.Postprocess(driver.Library); |
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Generating code..."); |
|
|
|
Console.WriteLine("Generating code..."); |
|
|
|
driver.GenerateCode(); |
|
|
|
var outputs = driver.GenerateCode(); |
|
|
|
|
|
|
|
driver.WriteCode(outputs); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |