|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.Linq;
|
| 4 | +using CppSharp; |
4 | 5 | using CppSharp.AST;
|
5 | 6 | using CppSharp.AST.Extensions;
|
6 | 7 | using CppSharp.Generators;
|
@@ -30,11 +31,11 @@ private void OnUnitGenerated(GeneratorOutput generatorOutput)
|
30 | 31 | {
|
31 | 32 | var blocks = (from template in generatorOutput.Templates
|
32 | 33 | from block in template.FindBlocks(CSharpBlockKind.Method)
|
33 |
| - where this.events.Contains(block.Declaration) |
| 34 | + where this.events.Contains(block.Object) |
34 | 35 | select block).ToList();
|
35 | 36 | foreach (var block in blocks)
|
36 | 37 | {
|
37 |
| - var method = (Function) block.Declaration; |
| 38 | + var method = (Function) block.Object; |
38 | 39 | string @event;
|
39 | 40 | if (((Class) method.Namespace).Methods.Any(m => m != method && m.OriginalName == method.OriginalName))
|
40 | 41 | {
|
@@ -81,17 +82,22 @@ public override bool VisitMethodDecl(Method method)
|
81 | 82 | var type = method.Parameters[0].Type;
|
82 | 83 | type = type.GetFinalPointee() ?? type;
|
83 | 84 | Class @class;
|
84 |
| - if (type.TryGetClass(out @class) && @class.Name.EndsWith("Event", StringComparison.Ordinal)) |
| 85 | + if (type.TryGetClass(out @class)) |
85 | 86 | {
|
86 |
| - var name = char.ToUpperInvariant(method.Name[0]) + method.Name.Substring(1); |
87 |
| - method.Name = "on" + name; |
88 |
| - Method baseMethod; |
89 |
| - if (!method.IsOverride || |
90 |
| - (baseMethod = ((Class) method.Namespace).GetBaseMethod(method, true, true)) == null || |
91 |
| - baseMethod.IsPure) |
| 87 | + while (@class.BaseClass != null) |
| 88 | + @class = @class.BaseClass; |
| 89 | + if (@class.OriginalName == "QEvent") |
92 | 90 | {
|
93 |
| - this.events.Add(method); |
94 |
| - this.Context.Options.ExplicitlyPatchedVirtualFunctions.Add(method.QualifiedOriginalName); |
| 91 | + var name = char.ToUpperInvariant(method.Name[0]) + method.Name.Substring(1); |
| 92 | + method.Name = "on" + name; |
| 93 | + Method baseMethod; |
| 94 | + if (!method.IsOverride || |
| 95 | + (baseMethod = ((Class) method.Namespace).GetBaseMethod(method, true, true)) == null || |
| 96 | + baseMethod.IsPure) |
| 97 | + { |
| 98 | + this.events.Add(method); |
| 99 | + this.Context.Options.ExplicitlyPatchedVirtualFunctions.Add(method.QualifiedOriginalName); |
| 100 | + } |
95 | 101 | }
|
96 | 102 | }
|
97 | 103 | }
|
|
0 commit comments