Skip to content

Commit d28b57b

Browse files
committed
More COM work
-Added early out -fix duplicate call -Add INativeGuid
1 parent 4712536 commit d28b57b

File tree

5 files changed

+45
-18
lines changed

5 files changed

+45
-18
lines changed

Silk.NET.sln

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.12.35527.113 d17.12
4+
VisualStudioVersion = 17.12.35527.113
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{60A10DB9-C4D6-48CD-8982-7F02345D7ADF}"
77
ProjectSection(SolutionItems) = preProject
@@ -151,15 +151,12 @@ Global
151151
{AF6C70ED-D6A8-4C57-8DB3-EAFF94396049}.Release|Any CPU.ActiveCfg = Release|Any CPU
152152
{AF6C70ED-D6A8-4C57-8DB3-EAFF94396049}.Release|Any CPU.Build.0 = Release|Any CPU
153153
{9625C977-25BE-48F3-9B6F-BC94B8B799A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
154-
{9625C977-25BE-48F3-9B6F-BC94B8B799A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
155154
{9625C977-25BE-48F3-9B6F-BC94B8B799A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
156155
{9625C977-25BE-48F3-9B6F-BC94B8B799A6}.Release|Any CPU.Build.0 = Release|Any CPU
157156
{19B05730-F97E-43D4-B922-DF4697E5CE5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
158-
{19B05730-F97E-43D4-B922-DF4697E5CE5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
159157
{19B05730-F97E-43D4-B922-DF4697E5CE5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
160158
{19B05730-F97E-43D4-B922-DF4697E5CE5F}.Release|Any CPU.Build.0 = Release|Any CPU
161159
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
162-
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807}.Debug|Any CPU.Build.0 = Debug|Any CPU
163160
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807}.Release|Any CPU.ActiveCfg = Release|Any CPU
164161
{D2B9C43F-A80D-4C9A-9643-BC1AC1B4E807}.Release|Any CPU.Build.0 = Release|Any CPU
165162
{3CADD95A-179F-4ECF-A49D-4B753832C63C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -171,15 +168,13 @@ Global
171168
{6FA628B8-9696-4847-89F9-E58F470AF4FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
172169
{6FA628B8-9696-4847-89F9-E58F470AF4FB}.Release|Any CPU.Build.0 = Release|Any CPU
173170
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
174-
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
175171
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
176172
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Release|Any CPU.Build.0 = Release|Any CPU
177173
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
178174
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
179175
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
180176
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Release|Any CPU.Build.0 = Release|Any CPU
181177
{BB33CC4A-EA3A-4D4F-879A-F93C617C5E63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
182-
{BB33CC4A-EA3A-4D4F-879A-F93C617C5E63}.Debug|Any CPU.Build.0 = Debug|Any CPU
183178
{BB33CC4A-EA3A-4D4F-879A-F93C617C5E63}.Release|Any CPU.ActiveCfg = Release|Any CPU
184179
{BB33CC4A-EA3A-4D4F-879A-F93C617C5E63}.Release|Any CPU.Build.0 = Release|Any CPU
185180
{C8F32825-1F93-44F0-AB88-26167C21CADF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

generator.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
],
1313
"ClangScraper": {
1414
"ClangSharpResponseFiles": [
15-
"eng/submodules/terrafx.interop.windows/generation/**/generate.rsp"
15+
"eng/submodules/terrafx.interop.windows/generation/**/generate.rsp",
16+
"!eng/submodules/terrafx.interop.windows/generation/DirectX/d3dx12/d3dx12_state_object/generate.rsp"
1617
],
1718
"ManualOverrides": {
1819
"sources/Windows/um/icm/Windows.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/icm/Windows.cs",
20+
"sources/Windows/um/WinUser/Windows.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/WinUser/Windows.cs",
21+
"sources/Windows/shared/strsafe/Windows.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/shared/strsafe/Windows.cs",
22+
"sources/Windows/shared/hidpi/Windows.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/shared/hidpi/Windows.cs",
1923
"sources/Gdiplus/um/gdiplustypes/GpRect.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Gdiplus/um/gdiplustypes/GpRect.cs",
2024
"sources/Gdiplus/um/gdiplustypes/GpRectF.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Gdiplus/um/gdiplustypes/GpRectF.cs",
2125
"sources/Gdiplus/um/gdiplustypes/GpPathData.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Gdiplus/um/gdiplustypes/GpPathData.cs"

sources/Core/Core/INativeGuid.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
10+
namespace Silk.NET.Core
11+
{
12+
/// <summary>
13+
/// An interface to retrieve Native class Guids
14+
/// </summary>
15+
public unsafe interface INativeGuid
16+
{
17+
/// <summary>
18+
/// The guid for the native version of this class
19+
/// </summary>
20+
static abstract Guid* NativeGuid { get; }
21+
}
22+
}

sources/Core/Core/PublicAPI/net8.0/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Silk.NET.Core.IGLContextSource
103103
Silk.NET.Core.IGLContextSource.GLContext.get -> Silk.NET.Core.IGLContext?
104104
Silk.NET.Core.INativeWindow
105105
Silk.NET.Core.INativeWindow.TryGetPlatformInfo<TPlatformInfo>(out TPlatformInfo? info) -> bool
106+
Silk.NET.Core.INativeGuid
107+
Silk.NET.Core.INativeGuid.NativeGuid.get -> System.Guid*
106108
Silk.NET.Core.Loader.DefaultNativeContext
107109
Silk.NET.Core.Loader.DefaultNativeContext.DefaultNativeContext() -> void
108110
Silk.NET.Core.Loader.DefaultNativeContext.Dispose() -> void

sources/SilkTouch/SilkTouch/Mods/TransformCOM.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,19 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct =
9595
continue;
9696
}
9797

98-
var semanticModel = await doc.GetSemanticModelAsync();
9998
var editor = new SyntaxEditor(root, proj.Solution.Workspace.Services);
10099
// Replace pointer member access -> with regular member access .
101100
var memberAccesses = root.DescendantNodes()
102101
.OfType<MemberAccessExpressionSyntax>()
103102
.Where(m => m.Expression is PrefixUnaryExpressionSyntax pues && pues.IsKind(SyntaxKind.PointerMemberAccessExpression));
104103

104+
if (memberAccesses.Count() == 0)
105+
{
106+
continue;
107+
}
108+
109+
var semanticModel = await doc.GetSemanticModelAsync();
110+
105111
foreach (var memberAccess in memberAccesses)
106112
{
107113
var pointerIndirection = (PrefixUnaryExpressionSyntax)memberAccess.Expression;
@@ -114,8 +120,6 @@ public override async Task ExecuteAsync(IModContext ctx, CancellationToken ct =
114120
}
115121
}
116122

117-
doc = doc.WithSyntaxRoot(rewriter.Visit(root).NormalizeWhitespace());
118-
119123
proj = doc.Project;
120124

121125
logger.LogInformation("COM Object Usage Update for {0} Complete ({1}/{2})", doc.Name, index, count);
@@ -230,15 +234,15 @@ class Rewriter(List<(string, bool)> ComTypes)
230234

231235
public override SyntaxNode VisitGenericName(GenericNameSyntax node) => node;
232236

233-
//public override SyntaxNode? VisitIdentifierName(IdentifierNameSyntax node)
234-
//{
235-
// if (node.Identifier.ToString() == "lpVtbl")
236-
// {
237-
// return ParenthesizedExpression(PrefixUnaryExpression(SyntaxKind.PointerIndirectionExpression, node));
238-
// }
237+
public override SyntaxNode? VisitIdentifierName(IdentifierNameSyntax node)
238+
{
239+
if (node.Identifier.ToString() == "lpVtbl")
240+
{
241+
return ParenthesizedExpression(PrefixUnaryExpression(SyntaxKind.PointerIndirectionExpression, node));
242+
}
239243

240-
// return base.VisitIdentifierName(node);
241-
//}
244+
return base.VisitIdentifierName(node);
245+
}
242246

243247
public override SyntaxNode? VisitVariableDeclaration(VariableDeclarationSyntax node)
244248
{

0 commit comments

Comments
 (0)