fromFunctionPointer static method

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