Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions docs/api/ObjCRuntime/BlockLiteral.xml

This file was deleted.

2 changes: 2 additions & 0 deletions src/ImageIO/CGImageMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ static byte TagEnumerator (IntPtr block, NativeHandle key, NativeHandle value)
var nsKey = Runtime.GetNSObject<NSString> (key, false)!;
var nsValue = Runtime.GetINativeObject<CGImageMetadataTag> (value, false)!;
var del = BlockLiteral.GetTarget<CGImageMetadataTagBlock> (block);
if (del is null)
return default;
return del (nsKey, nsValue) ? (byte) 1 : (byte) 0;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Metal/MTLDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ public static IMTLDevice [] GetAllDevices (MTLDeviceNotificationHandler handler,
[UnmanagedCallersOnly]
public static unsafe void TrampolineNotificationHandler (IntPtr block, IntPtr device, IntPtr notifyName)
{
var descriptor = (BlockLiteral*) block;
var del = (MTLDeviceNotificationHandler) (descriptor->Target);
var del = BlockLiteral.GetTarget<MTLDeviceNotificationHandler> (block);
if (del is not null)
del ((IMTLDevice) Runtime.GetNSObject (device)!, (Foundation.NSString) Runtime.GetNSObject (notifyName)!);
}
Expand Down
2 changes: 1 addition & 1 deletion src/MetalPerformanceShaders/MPSImageBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static nuint GetResourceSize (NSArray<MPSImage> imageBatch)
[UnmanagedCallersOnly]
static unsafe nint InvokeIterator (IntPtr block, IntPtr image, nuint index)
{
var del = (MPSImageBatchIterator) BlockLiteral.GetTarget<MPSImageBatchIterator> (block);
var del = BlockLiteral.GetTarget<MPSImageBatchIterator> (block);
if (del is not null) {
using var img = Runtime.GetNSObject<MPSImage> (image)!;
return del (img, index);
Expand Down
219 changes: 136 additions & 83 deletions src/ObjCRuntime/Blocks.cs

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions src/Security/SecSharedCredential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ static internal class ActionTrampoline {
[UnmanagedCallersOnly]
internal static unsafe void Invoke (IntPtr block, IntPtr obj)
{
var descriptor = (BlockLiteral*) block;
var del = (global::System.Action<NSError?>) (descriptor->Target);
var del = BlockLiteral.GetTarget<Action<NSError?>> (block);
if (del is not null) {
del (Runtime.GetNSObject<NSError> (obj));
}
Expand Down Expand Up @@ -89,8 +88,7 @@ static internal class ArrayErrorActionTrampoline {
[UnmanagedCallersOnly]
internal static unsafe void Invoke (IntPtr block, IntPtr array, IntPtr err)
{
var descriptor = (BlockLiteral*) block;
var del = (global::System.Action<NSArray?, NSError?>) (descriptor->Target);
var del = BlockLiteral.GetTarget<Action<NSArray?, NSError?>> (block);
if (del is not null)
del (Runtime.GetNSObject<NSArray> (array), Runtime.GetNSObject<NSError> (err));
}
Expand Down
3 changes: 1 addition & 2 deletions src/UIKit/UIAccessibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ public static Task<bool> RequestGuidedAccessSessionAsync (bool enable)
[UnmanagedCallersOnly]
static unsafe void TrampolineRequestGuidedAccessSession (IntPtr block, byte enable)
{
var descriptor = (BlockLiteral*) block;
var del = (Action<bool>) (descriptor->Target);
var del = BlockLiteral.GetTarget<Action<bool>> (block);
if (del is not null)
del (enable != 0);
}
Expand Down
5 changes: 3 additions & 2 deletions src/UIKit/UICellAccessory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ static internal class SDUICellAccessoryPosition {
[UnmanagedCallersOnly]
static unsafe nuint Invoke (IntPtr block, IntPtr accessories)
{
var descriptor = (BlockLiteral*) block;
var del = (UICellAccessoryPosition) (descriptor->Target);
var del = BlockLiteral.GetTarget<UICellAccessoryPosition> (block);
if (del is null)
return default;
nuint retval = del (NSArray.ArrayFromHandle<UICellAccessory> (accessories));
return retval;
}
Expand Down
3 changes: 1 addition & 2 deletions src/UIKit/UIConfigurationColorTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ static internal class SDUIConfigurationColorTransformerHandler {
[UnmanagedCallersOnly]
static unsafe IntPtr Invoke (IntPtr block, IntPtr color)
{
var descriptor = (BlockLiteral*) block;
var del = (UIConfigurationColorTransformerHandler) (descriptor->Target);
var del = BlockLiteral.GetTarget<UIConfigurationColorTransformerHandler> (block);
var retval = del is null ? null : del (Runtime.GetNSObject<UIColor> (color)!);
return Runtime.RetainAndAutoreleaseNSObject (retval);
}
Expand Down
3 changes: 1 addition & 2 deletions src/UIKit/UIGuidedAccessRestriction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ static internal class UIGuidedAccessConfigureAccessibilityFeaturesTrampoline {
[UnmanagedCallersOnlyAttribute]
internal static unsafe void Invoke (IntPtr block, byte success, IntPtr error)
{
var descriptor = (BlockLiteral*) block;
var del = (UIGuidedAccessConfigureAccessibilityFeaturesCompletionHandler) (descriptor->Target);
var del = BlockLiteral.GetTarget<UIGuidedAccessConfigureAccessibilityFeaturesCompletionHandler> (block);
if (del is not null)
del (success != 0, Runtime.GetNSObject<NSError> (error));
}
Expand Down
4 changes: 4 additions & 0 deletions src/bgen/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,10 @@ void GenerateTrampolinesForQueue (TrampolineInfo [] queue)
}
print ("}");
} else {
print ("if (del is null)");
indent++;
print ("return default;");
indent--;
if (ti.Convert.Length > 0)
print (ti.Convert);
print ("var retval = del ({1});", ti.DelegateReturnType, ti.Invoke);
Expand Down
1 change: 0 additions & 1 deletion tests/cecil-tests/Documentation.KnownFailures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15214,7 +15214,6 @@ M:ObjCRuntime.AssemblyRegistrationEventArgs.#ctor
M:ObjCRuntime.BaseWrapper.#ctor(ObjCRuntime.NativeHandle,System.Boolean)
M:ObjCRuntime.BaseWrapper.Release
M:ObjCRuntime.BaseWrapper.Retain
M:ObjCRuntime.BlockLiteral.Dispose
M:ObjCRuntime.Class.#ctor(ObjCRuntime.NativeHandle)
M:ObjCRuntime.Class.Equals(ObjCRuntime.Class)
M:ObjCRuntime.Class.Equals(System.Object)
Expand Down
Loading