fromFunctionPointer static method

ObjCBlock<Double Function(Pointer<Void>, NSBrowser, Long)> fromFunctionPointer(
  1. Pointer<NativeFunction<CGFloat Function(Pointer<Void> arg0, Pointer<ObjCObject> arg1, NSInteger arg2)>> ptr
)

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.

Implementation

static objc.ObjCBlock<
  ffi.Double Function(ffi.Pointer<ffi.Void>, NSBrowser, ffi.Long)
>
fromFunctionPointer(
  ffi.Pointer<
    ffi.NativeFunction<
      CGFloat Function(
        ffi.Pointer<ffi.Void> arg0,
        ffi.Pointer<objc.ObjCObject> arg1,
        NSInteger arg2,
      )
    >
  >
  ptr,
) =>
    objc.ObjCBlock<
      ffi.Double Function(ffi.Pointer<ffi.Void>, NSBrowser, ffi.Long)
    >(
      objc.newPointerBlock(
        _ObjCBlock_CGFloat_ffiVoid_NSBrowser_NSInteger_fnPtrCallable,
        ptr.cast(),
      ),
      retain: false,
      release: true,
    );