blob: 3b8c71bf65fee4afb0892927cd4e616faff1b764 [file]
// 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>>(symbol: 'globalBlock')
external ffi.Pointer<objc.ObjCBlockImpl> _globalBlock;
objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)>? get globalBlock =>
_globalBlock.address == 0
? null
: ObjCBlock_Int32_Int32.fromPointer(
_globalBlock,
retain: true,
release: true,
);
set globalBlock(objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)>? value) {
_globalBlock.address == 0
? null
: ObjCBlock_Int32_Int32.fromPointer(
_globalBlock,
retain: false,
release: true,
).ref.release();
_globalBlock = value?.ref.retainAndReturnPointer() ?? ffi.nullptr;
}
@ffi.Native<ffi.Pointer<objc.ObjCObjectImpl>>(symbol: 'globalObject')
external ffi.Pointer<objc.ObjCObjectImpl> _globalObject;
objc.NSObject? get globalObject => _globalObject.address == 0
? null
: objc.NSObject.fromPointer(_globalObject, retain: true, release: true);
set globalObject(objc.NSObject? value) {
_globalObject.address == 0
? null
: objc.NSObject.fromPointer(
_globalObject,
retain: false,
release: true,
).ref.release();
_globalObject = value?.ref.retainAndReturnPointer() ?? ffi.nullptr;
}
@ffi.Native<ffi.Pointer<objc.ObjCObjectImpl>>(symbol: 'globalString')
external ffi.Pointer<objc.ObjCObjectImpl> _globalString;
objc.NSString get globalString =>
objc.NSString.fromPointer(_globalString, retain: true, release: true);
set globalString(objc.NSString value) {
objc.NSString.fromPointer(
_globalString,
retain: false,
release: true,
).ref.release();
_globalString = value.ref.retainAndReturnPointer();
}
/// 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,
);
}