Skip to content

Commit

Permalink
Updated to the latest C++# to take advantage of the improved inlines.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddobrev committed Feb 5, 2017
1 parent 12a701c commit 887a8c3
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 36 deletions.
3 changes: 2 additions & 1 deletion QtSharp.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using CppSharp;

Expand Down Expand Up @@ -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);

Expand Down
12 changes: 6 additions & 6 deletions QtSharp.CLI/QtSharp.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,27 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="CppSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.AST, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.AST.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.AST.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.Generator, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Generator.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Generator.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.Parser, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.Parser.CLI, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.CLI.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.CLI.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.Runtime, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Runtime.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
Expand Down
2 changes: 1 addition & 1 deletion QtSharp.CLI/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Baseclass.Contrib.Nuget.Output" version="2.1.0" targetFramework="net451" />
<package id="CppSharp" version="0.8.1" targetFramework="net461" developmentDependency="true" />
<package id="CppSharp" version="0.8.3" targetFramework="net461" developmentDependency="true" />
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net461" />
</packages>
28 changes: 17 additions & 11 deletions QtSharp/GenerateEventEventsPass.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions QtSharp/GenerateSignalEventsPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -176,15 +177,14 @@ private void HandleQSignal(Class @class, Method method)
method.Parameters.RemoveAt(method.Parameters.Count - 1);
}
}
var functionType = method.GetFunctionType();

var @event = new Event
{
OriginalDeclaration = 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)
Expand Down
12 changes: 6 additions & 6 deletions QtSharp/QtSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="CppSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.AST, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.AST.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.AST.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.Generator, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Generator.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Generator.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.Parser, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.Parser.CLI, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Parser.CLI.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Parser.CLI.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.Runtime, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.8.1\lib\CppSharp.Runtime.dll</HintPath>
<HintPath>..\packages\CppSharp.0.8.3\lib\CppSharp.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.4.9.5, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
Expand Down
4 changes: 2 additions & 2 deletions QtSharp/RemoveQObjectMembersPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion QtSharp/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Baseclass.Contrib.Nuget.Output" version="2.1.0" targetFramework="net451" />
<package id="CppSharp" version="0.8.1" targetFramework="net461" developmentDependency="true" />
<package id="CppSharp" version="0.8.3" targetFramework="net461" developmentDependency="true" />
<package id="HtmlAgilityPack" version="1.4.9.5" targetFramework="net451" />
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net461" />
<package id="zlib.net" version="1.0.4" targetFramework="net451" />
Expand Down

0 comments on commit 887a8c3

Please sign in to comment.