From 0a6e7769bf3c14df54178f22304a0987f7cd9470 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Tue, 7 Jan 2025 12:18:45 +1100 Subject: [PATCH 1/4] [ffigen] Experiment to remove synth blocks --- .../lib/src/code_generator/objc_block.dart | 150 +- .../objc_built_in_functions.dart | 54 +- .../lib/src/code_generator/pointer.dart | 2 +- .../test/native_objc_test/block_test.dart | 110 +- pkgs/objective_c/ffigen_c.yaml | 5 - .../lib/src/c_bindings_generated.dart | 61 +- pkgs/objective_c/lib/src/internal.dart | 17 +- .../src/objective_c_bindings_generated.dart | 2186 +++++++---------- pkgs/objective_c/src/objective_c.c | 24 +- .../src/objective_c_bindings_generated.m | 198 +- pkgs/objective_c/src/objective_c_runtime.h | 30 +- 11 files changed, 1329 insertions(+), 1508 deletions(-) diff --git a/pkgs/ffigen/lib/src/code_generator/objc_block.dart b/pkgs/ffigen/lib/src/code_generator/objc_block.dart index d46c3d913..41c8104a6 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_block.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_block.dart @@ -14,7 +14,7 @@ class ObjCBlock extends BindingType { final Type returnType; final List params; final bool returnsRetained; - ObjCBlockWrapperFuncs? _blockWrappers; + late final ObjCBlockWrapperFuncs _blockWrappers; factory ObjCBlock({ required Type returnType, @@ -59,9 +59,7 @@ class ObjCBlock extends BindingType { required this.returnsRetained, required this.builtInFunctions, }) : super(originalName: name) { - if (hasListener) { - _blockWrappers = builtInFunctions.getBlockTrampolines(this); - } + _blockWrappers = builtInFunctions.getBlockTrampolines(this); } // Generates a human readable name for the block based on the args and return @@ -138,8 +136,10 @@ class ObjCBlock extends BindingType { final callExtension = w.topLevelUniqueNamer.makeUnique('${name}_CallExtension'); - final newPointerBlock = ObjCBuiltInFunctions.newPointerBlock.gen(w); - final newClosureBlock = ObjCBuiltInFunctions.newClosureBlock.gen(w); + final newPointerBlock = 'todo';//ObjCBuiltInFunctions.newPointerBlock.gen(w); + // final newClosureBlock = ObjCBuiltInFunctions.newClosureBlock.gen(w); + final newClosureBlock = _blockWrappers.newClosureBlock.name; + final registerBlockClosure = ObjCBuiltInFunctions.registerBlockClosure.gen(w); final getBlockClosure = ObjCBuiltInFunctions.getBlockClosure.gen(w); final releaseFn = ObjCBuiltInFunctions.objectRelease.gen(w); final wrapBlockingBlockFn = ObjCBuiltInFunctions.wrapBlockingBlock.gen(w); @@ -154,40 +154,40 @@ class ObjCBlock extends BindingType { // Write the function pointer based trampoline function. s.write(''' $returnFfiDartType $funcPtrTrampoline( - $blockCType block, ${func.paramsFfiDartType}) => - block.ref.target.cast<${func.natFnFfiDartType}>() + $voidPtrCType target, ${func.paramsFfiDartType}) => + target.cast<${func.natFnFfiDartType}>() .asFunction<${func.ffiDartType}>()(${func.paramsNameOnly}); -$voidPtrCType $funcPtrCallable = ${w.ffiLibraryPrefix}.Pointer.fromFunction< - ${func.trampCType}>($funcPtrTrampoline $exceptionalReturn).cast(); +final $funcPtrCallable = ${w.ffiLibraryPrefix}.Pointer.fromFunction< + ${func.trampCType}>($funcPtrTrampoline $exceptionalReturn); '''); // Write the closure based trampoline function. s.write(''' $returnFfiDartType $closureTrampoline( - $blockCType block, ${func.paramsFfiDartType}) => - ($getBlockClosure(block) as ${func.ffiDartType})(${func.paramsNameOnly}); -$voidPtrCType $closureCallable = ${w.ffiLibraryPrefix}.Pointer.fromFunction< - ${func.trampCType}>($closureTrampoline $exceptionalReturn).cast(); + $voidPtrCType target, ${func.paramsFfiDartType}) => + ($getBlockClosure(target.address) as ${func.ffiDartType})(${func.paramsNameOnly}); +final $closureCallable = ${w.ffiLibraryPrefix}.Pointer.fromFunction< + ${func.trampCType}>($closureTrampoline $exceptionalReturn); '''); if (hasListener) { // Write the listener trampoline function. s.write(''' $returnFfiDartType $listenerTrampoline( - $blockCType block, ${func.paramsFfiDartType}) { - ($getBlockClosure(block) as ${func.ffiDartType})(${func.paramsNameOnly}); - $releaseFn(block.cast()); + $voidPtrCType target, ${func.paramsFfiDartType}) { + ($getBlockClosure(target.address) as ${func.ffiDartType})(${func.paramsNameOnly}); + // $releaseFn(block.cast()); } ${func.trampNatCallType} $listenerCallable = ${func.trampNatCallType}.listener( $listenerTrampoline $exceptionalReturn)..keepIsolateAlive = false; $returnFfiDartType $blockingTrampoline( - $blockCType block, ${blockingFunc.paramsFfiDartType}) { + $voidPtrCType target, ${blockingFunc.paramsFfiDartType}) { try { - ($getBlockClosure(block) as ${func.ffiDartType})(${func.paramsNameOnly}); + ($getBlockClosure(target.address) as ${func.ffiDartType})(${func.paramsNameOnly}); } catch (e) { } finally { $signalWaiterFn(waiter); - $releaseFn(block.cast()); + // $releaseFn(block.cast()); } } ${blockingFunc.trampNatCallType} $blockingCallable = @@ -231,9 +231,9 @@ abstract final class $name { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static $blockType fromFunctionPointer(${func.natFnPtrCType} ptr) => - $blockType($newPointerBlock($funcPtrCallable, ptr.cast()), - retain: false, release: true); + // static $blockType fromFunctionPointer(${func.natFnPtrCType} ptr) => + // $blockType($newPointerBlock($funcPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -241,8 +241,9 @@ abstract final class $name { /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. static $blockType fromFunction(${func.dartType} fn) => - $blockType($newClosureBlock($closureCallable, $convFn), - retain: false, release: true); + $blockType($newClosureBlock( + $closureCallable, $registerBlockClosure($convFn)), + retain: false, release: true); '''); // Listener block constructor is only available for void blocks. @@ -262,8 +263,8 @@ abstract final class $name { ); final listenerConvFn = '(${func.paramsFfiDartType}) => $listenerConvFnInvocation'; - final wrapListenerFn = _blockWrappers!.listenerWrapper.name; - final wrapBlockingFn = _blockWrappers!.blockingWrapper.name; + final wrapListenerFn = _blockWrappers.listenerWrapper!.name; + final wrapBlockingFn = _blockWrappers.blockingWrapper!.name; s.write(''' @@ -278,7 +279,7 @@ abstract final class $name { /// blocks do not keep the isolate alive. static $blockType listener(${func.dartType} fn) { final raw = $newClosureBlock( - $listenerCallable.nativeFunction.cast(), $listenerConvFn); + $listenerCallable.nativeFunction.cast(), $registerBlockClosure($listenerConvFn)); final wrapper = $wrapListenerFn(raw); $releaseFn(raw.cast()); return $blockType(wrapper, retain: false, release: true); @@ -295,9 +296,9 @@ abstract final class $name { /// indefinitely, or have other undefined behavior. static $blockType blocking(${func.dartType} fn) { final raw = $newClosureBlock( - $blockingCallable.nativeFunction.cast(), $listenerConvFn); + $blockingCallable.nativeFunction.cast(), $registerBlockClosure($listenerConvFn)); final rawListener = $newClosureBlock( - $blockingListenerCallable.nativeFunction.cast(), $listenerConvFn); + $blockingListenerCallable.nativeFunction.cast(), $registerBlockClosure($listenerConvFn)); final wrapper = $wrapBlockingBlockFn($wrapBlockingFn, raw, rawListener); $releaseFn(raw.cast()); $releaseFn(rawListener.cast()); @@ -308,30 +309,30 @@ abstract final class $name { s.write('}\n\n'); // Call operator extension method. - s.write(''' -/// Call operator for `$blockType`. -extension $callExtension on $blockType { - ${returnType.getDartType(w)} call(${func.paramsDartType}) =>'''); - final callMethodArgs = params - .map((p) => p.type.convertDartTypeToFfiDartType( - w, - p.name, - objCRetain: p.objCConsumed, - objCAutorelease: false, - )) - .join(', '); - final callMethodInvocation = ''' -ref.pointer.ref.invoke.cast<${func.trampNatFnCType}>() - .asFunction<${func.trampFfiDartType}>()( - ref.pointer, $callMethodArgs)'''; - s.write(returnType.convertFfiDartTypeToDartType( - w, - callMethodInvocation, - objCRetain: !returnsRetained, - )); - s.write(';\n'); - - s.write('}\n\n'); +// s.write(''' +// /// Call operator for `$blockType`. +// extension $callExtension on $blockType { +// ${returnType.getDartType(w)} call(${func.paramsDartType}) =>'''); +// final callMethodArgs = params +// .map((p) => p.type.convertDartTypeToFfiDartType( +// w, +// p.name, +// objCRetain: p.objCConsumed, +// objCAutorelease: false, +// )) +// .join(', '); +// final callMethodInvocation = ''' +// ref.pointer.ref.invoke.cast<${func.trampNatFnCType}>() +// .asFunction<${func.trampFfiDartType}>()( +// ref.pointer, $callMethodArgs)'''; +// s.write(returnType.convertFfiDartTypeToDartType( +// w, +// callMethodInvocation, +// objCRetain: !returnsRetained, +// )); +// s.write(';\n'); + +// s.write('}\n\n'); return BindingString( type: BindingStringType.objcBlock, string: s.toString()); } @@ -343,9 +344,11 @@ ref.pointer.ref.invoke.cast<${func.trampNatFnCType}>() final argsReceived = []; final retains = []; + final noRetains = []; for (var i = 0; i < params.length; ++i) { final param = params[i]; final argName = 'arg$i'; + noRetains.add(argName); argsReceived.add(param.getNativeType(varName: argName)); retains.add(param.type.generateRetain(argName) ?? argName); } @@ -360,28 +363,46 @@ ref.pointer.ref.invoke.cast<${func.trampNatFnCType}>() ...argsReceived, ].join(', '); - final listenerWrapper = _blockWrappers!.listenerWrapper.name; - final blockingWrapper = _blockWrappers!.blockingWrapper.name; - final listenerName = - w.objCLevelUniqueNamer.makeUnique('_ListenerTrampoline'); + final returnNativeType = returnType.getNativeType(); + + final newClosureBlock = _blockWrappers.newClosureBlock.name; + final blockTypeName = + w.objCLevelUniqueNamer.makeUnique('_BlockType'); final blockingName = w.objCLevelUniqueNamer.makeUnique('_BlockingTrampoline'); + final trampolineArg = + _blockWrappers.trampolineType.getNativeType(varName: 'trampoline'); final s = StringBuffer(); s.write(''' -typedef ${returnType.getNativeType()} (^$listenerName)($argStr); +typedef $returnNativeType (^$blockTypeName)($argStr); __attribute__((visibility("default"))) __attribute__((used)) -$listenerName $listenerWrapper($listenerName block) NS_RETURNS_RETAINED { +$blockTypeName $newClosureBlock( + $trampolineArg, void* target) NS_RETURNS_RETAINED { + return ^$returnNativeType($argStr) { + return trampoline(${['target', ...noRetains].join(', ')}); + }; +} +'''); + + if (hasListener) { + final listenerWrapper = _blockWrappers.listenerWrapper!.name; + final blockingWrapper = _blockWrappers.blockingWrapper!.name; + + s.write(''' + +__attribute__((visibility("default"))) __attribute__((used)) +$blockTypeName $listenerWrapper($blockTypeName block) NS_RETURNS_RETAINED { return ^void($argStr) { ${generateRetain('block')}; block(${retains.join(', ')}); }; } -typedef ${returnType.getNativeType()} (^$blockingName)($blockingArgStr); +typedef $returnNativeType (^$blockingName)($blockingArgStr); __attribute__((visibility("default"))) __attribute__((used)) -$listenerName $blockingWrapper( +$blockTypeName $blockingWrapper( $blockingName block, $blockingName listenerBlock, void* (*newWaiter)(), void (*awaitWaiter)(void*)) NS_RETURNS_RETAINED { NSThread *targetThread = [NSThread currentThread]; @@ -398,6 +419,7 @@ $listenerName $blockingWrapper( }; } '''); + } return BindingString( type: BindingStringType.objcBlock, string: s.toString()); } @@ -500,8 +522,8 @@ class _FnHelper { returnType: returnType, parameters: [ Parameter( - type: PointerType(objCBlockType), - name: 'block', + type: PointerType(voidType), + name: 'target', objCConsumed: false), ...params, ], diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart index 8306d1d7c..f5f212f1d 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart @@ -26,8 +26,7 @@ class ObjCBuiltInFunctions { static const msgSendStretPointer = ObjCImport('msgSendStretPointer'); static const useMsgSendVariants = ObjCImport('useMsgSendVariants'); static const respondsToSelector = ObjCImport('respondsToSelector'); - static const newPointerBlock = ObjCImport('newPointerBlock'); - static const newClosureBlock = ObjCImport('newClosureBlock'); + static const registerBlockClosure = ObjCImport('registerBlockClosure'); static const getBlockClosure = ObjCImport('getBlockClosure'); static const getProtocolMethodSignature = ObjCImport('getProtocolMethodSignature'); @@ -210,13 +209,44 @@ class ObjCBuiltInFunctions { .toList(); final _blockTrampolines = {}; - ObjCBlockWrapperFuncs? getBlockTrampolines(ObjCBlock block) { + ObjCBlockWrapperFuncs getBlockTrampolines(ObjCBlock block) { final id = _methodSigId(block.returnType, block.params); final idHash = fnvHash32(id).toRadixString(36); + final trampolineType = FunctionType( + returnType: block.returnType, + parameters: [ + Parameter( + type: PointerType(voidType), + name: 'target', + objCConsumed: false), + ...block.params, + ], + ); return _blockTrampolines[id] ??= ObjCBlockWrapperFuncs( - _blockTrampolineFunc('_${wrapperName}_wrapListenerBlock_$idHash'), - _blockTrampolineFunc('_${wrapperName}_wrapBlockingBlock_$idHash', - blocking: true), + trampolineType, + Func( + name: '_${wrapperName}_newClosureBlock_$idHash', + returnType: PointerType(objCBlockType), + parameters: [ + Parameter( + name: 'trampoline', + type: PointerType(NativeFunc(trampolineType)), + objCConsumed: false), + Parameter( + type: PointerType(voidType), + name: 'target', + objCConsumed: false), + ], + objCReturnsRetained: true, + isLeaf: true, + isInternal: true, + useNameForLookup: true, + ffiNativeConfig: const FfiNativeConfig(enabled: true), + ), + // TODO: wrap*Block should become new*Block. + block.hasListener ? _blockTrampolineFunc('_${wrapperName}_wrapListenerBlock_$idHash') : null, + block.hasListener ? _blockTrampolineFunc('_${wrapperName}_wrapBlockingBlock_$idHash', + blocking: true) : null, ); } @@ -263,15 +293,21 @@ class ObjCBuiltInFunctions { /// A native trampoline function for a listener block. class ObjCBlockWrapperFuncs extends AstNode { - final Func listenerWrapper; - final Func blockingWrapper; + final FunctionType trampolineType; + final Func newClosureBlock; + final Func? listenerWrapper; + final Func? blockingWrapper; bool objCBindingsGenerated = false; - ObjCBlockWrapperFuncs(this.listenerWrapper, this.blockingWrapper); + ObjCBlockWrapperFuncs( + this.trampolineType, + this.newClosureBlock, this.listenerWrapper, this.blockingWrapper); @override void visitChildren(Visitor visitor) { super.visitChildren(visitor); + visitor.visit(trampolineType); + visitor.visit(newClosureBlock); visitor.visit(listenerWrapper); visitor.visit(blockingWrapper); } diff --git a/pkgs/ffigen/lib/src/code_generator/pointer.dart b/pkgs/ffigen/lib/src/code_generator/pointer.dart index 4df2e867c..f64873a45 100644 --- a/pkgs/ffigen/lib/src/code_generator/pointer.dart +++ b/pkgs/ffigen/lib/src/code_generator/pointer.dart @@ -105,7 +105,7 @@ class IncompleteArray extends PointerType { @override String getNativeType({String varName = ''}) => - '${child.getNativeType()} $varName[]'; + '${child.getNativeType()}* $varName'; @override String toString() => '$child[]'; diff --git a/pkgs/ffigen/test/native_objc_test/block_test.dart b/pkgs/ffigen/test/native_objc_test/block_test.dart index 5da273c5d..557e0256b 100644 --- a/pkgs/ffigen/test/native_objc_test/block_test.dart +++ b/pkgs/ffigen/test/native_objc_test/block_test.dart @@ -65,14 +65,14 @@ void main() { expect(blockTester2.call_(456), 4560); }); - test('Block from function pointer', () { + /*test('Block from function pointer', () { final block = IntBlock.fromFunctionPointer(Pointer.fromFunction(_add100, 999)); final blockTester = BlockTester.newFromBlock_(block); blockTester.pokeBlock(); expect(blockTester.call_(123), 223); expect(block(123), 223); - }); + });*/ int Function(int) makeAdder(int addTo) { return (int x) => addTo + x; @@ -83,7 +83,7 @@ void main() { final blockTester = BlockTester.newFromBlock_(block); blockTester.pokeBlock(); expect(blockTester.call_(123), 4123); - expect(block(123), 4123); + // expect(block(123), 4123); }); test('Listener block same thread', () async { @@ -169,7 +169,7 @@ void main() { expect(await resultCompleter.future, 123456); }); - test('Blocking block manual invocation', () { + /*test('Blocking block manual invocation', () { int value = 0; final block = VoidBlock.blocking(() { waitSync(Duration(milliseconds: 100)); @@ -177,13 +177,13 @@ void main() { }); block(); expect(value, 123); - }); + });*/ test('Float block', () { final block = FloatBlock.fromFunction((double x) { return x + 4.56; }); - expect(block(1.23), closeTo(5.79, 1e-6)); + // expect(block(1.23), closeTo(5.79, 1e-6)); expect(BlockTester.callFloatBlock_(block), closeTo(5.79, 1e-6)); }); @@ -191,7 +191,7 @@ void main() { final block = DoubleBlock.fromFunction((double x) { return x + 4.56; }); - expect(block(1.23), closeTo(5.79, 1e-6)); + // expect(block(1.23), closeTo(5.79, 1e-6)); expect(BlockTester.callDoubleBlock_(block), closeTo(5.79, 1e-6)); }); @@ -215,11 +215,11 @@ void main() { return temp; }); - final result1 = block(input); - expect(result1.x, 3.4); - expect(result1.y, 5.6); - expect(result1.z, 7.8); - expect(result1.w, 1.2); + // final result1 = block(input); + // expect(result1.x, 3.4); + // expect(result1.y, 5.6); + // expect(result1.z, 7.8); + // expect(result1.w, 1.2); final result2 = BlockTester.callVec4Block_(block); expect(result2.x, 3.4); @@ -235,8 +235,8 @@ void main() { sel = x.toDartString(); }); - block('Hello'.toSelector()); - expect(sel, 'Hello'); + // block('Hello'.toSelector()); + // expect(sel, 'Hello'); BlockTester.callSelectorBlock_(block); expect(sel, 'Select'); @@ -249,14 +249,14 @@ void main() { return x; }); - final obj = DummyObject.new1(); - final result1 = block(obj); - expect(result1, obj); - expect(isCalled, isTrue); + // final obj = DummyObject.new1(); + // final result1 = block(obj); + // expect(result1, obj); + // expect(isCalled, isTrue); isCalled = false; final result2 = BlockTester.callObjectBlock_(block); - expect(result2, isNot(obj)); + // expect(result2, isNot(obj)); expect(result2.ref.pointer, isNot(nullptr)); expect(isCalled, isTrue); }); @@ -268,15 +268,15 @@ void main() { return x; }); - final obj = DummyObject.new1(); - final result1 = block(obj); - expect(result1, obj); - expect(isCalled, isTrue); + // final obj = DummyObject.new1(); + // final result1 = block(obj); + // expect(result1, obj); + // expect(isCalled, isTrue); - isCalled = false; - final result2 = block(null); - expect(result2, isNull); - expect(isCalled, isTrue); + // isCalled = false; + // final result2 = block(null); + // expect(result2, isNull); + // expect(isCalled, isTrue); isCalled = false; final result3 = BlockTester.callNullableObjectBlock_(block); @@ -289,11 +289,11 @@ void main() { final block = NullableStringBlock.fromFunction( (NSString? x) => '$x Cat'.toNSString()); - final result1 = block('Dog'.toNSString()); - expect(result1.toString(), 'Dog Cat'); + // final result1 = block('Dog'.toNSString()); + // expect(result1.toString(), 'Dog Cat'); - final result2 = block(null); - expect(result2.toString(), 'null Cat'); + // final result2 = block(null); + // expect(result2.toString(), 'null Cat'); final result3 = BlockTester.callNullableStringBlock_(block); expect(result3.toString(), 'Lizard Cat'); @@ -373,7 +373,7 @@ void main() { await hasRun.future; }); - test('Block block', () { + /*test('Block block', () { final blockBlock = BlockBlock.fromFunction((ObjCBlock intBlock) { return IntBlock.fromFunction((int x) { @@ -402,9 +402,9 @@ void main() { final result2 = BlockTester.newBlock_withMult_(blockBlock, 2); expect(result2(1), 14); - }); + });*/ - Pointer funcPointerBlockRefCountTest() { + /*Pointer funcPointerBlockRefCountTest() { final block = IntBlock.fromFunctionPointer(Pointer.fromFunction(_add100, 999)); expect(internal_for_testing.blockHasRegisteredClosure(block.ref.pointer), @@ -417,9 +417,9 @@ void main() { final rawBlock = funcPointerBlockRefCountTest(); doGC(); expect(blockRetainCount(rawBlock), 0); - }, skip: !canDoGC); + }, skip: !canDoGC);*/ - Pointer funcBlockRefCountTest() { + /*Pointer funcBlockRefCountTest() { final block = IntBlock.fromFunction(makeAdder(4000)); expect(internal_for_testing.blockHasRegisteredClosure(block.ref.pointer), true); @@ -444,9 +444,9 @@ void main() { final rawBlock = block.ref.retainAndReturnPointer(); expect(blockRetainCount(rawBlock), 2); return rawBlock; - } + }*/ - int blockManualRetainRefCountTest2(Pointer rawBlock) { + /*int blockManualRetainRefCountTest2(Pointer rawBlock) { final block = IntBlock.castFromPointer(rawBlock.cast(), retain: false, release: true); return blockRetainCount(block.ref.pointer); @@ -462,9 +462,9 @@ void main() { expect(blockRetainCount(rawBlock), 0); expect(internal_for_testing.blockHasRegisteredClosure(rawBlock.cast()), false); - }, skip: !canDoGC); + }, skip: !canDoGC);*/ - (Pointer, Pointer, Pointer) + /*(Pointer, Pointer, Pointer) blockBlockDartCallRefCountTest() { final pool = lib.objc_autoreleasePoolPush(); final inputBlock = IntBlock.fromFunction((int x) { @@ -523,9 +523,9 @@ void main() { expect(blockRetainCount(outputBlock), 0); expect(internal_for_testing.blockHasRegisteredClosure(outputBlock.cast()), false); - }, skip: !canDoGC); + }, skip: !canDoGC);*/ - (Pointer, Pointer, Pointer) + /*(Pointer, Pointer, Pointer) blockBlockObjCCallRefCountTest() { final pool = lib.objc_autoreleasePoolPush(); late Pointer inputBlock; @@ -574,9 +574,9 @@ void main() { expect(blockRetainCount(outputBlock), 0); expect(internal_for_testing.blockHasRegisteredClosure(outputBlock.cast()), false); - }, skip: !canDoGC); + }, skip: !canDoGC);*/ - (Pointer, Pointer, Pointer) + /*(Pointer, Pointer, Pointer) nativeBlockBlockDartCallRefCountTest() { final pool = lib.objc_autoreleasePoolPush(); final inputBlock = IntBlock.fromFunction((int x) { @@ -608,13 +608,13 @@ void main() { expect(blockRetainCount(inputBlock), 0); expect(blockRetainCount(blockBlock), 0); expect(blockRetainCount(outputBlock), 0); - }, skip: !canDoGC); + }, skip: !canDoGC);*/ (Pointer, Pointer) nativeBlockBlockObjCCallRefCountTest() { final blockBlock = BlockTester.newBlockBlock_(7); final outputBlock = BlockTester.newBlock_withMult_(blockBlock, 2); - expect(outputBlock(1), 14); + expect(BlockTester.newFromBlock_(outputBlock).call_(1), 14); doGC(); expect(blockRetainCount(blockBlock.ref.pointer), 1); @@ -629,7 +629,7 @@ void main() { expect(blockRetainCount(outputBlock), 0); }, skip: !canDoGC); - (Pointer, Pointer) objectBlockRefCountTest(Allocator alloc) { + /*(Pointer, Pointer) objectBlockRefCountTest(Allocator alloc) { final pool = lib.objc_autoreleasePoolPush(); final inputCounter = alloc(); final outputCounter = alloc(); @@ -656,7 +656,7 @@ void main() { expect(inputCounter.value, 0); expect(outputCounter.value, 0); }); - }, skip: !canDoGC); + }, skip: !canDoGC);*/ (Pointer, Pointer) objectNativeBlockRefCountTest( Allocator alloc) { @@ -709,7 +709,7 @@ void main() { thread.start(); await hasRun.future; - expect(inputBlock(123), 12300); + expect(BlockTester.newFromBlock_(inputBlock).call_(123), 12300); thread.ref.release(); doGC(); @@ -726,7 +726,7 @@ void main() { await Future.delayed(Duration.zero); // Let dispose message arrive. doGC(); - expect(blockRetainCount(inputBlock), 0); + // expect(blockRetainCount(inputBlock), 0); expect(blockRetainCount(blockBlock), 0); }, skip: !canDoGC); @@ -759,7 +759,7 @@ void main() { expect(objectRetainCount(rawDummyObject), 0); }, skip: !canDoGC); - test('Blocking block ref counting new thread', () async { + /*test('Blocking block ref counting new thread', () async { final completer = Completer(); DummyObject? dummyObject = DummyObject.new1(); DartObjectListenerBlock? block = @@ -790,9 +790,9 @@ void main() { expect(blockRetainCount(rawBlock), 0); expect(objectRetainCount(rawDummyObject), 0); - }, skip: !canDoGC); + }, skip: !canDoGC);*/ - test('Block fields have sensible values', () { + /*test('Block fields have sensible values', () { final block = IntBlock.fromFunction(makeAdder(4000)); final blockPtr = block.ref.pointer; expect(blockPtr.ref.isa, isNot(0)); @@ -806,7 +806,7 @@ void main() { expect(descPtr.ref.copy_helper, nullptr); expect(descPtr.ref.dispose_helper, isNot(nullptr)); expect(descPtr.ref.signature, nullptr); - }); + });*/ test('Block trampoline args converted to id', () { final objCBindings = @@ -860,7 +860,7 @@ void main() { await flutterDoGC(); expect(blockRetainCount(blockPtr), 0); - expect(objectRetainCount(objectPtr), 0); + // expect(objectRetainCount(objectPtr), 0); } }); }); diff --git a/pkgs/objective_c/ffigen_c.yaml b/pkgs/objective_c/ffigen_c.yaml index a1a733118..d83764bed 100644 --- a/pkgs/objective_c/ffigen_c.yaml +++ b/pkgs/objective_c/ffigen_c.yaml @@ -57,11 +57,6 @@ functions: 'objc_getProtocol': 'getProtocol' 'protocol_getMethodDescription': 'getMethodDescription' 'protocol_getName': 'getProtocolName' -globals: - include: - - '_NSConcrete.*Block' - rename: - '_(.*)': '$1' typedefs: include: - 'ObjC.*' diff --git a/pkgs/objective_c/lib/src/c_bindings_generated.dart b/pkgs/objective_c/lib/src/c_bindings_generated.dart index be88ca160..618529460 100644 --- a/pkgs/objective_c/lib/src/c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/c_bindings_generated.dart @@ -47,27 +47,6 @@ external int Dart_InitializeApiDL( ffi.Pointer data, ); -@ffi.Array.multi([32]) -@ffi.Native>>(symbol: "_NSConcreteAutoBlock") -external ffi.Array> NSConcreteAutoBlock; - -@ffi.Array.multi([32]) -@ffi.Native>>( - symbol: "_NSConcreteFinalizingBlock") -external ffi.Array> NSConcreteFinalizingBlock; - -@ffi.Array.multi([32]) -@ffi.Native>>(symbol: "_NSConcreteGlobalBlock") -external ffi.Array> NSConcreteGlobalBlock; - -@ffi.Array.multi([32]) -@ffi.Native>>(symbol: "_NSConcreteMallocBlock") -external ffi.Array> NSConcreteMallocBlock; - -@ffi.Array.multi([32]) -@ffi.Native>>(symbol: "_NSConcreteStackBlock") -external ffi.Array> NSConcreteStackBlock; - @ffi.Native)>( symbol: "DOBJC_awaitWaiter") external void awaitWaiter( @@ -208,7 +187,6 @@ external void signalWaiter( ); typedef Dart_FinalizableHandle = ffi.Pointer<_Dart_FinalizableHandle>; -typedef ObjCBlockDesc = _ObjCBlockDesc; typedef ObjCBlockImpl = _ObjCBlockImpl; typedef ObjCMethodDesc = _ObjCMethodDesc; typedef ObjCObject = _ObjCObject; @@ -217,44 +195,7 @@ typedef ObjCSelector = _ObjCSelector; final class _Dart_FinalizableHandle extends ffi.Opaque {} -final class _ObjCBlockDesc extends ffi.Struct { - @ffi.UnsignedLong() - external int reserved; - - @ffi.UnsignedLong() - external int size; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer dst, ffi.Pointer src)>> - copy_helper; - - external ffi - .Pointer src)>> - dispose_helper; - - external ffi.Pointer signature; -} - -final class _ObjCBlockImpl extends ffi.Struct { - external ffi.Pointer isa; - - @ffi.Int() - external int flags; - - @ffi.Int() - external int reserved; - - external ffi.Pointer invoke; - - external ffi.Pointer descriptor; - - external ffi.Pointer target; - - @ffi.Int64() - external int dispose_port; -} +final class _ObjCBlockImpl extends ffi.Opaque {} final class _ObjCMethodDesc extends ffi.Struct { external ffi.Pointer name; diff --git a/pkgs/objective_c/lib/src/internal.dart b/pkgs/objective_c/lib/src/internal.dart index af40dad25..5e8528770 100644 --- a/pkgs/objective_c/lib/src/internal.dart +++ b/pkgs/objective_c/lib/src/internal.dart @@ -345,7 +345,7 @@ class ObjCBlockBase extends _ObjCRefHolder { : super(_ObjCBlockRef(ptr, retain: retain, release: release)); } -Pointer _newBlockDesc( +/*Pointer _newBlockDesc( Pointer> disposeHelper) { final desc = calloc.allocate(sizeOf()); desc.ref.reserved = 0; @@ -392,13 +392,13 @@ BlockPtr newClosureBlock(VoidPtr invoke, Function fn) => _newBlock( /// Only for use by ffigen bindings. BlockPtr newPointerBlock(VoidPtr invoke, VoidPtr target) => - _newBlock(invoke, target, _pointerBlockDesc, 0, 0); + _newBlock(invoke, target, _pointerBlockDesc, 0, 0);*/ final _blockClosureRegistry = {}; int _blockClosureRegistryLastId = 0; -final _blockClosureDisposer = () { +/*final _blockClosureDisposer = () { _ensureDartAPI(); return RawReceivePort((dynamic msg) { final id = msg as int; @@ -406,9 +406,9 @@ final _blockClosureDisposer = () { _blockClosureRegistry.remove(id); }, 'ObjCBlockClosureDisposer') ..keepIsolateAlive = false; -}(); +}();*/ -VoidPtr _registerBlockClosure(Function closure) { +VoidPtr registerBlockClosure(Function closure) { ++_blockClosureRegistryLastId; assert(!_blockClosureRegistry.containsKey(_blockClosureRegistryLastId)); _blockClosureRegistry[_blockClosureRegistryLastId] = closure; @@ -416,8 +416,7 @@ VoidPtr _registerBlockClosure(Function closure) { } /// Only for use by ffigen bindings. -Function getBlockClosure(BlockPtr block) { - var id = block.ref.target.address; +Function getBlockClosure(int id) { assert(_blockClosureRegistry.containsKey(id)); return _blockClosureRegistry[id]!; } @@ -438,8 +437,8 @@ BlockPtr wrapBlockingBlock( ); // Not exported by ../objective_c.dart, because they're only for testing. -bool blockHasRegisteredClosure(BlockPtr block) => - _blockClosureRegistry.containsKey(block.ref.target.address); +bool blockHasRegisteredClosure(int id) => + _blockClosureRegistry.containsKey(id); bool isValidBlock(BlockPtr block) => c.isValidBlock(block); bool isValidClass(ObjectPtr clazz) => _isValidClass(clazz); bool isValidObject(ObjectPtr object) => _isValidObject(object); diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index 767000c3e..36b235003 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -36,6 +36,361 @@ set NSLocalizedDescriptionKey(NSString value) { _NSLocalizedDescriptionKey = value.ref.retainAndReturnPointer(); } +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer> arg2, + ffi.UnsignedLong arg3)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_17ap02x( + ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer> arg2, + ffi.UnsignedLong arg3)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.UnsignedLong arg2)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_18d6mda( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.UnsignedLong arg2)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer<_NSZone> Function( + ffi.Pointer target, ffi.Pointer arg0)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_1a8cl66( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer<_NSZone> Function( + ffi.Pointer target, ffi.Pointer arg0)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_1c0c70u( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer target, ffi.Pointer arg0)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_1ckyi24( + ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer target, ffi.Pointer arg0)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_1j2nt86( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_1m9h2n( + ffi.Pointer< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer target, ffi.Pointer arg0)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_1yesha9( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer target, ffi.Pointer arg0)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer> arg3)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_e2pkq8( + ffi.Pointer< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer> arg3)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer target, ffi.Pointer arg0)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_e3qsqz( + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer target, ffi.Pointer arg0)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer target, ffi.Pointer arg0)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_ovsamd( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer target, ffi.Pointer arg0)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_ozkafd( + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_u8b97m( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_w1e3k0( + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_wjovn7( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_wjvic9( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>> + trampoline, + ffi.Pointer target, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>>, + ffi.Pointer)>(isLeaf: true) +external ffi.Pointer + _ObjectiveCBindings_newClosureBlock_ykn0t6( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1)>> + trampoline, + ffi.Pointer target, +); + @ffi.Native< ffi.Pointer Function( ffi.Pointer, @@ -8622,8 +8977,8 @@ class NSValue extends NSObject { } ffi.Pointer _ObjCBlock_NSString_ffiVoid_fnPtrTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - block.ref.target + ffi.Pointer target, ffi.Pointer arg0) => + target .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -8631,22 +8986,16 @@ ffi.Pointer _ObjCBlock_NSString_ffiVoid_fnPtrTrampoline( .asFunction< ffi.Pointer Function( ffi.Pointer)>()(arg0); -ffi.Pointer _ObjCBlock_NSString_ffiVoid_fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_NSString_ffiVoid_fnPtrTrampoline) - .cast(); +final _ObjCBlock_NSString_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>(_ObjCBlock_NSString_ffiVoid_fnPtrTrampoline); ffi.Pointer _ObjCBlock_NSString_ffiVoid_closureTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - (objc.getBlockClosure(block) as ffi.Pointer Function( - ffi.Pointer))(arg0); -ffi.Pointer _ObjCBlock_NSString_ffiVoid_closureCallable = - ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_NSString_ffiVoid_closureTrampoline) - .cast(); + ffi.Pointer target, ffi.Pointer arg0) => + (objc.getBlockClosure(target.address) as ffi.Pointer + Function(ffi.Pointer))(arg0); +final _ObjCBlock_NSString_ffiVoid_closureCallable = ffi.Pointer.fromFunction< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>(_ObjCBlock_NSString_ffiVoid_closureTrampoline); /// Construction methods for `objc.ObjCBlock)>`. abstract final class ObjCBlock_NSString_ffiVoid { @@ -8662,17 +9011,9 @@ abstract final class ObjCBlock_NSString_ffiVoid { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock)> fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer arg0)>> - ptr) => - objc.ObjCBlock)>( - objc.newPointerBlock( - _ObjCBlock_NSString_ffiVoid_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock)> fromFunctionPointer(ffi.Pointer Function(ffi.Pointer arg0)>> ptr) => + // objc.ObjCBlock)>(todo(_ObjCBlock_NSString_ffiVoid_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -8682,54 +9023,33 @@ abstract final class ObjCBlock_NSString_ffiVoid { static objc.ObjCBlock)> fromFunction( NSString Function(ffi.Pointer) fn) => objc.ObjCBlock)>( - objc.newClosureBlock( + _ObjectiveCBindings_newClosureBlock_1yesha9( _ObjCBlock_NSString_ffiVoid_closureCallable, - (ffi.Pointer arg0) => - fn(arg0).ref.retainAndAutorelease()), + objc.registerBlockClosure((ffi.Pointer arg0) => + fn(arg0).ref.retainAndAutorelease())), retain: false, release: true); } -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_NSString_ffiVoid_CallExtension - on objc.ObjCBlock)> { - NSString call(ffi.Pointer arg0) => NSString.castFromPointer( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer block, - ffi.Pointer arg0)>>() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>()(ref.pointer, arg0), - retain: true, - release: true); -} - int _ObjCBlock_NSUInteger_ffiVoid_fnPtrTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - block.ref.target + ffi.Pointer target, ffi.Pointer arg0) => + target .cast< ffi.NativeFunction< ffi.UnsignedLong Function(ffi.Pointer arg0)>>() .asFunction)>()(arg0); -ffi.Pointer _ObjCBlock_NSUInteger_ffiVoid_fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.UnsignedLong Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_NSUInteger_ffiVoid_fnPtrTrampoline, 0) - .cast(); +final _ObjCBlock_NSUInteger_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< + ffi.UnsignedLong Function( + ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_NSUInteger_ffiVoid_fnPtrTrampoline, 0); int _ObjCBlock_NSUInteger_ffiVoid_closureTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - (objc.getBlockClosure(block) as int Function(ffi.Pointer))(arg0); -ffi.Pointer _ObjCBlock_NSUInteger_ffiVoid_closureCallable = - ffi.Pointer.fromFunction< - ffi.UnsignedLong Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_NSUInteger_ffiVoid_closureTrampoline, 0) - .cast(); + ffi.Pointer target, ffi.Pointer arg0) => + (objc.getBlockClosure(target.address) as int Function( + ffi.Pointer))(arg0); +final _ObjCBlock_NSUInteger_ffiVoid_closureCallable = ffi.Pointer.fromFunction< + ffi.UnsignedLong Function( + ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_NSUInteger_ffiVoid_closureTrampoline, 0); /// Construction methods for `objc.ObjCBlock)>`. abstract final class ObjCBlock_NSUInteger_ffiVoid { @@ -8747,17 +9067,9 @@ abstract final class ObjCBlock_NSUInteger_ffiVoid { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer arg0)>> - ptr) => - objc.ObjCBlock)>( - objc.newPointerBlock(_ObjCBlock_NSUInteger_ffiVoid_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock)> fromFunctionPointer(ffi.Pointer arg0)>> ptr) => + // objc.ObjCBlock)>(todo(_ObjCBlock_NSUInteger_ffiVoid_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -8767,33 +9079,21 @@ abstract final class ObjCBlock_NSUInteger_ffiVoid { static objc.ObjCBlock)> fromFunction(int Function(ffi.Pointer) fn) => objc.ObjCBlock)>( - objc.newClosureBlock( + _ObjectiveCBindings_newClosureBlock_1ckyi24( _ObjCBlock_NSUInteger_ffiVoid_closureCallable, - (ffi.Pointer arg0) => fn(arg0)), + objc.registerBlockClosure( + (ffi.Pointer arg0) => fn(arg0))), retain: false, release: true); } -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_NSUInteger_ffiVoid_CallExtension - on objc.ObjCBlock)> { - int call(ffi.Pointer arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.UnsignedLong Function(ffi.Pointer block, - ffi.Pointer arg0)>>() - .asFunction< - int Function(ffi.Pointer, - ffi.Pointer)>()(ref.pointer, arg0); -} - int _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer> arg2, int arg3) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.UnsignedLong Function( @@ -8807,41 +9107,37 @@ int _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteg ffi.Pointer, ffi.Pointer>, int)>()(arg0, arg1, arg2, arg3); -ffi.Pointer - _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_fnPtrCallable = +final _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong)>( - _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_fnPtrTrampoline, - 0) - .cast(); + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.UnsignedLong)>( + _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_fnPtrTrampoline, + 0); int _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer> arg2, int arg3) => - (objc.getBlockClosure(block) as int Function( + (objc.getBlockClosure(target.address) as int Function( ffi.Pointer, ffi.Pointer, ffi.Pointer>, int))(arg0, arg1, arg2, arg3); -ffi.Pointer - _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_closureCallable = +final _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_closureCallable = ffi.Pointer.fromFunction< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong)>( - _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_closureTrampoline, - 0) - .cast(); + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.UnsignedLong)>( + _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_closureTrampoline, + 0); /// Construction methods for `objc.ObjCBlock, ffi.Pointer, ffi.Pointer>, ffi.UnsignedLong)>`. abstract final class ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger { @@ -8866,95 +9162,47 @@ abstract final class ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObj /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong)> - fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer> arg2, ffi.UnsignedLong arg3)>> ptr) => - objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong)>( - objc.newPointerBlock(_ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock, ffi.Pointer, ffi.Pointer>, ffi.UnsignedLong)> fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer> arg2, ffi.UnsignedLong arg3)>> ptr) => + // objc.ObjCBlock, ffi.Pointer, ffi.Pointer>, ffi.UnsignedLong)>(todo(_ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong)> fromFunction(int Function(ffi.Pointer, ffi.Pointer, ffi.Pointer>, int) fn) => - objc.ObjCBlock, ffi.Pointer, ffi.Pointer>, ffi.UnsignedLong)>( - objc.newClosureBlock( - _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer> arg2, int arg3) => - fn(arg0, arg1, arg2, arg3)), - retain: false, - release: true); -} - -/// Call operator for `objc.ObjCBlock, ffi.Pointer, ffi.Pointer>, ffi.UnsignedLong)>`. -extension ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_CallExtension - on objc.ObjCBlock< - ffi.UnsignedLong Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ffi.UnsignedLong)> { - int call(ffi.Pointer arg0, ffi.Pointer arg1, - ffi.Pointer> arg2, int arg3) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer> arg2, - ffi.UnsignedLong arg3)>>() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - int)>()(ref.pointer, arg0, arg1, arg2, arg3); + static objc.ObjCBlock, ffi.Pointer, ffi.Pointer>, ffi.UnsignedLong)> + fromFunction(int Function(ffi.Pointer, ffi.Pointer, ffi.Pointer>, int) fn) => + objc.ObjCBlock, ffi.Pointer, ffi.Pointer>, ffi.UnsignedLong)>( + _ObjectiveCBindings_newClosureBlock_17ap02x( + _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_closureCallable, + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer> arg2, + int arg3) => + fn(arg0, arg1, arg2, arg3))), + retain: false, + release: true); } ffi.Pointer<_NSZone> _ObjCBlock_NSZone_ffiVoid_fnPtrTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - block.ref.target + ffi.Pointer target, ffi.Pointer arg0) => + target .cast< ffi.NativeFunction< ffi.Pointer<_NSZone> Function(ffi.Pointer arg0)>>() .asFunction< ffi.Pointer<_NSZone> Function(ffi.Pointer)>()(arg0); -ffi.Pointer _ObjCBlock_NSZone_ffiVoid_fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Pointer<_NSZone> Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_NSZone_ffiVoid_fnPtrTrampoline) - .cast(); +final _ObjCBlock_NSZone_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< + ffi.Pointer<_NSZone> Function(ffi.Pointer, + ffi.Pointer)>(_ObjCBlock_NSZone_ffiVoid_fnPtrTrampoline); ffi.Pointer<_NSZone> _ObjCBlock_NSZone_ffiVoid_closureTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - (objc.getBlockClosure(block) as ffi.Pointer<_NSZone> Function( + ffi.Pointer target, ffi.Pointer arg0) => + (objc.getBlockClosure(target.address) as ffi.Pointer<_NSZone> Function( ffi.Pointer))(arg0); -ffi.Pointer _ObjCBlock_NSZone_ffiVoid_closureCallable = - ffi.Pointer.fromFunction< - ffi.Pointer<_NSZone> Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_NSZone_ffiVoid_closureTrampoline) - .cast(); +final _ObjCBlock_NSZone_ffiVoid_closureCallable = ffi.Pointer.fromFunction< + ffi.Pointer<_NSZone> Function(ffi.Pointer, + ffi.Pointer)>(_ObjCBlock_NSZone_ffiVoid_closureTrampoline); /// Construction methods for `objc.ObjCBlock Function(ffi.Pointer)>`. abstract final class ObjCBlock_NSZone_ffiVoid { @@ -8972,17 +9220,9 @@ abstract final class ObjCBlock_NSZone_ffiVoid { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock Function(ffi.Pointer)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer<_NSZone> Function( - ffi.Pointer arg0)>> - ptr) => - objc.ObjCBlock Function(ffi.Pointer)>( - objc.newPointerBlock(_ObjCBlock_NSZone_ffiVoid_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock Function(ffi.Pointer)> fromFunctionPointer(ffi.Pointer Function(ffi.Pointer arg0)>> ptr) => + // objc.ObjCBlock Function(ffi.Pointer)>(todo(_ObjCBlock_NSZone_ffiVoid_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -8992,48 +9232,30 @@ abstract final class ObjCBlock_NSZone_ffiVoid { static objc.ObjCBlock Function(ffi.Pointer)> fromFunction(ffi.Pointer<_NSZone> Function(ffi.Pointer) fn) => objc.ObjCBlock Function(ffi.Pointer)>( - objc.newClosureBlock(_ObjCBlock_NSZone_ffiVoid_closureCallable, - (ffi.Pointer arg0) => fn(arg0)), + _ObjectiveCBindings_newClosureBlock_1a8cl66( + _ObjCBlock_NSZone_ffiVoid_closureCallable, + objc.registerBlockClosure( + (ffi.Pointer arg0) => fn(arg0))), retain: false, release: true); } -/// Call operator for `objc.ObjCBlock Function(ffi.Pointer)>`. -extension ObjCBlock_NSZone_ffiVoid_CallExtension - on objc.ObjCBlock Function(ffi.Pointer)> { - ffi.Pointer<_NSZone> call(ffi.Pointer arg0) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Pointer<_NSZone> Function( - ffi.Pointer block, - ffi.Pointer arg0)>>() - .asFunction< - ffi.Pointer<_NSZone> Function(ffi.Pointer, - ffi.Pointer)>()(ref.pointer, arg0); -} - bool _ObjCBlock_bool_ffiVoid_fnPtrTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - block.ref.target + ffi.Pointer target, ffi.Pointer arg0) => + target .cast< ffi.NativeFunction arg0)>>() .asFunction)>()(arg0); -ffi.Pointer _ObjCBlock_bool_ffiVoid_fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Bool Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_bool_ffiVoid_fnPtrTrampoline, false) - .cast(); +final _ObjCBlock_bool_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_bool_ffiVoid_fnPtrTrampoline, false); bool _ObjCBlock_bool_ffiVoid_closureTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - (objc.getBlockClosure(block) as bool Function(ffi.Pointer))(arg0); -ffi.Pointer _ObjCBlock_bool_ffiVoid_closureCallable = - ffi.Pointer.fromFunction< - ffi.Bool Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_bool_ffiVoid_closureTrampoline, false) - .cast(); + ffi.Pointer target, ffi.Pointer arg0) => + (objc.getBlockClosure(target.address) as bool Function( + ffi.Pointer))(arg0); +final _ObjCBlock_bool_ffiVoid_closureCallable = ffi.Pointer.fromFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_bool_ffiVoid_closureTrampoline, false); /// Construction methods for `objc.ObjCBlock)>`. abstract final class ObjCBlock_bool_ffiVoid { @@ -9049,16 +9271,9 @@ abstract final class ObjCBlock_bool_ffiVoid { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer arg0)>> - ptr) => - objc.ObjCBlock)>( - objc.newPointerBlock(_ObjCBlock_bool_ffiVoid_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock)> fromFunctionPointer(ffi.Pointer arg0)>> ptr) => + // objc.ObjCBlock)>(todo(_ObjCBlock_bool_ffiVoid_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -9068,30 +9283,19 @@ abstract final class ObjCBlock_bool_ffiVoid { static objc.ObjCBlock)> fromFunction( bool Function(ffi.Pointer) fn) => objc.ObjCBlock)>( - objc.newClosureBlock(_ObjCBlock_bool_ffiVoid_closureCallable, - (ffi.Pointer arg0) => fn(arg0)), + _ObjectiveCBindings_newClosureBlock_e3qsqz( + _ObjCBlock_bool_ffiVoid_closureCallable, + objc.registerBlockClosure( + (ffi.Pointer arg0) => fn(arg0))), retain: false, release: true); } -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_bool_ffiVoid_CallExtension - on objc.ObjCBlock)> { - bool call(ffi.Pointer arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer block, - ffi.Pointer arg0)>>() - .asFunction< - bool Function(ffi.Pointer, - ffi.Pointer)>()(ref.pointer, arg0); -} - bool _ObjCBlock_bool_ffiVoid_Protocol_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.Bool Function(ffi.Pointer arg0, @@ -9099,24 +9303,21 @@ bool _ObjCBlock_bool_ffiVoid_Protocol_fnPtrTrampoline( .asFunction< bool Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); -ffi.Pointer _ObjCBlock_bool_ffiVoid_Protocol_fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_bool_ffiVoid_Protocol_fnPtrTrampoline, false) - .cast(); +final _ObjCBlock_bool_ffiVoid_Protocol_fnPtrCallable = ffi.Pointer.fromFunction< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ffiVoid_Protocol_fnPtrTrampoline, false); bool _ObjCBlock_bool_ffiVoid_Protocol_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(block) as bool Function( + (objc.getBlockClosure(target.address) as bool Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); -ffi.Pointer _ObjCBlock_bool_ffiVoid_Protocol_closureCallable = +final _ObjCBlock_bool_ffiVoid_Protocol_closureCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_bool_ffiVoid_Protocol_closureTrampoline, false) - .cast(); + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ffiVoid_Protocol_closureTrampoline, false); /// Construction methods for `objc.ObjCBlock, Protocol)>`. abstract final class ObjCBlock_bool_ffiVoid_Protocol { @@ -9134,58 +9335,33 @@ abstract final class ObjCBlock_bool_ffiVoid_Protocol { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock, Protocol)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer arg0, - ffi.Pointer arg1)>> - ptr) => - objc.ObjCBlock, Protocol)>( - objc.newPointerBlock(_ObjCBlock_bool_ffiVoid_Protocol_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock, Protocol)> fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1)>> ptr) => + // objc.ObjCBlock, Protocol)>(todo(_ObjCBlock_bool_ffiVoid_Protocol_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock, Protocol)> - fromFunction(bool Function(ffi.Pointer, Protocol) fn) => - objc.ObjCBlock, Protocol)>( - objc.newClosureBlock( - _ObjCBlock_bool_ffiVoid_Protocol_closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => - fn( - arg0, - Protocol.castFromPointer(arg1, - retain: true, release: true))), - retain: false, - release: true); -} - -/// Call operator for `objc.ObjCBlock, Protocol)>`. -extension ObjCBlock_bool_ffiVoid_Protocol_CallExtension - on objc.ObjCBlock, Protocol)> { - bool call(ffi.Pointer arg0, Protocol arg1) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1)>>() - .asFunction< - bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>()( - ref.pointer, arg0, arg1.ref.pointer); + static objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer, Protocol)> fromFunction( + bool Function(ffi.Pointer, Protocol) fn) => + objc.ObjCBlock, Protocol)>( + _ObjectiveCBindings_newClosureBlock_ozkafd( + _ObjCBlock_bool_ffiVoid_Protocol_closureCallable, + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(arg0, Protocol.castFromPointer(arg1, retain: true, release: true)))), + retain: false, + release: true); } bool _ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.Bool Function(ffi.Pointer arg0, @@ -9193,24 +9369,22 @@ bool _ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrTrampoline( .asFunction< bool Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); -ffi.Pointer _ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrCallable = +final _ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrTrampoline, false) - .cast(); + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrTrampoline, false); bool _ObjCBlock_bool_ffiVoid_objcObjCObject_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(block) as bool Function( + (objc.getBlockClosure(target.address) as bool Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); -ffi.Pointer _ObjCBlock_bool_ffiVoid_objcObjCObject_closureCallable = +final _ObjCBlock_bool_ffiVoid_objcObjCObject_closureCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_bool_ffiVoid_objcObjCObject_closureTrampoline, false) - .cast(); + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ffiVoid_objcObjCObject_closureTrampoline, false); /// Construction methods for `objc.ObjCBlock, ffi.Pointer)>`. abstract final class ObjCBlock_bool_ffiVoid_objcObjCObject { @@ -9232,16 +9406,9 @@ abstract final class ObjCBlock_bool_ffiVoid_objcObjCObject { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock, ffi.Pointer)> fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer arg0, - ffi.Pointer arg1)>> - ptr) => - objc.ObjCBlock, ffi.Pointer)>( - objc.newPointerBlock(_ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock, ffi.Pointer)> fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1)>> ptr) => + // objc.ObjCBlock, ffi.Pointer)>(todo(_ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -9251,39 +9418,21 @@ abstract final class ObjCBlock_bool_ffiVoid_objcObjCObject { static objc.ObjCBlock, ffi.Pointer)> fromFunction( bool Function(ffi.Pointer, objc.ObjCObjectBase) fn) => - objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, ffi.Pointer)>( - objc.newClosureBlock( + objc.ObjCBlock, ffi.Pointer)>( + _ObjectiveCBindings_newClosureBlock_ozkafd( _ObjCBlock_bool_ffiVoid_objcObjCObject_closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => - fn(arg0, objc.ObjCObjectBase(arg1, retain: true, release: true))), + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(arg0, objc.ObjCObjectBase(arg1, retain: true, release: true)))), retain: false, release: true); } -/// Call operator for `objc.ObjCBlock, ffi.Pointer)>`. -extension ObjCBlock_bool_ffiVoid_objcObjCObject_CallExtension on objc.ObjCBlock< - ffi.Bool Function(ffi.Pointer, ffi.Pointer)> { - bool call(ffi.Pointer arg0, objc.ObjCObjectBase arg1) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1)>>() - .asFunction< - bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>()( - ref.pointer, arg0, arg1.ref.pointer); -} - bool _ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.Bool Function(ffi.Pointer arg0, @@ -9291,24 +9440,22 @@ bool _ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrTrampoline( .asFunction< bool Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); -ffi.Pointer _ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrCallable = +final _ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrTrampoline, false) - .cast(); + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrTrampoline, false); bool _ObjCBlock_bool_ffiVoid_objcObjCSelector_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(block) as bool Function( + (objc.getBlockClosure(target.address) as bool Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); -ffi.Pointer _ObjCBlock_bool_ffiVoid_objcObjCSelector_closureCallable = +final _ObjCBlock_bool_ffiVoid_objcObjCSelector_closureCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_bool_ffiVoid_objcObjCSelector_closureTrampoline, false) - .cast(); + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_bool_ffiVoid_objcObjCSelector_closureTrampoline, false); /// Construction methods for `objc.ObjCBlock, ffi.Pointer)>`. abstract final class ObjCBlock_bool_ffiVoid_objcObjCSelector { @@ -9330,63 +9477,34 @@ abstract final class ObjCBlock_bool_ffiVoid_objcObjCSelector { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock, ffi.Pointer)> fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer arg0, - ffi.Pointer arg1)>> - ptr) => - objc.ObjCBlock, ffi.Pointer)>( - objc.newPointerBlock(_ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock, ffi.Pointer)> fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1)>> ptr) => + // objc.ObjCBlock, ffi.Pointer)>(todo(_ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc - .ObjCBlock, ffi.Pointer)> + static objc.ObjCBlock, ffi.Pointer)> fromFunction(bool Function(ffi.Pointer, ffi.Pointer) fn) => - objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, ffi.Pointer)>( - objc.newClosureBlock( + objc.ObjCBlock, ffi.Pointer)>( + _ObjectiveCBindings_newClosureBlock_w1e3k0( _ObjCBlock_bool_ffiVoid_objcObjCSelector_closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => - fn(arg0, arg1)), + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(arg0, arg1))), retain: false, release: true); } -/// Call operator for `objc.ObjCBlock, ffi.Pointer)>`. -extension ObjCBlock_bool_ffiVoid_objcObjCSelector_CallExtension - on objc.ObjCBlock< - ffi.Bool Function( - ffi.Pointer, ffi.Pointer)> { - bool call(ffi.Pointer arg0, ffi.Pointer arg1) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1)>>() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>()(ref.pointer, arg0, arg1); -} - void _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.Void Function( @@ -9398,59 +9516,55 @@ void ffi.Pointer, ffi.Pointer, ffi.Pointer)>()(arg0, arg1, arg2); -ffi.Pointer - _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrCallable = +final _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrTrampoline) - .cast(); + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrTrampoline); void _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => - (objc.getBlockClosure(block) as void Function( + (objc.getBlockClosure(target.address) as void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer))(arg0, arg1, arg2); -ffi.Pointer - _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_closureCallable = +final _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_closureCallable = ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_closureTrampoline) - .cast(); + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_closureTrampoline); void _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_listenerTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) { - (objc.getBlockClosure(block) as void Function( + (objc.getBlockClosure(target.address) as void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); + // objc.objectRelease(block.cast()); } ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_listenerCallable = ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>.listener( @@ -9458,26 +9572,26 @@ ffi.NativeCallable< ..keepIsolateAlive = false; void _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_blockingTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer waiter, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) { try { - (objc.getBlockClosure(block) as void Function( + (objc.getBlockClosure(target.address) as void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer))(arg0, arg1, arg2); } catch (e) { } finally { objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); + // objc.objectRelease(block.cast()); } } ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -9485,7 +9599,7 @@ ffi.NativeCallable< _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_blockingCallable = ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -9494,7 +9608,7 @@ ffi.NativeCallable< ..keepIsolateAlive = false; ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -9502,7 +9616,7 @@ ffi.NativeCallable< _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_blockingListenerCallable = ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -9531,18 +9645,9 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError)>, - ffi.Pointer, - NSDictionary)> - fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2)>> ptr) => - objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock?, NSError)>, - ffi.Pointer, - NSDictionary)>(objc.newPointerBlock(_ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrCallable, ptr.cast()), retain: false, release: true); + // static objc.ObjCBlock?, NSError)>, ffi.Pointer, NSDictionary)> fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2)>> ptr) => + // objc.ObjCBlock?, NSError)>, ffi.Pointer, NSDictionary)>(todo(_ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -9552,15 +9657,12 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO static objc.ObjCBlock?, NSError)>, ffi.Pointer, NSDictionary)> fromFunction(void Function(objc.ObjCBlock?, NSError)>, objc.ObjCObjectBase, NSDictionary) fn) => objc.ObjCBlock?, NSError)>, ffi.Pointer, NSDictionary)>( - objc.newClosureBlock( + _ObjectiveCBindings_newClosureBlock_1j2nt86( _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_closureCallable, - (ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2) => - fn( - ObjCBlock_ffiVoid_objcObjCObject_NSError.castFromPointer(arg0, retain: true, release: true), - objc.ObjCObjectBase(arg1, retain: true, release: true), - NSDictionary.castFromPointer(arg2, retain: true, release: true))), + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => fn( + ObjCBlock_ffiVoid_objcObjCObject_NSError.castFromPointer(arg0, retain: true, release: true), + objc.ObjCObjectBase(arg1, retain: true, release: true), + NSDictionary.castFromPointer(arg2, retain: true, release: true)))), retain: false, release: true); @@ -9585,11 +9687,11 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO objc.ObjCObjectBase, NSDictionary) fn) { - final raw = objc.newClosureBlock( + final raw = _ObjectiveCBindings_newClosureBlock_1j2nt86( _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_listenerCallable .nativeFunction .cast(), - (ffi.Pointer arg0, + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => fn( @@ -9597,7 +9699,7 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO retain: false, release: true), objc.ObjCObjectBase(arg1, retain: false, release: true), NSDictionary.castFromPointer(arg2, - retain: false, release: true))); + retain: false, release: true)))); final wrapper = _ObjectiveCBindings_wrapListenerBlock_1j2nt86(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock< @@ -9629,11 +9731,11 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO objc.ObjCObjectBase, NSDictionary) fn) { - final raw = objc.newClosureBlock( + final raw = _ObjectiveCBindings_newClosureBlock_1j2nt86( _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_blockingCallable .nativeFunction .cast(), - (ffi.Pointer arg0, + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => fn( @@ -9641,12 +9743,12 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO retain: false, release: true), objc.ObjCObjectBase(arg1, retain: false, release: true), NSDictionary.castFromPointer(arg2, - retain: false, release: true))); - final rawListener = objc.newClosureBlock( + retain: false, release: true)))); + final rawListener = _ObjectiveCBindings_newClosureBlock_1j2nt86( _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_blockingListenerCallable .nativeFunction .cast(), - (ffi.Pointer arg0, + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => fn( @@ -9654,7 +9756,7 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO retain: false, release: true), objc.ObjCObjectBase(arg1, retain: false, release: true), NSDictionary.castFromPointer(arg2, - retain: false, release: true))); + retain: false, release: true)))); final wrapper = objc.wrapBlockingBlock( _ObjectiveCBindings_wrapBlockingBlock_1j2nt86, raw, rawListener); objc.objectRelease(raw.cast()); @@ -9668,98 +9770,62 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO } } -/// Call operator for `objc.ObjCBlock?, NSError)>, ffi.Pointer, NSDictionary)>`. -extension ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_CallExtension - on objc.ObjCBlock< - ffi.Void Function( - objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError)>, - ffi.Pointer, - NSDictionary)> { - void call( - objc.ObjCBlock?, NSError)> - arg0, - objc.ObjCObjectBase arg1, - NSDictionary arg2) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2)>>() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>()( - ref.pointer, arg0.ref.pointer, arg1.ref.pointer, arg2.ref.pointer); -} - void _ObjCBlock_ffiVoid_ffiVoid_fnPtrTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - block.ref.target + ffi.Pointer target, ffi.Pointer arg0) => + target .cast< ffi.NativeFunction arg0)>>() .asFunction)>()(arg0); -ffi.Pointer _ObjCBlock_ffiVoid_ffiVoid_fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_ffiVoid_ffiVoid_fnPtrTrampoline) - .cast(); +final _ObjCBlock_ffiVoid_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer)>(_ObjCBlock_ffiVoid_ffiVoid_fnPtrTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_closureTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - (objc.getBlockClosure(block) as void Function(ffi.Pointer))(arg0); -ffi.Pointer _ObjCBlock_ffiVoid_ffiVoid_closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_ffiVoid_ffiVoid_closureTrampoline) - .cast(); + ffi.Pointer target, ffi.Pointer arg0) => + (objc.getBlockClosure(target.address) as void Function( + ffi.Pointer))(arg0); +final _ObjCBlock_ffiVoid_ffiVoid_closureCallable = ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer, + ffi.Pointer)>(_ObjCBlock_ffiVoid_ffiVoid_closureTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_listenerTrampoline( - ffi.Pointer block, ffi.Pointer arg0) { - (objc.getBlockClosure(block) as void Function(ffi.Pointer))(arg0); - objc.objectRelease(block.cast()); + ffi.Pointer target, ffi.Pointer arg0) { + (objc.getBlockClosure(target.address) as void Function( + ffi.Pointer))(arg0); + // objc.objectRelease(block.cast()); } ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_listenerCallable = ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, - ffi.Pointer)>.listener( + ffi.Void Function( + ffi.Pointer, ffi.Pointer)>.listener( _ObjCBlock_ffiVoid_ffiVoid_listenerTrampoline) ..keepIsolateAlive = false; -void _ObjCBlock_ffiVoid_ffiVoid_blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0) { +void _ObjCBlock_ffiVoid_ffiVoid_blockingTrampoline(ffi.Pointer target, + ffi.Pointer waiter, ffi.Pointer arg0) { try { - (objc.getBlockClosure(block) as void Function(ffi.Pointer))(arg0); + (objc.getBlockClosure(target.address) as void Function( + ffi.Pointer))(arg0); } catch (e) { } finally { objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); + // objc.objectRelease(block.cast()); } } ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_blockingCallable = ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>.isolateLocal( + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>.isolateLocal( _ObjCBlock_ffiVoid_ffiVoid_blockingTrampoline) ..keepIsolateAlive = false; ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_blockingListenerCallable = ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>.listener( + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>.listener( _ObjCBlock_ffiVoid_ffiVoid_blockingTrampoline) ..keepIsolateAlive = false; @@ -9777,16 +9843,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock)> fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0)>> - ptr) => - objc.ObjCBlock)>( - objc.newPointerBlock( - _ObjCBlock_ffiVoid_ffiVoid_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock)> fromFunctionPointer(ffi.Pointer arg0)>> ptr) => + // objc.ObjCBlock)>(todo(_ObjCBlock_ffiVoid_ffiVoid_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -9796,8 +9855,10 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid { static objc.ObjCBlock)> fromFunction( void Function(ffi.Pointer) fn) => objc.ObjCBlock)>( - objc.newClosureBlock(_ObjCBlock_ffiVoid_ffiVoid_closureCallable, - (ffi.Pointer arg0) => fn(arg0)), + _ObjectiveCBindings_newClosureBlock_ovsamd( + _ObjCBlock_ffiVoid_ffiVoid_closureCallable, + objc.registerBlockClosure( + (ffi.Pointer arg0) => fn(arg0))), retain: false, release: true); @@ -9812,9 +9873,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid { /// blocks do not keep the isolate alive. static objc.ObjCBlock)> listener( void Function(ffi.Pointer) fn) { - final raw = objc.newClosureBlock( + final raw = _ObjectiveCBindings_newClosureBlock_ovsamd( _ObjCBlock_ffiVoid_ffiVoid_listenerCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn(arg0)); + objc.registerBlockClosure((ffi.Pointer arg0) => fn(arg0))); final wrapper = _ObjectiveCBindings_wrapListenerBlock_ovsamd(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock)>(wrapper, @@ -9832,13 +9893,13 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid { /// indefinitely, or have other undefined behavior. static objc.ObjCBlock)> blocking( void Function(ffi.Pointer) fn) { - final raw = objc.newClosureBlock( + final raw = _ObjectiveCBindings_newClosureBlock_ovsamd( _ObjCBlock_ffiVoid_ffiVoid_blockingCallable.nativeFunction.cast(), - (ffi.Pointer arg0) => fn(arg0)); - final rawListener = objc.newClosureBlock( + objc.registerBlockClosure((ffi.Pointer arg0) => fn(arg0))); + final rawListener = _ObjectiveCBindings_newClosureBlock_ovsamd( _ObjCBlock_ffiVoid_ffiVoid_blockingListenerCallable.nativeFunction .cast(), - (ffi.Pointer arg0) => fn(arg0)); + objc.registerBlockClosure((ffi.Pointer arg0) => fn(arg0))); final wrapper = objc.wrapBlockingBlock( _ObjectiveCBindings_wrapBlockingBlock_ovsamd, raw, rawListener); objc.objectRelease(raw.cast()); @@ -9848,24 +9909,11 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid { } } -/// Call operator for `objc.ObjCBlock)>`. -extension ObjCBlock_ffiVoid_ffiVoid_CallExtension - on objc.ObjCBlock)> { - void call(ffi.Pointer arg0) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer block, - ffi.Pointer arg0)>>() - .asFunction< - void Function(ffi.Pointer, - ffi.Pointer)>()(ref.pointer, arg0); -} - void _ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.Void Function(ffi.Pointer arg0, @@ -9873,83 +9921,72 @@ void _ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrTrampoline( .asFunction< void Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); -ffi.Pointer _ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrCallable = +final _ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrTrampoline) - .cast(); + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(block) as void Function( + (objc.getBlockClosure(target.address) as void Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); -ffi.Pointer _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureCallable = +final _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureCallable = ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureTrampoline) - .cast(); + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_NSCoder_listenerTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) { - (objc.getBlockClosure(block) as void Function( + (objc.getBlockClosure(target.address) as void Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); - objc.objectRelease(block.cast()); + // objc.objectRelease(block.cast()); } ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_NSCoder_listenerCallable = ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>.listener( + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>.listener( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_listenerTrampoline) ..keepIsolateAlive = false; void _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer waiter, ffi.Pointer arg0, ffi.Pointer arg1) { try { - (objc.getBlockClosure(block) as void Function( + (objc.getBlockClosure(target.address) as void Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); } catch (e) { } finally { objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); + // objc.objectRelease(block.cast()); } } ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingCallable = ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>.isolateLocal( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingTrampoline) ..keepIsolateAlive = false; ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingListenerCallable = ffi .NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>.listener( + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>.listener( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingTrampoline) ..keepIsolateAlive = false; @@ -9969,17 +10006,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock, NSCoder)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0, - ffi.Pointer arg1)>> - ptr) => - objc.ObjCBlock, NSCoder)>( - objc.newPointerBlock(_ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock, NSCoder)> fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1)>> ptr) => + // objc.ObjCBlock, NSCoder)>(todo(_ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -9990,11 +10019,11 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { ffi.Void Function(ffi.Pointer, NSCoder)> fromFunction( void Function(ffi.Pointer, NSCoder) fn) => objc.ObjCBlock, NSCoder)>( - objc.newClosureBlock( + _ObjectiveCBindings_newClosureBlock_wjovn7( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, - NSCoder.castFromPointer(arg1, retain: true, release: true))), + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(arg0, NSCoder.castFromPointer(arg1, retain: true, release: true)))), retain: false, release: true); @@ -10009,11 +10038,13 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { /// blocks do not keep the isolate alive. static objc.ObjCBlock, NSCoder)> listener(void Function(ffi.Pointer, NSCoder) fn) { - final raw = objc.newClosureBlock( + final raw = _ObjectiveCBindings_newClosureBlock_wjovn7( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_listenerCallable.nativeFunction .cast(), - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, NSCoder.castFromPointer(arg1, retain: false, release: true))); + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(arg0, + NSCoder.castFromPointer(arg1, retain: false, release: true)))); final wrapper = _ObjectiveCBindings_wrapListenerBlock_wjovn7(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock, NSCoder)>( @@ -10033,17 +10064,21 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { /// indefinitely, or have other undefined behavior. static objc.ObjCBlock, NSCoder)> blocking(void Function(ffi.Pointer, NSCoder) fn) { - final raw = objc.newClosureBlock( + final raw = _ObjectiveCBindings_newClosureBlock_wjovn7( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingCallable.nativeFunction .cast(), - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, NSCoder.castFromPointer(arg1, retain: false, release: true))); - final rawListener = objc.newClosureBlock( + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(arg0, + NSCoder.castFromPointer(arg1, retain: false, release: true)))); + final rawListener = _ObjectiveCBindings_newClosureBlock_wjovn7( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingListenerCallable .nativeFunction .cast(), - (ffi.Pointer arg0, ffi.Pointer arg1) => fn( - arg0, NSCoder.castFromPointer(arg1, retain: false, release: true))); + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(arg0, + NSCoder.castFromPointer(arg1, retain: false, release: true)))); final wrapper = objc.wrapBlockingBlock( _ObjectiveCBindings_wrapBlockingBlock_wjovn7, raw, rawListener); objc.objectRelease(raw.cast()); @@ -10055,28 +10090,12 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { } } -/// Call operator for `objc.ObjCBlock, NSCoder)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSCoder_CallExtension - on objc.ObjCBlock, NSCoder)> { - void call(ffi.Pointer arg0, NSCoder arg1) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1)>>() - .asFunction< - void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>()( - ref.pointer, arg0, arg1.ref.pointer); -} - void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, int arg2) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.Void Function( @@ -10086,85 +10105,73 @@ void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrTrampoline( .asFunction< void Function(ffi.Pointer, ffi.Pointer, int)>()(arg0, arg1, arg2); -ffi.Pointer - _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrCallable = +final _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong)>( - _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrTrampoline) - .cast(); + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, int arg2) => - (objc.getBlockClosure(block) as void Function(ffi.Pointer, - ffi.Pointer, int))(arg0, arg1, arg2); -ffi.Pointer - _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureCallable = + (objc.getBlockClosure(target.address) as void Function( + ffi.Pointer, + ffi.Pointer, + int))(arg0, arg1, arg2); +final _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureCallable = ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong)>( - _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureTrampoline) - .cast(); + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, int arg2) { - (objc.getBlockClosure(block) as void Function(ffi.Pointer, + (objc.getBlockClosure(target.address) as void Function(ffi.Pointer, ffi.Pointer, int))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); + // objc.objectRelease(block.cast()); } ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong)> + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)> _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerCallable = ffi .NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong)>.listener( + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>.listener( _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerTrampoline) ..keepIsolateAlive = false; void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_blockingTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer waiter, ffi.Pointer arg0, ffi.Pointer arg1, int arg2) { try { - (objc.getBlockClosure(block) as void Function(ffi.Pointer, - ffi.Pointer, int))(arg0, arg1, arg2); + (objc.getBlockClosure(target.address) as void Function( + ffi.Pointer, + ffi.Pointer, + int))(arg0, arg1, arg2); } catch (e) { } finally { objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); + // objc.objectRelease(block.cast()); } } ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.UnsignedLong)> - _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_blockingCallable = - ffi.NativeCallable< + _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_blockingCallable = ffi + .NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10173,7 +10180,7 @@ ffi.NativeCallable< ..keepIsolateAlive = false; ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10181,7 +10188,7 @@ ffi.NativeCallable< _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_blockingListenerCallable = ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10205,17 +10212,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc - .ObjCBlock, NSStream, ffi.UnsignedLong)> - fromFunctionPointer( - ffi.Pointer arg0, ffi.Pointer arg1, ffi.UnsignedLong arg2)>> - ptr) => - objc.ObjCBlock, NSStream, ffi.UnsignedLong)>( - objc.newPointerBlock( - _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrCallable, - ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock, NSStream, ffi.UnsignedLong)> fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1, ffi.UnsignedLong arg2)>> ptr) => + // objc.ObjCBlock, NSStream, ffi.UnsignedLong)>(todo(_ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -10225,14 +10224,11 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { static objc.ObjCBlock, NSStream, ffi.UnsignedLong)> fromFunction( void Function(ffi.Pointer, NSStream, NSStreamEvent) fn) => objc.ObjCBlock, NSStream, ffi.UnsignedLong)>( - objc.newClosureBlock( + _ObjectiveCBindings_newClosureBlock_18d6mda( _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1, - int arg2) => - fn( - arg0, - NSStream.castFromPointer(arg1, retain: true, release: true), - NSStreamEvent.fromValue(arg2))), + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1, int arg2) => + fn(arg0, NSStream.castFromPointer(arg1, retain: true, release: true), NSStreamEvent.fromValue(arg2)))), retain: false, release: true); @@ -10249,16 +10245,16 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { ffi.Void Function(ffi.Pointer, NSStream, ffi.UnsignedLong)> listener( void Function(ffi.Pointer, NSStream, NSStreamEvent) fn) { - final raw = objc.newClosureBlock( + final raw = _ObjectiveCBindings_newClosureBlock_18d6mda( _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerCallable .nativeFunction .cast(), - (ffi.Pointer arg0, ffi.Pointer arg1, - int arg2) => + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1, int arg2) => fn( arg0, NSStream.castFromPointer(arg1, retain: false, release: true), - NSStreamEvent.fromValue(arg2))); + NSStreamEvent.fromValue(arg2)))); final wrapper = _ObjectiveCBindings_wrapListenerBlock_18d6mda(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock< @@ -10279,26 +10275,26 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { ffi.Void Function(ffi.Pointer, NSStream, ffi.UnsignedLong)> blocking( void Function(ffi.Pointer, NSStream, NSStreamEvent) fn) { - final raw = objc.newClosureBlock( + final raw = _ObjectiveCBindings_newClosureBlock_18d6mda( _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_blockingCallable .nativeFunction .cast(), - (ffi.Pointer arg0, ffi.Pointer arg1, - int arg2) => + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1, int arg2) => fn( arg0, NSStream.castFromPointer(arg1, retain: false, release: true), - NSStreamEvent.fromValue(arg2))); - final rawListener = objc.newClosureBlock( + NSStreamEvent.fromValue(arg2)))); + final rawListener = _ObjectiveCBindings_newClosureBlock_18d6mda( _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_blockingListenerCallable .nativeFunction .cast(), - (ffi.Pointer arg0, ffi.Pointer arg1, - int arg2) => + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1, int arg2) => fn( arg0, NSStream.castFromPointer(arg1, retain: false, release: true), - NSStreamEvent.fromValue(arg2))); + NSStreamEvent.fromValue(arg2)))); final wrapper = objc.wrapBlockingBlock( _ObjectiveCBindings_wrapBlockingBlock_18d6mda, raw, rawListener); objc.objectRelease(raw.cast()); @@ -10309,32 +10305,11 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { } } -/// Call operator for `objc.ObjCBlock, NSStream, ffi.UnsignedLong)>`. -extension ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_CallExtension - on objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSStream, ffi.UnsignedLong)> { - void call(ffi.Pointer arg0, NSStream arg1, NSStreamEvent arg2) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.UnsignedLong arg2)>>() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int)>()(ref.pointer, arg0, arg1.ref.pointer, arg2.value); -} - void _ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.Void Function(ffi.Pointer arg0, @@ -10342,89 +10317,78 @@ void _ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrTrampoline( .asFunction< void Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); -ffi.Pointer _ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrCallable = +final _ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - _ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrTrampoline) - .cast(); + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrTrampoline); void _ObjCBlock_ffiVoid_objcObjCObject_NSError_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(block) as void Function(ffi.Pointer, + (objc.getBlockClosure(target.address) as void Function( + ffi.Pointer, ffi.Pointer))(arg0, arg1); -ffi.Pointer - _ObjCBlock_ffiVoid_objcObjCObject_NSError_closureCallable = +final _ObjCBlock_ffiVoid_objcObjCObject_NSError_closureCallable = ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - _ObjCBlock_ffiVoid_objcObjCObject_NSError_closureTrampoline) - .cast(); + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_ffiVoid_objcObjCObject_NSError_closureTrampoline); void _ObjCBlock_ffiVoid_objcObjCObject_NSError_listenerTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) { - (objc.getBlockClosure(block) as void Function( + (objc.getBlockClosure(target.address) as void Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); - objc.objectRelease(block.cast()); + // objc.objectRelease(block.cast()); } ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)> _ObjCBlock_ffiVoid_objcObjCObject_NSError_listenerCallable = ffi .NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer)>.listener( _ObjCBlock_ffiVoid_objcObjCObject_NSError_listenerTrampoline) ..keepIsolateAlive = false; void _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer waiter, ffi.Pointer arg0, ffi.Pointer arg1) { try { - (objc.getBlockClosure(block) as void Function(ffi.Pointer, + (objc.getBlockClosure(target.address) as void Function( + ffi.Pointer, ffi.Pointer))(arg0, arg1); } catch (e) { } finally { objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); + // objc.objectRelease(block.cast()); } } ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingCallable = ffi .NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>.isolateLocal( _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingTrampoline) ..keepIsolateAlive = false; ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingListenerCallable = ffi .NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>.listener( @@ -10447,16 +10411,9 @@ abstract final class ObjCBlock_ffiVoid_objcObjCObject_NSError { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock?, NSError)> fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer arg0, - ffi.Pointer arg1)>> - ptr) => - objc.ObjCBlock?, NSError)>( - objc.newPointerBlock(_ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock?, NSError)> fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1)>> ptr) => + // objc.ObjCBlock?, NSError)>(todo(_ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -10466,15 +10423,13 @@ abstract final class ObjCBlock_ffiVoid_objcObjCObject_NSError { static objc.ObjCBlock?, NSError)> fromFunction( void Function(objc.ObjCObjectBase?, NSError) fn) => objc.ObjCBlock?, NSError)>( - objc.newClosureBlock( + _ObjectiveCBindings_newClosureBlock_wjvic9( _ObjCBlock_ffiVoid_objcObjCObject_NSError_closureCallable, - (ffi.Pointer arg0, - ffi.Pointer arg1) => - fn( - arg0.address == 0 - ? null - : objc.ObjCObjectBase(arg0, retain: true, release: true), - NSError.castFromPointer(arg1, retain: true, release: true))), + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0.address == 0 + ? null + : objc.ObjCObjectBase(arg0, retain: true, release: true), + NSError.castFromPointer(arg1, retain: true, release: true)))), retain: false, release: true); @@ -10490,17 +10445,17 @@ abstract final class ObjCBlock_ffiVoid_objcObjCObject_NSError { static objc .ObjCBlock?, NSError)> listener(void Function(objc.ObjCObjectBase?, NSError) fn) { - final raw = objc.newClosureBlock( + final raw = _ObjectiveCBindings_newClosureBlock_wjvic9( _ObjCBlock_ffiVoid_objcObjCObject_NSError_listenerCallable .nativeFunction .cast(), - (ffi.Pointer arg0, + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => fn( arg0.address == 0 ? null : objc.ObjCObjectBase(arg0, retain: false, release: true), - NSError.castFromPointer(arg1, retain: false, release: true))); + NSError.castFromPointer(arg1, retain: false, release: true)))); final wrapper = _ObjectiveCBindings_wrapListenerBlock_wjvic9(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock< @@ -10520,28 +10475,28 @@ abstract final class ObjCBlock_ffiVoid_objcObjCObject_NSError { static objc .ObjCBlock?, NSError)> blocking(void Function(objc.ObjCObjectBase?, NSError) fn) { - final raw = objc.newClosureBlock( + final raw = _ObjectiveCBindings_newClosureBlock_wjvic9( _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingCallable .nativeFunction .cast(), - (ffi.Pointer arg0, + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => fn( arg0.address == 0 ? null : objc.ObjCObjectBase(arg0, retain: false, release: true), - NSError.castFromPointer(arg1, retain: false, release: true))); - final rawListener = objc.newClosureBlock( + NSError.castFromPointer(arg1, retain: false, release: true)))); + final rawListener = _ObjectiveCBindings_newClosureBlock_wjvic9( _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingListenerCallable .nativeFunction .cast(), - (ffi.Pointer arg0, + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => fn( arg0.address == 0 ? null : objc.ObjCObjectBase(arg0, retain: false, release: true), - NSError.castFromPointer(arg1, retain: false, release: true))); + NSError.castFromPointer(arg1, retain: false, release: true)))); final wrapper = objc.wrapBlockingBlock( _ObjectiveCBindings_wrapBlockingBlock_wjvic9, raw, rawListener); objc.objectRelease(raw.cast()); @@ -10552,29 +10507,11 @@ abstract final class ObjCBlock_ffiVoid_objcObjCObject_NSError { } } -/// Call operator for `objc.ObjCBlock?, NSError)>`. -extension ObjCBlock_ffiVoid_objcObjCObject_NSError_CallExtension on objc - .ObjCBlock?, NSError)> { - void call(objc.ObjCObjectBase? arg0, NSError arg1) => ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1)>>() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>()( - ref.pointer, arg0?.ref.pointer ?? ffi.nullptr, arg1.ref.pointer); -} - instancetype _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - block.ref.target + target .cast< ffi.NativeFunction< instancetype Function(ffi.Pointer arg0, @@ -10582,24 +10519,22 @@ instancetype _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrTrampoline( .asFunction< instancetype Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); -ffi.Pointer _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrCallable = +final _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrCallable = ffi.Pointer.fromFunction< - instancetype Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrTrampoline) - .cast(); + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrTrampoline); instancetype _ObjCBlock_instancetype_ffiVoid_NSCoder_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(block) as instancetype Function( + (objc.getBlockClosure(target.address) as instancetype Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); -ffi.Pointer _ObjCBlock_instancetype_ffiVoid_NSCoder_closureCallable = +final _ObjCBlock_instancetype_ffiVoid_NSCoder_closureCallable = ffi.Pointer.fromFunction< - instancetype Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_instancetype_ffiVoid_NSCoder_closureTrampoline) - .cast(); + instancetype Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_instancetype_ffiVoid_NSCoder_closureTrampoline); /// Construction methods for `objc.ObjCBlock?> Function(ffi.Pointer, NSCoder)>`. abstract final class ObjCBlock_instancetype_ffiVoid_NSCoder { @@ -10619,73 +10554,37 @@ abstract final class ObjCBlock_instancetype_ffiVoid_NSCoder { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, NSCoder)> - fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1)>> ptr) => - objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, NSCoder)>( - objc.newPointerBlock( - _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock?> Function(ffi.Pointer, NSCoder)> fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1)>> ptr) => + // objc.ObjCBlock?> Function(ffi.Pointer, NSCoder)>(todo(_ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc - .ObjCBlock?> Function(ffi.Pointer, NSCoder)> - fromFunction( - Dartinstancetype? Function(ffi.Pointer, NSCoder) fn) => - objc.ObjCBlock?> Function(ffi.Pointer, NSCoder)>( - objc.newClosureBlock( - _ObjCBlock_instancetype_ffiVoid_NSCoder_closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => - fn(arg0, NSCoder.castFromPointer(arg1, retain: true, release: true)) - ?.ref - .retainAndReturnPointer() ?? - ffi.nullptr), - retain: false, - release: true); -} - -/// Call operator for `objc.ObjCBlock?> Function(ffi.Pointer, NSCoder)>`. -extension ObjCBlock_instancetype_ffiVoid_NSCoder_CallExtension - on objc.ObjCBlock< - objc.Retained?> Function( - ffi.Pointer, NSCoder)> { - Dartinstancetype? call(ffi.Pointer arg0, NSCoder arg1) => ref - .pointer.ref.invoke - .cast< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1)>>() - .asFunction, ffi.Pointer, ffi.Pointer)>() - (ref.pointer, arg0, arg1.ref.pointer) - .address == - 0 - ? null - : objc.ObjCObjectBase( - ref.pointer.ref.invoke - .cast block, ffi.Pointer arg0, ffi.Pointer arg1)>>() - .asFunction, ffi.Pointer, ffi.Pointer)>()(ref.pointer, arg0, arg1.ref.pointer), + static objc.ObjCBlock?> Function(ffi.Pointer, NSCoder)> fromFunction( + Dartinstancetype? Function(ffi.Pointer, NSCoder) fn) => + objc.ObjCBlock?> Function(ffi.Pointer, NSCoder)>( + _ObjectiveCBindings_newClosureBlock_1m9h2n( + _ObjCBlock_instancetype_ffiVoid_NSCoder_closureCallable, + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => + fn(arg0, NSCoder.castFromPointer(arg1, retain: true, release: true)) + ?.ref + .retainAndReturnPointer() ?? + ffi.nullptr)), retain: false, release: true); } instancetype _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer> arg3) => - block.ref.target + target .cast< ffi.NativeFunction< instancetype Function( @@ -10700,40 +10599,36 @@ instancetype ffi.Pointer, ffi.Pointer>)>()( arg0, arg1, arg2, arg3); -ffi.Pointer - _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrCallable = +final _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrCallable = ffi.Pointer.fromFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>)>( - _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrTrampoline) - .cast(); + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>( + _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrTrampoline); instancetype _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer> arg3) => - (objc.getBlockClosure(block) as instancetype Function( + (objc.getBlockClosure(target.address) as instancetype Function( ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer>))(arg0, arg1, arg2, arg3); -ffi.Pointer - _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_closureCallable = +final _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_closureCallable = ffi.Pointer.fromFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>)>( - _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_closureTrampoline) - .cast(); + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>( + _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_closureTrampoline); /// Construction methods for `objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)>`. abstract final class ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError { @@ -10756,19 +10651,9 @@ abstract final class ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock< - ffi.Pointer? Function(ffi.Pointer, NSData, - NSString, ffi.Pointer>)> - fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer> arg3)>> ptr) => - objc.ObjCBlock< - ffi.Pointer? Function( - ffi.Pointer, - NSData, - NSString, - ffi.Pointer>)>( - objc.newPointerBlock(_ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)> fromFunctionPointer(ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer> arg3)>> ptr) => + // objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)>(todo(_ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -10778,53 +10663,20 @@ abstract final class ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError { static objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)> fromFunction(Dartinstancetype? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>) fn) => objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)>( - objc.newClosureBlock( + _ObjectiveCBindings_newClosureBlock_e2pkq8( _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_closureCallable, - (ffi.Pointer arg0, + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer> arg3) => - fn(arg0, NSData.castFromPointer(arg1, retain: true, release: true), NSString.castFromPointer(arg2, retain: true, release: true), arg3)?.ref.retainAndAutorelease() ?? - ffi.nullptr), + fn(arg0, NSData.castFromPointer(arg1, retain: true, release: true), NSString.castFromPointer(arg2, retain: true, release: true), arg3)?.ref.retainAndAutorelease() ?? ffi.nullptr)), retain: false, release: true); } -/// Call operator for `objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)>`. -extension ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_CallExtension - on objc.ObjCBlock< - ffi.Pointer? Function(ffi.Pointer, NSData, - NSString, ffi.Pointer>)> { - Dartinstancetype? call(ffi.Pointer arg0, NSData arg1, NSString arg2, ffi.Pointer> arg3) => ref - .pointer.ref.invoke - .cast< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3)>>() - .asFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>)>() - (ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer, arg3) - .address == - 0 - ? null - : objc.ObjCObjectBase( - ref.pointer.ref.invoke.cast block, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer> arg3)>>().asFunction, ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer>)>()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer, arg3), - retain: true, - release: true); -} - ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_fnPtrTrampoline( - ffi.Pointer block, ffi.Pointer arg0) => - block.ref.target + ffi.Pointer target, ffi.Pointer arg0) => + target .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -10832,24 +10684,21 @@ ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_fnPtrTrampoline( .asFunction< ffi.Pointer Function( ffi.Pointer)>()(arg0); -ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_fnPtrCallable = +final _ObjCBlock_objcObjCObject_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_objcObjCObject_ffiVoid_fnPtrTrampoline) - .cast(); + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_objcObjCObject_ffiVoid_fnPtrTrampoline); ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0) => - (objc.getBlockClosure(block) as ffi.Pointer Function( - ffi.Pointer))(arg0); -ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_closureCallable = + ffi.Pointer target, ffi.Pointer arg0) => + (objc.getBlockClosure(target.address) as ffi.Pointer + Function(ffi.Pointer))(arg0); +final _ObjCBlock_objcObjCObject_ffiVoid_closureCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_objcObjCObject_ffiVoid_closureTrampoline) - .cast(); + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_objcObjCObject_ffiVoid_closureTrampoline); /// Construction methods for `objc.ObjCBlock Function(ffi.Pointer)>`. abstract final class ObjCBlock_objcObjCObject_ffiVoid { @@ -10869,60 +10718,33 @@ abstract final class ObjCBlock_objcObjCObject_ffiVoid { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock Function(ffi.Pointer)> - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer arg0)>> - ptr) => - objc.ObjCBlock Function(ffi.Pointer)>( - objc.newPointerBlock(_ObjCBlock_objcObjCObject_ffiVoid_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock Function(ffi.Pointer)> fromFunctionPointer(ffi.Pointer Function(ffi.Pointer arg0)>> ptr) => + // objc.ObjCBlock Function(ffi.Pointer)>(todo(_ObjCBlock_objcObjCObject_ffiVoid_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc - .ObjCBlock Function(ffi.Pointer)> - fromFunction(objc.ObjCObjectBase Function(ffi.Pointer) fn) => - objc.ObjCBlock< - ffi.Pointer Function(ffi.Pointer)>( - objc.newClosureBlock( - _ObjCBlock_objcObjCObject_ffiVoid_closureCallable, - (ffi.Pointer arg0) => - fn(arg0).ref.retainAndAutorelease()), - retain: false, - release: true); -} - -/// Call operator for `objc.ObjCBlock Function(ffi.Pointer)>`. -extension ObjCBlock_objcObjCObject_ffiVoid_CallExtension on objc - .ObjCBlock Function(ffi.Pointer)> { - objc.ObjCObjectBase call(ffi.Pointer arg0) => objc.ObjCObjectBase( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer block, - ffi.Pointer arg0)>>() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer)>()(ref.pointer, arg0), - retain: true, - release: true); + static objc.ObjCBlock< + ffi.Pointer Function(ffi.Pointer)> fromFunction( + objc.ObjCObjectBase Function(ffi.Pointer) fn) => + objc.ObjCBlock Function(ffi.Pointer)>( + _ObjectiveCBindings_newClosureBlock_1yesha9( + _ObjCBlock_objcObjCObject_ffiVoid_closureCallable, + objc.registerBlockClosure((ffi.Pointer arg0) => + fn(arg0).ref.retainAndAutorelease())), + retain: false, + release: true); } ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -10931,31 +10753,24 @@ ffi.Pointer .asFunction< ffi.Pointer Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); -ffi.Pointer - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_fnPtrCallable = +final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_fnPtrTrampoline) - .cast(); + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_fnPtrTrampoline); ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(block) as ffi.Pointer Function( - ffi.Pointer, ffi.Pointer))(arg0, arg1); -ffi.Pointer - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_closureCallable = + (objc.getBlockClosure(target.address) + as ffi.Pointer Function(ffi.Pointer, + ffi.Pointer))(arg0, arg1); +final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_closureCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_closureTrampoline) - .cast(); + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_closureTrampoline); /// Construction methods for `objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer)>`. abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector { @@ -10977,16 +10792,9 @@ abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)> - fromFunctionPointer(ffi.Pointer Function(ffi.Pointer arg0, ffi.Pointer arg1)>> ptr) => - objc.ObjCBlock< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>( - objc.newPointerBlock(_ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer)> fromFunctionPointer(ffi.Pointer Function(ffi.Pointer arg0, ffi.Pointer arg1)>> ptr) => + // objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer)>(todo(_ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -10995,49 +10803,23 @@ abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector { /// will result in a crash. static objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer)> fromFunction(objc.ObjCObjectBase Function(ffi.Pointer, ffi.Pointer) fn) => - objc.ObjCBlock< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>( - objc.newClosureBlock( + objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer)>( + _ObjectiveCBindings_newClosureBlock_ykn0t6( _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_closureCallable, - (ffi.Pointer arg0, ffi.Pointer arg1) => - fn(arg0, arg1).ref.retainAndAutorelease()), + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(arg0, arg1).ref.retainAndAutorelease())), retain: false, release: true); } -/// Call operator for `objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer)>`. -extension ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_CallExtension - on objc.ObjCBlock< - ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)> { - objc.ObjCObjectBase call( - ffi.Pointer arg0, ffi.Pointer arg1) => - objc.ObjCObjectBase( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1)>>() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>()( - ref.pointer, arg0, arg1), - retain: true, - release: true); -} - ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -11049,36 +10831,33 @@ ffi.Pointer ffi.Pointer, ffi.Pointer, ffi.Pointer)>()(arg0, arg1, arg2); -ffi.Pointer - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_fnPtrCallable = +final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_fnPtrTrampoline) - .cast(); + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_fnPtrTrampoline); ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => - (objc.getBlockClosure(block) as ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer))(arg0, arg1, arg2); -ffi.Pointer - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_closureCallable = + (objc.getBlockClosure(target.address) + as ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer))(arg0, arg1, arg2); +final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_closureCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_closureTrampoline) - .cast(); + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_closureTrampoline); /// Construction methods for `objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>`. abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject { @@ -11100,18 +10879,9 @@ abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCO /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)> - fromFunctionPointer(ffi.Pointer Function(ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2)>> ptr) => - objc.ObjCBlock< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - objc.newPointerBlock(_ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)> fromFunctionPointer(ffi.Pointer Function(ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2)>> ptr) => + // objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(todo(_ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// @@ -11121,53 +10891,24 @@ abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCO static objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)> fromFunction(objc.ObjCObjectBase Function(ffi.Pointer, ffi.Pointer, objc.ObjCObjectBase) fn) => objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>( - objc.newClosureBlock( + _ObjectiveCBindings_newClosureBlock_1c0c70u( _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_closureCallable, - (ffi.Pointer arg0, + objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => - fn(arg0, arg1, objc.ObjCObjectBase(arg2, retain: true, release: true)) - .ref - .retainAndAutorelease()), + fn(arg0, arg1, objc.ObjCObjectBase(arg2, retain: true, release: true)).ref.retainAndAutorelease())), retain: false, release: true); } -/// Call operator for `objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>`. -extension ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_CallExtension - on objc.ObjCBlock< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)> { - objc.ObjCObjectBase call(ffi.Pointer arg0, - ffi.Pointer arg1, objc.ObjCObjectBase arg2) => - objc.ObjCObjectBase( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2)>>() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>()( - ref.pointer, arg0, arg1, arg2.ref.pointer), - retain: true, - release: true); -} - ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_fnPtrTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer arg3) => - block.ref.target + target .cast< ffi.NativeFunction< ffi.Pointer Function( @@ -11181,40 +10922,37 @@ ffi.Pointer ffi.Pointer, ffi.Pointer, ffi.Pointer)>()(arg0, arg1, arg2, arg3); -ffi.Pointer - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_fnPtrCallable = +final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_fnPtrTrampoline) - .cast(); + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_fnPtrTrampoline); ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_closureTrampoline( - ffi.Pointer block, + ffi.Pointer target, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer arg3) => - (objc.getBlockClosure(block) as ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer))(arg0, arg1, arg2, arg3); -ffi.Pointer - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_closureCallable = + (objc.getBlockClosure(target.address) + as ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer))(arg0, arg1, arg2, arg3); +final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_closureCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_closureTrampoline) - .cast(); + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_closureTrampoline); /// Construction methods for `objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>`. abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject { @@ -11239,75 +10977,25 @@ abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCO /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)> - fromFunctionPointer(ffi.Pointer Function(ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer arg3)>> ptr) => - objc.ObjCBlock< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>( - objc.newPointerBlock(_ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_fnPtrCallable, ptr.cast()), - retain: false, - release: true); + // static objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)> fromFunctionPointer(ffi.Pointer Function(ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer arg3)>> ptr) => + // objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>(todo(_ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_fnPtrCallable, ptr.cast()), + // retain: false, release: true); /// Creates a block from a Dart function. /// /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)> - fromFunction(objc.ObjCObjectBase Function(ffi.Pointer, ffi.Pointer, objc.ObjCObjectBase, objc.ObjCObjectBase) fn) => - objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>( - objc.newClosureBlock( - _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_closureCallable, - (ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3) => - fn(arg0, arg1, objc.ObjCObjectBase(arg2, retain: true, release: true), objc.ObjCObjectBase(arg3, retain: true, release: true)) - .ref - .retainAndAutorelease()), - retain: false, - release: true); -} - -/// Call operator for `objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>`. -extension ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_CallExtension - on objc.ObjCBlock< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)> { - objc.ObjCObjectBase call( - ffi.Pointer arg0, - ffi.Pointer arg1, - objc.ObjCObjectBase arg2, - objc.ObjCObjectBase arg3) => - objc.ObjCObjectBase( - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer arg3)>>() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>()(ref.pointer, arg0, arg1, arg2.ref.pointer, arg3.ref.pointer), - retain: true, + static objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)> fromFunction(objc.ObjCObjectBase Function(ffi.Pointer, ffi.Pointer, objc.ObjCObjectBase, objc.ObjCObjectBase) fn) => + objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>( + _ObjectiveCBindings_newClosureBlock_u8b97m( + _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_closureCallable, + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3) => + fn(arg0, arg1, objc.ObjCObjectBase(arg2, retain: true, release: true), objc.ObjCObjectBase(arg3, retain: true, release: true)).ref.retainAndAutorelease())), + retain: false, release: true); } diff --git a/pkgs/objective_c/src/objective_c.c b/pkgs/objective_c/src/objective_c.c index 29ccd3244..5ac45e685 100644 --- a/pkgs/objective_c/src/objective_c.c +++ b/pkgs/objective_c/src/objective_c.c @@ -10,15 +10,35 @@ #include "include/dart_api_dl.h" #include "objective_c_runtime.h" +typedef struct _ObjCBlockInternal { + void *isa; + int flags; + int reserved; + void *invoke; + void *descriptor; + void *target; + Dart_Port dispose_port; +} ObjCBlockInternal; + +// https://opensource.apple.com/source/libclosure/libclosure-38/Block_private.h +extern void *_NSConcreteStackBlock[32]; +extern void *_NSConcreteMallocBlock[32]; +extern void *_NSConcreteAutoBlock[32]; +extern void *_NSConcreteFinalizingBlock[32]; +extern void *_NSConcreteGlobalBlock[32]; +extern void *_NSConcreteWeakBlockVariable[32]; + // Dispose helper for ObjC blocks that wrap a Dart closure. For these blocks, // the target is an int ID, and the dispose_port is listening for these IDs. void DOBJC_disposeObjCBlockWithClosure(ObjCBlockImpl* block) { - Dart_PostInteger_DL(block->dispose_port, (int64_t)block->target); + ObjCBlockInternal* blk = (ObjCBlockInternal*)block; + Dart_PostInteger_DL(blk->dispose_port, (int64_t)blk->target); } bool DOBJC_isValidBlock(ObjCBlockImpl* block) { if (block == NULL) return false; - void* isa = block->isa; + ObjCBlockInternal* blk = (ObjCBlockInternal*)block; + void* isa = blk->isa; return isa == &_NSConcreteStackBlock || isa == &_NSConcreteMallocBlock || isa == &_NSConcreteAutoBlock || isa == &_NSConcreteFinalizingBlock || isa == &_NSConcreteGlobalBlock || isa == &_NSConcreteWeakBlockVariable; diff --git a/pkgs/objective_c/src/objective_c_bindings_generated.m b/pkgs/objective_c/src/objective_c_bindings_generated.m index 951871d0c..0bbfac8e7 100644 --- a/pkgs/objective_c/src/objective_c_bindings_generated.m +++ b/pkgs/objective_c/src/objective_c_bindings_generated.m @@ -13,19 +13,90 @@ Protocol* _ObjectiveCBindings_NSStreamDelegate(void) { return @protocol(NSStreamDelegate); } -typedef void (^_ListenerTrampoline)(id arg0, id arg1, id arg2); +typedef id (^_BlockType)(void * arg0); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline _ObjectiveCBindings_wrapListenerBlock_1j2nt86(_ListenerTrampoline block) NS_RETURNS_RETAINED { +_BlockType _ObjectiveCBindings_newClosureBlock_1yesha9( + id (*trampoline)(void * , void * ), void* target) NS_RETURNS_RETAINED { + return ^id (void * arg0) { + return trampoline(target, arg0); + }; +} + +typedef unsigned long (^_BlockType1)(void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType1 _ObjectiveCBindings_newClosureBlock_1ckyi24( + unsigned long (*trampoline)(void * , void * ), void* target) NS_RETURNS_RETAINED { + return ^unsigned long (void * arg0) { + return trampoline(target, arg0); + }; +} + +typedef unsigned long (^_BlockType2)(void * arg0, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType2 _ObjectiveCBindings_newClosureBlock_17ap02x( + unsigned long (*trampoline)(void * , void * , NSFastEnumerationState * , id * , unsigned long ), void* target) NS_RETURNS_RETAINED { + return ^unsigned long (void * arg0, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3) { + return trampoline(target, arg0, arg1, arg2, arg3); + }; +} + +typedef struct _NSZone * (^_BlockType3)(void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType3 _ObjectiveCBindings_newClosureBlock_1a8cl66( + struct _NSZone * (*trampoline)(void * , void * ), void* target) NS_RETURNS_RETAINED { + return ^struct _NSZone * (void * arg0) { + return trampoline(target, arg0); + }; +} + +typedef BOOL (^_BlockType4)(void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType4 _ObjectiveCBindings_newClosureBlock_e3qsqz( + BOOL (*trampoline)(void * , void * ), void* target) NS_RETURNS_RETAINED { + return ^BOOL (void * arg0) { + return trampoline(target, arg0); + }; +} + +typedef BOOL (^_BlockType5)(void * arg0, id arg1); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType5 _ObjectiveCBindings_newClosureBlock_ozkafd( + BOOL (*trampoline)(void * , void * , id ), void* target) NS_RETURNS_RETAINED { + return ^BOOL (void * arg0, id arg1) { + return trampoline(target, arg0, arg1); + }; +} + +typedef BOOL (^_BlockType6)(void * arg0, struct objc_selector * arg1); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType6 _ObjectiveCBindings_newClosureBlock_w1e3k0( + BOOL (*trampoline)(void * , void * , struct objc_selector * ), void* target) NS_RETURNS_RETAINED { + return ^BOOL (void * arg0, struct objc_selector * arg1) { + return trampoline(target, arg0, arg1); + }; +} + +typedef void (^_BlockType7)(id arg0, id arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType7 _ObjectiveCBindings_newClosureBlock_1j2nt86( + void (*trampoline)(void * , id , id , id ), void* target) NS_RETURNS_RETAINED { + return ^void (id arg0, id arg1, id arg2) { + return trampoline(target, arg0, arg1, arg2); + }; +} + +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType7 _ObjectiveCBindings_wrapListenerBlock_1j2nt86(_BlockType7 block) NS_RETURNS_RETAINED { return ^void(id arg0, id arg1, id arg2) { objc_retainBlock(block); block(objc_retainBlock(arg0), objc_retain(arg1), objc_retain(arg2)); }; } -typedef void (^_BlockingTrampoline)(void * waiter, id arg0, id arg1, id arg2); +typedef void (^_BlockingTrampoline7)(void * waiter, id arg0, id arg1, id arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline _ObjectiveCBindings_wrapBlockingBlock_1j2nt86( - _BlockingTrampoline block, _BlockingTrampoline listenerBlock, +_BlockType7 _ObjectiveCBindings_wrapBlockingBlock_1j2nt86( + _BlockingTrampoline7 block, _BlockingTrampoline7 listenerBlock, void* (*newWaiter)(), void (*awaitWaiter)(void*)) NS_RETURNS_RETAINED { NSThread *targetThread = [NSThread currentThread]; return ^void(id arg0, id arg1, id arg2) { @@ -41,19 +112,27 @@ _ListenerTrampoline _ObjectiveCBindings_wrapBlockingBlock_1j2nt86( }; } -typedef void (^_ListenerTrampoline1)(void * arg0); +typedef void (^_BlockType8)(void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType8 _ObjectiveCBindings_newClosureBlock_ovsamd( + void (*trampoline)(void * , void * ), void* target) NS_RETURNS_RETAINED { + return ^void (void * arg0) { + return trampoline(target, arg0); + }; +} + __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline1 _ObjectiveCBindings_wrapListenerBlock_ovsamd(_ListenerTrampoline1 block) NS_RETURNS_RETAINED { +_BlockType8 _ObjectiveCBindings_wrapListenerBlock_ovsamd(_BlockType8 block) NS_RETURNS_RETAINED { return ^void(void * arg0) { objc_retainBlock(block); block(arg0); }; } -typedef void (^_BlockingTrampoline1)(void * waiter, void * arg0); +typedef void (^_BlockingTrampoline8)(void * waiter, void * arg0); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline1 _ObjectiveCBindings_wrapBlockingBlock_ovsamd( - _BlockingTrampoline1 block, _BlockingTrampoline1 listenerBlock, +_BlockType8 _ObjectiveCBindings_wrapBlockingBlock_ovsamd( + _BlockingTrampoline8 block, _BlockingTrampoline8 listenerBlock, void* (*newWaiter)(), void (*awaitWaiter)(void*)) NS_RETURNS_RETAINED { NSThread *targetThread = [NSThread currentThread]; return ^void(void * arg0) { @@ -69,19 +148,27 @@ _ListenerTrampoline1 _ObjectiveCBindings_wrapBlockingBlock_ovsamd( }; } -typedef void (^_ListenerTrampoline2)(void * arg0, id arg1); +typedef void (^_BlockType9)(void * arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline2 _ObjectiveCBindings_wrapListenerBlock_wjovn7(_ListenerTrampoline2 block) NS_RETURNS_RETAINED { +_BlockType9 _ObjectiveCBindings_newClosureBlock_wjovn7( + void (*trampoline)(void * , void * , id ), void* target) NS_RETURNS_RETAINED { + return ^void (void * arg0, id arg1) { + return trampoline(target, arg0, arg1); + }; +} + +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType9 _ObjectiveCBindings_wrapListenerBlock_wjovn7(_BlockType9 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1) { objc_retainBlock(block); block(arg0, objc_retain(arg1)); }; } -typedef void (^_BlockingTrampoline2)(void * waiter, void * arg0, id arg1); +typedef void (^_BlockingTrampoline9)(void * waiter, void * arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline2 _ObjectiveCBindings_wrapBlockingBlock_wjovn7( - _BlockingTrampoline2 block, _BlockingTrampoline2 listenerBlock, +_BlockType9 _ObjectiveCBindings_wrapBlockingBlock_wjovn7( + _BlockingTrampoline9 block, _BlockingTrampoline9 listenerBlock, void* (*newWaiter)(), void (*awaitWaiter)(void*)) NS_RETURNS_RETAINED { NSThread *targetThread = [NSThread currentThread]; return ^void(void * arg0, id arg1) { @@ -97,19 +184,27 @@ _ListenerTrampoline2 _ObjectiveCBindings_wrapBlockingBlock_wjovn7( }; } -typedef void (^_ListenerTrampoline3)(void * arg0, id arg1, NSStreamEvent arg2); +typedef void (^_BlockType10)(void * arg0, id arg1, NSStreamEvent arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline3 _ObjectiveCBindings_wrapListenerBlock_18d6mda(_ListenerTrampoline3 block) NS_RETURNS_RETAINED { +_BlockType10 _ObjectiveCBindings_newClosureBlock_18d6mda( + void (*trampoline)(void * , void * , id , NSStreamEvent ), void* target) NS_RETURNS_RETAINED { + return ^void (void * arg0, id arg1, NSStreamEvent arg2) { + return trampoline(target, arg0, arg1, arg2); + }; +} + +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType10 _ObjectiveCBindings_wrapListenerBlock_18d6mda(_BlockType10 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, NSStreamEvent arg2) { objc_retainBlock(block); block(arg0, objc_retain(arg1), arg2); }; } -typedef void (^_BlockingTrampoline3)(void * waiter, void * arg0, id arg1, NSStreamEvent arg2); +typedef void (^_BlockingTrampoline10)(void * waiter, void * arg0, id arg1, NSStreamEvent arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline3 _ObjectiveCBindings_wrapBlockingBlock_18d6mda( - _BlockingTrampoline3 block, _BlockingTrampoline3 listenerBlock, +_BlockType10 _ObjectiveCBindings_wrapBlockingBlock_18d6mda( + _BlockingTrampoline10 block, _BlockingTrampoline10 listenerBlock, void* (*newWaiter)(), void (*awaitWaiter)(void*)) NS_RETURNS_RETAINED { NSThread *targetThread = [NSThread currentThread]; return ^void(void * arg0, id arg1, NSStreamEvent arg2) { @@ -125,19 +220,27 @@ _ListenerTrampoline3 _ObjectiveCBindings_wrapBlockingBlock_18d6mda( }; } -typedef void (^_ListenerTrampoline4)(id arg0, id arg1); +typedef void (^_BlockType11)(id arg0, id arg1); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType11 _ObjectiveCBindings_newClosureBlock_wjvic9( + void (*trampoline)(void * , id , id ), void* target) NS_RETURNS_RETAINED { + return ^void (id arg0, id arg1) { + return trampoline(target, arg0, arg1); + }; +} + __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline4 _ObjectiveCBindings_wrapListenerBlock_wjvic9(_ListenerTrampoline4 block) NS_RETURNS_RETAINED { +_BlockType11 _ObjectiveCBindings_wrapListenerBlock_wjvic9(_BlockType11 block) NS_RETURNS_RETAINED { return ^void(id arg0, id arg1) { objc_retainBlock(block); block(objc_retain(arg0), objc_retain(arg1)); }; } -typedef void (^_BlockingTrampoline4)(void * waiter, id arg0, id arg1); +typedef void (^_BlockingTrampoline11)(void * waiter, id arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline4 _ObjectiveCBindings_wrapBlockingBlock_wjvic9( - _BlockingTrampoline4 block, _BlockingTrampoline4 listenerBlock, +_BlockType11 _ObjectiveCBindings_wrapBlockingBlock_wjvic9( + _BlockingTrampoline11 block, _BlockingTrampoline11 listenerBlock, void* (*newWaiter)(), void (*awaitWaiter)(void*)) NS_RETURNS_RETAINED { NSThread *targetThread = [NSThread currentThread]; return ^void(id arg0, id arg1) { @@ -152,3 +255,48 @@ _ListenerTrampoline4 _ObjectiveCBindings_wrapBlockingBlock_wjvic9( } }; } + +typedef id (^_BlockType12)(void * arg0, id arg1); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType12 _ObjectiveCBindings_newClosureBlock_1m9h2n( + id (*trampoline)(void * , void * , id ), void* target) NS_RETURNS_RETAINED { + return ^id (void * arg0, id arg1) { + return trampoline(target, arg0, arg1); + }; +} + +typedef id (^_BlockType13)(void * arg0, id arg1, id arg2, id * arg3); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType13 _ObjectiveCBindings_newClosureBlock_e2pkq8( + id (*trampoline)(void * , void * , id , id , id * ), void* target) NS_RETURNS_RETAINED { + return ^id (void * arg0, id arg1, id arg2, id * arg3) { + return trampoline(target, arg0, arg1, arg2, arg3); + }; +} + +typedef id (^_BlockType14)(void * arg0, struct objc_selector * arg1); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType14 _ObjectiveCBindings_newClosureBlock_ykn0t6( + id (*trampoline)(void * , void * , struct objc_selector * ), void* target) NS_RETURNS_RETAINED { + return ^id (void * arg0, struct objc_selector * arg1) { + return trampoline(target, arg0, arg1); + }; +} + +typedef id (^_BlockType15)(void * arg0, struct objc_selector * arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType15 _ObjectiveCBindings_newClosureBlock_1c0c70u( + id (*trampoline)(void * , void * , struct objc_selector * , id ), void* target) NS_RETURNS_RETAINED { + return ^id (void * arg0, struct objc_selector * arg1, id arg2) { + return trampoline(target, arg0, arg1, arg2); + }; +} + +typedef id (^_BlockType16)(void * arg0, struct objc_selector * arg1, id arg2, id arg3); +__attribute__((visibility("default"))) __attribute__((used)) +_BlockType16 _ObjectiveCBindings_newClosureBlock_u8b97m( + id (*trampoline)(void * , void * , struct objc_selector * , id , id ), void* target) NS_RETURNS_RETAINED { + return ^id (void * arg0, struct objc_selector * arg1, id arg2, id arg3) { + return trampoline(target, arg0, arg1, arg2, arg3); + }; +} diff --git a/pkgs/objective_c/src/objective_c_runtime.h b/pkgs/objective_c/src/objective_c_runtime.h index f911c549f..4e1824373 100644 --- a/pkgs/objective_c/src/objective_c_runtime.h +++ b/pkgs/objective_c/src/objective_c_runtime.h @@ -13,6 +13,7 @@ typedef struct _ObjCSelector ObjCSelector; typedef struct _ObjCObject ObjCObject; +typedef struct _ObjCBlockImpl ObjCBlockImpl; typedef struct _ObjCProtocol ObjCProtocol; ObjCSelector *sel_registerName(const char *name); @@ -31,35 +32,6 @@ void objc_msgSend(void); void objc_msgSend_fpret(void); void objc_msgSend_stret(void); -// See https://clang.llvm.org/docs/Block-ABI-Apple.html -typedef struct _ObjCBlockDesc { - unsigned long int reserved; - unsigned long int size; // sizeof(ObjCBlockImpl) - void (*copy_helper)(void *dst, void *src); - void (*dispose_helper)(void *src); - const char *signature; -} ObjCBlockDesc; - -typedef struct _ObjCBlockImpl { - void *isa; // _NSConcreteGlobalBlock - int flags; - int reserved; - void *invoke; // RET (*invoke)(ObjCBlockImpl *, ARGS...); - ObjCBlockDesc *descriptor; - - // Captured variables follow. These are specific to our use case. - void *target; - Dart_Port dispose_port; -} ObjCBlockImpl; - -// https://opensource.apple.com/source/libclosure/libclosure-38/Block_private.h -extern void *_NSConcreteStackBlock[32]; -extern void *_NSConcreteMallocBlock[32]; -extern void *_NSConcreteAutoBlock[32]; -extern void *_NSConcreteFinalizingBlock[32]; -extern void *_NSConcreteGlobalBlock[32]; -extern void *_NSConcreteWeakBlockVariable[32]; - typedef struct _ObjCMethodDesc { ObjCSelector* name; const char* types; From 4e74ba91acdaba332c84fe558d8cf7a6f765d33c Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Tue, 7 Jan 2025 12:38:20 +1100 Subject: [PATCH 2/4] Fix analysis --- .../lib/src/code_generator/objc_block.dart | 21 ++++++++--------- .../objc_built_in_functions.dart | 23 +++++++++---------- pkgs/objective_c/lib/src/internal.dart | 4 +--- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/pkgs/ffigen/lib/src/code_generator/objc_block.dart b/pkgs/ffigen/lib/src/code_generator/objc_block.dart index 41c8104a6..3d427428f 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_block.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_block.dart @@ -133,13 +133,15 @@ class ObjCBlock extends BindingType { w.topLevelUniqueNamer.makeUnique('_${name}_blockingCallable'); final blockingListenerCallable = w.topLevelUniqueNamer.makeUnique('_${name}_blockingListenerCallable'); - final callExtension = - w.topLevelUniqueNamer.makeUnique('${name}_CallExtension'); + // final callExtension = + // w.topLevelUniqueNamer.makeUnique('${name}_CallExtension'); - final newPointerBlock = 'todo';//ObjCBuiltInFunctions.newPointerBlock.gen(w); + final newPointerBlock = + 'todo'; //ObjCBuiltInFunctions.newPointerBlock.gen(w); // final newClosureBlock = ObjCBuiltInFunctions.newClosureBlock.gen(w); final newClosureBlock = _blockWrappers.newClosureBlock.name; - final registerBlockClosure = ObjCBuiltInFunctions.registerBlockClosure.gen(w); + final registerBlockClosure = + ObjCBuiltInFunctions.registerBlockClosure.gen(w); final getBlockClosure = ObjCBuiltInFunctions.getBlockClosure.gen(w); final releaseFn = ObjCBuiltInFunctions.objectRelease.gen(w); final wrapBlockingBlockFn = ObjCBuiltInFunctions.wrapBlockingBlock.gen(w); @@ -339,8 +341,8 @@ abstract final class $name { @override BindingString? toObjCBindingString(Writer w) { - if (_blockWrappers?.objCBindingsGenerated ?? true) return null; - _blockWrappers!.objCBindingsGenerated = true; + if (_blockWrappers.objCBindingsGenerated) return null; + _blockWrappers.objCBindingsGenerated = true; final argsReceived = []; final retains = []; @@ -366,8 +368,7 @@ abstract final class $name { final returnNativeType = returnType.getNativeType(); final newClosureBlock = _blockWrappers.newClosureBlock.name; - final blockTypeName = - w.objCLevelUniqueNamer.makeUnique('_BlockType'); + final blockTypeName = w.objCLevelUniqueNamer.makeUnique('_BlockType'); final blockingName = w.objCLevelUniqueNamer.makeUnique('_BlockingTrampoline'); final trampolineArg = @@ -522,9 +523,7 @@ class _FnHelper { returnType: returnType, parameters: [ Parameter( - type: PointerType(voidType), - name: 'target', - objCConsumed: false), + type: PointerType(voidType), name: 'target', objCConsumed: false), ...params, ], ); diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart index f5f212f1d..fad51a670 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart @@ -216,9 +216,7 @@ class ObjCBuiltInFunctions { returnType: block.returnType, parameters: [ Parameter( - type: PointerType(voidType), - name: 'target', - objCConsumed: false), + type: PointerType(voidType), name: 'target', objCConsumed: false), ...block.params, ], ); @@ -233,9 +231,7 @@ class ObjCBuiltInFunctions { type: PointerType(NativeFunc(trampolineType)), objCConsumed: false), Parameter( - type: PointerType(voidType), - name: 'target', - objCConsumed: false), + type: PointerType(voidType), name: 'target', objCConsumed: false), ], objCReturnsRetained: true, isLeaf: true, @@ -244,9 +240,13 @@ class ObjCBuiltInFunctions { ffiNativeConfig: const FfiNativeConfig(enabled: true), ), // TODO: wrap*Block should become new*Block. - block.hasListener ? _blockTrampolineFunc('_${wrapperName}_wrapListenerBlock_$idHash') : null, - block.hasListener ? _blockTrampolineFunc('_${wrapperName}_wrapBlockingBlock_$idHash', - blocking: true) : null, + block.hasListener + ? _blockTrampolineFunc('_${wrapperName}_wrapListenerBlock_$idHash') + : null, + block.hasListener + ? _blockTrampolineFunc('_${wrapperName}_wrapBlockingBlock_$idHash', + blocking: true) + : null, ); } @@ -299,9 +299,8 @@ class ObjCBlockWrapperFuncs extends AstNode { final Func? blockingWrapper; bool objCBindingsGenerated = false; - ObjCBlockWrapperFuncs( - this.trampolineType, - this.newClosureBlock, this.listenerWrapper, this.blockingWrapper); + ObjCBlockWrapperFuncs(this.trampolineType, this.newClosureBlock, + this.listenerWrapper, this.blockingWrapper); @override void visitChildren(Visitor visitor) { diff --git a/pkgs/objective_c/lib/src/internal.dart b/pkgs/objective_c/lib/src/internal.dart index 5e8528770..220ee8369 100644 --- a/pkgs/objective_c/lib/src/internal.dart +++ b/pkgs/objective_c/lib/src/internal.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:ffi'; -import 'dart:isolate'; import 'package:ffi/ffi.dart'; @@ -437,8 +436,7 @@ BlockPtr wrapBlockingBlock( ); // Not exported by ../objective_c.dart, because they're only for testing. -bool blockHasRegisteredClosure(int id) => - _blockClosureRegistry.containsKey(id); +bool blockHasRegisteredClosure(int id) => _blockClosureRegistry.containsKey(id); bool isValidBlock(BlockPtr block) => c.isValidBlock(block); bool isValidClass(ObjectPtr clazz) => _isValidClass(clazz); bool isValidObject(ObjectPtr object) => _isValidObject(object); From 27176d847b003c1085e71b5b9e68c8b77f11c078 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 8 Jan 2025 11:53:34 +1100 Subject: [PATCH 3/4] Support invoking blocks from Dart --- .../lib/src/code_generator/objc_block.dart | 59 +++--- .../objc_built_in_functions.dart | 22 ++- .../test/native_objc_test/block_test.dart | 174 +++++++++--------- 3 files changed, 139 insertions(+), 116 deletions(-) diff --git a/pkgs/ffigen/lib/src/code_generator/objc_block.dart b/pkgs/ffigen/lib/src/code_generator/objc_block.dart index 3d427428f..4e3facb56 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_block.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_block.dart @@ -133,13 +133,13 @@ class ObjCBlock extends BindingType { w.topLevelUniqueNamer.makeUnique('_${name}_blockingCallable'); final blockingListenerCallable = w.topLevelUniqueNamer.makeUnique('_${name}_blockingListenerCallable'); - // final callExtension = - // w.topLevelUniqueNamer.makeUnique('${name}_CallExtension'); + final callExtension = + w.topLevelUniqueNamer.makeUnique('${name}_CallExtension'); final newPointerBlock = 'todo'; //ObjCBuiltInFunctions.newPointerBlock.gen(w); - // final newClosureBlock = ObjCBuiltInFunctions.newClosureBlock.gen(w); final newClosureBlock = _blockWrappers.newClosureBlock.name; + final invokeBlock = _blockWrappers.invokeBlock.name; final registerBlockClosure = ObjCBuiltInFunctions.registerBlockClosure.gen(w); final getBlockClosure = ObjCBuiltInFunctions.getBlockClosure.gen(w); @@ -311,30 +311,27 @@ abstract final class $name { s.write('}\n\n'); // Call operator extension method. -// s.write(''' -// /// Call operator for `$blockType`. -// extension $callExtension on $blockType { -// ${returnType.getDartType(w)} call(${func.paramsDartType}) =>'''); -// final callMethodArgs = params -// .map((p) => p.type.convertDartTypeToFfiDartType( -// w, -// p.name, -// objCRetain: p.objCConsumed, -// objCAutorelease: false, -// )) -// .join(', '); -// final callMethodInvocation = ''' -// ref.pointer.ref.invoke.cast<${func.trampNatFnCType}>() -// .asFunction<${func.trampFfiDartType}>()( -// ref.pointer, $callMethodArgs)'''; -// s.write(returnType.convertFfiDartTypeToDartType( -// w, -// callMethodInvocation, -// objCRetain: !returnsRetained, -// )); -// s.write(';\n'); - -// s.write('}\n\n'); + final callMethodArgs = params + .map((p) => p.type.convertDartTypeToFfiDartType( + w, + p.name, + objCRetain: p.objCConsumed, + objCAutorelease: false, + )) + .join(', '); + final callMethod = returnType.convertFfiDartTypeToDartType( + w, + '$invokeBlock(ref.pointer, $callMethodArgs)', + objCRetain: !returnsRetained, + ); + s.write(''' +/// Call operator for `$blockType`. +extension $callExtension on $blockType { + ${returnType.getDartType(w)} call(${func.paramsDartType}) => $callMethod; +} + +'''); + return BindingString( type: BindingStringType.objcBlock, string: s.toString()); } @@ -368,16 +365,24 @@ abstract final class $name { final returnNativeType = returnType.getNativeType(); final newClosureBlock = _blockWrappers.newClosureBlock.name; + final invokeBlock = _blockWrappers.invokeBlock.name; final blockTypeName = w.objCLevelUniqueNamer.makeUnique('_BlockType'); final blockingName = w.objCLevelUniqueNamer.makeUnique('_BlockingTrampoline'); final trampolineArg = _blockWrappers.trampolineType.getNativeType(varName: 'trampoline'); + final retainStr = returnsRetained ? 'NS_RETURNS_RETAINED' : ''; final s = StringBuffer(); s.write(''' typedef $returnNativeType (^$blockTypeName)($argStr); +__attribute__((visibility("default"))) __attribute__((used)) +$returnNativeType $invokeBlock( + ${['$blockTypeName block', ...argsReceived].join(', ')}) $retainStr { + return block(${noRetains.join(', ')}); +} + __attribute__((visibility("default"))) __attribute__((used)) $blockTypeName $newClosureBlock( $trampolineArg, void* target) NS_RETURNS_RETAINED { diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart index fad51a670..b1f258cd6 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart @@ -222,6 +222,22 @@ class ObjCBuiltInFunctions { ); return _blockTrampolines[id] ??= ObjCBlockWrapperFuncs( trampolineType, + Func( + name: '_${wrapperName}_invokeBlock_$idHash', + returnType: block.returnType, + parameters: [ + Parameter( + name: 'block', + type: PointerType(objCBlockType), + objCConsumed: false), + ...block.params, + ], + objCReturnsRetained: block.returnsRetained, + isLeaf: false, + isInternal: true, + useNameForLookup: true, + ffiNativeConfig: const FfiNativeConfig(enabled: true), + ), Func( name: '_${wrapperName}_newClosureBlock_$idHash', returnType: PointerType(objCBlockType), @@ -294,18 +310,20 @@ class ObjCBuiltInFunctions { /// A native trampoline function for a listener block. class ObjCBlockWrapperFuncs extends AstNode { final FunctionType trampolineType; + final Func invokeBlock; final Func newClosureBlock; final Func? listenerWrapper; final Func? blockingWrapper; bool objCBindingsGenerated = false; - ObjCBlockWrapperFuncs(this.trampolineType, this.newClosureBlock, - this.listenerWrapper, this.blockingWrapper); + ObjCBlockWrapperFuncs(this.trampolineType, this.invokeBlock, + this.newClosureBlock, this.listenerWrapper, this.blockingWrapper); @override void visitChildren(Visitor visitor) { super.visitChildren(visitor); visitor.visit(trampolineType); + visitor.visit(invokeBlock); visitor.visit(newClosureBlock); visitor.visit(listenerWrapper); visitor.visit(blockingWrapper); diff --git a/pkgs/ffigen/test/native_objc_test/block_test.dart b/pkgs/ffigen/test/native_objc_test/block_test.dart index 557e0256b..475df9506 100644 --- a/pkgs/ffigen/test/native_objc_test/block_test.dart +++ b/pkgs/ffigen/test/native_objc_test/block_test.dart @@ -83,7 +83,7 @@ void main() { final blockTester = BlockTester.newFromBlock_(block); blockTester.pokeBlock(); expect(blockTester.call_(123), 4123); - // expect(block(123), 4123); + expect(block(123), 4123); }); test('Listener block same thread', () async { @@ -169,7 +169,7 @@ void main() { expect(await resultCompleter.future, 123456); }); - /*test('Blocking block manual invocation', () { + test('Blocking block manual invocation', () { int value = 0; final block = VoidBlock.blocking(() { waitSync(Duration(milliseconds: 100)); @@ -177,13 +177,13 @@ void main() { }); block(); expect(value, 123); - });*/ + }); test('Float block', () { final block = FloatBlock.fromFunction((double x) { return x + 4.56; }); - // expect(block(1.23), closeTo(5.79, 1e-6)); + expect(block(1.23), closeTo(5.79, 1e-6)); expect(BlockTester.callFloatBlock_(block), closeTo(5.79, 1e-6)); }); @@ -191,7 +191,7 @@ void main() { final block = DoubleBlock.fromFunction((double x) { return x + 4.56; }); - // expect(block(1.23), closeTo(5.79, 1e-6)); + expect(block(1.23), closeTo(5.79, 1e-6)); expect(BlockTester.callDoubleBlock_(block), closeTo(5.79, 1e-6)); }); @@ -215,11 +215,11 @@ void main() { return temp; }); - // final result1 = block(input); - // expect(result1.x, 3.4); - // expect(result1.y, 5.6); - // expect(result1.z, 7.8); - // expect(result1.w, 1.2); + final result1 = block(input); + expect(result1.x, 3.4); + expect(result1.y, 5.6); + expect(result1.z, 7.8); + expect(result1.w, 1.2); final result2 = BlockTester.callVec4Block_(block); expect(result2.x, 3.4); @@ -235,8 +235,8 @@ void main() { sel = x.toDartString(); }); - // block('Hello'.toSelector()); - // expect(sel, 'Hello'); + block('Hello'.toSelector()); + expect(sel, 'Hello'); BlockTester.callSelectorBlock_(block); expect(sel, 'Select'); @@ -249,14 +249,14 @@ void main() { return x; }); - // final obj = DummyObject.new1(); - // final result1 = block(obj); - // expect(result1, obj); - // expect(isCalled, isTrue); + final obj = DummyObject.new1(); + final result1 = block(obj); + expect(result1, obj); + expect(isCalled, isTrue); isCalled = false; final result2 = BlockTester.callObjectBlock_(block); - // expect(result2, isNot(obj)); + expect(result2, isNot(obj)); expect(result2.ref.pointer, isNot(nullptr)); expect(isCalled, isTrue); }); @@ -268,15 +268,15 @@ void main() { return x; }); - // final obj = DummyObject.new1(); - // final result1 = block(obj); - // expect(result1, obj); - // expect(isCalled, isTrue); + final obj = DummyObject.new1(); + final result1 = block(obj); + expect(result1, obj); + expect(isCalled, isTrue); - // isCalled = false; - // final result2 = block(null); - // expect(result2, isNull); - // expect(isCalled, isTrue); + isCalled = false; + final result2 = block(null); + expect(result2, isNull); + expect(isCalled, isTrue); isCalled = false; final result3 = BlockTester.callNullableObjectBlock_(block); @@ -289,11 +289,11 @@ void main() { final block = NullableStringBlock.fromFunction( (NSString? x) => '$x Cat'.toNSString()); - // final result1 = block('Dog'.toNSString()); - // expect(result1.toString(), 'Dog Cat'); + final result1 = block('Dog'.toNSString()); + expect(result1.toString(), 'Dog Cat'); - // final result2 = block(null); - // expect(result2.toString(), 'null Cat'); + final result2 = block(null); + expect(result2.toString(), 'null Cat'); final result3 = BlockTester.callNullableStringBlock_(block); expect(result3.toString(), 'Lizard Cat'); @@ -373,7 +373,7 @@ void main() { await hasRun.future; }); - /*test('Block block', () { + test('Block block', () { final blockBlock = BlockBlock.fromFunction((ObjCBlock intBlock) { return IntBlock.fromFunction((int x) { @@ -402,7 +402,7 @@ void main() { final result2 = BlockTester.newBlock_withMult_(blockBlock, 2); expect(result2(1), 14); - });*/ + }); /*Pointer funcPointerBlockRefCountTest() { final block = @@ -419,10 +419,10 @@ void main() { expect(blockRetainCount(rawBlock), 0); }, skip: !canDoGC);*/ - /*Pointer funcBlockRefCountTest() { + Pointer funcBlockRefCountTest() { final block = IntBlock.fromFunction(makeAdder(4000)); - expect(internal_for_testing.blockHasRegisteredClosure(block.ref.pointer), - true); + // expect(internal_for_testing.blockHasRegisteredClosure(block.ref.pointer), + // true); expect(blockRetainCount(block.ref.pointer), 1); return block.ref.pointer; } @@ -432,21 +432,21 @@ void main() { doGC(); await Future.delayed(Duration.zero); // Let dispose message arrive. expect(blockRetainCount(rawBlock), 0); - expect(internal_for_testing.blockHasRegisteredClosure(rawBlock.cast()), - false); + // expect(internal_for_testing.blockHasRegisteredClosure(rawBlock.cast()), + // false); }, skip: !canDoGC); Pointer blockManualRetainRefCountTest() { final block = IntBlock.fromFunction(makeAdder(4000)); - expect(internal_for_testing.blockHasRegisteredClosure(block.ref.pointer), - true); + // expect(internal_for_testing.blockHasRegisteredClosure(block.ref.pointer), + // true); expect(blockRetainCount(block.ref.pointer), 1); final rawBlock = block.ref.retainAndReturnPointer(); expect(blockRetainCount(rawBlock), 2); return rawBlock; - }*/ + } - /*int blockManualRetainRefCountTest2(Pointer rawBlock) { + int blockManualRetainRefCountTest2(Pointer rawBlock) { final block = IntBlock.castFromPointer(rawBlock.cast(), retain: false, release: true); return blockRetainCount(block.ref.pointer); @@ -460,11 +460,11 @@ void main() { doGC(); await Future.delayed(Duration.zero); // Let dispose message arrive. expect(blockRetainCount(rawBlock), 0); - expect(internal_for_testing.blockHasRegisteredClosure(rawBlock.cast()), - false); - }, skip: !canDoGC);*/ + // expect(internal_for_testing.blockHasRegisteredClosure(rawBlock.cast()), + // false); + }, skip: !canDoGC); - /*(Pointer, Pointer, Pointer) + (Pointer, Pointer, Pointer) blockBlockDartCallRefCountTest() { final pool = lib.objc_autoreleasePoolPush(); final inputBlock = IntBlock.fromFunction((int x) { @@ -484,21 +484,21 @@ void main() { // One reference held by inputBlock object, another bound to the // outputBlock lambda. expect(blockRetainCount(inputBlock.ref.pointer), 2); - expect( - internal_for_testing - .blockHasRegisteredClosure(inputBlock.ref.pointer.cast()), - true); + // expect( + // internal_for_testing + // .blockHasRegisteredClosure(inputBlock.ref.pointer.cast()), + // true); expect(blockRetainCount(blockBlock.ref.pointer), 1); - expect( - internal_for_testing - .blockHasRegisteredClosure(blockBlock.ref.pointer.cast()), - true); + // expect( + // internal_for_testing + // .blockHasRegisteredClosure(blockBlock.ref.pointer.cast()), + // true); expect(blockRetainCount(outputBlock.ref.pointer), 1); - expect( - internal_for_testing - .blockHasRegisteredClosure(outputBlock.ref.pointer.cast()), - true); + // expect( + // internal_for_testing + // .blockHasRegisteredClosure(outputBlock.ref.pointer.cast()), + // true); return ( inputBlock.ref.pointer, blockBlock.ref.pointer, @@ -514,18 +514,18 @@ void main() { doGC(); await Future.delayed(Duration.zero); // Let dispose message arrive. - expect(blockRetainCount(inputBlock), 0); - expect(internal_for_testing.blockHasRegisteredClosure(inputBlock.cast()), - false); + // expect(blockRetainCount(inputBlock), 0); + // expect(internal_for_testing.blockHasRegisteredClosure(inputBlock.cast()), + // false); expect(blockRetainCount(blockBlock), 0); - expect(internal_for_testing.blockHasRegisteredClosure(blockBlock.cast()), - false); + // expect(internal_for_testing.blockHasRegisteredClosure(blockBlock.cast()), + // false); expect(blockRetainCount(outputBlock), 0); - expect(internal_for_testing.blockHasRegisteredClosure(outputBlock.cast()), - false); - }, skip: !canDoGC);*/ + // expect(internal_for_testing.blockHasRegisteredClosure(outputBlock.cast()), + // false); + }, skip: !canDoGC); - /*(Pointer, Pointer, Pointer) + (Pointer, Pointer, Pointer) blockBlockObjCCallRefCountTest() { final pool = lib.objc_autoreleasePoolPush(); late Pointer inputBlock; @@ -542,18 +542,18 @@ void main() { doGC(); expect(blockRetainCount(inputBlock), 1); - expect(internal_for_testing.blockHasRegisteredClosure(inputBlock.cast()), - false); + // expect(internal_for_testing.blockHasRegisteredClosure(inputBlock.cast()), + // false); expect(blockRetainCount(blockBlock.ref.pointer), 1); - expect( - internal_for_testing - .blockHasRegisteredClosure(blockBlock.ref.pointer.cast()), - true); + // expect( + // internal_for_testing + // .blockHasRegisteredClosure(blockBlock.ref.pointer.cast()), + // true); expect(blockRetainCount(outputBlock.ref.pointer), 1); - expect( - internal_for_testing - .blockHasRegisteredClosure(outputBlock.ref.pointer.cast()), - true); + // expect( + // internal_for_testing + // .blockHasRegisteredClosure(outputBlock.ref.pointer.cast()), + // true); return (inputBlock, blockBlock.ref.pointer, outputBlock.ref.pointer); } @@ -565,18 +565,18 @@ void main() { doGC(); await Future.delayed(Duration.zero); // Let dispose message arrive. - expect(blockRetainCount(inputBlock), 0); - expect(internal_for_testing.blockHasRegisteredClosure(inputBlock.cast()), - false); + // expect(blockRetainCount(inputBlock), 0); + // expect(internal_for_testing.blockHasRegisteredClosure(inputBlock.cast()), + // false); expect(blockRetainCount(blockBlock), 0); - expect(internal_for_testing.blockHasRegisteredClosure(blockBlock.cast()), - false); + // expect(internal_for_testing.blockHasRegisteredClosure(blockBlock.cast()), + // false); expect(blockRetainCount(outputBlock), 0); - expect(internal_for_testing.blockHasRegisteredClosure(outputBlock.cast()), - false); - }, skip: !canDoGC);*/ + // expect(internal_for_testing.blockHasRegisteredClosure(outputBlock.cast()), + // false); + }, skip: !canDoGC); - /*(Pointer, Pointer, Pointer) + (Pointer, Pointer, Pointer) nativeBlockBlockDartCallRefCountTest() { final pool = lib.objc_autoreleasePoolPush(); final inputBlock = IntBlock.fromFunction((int x) { @@ -608,7 +608,7 @@ void main() { expect(blockRetainCount(inputBlock), 0); expect(blockRetainCount(blockBlock), 0); expect(blockRetainCount(outputBlock), 0); - }, skip: !canDoGC);*/ + }, skip: !canDoGC); (Pointer, Pointer) nativeBlockBlockObjCCallRefCountTest() { @@ -629,7 +629,7 @@ void main() { expect(blockRetainCount(outputBlock), 0); }, skip: !canDoGC); - /*(Pointer, Pointer) objectBlockRefCountTest(Allocator alloc) { + (Pointer, Pointer) objectBlockRefCountTest(Allocator alloc) { final pool = lib.objc_autoreleasePoolPush(); final inputCounter = alloc(); final outputCounter = alloc(); @@ -656,7 +656,7 @@ void main() { expect(inputCounter.value, 0); expect(outputCounter.value, 0); }); - }, skip: !canDoGC);*/ + }, skip: !canDoGC); (Pointer, Pointer) objectNativeBlockRefCountTest( Allocator alloc) { From 5c311cab0b2a51bac7af102ee69ca9ce4e67d262 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 9 Jan 2025 13:34:16 +1100 Subject: [PATCH 4/4] Fix memory management --- .../lib/src/code_generator/objc_block.dart | 62 +- .../objc_built_in_functions.dart | 36 +- .../ffigen/lib/src/code_generator/writer.dart | 10 + .../test/native_objc_test/block_test.dart | 144 +- pkgs/objective_c/lib/objective_c.dart | 5 +- .../lib/src/c_bindings_generated.dart | 5 +- pkgs/objective_c/lib/src/internal.dart | 70 +- .../src/objective_c_bindings_generated.dart | 1630 ++++++++++++----- pkgs/objective_c/src/objective_c.c | 10 +- pkgs/objective_c/src/objective_c.h | 2 +- .../src/objective_c_bindings_generated.m | 350 +++- pkgs/objective_c/test/main.c | 9 +- pkgs/objective_c/test/setup.dart | 2 +- 13 files changed, 1681 insertions(+), 654 deletions(-) diff --git a/pkgs/ffigen/lib/src/code_generator/objc_block.dart b/pkgs/ffigen/lib/src/code_generator/objc_block.dart index 4e3facb56..81bba4ab9 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_block.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_block.dart @@ -146,8 +146,13 @@ class ObjCBlock extends BindingType { final releaseFn = ObjCBuiltInFunctions.objectRelease.gen(w); final wrapBlockingBlockFn = ObjCBuiltInFunctions.wrapBlockingBlock.gen(w); final signalWaiterFn = ObjCBuiltInFunctions.signalWaiter.gen(w); + final blockClosureDisposePort = + ObjCBuiltInFunctions.blockClosureDisposePort.gen(w); + final disposeObjCBlockWithClosure = + ObjCBuiltInFunctions.disposeObjCBlockWithClosure.gen(w); final returnFfiDartType = returnType.getFfiDartType(w); final voidPtrCType = voidPtr.getCType(w); + final int64Type = NativeType(SupportedNativeType.int64).getCType(w); final blockCType = blockPtr.getCType(w); final blockType = _blockType(w); final defaultValue = returnType.getDefaultValue(w); @@ -156,8 +161,8 @@ class ObjCBlock extends BindingType { // Write the function pointer based trampoline function. s.write(''' $returnFfiDartType $funcPtrTrampoline( - $voidPtrCType target, ${func.paramsFfiDartType}) => - target.cast<${func.natFnFfiDartType}>() + $blockCType block, int closureId, ${func.paramsFfiDartType}) => + ${w.ffiLibraryPrefix}.Pointer<${func.natFnFfiDartType}>.fromAddress(closureId) .asFunction<${func.ffiDartType}>()(${func.paramsNameOnly}); final $funcPtrCallable = ${w.ffiLibraryPrefix}.Pointer.fromFunction< ${func.trampCType}>($funcPtrTrampoline $exceptionalReturn); @@ -166,8 +171,8 @@ final $funcPtrCallable = ${w.ffiLibraryPrefix}.Pointer.fromFunction< // Write the closure based trampoline function. s.write(''' $returnFfiDartType $closureTrampoline( - $voidPtrCType target, ${func.paramsFfiDartType}) => - ($getBlockClosure(target.address) as ${func.ffiDartType})(${func.paramsNameOnly}); + $blockCType block, int closureId, ${func.paramsFfiDartType}) => + ($getBlockClosure(closureId) as ${func.ffiDartType})(${func.paramsNameOnly}); final $closureCallable = ${w.ffiLibraryPrefix}.Pointer.fromFunction< ${func.trampCType}>($closureTrampoline $exceptionalReturn); '''); @@ -176,20 +181,20 @@ final $closureCallable = ${w.ffiLibraryPrefix}.Pointer.fromFunction< // Write the listener trampoline function. s.write(''' $returnFfiDartType $listenerTrampoline( - $voidPtrCType target, ${func.paramsFfiDartType}) { - ($getBlockClosure(target.address) as ${func.ffiDartType})(${func.paramsNameOnly}); - // $releaseFn(block.cast()); + $blockCType block, int closureId, ${func.paramsFfiDartType}) { + ($getBlockClosure(closureId) as ${func.ffiDartType})(${func.paramsNameOnly}); + $releaseFn(block.cast()); } ${func.trampNatCallType} $listenerCallable = ${func.trampNatCallType}.listener( $listenerTrampoline $exceptionalReturn)..keepIsolateAlive = false; $returnFfiDartType $blockingTrampoline( - $voidPtrCType target, ${blockingFunc.paramsFfiDartType}) { + $blockCType block, int closureId, ${blockingFunc.paramsFfiDartType}) { try { - ($getBlockClosure(target.address) as ${func.ffiDartType})(${func.paramsNameOnly}); + ($getBlockClosure(closureId) as ${func.ffiDartType})(${func.paramsNameOnly}); } catch (e) { } finally { $signalWaiterFn(waiter); - // $releaseFn(block.cast()); + $releaseFn(block.cast()); } } ${blockingFunc.trampNatCallType} $blockingCallable = @@ -244,7 +249,8 @@ abstract final class $name { /// will result in a crash. static $blockType fromFunction(${func.dartType} fn) => $blockType($newClosureBlock( - $closureCallable, $registerBlockClosure($convFn)), + $closureCallable, $registerBlockClosure($convFn), + $blockClosureDisposePort, $disposeObjCBlockWithClosure), retain: false, release: true); '''); @@ -281,7 +287,9 @@ abstract final class $name { /// blocks do not keep the isolate alive. static $blockType listener(${func.dartType} fn) { final raw = $newClosureBlock( - $listenerCallable.nativeFunction.cast(), $registerBlockClosure($listenerConvFn)); + $listenerCallable.nativeFunction.cast(), + $registerBlockClosure($listenerConvFn), + $blockClosureDisposePort, $disposeObjCBlockWithClosure); final wrapper = $wrapListenerFn(raw); $releaseFn(raw.cast()); return $blockType(wrapper, retain: false, release: true); @@ -298,9 +306,13 @@ abstract final class $name { /// indefinitely, or have other undefined behavior. static $blockType blocking(${func.dartType} fn) { final raw = $newClosureBlock( - $blockingCallable.nativeFunction.cast(), $registerBlockClosure($listenerConvFn)); + $blockingCallable.nativeFunction.cast(), + $registerBlockClosure($listenerConvFn), + $blockClosureDisposePort, $disposeObjCBlockWithClosure); final rawListener = $newClosureBlock( - $blockingListenerCallable.nativeFunction.cast(), $registerBlockClosure($listenerConvFn)); + $blockingListenerCallable.nativeFunction.cast(), + $registerBlockClosure($listenerConvFn), + $blockClosureDisposePort, $disposeObjCBlockWithClosure); final wrapper = $wrapBlockingBlockFn($wrapBlockingFn, raw, rawListener); $releaseFn(raw.cast()); $releaseFn(rawListener.cast()); @@ -372,6 +384,7 @@ extension $callExtension on $blockType { final trampolineArg = _blockWrappers.trampolineType.getNativeType(varName: 'trampoline'); final retainStr = returnsRetained ? 'NS_RETURNS_RETAINED' : ''; + final dtorClass = '_${w.className}_BlockDestroyer'; final s = StringBuffer(); s.write(''' @@ -385,10 +398,18 @@ $returnNativeType $invokeBlock( __attribute__((visibility("default"))) __attribute__((used)) $blockTypeName $newClosureBlock( - $trampolineArg, void* target) NS_RETURNS_RETAINED { - return ^$returnNativeType($argStr) { - return trampoline(${['target', ...noRetains].join(', ')}); + $trampolineArg, int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + $dtorClass* obj = [[$dtorClass alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block $blockTypeName weakBlk; + $blockTypeName blk = ^$returnNativeType($argStr) { + return trampoline(weakBlk, ${['obj.closure_id', ...noRetains].join(', ')}); }; + weakBlk = blk; + return blk; } '''); @@ -528,7 +549,12 @@ class _FnHelper { returnType: returnType, parameters: [ Parameter( - type: PointerType(voidType), name: 'target', objCConsumed: false), + type: PointerType(objCBlockType), + name: 'block', + objCConsumed: false), + Parameter( + type: NativeType(SupportedNativeType.int64), + name: 'closure_id', objCConsumed: false), ...params, ], ); diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart index b1f258cd6..48c771d90 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart @@ -34,6 +34,9 @@ class ObjCBuiltInFunctions { static const objectRelease = ObjCImport('objectRelease'); static const signalWaiter = ObjCImport('signalWaiter'); static const wrapBlockingBlock = ObjCImport('wrapBlockingBlock'); + static const blockClosureDisposePort = ObjCImport('blockClosureDisposePort'); + static const disposeObjCBlockWithClosure = + ObjCImport('disposeObjCBlockWithClosure'); static const objectBase = ObjCImport('ObjCObjectBase'); static const blockType = ObjCImport('ObjCBlock'); static const consumedType = ObjCImport('Consumed'); @@ -216,10 +219,29 @@ class ObjCBuiltInFunctions { returnType: block.returnType, parameters: [ Parameter( - type: PointerType(voidType), name: 'target', objCConsumed: false), + type: PointerType(objCBlockType), + name: 'block', + objCConsumed: false), + Parameter( + type: NativeType(SupportedNativeType.int64), + name: 'closure_id', + objCConsumed: false), ...block.params, ], ); + final dtorType = FunctionType( + returnType: voidType, + parameters: [ + Parameter( + type: NativeType(SupportedNativeType.int64), + name: 'dispose_port', + objCConsumed: false), + Parameter( + type: NativeType(SupportedNativeType.int64), + name: 'closure_id', + objCConsumed: false), + ], + ); return _blockTrampolines[id] ??= ObjCBlockWrapperFuncs( trampolineType, Func( @@ -247,7 +269,17 @@ class ObjCBuiltInFunctions { type: PointerType(NativeFunc(trampolineType)), objCConsumed: false), Parameter( - type: PointerType(voidType), name: 'target', objCConsumed: false), + type: NativeType(SupportedNativeType.int64), + name: 'closure_id', + objCConsumed: false), + Parameter( + type: NativeType(SupportedNativeType.int64), + name: 'dispose_port', + objCConsumed: false), + Parameter( + name: 'dtor', + type: PointerType(NativeFunc(dtorType)), + objCConsumed: false), ], objCReturnsRetained: true, isLeaf: true, diff --git a/pkgs/ffigen/lib/src/code_generator/writer.dart b/pkgs/ffigen/lib/src/code_generator/writer.dart index 556126632..d313cfa8d 100644 --- a/pkgs/ffigen/lib/src/code_generator/writer.dart +++ b/pkgs/ffigen/lib/src/code_generator/writer.dart @@ -446,6 +446,16 @@ class Writer { id objc_retain(id); id objc_retainBlock(id); + +@interface _${className}_BlockDestroyer : NSObject {} +@property int64_t closure_id; +@property int64_t dispose_port; +@property void (*dtor)(int64_t, int64_t); +- (void)dealloc; +@end +@implementation _${className}_BlockDestroyer +- (void)dealloc { self.dtor(self.dispose_port, self.closure_id); } +@end '''); var empty = true; diff --git a/pkgs/ffigen/test/native_objc_test/block_test.dart b/pkgs/ffigen/test/native_objc_test/block_test.dart index 475df9506..4f7912e51 100644 --- a/pkgs/ffigen/test/native_objc_test/block_test.dart +++ b/pkgs/ffigen/test/native_objc_test/block_test.dart @@ -14,7 +14,7 @@ import 'dart:io'; import 'package:ffi/ffi.dart'; import 'package:objective_c/objective_c.dart'; import 'package:objective_c/src/internal.dart' as internal_for_testing - show blockHasRegisteredClosure; + show isClosureOfBlock, lastClosureRegistryId; import 'package:test/test.dart'; import '../test_utils.dart'; @@ -123,7 +123,7 @@ void main() { } } - test('Blocking block same thread', () { + /*test('Blocking block same thread', () { int value = 0; final block = VoidBlock.blocking(() { waitSync(Duration(milliseconds: 100)); @@ -177,7 +177,7 @@ void main() { }); block(); expect(value, 123); - }); + });*/ test('Float block', () { final block = FloatBlock.fromFunction((double x) { @@ -407,7 +407,7 @@ void main() { /*Pointer funcPointerBlockRefCountTest() { final block = IntBlock.fromFunctionPointer(Pointer.fromFunction(_add100, 999)); - expect(internal_for_testing.blockHasRegisteredClosure(block.ref.pointer), + expect(internal_for_testing.isClosureOfBlock(closureId), false); expect(blockRetainCount(block.ref.pointer), 1); return block.ref.pointer; @@ -419,31 +419,30 @@ void main() { expect(blockRetainCount(rawBlock), 0); }, skip: !canDoGC);*/ - Pointer funcBlockRefCountTest() { + (Pointer, int) funcBlockRefCountTest() { final block = IntBlock.fromFunction(makeAdder(4000)); - // expect(internal_for_testing.blockHasRegisteredClosure(block.ref.pointer), - // true); + final closureId = internal_for_testing.lastClosureRegistryId; + expect(internal_for_testing.isClosureOfBlock(closureId), true); expect(blockRetainCount(block.ref.pointer), 1); - return block.ref.pointer; + return (block.ref.pointer, closureId); } test('Function block ref counting', () async { - final rawBlock = funcBlockRefCountTest(); + final (rawBlock, closureId) = funcBlockRefCountTest(); doGC(); await Future.delayed(Duration.zero); // Let dispose message arrive. expect(blockRetainCount(rawBlock), 0); - // expect(internal_for_testing.blockHasRegisteredClosure(rawBlock.cast()), - // false); + expect(internal_for_testing.isClosureOfBlock(closureId), false); }, skip: !canDoGC); - Pointer blockManualRetainRefCountTest() { + (Pointer, int) blockManualRetainRefCountTest() { final block = IntBlock.fromFunction(makeAdder(4000)); - // expect(internal_for_testing.blockHasRegisteredClosure(block.ref.pointer), - // true); + final closureId = internal_for_testing.lastClosureRegistryId; + expect(internal_for_testing.isClosureOfBlock(closureId), true); expect(blockRetainCount(block.ref.pointer), 1); final rawBlock = block.ref.retainAndReturnPointer(); expect(blockRetainCount(rawBlock), 2); - return rawBlock; + return (rawBlock, closureId); } int blockManualRetainRefCountTest2(Pointer rawBlock) { @@ -453,30 +452,35 @@ void main() { } test('Block ref counting with manual retain and release', () async { - final rawBlock = blockManualRetainRefCountTest(); + final (rawBlock, closureId) = blockManualRetainRefCountTest(); doGC(); expect(blockRetainCount(rawBlock), 1); expect(blockManualRetainRefCountTest2(rawBlock), 1); doGC(); await Future.delayed(Duration.zero); // Let dispose message arrive. expect(blockRetainCount(rawBlock), 0); - // expect(internal_for_testing.blockHasRegisteredClosure(rawBlock.cast()), - // false); + expect(internal_for_testing.isClosureOfBlock(closureId), false); }, skip: !canDoGC); - (Pointer, Pointer, Pointer) + (Pointer, Pointer, Pointer, int, int, int) blockBlockDartCallRefCountTest() { final pool = lib.objc_autoreleasePoolPush(); final inputBlock = IntBlock.fromFunction((int x) { return 5 * x; }); + final inputBlockId = internal_for_testing.lastClosureRegistryId; final blockBlock = BlockBlock.fromFunction((ObjCBlock intBlock) { return IntBlock.fromFunction((int x) { return 3 * intBlock(x); }); }); + final blockBlockId = internal_for_testing.lastClosureRegistryId; + expect(blockBlockId, isNot(inputBlockId)); final outputBlock = blockBlock(inputBlock); + final outputBlockId = internal_for_testing.lastClosureRegistryId; + expect(outputBlockId, isNot(inputBlockId)); + expect(outputBlockId, isNot(blockBlockId)); expect(outputBlock(1), 15); lib.objc_autoreleasePoolPop(pool); doGC(); @@ -484,48 +488,51 @@ void main() { // One reference held by inputBlock object, another bound to the // outputBlock lambda. expect(blockRetainCount(inputBlock.ref.pointer), 2); - // expect( - // internal_for_testing - // .blockHasRegisteredClosure(inputBlock.ref.pointer.cast()), - // true); + expect( + internal_for_testing + .isClosureOfBlock(inputBlockId), + true); expect(blockRetainCount(blockBlock.ref.pointer), 1); - // expect( - // internal_for_testing - // .blockHasRegisteredClosure(blockBlock.ref.pointer.cast()), - // true); + expect( + internal_for_testing + .isClosureOfBlock(blockBlockId), + true); expect(blockRetainCount(outputBlock.ref.pointer), 1); - // expect( - // internal_for_testing - // .blockHasRegisteredClosure(outputBlock.ref.pointer.cast()), - // true); + expect( + internal_for_testing + .isClosureOfBlock(outputBlockId), + true); return ( inputBlock.ref.pointer, blockBlock.ref.pointer, - outputBlock.ref.pointer + outputBlock.ref.pointer, + inputBlockId, + blockBlockId, + outputBlockId, ); } test('Calling a block block from Dart has correct ref counting', () async { - final (inputBlock, blockBlock, outputBlock) = + final (inputBlock, blockBlock, outputBlock, inputBlockId, blockBlockId, outputBlockId) = blockBlockDartCallRefCountTest(); doGC(); await Future.delayed(Duration.zero); // Let dispose message arrive. doGC(); await Future.delayed(Duration.zero); // Let dispose message arrive. - // expect(blockRetainCount(inputBlock), 0); - // expect(internal_for_testing.blockHasRegisteredClosure(inputBlock.cast()), - // false); + expect(blockRetainCount(inputBlock), 0); + expect(internal_for_testing.isClosureOfBlock(inputBlockId), + false); expect(blockRetainCount(blockBlock), 0); - // expect(internal_for_testing.blockHasRegisteredClosure(blockBlock.cast()), - // false); + expect(internal_for_testing.isClosureOfBlock(blockBlockId), + false); expect(blockRetainCount(outputBlock), 0); - // expect(internal_for_testing.blockHasRegisteredClosure(outputBlock.cast()), - // false); + expect(internal_for_testing.isClosureOfBlock(outputBlockId), + false); }, skip: !canDoGC); - (Pointer, Pointer, Pointer) + (Pointer, Pointer, Pointer, int, int) blockBlockObjCCallRefCountTest() { final pool = lib.objc_autoreleasePoolPush(); late Pointer inputBlock; @@ -536,44 +543,41 @@ void main() { return 3 * intBlock(x); }); }); + final blockBlockId = internal_for_testing.lastClosureRegistryId; final outputBlock = BlockTester.newBlock_withMult_(blockBlock, 2); + final outputBlockId = internal_for_testing.lastClosureRegistryId; + expect(outputBlockId, isNot(blockBlockId)); expect(outputBlock(1), 6); lib.objc_autoreleasePoolPop(pool); doGC(); expect(blockRetainCount(inputBlock), 1); - // expect(internal_for_testing.blockHasRegisteredClosure(inputBlock.cast()), - // false); expect(blockRetainCount(blockBlock.ref.pointer), 1); - // expect( - // internal_for_testing - // .blockHasRegisteredClosure(blockBlock.ref.pointer.cast()), - // true); + expect( + internal_for_testing + .isClosureOfBlock(blockBlockId), + true); expect(blockRetainCount(outputBlock.ref.pointer), 1); - // expect( - // internal_for_testing - // .blockHasRegisteredClosure(outputBlock.ref.pointer.cast()), - // true); - return (inputBlock, blockBlock.ref.pointer, outputBlock.ref.pointer); + expect( + internal_for_testing + .isClosureOfBlock(outputBlockId), + true); + return (inputBlock, blockBlock.ref.pointer, outputBlock.ref.pointer, blockBlockId, outputBlockId); } test('Calling a block block from ObjC has correct ref counting', () async { - final (inputBlock, blockBlock, outputBlock) = + final (inputBlock, blockBlock, outputBlock, blockBlockId, outputBlockId) = blockBlockObjCCallRefCountTest(); doGC(); await Future.delayed(Duration.zero); // Let dispose message arrive. doGC(); await Future.delayed(Duration.zero); // Let dispose message arrive. - // expect(blockRetainCount(inputBlock), 0); - // expect(internal_for_testing.blockHasRegisteredClosure(inputBlock.cast()), - // false); + expect(blockRetainCount(inputBlock), 0); expect(blockRetainCount(blockBlock), 0); - // expect(internal_for_testing.blockHasRegisteredClosure(blockBlock.cast()), - // false); + expect(internal_for_testing.isClosureOfBlock(blockBlockId), false); expect(blockRetainCount(outputBlock), 0); - // expect(internal_for_testing.blockHasRegisteredClosure(outputBlock.cast()), - // false); + expect(internal_for_testing.isClosureOfBlock(outputBlockId), false); }, skip: !canDoGC); (Pointer, Pointer, Pointer) @@ -792,28 +796,12 @@ void main() { expect(objectRetainCount(rawDummyObject), 0); }, skip: !canDoGC);*/ - /*test('Block fields have sensible values', () { - final block = IntBlock.fromFunction(makeAdder(4000)); - final blockPtr = block.ref.pointer; - expect(blockPtr.ref.isa, isNot(0)); - expect(blockPtr.ref.flags, isNot(0)); // Set by Block_copy. - expect(blockPtr.ref.reserved, 0); - expect(blockPtr.ref.invoke, isNot(0)); - expect(blockPtr.ref.target, isNot(0)); - final descPtr = blockPtr.ref.descriptor; - expect(descPtr.ref.reserved, 0); - expect(descPtr.ref.size, isNot(0)); - expect(descPtr.ref.copy_helper, nullptr); - expect(descPtr.ref.dispose_helper, isNot(nullptr)); - expect(descPtr.ref.signature, nullptr); - });*/ - test('Block trampoline args converted to id', () { final objCBindings = File('test/native_objc_test/block_bindings.m').readAsStringSync(); // Objects are converted to id. - expect(objCBindings, isNot(contains('NSObject'))); + expect(objCBindings, isNot(contains('DummyObject'))); expect(objCBindings, isNot(contains('NSString'))); expect(objCBindings, contains('id')); @@ -860,7 +848,7 @@ void main() { await flutterDoGC(); expect(blockRetainCount(blockPtr), 0); - // expect(objectRetainCount(objectPtr), 0); + expect(objectRetainCount(objectPtr), 0); } }); }); diff --git a/pkgs/objective_c/lib/objective_c.dart b/pkgs/objective_c/lib/objective_c.dart index 08c246795..70adb248b 100644 --- a/pkgs/objective_c/lib/objective_c.dart +++ b/pkgs/objective_c/lib/objective_c.dart @@ -15,10 +15,11 @@ export 'src/c_bindings_generated.dart' export 'src/internal.dart' hide ObjCBlockBase, - blockHasRegisteredClosure, + isClosureOfBlock, isValidBlock, isValidClass, - isValidObject; + isValidObject, + lastClosureRegistryId; export 'src/ns_data.dart'; export 'src/ns_input_stream.dart'; export 'src/ns_mutable_data.dart'; diff --git a/pkgs/objective_c/lib/src/c_bindings_generated.dart b/pkgs/objective_c/lib/src/c_bindings_generated.dart index 618529460..871d6d9ac 100644 --- a/pkgs/objective_c/lib/src/c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/c_bindings_generated.dart @@ -74,10 +74,11 @@ external void deleteFinalizableHandle( Object owner, ); -@ffi.Native)>( +@ffi.Native( symbol: "DOBJC_disposeObjCBlockWithClosure") external void disposeObjCBlockWithClosure( - ffi.Pointer block, + int dispose_port, + int closure_id, ); @ffi.Native Function(ffi.Pointer)>( diff --git a/pkgs/objective_c/lib/src/internal.dart b/pkgs/objective_c/lib/src/internal.dart index 220ee8369..dcfb52ad4 100644 --- a/pkgs/objective_c/lib/src/internal.dart +++ b/pkgs/objective_c/lib/src/internal.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:ffi'; +import 'dart:isolate'; import 'package:ffi/ffi.dart'; @@ -344,60 +345,11 @@ class ObjCBlockBase extends _ObjCRefHolder { : super(_ObjCBlockRef(ptr, retain: retain, release: release)); } -/*Pointer _newBlockDesc( - Pointer> disposeHelper) { - final desc = calloc.allocate(sizeOf()); - desc.ref.reserved = 0; - desc.ref.size = sizeOf(); - desc.ref.copy_helper = nullptr; - desc.ref.dispose_helper = disposeHelper.cast(); - desc.ref.signature = nullptr; - return desc; -} - -final _pointerBlockDesc = _newBlockDesc(nullptr); -final _closureBlockDesc = _newBlockDesc( - Native.addressOf>( - c.disposeObjCBlockWithClosure)); - -BlockPtr _newBlock(VoidPtr invoke, VoidPtr target, - Pointer descriptor, int disposePort, int flags) { - final b = calloc.allocate(sizeOf()); - b.ref.isa = Native.addressOf>(c.NSConcreteGlobalBlock).cast(); - b.ref.flags = flags; - b.ref.reserved = 0; - b.ref.invoke = invoke; - b.ref.target = target; - b.ref.dispose_port = disposePort; - b.ref.descriptor = descriptor; - assert(c.isValidBlock(b)); - final copy = c.blockRetain(b.cast()).cast(); - calloc.free(b); - assert(copy.ref.isa == - Native.addressOf>(c.NSConcreteMallocBlock).cast()); - assert(c.isValidBlock(copy)); - return copy; -} - -const int _blockHasCopyDispose = 1 << 25; - -/// Only for use by ffigen bindings. -BlockPtr newClosureBlock(VoidPtr invoke, Function fn) => _newBlock( - invoke, - _registerBlockClosure(fn), - _closureBlockDesc, - _blockClosureDisposer.sendPort.nativePort, - _blockHasCopyDispose); - -/// Only for use by ffigen bindings. -BlockPtr newPointerBlock(VoidPtr invoke, VoidPtr target) => - _newBlock(invoke, target, _pointerBlockDesc, 0, 0);*/ - final _blockClosureRegistry = {}; int _blockClosureRegistryLastId = 0; -/*final _blockClosureDisposer = () { +final _blockClosureDisposer = () { _ensureDartAPI(); return RawReceivePort((dynamic msg) { final id = msg as int; @@ -405,15 +357,24 @@ int _blockClosureRegistryLastId = 0; _blockClosureRegistry.remove(id); }, 'ObjCBlockClosureDisposer') ..keepIsolateAlive = false; -}();*/ +}(); + +/// Only for use by ffigen bindings. +int get blockClosureDisposePort => _blockClosureDisposer.sendPort.nativePort; -VoidPtr registerBlockClosure(Function closure) { +/// Only for use by ffigen bindings. +int registerBlockClosure(Function closure) { ++_blockClosureRegistryLastId; assert(!_blockClosureRegistry.containsKey(_blockClosureRegistryLastId)); _blockClosureRegistry[_blockClosureRegistryLastId] = closure; - return VoidPtr.fromAddress(_blockClosureRegistryLastId); + return _blockClosureRegistryLastId; } +/// Only for use by ffigen bindings. +typedef DisposeBlockFn = NativeFunction; +Pointer get disposeObjCBlockWithClosure => + Native.addressOf(c.disposeObjCBlockWithClosure); + /// Only for use by ffigen bindings. Function getBlockClosure(int id) { assert(_blockClosureRegistry.containsKey(id)); @@ -436,7 +397,8 @@ BlockPtr wrapBlockingBlock( ); // Not exported by ../objective_c.dart, because they're only for testing. -bool blockHasRegisteredClosure(int id) => _blockClosureRegistry.containsKey(id); +int get lastClosureRegistryId => _blockClosureRegistryLastId; +bool isClosureOfBlock(int id) => _blockClosureRegistry.containsKey(id); bool isValidBlock(BlockPtr block) => c.isValidBlock(block); bool isValidClass(ObjectPtr clazz) => _isValidClass(clazz); bool isValidObject(ObjectPtr object) => _isValidObject(object); diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index 36b235003..14cdf0217 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -36,29 +36,214 @@ set NSLocalizedDescriptionKey(NSString value) { _NSLocalizedDescriptionKey = value.ref.retainAndReturnPointer(); } +@ffi.Native< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.UnsignedLong)>() +external int _ObjectiveCBindings_invokeBlock_17ap02x( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer> arg2, + int arg3, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.UnsignedLong)>() +external void _ObjectiveCBindings_invokeBlock_18d6mda( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, +); + +@ffi.Native< + ffi.Pointer<_NSZone> Function( + ffi.Pointer, ffi.Pointer)>() +external ffi.Pointer<_NSZone> _ObjectiveCBindings_invokeBlock_1a8cl66( + ffi.Pointer block, + ffi.Pointer arg0, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>() +external ffi.Pointer _ObjectiveCBindings_invokeBlock_1c0c70u( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, +); + +@ffi.Native< + ffi.UnsignedLong Function( + ffi.Pointer, ffi.Pointer)>() +external int _ObjectiveCBindings_invokeBlock_1ckyi24( + ffi.Pointer block, + ffi.Pointer arg0, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>() +external void _ObjectiveCBindings_invokeBlock_1j2nt86( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, +); + +@ffi.Native< + instancetype Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>() +external instancetype _ObjectiveCBindings_invokeBlock_1m9h2n( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>() +external ffi.Pointer _ObjectiveCBindings_invokeBlock_1yesha9( + ffi.Pointer block, + ffi.Pointer arg0, +); + +@ffi.Native< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>() +external instancetype _ObjectiveCBindings_invokeBlock_e2pkq8( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer> arg3, +); + +@ffi.Native< + ffi.Bool Function(ffi.Pointer, ffi.Pointer)>() +external bool _ObjectiveCBindings_invokeBlock_e3qsqz( + ffi.Pointer block, + ffi.Pointer arg0, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer)>() +external void _ObjectiveCBindings_invokeBlock_ovsamd( + ffi.Pointer block, + ffi.Pointer arg0, +); + +@ffi.Native< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>() +external bool _ObjectiveCBindings_invokeBlock_ozkafd( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>() +external ffi.Pointer _ObjectiveCBindings_invokeBlock_u8b97m( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer arg3, +); + +@ffi.Native< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>() +external bool _ObjectiveCBindings_invokeBlock_w1e3k0( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>() +external void _ObjectiveCBindings_invokeBlock_wjovn7( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>() +external void _ObjectiveCBindings_invokeBlock_wjvic9( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, +); + +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>() +external ffi.Pointer _ObjectiveCBindings_invokeBlock_ykn0t6( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, +); + @ffi.Native< ffi.Pointer Function( ffi.Pointer< ffi.NativeFunction< ffi.UnsignedLong Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer> arg2, ffi.UnsignedLong arg3)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_17ap02x( ffi.Pointer< ffi.NativeFunction< ffi.UnsignedLong Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer> arg2, ffi.UnsignedLong arg3)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -66,22 +251,34 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.UnsignedLong arg2)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_18d6mda( ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.UnsignedLong arg2)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -89,16 +286,30 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Pointer<_NSZone> Function( - ffi.Pointer target, ffi.Pointer arg0)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Pointer block, + ffi.Int64 closure_id, + ffi.Pointer arg0)>>, + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_1a8cl66( ffi.Pointer< ffi.NativeFunction< ffi.Pointer<_NSZone> Function( - ffi.Pointer target, ffi.Pointer arg0)>> + ffi.Pointer block, + ffi.Int64 closure_id, + ffi.Pointer arg0)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -106,39 +317,61 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_1c0c70u( ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< ffi.Pointer Function( ffi.Pointer< ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer target, ffi.Pointer arg0)>>, - ffi.Pointer)>(isLeaf: true) + ffi.UnsignedLong Function(ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0)>>, + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_1ckyi24( ffi.Pointer< ffi.NativeFunction< - ffi.UnsignedLong Function( - ffi.Pointer target, ffi.Pointer arg0)>> + ffi.UnsignedLong Function(ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -146,22 +379,34 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_1j2nt86( ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -169,20 +414,32 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< instancetype Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_1m9h2n( ffi.Pointer< ffi.NativeFunction< instancetype Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -190,16 +447,30 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer target, ffi.Pointer arg0)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Pointer block, + ffi.Int64 closure_id, + ffi.Pointer arg0)>>, + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_1yesha9( ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer target, ffi.Pointer arg0)>> + ffi.Pointer block, + ffi.Int64 closure_id, + ffi.Pointer arg0)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -207,58 +478,90 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< instancetype Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer> arg3)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_e2pkq8( ffi.Pointer< ffi.NativeFunction< instancetype Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer> arg3)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< ffi.Pointer Function( ffi.Pointer< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer target, ffi.Pointer arg0)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Bool Function(ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0)>>, + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_e3qsqz( ffi.Pointer< ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer target, ffi.Pointer arg0)>> + ffi.Bool Function(ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< ffi.Pointer Function( ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer target, ffi.Pointer arg0)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Void Function(ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0)>>, + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_ovsamd( ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer target, ffi.Pointer arg0)>> + ffi.Void Function(ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -266,20 +569,32 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Bool Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_ozkafd( ffi.Pointer< ffi.NativeFunction< ffi.Bool Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -287,24 +602,36 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer arg3)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_u8b97m( ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer arg3)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -312,20 +639,32 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Bool Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_w1e3k0( ffi.Pointer< ffi.NativeFunction< ffi.Bool Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -333,20 +672,32 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_wjovn7( ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -354,20 +705,32 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_wjvic9( ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -375,20 +738,32 @@ external ffi.Pointer ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>>, - ffi.Pointer)>(isLeaf: true) + ffi.Int64, + ffi.Int64, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, + ffi.Int64 closure_id)>>)>(isLeaf: true) external ffi.Pointer _ObjectiveCBindings_newClosureBlock_ykn0t6( ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer target, + ffi.Pointer block, + ffi.Int64 closure_id, ffi.Pointer arg0, ffi.Pointer arg1)>> trampoline, - ffi.Pointer target, + int closure_id, + int dispose_port, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64 dispose_port, ffi.Int64 closure_id)>> + dtor, ); @ffi.Native< @@ -8977,24 +9352,31 @@ class NSValue extends NSObject { } ffi.Pointer _ObjCBlock_NSString_ffiVoid_fnPtrTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - target - .cast< + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer arg0)>>() + ffi.Pointer arg0)>>.fromAddress(closureId) .asFunction< ffi.Pointer Function( ffi.Pointer)>()(arg0); final _ObjCBlock_NSString_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function(ffi.Pointer, + ffi.Pointer Function( + ffi.Pointer, + ffi.Int64, ffi.Pointer)>(_ObjCBlock_NSString_ffiVoid_fnPtrTrampoline); ffi.Pointer _ObjCBlock_NSString_ffiVoid_closureTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - (objc.getBlockClosure(target.address) as ffi.Pointer - Function(ffi.Pointer))(arg0); + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + (objc.getBlockClosure(closureId) as ffi.Pointer Function( + ffi.Pointer))(arg0); final _ObjCBlock_NSString_ffiVoid_closureCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function(ffi.Pointer, + ffi.Pointer Function( + ffi.Pointer, + ffi.Int64, ffi.Pointer)>(_ObjCBlock_NSString_ffiVoid_closureTrampoline); /// Construction methods for `objc.ObjCBlock)>`. @@ -9026,29 +9408,44 @@ abstract final class ObjCBlock_NSString_ffiVoid { _ObjectiveCBindings_newClosureBlock_1yesha9( _ObjCBlock_NSString_ffiVoid_closureCallable, objc.registerBlockClosure((ffi.Pointer arg0) => - fn(arg0).ref.retainAndAutorelease())), + fn(arg0).ref.retainAndAutorelease()), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock)>`. +extension ObjCBlock_NSString_ffiVoid_CallExtension + on objc.ObjCBlock)> { + NSString call(ffi.Pointer arg0) => NSString.castFromPointer( + _ObjectiveCBindings_invokeBlock_1yesha9(ref.pointer, arg0), + retain: true, + release: true); +} + int _ObjCBlock_NSUInteger_ffiVoid_fnPtrTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - target - .cast< + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + ffi.Pointer< ffi.NativeFunction< - ffi.UnsignedLong Function(ffi.Pointer arg0)>>() + ffi.UnsignedLong Function( + ffi.Pointer arg0)>>.fromAddress(closureId) .asFunction)>()(arg0); final _ObjCBlock_NSUInteger_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< ffi.UnsignedLong Function( - ffi.Pointer, ffi.Pointer)>( + ffi.Pointer, ffi.Int64, ffi.Pointer)>( _ObjCBlock_NSUInteger_ffiVoid_fnPtrTrampoline, 0); int _ObjCBlock_NSUInteger_ffiVoid_closureTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - (objc.getBlockClosure(target.address) as int Function( + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + (objc.getBlockClosure(closureId) as int Function( ffi.Pointer))(arg0); final _ObjCBlock_NSUInteger_ffiVoid_closureCallable = ffi.Pointer.fromFunction< ffi.UnsignedLong Function( - ffi.Pointer, ffi.Pointer)>( + ffi.Pointer, ffi.Int64, ffi.Pointer)>( _ObjCBlock_NSUInteger_ffiVoid_closureTrampoline, 0); /// Construction methods for `objc.ObjCBlock)>`. @@ -9082,25 +9479,34 @@ abstract final class ObjCBlock_NSUInteger_ffiVoid { _ObjectiveCBindings_newClosureBlock_1ckyi24( _ObjCBlock_NSUInteger_ffiVoid_closureCallable, objc.registerBlockClosure( - (ffi.Pointer arg0) => fn(arg0))), + (ffi.Pointer arg0) => fn(arg0)), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock)>`. +extension ObjCBlock_NSUInteger_ffiVoid_CallExtension + on objc.ObjCBlock)> { + int call(ffi.Pointer arg0) => + _ObjectiveCBindings_invokeBlock_1ckyi24(ref.pointer, arg0); +} + int _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer> arg2, int arg3) => - target - .cast< + ffi.Pointer< ffi.NativeFunction< ffi.UnsignedLong Function( ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer> arg2, - ffi.UnsignedLong arg3)>>() + ffi.UnsignedLong arg3)>>.fromAddress(closureId) .asFunction< int Function( ffi.Pointer, @@ -9110,7 +9516,8 @@ int _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteg final _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_fnPtrCallable = ffi.Pointer.fromFunction< ffi.UnsignedLong Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer>, @@ -9118,12 +9525,13 @@ final _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInt _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_fnPtrTrampoline, 0); int _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer> arg2, int arg3) => - (objc.getBlockClosure(target.address) as int Function( + (objc.getBlockClosure(closureId) as int Function( ffi.Pointer, ffi.Pointer, ffi.Pointer>, @@ -9131,7 +9539,8 @@ int _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteg final _ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_closureCallable = ffi.Pointer.fromFunction< ffi.UnsignedLong Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer>, @@ -9180,28 +9589,48 @@ abstract final class ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObj ffi.Pointer arg1, ffi.Pointer> arg2, int arg3) => - fn(arg0, arg1, arg2, arg3))), + fn(arg0, arg1, arg2, arg3)), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock, ffi.Pointer, ffi.Pointer>, ffi.UnsignedLong)>`. +extension ObjCBlock_NSUInteger_ffiVoid_NSFastEnumerationState_objcObjCObject_NSUInteger_CallExtension + on objc.ObjCBlock< + ffi.UnsignedLong Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.UnsignedLong)> { + int call(ffi.Pointer arg0, ffi.Pointer arg1, + ffi.Pointer> arg2, int arg3) => + _ObjectiveCBindings_invokeBlock_17ap02x( + ref.pointer, arg0, arg1, arg2, arg3); +} + ffi.Pointer<_NSZone> _ObjCBlock_NSZone_ffiVoid_fnPtrTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - target - .cast< - ffi.NativeFunction< - ffi.Pointer<_NSZone> Function(ffi.Pointer arg0)>>() - .asFunction< - ffi.Pointer<_NSZone> Function(ffi.Pointer)>()(arg0); + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer<_NSZone> Function( + ffi.Pointer arg0)>>.fromAddress(closureId) + .asFunction Function(ffi.Pointer)>()( + arg0); final _ObjCBlock_NSZone_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Pointer<_NSZone> Function(ffi.Pointer, + ffi.Pointer<_NSZone> Function(ffi.Pointer, ffi.Int64, ffi.Pointer)>(_ObjCBlock_NSZone_ffiVoid_fnPtrTrampoline); ffi.Pointer<_NSZone> _ObjCBlock_NSZone_ffiVoid_closureTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - (objc.getBlockClosure(target.address) as ffi.Pointer<_NSZone> Function( + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + (objc.getBlockClosure(closureId) as ffi.Pointer<_NSZone> Function( ffi.Pointer))(arg0); final _ObjCBlock_NSZone_ffiVoid_closureCallable = ffi.Pointer.fromFunction< - ffi.Pointer<_NSZone> Function(ffi.Pointer, + ffi.Pointer<_NSZone> Function(ffi.Pointer, ffi.Int64, ffi.Pointer)>(_ObjCBlock_NSZone_ffiVoid_closureTrampoline); /// Construction methods for `objc.ObjCBlock Function(ffi.Pointer)>`. @@ -9235,26 +9664,41 @@ abstract final class ObjCBlock_NSZone_ffiVoid { _ObjectiveCBindings_newClosureBlock_1a8cl66( _ObjCBlock_NSZone_ffiVoid_closureCallable, objc.registerBlockClosure( - (ffi.Pointer arg0) => fn(arg0))), + (ffi.Pointer arg0) => fn(arg0)), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock Function(ffi.Pointer)>`. +extension ObjCBlock_NSZone_ffiVoid_CallExtension + on objc.ObjCBlock Function(ffi.Pointer)> { + ffi.Pointer<_NSZone> call(ffi.Pointer arg0) => + _ObjectiveCBindings_invokeBlock_1a8cl66(ref.pointer, arg0); +} + bool _ObjCBlock_bool_ffiVoid_fnPtrTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - target - .cast< - ffi.NativeFunction arg0)>>() + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer arg0)>>.fromAddress(closureId) .asFunction)>()(arg0); final _ObjCBlock_bool_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer)>( - _ObjCBlock_bool_ffiVoid_fnPtrTrampoline, false); + ffi.Bool Function(ffi.Pointer, ffi.Int64, + ffi.Pointer)>(_ObjCBlock_bool_ffiVoid_fnPtrTrampoline, false); bool _ObjCBlock_bool_ffiVoid_closureTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - (objc.getBlockClosure(target.address) as bool Function( + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + (objc.getBlockClosure(closureId) as bool Function( ffi.Pointer))(arg0); final _ObjCBlock_bool_ffiVoid_closureCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer)>( + ffi.Bool Function( + ffi.Pointer, ffi.Int64, ffi.Pointer)>( _ObjCBlock_bool_ffiVoid_closureTrampoline, false); /// Construction methods for `objc.ObjCBlock)>`. @@ -9286,37 +9730,47 @@ abstract final class ObjCBlock_bool_ffiVoid { _ObjectiveCBindings_newClosureBlock_e3qsqz( _ObjCBlock_bool_ffiVoid_closureCallable, objc.registerBlockClosure( - (ffi.Pointer arg0) => fn(arg0))), + (ffi.Pointer arg0) => fn(arg0)), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock)>`. +extension ObjCBlock_bool_ffiVoid_CallExtension + on objc.ObjCBlock)> { + bool call(ffi.Pointer arg0) => + _ObjectiveCBindings_invokeBlock_e3qsqz(ref.pointer, arg0); +} + bool _ObjCBlock_bool_ffiVoid_Protocol_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - target - .cast< + ffi.Pointer< ffi.NativeFunction< ffi.Bool Function(ffi.Pointer arg0, - ffi.Pointer arg1)>>() + ffi.Pointer arg1)>>.fromAddress(closureId) .asFunction< bool Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); final _ObjCBlock_bool_ffiVoid_Protocol_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>( + ffi.Bool Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>( _ObjCBlock_bool_ffiVoid_Protocol_fnPtrTrampoline, false); bool _ObjCBlock_bool_ffiVoid_Protocol_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(target.address) as bool Function( + (objc.getBlockClosure(closureId) as bool Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); final _ObjCBlock_bool_ffiVoid_Protocol_closureCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>( + ffi.Bool Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>( _ObjCBlock_bool_ffiVoid_Protocol_closureTrampoline, false); /// Construction methods for `objc.ObjCBlock, Protocol)>`. @@ -9344,46 +9798,56 @@ abstract final class ObjCBlock_bool_ffiVoid_Protocol { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock< - ffi.Bool Function(ffi.Pointer, Protocol)> fromFunction( - bool Function(ffi.Pointer, Protocol) fn) => - objc.ObjCBlock, Protocol)>( - _ObjectiveCBindings_newClosureBlock_ozkafd( - _ObjCBlock_bool_ffiVoid_Protocol_closureCallable, - objc.registerBlockClosure((ffi.Pointer arg0, - ffi.Pointer arg1) => - fn(arg0, Protocol.castFromPointer(arg1, retain: true, release: true)))), - retain: false, - release: true); + static objc.ObjCBlock, Protocol)> + fromFunction(bool Function(ffi.Pointer, Protocol) fn) => + objc.ObjCBlock, Protocol)>( + _ObjectiveCBindings_newClosureBlock_ozkafd( + _ObjCBlock_bool_ffiVoid_Protocol_closureCallable, + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(arg0, Protocol.castFromPointer(arg1, retain: true, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock, Protocol)>`. +extension ObjCBlock_bool_ffiVoid_Protocol_CallExtension + on objc.ObjCBlock, Protocol)> { + bool call(ffi.Pointer arg0, Protocol arg1) => + _ObjectiveCBindings_invokeBlock_ozkafd( + ref.pointer, arg0, arg1.ref.pointer); } bool _ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - target - .cast< + ffi.Pointer< ffi.NativeFunction< ffi.Bool Function(ffi.Pointer arg0, - ffi.Pointer arg1)>>() + ffi.Pointer arg1)>>.fromAddress(closureId) .asFunction< bool Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); final _ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>( + ffi.Bool Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>( _ObjCBlock_bool_ffiVoid_objcObjCObject_fnPtrTrampoline, false); bool _ObjCBlock_bool_ffiVoid_objcObjCObject_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(target.address) as bool Function( + (objc.getBlockClosure(closureId) as bool Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); final _ObjCBlock_bool_ffiVoid_objcObjCObject_closureCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>( + ffi.Bool Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>( _ObjCBlock_bool_ffiVoid_objcObjCObject_closureTrampoline, false); /// Construction methods for `objc.ObjCBlock, ffi.Pointer)>`. @@ -9423,38 +9887,50 @@ abstract final class ObjCBlock_bool_ffiVoid_objcObjCObject { _ObjCBlock_bool_ffiVoid_objcObjCObject_closureCallable, objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => - fn(arg0, objc.ObjCObjectBase(arg1, retain: true, release: true)))), + fn(arg0, objc.ObjCObjectBase(arg1, retain: true, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock, ffi.Pointer)>`. +extension ObjCBlock_bool_ffiVoid_objcObjCObject_CallExtension on objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer, ffi.Pointer)> { + bool call(ffi.Pointer arg0, objc.ObjCObjectBase arg1) => + _ObjectiveCBindings_invokeBlock_ozkafd( + ref.pointer, arg0, arg1.ref.pointer); +} + bool _ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - target - .cast< - ffi.NativeFunction< - ffi.Bool Function(ffi.Pointer arg0, - ffi.Pointer arg1)>>() + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer arg0, + ffi.Pointer arg1)>>.fromAddress( + closureId) .asFunction< bool Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); final _ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>( + ffi.Bool Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>( _ObjCBlock_bool_ffiVoid_objcObjCSelector_fnPtrTrampoline, false); bool _ObjCBlock_bool_ffiVoid_objcObjCSelector_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(target.address) as bool Function( + (objc.getBlockClosure(closureId) as bool Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); final _ObjCBlock_bool_ffiVoid_objcObjCSelector_closureCallable = ffi.Pointer.fromFunction< - ffi.Bool Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>( + ffi.Bool Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>( _ObjCBlock_bool_ffiVoid_objcObjCSelector_closureTrampoline, false); /// Construction methods for `objc.ObjCBlock, ffi.Pointer)>`. @@ -9493,24 +9969,36 @@ abstract final class ObjCBlock_bool_ffiVoid_objcObjCSelector { _ObjCBlock_bool_ffiVoid_objcObjCSelector_closureCallable, objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => - fn(arg0, arg1))), + fn(arg0, arg1)), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock, ffi.Pointer)>`. +extension ObjCBlock_bool_ffiVoid_objcObjCSelector_CallExtension + on objc.ObjCBlock< + ffi.Bool Function( + ffi.Pointer, ffi.Pointer)> { + bool call(ffi.Pointer arg0, ffi.Pointer arg1) => + _ObjectiveCBindings_invokeBlock_w1e3k0(ref.pointer, arg0, arg1); +} + void _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => - target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2)>>() + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2)>>.fromAddress( + closureId) .asFunction< void Function( ffi.Pointer, @@ -9519,52 +10007,58 @@ void final _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrCallable = ffi.Pointer.fromFunction< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer)>( _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrTrampoline); void _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => - (objc.getBlockClosure(target.address) as void Function( + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer))(arg0, arg1, arg2); final _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_closureCallable = ffi.Pointer.fromFunction< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer)>( _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_closureTrampoline); void _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_listenerTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) { - (objc.getBlockClosure(target.address) as void Function( + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer))(arg0, arg1, arg2); - // objc.objectRelease(block.cast()); + objc.objectRelease(block.cast()); } ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_listenerCallable = ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer)>.listener( @@ -9572,26 +10066,28 @@ ffi.NativeCallable< ..keepIsolateAlive = false; void _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_blockingTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer waiter, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) { try { - (objc.getBlockClosure(target.address) as void Function( + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer, ffi.Pointer, ffi.Pointer))(arg0, arg1, arg2); } catch (e) { } finally { objc.signalWaiter(waiter); - // objc.objectRelease(block.cast()); + objc.objectRelease(block.cast()); } } ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -9599,7 +10095,8 @@ ffi.NativeCallable< _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_blockingCallable = ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -9608,7 +10105,8 @@ ffi.NativeCallable< ..keepIsolateAlive = false; ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -9616,7 +10114,8 @@ ffi.NativeCallable< _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_blockingListenerCallable = ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -9662,7 +10161,9 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => fn( ObjCBlock_ffiVoid_objcObjCObject_NSError.castFromPointer(arg0, retain: true, release: true), objc.ObjCObjectBase(arg1, retain: true, release: true), - NSDictionary.castFromPointer(arg2, retain: true, release: true)))), + NSDictionary.castFromPointer(arg2, retain: true, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); @@ -9699,7 +10200,9 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO retain: false, release: true), objc.ObjCObjectBase(arg1, retain: false, release: true), NSDictionary.castFromPointer(arg2, - retain: false, release: true)))); + retain: false, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final wrapper = _ObjectiveCBindings_wrapListenerBlock_1j2nt86(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock< @@ -9743,7 +10246,9 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO retain: false, release: true), objc.ObjCObjectBase(arg1, retain: false, release: true), NSDictionary.castFromPointer(arg2, - retain: false, release: true)))); + retain: false, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final rawListener = _ObjectiveCBindings_newClosureBlock_1j2nt86( _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_blockingListenerCallable .nativeFunction @@ -9756,7 +10261,9 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO retain: false, release: true), objc.ObjCObjectBase(arg1, retain: false, release: true), NSDictionary.castFromPointer(arg2, - retain: false, release: true)))); + retain: false, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final wrapper = objc.wrapBlockingBlock( _ObjectiveCBindings_wrapBlockingBlock_1j2nt86, raw, rawListener); objc.objectRelease(raw.cast()); @@ -9770,62 +10277,91 @@ abstract final class ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCO } } +/// Call operator for `objc.ObjCBlock?, NSError)>, ffi.Pointer, NSDictionary)>`. +extension ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_CallExtension + on objc.ObjCBlock< + ffi.Void Function( + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError)>, + ffi.Pointer, + NSDictionary)> { + void call( + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError)> + arg0, + objc.ObjCObjectBase arg1, + NSDictionary arg2) => + _ObjectiveCBindings_invokeBlock_1j2nt86( + ref.pointer, arg0.ref.pointer, arg1.ref.pointer, arg2.ref.pointer); +} + void _ObjCBlock_ffiVoid_ffiVoid_fnPtrTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - target - .cast< - ffi.NativeFunction arg0)>>() + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0)>>.fromAddress(closureId) .asFunction)>()(arg0); final _ObjCBlock_ffiVoid_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, + ffi.Void Function(ffi.Pointer, ffi.Int64, ffi.Pointer)>(_ObjCBlock_ffiVoid_ffiVoid_fnPtrTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_closureTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - (objc.getBlockClosure(target.address) as void Function( + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer))(arg0); final _ObjCBlock_ffiVoid_ffiVoid_closureCallable = ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, + ffi.Void Function(ffi.Pointer, ffi.Int64, ffi.Pointer)>(_ObjCBlock_ffiVoid_ffiVoid_closureTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_listenerTrampoline( - ffi.Pointer target, ffi.Pointer arg0) { - (objc.getBlockClosure(target.address) as void Function( + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) { + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer))(arg0); - // objc.objectRelease(block.cast()); + objc.objectRelease(block.cast()); } ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer)> + ffi.Void Function( + ffi.Pointer, ffi.Int64, ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_listenerCallable = ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, ffi.Pointer)>.listener( + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Pointer)>.listener( _ObjCBlock_ffiVoid_ffiVoid_listenerTrampoline) ..keepIsolateAlive = false; -void _ObjCBlock_ffiVoid_ffiVoid_blockingTrampoline(ffi.Pointer target, - ffi.Pointer waiter, ffi.Pointer arg0) { +void _ObjCBlock_ffiVoid_ffiVoid_blockingTrampoline( + ffi.Pointer block, + int closureId, + ffi.Pointer waiter, + ffi.Pointer arg0) { try { - (objc.getBlockClosure(target.address) as void Function( + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer))(arg0); } catch (e) { } finally { objc.signalWaiter(waiter); - // objc.objectRelease(block.cast()); + objc.objectRelease(block.cast()); } } ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_blockingCallable = ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>.isolateLocal( + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>.isolateLocal( _ObjCBlock_ffiVoid_ffiVoid_blockingTrampoline) ..keepIsolateAlive = false; ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_blockingListenerCallable = ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>.listener( + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>.listener( _ObjCBlock_ffiVoid_ffiVoid_blockingTrampoline) ..keepIsolateAlive = false; @@ -9858,7 +10394,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid { _ObjectiveCBindings_newClosureBlock_ovsamd( _ObjCBlock_ffiVoid_ffiVoid_closureCallable, objc.registerBlockClosure( - (ffi.Pointer arg0) => fn(arg0))), + (ffi.Pointer arg0) => fn(arg0)), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); @@ -9875,7 +10413,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid { void Function(ffi.Pointer) fn) { final raw = _ObjectiveCBindings_newClosureBlock_ovsamd( _ObjCBlock_ffiVoid_ffiVoid_listenerCallable.nativeFunction.cast(), - objc.registerBlockClosure((ffi.Pointer arg0) => fn(arg0))); + objc.registerBlockClosure((ffi.Pointer arg0) => fn(arg0)), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final wrapper = _ObjectiveCBindings_wrapListenerBlock_ovsamd(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock)>(wrapper, @@ -9895,11 +10435,15 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid { void Function(ffi.Pointer) fn) { final raw = _ObjectiveCBindings_newClosureBlock_ovsamd( _ObjCBlock_ffiVoid_ffiVoid_blockingCallable.nativeFunction.cast(), - objc.registerBlockClosure((ffi.Pointer arg0) => fn(arg0))); + objc.registerBlockClosure((ffi.Pointer arg0) => fn(arg0)), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final rawListener = _ObjectiveCBindings_newClosureBlock_ovsamd( _ObjCBlock_ffiVoid_ffiVoid_blockingListenerCallable.nativeFunction .cast(), - objc.registerBlockClosure((ffi.Pointer arg0) => fn(arg0))); + objc.registerBlockClosure((ffi.Pointer arg0) => fn(arg0)), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final wrapper = objc.wrapBlockingBlock( _ObjectiveCBindings_wrapBlockingBlock_ovsamd, raw, rawListener); objc.objectRelease(raw.cast()); @@ -9909,84 +10453,107 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid { } } +/// Call operator for `objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid_CallExtension + on objc.ObjCBlock)> { + void call(ffi.Pointer arg0) => + _ObjectiveCBindings_invokeBlock_ovsamd(ref.pointer, arg0); +} + void _ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - target - .cast< + ffi.Pointer< ffi.NativeFunction< ffi.Void Function(ffi.Pointer arg0, - ffi.Pointer arg1)>>() + ffi.Pointer arg1)>>.fromAddress(closureId) .asFunction< void Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); final _ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>( + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_fnPtrTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(target.address) as void Function( + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); final _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureCallable = ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>( + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_NSCoder_listenerTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) { - (objc.getBlockClosure(target.address) as void Function( + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); - // objc.objectRelease(block.cast()); + objc.objectRelease(block.cast()); } ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_NSCoder_listenerCallable = ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>.listener( + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>.listener( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_listenerTrampoline) ..keepIsolateAlive = false; void _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer waiter, ffi.Pointer arg0, ffi.Pointer arg1) { try { - (objc.getBlockClosure(target.address) as void Function( + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); } catch (e) { } finally { objc.signalWaiter(waiter); - // objc.objectRelease(block.cast()); + objc.objectRelease(block.cast()); } } ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)> + ffi.Void Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingCallable = ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer)>.isolateLocal( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingTrampoline) ..keepIsolateAlive = false; ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)> + ffi.Void Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)> _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingListenerCallable = ffi .NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)>.listener( + ffi.Void Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>.listener( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingTrampoline) ..keepIsolateAlive = false; @@ -10015,17 +10582,18 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer, NSCoder)> fromFunction( - void Function(ffi.Pointer, NSCoder) fn) => - objc.ObjCBlock, NSCoder)>( - _ObjectiveCBindings_newClosureBlock_wjovn7( - _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureCallable, - objc.registerBlockClosure((ffi.Pointer arg0, - ffi.Pointer arg1) => - fn(arg0, NSCoder.castFromPointer(arg1, retain: true, release: true)))), - retain: false, - release: true); + static objc.ObjCBlock, NSCoder)> + fromFunction(void Function(ffi.Pointer, NSCoder) fn) => + objc.ObjCBlock, NSCoder)>( + _ObjectiveCBindings_newClosureBlock_wjovn7( + _ObjCBlock_ffiVoid_ffiVoid_NSCoder_closureCallable, + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1) => + fn(arg0, NSCoder.castFromPointer(arg1, retain: true, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), + retain: false, + release: true); /// Creates a listener block from a Dart function. /// @@ -10044,7 +10612,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => fn(arg0, - NSCoder.castFromPointer(arg1, retain: false, release: true)))); + NSCoder.castFromPointer(arg1, retain: false, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final wrapper = _ObjectiveCBindings_wrapListenerBlock_wjovn7(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock, NSCoder)>( @@ -10070,7 +10640,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => fn(arg0, - NSCoder.castFromPointer(arg1, retain: false, release: true)))); + NSCoder.castFromPointer(arg1, retain: false, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final rawListener = _ObjectiveCBindings_newClosureBlock_wjovn7( _ObjCBlock_ffiVoid_ffiVoid_NSCoder_blockingListenerCallable .nativeFunction @@ -10078,7 +10650,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => fn(arg0, - NSCoder.castFromPointer(arg1, retain: false, release: true)))); + NSCoder.castFromPointer(arg1, retain: false, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final wrapper = objc.wrapBlockingBlock( _ObjectiveCBindings_wrapBlockingBlock_wjovn7, raw, rawListener); objc.objectRelease(raw.cast()); @@ -10090,80 +10664,104 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSCoder { } } +/// Call operator for `objc.ObjCBlock, NSCoder)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSCoder_CallExtension + on objc.ObjCBlock, NSCoder)> { + void call(ffi.Pointer arg0, NSCoder arg1) => + _ObjectiveCBindings_invokeBlock_wjovn7( + ref.pointer, arg0, arg1.ref.pointer); +} + void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, int arg2) => - target - .cast< + ffi.Pointer< ffi.NativeFunction< ffi.Void Function( ffi.Pointer arg0, ffi.Pointer arg1, - ffi.UnsignedLong arg2)>>() + ffi.UnsignedLong arg2)>>.fromAddress(closureId) .asFunction< void Function(ffi.Pointer, ffi.Pointer, int)>()(arg0, arg1, arg2); final _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.UnsignedLong)>( + ffi.Void Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>( _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, int arg2) => - (objc.getBlockClosure(target.address) as void Function( - ffi.Pointer, - ffi.Pointer, - int))(arg0, arg1, arg2); + (objc.getBlockClosure(closureId) as void Function(ffi.Pointer, + ffi.Pointer, int))(arg0, arg1, arg2); final _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureCallable = ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.UnsignedLong)>( + ffi.Void Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>( _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureTrampoline); void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, int arg2) { - (objc.getBlockClosure(target.address) as void Function(ffi.Pointer, + (objc.getBlockClosure(closureId) as void Function(ffi.Pointer, ffi.Pointer, int))(arg0, arg1, arg2); - // objc.objectRelease(block.cast()); + objc.objectRelease(block.cast()); } ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.UnsignedLong)> + ffi.Void Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)> _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerCallable = ffi .NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.UnsignedLong)>.listener( + ffi.Void Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedLong)>.listener( _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_listenerTrampoline) ..keepIsolateAlive = false; void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_blockingTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer waiter, ffi.Pointer arg0, ffi.Pointer arg1, int arg2) { try { - (objc.getBlockClosure(target.address) as void Function( - ffi.Pointer, - ffi.Pointer, - int))(arg0, arg1, arg2); + (objc.getBlockClosure(closureId) as void Function(ffi.Pointer, + ffi.Pointer, int))(arg0, arg1, arg2); } catch (e) { } finally { objc.signalWaiter(waiter); - // objc.objectRelease(block.cast()); + objc.objectRelease(block.cast()); } } ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10171,7 +10769,8 @@ ffi.NativeCallable< _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_blockingCallable = ffi .NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10180,7 +10779,8 @@ ffi.NativeCallable< ..keepIsolateAlive = false; ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10188,7 +10788,8 @@ ffi.NativeCallable< _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_blockingListenerCallable = ffi.NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10228,7 +10829,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_closureCallable, objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1, int arg2) => - fn(arg0, NSStream.castFromPointer(arg1, retain: true, release: true), NSStreamEvent.fromValue(arg2)))), + fn(arg0, NSStream.castFromPointer(arg1, retain: true, release: true), NSStreamEvent.fromValue(arg2))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); @@ -10254,7 +10857,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { fn( arg0, NSStream.castFromPointer(arg1, retain: false, release: true), - NSStreamEvent.fromValue(arg2)))); + NSStreamEvent.fromValue(arg2))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final wrapper = _ObjectiveCBindings_wrapListenerBlock_18d6mda(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock< @@ -10284,7 +10889,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { fn( arg0, NSStream.castFromPointer(arg1, retain: false, release: true), - NSStreamEvent.fromValue(arg2)))); + NSStreamEvent.fromValue(arg2))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final rawListener = _ObjectiveCBindings_newClosureBlock_18d6mda( _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_blockingListenerCallable .nativeFunction @@ -10294,7 +10901,9 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { fn( arg0, NSStream.castFromPointer(arg1, retain: false, release: true), - NSStreamEvent.fromValue(arg2)))); + NSStreamEvent.fromValue(arg2))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final wrapper = objc.wrapBlockingBlock( _ObjectiveCBindings_wrapBlockingBlock_18d6mda, raw, rawListener); objc.objectRelease(raw.cast()); @@ -10305,90 +10914,113 @@ abstract final class ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent { } } +/// Call operator for `objc.ObjCBlock, NSStream, ffi.UnsignedLong)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_CallExtension + on objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, NSStream, ffi.UnsignedLong)> { + void call(ffi.Pointer arg0, NSStream arg1, NSStreamEvent arg2) => + _ObjectiveCBindings_invokeBlock_18d6mda( + ref.pointer, arg0, arg1.ref.pointer, arg2.value); +} + void _ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - target - .cast< + ffi.Pointer< ffi.NativeFunction< ffi.Void Function(ffi.Pointer arg0, - ffi.Pointer arg1)>>() + ffi.Pointer arg1)>>.fromAddress(closureId) .asFunction< void Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); final _ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, + ffi.Void Function(ffi.Pointer, ffi.Int64, ffi.Pointer, ffi.Pointer)>( _ObjCBlock_ffiVoid_objcObjCObject_NSError_fnPtrTrampoline); void _ObjCBlock_ffiVoid_objcObjCObject_NSError_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(target.address) as void Function( + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); final _ObjCBlock_ffiVoid_objcObjCObject_NSError_closureCallable = ffi.Pointer.fromFunction< - ffi.Void Function(ffi.Pointer, + ffi.Void Function(ffi.Pointer, ffi.Int64, ffi.Pointer, ffi.Pointer)>( _ObjCBlock_ffiVoid_objcObjCObject_NSError_closureTrampoline); void _ObjCBlock_ffiVoid_objcObjCObject_NSError_listenerTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) { - (objc.getBlockClosure(target.address) as void Function( + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); - // objc.objectRelease(block.cast()); + objc.objectRelease(block.cast()); } ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)> + ffi.Void Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)> _ObjCBlock_ffiVoid_objcObjCObject_NSError_listenerCallable = ffi .NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer)>.listener( _ObjCBlock_ffiVoid_objcObjCObject_NSError_listenerTrampoline) ..keepIsolateAlive = false; void _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer waiter, ffi.Pointer arg0, ffi.Pointer arg1) { try { - (objc.getBlockClosure(target.address) as void Function( + (objc.getBlockClosure(closureId) as void Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); } catch (e) { } finally { objc.signalWaiter(waiter); - // objc.objectRelease(block.cast()); + objc.objectRelease(block.cast()); } } ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)> + ffi.Void Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)> _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingCallable = ffi .NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer)>.isolateLocal( _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingTrampoline) ..keepIsolateAlive = false; ffi.NativeCallable< - ffi.Void Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)> + ffi.Void Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)> _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingListenerCallable = ffi .NativeCallable< ffi.Void Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer)>.listener( @@ -10429,7 +11061,9 @@ abstract final class ObjCBlock_ffiVoid_objcObjCObject_NSError { arg0.address == 0 ? null : objc.ObjCObjectBase(arg0, retain: true, release: true), - NSError.castFromPointer(arg1, retain: true, release: true)))), + NSError.castFromPointer(arg1, retain: true, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); @@ -10455,7 +11089,9 @@ abstract final class ObjCBlock_ffiVoid_objcObjCObject_NSError { arg0.address == 0 ? null : objc.ObjCObjectBase(arg0, retain: false, release: true), - NSError.castFromPointer(arg1, retain: false, release: true)))); + NSError.castFromPointer(arg1, retain: false, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final wrapper = _ObjectiveCBindings_wrapListenerBlock_wjvic9(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock< @@ -10485,7 +11121,9 @@ abstract final class ObjCBlock_ffiVoid_objcObjCObject_NSError { arg0.address == 0 ? null : objc.ObjCObjectBase(arg0, retain: false, release: true), - NSError.castFromPointer(arg1, retain: false, release: true)))); + NSError.castFromPointer(arg1, retain: false, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final rawListener = _ObjectiveCBindings_newClosureBlock_wjvic9( _ObjCBlock_ffiVoid_objcObjCObject_NSError_blockingListenerCallable .nativeFunction @@ -10496,7 +11134,9 @@ abstract final class ObjCBlock_ffiVoid_objcObjCObject_NSError { arg0.address == 0 ? null : objc.ObjCObjectBase(arg0, retain: false, release: true), - NSError.castFromPointer(arg1, retain: false, release: true)))); + NSError.castFromPointer(arg1, retain: false, release: true))), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure); final wrapper = objc.wrapBlockingBlock( _ObjectiveCBindings_wrapBlockingBlock_wjvic9, raw, rawListener); objc.objectRelease(raw.cast()); @@ -10507,33 +11147,42 @@ abstract final class ObjCBlock_ffiVoid_objcObjCObject_NSError { } } +/// Call operator for `objc.ObjCBlock?, NSError)>`. +extension ObjCBlock_ffiVoid_objcObjCObject_NSError_CallExtension on objc + .ObjCBlock?, NSError)> { + void call(objc.ObjCObjectBase? arg0, NSError arg1) => + _ObjectiveCBindings_invokeBlock_wjvic9( + ref.pointer, arg0?.ref.pointer ?? ffi.nullptr, arg1.ref.pointer); +} + instancetype _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - target - .cast< + ffi.Pointer< ffi.NativeFunction< instancetype Function(ffi.Pointer arg0, - ffi.Pointer arg1)>>() + ffi.Pointer arg1)>>.fromAddress(closureId) .asFunction< instancetype Function(ffi.Pointer, ffi.Pointer)>()(arg0, arg1); final _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrCallable = ffi.Pointer.fromFunction< - instancetype Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>( + instancetype Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>( _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrTrampoline); instancetype _ObjCBlock_instancetype_ffiVoid_NSCoder_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(target.address) as instancetype Function( + (objc.getBlockClosure(closureId) as instancetype Function( ffi.Pointer, ffi.Pointer))(arg0, arg1); final _ObjCBlock_instancetype_ffiVoid_NSCoder_closureCallable = ffi.Pointer.fromFunction< - instancetype Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>( + instancetype Function(ffi.Pointer, ffi.Int64, + ffi.Pointer, ffi.Pointer)>( _ObjCBlock_instancetype_ffiVoid_NSCoder_closureTrampoline); /// Construction methods for `objc.ObjCBlock?> Function(ffi.Pointer, NSCoder)>`. @@ -10572,37 +11221,57 @@ abstract final class ObjCBlock_instancetype_ffiVoid_NSCoder { fn(arg0, NSCoder.castFromPointer(arg1, retain: true, release: true)) ?.ref .retainAndReturnPointer() ?? - ffi.nullptr)), + ffi.nullptr), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } -instancetype - _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrTrampoline( - ffi.Pointer target, - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3) => - target - .cast< - ffi.NativeFunction< - instancetype Function( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3)>>() - .asFunction< - instancetype Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>)>()( - arg0, arg1, arg2, arg3); +/// Call operator for `objc.ObjCBlock?> Function(ffi.Pointer, NSCoder)>`. +extension ObjCBlock_instancetype_ffiVoid_NSCoder_CallExtension + on objc.ObjCBlock< + objc.Retained?> Function( + ffi.Pointer, NSCoder)> { + Dartinstancetype? call(ffi.Pointer arg0, NSCoder arg1) => + _ObjectiveCBindings_invokeBlock_1m9h2n( + ref.pointer, arg0, arg1.ref.pointer) + .address == + 0 + ? null + : objc.ObjCObjectBase( + _ObjectiveCBindings_invokeBlock_1m9h2n( + ref.pointer, arg0, arg1.ref.pointer), + retain: false, + release: true); +} + +instancetype _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrTrampoline( + ffi.Pointer block, + int closureId, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer> arg3) => + ffi.Pointer< + ffi.NativeFunction< + instancetype Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer> + arg3)>>.fromAddress(closureId) + .asFunction< + instancetype Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>)>()(arg0, arg1, arg2, arg3); final _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrCallable = ffi.Pointer.fromFunction< instancetype Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10610,12 +11279,13 @@ final _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrCallable = _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_fnPtrTrampoline); instancetype _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer> arg3) => - (objc.getBlockClosure(target.address) as instancetype Function( + (objc.getBlockClosure(closureId) as instancetype Function( ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10623,7 +11293,8 @@ instancetype final _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_closureCallable = ffi.Pointer.fromFunction< instancetype Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10660,44 +11331,71 @@ abstract final class ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError { /// This block must be invoked by native code running on the same thread as /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. - static objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)> - fromFunction(Dartinstancetype? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>) fn) => - objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)>( - _ObjectiveCBindings_newClosureBlock_e2pkq8( - _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_closureCallable, - objc.registerBlockClosure((ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer> arg3) => - fn(arg0, NSData.castFromPointer(arg1, retain: true, release: true), NSString.castFromPointer(arg2, retain: true, release: true), arg3)?.ref.retainAndAutorelease() ?? ffi.nullptr)), - retain: false, + static objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)> fromFunction(Dartinstancetype? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>) fn) => + objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)>( + _ObjectiveCBindings_newClosureBlock_e2pkq8( + _ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_closureCallable, + objc.registerBlockClosure((ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer> arg3) => + fn(arg0, NSData.castFromPointer(arg1, retain: true, release: true), NSString.castFromPointer(arg2, retain: true, release: true), arg3)?.ref.retainAndAutorelease() ?? ffi.nullptr), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock? Function(ffi.Pointer, NSData, NSString, ffi.Pointer>)>`. +extension ObjCBlock_instancetype_ffiVoid_NSData_NSString_NSError_CallExtension + on objc.ObjCBlock< + ffi.Pointer? Function(ffi.Pointer, NSData, + NSString, ffi.Pointer>)> { + Dartinstancetype? call(ffi.Pointer arg0, NSData arg1, NSString arg2, + ffi.Pointer> arg3) => + _ObjectiveCBindings_invokeBlock_e2pkq8(ref.pointer, arg0, + arg1.ref.pointer, arg2.ref.pointer, arg3) + .address == + 0 + ? null + : objc.ObjCObjectBase( + _ObjectiveCBindings_invokeBlock_e2pkq8( + ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer, arg3), + retain: true, release: true); } ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_fnPtrTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - target - .cast< + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer arg0)>>() + ffi.Pointer arg0)>>.fromAddress(closureId) .asFunction< ffi.Pointer Function( ffi.Pointer)>()(arg0); final _ObjCBlock_objcObjCObject_ffiVoid_fnPtrCallable = ffi.Pointer.fromFunction< ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>( + ffi.Pointer, + ffi.Int64, + ffi.Pointer)>( _ObjCBlock_objcObjCObject_ffiVoid_fnPtrTrampoline); ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_closureTrampoline( - ffi.Pointer target, ffi.Pointer arg0) => - (objc.getBlockClosure(target.address) as ffi.Pointer + ffi.Pointer block, + int closureId, + ffi.Pointer arg0) => + (objc.getBlockClosure(closureId) as ffi.Pointer Function(ffi.Pointer))(arg0); final _ObjCBlock_objcObjCObject_ffiVoid_closureCallable = ffi.Pointer.fromFunction< ffi.Pointer Function( - ffi.Pointer, ffi.Pointer)>( + ffi.Pointer, + ffi.Int64, + ffi.Pointer)>( _ObjCBlock_objcObjCObject_ffiVoid_closureTrampoline); /// Construction methods for `objc.ObjCBlock Function(ffi.Pointer)>`. @@ -10734,42 +11432,60 @@ abstract final class ObjCBlock_objcObjCObject_ffiVoid { _ObjectiveCBindings_newClosureBlock_1yesha9( _ObjCBlock_objcObjCObject_ffiVoid_closureCallable, objc.registerBlockClosure((ffi.Pointer arg0) => - fn(arg0).ref.retainAndAutorelease())), + fn(arg0).ref.retainAndAutorelease()), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock Function(ffi.Pointer)>`. +extension ObjCBlock_objcObjCObject_ffiVoid_CallExtension on objc + .ObjCBlock Function(ffi.Pointer)> { + objc.ObjCObjectBase call(ffi.Pointer arg0) => objc.ObjCObjectBase( + _ObjectiveCBindings_invokeBlock_1yesha9(ref.pointer, arg0), + retain: true, + release: true); +} + ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - target - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer arg0, - ffi.Pointer arg1)>>() - .asFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer)>()(arg0, arg1); + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer arg0, + ffi.Pointer arg1)>>.fromAddress( + closureId) + .asFunction Function(ffi.Pointer, ffi.Pointer)>()( + arg0, arg1); final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_fnPtrCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( + ffi.Pointer Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer)>( _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_fnPtrTrampoline); ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1) => - (objc.getBlockClosure(target.address) + (objc.getBlockClosure(closureId) as ffi.Pointer Function(ffi.Pointer, ffi.Pointer))(arg0, arg1); final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_closureCallable = ffi.Pointer.fromFunction< - ffi.Pointer Function(ffi.Pointer, - ffi.Pointer, ffi.Pointer)>( + ffi.Pointer Function( + ffi.Pointer, + ffi.Int64, + ffi.Pointer, + ffi.Pointer)>( _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_closureTrampoline); /// Construction methods for `objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer)>`. @@ -10808,44 +11524,57 @@ abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector { _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_closureCallable, objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1) => - fn(arg0, arg1).ref.retainAndAutorelease())), + fn(arg0, arg1).ref.retainAndAutorelease()), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer)>`. +extension ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_CallExtension + on objc.ObjCBlock< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)> { + objc.ObjCObjectBase call( + ffi.Pointer arg0, ffi.Pointer arg1) => + objc.ObjCObjectBase( + _ObjectiveCBindings_invokeBlock_ykn0t6(ref.pointer, arg0, arg1), + retain: true, + release: true); +} + ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => - target - .cast< + ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( ffi.Pointer arg0, ffi.Pointer arg1, - ffi.Pointer arg2)>>() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>()(arg0, arg1, arg2); + ffi.Pointer arg2)>>.fromAddress(closureId) + .asFunction Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>()(arg0, arg1, arg2); final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_fnPtrCallable = ffi.Pointer.fromFunction< ffi.Pointer Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer)>( _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_fnPtrTrampoline); ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => - (objc.getBlockClosure(target.address) + (objc.getBlockClosure(closureId) as ffi.Pointer Function( ffi.Pointer, ffi.Pointer, @@ -10853,7 +11582,8 @@ ffi.Pointer final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_closureCallable = ffi.Pointer.fromFunction< ffi.Pointer Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer)>( @@ -10896,36 +11626,48 @@ abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCO objc.registerBlockClosure((ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2) => - fn(arg0, arg1, objc.ObjCObjectBase(arg2, retain: true, release: true)).ref.retainAndAutorelease())), + fn(arg0, arg1, objc.ObjCObjectBase(arg2, retain: true, release: true)).ref.retainAndAutorelease()), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>`. +extension ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_CallExtension + on objc.ObjCBlock< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)> { + objc.ObjCObjectBase call(ffi.Pointer arg0, + ffi.Pointer arg1, objc.ObjCObjectBase arg2) => + objc.ObjCObjectBase( + _ObjectiveCBindings_invokeBlock_1c0c70u( + ref.pointer, arg0, arg1, arg2.ref.pointer), + retain: true, + release: true); +} + ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_fnPtrTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer arg3) => - target - .cast< + ffi.Pointer< ffi.NativeFunction< ffi.Pointer Function( ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, - ffi.Pointer arg3)>>() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer)>()(arg0, arg1, arg2, arg3); + ffi.Pointer arg3)>>.fromAddress(closureId) + .asFunction Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>()(arg0, arg1, arg2, arg3); final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_fnPtrCallable = ffi.Pointer.fromFunction< ffi.Pointer Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10933,12 +11675,13 @@ final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjC _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_fnPtrTrampoline); ffi.Pointer _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_closureTrampoline( - ffi.Pointer target, + ffi.Pointer block, + int closureId, ffi.Pointer arg0, ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer arg3) => - (objc.getBlockClosure(target.address) + (objc.getBlockClosure(closureId) as ffi.Pointer Function( ffi.Pointer, ffi.Pointer, @@ -10947,7 +11690,8 @@ ffi.Pointer final _ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_closureCallable = ffi.Pointer.fromFunction< ffi.Pointer Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Pointer, @@ -10994,11 +11738,33 @@ abstract final class ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCO ffi.Pointer arg1, ffi.Pointer arg2, ffi.Pointer arg3) => - fn(arg0, arg1, objc.ObjCObjectBase(arg2, retain: true, release: true), objc.ObjCObjectBase(arg3, retain: true, release: true)).ref.retainAndAutorelease())), + fn(arg0, arg1, objc.ObjCObjectBase(arg2, retain: true, release: true), objc.ObjCObjectBase(arg3, retain: true, release: true)).ref.retainAndAutorelease()), + objc.blockClosureDisposePort, + objc.disposeObjCBlockWithClosure), retain: false, release: true); } +/// Call operator for `objc.ObjCBlock Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer)>`. +extension ObjCBlock_objcObjCObject_ffiVoid_objcObjCSelector_objcObjCObject_objcObjCObject_CallExtension + on objc.ObjCBlock< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)> { + objc.ObjCObjectBase call( + ffi.Pointer arg0, + ffi.Pointer arg1, + objc.ObjCObjectBase arg2, + objc.ObjCObjectBase arg3) => + objc.ObjCObjectBase( + _ObjectiveCBindings_invokeBlock_u8b97m( + ref.pointer, arg0, arg1, arg2.ref.pointer, arg3.ref.pointer), + retain: true, + release: true); +} + /// Protocol class Protocol extends objc.ObjCObjectBase { Protocol._(ffi.Pointer pointer, diff --git a/pkgs/objective_c/src/objective_c.c b/pkgs/objective_c/src/objective_c.c index 5ac45e685..c3d963944 100644 --- a/pkgs/objective_c/src/objective_c.c +++ b/pkgs/objective_c/src/objective_c.c @@ -16,8 +16,6 @@ typedef struct _ObjCBlockInternal { int reserved; void *invoke; void *descriptor; - void *target; - Dart_Port dispose_port; } ObjCBlockInternal; // https://opensource.apple.com/source/libclosure/libclosure-38/Block_private.h @@ -28,11 +26,9 @@ extern void *_NSConcreteFinalizingBlock[32]; extern void *_NSConcreteGlobalBlock[32]; extern void *_NSConcreteWeakBlockVariable[32]; -// Dispose helper for ObjC blocks that wrap a Dart closure. For these blocks, -// the target is an int ID, and the dispose_port is listening for these IDs. -void DOBJC_disposeObjCBlockWithClosure(ObjCBlockImpl* block) { - ObjCBlockInternal* blk = (ObjCBlockInternal*)block; - Dart_PostInteger_DL(blk->dispose_port, (int64_t)blk->target); +// Dispose helper for ObjC blocks that wrap a Dart closure. +void DOBJC_disposeObjCBlockWithClosure(int64_t dispose_port, int64_t closure_id) { + Dart_PostInteger_DL(dispose_port, closure_id); } bool DOBJC_isValidBlock(ObjCBlockImpl* block) { diff --git a/pkgs/objective_c/src/objective_c.h b/pkgs/objective_c/src/objective_c.h index 29ffa044b..d4fbabd9b 100644 --- a/pkgs/objective_c/src/objective_c.h +++ b/pkgs/objective_c/src/objective_c.h @@ -10,7 +10,7 @@ #include "objective_c_runtime.h" // Dispose helper for ObjC blocks that wrap a Dart closure. -FFI_EXPORT void DOBJC_disposeObjCBlockWithClosure(ObjCBlockImpl *block); +FFI_EXPORT void DOBJC_disposeObjCBlockWithClosure(int64_t dispose_port, int64_t closure_id); // Returns whether the block is valid and live. The pointer must point to // readable memory, or be null. May (rarely) return false positives. diff --git a/pkgs/objective_c/src/objective_c_bindings_generated.m b/pkgs/objective_c/src/objective_c_bindings_generated.m index 0bbfac8e7..417c0e11e 100644 --- a/pkgs/objective_c/src/objective_c_bindings_generated.m +++ b/pkgs/objective_c/src/objective_c_bindings_generated.m @@ -11,78 +11,200 @@ id objc_retain(id); id objc_retainBlock(id); +@interface _ObjectiveCBindings_BlockDestroyer : NSObject {} +@property int64_t closure_id; +@property int64_t dispose_port; +@property void (*dtor)(int64_t, int64_t); +- (void)dealloc; +@end +@implementation _ObjectiveCBindings_BlockDestroyer +- (void)dealloc { self.dtor(self.dispose_port, self.closure_id); } +@end + Protocol* _ObjectiveCBindings_NSStreamDelegate(void) { return @protocol(NSStreamDelegate); } typedef id (^_BlockType)(void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +id _ObjectiveCBindings_invokeBlock_1yesha9( + _BlockType block, void * arg0) { + return block(arg0); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType _ObjectiveCBindings_newClosureBlock_1yesha9( - id (*trampoline)(void * , void * ), void* target) NS_RETURNS_RETAINED { - return ^id (void * arg0) { - return trampoline(target, arg0); + id (*trampoline)(id , int64_t , void * ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType weakBlk; + _BlockType blk = ^id (void * arg0) { + return trampoline(weakBlk, obj.closure_id, arg0); }; + weakBlk = blk; + return blk; } typedef unsigned long (^_BlockType1)(void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +unsigned long _ObjectiveCBindings_invokeBlock_1ckyi24( + _BlockType1 block, void * arg0) { + return block(arg0); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType1 _ObjectiveCBindings_newClosureBlock_1ckyi24( - unsigned long (*trampoline)(void * , void * ), void* target) NS_RETURNS_RETAINED { - return ^unsigned long (void * arg0) { - return trampoline(target, arg0); + unsigned long (*trampoline)(id , int64_t , void * ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType1 weakBlk; + _BlockType1 blk = ^unsigned long (void * arg0) { + return trampoline(weakBlk, obj.closure_id, arg0); }; + weakBlk = blk; + return blk; } typedef unsigned long (^_BlockType2)(void * arg0, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3); +__attribute__((visibility("default"))) __attribute__((used)) +unsigned long _ObjectiveCBindings_invokeBlock_17ap02x( + _BlockType2 block, void * arg0, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3) { + return block(arg0, arg1, arg2, arg3); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType2 _ObjectiveCBindings_newClosureBlock_17ap02x( - unsigned long (*trampoline)(void * , void * , NSFastEnumerationState * , id * , unsigned long ), void* target) NS_RETURNS_RETAINED { - return ^unsigned long (void * arg0, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3) { - return trampoline(target, arg0, arg1, arg2, arg3); + unsigned long (*trampoline)(id , int64_t , void * , NSFastEnumerationState * , id * , unsigned long ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType2 weakBlk; + _BlockType2 blk = ^unsigned long (void * arg0, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1, arg2, arg3); }; + weakBlk = blk; + return blk; } typedef struct _NSZone * (^_BlockType3)(void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +struct _NSZone * _ObjectiveCBindings_invokeBlock_1a8cl66( + _BlockType3 block, void * arg0) { + return block(arg0); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType3 _ObjectiveCBindings_newClosureBlock_1a8cl66( - struct _NSZone * (*trampoline)(void * , void * ), void* target) NS_RETURNS_RETAINED { - return ^struct _NSZone * (void * arg0) { - return trampoline(target, arg0); + struct _NSZone * (*trampoline)(id , int64_t , void * ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType3 weakBlk; + _BlockType3 blk = ^struct _NSZone * (void * arg0) { + return trampoline(weakBlk, obj.closure_id, arg0); }; + weakBlk = blk; + return blk; } typedef BOOL (^_BlockType4)(void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +BOOL _ObjectiveCBindings_invokeBlock_e3qsqz( + _BlockType4 block, void * arg0) { + return block(arg0); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType4 _ObjectiveCBindings_newClosureBlock_e3qsqz( - BOOL (*trampoline)(void * , void * ), void* target) NS_RETURNS_RETAINED { - return ^BOOL (void * arg0) { - return trampoline(target, arg0); + BOOL (*trampoline)(id , int64_t , void * ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType4 weakBlk; + _BlockType4 blk = ^BOOL (void * arg0) { + return trampoline(weakBlk, obj.closure_id, arg0); }; + weakBlk = blk; + return blk; } typedef BOOL (^_BlockType5)(void * arg0, id arg1); +__attribute__((visibility("default"))) __attribute__((used)) +BOOL _ObjectiveCBindings_invokeBlock_ozkafd( + _BlockType5 block, void * arg0, id arg1) { + return block(arg0, arg1); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType5 _ObjectiveCBindings_newClosureBlock_ozkafd( - BOOL (*trampoline)(void * , void * , id ), void* target) NS_RETURNS_RETAINED { - return ^BOOL (void * arg0, id arg1) { - return trampoline(target, arg0, arg1); + BOOL (*trampoline)(id , int64_t , void * , id ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType5 weakBlk; + _BlockType5 blk = ^BOOL (void * arg0, id arg1) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1); }; + weakBlk = blk; + return blk; } typedef BOOL (^_BlockType6)(void * arg0, struct objc_selector * arg1); +__attribute__((visibility("default"))) __attribute__((used)) +BOOL _ObjectiveCBindings_invokeBlock_w1e3k0( + _BlockType6 block, void * arg0, struct objc_selector * arg1) { + return block(arg0, arg1); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType6 _ObjectiveCBindings_newClosureBlock_w1e3k0( - BOOL (*trampoline)(void * , void * , struct objc_selector * ), void* target) NS_RETURNS_RETAINED { - return ^BOOL (void * arg0, struct objc_selector * arg1) { - return trampoline(target, arg0, arg1); + BOOL (*trampoline)(id , int64_t , void * , struct objc_selector * ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType6 weakBlk; + _BlockType6 blk = ^BOOL (void * arg0, struct objc_selector * arg1) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1); }; + weakBlk = blk; + return blk; } typedef void (^_BlockType7)(id arg0, id arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +void _ObjectiveCBindings_invokeBlock_1j2nt86( + _BlockType7 block, id arg0, id arg1, id arg2) { + return block(arg0, arg1, arg2); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType7 _ObjectiveCBindings_newClosureBlock_1j2nt86( - void (*trampoline)(void * , id , id , id ), void* target) NS_RETURNS_RETAINED { - return ^void (id arg0, id arg1, id arg2) { - return trampoline(target, arg0, arg1, arg2); + void (*trampoline)(id , int64_t , id , id , id ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType7 weakBlk; + _BlockType7 blk = ^void (id arg0, id arg1, id arg2) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1, arg2); }; + weakBlk = blk; + return blk; } __attribute__((visibility("default"))) __attribute__((used)) @@ -113,12 +235,26 @@ _BlockType7 _ObjectiveCBindings_wrapBlockingBlock_1j2nt86( } typedef void (^_BlockType8)(void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +void _ObjectiveCBindings_invokeBlock_ovsamd( + _BlockType8 block, void * arg0) { + return block(arg0); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType8 _ObjectiveCBindings_newClosureBlock_ovsamd( - void (*trampoline)(void * , void * ), void* target) NS_RETURNS_RETAINED { - return ^void (void * arg0) { - return trampoline(target, arg0); + void (*trampoline)(id , int64_t , void * ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType8 weakBlk; + _BlockType8 blk = ^void (void * arg0) { + return trampoline(weakBlk, obj.closure_id, arg0); }; + weakBlk = blk; + return blk; } __attribute__((visibility("default"))) __attribute__((used)) @@ -149,12 +285,26 @@ _BlockType8 _ObjectiveCBindings_wrapBlockingBlock_ovsamd( } typedef void (^_BlockType9)(void * arg0, id arg1); +__attribute__((visibility("default"))) __attribute__((used)) +void _ObjectiveCBindings_invokeBlock_wjovn7( + _BlockType9 block, void * arg0, id arg1) { + return block(arg0, arg1); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType9 _ObjectiveCBindings_newClosureBlock_wjovn7( - void (*trampoline)(void * , void * , id ), void* target) NS_RETURNS_RETAINED { - return ^void (void * arg0, id arg1) { - return trampoline(target, arg0, arg1); + void (*trampoline)(id , int64_t , void * , id ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType9 weakBlk; + _BlockType9 blk = ^void (void * arg0, id arg1) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1); }; + weakBlk = blk; + return blk; } __attribute__((visibility("default"))) __attribute__((used)) @@ -185,12 +335,26 @@ _BlockType9 _ObjectiveCBindings_wrapBlockingBlock_wjovn7( } typedef void (^_BlockType10)(void * arg0, id arg1, NSStreamEvent arg2); +__attribute__((visibility("default"))) __attribute__((used)) +void _ObjectiveCBindings_invokeBlock_18d6mda( + _BlockType10 block, void * arg0, id arg1, NSStreamEvent arg2) { + return block(arg0, arg1, arg2); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType10 _ObjectiveCBindings_newClosureBlock_18d6mda( - void (*trampoline)(void * , void * , id , NSStreamEvent ), void* target) NS_RETURNS_RETAINED { - return ^void (void * arg0, id arg1, NSStreamEvent arg2) { - return trampoline(target, arg0, arg1, arg2); + void (*trampoline)(id , int64_t , void * , id , NSStreamEvent ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType10 weakBlk; + _BlockType10 blk = ^void (void * arg0, id arg1, NSStreamEvent arg2) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1, arg2); }; + weakBlk = blk; + return blk; } __attribute__((visibility("default"))) __attribute__((used)) @@ -221,12 +385,26 @@ _BlockType10 _ObjectiveCBindings_wrapBlockingBlock_18d6mda( } typedef void (^_BlockType11)(id arg0, id arg1); +__attribute__((visibility("default"))) __attribute__((used)) +void _ObjectiveCBindings_invokeBlock_wjvic9( + _BlockType11 block, id arg0, id arg1) { + return block(arg0, arg1); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType11 _ObjectiveCBindings_newClosureBlock_wjvic9( - void (*trampoline)(void * , id , id ), void* target) NS_RETURNS_RETAINED { - return ^void (id arg0, id arg1) { - return trampoline(target, arg0, arg1); + void (*trampoline)(id , int64_t , id , id ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType11 weakBlk; + _BlockType11 blk = ^void (id arg0, id arg1) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1); }; + weakBlk = blk; + return blk; } __attribute__((visibility("default"))) __attribute__((used)) @@ -257,46 +435,116 @@ _BlockType11 _ObjectiveCBindings_wrapBlockingBlock_wjvic9( } typedef id (^_BlockType12)(void * arg0, id arg1); +__attribute__((visibility("default"))) __attribute__((used)) +id _ObjectiveCBindings_invokeBlock_1m9h2n( + _BlockType12 block, void * arg0, id arg1) NS_RETURNS_RETAINED { + return block(arg0, arg1); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType12 _ObjectiveCBindings_newClosureBlock_1m9h2n( - id (*trampoline)(void * , void * , id ), void* target) NS_RETURNS_RETAINED { - return ^id (void * arg0, id arg1) { - return trampoline(target, arg0, arg1); + id (*trampoline)(id , int64_t , void * , id ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType12 weakBlk; + _BlockType12 blk = ^id (void * arg0, id arg1) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1); }; + weakBlk = blk; + return blk; } typedef id (^_BlockType13)(void * arg0, id arg1, id arg2, id * arg3); +__attribute__((visibility("default"))) __attribute__((used)) +id _ObjectiveCBindings_invokeBlock_e2pkq8( + _BlockType13 block, void * arg0, id arg1, id arg2, id * arg3) { + return block(arg0, arg1, arg2, arg3); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType13 _ObjectiveCBindings_newClosureBlock_e2pkq8( - id (*trampoline)(void * , void * , id , id , id * ), void* target) NS_RETURNS_RETAINED { - return ^id (void * arg0, id arg1, id arg2, id * arg3) { - return trampoline(target, arg0, arg1, arg2, arg3); + id (*trampoline)(id , int64_t , void * , id , id , id * ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType13 weakBlk; + _BlockType13 blk = ^id (void * arg0, id arg1, id arg2, id * arg3) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1, arg2, arg3); }; + weakBlk = blk; + return blk; } typedef id (^_BlockType14)(void * arg0, struct objc_selector * arg1); +__attribute__((visibility("default"))) __attribute__((used)) +id _ObjectiveCBindings_invokeBlock_ykn0t6( + _BlockType14 block, void * arg0, struct objc_selector * arg1) { + return block(arg0, arg1); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType14 _ObjectiveCBindings_newClosureBlock_ykn0t6( - id (*trampoline)(void * , void * , struct objc_selector * ), void* target) NS_RETURNS_RETAINED { - return ^id (void * arg0, struct objc_selector * arg1) { - return trampoline(target, arg0, arg1); + id (*trampoline)(id , int64_t , void * , struct objc_selector * ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType14 weakBlk; + _BlockType14 blk = ^id (void * arg0, struct objc_selector * arg1) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1); }; + weakBlk = blk; + return blk; } typedef id (^_BlockType15)(void * arg0, struct objc_selector * arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +id _ObjectiveCBindings_invokeBlock_1c0c70u( + _BlockType15 block, void * arg0, struct objc_selector * arg1, id arg2) { + return block(arg0, arg1, arg2); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType15 _ObjectiveCBindings_newClosureBlock_1c0c70u( - id (*trampoline)(void * , void * , struct objc_selector * , id ), void* target) NS_RETURNS_RETAINED { - return ^id (void * arg0, struct objc_selector * arg1, id arg2) { - return trampoline(target, arg0, arg1, arg2); + id (*trampoline)(id , int64_t , void * , struct objc_selector * , id ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType15 weakBlk; + _BlockType15 blk = ^id (void * arg0, struct objc_selector * arg1, id arg2) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1, arg2); }; + weakBlk = blk; + return blk; } typedef id (^_BlockType16)(void * arg0, struct objc_selector * arg1, id arg2, id arg3); +__attribute__((visibility("default"))) __attribute__((used)) +id _ObjectiveCBindings_invokeBlock_u8b97m( + _BlockType16 block, void * arg0, struct objc_selector * arg1, id arg2, id arg3) { + return block(arg0, arg1, arg2, arg3); +} + __attribute__((visibility("default"))) __attribute__((used)) _BlockType16 _ObjectiveCBindings_newClosureBlock_u8b97m( - id (*trampoline)(void * , void * , struct objc_selector * , id , id ), void* target) NS_RETURNS_RETAINED { - return ^id (void * arg0, struct objc_selector * arg1, id arg2, id arg3) { - return trampoline(target, arg0, arg1, arg2, arg3); + id (*trampoline)(id , int64_t , void * , struct objc_selector * , id , id ), int64_t closure_id, int64_t dispose_port, + void (*dtor)(int64_t, int64_t)) NS_RETURNS_RETAINED { + _ObjectiveCBindings_BlockDestroyer* obj = [[_ObjectiveCBindings_BlockDestroyer alloc] init]; + obj.closure_id = closure_id; + obj.dispose_port = dispose_port; + obj.dtor = dtor; + __weak __block _BlockType16 weakBlk; + _BlockType16 blk = ^id (void * arg0, struct objc_selector * arg1, id arg2, id arg3) { + return trampoline(weakBlk, obj.closure_id, arg0, arg1, arg2, arg3); }; + weakBlk = blk; + return blk; } diff --git a/pkgs/objective_c/test/main.c b/pkgs/objective_c/test/main.c index 88bd241be..b02316d43 100644 --- a/pkgs/objective_c/test/main.c +++ b/pkgs/objective_c/test/main.c @@ -15,12 +15,9 @@ } int main() { - ASSERT_SYMBOL("DOBJC_disposeObjCBlockWithClosure"); // objective_c.c - ASSERT_SYMBOL("DOBJC_runOnMainThread"); - - ASSERT_SYMBOL("DOBJC_disposeObjCBlockWithClosure"); // objective_c.c - ASSERT_SYMBOL("DOBJC_runOnMainThread"); // objective_c.m - ASSERT_SYMBOL("OBJC_CLASS_$_DOBJCDartProxy"); // proxy.m + ASSERT_SYMBOL("DOBJC_finalizeObject"); // objective_c.c + ASSERT_SYMBOL("DOBJC_runOnMainThread"); // objective_c.m + ASSERT_SYMBOL("OBJC_CLASS_$_DOBJCDartProxy"); // proxy.m // objective_c_bindings_generated.m ASSERT_SYMBOL("_ObjectiveCBindings_wrapListenerBlock_ovsamd"); return 0; diff --git a/pkgs/objective_c/test/setup.dart b/pkgs/objective_c/test/setup.dart index e78993627..d12cf593c 100644 --- a/pkgs/objective_c/test/setup.dart +++ b/pkgs/objective_c/test/setup.dart @@ -92,7 +92,7 @@ void main(List arguments) { // Sanity check that the dylib was created correctly. final lib = DynamicLibrary.open(outputFile); - lib.lookup('DOBJC_disposeObjCBlockWithClosure'); // objective_c.c + lib.lookup('DOBJC_finalizeObject'); // objective_c.c lib.lookup('DOBJC_runOnMainThread'); // objective_c.m lib.lookup('Dart_InitializeApiDL'); // dart_api_dl.c lib.lookup('OBJC_CLASS_\$_DOBJCDartProxy'); // proxy.m