Skip to content

Commit

Permalink
fix fmt again
Browse files Browse the repository at this point in the history
  • Loading branch information
sagudev committed May 12, 2022
1 parent cb4afd2 commit 992139f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
3 changes: 2 additions & 1 deletion frb_dart/lib/flutter_rust_bridge.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export 'src/flutter_rust_bridge_io.dart' if (dart.library.html) 'flutter_rust_bridge_web.dart';
export 'src/flutter_rust_bridge_io.dart'
if (dart.library.html) 'flutter_rust_bridge_web.dart';
export 'src/platform_independent.dart';
11 changes: 8 additions & 3 deletions frb_dart/lib/src/basic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ abstract class FlutterRustBridgeBase<T extends FlutterRustBridgeWireBase> {
final completer = Completer<dynamic>();
final sendPort = singleCompletePort(completer);
task.callFfi(sendPort.nativePort);
return completer.future.then((dynamic raw) => _transformRust2DartMessage(raw, task.parseSuccessData));
return completer.future.then((dynamic raw) =>
_transformRust2DartMessage(raw, task.parseSuccessData));
}

/// Similar to [executeNormal], except that this will return synchronously
Expand Down Expand Up @@ -76,7 +77,8 @@ abstract class FlutterRustBridgeBase<T extends FlutterRustBridgeWireBase> {
}
}

S _transformRust2DartMessage<S>(dynamic raw, S Function(dynamic) parseSuccessData) {
S _transformRust2DartMessage<S>(
dynamic raw, S Function(dynamic) parseSuccessData) {
final action = raw[0];
switch (action) {
case _RUST2DART_ACTION_SUCCESS:
Expand Down Expand Up @@ -149,7 +151,10 @@ abstract class FlutterRustBridgeWireBase {
/// Not to be used by normal users, but has to be public for generated code
// ignore: non_constant_identifier_names
void store_dart_post_cobject(
ffi.Pointer<ffi.NativeFunction<ffi.Uint8 Function(ffi.Int64, ffi.Pointer<ffi.Void>)>> ptr,
ffi.Pointer<
ffi.NativeFunction<
ffi.Uint8 Function(ffi.Int64, ffi.Pointer<ffi.Void>)>>
ptr,
);

/// Not to be used by normal users, but has to be public for generated code
Expand Down
13 changes: 8 additions & 5 deletions frb_dart/lib/src/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import 'package:meta/meta.dart';
///
/// 1. Please call [setupMixinConstructor] inside the constructor of your class.
/// 2. Inside your [setup], please call ffi functions with hint=[kHintSetup].
mixin FlutterRustBridgeSetupMixin<T extends FlutterRustBridgeWireBase> on FlutterRustBridgeBase<T> {
mixin FlutterRustBridgeSetupMixin<T extends FlutterRustBridgeWireBase>
on FlutterRustBridgeBase<T> {
/// Inside your [setup], please call ffi functions with hint=[kHintSetup].
static const kHintSetup = _FlutterRustBridgeSetupMixinSkipWaitHint._();

Expand Down Expand Up @@ -43,7 +44,8 @@ mixin FlutterRustBridgeSetupMixin<T extends FlutterRustBridgeWireBase> on Flutte
}

Future<void> _beforeExecute<S>(FlutterRustBridgeTask<S> task) async {
if (!_setupCompleter.isCompleted && task.hint is! _FlutterRustBridgeSetupMixinSkipWaitHint) {
if (!_setupCompleter.isCompleted &&
task.hint is! _FlutterRustBridgeSetupMixinSkipWaitHint) {
log('FlutterRustBridgeSetupMixin.beforeExecute start waiting setup to complete (task=${task.debugName})');
await _setupCompleter.future;
log('FlutterRustBridgeSetupMixin.beforeExecute end waiting setup to complete (task=${task.debugName})');
Expand All @@ -64,15 +66,16 @@ class _FlutterRustBridgeSetupMixinSkipWaitHint {
}

/// Add a timeout to [executeNormal]
mixin FlutterRustBridgeTimeoutMixin<T extends FlutterRustBridgeWireBase> on FlutterRustBridgeBase<T> {
mixin FlutterRustBridgeTimeoutMixin<T extends FlutterRustBridgeWireBase>
on FlutterRustBridgeBase<T> {
@override
Future<S> executeNormal<S>(FlutterRustBridgeTask<S> task) async {
// capture a stack trace at *here*, such that when timeout, can have a good stack trace
final stackTrace = StackTrace.current;

return super.executeNormal(task).timeout(timeLimitForExecuteNormal,
onTimeout: () =>
throw FlutterRustBridgeTimeoutException(timeLimitForExecuteNormal, task.debugName, stackTrace));
onTimeout: () => throw FlutterRustBridgeTimeoutException(
timeLimitForExecuteNormal, task.debugName, stackTrace));
}

/// The time limit for methods using [executeNormal]
Expand Down
3 changes: 2 additions & 1 deletion frb_dart/lib/src/platform_independent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class FlutterRustBridgeTimeoutException {
/// The stack trace of the error
final StackTrace stackTrace;

const FlutterRustBridgeTimeoutException(this.duration, this.debugName, this.stackTrace);
const FlutterRustBridgeTimeoutException(
this.duration, this.debugName, this.stackTrace);

@override
String toString() =>
Expand Down
3 changes: 2 additions & 1 deletion frb_dart/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ SendPort singleCompletePort<R, P>(
completer.completeError(e, st);
}
} else {
completer.completeError(TimeoutException('Future not completed', timeout));
completer
.completeError(TimeoutException('Future not completed', timeout));
}
});
}
Expand Down
4 changes: 3 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ gen-bridge: build

alias l := lint
lint:
dart format --fix -l {{line_length}} .
dart format --fix .
dart format --fix -l {{line_length}} {{frb_pure}}
dart format --fix -l {{line_length}} {{frb_flutter}}

alias t := test
test: test-pure test-integration
Expand Down

0 comments on commit 992139f

Please sign in to comment.