Skip to content

Commit 598604e

Browse files
committed
Add ILibrary.GenerateCode as a custom code generation callback.
1 parent 9bc3453 commit 598604e

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/CLI/Generator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ public void SetupPasses(Driver driver)
174174
driver.Context.TranslationUnitPasses.AddPass(new MarshalPrimitivePointersAsRefTypePass());
175175
}
176176

177+
public void GenerateCode(Driver driver, List<GeneratorOutput> outputs)
178+
{
179+
}
180+
177181
public void Preprocess(Driver driver, ASTContext ctx)
178182
{
179183
}

src/Generator/Driver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,8 @@ public static void Run(ILibrary library)
486486
{
487487
var outputs = driver.GenerateCode();
488488

489+
library.GenerateCode(driver, outputs);
490+
489491
foreach (var output in outputs)
490492
{
491493
foreach (var pass in driver.Context.GeneratorOutputPasses.Passes)

src/Generator/Library.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using System.Text.RegularExpressions;
66
using CppSharp.AST;
7+
using CppSharp.Generators;
78
using CppSharp.Passes;
89

910
namespace CppSharp
@@ -33,6 +34,11 @@ public interface ILibrary
3334
/// </summary>
3435
/// <param name="driver"></param>
3536
void SetupPasses(Driver driver);
37+
38+
/// <summary>
39+
/// Generate custom code here.
40+
/// </summary>
41+
void GenerateCode(Driver driver, List<GeneratorOutput> outputs) { }
3642
}
3743

3844
public static class LibraryHelpers

0 commit comments

Comments
 (0)