diff --git a/CHANGELOG b/CHANGELOG index c564b52e..ca581e4a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +0.7.2 - 18.9.2017 +Added: +- Bindings for the constructors of QImage and QPixmap taking arrays; +- Bindings for QGraphicsScene::drawItems, QGraphicsView::drawItems and QAbstractVideoBuffer::mapPlanes. + 0.7.1 - 10.2.2017 Fixed: - Crashes when calling certain constructors and destructors. diff --git a/QtSharp.CLI/QtSharp.CLI.csproj b/QtSharp.CLI/QtSharp.CLI.csproj index b0e7b505..a8ddd595 100644 --- a/QtSharp.CLI/QtSharp.CLI.csproj +++ b/QtSharp.CLI/QtSharp.CLI.csproj @@ -63,28 +63,22 @@ - ..\packages\CppSharp.0.8.13\lib\CppSharp.dll - True + ..\packages\CppSharp.0.8.14\lib\CppSharp.dll - ..\packages\CppSharp.0.8.13\lib\CppSharp.AST.dll - True + ..\packages\CppSharp.0.8.14\lib\CppSharp.AST.dll - ..\packages\CppSharp.0.8.13\lib\CppSharp.Generator.dll - True + ..\packages\CppSharp.0.8.14\lib\CppSharp.Generator.dll - ..\packages\CppSharp.0.8.13\lib\CppSharp.Parser.dll - True + ..\packages\CppSharp.0.8.14\lib\CppSharp.Parser.dll - - ..\packages\CppSharp.0.8.13\lib\CppSharp.Parser.CSharp.dll - True + + ..\packages\CppSharp.0.8.14\lib\CppSharp.Parser.CLI.dll - ..\packages\CppSharp.0.8.13\lib\CppSharp.Runtime.dll - True + ..\packages\CppSharp.0.8.14\lib\CppSharp.Runtime.dll ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll diff --git a/QtSharp.CLI/packages.config b/QtSharp.CLI/packages.config index c0b5d2f1..9e2f97f9 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/DocGeneration/Documentation.cs b/QtSharp/DocGeneration/Documentation.cs index fb8eb73f..395bf447 100644 --- a/QtSharp/DocGeneration/Documentation.cs +++ b/QtSharp/DocGeneration/Documentation.cs @@ -252,14 +252,19 @@ private void CollectTypesDocumentation(HtmlNode documentRoot, string docFile) public void DocumentFunction(Function function) { - if (!this.functionNodes.ContainsKey(function.OriginalName)) + var nodeKey = function.OriginalName; + if (function.IsDependent && !function.IsOperator && nodeKey.Contains('<')) + { + nodeKey = nodeKey.Substring(0, nodeKey.IndexOf('<')); + } + if (!this.functionNodes.ContainsKey(nodeKey)) { return; } var lineStart = function.LineNumberStart; var lineEnd = function.LineNumberEnd; - var functions = this.functionNodes[function.OriginalName]; + var functions = this.functionNodes[nodeKey]; var unit = function.OriginalNamespace.TranslationUnit; var location = unit.FileName; FunctionDocIndexNode node = null; @@ -313,8 +318,7 @@ public void DocumentFunction(Function function) var i = 0; // HACK: work around https://bugreports.qt.io/browse/QTBUG-53941 if (function.Namespace.Name == "QByteArray" && - ((function.OriginalName == "qCompress" && @params.Count == 2) || - (function.OriginalName == "qUncompress" && @params.Count == 1))) + function.OriginalName == "qCompress" && @params.Count == 2) { docs = this.membersDocumentation[file][key + "-hack"]; } @@ -344,6 +348,14 @@ public void DocumentFunction(Function function) { AddObsoleteAttribute(function); } + var @event = function.Namespace.Events.FirstOrDefault(e => e.OriginalDeclaration == function); + if (@event != null) + { + for (i = 0; i < function.Parameters.Count; i++) + { + @event.Parameters[i].Name = function.Parameters[i].Name; + } + } } } } @@ -451,7 +463,11 @@ public void DocumentProperty(Property property) { if (property.IsOverride) { - comment.BriefText = ((Class) property.Namespace).GetBaseProperty(property).Comment.BriefText; + Property baseProperty = ((Class) property.Namespace).GetBaseProperty(property); + if (baseProperty.Comment != null) + { + comment.BriefText = baseProperty.Comment.BriefText; + } } if (string.IsNullOrEmpty(comment.BriefText)) { @@ -545,7 +561,7 @@ public void DocumentType(Class type) summary.Content.Add(new TextComment { Text = briefText }); type.Comment.FullComment.Blocks.Add(summary); var remarks = new ParagraphComment(); - remarks.Content.AddRange(text.Split('\n').Select(t => new TextComment { Text = t })); + remarks.Content.AddRange(text.Split('\n').Select(t => new TextComment { Text = t, HasTrailingNewline = true })); type.Comment.FullComment.Blocks.Add(remarks); } } diff --git a/QtSharp/GenerateEventEventsPass.cs b/QtSharp/GenerateEventEventsPass.cs index b41a3c52..15ca8d4e 100644 --- a/QtSharp/GenerateEventEventsPass.cs +++ b/QtSharp/GenerateEventEventsPass.cs @@ -90,10 +90,7 @@ public override bool VisitMethodDecl(Method method) { 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) + if (!method.IsOverride || method.BaseMethod.IsPure) { this.events.Add(method); this.Context.Options.ExplicitlyPatchedVirtualFunctions.Add(method.QualifiedOriginalName); diff --git a/QtSharp/GenerateSignalEventsPass.cs b/QtSharp/GenerateSignalEventsPass.cs index c6b610e3..802b49a1 100644 --- a/QtSharp/GenerateSignalEventsPass.cs +++ b/QtSharp/GenerateSignalEventsPass.cs @@ -108,14 +108,14 @@ from e in @event.Parameters } block.WriteLine(string.Format(@"public event {0} {1} {{ - add - {{ + add + {{ ConnectDynamicSlot(this, ""{2}"", value); - }} - remove - {{ + }} + remove + {{ DisconnectDynamicSlot(this, ""{2}"", value); - }} + }} }}", fullNameBuilder, finalName, signature)); } } @@ -184,9 +184,10 @@ private void HandleQSignal(Class @class, Method method) Name = method.Name, OriginalName = method.OriginalName, Namespace = method.Namespace, - QualifiedType = new QualifiedType(method.FunctionType.Type), - Parameters = method.Parameters + QualifiedType = new QualifiedType(method.FunctionType.Type) }; + @event.Parameters.AddRange(method.Parameters.Select( + p => new Parameter(p) { Namespace = @event })); if (method.IsGenerated) { method.ExplicitlyIgnore(); diff --git a/QtSharp/QFlags.cs b/QtSharp/QFlags.cs index 31dbb10d..d56a727e 100644 --- a/QtSharp/QFlags.cs +++ b/QtSharp/QFlags.cs @@ -50,6 +50,8 @@ public override void CSharpMarshalToManaged(CSharpMarshalContext ctx) } } + public override bool IsIgnored => Type != null ? Type.IsDependent : Declaration.IsDependent; + private static Type GetEnumType(Type mappedType) { var type = mappedType.Desugar(); diff --git a/QtSharp/QString.cs b/QtSharp/QString.cs index c8e04991..df757b4b 100644 --- a/QtSharp/QString.cs +++ b/QtSharp/QString.cs @@ -13,15 +13,15 @@ public override string CSharpSignature(TypePrinterContext ctx) { if (ctx.Kind == TypePrinterContextKind.Native) { - return string.Format("QtCore.QString.{0}{1}", Helpers.InternalStruct, ctx.Type.IsAddress() ? "*" : string.Empty); + return $"QtCore.QString.{Helpers.InternalStruct}{(ctx.Type.IsAddress() ? "*" : string.Empty)}"; } return "string"; } public override void CSharpMarshalToNative(CSharpMarshalContext ctx) { - var type = ctx.Parameter.Type.Desugar(); - var finalType = (type.GetFinalPointee() ?? type).Desugar(); + var type = ctx.Parameter.Type.Desugar(false); + var finalType = (type.GetFinalPointee() ?? type).Desugar(false); var substitution = finalType as TemplateParameterSubstitutionType; string param; if (substitution != null) @@ -57,13 +57,13 @@ public override void CSharpMarshalToNative(CSharpMarshalContext ctx) public override void CSharpMarshalToManaged(CSharpMarshalContext ctx) { - var type = ctx.ReturnType.Type.Desugar(); - var finalType = (type.GetFinalPointee() ?? type).Desugar(); - var substitution = finalType as TemplateParameterSubstitutionType; + var type = ctx.ReturnType.Type.Desugar(false); + var finalType = (type.GetFinalPointee() ?? type).Desugar(false); + var templateParameter = finalType as TemplateParameterType; string cast = string.Empty; - if (substitution != null) + if (templateParameter != null) { - cast = $"({substitution.ReplacedParameter.Parameter.Name}) (object) "; + cast = $"({templateParameter.Parameter.Name}) (object) "; } ctx.Return.Write($@"{cast}Marshal.PtrToStringUni(new IntPtr(QtCore.QString.{ Helpers.CreateInstanceIdentifier}({ctx.ReturnVarName}).Utf16))"); diff --git a/QtSharp/QtSharp.cs b/QtSharp/QtSharp.cs index 26af66d8..b00b2e6c 100644 --- a/QtSharp/QtSharp.cs +++ b/QtSharp/QtSharp.cs @@ -92,34 +92,6 @@ where string.IsNullOrEmpty(@enum.Name) { enumeration.Name = "TypeEnum"; } - - // HACK: work around https://github.com/mono/CppSharp/issues/692 - foreach (var name in new[] { "QImage", "QPixmap" }) - { - var @class = lib.FindCompleteClass(name); - var ctorWithArray = @class.Constructors.FirstOrDefault( - c => c.Parameters.Count == 1 && c.Parameters[0].Type.Desugar() is ArrayType); - if (ctorWithArray != null) - { - ctorWithArray.ExplicitlyIgnore(); - } - } - foreach (var name in new[] { "QGraphicsScene", "QGraphicsView" }) - { - var @class = lib.FindCompleteClass(name); - var drawItems = @class.Methods.FirstOrDefault(m => m.OriginalName == "drawItems"); - if (drawItems != null) - { - drawItems.ExplicitlyIgnore(); - } - } - lib.FindCompleteClass("QAbstractPlanarVideoBuffer").ExplicitlyIgnore(); - var qAbstractVideoBuffer = lib.FindCompleteClass("QAbstractVideoBuffer"); - var mapPlanes = qAbstractVideoBuffer.Methods.FirstOrDefault(m => m.OriginalName == "mapPlanes"); - if (mapPlanes != null) - { - mapPlanes.ExplicitlyIgnore(); - } } public void Postprocess(Driver driver, ASTContext lib) @@ -224,6 +196,7 @@ public void Setup(Driver driver) module.Libraries.Add(libFile); if (moduleName == "Core") { + module.Headers.Insert(0, "guiddef.h"); module.CodeFiles.Add(Path.Combine(dir, "QObject.cs")); module.CodeFiles.Add(Path.Combine(dir, "QChar.cs")); module.CodeFiles.Add(Path.Combine(dir, "QEvent.cs")); @@ -243,9 +216,6 @@ public void Setup(Driver driver) driver.ParserOptions.AddIncludeDirs(qtInfo.Headers); driver.ParserOptions.AddLibraryDirs(Platform.IsWindows ? qtInfo.Bins : qtInfo.Libs); - - // Qt defines its own GUID with the same header guard as the system GUID, so ensure the system GUID is read first - driver.Project.AddFile("guiddef.h"); } public static string GetModuleNameFromLibFile(string libFile) @@ -322,21 +292,7 @@ private void CompileMakefile(GenerateSymbolsPass.SymbolsCodeEventArgs e) proBuilder.Append("LIBS += -loleaut32 -lole32"); } File.WriteAllText(path, proBuilder.ToString()); - // HACK: work around https://bugreports.qt.io/browse/QTBUG-55952 - if (e.Module.LibraryName == "Qt3DRender.Sharp") - { - var cpp = Path.ChangeExtension(pro, "cpp"); - var unlinkable = new[] - { - "&Qt3DRender::QSortCriterion::tr;", - "&Qt3DRender::QSortCriterion::trUtf8;", - "&Qt3DRender::qt_getEnumMetaObject;" - }; - var linkable = (from line in File.ReadLines(cpp) - where unlinkable.All(ul => !line.EndsWith(ul, StringComparison.Ordinal)) - select line).ToList(); - File.WriteAllLines(cpp, linkable); - } + int error; string errorMessage; ProcessHelper.Run(this.qtInfo.QMake, $"\"{path}\"", out error, out errorMessage); diff --git a/QtSharp/QtSharp.csproj b/QtSharp/QtSharp.csproj index 739617fd..d90d8827 100644 --- a/QtSharp/QtSharp.csproj +++ b/QtSharp/QtSharp.csproj @@ -38,32 +38,25 @@ - ..\packages\CppSharp.0.8.13\lib\CppSharp.dll - True + ..\packages\CppSharp.0.8.14\lib\CppSharp.dll - ..\packages\CppSharp.0.8.13\lib\CppSharp.AST.dll - True + ..\packages\CppSharp.0.8.14\lib\CppSharp.AST.dll - ..\packages\CppSharp.0.8.13\lib\CppSharp.Generator.dll - True + ..\packages\CppSharp.0.8.14\lib\CppSharp.Generator.dll - ..\packages\CppSharp.0.8.13\lib\CppSharp.Parser.dll - True + ..\packages\CppSharp.0.8.14\lib\CppSharp.Parser.dll - - ..\packages\CppSharp.0.8.13\lib\CppSharp.Parser.CSharp.dll - True + + ..\packages\CppSharp.0.8.14\lib\CppSharp.Parser.CLI.dll - ..\packages\CppSharp.0.8.13\lib\CppSharp.Runtime.dll - True + ..\packages\CppSharp.0.8.14\lib\CppSharp.Runtime.dll - - ..\packages\HtmlAgilityPack.1.5.1\lib\Net45\HtmlAgilityPack.dll - True + + ..\packages\HtmlAgilityPack.1.5.5\lib\Net45\HtmlAgilityPack.dll ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll diff --git a/QtSharp/packages.config b/QtSharp/packages.config index a234daad..c327adf0 100644 --- a/QtSharp/packages.config +++ b/QtSharp/packages.config @@ -1,8 +1,8 @@  - - + + \ No newline at end of file