Skip to content

Commit 1582ea0

Browse files
committed
Addressing some Review Feedback
1 parent 3352032 commit 1582ea0

File tree

10 files changed

+80
-747
lines changed

10 files changed

+80
-747
lines changed

generator.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"DefaultLicenseHeader": "eng/silktouch/header.txt",
88
"Mods": [
99
"ClangScraper",
10-
"ManualFileImporter",
10+
"ImportManualFiles",
1111
"ChangeNamespace",
1212
"TransformInterfaces",
1313
"TransformCOM",
@@ -49,7 +49,7 @@
4949
"tests/DirectX/d3dx12/d3dx12_barriers/**.cs"
5050
]
5151
},
52-
"ManualFileImporter": {
52+
"ImportManualFiles": {
5353
"ManualImports": {
5454
"sources/**.Manual.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/**.Manual.cs",
5555
"!sources/**/INativeGuid.Manual.cs": "!**/INativeGuid.Manual.cs",

sources/Core/Core/Pointers/Ptr2D.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public T[][] ToArray<T>(int length, int[] lengths)
307307
[MethodImpl(
308308
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
309309
)]
310-
public static implicit operator Ptr2D(void* ptr) => new((void**)ptr);
310+
public static explicit operator Ptr2D(void* ptr) => new((void**)ptr);
311311

312312
/// <summary>
313313
/// Creates a <see cref="Ptr2D"/> from a native pointer
@@ -428,6 +428,6 @@ public T[][] ToArray<T>(int length, int[] lengths)
428428
/// </summary>
429429
/// <param name="ptr">The pointer.</param>
430430
/// <returns>The wrapped pointer.</returns>
431-
public static implicit operator Ptr2D(Ptr* ptr) => (byte*)ptr;
431+
public static implicit operator Ptr2D(Ptr* ptr) => (Ptr2D)(byte**)ptr;
432432
}
433433
}

sources/Core/Core/Pointers/Ptr2D.generic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ public T[][] ToArray(int length, int[] lengths) =>
444444
[MethodImpl(
445445
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
446446
)]
447-
public static implicit operator Ptr2D<T>(void* ptr) => new((Ptr<T>*)ptr);
447+
public static explicit operator Ptr2D<T>(void* ptr) => new((Ptr<T>*)ptr);
448448

449449
/// <summary>
450450
/// Creates a native pointer from a <see cref="Ptr2D{T}"/>

sources/Core/Core/Pointers/Ptr3D.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public T[][][] ToArray<T>(int length, int[] lengths0, int[][] lengths1)
318318
[MethodImpl(
319319
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
320320
)]
321-
public static implicit operator Ptr3D(void* ptr) => new((void***)ptr);
321+
public static explicit operator Ptr3D(void* ptr) => new((void***)ptr);
322322

323323
/// <summary>
324324
/// Creates a <see cref="Ptr3D"/> from a native pointer
@@ -327,7 +327,7 @@ public T[][][] ToArray<T>(int length, int[] lengths0, int[][] lengths1)
327327
[MethodImpl(
328328
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
329329
)]
330-
public static implicit operator Ptr3D(void** ptr) => new((void***)ptr);
330+
public static explicit operator Ptr3D(void** ptr) => new((void***)ptr);
331331

332332
/// <summary>
333333
/// Creates a <see cref="Ptr3D"/> from a native pointer
@@ -409,8 +409,7 @@ ptr.Native is not null && ptr.Native->Native is not null
409409
[MethodImpl(
410410
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
411411
)]
412-
// TODO analyzer to ensure ptr is on stack or otherwise pinned
413-
public static explicit operator Ptr3D(Ref2D ptr) => (void**)ptr;
412+
public static explicit operator Ptr3D(Ref2D ptr) => (Ptr3D)(void**)ptr;
414413

415414
/// <summary>
416415
/// Creates a null ptr
@@ -460,6 +459,6 @@ ptr.Native is not null && ptr.Native->Native is not null
460459
/// </summary>
461460
/// <param name="ptr">The pointer.</param>
462461
/// <returns>The wrapped pointer.</returns>
463-
public static implicit operator Ptr3D(Ptr2D* ptr) => (byte***)ptr;
462+
public static implicit operator Ptr3D(Ptr2D* ptr) => (Ptr3D)(byte***)ptr;
464463
}
465464
}

sources/Core/Core/Pointers/Ptr3D.generic.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public T[][][] ToArray(int length, int[] lengths0, int[][] lengths1) =>
443443
[MethodImpl(
444444
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
445445
)]
446-
public static implicit operator Ptr3D<T>(void* ptr) => new((Ptr2D<T>*)ptr);
446+
public static explicit operator Ptr3D<T>(void* ptr) => new((Ptr2D<T>*)ptr);
447447

448448
/// <summary>
449449
/// Creates a native pointer from a <see cref="Ptr3D{T}"/>
@@ -461,7 +461,7 @@ ptr.Native is not null && ptr.Native->Native is not null
461461
[MethodImpl(
462462
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
463463
)]
464-
public static implicit operator Ptr3D<T>(void** ptr) => new((Ptr2D<T>*)ptr);
464+
public static explicit operator Ptr3D<T>(void** ptr) => new((Ptr2D<T>*)ptr);
465465

466466
/// <summary>
467467
/// Creates a native pointer from a <see cref="Ptr3D{T}"/>

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static Silk.NET.Core.Ptr2D.explicit operator Silk.NET.Core.Ptr2D(Silk.NET.Core.R
454454
static Silk.NET.Core.Ptr2D.implicit operator Silk.NET.Core.Ptr(Silk.NET.Core.Ptr2D ptr) -> Silk.NET.Core.Ptr
455455
static Silk.NET.Core.Ptr2D.implicit operator Silk.NET.Core.Ptr2D(Silk.NET.Core.NullPtr ptr) -> Silk.NET.Core.Ptr2D
456456
static Silk.NET.Core.Ptr2D.implicit operator Silk.NET.Core.Ptr2D(Silk.NET.Core.Ptr* ptr) -> Silk.NET.Core.Ptr2D
457-
static Silk.NET.Core.Ptr2D.implicit operator Silk.NET.Core.Ptr2D(void* ptr) -> Silk.NET.Core.Ptr2D
457+
static Silk.NET.Core.Ptr2D.explicit operator Silk.NET.Core.Ptr2D(void* ptr) -> Silk.NET.Core.Ptr2D
458458
static Silk.NET.Core.Ptr2D.implicit operator Silk.NET.Core.Ptr2D(void** ptr) -> Silk.NET.Core.Ptr2D
459459
static Silk.NET.Core.Ptr2D.implicit operator Silk.NET.Core.Ref(Silk.NET.Core.Ptr2D ptr) -> Silk.NET.Core.Ref
460460
static Silk.NET.Core.Ptr2D.implicit operator Silk.NET.Core.Ref2D(Silk.NET.Core.Ptr2D ptr) -> Silk.NET.Core.Ref2D
@@ -486,7 +486,7 @@ static Silk.NET.Core.Ptr2D<T>.implicit operator Silk.NET.Core.Ptr2D<T>(Silk.NET.
486486
static Silk.NET.Core.Ptr2D<T>.implicit operator Silk.NET.Core.Ptr2D<T>(Silk.NET.Core.Ptr2D ptr) -> Silk.NET.Core.Ptr2D<T>
487487
static Silk.NET.Core.Ptr2D<T>.implicit operator Silk.NET.Core.Ptr2D<T>(Silk.NET.Core.Ptr<T>* ptr) -> Silk.NET.Core.Ptr2D<T>
488488
static Silk.NET.Core.Ptr2D<T>.implicit operator Silk.NET.Core.Ptr2D<T>(T** ptr) -> Silk.NET.Core.Ptr2D<T>
489-
static Silk.NET.Core.Ptr2D<T>.implicit operator Silk.NET.Core.Ptr2D<T>(void* ptr) -> Silk.NET.Core.Ptr2D<T>
489+
static Silk.NET.Core.Ptr2D<T>.explicit operator Silk.NET.Core.Ptr2D<T>(void* ptr) -> Silk.NET.Core.Ptr2D<T>
490490
static Silk.NET.Core.Ptr2D<T>.implicit operator Silk.NET.Core.Ptr2D<T>(void** ptr) -> Silk.NET.Core.Ptr2D<T>
491491
static Silk.NET.Core.Ptr2D<T>.implicit operator Silk.NET.Core.Ref(Silk.NET.Core.Ptr2D<T> ptr) -> Silk.NET.Core.Ref
492492
static Silk.NET.Core.Ptr2D<T>.implicit operator Silk.NET.Core.Ref2D(Silk.NET.Core.Ptr2D<T> ptr) -> Silk.NET.Core.Ref2D
@@ -529,8 +529,8 @@ static Silk.NET.Core.Ptr3D.explicit operator Silk.NET.Core.Ptr3D(Silk.NET.Core.R
529529
static Silk.NET.Core.Ptr3D.implicit operator Silk.NET.Core.Ptr(Silk.NET.Core.Ptr3D ptr) -> Silk.NET.Core.Ptr
530530
static Silk.NET.Core.Ptr3D.implicit operator Silk.NET.Core.Ptr3D(Silk.NET.Core.NullPtr ptr) -> Silk.NET.Core.Ptr3D
531531
static Silk.NET.Core.Ptr3D.implicit operator Silk.NET.Core.Ptr3D(Silk.NET.Core.Ptr2D* ptr) -> Silk.NET.Core.Ptr3D
532-
static Silk.NET.Core.Ptr3D.implicit operator Silk.NET.Core.Ptr3D(void* ptr) -> Silk.NET.Core.Ptr3D
533-
static Silk.NET.Core.Ptr3D.implicit operator Silk.NET.Core.Ptr3D(void** ptr) -> Silk.NET.Core.Ptr3D
532+
static Silk.NET.Core.Ptr3D.explicit operator Silk.NET.Core.Ptr3D(void* ptr) -> Silk.NET.Core.Ptr3D
533+
static Silk.NET.Core.Ptr3D.explicit operator Silk.NET.Core.Ptr3D(void** ptr) -> Silk.NET.Core.Ptr3D
534534
static Silk.NET.Core.Ptr3D.implicit operator Silk.NET.Core.Ptr3D(void*** ptr) -> Silk.NET.Core.Ptr3D
535535
static Silk.NET.Core.Ptr3D.implicit operator Silk.NET.Core.Ref(Silk.NET.Core.Ptr3D ptr) -> Silk.NET.Core.Ref
536536
static Silk.NET.Core.Ptr3D.implicit operator Silk.NET.Core.Ref3D(Silk.NET.Core.Ptr3D ptr) -> Silk.NET.Core.Ref3D
@@ -563,8 +563,8 @@ static Silk.NET.Core.Ptr3D<T>.implicit operator Silk.NET.Core.Ptr3D<T>(Silk.NET.
563563
static Silk.NET.Core.Ptr3D<T>.implicit operator Silk.NET.Core.Ptr3D<T>(Silk.NET.Core.Ptr2D<T>* ptr) -> Silk.NET.Core.Ptr3D<T>
564564
static Silk.NET.Core.Ptr3D<T>.implicit operator Silk.NET.Core.Ptr3D<T>(Silk.NET.Core.Ptr3D ptr) -> Silk.NET.Core.Ptr3D<T>
565565
static Silk.NET.Core.Ptr3D<T>.implicit operator Silk.NET.Core.Ptr3D<T>(T*** ptr) -> Silk.NET.Core.Ptr3D<T>
566-
static Silk.NET.Core.Ptr3D<T>.implicit operator Silk.NET.Core.Ptr3D<T>(void* ptr) -> Silk.NET.Core.Ptr3D<T>
567-
static Silk.NET.Core.Ptr3D<T>.implicit operator Silk.NET.Core.Ptr3D<T>(void** ptr) -> Silk.NET.Core.Ptr3D<T>
566+
static Silk.NET.Core.Ptr3D<T>.explicit operator Silk.NET.Core.Ptr3D<T>(void* ptr) -> Silk.NET.Core.Ptr3D<T>
567+
static Silk.NET.Core.Ptr3D<T>.explicit operator Silk.NET.Core.Ptr3D<T>(void** ptr) -> Silk.NET.Core.Ptr3D<T>
568568
static Silk.NET.Core.Ptr3D<T>.implicit operator Silk.NET.Core.Ptr3D<T>(void*** ptr) -> Silk.NET.Core.Ptr3D<T>
569569
static Silk.NET.Core.Ptr3D<T>.implicit operator Silk.NET.Core.Ref(Silk.NET.Core.Ptr3D<T> ptr) -> Silk.NET.Core.Ref
570570
static Silk.NET.Core.Ptr3D<T>.implicit operator Silk.NET.Core.Ref3D(Silk.NET.Core.Ptr3D<T> ptr) -> Silk.NET.Core.Ref3D

sources/SilkTouch/SilkTouch/Mods/ManualFileImporter.cs renamed to sources/SilkTouch/SilkTouch/Mods/ImportManualFiles.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ namespace Silk.NET.SilkTouch.Mods
2727
/// <param name="logger">The logger to use.</param>
2828
/// <param name="config">The configuration to use.</param>
2929
[ModConfiguration<Configuration>]
30-
internal class ManualFileImporter(
31-
ILogger<ManualFileImporter> logger,
32-
IOptionsSnapshot<ManualFileImporter.Configuration> config
30+
public class ImportManualFiles(
31+
ILogger<ImportManualFiles> logger,
32+
IOptionsSnapshot<ImportManualFiles.Configuration> config
3333
) : Mod
3434
{
3535
/// <summary>

sources/SilkTouch/SilkTouch/Mods/TransformCOM.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public override void VisitStructDeclaration(StructDeclarationSyntax node)
193193
{
194194
_ObjectNames.Add(node.Identifier.Text);
195195
base.VisitStructDeclaration(node);
196-
_ObjectNames.RemoveAt(_Namespace.Count - 1);
196+
_ObjectNames.RemoveAt(_ObjectNames.Count - 1);
197197

198198
if (node.Identifier.Text == "Native")
199199
return;
@@ -702,9 +702,8 @@ private ConversionOperatorDeclarationSyntax GenerateCastDefinition(
702702
SingletonSeparatedList(
703703
Argument(
704704
CastExpression(
705-
PointerType(
706-
ParseTypeName($"{className}.Native")
707-
),
705+
ParseTypeName($"Ptr<{className}.Native>")
706+
,
708707
IdentifierName("value.lpVtbl")
709708
)
710709
)

0 commit comments

Comments
 (0)