Skip to content

Commit 5e08999

Browse files
committed
Added a binding for the QtQml module - just a wrapper, no QML integration yet.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 04ad1cc commit 5e08999

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

QtSharp.CLI/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static int Main(string[] args)
9595
dependencies[libFile] = Enumerable.Empty<string>();
9696
}
9797
}
98-
var modules = new List<string> { "Qt5Core", "Qt5Gui", "Qt5Widgets", "Qt5Xml", "Qt5Designer", "Qt5Network" };
98+
var modules = new List<string> { "Qt5Core", "Qt5Gui", "Qt5Widgets", "Qt5Xml", "Qt5Designer", "Qt5Network", "Qt5Qml" };
9999
if (debug)
100100
{
101101
for (var i = 0; i < modules.Count; i++)

QtSharp/QString.cs

+6-10
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ public override string CSharpSignature(CSharpTypePrinterContext ctx)
1313
{
1414
if (ctx.CSharpKind == CSharpTypePrinterContextKind.Native)
1515
{
16-
if (ctx.Type.IsAddress())
17-
{
18-
return "QtCore.QString.Internal*";
19-
}
20-
return "QtCore.QString.Internal";
16+
return ctx.Type.IsAddress() ? "QtCore.QString.Internal*" : "QtCore.QString.Internal";
2117
}
2218
return "string";
2319
}
@@ -28,7 +24,7 @@ public override void CSharpMarshalToNative(MarshalContext ctx)
2824
ctx.ParameterIndex, ctx.Parameter.Name);
2925
ctx.SupportBefore.WriteLine("var __qstring{0} = QtCore.QString.FromUtf16(ref *__stringPtr{0}, {1}.Length);",
3026
ctx.ParameterIndex, ctx.Parameter.Name);
31-
Type type = ctx.Parameter.Type.Desugar();
27+
var type = ctx.Parameter.Type.Desugar();
3228
if (type.IsAddress())
3329
{
3430
ctx.Return.Write("ReferenceEquals(__qstring{0}, null) ? global::System.IntPtr.Zero : __qstring{0}.{1}",
@@ -39,10 +35,10 @@ public override void CSharpMarshalToNative(MarshalContext ctx)
3935
type.TryGetClass(out @class);
4036
if (@class == null)
4137
{
42-
Type.TryGetClass(out @class);
38+
this.Type.TryGetClass(out @class);
4339
}
44-
typePrinter = typePrinter ?? (typePrinter = new CSharpTypePrinter(ctx.Driver));
45-
var qualifiedIdentifier = (@class.OriginalClass ?? @class).Visit(typePrinter);
40+
this.typePrinter = this.typePrinter ?? (this.typePrinter = new CSharpTypePrinter(ctx.Driver));
41+
var qualifiedIdentifier = (@class.OriginalClass ?? @class).Visit(this.typePrinter);
4642
ctx.Return.Write("ReferenceEquals(__qstring{0}, null) ? new {1}.Internal() : *({1}.Internal*) (__qstring{0}.{2})",
4743
ctx.ParameterIndex, qualifiedIdentifier, Helpers.InstanceIdentifier);
4844
}
@@ -53,6 +49,6 @@ public override void CSharpMarshalToManaged(MarshalContext ctx)
5349
Helpers.CreateInstanceIdentifier, ctx.ReturnVarName);
5450
}
5551

56-
CSharpTypePrinter typePrinter;
52+
private CSharpTypePrinter typePrinter;
5753
}
5854
}

0 commit comments

Comments
 (0)