From 4fdee9a0d5ae4404e937c1d988865618b4d18968 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Thu, 16 Feb 2017 02:17:46 +0000 Subject: [PATCH] Convert event handling in C# generator to visitor model --- src/Generator/Generators/CSharp/CSharpSources.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index 8ece1ebb..432384c4 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -229,7 +229,7 @@ namespace CppSharp.Generators.CSharp @class.Visit(this); foreach (var @event in context.Events) - GenerateEvent(@event); + @event.Visit(this); GenerateNamespaceFunctionsAndVariables(context); @@ -1768,10 +1768,10 @@ namespace CppSharp.Generators.CSharp #region Events - private void GenerateEvent(Event @event) + public override bool VisitEvent(Event @event) { if (!@event.IsGenerated) - return; + return true; PushBlock(CSharpBlockKind.Event, @event); TypePrinter.PushContext(TypePrinterContextKind.Native); @@ -1801,6 +1801,8 @@ namespace CppSharp.Generators.CSharp GenerateEventRaiseWrapper(@event, delegateInstance); PopBlock(NewLineKind.BeforeNextBlock); + + return true; } private void GenerateEventAdd(Event @event, string delegateRaise, string delegateName, string delegateInstance)