fromFunction static method
ObjCBlock<Long Function(Pointer<Void> , NSBrowser, Pointer<ObjCObject> ?)>
fromFunction(
- DartNSInteger fn(), {
- bool keepIsolateAlive = 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.
Implementation
static objc.ObjCBlock<
ffi.Long Function(
ffi.Pointer<ffi.Void>,
NSBrowser,
ffi.Pointer<objc.ObjCObject>?,
)
>
fromFunction(
DartNSInteger Function(
ffi.Pointer<ffi.Void>,
NSBrowser,
objc.ObjCObjectBase?,
)
fn, {
bool keepIsolateAlive = true,
}) =>
objc.ObjCBlock<
ffi.Long Function(
ffi.Pointer<ffi.Void>,
NSBrowser,
ffi.Pointer<objc.ObjCObject>?,
)
>(
objc.newClosureBlock(
_ObjCBlock_NSInteger_ffiVoid_NSBrowser_objcObjCObject_closureCallable,
(
ffi.Pointer<ffi.Void> arg0,
ffi.Pointer<objc.ObjCObject> arg1,
ffi.Pointer<objc.ObjCObject> arg2,
) => fn(
arg0,
NSBrowser.castFromPointer(arg1, retain: true, release: true),
arg2.address == 0
? null
: objc.ObjCObjectBase(arg2, retain: true, release: true),
),
keepIsolateAlive,
),
retain: false,
release: true,
);