Skip to content

Commit 73ffd5d

Browse files
authored
[GameplayKit] Improve and simplify the manually bound constructors for GKPath slightly. (#22847)
Improve and simplify the manually bound constructors for GKPath by using the same pattern we use elsewhere for manually bound constructors.
1 parent 9c78bd7 commit 73ffd5d

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

src/GameplayKit/GKPath.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public static GKPath FromPoints (Vector2 [] points, float radius, bool cyclical)
4343

4444
[DesignatedInitializer]
4545
public GKPath (Vector2 [] points, float radius, bool cyclical)
46+
: base (NSObjectFlag.Empty)
4647
{
4748
if (points is null)
4849
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (points));
@@ -51,7 +52,7 @@ public GKPath (Vector2 [] points, float radius, bool cyclical)
5152
try {
5253
PrepareBuffer (out buffer, ref points);
5354

54-
Handle = InitWithPoints (buffer, (nuint) points.Length, radius, cyclical);
55+
InitializeHandle (_InitWithPoints (buffer, (nuint) points.Length, radius, cyclical), "initWithPoints:count:radius:cyclical:");
5556
} finally {
5657
if (buffer != IntPtr.Zero)
5758
Marshal.FreeHGlobal (buffer);
@@ -87,6 +88,7 @@ public static GKPath FromPoints (Vector3 [] points, float radius, bool cyclical)
8788
[SupportedOSPlatform ("maccatalyst")]
8889
#endif
8990
public GKPath (Vector3 [] points, float radius, bool cyclical)
91+
: base (NSObjectFlag.Empty)
9092
{
9193
if (points is null)
9294
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (points));
@@ -95,7 +97,7 @@ public GKPath (Vector3 [] points, float radius, bool cyclical)
9597
try {
9698
PrepareBuffer (out buffer, ref points);
9799

98-
Handle = InitWithFloat3Points (buffer, (nuint) points.Length, radius, cyclical);
100+
InitializeHandle (_InitWithFloat3Points (buffer, (nuint) points.Length, radius, cyclical), "initWithFloat3Points:count:radius:cyclical:");
99101
} finally {
100102
if (buffer != IntPtr.Zero)
101103
Marshal.FreeHGlobal (buffer);

src/gameplaykit.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ interface GKPath {
11841184

11851185
[Internal]
11861186
[Export ("initWithPoints:count:radius:cyclical:")]
1187-
IntPtr InitWithPoints (IntPtr points, nuint count, float radius, bool cyclical);
1187+
IntPtr _InitWithPoints (IntPtr points, nuint count, float radius, bool cyclical);
11881188

11891189
[MacCatalyst (13, 1)]
11901190
[Static, Internal]
@@ -1194,7 +1194,7 @@ interface GKPath {
11941194
[MacCatalyst (13, 1)]
11951195
[Internal]
11961196
[Export ("initWithFloat3Points:count:radius:cyclical:")]
1197-
IntPtr InitWithFloat3Points (IntPtr points, nuint count, float radius, bool cyclical);
1197+
IntPtr _InitWithFloat3Points (IntPtr points, nuint count, float radius, bool cyclical);
11981198

11991199
[Static]
12001200
[Export ("pathWithGraphNodes:radius:")]

tests/cecil-tests/ConstructorTest.KnownFailures.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ public partial class ConstructorTest {
2121
"Foundation.NSObject::.ctor(ObjCRuntime.NativeHandle,System.Boolean)",
2222
"Foundation.NSSynchronizationContextDispatcher::.ctor(System.Threading.SendOrPostCallback,System.Object)",
2323
"Foundation.NSTimerActionDispatcher::.ctor(System.Action`1<Foundation.NSTimer>)",
24-
"GameplayKit.GKPath::.ctor(System.Numerics.Vector2[],System.Single,System.Boolean)",
25-
"GameplayKit.GKPath::.ctor(System.Numerics.Vector3[],System.Single,System.Boolean)",
2624
"HomeKit.HMMatterHome::.ctor(Foundation.NSCoder)",
2725
"HomeKit.HMMatterHome::.ctor(Foundation.NSObjectFlag)",
2826
"HomeKit.HMMatterHome::.ctor(Foundation.NSUuid,System.String)",

tests/cecil-tests/SetHandleTest.KnownFailures.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ public partial class SetHandleTest {
1515
"CoreGraphics.CGPattern::.ctor(CoreGraphics.CGRect,CoreGraphics.CGAffineTransform,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,CoreGraphics.CGPatternTiling,System.Boolean,CoreGraphics.CGPattern/DrawPattern)",
1616
"Foundation.NSKeyedUnarchiver::.ctor(Foundation.NSData)",
1717
"Foundation.NSUuid::.ctor(System.Byte[])",
18-
"GameplayKit.GKPath::.ctor(System.Numerics.Vector2[],System.Single,System.Boolean)",
19-
"GameplayKit.GKPath::.ctor(System.Numerics.Vector3[],System.Single,System.Boolean)",
2018
"ObjCRuntime.Runtime::RegisterNSObject(Foundation.NSObject,System.IntPtr)",
2119
"ScreenCaptureKit.SCContentFilter::.ctor(ScreenCaptureKit.SCDisplay,ScreenCaptureKit.SCRunningApplication[],ScreenCaptureKit.SCWindow[],ScreenCaptureKit.SCContentFilterOption)",
2220
"ScreenCaptureKit.SCContentFilter::.ctor(ScreenCaptureKit.SCDisplay,ScreenCaptureKit.SCWindow[],ScreenCaptureKit.SCContentFilterOption)",

0 commit comments

Comments
 (0)