Skip to content

Commit 887a8c3

Browse files
committed
Updated to the latest C++# to take advantage of the improved inlines.
1 parent 12a701c commit 887a8c3

File tree

8 files changed

+43
-36
lines changed

8 files changed

+43
-36
lines changed

QtSharp.CLI/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.IO.Compression;
66
using System.Linq;
7+
using System.Reflection;
78
using System.Text.RegularExpressions;
89
using CppSharp;
910

@@ -138,7 +139,7 @@ static bool QueryQt(QtInfo qt, bool debug)
138139
.Select(s => s.Trim()).ToList();
139140

140141
const string frameworkDirectory = "(framework directory)";
141-
142+
includeDirs.Insert(0, Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "include"));
142143
qt.SystemIncludeDirs = includeDirs.Where(s => !s.Contains(frameworkDirectory))
143144
.Select(Path.GetFullPath);
144145

QtSharp.CLI/QtSharp.CLI.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,27 @@
6363
</PropertyGroup>
6464
<ItemGroup>
6565
<Reference Include="CppSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
66-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.dll</HintPath>
66+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.dll</HintPath>
6767
<Private>True</Private>
6868
</Reference>
6969
<Reference Include="CppSharp.AST, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
70-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.AST.dll</HintPath>
70+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.AST.dll</HintPath>
7171
<Private>True</Private>
7272
</Reference>
7373
<Reference Include="CppSharp.Generator, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
74-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Generator.dll</HintPath>
74+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Generator.dll</HintPath>
7575
<Private>True</Private>
7676
</Reference>
7777
<Reference Include="CppSharp.Parser, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
78-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.dll</HintPath>
78+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.dll</HintPath>
7979
<Private>True</Private>
8080
</Reference>
8181
<Reference Include="CppSharp.Parser.CLI, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
82-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.CLI.dll</HintPath>
82+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.CLI.dll</HintPath>
8383
<Private>True</Private>
8484
</Reference>
8585
<Reference Include="CppSharp.Runtime, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
86-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Runtime.dll</HintPath>
86+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Runtime.dll</HintPath>
8787
<Private>True</Private>
8888
</Reference>
8989
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">

QtSharp.CLI/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Baseclass.Contrib.Nuget.Output" version="2.1.0" targetFramework="net451" />
4-
<package id="CppSharp" version="0.8.1" targetFramework="net461" developmentDependency="true" />
4+
<package id="CppSharp" version="0.8.3" targetFramework="net461" developmentDependency="true" />
55
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net461" />
66
</packages>

QtSharp/GenerateEventEventsPass.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using CppSharp;
45
using CppSharp.AST;
56
using CppSharp.AST.Extensions;
67
using CppSharp.Generators;
@@ -30,11 +31,11 @@ private void OnUnitGenerated(GeneratorOutput generatorOutput)
3031
{
3132
var blocks = (from template in generatorOutput.Templates
3233
from block in template.FindBlocks(CSharpBlockKind.Method)
33-
where this.events.Contains(block.Declaration)
34+
where this.events.Contains(block.Object)
3435
select block).ToList();
3536
foreach (var block in blocks)
3637
{
37-
var method = (Function) block.Declaration;
38+
var method = (Function) block.Object;
3839
string @event;
3940
if (((Class) method.Namespace).Methods.Any(m => m != method && m.OriginalName == method.OriginalName))
4041
{
@@ -81,17 +82,22 @@ public override bool VisitMethodDecl(Method method)
8182
var type = method.Parameters[0].Type;
8283
type = type.GetFinalPointee() ?? type;
8384
Class @class;
84-
if (type.TryGetClass(out @class) && @class.Name.EndsWith("Event", StringComparison.Ordinal))
85+
if (type.TryGetClass(out @class))
8586
{
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")
9290
{
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+
}
95101
}
96102
}
97103
}

QtSharp/GenerateSignalEventsPass.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ private void OnUnitGenerated(GeneratorOutput generatorOutput)
3939

4040
private void GenerateSignalEvents(GeneratorOutput generatorOutput)
4141
{
42-
foreach (Block block in from template in generatorOutput.Templates
43-
from block in template.FindBlocks(CSharpBlockKind.Event)
44-
select block)
42+
foreach (var block in from template in generatorOutput.Templates
43+
from block in template.FindBlocks(CSharpBlockKind.Event)
44+
select block)
4545
{
46-
Event @event = (Event) block.Declaration;
46+
Event @event = (Event) block.Object;
4747
if (this.events.Contains(@event))
4848
{
4949
block.Text.StringBuilder.Clear();
@@ -121,8 +121,9 @@ from e in @event.Parameters
121121
var qtMetacall = (
122122
from template in generatorOutput.Templates
123123
from block in template.FindBlocks(CSharpBlockKind.Method)
124-
where block.Declaration != null && block.Declaration.Name == "QtMetacall" &&
125-
block.Declaration.Namespace.Name == "QObject"
124+
let declaration = block.Object as Declaration
125+
where declaration != null && declaration.Name == "QtMetacall" &&
126+
declaration.Namespace.Name == "QObject"
126127
select block).FirstOrDefault();
127128
if (qtMetacall != null)
128129
{
@@ -176,15 +177,14 @@ private void HandleQSignal(Class @class, Method method)
176177
method.Parameters.RemoveAt(method.Parameters.Count - 1);
177178
}
178179
}
179-
var functionType = method.GetFunctionType();
180180

181181
var @event = new Event
182182
{
183183
OriginalDeclaration = method,
184184
Name = method.Name,
185185
OriginalName = method.OriginalName,
186186
Namespace = method.Namespace,
187-
QualifiedType = new QualifiedType(functionType),
187+
QualifiedType = new QualifiedType(method.FunctionType.Type),
188188
Parameters = method.Parameters
189189
};
190190
if (method.IsGenerated)

QtSharp/QtSharp.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,27 @@
3838
</PropertyGroup>
3939
<ItemGroup>
4040
<Reference Include="CppSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
41-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.dll</HintPath>
41+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.dll</HintPath>
4242
<Private>True</Private>
4343
</Reference>
4444
<Reference Include="CppSharp.AST, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
45-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.AST.dll</HintPath>
45+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.AST.dll</HintPath>
4646
<Private>True</Private>
4747
</Reference>
4848
<Reference Include="CppSharp.Generator, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
49-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Generator.dll</HintPath>
49+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Generator.dll</HintPath>
5050
<Private>True</Private>
5151
</Reference>
5252
<Reference Include="CppSharp.Parser, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
53-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.dll</HintPath>
53+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.dll</HintPath>
5454
<Private>True</Private>
5555
</Reference>
5656
<Reference Include="CppSharp.Parser.CLI, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
57-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.CLI.dll</HintPath>
57+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.CLI.dll</HintPath>
5858
<Private>True</Private>
5959
</Reference>
6060
<Reference Include="CppSharp.Runtime, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
61-
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Runtime.dll</HintPath>
61+
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Runtime.dll</HintPath>
6262
<Private>True</Private>
6363
</Reference>
6464
<Reference Include="HtmlAgilityPack, Version=1.4.9.5, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">

QtSharp/RemoveQObjectMembersPass.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ private static void RemoveQObjectMembers(Class @class)
3939

4040
private static void RemoveMethodOverloads(Class @class, string originalName)
4141
{
42-
var overloads = @class.FindMethodByOriginalName(originalName).ToList();
42+
var overloads = @class.Methods.Where(m => m.OriginalName == originalName).ToList();
4343
foreach (var method in overloads)
4444
@class.Methods.Remove(method);
4545
}
4646

4747
private static void RemoveVariables(Class @class, string originalName)
4848
{
49-
var variables = @class.FindVariableByOriginalName(originalName).ToList();
49+
var variables = @class.Variables.Where(v => v.OriginalName == originalName).ToList();
5050
foreach (var variable in variables)
5151
variable.ExplicitlyIgnore();
5252
}

QtSharp/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Baseclass.Contrib.Nuget.Output" version="2.1.0" targetFramework="net451" />
4-
<package id="CppSharp" version="0.8.1" targetFramework="net461" developmentDependency="true" />
4+
<package id="CppSharp" version="0.8.3" targetFramework="net461" developmentDependency="true" />
55
<package id="HtmlAgilityPack" version="1.4.9.5" targetFramework="net451" />
66
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net461" />
77
<package id="zlib.net" version="1.0.4" targetFramework="net451" />

0 commit comments

Comments
 (0)