From 887a8c31fa979a22c2b4d608b6e23d7ddc23e4a1 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sun, 5 Feb 2017 03:04:41 +0200 Subject: [PATCH] Updated to the latest C++# to take advantage of the improved inlines. --- QtSharp.CLI/Program.cs | 3 ++- QtSharp.CLI/QtSharp.CLI.csproj | 12 ++++++------ QtSharp.CLI/packages.config | 2 +- QtSharp/GenerateEventEventsPass.cs | 28 +++++++++++++++++----------- QtSharp/GenerateSignalEventsPass.cs | 16 ++++++++-------- QtSharp/QtSharp.csproj | 12 ++++++------ QtSharp/RemoveQObjectMembersPass.cs | 4 ++-- QtSharp/packages.config | 2 +- 8 files changed, 43 insertions(+), 36 deletions(-) diff --git a/QtSharp.CLI/Program.cs b/QtSharp.CLI/Program.cs index 0df62618..1e058fd1 100644 --- a/QtSharp.CLI/Program.cs +++ b/QtSharp.CLI/Program.cs @@ -4,6 +4,7 @@ using System.IO; using System.IO.Compression; using System.Linq; +using System.Reflection; using System.Text.RegularExpressions; using CppSharp; @@ -138,7 +139,7 @@ static bool QueryQt(QtInfo qt, bool debug) .Select(s => s.Trim()).ToList(); const string frameworkDirectory = "(framework directory)"; - + includeDirs.Insert(0, Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "include")); qt.SystemIncludeDirs = includeDirs.Where(s => !s.Contains(frameworkDirectory)) .Select(Path.GetFullPath); diff --git a/QtSharp.CLI/QtSharp.CLI.csproj b/QtSharp.CLI/QtSharp.CLI.csproj index cec2c560..b1a715d0 100644 --- a/QtSharp.CLI/QtSharp.CLI.csproj +++ b/QtSharp.CLI/QtSharp.CLI.csproj @@ -63,27 +63,27 @@ - ..\packages\CppSharp.0.8.1\lib\CppSharp.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.dll True - ..\packages\CppSharp.0.8.1\lib\CppSharp.AST.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.AST.dll True - ..\packages\CppSharp.0.8.1\lib\CppSharp.Generator.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.Generator.dll True - ..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.dll True - ..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.CLI.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.CLI.dll True - ..\packages\CppSharp.0.8.1\lib\CppSharp.Runtime.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.Runtime.dll True diff --git a/QtSharp.CLI/packages.config b/QtSharp.CLI/packages.config index eda68ec6..6e343237 100644 --- a/QtSharp.CLI/packages.config +++ b/QtSharp.CLI/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/QtSharp/GenerateEventEventsPass.cs b/QtSharp/GenerateEventEventsPass.cs index 62e0780f..45c67eb9 100644 --- a/QtSharp/GenerateEventEventsPass.cs +++ b/QtSharp/GenerateEventEventsPass.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using CppSharp; using CppSharp.AST; using CppSharp.AST.Extensions; using CppSharp.Generators; @@ -30,11 +31,11 @@ private void OnUnitGenerated(GeneratorOutput generatorOutput) { var blocks = (from template in generatorOutput.Templates from block in template.FindBlocks(CSharpBlockKind.Method) - where this.events.Contains(block.Declaration) + where this.events.Contains(block.Object) select block).ToList(); foreach (var block in blocks) { - var method = (Function) block.Declaration; + var method = (Function) block.Object; string @event; if (((Class) method.Namespace).Methods.Any(m => m != method && m.OriginalName == method.OriginalName)) { @@ -81,17 +82,22 @@ public override bool VisitMethodDecl(Method method) var type = method.Parameters[0].Type; type = type.GetFinalPointee() ?? type; Class @class; - if (type.TryGetClass(out @class) && @class.Name.EndsWith("Event", StringComparison.Ordinal)) + if (type.TryGetClass(out @class)) { - var name = char.ToUpperInvariant(method.Name[0]) + method.Name.Substring(1); - method.Name = "on" + name; - Method baseMethod; - if (!method.IsOverride || - (baseMethod = ((Class) method.Namespace).GetBaseMethod(method, true, true)) == null || - baseMethod.IsPure) + while (@class.BaseClass != null) + @class = @class.BaseClass; + if (@class.OriginalName == "QEvent") { - this.events.Add(method); - this.Context.Options.ExplicitlyPatchedVirtualFunctions.Add(method.QualifiedOriginalName); + var name = char.ToUpperInvariant(method.Name[0]) + method.Name.Substring(1); + method.Name = "on" + name; + Method baseMethod; + if (!method.IsOverride || + (baseMethod = ((Class) method.Namespace).GetBaseMethod(method, true, true)) == null || + baseMethod.IsPure) + { + this.events.Add(method); + this.Context.Options.ExplicitlyPatchedVirtualFunctions.Add(method.QualifiedOriginalName); + } } } } diff --git a/QtSharp/GenerateSignalEventsPass.cs b/QtSharp/GenerateSignalEventsPass.cs index f213ab0b..7f1f5ee0 100644 --- a/QtSharp/GenerateSignalEventsPass.cs +++ b/QtSharp/GenerateSignalEventsPass.cs @@ -39,11 +39,11 @@ private void OnUnitGenerated(GeneratorOutput generatorOutput) private void GenerateSignalEvents(GeneratorOutput generatorOutput) { - foreach (Block block in from template in generatorOutput.Templates - from block in template.FindBlocks(CSharpBlockKind.Event) - select block) + foreach (var block in from template in generatorOutput.Templates + from block in template.FindBlocks(CSharpBlockKind.Event) + select block) { - Event @event = (Event) block.Declaration; + Event @event = (Event) block.Object; if (this.events.Contains(@event)) { block.Text.StringBuilder.Clear(); @@ -121,8 +121,9 @@ from e in @event.Parameters var qtMetacall = ( from template in generatorOutput.Templates from block in template.FindBlocks(CSharpBlockKind.Method) - where block.Declaration != null && block.Declaration.Name == "QtMetacall" && - block.Declaration.Namespace.Name == "QObject" + let declaration = block.Object as Declaration + where declaration != null && declaration.Name == "QtMetacall" && + declaration.Namespace.Name == "QObject" select block).FirstOrDefault(); if (qtMetacall != null) { @@ -176,7 +177,6 @@ private void HandleQSignal(Class @class, Method method) method.Parameters.RemoveAt(method.Parameters.Count - 1); } } - var functionType = method.GetFunctionType(); var @event = new Event { @@ -184,7 +184,7 @@ private void HandleQSignal(Class @class, Method method) Name = method.Name, OriginalName = method.OriginalName, Namespace = method.Namespace, - QualifiedType = new QualifiedType(functionType), + QualifiedType = new QualifiedType(method.FunctionType.Type), Parameters = method.Parameters }; if (method.IsGenerated) diff --git a/QtSharp/QtSharp.csproj b/QtSharp/QtSharp.csproj index bfd7643c..e6863084 100644 --- a/QtSharp/QtSharp.csproj +++ b/QtSharp/QtSharp.csproj @@ -38,27 +38,27 @@ - ..\packages\CppSharp.0.8.1\lib\CppSharp.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.dll True - ..\packages\CppSharp.0.8.1\lib\CppSharp.AST.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.AST.dll True - ..\packages\CppSharp.0.8.1\lib\CppSharp.Generator.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.Generator.dll True - ..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.dll True - ..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.CLI.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.CLI.dll True - ..\packages\CppSharp.0.8.1\lib\CppSharp.Runtime.dll + ..\packages\CppSharp.0.8.3\lib\CppSharp.Runtime.dll True diff --git a/QtSharp/RemoveQObjectMembersPass.cs b/QtSharp/RemoveQObjectMembersPass.cs index 8502c7c3..88028dd7 100644 --- a/QtSharp/RemoveQObjectMembersPass.cs +++ b/QtSharp/RemoveQObjectMembersPass.cs @@ -39,14 +39,14 @@ private static void RemoveQObjectMembers(Class @class) private static void RemoveMethodOverloads(Class @class, string originalName) { - var overloads = @class.FindMethodByOriginalName(originalName).ToList(); + var overloads = @class.Methods.Where(m => m.OriginalName == originalName).ToList(); foreach (var method in overloads) @class.Methods.Remove(method); } private static void RemoveVariables(Class @class, string originalName) { - var variables = @class.FindVariableByOriginalName(originalName).ToList(); + var variables = @class.Variables.Where(v => v.OriginalName == originalName).ToList(); foreach (var variable in variables) variable.ExplicitlyIgnore(); } diff --git a/QtSharp/packages.config b/QtSharp/packages.config index 4a4e2589..a46bf662 100644 --- a/QtSharp/packages.config +++ b/QtSharp/packages.config @@ -1,7 +1,7 @@  - +