fromFunctionPointer static method

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