fromFunctionPointer static method

ObjCBlock<NSTextLayoutFragment Function(Pointer<Void>, NSTextLayoutManager, Pointer<ObjCObject>, NSTextElement)> fromFunctionPointer(
  1. Pointer<NativeFunction<Pointer<ObjCObject> Function(Pointer<Void> arg0, Pointer<ObjCObject> arg1, Pointer<ObjCObject> arg2, Pointer<ObjCObject> arg3)>> 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<
  NSTextLayoutFragment Function(
    ffi.Pointer<ffi.Void>,
    NSTextLayoutManager,
    ffi.Pointer<objc.ObjCObject>,
    NSTextElement,
  )
>
fromFunctionPointer(
  ffi.Pointer<
    ffi.NativeFunction<
      ffi.Pointer<objc.ObjCObject> Function(
        ffi.Pointer<ffi.Void> arg0,
        ffi.Pointer<objc.ObjCObject> arg1,
        ffi.Pointer<objc.ObjCObject> arg2,
        ffi.Pointer<objc.ObjCObject> arg3,
      )
    >
  >
  ptr,
) =>
    objc.ObjCBlock<
      NSTextLayoutFragment Function(
        ffi.Pointer<ffi.Void>,
        NSTextLayoutManager,
        ffi.Pointer<objc.ObjCObject>,
        NSTextElement,
      )
    >(
      objc.newPointerBlock(
        _ObjCBlock_NSTextLayoutFragment_ffiVoid_NSTextLayoutManager_idNSTextLocation_NSTextElement_fnPtrCallable,
        ptr.cast(),
      ),
      retain: false,
      release: true,
    );