diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index 3fb82c7ae40f..94dff6cd9b39 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,3 +1,7 @@ +## 7.1.0 + +* Adds `@SwiftFunction` annotation for specifying custom swift function signature. + ## 7.0.5 * Requires analyzer 5.0.0 and replaces use of deprecated APIs. diff --git a/packages/pigeon/lib/ast.dart b/packages/pigeon/lib/ast.dart index 8da2b746f88b..08ddcbdb5198 100644 --- a/packages/pigeon/lib/ast.dart +++ b/packages/pigeon/lib/ast.dart @@ -32,6 +32,7 @@ class Method extends Node { this.isAsynchronous = false, this.offset, this.objcSelector = '', + this.swiftFunction = '', this.taskQueueType = TaskQueueType.serial, this.documentationComments = const [], }); @@ -54,6 +55,9 @@ class Method extends Node { /// An override for the generated objc selector (ex. "divideNumber:by:"). String objcSelector; + /// An override for the generated swift function signature (ex. "divideNumber(_:by:)"). + String swiftFunction; + /// Specifies how handlers are dispatched with respect to threading. TaskQueueType taskQueueType; @@ -68,7 +72,9 @@ class Method extends Node { String toString() { final String objcSelectorStr = objcSelector.isEmpty ? '' : ' objcSelector:$objcSelector'; - return '(Method name:$name returnType:$returnType arguments:$arguments isAsynchronous:$isAsynchronous$objcSelectorStr documentationComments:$documentationComments)'; + final String swiftFunctionStr = + swiftFunction.isEmpty ? '' : ' swiftFunction:$swiftFunction'; + return '(Method name:$name returnType:$returnType arguments:$arguments isAsynchronous:$isAsynchronous$objcSelectorStr$swiftFunctionStr documentationComments:$documentationComments)'; } } diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index ccc7326749b3..2618648e52b2 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -11,7 +11,7 @@ import 'ast.dart'; /// The current version of pigeon. /// /// This must match the version in pubspec.yaml. -const String pigeonVersion = '7.0.5'; +const String pigeonVersion = '7.1.0'; /// Read all the content from [stdin] to a String. String readStdin() { diff --git a/packages/pigeon/lib/pigeon_lib.dart b/packages/pigeon/lib/pigeon_lib.dart index cad4f5c64255..58fb6bb73787 100644 --- a/packages/pigeon/lib/pigeon_lib.dart +++ b/packages/pigeon/lib/pigeon_lib.dart @@ -100,6 +100,20 @@ class ObjCSelector { final String value; } +/// Metadata to annotate methods to control the signature used for Swift output. +/// +/// The number of components in the provided signature must match the number of +/// arguments in the annotated method. +/// For example: +/// @SwiftFunction('divide(_:by:)') double divide(int x, String y); +class SwiftFunction { + /// Constructor. + const SwiftFunction(this.value); + + /// The string representation of the function signature. + final String value; +} + /// Type of TaskQueue which determines how handlers are dispatched for /// HostApi's. enum TaskQueueType { @@ -724,6 +738,17 @@ List _validateAst(Root root, String source) { )); } } + if (method.swiftFunction.isNotEmpty) { + final RegExp signatureRegex = + RegExp('\\w+ *\\((\\w+:){${method.arguments.length}}\\)'); + if (!signatureRegex.hasMatch(method.swiftFunction)) { + result.add(Error( + message: + 'Invalid function signature, expected ${method.arguments.length} arguments.', + lineNumber: _calculateLineNumberNullable(source, method.offset), + )); + } + } if (method.taskQueueType != TaskQueueType.serial && api.location != ApiLocation.host) { result.add(Error( @@ -1026,6 +1051,13 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor { .asNullable() ?.value ?? ''; + final String swiftFunction = _findMetadata(node.metadata, 'SwiftFunction') + ?.arguments + ?.arguments + .first + .asNullable() + ?.value ?? + ''; final dart_ast.ArgumentList? taskQueueArguments = _findMetadata(node.metadata, 'TaskQueue')?.arguments; final String? taskQueueTypeName = taskQueueArguments == null @@ -1054,6 +1086,7 @@ class _RootBuilder extends dart_ast_visitor.RecursiveAstVisitor { arguments: arguments, isAsynchronous: isAsynchronous, objcSelector: objcSelector, + swiftFunction: swiftFunction, offset: node.offset, taskQueueType: taskQueueType, documentationComments: diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index b0aa98d56753..6109b8d3df8f 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -294,6 +294,9 @@ import FlutterMacOS }); } for (final Method func in api.methods) { + final _SwiftFunctionComponents components = + _SwiftFunctionComponents.fromMethod(func); + final String channelName = makeChannelName(api, func); final String returnType = func.returnType.isVoid ? '' @@ -309,8 +312,11 @@ import FlutterMacOS } else { final Iterable argTypes = func.arguments .map((NamedType e) => _nullsafeSwiftTypeForDartType(e.type)); - final Iterable argLabels = - indexMap(func.arguments, _getArgumentName); + final Iterable argLabels = indexMap(components.arguments, + (int index, _SwiftFunctionArgument argument) { + return argument.label ?? + _getArgumentName(index, argument.namedType); + }); final Iterable argNames = indexMap(func.arguments, _getSafeArgumentName); sendArgument = '[${argNames.join(', ')}] as [Any?]'; @@ -322,10 +328,10 @@ import FlutterMacOS '$label $name: $type').join(', '); if (func.returnType.isVoid) { indent.write( - 'func ${func.name}($argsSignature, completion: @escaping () -> Void) '); + 'func ${components.name}($argsSignature, completion: @escaping () -> Void) '); } else { indent.write( - 'func ${func.name}($argsSignature, completion: @escaping ($returnType) -> Void) '); + 'func ${components.name}($argsSignature, completion: @escaping ($returnType) -> Void) '); } } indent.addScoped('{', '}', () { @@ -369,7 +375,6 @@ import FlutterMacOS if (isCustomCodec) { _writeCodec(indent, api, root); } - const List generatedComments = [ ' Generated protocol from Pigeon that represents a handler of messages from Flutter.' ]; @@ -379,17 +384,15 @@ import FlutterMacOS indent.write('protocol $apiName '); indent.addScoped('{', '}', () { for (final Method method in api.methods) { - final List argSignature = []; - if (method.arguments.isNotEmpty) { - final Iterable argTypes = method.arguments - .map((NamedType e) => _nullsafeSwiftTypeForDartType(e.type)); - final Iterable argNames = - method.arguments.map((NamedType e) => e.name); - argSignature.addAll( - map2(argTypes, argNames, (String argType, String argName) { - return '$argName: $argType'; - })); - } + final _SwiftFunctionComponents components = + _SwiftFunctionComponents.fromMethod(method); + final List argSignature = + components.arguments.map((_SwiftFunctionArgument argument) { + final String? label = argument.label; + final String name = argument.name; + final String type = _nullsafeSwiftTypeForDartType(argument.type); + return '${label == null ? '' : '$label '}$name: $type'; + }).toList(); final String returnType = method.returnType.isVoid ? '' @@ -399,12 +402,12 @@ import FlutterMacOS if (method.isAsynchronous) { argSignature.add('completion: @escaping ($returnType) -> Void'); - indent.writeln('func ${method.name}(${argSignature.join(', ')})'); + indent.writeln('func ${components.name}(${argSignature.join(', ')})'); } else if (method.returnType.isVoid) { - indent.writeln('func ${method.name}(${argSignature.join(', ')})'); + indent.writeln('func ${components.name}(${argSignature.join(', ')})'); } else { indent.writeln( - 'func ${method.name}(${argSignature.join(', ')}) -> $returnType'); + 'func ${components.name}(${argSignature.join(', ')}) -> $returnType'); } } }); @@ -428,6 +431,9 @@ import FlutterMacOS 'static func setUp(binaryMessenger: FlutterBinaryMessenger, api: $apiName?) '); indent.addScoped('{', '}', () { for (final Method method in api.methods) { + final _SwiftFunctionComponents components = + _SwiftFunctionComponents.fromMethod(method); + final String channelName = makeChannelName(api, method); final String varChannelName = '${method.name}Channel'; addDocumentationComments( @@ -442,18 +448,25 @@ import FlutterMacOS method.arguments.isNotEmpty ? 'message' : '_'; indent.addScoped('{ $messageVarName, reply in', '}', () { final List methodArgument = []; - if (method.arguments.isNotEmpty) { + if (components.arguments.isNotEmpty) { indent.writeln('let args = message as! [Any?]'); - enumerate(method.arguments, (int index, NamedType arg) { - final String argName = _getSafeArgumentName(index, arg); + enumerate(components.arguments, + (int index, _SwiftFunctionArgument arg) { + final String argName = + _getSafeArgumentName(index, arg.namedType); final String argIndex = 'args[$index]'; indent.writeln( 'let $argName = ${_castForceUnwrap(argIndex, arg.type, root)}'); - methodArgument.add('${arg.name}: $argName'); + + if (arg.label == '_') { + methodArgument.add(argName); + } else { + methodArgument.add('${arg.label ?? arg.name}: $argName'); + } }); } final String call = - 'api.${method.name}(${methodArgument.join(', ')})'; + 'api.${components.name}(${methodArgument.join(', ')})'; if (method.isAsynchronous) { indent.write('$call '); if (method.returnType.isVoid) { @@ -695,3 +708,87 @@ String _nullsafeSwiftTypeForDartType(TypeDeclaration type) { final String nullSafe = type.isNullable ? '?' : ''; return '${_swiftTypeForDartType(type)}$nullSafe'; } + +/// A class that represents a Swift function argument. +/// +/// The [name] is the name of the argument. +/// The [type] is the type of the argument. +/// The [namedType] is the [NamedType] that this argument is generated from. +/// The [label] is the label of the argument. +class _SwiftFunctionArgument { + _SwiftFunctionArgument({ + required this.name, + required this.type, + required this.namedType, + this.label, + }); + + final String name; + final TypeDeclaration type; + final NamedType namedType; + final String? label; +} + +/// A class that represents a Swift function signature. +/// +/// The [name] is the name of the function. +/// The [arguments] are the arguments of the function. +/// The [returnType] is the return type of the function. +/// The [method] is the method that this function signature is generated from. +class _SwiftFunctionComponents { + _SwiftFunctionComponents._({ + required this.name, + required this.arguments, + required this.returnType, + required this.method, + }); + + /// Constructor that generates a [_SwiftFunctionComponents] from a [Method]. + factory _SwiftFunctionComponents.fromMethod(Method method) { + if (method.swiftFunction.isEmpty) { + return _SwiftFunctionComponents._( + name: method.name, + returnType: method.returnType, + arguments: method.arguments + .map((NamedType field) => _SwiftFunctionArgument( + name: field.name, + type: field.type, + namedType: field, + )) + .toList(), + method: method, + ); + } + + final String argsExtractor = + repeat(r'(\w+):', method.arguments.length).join(); + final RegExp signatureRegex = RegExp(r'(\w+) *\(' + argsExtractor + r'\)'); + final RegExpMatch match = signatureRegex.firstMatch(method.swiftFunction)!; + + final Iterable labels = match + .groups(List.generate( + method.arguments.length, (int index) => index + 2)) + .whereType(); + + return _SwiftFunctionComponents._( + name: match.group(1)!, + returnType: method.returnType, + arguments: map2( + method.arguments, + labels, + (NamedType field, String label) => _SwiftFunctionArgument( + name: field.name, + label: label == field.name ? null : label, + type: field.type, + namedType: field, + ), + ).toList(), + method: method, + ); + } + + final String name; + final List<_SwiftFunctionArgument> arguments; + final TypeDeclaration returnType; + final Method method; +} diff --git a/packages/pigeon/pigeons/core_tests.dart b/packages/pigeon/pigeons/core_tests.dart index 890e7d6e98ec..fe1cb9b1785b 100644 --- a/packages/pigeon/pigeons/core_tests.dart +++ b/packages/pigeon/pigeons/core_tests.dart @@ -96,10 +96,12 @@ abstract class HostIntegrationCoreApi { /// Returns the passed object, to test serialization and deserialization. @ObjCSelector('echoAllTypes:') + @SwiftFunction('echo(_:)') AllTypes echoAllTypes(AllTypes everything); /// Returns the passed object, to test serialization and deserialization. @ObjCSelector('echoAllNullableTypes:') + @SwiftFunction('echo(_:)') AllNullableTypes? echoAllNullableTypes(AllNullableTypes? everything); /// Returns an error, to test error handling. @@ -107,26 +109,32 @@ abstract class HostIntegrationCoreApi { /// Returns passed in int. @ObjCSelector('echoInt:') + @SwiftFunction('echo(_:)') int echoInt(int anInt); /// Returns passed in double. @ObjCSelector('echoDouble:') + @SwiftFunction('echo(_:)') double echoDouble(double aDouble); /// Returns the passed in boolean. @ObjCSelector('echoBool:') + @SwiftFunction('echo(_:)') bool echoBool(bool aBool); /// Returns the passed in string. @ObjCSelector('echoString:') + @SwiftFunction('echo(_:)') String echoString(String aString); /// Returns the passed in Uint8List. @ObjCSelector('echoUint8List:') + @SwiftFunction('echo(_:)') Uint8List echoUint8List(Uint8List aUint8List); /// Returns the passed in generic Object. @ObjCSelector('echoObject:') + @SwiftFunction('echo(_:)') Object echoObject(Object anObject); // ========== Syncronous nullable method tests ========== @@ -134,40 +142,49 @@ abstract class HostIntegrationCoreApi { /// Returns the inner `aString` value from the wrapped object, to test /// sending of nested objects. @ObjCSelector('extractNestedNullableStringFrom:') + @SwiftFunction('extractNestedNullableString(from:)') String? extractNestedNullableString(AllNullableTypesWrapper wrapper); /// Returns the inner `aString` value from the wrapped object, to test /// sending of nested objects. @ObjCSelector('createNestedObjectWithNullableString:') + @SwiftFunction('createNestedObject(with:)') AllNullableTypesWrapper createNestedNullableString(String? nullableString); /// Returns passed in arguments of multiple types. @ObjCSelector('sendMultipleNullableTypesABool:anInt:aString:') + @SwiftFunction('sendMultipleNullableTypes(aBool:anInt:aString:)') AllNullableTypes sendMultipleNullableTypes( bool? aNullableBool, int? aNullableInt, String? aNullableString); /// Returns passed in int. @ObjCSelector('echoNullableInt:') + @SwiftFunction('echo(_:)') int? echoNullableInt(int? aNullableInt); /// Returns passed in double. @ObjCSelector('echoNullableDouble:') + @SwiftFunction('echo(_:)') double? echoNullableDouble(double? aNullableDouble); /// Returns the passed in boolean. @ObjCSelector('echoNullableBool:') + @SwiftFunction('echo(_:)') bool? echoNullableBool(bool? aNullableBool); /// Returns the passed in string. @ObjCSelector('echoNullableString:') + @SwiftFunction('echo(_:)') String? echoNullableString(String? aNullableString); /// Returns the passed in Uint8List. @ObjCSelector('echoNullableUint8List:') + @SwiftFunction('echo(_:)') Uint8List? echoNullableUint8List(Uint8List? aNullableUint8List); /// Returns the passed in generic Object. @ObjCSelector('echoNullableObject:') + @SwiftFunction('echo(_:)') Object? echoNullableObject(Object? aNullableObject); // ========== Asyncronous method tests ========== @@ -180,6 +197,7 @@ abstract class HostIntegrationCoreApi { /// Returns the passed string asynchronously. @async @ObjCSelector('echoAsyncString:') + @SwiftFunction('echoAsync(_:)') String echoAsyncString(String aString); // ========== Flutter API test wrappers ========== @@ -189,6 +207,7 @@ abstract class HostIntegrationCoreApi { @async @ObjCSelector('callFlutterEchoAllTypes:') + @SwiftFunction('callFlutterEcho(_:)') AllTypes callFlutterEchoAllTypes(AllTypes everything); // TODO(stuartmorgan): Add callFlutterEchoAllNullableTypes and the associated @@ -198,63 +217,78 @@ abstract class HostIntegrationCoreApi { @async @ObjCSelector('callFlutterSendMultipleNullableTypesABool:anInt:aString:') + @SwiftFunction('callFlutterSendMultipleNullableTypes(aBool:anInt:aString:)') AllNullableTypes callFlutterSendMultipleNullableTypes( bool? aNullableBool, int? aNullableInt, String? aNullableString); @async @ObjCSelector('callFlutterEchoBool:') + @SwiftFunction('callFlutterEcho(_:)') bool callFlutterEchoBool(bool aBool); @async @ObjCSelector('callFlutterEchoInt:') + @SwiftFunction('callFlutterEcho(_:)') int callFlutterEchoInt(int anInt); @async @ObjCSelector('callFlutterEchoDouble:') + @SwiftFunction('callFlutterEcho(_:)') double callFlutterEchoDouble(double aDouble); @async @ObjCSelector('callFlutterEchoString:') + @SwiftFunction('callFlutterEcho(_:)') String callFlutterEchoString(String aString); @async @ObjCSelector('callFlutterEchoUint8List:') + @SwiftFunction('callFlutterEcho(_:)') Uint8List callFlutterEchoUint8List(Uint8List aList); @async @ObjCSelector('callFlutterEchoList:') + @SwiftFunction('callFlutterEcho(_:)') List callFlutterEchoList(List aList); @async @ObjCSelector('callFlutterEchoMap:') + @SwiftFunction('callFlutterEcho(_:)') Map callFlutterEchoMap(Map aMap); @async @ObjCSelector('callFlutterEchoNullableBool:') + @SwiftFunction('callFlutterEchoNullable(_:)') bool? callFlutterEchoNullableBool(bool? aBool); @async @ObjCSelector('callFlutterEchoNullableInt:') + @SwiftFunction('callFlutterEchoNullable(_:)') int? callFlutterEchoNullableInt(int? anInt); @async @ObjCSelector('callFlutterEchoNullableDouble:') + @SwiftFunction('callFlutterEchoNullable(_:)') double? callFlutterEchoNullableDouble(double? aDouble); @async @ObjCSelector('callFlutterEchoNullableString:') + @SwiftFunction('callFlutterEchoNullable(_:)') String? callFlutterEchoNullableString(String? aString); @async @ObjCSelector('callFlutterEchoNullableUint8List:') + @SwiftFunction('callFlutterEchoNullable(_:)') Uint8List? callFlutterEchoNullableUint8List(Uint8List? aList); @async @ObjCSelector('callFlutterEchoNullableList:') + @SwiftFunction('callFlutterEchoNullable(_:)') List? callFlutterEchoNullableList(List? aList); @async @ObjCSelector('callFlutterEchoNullableMap:') + @SwiftFunction('callFlutterEchoNullable(_:)') Map? callFlutterEchoNullableMap( Map? aMap); } @@ -269,16 +303,19 @@ abstract class FlutterIntegrationCoreApi { /// Returns the passed object, to test serialization and deserialization. @ObjCSelector('echoAllTypes:') + @SwiftFunction('echo(_:)') AllTypes echoAllTypes(AllTypes everything); /// Returns the passed object, to test serialization and deserialization. @ObjCSelector('echoAllNullableTypes:') + @SwiftFunction('echoNullable(_:)') AllNullableTypes echoAllNullableTypes(AllNullableTypes everything); /// Returns passed in arguments of multiple types. /// /// Tests multiple-arity FlutterApi handling. @ObjCSelector('sendMultipleNullableTypesABool:anInt:aString:') + @SwiftFunction('sendMultipleNullableTypes(aBool:anInt:aString:)') AllNullableTypes sendMultipleNullableTypes( bool? aNullableBool, int? aNullableInt, String? aNullableString); @@ -286,60 +323,74 @@ abstract class FlutterIntegrationCoreApi { /// Returns the passed boolean, to test serialization and deserialization. @ObjCSelector('echoBool:') + @SwiftFunction('echo(_:)') bool echoBool(bool aBool); /// Returns the passed int, to test serialization and deserialization. @ObjCSelector('echoInt:') + @SwiftFunction('echo(_:)') int echoInt(int anInt); /// Returns the passed double, to test serialization and deserialization. @ObjCSelector('echoDouble:') + @SwiftFunction('echo(_:)') double echoDouble(double aDouble); /// Returns the passed string, to test serialization and deserialization. @ObjCSelector('echoString:') + @SwiftFunction('echo(_:)') String echoString(String aString); /// Returns the passed byte list, to test serialization and deserialization. @ObjCSelector('echoUint8List:') + @SwiftFunction('echo(_:)') Uint8List echoUint8List(Uint8List aList); /// Returns the passed list, to test serialization and deserialization. @ObjCSelector('echoList:') + @SwiftFunction('echo(_:)') List echoList(List aList); /// Returns the passed map, to test serialization and deserialization. @ObjCSelector('echoMap:') + @SwiftFunction('echo(_:)') Map echoMap(Map aMap); // ========== Nullable argument/return type tests ========== /// Returns the passed boolean, to test serialization and deserialization. @ObjCSelector('echoNullableBool:') + @SwiftFunction('echoNullable(_:)') bool? echoNullableBool(bool? aBool); /// Returns the passed int, to test serialization and deserialization. @ObjCSelector('echoNullableInt:') + @SwiftFunction('echoNullable(_:)') int? echoNullableInt(int? anInt); /// Returns the passed double, to test serialization and deserialization. @ObjCSelector('echoNullableDouble:') + @SwiftFunction('echoNullable(_:)') double? echoNullableDouble(double? aDouble); /// Returns the passed string, to test serialization and deserialization. @ObjCSelector('echoNullableString:') + @SwiftFunction('echoNullable(_:)') String? echoNullableString(String? aString); /// Returns the passed byte list, to test serialization and deserialization. @ObjCSelector('echoNullableUint8List:') + @SwiftFunction('echoNullable(_:)') Uint8List? echoNullableUint8List(Uint8List? aList); /// Returns the passed list, to test serialization and deserialization. @ObjCSelector('echoNullableList:') + @SwiftFunction('echoNullable(_:)') List? echoNullableList(List? aList); /// Returns the passed map, to test serialization and deserialization. @ObjCSelector('echoNullableMap:') + @SwiftFunction('echoNullable(_:)') Map? echoNullableMap(Map? aMap); } diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java index 7e4d7ae9964f..6f031f38d003 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/CoreTests.java @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v7.0.5), do not edit directly. +// Autogenerated from Pigeon (v7.1.0), do not edit directly. // See also: https://pub.dev/packages/pigeon package com.example.alternate_language_test_plugin; diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h index b7001f492f18..76982b5624b8 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.h @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v7.0.5), do not edit directly. +// Autogenerated from Pigeon (v7.1.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m index cae5ac340800..ad54c1414b1d 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/CoreTests.gen.m @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v7.0.5), do not edit directly. +// Autogenerated from Pigeon (v7.1.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "CoreTests.gen.h" diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart index 6fb1023d19bd..1768c37b4544 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/core_tests.gen.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v7.0.5), do not edit directly. +// Autogenerated from Pigeon (v7.1.0), 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 diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt index d4eaaef4d474..ef562980b2b8 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/CoreTests.gen.kt @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v7.0.5), do not edit directly. +// Autogenerated from Pigeon (v7.1.0), do not edit directly. // See also: https://pub.dev/packages/pigeon package com.example.test_plugin diff --git a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift index 4d35aff40c2a..08b9b3b15ebb 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift +++ b/packages/pigeon/platform_tests/test_plugin/example/ios/RunnerTests/AllDatatypesTests.swift @@ -15,7 +15,7 @@ class AllDatatypesTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") - api.echoAllNullableTypes(everything: everything) { result in + api.echoNullable(everything) { result in XCTAssertNil(result.aNullableBool) XCTAssertNil(result.aNullableInt) XCTAssertNil(result.aNullableDouble) @@ -57,7 +57,7 @@ class AllDatatypesTests: XCTestCase { let expectation = XCTestExpectation(description: "callback") - api.echoAllNullableTypes(everything: everything) { result in + api.echoNullable(everything) { result in XCTAssertEqual(result.aNullableBool, everything.aNullableBool) XCTAssertEqual(result.aNullableInt, everything.aNullableInt) XCTAssertEqual(result.aNullableDouble, everything.aNullableDouble) diff --git a/packages/pigeon/platform_tests/test_plugin/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/RunnerTests.xcscheme b/packages/pigeon/platform_tests/test_plugin/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/RunnerTests.xcscheme new file mode 100644 index 000000000000..720178f50151 --- /dev/null +++ b/packages/pigeon/platform_tests/test_plugin/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/RunnerTests.xcscheme @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift index d33a26ca364c..0f3391283b90 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v7.0.5), do not edit directly. +// Autogenerated from Pigeon (v7.1.0), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation @@ -238,65 +238,65 @@ protocol HostIntegrationCoreApi { /// test basic calling. func noop() /// Returns the passed object, to test serialization and deserialization. - func echoAllTypes(everything: AllTypes) -> AllTypes + func echo(_ everything: AllTypes) -> AllTypes /// Returns the passed object, to test serialization and deserialization. - func echoAllNullableTypes(everything: AllNullableTypes?) -> AllNullableTypes? + func echo(_ everything: AllNullableTypes?) -> AllNullableTypes? /// Returns an error, to test error handling. func throwError() /// Returns passed in int. - func echoInt(anInt: Int32) -> Int32 + func echo(_ anInt: Int32) -> Int32 /// Returns passed in double. - func echoDouble(aDouble: Double) -> Double + func echo(_ aDouble: Double) -> Double /// Returns the passed in boolean. - func echoBool(aBool: Bool) -> Bool + func echo(_ aBool: Bool) -> Bool /// Returns the passed in string. - func echoString(aString: String) -> String + func echo(_ aString: String) -> String /// Returns the passed in Uint8List. - func echoUint8List(aUint8List: FlutterStandardTypedData) -> FlutterStandardTypedData + func echo(_ aUint8List: FlutterStandardTypedData) -> FlutterStandardTypedData /// Returns the passed in generic Object. - func echoObject(anObject: Any) -> Any + func echo(_ anObject: Any) -> Any /// Returns the inner `aString` value from the wrapped object, to test /// sending of nested objects. - func extractNestedNullableString(wrapper: AllNullableTypesWrapper) -> String? + func extractNestedNullableString(from wrapper: AllNullableTypesWrapper) -> String? /// Returns the inner `aString` value from the wrapped object, to test /// sending of nested objects. - func createNestedNullableString(nullableString: String?) -> AllNullableTypesWrapper + func createNestedObject(with nullableString: String?) -> AllNullableTypesWrapper /// Returns passed in arguments of multiple types. - func sendMultipleNullableTypes(aNullableBool: Bool?, aNullableInt: Int32?, aNullableString: String?) -> AllNullableTypes + func sendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int32?, aString aNullableString: String?) -> AllNullableTypes /// Returns passed in int. - func echoNullableInt(aNullableInt: Int32?) -> Int32? + func echo(_ aNullableInt: Int32?) -> Int32? /// Returns passed in double. - func echoNullableDouble(aNullableDouble: Double?) -> Double? + func echo(_ aNullableDouble: Double?) -> Double? /// Returns the passed in boolean. - func echoNullableBool(aNullableBool: Bool?) -> Bool? + func echo(_ aNullableBool: Bool?) -> Bool? /// Returns the passed in string. - func echoNullableString(aNullableString: String?) -> String? + func echo(_ aNullableString: String?) -> String? /// Returns the passed in Uint8List. - func echoNullableUint8List(aNullableUint8List: FlutterStandardTypedData?) -> FlutterStandardTypedData? + func echo(_ aNullableUint8List: FlutterStandardTypedData?) -> FlutterStandardTypedData? /// Returns the passed in generic Object. - func echoNullableObject(aNullableObject: Any?) -> Any? + func echo(_ aNullableObject: Any?) -> Any? /// A no-op function taking no arguments and returning no value, to sanity /// test basic asynchronous calling. func noopAsync(completion: @escaping () -> Void) /// Returns the passed string asynchronously. - func echoAsyncString(aString: String, completion: @escaping (String) -> Void) + func echoAsync(_ aString: String, completion: @escaping (String) -> Void) func callFlutterNoop(completion: @escaping () -> Void) - func callFlutterEchoAllTypes(everything: AllTypes, completion: @escaping (AllTypes) -> Void) - func callFlutterSendMultipleNullableTypes(aNullableBool: Bool?, aNullableInt: Int32?, aNullableString: String?, completion: @escaping (AllNullableTypes) -> Void) - func callFlutterEchoBool(aBool: Bool, completion: @escaping (Bool) -> Void) - func callFlutterEchoInt(anInt: Int32, completion: @escaping (Int32) -> Void) - func callFlutterEchoDouble(aDouble: Double, completion: @escaping (Double) -> Void) - func callFlutterEchoString(aString: String, completion: @escaping (String) -> Void) - func callFlutterEchoUint8List(aList: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) - func callFlutterEchoList(aList: [Any?], completion: @escaping ([Any?]) -> Void) - func callFlutterEchoMap(aMap: [String?: Any?], completion: @escaping ([String?: Any?]) -> Void) - func callFlutterEchoNullableBool(aBool: Bool?, completion: @escaping (Bool?) -> Void) - func callFlutterEchoNullableInt(anInt: Int32?, completion: @escaping (Int32?) -> Void) - func callFlutterEchoNullableDouble(aDouble: Double?, completion: @escaping (Double?) -> Void) - func callFlutterEchoNullableString(aString: String?, completion: @escaping (String?) -> Void) - func callFlutterEchoNullableUint8List(aList: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) - func callFlutterEchoNullableList(aList: [Any?]?, completion: @escaping ([Any?]?) -> Void) - func callFlutterEchoNullableMap(aMap: [String?: Any?]?, completion: @escaping ([String?: Any?]?) -> Void) + func callFlutterEcho(_ everything: AllTypes, completion: @escaping (AllTypes) -> Void) + func callFlutterSendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int32?, aString aNullableString: String?, completion: @escaping (AllNullableTypes) -> Void) + func callFlutterEcho(_ aBool: Bool, completion: @escaping (Bool) -> Void) + func callFlutterEcho(_ anInt: Int32, completion: @escaping (Int32) -> Void) + func callFlutterEcho(_ aDouble: Double, completion: @escaping (Double) -> Void) + func callFlutterEcho(_ aString: String, completion: @escaping (String) -> Void) + func callFlutterEcho(_ aList: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) + func callFlutterEcho(_ aList: [Any?], completion: @escaping ([Any?]) -> Void) + func callFlutterEcho(_ aMap: [String?: Any?], completion: @escaping ([String?: Any?]) -> Void) + func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Bool?) -> Void) + func callFlutterEchoNullable(_ anInt: Int32?, completion: @escaping (Int32?) -> Void) + func callFlutterEchoNullable(_ aDouble: Double?, completion: @escaping (Double?) -> Void) + func callFlutterEchoNullable(_ aString: String?, completion: @escaping (String?) -> Void) + func callFlutterEchoNullable(_ aList: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) + func callFlutterEchoNullable(_ aList: [Any?]?, completion: @escaping ([Any?]?) -> Void) + func callFlutterEchoNullable(_ aMap: [String?: Any?]?, completion: @escaping ([String?: Any?]?) -> Void) } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. @@ -322,7 +322,7 @@ class HostIntegrationCoreApiSetup { echoAllTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg = args[0] as! AllTypes - let result = api.echoAllTypes(everything: everythingArg) + let result = api.echo(everythingArg) reply(wrapResult(result)) } } else { @@ -334,7 +334,7 @@ class HostIntegrationCoreApiSetup { echoAllNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg = args[0] as? AllNullableTypes - let result = api.echoAllNullableTypes(everything: everythingArg) + let result = api.echo(everythingArg) reply(wrapResult(result)) } } else { @@ -356,7 +356,7 @@ class HostIntegrationCoreApiSetup { echoIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anIntArg = args[0] as! Int32 - let result = api.echoInt(anInt: anIntArg) + let result = api.echo(anIntArg) reply(wrapResult(result)) } } else { @@ -368,7 +368,7 @@ class HostIntegrationCoreApiSetup { echoDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg = args[0] as! Double - let result = api.echoDouble(aDouble: aDoubleArg) + let result = api.echo(aDoubleArg) reply(wrapResult(result)) } } else { @@ -380,7 +380,7 @@ class HostIntegrationCoreApiSetup { echoBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg = args[0] as! Bool - let result = api.echoBool(aBool: aBoolArg) + let result = api.echo(aBoolArg) reply(wrapResult(result)) } } else { @@ -392,7 +392,7 @@ class HostIntegrationCoreApiSetup { echoStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String - let result = api.echoString(aString: aStringArg) + let result = api.echo(aStringArg) reply(wrapResult(result)) } } else { @@ -404,7 +404,7 @@ class HostIntegrationCoreApiSetup { echoUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aUint8ListArg = args[0] as! FlutterStandardTypedData - let result = api.echoUint8List(aUint8List: aUint8ListArg) + let result = api.echo(aUint8ListArg) reply(wrapResult(result)) } } else { @@ -416,7 +416,7 @@ class HostIntegrationCoreApiSetup { echoObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anObjectArg = args[0]! - let result = api.echoObject(anObject: anObjectArg) + let result = api.echo(anObjectArg) reply(wrapResult(result)) } } else { @@ -429,7 +429,7 @@ class HostIntegrationCoreApiSetup { extractNestedNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let wrapperArg = args[0] as! AllNullableTypesWrapper - let result = api.extractNestedNullableString(wrapper: wrapperArg) + let result = api.extractNestedNullableString(from: wrapperArg) reply(wrapResult(result)) } } else { @@ -442,7 +442,7 @@ class HostIntegrationCoreApiSetup { createNestedNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let nullableStringArg = args[0] as? String - let result = api.createNestedNullableString(nullableString: nullableStringArg) + let result = api.createNestedObject(with: nullableStringArg) reply(wrapResult(result)) } } else { @@ -456,7 +456,7 @@ class HostIntegrationCoreApiSetup { let aNullableBoolArg = args[0] as? Bool let aNullableIntArg = args[1] as? Int32 let aNullableStringArg = args[2] as? String - let result = api.sendMultipleNullableTypes(aNullableBool: aNullableBoolArg, aNullableInt: aNullableIntArg, aNullableString: aNullableStringArg) + let result = api.sendMultipleNullableTypes(aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) reply(wrapResult(result)) } } else { @@ -468,7 +468,7 @@ class HostIntegrationCoreApiSetup { echoNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableIntArg = args[0] as? Int32 - let result = api.echoNullableInt(aNullableInt: aNullableIntArg) + let result = api.echo(aNullableIntArg) reply(wrapResult(result)) } } else { @@ -480,7 +480,7 @@ class HostIntegrationCoreApiSetup { echoNullableDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableDoubleArg = args[0] as? Double - let result = api.echoNullableDouble(aNullableDouble: aNullableDoubleArg) + let result = api.echo(aNullableDoubleArg) reply(wrapResult(result)) } } else { @@ -492,7 +492,7 @@ class HostIntegrationCoreApiSetup { echoNullableBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableBoolArg = args[0] as? Bool - let result = api.echoNullableBool(aNullableBool: aNullableBoolArg) + let result = api.echo(aNullableBoolArg) reply(wrapResult(result)) } } else { @@ -504,7 +504,7 @@ class HostIntegrationCoreApiSetup { echoNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableStringArg = args[0] as? String - let result = api.echoNullableString(aNullableString: aNullableStringArg) + let result = api.echo(aNullableStringArg) reply(wrapResult(result)) } } else { @@ -516,7 +516,7 @@ class HostIntegrationCoreApiSetup { echoNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableUint8ListArg = args[0] as? FlutterStandardTypedData - let result = api.echoNullableUint8List(aNullableUint8List: aNullableUint8ListArg) + let result = api.echo(aNullableUint8ListArg) reply(wrapResult(result)) } } else { @@ -528,7 +528,7 @@ class HostIntegrationCoreApiSetup { echoNullableObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableObjectArg = args[0] - let result = api.echoNullableObject(aNullableObject: aNullableObjectArg) + let result = api.echo(aNullableObjectArg) reply(wrapResult(result)) } } else { @@ -552,7 +552,7 @@ class HostIntegrationCoreApiSetup { echoAsyncStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String - api.echoAsyncString(aString: aStringArg) { result in + api.echoAsync(aStringArg) { result in reply(wrapResult(result)) } } @@ -574,7 +574,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoAllTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg = args[0] as! AllTypes - api.callFlutterEchoAllTypes(everything: everythingArg) { result in + api.callFlutterEcho(everythingArg) { result in reply(wrapResult(result)) } } @@ -588,7 +588,7 @@ class HostIntegrationCoreApiSetup { let aNullableBoolArg = args[0] as? Bool let aNullableIntArg = args[1] as? Int32 let aNullableStringArg = args[2] as? String - api.callFlutterSendMultipleNullableTypes(aNullableBool: aNullableBoolArg, aNullableInt: aNullableIntArg, aNullableString: aNullableStringArg) { result in + api.callFlutterSendMultipleNullableTypes(aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) { result in reply(wrapResult(result)) } } @@ -600,7 +600,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg = args[0] as! Bool - api.callFlutterEchoBool(aBool: aBoolArg) { result in + api.callFlutterEcho(aBoolArg) { result in reply(wrapResult(result)) } } @@ -612,7 +612,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anIntArg = args[0] as! Int32 - api.callFlutterEchoInt(anInt: anIntArg) { result in + api.callFlutterEcho(anIntArg) { result in reply(wrapResult(result)) } } @@ -624,7 +624,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg = args[0] as! Double - api.callFlutterEchoDouble(aDouble: aDoubleArg) { result in + api.callFlutterEcho(aDoubleArg) { result in reply(wrapResult(result)) } } @@ -636,7 +636,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String - api.callFlutterEchoString(aString: aStringArg) { result in + api.callFlutterEcho(aStringArg) { result in reply(wrapResult(result)) } } @@ -648,7 +648,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as! FlutterStandardTypedData - api.callFlutterEchoUint8List(aList: aListArg) { result in + api.callFlutterEcho(aListArg) { result in reply(wrapResult(result)) } } @@ -660,7 +660,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as! [Any?] - api.callFlutterEchoList(aList: aListArg) { result in + api.callFlutterEcho(aListArg) { result in reply(wrapResult(result)) } } @@ -672,7 +672,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg = args[0] as! [String?: Any?] - api.callFlutterEchoMap(aMap: aMapArg) { result in + api.callFlutterEcho(aMapArg) { result in reply(wrapResult(result)) } } @@ -684,7 +684,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg = args[0] as? Bool - api.callFlutterEchoNullableBool(aBool: aBoolArg) { result in + api.callFlutterEchoNullable(aBoolArg) { result in reply(wrapResult(result)) } } @@ -696,7 +696,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anIntArg = args[0] as? Int32 - api.callFlutterEchoNullableInt(anInt: anIntArg) { result in + api.callFlutterEchoNullable(anIntArg) { result in reply(wrapResult(result)) } } @@ -708,7 +708,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg = args[0] as? Double - api.callFlutterEchoNullableDouble(aDouble: aDoubleArg) { result in + api.callFlutterEchoNullable(aDoubleArg) { result in reply(wrapResult(result)) } } @@ -720,7 +720,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as? String - api.callFlutterEchoNullableString(aString: aStringArg) { result in + api.callFlutterEchoNullable(aStringArg) { result in reply(wrapResult(result)) } } @@ -732,7 +732,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as? FlutterStandardTypedData - api.callFlutterEchoNullableUint8List(aList: aListArg) { result in + api.callFlutterEchoNullable(aListArg) { result in reply(wrapResult(result)) } } @@ -744,7 +744,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as? [Any?] - api.callFlutterEchoNullableList(aList: aListArg) { result in + api.callFlutterEchoNullable(aListArg) { result in reply(wrapResult(result)) } } @@ -756,7 +756,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg = args[0] as? [String?: Any?] - api.callFlutterEchoNullableMap(aMap: aMapArg) { result in + api.callFlutterEchoNullable(aMapArg) { result in reply(wrapResult(result)) } } @@ -832,7 +832,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed object, to test serialization and deserialization. - func echoAllTypes(everything everythingArg: AllTypes, completion: @escaping (AllTypes) -> Void) { + func echo(_ everythingArg: AllTypes, completion: @escaping (AllTypes) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoAllTypes", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([everythingArg] as [Any?]) { response in let result = response as! AllTypes @@ -840,7 +840,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed object, to test serialization and deserialization. - func echoAllNullableTypes(everything everythingArg: AllNullableTypes, completion: @escaping (AllNullableTypes) -> Void) { + func echoNullable(_ everythingArg: AllNullableTypes, completion: @escaping (AllNullableTypes) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoAllNullableTypes", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([everythingArg] as [Any?]) { response in let result = response as! AllNullableTypes @@ -850,7 +850,7 @@ class FlutterIntegrationCoreApi { /// Returns passed in arguments of multiple types. /// /// Tests multiple-arity FlutterApi handling. - func sendMultipleNullableTypes(aNullableBool aNullableBoolArg: Bool?, aNullableInt aNullableIntArg: Int32?, aNullableString aNullableStringArg: String?, completion: @escaping (AllNullableTypes) -> Void) { + func sendMultipleNullableTypes(aBool aNullableBoolArg: Bool?, anInt aNullableIntArg: Int32?, aString aNullableStringArg: String?, completion: @escaping (AllNullableTypes) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.sendMultipleNullableTypes", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aNullableBoolArg, aNullableIntArg, aNullableStringArg] as [Any?]) { response in let result = response as! AllNullableTypes @@ -858,7 +858,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed boolean, to test serialization and deserialization. - func echoBool(aBool aBoolArg: Bool, completion: @escaping (Bool) -> Void) { + func echo(_ aBoolArg: Bool, completion: @escaping (Bool) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoBool", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aBoolArg] as [Any?]) { response in let result = response as! Bool @@ -866,7 +866,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed int, to test serialization and deserialization. - func echoInt(anInt anIntArg: Int32, completion: @escaping (Int32) -> Void) { + func echo(_ anIntArg: Int32, completion: @escaping (Int32) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoInt", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anIntArg] as [Any?]) { response in let result = response as! Int32 @@ -874,7 +874,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed double, to test serialization and deserialization. - func echoDouble(aDouble aDoubleArg: Double, completion: @escaping (Double) -> Void) { + func echo(_ aDoubleArg: Double, completion: @escaping (Double) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoDouble", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aDoubleArg] as [Any?]) { response in let result = response as! Double @@ -882,7 +882,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed string, to test serialization and deserialization. - func echoString(aString aStringArg: String, completion: @escaping (String) -> Void) { + func echo(_ aStringArg: String, completion: @escaping (String) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoString", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in let result = response as! String @@ -890,7 +890,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed byte list, to test serialization and deserialization. - func echoUint8List(aList aListArg: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) { + func echo(_ aListArg: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoUint8List", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in let result = response as! FlutterStandardTypedData @@ -898,7 +898,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed list, to test serialization and deserialization. - func echoList(aList aListArg: [Any?], completion: @escaping ([Any?]) -> Void) { + func echo(_ aListArg: [Any?], completion: @escaping ([Any?]) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoList", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in let result = response as! [Any?] @@ -906,7 +906,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed map, to test serialization and deserialization. - func echoMap(aMap aMapArg: [String?: Any?], completion: @escaping ([String?: Any?]) -> Void) { + func echo(_ aMapArg: [String?: Any?], completion: @escaping ([String?: Any?]) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoMap", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aMapArg] as [Any?]) { response in let result = response as! [String?: Any?] @@ -914,7 +914,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed boolean, to test serialization and deserialization. - func echoNullableBool(aBool aBoolArg: Bool?, completion: @escaping (Bool?) -> Void) { + func echoNullable(_ aBoolArg: Bool?, completion: @escaping (Bool?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableBool", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aBoolArg] as [Any?]) { response in let result = response as? Bool @@ -922,7 +922,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed int, to test serialization and deserialization. - func echoNullableInt(anInt anIntArg: Int32?, completion: @escaping (Int32?) -> Void) { + func echoNullable(_ anIntArg: Int32?, completion: @escaping (Int32?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableInt", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anIntArg] as [Any?]) { response in let result = response as? Int32 @@ -930,7 +930,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed double, to test serialization and deserialization. - func echoNullableDouble(aDouble aDoubleArg: Double?, completion: @escaping (Double?) -> Void) { + func echoNullable(_ aDoubleArg: Double?, completion: @escaping (Double?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableDouble", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aDoubleArg] as [Any?]) { response in let result = response as? Double @@ -938,7 +938,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed string, to test serialization and deserialization. - func echoNullableString(aString aStringArg: String?, completion: @escaping (String?) -> Void) { + func echoNullable(_ aStringArg: String?, completion: @escaping (String?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableString", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in let result = response as? String @@ -946,7 +946,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed byte list, to test serialization and deserialization. - func echoNullableUint8List(aList aListArg: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) { + func echoNullable(_ aListArg: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableUint8List", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in let result = response as? FlutterStandardTypedData @@ -954,7 +954,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed list, to test serialization and deserialization. - func echoNullableList(aList aListArg: [Any?]?, completion: @escaping ([Any?]?) -> Void) { + func echoNullable(_ aListArg: [Any?]?, completion: @escaping ([Any?]?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableList", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in let result = response as? [Any?] @@ -962,7 +962,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed map, to test serialization and deserialization. - func echoNullableMap(aMap aMapArg: [String?: Any?]?, completion: @escaping ([String?: Any?]?) -> Void) { + func echoNullable(_ aMapArg: [String?: Any?]?, completion: @escaping ([String?: Any?]?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableMap", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aMapArg] as [Any?]) { response in let result = response as? [String?: Any?] diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift index 3515e4914b4c..edec42bc862f 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift @@ -26,11 +26,11 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func noop() { } - func echoAllTypes(everything: AllTypes) -> AllTypes { + func echo(_ everything: AllTypes) -> AllTypes { return everything } - func echoAllNullableTypes(everything: AllNullableTypes?) -> AllNullableTypes? { + func echo(_ everything: AllNullableTypes?) -> AllNullableTypes? { return everything } @@ -39,64 +39,64 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { // https://github.com/flutter/flutter/issues/112483 } - func echoInt(anInt: Int32) -> Int32 { + func echo(_ anInt: Int32) -> Int32 { return anInt } - func echoDouble(aDouble: Double) -> Double { + func echo(_ aDouble: Double) -> Double { return aDouble } - func echoBool(aBool: Bool) -> Bool { + func echo(_ aBool: Bool) -> Bool { return aBool } - func echoString(aString: String) -> String { + func echo(_ aString: String) -> String { return aString } - func echoUint8List(aUint8List: FlutterStandardTypedData) -> FlutterStandardTypedData { + func echo(_ aUint8List: FlutterStandardTypedData) -> FlutterStandardTypedData { return aUint8List } - func echoObject(anObject: Any) -> Any { + func echo(_ anObject: Any) -> Any { return anObject } - func extractNestedNullableString(wrapper: AllNullableTypesWrapper) -> String? { + func extractNestedNullableString(from wrapper: AllNullableTypesWrapper) -> String? { return wrapper.values.aNullableString; } - func createNestedNullableString(nullableString: String?) -> AllNullableTypesWrapper { + func createNestedObject(with nullableString: String?) -> AllNullableTypesWrapper { return AllNullableTypesWrapper(values: AllNullableTypes(aNullableString: nullableString)) } - func sendMultipleNullableTypes(aNullableBool: Bool?, aNullableInt: Int32?, aNullableString: String?) -> AllNullableTypes { + func sendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int32?, aString aNullableString: String?) -> AllNullableTypes { let someThings = AllNullableTypes(aNullableBool: aNullableBool, aNullableInt: aNullableInt, aNullableString: aNullableString) return someThings } - func echoNullableInt(aNullableInt: Int32?) -> Int32? { + func echo(_ aNullableInt: Int32?) -> Int32? { return aNullableInt } - func echoNullableDouble(aNullableDouble: Double?) -> Double? { + func echo(_ aNullableDouble: Double?) -> Double? { return aNullableDouble } - func echoNullableBool(aNullableBool: Bool?) -> Bool? { + func echo(_ aNullableBool: Bool?) -> Bool? { return aNullableBool } - func echoNullableString(aNullableString: String?) -> String? { + func echo(_ aNullableString: String?) -> String? { return aNullableString } - func echoNullableUint8List(aNullableUint8List: FlutterStandardTypedData?) -> FlutterStandardTypedData? { + func echo(_ aNullableUint8List: FlutterStandardTypedData?) -> FlutterStandardTypedData? { return aNullableUint8List } - func echoNullableObject(aNullableObject: Any?) -> Any? { + func echo(_ aNullableObject: Any?) -> Any? { return aNullableObject } @@ -104,7 +104,7 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion() } - func echoAsyncString(aString: String, completion: @escaping (String) -> Void) { + func echoAsync(_ aString: String, completion: @escaping (String) -> Void) { completion(aString) } @@ -114,78 +114,78 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoAllTypes(everything: AllTypes, completion: @escaping (AllTypes) -> Void) { - flutterAPI.echoAllTypes(everything: everything) { completion($0) } + func callFlutterEcho(_ everything: AllTypes, completion: @escaping (AllTypes) -> Void) { + flutterAPI.echo(everything) { completion($0) } } func callFlutterSendMultipleNullableTypes( - aNullableBool: Bool?, - aNullableInt: Int32?, - aNullableString: String?, + aBool aNullableBool: Bool?, + anInt aNullableInt: Int32?, + aString aNullableString: String?, completion: @escaping (AllNullableTypes) -> Void ) { flutterAPI.sendMultipleNullableTypes( - aNullableBool: aNullableBool, - aNullableInt: aNullableInt, - aNullableString: aNullableString + aBool: aNullableBool, + anInt: aNullableInt, + aString: aNullableString ) { completion($0) } } - func callFlutterEchoBool(aBool: Bool, completion: @escaping (Bool) -> Void) { - flutterAPI.echoBool(aBool: aBool) { completion($0) } + func callFlutterEcho(_ aBool: Bool, completion: @escaping (Bool) -> Void) { + flutterAPI.echo(aBool) { completion($0) } } - func callFlutterEchoInt(anInt: Int32, completion: @escaping (Int32) -> Void) { - flutterAPI.echoInt(anInt: anInt) { completion($0) } + func callFlutterEcho(_ anInt: Int32, completion: @escaping (Int32) -> Void) { + flutterAPI.echo(anInt) { completion($0) } } - func callFlutterEchoDouble(aDouble: Double, completion: @escaping (Double) -> Void) { - flutterAPI.echoDouble(aDouble: aDouble) { completion($0) } + func callFlutterEcho(_ aDouble: Double, completion: @escaping (Double) -> Void) { + flutterAPI.echo(aDouble) { completion($0) } } - func callFlutterEchoString(aString: String, completion: @escaping (String) -> Void) { - flutterAPI.echoString(aString: aString) { completion($0) } + func callFlutterEcho(_ aString: String, completion: @escaping (String) -> Void) { + flutterAPI.echo(aString) { completion($0) } } - func callFlutterEchoUint8List(aList: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) { - flutterAPI.echoUint8List(aList: aList) { completion($0) } + func callFlutterEcho(_ aList: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) { + flutterAPI.echo(aList) { completion($0) } } - func callFlutterEchoList(aList: [Any?], completion: @escaping ([Any?]) -> Void) { - flutterAPI.echoList(aList: aList) { completion($0) } + func callFlutterEcho(_ aList: [Any?], completion: @escaping ([Any?]) -> Void) { + flutterAPI.echo(aList) { completion($0) } } - func callFlutterEchoMap(aMap: [String? : Any?], completion: @escaping ([String? : Any?]) -> Void) { - flutterAPI.echoMap(aMap: aMap) { completion($0) } + func callFlutterEcho(_ aMap: [String? : Any?], completion: @escaping ([String? : Any?]) -> Void) { + flutterAPI.echo(aMap) { completion($0) } } - func callFlutterEchoNullableBool(aBool: Bool?, completion: @escaping (Bool?) -> Void) { - flutterAPI.echoNullableBool(aBool: aBool) { completion($0) } + func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Bool?) -> Void) { + flutterAPI.echoNullable(aBool) { completion($0) } } - func callFlutterEchoNullableInt(anInt: Int32?, completion: @escaping (Int32?) -> Void) { - flutterAPI.echoNullableInt(anInt: anInt) { completion($0) } + func callFlutterEchoNullable(_ anInt: Int32?, completion: @escaping (Int32?) -> Void) { + flutterAPI.echoNullable(anInt) { completion($0) } } - func callFlutterEchoNullableDouble(aDouble: Double?, completion: @escaping (Double?) -> Void) { - flutterAPI.echoNullableDouble(aDouble: aDouble) { completion($0) } + func callFlutterEchoNullable(_ aDouble: Double?, completion: @escaping (Double?) -> Void) { + flutterAPI.echoNullable(aDouble) { completion($0) } } - func callFlutterEchoNullableString(aString: String?, completion: @escaping (String?) -> Void) { - flutterAPI.echoNullableString(aString: aString) { completion($0) } + func callFlutterEchoNullable(_ aString: String?, completion: @escaping (String?) -> Void) { + flutterAPI.echoNullable(aString) { completion($0) } } - func callFlutterEchoNullableUint8List(aList: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) { - flutterAPI.echoNullableUint8List(aList: aList) { completion($0) } + func callFlutterEchoNullable(_ aList: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) { + flutterAPI.echoNullable(aList) { completion($0) } } - func callFlutterEchoNullableList(aList: [Any?]?, completion: @escaping ([Any?]?) -> Void) { - flutterAPI.echoNullableList(aList: aList) { completion($0) } + func callFlutterEchoNullable(_ aList: [Any?]?, completion: @escaping ([Any?]?) -> Void) { + flutterAPI.echoNullable(aList) { completion($0) } } - func callFlutterEchoNullableMap(aMap: [String? : Any?]?, completion: @escaping ([String? : Any?]?) -> Void) { - flutterAPI.echoNullableMap(aMap: aMap) { completion($0) } + func callFlutterEchoNullable(_ aMap: [String? : Any?]?, completion: @escaping ([String? : Any?]?) -> Void) { + flutterAPI.echoNullable(aMap) { completion($0) } } } diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift index d33a26ca364c..0f3391283b90 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v7.0.5), do not edit directly. +// Autogenerated from Pigeon (v7.1.0), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation @@ -238,65 +238,65 @@ protocol HostIntegrationCoreApi { /// test basic calling. func noop() /// Returns the passed object, to test serialization and deserialization. - func echoAllTypes(everything: AllTypes) -> AllTypes + func echo(_ everything: AllTypes) -> AllTypes /// Returns the passed object, to test serialization and deserialization. - func echoAllNullableTypes(everything: AllNullableTypes?) -> AllNullableTypes? + func echo(_ everything: AllNullableTypes?) -> AllNullableTypes? /// Returns an error, to test error handling. func throwError() /// Returns passed in int. - func echoInt(anInt: Int32) -> Int32 + func echo(_ anInt: Int32) -> Int32 /// Returns passed in double. - func echoDouble(aDouble: Double) -> Double + func echo(_ aDouble: Double) -> Double /// Returns the passed in boolean. - func echoBool(aBool: Bool) -> Bool + func echo(_ aBool: Bool) -> Bool /// Returns the passed in string. - func echoString(aString: String) -> String + func echo(_ aString: String) -> String /// Returns the passed in Uint8List. - func echoUint8List(aUint8List: FlutterStandardTypedData) -> FlutterStandardTypedData + func echo(_ aUint8List: FlutterStandardTypedData) -> FlutterStandardTypedData /// Returns the passed in generic Object. - func echoObject(anObject: Any) -> Any + func echo(_ anObject: Any) -> Any /// Returns the inner `aString` value from the wrapped object, to test /// sending of nested objects. - func extractNestedNullableString(wrapper: AllNullableTypesWrapper) -> String? + func extractNestedNullableString(from wrapper: AllNullableTypesWrapper) -> String? /// Returns the inner `aString` value from the wrapped object, to test /// sending of nested objects. - func createNestedNullableString(nullableString: String?) -> AllNullableTypesWrapper + func createNestedObject(with nullableString: String?) -> AllNullableTypesWrapper /// Returns passed in arguments of multiple types. - func sendMultipleNullableTypes(aNullableBool: Bool?, aNullableInt: Int32?, aNullableString: String?) -> AllNullableTypes + func sendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int32?, aString aNullableString: String?) -> AllNullableTypes /// Returns passed in int. - func echoNullableInt(aNullableInt: Int32?) -> Int32? + func echo(_ aNullableInt: Int32?) -> Int32? /// Returns passed in double. - func echoNullableDouble(aNullableDouble: Double?) -> Double? + func echo(_ aNullableDouble: Double?) -> Double? /// Returns the passed in boolean. - func echoNullableBool(aNullableBool: Bool?) -> Bool? + func echo(_ aNullableBool: Bool?) -> Bool? /// Returns the passed in string. - func echoNullableString(aNullableString: String?) -> String? + func echo(_ aNullableString: String?) -> String? /// Returns the passed in Uint8List. - func echoNullableUint8List(aNullableUint8List: FlutterStandardTypedData?) -> FlutterStandardTypedData? + func echo(_ aNullableUint8List: FlutterStandardTypedData?) -> FlutterStandardTypedData? /// Returns the passed in generic Object. - func echoNullableObject(aNullableObject: Any?) -> Any? + func echo(_ aNullableObject: Any?) -> Any? /// A no-op function taking no arguments and returning no value, to sanity /// test basic asynchronous calling. func noopAsync(completion: @escaping () -> Void) /// Returns the passed string asynchronously. - func echoAsyncString(aString: String, completion: @escaping (String) -> Void) + func echoAsync(_ aString: String, completion: @escaping (String) -> Void) func callFlutterNoop(completion: @escaping () -> Void) - func callFlutterEchoAllTypes(everything: AllTypes, completion: @escaping (AllTypes) -> Void) - func callFlutterSendMultipleNullableTypes(aNullableBool: Bool?, aNullableInt: Int32?, aNullableString: String?, completion: @escaping (AllNullableTypes) -> Void) - func callFlutterEchoBool(aBool: Bool, completion: @escaping (Bool) -> Void) - func callFlutterEchoInt(anInt: Int32, completion: @escaping (Int32) -> Void) - func callFlutterEchoDouble(aDouble: Double, completion: @escaping (Double) -> Void) - func callFlutterEchoString(aString: String, completion: @escaping (String) -> Void) - func callFlutterEchoUint8List(aList: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) - func callFlutterEchoList(aList: [Any?], completion: @escaping ([Any?]) -> Void) - func callFlutterEchoMap(aMap: [String?: Any?], completion: @escaping ([String?: Any?]) -> Void) - func callFlutterEchoNullableBool(aBool: Bool?, completion: @escaping (Bool?) -> Void) - func callFlutterEchoNullableInt(anInt: Int32?, completion: @escaping (Int32?) -> Void) - func callFlutterEchoNullableDouble(aDouble: Double?, completion: @escaping (Double?) -> Void) - func callFlutterEchoNullableString(aString: String?, completion: @escaping (String?) -> Void) - func callFlutterEchoNullableUint8List(aList: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) - func callFlutterEchoNullableList(aList: [Any?]?, completion: @escaping ([Any?]?) -> Void) - func callFlutterEchoNullableMap(aMap: [String?: Any?]?, completion: @escaping ([String?: Any?]?) -> Void) + func callFlutterEcho(_ everything: AllTypes, completion: @escaping (AllTypes) -> Void) + func callFlutterSendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int32?, aString aNullableString: String?, completion: @escaping (AllNullableTypes) -> Void) + func callFlutterEcho(_ aBool: Bool, completion: @escaping (Bool) -> Void) + func callFlutterEcho(_ anInt: Int32, completion: @escaping (Int32) -> Void) + func callFlutterEcho(_ aDouble: Double, completion: @escaping (Double) -> Void) + func callFlutterEcho(_ aString: String, completion: @escaping (String) -> Void) + func callFlutterEcho(_ aList: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) + func callFlutterEcho(_ aList: [Any?], completion: @escaping ([Any?]) -> Void) + func callFlutterEcho(_ aMap: [String?: Any?], completion: @escaping ([String?: Any?]) -> Void) + func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Bool?) -> Void) + func callFlutterEchoNullable(_ anInt: Int32?, completion: @escaping (Int32?) -> Void) + func callFlutterEchoNullable(_ aDouble: Double?, completion: @escaping (Double?) -> Void) + func callFlutterEchoNullable(_ aString: String?, completion: @escaping (String?) -> Void) + func callFlutterEchoNullable(_ aList: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) + func callFlutterEchoNullable(_ aList: [Any?]?, completion: @escaping ([Any?]?) -> Void) + func callFlutterEchoNullable(_ aMap: [String?: Any?]?, completion: @escaping ([String?: Any?]?) -> Void) } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. @@ -322,7 +322,7 @@ class HostIntegrationCoreApiSetup { echoAllTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg = args[0] as! AllTypes - let result = api.echoAllTypes(everything: everythingArg) + let result = api.echo(everythingArg) reply(wrapResult(result)) } } else { @@ -334,7 +334,7 @@ class HostIntegrationCoreApiSetup { echoAllNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg = args[0] as? AllNullableTypes - let result = api.echoAllNullableTypes(everything: everythingArg) + let result = api.echo(everythingArg) reply(wrapResult(result)) } } else { @@ -356,7 +356,7 @@ class HostIntegrationCoreApiSetup { echoIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anIntArg = args[0] as! Int32 - let result = api.echoInt(anInt: anIntArg) + let result = api.echo(anIntArg) reply(wrapResult(result)) } } else { @@ -368,7 +368,7 @@ class HostIntegrationCoreApiSetup { echoDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg = args[0] as! Double - let result = api.echoDouble(aDouble: aDoubleArg) + let result = api.echo(aDoubleArg) reply(wrapResult(result)) } } else { @@ -380,7 +380,7 @@ class HostIntegrationCoreApiSetup { echoBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg = args[0] as! Bool - let result = api.echoBool(aBool: aBoolArg) + let result = api.echo(aBoolArg) reply(wrapResult(result)) } } else { @@ -392,7 +392,7 @@ class HostIntegrationCoreApiSetup { echoStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String - let result = api.echoString(aString: aStringArg) + let result = api.echo(aStringArg) reply(wrapResult(result)) } } else { @@ -404,7 +404,7 @@ class HostIntegrationCoreApiSetup { echoUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aUint8ListArg = args[0] as! FlutterStandardTypedData - let result = api.echoUint8List(aUint8List: aUint8ListArg) + let result = api.echo(aUint8ListArg) reply(wrapResult(result)) } } else { @@ -416,7 +416,7 @@ class HostIntegrationCoreApiSetup { echoObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anObjectArg = args[0]! - let result = api.echoObject(anObject: anObjectArg) + let result = api.echo(anObjectArg) reply(wrapResult(result)) } } else { @@ -429,7 +429,7 @@ class HostIntegrationCoreApiSetup { extractNestedNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let wrapperArg = args[0] as! AllNullableTypesWrapper - let result = api.extractNestedNullableString(wrapper: wrapperArg) + let result = api.extractNestedNullableString(from: wrapperArg) reply(wrapResult(result)) } } else { @@ -442,7 +442,7 @@ class HostIntegrationCoreApiSetup { createNestedNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let nullableStringArg = args[0] as? String - let result = api.createNestedNullableString(nullableString: nullableStringArg) + let result = api.createNestedObject(with: nullableStringArg) reply(wrapResult(result)) } } else { @@ -456,7 +456,7 @@ class HostIntegrationCoreApiSetup { let aNullableBoolArg = args[0] as? Bool let aNullableIntArg = args[1] as? Int32 let aNullableStringArg = args[2] as? String - let result = api.sendMultipleNullableTypes(aNullableBool: aNullableBoolArg, aNullableInt: aNullableIntArg, aNullableString: aNullableStringArg) + let result = api.sendMultipleNullableTypes(aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) reply(wrapResult(result)) } } else { @@ -468,7 +468,7 @@ class HostIntegrationCoreApiSetup { echoNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableIntArg = args[0] as? Int32 - let result = api.echoNullableInt(aNullableInt: aNullableIntArg) + let result = api.echo(aNullableIntArg) reply(wrapResult(result)) } } else { @@ -480,7 +480,7 @@ class HostIntegrationCoreApiSetup { echoNullableDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableDoubleArg = args[0] as? Double - let result = api.echoNullableDouble(aNullableDouble: aNullableDoubleArg) + let result = api.echo(aNullableDoubleArg) reply(wrapResult(result)) } } else { @@ -492,7 +492,7 @@ class HostIntegrationCoreApiSetup { echoNullableBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableBoolArg = args[0] as? Bool - let result = api.echoNullableBool(aNullableBool: aNullableBoolArg) + let result = api.echo(aNullableBoolArg) reply(wrapResult(result)) } } else { @@ -504,7 +504,7 @@ class HostIntegrationCoreApiSetup { echoNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableStringArg = args[0] as? String - let result = api.echoNullableString(aNullableString: aNullableStringArg) + let result = api.echo(aNullableStringArg) reply(wrapResult(result)) } } else { @@ -516,7 +516,7 @@ class HostIntegrationCoreApiSetup { echoNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableUint8ListArg = args[0] as? FlutterStandardTypedData - let result = api.echoNullableUint8List(aNullableUint8List: aNullableUint8ListArg) + let result = api.echo(aNullableUint8ListArg) reply(wrapResult(result)) } } else { @@ -528,7 +528,7 @@ class HostIntegrationCoreApiSetup { echoNullableObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableObjectArg = args[0] - let result = api.echoNullableObject(aNullableObject: aNullableObjectArg) + let result = api.echo(aNullableObjectArg) reply(wrapResult(result)) } } else { @@ -552,7 +552,7 @@ class HostIntegrationCoreApiSetup { echoAsyncStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String - api.echoAsyncString(aString: aStringArg) { result in + api.echoAsync(aStringArg) { result in reply(wrapResult(result)) } } @@ -574,7 +574,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoAllTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg = args[0] as! AllTypes - api.callFlutterEchoAllTypes(everything: everythingArg) { result in + api.callFlutterEcho(everythingArg) { result in reply(wrapResult(result)) } } @@ -588,7 +588,7 @@ class HostIntegrationCoreApiSetup { let aNullableBoolArg = args[0] as? Bool let aNullableIntArg = args[1] as? Int32 let aNullableStringArg = args[2] as? String - api.callFlutterSendMultipleNullableTypes(aNullableBool: aNullableBoolArg, aNullableInt: aNullableIntArg, aNullableString: aNullableStringArg) { result in + api.callFlutterSendMultipleNullableTypes(aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) { result in reply(wrapResult(result)) } } @@ -600,7 +600,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg = args[0] as! Bool - api.callFlutterEchoBool(aBool: aBoolArg) { result in + api.callFlutterEcho(aBoolArg) { result in reply(wrapResult(result)) } } @@ -612,7 +612,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anIntArg = args[0] as! Int32 - api.callFlutterEchoInt(anInt: anIntArg) { result in + api.callFlutterEcho(anIntArg) { result in reply(wrapResult(result)) } } @@ -624,7 +624,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg = args[0] as! Double - api.callFlutterEchoDouble(aDouble: aDoubleArg) { result in + api.callFlutterEcho(aDoubleArg) { result in reply(wrapResult(result)) } } @@ -636,7 +636,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String - api.callFlutterEchoString(aString: aStringArg) { result in + api.callFlutterEcho(aStringArg) { result in reply(wrapResult(result)) } } @@ -648,7 +648,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as! FlutterStandardTypedData - api.callFlutterEchoUint8List(aList: aListArg) { result in + api.callFlutterEcho(aListArg) { result in reply(wrapResult(result)) } } @@ -660,7 +660,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as! [Any?] - api.callFlutterEchoList(aList: aListArg) { result in + api.callFlutterEcho(aListArg) { result in reply(wrapResult(result)) } } @@ -672,7 +672,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg = args[0] as! [String?: Any?] - api.callFlutterEchoMap(aMap: aMapArg) { result in + api.callFlutterEcho(aMapArg) { result in reply(wrapResult(result)) } } @@ -684,7 +684,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg = args[0] as? Bool - api.callFlutterEchoNullableBool(aBool: aBoolArg) { result in + api.callFlutterEchoNullable(aBoolArg) { result in reply(wrapResult(result)) } } @@ -696,7 +696,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anIntArg = args[0] as? Int32 - api.callFlutterEchoNullableInt(anInt: anIntArg) { result in + api.callFlutterEchoNullable(anIntArg) { result in reply(wrapResult(result)) } } @@ -708,7 +708,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg = args[0] as? Double - api.callFlutterEchoNullableDouble(aDouble: aDoubleArg) { result in + api.callFlutterEchoNullable(aDoubleArg) { result in reply(wrapResult(result)) } } @@ -720,7 +720,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as? String - api.callFlutterEchoNullableString(aString: aStringArg) { result in + api.callFlutterEchoNullable(aStringArg) { result in reply(wrapResult(result)) } } @@ -732,7 +732,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as? FlutterStandardTypedData - api.callFlutterEchoNullableUint8List(aList: aListArg) { result in + api.callFlutterEchoNullable(aListArg) { result in reply(wrapResult(result)) } } @@ -744,7 +744,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as? [Any?] - api.callFlutterEchoNullableList(aList: aListArg) { result in + api.callFlutterEchoNullable(aListArg) { result in reply(wrapResult(result)) } } @@ -756,7 +756,7 @@ class HostIntegrationCoreApiSetup { callFlutterEchoNullableMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg = args[0] as? [String?: Any?] - api.callFlutterEchoNullableMap(aMap: aMapArg) { result in + api.callFlutterEchoNullable(aMapArg) { result in reply(wrapResult(result)) } } @@ -832,7 +832,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed object, to test serialization and deserialization. - func echoAllTypes(everything everythingArg: AllTypes, completion: @escaping (AllTypes) -> Void) { + func echo(_ everythingArg: AllTypes, completion: @escaping (AllTypes) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoAllTypes", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([everythingArg] as [Any?]) { response in let result = response as! AllTypes @@ -840,7 +840,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed object, to test serialization and deserialization. - func echoAllNullableTypes(everything everythingArg: AllNullableTypes, completion: @escaping (AllNullableTypes) -> Void) { + func echoNullable(_ everythingArg: AllNullableTypes, completion: @escaping (AllNullableTypes) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoAllNullableTypes", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([everythingArg] as [Any?]) { response in let result = response as! AllNullableTypes @@ -850,7 +850,7 @@ class FlutterIntegrationCoreApi { /// Returns passed in arguments of multiple types. /// /// Tests multiple-arity FlutterApi handling. - func sendMultipleNullableTypes(aNullableBool aNullableBoolArg: Bool?, aNullableInt aNullableIntArg: Int32?, aNullableString aNullableStringArg: String?, completion: @escaping (AllNullableTypes) -> Void) { + func sendMultipleNullableTypes(aBool aNullableBoolArg: Bool?, anInt aNullableIntArg: Int32?, aString aNullableStringArg: String?, completion: @escaping (AllNullableTypes) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.sendMultipleNullableTypes", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aNullableBoolArg, aNullableIntArg, aNullableStringArg] as [Any?]) { response in let result = response as! AllNullableTypes @@ -858,7 +858,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed boolean, to test serialization and deserialization. - func echoBool(aBool aBoolArg: Bool, completion: @escaping (Bool) -> Void) { + func echo(_ aBoolArg: Bool, completion: @escaping (Bool) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoBool", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aBoolArg] as [Any?]) { response in let result = response as! Bool @@ -866,7 +866,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed int, to test serialization and deserialization. - func echoInt(anInt anIntArg: Int32, completion: @escaping (Int32) -> Void) { + func echo(_ anIntArg: Int32, completion: @escaping (Int32) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoInt", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anIntArg] as [Any?]) { response in let result = response as! Int32 @@ -874,7 +874,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed double, to test serialization and deserialization. - func echoDouble(aDouble aDoubleArg: Double, completion: @escaping (Double) -> Void) { + func echo(_ aDoubleArg: Double, completion: @escaping (Double) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoDouble", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aDoubleArg] as [Any?]) { response in let result = response as! Double @@ -882,7 +882,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed string, to test serialization and deserialization. - func echoString(aString aStringArg: String, completion: @escaping (String) -> Void) { + func echo(_ aStringArg: String, completion: @escaping (String) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoString", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in let result = response as! String @@ -890,7 +890,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed byte list, to test serialization and deserialization. - func echoUint8List(aList aListArg: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) { + func echo(_ aListArg: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoUint8List", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in let result = response as! FlutterStandardTypedData @@ -898,7 +898,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed list, to test serialization and deserialization. - func echoList(aList aListArg: [Any?], completion: @escaping ([Any?]) -> Void) { + func echo(_ aListArg: [Any?], completion: @escaping ([Any?]) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoList", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in let result = response as! [Any?] @@ -906,7 +906,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed map, to test serialization and deserialization. - func echoMap(aMap aMapArg: [String?: Any?], completion: @escaping ([String?: Any?]) -> Void) { + func echo(_ aMapArg: [String?: Any?], completion: @escaping ([String?: Any?]) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoMap", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aMapArg] as [Any?]) { response in let result = response as! [String?: Any?] @@ -914,7 +914,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed boolean, to test serialization and deserialization. - func echoNullableBool(aBool aBoolArg: Bool?, completion: @escaping (Bool?) -> Void) { + func echoNullable(_ aBoolArg: Bool?, completion: @escaping (Bool?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableBool", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aBoolArg] as [Any?]) { response in let result = response as? Bool @@ -922,7 +922,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed int, to test serialization and deserialization. - func echoNullableInt(anInt anIntArg: Int32?, completion: @escaping (Int32?) -> Void) { + func echoNullable(_ anIntArg: Int32?, completion: @escaping (Int32?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableInt", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anIntArg] as [Any?]) { response in let result = response as? Int32 @@ -930,7 +930,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed double, to test serialization and deserialization. - func echoNullableDouble(aDouble aDoubleArg: Double?, completion: @escaping (Double?) -> Void) { + func echoNullable(_ aDoubleArg: Double?, completion: @escaping (Double?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableDouble", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aDoubleArg] as [Any?]) { response in let result = response as? Double @@ -938,7 +938,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed string, to test serialization and deserialization. - func echoNullableString(aString aStringArg: String?, completion: @escaping (String?) -> Void) { + func echoNullable(_ aStringArg: String?, completion: @escaping (String?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableString", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in let result = response as? String @@ -946,7 +946,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed byte list, to test serialization and deserialization. - func echoNullableUint8List(aList aListArg: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) { + func echoNullable(_ aListArg: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableUint8List", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in let result = response as? FlutterStandardTypedData @@ -954,7 +954,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed list, to test serialization and deserialization. - func echoNullableList(aList aListArg: [Any?]?, completion: @escaping ([Any?]?) -> Void) { + func echoNullable(_ aListArg: [Any?]?, completion: @escaping ([Any?]?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableList", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in let result = response as? [Any?] @@ -962,7 +962,7 @@ class FlutterIntegrationCoreApi { } } /// Returns the passed map, to test serialization and deserialization. - func echoNullableMap(aMap aMapArg: [String?: Any?]?, completion: @escaping ([String?: Any?]?) -> Void) { + func echoNullable(_ aMapArg: [String?: Any?]?, completion: @escaping ([String?: Any?]?) -> Void) { let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.FlutterIntegrationCoreApi.echoNullableMap", binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aMapArg] as [Any?]) { response in let result = response as? [String?: Any?] diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift index 74614735afd4..4075a3d1bf76 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift @@ -26,11 +26,11 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { func noop() { } - func echoAllTypes(everything: AllTypes) -> AllTypes { + func echo(_ everything: AllTypes) -> AllTypes { return everything } - func echoAllNullableTypes(everything: AllNullableTypes?) -> AllNullableTypes? { + func echo(_ everything: AllNullableTypes?) -> AllNullableTypes? { return everything } @@ -39,64 +39,64 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { // https://github.com/flutter/flutter/issues/112483 } - func echoInt(anInt: Int32) -> Int32 { + func echo(_ anInt: Int32) -> Int32 { return anInt } - func echoDouble(aDouble: Double) -> Double { + func echo(_ aDouble: Double) -> Double { return aDouble } - func echoBool(aBool: Bool) -> Bool { + func echo(_ aBool: Bool) -> Bool { return aBool } - func echoString(aString: String) -> String { + func echo(_ aString: String) -> String { return aString } - func echoUint8List(aUint8List: FlutterStandardTypedData) -> FlutterStandardTypedData { + func echo(_ aUint8List: FlutterStandardTypedData) -> FlutterStandardTypedData { return aUint8List } - func echoObject(anObject: Any) -> Any { + func echo(_ anObject: Any) -> Any { return anObject } - func extractNestedNullableString(wrapper: AllNullableTypesWrapper) -> String? { + func extractNestedNullableString(from wrapper: AllNullableTypesWrapper) -> String? { return wrapper.values.aNullableString; } - func createNestedNullableString(nullableString: String?) -> AllNullableTypesWrapper { + func createNestedObject(with nullableString: String?) -> AllNullableTypesWrapper { return AllNullableTypesWrapper(values: AllNullableTypes(aNullableString: nullableString)) } - func sendMultipleNullableTypes(aNullableBool: Bool?, aNullableInt: Int32?, aNullableString: String?) -> AllNullableTypes { + func sendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int32?, aString aNullableString: String?) -> AllNullableTypes { let someThings = AllNullableTypes(aNullableBool: aNullableBool, aNullableInt: aNullableInt, aNullableString: aNullableString) return someThings } - func echoNullableInt(aNullableInt: Int32?) -> Int32? { + func echo(_ aNullableInt: Int32?) -> Int32? { return aNullableInt } - func echoNullableDouble(aNullableDouble: Double?) -> Double? { + func echo(_ aNullableDouble: Double?) -> Double? { return aNullableDouble } - func echoNullableBool(aNullableBool: Bool?) -> Bool? { + func echo(_ aNullableBool: Bool?) -> Bool? { return aNullableBool } - func echoNullableString(aNullableString: String?) -> String? { + func echo(_ aNullableString: String?) -> String? { return aNullableString } - func echoNullableUint8List(aNullableUint8List: FlutterStandardTypedData?) -> FlutterStandardTypedData? { + func echo(_ aNullableUint8List: FlutterStandardTypedData?) -> FlutterStandardTypedData? { return aNullableUint8List } - func echoNullableObject(aNullableObject: Any?) -> Any? { + func echo(_ aNullableObject: Any?) -> Any? { return aNullableObject } @@ -104,7 +104,7 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion() } - func echoAsyncString(aString: String, completion: @escaping (String) -> Void) { + func echoAsync(_ aString: String, completion: @escaping (String) -> Void) { completion(aString) } @@ -114,78 +114,78 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEchoAllTypes(everything: AllTypes, completion: @escaping (AllTypes) -> Void) { - flutterAPI.echoAllTypes(everything: everything) { completion($0) } + func callFlutterEcho(_ everything: AllTypes, completion: @escaping (AllTypes) -> Void) { + flutterAPI.echo(everything) { completion($0) } } func callFlutterSendMultipleNullableTypes( - aNullableBool: Bool?, - aNullableInt: Int32?, - aNullableString: String?, + aBool aNullableBool: Bool?, + anInt aNullableInt: Int32?, + aString aNullableString: String?, completion: @escaping (AllNullableTypes) -> Void ) { flutterAPI.sendMultipleNullableTypes( - aNullableBool: aNullableBool, - aNullableInt: aNullableInt, - aNullableString: aNullableString + aBool: aNullableBool, + anInt: aNullableInt, + aString: aNullableString ) { completion($0) } } - func callFlutterEchoBool(aBool: Bool, completion: @escaping (Bool) -> Void) { - flutterAPI.echoBool(aBool: aBool) { completion($0) } + func callFlutterEcho(_ aBool: Bool, completion: @escaping (Bool) -> Void) { + flutterAPI.echo(aBool) { completion($0) } } - func callFlutterEchoInt(anInt: Int32, completion: @escaping (Int32) -> Void) { - flutterAPI.echoInt(anInt: anInt) { completion($0) } + func callFlutterEcho(_ anInt: Int32, completion: @escaping (Int32) -> Void) { + flutterAPI.echo(anInt) { completion($0) } } - func callFlutterEchoDouble(aDouble: Double, completion: @escaping (Double) -> Void) { - flutterAPI.echoDouble(aDouble: aDouble) { completion($0) } + func callFlutterEcho(_ aDouble: Double, completion: @escaping (Double) -> Void) { + flutterAPI.echo(aDouble) { completion($0) } } - func callFlutterEchoString(aString: String, completion: @escaping (String) -> Void) { - flutterAPI.echoString(aString: aString) { completion($0) } + func callFlutterEcho(_ aString: String, completion: @escaping (String) -> Void) { + flutterAPI.echo(aString) { completion($0) } } - func callFlutterEchoUint8List(aList: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) { - flutterAPI.echoUint8List(aList: aList) { completion($0) } + func callFlutterEcho(_ aList: FlutterStandardTypedData, completion: @escaping (FlutterStandardTypedData) -> Void) { + flutterAPI.echo(aList) { completion($0) } } - func callFlutterEchoList(aList: [Any?], completion: @escaping ([Any?]) -> Void) { - flutterAPI.echoList(aList: aList) { completion($0) } + func callFlutterEcho(_ aList: [Any?], completion: @escaping ([Any?]) -> Void) { + flutterAPI.echo(aList) { completion($0) } } - func callFlutterEchoMap(aMap: [String? : Any?], completion: @escaping ([String? : Any?]) -> Void) { - flutterAPI.echoMap(aMap: aMap) { completion($0) } + func callFlutterEcho(_ aMap: [String? : Any?], completion: @escaping ([String? : Any?]) -> Void) { + flutterAPI.echo(aMap) { completion($0) } } - func callFlutterEchoNullableBool(aBool: Bool?, completion: @escaping (Bool?) -> Void) { - flutterAPI.echoNullableBool(aBool: aBool) { completion($0) } + func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Bool?) -> Void) { + flutterAPI.echoNullable(aBool) { completion($0) } } - func callFlutterEchoNullableInt(anInt: Int32?, completion: @escaping (Int32?) -> Void) { - flutterAPI.echoNullableInt(anInt: anInt) { completion($0) } + func callFlutterEchoNullable(_ anInt: Int32?, completion: @escaping (Int32?) -> Void) { + flutterAPI.echoNullable(anInt) { completion($0) } } - func callFlutterEchoNullableDouble(aDouble: Double?, completion: @escaping (Double?) -> Void) { - flutterAPI.echoNullableDouble(aDouble: aDouble) { completion($0) } + func callFlutterEchoNullable(_ aDouble: Double?, completion: @escaping (Double?) -> Void) { + flutterAPI.echoNullable(aDouble) { completion($0) } } - func callFlutterEchoNullableString(aString: String?, completion: @escaping (String?) -> Void) { - flutterAPI.echoNullableString(aString: aString) { completion($0) } + func callFlutterEchoNullable(_ aString: String?, completion: @escaping (String?) -> Void) { + flutterAPI.echoNullable(aString) { completion($0) } } - func callFlutterEchoNullableUint8List(aList: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) { - flutterAPI.echoNullableUint8List(aList: aList) { completion($0) } + func callFlutterEchoNullable(_ aList: FlutterStandardTypedData?, completion: @escaping (FlutterStandardTypedData?) -> Void) { + flutterAPI.echoNullable(aList) { completion($0) } } - func callFlutterEchoNullableList(aList: [Any?]?, completion: @escaping ([Any?]?) -> Void) { - flutterAPI.echoNullableList(aList: aList) { completion($0) } + func callFlutterEchoNullable(_ aList: [Any?]?, completion: @escaping ([Any?]?) -> Void) { + flutterAPI.echoNullable(aList) { completion($0) } } - func callFlutterEchoNullableMap(aMap: [String? : Any?]?, completion: @escaping ([String? : Any?]?) -> Void) { - flutterAPI.echoNullableMap(aMap: aMap) { completion($0) } + func callFlutterEchoNullable(_ aMap: [String? : Any?]?, completion: @escaping ([String? : Any?]?) -> Void) { + flutterAPI.echoNullable(aMap) { completion($0) } } } diff --git a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp index e1c00cc10022..94b9a49e0c54 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp +++ b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.cpp @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v7.0.5), do not edit directly. +// Autogenerated from Pigeon (v7.1.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #undef _HAS_EXCEPTIONS diff --git a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h index 68a2397261cd..51f6e21d6474 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h +++ b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // -// Autogenerated from Pigeon (v7.0.5), do not edit directly. +// Autogenerated from Pigeon (v7.1.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #ifndef PIGEON_CORE_TESTS_GEN_H_ diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index 537b5e9632ea..b779f0a3941d 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%3Apigeon -version: 7.0.5 # This must match the version in lib/generator_tools.dart +version: 7.1.0 # This must match the version in lib/generator_tools.dart environment: sdk: ">=2.12.0 <3.0.0" diff --git a/packages/pigeon/test/pigeon_lib_test.dart b/packages/pigeon/test/pigeon_lib_test.dart index 3d5c706bf410..fd71be54ad99 100644 --- a/packages/pigeon/test/pigeon_lib_test.dart +++ b/packages/pigeon/test/pigeon_lib_test.dart @@ -931,6 +931,52 @@ abstract class Api { expect(results.root.apis[0].methods[0].objcSelector, equals('foobar')); }); + test('custom swift valid function signature', () { + const String code = ''' +@HostApi() +abstract class Api { + @SwiftFunction('subtractValue(_:by:)') + void subtract(int x, int y); +} +'''; + final ParseResults results = parseSource(code); + expect(results.errors.length, 0); + expect(results.root.apis.length, 1); + expect(results.root.apis[0].methods.length, equals(1)); + expect(results.root.apis[0].methods[0].swiftFunction, + equals('subtractValue(_:by:)')); + }); + + test('custom swift invalid function signature', () { + const String code = ''' +@HostApi() +abstract class Api { + @SwiftFunction('subtractValue(_:by:error:)') + void subtract(int x, int y); +} +'''; + final ParseResults results = parseSource(code); + expect(results.errors.length, 1); + expect(results.errors[0].lineNumber, 3); + expect(results.errors[0].message, + contains('Invalid function signature, expected 2 arguments')); + }); + + test('custom swift function signature no arguments', () { + const String code = ''' +@HostApi() +abstract class Api { + @SwiftFunction('foobar()') + void initialize(); +} +'''; + final ParseResults results = parseSource(code); + expect(results.errors.length, 0); + expect(results.root.apis.length, 1); + expect(results.root.apis[0].methods.length, equals(1)); + expect(results.root.apis[0].methods[0].swiftFunction, equals('foobar()')); + }); + test('dart test has copyright', () { final Root root = Root(apis: [], classes: [], enums: []); const PigeonOptions options = PigeonOptions( diff --git a/packages/pigeon/test/swift_generator_test.dart b/packages/pigeon/test/swift_generator_test.dart index 1bf859461be1..1618216d1bbb 100644 --- a/packages/pigeon/test/swift_generator_test.dart +++ b/packages/pigeon/test/swift_generator_test.dart @@ -1142,4 +1142,96 @@ void main() { final String code = sink.toString(); expect(code, contains(': FlutterStandardReader ')); }); + + test('swift function signature', () { + final Root root = Root( + apis: [ + Api(name: 'Api', location: ApiLocation.host, methods: [ + Method( + name: 'set', + arguments: [ + NamedType( + type: const TypeDeclaration( + baseName: 'int', + isNullable: false, + ), + name: 'value', + ), + NamedType( + type: const TypeDeclaration( + baseName: 'String', + isNullable: false, + ), + name: 'key', + ), + ], + swiftFunction: 'setValue(_:for:)', + returnType: const TypeDeclaration.voidDeclaration(), + ) + ]) + ], + classes: [], + enums: [], + ); + final StringBuffer sink = StringBuffer(); + const SwiftOptions swiftOptions = SwiftOptions(); + const SwiftGenerator generator = SwiftGenerator(); + generator.generate(swiftOptions, root, sink); + final String code = sink.toString(); + expect(code, contains('func setValue(_ value: Int32, for key: String)')); + }); + + test('swift function signature with same name argument', () { + final Root root = Root( + apis: [ + Api(name: 'Api', location: ApiLocation.host, methods: [ + Method( + name: 'set', + arguments: [ + NamedType( + type: const TypeDeclaration( + baseName: 'String', + isNullable: false, + ), + name: 'key', + ), + ], + swiftFunction: 'removeValue(key:)', + returnType: const TypeDeclaration.voidDeclaration(), + ) + ]) + ], + classes: [], + enums: [], + ); + final StringBuffer sink = StringBuffer(); + const SwiftOptions swiftOptions = SwiftOptions(); + const SwiftGenerator generator = SwiftGenerator(); + generator.generate(swiftOptions, root, sink); + final String code = sink.toString(); + expect(code, contains('func removeValue(key: String)')); + }); + + test('swift function signature with no arguments', () { + final Root root = Root( + apis: [ + Api(name: 'Api', location: ApiLocation.host, methods: [ + Method( + name: 'clear', + arguments: [], + swiftFunction: 'removeAll()', + returnType: const TypeDeclaration.voidDeclaration(), + ) + ]) + ], + classes: [], + enums: [], + ); + final StringBuffer sink = StringBuffer(); + const SwiftOptions swiftOptions = SwiftOptions(); + const SwiftGenerator generator = SwiftGenerator(); + generator.generate(swiftOptions, root, sink); + final String code = sink.toString(); + expect(code, contains('func removeAll()')); + }); }