Skip to content

Commit

Permalink
Updated C++# in order not to manually ignore functions which use exte…
Browse files Browse the repository at this point in the history
…rnal types.

Signed-off-by: Dimitar Dobrev <[email protected]>
  • Loading branch information
ddobrev committed Nov 17, 2016
1 parent c8118c3 commit b9a9295
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 67 deletions.
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.7.9\lib\CppSharp.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\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.7.9\lib\CppSharp.AST.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\lib\CppSharp.AST.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.Generator, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.7.9\lib\CppSharp.Generator.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\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.7.9\lib\CppSharp.Parser.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\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.7.9\lib\CppSharp.Parser.CLI.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\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.7.9\lib\CppSharp.Runtime.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\lib\CppSharp.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion QtSharp.CLI/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?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.7.9" targetFramework="net451" developmentDependency="true" />
<package id="CppSharp" version="0.7.12" targetFramework="net451" developmentDependency="true" />
</packages>
9 changes: 5 additions & 4 deletions QtSharp/GenerateSignalEventsPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ public override bool VisitClassDecl(Class @class)
{
return false;
}
foreach (var method in from method in @class.Methods
where method.Access != AccessSpecifier.Private
select method)
Declaration decl;
foreach (var method in @class.Methods.Where(m => m.IsGenerated ||
(m.Parameters.Any() && m.Parameters.Last().Type.Desugar().TryGetDeclaration(out decl) &&
decl.OriginalName == "QPrivateSignal")))
{
this.HandleQSignal(@class, method);
}
Expand All @@ -170,7 +171,7 @@ private void HandleQSignal(Class @class, Method method)
if (method.Parameters.Any())
{
Class decl;
if (method.Parameters.Last().Type.TryGetClass(out decl) && decl.Name == "QPrivateSignal")
if (method.Parameters.Last().Type.Desugar().TryGetClass(out decl) && decl.Name == "QPrivateSignal")
{
method.Parameters.RemoveAt(method.Parameters.Count - 1);
}
Expand Down
50 changes: 1 addition & 49 deletions QtSharp/QtSharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,54 +57,6 @@ public void Preprocess(Driver driver, ASTContext lib)
method.ExplicitlyIgnore();
}

// HACK: work around https://github.com/mono/CppSharp/issues/657
var qSignalMapper = lib.FindCompleteClass("QSignalMapper");
for (int i = qSignalMapper.Methods.Count - 1; i >= 0; i--)
{
Class @class;
var method = qSignalMapper.Methods[i];
if (method.Parameters.Count > 0)
{
var type = method.Parameters.Last().Type;
var finalType = type.GetFinalPointee() ?? type;
if (finalType.TryGetClass(out @class) &&
@class.TranslationUnit.Module.OutputNamespace == "QtWidgets")
{
if (method.Name == "mapped")
{
qSignalMapper.Methods.RemoveAt(i);
}
else
{
method.ExplicitlyIgnore();
}
}
}
}
var qActionEvent = lib.FindCompleteClass("QActionEvent");
foreach (var method in qActionEvent.Methods)
{
if ((method.Name == "QActionEvent" && method.Parameters.Count == 3) ||
method.Name == "action" || method.Name == "before")
{
method.ExplicitlyIgnore();
}
}
var qCamera = lib.FindClass("QCamera").FirstOrDefault(c => !c.IsIncomplete &&
c.TranslationUnit.Module.OutputNamespace == "QtMultimedia");
var qMediaPlayer = lib.FindCompleteClass("QMediaPlayer");
foreach (var method in qCamera.Methods.Union(qMediaPlayer.Methods).Where(m => m.Parameters.Any()))
{
Class @class;
var type = method.Parameters.Last().Type;
var finalType = type.GetFinalPointee() ?? type;
if (finalType.TryGetClass(out @class) &&
@class.TranslationUnit.Module.OutputNamespace == "QtMultimediaWidgets")
{
method.ExplicitlyIgnore();
}
}

// HACK: work around https://github.com/mono/CppSharp/issues/594
lib.FindCompleteClass("QGraphicsItem").FindEnum("Extension").Access = AccessSpecifier.Public;
lib.FindCompleteClass("QAbstractSlider").FindEnum("SliderChange").Access = AccessSpecifier.Public;
Expand Down Expand Up @@ -140,7 +92,7 @@ where string.IsNullOrEmpty(@enum.Name)
foreach (var name in new[] { "QGraphicsScene", "QGraphicsView" })
{
var @class = lib.FindCompleteClass(name);
var drawItems = @class.Methods.FirstOrDefault(m => m.OriginalName == "drawItems");
var drawItems = @class.Methods.FirstOrDefault(m => m.OriginalName == "drawItems");
if (drawItems != null)
{
drawItems.ExplicitlyIgnore();
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.7.9\lib\CppSharp.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\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.7.9\lib\CppSharp.AST.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\lib\CppSharp.AST.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CppSharp.Generator, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CppSharp.0.7.9\lib\CppSharp.Generator.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\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.7.9\lib\CppSharp.Parser.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\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.7.9\lib\CppSharp.Parser.CLI.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\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.7.9\lib\CppSharp.Runtime.dll</HintPath>
<HintPath>..\packages\CppSharp.0.7.12\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
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.7.9" targetFramework="net451" developmentDependency="true" />
<package id="CppSharp" version="0.7.12" targetFramework="net451" developmentDependency="true" />
<package id="HtmlAgilityPack" version="1.4.9.5" targetFramework="net451" />
<package id="zlib.net" version="1.0.4" targetFramework="net451" />
</packages>

0 comments on commit b9a9295

Please sign in to comment.