diff --git a/src/Generator.Tests/Passes/TestPasses.cs b/src/Generator.Tests/Passes/TestPasses.cs index 6eb251d5..63a7cb74 100644 --- a/src/Generator.Tests/Passes/TestPasses.cs +++ b/src/Generator.Tests/Passes/TestPasses.cs @@ -18,6 +18,20 @@ namespace CppSharp.Generator.Tests.Passes passBuilder = new PassBuilder(Driver.Context); } + [Test] + public void TestExtractInterfacePass() + { + var c = AstContext.Class("TestExtractInterfacePass"); + + Assert.IsNull(c.GetInterface()); + + passBuilder.AddPass(new ExtractInterfacePass()); + passBuilder.RunPasses(pass => pass.VisitASTContext(AstContext)); + + Assert.IsNotNull(c.GetInterface()); + Assert.AreEqual("ITestExtractInterfacePass", c.GetInterface().Name); + } + [Test] public void TestCheckFlagEnumsPass() { diff --git a/src/Generator/Passes/ExtractInterfacePass.cs b/src/Generator/Passes/ExtractInterfacePass.cs index 18c1271e..c23f5a88 100644 --- a/src/Generator/Passes/ExtractInterfacePass.cs +++ b/src/Generator/Passes/ExtractInterfacePass.cs @@ -9,15 +9,12 @@ namespace CppSharp.Passes public class ExtractInterfacePass : TranslationUnitPass { /// - /// Collects all interfaces in a unit to be added at the end - /// because the unit cannot be changed while it's being iterated though. - /// We also need it to check if a class already has a complementary interface - /// because different classes may have the same secondary bases. + /// Creates interface from generated classes /// private readonly HashSet interfaces = new HashSet(); /// - /// Change and implement secondary bases at the end to avoid processing implementations. + /// Classes that require interfaces to be created /// private readonly HashSet classesNeedingInterface = new HashSet(); @@ -56,7 +53,6 @@ namespace CppSharp.Passes } classesNeedingInterface.Add(@class); - Console.WriteLine(@class.Name); GetInterface(@class); return true; } diff --git a/tests/Native/Passes.h b/tests/Native/Passes.h index c7687806..0cf2579e 100644 --- a/tests/Native/Passes.h +++ b/tests/Native/Passes.h @@ -105,3 +105,9 @@ protected: int Protected; }; }; + +class TestExtractInterfacePass +{ +public: + void DoSomething(); +};