Browse Source

Fixed the build after the refactoring.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/696/head
Dimitar Dobrev 9 years ago
parent
commit
4f10e9fb78
  1. 10
      examples/SDL/SDL.cs
  2. 6
      src/Generator.Tests/AST/TestAST.cs
  3. 6
      src/Generator.Tests/ASTTestFixture.cs
  4. 4
      src/Generator.Tests/Passes/TestPasses.cs
  5. 5
      src/Generator.Tests/ReadNativeDependenciesTest.cs
  6. 6
      src/Generator/Driver.cs
  7. 2
      src/Generator/Passes/CheckIgnoredDecls.cs
  8. 4
      src/Generator/Passes/CleanUnitPass.cs
  9. 6
      tests/CSharp/CSharp.cs
  10. 2
      tests/NamespacesDerived/NamespacesDerived.cs
  11. 4
      tests/VTables/VTables.cs

10
examples/SDL/SDL.cs

@ -19,11 +19,11 @@ namespace CppSharp
public void SetupPasses(Driver driver) public void SetupPasses(Driver driver)
{ {
driver.TranslationUnitPasses.RemovePrefix("SDL_"); driver.Context.TranslationUnitPasses.RemovePrefix("SDL_");
driver.TranslationUnitPasses.RemovePrefix("SCANCODE_"); driver.Context.TranslationUnitPasses.RemovePrefix("SCANCODE_");
driver.TranslationUnitPasses.RemovePrefix("SDLK_"); driver.Context.TranslationUnitPasses.RemovePrefix("SDLK_");
driver.TranslationUnitPasses.RemovePrefix("KMOD_"); driver.Context.TranslationUnitPasses.RemovePrefix("KMOD_");
driver.TranslationUnitPasses.RemovePrefix("LOG_CATEGORY_"); driver.Context.TranslationUnitPasses.RemovePrefix("LOG_CATEGORY_");
} }
public void Preprocess(Driver driver, ASTContext ctx) public void Preprocess(Driver driver, ASTContext ctx)

6
src/Generator.Tests/AST/TestAST.cs

@ -5,6 +5,7 @@ using CppSharp.AST.Extensions;
using NUnit.Framework; using NUnit.Framework;
using CppSharp.Generators.CSharp; using CppSharp.Generators.CSharp;
using System; using System;
using CppSharp.Generators;
namespace CppSharp.Generator.Tests.AST namespace CppSharp.Generator.Tests.AST
{ {
@ -313,8 +314,9 @@ namespace CppSharp.Generator.Tests.AST
[Test] [Test]
public void TestAmbiguity() public void TestAmbiguity()
{ {
new CheckAmbiguousFunctions { Driver = new Driver(new DriverOptions(), new TextDiagnosticPrinter()) } var bindingContext = new BindingContext(new TextDiagnosticPrinter(), new DriverOptions());
.VisitLibrary(AstContext); new CleanUnitPass { Context = bindingContext }.VisitLibrary(AstContext);
new CheckAmbiguousFunctions { Context = bindingContext }.VisitLibrary(AstContext);
Assert.IsTrue(AstContext.FindClass("HasAmbiguousFunctions").Single().FindMethod("ambiguous").IsAmbiguous); Assert.IsTrue(AstContext.FindClass("HasAmbiguousFunctions").Single().FindMethod("ambiguous").IsAmbiguous);
} }

6
src/Generator.Tests/ASTTestFixture.cs

@ -20,12 +20,14 @@ namespace CppSharp.Generator.Tests
Options.Headers.AddRange(files); Options.Headers.AddRange(files);
Driver = new Driver(Options, new TextDiagnosticPrinter()); Driver = new Driver(Options, new TextDiagnosticPrinter());
Driver.SetupIncludes(); foreach (var module in Driver.Options.Modules)
module.LibraryName = "Test";
Driver.Setup();
Driver.BuildParseOptions(); Driver.BuildParseOptions();
if (!Driver.ParseCode()) if (!Driver.ParseCode())
throw new Exception("Error parsing the code"); throw new Exception("Error parsing the code");
AstContext = Driver.ASTContext; AstContext = Driver.Context.ASTContext;
} }
} }
} }

4
src/Generator.Tests/Passes/TestPasses.cs

@ -20,7 +20,7 @@ namespace CppSharp.Generator.Tests.Passes
public void Setup() public void Setup()
{ {
ParseLibrary("Passes.h"); ParseLibrary("Passes.h");
passBuilder = new PassBuilder<TranslationUnitPass>(Driver); passBuilder = new PassBuilder<TranslationUnitPass>(Driver.Context);
} }
[Test] [Test]
@ -207,7 +207,7 @@ namespace CppSharp.Generator.Tests.Passes
private string TypePrinterDelegate(CppSharp.AST.Type type) private string TypePrinterDelegate(CppSharp.AST.Type type)
{ {
return type.Visit(new CSharpTypePrinter(Driver)).Type; return type.Visit(new CSharpTypePrinter(Driver.Context)).Type;
} }
[Test] [Test]

5
src/Generator.Tests/ReadNativeDependenciesTest.cs

@ -41,8 +41,11 @@ namespace CppSharp.Generator.Tests
driverOptions.addLibraryDirs(GeneratorTest.GetTestsDirectory("Native")); driverOptions.addLibraryDirs(GeneratorTest.GetTestsDirectory("Native"));
driverOptions.Libraries.Add(library); driverOptions.Libraries.Add(library);
var driver = new Driver(driverOptions, new TextDiagnosticPrinter()); var driver = new Driver(driverOptions, new TextDiagnosticPrinter());
foreach (var module in driver.Options.Modules)
module.LibraryName = "Test";
driver.Setup();
Assert.IsTrue(driver.ParseLibraries()); Assert.IsTrue(driver.ParseLibraries());
var dependencies = driver.Symbols.Libraries[0].Dependencies; var dependencies = driver.Context.Symbols.Libraries[0].Dependencies;
return dependencies; return dependencies;
} }
} }

6
src/Generator/Driver.cs

@ -226,8 +226,6 @@ namespace CppSharp
Project.Sources[0].Options = BuildParserOptions(); Project.Sources[0].Options = BuildParserOptions();
} }
public ParserTargetInfo TargetInfo { get; set; }
public void SortModulesByDependencies() public void SortModulesByDependencies()
{ {
if (Options.Modules.All(m => m.Libraries.Any())) if (Options.Modules.All(m => m.Libraries.Any()))
@ -504,7 +502,7 @@ namespace CppSharp
return; return;
} }
new CleanUnitPass().VisitLibrary(driver.Context.ASTContext); new CleanUnitPass { Context = driver.Context }.VisitLibrary(driver.Context.ASTContext);
options.Modules.RemoveAll(m => m != options.SystemModule && !m.Units.GetGenerated().Any()); options.Modules.RemoveAll(m => m != options.SystemModule && !m.Units.GetGenerated().Any());
if (!options.Quiet) if (!options.Quiet)
@ -543,7 +541,7 @@ namespace CppSharp
} }
driver.Generator.Dispose(); driver.Generator.Dispose();
driver.TargetInfo.Dispose(); driver.Context.TargetInfo.Dispose();
} }
} }
} }

2
src/Generator/Passes/CheckIgnoredDecls.cs

@ -102,7 +102,7 @@ namespace CppSharp.Passes
public override bool VisitFunctionDecl(Function function) public override bool VisitFunctionDecl(Function function)
{ {
if (!VisitDeclaration(function)) if (!VisitDeclaration(function) || function.IsSynthetized)
return false; return false;
var ret = function.ReturnType; var ret = function.ReturnType;

4
src/Generator/Passes/CleanUnitPass.cs

@ -6,10 +6,6 @@ namespace CppSharp.Passes
{ {
public class CleanUnitPass : TranslationUnitPass public class CleanUnitPass : TranslationUnitPass
{ {
public CleanUnitPass()
{
}
public override bool VisitTranslationUnit(TranslationUnit unit) public override bool VisitTranslationUnit(TranslationUnit unit)
{ {
if (!base.VisitTranslationUnit(unit)) if (!base.VisitTranslationUnit(unit))

6
tests/CSharp/CSharp.cs

@ -154,8 +154,8 @@ namespace CppSharp.Tests
// To ensure that calls to constructors in conversion operators // To ensure that calls to constructors in conversion operators
// are not ambiguous with multiple inheritance pass enabled. // are not ambiguous with multiple inheritance pass enabled.
driver.Options.GenerateConversionOperators = true; driver.Options.GenerateConversionOperators = true;
driver.TranslationUnitPasses.AddPass(new TestAttributesPass()); driver.Context.TranslationUnitPasses.AddPass(new TestAttributesPass());
driver.TranslationUnitPasses.AddPass(new CheckMacroPass()); driver.Context.TranslationUnitPasses.AddPass(new CheckMacroPass());
driver.Options.MarshalCharAsManagedChar = true; driver.Options.MarshalCharAsManagedChar = true;
driver.Options.GenerateDefaultValuesForArguments = true; driver.Options.GenerateDefaultValuesForArguments = true;
} }
@ -176,7 +176,7 @@ namespace CppSharp.Tests
{ {
new CaseRenamePass( new CaseRenamePass(
RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate | RenameTargets.Variable, RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate | RenameTargets.Variable,
RenameCasePattern.UpperCamelCase).VisitLibrary(driver.ASTContext); RenameCasePattern.UpperCamelCase).VisitLibrary(driver.Context.ASTContext);
} }
public static void Main(string[] args) public static void Main(string[] args)

2
tests/NamespacesDerived/NamespacesDerived.cs

@ -37,7 +37,7 @@ namespace CppSharp.Tests
{ {
new CaseRenamePass( new CaseRenamePass(
RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate | RenameTargets.Variable, RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate | RenameTargets.Variable,
RenameCasePattern.UpperCamelCase).VisitLibrary(driver.ASTContext); RenameCasePattern.UpperCamelCase).VisitLibrary(driver.Context.ASTContext);
} }
} }

4
tests/VTables/VTables.cs

@ -14,8 +14,8 @@ namespace CppSharp.Tests
public override void SetupPasses(Driver driver) public override void SetupPasses(Driver driver)
{ {
driver.TranslationUnitPasses.RenameDeclsUpperCase(RenameTargets.Any); driver.Context.TranslationUnitPasses.RenameDeclsUpperCase(RenameTargets.Any);
driver.TranslationUnitPasses.AddPass(new FunctionToInstanceMethodPass()); driver.Context.TranslationUnitPasses.AddPass(new FunctionToInstanceMethodPass());
} }
public override void Preprocess(Driver driver, ASTContext ctx) public override void Preprocess(Driver driver, ASTContext ctx)

Loading…
Cancel
Save