Skip to content

Commit

Permalink
Added a binding for the QtQml module - just a wrapper, no QML integra…
Browse files Browse the repository at this point in the history
…tion yet.

Signed-off-by: Dimitar Dobrev <[email protected]>
  • Loading branch information
ddobrev committed Nov 19, 2015
1 parent 04ad1cc commit 5e08999
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion QtSharp.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static int Main(string[] args)
dependencies[libFile] = Enumerable.Empty<string>();
}
}
var modules = new List<string> { "Qt5Core", "Qt5Gui", "Qt5Widgets", "Qt5Xml", "Qt5Designer", "Qt5Network" };
var modules = new List<string> { "Qt5Core", "Qt5Gui", "Qt5Widgets", "Qt5Xml", "Qt5Designer", "Qt5Network", "Qt5Qml" };
if (debug)
{
for (var i = 0; i < modules.Count; i++)
Expand Down
16 changes: 6 additions & 10 deletions QtSharp/QString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ public override string CSharpSignature(CSharpTypePrinterContext ctx)
{
if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
{
if (ctx.Type.IsAddress())
{
return "QtCore.QString.Internal*";
}
return "QtCore.QString.Internal";
return ctx.Type.IsAddress() ? "QtCore.QString.Internal*" : "QtCore.QString.Internal";
}
return "string";
}
Expand All @@ -28,7 +24,7 @@ public override void CSharpMarshalToNative(MarshalContext ctx)
ctx.ParameterIndex, ctx.Parameter.Name);
ctx.SupportBefore.WriteLine("var __qstring{0} = QtCore.QString.FromUtf16(ref *__stringPtr{0}, {1}.Length);",
ctx.ParameterIndex, ctx.Parameter.Name);
Type type = ctx.Parameter.Type.Desugar();
var type = ctx.Parameter.Type.Desugar();
if (type.IsAddress())
{
ctx.Return.Write("ReferenceEquals(__qstring{0}, null) ? global::System.IntPtr.Zero : __qstring{0}.{1}",
Expand All @@ -39,10 +35,10 @@ public override void CSharpMarshalToNative(MarshalContext ctx)
type.TryGetClass(out @class);
if (@class == null)
{
Type.TryGetClass(out @class);
this.Type.TryGetClass(out @class);
}
typePrinter = typePrinter ?? (typePrinter = new CSharpTypePrinter(ctx.Driver));
var qualifiedIdentifier = (@class.OriginalClass ?? @class).Visit(typePrinter);
this.typePrinter = this.typePrinter ?? (this.typePrinter = new CSharpTypePrinter(ctx.Driver));
var qualifiedIdentifier = (@class.OriginalClass ?? @class).Visit(this.typePrinter);
ctx.Return.Write("ReferenceEquals(__qstring{0}, null) ? new {1}.Internal() : *({1}.Internal*) (__qstring{0}.{2})",
ctx.ParameterIndex, qualifiedIdentifier, Helpers.InstanceIdentifier);
}
Expand All @@ -53,6 +49,6 @@ public override void CSharpMarshalToManaged(MarshalContext ctx)
Helpers.CreateInstanceIdentifier, ctx.ReturnVarName);
}

CSharpTypePrinter typePrinter;
private CSharpTypePrinter typePrinter;
}
}

0 comments on commit 5e08999

Please sign in to comment.