woodemi / libusb.dart

Dart wrapper via dart:ffi for https://github.com/libusb/libusb
BSD 3-Clause "New" or "Revised" License
40 stars 23 forks source link

`pkg_ffi.Size` doesn't map to int #20

Closed Sunbreak closed 2 years ago

Sunbreak commented 2 years ago

Since https://github.com/woodemi/libusb.dart/commit/0763bbd76b49600dc7cdf682c97790d715d7fe1b upgraded to ffigen 5.0.0-dev.0

flutter pub run ffigen results in pkg_ffi.Size in Dart funtion decleration

  ffi.Pointer<pkg_ffi.UnsignedChar> libusb_dev_mem_alloc(
    ffi.Pointer<libusb_device_handle> dev_handle,
    pkg_ffi.Size length,
  ) {
    return _libusb_dev_mem_alloc(
      dev_handle,
      length,
    );
  }

  late final _libusb_dev_mem_allocPtr = _lookup<
      ffi.NativeFunction<
          ffi.Pointer<pkg_ffi.UnsignedChar> Function(
              ffi.Pointer<libusb_device_handle>,
              pkg_ffi.Size)>>('libusb_dev_mem_alloc');
  late final _libusb_dev_mem_alloc = _libusb_dev_mem_allocPtr.asFunction<
      ffi.Pointer<pkg_ffi.UnsignedChar> Function(
          ffi.Pointer<libusb_device_handle>, pkg_ffi.Size)>();
  int libusb_dev_mem_free(
    ffi.Pointer<libusb_device_handle> dev_handle,
    ffi.Pointer<pkg_ffi.UnsignedChar> buffer,
    pkg_ffi.Size length,
  ) {
    return _libusb_dev_mem_free(
      dev_handle,
      buffer,
      length,
    );
  }

  late final _libusb_dev_mem_freePtr = _lookup<
      ffi.NativeFunction<
          pkg_ffi.Int Function(
              ffi.Pointer<libusb_device_handle>,
              ffi.Pointer<pkg_ffi.UnsignedChar>,
              pkg_ffi.Size)>>('libusb_dev_mem_free');
  late final _libusb_dev_mem_free = _libusb_dev_mem_freePtr.asFunction<
      int Function(ffi.Pointer<libusb_device_handle>,
          ffi.Pointer<pkg_ffi.UnsignedChar>, pkg_ffi.Size)>();