| // WARNING: This file is machine generated by fidlgen_dart. |
| // @dart = 2.12 |
| |
| library fidl_fidl_test_errorsyntax_async; |
| |
| import 'dart:async' as $async; |
| import 'dart:core' hide Set; |
| import 'dart:developer'; |
| import 'dart:typed_data'; |
| |
| import 'package:fidl/fidl.dart' as $fidl; |
| import 'package:meta/meta.dart'; |
| import 'package:zircon/zircon.dart' as $zircon; |
| |
| import 'package:fidl_fidl_test_errorsyntax_parent/fidl_async.dart' |
| as lib$fidl_test_errorsyntax_parent; |
| // ignore_for_file: always_specify_types |
| // ignore_for_file: avoid_positional_boolean_parameters |
| // ignore_for_file: avoid_returning_null |
| // ignore_for_file: cascade_invocations |
| // ignore_for_file: constant_identifier_names |
| // ignore_for_file: directives_ordering |
| // ignore_for_file: one_member_abstracts |
| // ignore_for_file: prefer_constructors_over_static_methods |
| // ignore_for_file: prefer_single_quotes |
| // ignore_for_file: public_member_api_docs |
| // ignore_for_file: unused_import |
| // ignore_for_file: unused_local_variable |
| // ignore_for_file: non_constant_identifier_names |
| // ignore_for_file: library_prefixes |
| // ignore_for_file: prefer_typing_uninitialized_variables |
| // ignore_for_file: avoid_js_rounded_ints |
| // ignore_for_file: unnecessary_parenthesis |
| // ignore_for_file: always_put_required_named_parameters_first |
| // ignore_for_file: prefer_generic_function_type_aliases |
| // ignore_for_file: prefer_equal_for_default_values |
| // ignore_for_file: avoid_catches_without_on_clauses |
| // ignore_for_file: unused_shown_name |
| // ignore_for_file: unnecessary_lambdas |
| // ignore_for_file: comment_references |
| // ignore_for_file: avoid_unused_constructor_parameters |
| // ignore_for_file: prefer_interpolation_to_compose_strings |
| |
| enum ExampleUseOfErrorSyntaxCallWhichMayFailResultTag { |
| response, // 0x1 |
| err, // 0x2 |
| } |
| |
| const Map<int, ExampleUseOfErrorSyntaxCallWhichMayFailResultTag> |
| _ExampleUseOfErrorSyntaxCallWhichMayFailResultTag_map = { |
| 1: ExampleUseOfErrorSyntaxCallWhichMayFailResultTag.response, |
| 2: ExampleUseOfErrorSyntaxCallWhichMayFailResultTag.err, |
| }; |
| |
| class ExampleUseOfErrorSyntaxCallWhichMayFailResult extends $fidl.Union { |
| const ExampleUseOfErrorSyntaxCallWhichMayFailResult.withResponse( |
| ExampleUseOfErrorSyntaxCallWhichMayFailResponse value) |
| : _ordinal = 1, |
| _data = value; |
| |
| const ExampleUseOfErrorSyntaxCallWhichMayFailResult.withErr(int value) |
| : _ordinal = 2, |
| _data = value; |
| |
| ExampleUseOfErrorSyntaxCallWhichMayFailResult._(int ordinal, Object data) |
| : _ordinal = ordinal, |
| _data = data; |
| |
| final int _ordinal; |
| final _data; |
| |
| ExampleUseOfErrorSyntaxCallWhichMayFailResultTag get $tag => |
| _ExampleUseOfErrorSyntaxCallWhichMayFailResultTag_map[_ordinal]!; |
| |
| ExampleUseOfErrorSyntaxCallWhichMayFailResponse? get response { |
| if (_ordinal != 1) { |
| return null; |
| } |
| return _data; |
| } |
| |
| int? get err { |
| if (_ordinal != 2) { |
| return null; |
| } |
| return _data; |
| } |
| |
| $fidl.UnknownRawData? get $unknownData { |
| switch (_ordinal) { |
| case 1: |
| case 2: |
| return null; |
| default: |
| return _data; |
| } |
| } |
| |
| @override |
| String toString() { |
| switch (_ordinal) { |
| case 1: |
| return r'ExampleUseOfErrorSyntaxCallWhichMayFailResult.response(' + |
| response.toString() + |
| ')'; |
| case 2: |
| return r'ExampleUseOfErrorSyntaxCallWhichMayFailResult.err(' + |
| err.toString() + |
| ')'; |
| default: |
| return r'ExampleUseOfErrorSyntaxCallWhichMayFailResult.<UNKNOWN>'; |
| } |
| } |
| |
| @override |
| int get $ordinal => _ordinal; |
| |
| @override |
| Object get $data => _data; |
| |
| static ExampleUseOfErrorSyntaxCallWhichMayFailResult _ctor( |
| int ordinal, Object data) { |
| return ExampleUseOfErrorSyntaxCallWhichMayFailResult._(ordinal, data); |
| } |
| } |
| |
| // See fxbug.dev/7644: |
| // ignore: recursive_compile_time_constant |
| const $fidl.UnionType<ExampleUseOfErrorSyntaxCallWhichMayFailResult> |
| kExampleUseOfErrorSyntax_CallWhichMayFail_Result_Type = |
| $fidl.UnionType<ExampleUseOfErrorSyntaxCallWhichMayFailResult>( |
| members: <int, $fidl.FidlType>{ |
| 1: kExampleUseOfErrorSyntax_CallWhichMayFail_Response_Type, |
| 2: $fidl.Uint32Type(), |
| }, |
| ctor: ExampleUseOfErrorSyntaxCallWhichMayFailResult._ctor, |
| flexible: false, |
| resource: false, |
| ); |
| // See fxbug.dev/7644: |
| // ignore: recursive_compile_time_constant |
| const $fidl.NullableUnionType<ExampleUseOfErrorSyntaxCallWhichMayFailResult> |
| kExampleUseOfErrorSyntax_CallWhichMayFail_Result_OptType = |
| $fidl.NullableUnionType<ExampleUseOfErrorSyntaxCallWhichMayFailResult>( |
| members: <int, $fidl.FidlType>{ |
| 1: kExampleUseOfErrorSyntax_CallWhichMayFail_Response_Type, |
| 2: $fidl.Uint32Type(), |
| }, |
| ctor: ExampleUseOfErrorSyntaxCallWhichMayFailResult._ctor, |
| flexible: false, |
| resource: false, |
| ); |
| |
| class ExampleUseOfErrorSyntaxCallWhichMayFailResponse extends $fidl.Struct { |
| const ExampleUseOfErrorSyntaxCallWhichMayFailResponse({ |
| required this.value, |
| }); |
| ExampleUseOfErrorSyntaxCallWhichMayFailResponse.clone( |
| ExampleUseOfErrorSyntaxCallWhichMayFailResponse $orig, { |
| int? value, |
| }) : this( |
| value: value ?? $orig.value, |
| ); |
| |
| final int value; |
| |
| @override |
| List<Object?> get $fields { |
| return <Object?>[ |
| value, |
| ]; |
| } |
| |
| static const $fieldType0 = $fidl.Int64Type(); |
| |
| @override |
| void $encode($fidl.Encoder $encoder, int $offset, int $depth) { |
| switch ($encoder.wireFormat) { |
| case $fidl.WireFormat.v1: |
| $fieldType0.encode($encoder, value, $offset + 0, $depth); |
| break; |
| case $fidl.WireFormat.v2: |
| $fieldType0.encode($encoder, value, $offset + 0, $depth); |
| break; |
| default: |
| throw $fidl.FidlError('unknown wire format'); |
| } |
| } |
| |
| @override |
| String toString() { |
| return r'ExampleUseOfErrorSyntaxCallWhichMayFailResponse' r'(value: ' + |
| value.toString() + |
| r')'; |
| } |
| |
| static ExampleUseOfErrorSyntaxCallWhichMayFailResponse _structDecode( |
| $fidl.Decoder $decoder, int $offset, int $depth) { |
| switch ($decoder.wireFormat) { |
| case $fidl.WireFormat.v1: |
| return ExampleUseOfErrorSyntaxCallWhichMayFailResponse( |
| value: $fieldType0.decode($decoder, $offset + 0, $depth)); |
| case $fidl.WireFormat.v2: |
| return ExampleUseOfErrorSyntaxCallWhichMayFailResponse( |
| value: $fieldType0.decode($decoder, $offset + 0, $depth)); |
| default: |
| throw $fidl.FidlError('unknown wire format'); |
| } |
| } |
| } |
| |
| // See fxbug.dev/7644: |
| // ignore: recursive_compile_time_constant |
| const $fidl.StructType<ExampleUseOfErrorSyntaxCallWhichMayFailResponse> |
| kExampleUseOfErrorSyntax_CallWhichMayFail_Response_Type = |
| $fidl.StructType<ExampleUseOfErrorSyntaxCallWhichMayFailResponse>( |
| inlineSizeV1: 8, |
| inlineSizeV2: 8, |
| structDecode: |
| ExampleUseOfErrorSyntaxCallWhichMayFailResponse._structDecode); |
| |
| // composedCallWhichMayFail: (String s) -> (int value) |
| const int _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Ordinal = |
| 0x71f05a4555fd5234; |
| const $fidl.MethodType _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type = |
| $fidl.MethodType( |
| request: <$fidl.MemberType>[ |
| $fidl.MemberType<String>( |
| type: $fidl.StringType(maybeElementCount: null), |
| offsetV1: 0, |
| offsetV2: 0), |
| ], |
| response: <$fidl.MemberType>[ |
| $fidl.MemberType< |
| lib$fidl_test_errorsyntax_parent |
| .ParentUsesErrorSyntaxComposedCallWhichMayFailResult>( |
| type: lib$fidl_test_errorsyntax_parent |
| .kParentUsesErrorSyntax_ComposedCallWhichMayFail_Result_Type, |
| offsetV1: 0, |
| offsetV2: 0), |
| ], |
| name: r"ExampleUseOfErrorSyntax.ComposedCallWhichMayFail", |
| requestInlineSizeV1: 16, |
| requestInlineSizeV2: 16, |
| responseInlineSizeV1: 24, |
| responseInlineSizeV2: 16, |
| ); |
| // callWhichMayFail: (String s) -> (int value) |
| const int _kExampleUseOfErrorSyntax_CallWhichMayFail_Ordinal = |
| 0x67314da4a7f84897; |
| const $fidl.MethodType _kExampleUseOfErrorSyntax_CallWhichMayFail_Type = |
| $fidl.MethodType( |
| request: <$fidl.MemberType>[ |
| $fidl.MemberType<String>( |
| type: $fidl.StringType(maybeElementCount: null), |
| offsetV1: 0, |
| offsetV2: 0), |
| ], |
| response: <$fidl.MemberType>[ |
| $fidl.MemberType<ExampleUseOfErrorSyntaxCallWhichMayFailResult>( |
| type: kExampleUseOfErrorSyntax_CallWhichMayFail_Result_Type, |
| offsetV1: 0, |
| offsetV2: 0), |
| ], |
| name: r"ExampleUseOfErrorSyntax.CallWhichMayFail", |
| requestInlineSizeV1: 16, |
| requestInlineSizeV2: 16, |
| responseInlineSizeV1: 24, |
| responseInlineSizeV2: 16, |
| ); |
| |
| abstract class ExampleUseOfErrorSyntax { |
| $fidl.ServiceData? get $serviceData => ExampleUseOfErrorSyntaxData(); |
| $async.Future<int> composedCallWhichMayFail(String s); |
| $async.Future<int> callWhichMayFail(String s); |
| } |
| |
| // TODO: Remove ServiceData for non-service |
| class ExampleUseOfErrorSyntaxData |
| implements $fidl.ServiceData<ExampleUseOfErrorSyntax> { |
| const ExampleUseOfErrorSyntaxData(); |
| |
| @override |
| String getName() { |
| return ""; |
| } |
| |
| @override |
| $fidl.AsyncBinding getBinding() { |
| return ExampleUseOfErrorSyntaxBinding(); |
| } |
| } |
| |
| class ExampleUseOfErrorSyntaxProxy extends $fidl |
| .AsyncProxy<ExampleUseOfErrorSyntax> implements ExampleUseOfErrorSyntax { |
| ExampleUseOfErrorSyntaxProxy() |
| : super($fidl.AsyncProxyController<ExampleUseOfErrorSyntax>( |
| $interfaceName: r'ExampleUseOfErrorSyntax')) { |
| ctrl.onResponse = _handleResponse; |
| } |
| @override |
| Null get $serviceData => null; |
| |
| void _handleEvent($fidl.IncomingMessage $message) { |
| switch ($message.ordinal) { |
| default: |
| $fidl.handleCtrlError( |
| ctrl, 'Unexpected message ordinal: ${$message.ordinal}'); |
| break; |
| } |
| } |
| |
| void _handleResponse($fidl.IncomingMessage $message) { |
| final int $txid = $message.txid; |
| if ($txid == 0) { |
| _handleEvent($message); |
| return; |
| } |
| final $async.Completer? $completer = ctrl.getCompleter($txid); |
| if ($completer == null) { |
| $message.closeHandles(); |
| return; |
| } |
| switch ($message.ordinal) { |
| case _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Ordinal: |
| final String _name = |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type.name; |
| $fidl.performCtrlWithExceptionHandling(_name, ctrl, () { |
| final List<$fidl.MemberType> $types = |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type.response!; |
| // ignore: prefer_const_declarations |
| final $response = $fidl.decodeMessage( |
| $message, |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type |
| .responseInlineSize($message.wireFormat), |
| $types[0]); |
| |
| if ($response.$tag == |
| lib$fidl_test_errorsyntax_parent |
| .ParentUsesErrorSyntaxComposedCallWhichMayFailResultTag |
| .response) { |
| $completer.complete($response.response.value); |
| } else { |
| $completer.completeError($fidl.MethodException($response.err)); |
| } |
| }, 'method response'); |
| break; |
| case _kExampleUseOfErrorSyntax_CallWhichMayFail_Ordinal: |
| final String _name = |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Type.name; |
| $fidl.performCtrlWithExceptionHandling(_name, ctrl, () { |
| final List<$fidl.MemberType> $types = |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Type.response!; |
| // ignore: prefer_const_declarations |
| final $response = $fidl.decodeMessage( |
| $message, |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Type |
| .responseInlineSize($message.wireFormat), |
| $types[0]); |
| |
| if ($response.$tag == |
| ExampleUseOfErrorSyntaxCallWhichMayFailResultTag.response) { |
| $completer.complete($response.response.value); |
| } else { |
| $completer.completeError($fidl.MethodException($response.err)); |
| } |
| }, 'method response'); |
| break; |
| default: |
| $fidl.handleCtrlError( |
| ctrl, 'Unexpected message ordinal: ${$message.ordinal}'); |
| break; |
| } |
| } |
| |
| @override |
| $async.Future<int> composedCallWhichMayFail(String s) async { |
| if (!ctrl.isBound) { |
| return $async.Future.error( |
| $fidl.FidlStateException('Proxy<${ctrl.$interfaceName}> is closed.'), |
| StackTrace.current); |
| } |
| |
| final $fidl.Encoder $encoder = $fidl.Encoder($fidl.kWireFormatDefault); |
| $encoder.encodeMessageHeader( |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Ordinal, 0); |
| final List<$fidl.MemberType> $types = |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type.request!; |
| $fidl.encodeMessageWithCallback( |
| $encoder, |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type |
| .requestInlineSize($encoder.wireFormat), () { |
| $types[0].encode($encoder, s, $fidl.kMessageHeaderSize, 1); |
| }); |
| final $completer = $async.Completer<int>(); |
| ctrl.sendMessageWithResponse($encoder.message, $completer); |
| return $completer.future; |
| } |
| |
| @override |
| $async.Future<int> callWhichMayFail(String s) async { |
| if (!ctrl.isBound) { |
| return $async.Future.error( |
| $fidl.FidlStateException('Proxy<${ctrl.$interfaceName}> is closed.'), |
| StackTrace.current); |
| } |
| |
| final $fidl.Encoder $encoder = $fidl.Encoder($fidl.kWireFormatDefault); |
| $encoder.encodeMessageHeader( |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Ordinal, 0); |
| final List<$fidl.MemberType> $types = |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Type.request!; |
| $fidl.encodeMessageWithCallback( |
| $encoder, |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Type |
| .requestInlineSize($encoder.wireFormat), () { |
| $types[0].encode($encoder, s, $fidl.kMessageHeaderSize, 1); |
| }); |
| final $completer = $async.Completer<int>(); |
| ctrl.sendMessageWithResponse($encoder.message, $completer); |
| return $completer.future; |
| } |
| } |
| |
| class ExampleUseOfErrorSyntaxBinding |
| extends $fidl.AsyncBinding<ExampleUseOfErrorSyntax> { |
| ExampleUseOfErrorSyntaxBinding() : super(r"ExampleUseOfErrorSyntax"); |
| |
| @override |
| void handleMessage( |
| $fidl.IncomingMessage $message, $fidl.OutgoingMessageSink $respond) { |
| switch ($message.ordinal) { |
| case _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Ordinal: |
| final String _name = |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type.name; |
| $fidl.performWithExceptionHandling(_name, () { |
| final List<$fidl.MemberType> $types = |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type.request!; |
| // ignore: prefer_const_declarations |
| final _impl = impl!; |
| final $async.Future<int> $future = $fidl |
| .decodeMessageWithCallback<$async.Future<int>>( |
| $message, |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type |
| .requestInlineSize($message.wireFormat), |
| ($fidl.Decoder decoder) { |
| return _impl.composedCallWhichMayFail( |
| $types[0].decode(decoder, $fidl.kMessageHeaderSize, 1), |
| ); |
| }); |
| $future.then(($responseValue) { |
| return lib$fidl_test_errorsyntax_parent |
| .ParentUsesErrorSyntaxComposedCallWhichMayFailResult |
| .withResponse(lib$fidl_test_errorsyntax_parent |
| .ParentUsesErrorSyntaxComposedCallWhichMayFailResponse( |
| value: $responseValue)); |
| }, onError: ($error) { |
| if ($error is $fidl.MethodException) { |
| return lib$fidl_test_errorsyntax_parent |
| .ParentUsesErrorSyntaxComposedCallWhichMayFailResult |
| .withErr($error.value); |
| } else { |
| return Future.error($error, StackTrace.current); |
| } |
| }).then(($response) { |
| final $fidl.Encoder $encoder = |
| $fidl.Encoder($fidl.kWireFormatDefault); |
| $encoder.encodeMessageHeader( |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Ordinal, |
| $message.txid); |
| final List<$fidl.MemberType> $types = |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type |
| .response!; |
| $fidl.encodeMessage( |
| $encoder, |
| _kExampleUseOfErrorSyntax_ComposedCallWhichMayFail_Type |
| .responseInlineSize($encoder.wireFormat), |
| $types[0], |
| $response); |
| $respond($encoder.message); |
| }, onError: (_e) { |
| $fidl.handleException(_name, _e, close); |
| }); |
| }, close); |
| break; |
| case _kExampleUseOfErrorSyntax_CallWhichMayFail_Ordinal: |
| final String _name = |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Type.name; |
| $fidl.performWithExceptionHandling(_name, () { |
| final List<$fidl.MemberType> $types = |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Type.request!; |
| // ignore: prefer_const_declarations |
| final _impl = impl!; |
| final $async.Future<int> $future = $fidl |
| .decodeMessageWithCallback<$async.Future<int>>( |
| $message, |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Type |
| .requestInlineSize($message.wireFormat), |
| ($fidl.Decoder decoder) { |
| return _impl.callWhichMayFail( |
| $types[0].decode(decoder, $fidl.kMessageHeaderSize, 1), |
| ); |
| }); |
| $future.then(($responseValue) { |
| return ExampleUseOfErrorSyntaxCallWhichMayFailResult.withResponse( |
| ExampleUseOfErrorSyntaxCallWhichMayFailResponse( |
| value: $responseValue)); |
| }, onError: ($error) { |
| if ($error is $fidl.MethodException) { |
| return ExampleUseOfErrorSyntaxCallWhichMayFailResult.withErr( |
| $error.value); |
| } else { |
| return Future.error($error, StackTrace.current); |
| } |
| }).then(($response) { |
| final $fidl.Encoder $encoder = |
| $fidl.Encoder($fidl.kWireFormatDefault); |
| $encoder.encodeMessageHeader( |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Ordinal, |
| $message.txid); |
| final List<$fidl.MemberType> $types = |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Type.response!; |
| $fidl.encodeMessage( |
| $encoder, |
| _kExampleUseOfErrorSyntax_CallWhichMayFail_Type |
| .responseInlineSize($encoder.wireFormat), |
| $types[0], |
| $response); |
| $respond($encoder.message); |
| }, onError: (_e) { |
| $fidl.handleException(_name, _e, close); |
| }); |
| }, close); |
| break; |
| default: |
| throw $fidl.FidlError( |
| r'Unexpected message name for ExampleUseOfErrorSyntaxBinding'); |
| } |
| } |
| } |