fromFunctionPointer static method

ObjCBlock<Void Function(Bool, NSObject?, Int)> fromFunctionPointer(
  1. Pointer<NativeFunction<Void Function(Bool arg0, dispatch_data_t arg1, Int 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.Void Function(ffi.Bool, objc.NSObject?, ffi.Int)>
fromFunctionPointer(
  ffi.Pointer<
    ffi.NativeFunction<
      ffi.Void Function(ffi.Bool arg0, dispatch_data_t arg1, ffi.Int arg2)
    >
  >
  ptr,
) => objc.ObjCBlock<ffi.Void Function(ffi.Bool, objc.NSObject?, ffi.Int)>(
  objc.newPointerBlock(
    _ObjCBlock_ffiVoid_bool_dispatchdatat_ffiInt_fnPtrCallable,
    ptr.cast(),
  ),
  retain: false,
  release: true,
);