Skip to content

Commit 4befbdc

Browse files
Address reviews.
1 parent 00be7b1 commit 4befbdc

File tree

7 files changed

+173
-28
lines changed

7 files changed

+173
-28
lines changed

src/rgen/Microsoft.Macios.Generator/DataModel/Method.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@ namespace Microsoft.Macios.Generator.DataModel;
7272
/// </summary>
7373
public bool IsStatic => isStatic;
7474

75-
readonly bool isSealed;
76-
77-
/// <summary>
78-
/// True if the method was marked as sealed.
79-
/// </summary>
80-
public bool IsSealed => isSealed;
81-
8275
readonly ImmutableArray<SyntaxToken> modifiers = [];
8376
/// <summary>
8477
/// Modifiers list.
@@ -88,7 +81,6 @@ public ImmutableArray<SyntaxToken> Modifiers {
8881
init {
8982
modifiers = value;
9083
isStatic = modifiers.Any (x => x.IsKind (SyntaxKind.StaticKeyword));
91-
isSealed = modifiers.Any (x => x.IsKind (SyntaxKind.SealedKeyword));
9284
}
9385
}
9486

src/rgen/Microsoft.Macios.Generator/DataModel/Property.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ private init {
7373
/// </summary>
7474
public bool IsStatic => isStatic;
7575

76-
readonly bool isSealed;
77-
78-
/// <summary>
79-
/// True if the method was marked as sealed.
80-
/// </summary>
81-
public bool IsSealed => isSealed;
82-
8376
/// <summary>
8477
/// The platform availability of the property.
8578
/// </summary>
@@ -101,7 +94,6 @@ public ImmutableArray<SyntaxToken> Modifiers {
10194
init {
10295
modifiers = value;
10396
isStatic = modifiers.Any (x => x.IsKind (SyntaxKind.StaticKeyword));
104-
isSealed = modifiers.Any (x => x.IsKind (SyntaxKind.SealedKeyword));
10597
}
10698
}
10799

src/rgen/Microsoft.Macios.Generator/Emitters/ClassEmitterExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public static void EmitProperty (this IClassEmitter self, in BindingContext cont
408408
// the return value
409409
var (tempVar, tempDeclaration) = GetReturnValueAuxVariable (property.ReturnType);
410410
// if the binding is a protocol, we need to call send directly
411-
if (context.Changes.BindingType == BindingType.Protocol || property.IsSealed) {
411+
if (context.Changes.BindingType == BindingType.Protocol || property.SkipRegistration) {
412412
getterBlock.WriteLine ($"{tempDeclaration}");
413413
getterBlock.WriteLine ($"{ExpressionStatement (invocations.Getter.Send)}");
414414
getterBlock.WriteLine ($"{ExpressionStatement (KeepAlive ("this"))}");
@@ -466,7 +466,7 @@ public static void EmitProperty (this IClassEmitter self, in BindingContext cont
466466

467467
// perform the invocation
468468
// if the binding is a protocol, we need to call send directly
469-
if (context.Changes.BindingType == BindingType.Protocol || property.IsSealed) {
469+
if (context.Changes.BindingType == BindingType.Protocol || property.SkipRegistration) {
470470
setterBlock.WriteLine ($"{ExpressionStatement (invocations.Setter.Value.Send)}");
471471
setterBlock.WriteLine ($"{ExpressionStatement (KeepAlive ("this"))}");
472472
} else {

tests/rgen/Microsoft.Macios.Generator.Tests/Classes/Data/PropertyTests.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public partial class PropertyTests {
7474
[SupportedOSPlatform ("macos")]
7575
[SupportedOSPlatform ("maccatalyst13.1")]
7676
[Export<Property> ("sealedProperty")]
77-
public sealed partial string SelaedProperty { get; set; }
77+
public sealed partial string SealedProperty { get; set; }
7878

7979
// array of strings
8080
[Export<Property> ("surnames")]
@@ -190,4 +190,12 @@ public virtual partial bool IsLenient {
190190
[BindFrom (typeof (NSValue))]
191191
[Export<Property> ("Center")]
192192
public virtual partial CGPoint [] Location { get; set; }
193+
194+
[SupportedOSPlatform ("ios")]
195+
[SupportedOSPlatform ("tvos")]
196+
[SupportedOSPlatform ("macos")]
197+
[SupportedOSPlatform ("maccatalyst13.1")]
198+
[BindFrom (typeof (NSValue))]
199+
[Export<Property> ("NotRegistedLocation", Flags = Property.SkipRegistration)]
200+
public virtual partial CGPoint [] NotRegistedLocation { get; set; }
193201
}

tests/rgen/Microsoft.Macios.Generator.Tests/Classes/Data/iOSExpectedPropertyTests.cs

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ public partial class PropertyTests
160160
const string selSetCenter_X = "setCenter:";
161161
static readonly global::ObjCRuntime.NativeHandle selSetCenter_XHandle = global::ObjCRuntime.Selector.GetHandle ("setCenter:");
162162

163+
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
164+
const string selNotRegistedLocationX = "NotRegistedLocation";
165+
static readonly global::ObjCRuntime.NativeHandle selNotRegistedLocationXHandle = global::ObjCRuntime.Selector.GetHandle ("NotRegistedLocation");
166+
167+
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
168+
const string selSetNotRegistedLocation_X = "setNotRegistedLocation:";
169+
static readonly global::ObjCRuntime.NativeHandle selSetNotRegistedLocation_XHandle = global::ObjCRuntime.Selector.GetHandle ("setNotRegistedLocation:");
170+
163171
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
164172
static readonly global::ObjCRuntime.NativeHandle class_ptr = global::ObjCRuntime.Class.GetHandle ("PropertyTests");
165173

@@ -808,6 +816,41 @@ public virtual partial string[] Names
808816
}
809817
}
810818

819+
[SupportedOSPlatform ("macos")]
820+
[SupportedOSPlatform ("ios")]
821+
[SupportedOSPlatform ("tvos")]
822+
[SupportedOSPlatform ("maccatalyst13.1")]
823+
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
824+
public virtual partial global::CoreGraphics.CGPoint[] NotRegistedLocation
825+
{
826+
[SupportedOSPlatform ("macos")]
827+
[SupportedOSPlatform ("ios")]
828+
[SupportedOSPlatform ("tvos")]
829+
[SupportedOSPlatform ("maccatalyst13.1")]
830+
get
831+
{
832+
global::CoreGraphics.CGPoint[] ret;
833+
ret = global::Foundation.NSArray.ArrayFromHandleFunc<global::CoreGraphics.CGPoint> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("NotRegistedLocation")), global::Foundation.NSValue.ToCGPoint, false);
834+
global::System.GC.KeepAlive (this);
835+
return ret;
836+
}
837+
838+
[SupportedOSPlatform ("macos")]
839+
[SupportedOSPlatform ("ios")]
840+
[SupportedOSPlatform ("tvos")]
841+
[SupportedOSPlatform ("maccatalyst13.1")]
842+
set
843+
{
844+
if (value is null)
845+
global::ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (value));
846+
using var nsa_value = global::Foundation.NSArray.FromNSObjects (value);
847+
var nsb_value__handle__ = nsb_value!.GetNonNullHandle (nameof (nsb_value));
848+
global::ObjCRuntime.Messaging.void_objc_msgSend_NativeHandle (this.Handle, global::ObjCRuntime.Selector.GetHandle ("setNotRegistedLocation:"), nsa_value__handle__);
849+
global::System.GC.KeepAlive (this);
850+
global::System.GC.KeepAlive (nsb_value);
851+
}
852+
}
853+
811854
[SupportedOSPlatform ("macos")]
812855
[SupportedOSPlatform ("ios")]
813856
[SupportedOSPlatform ("tvos")]
@@ -949,7 +992,7 @@ public virtual partial string? OtherName
949992
[SupportedOSPlatform ("tvos")]
950993
[SupportedOSPlatform ("maccatalyst13.1")]
951994
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
952-
public sealed partial string SelaedProperty
995+
public sealed partial string SealedProperty
953996
{
954997
[SupportedOSPlatform ("macos")]
955998
[SupportedOSPlatform ("ios")]
@@ -959,7 +1002,11 @@ public sealed partial string SelaedProperty
9591002
get
9601003
{
9611004
string ret;
962-
ret = global::CoreFoundation.CFString.FromHandle (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("sealedProperty")), false)!;
1005+
if (IsDirectBinding) {
1006+
ret = global::CoreFoundation.CFString.FromHandle (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("sealedProperty")), false)!;
1007+
} else {
1008+
ret = global::CoreFoundation.CFString.FromHandle (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.SuperHandle, global::ObjCRuntime.Selector.GetHandle ("sealedProperty")), false)!;
1009+
}
9631010
global::System.GC.KeepAlive (this);
9641011
return ret;
9651012
}
@@ -974,7 +1021,11 @@ public sealed partial string SelaedProperty
9741021
if (value is null)
9751022
global::ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (value));
9761023
var nsvalue = global::CoreFoundation.CFString.CreateNative (value);
977-
global::ObjCRuntime.Messaging.void_objc_msgSend_NativeHandle (this.Handle, global::ObjCRuntime.Selector.GetHandle ("setSealedProperty:"), nsvalue);
1024+
if (IsDirectBinding) {
1025+
global::ObjCRuntime.Messaging.void_objc_msgSend_NativeHandle (this.Handle, global::ObjCRuntime.Selector.GetHandle ("setSealedProperty:"), nsvalue);
1026+
} else {
1027+
global::ObjCRuntime.Messaging.void_objc_msgSendSuper_NativeHandle (this.SuperHandle, global::ObjCRuntime.Selector.GetHandle ("setSealedProperty:"), nsvalue);
1028+
}
9781029
global::System.GC.KeepAlive (this);
9791030
global::CoreFoundation.CFString.ReleaseNative (nsvalue);
9801031
}

tests/rgen/Microsoft.Macios.Generator.Tests/Classes/Data/macOSExpectedPropertyTests.cs

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ public partial class PropertyTests
160160
const string selSetCenter_X = "setCenter:";
161161
static readonly global::ObjCRuntime.NativeHandle selSetCenter_XHandle = global::ObjCRuntime.Selector.GetHandle ("setCenter:");
162162

163+
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
164+
const string selNotRegistedLocationX = "NotRegistedLocation";
165+
static readonly global::ObjCRuntime.NativeHandle selNotRegistedLocationXHandle = global::ObjCRuntime.Selector.GetHandle ("NotRegistedLocation");
166+
167+
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
168+
const string selSetNotRegistedLocation_X = "setNotRegistedLocation:";
169+
static readonly global::ObjCRuntime.NativeHandle selSetNotRegistedLocation_XHandle = global::ObjCRuntime.Selector.GetHandle ("setNotRegistedLocation:");
170+
163171
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
164172
static readonly global::ObjCRuntime.NativeHandle class_ptr = global::ObjCRuntime.Class.GetHandle ("PropertyTests");
165173

@@ -808,6 +816,41 @@ public virtual partial string[] Names
808816
}
809817
}
810818

819+
[SupportedOSPlatform ("macos")]
820+
[SupportedOSPlatform ("ios")]
821+
[SupportedOSPlatform ("tvos")]
822+
[SupportedOSPlatform ("maccatalyst13.1")]
823+
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
824+
public virtual partial global::CoreGraphics.CGPoint[] NotRegistedLocation
825+
{
826+
[SupportedOSPlatform ("macos")]
827+
[SupportedOSPlatform ("ios")]
828+
[SupportedOSPlatform ("tvos")]
829+
[SupportedOSPlatform ("maccatalyst13.1")]
830+
get
831+
{
832+
global::CoreGraphics.CGPoint[] ret;
833+
ret = global::Foundation.NSArray.ArrayFromHandleFunc<global::CoreGraphics.CGPoint> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("NotRegistedLocation")), global::Foundation.NSValue.ToCGPoint, false);
834+
global::System.GC.KeepAlive (this);
835+
return ret;
836+
}
837+
838+
[SupportedOSPlatform ("macos")]
839+
[SupportedOSPlatform ("ios")]
840+
[SupportedOSPlatform ("tvos")]
841+
[SupportedOSPlatform ("maccatalyst13.1")]
842+
set
843+
{
844+
if (value is null)
845+
global::ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (value));
846+
using var nsa_value = global::Foundation.NSArray.FromNSObjects (value);
847+
var nsb_value__handle__ = nsb_value!.GetNonNullHandle (nameof (nsb_value));
848+
global::ObjCRuntime.Messaging.void_objc_msgSend_NativeHandle (this.Handle, global::ObjCRuntime.Selector.GetHandle ("setNotRegistedLocation:"), nsa_value__handle__);
849+
global::System.GC.KeepAlive (this);
850+
global::System.GC.KeepAlive (nsb_value);
851+
}
852+
}
853+
811854
[SupportedOSPlatform ("macos")]
812855
[SupportedOSPlatform ("ios")]
813856
[SupportedOSPlatform ("tvos")]
@@ -949,7 +992,7 @@ public virtual partial string? OtherName
949992
[SupportedOSPlatform ("tvos")]
950993
[SupportedOSPlatform ("maccatalyst13.1")]
951994
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
952-
public sealed partial string SelaedProperty
995+
public sealed partial string SealedProperty
953996
{
954997
[SupportedOSPlatform ("macos")]
955998
[SupportedOSPlatform ("ios")]
@@ -959,7 +1002,11 @@ public sealed partial string SelaedProperty
9591002
get
9601003
{
9611004
string ret;
962-
ret = global::CoreFoundation.CFString.FromHandle (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("sealedProperty")), false)!;
1005+
if (IsDirectBinding) {
1006+
ret = global::CoreFoundation.CFString.FromHandle (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("sealedProperty")), false)!;
1007+
} else {
1008+
ret = global::CoreFoundation.CFString.FromHandle (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.SuperHandle, global::ObjCRuntime.Selector.GetHandle ("sealedProperty")), false)!;
1009+
}
9631010
global::System.GC.KeepAlive (this);
9641011
return ret;
9651012
}
@@ -974,7 +1021,11 @@ public sealed partial string SelaedProperty
9741021
if (value is null)
9751022
global::ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (value));
9761023
var nsvalue = global::CoreFoundation.CFString.CreateNative (value);
977-
global::ObjCRuntime.Messaging.void_objc_msgSend_NativeHandle (this.Handle, global::ObjCRuntime.Selector.GetHandle ("setSealedProperty:"), nsvalue);
1024+
if (IsDirectBinding) {
1025+
global::ObjCRuntime.Messaging.void_objc_msgSend_NativeHandle (this.Handle, global::ObjCRuntime.Selector.GetHandle ("setSealedProperty:"), nsvalue);
1026+
} else {
1027+
global::ObjCRuntime.Messaging.void_objc_msgSendSuper_NativeHandle (this.SuperHandle, global::ObjCRuntime.Selector.GetHandle ("setSealedProperty:"), nsvalue);
1028+
}
9781029
global::System.GC.KeepAlive (this);
9791030
global::CoreFoundation.CFString.ReleaseNative (nsvalue);
9801031
}

tests/rgen/Microsoft.Macios.Generator.Tests/Classes/Data/tvOSExpectedPropertyTests.cs

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ public partial class PropertyTests
160160
const string selSetCenter_X = "setCenter:";
161161
static readonly global::ObjCRuntime.NativeHandle selSetCenter_XHandle = global::ObjCRuntime.Selector.GetHandle ("setCenter:");
162162

163+
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
164+
const string selNotRegistedLocationX = "NotRegistedLocation";
165+
static readonly global::ObjCRuntime.NativeHandle selNotRegistedLocationXHandle = global::ObjCRuntime.Selector.GetHandle ("NotRegistedLocation");
166+
167+
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
168+
const string selSetNotRegistedLocation_X = "setNotRegistedLocation:";
169+
static readonly global::ObjCRuntime.NativeHandle selSetNotRegistedLocation_XHandle = global::ObjCRuntime.Selector.GetHandle ("setNotRegistedLocation:");
170+
163171
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
164172
static readonly global::ObjCRuntime.NativeHandle class_ptr = global::ObjCRuntime.Class.GetHandle ("PropertyTests");
165173

@@ -808,6 +816,41 @@ public virtual partial string[] Names
808816
}
809817
}
810818

819+
[SupportedOSPlatform ("macos")]
820+
[SupportedOSPlatform ("ios")]
821+
[SupportedOSPlatform ("tvos")]
822+
[SupportedOSPlatform ("maccatalyst13.1")]
823+
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
824+
public virtual partial global::CoreGraphics.CGPoint[] NotRegistedLocation
825+
{
826+
[SupportedOSPlatform ("macos")]
827+
[SupportedOSPlatform ("ios")]
828+
[SupportedOSPlatform ("tvos")]
829+
[SupportedOSPlatform ("maccatalyst13.1")]
830+
get
831+
{
832+
global::CoreGraphics.CGPoint[] ret;
833+
ret = global::Foundation.NSArray.ArrayFromHandleFunc<global::CoreGraphics.CGPoint> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("NotRegistedLocation")), global::Foundation.NSValue.ToCGPoint, false);
834+
global::System.GC.KeepAlive (this);
835+
return ret;
836+
}
837+
838+
[SupportedOSPlatform ("macos")]
839+
[SupportedOSPlatform ("ios")]
840+
[SupportedOSPlatform ("tvos")]
841+
[SupportedOSPlatform ("maccatalyst13.1")]
842+
set
843+
{
844+
if (value is null)
845+
global::ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (value));
846+
using var nsa_value = global::Foundation.NSArray.FromNSObjects (value);
847+
var nsb_value__handle__ = nsb_value!.GetNonNullHandle (nameof (nsb_value));
848+
global::ObjCRuntime.Messaging.void_objc_msgSend_NativeHandle (this.Handle, global::ObjCRuntime.Selector.GetHandle ("setNotRegistedLocation:"), nsa_value__handle__);
849+
global::System.GC.KeepAlive (this);
850+
global::System.GC.KeepAlive (nsb_value);
851+
}
852+
}
853+
811854
[SupportedOSPlatform ("macos")]
812855
[SupportedOSPlatform ("ios")]
813856
[SupportedOSPlatform ("tvos")]
@@ -949,7 +992,7 @@ public virtual partial string? OtherName
949992
[SupportedOSPlatform ("tvos")]
950993
[SupportedOSPlatform ("maccatalyst13.1")]
951994
[BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
952-
public sealed partial string SelaedProperty
995+
public sealed partial string SealedProperty
953996
{
954997
[SupportedOSPlatform ("macos")]
955998
[SupportedOSPlatform ("ios")]
@@ -959,7 +1002,11 @@ public sealed partial string SelaedProperty
9591002
get
9601003
{
9611004
string ret;
962-
ret = global::CoreFoundation.CFString.FromHandle (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("sealedProperty")), false)!;
1005+
if (IsDirectBinding) {
1006+
ret = global::CoreFoundation.CFString.FromHandle (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, global::ObjCRuntime.Selector.GetHandle ("sealedProperty")), false)!;
1007+
} else {
1008+
ret = global::CoreFoundation.CFString.FromHandle (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.SuperHandle, global::ObjCRuntime.Selector.GetHandle ("sealedProperty")), false)!;
1009+
}
9631010
global::System.GC.KeepAlive (this);
9641011
return ret;
9651012
}
@@ -974,7 +1021,11 @@ public sealed partial string SelaedProperty
9741021
if (value is null)
9751022
global::ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (value));
9761023
var nsvalue = global::CoreFoundation.CFString.CreateNative (value);
977-
global::ObjCRuntime.Messaging.void_objc_msgSend_NativeHandle (this.Handle, global::ObjCRuntime.Selector.GetHandle ("setSealedProperty:"), nsvalue);
1024+
if (IsDirectBinding) {
1025+
global::ObjCRuntime.Messaging.void_objc_msgSend_NativeHandle (this.Handle, global::ObjCRuntime.Selector.GetHandle ("setSealedProperty:"), nsvalue);
1026+
} else {
1027+
global::ObjCRuntime.Messaging.void_objc_msgSendSuper_NativeHandle (this.SuperHandle, global::ObjCRuntime.Selector.GetHandle ("setSealedProperty:"), nsvalue);
1028+
}
9781029
global::System.GC.KeepAlive (this);
9791030
global::CoreFoundation.CFString.ReleaseNative (nsvalue);
9801031
}

0 commit comments

Comments
 (0)