wip
diff --git a/pkgs/ffigen/lib/src/code_generator/objc_methods.dart b/pkgs/ffigen/lib/src/code_generator/objc_methods.dart index 2ac187d..78f41c5 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_methods.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_methods.dart
@@ -30,14 +30,12 @@ void addMethod(ObjCMethod? method) { if (method == null) return; - if (_shouldIncludeMethod(method)) { - final oldMethod = getSimilarMethod(method); - if (oldMethod != null) { - _methods[method.key] = _maybeReplaceMethod(oldMethod, method); - } else { - _methods[method.key] = method; - _order.add(method.key); - } + final oldMethod = getSimilarMethod(method); + if (oldMethod != null) { + _methods[method.key] = _maybeReplaceMethod(oldMethod, method); + } else { + _methods[method.key] = method; + _order.add(method.key); } } @@ -89,20 +87,6 @@ return newMethod; } - bool _shouldIncludeMethod(ObjCMethod method) => - method.childTypes.every((Type t) { - t = t.typealiasType.baseType; - - // Ignore methods with block args or rets when we're generating in - // package:objective_c. - // TODO(https://github.com/dart-lang/native/issues/1180): Remove this. - if (builtInFunctions.generateForPackageObjectiveC && t is ObjCBlock) { - return false; - } - - return true; - }); - UniqueNamer createMethodRenamer(Writer w) => UniqueNamer(parent: w.topLevelUniqueNamer) ..markAllUsed([
diff --git a/pkgs/ffigen/lib/src/header_parser/parser.dart b/pkgs/ffigen/lib/src/header_parser/parser.dart index 1680d7f..711cd27 100644 --- a/pkgs/ffigen/lib/src/header_parser/parser.dart +++ b/pkgs/ffigen/lib/src/header_parser/parser.dart
@@ -167,6 +167,12 @@ @visibleForTesting List<Binding> transformBindings(Config config, List<Binding> bindings) { + + bindings + .whereType<ObjCInterface>() + .where((o) => o.originalName == 'DOBJCObserver') + .single.methods.forEach(print); + visit(CopyMethodsFromSuperTypesVisitation(), bindings); visit(FixOverriddenMethodsVisitation(), bindings); visit(FillMethodDependenciesVisitation(), bindings);
diff --git a/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart b/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart index 0db4ef1..1ac8339 100644 --- a/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart +++ b/pkgs/ffigen/lib/src/header_parser/sub_parsers/objcinterfacedecl_parser.dart
@@ -53,6 +53,8 @@ _logger.fine('++++ Filling ObjC interface: ' 'Name: ${itf.originalName}, ${cursor.completeStringRepr()}'); + final debug = itf.originalName == 'DOBJCObserver'; + final itfDecl = Declaration(usr: itf.usr, originalName: itf.originalName); cursor.visitChildren((child) { switch (child.kind) { @@ -71,11 +73,17 @@ break; case clang_types.CXCursorKind.CXCursor_ObjCInstanceMethodDecl: case clang_types.CXCursorKind.CXCursor_ObjCClassMethodDecl: - itf.addMethod(parseObjCMethod(child, itfDecl, config.objcInterfaces)); + itf.addMethod(parseObjCMethod(child, itfDecl, config.objcInterfaces, debug: debug)); break; } }); + if (debug) { + print('\nQWER'); + itf.methods.forEach(print); + print('\n'); + } + _logger.fine('++++ Finished ObjC interface: ' 'Name: ${itf.originalName}, ${cursor.completeStringRepr()}'); } @@ -187,8 +195,12 @@ } ObjCMethod? parseObjCMethod(clang_types.CXCursor cursor, Declaration itfDecl, - DeclarationFilters filters) { + DeclarationFilters filters, {bool debug = false}) { final methodName = cursor.spelling(); + debug = debug && methodName == 'initForKeyPath:ofObject:withBlock:'; + if (debug) { + cursor.printAst(); + } final isClassMethod = cursor.kind == clang_types.CXCursorKind.CXCursor_ObjCClassMethodDecl; final isOptionalMethod = clang.clang_Cursor_isObjCOptional(cursor) != 0; @@ -197,6 +209,7 @@ _logger.warning('Method "$methodName" in instance ' '"${itfDecl.originalName}" has incomplete ' 'return type: $returnType.'); + if (debug) print('ZXCV: 1'); return null; } @@ -204,6 +217,7 @@ if (apiAvailability.availability == Availability.none) { _logger .info('Omitting deprecated method ${itfDecl.originalName}.$methodName'); + if (debug) print('ZXCV: 2'); return null; } @@ -246,6 +260,7 @@ } }); method.finalizeParams(); + if (debug) print('ZXCV: 3 $hasError\n\t$method'); return hasError ? null : method; }
diff --git a/pkgs/objective_c/ffigen_objc.yaml b/pkgs/objective_c/ffigen_objc.yaml index 27e7ad2..8609d11 100644 --- a/pkgs/objective_c/ffigen_objc.yaml +++ b/pkgs/objective_c/ffigen_objc.yaml
@@ -10,6 +10,7 @@ - 'src/foundation.h' - 'src/input_stream_adapter.h' - 'src/ns_number.h' + - 'src/observer.h' - 'src/protocol.h' ffi-native: exclude-all-by-default: true @@ -28,6 +29,7 @@ - DOBJCDartInputStreamAdapter - DOBJCDartProtocolBuilder - DOBJCDartProtocol + - DOBJCObserver - NSArray - NSCharacterSet - NSCoder @@ -158,6 +160,7 @@ typedefs: include: - 'CFStringRef' + - 'DOBJCObserverBlock' preamble: | // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a
diff --git a/pkgs/objective_c/ios/Classes/objective_c.m b/pkgs/objective_c/ios/Classes/objective_c.m index 745ecab..b3ce4fb 100644 --- a/pkgs/objective_c/ios/Classes/objective_c.m +++ b/pkgs/objective_c/ios/Classes/objective_c.m
@@ -7,4 +7,5 @@ #include "../../src/input_stream_adapter.m" #include "../../src/objective_c.m" #include "../../src/objective_c_bindings_generated.m" +#include "../../src/observer.m" #include "../../src/protocol.m"
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 92af210..96fd9a3 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart
@@ -135,6 +135,20 @@ ); @ffi.Native< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>() +external ffi.Pointer<objc.ObjCObject> + _ObjectiveCBindings_protocolTrampoline_1q0i84( + ffi.Pointer<objc.ObjCObject> target, + ffi.Pointer<ffi.Void> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCBlockImpl> arg2, +); + +@ffi.Native< ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Void>, ffi.Pointer<objc.ObjCObject>)>() external bool _ObjectiveCBindings_protocolTrampoline_3su7tt( @@ -241,6 +255,54 @@ ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_1o83rbn( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_1p9ui4q( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_1pl9qdv( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_1q8ia8l( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> _ObjectiveCBindings_wrapBlockingBlock_hoampi( ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, @@ -253,6 +315,18 @@ ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_lmc3p5( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> _ObjectiveCBindings_wrapBlockingBlock_ovsamd( ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, @@ -273,6 +347,102 @@ @ffi.Native< ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_q5jeyk( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_r8gdi7( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_rnu2c5( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_t8l8el( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_vhbh5h( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_xtuoz7( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_zkjmn1( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.DOBJC_Context>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapBlockingBlock_zuf90e( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> listnerBlock, + ffi.Pointer<objc.DOBJC_Context> context, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) external ffi.Pointer<objc.ObjCBlockImpl> _ObjectiveCBindings_wrapListenerBlock_18v1jvf( @@ -291,6 +461,38 @@ ffi.Pointer<objc.ObjCBlockImpl> Function( ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_1o83rbn( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_1p9ui4q( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_1pl9qdv( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_1q8ia8l( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> _ObjectiveCBindings_wrapListenerBlock_hoampi( ffi.Pointer<objc.ObjCBlockImpl> block, ); @@ -299,6 +501,14 @@ ffi.Pointer<objc.ObjCBlockImpl> Function( ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_lmc3p5( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> _ObjectiveCBindings_wrapListenerBlock_ovsamd( ffi.Pointer<objc.ObjCBlockImpl> block, ); @@ -311,6 +521,70 @@ ffi.Pointer<objc.ObjCBlockImpl> block, ); +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_q5jeyk( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_r8gdi7( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_rnu2c5( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_t8l8el( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_vhbh5h( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_xtuoz7( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_zkjmn1( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + +@ffi.Native< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>(isLeaf: true) +external ffi.Pointer<objc.ObjCBlockImpl> + _ObjectiveCBindings_wrapListenerBlock_zuf90e( + ffi.Pointer<objc.ObjCBlockImpl> block, +); + @ffi.Packed(2) final class AEDesc extends ffi.Struct { @ffi.UnsignedInt() @@ -347,6 +621,120 @@ external double height; } +/// Represents a single KVO observation. Each observation uses a new +/// DOBJCObserver, even for the same observed object and keyPath. +class DOBJCObserver extends NSObject { + DOBJCObserver._(ffi.Pointer<objc.ObjCObject> pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release); + + /// Constructs a [DOBJCObserver] that points to the same underlying object as [other]. + DOBJCObserver.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [DOBJCObserver] that wraps the given raw object pointer. + DOBJCObserver.castFromPointer(ffi.Pointer<objc.ObjCObject> other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [DOBJCObserver]. + static bool isInstance(objc.ObjCObjectBase obj) { + return _objc_msgSend_19nvye5( + obj.ref.pointer, _sel_isKindOfClass_, _class_DOBJCObserver); + } + + /// alloc + static DOBJCObserver alloc() { + final _ret = _objc_msgSend_151sglz(_class_DOBJCObserver, _sel_alloc); + return DOBJCObserver.castFromPointer(_ret, retain: false, release: true); + } + + /// allocWithZone: + static DOBJCObserver allocWithZone(ffi.Pointer<NSZone> zone) { + final _ret = + _objc_msgSend_1cwp428(_class_DOBJCObserver, _sel_allocWithZone_, zone); + return DOBJCObserver.castFromPointer(_ret, retain: false, release: true); + } + + /// new + static DOBJCObserver new$() { + final _ret = _objc_msgSend_151sglz(_class_DOBJCObserver, _sel_new); + return DOBJCObserver.castFromPointer(_ret, retain: false, release: true); + } + + /// autorelease + DOBJCObserver autorelease() { + final _ret = _objc_msgSend_151sglz(this.ref.pointer, _sel_autorelease); + return DOBJCObserver.castFromPointer(_ret, retain: true, release: true); + } + + /// dealloc + void dealloc() { + _objc_msgSend_1pl9qdv(this.ref.pointer, _sel_dealloc); + } + + /// init + DOBJCObserver init() { + objc.checkOsVersionInternal('DOBJCObserver.init', + iOS: (false, (2, 0, 0)), macOS: (false, (10, 0, 0))); + final _ret = + _objc_msgSend_151sglz(this.ref.retainAndReturnPointer(), _sel_init); + return DOBJCObserver.castFromPointer(_ret, retain: false, release: true); + } + + /// initForKeyPath:ofObject:withBlock: + DOBJCObserver initForKeyPath(NSString keyPath, + {required objc.ObjCObjectBase ofObject, + required DartDOBJCObserverBlock withBlock}) { + final _ret = _objc_msgSend_2wiv66( + this.ref.retainAndReturnPointer(), + _sel_initForKeyPath_ofObject_withBlock_, + keyPath.ref.pointer, + ofObject.ref.pointer, + withBlock.ref.pointer); + return DOBJCObserver.castFromPointer(_ret, retain: false, release: true); + } + + /// observeValueForKeyPath:ofObject:change:context: + void observeValueForKeyPath(NSString keyPath, + {required objc.ObjCObjectBase ofObject, + required NSDictionary change, + required ffi.Pointer<ffi.Void> context}) { + _objc_msgSend_1pl4k3n( + this.ref.pointer, + _sel_observeValueForKeyPath_ofObject_change_context_, + keyPath.ref.pointer, + ofObject.ref.pointer, + change.ref.pointer, + context); + } + + /// remove + void remove() { + _objc_msgSend_1pl9qdv(this.ref.pointer, _sel_remove); + } + + /// retain + DOBJCObserver retain() { + final _ret = _objc_msgSend_151sglz(this.ref.pointer, _sel_retain); + return DOBJCObserver.castFromPointer(_ret, retain: true, release: true); + } + + /// self + DOBJCObserver self$1() { + final _ret = _objc_msgSend_151sglz(this.ref.pointer, _sel_self); + return DOBJCObserver.castFromPointer(_ret, retain: true, release: true); + } + + /// Returns a new instance of DOBJCObserver constructed with the default `new` method. + factory DOBJCObserver() => new$(); +} + +typedef DOBJCObserverBlock = ffi.Pointer<objc.ObjCBlockImpl>; +typedef DartDOBJCObserverBlock = objc.ObjCBlock< + ffi.Void Function( + NSObject, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)>; + /// Helper class to adapt a Dart stream into a `NSInputStream`. class DartInputStreamAdapter extends NSInputStream implements NSStreamDelegate { DartInputStreamAdapter._(ffi.Pointer<objc.ObjCObject> pointer, @@ -724,29 +1112,7 @@ /// NSArray class NSArray extends NSObject - with Iterable<objc.ObjCObjectBase> implements NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration { - /// Creates a [NSArray] of the given length with [fill] at each position. - /// - /// The [length] must be a non-negative integer. - static NSArray filled(int length, objc.ObjCObjectBase fill) => - NSMutableArray.filled(length, fill); - - /// Creates a [NSArray] from [elements]. - static NSArray of(Iterable<objc.ObjCObjectBase> elements) => - NSMutableArray.of(elements); - - @override - int get length => count; - - @override - objc.ObjCObjectBase elementAt(int index) => objectAtIndex(index); - - @override - Iterator<objc.ObjCObjectBase> get iterator => _NSArrayIterator(this); - - objc.ObjCObjectBase operator [](int index) => objectAtIndex(index); - NSArray._(ffi.Pointer<objc.ObjCObject> pointer, {bool retain = false, bool release = false}) : super.castFromPointer(pointer, retain: retain, release: release); @@ -1448,6 +1814,23 @@ ); } +/// iOS: introduced 13.0.0 +/// macOS: introduced 10.15.0 +enum NSCollectionChangeType { + NSCollectionChangeInsert(0), + NSCollectionChangeRemove(1); + + final int value; + const NSCollectionChangeType(this.value); + + static NSCollectionChangeType fromValue(int value) => switch (value) { + 0 => NSCollectionChangeInsert, + 1 => NSCollectionChangeRemove, + _ => throw ArgumentError( + 'Unknown value for NSCollectionChangeType: $value'), + }; +} + enum NSComparisonResult { NSOrderedAscending(-1), NSOrderedSame(0), @@ -1771,8 +2154,27 @@ return NSData.castFromPointer(_ret, retain: false, release: true); } - /// initWithBytesNoCopy:length:freeWhenDone: + /// initWithBytesNoCopy:length:deallocator: NSData initWithBytesNoCopy$1(ffi.Pointer<ffi.Void> bytes$1, + {required int length, + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>? + deallocator}) { + objc.checkOsVersionInternal( + 'NSData.initWithBytesNoCopy:length:deallocator:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0))); + final _ret = _objc_msgSend_134vhyh( + this.ref.retainAndReturnPointer(), + _sel_initWithBytesNoCopy_length_deallocator_, + bytes$1, + length, + deallocator?.ref.pointer ?? ffi.nullptr); + return NSData.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithBytesNoCopy:length:freeWhenDone: + NSData initWithBytesNoCopy$2(ffi.Pointer<ffi.Void> bytes$1, {required int length, required bool freeWhenDone}) { final _ret = _objc_msgSend_161ne8y( this.ref.retainAndReturnPointer(), @@ -2172,44 +2574,7 @@ /// NSDictionary class NSDictionary extends NSObject - with MapBase<NSCopying, objc.ObjCObjectBase> implements NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration { - /// Creates a [NSDictionary] from [other]. - static NSDictionary of(Map<NSCopying, objc.ObjCObjectBase> other) => - NSMutableDictionary.of(other); - - /// Creates a [NSDictionary] from [entries]. - static NSDictionary fromEntries( - Iterable<MapEntry<NSCopying, objc.ObjCObjectBase>> entries) => - NSMutableDictionary.fromEntries(entries); - - @override - int get length => count; - - @override - objc.ObjCObjectBase? operator [](Object? key) => - key is NSCopying ? objectForKey(key) : null; - - @override - Iterable<NSCopying> get keys => _NSDictionaryKeyIterable(this); - - @override - Iterable<objc.ObjCObjectBase> get values => _NSDictionaryValueIterable(this); - - @override - bool containsKey(Object? key) => this[key] != null; - - @override - void operator []=(NSCopying key, objc.ObjCObjectBase value) => - throw UnsupportedError("Cannot modify NSDictionary"); - - @override - void clear() => throw UnsupportedError("Cannot modify NSDictionary"); - - @override - objc.ObjCObjectBase? remove(Object? key) => - throw UnsupportedError("Cannot modify NSDictionary"); - NSDictionary._(ffi.Pointer<objc.ObjCObject> pointer, {bool retain = false, bool release = false}) : super.castFromPointer(pointer, retain: retain, release: release); @@ -2441,20 +2806,7 @@ } /// NSEnumerator -class NSEnumerator extends NSObject - implements NSFastEnumeration, Iterator<objc.ObjCObjectBase> { - objc.ObjCObjectBase? _current; - - @override - objc.ObjCObjectBase get current => _current!; - - @override - @pragma('vm:prefer-inline') - bool moveNext() { - _current = nextObject(); - return _current != null; - } - +class NSEnumerator extends NSObject implements NSFastEnumeration { NSEnumerator._(ffi.Pointer<objc.ObjCObject> pointer, {bool retain = false, bool release = false}) : super.castFromPointer(pointer, retain: retain, release: release); @@ -2578,11 +2930,48 @@ return NSError.castFromPointer(_ret, retain: false, release: true); } + /// setUserInfoValueProviderForDomain:provider: + static void setUserInfoValueProviderForDomain(NSString errorDomain, + {objc + .ObjCBlock<ffi.Pointer<objc.ObjCObject>? Function(NSError, NSString)>? + provider}) { + objc.checkOsVersionInternal( + 'NSError.setUserInfoValueProviderForDomain:provider:', + iOS: (false, (9, 0, 0)), + macOS: (false, (10, 11, 0))); + _objc_msgSend_o762yo( + _class_NSError, + _sel_setUserInfoValueProviderForDomain_provider_, + errorDomain.ref.pointer, + provider?.ref.pointer ?? ffi.nullptr); + } + /// supportsSecureCoding static bool getSupportsSecureCoding() { return _objc_msgSend_91o635(_class_NSError, _sel_supportsSecureCoding); } + /// userInfoValueProviderForDomain: + static objc + .ObjCBlock<ffi.Pointer<objc.ObjCObject>? Function(NSError, NSString)>? + userInfoValueProviderForDomain_(NSError err, + {required NSString userInfoKey, required NSString errorDomain}) { + objc.checkOsVersionInternal('NSError.userInfoValueProviderForDomain:', + iOS: (false, (9, 0, 0)), macOS: (false, (10, 11, 0))); + final _ret = _objc_msgSend_cnxxyq( + _class_NSError, + _sel_userInfoValueProviderForDomain_, + err.ref.pointer, + userInfoKey.ref.pointer, + errorDomain.ref.pointer); + return _ret.address == 0 + ? null + : ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey.castFromPointer( + _ret, + retain: true, + release: true); + } + /// code int get code { return _objc_msgSend_1hz7y9r(this.ref.pointer, _sel_code); @@ -2753,6 +3142,54 @@ return NSString.castFromPointer(_ret, retain: true, release: true); } + /// enumerateObjectsAtIndexes:options:usingBlock: + void enumerateObjectsAtIndexes(NSIndexSet s, + {required NSEnumerationOptions options, + required objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal( + 'NSArray.enumerateObjectsAtIndexes:options:usingBlock:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + _objc_msgSend_a3wp08( + this.ref.pointer, + _sel_enumerateObjectsAtIndexes_options_usingBlock_, + s.ref.pointer, + options.value, + usingBlock.ref.pointer); + } + + /// enumerateObjectsUsingBlock: + void enumerateObjectsUsingBlock( + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + block) { + objc.checkOsVersionInternal('NSArray.enumerateObjectsUsingBlock:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + _objc_msgSend_f167m6( + this.ref.pointer, _sel_enumerateObjectsUsingBlock_, block.ref.pointer); + } + + /// enumerateObjectsWithOptions:usingBlock: + void enumerateObjectsWithOptions(NSEnumerationOptions opts, + {required objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal( + 'NSArray.enumerateObjectsWithOptions:usingBlock:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + _objc_msgSend_yx8yc6( + this.ref.pointer, + _sel_enumerateObjectsWithOptions_usingBlock_, + opts.value, + usingBlock.ref.pointer); + } + /// firstObject objc.ObjCObjectBase? get firstObject { objc.checkOsVersionInternal('NSArray.firstObject', @@ -2792,6 +3229,46 @@ anObject.ref.pointer, inRange); } + /// indexOfObject:inSortedRange:options:usingComparator: + int indexOfObject$2(objc.ObjCObjectBase obj, + {required NSRange inSortedRange, + required NSBinarySearchingOptions options, + required objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + usingComparator}) { + objc.checkOsVersionInternal( + 'NSArray.indexOfObject:inSortedRange:options:usingComparator:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + return _objc_msgSend_kshx9d( + this.ref.pointer, + _sel_indexOfObject_inSortedRange_options_usingComparator_, + obj.ref.pointer, + inSortedRange, + options.value, + usingComparator.ref.pointer); + } + + /// indexOfObjectAtIndexes:options:passingTest: + int indexOfObjectAtIndexes(NSIndexSet s, + {required NSEnumerationOptions options, + required objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal( + 'NSArray.indexOfObjectAtIndexes:options:passingTest:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + return _objc_msgSend_k1x6mt( + this.ref.pointer, + _sel_indexOfObjectAtIndexes_options_passingTest_, + s.ref.pointer, + options.value, + passingTest.ref.pointer); + } + /// indexOfObjectIdenticalTo: int indexOfObjectIdenticalTo(objc.ObjCObjectBase anObject) { return _objc_msgSend_1vd1c5m( @@ -2805,6 +3282,84 @@ _sel_indexOfObjectIdenticalTo_inRange_, anObject.ref.pointer, inRange); } + /// indexOfObjectPassingTest: + int indexOfObjectPassingTest( + objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + predicate) { + objc.checkOsVersionInternal('NSArray.indexOfObjectPassingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + return _objc_msgSend_10mlopr(this.ref.pointer, + _sel_indexOfObjectPassingTest_, predicate.ref.pointer); + } + + /// indexOfObjectWithOptions:passingTest: + int indexOfObjectWithOptions(NSEnumerationOptions opts, + {required objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal('NSArray.indexOfObjectWithOptions:passingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + return _objc_msgSend_1698hqz( + this.ref.pointer, + _sel_indexOfObjectWithOptions_passingTest_, + opts.value, + passingTest.ref.pointer); + } + + /// indexesOfObjectsAtIndexes:options:passingTest: + NSIndexSet indexesOfObjectsAtIndexes(NSIndexSet s, + {required NSEnumerationOptions options, + required objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal( + 'NSArray.indexesOfObjectsAtIndexes:options:passingTest:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_1i9v144( + this.ref.pointer, + _sel_indexesOfObjectsAtIndexes_options_passingTest_, + s.ref.pointer, + options.value, + passingTest.ref.pointer); + return NSIndexSet.castFromPointer(_ret, retain: true, release: true); + } + + /// indexesOfObjectsPassingTest: + NSIndexSet indexesOfObjectsPassingTest( + objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + predicate) { + objc.checkOsVersionInternal('NSArray.indexesOfObjectsPassingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_nnxkei(this.ref.pointer, + _sel_indexesOfObjectsPassingTest_, predicate.ref.pointer); + return NSIndexSet.castFromPointer(_ret, retain: true, release: true); + } + + /// indexesOfObjectsWithOptions:passingTest: + NSIndexSet indexesOfObjectsWithOptions(NSEnumerationOptions opts, + {required objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal( + 'NSArray.indexesOfObjectsWithOptions:passingTest:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_13x5boi( + this.ref.pointer, + _sel_indexesOfObjectsWithOptions_passingTest_, + opts.value, + passingTest.ref.pointer); + return NSIndexSet.castFromPointer(_ret, retain: true, release: true); + } + /// isEqualToArray: bool isEqualToArray(NSArray otherArray) { return _objc_msgSend_19nvye5( @@ -2870,6 +3425,19 @@ return NSData.castFromPointer(_ret, retain: true, release: true); } + /// sortedArrayUsingComparator: + NSArray sortedArrayUsingComparator( + objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + cmptr) { + objc.checkOsVersionInternal('NSArray.sortedArrayUsingComparator:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_nnxkei( + this.ref.pointer, _sel_sortedArrayUsingComparator_, cmptr.ref.pointer); + return NSArray.castFromPointer(_ret, retain: true, release: true); + } + /// sortedArrayUsingFunction:context: NSArray sortedArrayUsingFunction( ffi.Pointer< @@ -2908,6 +3476,24 @@ return NSArray.castFromPointer(_ret, retain: true, release: true); } + /// sortedArrayWithOptions:usingComparator: + NSArray sortedArrayWithOptions(NSSortOptions opts, + {required objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + usingComparator}) { + objc.checkOsVersionInternal( + 'NSArray.sortedArrayWithOptions:usingComparator:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_1x5ew3h( + this.ref.pointer, + _sel_sortedArrayWithOptions_usingComparator_, + opts.value, + usingComparator.ref.pointer); + return NSArray.castFromPointer(_ret, retain: true, release: true); + } + /// subarrayWithRange: NSArray subarrayWithRange(NSRange range) { final _ret = @@ -2933,6 +3519,18 @@ return NSString.castFromPointer(_ret, retain: true, release: true); } + /// enumerateByteRangesUsingBlock: + void enumerateByteRangesUsingBlock( + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)> + block) { + objc.checkOsVersionInternal('NSData.enumerateByteRangesUsingBlock:', + iOS: (false, (7, 0, 0)), macOS: (false, (10, 9, 0))); + _objc_msgSend_f167m6(this.ref.pointer, _sel_enumerateByteRangesUsingBlock_, + block.ref.pointer); + } + /// getBytes:length: void getBytes(ffi.Pointer<ffi.Void> buffer, {required int length}) { _objc_msgSend_zuf90e( @@ -3145,6 +3743,37 @@ return NSString.castFromPointer(_ret, retain: true, release: true); } + /// enumerateKeysAndObjectsUsingBlock: + void enumerateKeysAndObjectsUsingBlock( + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + block) { + objc.checkOsVersionInternal( + 'NSDictionary.enumerateKeysAndObjectsUsingBlock:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + _objc_msgSend_f167m6(this.ref.pointer, + _sel_enumerateKeysAndObjectsUsingBlock_, block.ref.pointer); + } + + /// enumerateKeysAndObjectsWithOptions:usingBlock: + void enumerateKeysAndObjectsWithOptions(NSEnumerationOptions opts, + {required objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal( + 'NSDictionary.enumerateKeysAndObjectsWithOptions:usingBlock:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + _objc_msgSend_yx8yc6( + this.ref.pointer, + _sel_enumerateKeysAndObjectsWithOptions_usingBlock_, + opts.value, + usingBlock.ref.pointer); + } + /// getObjects:andKeys:count: void getObjects(ffi.Pointer<ffi.Pointer<objc.ObjCObject>> objects, {required ffi.Pointer<ffi.Pointer<objc.ObjCObject>> andKeys, @@ -3161,6 +3790,52 @@ otherDictionary.ref.pointer); } + /// keysOfEntriesPassingTest: + NSSet keysOfEntriesPassingTest( + objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + predicate) { + objc.checkOsVersionInternal('NSDictionary.keysOfEntriesPassingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_nnxkei(this.ref.pointer, + _sel_keysOfEntriesPassingTest_, predicate.ref.pointer); + return NSSet.castFromPointer(_ret, retain: true, release: true); + } + + /// keysOfEntriesWithOptions:passingTest: + NSSet keysOfEntriesWithOptions(NSEnumerationOptions opts, + {required objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal( + 'NSDictionary.keysOfEntriesWithOptions:passingTest:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_13x5boi( + this.ref.pointer, + _sel_keysOfEntriesWithOptions_passingTest_, + opts.value, + passingTest.ref.pointer); + return NSSet.castFromPointer(_ret, retain: true, release: true); + } + + /// keysSortedByValueUsingComparator: + NSArray keysSortedByValueUsingComparator( + objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + cmptr) { + objc.checkOsVersionInternal( + 'NSDictionary.keysSortedByValueUsingComparator:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_nnxkei(this.ref.pointer, + _sel_keysSortedByValueUsingComparator_, cmptr.ref.pointer); + return NSArray.castFromPointer(_ret, retain: true, release: true); + } + /// keysSortedByValueUsingSelector: NSArray keysSortedByValueUsingSelector( ffi.Pointer<objc.ObjCSelector> comparator) { @@ -3169,6 +3844,24 @@ return NSArray.castFromPointer(_ret, retain: true, release: true); } + /// keysSortedByValueWithOptions:usingComparator: + NSArray keysSortedByValueWithOptions(NSSortOptions opts, + {required objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + usingComparator}) { + objc.checkOsVersionInternal( + 'NSDictionary.keysSortedByValueWithOptions:usingComparator:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_1x5ew3h( + this.ref.pointer, + _sel_keysSortedByValueWithOptions_usingComparator_, + opts.value, + usingComparator.ref.pointer); + return NSArray.castFromPointer(_ret, retain: true, release: true); + } + /// objectEnumerator NSEnumerator objectEnumerator() { final _ret = _objc_msgSend_151sglz(this.ref.pointer, _sel_objectEnumerator); @@ -3329,6 +4022,18 @@ obj.ref.pointer, atIndexedSubscript); } + /// sortUsingComparator: + void sortUsingComparator( + objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + cmptr) { + objc.checkOsVersionInternal('NSMutableArray.sortUsingComparator:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + _objc_msgSend_f167m6( + this.ref.pointer, _sel_sortUsingComparator_, cmptr.ref.pointer); + } + /// sortUsingFunction:context: void sortUsingFunction( ffi.Pointer< @@ -3346,6 +4051,23 @@ _objc_msgSend_1d9e4oe( this.ref.pointer, _sel_sortUsingSelector_, comparator); } + + /// sortWithOptions:usingComparator: + void sortWithOptions(NSSortOptions opts, + {required objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + usingComparator}) { + objc.checkOsVersionInternal( + 'NSMutableArray.sortWithOptions:usingComparator:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + _objc_msgSend_jjgvjt( + this.ref.pointer, + _sel_sortWithOptions_usingComparator_, + opts.value, + usingComparator.ref.pointer); + } } /// NSExtendedMutableData @@ -3600,6 +4322,54 @@ obj.ref.pointer, atIndexedSubscript); } + /// sortRange:options:usingComparator: + void sortRange(NSRange range, + {required NSSortOptions options, + required objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + usingComparator}) { + objc.checkOsVersionInternal( + 'NSMutableOrderedSet.sortRange:options:usingComparator:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + _objc_msgSend_arew0j( + this.ref.pointer, + _sel_sortRange_options_usingComparator_, + range, + options.value, + usingComparator.ref.pointer); + } + + /// sortUsingComparator: + void sortUsingComparator( + objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + cmptr) { + objc.checkOsVersionInternal('NSMutableOrderedSet.sortUsingComparator:', + iOS: (false, (5, 0, 0)), macOS: (false, (10, 7, 0))); + _objc_msgSend_f167m6( + this.ref.pointer, _sel_sortUsingComparator_, cmptr.ref.pointer); + } + + /// sortWithOptions:usingComparator: + void sortWithOptions(NSSortOptions opts, + {required objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + usingComparator}) { + objc.checkOsVersionInternal( + 'NSMutableOrderedSet.sortWithOptions:usingComparator:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + _objc_msgSend_jjgvjt( + this.ref.pointer, + _sel_sortWithOptions_usingComparator_, + opts.value, + usingComparator.ref.pointer); + } + /// unionOrderedSet: void unionOrderedSet(NSOrderedSet other) { objc.checkOsVersionInternal('NSMutableOrderedSet.unionOrderedSet:', @@ -3701,6 +4471,54 @@ return NSString.castFromPointer(_ret, retain: true, release: true); } + /// enumerateObjectsAtIndexes:options:usingBlock: + void enumerateObjectsAtIndexes(NSIndexSet s, + {required NSEnumerationOptions options, + required objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal( + 'NSOrderedSet.enumerateObjectsAtIndexes:options:usingBlock:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + _objc_msgSend_a3wp08( + this.ref.pointer, + _sel_enumerateObjectsAtIndexes_options_usingBlock_, + s.ref.pointer, + options.value, + usingBlock.ref.pointer); + } + + /// enumerateObjectsUsingBlock: + void enumerateObjectsUsingBlock( + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + block) { + objc.checkOsVersionInternal('NSOrderedSet.enumerateObjectsUsingBlock:', + iOS: (false, (5, 0, 0)), macOS: (false, (10, 7, 0))); + _objc_msgSend_f167m6( + this.ref.pointer, _sel_enumerateObjectsUsingBlock_, block.ref.pointer); + } + + /// enumerateObjectsWithOptions:usingBlock: + void enumerateObjectsWithOptions(NSEnumerationOptions opts, + {required objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal( + 'NSOrderedSet.enumerateObjectsWithOptions:usingBlock:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + _objc_msgSend_yx8yc6( + this.ref.pointer, + _sel_enumerateObjectsWithOptions_usingBlock_, + opts.value, + usingBlock.ref.pointer); + } + /// firstObject objc.ObjCObjectBase? get firstObject { objc.checkOsVersionInternal('NSOrderedSet.firstObject', @@ -3718,6 +4536,126 @@ this.ref.pointer, _sel_getObjects_range_, objects, range); } + /// indexOfObject:inSortedRange:options:usingComparator: + int indexOfObject(objc.ObjCObjectBase object, + {required NSRange inSortedRange, + required NSBinarySearchingOptions options, + required objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + usingComparator}) { + objc.checkOsVersionInternal( + 'NSOrderedSet.indexOfObject:inSortedRange:options:usingComparator:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + return _objc_msgSend_kshx9d( + this.ref.pointer, + _sel_indexOfObject_inSortedRange_options_usingComparator_, + object.ref.pointer, + inSortedRange, + options.value, + usingComparator.ref.pointer); + } + + /// indexOfObjectAtIndexes:options:passingTest: + int indexOfObjectAtIndexes(NSIndexSet s, + {required NSEnumerationOptions options, + required objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal( + 'NSOrderedSet.indexOfObjectAtIndexes:options:passingTest:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + return _objc_msgSend_k1x6mt( + this.ref.pointer, + _sel_indexOfObjectAtIndexes_options_passingTest_, + s.ref.pointer, + options.value, + passingTest.ref.pointer); + } + + /// indexOfObjectPassingTest: + int indexOfObjectPassingTest( + objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + predicate) { + objc.checkOsVersionInternal('NSOrderedSet.indexOfObjectPassingTest:', + iOS: (false, (5, 0, 0)), macOS: (false, (10, 7, 0))); + return _objc_msgSend_10mlopr(this.ref.pointer, + _sel_indexOfObjectPassingTest_, predicate.ref.pointer); + } + + /// indexOfObjectWithOptions:passingTest: + int indexOfObjectWithOptions(NSEnumerationOptions opts, + {required objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal( + 'NSOrderedSet.indexOfObjectWithOptions:passingTest:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + return _objc_msgSend_1698hqz( + this.ref.pointer, + _sel_indexOfObjectWithOptions_passingTest_, + opts.value, + passingTest.ref.pointer); + } + + /// indexesOfObjectsAtIndexes:options:passingTest: + NSIndexSet indexesOfObjectsAtIndexes(NSIndexSet s, + {required NSEnumerationOptions options, + required objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal( + 'NSOrderedSet.indexesOfObjectsAtIndexes:options:passingTest:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + final _ret = _objc_msgSend_1i9v144( + this.ref.pointer, + _sel_indexesOfObjectsAtIndexes_options_passingTest_, + s.ref.pointer, + options.value, + passingTest.ref.pointer); + return NSIndexSet.castFromPointer(_ret, retain: true, release: true); + } + + /// indexesOfObjectsPassingTest: + NSIndexSet indexesOfObjectsPassingTest( + objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + predicate) { + objc.checkOsVersionInternal('NSOrderedSet.indexesOfObjectsPassingTest:', + iOS: (false, (5, 0, 0)), macOS: (false, (10, 7, 0))); + final _ret = _objc_msgSend_nnxkei(this.ref.pointer, + _sel_indexesOfObjectsPassingTest_, predicate.ref.pointer); + return NSIndexSet.castFromPointer(_ret, retain: true, release: true); + } + + /// indexesOfObjectsWithOptions:passingTest: + NSIndexSet indexesOfObjectsWithOptions(NSEnumerationOptions opts, + {required objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal( + 'NSOrderedSet.indexesOfObjectsWithOptions:passingTest:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + final _ret = _objc_msgSend_13x5boi( + this.ref.pointer, + _sel_indexesOfObjectsWithOptions_passingTest_, + opts.value, + passingTest.ref.pointer); + return NSIndexSet.castFromPointer(_ret, retain: true, release: true); + } + /// intersectsOrderedSet: bool intersectsOrderedSet(NSOrderedSet other) { objc.checkOsVersionInternal('NSOrderedSet.intersectsOrderedSet:', @@ -3819,6 +4757,37 @@ final _ret = _objc_msgSend_151sglz(this.ref.pointer, _sel_set); return NSSet.castFromPointer(_ret, retain: true, release: true); } + + /// sortedArrayUsingComparator: + NSArray sortedArrayUsingComparator( + objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + cmptr) { + objc.checkOsVersionInternal('NSOrderedSet.sortedArrayUsingComparator:', + iOS: (false, (5, 0, 0)), macOS: (false, (10, 7, 0))); + final _ret = _objc_msgSend_nnxkei( + this.ref.pointer, _sel_sortedArrayUsingComparator_, cmptr.ref.pointer); + return NSArray.castFromPointer(_ret, retain: true, release: true); + } + + /// sortedArrayWithOptions:usingComparator: + NSArray sortedArrayWithOptions(NSSortOptions opts, + {required objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + usingComparator}) { + objc.checkOsVersionInternal( + 'NSOrderedSet.sortedArrayWithOptions:usingComparator:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + final _ret = _objc_msgSend_1x5ew3h( + this.ref.pointer, + _sel_sortedArrayWithOptions_usingComparator_, + opts.value, + usingComparator.ref.pointer); + return NSArray.castFromPointer(_ret, retain: true, release: true); + } } /// NSExtendedSet @@ -3856,6 +4825,33 @@ return NSString.castFromPointer(_ret, retain: true, release: true); } + /// enumerateObjectsUsingBlock: + void enumerateObjectsUsingBlock( + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + block) { + objc.checkOsVersionInternal('NSSet.enumerateObjectsUsingBlock:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + _objc_msgSend_f167m6( + this.ref.pointer, _sel_enumerateObjectsUsingBlock_, block.ref.pointer); + } + + /// enumerateObjectsWithOptions:usingBlock: + void enumerateObjectsWithOptions(NSEnumerationOptions opts, + {required objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal('NSSet.enumerateObjectsWithOptions:usingBlock:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + _objc_msgSend_yx8yc6( + this.ref.pointer, + _sel_enumerateObjectsWithOptions_usingBlock_, + opts.value, + usingBlock.ref.pointer); + } + /// intersectsSet: bool intersectsSet(NSSet otherSet) { return _objc_msgSend_19nvye5( @@ -3890,6 +4886,35 @@ withObject?.ref.pointer ?? ffi.nullptr); } + /// objectsPassingTest: + NSSet objectsPassingTest( + objc.ObjCBlock< + ffi.Bool Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + predicate) { + objc.checkOsVersionInternal('NSSet.objectsPassingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_nnxkei( + this.ref.pointer, _sel_objectsPassingTest_, predicate.ref.pointer); + return NSSet.castFromPointer(_ret, retain: true, release: true); + } + + /// objectsWithOptions:passingTest: + NSSet objectsWithOptions(NSEnumerationOptions opts, + {required objc.ObjCBlock< + ffi.Bool Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal('NSSet.objectsWithOptions:passingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_13x5boi( + this.ref.pointer, + _sel_objectsWithOptions_passingTest_, + opts.value, + passingTest.ref.pointer); + return NSSet.castFromPointer(_ret, retain: true, release: true); + } + /// setByAddingObject: NSSet setByAddingObject(objc.ObjCObjectBase anObject) { objc.checkOsVersionInternal('NSSet.setByAddingObject:', @@ -4124,6 +5149,92 @@ this.ref.pointer, _sel_encodeWithCoder_, coder.ref.pointer); } + /// enumerateIndexesInRange:options:usingBlock: + void enumerateIndexesInRange(NSRange range, + {required NSEnumerationOptions options, + required objc + .ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal( + 'NSIndexSet.enumerateIndexesInRange:options:usingBlock:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + _objc_msgSend_177cajs( + this.ref.pointer, + _sel_enumerateIndexesInRange_options_usingBlock_, + range, + options.value, + usingBlock.ref.pointer); + } + + /// enumerateIndexesUsingBlock: + void enumerateIndexesUsingBlock( + objc.ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + block) { + objc.checkOsVersionInternal('NSIndexSet.enumerateIndexesUsingBlock:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + _objc_msgSend_f167m6( + this.ref.pointer, _sel_enumerateIndexesUsingBlock_, block.ref.pointer); + } + + /// enumerateIndexesWithOptions:usingBlock: + void enumerateIndexesWithOptions(NSEnumerationOptions opts, + {required objc + .ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal( + 'NSIndexSet.enumerateIndexesWithOptions:usingBlock:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + _objc_msgSend_yx8yc6( + this.ref.pointer, + _sel_enumerateIndexesWithOptions_usingBlock_, + opts.value, + usingBlock.ref.pointer); + } + + /// enumerateRangesInRange:options:usingBlock: + void enumerateRangesInRange(NSRange range, + {required NSEnumerationOptions options, + required objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal( + 'NSIndexSet.enumerateRangesInRange:options:usingBlock:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + _objc_msgSend_177cajs( + this.ref.pointer, + _sel_enumerateRangesInRange_options_usingBlock_, + range, + options.value, + usingBlock.ref.pointer); + } + + /// enumerateRangesUsingBlock: + void enumerateRangesUsingBlock( + objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)> block) { + objc.checkOsVersionInternal('NSIndexSet.enumerateRangesUsingBlock:', + iOS: (false, (5, 0, 0)), macOS: (false, (10, 7, 0))); + _objc_msgSend_f167m6( + this.ref.pointer, _sel_enumerateRangesUsingBlock_, block.ref.pointer); + } + + /// enumerateRangesWithOptions:usingBlock: + void enumerateRangesWithOptions(NSEnumerationOptions opts, + {required objc + .ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal( + 'NSIndexSet.enumerateRangesWithOptions:usingBlock:', + iOS: (false, (5, 0, 0)), + macOS: (false, (10, 7, 0))); + _objc_msgSend_yx8yc6( + this.ref.pointer, + _sel_enumerateRangesWithOptions_usingBlock_, + opts.value, + usingBlock.ref.pointer); + } + /// firstIndex int get firstIndex { return _objc_msgSend_xw2lbc(this.ref.pointer, _sel_firstIndex); @@ -4152,6 +5263,22 @@ this.ref.pointer, _sel_indexGreaterThanOrEqualToIndex_, value); } + /// indexInRange:options:passingTest: + int indexInRange(NSRange range, + {required NSEnumerationOptions options, + required objc + .ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal('NSIndexSet.indexInRange:options:passingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + return _objc_msgSend_6jmuyz( + this.ref.pointer, + _sel_indexInRange_options_passingTest_, + range, + options.value, + passingTest.ref.pointer); + } + /// indexLessThanIndex: int indexLessThanIndex(int value) { return _objc_msgSend_12py2ux( @@ -4164,6 +5291,75 @@ this.ref.pointer, _sel_indexLessThanOrEqualToIndex_, value); } + /// indexPassingTest: + int indexPassingTest( + objc.ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + predicate) { + objc.checkOsVersionInternal('NSIndexSet.indexPassingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + return _objc_msgSend_10mlopr( + this.ref.pointer, _sel_indexPassingTest_, predicate.ref.pointer); + } + + /// indexWithOptions:passingTest: + int indexWithOptions(NSEnumerationOptions opts, + {required objc + .ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal('NSIndexSet.indexWithOptions:passingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + return _objc_msgSend_1698hqz( + this.ref.pointer, + _sel_indexWithOptions_passingTest_, + opts.value, + passingTest.ref.pointer); + } + + /// indexesInRange:options:passingTest: + NSIndexSet indexesInRange(NSRange range, + {required NSEnumerationOptions options, + required objc + .ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal( + 'NSIndexSet.indexesInRange:options:passingTest:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_1q30cs4( + this.ref.pointer, + _sel_indexesInRange_options_passingTest_, + range, + options.value, + passingTest.ref.pointer); + return NSIndexSet.castFromPointer(_ret, retain: true, release: true); + } + + /// indexesPassingTest: + NSIndexSet indexesPassingTest( + objc.ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + predicate) { + objc.checkOsVersionInternal('NSIndexSet.indexesPassingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_nnxkei( + this.ref.pointer, _sel_indexesPassingTest_, predicate.ref.pointer); + return NSIndexSet.castFromPointer(_ret, retain: true, release: true); + } + + /// indexesWithOptions:passingTest: + NSIndexSet indexesWithOptions(NSEnumerationOptions opts, + {required objc + .ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + passingTest}) { + objc.checkOsVersionInternal('NSIndexSet.indexesWithOptions:passingTest:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + final _ret = _objc_msgSend_13x5boi( + this.ref.pointer, + _sel_indexesWithOptions_passingTest_, + opts.value, + passingTest.ref.pointer); + return NSIndexSet.castFromPointer(_ret, retain: true, release: true); + } + /// init NSIndexSet init() { objc.checkOsVersionInternal('NSIndexSet.init', @@ -4584,6 +5780,55 @@ return NSItemProvider.castFromPointer(_ret, retain: false, release: true); } + /// loadDataRepresentationForTypeIdentifier:completionHandler: + NSProgress loadDataRepresentationForTypeIdentifier(NSString typeIdentifier, + {required objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)> + completionHandler}) { + objc.checkOsVersionInternal( + 'NSItemProvider.loadDataRepresentationForTypeIdentifier:completionHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0))); + final _ret = _objc_msgSend_r0bo0s( + this.ref.pointer, + _sel_loadDataRepresentationForTypeIdentifier_completionHandler_, + typeIdentifier.ref.pointer, + completionHandler.ref.pointer); + return NSProgress.castFromPointer(_ret, retain: true, release: true); + } + + /// loadFileRepresentationForTypeIdentifier:completionHandler: + NSProgress loadFileRepresentationForTypeIdentifier(NSString typeIdentifier, + {required objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)> + completionHandler}) { + objc.checkOsVersionInternal( + 'NSItemProvider.loadFileRepresentationForTypeIdentifier:completionHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0))); + final _ret = _objc_msgSend_r0bo0s( + this.ref.pointer, + _sel_loadFileRepresentationForTypeIdentifier_completionHandler_, + typeIdentifier.ref.pointer, + completionHandler.ref.pointer); + return NSProgress.castFromPointer(_ret, retain: true, release: true); + } + + /// loadInPlaceFileRepresentationForTypeIdentifier:completionHandler: + NSProgress loadInPlaceFileRepresentationForTypeIdentifier( + NSString typeIdentifier, + {required objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)> + completionHandler}) { + objc.checkOsVersionInternal( + 'NSItemProvider.loadInPlaceFileRepresentationForTypeIdentifier:completionHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0))); + final _ret = _objc_msgSend_r0bo0s( + this.ref.pointer, + _sel_loadInPlaceFileRepresentationForTypeIdentifier_completionHandler_, + typeIdentifier.ref.pointer, + completionHandler.ref.pointer); + return NSProgress.castFromPointer(_ret, retain: true, release: true); + } + /// loadItemForTypeIdentifier:options:completionHandler: void loadItemForTypeIdentifier(NSString typeIdentifier, {NSDictionary? options, @@ -4601,6 +5846,85 @@ completionHandler?.ref.pointer ?? ffi.nullptr); } + /// loadObjectOfClass:completionHandler: + NSProgress loadObjectOfClass(NSItemProviderReading aClass, + {required objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> + completionHandler}) { + objc.checkOsVersionInternal( + 'NSItemProvider.loadObjectOfClass:completionHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0))); + final _ret = _objc_msgSend_r0bo0s( + this.ref.pointer, + _sel_loadObjectOfClass_completionHandler_, + aClass.ref.pointer, + completionHandler.ref.pointer); + return NSProgress.castFromPointer(_ret, retain: true, release: true); + } + + /// registerDataRepresentationForTypeIdentifier:visibility:loadHandler: + void registerDataRepresentationForTypeIdentifier(NSString typeIdentifier, + {required NSItemProviderRepresentationVisibility visibility, + required objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)> + loadHandler}) { + objc.checkOsVersionInternal( + 'NSItemProvider.registerDataRepresentationForTypeIdentifier:visibility:loadHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0))); + _objc_msgSend_1pl40xc( + this.ref.pointer, + _sel_registerDataRepresentationForTypeIdentifier_visibility_loadHandler_, + typeIdentifier.ref.pointer, + visibility.value, + loadHandler.ref.pointer); + } + + /// registerFileRepresentationForTypeIdentifier:fileOptions:visibility:loadHandler: + void registerFileRepresentationForTypeIdentifier(NSString typeIdentifier, + {required NSItemProviderFileOptions fileOptions, + required NSItemProviderRepresentationVisibility visibility, + required objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock< + ffi.Void Function(NSURL?, ffi.Bool, NSError?)>)> + loadHandler}) { + objc.checkOsVersionInternal( + 'NSItemProvider.registerFileRepresentationForTypeIdentifier:fileOptions:visibility:loadHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0))); + _objc_msgSend_t7arir( + this.ref.pointer, + _sel_registerFileRepresentationForTypeIdentifier_fileOptions_visibility_loadHandler_, + typeIdentifier.ref.pointer, + fileOptions.value, + visibility.value, + loadHandler.ref.pointer); + } + + /// registerItemForTypeIdentifier:loadHandler: + void registerItemForTypeIdentifier(NSString typeIdentifier, + {required objc.ObjCBlock< + ffi.Void Function( + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>?, NSError)>, + ffi.Pointer<objc.ObjCObject>, + NSDictionary)> + loadHandler}) { + objc.checkOsVersionInternal( + 'NSItemProvider.registerItemForTypeIdentifier:loadHandler:', + iOS: (false, (8, 0, 0)), + macOS: (false, (10, 10, 0))); + _objc_msgSend_o762yo( + this.ref.pointer, + _sel_registerItemForTypeIdentifier_loadHandler_, + typeIdentifier.ref.pointer, + loadHandler.ref.pointer); + } + /// registerObject:visibility: void registerObject(NSItemProviderWriting object, {required NSItemProviderRepresentationVisibility visibility}) { @@ -4610,6 +5934,27 @@ object.ref.pointer, visibility.value); } + /// registerObjectOfClass:visibility:loadHandler: + void registerObjectOfClass(NSItemProviderWriting aClass, + {required NSItemProviderRepresentationVisibility visibility, + required objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>?, NSError?)>)> + loadHandler}) { + objc.checkOsVersionInternal( + 'NSItemProvider.registerObjectOfClass:visibility:loadHandler:', + iOS: (false, (11, 0, 0)), + macOS: (false, (10, 13, 0))); + _objc_msgSend_1pl40xc( + this.ref.pointer, + _sel_registerObjectOfClass_visibility_loadHandler_, + aClass.ref.pointer, + visibility.value, + loadHandler.ref.pointer); + } + /// registeredTypeIdentifiers NSArray get registeredTypeIdentifiers { objc.checkOsVersionInternal('NSItemProvider.registeredTypeIdentifiers', @@ -4782,6 +6127,9 @@ static NSItemProviderWriting implement( {NSItemProviderRepresentationVisibility Function(NSString)? itemProviderVisibilityForRepresentationWithTypeIdentifier_, + required NSProgress? Function( + NSString, objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>) + loadDataWithTypeIdentifier_forItemProviderCompletionHandler_, NSArray Function()? writableTypeIdentifiersForItemProvider, bool $keepIsolateAlive = true}) { final builder = @@ -4790,6 +6138,10 @@ .itemProviderVisibilityForRepresentationWithTypeIdentifier_ .implement(builder, itemProviderVisibilityForRepresentationWithTypeIdentifier_); + NSItemProviderWriting + .loadDataWithTypeIdentifier_forItemProviderCompletionHandler_ + .implement(builder, + loadDataWithTypeIdentifier_forItemProviderCompletionHandler_); NSItemProviderWriting.writableTypeIdentifiersForItemProvider .implement(builder, writableTypeIdentifiersForItemProvider); builder.addProtocol($protocol); @@ -4804,12 +6156,19 @@ static void addToBuilder(objc.ObjCProtocolBuilder builder, {NSItemProviderRepresentationVisibility Function(NSString)? itemProviderVisibilityForRepresentationWithTypeIdentifier_, + required NSProgress? Function( + NSString, objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>) + loadDataWithTypeIdentifier_forItemProviderCompletionHandler_, NSArray Function()? writableTypeIdentifiersForItemProvider, bool $keepIsolateAlive = true}) { NSItemProviderWriting .itemProviderVisibilityForRepresentationWithTypeIdentifier_ .implement(builder, itemProviderVisibilityForRepresentationWithTypeIdentifier_); + NSItemProviderWriting + .loadDataWithTypeIdentifier_forItemProviderCompletionHandler_ + .implement(builder, + loadDataWithTypeIdentifier_forItemProviderCompletionHandler_); NSItemProviderWriting.writableTypeIdentifiersForItemProvider .implement(builder, writableTypeIdentifiersForItemProvider); builder.addProtocol($protocol); @@ -4839,6 +6198,39 @@ (ffi.Pointer<ffi.Void> _, NSString arg1) => func(arg1)), ); + /// loadDataWithTypeIdentifier:forItemProviderCompletionHandler: + static final loadDataWithTypeIdentifier_forItemProviderCompletionHandler_ = + objc.ObjCProtocolMethod< + NSProgress? Function( + NSString, objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>( + _protocol_NSItemProviderWriting, + _sel_loadDataWithTypeIdentifier_forItemProviderCompletionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>>( + _ObjectiveCBindings_protocolTrampoline_1q0i84) + .cast(), + objc.getProtocolMethodSignature( + _protocol_NSItemProviderWriting, + _sel_loadDataWithTypeIdentifier_forItemProviderCompletionHandler_, + isRequired: true, + isInstanceMethod: true, + ), + (NSProgress? Function( + NSString, objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>) + func) => + ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError.fromFunction( + (ffi.Pointer<ffi.Void> _, + NSString arg1, + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)> + arg2) => + func(arg1, arg2)), + ); + /// writableTypeIdentifiersForItemProvider static final writableTypeIdentifiersForItemProvider = objc.ObjCProtocolMethod<NSArray Function()>( @@ -5186,41 +6578,7 @@ } /// NSMutableArray -class NSMutableArray extends NSArray with ListBase<objc.ObjCObjectBase> { - /// Creates a [NSMutableArray] of the given length with [fill] at each - /// position. - /// - /// The [length] must be a non-negative integer. - static NSMutableArray filled(int length, objc.ObjCObjectBase fill) { - final a = arrayWithCapacity(length); - for (var i = 0; i < length; ++i) a.add(fill); - return a; - } - - /// Creates a [NSMutableArray] from [elements]. - static NSMutableArray of(Iterable<objc.ObjCObjectBase> elements) => - arrayWithCapacity(elements.length)..addAll(elements); - - @override - set length(int newLength) { - var len = length; - RangeError.checkValueInInterval(newLength, 0, len); - for (; len > newLength; --len) removeLastObject(); - } - - @override - Iterator<objc.ObjCObjectBase> get iterator => _NSArrayIterator(this); - - @override - objc.ObjCObjectBase operator [](int index) => objectAtIndex(index); - - @override - void operator []=(int index, objc.ObjCObjectBase value) => - replaceObjectAtIndex(index, withObject: value); - - @override - void add(objc.ObjCObjectBase value) => addObject(value); - +class NSMutableArray extends NSArray { NSMutableArray._(ffi.Pointer<objc.ObjCObject> pointer, {bool retain = false, bool release = false}) : super.castFromPointer(pointer, retain: retain, release: release); @@ -5724,8 +7082,27 @@ return NSMutableData.castFromPointer(_ret, retain: false, release: true); } - /// initWithBytesNoCopy:length:freeWhenDone: + /// initWithBytesNoCopy:length:deallocator: NSMutableData initWithBytesNoCopy$1(ffi.Pointer<ffi.Void> bytes$1, + {required int length, + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>? + deallocator}) { + objc.checkOsVersionInternal( + 'NSMutableData.initWithBytesNoCopy:length:deallocator:', + iOS: (false, (7, 0, 0)), + macOS: (false, (10, 9, 0))); + final _ret = _objc_msgSend_134vhyh( + this.ref.retainAndReturnPointer(), + _sel_initWithBytesNoCopy_length_deallocator_, + bytes$1, + length, + deallocator?.ref.pointer ?? ffi.nullptr); + return NSMutableData.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithBytesNoCopy:length:freeWhenDone: + NSMutableData initWithBytesNoCopy$2(ffi.Pointer<ffi.Void> bytes$1, {required int length, required bool freeWhenDone}) { final _ret = _objc_msgSend_161ne8y( this.ref.retainAndReturnPointer(), @@ -5839,31 +7216,6 @@ /// NSMutableDictionary class NSMutableDictionary extends NSDictionary { - /// Creates a [NSMutableDictionary] from [other]. - static NSDictionary of(Map<NSCopying, objc.ObjCObjectBase> other) => - NSMutableDictionary.dictionaryWithCapacity(other.length)..addAll(other); - - /// Creates a [NSMutableDictionary] from [entries]. - static NSMutableDictionary fromEntries( - Iterable<MapEntry<NSCopying, objc.ObjCObjectBase>> entries) => - NSMutableDictionary.dictionaryWithCapacity(entries.length) - ..addEntries(entries); - - @override - void clear() => removeAllObjects(); - - @override - objc.ObjCObjectBase? remove(Object? key) { - if (key is! NSCopying) return null; - final old = this[key]; - removeObjectForKey(key); - return old; - } - - @override - void operator []=(NSCopying key, objc.ObjCObjectBase value) => - setObject(value, forKey: NSCopying.castFrom(key)); - NSMutableDictionary._(ffi.Pointer<objc.ObjCObject> pointer, {bool retain = false, bool release = false}) : super.castFromPointer(pointer, retain: retain, release: release); @@ -6608,28 +7960,6 @@ /// NSMutableSet class NSMutableSet extends NSSet { - /// Creates a [NSMutableSet] from [elements]. - static NSMutableSet of(Iterable<objc.ObjCObjectBase> elements) => - setWithCapacity(elements.length)..addAll(elements); - - @override - bool add(objc.ObjCObjectBase value) { - final alreadyContains = contains(value); - addObject(value); - return !alreadyContains; - } - - @override - bool remove(Object? value) { - if (value is! objc.ObjCObjectBase) return false; - final alreadyContains = contains(value); - removeObject(value); - return alreadyContains; - } - - @override - void clear() => removeAllObjects(); - NSMutableSet._(ffi.Pointer<objc.ObjCObject> pointer, {bool retain = false, bool release = false}) : super.castFromPointer(pointer, retain: retain, release: release); @@ -7044,10 +8374,29 @@ : NSMutableString.castFromPointer(_ret, retain: false, release: true); } - /// initWithBytesNoCopy:length:encoding:freeWhenDone: + /// initWithBytesNoCopy:length:encoding:deallocator: NSMutableString? initWithBytesNoCopy(ffi.Pointer<ffi.Void> bytes, {required int length, required int encoding, + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>? + deallocator}) { + final _ret = _objc_msgSend_1lbgrac( + this.ref.retainAndReturnPointer(), + _sel_initWithBytesNoCopy_length_encoding_deallocator_, + bytes, + length, + encoding, + deallocator?.ref.pointer ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSMutableString.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithBytesNoCopy:length:encoding:freeWhenDone: + NSMutableString? initWithBytesNoCopy$1(ffi.Pointer<ffi.Void> bytes, + {required int length, + required int encoding, required bool freeWhenDone}) { final _ret = _objc_msgSend_k4j8m3( this.ref.retainAndReturnPointer(), @@ -7079,8 +8428,24 @@ return NSMutableString.castFromPointer(_ret, retain: false, release: true); } + /// initWithCharactersNoCopy:length:deallocator: + NSMutableString initWithCharactersNoCopy(ffi.Pointer<ffi.UnsignedShort> chars, + {required int length, + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)>? + deallocator}) { + final _ret = _objc_msgSend_talwei( + this.ref.retainAndReturnPointer(), + _sel_initWithCharactersNoCopy_length_deallocator_, + chars, + length, + deallocator?.ref.pointer ?? ffi.nullptr); + return NSMutableString.castFromPointer(_ret, retain: false, release: true); + } + /// initWithCharactersNoCopy:length:freeWhenDone: - NSMutableString initWithCharactersNoCopy( + NSMutableString initWithCharactersNoCopy$1( ffi.Pointer<ffi.UnsignedShort> characters, {required int length, required bool freeWhenDone}) { @@ -9088,6 +10453,31 @@ ); } +/// WARNING: NSOrderedCollectionChange is a stub. To generate bindings for this class, include +/// NSOrderedCollectionChange in your config's objc-interfaces list. +/// +/// NSOrderedCollectionChange +/// +/// iOS: introduced 13.0.0 +/// macOS: introduced 10.15.0 +class NSOrderedCollectionChange extends NSObject { + NSOrderedCollectionChange._(ffi.Pointer<objc.ObjCObject> pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release) { + objc.checkOsVersionInternal('NSOrderedCollectionChange', + iOS: (false, (13, 0, 0)), macOS: (false, (10, 15, 0))); + } + + /// Constructs a [NSOrderedCollectionChange] that points to the same underlying object as [other]. + NSOrderedCollectionChange.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [NSOrderedCollectionChange] that wraps the given raw object pointer. + NSOrderedCollectionChange.castFromPointer(ffi.Pointer<objc.ObjCObject> other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); +} + /// NSOrderedCollectionDifference /// /// iOS: introduced 13.0.0 @@ -9154,6 +10544,24 @@ count$1); } + /// differenceByTransformingChangesWithBlock: + /// + /// iOS: introduced 13.0.0 + /// macOS: introduced 10.15.0 + NSOrderedCollectionDifference differenceByTransformingChangesWithBlock( + objc.ObjCBlock< + NSOrderedCollectionChange Function(NSOrderedCollectionChange)> + block) { + objc.checkOsVersionInternal( + 'NSOrderedCollectionDifference.differenceByTransformingChangesWithBlock:', + iOS: (false, (13, 0, 0)), + macOS: (false, (10, 15, 0))); + final _ret = _objc_msgSend_nnxkei(this.ref.pointer, + _sel_differenceByTransformingChangesWithBlock_, block.ref.pointer); + return NSOrderedCollectionDifference.castFromPointer(_ret, + retain: true, release: true); + } + /// iOS: introduced 13.0.0 /// macOS: introduced 10.15.0 bool get hasChanges { @@ -10153,6 +11561,25 @@ factory NSPortMessage() => new$(); } +/// WARNING: NSProgress is a stub. To generate bindings for this class, include +/// NSProgress in your config's objc-interfaces list. +/// +/// NSProgress +class NSProgress extends NSObject { + NSProgress._(ffi.Pointer<objc.ObjCObject> pointer, + {bool retain = false, bool release = false}) + : super.castFromPointer(pointer, retain: retain, release: release); + + /// Constructs a [NSProgress] that points to the same underlying object as [other]. + NSProgress.castFrom(objc.ObjCObjectBase other) + : this._(other.ref.pointer, retain: true, release: true); + + /// Constructs a [NSProgress] that wraps the given raw object pointer. + NSProgress.castFromPointer(ffi.Pointer<objc.ObjCObject> other, + {bool retain = false, bool release = false}) + : this._(other, retain: retain, release: release); +} + enum NSPropertyListFormat { NSPropertyListOpenStepFormat(1), NSPropertyListXMLFormat_v1_0(100), @@ -10505,39 +11932,7 @@ /// NSSet class NSSet extends NSObject - with SetBase<objc.ObjCObjectBase> implements NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration { - /// Creates a [NSSet] from [elements]. - static NSSet of(Iterable<objc.ObjCObjectBase> elements) => - NSMutableSet.of(elements); - - @override - int get length => count; - - @override - bool contains(Object? element) => - element is objc.ObjCObjectBase ? containsObject(element) : false; - - @override - objc.ObjCObjectBase? lookup(Object? element) => - element is objc.ObjCObjectBase ? member(element) : null; - - @override - Iterator<objc.ObjCObjectBase> get iterator => objectEnumerator(); - - @override - Set<objc.ObjCObjectBase> toSet() => {...this}; - - @override - bool add(objc.ObjCObjectBase value) => - throw UnsupportedError("Cannot modify NSSet"); - - @override - bool remove(Object? value) => throw UnsupportedError("Cannot modify NSSet"); - - @override - void clear() => throw UnsupportedError("Cannot modify NSSet"); - NSSet._(ffi.Pointer<objc.ObjCObject> pointer, {bool retain = false, bool release = false}) : super.castFromPointer(pointer, retain: retain, release: release); @@ -11069,13 +12464,6 @@ /// NSString class NSString extends NSObject implements NSCopying, NSMutableCopying, NSSecureCoding { - factory NSString(String str) { - final cstr = str.toNativeUtf16(); - final nsstr = stringWithCharacters(cstr.cast(), length: str.length); - pkg_ffi.calloc.free(cstr); - return nsstr; - } - NSString._(ffi.Pointer<objc.ObjCObject> pointer, {bool retain = false, bool release = false}) : super.castFromPointer(pointer, retain: retain, release: release); @@ -11329,10 +12717,29 @@ : NSString.castFromPointer(_ret, retain: false, release: true); } - /// initWithBytesNoCopy:length:encoding:freeWhenDone: + /// initWithBytesNoCopy:length:encoding:deallocator: NSString? initWithBytesNoCopy(ffi.Pointer<ffi.Void> bytes, {required int length, required int encoding, + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>? + deallocator}) { + final _ret = _objc_msgSend_1lbgrac( + this.ref.retainAndReturnPointer(), + _sel_initWithBytesNoCopy_length_encoding_deallocator_, + bytes, + length, + encoding, + deallocator?.ref.pointer ?? ffi.nullptr); + return _ret.address == 0 + ? null + : NSString.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithBytesNoCopy:length:encoding:freeWhenDone: + NSString? initWithBytesNoCopy$1(ffi.Pointer<ffi.Void> bytes, + {required int length, + required int encoding, required bool freeWhenDone}) { final _ret = _objc_msgSend_k4j8m3( this.ref.retainAndReturnPointer(), @@ -11364,8 +12771,24 @@ return NSString.castFromPointer(_ret, retain: false, release: true); } + /// initWithCharactersNoCopy:length:deallocator: + NSString initWithCharactersNoCopy(ffi.Pointer<ffi.UnsignedShort> chars, + {required int length, + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)>? + deallocator}) { + final _ret = _objc_msgSend_talwei( + this.ref.retainAndReturnPointer(), + _sel_initWithCharactersNoCopy_length_deallocator_, + chars, + length, + deallocator?.ref.pointer ?? ffi.nullptr); + return NSString.castFromPointer(_ret, retain: false, release: true); + } + /// initWithCharactersNoCopy:length:freeWhenDone: - NSString initWithCharactersNoCopy(ffi.Pointer<ffi.UnsignedShort> characters, + NSString initWithCharactersNoCopy$1(ffi.Pointer<ffi.UnsignedShort> characters, {required int length, required bool freeWhenDone}) { final _ret = _objc_msgSend_lh0jh5( this.ref.retainAndReturnPointer(), @@ -11815,6 +13238,35 @@ : _objc_msgSend_1ukqyt8(this.ref.pointer, _sel_doubleValue); } + /// enumerateLinesUsingBlock: + void enumerateLinesUsingBlock( + objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)> + block) { + objc.checkOsVersionInternal('NSString.enumerateLinesUsingBlock:', + iOS: (false, (4, 0, 0)), macOS: (false, (10, 6, 0))); + _objc_msgSend_f167m6( + this.ref.pointer, _sel_enumerateLinesUsingBlock_, block.ref.pointer); + } + + /// enumerateSubstringsInRange:options:usingBlock: + void enumerateSubstringsInRange(NSRange range, + {required NSStringEnumerationOptions options, + required objc.ObjCBlock< + ffi.Void Function( + NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)> + usingBlock}) { + objc.checkOsVersionInternal( + 'NSString.enumerateSubstringsInRange:options:usingBlock:', + iOS: (false, (4, 0, 0)), + macOS: (false, (10, 6, 0))); + _objc_msgSend_14ew8zr( + this.ref.pointer, + _sel_enumerateSubstringsInRange_options_usingBlock_, + range, + options.value, + usingBlock.ref.pointer); + } + /// fastestEncoding int get fastestEncoding { return _objc_msgSend_xw2lbc(this.ref.pointer, _sel_fastestEncoding); @@ -12498,8 +13950,25 @@ return NSTimer.castFromPointer(_ret, retain: true, release: true); } + /// scheduledTimerWithTimeInterval:repeats:block: + static NSTimer scheduledTimerWithTimeInterval$1(double interval, + {required bool repeats, + required objc.ObjCBlock<ffi.Void Function(NSTimer)> block}) { + objc.checkOsVersionInternal( + 'NSTimer.scheduledTimerWithTimeInterval:repeats:block:', + iOS: (false, (10, 0, 0)), + macOS: (false, (10, 12, 0))); + final _ret = _objc_msgSend_9a64f1( + _class_NSTimer, + _sel_scheduledTimerWithTimeInterval_repeats_block_, + interval, + repeats, + block.ref.pointer); + return NSTimer.castFromPointer(_ret, retain: true, release: true); + } + /// scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: - static NSTimer scheduledTimerWithTimeInterval$1(double ti, + static NSTimer scheduledTimerWithTimeInterval$2(double ti, {required objc.ObjCObjectBase target, required ffi.Pointer<objc.ObjCSelector> selector, objc.ObjCObjectBase? userInfo, @@ -12527,8 +13996,23 @@ return NSTimer.castFromPointer(_ret, retain: true, release: true); } + /// timerWithTimeInterval:repeats:block: + static NSTimer timerWithTimeInterval$1(double interval, + {required bool repeats, + required objc.ObjCBlock<ffi.Void Function(NSTimer)> block}) { + objc.checkOsVersionInternal('NSTimer.timerWithTimeInterval:repeats:block:', + iOS: (false, (10, 0, 0)), macOS: (false, (10, 12, 0))); + final _ret = _objc_msgSend_9a64f1( + _class_NSTimer, + _sel_timerWithTimeInterval_repeats_block_, + interval, + repeats, + block.ref.pointer); + return NSTimer.castFromPointer(_ret, retain: true, release: true); + } + /// timerWithTimeInterval:target:selector:userInfo:repeats: - static NSTimer timerWithTimeInterval$1(double ti, + static NSTimer timerWithTimeInterval$2(double ti, {required objc.ObjCObjectBase target, required ffi.Pointer<objc.ObjCSelector> selector, objc.ObjCObjectBase? userInfo, @@ -12570,9 +14054,28 @@ return NSTimer.castFromPointer(_ret, retain: false, release: true); } - /// initWithFireDate:interval:target:selector:userInfo:repeats: + /// initWithFireDate:interval:repeats:block: NSTimer initWithFireDate(NSDate date, {required double interval, + required bool repeats, + required objc.ObjCBlock<ffi.Void Function(NSTimer)> block}) { + objc.checkOsVersionInternal( + 'NSTimer.initWithFireDate:interval:repeats:block:', + iOS: (false, (10, 0, 0)), + macOS: (false, (10, 12, 0))); + final _ret = _objc_msgSend_1s0rfm3( + this.ref.retainAndReturnPointer(), + _sel_initWithFireDate_interval_repeats_block_, + date.ref.pointer, + interval, + repeats, + block.ref.pointer); + return NSTimer.castFromPointer(_ret, retain: false, release: true); + } + + /// initWithFireDate:interval:target:selector:userInfo:repeats: + NSTimer initWithFireDate$1(NSDate date, + {required double interval, required objc.ObjCObjectBase target, required ffi.Pointer<objc.ObjCSelector> selector, objc.ObjCObjectBase? userInfo, @@ -13736,6 +15239,119 @@ release: true); } +int _ObjCBlock_NSComparisonResult_objcObjCObject_objcObjCObject_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Long Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + int Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSComparisonResult_objcObjCObject_objcObjCObject_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Long Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_NSComparisonResult_objcObjCObject_objcObjCObject_fnPtrTrampoline, + 0) + .cast(); +int _ObjCBlock_NSComparisonResult_objcObjCObject_objcObjCObject_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + (objc.getBlockClosure(block) as int Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSComparisonResult_objcObjCObject_objcObjCObject_closureCallable = + ffi.Pointer.fromFunction< + ffi.Long Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_NSComparisonResult_objcObjCObject_objcObjCObject_closureTrampoline, + 0) + .cast(); + +/// Construction methods for `objc.ObjCBlock<ffi.Long Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)>`. +abstract final class ObjCBlock_NSComparisonResult_objcObjCObject_objcObjCObject { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Long Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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.Long Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + fromFunctionPointer(ffi.Pointer<ffi.NativeFunction<ffi.Long Function(ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1)>> ptr) => + objc.ObjCBlock< + ffi.Long Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + objc.newPointerBlock( + _ObjCBlock_NSComparisonResult_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Long Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + fromFunction(NSComparisonResult Function(objc.ObjCObjectBase, objc.ObjCObjectBase) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Long Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)>( + objc.newClosureBlock( + _ObjCBlock_NSComparisonResult_objcObjCObject_objcObjCObject_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn(objc.ObjCObjectBase(arg0, retain: true, release: true), objc.ObjCObjectBase(arg1, retain: true, release: true)).value, + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<ffi.Long Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)>`. +extension ObjCBlock_NSComparisonResult_objcObjCObject_objcObjCObject_CallExtension + on objc.ObjCBlock< + ffi.Long Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> { + NSComparisonResult call(objc.ObjCObjectBase arg0, objc.ObjCObjectBase arg1) => + NSComparisonResult.fromValue(ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + int Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()( + ref.pointer, arg0.ref.pointer, arg1.ref.pointer)); +} + int _ObjCBlock_NSItemProviderRepresentationVisibility_ffiVoid_NSString_fnPtrTrampoline( ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<ffi.Void> arg0, @@ -13840,6 +15456,712 @@ ref.pointer, arg0, arg1.ref.pointer)); } +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_NSOrderedCollectionChange_NSOrderedCollectionChange_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject> arg0)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>)>()(arg0); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSOrderedCollectionChange_NSOrderedCollectionChange_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_NSOrderedCollectionChange_NSOrderedCollectionChange_fnPtrTrampoline) + .cast(); +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_NSOrderedCollectionChange_NSOrderedCollectionChange_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0) => + (objc.getBlockClosure(block) as ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>))(arg0); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSOrderedCollectionChange_NSOrderedCollectionChange_closureCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_NSOrderedCollectionChange_NSOrderedCollectionChange_closureTrampoline) + .cast(); + +/// Construction methods for `objc.ObjCBlock<NSOrderedCollectionChange Function(NSOrderedCollectionChange)>`. +abstract final class ObjCBlock_NSOrderedCollectionChange_NSOrderedCollectionChange { + /// Returns a block that wraps the given raw block pointer. + static objc + .ObjCBlock<NSOrderedCollectionChange Function(NSOrderedCollectionChange)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + NSOrderedCollectionChange Function( + NSOrderedCollectionChange)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<NSOrderedCollectionChange Function(NSOrderedCollectionChange)> + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject> arg0)>> + ptr) => + objc.ObjCBlock< + NSOrderedCollectionChange Function(NSOrderedCollectionChange)>( + objc.newPointerBlock( + _ObjCBlock_NSOrderedCollectionChange_NSOrderedCollectionChange_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + NSOrderedCollectionChange Function(NSOrderedCollectionChange)> fromFunction( + NSOrderedCollectionChange Function(NSOrderedCollectionChange) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<NSOrderedCollectionChange Function(NSOrderedCollectionChange)>( + objc.newClosureBlock( + _ObjCBlock_NSOrderedCollectionChange_NSOrderedCollectionChange_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0) => + fn(NSOrderedCollectionChange.castFromPointer(arg0, retain: true, release: true)) + .ref + .retainAndAutorelease(), + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<NSOrderedCollectionChange Function(NSOrderedCollectionChange)>`. +extension ObjCBlock_NSOrderedCollectionChange_NSOrderedCollectionChange_CallExtension + on objc + .ObjCBlock<NSOrderedCollectionChange Function(NSOrderedCollectionChange)> { + NSOrderedCollectionChange call(NSOrderedCollectionChange arg0) => + NSOrderedCollectionChange.castFromPointer( + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>)>()( + ref.pointer, arg0.ref.pointer), + retain: true, + release: true); +} + +ffi.Pointer<objc.ObjCBlockImpl> + _ObjCBlock_NSProgressUnpublishingHandler_NSProgress_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCObject> arg0)>>() + .asFunction< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCObject>)>()(arg0); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSProgressUnpublishingHandler_NSProgress_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_NSProgressUnpublishingHandler_NSProgress_fnPtrTrampoline) + .cast(); +ffi.Pointer<objc.ObjCBlockImpl> + _ObjCBlock_NSProgressUnpublishingHandler_NSProgress_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0) => + (objc.getBlockClosure(block) as ffi.Pointer<objc.ObjCBlockImpl> + Function(ffi.Pointer<objc.ObjCObject>))(arg0); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSProgressUnpublishingHandler_NSProgress_closureCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_NSProgressUnpublishingHandler_NSProgress_closureTrampoline) + .cast(); + +/// Construction methods for `objc.ObjCBlock<objc.ObjCBlock<ffi.Void Function()>? Function(NSProgress)>`. +abstract final class ObjCBlock_NSProgressUnpublishingHandler_NSProgress { + /// Returns a block that wraps the given raw block pointer. + static objc + .ObjCBlock<objc.ObjCBlock<ffi.Void Function()>? Function(NSProgress)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + objc.ObjCBlock<ffi.Void Function()>? Function( + NSProgress)>(pointer, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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.ObjCBlock<ffi.Void Function()>? Function(NSProgress)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCObject> arg0)>> + ptr) => + objc.ObjCBlock<objc.ObjCBlock<ffi.Void Function()>? Function(NSProgress)>( + objc.newPointerBlock( + _ObjCBlock_NSProgressUnpublishingHandler_NSProgress_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<objc.ObjCBlock<ffi.Void Function()>? Function(NSProgress)> + fromFunction(objc.ObjCBlock<ffi.Void Function()>? Function(NSProgress) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<objc.ObjCBlock<ffi.Void Function()>? Function(NSProgress)>( + objc.newClosureBlock( + _ObjCBlock_NSProgressUnpublishingHandler_NSProgress_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0) => + fn(NSProgress.castFromPointer(arg0, retain: true, release: true)) + ?.ref + .retainAndAutorelease() ?? + ffi.nullptr, + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<objc.ObjCBlock<ffi.Void Function()>? Function(NSProgress)>`. +extension ObjCBlock_NSProgressUnpublishingHandler_NSProgress_CallExtension + on objc + .ObjCBlock<objc.ObjCBlock<ffi.Void Function()>? Function(NSProgress)> { + objc.ObjCBlock<ffi.Void Function()>? call(NSProgress arg0) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0)>>() + .asFunction<ffi.Pointer<objc.ObjCBlockImpl> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCObject>)>() + (ref.pointer, arg0.ref.pointer) + .address == + 0 + ? null + : ObjCBlock_ffiVoid.castFromPointer( + ref.pointer.ref.invoke + .cast<ffi.NativeFunction<ffi.Pointer<objc.ObjCBlockImpl> Function(ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<objc.ObjCObject> arg0)>>() + .asFunction<ffi.Pointer<objc.ObjCBlockImpl> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCObject>)>()(ref.pointer, arg0.ref.pointer), + retain: true, + release: true); +} + +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> arg0) => + block.ref.target + .cast< + ffi + .NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl> arg0)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>()(arg0); +ffi.Pointer<ffi.Void> _ObjCBlock_NSProgress_ffiVoidNSDataNSError_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>)>( + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_fnPtrTrampoline) + .cast(); +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> arg0) => + (objc.getBlockClosure(block) as ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>))(arg0); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>)>( + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureTrampoline) + .cast(); + +/// Construction methods for `objc.ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>`. +abstract final class ObjCBlock_NSProgress_ffiVoidNSDataNSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)> + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl> arg0)>> + ptr) => + objc.ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>( + objc.newPointerBlock(_ObjCBlock_NSProgress_ffiVoidNSDataNSError_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)> + fromFunction(NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>( + objc.newClosureBlock( + _ObjCBlock_NSProgress_ffiVoidNSDataNSError_closureCallable, + (ffi.Pointer<objc.ObjCBlockImpl> arg0) => + fn(ObjCBlock_ffiVoid_NSData_NSError.castFromPointer(arg0, retain: true, release: true)) + ?.ref + .retainAndAutorelease() ?? + ffi.nullptr, + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>`. +extension ObjCBlock_NSProgress_ffiVoidNSDataNSError_CallExtension + on objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)> { + NSProgress? call(objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)> arg0) => ref + .pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> arg0)>>() + .asFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCBlockImpl>)>() + (ref.pointer, arg0.ref.pointer) + .address == + 0 + ? null + : NSProgress.castFromPointer( + ref.pointer.ref.invoke + .cast<ffi.NativeFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<objc.ObjCBlockImpl> arg0)>>() + .asFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCBlockImpl>)>()(ref.pointer, arg0.ref.pointer), + retain: true, + release: true); +} + +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> arg0) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl> arg0)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>()(arg0); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>)>( + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_fnPtrTrampoline) + .cast(); +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> arg0) => + (objc.getBlockClosure(block) as ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>))(arg0); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>)>( + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureTrampoline) + .cast(); + +/// Construction methods for `objc.ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>)>`. +abstract final class ObjCBlock_NSProgress_ffiVoidNSURLboolNSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>)> + fromFunctionPointer(ffi.Pointer<ffi.NativeFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl> arg0)>> ptr) => + objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>)>( + objc.newPointerBlock( + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>)> + fromFunction(NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>)>( + objc.newClosureBlock( + _ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_closureCallable, + (ffi.Pointer<objc.ObjCBlockImpl> arg0) => + fn(ObjCBlock_ffiVoid_NSURL_bool_NSError.castFromPointer(arg0, retain: true, release: true)) + ?.ref + .retainAndAutorelease() ?? + ffi.nullptr, + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>)>`. +extension ObjCBlock_NSProgress_ffiVoidNSURLboolNSError_CallExtension + on objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>)> { + NSProgress? call( + objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)> arg0) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> arg0)>>() + .asFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCBlockImpl>)>() + (ref.pointer, arg0.ref.pointer) + .address == + 0 + ? null + : NSProgress.castFromPointer( + ref.pointer.ref.invoke + .cast<ffi.NativeFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<objc.ObjCBlockImpl> arg0)>>() + .asFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCBlockImpl>)>()(ref.pointer, arg0.ref.pointer), + retain: true, + release: true); +} + +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCBlockImpl> arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<ffi.Void> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCBlockImpl> arg2)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>()(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>( + _ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError_fnPtrTrampoline) + .cast(); +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCBlockImpl> arg2) => + (objc.getBlockClosure(block) as ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>))(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError_closureCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>( + _ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError_closureTrampoline) + .cast(); + +/// Construction methods for `objc.ObjCBlock<NSProgress? Function(ffi.Pointer<ffi.Void>, NSString, objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>`. +abstract final class ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + NSProgress? Function(ffi.Pointer<ffi.Void>, NSString, + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + NSProgress? Function(ffi.Pointer<ffi.Void>, NSString, + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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< + NSProgress? Function(ffi.Pointer<ffi.Void>, NSString, + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)> + fromFunctionPointer(ffi.Pointer<ffi.NativeFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void> arg0, ffi.Pointer<objc.ObjCObject> arg1, ffi.Pointer<objc.ObjCBlockImpl> arg2)>> ptr) => + objc.ObjCBlock< + NSProgress? Function(ffi.Pointer<ffi.Void>, NSString, + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>( + objc.newPointerBlock(_ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<NSProgress? Function(ffi.Pointer<ffi.Void>, NSString, objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)> + fromFunction(NSProgress? Function(ffi.Pointer<ffi.Void>, NSString, objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<NSProgress? Function(ffi.Pointer<ffi.Void>, NSString, objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>( + objc.newClosureBlock( + _ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError_closureCallable, + (ffi.Pointer<ffi.Void> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCBlockImpl> arg2) => + fn(arg0, NSString.castFromPointer(arg1, retain: true, release: true), ObjCBlock_ffiVoid_NSData_NSError.castFromPointer(arg2, retain: true, release: true))?.ref.retainAndAutorelease() ?? + ffi.nullptr, + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<NSProgress? Function(ffi.Pointer<ffi.Void>, NSString, objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)>`. +extension ObjCBlock_NSProgress_ffiVoid_NSString_ffiVoidNSDataNSError_CallExtension + on objc.ObjCBlock< + NSProgress? Function(ffi.Pointer<ffi.Void>, NSString, + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>)> { + NSProgress? call(ffi.Pointer<ffi.Void> arg0, NSString arg1, + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)> arg2) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCBlockImpl> arg2)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>() + (ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer) + .address == + 0 + ? null + : NSProgress.castFromPointer(ref.pointer.ref.invoke.cast<ffi.NativeFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<ffi.Void> arg0, ffi.Pointer<objc.ObjCObject> arg1, ffi.Pointer<objc.ObjCBlockImpl> arg2)>>().asFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<ffi.Void>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCBlockImpl>)>()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer), retain: true, release: true); +} + +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_NSProgress_ffiVoididNSItemProviderWritingNSError_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> arg0) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl> arg0)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>)>()(arg0); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSProgress_ffiVoididNSItemProviderWritingNSError_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>)>( + _ObjCBlock_NSProgress_ffiVoididNSItemProviderWritingNSError_fnPtrTrampoline) + .cast(); +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_NSProgress_ffiVoididNSItemProviderWritingNSError_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> arg0) => + (objc.getBlockClosure(block) as ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>))(arg0); +ffi.Pointer<ffi.Void> + _ObjCBlock_NSProgress_ffiVoididNSItemProviderWritingNSError_closureCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCBlockImpl>)>( + _ObjCBlock_NSProgress_ffiVoididNSItemProviderWritingNSError_closureTrampoline) + .cast(); + +/// Construction methods for `objc.ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>)>`. +abstract final class ObjCBlock_NSProgress_ffiVoididNSItemProviderWritingNSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>)> + fromFunctionPointer(ffi.Pointer<ffi.NativeFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl> arg0)>> ptr) => + objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>)>( + objc.newPointerBlock( + _ObjCBlock_NSProgress_ffiVoididNSItemProviderWritingNSError_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>)> + fromFunction(NSProgress? Function(objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>)>( + objc.newClosureBlock( + _ObjCBlock_NSProgress_ffiVoididNSItemProviderWritingNSError_closureCallable, + (ffi.Pointer<objc.ObjCBlockImpl> arg0) => + fn(ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError.castFromPointer(arg0, retain: true, release: true)) + ?.ref + .retainAndAutorelease() ?? + ffi.nullptr, + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<NSProgress? Function(objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>)>`. +extension ObjCBlock_NSProgress_ffiVoididNSItemProviderWritingNSError_CallExtension + on objc.ObjCBlock< + NSProgress? Function( + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>)> { + NSProgress? call(objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> arg0) => ref + .pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCBlockImpl> arg0)>>() + .asFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCBlockImpl>)>() + (ref.pointer, arg0.ref.pointer) + .address == + 0 + ? null + : NSProgress.castFromPointer( + ref.pointer.ref.invoke + .cast<ffi.NativeFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<objc.ObjCBlockImpl> arg0)>>() + .asFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCBlockImpl>)>()(ref.pointer, arg0.ref.pointer), + retain: true, + release: true); +} + ffi.Pointer<objc.ObjCObject> _ObjCBlock_NSString_ffiVoid_fnPtrTrampoline( ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<ffi.Void> arg0) => block.ref.target @@ -14250,6 +16572,438 @@ ffi.Pointer<ffi.Void>)>()(ref.pointer, arg0); } +bool _ObjCBlock_bool_KeyType_ObjectType_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2)>>() + .asFunction< + bool Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>()(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> _ObjCBlock_bool_KeyType_ObjectType_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_bool_KeyType_ObjectType_bool_fnPtrTrampoline, false) + .cast(); +bool _ObjCBlock_bool_KeyType_ObjectType_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2) => + (objc.getBlockClosure(block) as bool Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> _ObjCBlock_bool_KeyType_ObjectType_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_bool_KeyType_ObjectType_bool_closureTrampoline, false) + .cast(); + +/// Construction methods for `objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_bool_KeyType_ObjectType_bool { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Bool Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + fromFunctionPointer(ffi.Pointer<ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, ffi.Pointer<ffi.Bool> arg2)>> ptr) => + objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock(_ObjCBlock_bool_KeyType_ObjectType_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + fromFunction(bool Function(objc.ObjCObjectBase, objc.ObjCObjectBase, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_bool_KeyType_ObjectType_bool_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, ffi.Pointer<ffi.Bool> arg2) => fn( + objc.ObjCObjectBase(arg0, retain: true, release: true), + objc.ObjCObjectBase(arg1, retain: true, release: true), + arg2), + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_bool_KeyType_ObjectType_bool_CallExtension + on objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> { + bool call(objc.ObjCObjectBase arg0, objc.ObjCObjectBase arg1, + ffi.Pointer<ffi.Bool> arg2) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2)>>() + .asFunction< + bool Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>()( + ref.pointer, arg0.ref.pointer, arg1.ref.pointer, arg2); +} + +bool _ObjCBlock_bool_NSUInteger_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + int arg0, + ffi.Pointer<ffi.Bool> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.UnsignedLong arg0, ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction<bool Function(int, ffi.Pointer<ffi.Bool>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_bool_NSUInteger_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Bool Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_bool_NSUInteger_bool_fnPtrTrampoline, false) + .cast(); +bool _ObjCBlock_bool_NSUInteger_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + int arg0, + ffi.Pointer<ffi.Bool> arg1) => + (objc.getBlockClosure(block) as bool Function(int, ffi.Pointer<ffi.Bool>))( + arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_bool_NSUInteger_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Bool Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_bool_NSUInteger_bool_closureTrampoline, false) + .cast(); + +/// Construction methods for `objc.ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_bool_NSUInteger_bool { + /// Returns a block that wraps the given raw block pointer. + static objc + .ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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.UnsignedLong, ffi.Pointer<ffi.Bool>)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function( + ffi.UnsignedLong arg0, ffi.Pointer<ffi.Bool> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock(_ObjCBlock_bool_NSUInteger_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + fromFunction(bool Function(int, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock< + ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_bool_NSUInteger_bool_closureCallable, + (int arg0, ffi.Pointer<ffi.Bool> arg1) => fn(arg0, arg1), + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_bool_NSUInteger_bool_CallExtension on objc + .ObjCBlock<ffi.Bool Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> { + bool call(int arg0, ffi.Pointer<ffi.Bool> arg1) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.UnsignedLong arg0, ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction< + bool Function(ffi.Pointer<objc.ObjCBlockImpl>, int, + ffi.Pointer<ffi.Bool>)>()(ref.pointer, arg0, arg1); +} + +bool _ObjCBlock_bool_ObjectType_NSUInteger_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + int arg1, + ffi.Pointer<ffi.Bool> arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.UnsignedLong arg1, ffi.Pointer<ffi.Bool> arg2)>>() + .asFunction< + bool Function(ffi.Pointer<objc.ObjCObject>, int, + ffi.Pointer<ffi.Bool>)>()(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> _ObjCBlock_bool_ObjectType_NSUInteger_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_bool_ObjectType_NSUInteger_bool_fnPtrTrampoline, false) + .cast(); +bool _ObjCBlock_bool_ObjectType_NSUInteger_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + int arg1, + ffi.Pointer<ffi.Bool> arg2) => + (objc.getBlockClosure(block) as bool Function(ffi.Pointer<objc.ObjCObject>, + int, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> + _ObjCBlock_bool_ObjectType_NSUInteger_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Bool Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_bool_ObjectType_NSUInteger_bool_closureTrampoline, false) + .cast(); + +/// Construction methods for `objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_bool_ObjectType_NSUInteger_bool { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + fromFunctionPointer(ffi.Pointer<ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<objc.ObjCObject> arg0, ffi.UnsignedLong arg1, ffi.Pointer<ffi.Bool> arg2)>> ptr) => + objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock(_ObjCBlock_bool_ObjectType_NSUInteger_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + fromFunction( + bool Function(objc.ObjCObjectBase, int, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_bool_ObjectType_NSUInteger_bool_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, int arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(objc.ObjCObjectBase(arg0, retain: true, release: true), arg1, arg2), + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_bool_ObjectType_NSUInteger_bool_CallExtension + on objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> { + bool call(objc.ObjCObjectBase arg0, int arg1, ffi.Pointer<ffi.Bool> arg2) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.UnsignedLong arg1, + ffi.Pointer<ffi.Bool> arg2)>>() + .asFunction< + bool Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + int, + ffi.Pointer<ffi.Bool>)>()( + ref.pointer, arg0.ref.pointer, arg1, arg2); +} + +bool _ObjCBlock_bool_ObjectType_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction< + bool Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_bool_ObjectType_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Bool Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_bool_ObjectType_bool_fnPtrTrampoline, false) + .cast(); +bool _ObjCBlock_bool_ObjectType_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1) => + (objc.getBlockClosure(block) as bool Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_bool_ObjectType_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Bool Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_bool_ObjectType_bool_closureTrampoline, false) + .cast(); + +/// Construction methods for `objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_bool_ObjectType_bool { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Bool Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Bool Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock(_ObjCBlock_bool_ObjectType_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> fromFunction( + bool Function(objc.ObjCObjectBase, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_bool_ObjectType_bool_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<ffi.Bool> arg1) => + fn(objc.ObjCObjectBase(arg0, retain: true, release: true), arg1), + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_bool_ObjectType_bool_CallExtension on objc.ObjCBlock< + ffi.Bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> { + bool call(objc.ObjCObjectBase arg0, ffi.Pointer<ffi.Bool> arg1) => ref + .pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction< + bool Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>()(ref.pointer, arg0.ref.pointer, arg1); +} + bool _ObjCBlock_bool_ffiVoid_fnPtrTrampoline( ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<ffi.Void> arg0) => block.ref.target @@ -14630,6 +17384,692 @@ ffi.Pointer<objc.ObjCSelector>)>()(ref.pointer, arg0, arg1); } +void _ObjCBlock_ffiVoid_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, +) => + block.ref.target + .cast<ffi.NativeFunction<ffi.Void Function()>>() + .asFunction<void Function()>()(); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_fnPtrCallable = ffi.Pointer + .fromFunction<ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>)>( + _ObjCBlock_ffiVoid_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, +) => + (objc.getBlockClosure(block) as void Function())(); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_closureCallable = ffi.Pointer + .fromFunction<ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>)>( + _ObjCBlock_ffiVoid_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, +) { + (objc.getBlockClosure(block) as void Function())(); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable<ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>)> + _ObjCBlock_ffiVoid_listenerCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>)>.listener( + _ObjCBlock_ffiVoid_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<ffi.Void> waiter) { + try { + (objc.getBlockClosure(block) as void Function())(); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<ffi.Void>)> + _ObjCBlock_ffiVoid_blockingCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>)>.isolateLocal( + _ObjCBlock_ffiVoid_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<ffi.Void>)> + _ObjCBlock_ffiVoid_blockingListenerCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>)>.listener( + _ObjCBlock_ffiVoid_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function()>`. +abstract final class ObjCBlock_ffiVoid { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock<ffi.Void Function()> castFromPointer( + ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, + bool release = false}) => + objc.ObjCBlock<ffi.Void Function()>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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()> fromFunctionPointer( + ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> ptr) => + objc.ObjCBlock<ffi.Void Function()>( + objc.newPointerBlock(_ObjCBlock_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function()> fromFunction(void Function() fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function()>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_closureCallable, () => fn(), keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function()> listener(void Function() fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_listenerCallable.nativeFunction.cast(), + () => fn(), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_1pl9qdv(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock<ffi.Void Function()>(wrapper, + retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock<ffi.Void Function()> blocking(void Function() fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_blockingCallable.nativeFunction.cast(), + () => fn(), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_blockingListenerCallable.nativeFunction.cast(), + () => fn(), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_1pl9qdv( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock<ffi.Void Function()>(wrapper, + retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function()>`. +extension ObjCBlock_ffiVoid_CallExtension + on objc.ObjCBlock<ffi.Void Function()> { + void call() => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl> block)>>() + .asFunction<void Function(ffi.Pointer<objc.ObjCBlockImpl>)>()( + ref.pointer, + ); +} + +void _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>()(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2) { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_listenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_blockingCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>.isolateLocal( + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_ffiVoid_KeyType_ObjectType_bool { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + fromFunctionPointer(ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, ffi.Pointer<ffi.Bool> arg2)>> ptr) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock(_ObjCBlock_ffiVoid_KeyType_ObjectType_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + fromFunction(void Function(objc.ObjCObjectBase, objc.ObjCObjectBase, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, ffi.Pointer<ffi.Bool> arg2) => fn( + objc.ObjCObjectBase(arg0, retain: true, release: true), + objc.ObjCObjectBase(arg1, retain: true, release: true), + arg2), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> listener( + void Function( + objc.ObjCObjectBase, objc.ObjCObjectBase, ffi.Pointer<ffi.Bool>) + fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_listenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(objc.ObjCObjectBase(arg0, retain: false, release: true), + objc.ObjCObjectBase(arg1, retain: false, release: true), arg2), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_1o83rbn(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>(wrapper, retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> blocking( + void Function( + objc.ObjCObjectBase, objc.ObjCObjectBase, ffi.Pointer<ffi.Bool>) + fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_blockingCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(objc.ObjCObjectBase(arg0, retain: false, release: true), + objc.ObjCObjectBase(arg1, retain: false, release: true), arg2), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_KeyType_ObjectType_bool_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(objc.ObjCObjectBase(arg0, retain: false, release: true), + objc.ObjCObjectBase(arg1, retain: false, release: true), arg2), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_1o83rbn( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>(wrapper, retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_ffiVoid_KeyType_ObjectType_bool_CallExtension + on objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> { + void call(objc.ObjCObjectBase arg0, objc.ObjCObjectBase arg1, + ffi.Pointer<ffi.Bool> arg2) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<ffi.Bool> arg2)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>()( + ref.pointer, arg0.ref.pointer, arg1.ref.pointer, arg2); +} + +void _ObjCBlock_ffiVoid_NSData_NSError_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSData_NSError_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_NSData_NSError_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSData_NSError_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSData_NSError_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_NSData_NSError_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSData_NSError_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>))(arg0, arg1); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSData_NSError_listenerCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_NSData_NSError_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_NSData_NSError_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSData_NSError_blockingCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.isolateLocal( + _ObjCBlock_ffiVoid_NSData_NSError_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSData_NSError_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_NSData_NSError_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>`. +abstract final class ObjCBlock_ffiVoid_NSData_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)> castFromPointer( + ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, + bool release = false}) => + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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(NSData?, NSError?)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>( + objc.newPointerBlock(_ObjCBlock_ffiVoid_NSData_NSError_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)> fromFunction( + void Function(NSData?, NSError?) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSData_NSError_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1) => fn( + arg0.address == 0 + ? null + : NSData.castFromPointer(arg0, retain: true, release: true), + arg1.address == 0 ? null : NSError.castFromPointer(arg1, retain: true, release: true)), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)> listener( + void Function(NSData?, NSError?) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSData_NSError_listenerCallable.nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSData.castFromPointer(arg0, + retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_pfv6jd(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>(wrapper, + retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)> blocking( + void Function(NSData?, NSError?) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSData_NSError_blockingCallable.nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSData.castFromPointer(arg0, + retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSData_NSError_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSData.castFromPointer(arg0, + retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_pfv6jd( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>(wrapper, + retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)>`. +extension ObjCBlock_ffiVoid_NSData_NSError_CallExtension + on objc.ObjCBlock<ffi.Void Function(NSData?, NSError?)> { + void call(NSData? arg0, NSError? arg1) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(ref.pointer, + arg0?.ref.pointer ?? ffi.nullptr, arg1?.ref.pointer ?? ffi.nullptr); +} + void _ObjCBlock_ffiVoid_NSItemProviderCompletionHandler_objcObjCObject_NSDictionary_fnPtrTrampoline( ffi.Pointer<objc.ObjCBlockImpl> block, @@ -14956,6 +18396,2408 @@ ref.pointer, arg0.ref.pointer, arg1.ref.pointer, arg2.ref.pointer); } +void _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCObject> arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCObject> arg2)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_fnPtrTrampoline) + .cast(); +void + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCObject> arg2) => + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_closureTrampoline) + .cast(); +void + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCObject> arg2) { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_listenerTrampoline) + ..keepIsolateAlive = false; +void + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCObject> arg2) { + try { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.isolateLocal( + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)>`. +abstract final class ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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(NSObject, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + fromFunctionPointer(ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, ffi.Pointer<objc.ObjCObject> arg2)>> ptr) => + objc.ObjCBlock< + ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + objc.newPointerBlock( + _ObjCBlock_ffiVoid_NSObject_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> fromFunction( + void Function(NSObject, objc.ObjCObjectBase, objc.ObjCObjectBase) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, ffi.Pointer<objc.ObjCObject> arg2) => + fn( + NSObject.castFromPointer(arg0, retain: true, release: true), + objc.ObjCObjectBase(arg1, retain: true, release: true), + objc.ObjCObjectBase(arg2, retain: true, release: true)), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> listener( + void Function(NSObject, objc.ObjCObjectBase, objc.ObjCObjectBase) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_listenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCObject> arg2) => + fn( + NSObject.castFromPointer(arg0, retain: false, release: true), + objc.ObjCObjectBase(arg1, retain: false, release: true), + objc.ObjCObjectBase(arg2, retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_r8gdi7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>(wrapper, + retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> blocking( + void Function(NSObject, objc.ObjCObjectBase, objc.ObjCObjectBase) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_blockingCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCObject> arg2) => + fn( + NSObject.castFromPointer(arg0, retain: false, release: true), + objc.ObjCObjectBase(arg1, retain: false, release: true), + objc.ObjCObjectBase(arg2, retain: false, release: true)), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCObject> arg2) => + fn( + NSObject.castFromPointer(arg0, retain: false, release: true), + objc.ObjCObjectBase(arg1, retain: false, release: true), + objc.ObjCObjectBase(arg2, retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_r8gdi7( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>(wrapper, + retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)>`. +extension ObjCBlock_ffiVoid_NSObject_objcObjCObject_objcObjCObject_CallExtension + on objc.ObjCBlock< + ffi.Void Function(NSObject, ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> { + void call( + NSObject arg0, objc.ObjCObjectBase arg1, objc.ObjCObjectBase arg2) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1, + ffi.Pointer<objc.ObjCObject> arg2)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()( + ref.pointer, arg0.ref.pointer, arg1.ref.pointer, arg2.ref.pointer); +} + +void _ObjCBlock_ffiVoid_NSRange_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + NSRange arg0, + ffi.Pointer<ffi.Bool> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(NSRange arg0, ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction< + void Function(NSRange, ffi.Pointer<ffi.Bool>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSRange_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, NSRange, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_NSRange_bool_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSRange_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + NSRange arg0, + ffi.Pointer<ffi.Bool> arg1) => + (objc.getBlockClosure(block) as void Function( + NSRange, ffi.Pointer<ffi.Bool>))(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSRange_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, NSRange, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_NSRange_bool_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSRange_bool_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + NSRange arg0, + ffi.Pointer<ffi.Bool> arg1) { + (objc.getBlockClosure(block) as void Function( + NSRange, ffi.Pointer<ffi.Bool>))(arg0, arg1); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, NSRange, ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSRange_bool_listenerCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, NSRange, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_NSRange_bool_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_NSRange_bool_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + NSRange arg0, + ffi.Pointer<ffi.Bool> arg1) { + try { + (objc.getBlockClosure(block) as void Function( + NSRange, ffi.Pointer<ffi.Bool>))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSRange_bool_blockingCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + NSRange, + ffi.Pointer<ffi.Bool>)>.isolateLocal( + _ObjCBlock_ffiVoid_NSRange_bool_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSRange_bool_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + NSRange, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_NSRange_bool_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_ffiVoid_NSRange_bool { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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(NSRange, ffi.Pointer<ffi.Bool>)> fromFunctionPointer( + ffi.Pointer<ffi.NativeFunction<ffi.Void Function(NSRange arg0, ffi.Pointer<ffi.Bool> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock( + _ObjCBlock_ffiVoid_NSRange_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)> + fromFunction(void Function(NSRange, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSRange_bool_closureCallable, + (NSRange arg0, ffi.Pointer<ffi.Bool> arg1) => fn(arg0, arg1), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)> + listener(void Function(NSRange, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSRange_bool_listenerCallable.nativeFunction.cast(), + (NSRange arg0, ffi.Pointer<ffi.Bool> arg1) => fn(arg0, arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_zkjmn1(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)>( + wrapper, + retain: false, + release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)> + blocking(void Function(NSRange, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSRange_bool_blockingCallable.nativeFunction.cast(), + (NSRange arg0, ffi.Pointer<ffi.Bool> arg1) => fn(arg0, arg1), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSRange_bool_blockingListenerCallable.nativeFunction + .cast(), + (NSRange arg0, ffi.Pointer<ffi.Bool> arg1) => fn(arg0, arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_zkjmn1( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)>( + wrapper, + retain: false, + release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_ffiVoid_NSRange_bool_CallExtension + on objc.ObjCBlock<ffi.Void Function(NSRange, ffi.Pointer<ffi.Bool>)> { + void call(NSRange arg0, ffi.Pointer<ffi.Bool> arg1) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl> block, + NSRange arg0, ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCBlockImpl>, NSRange, + ffi.Pointer<ffi.Bool>)>()(ref.pointer, arg0, arg1); +} + +void _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + NSRange arg1, + NSRange arg2, + ffi.Pointer<ffi.Bool> arg3) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + NSRange arg1, NSRange arg2, ffi.Pointer<ffi.Bool> arg3)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCObject>, NSRange, NSRange, + ffi.Pointer<ffi.Bool>)>()(arg0, arg1, arg2, arg3); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + NSRange, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + NSRange arg1, + NSRange arg2, + ffi.Pointer<ffi.Bool> arg3) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + NSRange, NSRange, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2, arg3); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + NSRange, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + NSRange arg1, + NSRange arg2, + ffi.Pointer<ffi.Bool> arg3) { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + NSRange, NSRange, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2, arg3); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + NSRange, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_listenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + NSRange, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + NSRange arg1, + NSRange arg2, + ffi.Pointer<ffi.Bool> arg3) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + NSRange, NSRange, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2, arg3); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + NSRange, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + NSRange, + ffi.Pointer<ffi.Bool>)>.isolateLocal( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + NSRange, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + NSRange, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function( + NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)> + fromFunctionPointer( + ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, NSRange arg1, NSRange arg2, ffi.Pointer<ffi.Bool> arg3)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)> + fromFunction(void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, NSRange arg1, + NSRange arg2, ffi.Pointer<ffi.Bool> arg3) => + fn(arg0.address == 0 ? null : NSString.castFromPointer(arg0, retain: true, release: true), arg1, arg2, arg3), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)> + listener( + void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_listenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, NSRange arg1, NSRange arg2, + ffi.Pointer<ffi.Bool> arg3) => + fn( + arg0.address == 0 + ? null + : NSString.castFromPointer(arg0, + retain: false, release: true), + arg1, + arg2, + arg3), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_lmc3p5(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(NSString?, NSRange, NSRange, + ffi.Pointer<ffi.Bool>)>(wrapper, retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)> + blocking( + void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_blockingCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, NSRange arg1, NSRange arg2, + ffi.Pointer<ffi.Bool> arg3) => + fn( + arg0.address == 0 + ? null + : NSString.castFromPointer(arg0, + retain: false, release: true), + arg1, + arg2, + arg3), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, NSRange arg1, NSRange arg2, + ffi.Pointer<ffi.Bool> arg3) => + fn( + arg0.address == 0 + ? null + : NSString.castFromPointer(arg0, + retain: false, release: true), + arg1, + arg2, + arg3), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_lmc3p5( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(NSString?, NSRange, NSRange, + ffi.Pointer<ffi.Bool>)>(wrapper, retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_ffiVoid_NSString_NSRange_NSRange_bool_CallExtension + on objc.ObjCBlock< + ffi.Void Function(NSString?, NSRange, NSRange, ffi.Pointer<ffi.Bool>)> { + void call(NSString? arg0, NSRange arg1, NSRange arg2, + ffi.Pointer<ffi.Bool> arg3) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + NSRange arg1, + NSRange arg2, + ffi.Pointer<ffi.Bool> arg3)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + NSRange, + ffi.Pointer<ffi.Bool>)>()( + ref.pointer, arg0?.ref.pointer ?? ffi.nullptr, arg1, arg2, arg3); +} + +void _ObjCBlock_ffiVoid_NSString_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSString_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_NSString_bool_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSString_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1) => + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSString_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_NSString_bool_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSString_bool_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1) { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSString_bool_listenerCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_NSString_bool_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_NSString_bool_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1) { + try { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSString_bool_blockingCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>.isolateLocal( + _ObjCBlock_ffiVoid_NSString_bool_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSString_bool_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_NSString_bool_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_ffiVoid_NSString_bool { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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(NSString, ffi.Pointer<ffi.Bool>)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock(_ObjCBlock_ffiVoid_NSString_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)> fromFunction( + void Function(NSString, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSString_bool_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<ffi.Bool> arg1) => + fn(NSString.castFromPointer(arg0, retain: true, release: true), arg1), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)> + listener(void Function(NSString, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSString_bool_listenerCallable.nativeFunction.cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<ffi.Bool> arg1) => fn( + NSString.castFromPointer(arg0, retain: false, release: true), arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_t8l8el(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)>( + wrapper, + retain: false, + release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)> + blocking(void Function(NSString, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSString_bool_blockingCallable.nativeFunction.cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<ffi.Bool> arg1) => fn( + NSString.castFromPointer(arg0, retain: false, release: true), arg1), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSString_bool_blockingListenerCallable.nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<ffi.Bool> arg1) => fn( + NSString.castFromPointer(arg0, retain: false, release: true), arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_t8l8el( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)>( + wrapper, + retain: false, + release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_ffiVoid_NSString_bool_CallExtension + on objc.ObjCBlock<ffi.Void Function(NSString, ffi.Pointer<ffi.Bool>)> { + void call(NSString arg0, ffi.Pointer<ffi.Bool> arg1) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>()(ref.pointer, arg0.ref.pointer, arg1); +} + +void _ObjCBlock_ffiVoid_NSTimer_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0)>>() + .asFunction<void Function(ffi.Pointer<objc.ObjCObject>)>()(arg0); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSTimer_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_NSTimer_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSTimer_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0) => + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>))(arg0); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSTimer_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_NSTimer_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSTimer_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<objc.ObjCObject> arg0) { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>))(arg0); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSTimer_listenerCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_NSTimer_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_NSTimer_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0) { + try { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSTimer_blockingCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>)>.isolateLocal( + _ObjCBlock_ffiVoid_NSTimer_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSTimer_blockingListenerCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_NSTimer_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(NSTimer)>`. +abstract final class ObjCBlock_ffiVoid_NSTimer { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock<ffi.Void Function(NSTimer)> castFromPointer( + ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, + bool release = false}) => + objc.ObjCBlock<ffi.Void Function(NSTimer)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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(NSTimer)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(NSTimer)>( + objc.newPointerBlock( + _ObjCBlock_ffiVoid_NSTimer_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSTimer)> fromFunction( + void Function(NSTimer) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(NSTimer)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSTimer_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0) => fn( + NSTimer.castFromPointer(arg0, retain: true, release: true)), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSTimer)> listener( + void Function(NSTimer) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSTimer_listenerCallable.nativeFunction.cast(), + (ffi.Pointer<objc.ObjCObject> arg0) => + fn(NSTimer.castFromPointer(arg0, retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_xtuoz7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock<ffi.Void Function(NSTimer)>(wrapper, + retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock<ffi.Void Function(NSTimer)> blocking( + void Function(NSTimer) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSTimer_blockingCallable.nativeFunction.cast(), + (ffi.Pointer<objc.ObjCObject> arg0) => + fn(NSTimer.castFromPointer(arg0, retain: false, release: true)), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSTimer_blockingListenerCallable.nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0) => + fn(NSTimer.castFromPointer(arg0, retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_xtuoz7( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock<ffi.Void Function(NSTimer)>(wrapper, + retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(NSTimer)>`. +extension ObjCBlock_ffiVoid_NSTimer_CallExtension + on objc.ObjCBlock<ffi.Void Function(NSTimer)> { + void call(NSTimer arg0) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>)>()(ref.pointer, arg0.ref.pointer); +} + +void _ObjCBlock_ffiVoid_NSUInteger_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + int arg0, + ffi.Pointer<ffi.Bool> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.UnsignedLong arg0, ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction<void Function(int, ffi.Pointer<ffi.Bool>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSUInteger_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_NSUInteger_bool_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSUInteger_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + int arg0, + ffi.Pointer<ffi.Bool> arg1) => + (objc.getBlockClosure(block) as void Function(int, ffi.Pointer<ffi.Bool>))( + arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSUInteger_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_NSUInteger_bool_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSUInteger_bool_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + int arg0, + ffi.Pointer<ffi.Bool> arg1) { + (objc.getBlockClosure(block) as void Function(int, ffi.Pointer<ffi.Bool>))( + arg0, arg1); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSUInteger_bool_listenerCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_NSUInteger_bool_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_NSUInteger_bool_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + int arg0, + ffi.Pointer<ffi.Bool> arg1) { + try { + (objc.getBlockClosure(block) as void Function(int, ffi.Pointer<ffi.Bool>))( + arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSUInteger_bool_blockingCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>.isolateLocal( + _ObjCBlock_ffiVoid_NSUInteger_bool_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_NSUInteger_bool_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_NSUInteger_bool_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_ffiVoid_NSUInteger_bool { + /// Returns a block that wraps the given raw block pointer. + static objc + .ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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.UnsignedLong, ffi.Pointer<ffi.Bool>)> fromFunctionPointer( + ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.UnsignedLong arg0, ffi.Pointer<ffi.Bool> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock( + _ObjCBlock_ffiVoid_NSUInteger_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + fromFunction(void Function(int, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock< + ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSUInteger_bool_closureCallable, + (int arg0, ffi.Pointer<ffi.Bool> arg1) => fn(arg0, arg1), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + listener(void Function(int, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSUInteger_bool_listenerCallable.nativeFunction + .cast(), + (int arg0, ffi.Pointer<ffi.Bool> arg1) => fn(arg0, arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_q5jeyk(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>(wrapper, + retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc + .ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + blocking(void Function(int, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSUInteger_bool_blockingCallable.nativeFunction + .cast(), + (int arg0, ffi.Pointer<ffi.Bool> arg1) => fn(arg0, arg1), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSUInteger_bool_blockingListenerCallable + .nativeFunction + .cast(), + (int arg0, ffi.Pointer<ffi.Bool> arg1) => fn(arg0, arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_q5jeyk( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>(wrapper, + retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_ffiVoid_NSUInteger_bool_CallExtension on objc + .ObjCBlock<ffi.Void Function(ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> { + void call(int arg0, ffi.Pointer<ffi.Bool> arg1) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.UnsignedLong arg0, ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCBlockImpl>, int, + ffi.Pointer<ffi.Bool>)>()(ref.pointer, arg0, arg1); +} + +void _ObjCBlock_ffiVoid_NSURL_NSError_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSURL_NSError_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_NSURL_NSError_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSURL_NSError_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSURL_NSError_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_NSURL_NSError_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSURL_NSError_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>))(arg0, arg1); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSURL_NSError_listenerCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_NSURL_NSError_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_NSURL_NSError_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSURL_NSError_blockingCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.isolateLocal( + _ObjCBlock_ffiVoid_NSURL_NSError_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSURL_NSError_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_NSURL_NSError_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)>`. +abstract final class ObjCBlock_ffiVoid_NSURL_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)> castFromPointer( + ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, + bool release = false}) => + objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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(NSURL?, NSError?)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)>( + objc.newPointerBlock(_ObjCBlock_ffiVoid_NSURL_NSError_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)> fromFunction( + void Function(NSURL?, NSError?) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSURL_NSError_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1) => fn( + arg0.address == 0 + ? null + : NSURL.castFromPointer(arg0, retain: true, release: true), + arg1.address == 0 ? null : NSError.castFromPointer(arg1, retain: true, release: true)), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)> listener( + void Function(NSURL?, NSError?) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSURL_NSError_listenerCallable.nativeFunction.cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSURL.castFromPointer(arg0, retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_pfv6jd(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)>(wrapper, + retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)> blocking( + void Function(NSURL?, NSError?) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSURL_NSError_blockingCallable.nativeFunction.cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSURL.castFromPointer(arg0, retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSURL_NSError_blockingListenerCallable.nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSURL.castFromPointer(arg0, retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_pfv6jd( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)>(wrapper, + retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)>`. +extension ObjCBlock_ffiVoid_NSURL_NSError_CallExtension + on objc.ObjCBlock<ffi.Void Function(NSURL?, NSError?)> { + void call(NSURL? arg0, NSError? arg1) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(ref.pointer, + arg0?.ref.pointer ?? ffi.nullptr, arg1?.ref.pointer ?? ffi.nullptr); +} + +void _ObjCBlock_ffiVoid_NSURL_bool_NSError_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + bool arg1, + ffi.Pointer<objc.ObjCObject> arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Bool arg1, ffi.Pointer<objc.ObjCObject> arg2)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCObject>, bool, + ffi.Pointer<objc.ObjCObject>)>()(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSURL_bool_NSError_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Bool, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + bool arg1, + ffi.Pointer<objc.ObjCObject> arg2) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + bool, ffi.Pointer<objc.ObjCObject>))(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Bool, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_NSURL_bool_NSError_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + bool arg1, + ffi.Pointer<objc.ObjCObject> arg2) { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + bool, ffi.Pointer<objc.ObjCObject>))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Bool, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSURL_bool_NSError_listenerCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Bool, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_NSURL_bool_NSError_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + bool arg1, + ffi.Pointer<objc.ObjCObject> arg2) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + bool, ffi.Pointer<objc.ObjCObject>))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Bool, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSURL_bool_NSError_blockingCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Bool, + ffi.Pointer<objc.ObjCObject>)>.isolateLocal( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Bool, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_NSURL_bool_NSError_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Bool, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>`. +abstract final class ObjCBlock_ffiVoid_NSURL_bool_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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(NSURL?, ffi.Bool, NSError?)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Bool arg1, ffi.Pointer<objc.ObjCObject> arg2)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>( + objc.newPointerBlock(_ObjCBlock_ffiVoid_NSURL_bool_NSError_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)> fromFunction( + void Function(NSURL?, bool, NSError?) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, bool arg1, ffi.Pointer<objc.ObjCObject> arg2) => fn( + arg0.address == 0 + ? null + : NSURL.castFromPointer(arg0, retain: true, release: true), + arg1, + arg2.address == 0 ? null : NSError.castFromPointer(arg2, retain: true, release: true)), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)> listener( + void Function(NSURL?, bool, NSError?) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_listenerCallable.nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, bool arg1, + ffi.Pointer<objc.ObjCObject> arg2) => + fn( + arg0.address == 0 + ? null + : NSURL.castFromPointer(arg0, retain: false, release: true), + arg1, + arg2.address == 0 + ? null + : NSError.castFromPointer(arg2, + retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_rnu2c5(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>( + wrapper, + retain: false, + release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)> blocking( + void Function(NSURL?, bool, NSError?) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_blockingCallable.nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, bool arg1, + ffi.Pointer<objc.ObjCObject> arg2) => + fn( + arg0.address == 0 + ? null + : NSURL.castFromPointer(arg0, retain: false, release: true), + arg1, + arg2.address == 0 + ? null + : NSError.castFromPointer(arg2, + retain: false, release: true)), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_NSURL_bool_NSError_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, bool arg1, + ffi.Pointer<objc.ObjCObject> arg2) => + fn( + arg0.address == 0 + ? null + : NSURL.castFromPointer(arg0, retain: false, release: true), + arg1, + arg2.address == 0 + ? null + : NSError.castFromPointer(arg2, + retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_rnu2c5( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>( + wrapper, + retain: false, + release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)>`. +extension ObjCBlock_ffiVoid_NSURL_bool_NSError_CallExtension + on objc.ObjCBlock<ffi.Void Function(NSURL?, ffi.Bool, NSError?)> { + void call(NSURL? arg0, bool arg1, NSError? arg2) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Bool arg1, + ffi.Pointer<objc.ObjCObject> arg2)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + bool, + ffi.Pointer<objc.ObjCObject>)>()(ref.pointer, + arg0?.ref.pointer ?? ffi.nullptr, arg1, arg2?.ref.pointer ?? ffi.nullptr); +} + +void _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + int arg1, + ffi.Pointer<ffi.Bool> arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.UnsignedLong arg1, ffi.Pointer<ffi.Bool> arg2)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCObject>, int, + ffi.Pointer<ffi.Bool>)>()(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + int arg1, + ffi.Pointer<ffi.Bool> arg2) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + int, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + int arg1, + ffi.Pointer<ffi.Bool> arg2) { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + int, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_listenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + int arg1, + ffi.Pointer<ffi.Bool> arg2) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + int, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>.isolateLocal( + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>(pointer, + retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<objc.ObjCObject>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + fromFunctionPointer(ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, ffi.UnsignedLong arg1, ffi.Pointer<ffi.Bool> arg2)>> ptr) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock( + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)> + fromFunction( + void Function(objc.ObjCObjectBase, int, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, int arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(objc.ObjCObjectBase(arg0, retain: true, release: true), arg1, arg2), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> listener( + void Function(objc.ObjCObjectBase, int, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_listenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, int arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(objc.ObjCObjectBase(arg0, retain: false, release: true), arg1, + arg2), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_1p9ui4q(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>(wrapper, retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> blocking( + void Function(objc.ObjCObjectBase, int, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_blockingCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, int arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(objc.ObjCObjectBase(arg0, retain: false, release: true), arg1, + arg2), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, int arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(objc.ObjCObjectBase(arg0, retain: false, release: true), arg1, + arg2), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_1p9ui4q( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)>(wrapper, retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool_CallExtension + on objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.UnsignedLong, + ffi.Pointer<ffi.Bool>)> { + void call(objc.ObjCObjectBase arg0, int arg1, ffi.Pointer<ffi.Bool> arg2) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.UnsignedLong arg1, + ffi.Pointer<ffi.Bool> arg2)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + int, + ffi.Pointer<ffi.Bool>)>()( + ref.pointer, arg0.ref.pointer, arg1, arg2); +} + +void _ObjCBlock_ffiVoid_ObjectType_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_ObjectType_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_ObjectType_bool_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_ObjectType_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1) => + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_ObjectType_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_ObjectType_bool_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_ObjectType_bool_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1) { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_ObjectType_bool_listenerCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_ObjectType_bool_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_ObjectType_bool_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1) { + try { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_ObjectType_bool_blockingCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>.isolateLocal( + _ObjCBlock_ffiVoid_ObjectType_bool_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_ObjectType_bool_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_ObjectType_bool_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_ffiVoid_ObjectType_bool { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock(_ObjCBlock_ffiVoid_ObjectType_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> fromFunction( + void Function(objc.ObjCObjectBase, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_ObjectType_bool_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<ffi.Bool> arg1) => + fn(objc.ObjCObjectBase(arg0, retain: true, release: true), arg1), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> listener( + void Function(objc.ObjCObjectBase, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ObjectType_bool_listenerCallable.nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<ffi.Bool> arg1) => + fn(objc.ObjCObjectBase(arg0, retain: false, release: true), arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_t8l8el(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>(wrapper, retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> blocking( + void Function(objc.ObjCObjectBase, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ObjectType_bool_blockingCallable.nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<ffi.Bool> arg1) => + fn(objc.ObjCObjectBase(arg0, retain: false, release: true), arg1), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ObjectType_bool_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<ffi.Bool> arg1) => + fn(objc.ObjCObjectBase(arg0, retain: false, release: true), arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_t8l8el( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>(wrapper, retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_ffiVoid_ObjectType_bool_CallExtension on objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Bool>)> { + void call(objc.ObjCObjectBase arg0, ffi.Pointer<ffi.Bool> arg1) => ref + .pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<ffi.Bool> arg1)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Bool>)>()(ref.pointer, arg0.ref.pointer, arg1); +} + void _ObjCBlock_ffiVoid_ffiVoid_fnPtrTrampoline( ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<ffi.Void> arg0) => block.ref.target @@ -15572,6 +21414,255 @@ ref.pointer, arg0, arg1.ref.pointer); } +void _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, + NSRange arg1, + ffi.Pointer<ffi.Bool> arg2) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<ffi.Void> arg0, NSRange arg1, + ffi.Pointer<ffi.Bool> arg2)>>() + .asFunction< + void Function(ffi.Pointer<ffi.Void>, NSRange, + ffi.Pointer<ffi.Bool>)>()(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, + NSRange arg1, + ffi.Pointer<ffi.Bool> arg2) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer<ffi.Void>, + NSRange, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)>( + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, + NSRange arg1, + ffi.Pointer<ffi.Bool> arg2) { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_listenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + NSRange, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<ffi.Void> arg0, + NSRange arg1, + ffi.Pointer<ffi.Bool> arg2) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<ffi.Void>, + NSRange, ffi.Pointer<ffi.Bool>))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<ffi.Void>, + NSRange, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_blockingCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<ffi.Void>, + NSRange, + ffi.Pointer<ffi.Bool>)>.isolateLocal( + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<ffi.Void>, + NSRange, + ffi.Pointer<ffi.Bool>)> + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<ffi.Void>, + NSRange, + ffi.Pointer<ffi.Bool>)>.listener( + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSRange_bool { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)>( + pointer, + retain: retain, + release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)> + fromFunctionPointer( + ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void> arg0, NSRange arg1, ffi.Pointer<ffi.Bool> arg2)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)>( + objc.newPointerBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)> + fromFunction(void Function(ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_closureCallable, + (ffi.Pointer<ffi.Void> arg0, NSRange arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(arg0, arg1, arg2), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)> listener( + void Function(ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_listenerCallable.nativeFunction + .cast(), + (ffi.Pointer<ffi.Void> arg0, NSRange arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(arg0, arg1, arg2), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_1q8ia8l(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.Void>, NSRange, + ffi.Pointer<ffi.Bool>)>(wrapper, retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)> blocking( + void Function(ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_blockingCallable.nativeFunction + .cast(), + (ffi.Pointer<ffi.Void> arg0, NSRange arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(arg0, arg1, arg2), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<ffi.Void> arg0, NSRange arg1, + ffi.Pointer<ffi.Bool> arg2) => + fn(arg0, arg1, arg2), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_1q8ia8l( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.Void>, NSRange, + ffi.Pointer<ffi.Bool>)>(wrapper, retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSRange_bool_CallExtension + on objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<ffi.Void>, NSRange, ffi.Pointer<ffi.Bool>)> { + void call(ffi.Pointer<ffi.Void> arg0, NSRange arg1, + ffi.Pointer<ffi.Bool> arg2) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, + NSRange arg1, + ffi.Pointer<ffi.Bool> arg2)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + NSRange, + ffi.Pointer<ffi.Bool>)>()(ref.pointer, arg0, arg1, arg2); +} + void _ObjCBlock_ffiVoid_ffiVoid_NSStream_NSStreamEvent_fnPtrTrampoline( ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<ffi.Void> arg0, @@ -15839,6 +21930,738 @@ int)>()(ref.pointer, arg0, arg1.ref.pointer, arg2.value); } +void _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, + int arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<ffi.Void> arg0, ffi.UnsignedLong arg1)>>() + .asFunction<void Function(ffi.Pointer<ffi.Void>, int)>()(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, + int arg1) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer<ffi.Void>, int))( + arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, + int arg1) { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<ffi.Void>, int))( + arg0, arg1); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.UnsignedLong)> + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_listenerCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>.listener( + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<ffi.Void> arg0, + int arg1) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<ffi.Void>, int))( + arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>, ffi.UnsignedLong)> + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_blockingCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<ffi.Void>, + ffi.UnsignedLong)>.isolateLocal( + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>, ffi.UnsignedLong)> + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<ffi.Void>, + ffi.UnsignedLong)>.listener( + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSUInteger { + /// Returns a block that wraps the given raw block pointer. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.Void>, + ffi.UnsignedLong)>(pointer, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<ffi.Void>, ffi.UnsignedLong)> fromFunctionPointer( + ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void> arg0, ffi.UnsignedLong arg1)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>( + objc.newPointerBlock( + _ObjCBlock_ffiVoid_ffiVoid_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)> + fromFunction(void Function(ffi.Pointer<ffi.Void>, int) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_closureCallable, + (ffi.Pointer<ffi.Void> arg0, int arg1) => fn(arg0, arg1), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)> + listener(void Function(ffi.Pointer<ffi.Void>, int) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_listenerCallable.nativeFunction + .cast(), + (ffi.Pointer<ffi.Void> arg0, int arg1) => fn(arg0, arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_zuf90e(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>(wrapper, + retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)> + blocking(void Function(ffi.Pointer<ffi.Void>, int) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_blockingCallable.nativeFunction + .cast(), + (ffi.Pointer<ffi.Void> arg0, int arg1) => fn(arg0, arg1), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_ffiVoid_NSUInteger_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<ffi.Void> arg0, int arg1) => fn(arg0, arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_zuf90e( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>(wrapper, + retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSUInteger_CallExtension on objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.UnsignedLong)> { + void call(ffi.Pointer<ffi.Void> arg0, int arg1) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> arg0, ffi.UnsignedLong arg1)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<ffi.Void>, + int)>()(ref.pointer, arg0, arg1); +} + +void _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>))(arg0, arg1); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_listenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_blockingCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.isolateLocal( + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>`. +abstract final class ObjCBlock_ffiVoid_idNSItemProviderReading_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, + NSError?)>(pointer, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<objc.ObjCObject>?, NSError?)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>( + objc.newPointerBlock(_ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> fromFunction( + void Function(NSItemProviderReading?, NSError?) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1) => fn( + arg0.address == 0 + ? null + : NSItemProviderReading.castFromPointer(arg0, retain: true, release: true), + arg1.address == 0 ? null : NSError.castFromPointer(arg1, retain: true, release: true)), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> + listener(void Function(NSItemProviderReading?, NSError?) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_listenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSItemProviderReading.castFromPointer(arg0, + retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_pfv6jd(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>(wrapper, + retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> + blocking(void Function(NSItemProviderReading?, NSError?) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_blockingCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSItemProviderReading.castFromPointer(arg0, + retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSItemProviderReading.castFromPointer(arg0, + retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_pfv6jd( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>(wrapper, + retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>`. +extension ObjCBlock_ffiVoid_idNSItemProviderReading_NSError_CallExtension + on objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> { + void call(NSItemProviderReading? arg0, NSError? arg1) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(ref.pointer, + arg0?.ref.pointer ?? ffi.nullptr, arg1?.ref.pointer ?? ffi.nullptr); +} + +void _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1); +ffi.Pointer<ffi.Void> + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>))(arg0, arg1); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_listenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) { + try { + (objc.getBlockClosure(block) as void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_blockingCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.isolateLocal( + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)> + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>.listener( + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>`. +abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, + NSError?)>(pointer, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<objc.ObjCObject>?, NSError?)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>( + objc.newPointerBlock(_ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> fromFunction( + void Function(NSItemProviderWriting?, NSError?) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1) => fn( + arg0.address == 0 + ? null + : NSItemProviderWriting.castFromPointer(arg0, retain: true, release: true), + arg1.address == 0 ? null : NSError.castFromPointer(arg1, retain: true, release: true)), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> + listener(void Function(NSItemProviderWriting?, NSError?) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_listenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSItemProviderWriting.castFromPointer(arg0, + retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_pfv6jd(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>(wrapper, + retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> + blocking(void Function(NSItemProviderWriting?, NSError?) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_blockingCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSItemProviderWriting.castFromPointer(arg0, + retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn( + arg0.address == 0 + ? null + : NSItemProviderWriting.castFromPointer(arg0, + retain: false, release: true), + arg1.address == 0 + ? null + : NSError.castFromPointer(arg1, + retain: false, release: true)), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_pfv6jd( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>(wrapper, + retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)>`. +extension ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError_CallExtension + on objc + .ObjCBlock<ffi.Void Function(ffi.Pointer<objc.ObjCObject>?, NSError?)> { + void call(NSItemProviderWriting? arg0, NSError? arg1) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(ref.pointer, + arg0?.ref.pointer ?? ffi.nullptr, arg1?.ref.pointer ?? ffi.nullptr); +} + void _ObjCBlock_ffiVoid_idNSSecureCoding_NSError_fnPtrTrampoline( ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<objc.ObjCObject> arg0, @@ -16092,6 +22915,222 @@ ref.pointer, arg0?.ref.pointer ?? ffi.nullptr, arg1.ref.pointer); } +void _ObjCBlock_ffiVoid_unichar_NSUInteger_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.UnsignedShort> arg0, + int arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<ffi.UnsignedShort> arg0, + ffi.UnsignedLong arg1)>>() + .asFunction<void Function(ffi.Pointer<ffi.UnsignedShort>, int)>()( + arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_unichar_NSUInteger_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_unichar_NSUInteger_fnPtrTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_unichar_NSUInteger_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.UnsignedShort> arg0, + int arg1) => + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<ffi.UnsignedShort>, int))(arg0, arg1); +ffi.Pointer<ffi.Void> _ObjCBlock_ffiVoid_unichar_NSUInteger_closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)>( + _ObjCBlock_ffiVoid_unichar_NSUInteger_closureTrampoline) + .cast(); +void _ObjCBlock_ffiVoid_unichar_NSUInteger_listenerTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.UnsignedShort> arg0, + int arg1) { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<ffi.UnsignedShort>, int))(arg0, arg1); + objc.objectRelease(block.cast()); +} + +ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)> + _ObjCBlock_ffiVoid_unichar_NSUInteger_listenerCallable = ffi.NativeCallable< + ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)>.listener( + _ObjCBlock_ffiVoid_unichar_NSUInteger_listenerTrampoline) + ..keepIsolateAlive = false; +void _ObjCBlock_ffiVoid_unichar_NSUInteger_blockingTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.Void> waiter, + ffi.Pointer<ffi.UnsignedShort> arg0, + int arg1) { + try { + (objc.getBlockClosure(block) as void Function( + ffi.Pointer<ffi.UnsignedShort>, int))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } +} + +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<ffi.UnsignedShort>, + ffi.UnsignedLong)> + _ObjCBlock_ffiVoid_unichar_NSUInteger_blockingCallable = ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<ffi.UnsignedShort>, + ffi.UnsignedLong)>.isolateLocal( + _ObjCBlock_ffiVoid_unichar_NSUInteger_blockingTrampoline) + ..keepIsolateAlive = false; +ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<ffi.UnsignedShort>, + ffi.UnsignedLong)> + _ObjCBlock_ffiVoid_unichar_NSUInteger_blockingListenerCallable = ffi + .NativeCallable< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.Void>, + ffi.Pointer<ffi.UnsignedShort>, + ffi.UnsignedLong)>.listener( + _ObjCBlock_ffiVoid_unichar_NSUInteger_blockingTrampoline) + ..keepIsolateAlive = false; + +/// Construction methods for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)>`. +abstract final class ObjCBlock_ffiVoid_unichar_NSUInteger { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, + ffi.UnsignedLong)>(pointer, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<ffi.UnsignedShort>, ffi.UnsignedLong)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer<ffi.UnsignedShort> arg0, + ffi.UnsignedLong arg1)>> + ptr) => + objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)>( + objc.newPointerBlock(_ObjCBlock_ffiVoid_unichar_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)> + fromFunction(void Function(ffi.Pointer<ffi.UnsignedShort>, int) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)>( + objc.newClosureBlock( + _ObjCBlock_ffiVoid_unichar_NSUInteger_closureCallable, + (ffi.Pointer<ffi.UnsignedShort> arg0, int arg1) => + fn(arg0, arg1), + keepIsolateAlive), + retain: false, + release: true); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)> + listener(void Function(ffi.Pointer<ffi.UnsignedShort>, int) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_unichar_NSUInteger_listenerCallable.nativeFunction + .cast(), + (ffi.Pointer<ffi.UnsignedShort> arg0, int arg1) => fn(arg0, arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapListenerBlock_vhbh5h(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, + ffi.UnsignedLong)>(wrapper, retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)> + blocking(void Function(ffi.Pointer<ffi.UnsignedShort>, int) fn, + {bool keepIsolateAlive = true}) { + final raw = objc.newClosureBlock( + _ObjCBlock_ffiVoid_unichar_NSUInteger_blockingCallable.nativeFunction + .cast(), + (ffi.Pointer<ffi.UnsignedShort> arg0, int arg1) => fn(arg0, arg1), + keepIsolateAlive); + final rawListener = objc.newClosureBlock( + _ObjCBlock_ffiVoid_unichar_NSUInteger_blockingListenerCallable + .nativeFunction + .cast(), + (ffi.Pointer<ffi.UnsignedShort> arg0, int arg1) => fn(arg0, arg1), + keepIsolateAlive); + final wrapper = _ObjectiveCBindings_wrapBlockingBlock_vhbh5h( + raw, rawListener, objc.objCContext); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, + ffi.UnsignedLong)>(wrapper, retain: false, release: true); + } +} + +/// Call operator for `objc.ObjCBlock<ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)>`. +extension ObjCBlock_ffiVoid_unichar_NSUInteger_CallExtension on objc.ObjCBlock< + ffi.Void Function(ffi.Pointer<ffi.UnsignedShort>, ffi.UnsignedLong)> { + void call(ffi.Pointer<ffi.UnsignedShort> arg0, int arg1) => ref + .pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<ffi.UnsignedShort> arg0, + ffi.UnsignedLong arg1)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<ffi.UnsignedShort>, int)>()(ref.pointer, arg0, arg1); +} + instancetype _ObjCBlock_instancetype_ffiVoid_NSCoder_fnPtrTrampoline( ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<ffi.Void> arg0, @@ -16353,6 +23392,126 @@ release: true); } +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey_fnPtrTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + block.ref.target + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>()(arg0, arg1); +ffi.Pointer<ffi.Void> + _ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey_fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey_fnPtrTrampoline) + .cast(); +ffi.Pointer<objc.ObjCObject> + _ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey_closureTrampoline( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + (objc.getBlockClosure(block) as ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>))(arg0, arg1); +ffi.Pointer<ffi.Void> + _ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey_closureCallable = + ffi.Pointer.fromFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>( + _ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey_closureTrampoline) + .cast(); + +/// Construction methods for `objc.ObjCBlock<ffi.Pointer<objc.ObjCObject>? Function(NSError, NSString)>`. +abstract final class ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey { + /// Returns a block that wraps the given raw block pointer. + static objc + .ObjCBlock<ffi.Pointer<objc.ObjCObject>? Function(NSError, NSString)> + castFromPointer(ffi.Pointer<objc.ObjCBlockImpl> pointer, + {bool retain = false, bool release = false}) => + objc.ObjCBlock< + ffi.Pointer<objc.ObjCObject>? Function(NSError, + NSString)>(pointer, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// 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<objc.ObjCObject>? Function(NSError, NSString)> fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>> + ptr) => + objc.ObjCBlock<ffi.Pointer<objc.ObjCObject>? Function(NSError, NSString)>( + objc.newPointerBlock(_ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey_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. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock<ffi.Pointer<objc.ObjCObject>? Function(NSError, NSString)> fromFunction( + objc.ObjCObjectBase? Function(NSError, NSString) fn, + {bool keepIsolateAlive = true}) => + objc.ObjCBlock<ffi.Pointer<objc.ObjCObject>? Function(NSError, NSString)>( + objc.newClosureBlock( + _ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey_closureCallable, + (ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1) => + fn(NSError.castFromPointer(arg0, retain: true, release: true), NSString.castFromPointer(arg1, retain: true, release: true)) + ?.ref + .retainAndAutorelease() ?? + ffi.nullptr, + keepIsolateAlive), + retain: false, + release: true); +} + +/// Call operator for `objc.ObjCBlock<ffi.Pointer<objc.ObjCObject>? Function(NSError, NSString)>`. +extension ObjCBlock_objcObjCObject_NSError_NSErrorUserInfoKey_CallExtension + on objc + .ObjCBlock<ffi.Pointer<objc.ObjCObject>? Function(NSError, NSString)> { + objc.ObjCObjectBase? call(NSError arg0, NSString arg1) => ref + .pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCBlockImpl> block, + ffi.Pointer<objc.ObjCObject> arg0, + ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)>() + (ref.pointer, arg0.ref.pointer, arg1.ref.pointer) + .address == + 0 + ? null + : objc.ObjCObjectBase( + ref.pointer.ref.invoke + .cast<ffi.NativeFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<objc.ObjCObject> arg0, ffi.Pointer<objc.ObjCObject> arg1)>>() + .asFunction<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)>()(ref.pointer, arg0.ref.pointer, arg1.ref.pointer), + retain: true, + release: true); +} + ffi.Pointer<objc.ObjCObject> _ObjCBlock_objcObjCObject_ffiVoid_fnPtrTrampoline( ffi.Pointer<objc.ObjCBlockImpl> block, ffi.Pointer<ffi.Void> arg0) => block.ref.target @@ -17004,6 +24163,7 @@ late final _class_DOBJCDartProtocol = objc.getClass("DOBJCDartProtocol"); late final _class_DOBJCDartProtocolBuilder = objc.getClass("DOBJCDartProtocolBuilder"); +late final _class_DOBJCObserver = objc.getClass("DOBJCObserver"); late final _class_NSArray = objc.getClass("NSArray"); late final _class_NSCharacterSet = objc.getClass("NSCharacterSet"); late final _class_NSCoder = objc.getClass("NSCoder"); @@ -17073,6 +24233,16 @@ ffi.Pointer<objc.ObjCSelector>, ffi.Pointer<objc.ObjCObject>, int)>(); +final _objc_msgSend_10mlopr = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + int Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_11cbyu0 = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -17138,6 +24308,22 @@ .asFunction< int Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>, int)>(); +final _objc_msgSend_134vhyh = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<ffi.Void>, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<ffi.Void>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_13mclwd = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -17146,6 +24332,20 @@ .asFunction< ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>, int)>(); +final _objc_msgSend_13x5boi = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_13yqbb6 = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -17154,6 +24354,22 @@ .asFunction< int Function( ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>)>(); +final _objc_msgSend_14ew8zr = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + NSRange, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + NSRange, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_14hpxwa = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -17257,6 +24473,20 @@ ffi.Pointer<ffi.Void>, int, bool)>(); +final _objc_msgSend_1698hqz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + int Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_16f0drb = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -17275,6 +24505,22 @@ .asFunction< int Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>, ffi.Pointer<objc.ObjCObject>)>(); +final _objc_msgSend_177cajs = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + NSRange, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + NSRange, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_17amj0z = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -17690,6 +24936,22 @@ .asFunction< void Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>, int)>(); +final _objc_msgSend_1i9v144 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_1iyq28l = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -17806,6 +25068,24 @@ .asFunction< int Function( ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>)>(); +final _objc_msgSend_1lbgrac = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<ffi.Void>, + ffi.UnsignedLong, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<ffi.Void>, + int, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_1lhpu4m = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -17977,6 +25257,40 @@ ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>, ffi.Pointer<objc.ObjCSelector>)>(); +final _objc_msgSend_1pl40xc = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Long, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); +final _objc_msgSend_1pl4k3n = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Void>)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<ffi.Void>)>(); final _objc_msgSend_1pl9qdv = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18001,6 +25315,22 @@ ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<ffi.Pointer<objc.ObjCObject>>)>(); +final _objc_msgSend_1q30cs4 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + NSRange, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + NSRange, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_1qv0eq4 = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18025,6 +25355,24 @@ .asFunction< int Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>, ffi.Pointer<objc.ObjCObject>)>(); +final _objc_msgSend_1s0rfm3 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Double, + ffi.Bool, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + double, + bool, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_1s2gdyk = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18215,6 +25563,20 @@ .asFunction< ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>, int)>(); +final _objc_msgSend_1x5ew3h = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_1xi08ar = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18291,6 +25653,22 @@ ffi.Pointer<objc.ObjCObject>, int, NSRange)>(); +final _objc_msgSend_2wiv66 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_3cbdpb = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18378,6 +25756,22 @@ .asFunction< ffi.Pointer<ffi.Void> Function( ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>)>(); +final _objc_msgSend_6jmuyz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + NSRange, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + int Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + NSRange, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_6peh6o = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18497,6 +25891,22 @@ .asFunction< bool Function( ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>)>(); +final _objc_msgSend_9a64f1 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Double, + ffi.Bool, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + double, + bool, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_9b3h4v = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18523,6 +25933,38 @@ ffi.Pointer<objc.ObjCSelector>, ffi.Pointer<ffi.UnsignedShort>, int)>(); +final _objc_msgSend_a3wp08 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); +final _objc_msgSend_arew0j = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + NSRange, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + NSRange, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_bfp043 = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18580,6 +26022,22 @@ ffi.Pointer<objc.ObjCSelector>, ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCObject>)>(); +final _objc_msgSend_cnxxyq = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>>() + .asFunction< + ffi.Pointer<objc.ObjCBlockImpl> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCObject>)>(); final _objc_msgSend_d3i1uy = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18721,6 +26179,16 @@ .asFunction< ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>, double)>(); +final _objc_msgSend_f167m6 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + void Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_gcjqkl = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18867,6 +26335,20 @@ int, NSRange, ffi.Pointer<NSRange>)>(); +final _objc_msgSend_jjgvjt = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_jsclrq = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18875,6 +26357,22 @@ .asFunction< bool Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>, int)>(); +final _objc_msgSend_k1x6mt = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + int Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_k4j8m3 = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18893,6 +26391,24 @@ int, int, bool)>(); +final _objc_msgSend_kshx9d = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.UnsignedLong Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + int Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + NSRange, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_l9p60w = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18975,6 +26491,16 @@ ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Void>, int)>(); +final _objc_msgSend_nnxkei = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_o16d3k = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -18989,6 +26515,20 @@ ffi.Pointer<objc.ObjCSelector>, ffi.Pointer<ffi.Pointer<objc.ObjCObject>>, NSRange)>(); +final _objc_msgSend_o762yo = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_oa8mke = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -19103,6 +26643,20 @@ .asFunction< ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>, int)>(); +final _objc_msgSend_r0bo0s = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_r49ehc = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -19161,6 +26715,40 @@ .asFunction< ffi.Pointer<NSZone> Function( ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>)>(); +final _objc_msgSend_t7arir = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + ffi.Long, + ffi.Long, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<objc.ObjCObject>, + int, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); +final _objc_msgSend_talwei = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<ffi.UnsignedShort>, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + ffi.Pointer<objc.ObjCObject> Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.Pointer<ffi.UnsignedShort>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_ud8gg = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -19276,6 +26864,20 @@ .asFunction< int Function( ffi.Pointer<objc.ObjCObject>, ffi.Pointer<objc.ObjCSelector>)>(); +final _objc_msgSend_yx8yc6 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + ffi.UnsignedLong, + ffi.Pointer<objc.ObjCBlockImpl>)>>() + .asFunction< + void Function( + ffi.Pointer<objc.ObjCObject>, + ffi.Pointer<objc.ObjCSelector>, + int, + ffi.Pointer<objc.ObjCBlockImpl>)>(); final _objc_msgSend_zmbtbd = objc.msgSendPointer .cast< ffi.NativeFunction< @@ -19528,6 +27130,8 @@ objc.registerName("dictionaryWithObjects:forKeys:"); late final _sel_dictionaryWithObjects_forKeys_count_ = objc.registerName("dictionaryWithObjects:forKeys:count:"); +late final _sel_differenceByTransformingChangesWithBlock_ = + objc.registerName("differenceByTransformingChangesWithBlock:"); late final _sel_displayNameForKey_value_ = objc.registerName("displayNameForKey:value:"); late final _sel_doesNotRecognizeSelector_ = @@ -19539,6 +27143,34 @@ late final _sel_encodeValueOfObjCType_at_ = objc.registerName("encodeValueOfObjCType:at:"); late final _sel_encodeWithCoder_ = objc.registerName("encodeWithCoder:"); +late final _sel_enumerateByteRangesUsingBlock_ = + objc.registerName("enumerateByteRangesUsingBlock:"); +late final _sel_enumerateIndexesInRange_options_usingBlock_ = + objc.registerName("enumerateIndexesInRange:options:usingBlock:"); +late final _sel_enumerateIndexesUsingBlock_ = + objc.registerName("enumerateIndexesUsingBlock:"); +late final _sel_enumerateIndexesWithOptions_usingBlock_ = + objc.registerName("enumerateIndexesWithOptions:usingBlock:"); +late final _sel_enumerateKeysAndObjectsUsingBlock_ = + objc.registerName("enumerateKeysAndObjectsUsingBlock:"); +late final _sel_enumerateKeysAndObjectsWithOptions_usingBlock_ = + objc.registerName("enumerateKeysAndObjectsWithOptions:usingBlock:"); +late final _sel_enumerateLinesUsingBlock_ = + objc.registerName("enumerateLinesUsingBlock:"); +late final _sel_enumerateObjectsAtIndexes_options_usingBlock_ = + objc.registerName("enumerateObjectsAtIndexes:options:usingBlock:"); +late final _sel_enumerateObjectsUsingBlock_ = + objc.registerName("enumerateObjectsUsingBlock:"); +late final _sel_enumerateObjectsWithOptions_usingBlock_ = + objc.registerName("enumerateObjectsWithOptions:usingBlock:"); +late final _sel_enumerateRangesInRange_options_usingBlock_ = + objc.registerName("enumerateRangesInRange:options:usingBlock:"); +late final _sel_enumerateRangesUsingBlock_ = + objc.registerName("enumerateRangesUsingBlock:"); +late final _sel_enumerateRangesWithOptions_usingBlock_ = + objc.registerName("enumerateRangesWithOptions:usingBlock:"); +late final _sel_enumerateSubstringsInRange_options_usingBlock_ = + objc.registerName("enumerateSubstringsInRange:options:usingBlock:"); late final _sel_errorWithDomain_code_userInfo_ = objc.registerName("errorWithDomain:code:userInfo:"); late final _sel_exchangeObjectAtIndex_withObjectAtIndex_ = @@ -19625,20 +27257,44 @@ objc.registerName("indexGreaterThanIndex:"); late final _sel_indexGreaterThanOrEqualToIndex_ = objc.registerName("indexGreaterThanOrEqualToIndex:"); +late final _sel_indexInRange_options_passingTest_ = + objc.registerName("indexInRange:options:passingTest:"); late final _sel_indexLessThanIndex_ = objc.registerName("indexLessThanIndex:"); late final _sel_indexLessThanOrEqualToIndex_ = objc.registerName("indexLessThanOrEqualToIndex:"); +late final _sel_indexOfObjectAtIndexes_options_passingTest_ = + objc.registerName("indexOfObjectAtIndexes:options:passingTest:"); late final _sel_indexOfObjectIdenticalTo_ = objc.registerName("indexOfObjectIdenticalTo:"); late final _sel_indexOfObjectIdenticalTo_inRange_ = objc.registerName("indexOfObjectIdenticalTo:inRange:"); +late final _sel_indexOfObjectPassingTest_ = + objc.registerName("indexOfObjectPassingTest:"); +late final _sel_indexOfObjectWithOptions_passingTest_ = + objc.registerName("indexOfObjectWithOptions:passingTest:"); late final _sel_indexOfObject_ = objc.registerName("indexOfObject:"); late final _sel_indexOfObject_inRange_ = objc.registerName("indexOfObject:inRange:"); +late final _sel_indexOfObject_inSortedRange_options_usingComparator_ = + objc.registerName("indexOfObject:inSortedRange:options:usingComparator:"); +late final _sel_indexPassingTest_ = objc.registerName("indexPassingTest:"); late final _sel_indexSet = objc.registerName("indexSet"); late final _sel_indexSetWithIndex_ = objc.registerName("indexSetWithIndex:"); late final _sel_indexSetWithIndexesInRange_ = objc.registerName("indexSetWithIndexesInRange:"); +late final _sel_indexWithOptions_passingTest_ = + objc.registerName("indexWithOptions:passingTest:"); +late final _sel_indexesInRange_options_passingTest_ = + objc.registerName("indexesInRange:options:passingTest:"); +late final _sel_indexesOfObjectsAtIndexes_options_passingTest_ = + objc.registerName("indexesOfObjectsAtIndexes:options:passingTest:"); +late final _sel_indexesOfObjectsPassingTest_ = + objc.registerName("indexesOfObjectsPassingTest:"); +late final _sel_indexesOfObjectsWithOptions_passingTest_ = + objc.registerName("indexesOfObjectsWithOptions:passingTest:"); +late final _sel_indexesPassingTest_ = objc.registerName("indexesPassingTest:"); +late final _sel_indexesWithOptions_passingTest_ = + objc.registerName("indexesWithOptions:passingTest:"); late final _sel_init = objc.registerName("init"); late final _sel_initAbsoluteURLWithDataRepresentation_relativeToURL_ = objc.registerName("initAbsoluteURLWithDataRepresentation:relativeToURL:"); @@ -19659,6 +27315,8 @@ objc.registerName("initFileURLWithPath:isDirectory:relativeToURL:"); late final _sel_initFileURLWithPath_relativeToURL_ = objc.registerName("initFileURLWithPath:relativeToURL:"); +late final _sel_initForKeyPath_ofObject_withBlock_ = + objc.registerName("initForKeyPath:ofObject:withBlock:"); late final _sel_initToBuffer_capacity_ = objc.registerName("initToBuffer:capacity:"); late final _sel_initToFileAtPath_append_ = @@ -19676,6 +27334,10 @@ late final _sel_initWithBool_ = objc.registerName("initWithBool:"); late final _sel_initWithBytesNoCopy_length_ = objc.registerName("initWithBytesNoCopy:length:"); +late final _sel_initWithBytesNoCopy_length_deallocator_ = + objc.registerName("initWithBytesNoCopy:length:deallocator:"); +late final _sel_initWithBytesNoCopy_length_encoding_deallocator_ = + objc.registerName("initWithBytesNoCopy:length:encoding:deallocator:"); late final _sel_initWithBytesNoCopy_length_encoding_freeWhenDone_ = objc.registerName("initWithBytesNoCopy:length:encoding:freeWhenDone:"); late final _sel_initWithBytesNoCopy_length_freeWhenDone_ = @@ -19691,6 +27353,8 @@ late final _sel_initWithCapacity_ = objc.registerName("initWithCapacity:"); late final _sel_initWithChanges_ = objc.registerName("initWithChanges:"); late final _sel_initWithChar_ = objc.registerName("initWithChar:"); +late final _sel_initWithCharactersNoCopy_length_deallocator_ = + objc.registerName("initWithCharactersNoCopy:length:deallocator:"); late final _sel_initWithCharactersNoCopy_length_freeWhenDone_ = objc.registerName("initWithCharactersNoCopy:length:freeWhenDone:"); late final _sel_initWithCharacters_length_ = @@ -19725,6 +27389,8 @@ objc.registerName("initWithDomain:code:userInfo:"); late final _sel_initWithDouble_ = objc.registerName("initWithDouble:"); late final _sel_initWithFileAtPath_ = objc.registerName("initWithFileAtPath:"); +late final _sel_initWithFireDate_interval_repeats_block_ = + objc.registerName("initWithFireDate:interval:repeats:block:"); late final _sel_initWithFireDate_interval_target_selector_userInfo_repeats_ = objc.registerName( "initWithFireDate:interval:target:selector:userInfo:repeats:"); @@ -19873,8 +27539,16 @@ objc.registerName( "itemProviderVisibilityForRepresentationWithTypeIdentifier:"); late final _sel_keyEnumerator = objc.registerName("keyEnumerator"); +late final _sel_keysOfEntriesPassingTest_ = + objc.registerName("keysOfEntriesPassingTest:"); +late final _sel_keysOfEntriesWithOptions_passingTest_ = + objc.registerName("keysOfEntriesWithOptions:passingTest:"); +late final _sel_keysSortedByValueUsingComparator_ = + objc.registerName("keysSortedByValueUsingComparator:"); late final _sel_keysSortedByValueUsingSelector_ = objc.registerName("keysSortedByValueUsingSelector:"); +late final _sel_keysSortedByValueWithOptions_usingComparator_ = + objc.registerName("keysSortedByValueWithOptions:usingComparator:"); late final _sel_lastIndex = objc.registerName("lastIndex"); late final _sel_lastObject = objc.registerName("lastObject"); late final _sel_laterDate_ = objc.registerName("laterDate:"); @@ -19885,8 +27559,22 @@ late final _sel_limitDateForMode_ = objc.registerName("limitDateForMode:"); late final _sel_lineRangeForRange_ = objc.registerName("lineRangeForRange:"); late final _sel_load = objc.registerName("load"); +late final _sel_loadDataRepresentationForTypeIdentifier_completionHandler_ = + objc.registerName( + "loadDataRepresentationForTypeIdentifier:completionHandler:"); +late final _sel_loadDataWithTypeIdentifier_forItemProviderCompletionHandler_ = + objc.registerName( + "loadDataWithTypeIdentifier:forItemProviderCompletionHandler:"); +late final _sel_loadFileRepresentationForTypeIdentifier_completionHandler_ = + objc.registerName( + "loadFileRepresentationForTypeIdentifier:completionHandler:"); +late final _sel_loadInPlaceFileRepresentationForTypeIdentifier_completionHandler_ = + objc.registerName( + "loadInPlaceFileRepresentationForTypeIdentifier:completionHandler:"); late final _sel_loadItemForTypeIdentifier_options_completionHandler_ = objc.registerName("loadItemForTypeIdentifier:options:completionHandler:"); +late final _sel_loadObjectOfClass_completionHandler_ = + objc.registerName("loadObjectOfClass:completionHandler:"); late final _sel_localeWithLocaleIdentifier_ = objc.registerName("localeWithLocaleIdentifier:"); late final _sel_localizedCapitalizedString = @@ -19998,6 +27686,11 @@ late final _sel_objectsAtIndexes_ = objc.registerName("objectsAtIndexes:"); late final _sel_objectsForKeys_notFoundMarker_ = objc.registerName("objectsForKeys:notFoundMarker:"); +late final _sel_objectsPassingTest_ = objc.registerName("objectsPassingTest:"); +late final _sel_objectsWithOptions_passingTest_ = + objc.registerName("objectsWithOptions:passingTest:"); +late final _sel_observeValueForKeyPath_ofObject_change_context_ = + objc.registerName("observeValueForKeyPath:ofObject:change:context:"); late final _sel_open = objc.registerName("open"); late final _sel_orderedSet = objc.registerName("orderedSet"); late final _sel_orderedSetWithArray_ = @@ -20069,6 +27762,16 @@ late final _sel_receivePort = objc.registerName("receivePort"); late final _sel_recoveryAttempter = objc.registerName("recoveryAttempter"); late final _sel_registerClass = objc.registerName("registerClass"); +late final _sel_registerDataRepresentationForTypeIdentifier_visibility_loadHandler_ = + objc.registerName( + "registerDataRepresentationForTypeIdentifier:visibility:loadHandler:"); +late final _sel_registerFileRepresentationForTypeIdentifier_fileOptions_visibility_loadHandler_ = + objc.registerName( + "registerFileRepresentationForTypeIdentifier:fileOptions:visibility:loadHandler:"); +late final _sel_registerItemForTypeIdentifier_loadHandler_ = + objc.registerName("registerItemForTypeIdentifier:loadHandler:"); +late final _sel_registerObjectOfClass_visibility_loadHandler_ = + objc.registerName("registerObjectOfClass:visibility:loadHandler:"); late final _sel_registerObject_visibility_ = objc.registerName("registerObject:visibility:"); late final _sel_registeredTypeIdentifiers = @@ -20079,6 +27782,7 @@ late final _sel_relativeString = objc.registerName("relativeString"); late final _sel_release = objc.registerName("release"); late final _sel_removals = objc.registerName("removals"); +late final _sel_remove = objc.registerName("remove"); late final _sel_removeAllCachedResourceValues = objc.registerName("removeAllCachedResourceValues"); late final _sel_removeAllIndexes = objc.registerName("removeAllIndexes"); @@ -20148,6 +27852,8 @@ objc.registerName("scheduleInRunLoop:forMode:"); late final _sel_scheduledTimerWithTimeInterval_invocation_repeats_ = objc.registerName("scheduledTimerWithTimeInterval:invocation:repeats:"); +late final _sel_scheduledTimerWithTimeInterval_repeats_block_ = + objc.registerName("scheduledTimerWithTimeInterval:repeats:block:"); late final _sel_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ = objc.registerName( "scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:"); @@ -20196,6 +27902,8 @@ late final _sel_setTemporaryResourceValue_forKey_ = objc.registerName("setTemporaryResourceValue:forKey:"); late final _sel_setTolerance_ = objc.registerName("setTolerance:"); +late final _sel_setUserInfoValueProviderForDomain_provider_ = + objc.registerName("setUserInfoValueProviderForDomain:provider:"); late final _sel_setWithArray_ = objc.registerName("setWithArray:"); late final _sel_setWithCapacity_ = objc.registerName("setWithCapacity:"); late final _sel_setWithObject_ = objc.registerName("setWithObject:"); @@ -20209,16 +27917,26 @@ late final _sel_signatureWithObjCTypes_ = objc.registerName("signatureWithObjCTypes:"); late final _sel_smallestEncoding = objc.registerName("smallestEncoding"); +late final _sel_sortRange_options_usingComparator_ = + objc.registerName("sortRange:options:usingComparator:"); +late final _sel_sortUsingComparator_ = + objc.registerName("sortUsingComparator:"); late final _sel_sortUsingFunction_context_ = objc.registerName("sortUsingFunction:context:"); late final _sel_sortUsingSelector_ = objc.registerName("sortUsingSelector:"); +late final _sel_sortWithOptions_usingComparator_ = + objc.registerName("sortWithOptions:usingComparator:"); late final _sel_sortedArrayHint = objc.registerName("sortedArrayHint"); +late final _sel_sortedArrayUsingComparator_ = + objc.registerName("sortedArrayUsingComparator:"); late final _sel_sortedArrayUsingFunction_context_ = objc.registerName("sortedArrayUsingFunction:context:"); late final _sel_sortedArrayUsingFunction_context_hint_ = objc.registerName("sortedArrayUsingFunction:context:hint:"); late final _sel_sortedArrayUsingSelector_ = objc.registerName("sortedArrayUsingSelector:"); +late final _sel_sortedArrayWithOptions_usingComparator_ = + objc.registerName("sortedArrayWithOptions:usingComparator:"); late final _sel_standardizedURL = objc.registerName("standardizedURL"); late final _sel_startAccessingSecurityScopedResource = objc.registerName("startAccessingSecurityScopedResource"); @@ -20288,6 +28006,8 @@ objc.registerName("timeIntervalSinceReferenceDate"); late final _sel_timerWithTimeInterval_invocation_repeats_ = objc.registerName("timerWithTimeInterval:invocation:repeats:"); +late final _sel_timerWithTimeInterval_repeats_block_ = + objc.registerName("timerWithTimeInterval:repeats:block:"); late final _sel_timerWithTimeInterval_target_selector_userInfo_repeats_ = objc .registerName("timerWithTimeInterval:target:selector:userInfo:repeats:"); late final _sel_tolerance = objc.registerName("tolerance"); @@ -20309,6 +28029,8 @@ objc.registerName("uppercaseStringWithLocale:"); late final _sel_user = objc.registerName("user"); late final _sel_userInfo = objc.registerName("userInfo"); +late final _sel_userInfoValueProviderForDomain_ = + objc.registerName("userInfoValueProviderForDomain:"); late final _sel_versionForClassName_ = objc.registerName("versionForClassName:"); late final _sel_whitespaceAndNewlineCharacterSet = @@ -20336,74 +28058,3 @@ late final _sel_zone = objc.registerName("zone"); typedef instancetype = ffi.Pointer<objc.ObjCObject>; typedef Dartinstancetype = objc.ObjCObjectBase; - -class _NSArrayIterator implements Iterator<objc.ObjCObjectBase> { - final Iterable<objc.ObjCObjectBase> _iterable; - final int _length; - int _index; - objc.ObjCObjectBase? _current; - - _NSArrayIterator(Iterable<objc.ObjCObjectBase> iterable) - : _iterable = iterable, - _length = iterable.length, - _index = 0; - - @override - objc.ObjCObjectBase get current => _current!; - - @override - @pragma('vm:prefer-inline') - bool moveNext() { - final length = _iterable.length; - if (_length != length) { - throw ConcurrentModificationError(_iterable); - } - if (_index >= length) { - _current = null; - return false; - } - _current = _iterable.elementAt(_index); - _index++; - return true; - } -} - -class _NSDictionaryKeyIterable with Iterable<NSCopying> { - NSDictionary _dictionary; - - _NSDictionaryKeyIterable(this._dictionary); - - @override - int get length => _dictionary.length; - - @override - Iterator<NSCopying> get iterator => - _NSDictionaryKeyIterator(_dictionary.keyEnumerator()); - - @override - bool contains(Object? key) => _dictionary.containsKey(key); -} - -class _NSDictionaryValueIterable with Iterable<objc.ObjCObjectBase> { - NSDictionary _dictionary; - - _NSDictionaryValueIterable(this._dictionary); - - @override - int get length => _dictionary.length; - - @override - Iterator<objc.ObjCObjectBase> get iterator => _dictionary.objectEnumerator(); -} - -class _NSDictionaryKeyIterator implements Iterator<NSCopying> { - final Iterator<objc.ObjCObjectBase> _iterator; - _NSDictionaryKeyIterator(this._iterator); - - @override - NSCopying get current => NSCopying.castFrom(_iterator.current); - - @override - @pragma('vm:prefer-inline') - bool moveNext() => _iterator.moveNext(); -}
diff --git a/pkgs/objective_c/lib/src/observer.dart b/pkgs/objective_c/lib/src/observer.dart new file mode 100644 index 0000000..ff0202b --- /dev/null +++ b/pkgs/objective_c/lib/src/observer.dart
@@ -0,0 +1,25 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +typedef Observer = void Function( + NSObject observed, ObjCObjectBase oldValue, ObjCObjectBase newValue); + +extension Observed on NSObject { + Observation addObserver(String key, DOBJCObserverBlock block) => + Observation._(DOBJCObserver() + .initForKeyPath(key.toNSString(), ofObject: this, withBlock: block)); + + Observation addObserverListener(String key, Observer observer, + {bool keepIsolateAlive = false}) => + addObserver( + key, + DOBJCObserverBlock.listener(observer, + keepIsolateAlive: keepIsolateAlive)); +} + +class Observation { + DOBJCObserver _observer; + Observation._(this._observer); + void remove() => _observer.remove(); +}
diff --git a/pkgs/objective_c/macos/Classes/objective_c.m b/pkgs/objective_c/macos/Classes/objective_c.m index 745ecab..b3ce4fb 100644 --- a/pkgs/objective_c/macos/Classes/objective_c.m +++ b/pkgs/objective_c/macos/Classes/objective_c.m
@@ -7,4 +7,5 @@ #include "../../src/input_stream_adapter.m" #include "../../src/objective_c.m" #include "../../src/objective_c_bindings_generated.m" +#include "../../src/observer.m" #include "../../src/protocol.m"
diff --git a/pkgs/objective_c/src/objective_c_bindings_generated.m b/pkgs/objective_c/src/objective_c_bindings_generated.m index c2d2d99..e4ead39 100644 --- a/pkgs/objective_c/src/objective_c_bindings_generated.m +++ b/pkgs/objective_c/src/objective_c_bindings_generated.m
@@ -4,6 +4,7 @@ #import "foundation.h" #import "input_stream_adapter.h" #import "ns_number.h" +#import "observer.h" #import "protocol.h" #if !__has_feature(objc_arc) @@ -84,165 +85,107 @@ return ((ProtocolTrampoline_1)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); } -typedef unsigned long (^ProtocolTrampoline_2)(void * sel); +typedef id (^ProtocolTrampoline_2)(void * sel, id arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +id _ObjectiveCBindings_protocolTrampoline_1q0i84(id target, void * sel, id arg1, id arg2) { + return ((ProtocolTrampoline_2)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); +} + +typedef unsigned long (^ProtocolTrampoline_3)(void * sel); __attribute__((visibility("default"))) __attribute__((used)) unsigned long _ObjectiveCBindings_protocolTrampoline_1ckyi24(id target, void * sel) { - return ((ProtocolTrampoline_2)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); + return ((ProtocolTrampoline_3)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); } -typedef unsigned long (^ProtocolTrampoline_3)(void * sel, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3); +typedef unsigned long (^ProtocolTrampoline_4)(void * sel, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3); __attribute__((visibility("default"))) __attribute__((used)) unsigned long _ObjectiveCBindings_protocolTrampoline_17ap02x(id target, void * sel, NSFastEnumerationState * arg1, id * arg2, unsigned long arg3) { - return ((ProtocolTrampoline_3)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); + return ((ProtocolTrampoline_4)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); } -typedef struct _NSZone * (^ProtocolTrampoline_4)(void * sel); +typedef struct _NSZone * (^ProtocolTrampoline_5)(void * sel); __attribute__((visibility("default"))) __attribute__((used)) struct _NSZone * _ObjectiveCBindings_protocolTrampoline_1a8cl66(id target, void * sel) { - return ((ProtocolTrampoline_4)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); -} - -typedef BOOL (^ProtocolTrampoline_5)(void * sel); -__attribute__((visibility("default"))) __attribute__((used)) -BOOL _ObjectiveCBindings_protocolTrampoline_e3qsqz(id target, void * sel) { return ((ProtocolTrampoline_5)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); } -typedef BOOL (^ProtocolTrampoline_6)(void * sel, id arg1); +typedef BOOL (^ProtocolTrampoline_6)(void * sel); __attribute__((visibility("default"))) __attribute__((used)) -BOOL _ObjectiveCBindings_protocolTrampoline_3su7tt(id target, void * sel, id arg1) { - return ((ProtocolTrampoline_6)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); +BOOL _ObjectiveCBindings_protocolTrampoline_e3qsqz(id target, void * sel) { + return ((ProtocolTrampoline_6)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); } -typedef BOOL (^ProtocolTrampoline_7)(void * sel, struct objc_selector * arg1); +typedef BOOL (^ProtocolTrampoline_7)(void * sel, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -BOOL _ObjectiveCBindings_protocolTrampoline_w1e3k0(id target, void * sel, struct objc_selector * arg1) { +BOOL _ObjectiveCBindings_protocolTrampoline_3su7tt(id target, void * sel, id arg1) { return ((ProtocolTrampoline_7)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); } -typedef void (^ListenerTrampoline)(id arg0, id arg1, id arg2); +typedef BOOL (^ProtocolTrampoline_8)(void * sel, struct objc_selector * arg1); __attribute__((visibility("default"))) __attribute__((used)) -ListenerTrampoline _ObjectiveCBindings_wrapListenerBlock_1b3bb6a(ListenerTrampoline block) NS_RETURNS_RETAINED { - return ^void(id arg0, id arg1, id arg2) { +BOOL _ObjectiveCBindings_protocolTrampoline_w1e3k0(id target, void * sel, struct objc_selector * arg1) { + return ((ProtocolTrampoline_8)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); +} + +typedef void (^ListenerTrampoline)(); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline _ObjectiveCBindings_wrapListenerBlock_1pl9qdv(ListenerTrampoline block) NS_RETURNS_RETAINED { + return ^void() { objc_retainBlock(block); - block(objc_retainBlock(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + block(); }; } -typedef void (^BlockingTrampoline)(void * waiter, id arg0, id arg1, id arg2); +typedef void (^BlockingTrampoline)(void * waiter); __attribute__((visibility("default"))) __attribute__((used)) -ListenerTrampoline _ObjectiveCBindings_wrapBlockingBlock_1b3bb6a( +ListenerTrampoline _ObjectiveCBindings_wrapBlockingBlock_1pl9qdv( BlockingTrampoline block, BlockingTrampoline listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1, id arg2), { + BLOCKING_BLOCK_IMPL(ctx, ^void(), { objc_retainBlock(block); - block(nil, objc_retainBlock(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + block(nil); }, { objc_retainBlock(listenerBlock); - listenerBlock(waiter, objc_retainBlock(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + listenerBlock(waiter); }); } -typedef void (^ListenerTrampoline_1)(void * arg0); +typedef void (^ListenerTrampoline_1)(id arg0, id arg1, BOOL * arg2); __attribute__((visibility("default"))) __attribute__((used)) -ListenerTrampoline_1 _ObjectiveCBindings_wrapListenerBlock_ovsamd(ListenerTrampoline_1 block) NS_RETURNS_RETAINED { - return ^void(void * arg0) { +ListenerTrampoline_1 _ObjectiveCBindings_wrapListenerBlock_1o83rbn(ListenerTrampoline_1 block) NS_RETURNS_RETAINED { + return ^void(id arg0, id arg1, BOOL * arg2) { objc_retainBlock(block); - block(arg0); + block((__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), arg2); }; } -typedef void (^BlockingTrampoline_1)(void * waiter, void * arg0); +typedef void (^BlockingTrampoline_1)(void * waiter, id arg0, id arg1, BOOL * arg2); __attribute__((visibility("default"))) __attribute__((used)) -ListenerTrampoline_1 _ObjectiveCBindings_wrapBlockingBlock_ovsamd( +ListenerTrampoline_1 _ObjectiveCBindings_wrapBlockingBlock_1o83rbn( BlockingTrampoline_1 block, BlockingTrampoline_1 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0), { + BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1, BOOL * arg2), { objc_retainBlock(block); - block(nil, arg0); + block(nil, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), arg2); }, { objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0); + listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), arg2); }); } -typedef void (^ProtocolTrampoline_8)(void * sel); +typedef void (^ListenerTrampoline_2)(id arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -void _ObjectiveCBindings_protocolTrampoline_ovsamd(id target, void * sel) { - return ((ProtocolTrampoline_8)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); -} - -typedef void (^ListenerTrampoline_2)(void * arg0, id arg1); -__attribute__((visibility("default"))) __attribute__((used)) -ListenerTrampoline_2 _ObjectiveCBindings_wrapListenerBlock_18v1jvf(ListenerTrampoline_2 block) NS_RETURNS_RETAINED { - return ^void(void * arg0, id arg1) { - objc_retainBlock(block); - block(arg0, (__bridge id)(__bridge_retained void*)(arg1)); - }; -} - -typedef void (^BlockingTrampoline_2)(void * waiter, void * arg0, id arg1); -__attribute__((visibility("default"))) __attribute__((used)) -ListenerTrampoline_2 _ObjectiveCBindings_wrapBlockingBlock_18v1jvf( - BlockingTrampoline_2 block, BlockingTrampoline_2 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1), { - objc_retainBlock(block); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1)); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1)); - }); -} - -typedef void (^ProtocolTrampoline_9)(void * sel, id arg1); -__attribute__((visibility("default"))) __attribute__((used)) -void _ObjectiveCBindings_protocolTrampoline_18v1jvf(id target, void * sel, id arg1) { - return ((ProtocolTrampoline_9)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); -} - -typedef void (^ListenerTrampoline_3)(void * arg0, id arg1, NSStreamEvent arg2); -__attribute__((visibility("default"))) __attribute__((used)) -ListenerTrampoline_3 _ObjectiveCBindings_wrapListenerBlock_hoampi(ListenerTrampoline_3 block) NS_RETURNS_RETAINED { - return ^void(void * arg0, id arg1, NSStreamEvent arg2) { - objc_retainBlock(block); - block(arg0, (__bridge id)(__bridge_retained void*)(arg1), arg2); - }; -} - -typedef void (^BlockingTrampoline_3)(void * waiter, void * arg0, id arg1, NSStreamEvent arg2); -__attribute__((visibility("default"))) __attribute__((used)) -ListenerTrampoline_3 _ObjectiveCBindings_wrapBlockingBlock_hoampi( - BlockingTrampoline_3 block, BlockingTrampoline_3 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, NSStreamEvent arg2), { - objc_retainBlock(block); - block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), arg2); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), arg2); - }); -} - -typedef void (^ProtocolTrampoline_10)(void * sel, id arg1, NSStreamEvent arg2); -__attribute__((visibility("default"))) __attribute__((used)) -void _ObjectiveCBindings_protocolTrampoline_hoampi(id target, void * sel, id arg1, NSStreamEvent arg2) { - return ((ProtocolTrampoline_10)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); -} - -typedef void (^ListenerTrampoline_4)(id arg0, id arg1); -__attribute__((visibility("default"))) __attribute__((used)) -ListenerTrampoline_4 _ObjectiveCBindings_wrapListenerBlock_pfv6jd(ListenerTrampoline_4 block) NS_RETURNS_RETAINED { +ListenerTrampoline_2 _ObjectiveCBindings_wrapListenerBlock_pfv6jd(ListenerTrampoline_2 block) NS_RETURNS_RETAINED { return ^void(id arg0, id arg1) { objc_retainBlock(block); block((__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1)); }; } -typedef void (^BlockingTrampoline_4)(void * waiter, id arg0, id arg1); +typedef void (^BlockingTrampoline_2)(void * waiter, id arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -ListenerTrampoline_4 _ObjectiveCBindings_wrapBlockingBlock_pfv6jd( - BlockingTrampoline_4 block, BlockingTrampoline_4 listenerBlock, +ListenerTrampoline_2 _ObjectiveCBindings_wrapBlockingBlock_pfv6jd( + BlockingTrampoline_2 block, BlockingTrampoline_2 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1), { objc_retainBlock(block); @@ -253,40 +196,403 @@ }); } -typedef id (^ProtocolTrampoline_11)(void * sel, id arg1); +typedef void (^ListenerTrampoline_3)(id arg0, id arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_3 _ObjectiveCBindings_wrapListenerBlock_1b3bb6a(ListenerTrampoline_3 block) NS_RETURNS_RETAINED { + return ^void(id arg0, id arg1, id arg2) { + objc_retainBlock(block); + block(objc_retainBlock(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + }; +} + +typedef void (^BlockingTrampoline_3)(void * waiter, id arg0, id arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_3 _ObjectiveCBindings_wrapBlockingBlock_1b3bb6a( + BlockingTrampoline_3 block, BlockingTrampoline_3 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1, id arg2), { + objc_retainBlock(block); + block(nil, objc_retainBlock(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, objc_retainBlock(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + }); +} + +typedef void (^ListenerTrampoline_4)(id arg0, id arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_4 _ObjectiveCBindings_wrapListenerBlock_r8gdi7(ListenerTrampoline_4 block) NS_RETURNS_RETAINED { + return ^void(id arg0, id arg1, id arg2) { + objc_retainBlock(block); + block((__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + }; +} + +typedef void (^BlockingTrampoline_4)(void * waiter, id arg0, id arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_4 _ObjectiveCBindings_wrapBlockingBlock_r8gdi7( + BlockingTrampoline_4 block, BlockingTrampoline_4 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, id arg1, id arg2), { + objc_retainBlock(block); + block(nil, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2)); + }); +} + +typedef void (^ListenerTrampoline_5)(struct _NSRange arg0, BOOL * arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_5 _ObjectiveCBindings_wrapListenerBlock_zkjmn1(ListenerTrampoline_5 block) NS_RETURNS_RETAINED { + return ^void(struct _NSRange arg0, BOOL * arg1) { + objc_retainBlock(block); + block(arg0, arg1); + }; +} + +typedef void (^BlockingTrampoline_5)(void * waiter, struct _NSRange arg0, BOOL * arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_5 _ObjectiveCBindings_wrapBlockingBlock_zkjmn1( + BlockingTrampoline_5 block, BlockingTrampoline_5 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(struct _NSRange arg0, BOOL * arg1), { + objc_retainBlock(block); + block(nil, arg0, arg1); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, arg0, arg1); + }); +} + +typedef void (^ListenerTrampoline_6)(id arg0, struct _NSRange arg1, struct _NSRange arg2, BOOL * arg3); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_6 _ObjectiveCBindings_wrapListenerBlock_lmc3p5(ListenerTrampoline_6 block) NS_RETURNS_RETAINED { + return ^void(id arg0, struct _NSRange arg1, struct _NSRange arg2, BOOL * arg3) { + objc_retainBlock(block); + block((__bridge id)(__bridge_retained void*)(arg0), arg1, arg2, arg3); + }; +} + +typedef void (^BlockingTrampoline_6)(void * waiter, id arg0, struct _NSRange arg1, struct _NSRange arg2, BOOL * arg3); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_6 _ObjectiveCBindings_wrapBlockingBlock_lmc3p5( + BlockingTrampoline_6 block, BlockingTrampoline_6 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, struct _NSRange arg1, struct _NSRange arg2, BOOL * arg3), { + objc_retainBlock(block); + block(nil, (__bridge id)(__bridge_retained void*)(arg0), arg1, arg2, arg3); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), arg1, arg2, arg3); + }); +} + +typedef void (^ListenerTrampoline_7)(id arg0, BOOL * arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_7 _ObjectiveCBindings_wrapListenerBlock_t8l8el(ListenerTrampoline_7 block) NS_RETURNS_RETAINED { + return ^void(id arg0, BOOL * arg1) { + objc_retainBlock(block); + block((__bridge id)(__bridge_retained void*)(arg0), arg1); + }; +} + +typedef void (^BlockingTrampoline_7)(void * waiter, id arg0, BOOL * arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_7 _ObjectiveCBindings_wrapBlockingBlock_t8l8el( + BlockingTrampoline_7 block, BlockingTrampoline_7 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, BOOL * arg1), { + objc_retainBlock(block); + block(nil, (__bridge id)(__bridge_retained void*)(arg0), arg1); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), arg1); + }); +} + +typedef void (^ListenerTrampoline_8)(id arg0); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_8 _ObjectiveCBindings_wrapListenerBlock_xtuoz7(ListenerTrampoline_8 block) NS_RETURNS_RETAINED { + return ^void(id arg0) { + objc_retainBlock(block); + block((__bridge id)(__bridge_retained void*)(arg0)); + }; +} + +typedef void (^BlockingTrampoline_8)(void * waiter, id arg0); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_8 _ObjectiveCBindings_wrapBlockingBlock_xtuoz7( + BlockingTrampoline_8 block, BlockingTrampoline_8 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0), { + objc_retainBlock(block); + block(nil, (__bridge id)(__bridge_retained void*)(arg0)); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0)); + }); +} + +typedef void (^ListenerTrampoline_9)(unsigned long arg0, BOOL * arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_9 _ObjectiveCBindings_wrapListenerBlock_q5jeyk(ListenerTrampoline_9 block) NS_RETURNS_RETAINED { + return ^void(unsigned long arg0, BOOL * arg1) { + objc_retainBlock(block); + block(arg0, arg1); + }; +} + +typedef void (^BlockingTrampoline_9)(void * waiter, unsigned long arg0, BOOL * arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_9 _ObjectiveCBindings_wrapBlockingBlock_q5jeyk( + BlockingTrampoline_9 block, BlockingTrampoline_9 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(unsigned long arg0, BOOL * arg1), { + objc_retainBlock(block); + block(nil, arg0, arg1); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, arg0, arg1); + }); +} + +typedef void (^ListenerTrampoline_10)(id arg0, BOOL arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_10 _ObjectiveCBindings_wrapListenerBlock_rnu2c5(ListenerTrampoline_10 block) NS_RETURNS_RETAINED { + return ^void(id arg0, BOOL arg1, id arg2) { + objc_retainBlock(block); + block((__bridge id)(__bridge_retained void*)(arg0), arg1, (__bridge id)(__bridge_retained void*)(arg2)); + }; +} + +typedef void (^BlockingTrampoline_10)(void * waiter, id arg0, BOOL arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_10 _ObjectiveCBindings_wrapBlockingBlock_rnu2c5( + BlockingTrampoline_10 block, BlockingTrampoline_10 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, BOOL arg1, id arg2), { + objc_retainBlock(block); + block(nil, (__bridge id)(__bridge_retained void*)(arg0), arg1, (__bridge id)(__bridge_retained void*)(arg2)); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), arg1, (__bridge id)(__bridge_retained void*)(arg2)); + }); +} + +typedef void (^ListenerTrampoline_11)(id arg0, unsigned long arg1, BOOL * arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_11 _ObjectiveCBindings_wrapListenerBlock_1p9ui4q(ListenerTrampoline_11 block) NS_RETURNS_RETAINED { + return ^void(id arg0, unsigned long arg1, BOOL * arg2) { + objc_retainBlock(block); + block((__bridge id)(__bridge_retained void*)(arg0), arg1, arg2); + }; +} + +typedef void (^BlockingTrampoline_11)(void * waiter, id arg0, unsigned long arg1, BOOL * arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_11 _ObjectiveCBindings_wrapBlockingBlock_1p9ui4q( + BlockingTrampoline_11 block, BlockingTrampoline_11 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, unsigned long arg1, BOOL * arg2), { + objc_retainBlock(block); + block(nil, (__bridge id)(__bridge_retained void*)(arg0), arg1, arg2); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), arg1, arg2); + }); +} + +typedef void (^ListenerTrampoline_12)(void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_12 _ObjectiveCBindings_wrapListenerBlock_ovsamd(ListenerTrampoline_12 block) NS_RETURNS_RETAINED { + return ^void(void * arg0) { + objc_retainBlock(block); + block(arg0); + }; +} + +typedef void (^BlockingTrampoline_12)(void * waiter, void * arg0); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_12 _ObjectiveCBindings_wrapBlockingBlock_ovsamd( + BlockingTrampoline_12 block, BlockingTrampoline_12 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0), { + objc_retainBlock(block); + block(nil, arg0); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, arg0); + }); +} + +typedef void (^ProtocolTrampoline_9)(void * sel); +__attribute__((visibility("default"))) __attribute__((used)) +void _ObjectiveCBindings_protocolTrampoline_ovsamd(id target, void * sel) { + return ((ProtocolTrampoline_9)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); +} + +typedef void (^ListenerTrampoline_13)(void * arg0, id arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_13 _ObjectiveCBindings_wrapListenerBlock_18v1jvf(ListenerTrampoline_13 block) NS_RETURNS_RETAINED { + return ^void(void * arg0, id arg1) { + objc_retainBlock(block); + block(arg0, (__bridge id)(__bridge_retained void*)(arg1)); + }; +} + +typedef void (^BlockingTrampoline_13)(void * waiter, void * arg0, id arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_13 _ObjectiveCBindings_wrapBlockingBlock_18v1jvf( + BlockingTrampoline_13 block, BlockingTrampoline_13 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1), { + objc_retainBlock(block); + block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1)); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1)); + }); +} + +typedef void (^ProtocolTrampoline_10)(void * sel, id arg1); +__attribute__((visibility("default"))) __attribute__((used)) +void _ObjectiveCBindings_protocolTrampoline_18v1jvf(id target, void * sel, id arg1) { + return ((ProtocolTrampoline_10)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); +} + +typedef void (^ListenerTrampoline_14)(void * arg0, struct _NSRange arg1, BOOL * arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_14 _ObjectiveCBindings_wrapListenerBlock_1q8ia8l(ListenerTrampoline_14 block) NS_RETURNS_RETAINED { + return ^void(void * arg0, struct _NSRange arg1, BOOL * arg2) { + objc_retainBlock(block); + block(arg0, arg1, arg2); + }; +} + +typedef void (^BlockingTrampoline_14)(void * waiter, void * arg0, struct _NSRange arg1, BOOL * arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_14 _ObjectiveCBindings_wrapBlockingBlock_1q8ia8l( + BlockingTrampoline_14 block, BlockingTrampoline_14 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, struct _NSRange arg1, BOOL * arg2), { + objc_retainBlock(block); + block(nil, arg0, arg1, arg2); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, arg0, arg1, arg2); + }); +} + +typedef void (^ListenerTrampoline_15)(void * arg0, id arg1, NSStreamEvent arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_15 _ObjectiveCBindings_wrapListenerBlock_hoampi(ListenerTrampoline_15 block) NS_RETURNS_RETAINED { + return ^void(void * arg0, id arg1, NSStreamEvent arg2) { + objc_retainBlock(block); + block(arg0, (__bridge id)(__bridge_retained void*)(arg1), arg2); + }; +} + +typedef void (^BlockingTrampoline_15)(void * waiter, void * arg0, id arg1, NSStreamEvent arg2); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_15 _ObjectiveCBindings_wrapBlockingBlock_hoampi( + BlockingTrampoline_15 block, BlockingTrampoline_15 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, NSStreamEvent arg2), { + objc_retainBlock(block); + block(nil, arg0, (__bridge id)(__bridge_retained void*)(arg1), arg2); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, arg0, (__bridge id)(__bridge_retained void*)(arg1), arg2); + }); +} + +typedef void (^ProtocolTrampoline_11)(void * sel, id arg1, NSStreamEvent arg2); +__attribute__((visibility("default"))) __attribute__((used)) +void _ObjectiveCBindings_protocolTrampoline_hoampi(id target, void * sel, id arg1, NSStreamEvent arg2) { + return ((ProtocolTrampoline_11)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); +} + +typedef void (^ListenerTrampoline_16)(void * arg0, unsigned long arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_16 _ObjectiveCBindings_wrapListenerBlock_zuf90e(ListenerTrampoline_16 block) NS_RETURNS_RETAINED { + return ^void(void * arg0, unsigned long arg1) { + objc_retainBlock(block); + block(arg0, arg1); + }; +} + +typedef void (^BlockingTrampoline_16)(void * waiter, void * arg0, unsigned long arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_16 _ObjectiveCBindings_wrapBlockingBlock_zuf90e( + BlockingTrampoline_16 block, BlockingTrampoline_16 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, unsigned long arg1), { + objc_retainBlock(block); + block(nil, arg0, arg1); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, arg0, arg1); + }); +} + +typedef void (^ListenerTrampoline_17)(unsigned short * arg0, unsigned long arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_17 _ObjectiveCBindings_wrapListenerBlock_vhbh5h(ListenerTrampoline_17 block) NS_RETURNS_RETAINED { + return ^void(unsigned short * arg0, unsigned long arg1) { + objc_retainBlock(block); + block(arg0, arg1); + }; +} + +typedef void (^BlockingTrampoline_17)(void * waiter, unsigned short * arg0, unsigned long arg1); +__attribute__((visibility("default"))) __attribute__((used)) +ListenerTrampoline_17 _ObjectiveCBindings_wrapBlockingBlock_vhbh5h( + BlockingTrampoline_17 block, BlockingTrampoline_17 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(unsigned short * arg0, unsigned long arg1), { + objc_retainBlock(block); + block(nil, arg0, arg1); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, arg0, arg1); + }); +} + +typedef id (^ProtocolTrampoline_12)(void * sel, id arg1); __attribute__((visibility("default"))) __attribute__((used)) id _ObjectiveCBindings_protocolTrampoline_xr62hr(id target, void * sel, id arg1) { - return ((ProtocolTrampoline_11)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); + return ((ProtocolTrampoline_12)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); } -typedef id (^ProtocolTrampoline_12)(void * sel, id arg1, id arg2, id * arg3); +typedef id (^ProtocolTrampoline_13)(void * sel, id arg1, id arg2, id * arg3); __attribute__((visibility("default"))) __attribute__((used)) id _ObjectiveCBindings_protocolTrampoline_10z9f5k(id target, void * sel, id arg1, id arg2, id * arg3) { - return ((ProtocolTrampoline_12)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); + return ((ProtocolTrampoline_13)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); } -typedef id (^ProtocolTrampoline_13)(void * sel, struct _NSZone * arg1); +typedef id (^ProtocolTrampoline_14)(void * sel, struct _NSZone * arg1); __attribute__((visibility("default"))) __attribute__((used)) id _ObjectiveCBindings_protocolTrampoline_18nsem0(id target, void * sel, struct _NSZone * arg1) { - return ((ProtocolTrampoline_13)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); -} - -typedef id (^ProtocolTrampoline_14)(void * sel, struct objc_selector * arg1); -__attribute__((visibility("default"))) __attribute__((used)) -id _ObjectiveCBindings_protocolTrampoline_50as9u(id target, void * sel, struct objc_selector * arg1) { return ((ProtocolTrampoline_14)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); } -typedef id (^ProtocolTrampoline_15)(void * sel, struct objc_selector * arg1, id arg2); +typedef id (^ProtocolTrampoline_15)(void * sel, struct objc_selector * arg1); __attribute__((visibility("default"))) __attribute__((used)) -id _ObjectiveCBindings_protocolTrampoline_1mllhpc(id target, void * sel, struct objc_selector * arg1, id arg2) { - return ((ProtocolTrampoline_15)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); +id _ObjectiveCBindings_protocolTrampoline_50as9u(id target, void * sel, struct objc_selector * arg1) { + return ((ProtocolTrampoline_15)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); } -typedef id (^ProtocolTrampoline_16)(void * sel, struct objc_selector * arg1, id arg2, id arg3); +typedef id (^ProtocolTrampoline_16)(void * sel, struct objc_selector * arg1, id arg2); +__attribute__((visibility("default"))) __attribute__((used)) +id _ObjectiveCBindings_protocolTrampoline_1mllhpc(id target, void * sel, struct objc_selector * arg1, id arg2) { + return ((ProtocolTrampoline_16)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); +} + +typedef id (^ProtocolTrampoline_17)(void * sel, struct objc_selector * arg1, id arg2, id arg3); __attribute__((visibility("default"))) __attribute__((used)) id _ObjectiveCBindings_protocolTrampoline_c7gk2u(id target, void * sel, struct objc_selector * arg1, id arg2, id arg3) { - return ((ProtocolTrampoline_16)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); + return ((ProtocolTrampoline_17)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3); } #undef BLOCKING_BLOCK_IMPL
diff --git a/pkgs/objective_c/src/observer.h b/pkgs/objective_c/src/observer.h new file mode 100644 index 0000000..a0ec5dc --- /dev/null +++ b/pkgs/objective_c/src/observer.h
@@ -0,0 +1,29 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +#ifndef OBJECTIVE_C_SRC_OBSERVER_H_ +#define OBJECTIVE_C_SRC_OBSERVER_H_ + +#import <Foundation/NSObject.h> +#import <Foundation/NSKeyValueObserving.h> + +typedef void (^DOBJCObserverBlock)(NSObject* object, id oldValue, id newValue); + +/** + * Represents a single KVO observation. Each observation uses a new + * DOBJCObserver, even for the same observed object and keyPath. + */ +@interface DOBJCObserver : NSObject +- (instancetype)initForKeyPath:(NSString*)keyPath + ofObject:(id)object + withBlock:(DOBJCObserverBlock)block; +- (void)observeValueForKeyPath:(NSString*)keyPath + ofObject:(id)object + change:(NSDictionary<NSKeyValueChangeKey,id>*)change + context:(void*)context; +- (void)remove; +- (void)dealloc; +@end + +#endif // OBJECTIVE_C_SRC_OBSERVER_H_
diff --git a/pkgs/objective_c/src/observer.m b/pkgs/objective_c/src/observer.m new file mode 100644 index 0000000..a5dffa6 --- /dev/null +++ b/pkgs/objective_c/src/observer.m
@@ -0,0 +1,66 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +#include "observer.h" + +#import <objc/runtime.h> + +#if !__has_feature(objc_arc) +#error "This file must be compiled with ARC enabled" +#endif + +void setAssociatedObject(id from, id key, id value) { + if (from != nil) { + objc_setAssociatedObject( + from, (__bridge void*)key, value, OBJC_ASSOCIATION_RETAIN); + } +} + +void addStrongRef(id from, id to) { setAssociatedObject(from, to, to); } +void removeStrongRef(id from, id to) { setAssociatedObject(from, to, nil); } + +@implementation DOBJCObserver { + DOBJCObserverBlock _block; // final + NSString* _keyPath; // final + __weak id _observed; // final, except becomes nil if observed dies + BOOL _isObserving; // mutable, guarded by @synchronized(self) +} + +- (instancetype)initForKeyPath:(NSString*)keyPath + ofObject:(id)observer + withBlock:(DOBJCObserverBlock)block { + _block = block; + _keyPath = keyPath; + _observed = observer; + _isObserving = true; + [observer addObserver: self + forKeyPath: keyPath + options: (NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) + context: nil]; + addStrongRef(observer, self); + return self; +} + +- (void)observeValueForKeyPath:(NSString*)keyPath + ofObject:(id)observer + change:(NSDictionary<NSKeyValueChangeKey, id>*)change + context:(void*)context { + _block( + observer, change[NSKeyValueChangeOldKey], change[NSKeyValueChangeNewKey]); +} + +- (void)remove { + @synchronized(self) { + if (_isObserving) { + _isObserving = false; + [_observed removeObserver:self forKeyPath:_keyPath context:nil]; + removeStrongRef(_observed, self); + } + } +} + +- (void)dealloc { + [self remove]; +} +@end
diff --git a/pkgs/objective_c/test/main.c b/pkgs/objective_c/test/main.c index bdb1532..6abd6ee 100644 --- a/pkgs/objective_c/test/main.c +++ b/pkgs/objective_c/test/main.c
@@ -20,6 +20,7 @@ ASSERT_SYMBOL("DOBJC_disposeObjCBlockWithClosure"); // objective_c.c ASSERT_SYMBOL("DOBJC_runOnMainThread"); // objective_c.m + ASSERT_SYMBOL("OBJC_CLASS_$_DOBJCObserver"); // observer.c ASSERT_SYMBOL("OBJC_CLASS_$_DOBJCDartProtocol"); // protocol.m // objective_c_bindings_generated.m ASSERT_SYMBOL("_ObjectiveCBindings_wrapListenerBlock_ovsamd");
diff --git a/pkgs/objective_c/test/setup.dart b/pkgs/objective_c/test/setup.dart index ef594eb..6149d76 100644 --- a/pkgs/objective_c/test/setup.dart +++ b/pkgs/objective_c/test/setup.dart
@@ -25,6 +25,7 @@ 'src/ns_number.m', 'src/objective_c.m', 'src/objective_c_bindings_generated.m', + 'src/observer.m', 'src/protocol.m', ].map(_resolve); const objCFlags = [ @@ -96,6 +97,7 @@ lib.lookup('DOBJC_disposeObjCBlockWithClosure'); // objective_c.c lib.lookup('DOBJC_runOnMainThread'); // objective_c.m lib.lookup('Dart_InitializeApiDL'); // dart_api_dl.c + lib.lookup('OBJC_CLASS_\$_DOBJCObserver'); // observer.c lib.lookup('OBJC_CLASS_\$_DOBJCDartProtocol'); // protocol.m // objective_c_bindings_generated.m lib.lookup('_ObjectiveCBindings_wrapListenerBlock_ovsamd');