// // Simple method that we can use to wrap methods that need to call a block // // usage: // void MyCallBack () {} // BlockLiteral.SimpleCall (MyCallBack, (x) => my_PINvokeThatTakesaBlock (x)); // The above will call the unmanaged my_PINvokeThatTakesaBlock method with a block // that when invoked will call MyCallback // internal unsafe static void SimpleCall(Action callbackToInvoke, Action <IntPtr> pinvoke) { unsafe { BlockLiteral block_handler = new BlockLiteral(); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe(BlockStaticDispatchClass.static_dispatch_block, callbackToInvoke); try { pinvoke((IntPtr)block_ptr_handler); } finally { block_handler.CleanupBlock(); } } }
unsafe void Invoke(global::Flutter.Internal.FlutterMethodCall call, [BlockProxy(typeof(ObjCRuntime.Trampolines.NIDFlutterResult))] global::Flutter.Internal.FlutterResult result) { var call__handle__ = call.GetHandle(); if (result is null) { ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(result)); } BlockLiteral *block_ptr_result; BlockLiteral block_result; block_result = new BlockLiteral(); block_ptr_result = &block_result; block_result.SetupBlockUnsafe(Trampolines.SDFlutterResult.Handler, result); invoker(BlockPointer, call__handle__, (IntPtr)block_ptr_result); block_ptr_result->CleanupBlock(); }