blob: 7d577af90f4941ff13fb5d534f3f3a1d09db9fa8 [file]
// 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;
/// Tests global variables
class GlobalTestObjCLibrary {
/// Holds the symbol lookup function.
final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
_lookup;
/// The symbols are looked up in [dynamicLibrary].
GlobalTestObjCLibrary(ffi.DynamicLibrary dynamicLibrary)
: _lookup = dynamicLibrary.lookup;
/// The symbols are looked up with [lookup].
GlobalTestObjCLibrary.fromLookup(
ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName) lookup,
) : _lookup = lookup;
late final ffi.Pointer<ffi.Pointer<objc.ObjCBlockImpl>> _globalBlock =
_lookup<ffi.Pointer<objc.ObjCBlockImpl>>('globalBlock');
objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)>? get globalBlock =>
_globalBlock.value.address == 0
? null
: ObjCBlock_Int32_Int32.fromPointer(
_globalBlock.value,
retain: true,
release: true,
);
set globalBlock(objc.ObjCBlock<ffi.Int32 Function(ffi.Int32)>? value) {
_globalBlock.value.address == 0
? null
: ObjCBlock_Int32_Int32.fromPointer(
_globalBlock.value,
retain: false,
release: true,
).ref.release();
_globalBlock.value = value?.ref.retainAndReturnPointer() ?? ffi.nullptr;
}
late final ffi.Pointer<ffi.Pointer<objc.ObjCObjectImpl>> _globalObject =
_lookup<ffi.Pointer<objc.ObjCObjectImpl>>('globalObject');
objc.NSObject? get globalObject => _globalObject.value.address == 0
? null
: objc.NSObject.fromPointer(
_globalObject.value,
retain: true,
release: true,
);
set globalObject(objc.NSObject? value) {
_globalObject.value.address == 0
? null
: objc.NSObject.fromPointer(
_globalObject.value,
retain: false,
release: true,
).ref.release();
_globalObject.value = value?.ref.retainAndReturnPointer() ?? ffi.nullptr;
}
late final ffi.Pointer<ffi.Pointer<objc.ObjCObjectImpl>> _globalString =
_lookup<ffi.Pointer<objc.ObjCObjectImpl>>('globalString');
objc.NSString get globalString => objc.NSString.fromPointer(
_globalString.value,
retain: true,
release: true,
);
set globalString(objc.NSString value) {
objc.NSString.fromPointer(
_globalString.value,
retain: false,
release: true,
).ref.release();
_globalString.value = 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,
);
}