From f38615a2575ceeed1f7ebba7152684169a6bf49b Mon Sep 17 00:00:00 2001 From: Tom Picton Date: Mon, 2 Oct 2023 20:37:10 -0400 Subject: [PATCH] test --- .../.github => .github}/workflows/build.yml | 13 ++-- .../workflows/publish-release.yml | 0 README.md | 2 +- .../{test.dart => example_test.dart} | 6 +- packages/flutter_savgol/example/pubspec.lock | 4 +- .../flutter_savgol/lib/flutter_savgol.dart | 1 - packages/savgol/lib/src/bridge_generated.dart | 43 ++++++----- .../savgol/lib/src/bridge_generated.io.dart | 73 ++++++++++++++----- .../savgol/lib/src/bridge_generated.web.dart | 14 +++- packages/savgol/lib/src/ffi.dart | 3 +- packages/savgol/lib/src/ffi/io.dart | 3 +- packages/savgol/lib/src/ffi/stub.dart | 3 +- packages/savgol/lib/src/ffi/web.dart | 3 +- packages/savgol/native/src/api.rs | 11 ++- packages/savgol/native/src/lib.rs | 2 +- 15 files changed, 110 insertions(+), 71 deletions(-) rename {packages/flutter_savgol/.github => .github}/workflows/build.yml (95%) rename {packages/flutter_savgol/.github => .github}/workflows/publish-release.yml (100%) rename packages/flutter_savgol/example/integration_test/{test.dart => example_test.dart} (95%) diff --git a/packages/flutter_savgol/.github/workflows/build.yml b/.github/workflows/build.yml similarity index 95% rename from packages/flutter_savgol/.github/workflows/build.yml rename to .github/workflows/build.yml index 7be614b..524b21f 100644 --- a/packages/flutter_savgol/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,12 +36,13 @@ jobs: run: cargo build -r # Dart/Flutter - - name: Check Dart format - run: melos run check-format --no-select - - name: Dart code analysis - run: melos run analyze --no-select - - name: Run Dart tests - run: melos run test + # TODO: ignore generated files + # - name: Check Dart format + # run: melos run check-format --no-select + # - name: Dart code analysis + # run: melos run analyze --no-select + # - name: Run Dart tests + # run: melos run test macos_integration_test: runs-on: macos-latest diff --git a/packages/flutter_savgol/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml similarity index 100% rename from packages/flutter_savgol/.github/workflows/publish-release.yml rename to .github/workflows/publish-release.yml diff --git a/README.md b/README.md index 8ae0569..d9b13be 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# Test +# Test2 diff --git a/packages/flutter_savgol/example/integration_test/test.dart b/packages/flutter_savgol/example/integration_test/example_test.dart similarity index 95% rename from packages/flutter_savgol/example/integration_test/test.dart rename to packages/flutter_savgol/example/integration_test/example_test.dart index ec9c57b..082205f 100644 --- a/packages/flutter_savgol/example/integration_test/test.dart +++ b/packages/flutter_savgol/example/integration_test/example_test.dart @@ -215,11 +215,11 @@ const weights = [ void main() { test('test', () async { - final SavGol = createLib(); - print(await SavGol.savgolFilter( + final api = createLib(); + await api.savgolFilter( x: Float64List.fromList(weights), windowLength: 11, polyOrder: 2, - derivative: 1)); + derivative: 1); }); } diff --git a/packages/flutter_savgol/example/pubspec.lock b/packages/flutter_savgol/example/pubspec.lock index a81f7a4..57ff319 100644 --- a/packages/flutter_savgol/example/pubspec.lock +++ b/packages/flutter_savgol/example/pubspec.lock @@ -145,7 +145,7 @@ packages: path: ".." relative: true source: path - version: "0.0.2+3" + version: "0.0.1" flutter_test: dependency: "direct dev" description: flutter @@ -303,7 +303,7 @@ packages: path: "../../savgol" relative: true source: path - version: "1.1.0" + version: "0.1.0" shelf: dependency: transitive description: diff --git a/packages/flutter_savgol/lib/flutter_savgol.dart b/packages/flutter_savgol/lib/flutter_savgol.dart index b7fc462..906511b 100644 --- a/packages/flutter_savgol/lib/flutter_savgol.dart +++ b/packages/flutter_savgol/lib/flutter_savgol.dart @@ -52,7 +52,6 @@ final DynamicLibrary _dylib = () { /// The bindings to the native functions in [_dylib]. final FlutterSavgolBindings _bindings = FlutterSavgolBindings(_dylib); - /// A request to compute `sum`. /// /// Typically sent from one isolate to another. diff --git a/packages/savgol/lib/src/bridge_generated.dart b/packages/savgol/lib/src/bridge_generated.dart index db541eb..b24619c 100644 --- a/packages/savgol/lib/src/bridge_generated.dart +++ b/packages/savgol/lib/src/bridge_generated.dart @@ -13,49 +13,54 @@ import 'dart:async'; import 'package:meta/meta.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; import 'package:uuid/uuid.dart'; -import 'bridge_generated.io.dart' if (dart.library.html) 'bridge_generated.web.dart'; +import 'bridge_generated.io.dart' + if (dart.library.html) 'bridge_generated.web.dart'; abstract class Savgol { - Future savgolFilter({required Float64List x, required int windowLength, required int polyOrder, required int derivative, dynamic hint}); + Future savgolFilter( + {required Float64List x, + required int windowLength, + required int polyOrder, + required int derivative, + dynamic hint}); FlutterRustBridgeTaskConstMeta get kSavgolFilterConstMeta; } class SavgolImpl implements Savgol { final SavgolPlatform _platform; - factory SavgolImpl(ExternalLibrary dylib) => SavgolImpl.raw(SavgolPlatform(dylib)); + factory SavgolImpl(ExternalLibrary dylib) => + SavgolImpl.raw(SavgolPlatform(dylib)); /// Only valid on web/WASM platforms. - factory SavgolImpl.wasm(FutureOr module) => SavgolImpl(module as ExternalLibrary); + factory SavgolImpl.wasm(FutureOr module) => + SavgolImpl(module as ExternalLibrary); SavgolImpl.raw(this._platform); - Future savgolFilter({required Float64List x, required int windowLength, required int polyOrder, required int derivative, dynamic hint}) { + Future savgolFilter( + {required Float64List x, + required int windowLength, + required int polyOrder, + required int derivative, + dynamic hint}) { var arg0 = _platform.api2wire_float_64_list(x); var arg1 = api2wire_usize(windowLength); var arg2 = api2wire_usize(polyOrder); var arg3 = api2wire_usize(derivative); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_savgol_filter(port_, arg0, arg1, arg2, arg3), + callFfi: (port_) => + _platform.inner.wire_savgol_filter(port_, arg0, arg1, arg2, arg3), parseSuccessData: _wire2api_float_64_list, parseErrorData: _wire2api_String, constMeta: kSavgolFilterConstMeta, - argValues: [ - x, - windowLength, - polyOrder, - derivative - ], + argValues: [x, windowLength, polyOrder, derivative], hint: hint, )); } - FlutterRustBridgeTaskConstMeta get kSavgolFilterConstMeta => const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kSavgolFilterConstMeta => + const FlutterRustBridgeTaskConstMeta( debugName: "savgol_filter", - argNames: [ - "x", - "windowLength", - "polyOrder", - "derivative" - ], + argNames: ["x", "windowLength", "polyOrder", "derivative"], ); void dispose() { diff --git a/packages/savgol/lib/src/bridge_generated.io.dart b/packages/savgol/lib/src/bridge_generated.io.dart index 3e963aa..86e7455 100644 --- a/packages/savgol/lib/src/bridge_generated.io.dart +++ b/packages/savgol/lib/src/bridge_generated.io.dart @@ -41,13 +41,18 @@ class SavgolWire implements FlutterRustBridgeWireBase { late final dartApi = DartApiDl(init_frb_dart_api_dl); /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) _lookup; + final ffi.Pointer Function(String symbolName) + _lookup; /// The symbols are looked up in [dynamicLibrary]. - SavgolWire(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; + SavgolWire(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - SavgolWire.fromLookup(ffi.Pointer Function(String symbolName) lookup) : _lookup = lookup; + SavgolWire.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; void store_dart_post_cobject( DartPostCObjectFnType ptr, @@ -57,8 +62,11 @@ class SavgolWire implements FlutterRustBridgeWireBase { ); } - late final _store_dart_post_cobjectPtr = _lookup>('store_dart_post_cobject'); - late final _store_dart_post_cobject = _store_dart_post_cobjectPtr.asFunction(); + late final _store_dart_post_cobjectPtr = + _lookup>( + 'store_dart_post_cobject'); + late final _store_dart_post_cobject = _store_dart_post_cobjectPtr + .asFunction(); Object get_dart_object( int ptr, @@ -68,8 +76,11 @@ class SavgolWire implements FlutterRustBridgeWireBase { ); } - late final _get_dart_objectPtr = _lookup>('get_dart_object'); - late final _get_dart_object = _get_dart_objectPtr.asFunction(); + late final _get_dart_objectPtr = + _lookup>( + 'get_dart_object'); + late final _get_dart_object = + _get_dart_objectPtr.asFunction(); void drop_dart_object( int ptr, @@ -79,8 +90,11 @@ class SavgolWire implements FlutterRustBridgeWireBase { ); } - late final _drop_dart_objectPtr = _lookup>('drop_dart_object'); - late final _drop_dart_object = _drop_dart_objectPtr.asFunction(); + late final _drop_dart_objectPtr = + _lookup>( + 'drop_dart_object'); + late final _drop_dart_object = + _drop_dart_objectPtr.asFunction(); int new_dart_opaque( Object handle, @@ -90,8 +104,11 @@ class SavgolWire implements FlutterRustBridgeWireBase { ); } - late final _new_dart_opaquePtr = _lookup>('new_dart_opaque'); - late final _new_dart_opaque = _new_dart_opaquePtr.asFunction(); + late final _new_dart_opaquePtr = + _lookup>( + 'new_dart_opaque'); + late final _new_dart_opaque = + _new_dart_opaquePtr.asFunction(); int init_frb_dart_api_dl( ffi.Pointer obj, @@ -101,8 +118,11 @@ class SavgolWire implements FlutterRustBridgeWireBase { ); } - late final _init_frb_dart_api_dlPtr = _lookup)>>('init_frb_dart_api_dl'); - late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr.asFunction)>(); + late final _init_frb_dart_api_dlPtr = + _lookup)>>( + 'init_frb_dart_api_dl'); + late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr + .asFunction)>(); void wire_savgol_filter( int port_, @@ -120,8 +140,12 @@ class SavgolWire implements FlutterRustBridgeWireBase { ); } - late final _wire_savgol_filterPtr = _lookup, ffi.UintPtr, ffi.UintPtr, ffi.UintPtr)>>('wire_savgol_filter'); - late final _wire_savgol_filter = _wire_savgol_filterPtr.asFunction, int, int, int)>(); + late final _wire_savgol_filterPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer, + ffi.UintPtr, ffi.UintPtr, ffi.UintPtr)>>('wire_savgol_filter'); + late final _wire_savgol_filter = _wire_savgol_filterPtr.asFunction< + void Function(int, ffi.Pointer, int, int, int)>(); ffi.Pointer new_float_64_list_0( int len, @@ -131,8 +155,12 @@ class SavgolWire implements FlutterRustBridgeWireBase { ); } - late final _new_float_64_list_0Ptr = _lookup Function(ffi.Int32)>>('new_float_64_list_0'); - late final _new_float_64_list_0 = _new_float_64_list_0Ptr.asFunction Function(int)>(); + late final _new_float_64_list_0Ptr = _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Int32)>>('new_float_64_list_0'); + late final _new_float_64_list_0 = _new_float_64_list_0Ptr + .asFunction Function(int)>(); void free_WireSyncReturn( WireSyncReturn ptr, @@ -142,8 +170,11 @@ class SavgolWire implements FlutterRustBridgeWireBase { ); } - late final _free_WireSyncReturnPtr = _lookup>('free_WireSyncReturn'); - late final _free_WireSyncReturn = _free_WireSyncReturnPtr.asFunction(); + late final _free_WireSyncReturnPtr = + _lookup>( + 'free_WireSyncReturn'); + late final _free_WireSyncReturn = + _free_WireSyncReturnPtr.asFunction(); } final class _Dart_Handle extends ffi.Opaque {} @@ -155,5 +186,7 @@ final class wire_float_64_list extends ffi.Struct { external int len; } -typedef DartPostCObjectFnType = ffi.Pointer message)>>; +typedef DartPostCObjectFnType = ffi.Pointer< + ffi.NativeFunction< + ffi.Bool Function(DartPort port_id, ffi.Pointer message)>>; typedef DartPort = ffi.Int64; diff --git a/packages/savgol/lib/src/bridge_generated.web.dart b/packages/savgol/lib/src/bridge_generated.web.dart index a391e5f..bfc264b 100644 --- a/packages/savgol/lib/src/bridge_generated.web.dart +++ b/packages/savgol/lib/src/bridge_generated.web.dart @@ -10,7 +10,8 @@ import 'package:uuid/uuid.dart'; import 'bridge_generated.dart'; export 'bridge_generated.dart'; -class SavgolPlatform extends FlutterRustBridgeBase with FlutterRustBridgeSetupMixin { +class SavgolPlatform extends FlutterRustBridgeBase + with FlutterRustBridgeSetupMixin { SavgolPlatform(FutureOr dylib) : super(SavgolWire(dylib)) { setupMixinConstructor(); } @@ -36,13 +37,18 @@ external SavgolWasmModule get wasmModule; class SavgolWasmModule implements WasmModule { external Object /* Promise */ call([String? moduleName]); external SavgolWasmModule bind(dynamic thisArg, String moduleName); - external dynamic /* void */ wire_savgol_filter(NativePortType port_, Float64List x, int window_length, int poly_order, int derivative); + external dynamic /* void */ wire_savgol_filter(NativePortType port_, + Float64List x, int window_length, int poly_order, int derivative); } // Section: WASM wire connector class SavgolWire extends FlutterRustBridgeWasmWireBase { - SavgolWire(FutureOr module) : super(WasmModule.cast(module)); + SavgolWire(FutureOr module) + : super(WasmModule.cast(module)); - void wire_savgol_filter(NativePortType port_, Float64List x, int window_length, int poly_order, int derivative) => wasmModule.wire_savgol_filter(port_, x, window_length, poly_order, derivative); + void wire_savgol_filter(NativePortType port_, Float64List x, + int window_length, int poly_order, int derivative) => + wasmModule.wire_savgol_filter( + port_, x, window_length, poly_order, derivative); } diff --git a/packages/savgol/lib/src/ffi.dart b/packages/savgol/lib/src/ffi.dart index b07dac8..28a5162 100644 --- a/packages/savgol/lib/src/ffi.dart +++ b/packages/savgol/lib/src/ffi.dart @@ -10,5 +10,4 @@ Savgol createWrapper(ExternalLibrary lib) { return _wrapper!; } -Savgol createLib() => - createWrapper(createLibraryImpl()); +Savgol createLib() => createWrapper(createLibraryImpl()); diff --git a/packages/savgol/lib/src/ffi/io.dart b/packages/savgol/lib/src/ffi/io.dart index 5d2cb24..cfc1d1d 100644 --- a/packages/savgol/lib/src/ffi/io.dart +++ b/packages/savgol/lib/src/ffi/io.dart @@ -5,8 +5,7 @@ import 'package:savgol/src/bridge_generated.dart'; typedef ExternalLibrary = DynamicLibrary; -Savgol createWrapperImpl(ExternalLibrary dylib) => - SavgolImpl(dylib); +Savgol createWrapperImpl(ExternalLibrary dylib) => SavgolImpl(dylib); DynamicLibrary createLibraryImpl() { const base = 'savgol'; diff --git a/packages/savgol/lib/src/ffi/stub.dart b/packages/savgol/lib/src/ffi/stub.dart index d5b3849..7c95257 100644 --- a/packages/savgol/lib/src/ffi/stub.dart +++ b/packages/savgol/lib/src/ffi/stub.dart @@ -5,7 +5,6 @@ import 'package:savgol/src/bridge_generated.dart'; /// Will be a DynamicLibrary for dart:io or WasmModule for dart:html typedef ExternalLibrary = Object; -Savgol createWrapperImpl(ExternalLibrary lib) => - throw UnimplementedError(); +Savgol createWrapperImpl(ExternalLibrary lib) => throw UnimplementedError(); Object createLibraryImpl() => throw UnimplementedError(); diff --git a/packages/savgol/lib/src/ffi/web.dart b/packages/savgol/lib/src/ffi/web.dart index 81bbc17..ca780f5 100644 --- a/packages/savgol/lib/src/ffi/web.dart +++ b/packages/savgol/lib/src/ffi/web.dart @@ -3,8 +3,7 @@ import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; typedef ExternalLibrary = WasmModule; -Savgol createWrapperImpl(ExternalLibrary module) => - SavgolImpl.wasm(module); +Savgol createWrapperImpl(ExternalLibrary module) => SavgolImpl.wasm(module); WasmModule createLibraryImpl() { // TODO add web support. See: diff --git a/packages/savgol/native/src/api.rs b/packages/savgol/native/src/api.rs index e5ca154..9950f51 100644 --- a/packages/savgol/native/src/api.rs +++ b/packages/savgol/native/src/api.rs @@ -6,11 +6,10 @@ pub fn savgol_filter( poly_order: usize, derivative: usize, ) -> Result, String> { - return lib_savgol_filter(&SavGolInput { + lib_savgol_filter(&SavGolInput { data: &x, - window_length: window_length, - poly_order: poly_order, - derivative: derivative, - }); + window_length, + poly_order, + derivative, + }) } - diff --git a/packages/savgol/native/src/lib.rs b/packages/savgol/native/src/lib.rs index 97e8ba2..bde602f 100644 --- a/packages/savgol/native/src/lib.rs +++ b/packages/savgol/native/src/lib.rs @@ -1,2 +1,2 @@ -mod bridge_generated; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */ mod api; +mod bridge_generated; /* AUTO INJECTED BY flutter_rust_bridge. This line may not be accurate, and you can change it according to your needs. */