allocNative method

Pointer<native_shortcut_options_t> allocNative()

Allocates the C form; free it with freeNative.

Implementation

ffi.Pointer<c.native_shortcut_options_t> allocNative() {
  final pointer = pkg_ffi.calloc<c.native_shortcut_options_t>();
  pointer.ref.accelerator = accelerator == null
      ? ffi.nullptr
      : accelerator!.toNativeUtf8().cast<ffi.Char>();
  final callback = this.callback;
  final callbackCallable = callback == null
      ? null
      : ffi.NativeCallable<
          ffi.Void Function(ffi.Pointer<ffi.Void>)
        >.isolateLocal((ffi.Pointer<ffi.Void> _) {
          callback();
        });
  pointer.ref.callback = callbackCallable?.nativeFunction ?? ffi.nullptr;
  pointer.ref.callback_user_data = NativeCallbacks.userData(callbackCallable);
  pointer.ref.callback_release_user_data = NativeCallbacks.release;
  pointer.ref.description = description == null
      ? ffi.nullptr
      : description!.toNativeUtf8().cast<ffi.Char>();
  pointer.ref.scopeAsInt = scope.value;
  pointer.ref.enabled = enabled;
  return pointer;
}