| // AUTO GENERATED FILE, DO NOT EDIT. |
| // |
| // Generated by `package:ffigen`. |
| // ignore_for_file: type=lint, unused_import |
| @ffi.DefaultAsset('package:ffigen/objc_test') |
| library; |
| |
| import 'dart:ffi' as ffi; |
| import 'package:objective_c/objective_c.dart' as objc; |
| import 'package:ffi/ffi.dart' as pkg_ffi; |
| |
| @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> _rdx59v_wrapBlockingBlock_1bqef4y( |
| 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> _rdx59v_wrapListenerBlock_1bqef4y( |
| ffi.Pointer<objc.ObjCBlockImpl> block, |
| ); |
| |
| /// Construction methods for `objc.ObjCBlock<ffi.Void Function(ffi.Int32)>`. |
| abstract final class ObjCBlock_ffiVoid_Int32 { |
| /// Returns a block that wraps the given raw block pointer. |
| static objc.ObjCBlock<ffi.Void Function(ffi.Int32)> fromPointer( |
| ffi.Pointer<objc.ObjCBlockImpl> pointer, { |
| bool retain = false, |
| bool release = false, |
| }) => objc.ObjCBlock<ffi.Void Function(ffi.Int32)>( |
| 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.Int32)> fromFunctionPointer( |
| ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Int32 arg0)>> ptr, |
| ) => objc.ObjCBlock<ffi.Void Function(ffi.Int32)>( |
| objc.newPointerBlock(_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.Int32)> fromFunction( |
| void Function(int) fn, { |
| bool keepIsolateAlive = true, |
| }) => objc.ObjCBlock<ffi.Void Function(ffi.Int32)>( |
| objc.newClosureBlock( |
| _closureCallable, |
| (int arg0) => fn(arg0), |
| 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.Int32)> listener( |
| void Function(int) fn, { |
| bool keepIsolateAlive = true, |
| }) { |
| final raw = objc.newClosureBlock( |
| _listenerCallable.nativeFunction.cast(), |
| (int arg0) => fn(arg0), |
| keepIsolateAlive, |
| ); |
| final wrapper = _rdx59v_wrapListenerBlock_1bqef4y(raw); |
| objc.objectRelease(raw.cast()); |
| return objc.ObjCBlock<ffi.Void Function(ffi.Int32)>( |
| 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.Int32)> blocking( |
| void Function(int) fn, { |
| bool keepIsolateAlive = true, |
| }) { |
| final raw = objc.newClosureBlock( |
| _blockingCallable.nativeFunction.cast(), |
| (int arg0) => fn(arg0), |
| keepIsolateAlive, |
| ); |
| final rawListener = objc.newClosureBlock( |
| _blockingListenerCallable.nativeFunction.cast(), |
| (int arg0) => fn(arg0), |
| keepIsolateAlive, |
| ); |
| final wrapper = _rdx59v_wrapBlockingBlock_1bqef4y( |
| raw, |
| rawListener, |
| objc.objCContext, |
| ); |
| objc.objectRelease(raw.cast()); |
| objc.objectRelease(rawListener.cast()); |
| return objc.ObjCBlock<ffi.Void Function(ffi.Int32)>( |
| wrapper, |
| retain: false, |
| release: true, |
| ); |
| } |
| |
| static void _listenerTrampoline( |
| ffi.Pointer<objc.ObjCBlockImpl> block, |
| int arg0, |
| ) { |
| (objc.getBlockClosure(block) as void Function(int))(arg0); |
| objc.objectRelease(block.cast()); |
| } |
| |
| static ffi.NativeCallable< |
| ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Int32) |
| > |
| _listenerCallable = |
| ffi.NativeCallable< |
| ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Int32) |
| >.listener(_listenerTrampoline) |
| ..keepIsolateAlive = false; |
| static void _blockingTrampoline( |
| ffi.Pointer<objc.ObjCBlockImpl> block, |
| ffi.Pointer<ffi.Void> waiter, |
| int arg0, |
| ) { |
| try { |
| (objc.getBlockClosure(block) as void Function(int))(arg0); |
| } catch (e) { |
| } finally { |
| objc.signalWaiter(waiter); |
| objc.objectRelease(block.cast()); |
| } |
| } |
| |
| static ffi.NativeCallable< |
| ffi.Void Function( |
| ffi.Pointer<objc.ObjCBlockImpl>, |
| ffi.Pointer<ffi.Void>, |
| ffi.Int32, |
| ) |
| > |
| _blockingCallable = |
| ffi.NativeCallable< |
| ffi.Void Function( |
| ffi.Pointer<objc.ObjCBlockImpl>, |
| ffi.Pointer<ffi.Void>, |
| ffi.Int32, |
| ) |
| >.isolateLocal(_blockingTrampoline) |
| ..keepIsolateAlive = false; |
| static ffi.NativeCallable< |
| ffi.Void Function( |
| ffi.Pointer<objc.ObjCBlockImpl>, |
| ffi.Pointer<ffi.Void>, |
| ffi.Int32, |
| ) |
| > |
| _blockingListenerCallable = |
| ffi.NativeCallable< |
| ffi.Void Function( |
| ffi.Pointer<objc.ObjCBlockImpl>, |
| ffi.Pointer<ffi.Void>, |
| ffi.Int32, |
| ) |
| >.listener(_blockingTrampoline) |
| ..keepIsolateAlive = false; |
| static void _fnPtrTrampoline( |
| ffi.Pointer<objc.ObjCBlockImpl> block, |
| int arg0, |
| ) => block.ref.target |
| .cast<ffi.NativeFunction<ffi.Void Function(ffi.Int32 arg0)>>() |
| .asFunction<void Function(int)>()(arg0); |
| static ffi.Pointer<ffi.Void> _fnPtrCallable = |
| ffi.Pointer.fromFunction< |
| ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Int32) |
| >(_fnPtrTrampoline) |
| .cast(); |
| static void _closureTrampoline( |
| ffi.Pointer<objc.ObjCBlockImpl> block, |
| int arg0, |
| ) => (objc.getBlockClosure(block) as void Function(int))(arg0); |
| static ffi.Pointer<ffi.Void> _closureCallable = |
| ffi.Pointer.fromFunction< |
| ffi.Void Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Int32) |
| >(_closureTrampoline) |
| .cast(); |
| } |
| |
| /// Call operator for `objc.ObjCBlock<ffi.Void Function(ffi.Int32)>`. |
| extension ObjCBlock_ffiVoid_Int32$CallExtension |
| on objc.ObjCBlock<ffi.Void Function(ffi.Int32)> { |
| void call(int arg0) => |
| ref.pointer.ref.invoke |
| .cast< |
| ffi.NativeFunction< |
| ffi.Void Function( |
| ffi.Pointer<objc.ObjCBlockImpl> block, |
| ffi.Int32 arg0, |
| ) |
| > |
| >() |
| .asFunction<void Function(ffi.Pointer<objc.ObjCBlockImpl>, int)>()( |
| ref.pointer, |
| arg0, |
| ); |
| } |
| |
| /// Sendable |
| extension type Sendable._(objc.ObjCObject object$) |
| implements objc.ObjCObject, objc.NSObject { |
| /// Constructs a [Sendable] that points to the same underlying object as [other]. |
| Sendable.as(objc.ObjCObject other) : object$ = other { |
| assert(isA(object$)); |
| } |
| |
| /// Constructs a [Sendable] that wraps the given raw object pointer. |
| Sendable.fromPointer( |
| ffi.Pointer<objc.ObjCObjectImpl> other, { |
| bool retain = false, |
| bool release = false, |
| }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { |
| assert(isA(object$)); |
| } |
| |
| /// Returns whether [obj] is an instance of [Sendable]. |
| static bool isA(objc.ObjCObject? obj) => obj == null |
| ? false |
| : _objc_msgSend_19nvye5( |
| obj.ref.pointer, |
| _sel_isKindOfClass_, |
| _class_Sendable, |
| ); |
| |
| /// alloc |
| static Sendable alloc() { |
| final $ret = _objc_msgSend_151sglz(_class_Sendable, _sel_alloc); |
| return Sendable.fromPointer($ret, retain: false, release: true); |
| } |
| |
| /// allocWithZone: |
| static Sendable allocWithZone(ffi.Pointer<objc.NSZone> zone) { |
| final $ret = _objc_msgSend_1cwp428( |
| _class_Sendable, |
| _sel_allocWithZone_, |
| zone, |
| ); |
| return Sendable.fromPointer($ret, retain: false, release: true); |
| } |
| |
| /// dummyMethodToForceGenerationOfListener |
| static objc.ObjCBlock<ffi.Void Function(ffi.Int32)> |
| dummyMethodToForceGenerationOfListener() { |
| final $ret = _objc_msgSend_uwvaik( |
| _class_Sendable, |
| _sel_dummyMethodToForceGenerationOfListener, |
| ); |
| return ObjCBlock_ffiVoid_Int32.fromPointer( |
| $ret, |
| retain: true, |
| release: true, |
| ); |
| } |
| |
| /// new |
| static Sendable new$() { |
| final $ret = _objc_msgSend_151sglz(_class_Sendable, _sel_new); |
| return Sendable.fromPointer($ret, retain: false, release: true); |
| } |
| |
| /// Returns a new instance of Sendable constructed with the default `new` method. |
| Sendable() : this.as(new$().object$); |
| } |
| |
| extension Sendable$Methods on Sendable { |
| /// init |
| Sendable init() { |
| objc.checkOsVersionInternal( |
| 'Sendable.init', |
| iOS: (false, (2, 0, 0)), |
| macOS: (false, (10, 0, 0)), |
| ); |
| final $ret = _objc_msgSend_151sglz( |
| object$.ref.retainAndReturnPointer(), |
| _sel_init, |
| ); |
| return Sendable.fromPointer($ret, retain: false, release: true); |
| } |
| |
| /// setValue: |
| set value(int value) { |
| _objc_msgSend_1bqef4y(object$.ref.pointer, _sel_setValue_, value); |
| } |
| |
| /// value |
| int get value { |
| return _objc_msgSend_1gcq84o(object$.ref.pointer, _sel_value); |
| } |
| } |
| |
| late final _class_Sendable = objc.getClass("Sendable"); |
| final _objc_msgSend_151sglz = objc.msgSendPointer |
| .cast< |
| ffi.NativeFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ) |
| > |
| >() |
| .asFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ) |
| >(); |
| final _objc_msgSend_19nvye5 = objc.msgSendPointer |
| .cast< |
| ffi.NativeFunction< |
| ffi.Bool Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ) |
| > |
| >() |
| .asFunction< |
| bool Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ) |
| >(); |
| final _objc_msgSend_1bqef4y = objc.msgSendPointer |
| .cast< |
| ffi.NativeFunction< |
| ffi.Void Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ffi.Int32, |
| ) |
| > |
| >() |
| .asFunction< |
| void Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| int, |
| ) |
| >(); |
| final _objc_msgSend_1cwp428 = objc.msgSendPointer |
| .cast< |
| ffi.NativeFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ffi.Pointer<objc.NSZone>, |
| ) |
| > |
| >() |
| .asFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ffi.Pointer<objc.NSZone>, |
| ) |
| >(); |
| final _objc_msgSend_1gcq84o = objc.msgSendPointer |
| .cast< |
| ffi.NativeFunction< |
| ffi.Int32 Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ) |
| > |
| >() |
| .asFunction< |
| int Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ) |
| >(); |
| final _objc_msgSend_uwvaik = objc.msgSendPointer |
| .cast< |
| ffi.NativeFunction< |
| ffi.Pointer<objc.ObjCBlockImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ) |
| > |
| >() |
| .asFunction< |
| ffi.Pointer<objc.ObjCBlockImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ) |
| >(); |
| late final _sel_alloc = objc.registerName("alloc"); |
| late final _sel_allocWithZone_ = objc.registerName("allocWithZone:"); |
| late final _sel_dummyMethodToForceGenerationOfListener = objc.registerName( |
| "dummyMethodToForceGenerationOfListener", |
| ); |
| late final _sel_init = objc.registerName("init"); |
| late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); |
| late final _sel_new = objc.registerName("new"); |
| late final _sel_setValue_ = objc.registerName("setValue:"); |
| late final _sel_value = objc.registerName("value"); |
| typedef instancetype = ffi.Pointer<objc.ObjCObjectImpl>; |
| typedef Dartinstancetype = objc.ObjCObject; |