mirror of https://github.com/mono/CppSharp.git
10 changed files with 116 additions and 44 deletions
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
using CppSharp.AST; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace CppSharp.Generators.Registrable |
||||
{ |
||||
public abstract class RegistrableCodeGenerator<TGenerator> : CodeGenerator |
||||
where TGenerator : Generator |
||||
{ |
||||
public TGenerator Generator { get; set; } |
||||
|
||||
public RegistrableCodeGenerator(TGenerator generator, IEnumerable<TranslationUnit> units) : base(generator.Context, units) |
||||
{ |
||||
Generator = generator; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
using CppSharp.AST; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace CppSharp.Generators.Registrable |
||||
{ |
||||
public abstract class RegistrableGenerator<TOptions, THeader, TSource> : Generator |
||||
where THeader : CodeGenerator |
||||
where TSource : CodeGenerator |
||||
{ |
||||
public TOptions GeneratorOptions { get; } |
||||
|
||||
public RegistrableGenerator(BindingContext context) : base(context) |
||||
{ |
||||
GeneratorOptions = CreateOptions(this); |
||||
} |
||||
|
||||
protected abstract TOptions CreateOptions(RegistrableGenerator<TOptions, THeader, TSource> generator); |
||||
|
||||
protected abstract THeader CreateHeader(RegistrableGenerator<TOptions, THeader, TSource> generator, IEnumerable<TranslationUnit> units); |
||||
|
||||
protected abstract TSource CreateSource(RegistrableGenerator<TOptions, THeader, TSource> generator, IEnumerable<TranslationUnit> units); |
||||
|
||||
public override List<CodeGenerator> Generate(IEnumerable<TranslationUnit> units) |
||||
{ |
||||
return new List<CodeGenerator> |
||||
{ |
||||
CreateHeader(this, units), |
||||
CreateSource(this, units) |
||||
}; |
||||
} |
||||
|
||||
public override bool SetupPasses() => true; |
||||
} |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
using CppSharp.AST; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace CppSharp.Generators.Registrable |
||||
{ |
||||
public abstract class RegistrableHeaders<TGenerator> : RegistrableCodeGenerator<TGenerator> |
||||
where TGenerator : Generator |
||||
{ |
||||
public RegistrableHeaders(TGenerator generator, IEnumerable<TranslationUnit> units) : base(generator, units) |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
using CppSharp.AST; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace CppSharp.Generators.Registrable |
||||
{ |
||||
public abstract class RegistrableSources<TGenerator> : RegistrableCodeGenerator<TGenerator> |
||||
where TGenerator : Generator |
||||
{ |
||||
public RegistrableSources(TGenerator generator, IEnumerable<TranslationUnit> units) : base(generator, units) |
||||
{ |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue