| // AUTO GENERATED FILE, DO NOT EDIT. |
| // |
| // Generated by `package:ffigen`. |
| // ignore_for_file: type=lint, unused_import |
| import 'dart:ffi' as ffi; |
| import 'package:objective_c/objective_c.dart' as objc; |
| import 'package:ffi/ffi.dart' as pkg_ffi; |
| |
| /// Test ObjC static functions |
| class StaticFuncTestObjCLibrary { |
| /// Holds the symbol lookup function. |
| final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName) |
| _lookup; |
| |
| /// The symbols are looked up in [dynamicLibrary]. |
| StaticFuncTestObjCLibrary(ffi.DynamicLibrary dynamicLibrary) |
| : _lookup = dynamicLibrary.lookup; |
| |
| /// The symbols are looked up with [lookup]. |
| StaticFuncTestObjCLibrary.fromLookup( |
| ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName) lookup, |
| ) : _lookup = lookup; |
| |
| int foo(int x) { |
| return _foo(x); |
| } |
| |
| late final _fooPtr$1 = _lookup<ffi.NativeFunction<ffi.Int Function(ffi.Int)>>( |
| 'foo', |
| ); |
| late final _foo = _fooPtr$1.asFunction<int Function(int)>(); |
| |
| int fooPtr(int x) { |
| return _fooPtr(x); |
| } |
| |
| late final _fooPtrPtr = |
| _lookup<ffi.NativeFunction<ffi.Int Function(ffi.Int)>>('fooPtr'); |
| late final _fooPtr = _fooPtrPtr.asFunction<int Function(int)>(); |
| |
| void objc_autoreleasePoolPop(ffi.Pointer<ffi.Void> pool) { |
| return _objc_autoreleasePoolPop(pool); |
| } |
| |
| late final _objc_autoreleasePoolPopPtr = |
| _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>( |
| 'objc_autoreleasePoolPop', |
| ); |
| late final _objc_autoreleasePoolPop = _objc_autoreleasePoolPopPtr |
| .asFunction<void Function(ffi.Pointer<ffi.Void>)>(); |
| |
| ffi.Pointer<ffi.Void> objc_autoreleasePoolPush() { |
| return _objc_autoreleasePoolPush(); |
| } |
| |
| late final _objc_autoreleasePoolPushPtr = |
| _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function()>>( |
| 'objc_autoreleasePoolPush', |
| ); |
| late final _objc_autoreleasePoolPush = _objc_autoreleasePoolPushPtr |
| .asFunction<ffi.Pointer<ffi.Void> Function()>(); |
| |
| void staticFuncConsumesArg(StaticFuncTestObj a) { |
| return _staticFuncConsumesArg(a.ref.retainAndReturnPointer()); |
| } |
| |
| late final _staticFuncConsumesArgPtr = |
| _lookup< |
| ffi.NativeFunction<ffi.Void Function(ffi.Pointer<objc.ObjCObjectImpl>)> |
| >('staticFuncConsumesArg'); |
| late final _staticFuncConsumesArg = _staticFuncConsumesArgPtr |
| .asFunction<void Function(ffi.Pointer<objc.ObjCObjectImpl>)>(); |
| |
| objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)> staticFuncOfBlock( |
| objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)> a, |
| ) { |
| return ObjCBlock_Int32_Int32.fromPointer( |
| _staticFuncOfBlock(a.ref.pointer), |
| retain: true, |
| release: true, |
| ); |
| } |
| |
| late final _staticFuncOfBlockPtr = |
| _lookup< |
| ffi.NativeFunction< |
| ffi.Pointer<objc.ObjCBlockImpl> Function( |
| ffi.Pointer<objc.ObjCBlockImpl>, |
| ) |
| > |
| >('staticFuncOfBlock'); |
| late final _staticFuncOfBlock = _staticFuncOfBlockPtr |
| .asFunction< |
| ffi.Pointer<objc.ObjCBlockImpl> Function( |
| ffi.Pointer<objc.ObjCBlockImpl>, |
| ) |
| >(); |
| |
| StaticFuncTestObj? staticFuncOfNullableObject(StaticFuncTestObj? a) { |
| return _staticFuncOfNullableObject(a?.ref.pointer ?? ffi.nullptr).address == |
| 0 |
| ? null |
| : StaticFuncTestObj.fromPointer( |
| _staticFuncOfNullableObject(a?.ref.pointer ?? ffi.nullptr), |
| retain: true, |
| release: true, |
| ); |
| } |
| |
| late final _staticFuncOfNullableObjectPtr = |
| _lookup< |
| ffi.NativeFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ) |
| > |
| >('staticFuncOfNullableObject'); |
| late final _staticFuncOfNullableObject = _staticFuncOfNullableObjectPtr |
| .asFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ) |
| >(); |
| |
| StaticFuncTestObj staticFuncOfObject(StaticFuncTestObj a) { |
| return StaticFuncTestObj.fromPointer( |
| _staticFuncOfObject(a.ref.pointer), |
| retain: true, |
| release: true, |
| ); |
| } |
| |
| late final _staticFuncOfObjectPtr = |
| _lookup< |
| ffi.NativeFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ) |
| > |
| >('staticFuncOfObject'); |
| late final _staticFuncOfObject = _staticFuncOfObjectPtr |
| .asFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ) |
| >(); |
| |
| StaticFuncTestObj staticFuncReturnsRetained(ffi.Pointer<ffi.Int32> counter) { |
| return StaticFuncTestObj.fromPointer( |
| _staticFuncReturnsRetained(counter), |
| retain: false, |
| release: true, |
| ); |
| } |
| |
| late final _staticFuncReturnsRetainedPtr = |
| _lookup< |
| ffi.NativeFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function(ffi.Pointer<ffi.Int32>) |
| > |
| >('staticFuncReturnsRetained'); |
| late final _staticFuncReturnsRetained = _staticFuncReturnsRetainedPtr |
| .asFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function(ffi.Pointer<ffi.Int32>) |
| >(); |
| |
| StaticFuncTestObj staticFuncReturnsRetainedArg(StaticFuncTestObj a) { |
| return StaticFuncTestObj.fromPointer( |
| _staticFuncReturnsRetainedArg(a.ref.pointer), |
| retain: false, |
| release: true, |
| ); |
| } |
| |
| late final _staticFuncReturnsRetainedArgPtr = |
| _lookup< |
| ffi.NativeFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ) |
| > |
| >('staticFuncReturnsRetainedArg'); |
| late final _staticFuncReturnsRetainedArg = _staticFuncReturnsRetainedArgPtr |
| .asFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ) |
| >(); |
| } |
| |
| /// Construction methods for `objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)>`. |
| abstract final class ObjCBlock_Int32_Int32 { |
| /// Returns a block that wraps the given raw block pointer. |
| static objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)> fromPointer( |
| ffi.Pointer<objc.ObjCBlockImpl> pointer, { |
| bool retain = false, |
| bool release = false, |
| }) => objc.ObjCBlock<ffi.Int32 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.Int32 Function(ffi.Int32)> fromFunctionPointer( |
| ffi.Pointer<ffi.NativeFunction<ffi.Int32 Function(ffi.Int32 arg0)>> ptr, |
| ) => objc.ObjCBlock<ffi.Int32 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.Int32 Function(ffi.Int32)> fromFunction( |
| int Function(int) fn, { |
| bool keepIsolateAlive = true, |
| }) => objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)>( |
| objc.newClosureBlock( |
| _closureCallable, |
| (int arg0) => fn(arg0), |
| keepIsolateAlive, |
| ), |
| retain: false, |
| release: true, |
| ); |
| |
| static int _fnPtrTrampoline( |
| ffi.Pointer<objc.ObjCBlockImpl> block, |
| int arg0, |
| ) => block.ref.target |
| .cast<ffi.NativeFunction<ffi.Int32 Function(ffi.Int32 arg0)>>() |
| .asFunction<int Function(int)>()(arg0); |
| static ffi.Pointer<ffi.Void> _fnPtrCallable = |
| ffi.Pointer.fromFunction< |
| ffi.Int32 Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Int32) |
| >(_fnPtrTrampoline, 0) |
| .cast(); |
| static int _closureTrampoline( |
| ffi.Pointer<objc.ObjCBlockImpl> block, |
| int arg0, |
| ) => (objc.getBlockClosure(block) as int Function(int))(arg0); |
| static ffi.Pointer<ffi.Void> _closureCallable = |
| ffi.Pointer.fromFunction< |
| ffi.Int32 Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Int32) |
| >(_closureTrampoline, 0) |
| .cast(); |
| } |
| |
| /// Call operator for `objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)>`. |
| extension ObjCBlock_Int32_Int32$CallExtension |
| on objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)> { |
| int call(int arg0) => |
| ref.pointer.ref.invoke |
| .cast< |
| ffi.NativeFunction< |
| ffi.Int32 Function( |
| ffi.Pointer<objc.ObjCBlockImpl> block, |
| ffi.Int32 arg0, |
| ) |
| > |
| >() |
| .asFunction<int Function(ffi.Pointer<objc.ObjCBlockImpl>, int)>()( |
| ref.pointer, |
| arg0, |
| ); |
| } |
| |
| /// StaticFuncTestObj |
| extension type StaticFuncTestObj._(objc.ObjCObject object$) |
| implements objc.ObjCObject, objc.NSObject { |
| /// Constructs a [StaticFuncTestObj] that points to the same underlying object as [other]. |
| StaticFuncTestObj.as(objc.ObjCObject other) : object$ = other { |
| assert(isA(object$)); |
| } |
| |
| /// Constructs a [StaticFuncTestObj] that wraps the given raw object pointer. |
| StaticFuncTestObj.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 [StaticFuncTestObj]. |
| static bool isA(objc.ObjCObject? obj) => obj == null |
| ? false |
| : _objc_msgSend_19nvye5( |
| obj.ref.pointer, |
| _sel_isKindOfClass_, |
| _class_StaticFuncTestObj, |
| ); |
| |
| /// alloc |
| static StaticFuncTestObj alloc() { |
| final $ret = _objc_msgSend_151sglz(_class_StaticFuncTestObj, _sel_alloc); |
| return StaticFuncTestObj.fromPointer($ret, retain: false, release: true); |
| } |
| |
| /// allocWithZone: |
| static StaticFuncTestObj allocWithZone(ffi.Pointer<objc.NSZone> zone) { |
| final $ret = _objc_msgSend_1cwp428( |
| _class_StaticFuncTestObj, |
| _sel_allocWithZone_, |
| zone, |
| ); |
| return StaticFuncTestObj.fromPointer($ret, retain: false, release: true); |
| } |
| |
| /// new |
| static StaticFuncTestObj new$() { |
| final $ret = _objc_msgSend_151sglz(_class_StaticFuncTestObj, _sel_new); |
| return StaticFuncTestObj.fromPointer($ret, retain: false, release: true); |
| } |
| |
| /// newWithCounter: |
| static StaticFuncTestObj newWithCounter(ffi.Pointer<ffi.Int32> _counter) { |
| final $ret = _objc_msgSend_129vhbw( |
| _class_StaticFuncTestObj, |
| _sel_newWithCounter_, |
| _counter, |
| ); |
| return StaticFuncTestObj.fromPointer($ret, retain: false, release: true); |
| } |
| |
| /// Returns a new instance of StaticFuncTestObj constructed with the default `new` method. |
| StaticFuncTestObj() : this.as(new$().object$); |
| } |
| |
| extension StaticFuncTestObj$Methods on StaticFuncTestObj { |
| /// dealloc |
| void dealloc() { |
| _objc_msgSend_1pl9qdv(object$.ref.pointer, _sel_dealloc); |
| } |
| |
| /// init |
| StaticFuncTestObj init() { |
| objc.checkOsVersionInternal( |
| 'StaticFuncTestObj.init', |
| iOS: (false, (2, 0, 0)), |
| macOS: (false, (10, 0, 0)), |
| ); |
| final $ret = _objc_msgSend_151sglz( |
| object$.ref.retainAndReturnPointer(), |
| _sel_init, |
| ); |
| return StaticFuncTestObj.fromPointer($ret, retain: false, release: true); |
| } |
| |
| /// initWithCounter: |
| StaticFuncTestObj initWithCounter(ffi.Pointer<ffi.Int32> _counter) { |
| final $ret = _objc_msgSend_129vhbw( |
| object$.ref.retainAndReturnPointer(), |
| _sel_initWithCounter_, |
| _counter, |
| ); |
| return StaticFuncTestObj.fromPointer($ret, retain: false, release: true); |
| } |
| } |
| |
| late final _class_StaticFuncTestObj = objc.getClass("StaticFuncTestObj"); |
| final _objc_msgSend_129vhbw = objc.msgSendPointer |
| .cast< |
| ffi.NativeFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ffi.Pointer<ffi.Int32>, |
| ) |
| > |
| >() |
| .asFunction< |
| ffi.Pointer<objc.ObjCObjectImpl> Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ffi.Pointer<ffi.Int32>, |
| ) |
| >(); |
| 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_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_1pl9qdv = objc.msgSendPointer |
| .cast< |
| ffi.NativeFunction< |
| ffi.Void Function( |
| ffi.Pointer<objc.ObjCObjectImpl>, |
| ffi.Pointer<objc.ObjCSelector>, |
| ) |
| > |
| >() |
| .asFunction< |
| void 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_dealloc = objc.registerName("dealloc"); |
| late final _sel_init = objc.registerName("init"); |
| late final _sel_initWithCounter_ = objc.registerName("initWithCounter:"); |
| late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); |
| late final _sel_new = objc.registerName("new"); |
| late final _sel_newWithCounter_ = objc.registerName("newWithCounter:"); |
| typedef instancetype = ffi.Pointer<objc.ObjCObjectImpl>; |
| typedef Dartinstancetype = objc.ObjCObject; |