diff --git a/.ci/flutter_master.version b/.ci/flutter_master.version index 174e1417a8da..da89d6b1d41f 100644 --- a/.ci/flutter_master.version +++ b/.ci/flutter_master.version @@ -1 +1 @@ -d31a85ba5c5e67199a9a3c95fd9fef51c89a9306 +b96c13d1e9ff3e8ebb9f3647b43c8d51c221e82e diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index 9ea0b8a095c1..6d5ddf51851a 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -2,6 +2,10 @@ * Modifies resolution selection logic to use an `AspectRatioStrategy` for all aspect ratios supported by CameraX. +## 0.6.0+1 + +* Updates `README.md` to encourage developers to opt into this implementation of the camera plugin. + ## 0.6.0 * Implements `setFocusMode`, which makes this plugin reach feature parity with camera_android. diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md index d60a71a46c84..64a56f1a3b54 100644 --- a/packages/camera/camera_android_camerax/README.md +++ b/packages/camera/camera_android_camerax/README.md @@ -2,26 +2,23 @@ An Android implementation of [`camera`][1] that uses the [CameraX library][2]. -*Note*: This package is under development, so please note the -[missing features and limitations](#limitations), but -otherwise feel free to try out the current implementation and provide any -feedback by filing issues under [`flutter/flutter`][5] with `[camerax]` in -the title, which will be actively triaged. +*Note*: This implementation will become the default implementation of `camera` +on Android by May 2024, so **we strongly encourage you to opt into it** +by using [the instructions](#usage) below. If any of [the limitations](#limitations) +prevent you from using `camera_android_camerax` or if you run into any problems, +please report these issues under [`flutter/flutter`][5] with `[camerax]` in +the title. ## Usage -This package is [non-endorsed][3]; the endorsed Android implementation of `camera` -is [`camera_android`][4]. To use this implementation of the plugin instead of -`camera_android`, you will need to specify it in your `pubspec.yaml` file as a -dependency in addition to `camera`: +To use this plugin instead of [`camera_android`][4], run -```yaml -dependencies: - # ...along with your other dependencies - camera: ^0.10.4 - camera_android_camerax: ^0.5.0 +```sh +$ flutter pub add camera_android_camerax ``` +from your project's root directory. + ## Limitations ### 240p resolution configuration for video recording diff --git a/packages/flutter_markdown/CHANGELOG.md b/packages/flutter_markdown/CHANGELOG.md index 3ce5c52c1a7b..f3ed8654f361 100644 --- a/packages/flutter_markdown/CHANGELOG.md +++ b/packages/flutter_markdown/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.6.22 + +* Introduces a new `MarkdownElementBuilder.isBlockElement()` method to specify if custom element + is a block. + ## 0.6.21+1 * Adds `onSelectionChanged` to the constructors of `Markdown` and `MarkdownBody`. diff --git a/packages/flutter_markdown/lib/src/builder.dart b/packages/flutter_markdown/lib/src/builder.dart index 8ecdd7b9b3fb..739520588db7 100644 --- a/packages/flutter_markdown/lib/src/builder.dart +++ b/packages/flutter_markdown/lib/src/builder.dart @@ -10,7 +10,7 @@ import '_functions_io.dart' if (dart.library.js_interop) '_functions_web.dart'; import 'style_sheet.dart'; import 'widget.dart'; -const List _kBlockTags = [ +final List _kBlockTags = [ 'p', 'h1', 'h2', @@ -190,6 +190,12 @@ class MarkdownBuilder implements md.NodeVisitor { _linkHandlers.clear(); _isInBlockquote = false; + builders.forEach((String key, MarkdownElementBuilder value) { + if (value.isBlockElement()) { + _kBlockTags.add(key); + } + }); + _blocks.add(_BlockElement(null)); for (final md.Node node in nodes) { diff --git a/packages/flutter_markdown/lib/src/widget.dart b/packages/flutter_markdown/lib/src/widget.dart index 8edc949242ef..38ffbdcc32ef 100644 --- a/packages/flutter_markdown/lib/src/widget.dart +++ b/packages/flutter_markdown/lib/src/widget.dart @@ -70,6 +70,11 @@ abstract class SyntaxHighlighter { /// An interface for an element builder. abstract class MarkdownElementBuilder { + /// For block syntax has to return true. + /// + /// By default returns false. + bool isBlockElement() => false; + /// Called when an Element has been reached, before its children have been /// visited. void visitElementBefore(md.Element element) {} diff --git a/packages/flutter_markdown/pubspec.yaml b/packages/flutter_markdown/pubspec.yaml index 20639b245fac..c077bb64f93e 100644 --- a/packages/flutter_markdown/pubspec.yaml +++ b/packages/flutter_markdown/pubspec.yaml @@ -4,7 +4,7 @@ description: A Markdown renderer for Flutter. Create rich text output, formatted with simple Markdown tags. repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22 -version: 0.6.21+1 +version: 0.6.22 environment: sdk: ^3.3.0 diff --git a/packages/flutter_markdown/test/custom_syntax_test.dart b/packages/flutter_markdown/test/custom_syntax_test.dart index 2bee4ebbf0bd..28d55cdfd0b5 100644 --- a/packages/flutter_markdown/test/custom_syntax_test.dart +++ b/packages/flutter_markdown/test/custom_syntax_test.dart @@ -35,6 +35,30 @@ void defineTests() { }, ); + testWidgets( + 'Custom block element', + (WidgetTester tester) async { + const String blockContent = 'note block'; + await tester.pumpWidget( + boilerplate( + Markdown( + data: '[!NOTE] $blockContent', + extensionSet: md.ExtensionSet.none, + blockSyntaxes: [NoteSyntax()], + builders: { + 'note': NoteBuilder(), + }, + ), + ), + ); + final ColoredBox container = + tester.widgetList(find.byType(ColoredBox)).first as ColoredBox; + expect(container.color, Colors.red); + expect(container.child, isInstanceOf()); + expect((container.child! as Text).data, blockContent); + }, + ); + testWidgets( 'link for wikistyle', (WidgetTester tester) async { @@ -331,3 +355,28 @@ class ImgBuilder extends MarkdownElementBuilder { return Text('foo', style: preferredStyle); } } + +class NoteBuilder extends MarkdownElementBuilder { + @override + Widget? visitText(md.Text text, TextStyle? preferredStyle) { + return ColoredBox( + color: Colors.red, child: Text(text.text, style: preferredStyle)); + } + + @override + bool isBlockElement() { + return true; + } +} + +class NoteSyntax extends md.BlockSyntax { + @override + md.Node? parse(md.BlockParser parser) { + final md.Line line = parser.current; + parser.advance(); + return md.Element('note', [md.Text(line.content.substring(8))]); + } + + @override + RegExp get pattern => RegExp(r'^\[!NOTE] '); +} diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index 1c775d236405..ea6cd9df5b55 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,3 +1,7 @@ +## 17.2.0 + +* [dart] Adds implementation for `@ProxyApi`. + ## 17.1.3 * [objc] Fixes double prefixes added to enum names. diff --git a/packages/pigeon/lib/ast.dart b/packages/pigeon/lib/ast.dart index 0c48faa45456..bc4ec8c44777 100644 --- a/packages/pigeon/lib/ast.dart +++ b/packages/pigeon/lib/ast.dart @@ -177,6 +177,133 @@ class AstProxyApi extends Api { (ApiField field) => !field.isAttached, ); + /// A list of AstProxyApis where each `extends` the API that follows it. + /// + /// Returns an empty list if this api does not extend a ProxyApi. + /// + /// This method assumes the super classes of each ProxyApi doesn't create a + /// loop. Throws a [ArgumentError] if a loop is found. + /// + /// This method also assumes that all super classes are ProxyApis. Otherwise, + /// throws an [ArgumentError]. + Iterable allSuperClasses() { + final List superClassChain = []; + + if (superClass != null && !superClass!.isProxyApi) { + throw ArgumentError( + 'Could not find a ProxyApi for super class: ${superClass!.baseName}', + ); + } + + AstProxyApi? currentProxyApi = superClass?.associatedProxyApi; + while (currentProxyApi != null) { + if (superClassChain.contains(currentProxyApi)) { + throw ArgumentError( + 'Loop found when processing super classes for a ProxyApi: ' + '$name, ${superClassChain.map((AstProxyApi api) => api.name)}', + ); + } + + superClassChain.add(currentProxyApi); + + if (currentProxyApi.superClass != null && + !currentProxyApi.superClass!.isProxyApi) { + throw ArgumentError( + 'Could not find a ProxyApi for super class: ' + '${currentProxyApi.superClass!.baseName}', + ); + } + + currentProxyApi = currentProxyApi.superClass?.associatedProxyApi; + } + + return superClassChain; + } + + /// All ProxyApis this API `implements` and all the interfaces those APIs + /// `implements`. + Iterable apisOfInterfaces() => _recursiveFindAllInterfaceApis(); + + /// All methods inherited from interfaces and the interfaces of interfaces. + Iterable flutterMethodsFromInterfaces() sync* { + for (final AstProxyApi proxyApi in apisOfInterfaces()) { + yield* proxyApi.methods; + } + } + + /// A list of Flutter methods inherited from the ProxyApi that this ProxyApi + /// `extends`. + /// + /// This also recursively checks the ProxyApi that the super class `extends` + /// and so on. + /// + /// This also includes methods that super classes inherited from interfaces + /// with `implements`. + Iterable flutterMethodsFromSuperClasses() sync* { + for (final AstProxyApi proxyApi in allSuperClasses().toList().reversed) { + yield* proxyApi.flutterMethods; + } + if (superClass != null) { + final Set interfaceApisFromSuperClasses = + superClass!.associatedProxyApi!._recursiveFindAllInterfaceApis(); + for (final AstProxyApi proxyApi in interfaceApisFromSuperClasses) { + yield* proxyApi.methods; + } + } + } + + /// Whether the api has a method that callbacks to Dart to add a new instance + /// to the InstanceManager. + /// + /// This is possible as long as no callback methods are required to + /// instantiate the class. + bool hasCallbackConstructor() { + return flutterMethods + .followedBy(flutterMethodsFromSuperClasses()) + .followedBy(flutterMethodsFromInterfaces()) + .every((Method method) => !method.isRequired); + } + + // Recursively search for all the interfaces apis from a list of names of + // interfaces. + // + // This method assumes that all interfaces are ProxyApis and an api doesn't + // contains itself as an interface. Otherwise, throws an [ArgumentError]. + Set _recursiveFindAllInterfaceApis([ + Set seenApis = const {}, + ]) { + final Set allInterfaces = {}; + + allInterfaces.addAll( + interfaces.map( + (TypeDeclaration type) { + if (!type.isProxyApi) { + throw ArgumentError( + 'Could not find a valid ProxyApi for an interface: $type', + ); + } else if (seenApis.contains(type.associatedProxyApi)) { + throw ArgumentError( + 'A ProxyApi cannot be a super class of itself: ${type.baseName}', + ); + } + return type.associatedProxyApi!; + }, + ), + ); + + // Adds the current api since it would be invalid for it to be an interface + // of itself. + final Set newSeenApis = {...seenApis, this}; + + for (final AstProxyApi interfaceApi in {...allInterfaces}) { + allInterfaces.addAll( + interfaceApi._recursiveFindAllInterfaceApis(newSeenApis), + ); + } + + return allInterfaces; + } + @override String toString() { return '(ProxyApi name:$name methods:$methods field:$fields ' diff --git a/packages/pigeon/lib/dart/templates.dart b/packages/pigeon/lib/dart/templates.dart new file mode 100644 index 000000000000..ce986b888dbf --- /dev/null +++ b/packages/pigeon/lib/dart/templates.dart @@ -0,0 +1,403 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import '../generator_tools.dart'; + +/// Creates the `InstanceManager` with the passed string values. +String instanceManagerTemplate({ + required Iterable allProxyApiNames, +}) { + final Iterable apiHandlerSetUps = allProxyApiNames.map( + (String name) { + return '$name.${classMemberNamePrefix}setUpMessageHandlers(${classMemberNamePrefix}instanceManager: instanceManager);'; + }, + ); + + return ''' +/// Maintains instances used to communicate with the native objects they +/// represent. +/// +/// Added instances are stored as weak references and their copies are stored +/// as strong references to maintain access to their variables and callback +/// methods. Both are stored with the same identifier. +/// +/// When a weak referenced instance becomes inaccessible, +/// [onWeakReferenceRemoved] is called with its associated identifier. +/// +/// If an instance is retrieved and has the possibility to be used, +/// (e.g. calling [getInstanceWithWeakReference]) a copy of the strong reference +/// is added as a weak reference with the same identifier. This prevents a +/// scenario where the weak referenced instance was released and then later +/// returned by the host platform. +class $instanceManagerClassName { + /// Constructs a [$instanceManagerClassName]. + $instanceManagerClassName({required void Function(int) onWeakReferenceRemoved}) { + this.onWeakReferenceRemoved = (int identifier) { + _weakInstances.remove(identifier); + onWeakReferenceRemoved(identifier); + }; + _finalizer = Finalizer(this.onWeakReferenceRemoved); + } + + // Identifiers are locked to a specific range to avoid collisions with objects + // created simultaneously by the host platform. + // Host uses identifiers >= 2^16 and Dart is expected to use values n where, + // 0 <= n < 2^16. + static const int _maxDartCreatedIdentifier = 65536; + + /// The default [$instanceManagerClassName] used by ProxyApis. + /// + /// On creation, this manager makes a call to clear the native + /// InstanceManager. This is to prevent identifier conflicts after a host + /// restart. + static final $instanceManagerClassName instance = _initInstance(); + + // Expando is used because it doesn't prevent its keys from becoming + // inaccessible. This allows the manager to efficiently retrieve an identifier + // of an instance without holding a strong reference to that instance. + // + // It also doesn't use `==` to search for identifiers, which would lead to an + // infinite loop when comparing an object to its copy. (i.e. which was caused + // by calling instanceManager.getIdentifier() inside of `==` while this was a + // HashMap). + final Expando _identifiers = Expando(); + final Map> _weakInstances = + >{}; + final Map _strongInstances = {}; + late final Finalizer _finalizer; + int _nextIdentifier = 0; + + /// Called when a weak referenced instance is removed by [removeWeakReference] + /// or becomes inaccessible. + late final void Function(int) onWeakReferenceRemoved; + + static $instanceManagerClassName _initInstance() { + WidgetsFlutterBinding.ensureInitialized(); + final _${instanceManagerClassName}Api api = _${instanceManagerClassName}Api(); + // Clears the native `$instanceManagerClassName` on the initial use of the Dart one. + api.clear(); + final $instanceManagerClassName instanceManager = $instanceManagerClassName( + onWeakReferenceRemoved: (int identifier) { + api.removeStrongReference(identifier); + }, + ); + _${instanceManagerClassName}Api.setUpMessageHandlers(instanceManager: instanceManager); + ${apiHandlerSetUps.join('\n\t\t')} + return instanceManager; + } + + /// Adds a new instance that was instantiated by Dart. + /// + /// In other words, Dart wants to add a new instance that will represent + /// an object that will be instantiated on the host platform. + /// + /// Throws assertion error if the instance has already been added. + /// + /// Returns the randomly generated id of the [instance] added. + int addDartCreatedInstance($proxyApiBaseClassName instance) { + final int identifier = _nextUniqueIdentifier(); + _addInstanceWithIdentifier(instance, identifier); + return identifier; + } + + /// Removes the instance, if present, and call [onWeakReferenceRemoved] with + /// its identifier. + /// + /// Returns the identifier associated with the removed instance. Otherwise, + /// `null` if the instance was not found in this manager. + /// + /// This does not remove the strong referenced instance associated with + /// [instance]. This can be done with [remove]. + int? removeWeakReference($proxyApiBaseClassName instance) { + final int? identifier = getIdentifier(instance); + if (identifier == null) { + return null; + } + + _identifiers[instance] = null; + _finalizer.detach(instance); + onWeakReferenceRemoved(identifier); + + return identifier; + } + + /// Removes [identifier] and its associated strongly referenced instance, if + /// present, from the manager. + /// + /// Returns the strong referenced instance associated with [identifier] before + /// it was removed. Returns `null` if [identifier] was not associated with + /// any strong reference. + /// + /// This does not remove the weak referenced instance associated with + /// [identifier]. This can be done with [removeWeakReference]. + T? remove(int identifier) { + return _strongInstances.remove(identifier) as T?; + } + + /// Retrieves the instance associated with identifier. + /// + /// The value returned is chosen from the following order: + /// + /// 1. A weakly referenced instance associated with identifier. + /// 2. If the only instance associated with identifier is a strongly + /// referenced instance, a copy of the instance is added as a weak reference + /// with the same identifier. Returning the newly created copy. + /// 3. If no instance is associated with identifier, returns null. + /// + /// This method also expects the host `InstanceManager` to have a strong + /// reference to the instance the identifier is associated with. + T? getInstanceWithWeakReference(int identifier) { + final $proxyApiBaseClassName? weakInstance = _weakInstances[identifier]?.target; + + if (weakInstance == null) { + final $proxyApiBaseClassName? strongInstance = _strongInstances[identifier]; + if (strongInstance != null) { + final $proxyApiBaseClassName copy = strongInstance.${classMemberNamePrefix}copy(); + _identifiers[copy] = identifier; + _weakInstances[identifier] = WeakReference<$proxyApiBaseClassName>(copy); + _finalizer.attach(copy, identifier, detach: copy); + return copy as T; + } + return strongInstance as T?; + } + + return weakInstance as T; + } + + /// Retrieves the identifier associated with instance. + int? getIdentifier($proxyApiBaseClassName instance) { + return _identifiers[instance]; + } + + /// Adds a new instance that was instantiated by the host platform. + /// + /// In other words, the host platform wants to add a new instance that + /// represents an object on the host platform. Stored with [identifier]. + /// + /// Throws assertion error if the instance or its identifier has already been + /// added. + /// + /// Returns unique identifier of the [instance] added. + void addHostCreatedInstance($proxyApiBaseClassName instance, int identifier) { + _addInstanceWithIdentifier(instance, identifier); + } + + void _addInstanceWithIdentifier($proxyApiBaseClassName instance, int identifier) { + assert(!containsIdentifier(identifier)); + assert(getIdentifier(instance) == null); + assert(identifier >= 0); + + _identifiers[instance] = identifier; + _weakInstances[identifier] = WeakReference<$proxyApiBaseClassName>(instance); + _finalizer.attach(instance, identifier, detach: instance); + + final $proxyApiBaseClassName copy = instance.${classMemberNamePrefix}copy(); + _identifiers[copy] = identifier; + _strongInstances[identifier] = copy; + } + + /// Whether this manager contains the given [identifier]. + bool containsIdentifier(int identifier) { + return _weakInstances.containsKey(identifier) || + _strongInstances.containsKey(identifier); + } + + int _nextUniqueIdentifier() { + late int identifier; + do { + identifier = _nextIdentifier; + _nextIdentifier = (_nextIdentifier + 1) % _maxDartCreatedIdentifier; + } while (containsIdentifier(identifier)); + return identifier; + } +} +'''; +} + +/// Creates the `InstanceManagerApi` with the passed string values. +String instanceManagerApiTemplate({ + required String dartPackageName, + required String pigeonChannelCodecVarName, +}) { + const String apiName = '${instanceManagerClassName}Api'; + + final String removeStrongReferenceName = makeChannelNameWithStrings( + apiName: apiName, + methodName: 'removeStrongReference', + dartPackageName: dartPackageName, + ); + + final String clearName = makeChannelNameWithStrings( + apiName: apiName, + methodName: 'clear', + dartPackageName: dartPackageName, + ); + + return ''' +/// Generated API for managing the Dart and native `$instanceManagerClassName`s. +class _$apiName { + /// Constructor for [_$apiName]. + _$apiName({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; + + final BinaryMessenger? _binaryMessenger; + + static const MessageCodec $pigeonChannelCodecVarName = + StandardMessageCodec(); + + static void setUpMessageHandlers({ + BinaryMessenger? binaryMessenger, + $instanceManagerClassName? instanceManager, + }) { + const String channelName = + r'$removeStrongReferenceName'; + final BasicMessageChannel channel = BasicMessageChannel( + channelName, + $pigeonChannelCodecVarName, + binaryMessenger: binaryMessenger, + ); + channel.setMessageHandler((Object? message) async { + assert( + message != null, + 'Argument for \$channelName was null.', + ); + final int? identifier = message as int?; + assert( + identifier != null, + r'Argument for \$channelName, expected non-null int.', + ); + (instanceManager ?? $instanceManagerClassName.instance).remove(identifier!); + return; + }); + } + + Future removeStrongReference(int identifier) async { + const String channelName = + r'$removeStrongReferenceName'; + final BasicMessageChannel channel = BasicMessageChannel( + channelName, + $pigeonChannelCodecVarName, + binaryMessenger: _binaryMessenger, + ); + final List? replyList = + await channel.send(identifier) as List?; + if (replyList == null) { + throw _createConnectionError(channelName); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else { + return; + } + } + + /// Clear the native `$instanceManagerClassName`. + /// + /// This is typically called after a hot restart. + Future clear() async { + const String channelName = + r'$clearName'; + final BasicMessageChannel channel = BasicMessageChannel( + channelName, + $pigeonChannelCodecVarName, + binaryMessenger: _binaryMessenger, + ); + final List? replyList = await channel.send(null) as List?; + if (replyList == null) { + throw _createConnectionError(channelName); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else { + return; + } + } +}'''; +} + +/// The base class for all ProxyApis. +/// +/// All Dart classes generated as a ProxyApi extends this one. +const String proxyApiBaseClass = ''' +/// An immutable object that serves as the base class for all ProxyApis and +/// can provide functional copies of itself. +/// +/// All implementers are expected to be [immutable] as defined by the annotation +/// and override [${classMemberNamePrefix}copy] returning an instance of itself. +@immutable +abstract class $proxyApiBaseClassName { + /// Construct a [$proxyApiBaseClassName]. + $proxyApiBaseClassName({ + this.$_proxyApiBaseClassMessengerVarName, + $instanceManagerClassName? $_proxyApiBaseClassInstanceManagerVarName, + }) : $_proxyApiBaseClassInstanceManagerVarName = + $_proxyApiBaseClassInstanceManagerVarName ?? $instanceManagerClassName.instance; + + /// Sends and receives binary data across the Flutter platform barrier. + /// + /// If it is null, the default BinaryMessenger will be used, which routes to + /// the host platform. + @protected + final BinaryMessenger? $_proxyApiBaseClassMessengerVarName; + + /// Maintains instances stored to communicate with native language objects. + @protected + final $instanceManagerClassName $_proxyApiBaseClassInstanceManagerVarName; + + /// Instantiates and returns a functionally identical object to oneself. + /// + /// Outside of tests, this method should only ever be called by + /// [$instanceManagerClassName]. + /// + /// Subclasses should always override their parent's implementation of this + /// method. + @protected + $proxyApiBaseClassName ${classMemberNamePrefix}copy(); +} +'''; + +/// The base codec for ProxyApis. +/// +/// All generated Dart proxy apis should use this codec or extend it. This codec +/// adds support to convert instances to their corresponding identifier from an +/// `InstanceManager` and vice versa. +const String proxyApiBaseCodec = ''' +class $_proxyApiCodecName extends StandardMessageCodec { + const $_proxyApiCodecName(this.instanceManager); + final $instanceManagerClassName instanceManager; + @override + void writeValue(WriteBuffer buffer, Object? value) { + if (value is $proxyApiBaseClassName) { + buffer.putUint8(128); + writeValue(buffer, instanceManager.getIdentifier(value)); + } else { + super.writeValue(buffer, value); + } + } + @override + Object? readValueOfType(int type, ReadBuffer buffer) { + switch (type) { + case 128: + return instanceManager + .getInstanceWithWeakReference(readValue(buffer)! as int); + default: + return super.readValueOfType(type, buffer); + } + } +} +'''; + +/// Name of the base class of all ProxyApis. +const String proxyApiBaseClassName = '${classNamePrefix}ProxyApiBaseClass'; +const String _proxyApiBaseClassMessengerVarName = + '${classMemberNamePrefix}binaryMessenger'; +const String _proxyApiBaseClassInstanceManagerVarName = + '${classMemberNamePrefix}instanceManager'; +const String _proxyApiCodecName = '_${classNamePrefix}ProxyApiBaseCodec'; diff --git a/packages/pigeon/lib/dart_generator.dart b/packages/pigeon/lib/dart_generator.dart index 8cdea012554b..40ce7a6e5df4 100644 --- a/packages/pigeon/lib/dart_generator.dart +++ b/packages/pigeon/lib/dart_generator.dart @@ -2,9 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:code_builder/code_builder.dart' as cb; +import 'package:dart_style/dart_style.dart'; import 'package:path/path.dart' as path; import 'ast.dart'; +import 'dart/templates.dart'; import 'functional.dart'; import 'generator.dart'; import 'generator_tools.dart'; @@ -18,6 +21,10 @@ const String _docCommentPrefix = '///'; /// user defined parameters. const String _varNamePrefix = '__pigeon_'; +/// Name of the `InstanceManager` variable for a ProxyApi class; +const String _instanceManagerVarName = + '${classMemberNamePrefix}instanceManager'; + /// Name of field used for host API codec. const String _pigeonChannelCodec = 'pigeonChannelCodec'; @@ -111,9 +118,16 @@ class DartGenerator extends StructuredGenerator { "import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;", ); indent.newln(); + + final bool hasProxyApi = root.apis.any((Api api) => api is AstProxyApi); indent.writeln( - "import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;"); + "import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer${hasProxyApi ? ', immutable, protected' : ''};"); indent.writeln("import 'package:flutter/services.dart';"); + if (hasProxyApi) { + indent.writeln( + "import 'package:flutter/widgets.dart' show WidgetsFlutterBinding;", + ); + } } @override @@ -434,6 +448,158 @@ final BinaryMessenger? ${_varNamePrefix}binaryMessenger; }); } + @override + void writeInstanceManager( + DartOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { + indent.format(proxyApiBaseClass); + + indent.format( + instanceManagerTemplate( + allProxyApiNames: root.apis + .whereType() + .map((AstProxyApi api) => api.name), + ), + ); + } + + @override + void writeInstanceManagerApi( + DartOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { + indent.format( + instanceManagerApiTemplate( + dartPackageName: dartPackageName, + pigeonChannelCodecVarName: _pigeonChannelCodec, + ), + ); + } + + @override + void writeProxyApiBaseCodec( + DartOptions generatorOptions, + Root root, + Indent indent, + ) { + indent.format(proxyApiBaseCodec); + } + + @override + void writeProxyApi( + DartOptions generatorOptions, + Root root, + Indent indent, + AstProxyApi api, { + required String dartPackageName, + }) { + const String codecName = '_${classNamePrefix}ProxyApiBaseCodec'; + + // Each API has a private codec instance used by every host method, + // constructor, or non-static field. + final String codecInstanceName = '${_varNamePrefix}codec${api.name}'; + + // AST class used by code_builder to generate the code. + final cb.Class proxyApi = cb.Class( + (cb.ClassBuilder builder) => builder + ..name = api.name + ..extend = api.superClass != null + ? cb.refer(api.superClass!.baseName) + : cb.refer(proxyApiBaseClassName) + ..implements.addAll( + api.interfaces.map( + (TypeDeclaration type) => cb.refer(type.baseName), + ), + ) + ..docs.addAll( + asDocumentationComments(api.documentationComments, _docCommentSpec), + ) + ..constructors.addAll(_proxyApiConstructors( + api.constructors, + apiName: api.name, + dartPackageName: dartPackageName, + codecName: codecName, + codecInstanceName: codecInstanceName, + superClassApi: api.superClass?.associatedProxyApi, + unattachedFields: api.unattachedFields, + flutterMethodsFromSuperClasses: api.flutterMethodsFromSuperClasses(), + flutterMethodsFromInterfaces: api.flutterMethodsFromInterfaces(), + declaredFlutterMethods: api.flutterMethods, + )) + ..constructors.add( + _proxyApiDetachedConstructor( + apiName: api.name, + superClassApi: api.superClass?.associatedProxyApi, + unattachedFields: api.unattachedFields, + flutterMethodsFromSuperClasses: + api.flutterMethodsFromSuperClasses(), + flutterMethodsFromInterfaces: api.flutterMethodsFromInterfaces(), + declaredFlutterMethods: api.flutterMethods, + ), + ) + ..fields.addAll([ + if (api.constructors.isNotEmpty || + api.attachedFields.any((ApiField field) => !field.isStatic) || + api.hostMethods.isNotEmpty) + _proxyApiCodecInstanceField( + codecInstanceName: codecInstanceName, + codecName: codecName, + ), + ]) + ..fields.addAll(_proxyApiUnattachedFields(api.unattachedFields)) + ..fields.addAll(_proxyApiFlutterMethodFields( + api.flutterMethods, + apiName: api.name, + )) + ..fields.addAll(_proxyApiInterfaceApiFields(api.apisOfInterfaces())) + ..fields.addAll(_proxyApiAttachedFields(api.attachedFields)) + ..methods.add( + _proxyApiSetUpMessageHandlerMethod( + flutterMethods: api.flutterMethods, + apiName: api.name, + dartPackageName: dartPackageName, + codecName: codecName, + unattachedFields: api.unattachedFields, + hasCallbackConstructor: api.hasCallbackConstructor(), + ), + ) + ..methods.addAll( + _proxyApiAttachedFieldMethods( + api.attachedFields, + apiName: api.name, + dartPackageName: dartPackageName, + codecInstanceName: codecInstanceName, + codecName: codecName, + ), + ) + ..methods.addAll(_proxyApiHostMethods( + api.hostMethods, + apiName: api.name, + dartPackageName: dartPackageName, + codecInstanceName: codecInstanceName, + codecName: codecName, + )) + ..methods.add( + _proxyApiCopyMethod( + apiName: api.name, + unattachedFields: api.unattachedFields, + declaredAndInheritedFlutterMethods: api + .flutterMethodsFromSuperClasses() + .followedBy(api.flutterMethodsFromInterfaces()) + .followedBy(api.flutterMethods), + ), + ), + ); + + final cb.DartEmitter emitter = cb.DartEmitter(useNullSafetySyntax: true); + indent.format(DartFormatter().format('${proxyApi.accept(emitter)}')); + } + /// Generates Dart source code for test support libraries based on the given AST /// represented by [root], outputting the code to [sink]. [sourceOutPath] is the /// path of the generated dart code to be tested. [testOutPath] is where the @@ -521,15 +687,22 @@ final BinaryMessenger? ${_varNamePrefix}binaryMessenger; Indent indent, { required String dartPackageName, }) { - final bool hasHostApi = - root.apis.any((Api api) => api.methods.isNotEmpty && api is AstHostApi); - final bool hasFlutterApi = root.apis - .any((Api api) => api.methods.isNotEmpty && api is AstFlutterApi); - - if (hasHostApi) { + final bool hasHostMethod = root.apis + .whereType() + .any((AstHostApi api) => api.methods.isNotEmpty) || + root.apis.whereType().any((AstProxyApi api) => + api.constructors.isNotEmpty || + api.attachedFields.isNotEmpty || + api.hostMethods.isNotEmpty); + final bool hasFlutterMethod = root.apis + .whereType() + .any((AstFlutterApi api) => api.methods.isNotEmpty) || + root.apis.any((Api api) => api is AstProxyApi); + + if (hasHostMethod) { _writeCreateConnectionError(indent); } - if (hasFlutterApi || generatorOptions.testOutPath != null) { + if (hasFlutterMethod || generatorOptions.testOutPath != null) { _writeWrapResponse(generatorOptions, root, indent); } } @@ -678,7 +851,8 @@ if (${_varNamePrefix}replyList == null) { required bool isMockHandler, required bool isAsynchronous, String nullHandlerExpression = 'api == null', - String Function(String methodName, Iterable safeArgumentNames) + String Function(String methodName, Iterable parameters, + Iterable safeArgumentNames) onCreateApiCall = _createFlutterApiMethodCall, }) { indent.write(''); @@ -745,7 +919,7 @@ if (${_varNamePrefix}replyList == null) { final String name = _getSafeArgumentName(index, field); return '${field.isNamed ? '${field.name}: ' : ''}$name${field.type.isNullable ? '' : '!'}'; }); - call = onCreateApiCall(name, argNames); + call = onCreateApiCall(name, parameters, argNames); } indent.writeScoped('try {', '} ', () { if (returnType.isVoid) { @@ -787,10 +961,820 @@ if (${_varNamePrefix}replyList == null) { static String _createFlutterApiMethodCall( String methodName, + Iterable parameters, Iterable safeArgumentNames, ) { return 'api.$methodName(${safeArgumentNames.join(', ')})'; } + + /// Converts Constructors from the pigeon AST to a `code_builder` Constructor + /// for a ProxyApi. + Iterable _proxyApiConstructors( + Iterable constructors, { + required String apiName, + required String dartPackageName, + required String codecName, + required String codecInstanceName, + required AstProxyApi? superClassApi, + required Iterable unattachedFields, + required Iterable flutterMethodsFromSuperClasses, + required Iterable flutterMethodsFromInterfaces, + required Iterable declaredFlutterMethods, + }) sync* { + final cb.Parameter binaryMessengerParameter = cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = '${classMemberNamePrefix}binaryMessenger' + ..named = true + ..toSuper = true, + ); + final cb.Parameter instanceManagerParameter = cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = _instanceManagerVarName + ..named = true + ..toSuper = true, + ); + for (final Constructor constructor in constructors) { + yield cb.Constructor( + (cb.ConstructorBuilder builder) { + final String channelName = makeChannelNameWithStrings( + apiName: apiName, + methodName: constructor.name.isNotEmpty + ? constructor.name + : '${classMemberNamePrefix}defaultConstructor', + dartPackageName: dartPackageName, + ); + builder + ..name = constructor.name.isNotEmpty ? constructor.name : null + ..docs.addAll(asDocumentationComments( + constructor.documentationComments, + _docCommentSpec, + )) + ..optionalParameters.addAll( + [ + binaryMessengerParameter, + instanceManagerParameter, + for (final ApiField field in unattachedFields) + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = field.name + ..named = true + ..toThis = true + ..required = !field.type.isNullable, + ), + for (final Method method in flutterMethodsFromSuperClasses) + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = method.name + ..named = true + ..toSuper = true + ..required = method.isRequired, + ), + for (final Method method in flutterMethodsFromInterfaces + .followedBy(declaredFlutterMethods)) + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = method.name + ..named = true + ..toThis = true + ..required = method.isRequired, + ), + ...indexMap( + constructor.parameters, + (int index, NamedType parameter) => cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = _getParameterName(index, parameter) + ..type = _refer(parameter.type) + ..named = true + ..required = !parameter.type.isNullable, + ), + ) + ], + ) + ..initializers.addAll( + [ + if (superClassApi != null) + const cb.Code('super.${classMemberNamePrefix}detached()') + ], + ) + ..body = cb.Block( + (cb.BlockBuilder builder) { + final StringBuffer messageCallSink = StringBuffer(); + _writeHostMethodMessageCall( + Indent(messageCallSink), + channelName: channelName, + parameters: [ + Parameter( + name: '${_varNamePrefix}instanceIdentifier', + type: const TypeDeclaration( + baseName: 'int', + isNullable: false, + ), + ), + ...unattachedFields.map( + (ApiField field) => Parameter( + name: field.name, + type: field.type, + ), + ), + ...constructor.parameters, + ], + returnType: const TypeDeclaration.voidDeclaration(), + ); + + builder.statements.addAll([ + const cb.Code( + 'final int ${_varNamePrefix}instanceIdentifier = $_instanceManagerVarName.addDartCreatedInstance(this);', + ), + cb.Code('final $codecName $_pigeonChannelCodec =\n' + ' $codecInstanceName;'), + cb.Code( + 'final BinaryMessenger? ${_varNamePrefix}binaryMessenger = ${binaryMessengerParameter.name};', + ), + const cb.Code('() async {'), + cb.Code(messageCallSink.toString()), + const cb.Code('}();'), + ]); + }, + ); + }, + ); + } + } + + /// The detached constructor present for every ProxyApi. + /// + /// This constructor doesn't include a host method call to create a new native + /// class instance. It is mainly used when the native side wants to create a + /// Dart instance or when the `InstanceManager` wants to create a copy for + /// automatic garbage collection. + cb.Constructor _proxyApiDetachedConstructor({ + required String apiName, + required AstProxyApi? superClassApi, + required Iterable unattachedFields, + required Iterable flutterMethodsFromSuperClasses, + required Iterable flutterMethodsFromInterfaces, + required Iterable declaredFlutterMethods, + }) { + final cb.Parameter binaryMessengerParameter = cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = '${classMemberNamePrefix}binaryMessenger' + ..named = true + ..toSuper = true, + ); + final cb.Parameter instanceManagerParameter = cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = _instanceManagerVarName + ..named = true + ..toSuper = true, + ); + return cb.Constructor( + (cb.ConstructorBuilder builder) => builder + ..name = '${classMemberNamePrefix}detached' + ..docs.addAll([ + '/// Constructs [$apiName] without creating the associated native object.', + '///', + '/// This should only be used by subclasses created by this library or to', + '/// create copies for an [$instanceManagerClassName].', + ]) + ..annotations.add(cb.refer('protected')) + ..optionalParameters.addAll([ + binaryMessengerParameter, + instanceManagerParameter, + for (final ApiField field in unattachedFields) + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = field.name + ..named = true + ..toThis = true + ..required = !field.type.isNullable, + ), + for (final Method method in flutterMethodsFromSuperClasses) + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = method.name + ..named = true + ..toSuper = true + ..required = method.isRequired, + ), + for (final Method method in flutterMethodsFromInterfaces + .followedBy(declaredFlutterMethods)) + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = method.name + ..named = true + ..toThis = true + ..required = method.isRequired, + ), + ]) + ..initializers.addAll([ + if (superClassApi != null) + const cb.Code('super.${classMemberNamePrefix}detached()'), + ]), + ); + } + + /// A private Field of the base codec. + cb.Field _proxyApiCodecInstanceField({ + required String codecInstanceName, + required String codecName, + }) { + return cb.Field( + (cb.FieldBuilder builder) => builder + ..name = codecInstanceName + ..type = cb.refer(codecName) + ..late = true + ..modifier = cb.FieldModifier.final$ + ..assignment = cb.Code('$codecName($_instanceManagerVarName)'), + ); + } + + /// Converts unattached fields from the pigeon AST to `code_builder` + /// Fields. + Iterable _proxyApiUnattachedFields( + Iterable fields, + ) sync* { + for (final ApiField field in fields) { + yield cb.Field( + (cb.FieldBuilder builder) => builder + ..name = field.name + ..type = cb.refer(_addGenericTypesNullable(field.type)) + ..modifier = cb.FieldModifier.final$ + ..docs.addAll(asDocumentationComments( + field.documentationComments, + _docCommentSpec, + )), + ); + } + } + + /// Converts Flutter methods from the pigeon AST to `code_builder` Fields. + /// + /// Flutter methods of a ProxyApi are set as an anonymous function of a class + /// instance, so this converts methods to a `Function` type field instance. + Iterable _proxyApiFlutterMethodFields( + Iterable methods, { + required String apiName, + }) sync* { + for (final Method method in methods) { + yield cb.Field( + (cb.FieldBuilder builder) => builder + ..name = method.name + ..modifier = cb.FieldModifier.final$ + ..docs.addAll(asDocumentationComments( + [ + ...method.documentationComments, + ...[ + if (method.documentationComments.isEmpty) 'Callback method.', + '', + 'For the associated Native object to be automatically garbage collected,', + "it is required that the implementation of this `Function` doesn't have a", + 'strong reference to the encapsulating class instance. When this `Function`', + 'references a non-local variable, it is strongly recommended to access it', + 'with a `WeakReference`:', + '', + '```dart', + 'final WeakReference weakMyVariable = WeakReference(myVariable);', + 'final $apiName instance = $apiName(', + ' ${method.name}: ($apiName ${classMemberNamePrefix}instance, ...) {', + ' print(weakMyVariable?.target);', + ' },', + ');', + '```', + '', + 'Alternatively, [$instanceManagerClassName.removeWeakReference] can be used to', + 'release the associated Native object manually.', + ], + ], + _docCommentSpec, + )) + ..type = cb.FunctionType( + (cb.FunctionTypeBuilder builder) => builder + ..returnType = _refer( + method.returnType, + asFuture: method.isAsynchronous, + ) + ..isNullable = !method.isRequired + ..requiredParameters.addAll([ + cb.refer('$apiName ${classMemberNamePrefix}instance'), + ...indexMap( + method.parameters, + (int index, NamedType parameter) { + return cb.refer( + '${_addGenericTypesNullable(parameter.type)} ${_getParameterName(index, parameter)}', + ); + }, + ), + ]), + ), + ); + } + } + + /// Converts the Flutter methods from the pigeon AST to `code_builder` Fields. + /// + /// Flutter methods of a ProxyApi are set as an anonymous function of a class + /// instance, so this converts methods to a `Function` type field instance. + /// + /// This is similar to [_proxyApiFlutterMethodFields] except all the methods are + /// inherited from apis that are being implemented (following the `implements` + /// keyword). + Iterable _proxyApiInterfaceApiFields( + Iterable apisOfInterfaces, + ) sync* { + for (final AstProxyApi proxyApi in apisOfInterfaces) { + for (final Method method in proxyApi.methods) { + yield cb.Field( + (cb.FieldBuilder builder) => builder + ..name = method.name + ..modifier = cb.FieldModifier.final$ + ..annotations.add(cb.refer('override')) + ..docs.addAll(asDocumentationComments( + method.documentationComments, + _docCommentSpec, + )) + ..type = cb.FunctionType( + (cb.FunctionTypeBuilder builder) => builder + ..returnType = _refer( + method.returnType, + asFuture: method.isAsynchronous, + ) + ..isNullable = !method.isRequired + ..requiredParameters.addAll([ + cb.refer( + '${proxyApi.name} ${classMemberNamePrefix}instance', + ), + ...indexMap( + method.parameters, + (int index, NamedType parameter) { + return cb.refer( + '${_addGenericTypesNullable(parameter.type)} ${_getParameterName(index, parameter)}', + ); + }, + ), + ]), + ), + ); + } + } + } + + /// Converts attached Fields from the pigeon AST to `code_builder` Field. + /// + /// Attached fields are set lazily by calling a private method that returns + /// it. + /// + /// Example Output: + /// + /// ```dart + /// final MyOtherProxyApiClass value = _pigeon_value(); + /// ``` + Iterable _proxyApiAttachedFields(Iterable fields) sync* { + for (final ApiField field in fields) { + yield cb.Field( + (cb.FieldBuilder builder) => builder + ..name = field.name + ..type = cb.refer(_addGenericTypesNullable(field.type)) + ..modifier = cb.FieldModifier.final$ + ..static = field.isStatic + ..late = !field.isStatic + ..docs.addAll(asDocumentationComments( + field.documentationComments, + _docCommentSpec, + )) + ..assignment = cb.Code('$_varNamePrefix${field.name}()'), + ); + } + } + + /// Creates the static `setUpMessageHandlers` method for a ProxyApi. + /// + /// This method handles setting the message handler for every un-inherited + /// Flutter method. + /// + /// This also adds a handler to receive a call from the platform to + /// instantiate a new Dart instance if [hasCallbackConstructor] is set to + /// true. + cb.Method _proxyApiSetUpMessageHandlerMethod({ + required Iterable flutterMethods, + required String apiName, + required String dartPackageName, + required String codecName, + required Iterable unattachedFields, + required bool hasCallbackConstructor, + }) { + final bool hasAnyMessageHandlers = + hasCallbackConstructor || flutterMethods.isNotEmpty; + return cb.Method.returnsVoid( + (cb.MethodBuilder builder) => builder + ..name = '${classMemberNamePrefix}setUpMessageHandlers' + ..returns = cb.refer('void') + ..static = true + ..optionalParameters.addAll([ + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = '${classMemberNamePrefix}clearHandlers' + ..type = cb.refer('bool') + ..named = true + ..defaultTo = const cb.Code('false'), + ), + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = '${classMemberNamePrefix}binaryMessenger' + ..named = true + ..type = cb.refer('BinaryMessenger?'), + ), + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = _instanceManagerVarName + ..named = true + ..type = cb.refer('$instanceManagerClassName?'), + ), + if (hasCallbackConstructor) + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = '${classMemberNamePrefix}newInstance' + ..named = true + ..type = cb.FunctionType( + (cb.FunctionTypeBuilder builder) => builder + ..returnType = cb.refer(apiName) + ..isNullable = true + ..requiredParameters.addAll( + indexMap( + unattachedFields, + (int index, ApiField field) { + return cb.refer( + '${_addGenericTypesNullable(field.type)} ${_getParameterName(index, field)}', + ); + }, + ), + ), + ), + ), + for (final Method method in flutterMethods) + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = method.name + ..type = cb.FunctionType( + (cb.FunctionTypeBuilder builder) => builder + ..returnType = _refer( + method.returnType, + asFuture: method.isAsynchronous, + ) + ..isNullable = true + ..requiredParameters.addAll([ + cb.refer('$apiName ${classMemberNamePrefix}instance'), + ...indexMap( + method.parameters, + (int index, NamedType parameter) { + return cb.refer( + '${_addGenericTypesNullable(parameter.type)} ${_getParameterName(index, parameter)}', + ); + }, + ), + ]), + ), + ), + ]) + ..body = cb.Block.of([ + if (hasAnyMessageHandlers) ...[ + cb.Code( + 'final $codecName $_pigeonChannelCodec = $codecName($_instanceManagerVarName ?? $instanceManagerClassName.instance);', + ), + const cb.Code( + 'final BinaryMessenger? binaryMessenger = ${classMemberNamePrefix}binaryMessenger;', + ) + ], + if (hasCallbackConstructor) + ...cb.Block((cb.BlockBuilder builder) { + final StringBuffer messageHandlerSink = StringBuffer(); + const String methodName = '${classMemberNamePrefix}newInstance'; + _writeFlutterMethodMessageHandler( + Indent(messageHandlerSink), + name: methodName, + parameters: [ + Parameter( + name: '${classMemberNamePrefix}instanceIdentifier', + type: const TypeDeclaration( + baseName: 'int', + isNullable: false, + ), + ), + ...unattachedFields.map( + (ApiField field) { + return Parameter(name: field.name, type: field.type); + }, + ), + ], + returnType: const TypeDeclaration.voidDeclaration(), + channelName: makeChannelNameWithStrings( + apiName: apiName, + methodName: methodName, + dartPackageName: dartPackageName, + ), + isMockHandler: false, + isAsynchronous: false, + nullHandlerExpression: '${classMemberNamePrefix}clearHandlers', + onCreateApiCall: ( + String methodName, + Iterable parameters, + Iterable safeArgumentNames, + ) { + final String argsAsNamedParams = map2( + parameters, + safeArgumentNames, + (Parameter parameter, String safeArgName) { + return '${parameter.name}: $safeArgName,\n'; + }, + ).skip(1).join(); + return '($_instanceManagerVarName ?? $instanceManagerClassName.instance)\n' + ' .addHostCreatedInstance(\n' + ' $methodName?.call(${safeArgumentNames.skip(1).join(',')}) ??\n' + ' $apiName.${classMemberNamePrefix}detached(' + ' ${classMemberNamePrefix}binaryMessenger: ${classMemberNamePrefix}binaryMessenger,\n' + ' $_instanceManagerVarName: $_instanceManagerVarName,\n' + ' $argsAsNamedParams\n' + ' ),\n' + ' ${safeArgumentNames.first},\n' + ')'; + }, + ); + builder.statements.add(cb.Code(messageHandlerSink.toString())); + }).statements, + for (final Method method in flutterMethods) + ...cb.Block((cb.BlockBuilder builder) { + final StringBuffer messageHandlerSink = StringBuffer(); + _writeFlutterMethodMessageHandler( + Indent(messageHandlerSink), + name: method.name, + parameters: [ + Parameter( + name: '${classMemberNamePrefix}instance', + type: TypeDeclaration( + baseName: apiName, + isNullable: false, + ), + ), + ...method.parameters, + ], + returnType: TypeDeclaration( + baseName: method.returnType.baseName, + isNullable: + !method.isRequired || method.returnType.isNullable, + typeArguments: method.returnType.typeArguments, + associatedEnum: method.returnType.associatedEnum, + associatedClass: method.returnType.associatedClass, + associatedProxyApi: method.returnType.associatedProxyApi, + ), + channelName: makeChannelNameWithStrings( + apiName: apiName, + methodName: method.name, + dartPackageName: dartPackageName, + ), + isMockHandler: false, + isAsynchronous: method.isAsynchronous, + nullHandlerExpression: '${classMemberNamePrefix}clearHandlers', + onCreateApiCall: ( + String methodName, + Iterable parameters, + Iterable safeArgumentNames, + ) { + final String nullability = method.isRequired ? '' : '?'; + return '($methodName ?? ${safeArgumentNames.first}.$methodName)$nullability.call(${safeArgumentNames.join(',')})'; + }, + ); + builder.statements.add(cb.Code(messageHandlerSink.toString())); + }).statements, + ]), + ); + } + + /// Converts attached fields from the pigeon AST to `code_builder` Methods. + /// + /// These private methods are used to lazily instantiate attached fields. The + /// instance is created and returned synchronously while the native instance + /// is created asynchronously. This is similar to how constructors work. + Iterable _proxyApiAttachedFieldMethods( + Iterable fields, { + required String apiName, + required String dartPackageName, + required String codecInstanceName, + required String codecName, + }) sync* { + for (final ApiField field in fields) { + yield cb.Method( + (cb.MethodBuilder builder) { + final String type = _addGenericTypesNullable(field.type); + const String instanceName = '${_varNamePrefix}instance'; + const String identifierInstanceName = + '${_varNamePrefix}instanceIdentifier'; + builder + ..name = '$_varNamePrefix${field.name}' + ..static = field.isStatic + ..returns = cb.refer(type) + ..body = cb.Block( + (cb.BlockBuilder builder) { + final StringBuffer messageCallSink = StringBuffer(); + _writeHostMethodMessageCall( + Indent(messageCallSink), + channelName: makeChannelNameWithStrings( + apiName: apiName, + methodName: field.name, + dartPackageName: dartPackageName, + ), + parameters: [ + if (!field.isStatic) + Parameter( + name: 'this', + type: TypeDeclaration( + baseName: apiName, + isNullable: false, + ), + ), + Parameter( + name: identifierInstanceName, + type: const TypeDeclaration( + baseName: 'int', + isNullable: false, + ), + ), + ], + returnType: const TypeDeclaration.voidDeclaration(), + ); + builder.statements.addAll([ + if (!field.isStatic) ...[ + cb.Code( + 'final $type $instanceName = $type.${classMemberNamePrefix}detached(\n' + ' pigeon_binaryMessenger: pigeon_binaryMessenger,\n' + ' pigeon_instanceManager: pigeon_instanceManager,\n' + ');', + ), + cb.Code('final $codecName $_pigeonChannelCodec =\n' + ' $codecInstanceName;'), + const cb.Code( + 'final BinaryMessenger? ${_varNamePrefix}binaryMessenger = ${classMemberNamePrefix}binaryMessenger;', + ), + const cb.Code( + 'final int $identifierInstanceName = $_instanceManagerVarName.addDartCreatedInstance($instanceName);', + ), + ] else ...[ + cb.Code( + 'final $type $instanceName = $type.${classMemberNamePrefix}detached();', + ), + cb.Code( + 'final $codecName $_pigeonChannelCodec = $codecName($instanceManagerClassName.instance);', + ), + const cb.Code( + 'final BinaryMessenger ${_varNamePrefix}binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger;', + ), + const cb.Code( + 'final int $identifierInstanceName = $instanceManagerClassName.instance.addDartCreatedInstance($instanceName);', + ), + ], + const cb.Code('() async {'), + cb.Code(messageCallSink.toString()), + const cb.Code('}();'), + const cb.Code('return $instanceName;'), + ]); + }, + ); + }, + ); + } + } + + /// Converts host methods from pigeon AST to `code_builder` Methods. + /// + /// This creates methods like a HostApi except that it includes the calling + /// instance if the method is not static. + Iterable _proxyApiHostMethods( + Iterable methods, { + required String apiName, + required String dartPackageName, + required String codecInstanceName, + required String codecName, + }) sync* { + for (final Method method in methods) { + assert(method.location == ApiLocation.host); + yield cb.Method( + (cb.MethodBuilder builder) => builder + ..name = method.name + ..static = method.isStatic + ..modifier = cb.MethodModifier.async + ..docs.addAll(asDocumentationComments( + method.documentationComments, + _docCommentSpec, + )) + ..returns = _refer(method.returnType, asFuture: true) + ..requiredParameters.addAll( + indexMap( + method.parameters, + (int index, NamedType parameter) => cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = _getParameterName(index, parameter) + ..type = cb.refer( + _addGenericTypesNullable(parameter.type), + ), + ), + ), + ) + ..optionalParameters.addAll([ + if (method.isStatic) ...[ + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = '${classMemberNamePrefix}binaryMessenger' + ..type = cb.refer('BinaryMessenger?') + ..named = true, + ), + cb.Parameter( + (cb.ParameterBuilder builder) => builder + ..name = _instanceManagerVarName + ..type = cb.refer('$instanceManagerClassName?'), + ), + ], + ]) + ..body = cb.Block( + (cb.BlockBuilder builder) { + final StringBuffer messageCallSink = StringBuffer(); + _writeHostMethodMessageCall( + Indent(messageCallSink), + channelName: makeChannelNameWithStrings( + apiName: apiName, + methodName: method.name, + dartPackageName: dartPackageName, + ), + parameters: [ + if (!method.isStatic) + Parameter( + name: 'this', + type: TypeDeclaration( + baseName: apiName, + isNullable: false, + ), + ), + ...method.parameters, + ], + returnType: method.returnType, + ); + builder.statements.addAll([ + if (!method.isStatic) + cb.Code('final $codecName $_pigeonChannelCodec =\n' + ' $codecInstanceName;') + else + cb.Code( + 'final $codecName $_pigeonChannelCodec = $codecName($_instanceManagerVarName ?? $instanceManagerClassName.instance);', + ), + const cb.Code( + 'final BinaryMessenger? ${_varNamePrefix}binaryMessenger = ${classMemberNamePrefix}binaryMessenger;', + ), + cb.Code(messageCallSink.toString()), + ]); + }, + ), + ); + } + } + + /// Creates the copy method for a ProxyApi. + /// + /// This method returns a copy of the instance with all the Flutter methods + /// and unattached fields passed to the new instance. This method is inherited + /// from the base ProxyApi class. + cb.Method _proxyApiCopyMethod({ + required String apiName, + required Iterable unattachedFields, + required Iterable declaredAndInheritedFlutterMethods, + }) { + return cb.Method( + (cb.MethodBuilder builder) => builder + ..name = '${classMemberNamePrefix}copy' + ..returns = cb.refer(apiName) + ..annotations.add(cb.refer('override')) + ..body = cb.Block.of([ + cb + .refer('$apiName.${classMemberNamePrefix}detached') + .call( + [], + { + '${classMemberNamePrefix}binaryMessenger': + cb.refer('${classMemberNamePrefix}binaryMessenger'), + _instanceManagerVarName: cb.refer(_instanceManagerVarName), + for (final ApiField field in unattachedFields) + field.name: cb.refer(field.name), + for (final Method method + in declaredAndInheritedFlutterMethods) + method.name: cb.refer(method.name), + }, + ) + .returned + .statement, + ]), + ); + } +} + +cb.Reference _refer(TypeDeclaration type, {bool asFuture = false}) { + final String symbol = _addGenericTypesNullable(type); + return cb.refer(asFuture ? 'Future<$symbol>' : symbol); } String _escapeForDartSingleQuotedString(String raw) { diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index 47a9b6c76169..66dd99750f34 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -13,7 +13,7 @@ import 'ast.dart'; /// The current version of pigeon. /// /// This must match the version in pubspec.yaml. -const String pigeonVersion = '17.1.3'; +const String pigeonVersion = '17.2.0'; /// Read all the content from [stdin] to a String. String readStdin() { @@ -164,9 +164,22 @@ class Indent { } } -/// Create the generated channel name for a [func] on a [api]. -String makeChannelName(Api api, Method func, String dartPackageName) { - return 'dev.flutter.pigeon.$dartPackageName.${api.name}.${func.name}'; +/// Create the generated channel name for a [method] on an [api]. +String makeChannelName(Api api, Method method, String dartPackageName) { + return makeChannelNameWithStrings( + apiName: api.name, + methodName: method.name, + dartPackageName: dartPackageName, + ); +} + +/// Create the generated channel name for a method on an api. +String makeChannelNameWithStrings({ + required String apiName, + required String methodName, + required String dartPackageName, +}) { + return 'dev.flutter.pigeon.$dartPackageName.$apiName.$methodName'; } // TODO(tarrinneal): Determine whether HostDataType is needed. @@ -286,7 +299,7 @@ const String seeAlsoWarning = 'See also: https://pub.dev/packages/pigeon'; /// /// This lowers the chances of variable name collisions with user defined /// parameters. -const String classNamePrefix = 'Pigeon_'; +const String classNamePrefix = 'Pigeon'; /// Name for the generated InstanceManager for ProxyApis. /// @@ -541,6 +554,23 @@ void addDocumentationComments( DocumentCommentSpecification commentSpec, { List generatorComments = const [], }) { + asDocumentationComments( + comments, + commentSpec, + generatorComments: generatorComments, + ).forEach(indent.writeln); +} + +/// Formats documentation comments and adds them to current Indent. +/// +/// The [comments] list is meant for comments written in the input dart file. +/// The [generatorComments] list is meant for comments added by the generators. +/// Include white space for all tokens when called, no assumptions are made. +Iterable asDocumentationComments( + Iterable comments, + DocumentCommentSpecification commentSpec, { + List generatorComments = const [], +}) sync* { final List allComments = [ ...comments, if (comments.isNotEmpty && generatorComments.isNotEmpty) '', @@ -549,24 +579,20 @@ void addDocumentationComments( String currentLineOpenToken = commentSpec.openCommentToken; if (allComments.length > 1) { if (commentSpec.closeCommentToken != '') { - indent.writeln(commentSpec.openCommentToken); + yield commentSpec.openCommentToken; currentLineOpenToken = commentSpec.blockContinuationToken; } for (String line in allComments) { if (line.isNotEmpty && line[0] != ' ') { line = ' $line'; } - indent.writeln( - '$currentLineOpenToken$line', - ); + yield '$currentLineOpenToken$line'; } if (commentSpec.closeCommentToken != '') { - indent.writeln(commentSpec.closeCommentToken); + yield commentSpec.closeCommentToken; } } else if (allComments.length == 1) { - indent.writeln( - '$currentLineOpenToken${allComments.first}${commentSpec.closeCommentToken}', - ); + yield '$currentLineOpenToken${allComments.first}${commentSpec.closeCommentToken}'; } } @@ -619,92 +645,6 @@ String? deducePackageName(String mainDartFile) { } } -/// Recursively search for all the interfaces apis from a list of names of -/// interfaces. -/// -/// This method assumes that all interfaces are ProxyApis and an api doesn't -/// contains itself as an interface. Otherwise, throws an [ArgumentError]. -Set recursiveFindAllInterfaceApis( - AstProxyApi api, { - Set seenApis = const {}, -}) { - final Set allInterfaces = {}; - - allInterfaces.addAll( - api.interfaces.map( - (TypeDeclaration type) { - if (!type.isProxyApi) { - throw ArgumentError( - 'Could not find a valid ProxyApi for an interface: $type', - ); - } else if (seenApis.contains(type.associatedProxyApi)) { - throw ArgumentError( - 'A ProxyApi cannot be a super class of itself: ${type.baseName}', - ); - } - return type.associatedProxyApi!; - }, - ), - ); - - // Adds the current api since it would be invalid for it to be an interface - // of itself. - final Set newSeenApis = {...seenApis, api}; - - for (final AstProxyApi interfaceApi in {...allInterfaces}) { - allInterfaces.addAll(recursiveFindAllInterfaceApis( - interfaceApi, - seenApis: newSeenApis, - )); - } - - return allInterfaces; -} - -/// Creates a list of ProxyApis where each `extends` the ProxyApi that follows -/// it. -/// -/// Returns an empty list if [proxyApi] does not extend a ProxyApi. -/// -/// This method assumes the super classes of each ProxyApi doesn't create a -/// loop. Throws a [ArgumentError] if a loop is found. -/// -/// This method also assumes that all super classes are ProxyApis. Otherwise, -/// throws an [ArgumentError]. -List recursiveGetSuperClassApisChain(AstProxyApi api) { - final List superClassChain = []; - - if (api.superClass != null && !api.superClass!.isProxyApi) { - throw ArgumentError( - 'Could not find a ProxyApi for super class: ${api.superClass!.baseName}', - ); - } - - AstProxyApi? currentProxyApi = api.superClass?.associatedProxyApi; - while (currentProxyApi != null) { - if (superClassChain.contains(currentProxyApi)) { - throw ArgumentError( - 'Loop found when processing super classes for a ProxyApi: ' - '${api.name}, ${superClassChain.map((AstProxyApi api) => api.name)}', - ); - } - - superClassChain.add(currentProxyApi); - - if (currentProxyApi.superClass != null && - !currentProxyApi.superClass!.isProxyApi) { - throw ArgumentError( - 'Could not find a ProxyApi for super class: ' - '${currentProxyApi.superClass!.baseName}', - ); - } - - currentProxyApi = currentProxyApi.superClass?.associatedProxyApi; - } - - return superClassChain; -} - /// Enum to specify api type when generating code. enum ApiType { /// Flutter api. diff --git a/packages/pigeon/lib/objc_generator.dart b/packages/pigeon/lib/objc_generator.dart index d30f02d14719..67c93a74f3a9 100644 --- a/packages/pigeon/lib/objc_generator.dart +++ b/packages/pigeon/lib/objc_generator.dart @@ -715,7 +715,10 @@ class ObjcSourceGenerator extends StructuredGenerator { _writeCreateConnectionError(indent); indent.newln(); } - _writeGetNullableObjectAtIndex(indent); + + if (hasHostApi || hasFlutterApi) { + _writeGetNullableObjectAtIndex(indent); + } } void _writeWrapError(Indent indent) { diff --git a/packages/pigeon/lib/pigeon.dart b/packages/pigeon/lib/pigeon.dart index a2c6026e3117..7f2fb7505fa8 100644 --- a/packages/pigeon/lib/pigeon.dart +++ b/packages/pigeon/lib/pigeon.dart @@ -9,7 +9,5 @@ export 'dart_generator.dart' show DartOptions; export 'java_generator.dart' show JavaOptions; export 'kotlin_generator.dart' show KotlinOptions; export 'objc_generator.dart' show ObjcOptions; -// TODO(bparrishMines): Remove hide once implementation of the api is finished -// for Dart and one host language. -export 'pigeon_lib.dart' hide ProxyApi; +export 'pigeon_lib.dart'; export 'swift_generator.dart' show SwiftOptions; diff --git a/packages/pigeon/lib/pigeon_lib.dart b/packages/pigeon/lib/pigeon_lib.dart index 8d6fc961c2ec..8f418d042598 100644 --- a/packages/pigeon/lib/pigeon_lib.dart +++ b/packages/pigeon/lib/pigeon_lib.dart @@ -1030,10 +1030,10 @@ List _validateProxyApi( } // Validate this api isn't used as an interface and contains anything except - // Flutter methods. - final bool isValidInterfaceProxyApi = api.hostMethods.isEmpty && - api.constructors.isEmpty && - api.fields.isEmpty; + // Flutter methods, a static host method, attached methods. + final bool isValidInterfaceProxyApi = api.constructors.isEmpty && + api.fields.where((ApiField field) => !field.isStatic).isEmpty && + api.hostMethods.where((Method method) => !method.isStatic).isEmpty; if (!isValidInterfaceProxyApi) { final Iterable interfaceNames = proxyApi.interfaces.map( (TypeDeclaration type) => type.baseName, diff --git a/packages/pigeon/pigeons/proxy_api_tests.dart b/packages/pigeon/pigeons/proxy_api_tests.dart new file mode 100644 index 000000000000..699e5dfaed86 --- /dev/null +++ b/packages/pigeon/pigeons/proxy_api_tests.dart @@ -0,0 +1,469 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:pigeon/pigeon.dart'; + +enum ProxyApiTestEnum { + one, + two, + three, +} + +/// The core ProxyApi test class that each supported host language must +/// implement in platform_tests integration tests. +@ProxyApi() +abstract class ProxyApiTestClass extends ProxyApiSuperClass + implements ProxyApiInterface { + ProxyApiTestClass( + // ignore: avoid_unused_constructor_parameters + bool boolParam, + // ignore: avoid_unused_constructor_parameters + int intParam, + // ignore: avoid_unused_constructor_parameters + double doubleParam, + // ignore: avoid_unused_constructor_parameters + String stringParam, + // ignore: avoid_unused_constructor_parameters + Uint8List aUint8ListParam, + // ignore: avoid_unused_constructor_parameters + List listParam, + // ignore: avoid_unused_constructor_parameters + Map mapParam, + // ignore: avoid_unused_constructor_parameters + ProxyApiTestEnum enumParam, + // ignore: avoid_unused_constructor_parameters + ProxyApiSuperClass proxyApiParam, + // ignore: avoid_unused_constructor_parameters + bool? nullableBoolParam, + // ignore: avoid_unused_constructor_parameters + int? nullableIntParam, + // ignore: avoid_unused_constructor_parameters + double? nullableDoubleParam, + // ignore: avoid_unused_constructor_parameters + String? nullableStringParam, + // ignore: avoid_unused_constructor_parameters + Uint8List? nullableUint8ListParam, + // ignore: avoid_unused_constructor_parameters + List? nullableListParam, + // ignore: avoid_unused_constructor_parameters + Map? nullableMapParam, + // ignore: avoid_unused_constructor_parameters + ProxyApiTestEnum? nullableEnumParam, + // ignore: avoid_unused_constructor_parameters + ProxyApiSuperClass? nullableProxyApiParam, + ); + + late bool aBool; + late int anInt; + late double aDouble; + late String aString; + late Uint8List aUint8List; + late List aList; + late Map aMap; + late ProxyApiTestEnum anEnum; + late ProxyApiSuperClass aProxyApi; + + late bool? aNullableBool; + late int? aNullableInt; + late double? aNullableDouble; + late String? aNullableString; + late Uint8List? aNullableUint8List; + late List? aNullableList; + late Map? aNullableMap; + late ProxyApiTestEnum? aNullableEnum; + late ProxyApiSuperClass? aNullableProxyApi; + + @attached + late ProxyApiSuperClass attachedField; + + @static + late ProxyApiSuperClass staticAttachedField; + + /// A no-op function taking no arguments and returning no value, to sanity + /// test basic calling. + late void Function()? flutterNoop; + + /// Responds with an error from an async function returning a value. + late Object? Function()? flutterThrowError; + + /// Responds with an error from an async void function. + late void Function()? flutterThrowErrorFromVoid; + + // ========== Non-nullable argument/return type tests ========== + + /// Returns the passed boolean, to test serialization and deserialization. + late bool Function(bool aBool)? flutterEchoBool; + + /// Returns the passed int, to test serialization and deserialization. + late int Function(int anInt)? flutterEchoInt; + + /// Returns the passed double, to test serialization and deserialization. + late double Function(double aDouble)? flutterEchoDouble; + + /// Returns the passed string, to test serialization and deserialization. + late String Function(String aString)? flutterEchoString; + + /// Returns the passed byte list, to test serialization and deserialization. + late Uint8List Function(Uint8List aList)? flutterEchoUint8List; + + /// Returns the passed list, to test serialization and deserialization. + late List Function(List aList)? flutterEchoList; + + /// Returns the passed list with ProxyApis, to test serialization and + /// deserialization. + late List Function(List aList)? + flutterEchoProxyApiList; + + /// Returns the passed map, to test serialization and deserialization. + late Map Function(Map aMap)? + flutterEchoMap; + + /// Returns the passed map with ProxyApis, to test serialization and + /// deserialization. + late Map Function( + Map aMap)? flutterEchoProxyApiMap; + + /// Returns the passed enum to test serialization and deserialization. + late ProxyApiTestEnum Function(ProxyApiTestEnum anEnum)? flutterEchoEnum; + + /// Returns the passed ProxyApi to test serialization and deserialization. + late ProxyApiSuperClass Function(ProxyApiSuperClass aProxyApi)? + flutterEchoProxyApi; + + // ========== Nullable argument/return type tests ========== + + /// Returns the passed boolean, to test serialization and deserialization. + late bool? Function(bool? aBool)? flutterEchoNullableBool; + + /// Returns the passed int, to test serialization and deserialization. + late int? Function(int? anInt)? flutterEchoNullableInt; + + /// Returns the passed double, to test serialization and deserialization. + late double? Function(double? aDouble)? flutterEchoNullableDouble; + + /// Returns the passed string, to test serialization and deserialization. + late String? Function(String? aString)? flutterEchoNullableString; + + /// Returns the passed byte list, to test serialization and deserialization. + late Uint8List? Function(Uint8List? aList)? flutterEchoNullableUint8List; + + /// Returns the passed list, to test serialization and deserialization. + late List? Function(List? aList)? flutterEchoNullableList; + + /// Returns the passed map, to test serialization and deserialization. + late Map? Function(Map? aMap)? + flutterEchoNullableMap; + + /// Returns the passed enum to test serialization and deserialization. + late ProxyApiTestEnum? Function(ProxyApiTestEnum? anEnum)? + flutterEchoNullableEnum; + + /// Returns the passed ProxyApi to test serialization and deserialization. + late ProxyApiSuperClass? Function(ProxyApiSuperClass? aProxyApi)? + flutterEchoNullableProxyApi; + + // ========== Async tests ========== + // These are minimal since async FlutterApi only changes Dart generation. + // Currently they aren't integration tested, but having them here ensures + // analysis coverage. + + /// A no-op function taking no arguments and returning no value, to sanity + /// test basic asynchronous calling. + @async + late void Function()? flutterNoopAsync; + + /// Returns the passed in generic Object asynchronously. + @async + late String Function(String aString)? flutterEchoAsyncString; + + // ========== Synchronous host method tests ========== + + /// A no-op function taking no arguments and returning no value, to sanity + /// test basic calling. + void noop(); + + /// Returns an error, to test error handling. + Object? throwError(); + + /// Returns an error from a void function, to test error handling. + void throwErrorFromVoid(); + + /// Returns a Flutter error, to test error handling. + Object? throwFlutterError(); + + /// Returns passed in int. + int echoInt(int anInt); + + /// Returns passed in double. + double echoDouble(double aDouble); + + /// Returns the passed in boolean. + bool echoBool(bool aBool); + + /// Returns the passed in string. + String echoString(String aString); + + /// Returns the passed in Uint8List. + Uint8List echoUint8List(Uint8List aUint8List); + + /// Returns the passed in generic Object. + Object echoObject(Object anObject); + + /// Returns the passed list, to test serialization and deserialization. + List echoList(List aList); + + /// Returns the passed list with ProxyApis, to test serialization and + /// deserialization. + List echoProxyApiList( + List aList, + ); + + /// Returns the passed map, to test serialization and deserialization. + Map echoMap(Map aMap); + + /// Returns the passed map with ProxyApis, to test serialization and + /// deserialization. + Map echoProxyApiMap( + Map aMap, + ); + + /// Returns the passed enum to test serialization and deserialization. + ProxyApiTestEnum echoEnum(ProxyApiTestEnum anEnum); + + /// Returns the passed ProxyApi to test serialization and deserialization. + ProxyApiSuperClass echoProxyApi(ProxyApiSuperClass aProxyApi); + + // ========== Synchronous host nullable method tests ========== + + /// Returns passed in int. + int? echoNullableInt(int? aNullableInt); + + /// Returns passed in double. + double? echoNullableDouble(double? aNullableDouble); + + /// Returns the passed in boolean. + bool? echoNullableBool(bool? aNullableBool); + + /// Returns the passed in string. + String? echoNullableString(String? aNullableString); + + /// Returns the passed in Uint8List. + Uint8List? echoNullableUint8List(Uint8List? aNullableUint8List); + + /// Returns the passed in generic Object. + Object? echoNullableObject(Object? aNullableObject); + + /// Returns the passed list, to test serialization and deserialization. + List? echoNullableList(List? aNullableList); + + /// Returns the passed map, to test serialization and deserialization. + Map? echoNullableMap(Map? aNullableMap); + + ProxyApiTestEnum? echoNullableEnum(ProxyApiTestEnum? aNullableEnum); + + /// Returns the passed ProxyApi to test serialization and deserialization. + ProxyApiSuperClass? echoNullableProxyApi( + ProxyApiSuperClass? aNullableProxyApi, + ); + + // ========== Asynchronous method tests ========== + + /// A no-op function taking no arguments and returning no value, to sanity + /// test basic asynchronous calling. + @async + void noopAsync(); + + /// Returns passed in int asynchronously. + @async + int echoAsyncInt(int anInt); + + /// Returns passed in double asynchronously. + @async + double echoAsyncDouble(double aDouble); + + /// Returns the passed in boolean asynchronously. + @async + bool echoAsyncBool(bool aBool); + + /// Returns the passed string asynchronously. + @async + String echoAsyncString(String aString); + + /// Returns the passed in Uint8List asynchronously. + @async + Uint8List echoAsyncUint8List(Uint8List aUint8List); + + /// Returns the passed in generic Object asynchronously. + @async + Object echoAsyncObject(Object anObject); + + /// Returns the passed list, to test asynchronous serialization and deserialization. + @async + List echoAsyncList(List aList); + + /// Returns the passed map, to test asynchronous serialization and deserialization. + @async + Map echoAsyncMap(Map aMap); + + /// Returns the passed enum, to test asynchronous serialization and deserialization. + @async + ProxyApiTestEnum echoAsyncEnum(ProxyApiTestEnum anEnum); + + /// Responds with an error from an async function returning a value. + @async + Object? throwAsyncError(); + + /// Responds with an error from an async void function. + @async + void throwAsyncErrorFromVoid(); + + /// Responds with a Flutter error from an async function returning a value. + @async + Object? throwAsyncFlutterError(); + + /// Returns passed in int asynchronously. + @async + int? echoAsyncNullableInt(int? anInt); + + /// Returns passed in double asynchronously. + @async + double? echoAsyncNullableDouble(double? aDouble); + + /// Returns the passed in boolean asynchronously. + @async + bool? echoAsyncNullableBool(bool? aBool); + + /// Returns the passed string asynchronously. + @async + String? echoAsyncNullableString(String? aString); + + /// Returns the passed in Uint8List asynchronously. + @async + Uint8List? echoAsyncNullableUint8List(Uint8List? aUint8List); + + /// Returns the passed in generic Object asynchronously. + @async + Object? echoAsyncNullableObject(Object? anObject); + + /// Returns the passed list, to test asynchronous serialization and deserialization. + @async + List? echoAsyncNullableList(List? aList); + + /// Returns the passed map, to test asynchronous serialization and deserialization. + @async + Map? echoAsyncNullableMap(Map? aMap); + + /// Returns the passed enum, to test asynchronous serialization and deserialization. + @async + ProxyApiTestEnum? echoAsyncNullableEnum(ProxyApiTestEnum? anEnum); + + // ========== Static method test ========== + + @static + void staticNoop(); + + @static + String echoStaticString(String aString); + + @static + @async + void staticAsyncNoop(); + + // ========== Flutter methods test wrappers ========== + + @async + void callFlutterNoop(); + + @async + Object? callFlutterThrowError(); + + @async + void callFlutterThrowErrorFromVoid(); + + @async + bool callFlutterEchoBool(bool aBool); + + @async + int callFlutterEchoInt(int anInt); + + @async + double callFlutterEchoDouble(double aDouble); + + @async + String callFlutterEchoString(String aString); + + @async + Uint8List callFlutterEchoUint8List(Uint8List aUint8List); + + @async + List callFlutterEchoList(List aList); + + @async + List callFlutterEchoProxyApiList( + List aList); + + @async + Map callFlutterEchoMap(Map aMap); + + @async + Map callFlutterEchoProxyApiMap( + Map aMap); + + @async + ProxyApiTestEnum callFlutterEchoEnum(ProxyApiTestEnum anEnum); + + @async + ProxyApiSuperClass callFlutterEchoProxyApi(ProxyApiSuperClass aProxyApi); + + @async + bool? callFlutterEchoNullableBool(bool? aBool); + + @async + int? callFlutterEchoNullableInt(int? anInt); + + @async + double? callFlutterEchoNullableDouble(double? aDouble); + + @async + String? callFlutterEchoNullableString(String? aString); + + @async + Uint8List? callFlutterEchoNullableUint8List(Uint8List? aUint8List); + + @async + List? callFlutterEchoNullableList(List? aList); + + @async + Map? callFlutterEchoNullableMap( + Map? aMap, + ); + + @async + ProxyApiTestEnum? callFlutterEchoNullableEnum(ProxyApiTestEnum? anEnum); + + @async + ProxyApiSuperClass? callFlutterEchoNullableProxyApi( + ProxyApiSuperClass? aProxyApi, + ); + + @async + void callFlutterNoopAsync(); + + @async + String callFlutterEchoAsyncString(String aString); +} + +/// ProxyApi to serve as a super class to the core ProxyApi class. +@ProxyApi() +abstract class ProxyApiSuperClass { + ProxyApiSuperClass(); + + void aSuperMethod(); +} + +/// ProxyApi to serve as an interface to the core ProxyApi class. +@ProxyApi() +abstract class ProxyApiInterface { + late void Function()? anInterfaceMethod; +} diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/proxy_api_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/proxy_api_tests.gen.dart new file mode 100644 index 000000000000..762f65d5aad0 --- /dev/null +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/proxy_api_tests.gen.dart @@ -0,0 +1,5023 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Autogenerated from Pigeon, do not edit directly. +// See also: https://pub.dev/packages/pigeon +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers + +import 'dart:async'; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; + +import 'package:flutter/foundation.dart' + show ReadBuffer, WriteBuffer, immutable, protected; +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart' show WidgetsFlutterBinding; + +PlatformException _createConnectionError(String channelName) { + return PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel: "$channelName".', + ); +} + +List wrapResponse( + {Object? result, PlatformException? error, bool empty = false}) { + if (empty) { + return []; + } + if (error == null) { + return [result]; + } + return [error.code, error.message, error.details]; +} + +/// An immutable object that serves as the base class for all ProxyApis and +/// can provide functional copies of itself. +/// +/// All implementers are expected to be [immutable] as defined by the annotation +/// and override [pigeon_copy] returning an instance of itself. +@immutable +abstract class PigeonProxyApiBaseClass { + /// Construct a [PigeonProxyApiBaseClass]. + PigeonProxyApiBaseClass({ + this.pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + }) : pigeon_instanceManager = + pigeon_instanceManager ?? PigeonInstanceManager.instance; + + /// Sends and receives binary data across the Flutter platform barrier. + /// + /// If it is null, the default BinaryMessenger will be used, which routes to + /// the host platform. + @protected + final BinaryMessenger? pigeon_binaryMessenger; + + /// Maintains instances stored to communicate with native language objects. + @protected + final PigeonInstanceManager pigeon_instanceManager; + + /// Instantiates and returns a functionally identical object to oneself. + /// + /// Outside of tests, this method should only ever be called by + /// [PigeonInstanceManager]. + /// + /// Subclasses should always override their parent's implementation of this + /// method. + @protected + PigeonProxyApiBaseClass pigeon_copy(); +} + +/// Maintains instances used to communicate with the native objects they +/// represent. +/// +/// Added instances are stored as weak references and their copies are stored +/// as strong references to maintain access to their variables and callback +/// methods. Both are stored with the same identifier. +/// +/// When a weak referenced instance becomes inaccessible, +/// [onWeakReferenceRemoved] is called with its associated identifier. +/// +/// If an instance is retrieved and has the possibility to be used, +/// (e.g. calling [getInstanceWithWeakReference]) a copy of the strong reference +/// is added as a weak reference with the same identifier. This prevents a +/// scenario where the weak referenced instance was released and then later +/// returned by the host platform. +class PigeonInstanceManager { + /// Constructs a [PigeonInstanceManager]. + PigeonInstanceManager({required void Function(int) onWeakReferenceRemoved}) { + this.onWeakReferenceRemoved = (int identifier) { + _weakInstances.remove(identifier); + onWeakReferenceRemoved(identifier); + }; + _finalizer = Finalizer(this.onWeakReferenceRemoved); + } + + // Identifiers are locked to a specific range to avoid collisions with objects + // created simultaneously by the host platform. + // Host uses identifiers >= 2^16 and Dart is expected to use values n where, + // 0 <= n < 2^16. + static const int _maxDartCreatedIdentifier = 65536; + + /// The default [PigeonInstanceManager] used by ProxyApis. + /// + /// On creation, this manager makes a call to clear the native + /// InstanceManager. This is to prevent identifier conflicts after a host + /// restart. + static final PigeonInstanceManager instance = _initInstance(); + + // Expando is used because it doesn't prevent its keys from becoming + // inaccessible. This allows the manager to efficiently retrieve an identifier + // of an instance without holding a strong reference to that instance. + // + // It also doesn't use `==` to search for identifiers, which would lead to an + // infinite loop when comparing an object to its copy. (i.e. which was caused + // by calling instanceManager.getIdentifier() inside of `==` while this was a + // HashMap). + final Expando _identifiers = Expando(); + final Map> _weakInstances = + >{}; + final Map _strongInstances = + {}; + late final Finalizer _finalizer; + int _nextIdentifier = 0; + + /// Called when a weak referenced instance is removed by [removeWeakReference] + /// or becomes inaccessible. + late final void Function(int) onWeakReferenceRemoved; + + static PigeonInstanceManager _initInstance() { + WidgetsFlutterBinding.ensureInitialized(); + final _PigeonInstanceManagerApi api = _PigeonInstanceManagerApi(); + // Clears the native `PigeonInstanceManager` on the initial use of the Dart one. + api.clear(); + final PigeonInstanceManager instanceManager = PigeonInstanceManager( + onWeakReferenceRemoved: (int identifier) { + api.removeStrongReference(identifier); + }, + ); + _PigeonInstanceManagerApi.setUpMessageHandlers( + instanceManager: instanceManager); + ProxyApiTestClass.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + ProxyApiSuperClass.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + ProxyApiInterface.pigeon_setUpMessageHandlers( + pigeon_instanceManager: instanceManager); + return instanceManager; + } + + /// Adds a new instance that was instantiated by Dart. + /// + /// In other words, Dart wants to add a new instance that will represent + /// an object that will be instantiated on the host platform. + /// + /// Throws assertion error if the instance has already been added. + /// + /// Returns the randomly generated id of the [instance] added. + int addDartCreatedInstance(PigeonProxyApiBaseClass instance) { + final int identifier = _nextUniqueIdentifier(); + _addInstanceWithIdentifier(instance, identifier); + return identifier; + } + + /// Removes the instance, if present, and call [onWeakReferenceRemoved] with + /// its identifier. + /// + /// Returns the identifier associated with the removed instance. Otherwise, + /// `null` if the instance was not found in this manager. + /// + /// This does not remove the strong referenced instance associated with + /// [instance]. This can be done with [remove]. + int? removeWeakReference(PigeonProxyApiBaseClass instance) { + final int? identifier = getIdentifier(instance); + if (identifier == null) { + return null; + } + + _identifiers[instance] = null; + _finalizer.detach(instance); + onWeakReferenceRemoved(identifier); + + return identifier; + } + + /// Removes [identifier] and its associated strongly referenced instance, if + /// present, from the manager. + /// + /// Returns the strong referenced instance associated with [identifier] before + /// it was removed. Returns `null` if [identifier] was not associated with + /// any strong reference. + /// + /// This does not remove the weak referenced instance associated with + /// [identifier]. This can be done with [removeWeakReference]. + T? remove(int identifier) { + return _strongInstances.remove(identifier) as T?; + } + + /// Retrieves the instance associated with identifier. + /// + /// The value returned is chosen from the following order: + /// + /// 1. A weakly referenced instance associated with identifier. + /// 2. If the only instance associated with identifier is a strongly + /// referenced instance, a copy of the instance is added as a weak reference + /// with the same identifier. Returning the newly created copy. + /// 3. If no instance is associated with identifier, returns null. + /// + /// This method also expects the host `InstanceManager` to have a strong + /// reference to the instance the identifier is associated with. + T? getInstanceWithWeakReference( + int identifier) { + final PigeonProxyApiBaseClass? weakInstance = + _weakInstances[identifier]?.target; + + if (weakInstance == null) { + final PigeonProxyApiBaseClass? strongInstance = + _strongInstances[identifier]; + if (strongInstance != null) { + final PigeonProxyApiBaseClass copy = strongInstance.pigeon_copy(); + _identifiers[copy] = identifier; + _weakInstances[identifier] = + WeakReference(copy); + _finalizer.attach(copy, identifier, detach: copy); + return copy as T; + } + return strongInstance as T?; + } + + return weakInstance as T; + } + + /// Retrieves the identifier associated with instance. + int? getIdentifier(PigeonProxyApiBaseClass instance) { + return _identifiers[instance]; + } + + /// Adds a new instance that was instantiated by the host platform. + /// + /// In other words, the host platform wants to add a new instance that + /// represents an object on the host platform. Stored with [identifier]. + /// + /// Throws assertion error if the instance or its identifier has already been + /// added. + /// + /// Returns unique identifier of the [instance] added. + void addHostCreatedInstance( + PigeonProxyApiBaseClass instance, int identifier) { + _addInstanceWithIdentifier(instance, identifier); + } + + void _addInstanceWithIdentifier( + PigeonProxyApiBaseClass instance, int identifier) { + assert(!containsIdentifier(identifier)); + assert(getIdentifier(instance) == null); + assert(identifier >= 0); + + _identifiers[instance] = identifier; + _weakInstances[identifier] = + WeakReference(instance); + _finalizer.attach(instance, identifier, detach: instance); + + final PigeonProxyApiBaseClass copy = instance.pigeon_copy(); + _identifiers[copy] = identifier; + _strongInstances[identifier] = copy; + } + + /// Whether this manager contains the given [identifier]. + bool containsIdentifier(int identifier) { + return _weakInstances.containsKey(identifier) || + _strongInstances.containsKey(identifier); + } + + int _nextUniqueIdentifier() { + late int identifier; + do { + identifier = _nextIdentifier; + _nextIdentifier = (_nextIdentifier + 1) % _maxDartCreatedIdentifier; + } while (containsIdentifier(identifier)); + return identifier; + } +} + +/// Generated API for managing the Dart and native `PigeonInstanceManager`s. +class _PigeonInstanceManagerApi { + /// Constructor for [_PigeonInstanceManagerApi]. + _PigeonInstanceManagerApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; + + final BinaryMessenger? _binaryMessenger; + + static const MessageCodec pigeonChannelCodec = + StandardMessageCodec(); + + static void setUpMessageHandlers({ + BinaryMessenger? binaryMessenger, + PigeonInstanceManager? instanceManager, + }) { + const String channelName = + r'dev.flutter.pigeon.pigeon_integration_tests.PigeonInstanceManagerApi.removeStrongReference'; + final BasicMessageChannel channel = BasicMessageChannel( + channelName, + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); + channel.setMessageHandler((Object? message) async { + assert( + message != null, + 'Argument for $channelName was null.', + ); + final int? identifier = message as int?; + assert( + identifier != null, + r'Argument for $channelName, expected non-null int.', + ); + (instanceManager ?? PigeonInstanceManager.instance).remove(identifier!); + return; + }); + } + + Future removeStrongReference(int identifier) async { + const String channelName = + r'dev.flutter.pigeon.pigeon_integration_tests.PigeonInstanceManagerApi.removeStrongReference'; + final BasicMessageChannel channel = BasicMessageChannel( + channelName, + pigeonChannelCodec, + binaryMessenger: _binaryMessenger, + ); + final List? replyList = + await channel.send(identifier) as List?; + if (replyList == null) { + throw _createConnectionError(channelName); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else { + return; + } + } + + /// Clear the native `PigeonInstanceManager`. + /// + /// This is typically called after a hot restart. + Future clear() async { + const String channelName = + r'dev.flutter.pigeon.pigeon_integration_tests.PigeonInstanceManagerApi.clear'; + final BasicMessageChannel channel = BasicMessageChannel( + channelName, + pigeonChannelCodec, + binaryMessenger: _binaryMessenger, + ); + final List? replyList = await channel.send(null) as List?; + if (replyList == null) { + throw _createConnectionError(channelName); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else { + return; + } + } +} + +class _PigeonProxyApiBaseCodec extends StandardMessageCodec { + const _PigeonProxyApiBaseCodec(this.instanceManager); + final PigeonInstanceManager instanceManager; + @override + void writeValue(WriteBuffer buffer, Object? value) { + if (value is PigeonProxyApiBaseClass) { + buffer.putUint8(128); + writeValue(buffer, instanceManager.getIdentifier(value)); + } else { + super.writeValue(buffer, value); + } + } + + @override + Object? readValueOfType(int type, ReadBuffer buffer) { + switch (type) { + case 128: + return instanceManager + .getInstanceWithWeakReference(readValue(buffer)! as int); + default: + return super.readValueOfType(type, buffer); + } + } +} + +enum ProxyApiTestEnum { + one, + two, + three, +} + +/// The core ProxyApi test class that each supported host language must +/// implement in platform_tests integration tests. +class ProxyApiTestClass extends ProxyApiSuperClass + implements ProxyApiInterface { + ProxyApiTestClass({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.aBool, + required this.anInt, + required this.aDouble, + required this.aString, + required this.aUint8List, + required this.aList, + required this.aMap, + required this.anEnum, + required this.aProxyApi, + this.aNullableBool, + this.aNullableInt, + this.aNullableDouble, + this.aNullableString, + this.aNullableUint8List, + this.aNullableList, + this.aNullableMap, + this.aNullableEnum, + this.aNullableProxyApi, + this.anInterfaceMethod, + this.flutterNoop, + this.flutterThrowError, + this.flutterThrowErrorFromVoid, + this.flutterEchoBool, + this.flutterEchoInt, + this.flutterEchoDouble, + this.flutterEchoString, + this.flutterEchoUint8List, + this.flutterEchoList, + this.flutterEchoProxyApiList, + this.flutterEchoMap, + this.flutterEchoProxyApiMap, + this.flutterEchoEnum, + this.flutterEchoProxyApi, + this.flutterEchoNullableBool, + this.flutterEchoNullableInt, + this.flutterEchoNullableDouble, + this.flutterEchoNullableString, + this.flutterEchoNullableUint8List, + this.flutterEchoNullableList, + this.flutterEchoNullableMap, + this.flutterEchoNullableEnum, + this.flutterEchoNullableProxyApi, + this.flutterNoopAsync, + this.flutterEchoAsyncString, + required bool boolParam, + required int intParam, + required double doubleParam, + required String stringParam, + required Uint8List aUint8ListParam, + required List listParam, + required Map mapParam, + required ProxyApiTestEnum enumParam, + required ProxyApiSuperClass proxyApiParam, + bool? nullableBoolParam, + int? nullableIntParam, + double? nullableDoubleParam, + String? nullableStringParam, + Uint8List? nullableUint8ListParam, + List? nullableListParam, + Map? nullableMapParam, + ProxyApiTestEnum? nullableEnumParam, + ProxyApiSuperClass? nullableProxyApiParam, + }) : super.pigeon_detached() { + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_defaultConstructor'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([ + __pigeon_instanceIdentifier, + aBool, + anInt, + aDouble, + aString, + aUint8List, + aList, + aMap, + anEnum.index, + aProxyApi, + aNullableBool, + aNullableInt, + aNullableDouble, + aNullableString, + aNullableUint8List, + aNullableList, + aNullableMap, + aNullableEnum?.index, + aNullableProxyApi, + boolParam, + intParam, + doubleParam, + stringParam, + aUint8ListParam, + listParam, + mapParam, + enumParam.index, + proxyApiParam, + nullableBoolParam, + nullableIntParam, + nullableDoubleParam, + nullableStringParam, + nullableUint8ListParam, + nullableListParam, + nullableMapParam, + nullableEnumParam?.index, + nullableProxyApiParam + ]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + } + + /// Constructs [ProxyApiTestClass] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + ProxyApiTestClass.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + required this.aBool, + required this.anInt, + required this.aDouble, + required this.aString, + required this.aUint8List, + required this.aList, + required this.aMap, + required this.anEnum, + required this.aProxyApi, + this.aNullableBool, + this.aNullableInt, + this.aNullableDouble, + this.aNullableString, + this.aNullableUint8List, + this.aNullableList, + this.aNullableMap, + this.aNullableEnum, + this.aNullableProxyApi, + this.anInterfaceMethod, + this.flutterNoop, + this.flutterThrowError, + this.flutterThrowErrorFromVoid, + this.flutterEchoBool, + this.flutterEchoInt, + this.flutterEchoDouble, + this.flutterEchoString, + this.flutterEchoUint8List, + this.flutterEchoList, + this.flutterEchoProxyApiList, + this.flutterEchoMap, + this.flutterEchoProxyApiMap, + this.flutterEchoEnum, + this.flutterEchoProxyApi, + this.flutterEchoNullableBool, + this.flutterEchoNullableInt, + this.flutterEchoNullableDouble, + this.flutterEchoNullableString, + this.flutterEchoNullableUint8List, + this.flutterEchoNullableList, + this.flutterEchoNullableMap, + this.flutterEchoNullableEnum, + this.flutterEchoNullableProxyApi, + this.flutterNoopAsync, + this.flutterEchoAsyncString, + }) : super.pigeon_detached(); + + late final _PigeonProxyApiBaseCodec __pigeon_codecProxyApiTestClass = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + final bool aBool; + + final int anInt; + + final double aDouble; + + final String aString; + + final Uint8List aUint8List; + + final List aList; + + final Map aMap; + + final ProxyApiTestEnum anEnum; + + final ProxyApiSuperClass aProxyApi; + + final bool? aNullableBool; + + final int? aNullableInt; + + final double? aNullableDouble; + + final String? aNullableString; + + final Uint8List? aNullableUint8List; + + final List? aNullableList; + + final Map? aNullableMap; + + final ProxyApiTestEnum? aNullableEnum; + + final ProxyApiSuperClass? aNullableProxyApi; + + /// A no-op function taking no arguments and returning no value, to sanity + /// test basic calling. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterNoop: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function(ProxyApiTestClass pigeon_instance)? flutterNoop; + + /// Responds with an error from an async function returning a value. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterThrowError: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final Object? Function(ProxyApiTestClass pigeon_instance)? flutterThrowError; + + /// Responds with an error from an async void function. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterThrowErrorFromVoid: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function(ProxyApiTestClass pigeon_instance)? + flutterThrowErrorFromVoid; + + /// Returns the passed boolean, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoBool: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final bool Function( + ProxyApiTestClass pigeon_instance, + bool aBool, + )? flutterEchoBool; + + /// Returns the passed int, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoInt: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final int Function( + ProxyApiTestClass pigeon_instance, + int anInt, + )? flutterEchoInt; + + /// Returns the passed double, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoDouble: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final double Function( + ProxyApiTestClass pigeon_instance, + double aDouble, + )? flutterEchoDouble; + + /// Returns the passed string, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoString: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final String Function( + ProxyApiTestClass pigeon_instance, + String aString, + )? flutterEchoString; + + /// Returns the passed byte list, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoUint8List: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final Uint8List Function( + ProxyApiTestClass pigeon_instance, + Uint8List aList, + )? flutterEchoUint8List; + + /// Returns the passed list, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoList: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final List Function( + ProxyApiTestClass pigeon_instance, + List aList, + )? flutterEchoList; + + /// Returns the passed list with ProxyApis, to test serialization and + /// deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoProxyApiList: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final List Function( + ProxyApiTestClass pigeon_instance, + List aList, + )? flutterEchoProxyApiList; + + /// Returns the passed map, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoMap: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final Map Function( + ProxyApiTestClass pigeon_instance, + Map aMap, + )? flutterEchoMap; + + /// Returns the passed map with ProxyApis, to test serialization and + /// deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoProxyApiMap: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final Map Function( + ProxyApiTestClass pigeon_instance, + Map aMap, + )? flutterEchoProxyApiMap; + + /// Returns the passed enum to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoEnum: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final ProxyApiTestEnum Function( + ProxyApiTestClass pigeon_instance, + ProxyApiTestEnum anEnum, + )? flutterEchoEnum; + + /// Returns the passed ProxyApi to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoProxyApi: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final ProxyApiSuperClass Function( + ProxyApiTestClass pigeon_instance, + ProxyApiSuperClass aProxyApi, + )? flutterEchoProxyApi; + + /// Returns the passed boolean, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoNullableBool: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final bool? Function( + ProxyApiTestClass pigeon_instance, + bool? aBool, + )? flutterEchoNullableBool; + + /// Returns the passed int, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoNullableInt: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final int? Function( + ProxyApiTestClass pigeon_instance, + int? anInt, + )? flutterEchoNullableInt; + + /// Returns the passed double, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoNullableDouble: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final double? Function( + ProxyApiTestClass pigeon_instance, + double? aDouble, + )? flutterEchoNullableDouble; + + /// Returns the passed string, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoNullableString: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final String? Function( + ProxyApiTestClass pigeon_instance, + String? aString, + )? flutterEchoNullableString; + + /// Returns the passed byte list, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoNullableUint8List: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final Uint8List? Function( + ProxyApiTestClass pigeon_instance, + Uint8List? aList, + )? flutterEchoNullableUint8List; + + /// Returns the passed list, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoNullableList: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final List? Function( + ProxyApiTestClass pigeon_instance, + List? aList, + )? flutterEchoNullableList; + + /// Returns the passed map, to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoNullableMap: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final Map? Function( + ProxyApiTestClass pigeon_instance, + Map? aMap, + )? flutterEchoNullableMap; + + /// Returns the passed enum to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoNullableEnum: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final ProxyApiTestEnum? Function( + ProxyApiTestClass pigeon_instance, + ProxyApiTestEnum? anEnum, + )? flutterEchoNullableEnum; + + /// Returns the passed ProxyApi to test serialization and deserialization. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoNullableProxyApi: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final ProxyApiSuperClass? Function( + ProxyApiTestClass pigeon_instance, + ProxyApiSuperClass? aProxyApi, + )? flutterEchoNullableProxyApi; + + /// A no-op function taking no arguments and returning no value, to sanity + /// test basic asynchronous calling. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterNoopAsync: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final Future Function(ProxyApiTestClass pigeon_instance)? + flutterNoopAsync; + + /// Returns the passed in generic Object asynchronously. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiTestClass instance = ProxyApiTestClass( + /// flutterEchoAsyncString: (ProxyApiTestClass pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final Future Function( + ProxyApiTestClass pigeon_instance, + String aString, + )? flutterEchoAsyncString; + + @override + final void Function(ProxyApiInterface pigeon_instance)? anInterfaceMethod; + + late final ProxyApiSuperClass attachedField = __pigeon_attachedField(); + + static final ProxyApiSuperClass staticAttachedField = + __pigeon_staticAttachedField(); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + ProxyApiTestClass Function( + bool aBool, + int anInt, + double aDouble, + String aString, + Uint8List aUint8List, + List aList, + Map aMap, + ProxyApiTestEnum anEnum, + ProxyApiSuperClass aProxyApi, + bool? aNullableBool, + int? aNullableInt, + double? aNullableDouble, + String? aNullableString, + Uint8List? aNullableUint8List, + List? aNullableList, + Map? aNullableMap, + ProxyApiTestEnum? aNullableEnum, + ProxyApiSuperClass? aNullableProxyApi, + )? pigeon_newInstance, + void Function(ProxyApiTestClass pigeon_instance)? flutterNoop, + Object? Function(ProxyApiTestClass pigeon_instance)? flutterThrowError, + void Function(ProxyApiTestClass pigeon_instance)? flutterThrowErrorFromVoid, + bool Function( + ProxyApiTestClass pigeon_instance, + bool aBool, + )? flutterEchoBool, + int Function( + ProxyApiTestClass pigeon_instance, + int anInt, + )? flutterEchoInt, + double Function( + ProxyApiTestClass pigeon_instance, + double aDouble, + )? flutterEchoDouble, + String Function( + ProxyApiTestClass pigeon_instance, + String aString, + )? flutterEchoString, + Uint8List Function( + ProxyApiTestClass pigeon_instance, + Uint8List aList, + )? flutterEchoUint8List, + List Function( + ProxyApiTestClass pigeon_instance, + List aList, + )? flutterEchoList, + List Function( + ProxyApiTestClass pigeon_instance, + List aList, + )? flutterEchoProxyApiList, + Map Function( + ProxyApiTestClass pigeon_instance, + Map aMap, + )? flutterEchoMap, + Map Function( + ProxyApiTestClass pigeon_instance, + Map aMap, + )? flutterEchoProxyApiMap, + ProxyApiTestEnum Function( + ProxyApiTestClass pigeon_instance, + ProxyApiTestEnum anEnum, + )? flutterEchoEnum, + ProxyApiSuperClass Function( + ProxyApiTestClass pigeon_instance, + ProxyApiSuperClass aProxyApi, + )? flutterEchoProxyApi, + bool? Function( + ProxyApiTestClass pigeon_instance, + bool? aBool, + )? flutterEchoNullableBool, + int? Function( + ProxyApiTestClass pigeon_instance, + int? anInt, + )? flutterEchoNullableInt, + double? Function( + ProxyApiTestClass pigeon_instance, + double? aDouble, + )? flutterEchoNullableDouble, + String? Function( + ProxyApiTestClass pigeon_instance, + String? aString, + )? flutterEchoNullableString, + Uint8List? Function( + ProxyApiTestClass pigeon_instance, + Uint8List? aList, + )? flutterEchoNullableUint8List, + List? Function( + ProxyApiTestClass pigeon_instance, + List? aList, + )? flutterEchoNullableList, + Map? Function( + ProxyApiTestClass pigeon_instance, + Map? aMap, + )? flutterEchoNullableMap, + ProxyApiTestEnum? Function( + ProxyApiTestClass pigeon_instance, + ProxyApiTestEnum? anEnum, + )? flutterEchoNullableEnum, + ProxyApiSuperClass? Function( + ProxyApiTestClass pigeon_instance, + ProxyApiSuperClass? aProxyApi, + )? flutterEchoNullableProxyApi, + Future Function(ProxyApiTestClass pigeon_instance)? flutterNoopAsync, + Future Function( + ProxyApiTestClass pigeon_instance, + String aString, + )? flutterEchoAsyncString, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null, expected non-null int.'); + final bool? arg_aBool = (args[1] as bool?); + assert(arg_aBool != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null, expected non-null bool.'); + final int? arg_anInt = (args[2] as int?); + assert(arg_anInt != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null, expected non-null int.'); + final double? arg_aDouble = (args[3] as double?); + assert(arg_aDouble != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null, expected non-null double.'); + final String? arg_aString = (args[4] as String?); + assert(arg_aString != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null, expected non-null String.'); + final Uint8List? arg_aUint8List = (args[5] as Uint8List?); + assert(arg_aUint8List != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null, expected non-null Uint8List.'); + final List? arg_aList = + (args[6] as List?)?.cast(); + assert(arg_aList != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null, expected non-null List.'); + final Map? arg_aMap = + (args[7] as Map?)?.cast(); + assert(arg_aMap != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null, expected non-null Map.'); + final ProxyApiTestEnum? arg_anEnum = + args[8] == null ? null : ProxyApiTestEnum.values[args[8]! as int]; + assert(arg_anEnum != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null, expected non-null ProxyApiTestEnum.'); + final ProxyApiSuperClass? arg_aProxyApi = + (args[9] as ProxyApiSuperClass?); + assert(arg_aProxyApi != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.pigeon_newInstance was null, expected non-null ProxyApiSuperClass.'); + final bool? arg_aNullableBool = (args[10] as bool?); + final int? arg_aNullableInt = (args[11] as int?); + final double? arg_aNullableDouble = (args[12] as double?); + final String? arg_aNullableString = (args[13] as String?); + final Uint8List? arg_aNullableUint8List = (args[14] as Uint8List?); + final List? arg_aNullableList = + (args[15] as List?)?.cast(); + final Map? arg_aNullableMap = + (args[16] as Map?)?.cast(); + final ProxyApiTestEnum? arg_aNullableEnum = args[17] == null + ? null + : ProxyApiTestEnum.values[args[17]! as int]; + final ProxyApiSuperClass? arg_aNullableProxyApi = + (args[18] as ProxyApiSuperClass?); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call( + arg_aBool!, + arg_anInt!, + arg_aDouble!, + arg_aString!, + arg_aUint8List!, + arg_aList!, + arg_aMap!, + arg_anEnum!, + arg_aProxyApi!, + arg_aNullableBool, + arg_aNullableInt, + arg_aNullableDouble, + arg_aNullableString, + arg_aNullableUint8List, + arg_aNullableList, + arg_aNullableMap, + arg_aNullableEnum, + arg_aNullableProxyApi) ?? + ProxyApiTestClass.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + aBool: arg_aBool!, + anInt: arg_anInt!, + aDouble: arg_aDouble!, + aString: arg_aString!, + aUint8List: arg_aUint8List!, + aList: arg_aList!, + aMap: arg_aMap!, + anEnum: arg_anEnum!, + aProxyApi: arg_aProxyApi!, + aNullableBool: arg_aNullableBool, + aNullableInt: arg_aNullableInt, + aNullableDouble: arg_aNullableDouble, + aNullableString: arg_aNullableString, + aNullableUint8List: arg_aNullableUint8List, + aNullableList: arg_aNullableList, + aNullableMap: arg_aNullableMap, + aNullableEnum: arg_aNullableEnum, + aNullableProxyApi: arg_aNullableProxyApi, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterNoop', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterNoop was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterNoop was null, expected non-null ProxyApiTestClass.'); + try { + (flutterNoop ?? arg_pigeon_instance!.flutterNoop) + ?.call(arg_pigeon_instance!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterThrowError', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterThrowError was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterThrowError was null, expected non-null ProxyApiTestClass.'); + try { + final Object? output = + (flutterThrowError ?? arg_pigeon_instance!.flutterThrowError) + ?.call(arg_pigeon_instance!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterThrowErrorFromVoid', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterThrowErrorFromVoid was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterThrowErrorFromVoid was null, expected non-null ProxyApiTestClass.'); + try { + (flutterThrowErrorFromVoid ?? + arg_pigeon_instance!.flutterThrowErrorFromVoid) + ?.call(arg_pigeon_instance!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoBool', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoBool was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoBool was null, expected non-null ProxyApiTestClass.'); + final bool? arg_aBool = (args[1] as bool?); + assert(arg_aBool != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoBool was null, expected non-null bool.'); + try { + final bool? output = + (flutterEchoBool ?? arg_pigeon_instance!.flutterEchoBool) + ?.call(arg_pigeon_instance!, arg_aBool!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoInt', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoInt was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoInt was null, expected non-null ProxyApiTestClass.'); + final int? arg_anInt = (args[1] as int?); + assert(arg_anInt != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoInt was null, expected non-null int.'); + try { + final int? output = + (flutterEchoInt ?? arg_pigeon_instance!.flutterEchoInt) + ?.call(arg_pigeon_instance!, arg_anInt!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoDouble', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoDouble was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoDouble was null, expected non-null ProxyApiTestClass.'); + final double? arg_aDouble = (args[1] as double?); + assert(arg_aDouble != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoDouble was null, expected non-null double.'); + try { + final double? output = + (flutterEchoDouble ?? arg_pigeon_instance!.flutterEchoDouble) + ?.call(arg_pigeon_instance!, arg_aDouble!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoString', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoString was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoString was null, expected non-null ProxyApiTestClass.'); + final String? arg_aString = (args[1] as String?); + assert(arg_aString != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoString was null, expected non-null String.'); + try { + final String? output = + (flutterEchoString ?? arg_pigeon_instance!.flutterEchoString) + ?.call(arg_pigeon_instance!, arg_aString!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoUint8List', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoUint8List was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoUint8List was null, expected non-null ProxyApiTestClass.'); + final Uint8List? arg_aList = (args[1] as Uint8List?); + assert(arg_aList != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoUint8List was null, expected non-null Uint8List.'); + try { + final Uint8List? output = (flutterEchoUint8List ?? + arg_pigeon_instance!.flutterEchoUint8List) + ?.call(arg_pigeon_instance!, arg_aList!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoList', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoList was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoList was null, expected non-null ProxyApiTestClass.'); + final List? arg_aList = + (args[1] as List?)?.cast(); + assert(arg_aList != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoList was null, expected non-null List.'); + try { + final List? output = + (flutterEchoList ?? arg_pigeon_instance!.flutterEchoList) + ?.call(arg_pigeon_instance!, arg_aList!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApiList', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApiList was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApiList was null, expected non-null ProxyApiTestClass.'); + final List? arg_aList = + (args[1] as List?)?.cast(); + assert(arg_aList != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApiList was null, expected non-null List.'); + try { + final List? output = (flutterEchoProxyApiList ?? + arg_pigeon_instance!.flutterEchoProxyApiList) + ?.call(arg_pigeon_instance!, arg_aList!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoMap', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoMap was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoMap was null, expected non-null ProxyApiTestClass.'); + final Map? arg_aMap = + (args[1] as Map?)?.cast(); + assert(arg_aMap != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoMap was null, expected non-null Map.'); + try { + final Map? output = + (flutterEchoMap ?? arg_pigeon_instance!.flutterEchoMap) + ?.call(arg_pigeon_instance!, arg_aMap!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApiMap', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApiMap was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApiMap was null, expected non-null ProxyApiTestClass.'); + final Map? arg_aMap = + (args[1] as Map?) + ?.cast(); + assert(arg_aMap != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApiMap was null, expected non-null Map.'); + try { + final Map? output = + (flutterEchoProxyApiMap ?? + arg_pigeon_instance!.flutterEchoProxyApiMap) + ?.call(arg_pigeon_instance!, arg_aMap!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoEnum', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoEnum was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoEnum was null, expected non-null ProxyApiTestClass.'); + final ProxyApiTestEnum? arg_anEnum = + args[1] == null ? null : ProxyApiTestEnum.values[args[1]! as int]; + assert(arg_anEnum != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoEnum was null, expected non-null ProxyApiTestEnum.'); + try { + final ProxyApiTestEnum? output = + (flutterEchoEnum ?? arg_pigeon_instance!.flutterEchoEnum) + ?.call(arg_pigeon_instance!, arg_anEnum!); + return wrapResponse(result: output?.index); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApi', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApi was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApi was null, expected non-null ProxyApiTestClass.'); + final ProxyApiSuperClass? arg_aProxyApi = + (args[1] as ProxyApiSuperClass?); + assert(arg_aProxyApi != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoProxyApi was null, expected non-null ProxyApiSuperClass.'); + try { + final ProxyApiSuperClass? output = (flutterEchoProxyApi ?? + arg_pigeon_instance!.flutterEchoProxyApi) + ?.call(arg_pigeon_instance!, arg_aProxyApi!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableBool', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableBool was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableBool was null, expected non-null ProxyApiTestClass.'); + final bool? arg_aBool = (args[1] as bool?); + try { + final bool? output = (flutterEchoNullableBool ?? + arg_pigeon_instance!.flutterEchoNullableBool) + ?.call(arg_pigeon_instance!, arg_aBool); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableInt', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableInt was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableInt was null, expected non-null ProxyApiTestClass.'); + final int? arg_anInt = (args[1] as int?); + try { + final int? output = (flutterEchoNullableInt ?? + arg_pigeon_instance!.flutterEchoNullableInt) + ?.call(arg_pigeon_instance!, arg_anInt); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableDouble', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableDouble was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableDouble was null, expected non-null ProxyApiTestClass.'); + final double? arg_aDouble = (args[1] as double?); + try { + final double? output = (flutterEchoNullableDouble ?? + arg_pigeon_instance!.flutterEchoNullableDouble) + ?.call(arg_pigeon_instance!, arg_aDouble); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableString', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableString was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableString was null, expected non-null ProxyApiTestClass.'); + final String? arg_aString = (args[1] as String?); + try { + final String? output = (flutterEchoNullableString ?? + arg_pigeon_instance!.flutterEchoNullableString) + ?.call(arg_pigeon_instance!, arg_aString); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableUint8List', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableUint8List was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableUint8List was null, expected non-null ProxyApiTestClass.'); + final Uint8List? arg_aList = (args[1] as Uint8List?); + try { + final Uint8List? output = (flutterEchoNullableUint8List ?? + arg_pigeon_instance!.flutterEchoNullableUint8List) + ?.call(arg_pigeon_instance!, arg_aList); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableList', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableList was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableList was null, expected non-null ProxyApiTestClass.'); + final List? arg_aList = + (args[1] as List?)?.cast(); + try { + final List? output = (flutterEchoNullableList ?? + arg_pigeon_instance!.flutterEchoNullableList) + ?.call(arg_pigeon_instance!, arg_aList); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableMap', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableMap was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableMap was null, expected non-null ProxyApiTestClass.'); + final Map? arg_aMap = + (args[1] as Map?)?.cast(); + try { + final Map? output = (flutterEchoNullableMap ?? + arg_pigeon_instance!.flutterEchoNullableMap) + ?.call(arg_pigeon_instance!, arg_aMap); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableEnum', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableEnum was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableEnum was null, expected non-null ProxyApiTestClass.'); + final ProxyApiTestEnum? arg_anEnum = + args[1] == null ? null : ProxyApiTestEnum.values[args[1]! as int]; + try { + final ProxyApiTestEnum? output = (flutterEchoNullableEnum ?? + arg_pigeon_instance!.flutterEchoNullableEnum) + ?.call(arg_pigeon_instance!, arg_anEnum); + return wrapResponse(result: output?.index); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableProxyApi', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableProxyApi was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoNullableProxyApi was null, expected non-null ProxyApiTestClass.'); + final ProxyApiSuperClass? arg_aProxyApi = + (args[1] as ProxyApiSuperClass?); + try { + final ProxyApiSuperClass? output = (flutterEchoNullableProxyApi ?? + arg_pigeon_instance!.flutterEchoNullableProxyApi) + ?.call(arg_pigeon_instance!, arg_aProxyApi); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterNoopAsync', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterNoopAsync was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterNoopAsync was null, expected non-null ProxyApiTestClass.'); + try { + await (flutterNoopAsync ?? arg_pigeon_instance!.flutterNoopAsync) + ?.call(arg_pigeon_instance!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoAsyncString', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoAsyncString was null.'); + final List args = (message as List?)!; + final ProxyApiTestClass? arg_pigeon_instance = + (args[0] as ProxyApiTestClass?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoAsyncString was null, expected non-null ProxyApiTestClass.'); + final String? arg_aString = (args[1] as String?); + assert(arg_aString != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.flutterEchoAsyncString was null, expected non-null String.'); + try { + final String? output = await (flutterEchoAsyncString ?? + arg_pigeon_instance!.flutterEchoAsyncString) + ?.call(arg_pigeon_instance!, arg_aString!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + ProxyApiSuperClass __pigeon_attachedField() { + final ProxyApiSuperClass __pigeon_instance = + ProxyApiSuperClass.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(__pigeon_instance); + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.attachedField'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, __pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + return __pigeon_instance; + } + + static ProxyApiSuperClass __pigeon_staticAttachedField() { + final ProxyApiSuperClass __pigeon_instance = + ProxyApiSuperClass.pigeon_detached(); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec(PigeonInstanceManager.instance); + final BinaryMessenger __pigeon_binaryMessenger = + ServicesBinding.instance.defaultBinaryMessenger; + final int __pigeon_instanceIdentifier = PigeonInstanceManager.instance + .addDartCreatedInstance(__pigeon_instance); + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.staticAttachedField'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + return __pigeon_instance; + } + + /// A no-op function taking no arguments and returning no value, to sanity + /// test basic calling. + Future noop() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.noop'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Returns an error, to test error handling. + Future throwError() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.throwError'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return __pigeon_replyList[0]; + } + } + + /// Returns an error from a void function, to test error handling. + Future throwErrorFromVoid() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.throwErrorFromVoid'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Returns a Flutter error, to test error handling. + Future throwFlutterError() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.throwFlutterError'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return __pigeon_replyList[0]; + } + } + + /// Returns passed in int. + Future echoInt(int anInt) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoInt'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, anInt]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as int?)!; + } + } + + /// Returns passed in double. + Future echoDouble(double aDouble) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoDouble'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aDouble]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as double?)!; + } + } + + /// Returns the passed in boolean. + Future echoBool(bool aBool) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoBool'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aBool]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as bool?)!; + } + } + + /// Returns the passed in string. + Future echoString(String aString) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoString'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aString]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as String?)!; + } + } + + /// Returns the passed in Uint8List. + Future echoUint8List(Uint8List aUint8List) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoUint8List'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aUint8List]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as Uint8List?)!; + } + } + + /// Returns the passed in generic Object. + Future echoObject(Object anObject) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoObject'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, anObject]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return __pigeon_replyList[0]!; + } + } + + /// Returns the passed list, to test serialization and deserialization. + Future> echoList(List aList) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoList'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aList]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as List?)!.cast(); + } + } + + /// Returns the passed list with ProxyApis, to test serialization and + /// deserialization. + Future> echoProxyApiList( + List aList) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoProxyApiList'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aList]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as List?)! + .cast(); + } + } + + /// Returns the passed map, to test serialization and deserialization. + Future> echoMap(Map aMap) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoMap'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aMap]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as Map?)! + .cast(); + } + } + + /// Returns the passed map with ProxyApis, to test serialization and + /// deserialization. + Future> echoProxyApiMap( + Map aMap) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoProxyApiMap'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aMap]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as Map?)! + .cast(); + } + } + + /// Returns the passed enum to test serialization and deserialization. + Future echoEnum(ProxyApiTestEnum anEnum) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoEnum'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, anEnum.index]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return ProxyApiTestEnum.values[__pigeon_replyList[0]! as int]; + } + } + + /// Returns the passed ProxyApi to test serialization and deserialization. + Future echoProxyApi(ProxyApiSuperClass aProxyApi) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoProxyApi'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aProxyApi]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as ProxyApiSuperClass?)!; + } + } + + /// Returns passed in int. + Future echoNullableInt(int? aNullableInt) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoNullableInt'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aNullableInt]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as int?); + } + } + + /// Returns passed in double. + Future echoNullableDouble(double? aNullableDouble) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoNullableDouble'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aNullableDouble]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as double?); + } + } + + /// Returns the passed in boolean. + Future echoNullableBool(bool? aNullableBool) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoNullableBool'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aNullableBool]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as bool?); + } + } + + /// Returns the passed in string. + Future echoNullableString(String? aNullableString) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoNullableString'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aNullableString]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as String?); + } + } + + /// Returns the passed in Uint8List. + Future echoNullableUint8List( + Uint8List? aNullableUint8List) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoNullableUint8List'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aNullableUint8List]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as Uint8List?); + } + } + + /// Returns the passed in generic Object. + Future echoNullableObject(Object? aNullableObject) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoNullableObject'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aNullableObject]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return __pigeon_replyList[0]; + } + } + + /// Returns the passed list, to test serialization and deserialization. + Future?> echoNullableList(List? aNullableList) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoNullableList'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aNullableList]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as List?)?.cast(); + } + } + + /// Returns the passed map, to test serialization and deserialization. + Future?> echoNullableMap( + Map? aNullableMap) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoNullableMap'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aNullableMap]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as Map?) + ?.cast(); + } + } + + Future echoNullableEnum( + ProxyApiTestEnum? aNullableEnum) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoNullableEnum'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aNullableEnum?.index]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as int?) == null + ? null + : ProxyApiTestEnum.values[__pigeon_replyList[0]! as int]; + } + } + + /// Returns the passed ProxyApi to test serialization and deserialization. + Future echoNullableProxyApi( + ProxyApiSuperClass? aNullableProxyApi) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoNullableProxyApi'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aNullableProxyApi]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as ProxyApiSuperClass?); + } + } + + /// A no-op function taking no arguments and returning no value, to sanity + /// test basic asynchronous calling. + Future noopAsync() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.noopAsync'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Returns passed in int asynchronously. + Future echoAsyncInt(int anInt) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncInt'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, anInt]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as int?)!; + } + } + + /// Returns passed in double asynchronously. + Future echoAsyncDouble(double aDouble) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncDouble'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aDouble]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as double?)!; + } + } + + /// Returns the passed in boolean asynchronously. + Future echoAsyncBool(bool aBool) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncBool'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aBool]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as bool?)!; + } + } + + /// Returns the passed string asynchronously. + Future echoAsyncString(String aString) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncString'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aString]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as String?)!; + } + } + + /// Returns the passed in Uint8List asynchronously. + Future echoAsyncUint8List(Uint8List aUint8List) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncUint8List'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aUint8List]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as Uint8List?)!; + } + } + + /// Returns the passed in generic Object asynchronously. + Future echoAsyncObject(Object anObject) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncObject'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, anObject]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return __pigeon_replyList[0]!; + } + } + + /// Returns the passed list, to test asynchronous serialization and deserialization. + Future> echoAsyncList(List aList) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncList'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aList]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as List?)!.cast(); + } + } + + /// Returns the passed map, to test asynchronous serialization and deserialization. + Future> echoAsyncMap(Map aMap) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncMap'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aMap]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as Map?)! + .cast(); + } + } + + /// Returns the passed enum, to test asynchronous serialization and deserialization. + Future echoAsyncEnum(ProxyApiTestEnum anEnum) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncEnum'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, anEnum.index]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return ProxyApiTestEnum.values[__pigeon_replyList[0]! as int]; + } + } + + /// Responds with an error from an async function returning a value. + Future throwAsyncError() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.throwAsyncError'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return __pigeon_replyList[0]; + } + } + + /// Responds with an error from an async void function. + Future throwAsyncErrorFromVoid() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.throwAsyncErrorFromVoid'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + /// Responds with a Flutter error from an async function returning a value. + Future throwAsyncFlutterError() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.throwAsyncFlutterError'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return __pigeon_replyList[0]; + } + } + + /// Returns passed in int asynchronously. + Future echoAsyncNullableInt(int? anInt) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncNullableInt'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, anInt]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as int?); + } + } + + /// Returns passed in double asynchronously. + Future echoAsyncNullableDouble(double? aDouble) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncNullableDouble'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aDouble]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as double?); + } + } + + /// Returns the passed in boolean asynchronously. + Future echoAsyncNullableBool(bool? aBool) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncNullableBool'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aBool]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as bool?); + } + } + + /// Returns the passed string asynchronously. + Future echoAsyncNullableString(String? aString) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncNullableString'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aString]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as String?); + } + } + + /// Returns the passed in Uint8List asynchronously. + Future echoAsyncNullableUint8List(Uint8List? aUint8List) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncNullableUint8List'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aUint8List]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as Uint8List?); + } + } + + /// Returns the passed in generic Object asynchronously. + Future echoAsyncNullableObject(Object? anObject) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncNullableObject'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, anObject]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return __pigeon_replyList[0]; + } + } + + /// Returns the passed list, to test asynchronous serialization and deserialization. + Future?> echoAsyncNullableList(List? aList) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncNullableList'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aList]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as List?)?.cast(); + } + } + + /// Returns the passed map, to test asynchronous serialization and deserialization. + Future?> echoAsyncNullableMap( + Map? aMap) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncNullableMap'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aMap]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as Map?) + ?.cast(); + } + } + + /// Returns the passed enum, to test asynchronous serialization and deserialization. + Future echoAsyncNullableEnum( + ProxyApiTestEnum? anEnum) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoAsyncNullableEnum'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, anEnum?.index]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as int?) == null + ? null + : ProxyApiTestEnum.values[__pigeon_replyList[0]! as int]; + } + } + + static Future staticNoop({ + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + }) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.staticNoop'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send(null) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + static Future echoStaticString( + String aString, { + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + }) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.echoStaticString'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([aString]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as String?)!; + } + } + + static Future staticAsyncNoop({ + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + }) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.staticAsyncNoop'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send(null) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + Future callFlutterNoop() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterNoop'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + Future callFlutterThrowError() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterThrowError'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return __pigeon_replyList[0]; + } + } + + Future callFlutterThrowErrorFromVoid() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterThrowErrorFromVoid'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + Future callFlutterEchoBool(bool aBool) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoBool'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aBool]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as bool?)!; + } + } + + Future callFlutterEchoInt(int anInt) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoInt'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, anInt]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as int?)!; + } + } + + Future callFlutterEchoDouble(double aDouble) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoDouble'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aDouble]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as double?)!; + } + } + + Future callFlutterEchoString(String aString) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoString'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aString]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as String?)!; + } + } + + Future callFlutterEchoUint8List(Uint8List aUint8List) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoUint8List'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aUint8List]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as Uint8List?)!; + } + } + + Future> callFlutterEchoList(List aList) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoList'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aList]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as List?)!.cast(); + } + } + + Future> callFlutterEchoProxyApiList( + List aList) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoProxyApiList'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aList]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as List?)! + .cast(); + } + } + + Future> callFlutterEchoMap( + Map aMap) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoMap'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aMap]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as Map?)! + .cast(); + } + } + + Future> callFlutterEchoProxyApiMap( + Map aMap) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoProxyApiMap'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aMap]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as Map?)! + .cast(); + } + } + + Future callFlutterEchoEnum(ProxyApiTestEnum anEnum) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoEnum'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, anEnum.index]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return ProxyApiTestEnum.values[__pigeon_replyList[0]! as int]; + } + } + + Future callFlutterEchoProxyApi( + ProxyApiSuperClass aProxyApi) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoProxyApi'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aProxyApi]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as ProxyApiSuperClass?)!; + } + } + + Future callFlutterEchoNullableBool(bool? aBool) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoNullableBool'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aBool]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as bool?); + } + } + + Future callFlutterEchoNullableInt(int? anInt) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoNullableInt'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, anInt]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as int?); + } + } + + Future callFlutterEchoNullableDouble(double? aDouble) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoNullableDouble'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aDouble]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as double?); + } + } + + Future callFlutterEchoNullableString(String? aString) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoNullableString'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aString]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as String?); + } + } + + Future callFlutterEchoNullableUint8List( + Uint8List? aUint8List) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoNullableUint8List'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aUint8List]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as Uint8List?); + } + } + + Future?> callFlutterEchoNullableList( + List? aList) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoNullableList'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aList]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as List?)?.cast(); + } + } + + Future?> callFlutterEchoNullableMap( + Map? aMap) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoNullableMap'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aMap]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as Map?) + ?.cast(); + } + } + + Future callFlutterEchoNullableEnum( + ProxyApiTestEnum? anEnum) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoNullableEnum'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, anEnum?.index]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as int?) == null + ? null + : ProxyApiTestEnum.values[__pigeon_replyList[0]! as int]; + } + } + + Future callFlutterEchoNullableProxyApi( + ProxyApiSuperClass? aProxyApi) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoNullableProxyApi'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([this, aProxyApi]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return (__pigeon_replyList[0] as ProxyApiSuperClass?); + } + } + + Future callFlutterNoopAsync() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterNoopAsync'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + Future callFlutterEchoAsyncString(String aString) async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiTestClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiTestClass.callFlutterEchoAsyncString'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this, aString]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as String?)!; + } + } + + @override + ProxyApiTestClass pigeon_copy() { + return ProxyApiTestClass.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + aBool: aBool, + anInt: anInt, + aDouble: aDouble, + aString: aString, + aUint8List: aUint8List, + aList: aList, + aMap: aMap, + anEnum: anEnum, + aProxyApi: aProxyApi, + aNullableBool: aNullableBool, + aNullableInt: aNullableInt, + aNullableDouble: aNullableDouble, + aNullableString: aNullableString, + aNullableUint8List: aNullableUint8List, + aNullableList: aNullableList, + aNullableMap: aNullableMap, + aNullableEnum: aNullableEnum, + aNullableProxyApi: aNullableProxyApi, + anInterfaceMethod: anInterfaceMethod, + flutterNoop: flutterNoop, + flutterThrowError: flutterThrowError, + flutterThrowErrorFromVoid: flutterThrowErrorFromVoid, + flutterEchoBool: flutterEchoBool, + flutterEchoInt: flutterEchoInt, + flutterEchoDouble: flutterEchoDouble, + flutterEchoString: flutterEchoString, + flutterEchoUint8List: flutterEchoUint8List, + flutterEchoList: flutterEchoList, + flutterEchoProxyApiList: flutterEchoProxyApiList, + flutterEchoMap: flutterEchoMap, + flutterEchoProxyApiMap: flutterEchoProxyApiMap, + flutterEchoEnum: flutterEchoEnum, + flutterEchoProxyApi: flutterEchoProxyApi, + flutterEchoNullableBool: flutterEchoNullableBool, + flutterEchoNullableInt: flutterEchoNullableInt, + flutterEchoNullableDouble: flutterEchoNullableDouble, + flutterEchoNullableString: flutterEchoNullableString, + flutterEchoNullableUint8List: flutterEchoNullableUint8List, + flutterEchoNullableList: flutterEchoNullableList, + flutterEchoNullableMap: flutterEchoNullableMap, + flutterEchoNullableEnum: flutterEchoNullableEnum, + flutterEchoNullableProxyApi: flutterEchoNullableProxyApi, + flutterNoopAsync: flutterNoopAsync, + flutterEchoAsyncString: flutterEchoAsyncString, + ); + } +} + +/// ProxyApi to serve as a super class to the core ProxyApi class. +class ProxyApiSuperClass extends PigeonProxyApiBaseClass { + ProxyApiSuperClass({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }) { + final int __pigeon_instanceIdentifier = + pigeon_instanceManager.addDartCreatedInstance(this); + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiSuperClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + () async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiSuperClass.pigeon_defaultConstructor'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([__pigeon_instanceIdentifier]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + }(); + } + + /// Constructs [ProxyApiSuperClass] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + ProxyApiSuperClass.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + }); + + late final _PigeonProxyApiBaseCodec __pigeon_codecProxyApiSuperClass = + _PigeonProxyApiBaseCodec(pigeon_instanceManager); + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + ProxyApiSuperClass Function()? pigeon_newInstance, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiSuperClass.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiSuperClass.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiSuperClass.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + ProxyApiSuperClass.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + Future aSuperMethod() async { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + __pigeon_codecProxyApiSuperClass; + final BinaryMessenger? __pigeon_binaryMessenger = pigeon_binaryMessenger; + const String __pigeon_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiSuperClass.aSuperMethod'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([this]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + @override + ProxyApiSuperClass pigeon_copy() { + return ProxyApiSuperClass.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ); + } +} + +/// ProxyApi to serve as an interface to the core ProxyApi class. +class ProxyApiInterface extends PigeonProxyApiBaseClass { + /// Constructs [ProxyApiInterface] without creating the associated native object. + /// + /// This should only be used by subclasses created by this library or to + /// create copies for an [PigeonInstanceManager]. + @protected + ProxyApiInterface.pigeon_detached({ + super.pigeon_binaryMessenger, + super.pigeon_instanceManager, + this.anInterfaceMethod, + }); + + /// Callback method. + /// + /// For the associated Native object to be automatically garbage collected, + /// it is required that the implementation of this `Function` doesn't have a + /// strong reference to the encapsulating class instance. When this `Function` + /// references a non-local variable, it is strongly recommended to access it + /// with a `WeakReference`: + /// + /// ```dart + /// final WeakReference weakMyVariable = WeakReference(myVariable); + /// final ProxyApiInterface instance = ProxyApiInterface( + /// anInterfaceMethod: (ProxyApiInterface pigeon_instance, ...) { + /// print(weakMyVariable?.target); + /// }, + /// ); + /// ``` + /// + /// Alternatively, [PigeonInstanceManager.removeWeakReference] can be used to + /// release the associated Native object manually. + final void Function(ProxyApiInterface pigeon_instance)? anInterfaceMethod; + + static void pigeon_setUpMessageHandlers({ + bool pigeon_clearHandlers = false, + BinaryMessenger? pigeon_binaryMessenger, + PigeonInstanceManager? pigeon_instanceManager, + ProxyApiInterface Function()? pigeon_newInstance, + void Function(ProxyApiInterface pigeon_instance)? anInterfaceMethod, + }) { + final _PigeonProxyApiBaseCodec pigeonChannelCodec = + _PigeonProxyApiBaseCodec( + pigeon_instanceManager ?? PigeonInstanceManager.instance); + final BinaryMessenger? binaryMessenger = pigeon_binaryMessenger; + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiInterface.pigeon_newInstance', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiInterface.pigeon_newInstance was null.'); + final List args = (message as List?)!; + final int? arg_pigeon_instanceIdentifier = (args[0] as int?); + assert(arg_pigeon_instanceIdentifier != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiInterface.pigeon_newInstance was null, expected non-null int.'); + try { + (pigeon_instanceManager ?? PigeonInstanceManager.instance) + .addHostCreatedInstance( + pigeon_newInstance?.call() ?? + ProxyApiInterface.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + ), + arg_pigeon_instanceIdentifier!, + ); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.pigeon_integration_tests.ProxyApiInterface.anInterfaceMethod', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (pigeon_clearHandlers) { + __pigeon_channel.setMessageHandler(null); + } else { + __pigeon_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiInterface.anInterfaceMethod was null.'); + final List args = (message as List?)!; + final ProxyApiInterface? arg_pigeon_instance = + (args[0] as ProxyApiInterface?); + assert(arg_pigeon_instance != null, + 'Argument for dev.flutter.pigeon.pigeon_integration_tests.ProxyApiInterface.anInterfaceMethod was null, expected non-null ProxyApiInterface.'); + try { + (anInterfaceMethod ?? arg_pigeon_instance!.anInterfaceMethod) + ?.call(arg_pigeon_instance!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } + + @override + ProxyApiInterface pigeon_copy() { + return ProxyApiInterface.pigeon_detached( + pigeon_binaryMessenger: pigeon_binaryMessenger, + pigeon_instanceManager: pigeon_instanceManager, + anInterfaceMethod: anInterfaceMethod, + ); + } +} diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/test/instance_manager_test.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/test/instance_manager_test.dart new file mode 100644 index 000000000000..aadce1b81d7b --- /dev/null +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/test/instance_manager_test.dart @@ -0,0 +1,168 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file specifically tests the test PigeonInstanceManager generated by core_tests. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_test_plugin_code/src/generated/proxy_api_tests.gen.dart'; + +void main() { + group('InstanceManager', () { + test('addHostCreatedInstance', () { + final PigeonInstanceManager instanceManager = + PigeonInstanceManager(onWeakReferenceRemoved: (_) {}); + + final CopyableObject object = CopyableObject( + pigeon_instanceManager: instanceManager, + ); + + instanceManager.addHostCreatedInstance(object, 0); + + expect(instanceManager.getIdentifier(object), 0); + expect( + instanceManager.getInstanceWithWeakReference(0), + object, + ); + }); + + test('addHostCreatedInstance prevents already used objects and ids', () { + final PigeonInstanceManager instanceManager = + PigeonInstanceManager(onWeakReferenceRemoved: (_) {}); + + final CopyableObject object = CopyableObject( + pigeon_instanceManager: instanceManager, + ); + + instanceManager.addHostCreatedInstance(object, 0); + + expect( + () => instanceManager.addHostCreatedInstance(object, 0), + throwsAssertionError, + ); + + expect( + () => instanceManager.addHostCreatedInstance( + CopyableObject(pigeon_instanceManager: instanceManager), + 0, + ), + throwsAssertionError, + ); + }); + + test('addFlutterCreatedInstance', () { + final PigeonInstanceManager instanceManager = + PigeonInstanceManager(onWeakReferenceRemoved: (_) {}); + + final CopyableObject object = CopyableObject( + pigeon_instanceManager: instanceManager, + ); + + instanceManager.addDartCreatedInstance(object); + + final int? instanceId = instanceManager.getIdentifier(object); + expect(instanceId, isNotNull); + expect( + instanceManager.getInstanceWithWeakReference(instanceId!), + object, + ); + }); + + test('removeWeakReference', () { + int? weakInstanceId; + final PigeonInstanceManager instanceManager = + PigeonInstanceManager(onWeakReferenceRemoved: (int instanceId) { + weakInstanceId = instanceId; + }); + + final CopyableObject object = CopyableObject( + pigeon_instanceManager: instanceManager, + ); + + instanceManager.addHostCreatedInstance(object, 0); + + expect(instanceManager.removeWeakReference(object), 0); + expect( + instanceManager.getInstanceWithWeakReference(0), + isA(), + ); + expect(weakInstanceId, 0); + }); + + test('removeWeakReference removes only weak reference', () { + final PigeonInstanceManager instanceManager = + PigeonInstanceManager(onWeakReferenceRemoved: (_) {}); + + final CopyableObject object = CopyableObject( + pigeon_instanceManager: instanceManager, + ); + + instanceManager.addHostCreatedInstance(object, 0); + + expect(instanceManager.removeWeakReference(object), 0); + final CopyableObject copy = instanceManager.getInstanceWithWeakReference( + 0, + )!; + expect(identical(object, copy), isFalse); + }); + + test('removeStrongReference', () { + final PigeonInstanceManager instanceManager = + PigeonInstanceManager(onWeakReferenceRemoved: (_) {}); + + final CopyableObject object = CopyableObject( + pigeon_instanceManager: instanceManager, + ); + + instanceManager.addHostCreatedInstance(object, 0); + instanceManager.removeWeakReference(object); + expect(instanceManager.remove(0), isA()); + expect(instanceManager.containsIdentifier(0), isFalse); + }); + + test('removeStrongReference removes only strong reference', () { + final PigeonInstanceManager instanceManager = + PigeonInstanceManager(onWeakReferenceRemoved: (_) {}); + + final CopyableObject object = CopyableObject( + pigeon_instanceManager: instanceManager, + ); + + instanceManager.addHostCreatedInstance(object, 0); + expect(instanceManager.remove(0), isA()); + expect( + instanceManager.getInstanceWithWeakReference(0), + object, + ); + }); + + test('getInstance can add a new weak reference', () { + final PigeonInstanceManager instanceManager = + PigeonInstanceManager(onWeakReferenceRemoved: (_) {}); + + final CopyableObject object = CopyableObject( + pigeon_instanceManager: instanceManager, + ); + + instanceManager.addHostCreatedInstance(object, 0); + instanceManager.removeWeakReference(object); + + final CopyableObject newWeakCopy = + instanceManager.getInstanceWithWeakReference( + 0, + )!; + expect(identical(object, newWeakCopy), isFalse); + }); + }); +} + +class CopyableObject extends PigeonProxyApiBaseClass { + // ignore: non_constant_identifier_names + CopyableObject({super.pigeon_instanceManager}); + + @override + // ignore: non_constant_identifier_names + CopyableObject pigeon_copy() { + return CopyableObject(pigeon_instanceManager: pigeon_instanceManager); + } +} diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index c97ed7d51e10..d5b579405d45 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -2,7 +2,7 @@ name: pigeon description: Code generator tool to make communication between Flutter and the host platform type-safe and easier. repository: https://github.com/flutter/packages/tree/main/packages/pigeon issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+pigeon%22 -version: 17.1.3 # This must match the version in lib/generator_tools.dart +version: 17.2.0 # This must match the version in lib/generator_tools.dart environment: sdk: ^3.1.0 @@ -10,7 +10,9 @@ environment: dependencies: analyzer: ">=5.13.0 <7.0.0" args: ^2.1.0 + code_builder: ^4.10.0 collection: ^1.15.0 + dart_style: ^2.3.4 meta: ^1.9.0 path: ^1.8.0 yaml: ^3.1.1 diff --git a/packages/pigeon/test/dart/proxy_api_test.dart b/packages/pigeon/test/dart/proxy_api_test.dart new file mode 100644 index 000000000000..fb24a2038615 --- /dev/null +++ b/packages/pigeon/test/dart/proxy_api_test.dart @@ -0,0 +1,1014 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:pigeon/ast.dart'; +import 'package:pigeon/dart_generator.dart'; +import 'package:test/test.dart'; + +const String DEFAULT_PACKAGE_NAME = 'test_package'; + +void main() { + group('ProxyApi', () { + test('one api', () { + final Root root = Root(apis: [ + AstProxyApi(name: 'Api', constructors: [ + Constructor(name: 'name', parameters: [ + Parameter( + type: const TypeDeclaration( + baseName: 'Input', + isNullable: false, + ), + name: 'input', + ), + ]), + ], fields: [ + ApiField( + name: 'someField', + type: const TypeDeclaration( + baseName: 'int', + isNullable: false, + ), + ) + ], methods: [ + Method( + name: 'doSomething', + location: ApiLocation.host, + parameters: [ + Parameter( + type: const TypeDeclaration( + baseName: 'Input', + isNullable: false, + ), + name: 'input', + ) + ], + returnType: const TypeDeclaration( + baseName: 'String', + isNullable: false, + ), + ), + Method( + name: 'doSomethingElse', + location: ApiLocation.flutter, + parameters: [ + Parameter( + type: const TypeDeclaration( + baseName: 'Input', + isNullable: false, + ), + name: 'input', + ) + ], + returnType: const TypeDeclaration( + baseName: 'String', + isNullable: false, + ), + isRequired: false, + ), + ]) + ], classes: [], enums: []); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + final String collapsedCode = _collapseNewlineAndIndentation(code); + + // Instance Manager + expect(code, contains(r'class PigeonInstanceManager')); + expect(code, contains(r'class _PigeonInstanceManagerApi')); + + // Base Api class + expect( + code, + contains(r'abstract class PigeonProxyApiBaseClass'), + ); + + // Codec and class + expect(code, contains('class _PigeonProxyApiBaseCodec')); + expect(code, contains(r'class Api extends PigeonProxyApiBaseClass')); + + // Constructors + expect( + collapsedCode, + contains( + r'Api.name({ super.pigeon_binaryMessenger, super.pigeon_instanceManager, required this.someField, this.doSomethingElse, required Input input, })', + ), + ); + expect( + code, + contains( + r'Api.pigeon_detached', + ), + ); + + // Field + expect(code, contains('final int someField;')); + + // Dart -> Host method + expect(code, contains('Future doSomething(Input input)')); + + // Host -> Dart method + expect(code, contains(r'static void pigeon_setUpMessageHandlers({')); + expect( + collapsedCode, + contains( + 'final String Function( Api pigeon_instance, Input input, )? doSomethingElse;', + ), + ); + + // Copy method + expect(code, contains(r'Api pigeon_copy(')); + }); + + group('inheritance', () { + test('extends', () { + final AstProxyApi api2 = AstProxyApi( + name: 'Api2', + constructors: [], + fields: [], + methods: [], + ); + final Root root = Root(apis: [ + AstProxyApi( + name: 'Api', + constructors: [], + fields: [], + methods: [], + superClass: TypeDeclaration( + baseName: 'Api2', + isNullable: false, + associatedProxyApi: api2, + ), + ), + api2, + ], classes: [], enums: []); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + final String collapsedCode = _collapseNewlineAndIndentation(code); + expect(code, contains(r'class Api extends Api2')); + expect( + collapsedCode, + contains( + r'Api.pigeon_detached({ super.pigeon_binaryMessenger, super.pigeon_instanceManager, }) : super.pigeon_detached();', + ), + ); + }); + + test('implements', () { + final AstProxyApi api2 = AstProxyApi( + name: 'Api2', + constructors: [], + fields: [], + methods: [], + ); + final Root root = Root(apis: [ + AstProxyApi( + name: 'Api', + constructors: [], + fields: [], + methods: [], + interfaces: { + TypeDeclaration( + baseName: 'Api2', + isNullable: false, + associatedProxyApi: api2, + ) + }, + ), + api2, + ], classes: [], enums: []); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + expect( + code, + contains( + r'class Api extends PigeonProxyApiBaseClass implements Api2', + ), + ); + }); + + test('implements 2 ProxyApis', () { + final AstProxyApi api2 = AstProxyApi( + name: 'Api2', + constructors: [], + fields: [], + methods: [], + ); + final AstProxyApi api3 = AstProxyApi( + name: 'Api3', + constructors: [], + fields: [], + methods: [], + ); + final Root root = Root(apis: [ + AstProxyApi( + name: 'Api', + constructors: [], + fields: [], + methods: [], + interfaces: { + TypeDeclaration( + baseName: 'Api2', + isNullable: false, + associatedProxyApi: api2, + ), + TypeDeclaration( + baseName: 'Api3', + isNullable: false, + associatedProxyApi: api2, + ), + }, + ), + api2, + api3, + ], classes: [], enums: []); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + expect( + code, + contains( + r'class Api extends PigeonProxyApiBaseClass implements Api2, Api3', + ), + ); + }); + + test('implements inherits flutter methods', () { + final AstProxyApi api2 = AstProxyApi( + name: 'Api2', + constructors: [], + fields: [], + methods: [ + Method( + name: 'aFlutterMethod', + returnType: const TypeDeclaration.voidDeclaration(), + parameters: [], + location: ApiLocation.flutter, + ), + Method( + name: 'aNullableFlutterMethod', + returnType: const TypeDeclaration.voidDeclaration(), + parameters: [], + location: ApiLocation.flutter, + isRequired: false, + ), + ], + ); + final Root root = Root(apis: [ + AstProxyApi( + name: 'Api', + constructors: [], + fields: [], + methods: [], + interfaces: { + TypeDeclaration( + baseName: 'Api2', + isNullable: false, + associatedProxyApi: api2, + ) + }, + ), + api2, + ], classes: [], enums: []); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + final String collapsedCode = _collapseNewlineAndIndentation(code); + expect( + code, + contains( + r'class Api extends PigeonProxyApiBaseClass implements Api2', + ), + ); + expect( + collapsedCode, + contains( + r'Api.pigeon_detached({ super.pigeon_binaryMessenger, ' + r'super.pigeon_instanceManager, ' + r'required this.aFlutterMethod, ' + r'this.aNullableFlutterMethod, })', + ), + ); + }); + }); + + group('Constructors', () { + test('empty name and no params constructor', () { + final Root root = Root( + apis: [ + AstProxyApi(name: 'Api', constructors: [ + Constructor( + name: '', + parameters: [], + ) + ], fields: [], methods: []), + ], + classes: [], + enums: [], + ); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + final String collapsedCode = _collapseNewlineAndIndentation(code); + expect(code, contains('class Api')); + expect( + collapsedCode, + contains( + r'Api({ super.pigeon_binaryMessenger, ' + r'super.pigeon_instanceManager, })', + ), + ); + expect( + collapsedCode, + contains( + r"const String __pigeon_channelName = 'dev.flutter.pigeon.test_package.Api.pigeon_defaultConstructor';", + ), + ); + expect( + collapsedCode, + contains( + r'__pigeon_channel .send([__pigeon_instanceIdentifier])', + ), + ); + }); + + test('multiple params constructor', () { + final Enum anEnum = Enum( + name: 'AnEnum', + members: [EnumMember(name: 'one')], + ); + final Root root = Root( + apis: [ + AstProxyApi(name: 'Api', constructors: [ + Constructor( + name: 'name', + parameters: [ + Parameter( + type: const TypeDeclaration( + isNullable: false, + baseName: 'int', + ), + name: 'validType', + ), + Parameter( + type: TypeDeclaration( + isNullable: false, + baseName: 'AnEnum', + associatedEnum: anEnum, + ), + name: 'enumType', + ), + Parameter( + type: const TypeDeclaration( + isNullable: false, + baseName: 'Api2', + ), + name: 'proxyApiType', + ), + Parameter( + type: const TypeDeclaration( + isNullable: true, + baseName: 'int', + ), + name: 'nullableValidType', + ), + Parameter( + type: TypeDeclaration( + isNullable: true, + baseName: 'AnEnum', + associatedEnum: anEnum, + ), + name: 'nullableEnumType', + ), + Parameter( + type: const TypeDeclaration( + isNullable: true, + baseName: 'Api2', + ), + name: 'nullableProxyApiType', + ), + ], + ) + ], fields: [], methods: []), + AstProxyApi( + name: 'Api2', + constructors: [], + fields: [], + methods: [], + ), + ], + classes: [], + enums: [anEnum], + ); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + final String collapsedCode = _collapseNewlineAndIndentation(code); + expect(code, contains('class Api')); + expect( + collapsedCode, + contains( + r'Api.name({ super.pigeon_binaryMessenger, ' + r'super.pigeon_instanceManager, ' + r'required int validType, ' + r'required AnEnum enumType, ' + r'required Api2 proxyApiType, ' + r'int? nullableValidType, ' + r'AnEnum? nullableEnumType, ' + r'Api2? nullableProxyApiType, })', + ), + ); + expect( + collapsedCode, + contains( + r'__pigeon_channel.send([ ' + r'__pigeon_instanceIdentifier, ' + r'validType, enumType.index, proxyApiType, ' + r'nullableValidType, nullableEnumType?.index, nullableProxyApiType ])', + ), + ); + }); + }); + + group('Fields', () { + test('constructor with fields', () { + final Enum anEnum = Enum( + name: 'AnEnum', + members: [EnumMember(name: 'one')], + ); + final Root root = Root( + apis: [ + AstProxyApi( + name: 'Api', + constructors: [ + Constructor( + name: 'name', + parameters: [], + ) + ], + fields: [ + ApiField( + type: const TypeDeclaration( + isNullable: false, + baseName: 'int', + ), + name: 'validType', + ), + ApiField( + type: TypeDeclaration( + isNullable: false, + baseName: 'AnEnum', + associatedEnum: anEnum, + ), + name: 'enumType', + ), + ApiField( + type: const TypeDeclaration( + isNullable: false, + baseName: 'Api2', + ), + name: 'proxyApiType', + ), + ApiField( + type: const TypeDeclaration( + isNullable: true, + baseName: 'int', + ), + name: 'nullableValidType', + ), + ApiField( + type: TypeDeclaration( + isNullable: true, + baseName: 'AnEnum', + associatedEnum: anEnum, + ), + name: 'nullableEnumType', + ), + ApiField( + type: const TypeDeclaration( + isNullable: true, + baseName: 'Api2', + ), + name: 'nullableProxyApiType', + ), + ], + methods: [], + ), + AstProxyApi( + name: 'Api2', + constructors: [], + fields: [], + methods: [], + ), + ], + classes: [], + enums: [anEnum], + ); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + final String collapsedCode = _collapseNewlineAndIndentation(code); + expect(code, contains('class Api')); + expect( + collapsedCode, + contains( + r'Api.name({ super.pigeon_binaryMessenger, ' + r'super.pigeon_instanceManager, ' + r'required this.validType, ' + r'required this.enumType, ' + r'required this.proxyApiType, ' + r'this.nullableValidType, ' + r'this.nullableEnumType, ' + r'this.nullableProxyApiType, })', + ), + ); + expect( + collapsedCode, + contains( + r'__pigeon_channel.send([ ' + r'__pigeon_instanceIdentifier, ' + r'validType, enumType.index, proxyApiType, ' + r'nullableValidType, nullableEnumType?.index, nullableProxyApiType ])', + ), + ); + expect( + code, + contains(r'final int validType;'), + ); + expect( + code, + contains(r'final AnEnum enumType;'), + ); + expect( + code, + contains(r'final Api2 proxyApiType;'), + ); + expect( + code, + contains(r'final int? nullableValidType;'), + ); + expect( + code, + contains(r'final AnEnum? nullableEnumType;'), + ); + expect( + code, + contains(r'final Api2? nullableProxyApiType;'), + ); + }); + + test('attached field', () { + final AstProxyApi api2 = AstProxyApi( + name: 'Api2', + constructors: [], + fields: [], + methods: [], + ); + final Root root = Root( + apis: [ + AstProxyApi( + name: 'Api', + constructors: [], + fields: [ + ApiField( + name: 'aField', + isAttached: true, + type: TypeDeclaration( + baseName: 'Api2', + isNullable: false, + associatedProxyApi: api2, + ), + ), + ], + methods: [], + ), + api2, + ], + classes: [], + enums: [], + ); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + expect(code, contains('class Api')); + expect(code, contains(r'late final Api2 aField = __pigeon_aField();')); + expect(code, contains(r'Api2 __pigeon_aField()')); + }); + + test('static attached field', () { + final AstProxyApi api2 = AstProxyApi( + name: 'Api2', + constructors: [], + fields: [], + methods: [], + ); + final Root root = Root( + apis: [ + AstProxyApi( + name: 'Api', + constructors: [], + fields: [ + ApiField( + name: 'aField', + isStatic: true, + isAttached: true, + type: TypeDeclaration( + baseName: 'Api2', + isNullable: false, + associatedProxyApi: api2, + ), + ), + ], + methods: [], + ), + api2, + ], + classes: [], + enums: [], + ); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + expect(code, contains('class Api')); + expect( + code, contains(r'static final Api2 aField = __pigeon_aField();')); + expect(code, contains(r'static Api2 __pigeon_aField()')); + }); + }); + + group('Host methods', () { + test('multiple params method', () { + final Enum anEnum = Enum( + name: 'AnEnum', + members: [EnumMember(name: 'one')], + ); + final Root root = Root( + apis: [ + AstProxyApi( + name: 'Api', + constructors: [], + fields: [], + methods: [ + Method( + name: 'doSomething', + location: ApiLocation.host, + parameters: [ + Parameter( + type: const TypeDeclaration( + isNullable: false, + baseName: 'int', + ), + name: 'validType', + ), + Parameter( + type: TypeDeclaration( + isNullable: false, + baseName: 'AnEnum', + associatedEnum: anEnum, + ), + name: 'enumType', + ), + Parameter( + type: const TypeDeclaration( + isNullable: false, + baseName: 'Api2', + ), + name: 'proxyApiType', + ), + Parameter( + type: const TypeDeclaration( + isNullable: true, + baseName: 'int', + ), + name: 'nullableValidType', + ), + Parameter( + type: TypeDeclaration( + isNullable: true, + baseName: 'AnEnum', + associatedEnum: anEnum, + ), + name: 'nullableEnumType', + ), + Parameter( + type: const TypeDeclaration( + isNullable: true, + baseName: 'Api2', + ), + name: 'nullableProxyApiType', + ), + ], + returnType: const TypeDeclaration.voidDeclaration(), + ), + ], + ), + AstProxyApi( + name: 'Api2', + constructors: [], + fields: [], + methods: [], + ), + ], + classes: [], + enums: [anEnum], + ); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + final String collapsedCode = _collapseNewlineAndIndentation(code); + expect(code, contains('class Api')); + expect( + collapsedCode, + contains( + r'Future doSomething( int validType, AnEnum enumType, ' + r'Api2 proxyApiType, int? nullableValidType, ' + r'AnEnum? nullableEnumType, Api2? nullableProxyApiType, )', + ), + ); + expect( + collapsedCode, + contains( + r'await __pigeon_channel.send([ this, validType, ' + r'enumType.index, proxyApiType, nullableValidType, ' + r'nullableEnumType?.index, nullableProxyApiType ])', + ), + ); + }); + + test('static method', () { + final Root root = Root( + apis: [ + AstProxyApi( + name: 'Api', + constructors: [], + fields: [], + methods: [ + Method( + name: 'doSomething', + location: ApiLocation.host, + isStatic: true, + parameters: [], + returnType: const TypeDeclaration.voidDeclaration(), + ), + ], + ), + ], + classes: [], + enums: [], + ); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + final String collapsedCode = _collapseNewlineAndIndentation(code); + expect(code, contains('class Api')); + expect( + collapsedCode, + contains( + r'static Future doSomething({ BinaryMessenger? pigeon_binaryMessenger, ' + r'PigeonInstanceManager? pigeon_instanceManager, })', + ), + ); + expect( + collapsedCode, + contains(r'await __pigeon_channel.send(null)'), + ); + }); + }); + + group('Flutter methods', () { + test('multiple params flutter method', () { + final Enum anEnum = Enum( + name: 'AnEnum', + members: [EnumMember(name: 'one')], + ); + final Root root = Root(apis: [ + AstProxyApi( + name: 'Api', + constructors: [], + fields: [], + methods: [ + Method( + name: 'doSomething', + location: ApiLocation.flutter, + isRequired: false, + parameters: [ + Parameter( + type: const TypeDeclaration( + isNullable: false, + baseName: 'int', + ), + name: 'validType', + ), + Parameter( + type: TypeDeclaration( + isNullable: false, + baseName: 'AnEnum', + associatedEnum: anEnum, + ), + name: 'enumType', + ), + Parameter( + type: const TypeDeclaration( + isNullable: false, + baseName: 'Api2', + ), + name: 'proxyApiType', + ), + Parameter( + type: const TypeDeclaration( + isNullable: true, + baseName: 'int', + ), + name: 'nullableValidType', + ), + Parameter( + type: TypeDeclaration( + isNullable: true, + baseName: 'AnEnum', + associatedEnum: anEnum, + ), + name: 'nullableEnumType', + ), + Parameter( + type: const TypeDeclaration( + isNullable: true, + baseName: 'Api2', + ), + name: 'nullableProxyApiType', + ), + ], + returnType: const TypeDeclaration.voidDeclaration(), + ), + ]) + ], classes: [], enums: [ + anEnum + ]); + final StringBuffer sink = StringBuffer(); + const DartGenerator generator = DartGenerator(); + generator.generate( + const DartOptions(), + root, + sink, + dartPackageName: DEFAULT_PACKAGE_NAME, + ); + final String code = sink.toString(); + final String collapsedCode = _collapseNewlineAndIndentation(code); + expect(code, contains('class Api')); + expect( + collapsedCode, + contains( + r'final void Function( Api pigeon_instance, int validType, ' + r'AnEnum enumType, Api2 proxyApiType, int? nullableValidType, ' + r'AnEnum? nullableEnumType, Api2? nullableProxyApiType, )? ' + r'doSomething;', + ), + ); + expect( + collapsedCode, + contains( + r'void Function( Api pigeon_instance, int validType, AnEnum enumType, ' + r'Api2 proxyApiType, int? nullableValidType, ' + r'AnEnum? nullableEnumType, Api2? nullableProxyApiType, )? ' + r'doSomething'), + ); + expect( + code, + contains(r'final Api? arg_pigeon_instance = (args[0] as Api?);'), + ); + expect( + code, + contains(r'final int? arg_validType = (args[1] as int?);'), + ); + expect( + collapsedCode, + contains( + r'final AnEnum? arg_enumType = args[2] == null ? ' + r'null : AnEnum.values[args[2]! as int];', + ), + ); + expect( + code, + contains(r'final Api2? arg_proxyApiType = (args[3] as Api2?);'), + ); + expect( + code, + contains(r'final int? arg_nullableValidType = (args[4] as int?);'), + ); + expect( + collapsedCode, + contains( + r'final AnEnum? arg_nullableEnumType = args[5] == null ? ' + r'null : AnEnum.values[args[5]! as int];', + ), + ); + expect( + collapsedCode, + contains( + r'(doSomething ?? arg_pigeon_instance!.doSomething)?.call( arg_pigeon_instance!, ' + r'arg_validType!, arg_enumType!, arg_proxyApiType!, ' + r'arg_nullableValidType, arg_nullableEnumType, ' + r'arg_nullableProxyApiType);', + ), + ); + }); + }); + }); +} + +/// Replaces a new line and the indentation with a single white space +/// +/// This +/// +/// ```dart +/// void method( +/// int param1, +/// int param2, +/// ) +/// ``` +/// +/// converts to +/// +/// ```dart +/// void method( int param1, int param2, ) +/// ``` +String _collapseNewlineAndIndentation(String string) { + final StringBuffer result = StringBuffer(); + for (final String line in string.split('\n')) { + result.write('${line.trimLeft()} '); + } + return result.toString().trim(); +} diff --git a/packages/pigeon/test/generator_tools_test.dart b/packages/pigeon/test/generator_tools_test.dart index 6b43b93eecc5..e68bb96239c1 100644 --- a/packages/pigeon/test/generator_tools_test.dart +++ b/packages/pigeon/test/generator_tools_test.dart @@ -404,10 +404,8 @@ void main() { ), ); - final List apiChain = recursiveGetSuperClassApisChain(api); - expect( - apiChain, + api.allSuperClasses().toList(), containsAllInOrder([ superClassApi, superClassOfSuperClassApi, @@ -478,10 +476,8 @@ void main() { }, ); - final Set allInterfaces = recursiveFindAllInterfaceApis(api); - expect( - allInterfaces, + api.apisOfInterfaces(), containsAll([ interfaceApi, interfaceApi2, @@ -523,9 +519,6 @@ void main() { TypeDeclaration(baseName: 'A', isNullable: false, associatedProxyApi: a), }; - expect( - () => recursiveFindAllInterfaceApis(a), - throwsArgumentError, - ); + expect(() => a.apisOfInterfaces(), throwsArgumentError); }); } diff --git a/packages/pigeon/tool/shared/generation.dart b/packages/pigeon/tool/shared/generation.dart index 51f0e95e851f..1cd3b6e5ea9b 100644 --- a/packages/pigeon/tool/shared/generation.dart +++ b/packages/pigeon/tool/shared/generation.dart @@ -68,6 +68,7 @@ Future generateTestPigeons({required String baseDir}) async { 'null_fields', 'nullable_returns', 'primitive', + 'proxy_api_tests', ]; final String outputBase = p.join(baseDir, 'platform_tests', 'test_plugin'); diff --git a/script/configs/allowed_unpinned_deps.yaml b/script/configs/allowed_unpinned_deps.yaml index fe4c138b0a63..84ff94a1101b 100644 --- a/script/configs/allowed_unpinned_deps.yaml +++ b/script/configs/allowed_unpinned_deps.yaml @@ -25,9 +25,11 @@ - build_config - build_runner - build_test +- code_builder - collection - convert - crypto +- dart_style - fake_async - ffi - gcloud