From a961d01031e182953e38ec421b1aa341db53a39e Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Thu, 28 Mar 2024 10:41:21 -0700 Subject: [PATCH 01/18] remove extra encode/decode --- .../java/io/flutter/plugins/Messages.java | 10 +- .../flutter/pigeon_example_app/Messages.g.kt | 34 +- .../example/app/ios/Runner/Messages.g.swift | 11 +- .../example/app/macos/Runner/messages.g.m | 18 +- .../example/app/windows/runner/messages.g.cpp | 10 +- packages/pigeon/lib/ast.dart | 2 +- packages/pigeon/lib/cpp_generator.dart | 55 +- packages/pigeon/lib/dart_generator.dart | 71 +-- packages/pigeon/lib/generator_tools.dart | 6 + packages/pigeon/lib/java_generator.dart | 11 +- packages/pigeon/lib/kotlin_generator.dart | 32 +- packages/pigeon/lib/objc_generator.dart | 32 +- packages/pigeon/lib/pigeon_lib.dart | 7 - packages/pigeon/lib/swift_generator.dart | 24 +- .../CoreTests.java | 140 ++--- .../ios/Classes/CoreTests.gen.m | 162 +++-- .../macos/Classes/CoreTests.gen.m | 162 +++-- .../lib/src/generated/core_tests.gen.dart | 21 +- .../lib/src/generated/message.gen.dart | 6 +- .../src/generated/non_null_fields.gen.dart | 4 +- .../lib/src/generated/null_fields.gen.dart | 6 +- .../com/example/test_plugin/CoreTests.gen.kt | 556 +++++++++--------- .../com/example/test_plugin/TestPlugin.kt | 2 +- .../ios/Classes/CoreTests.gen.swift | 147 +++-- .../macos/Classes/CoreTests.gen.swift | 147 +++-- .../windows/pigeon/core_tests.gen.cpp | 126 ++-- 26 files changed, 892 insertions(+), 910 deletions(-) diff --git a/packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java b/packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java index 1167e53d5fb..d0b98f2d0cd 100644 --- a/packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java +++ b/packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java @@ -186,15 +186,15 @@ ArrayList toList() { return toListResult; } - static @NonNull MessageData fromList(@NonNull ArrayList list) { + static @NonNull MessageData fromList(@NonNull ArrayList __pigeon_list) { MessageData pigeonResult = new MessageData(); - Object name = list.get(0); + Object name = __pigeon_list.get(0); pigeonResult.setName((String) name); - Object description = list.get(1); + Object description = __pigeon_list.get(1); pigeonResult.setDescription((String) description); - Object code = list.get(2); + Object code = __pigeon_list.get(2); pigeonResult.setCode(Code.values()[(int) code]); - Object data = list.get(3); + Object data = __pigeon_list.get(3); pigeonResult.setData((Map) data); return pigeonResult; } diff --git a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt index 00e48beba91..4d3d38220cb 100644 --- a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt +++ b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt @@ -65,11 +65,11 @@ data class MessageData( ) { companion object { @Suppress("UNCHECKED_CAST") - fun fromList(list: List): MessageData { - val name = list[0] as String? - val description = list[1] as String? - val code = Code.ofRaw(list[2] as Int)!! - val data = list[3] as Map + fun fromList(__pigeon_list: List): MessageData { + val name = __pigeon_list[0] as String? + val description = __pigeon_list[1] as String? + val code = Code.ofRaw(__pigeon_list[2] as Int)!! + val data = __pigeon_list[3] as Map return MessageData(name, description, code, data) } } @@ -128,12 +128,12 @@ interface ExampleHostApi { codec) if (api != null) { channel.setMessageHandler { _, reply -> - var wrapped: List - try { - wrapped = listOf(api.getHostLanguage()) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.getHostLanguage()) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -151,12 +151,12 @@ interface ExampleHostApi { val args = message as List val aArg = args[0].let { if (it is Int) it.toLong() else it as Long } val bArg = args[1].let { if (it is Int) it.toLong() else it as Long } - var wrapped: List - try { - wrapped = listOf(api.add(aArg, bArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.add(aArg, bArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { diff --git a/packages/pigeon/example/app/ios/Runner/Messages.g.swift b/packages/pigeon/example/app/ios/Runner/Messages.g.swift index 3acc38b2cb6..e332bd1530a 100644 --- a/packages/pigeon/example/app/ios/Runner/Messages.g.swift +++ b/packages/pigeon/example/app/ios/Runner/Messages.g.swift @@ -60,11 +60,12 @@ struct MessageData { var code: Code var data: [String?: String?] - static func fromList(_ list: [Any?]) -> MessageData? { - let name: String? = nilOrValue(list[0]) - let description: String? = nilOrValue(list[1]) - let code = Code(rawValue: list[2] as! Int)! - let data = list[3] as! [String?: String?] + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> MessageData? { + let name: String? = nilOrValue(__pigeon_list[0]) + let description: String? = nilOrValue(__pigeon_list[1]) + let code = Code(rawValue: __pigeon_list[2] as! Int)! + let data = __pigeon_list[3] as! [String?: String?] return MessageData( name: name, diff --git a/packages/pigeon/example/app/macos/Runner/messages.g.m b/packages/pigeon/example/app/macos/Runner/messages.g.m index 90983b10cd2..c155efa03b2 100644 --- a/packages/pigeon/example/app/macos/Runner/messages.g.m +++ b/packages/pigeon/example/app/macos/Runner/messages.g.m @@ -50,8 +50,8 @@ - (instancetype)initWithValue:(PGNCode)value { @end @interface PGNMessageData () -+ (PGNMessageData *)fromList:(NSArray *)list; -+ (nullable PGNMessageData *)nullableFromList:(NSArray *)list; ++ (PGNMessageData *)fromList:(NSArray *)__pigeon_list; ++ (nullable PGNMessageData *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @@ -67,16 +67,16 @@ + (instancetype)makeWithName:(nullable NSString *)name pigeonResult.data = data; return pigeonResult; } -+ (PGNMessageData *)fromList:(NSArray *)list { ++ (PGNMessageData *)fromList:(NSArray *)__pigeon_list { PGNMessageData *pigeonResult = [[PGNMessageData alloc] init]; - pigeonResult.name = GetNullableObjectAtIndex(list, 0); - pigeonResult.description = GetNullableObjectAtIndex(list, 1); - pigeonResult.code = [GetNullableObjectAtIndex(list, 2) integerValue]; - pigeonResult.data = GetNullableObjectAtIndex(list, 3); + pigeonResult.name = GetNullableObjectAtIndex(__pigeon_list, 0); + pigeonResult.description = GetNullableObjectAtIndex(__pigeon_list, 1); + pigeonResult.code = [GetNullableObjectAtIndex(__pigeon_list, 2) integerValue]; + pigeonResult.data = GetNullableObjectAtIndex(__pigeon_list, 3); return pigeonResult; } -+ (nullable PGNMessageData *)nullableFromList:(NSArray *)list { - return (list) ? [PGNMessageData fromList:list] : nil; ++ (nullable PGNMessageData *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [PGNMessageData fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ diff --git a/packages/pigeon/example/app/windows/runner/messages.g.cpp b/packages/pigeon/example/app/windows/runner/messages.g.cpp index 97d11da0bdf..8ef7584c4e5 100644 --- a/packages/pigeon/example/app/windows/runner/messages.g.cpp +++ b/packages/pigeon/example/app/windows/runner/messages.g.cpp @@ -87,14 +87,14 @@ EncodableList MessageData::ToEncodableList() const { return list; } -MessageData MessageData::FromEncodableList(const EncodableList& list) { - MessageData decoded((Code)(std::get(list[2])), - std::get(list[3])); - auto& encodable_name = list[0]; +MessageData MessageData::FromEncodableList(const EncodableList& __pigeon_list) { + MessageData decoded((Code)(std::get(__pigeon_list[2])), + std::get(__pigeon_list[3])); + auto& encodable_name = __pigeon_list[0]; if (!encodable_name.IsNull()) { decoded.set_name(std::get(encodable_name)); } - auto& encodable_description = list[1]; + auto& encodable_description = __pigeon_list[1]; if (!encodable_description.IsNull()) { decoded.set_description(std::get(encodable_description)); } diff --git a/packages/pigeon/lib/ast.dart b/packages/pigeon/lib/ast.dart index 08eef8cc6c7..d7bc2139729 100644 --- a/packages/pigeon/lib/ast.dart +++ b/packages/pigeon/lib/ast.dart @@ -518,7 +518,7 @@ class TypeDeclaration { @override String toString() { final String typeArgumentsStr = - typeArguments.isEmpty ? '' : 'typeArguments:$typeArguments'; + typeArguments.isEmpty ? '' : ' typeArguments:$typeArguments'; return '(TypeDeclaration baseName:$baseName isNullable:$isNullable$typeArgumentsStr isEnum:$isEnum isClass:$isClass isProxyApi:$isProxyApi)'; } } diff --git a/packages/pigeon/lib/cpp_generator.dart b/packages/pigeon/lib/cpp_generator.dart index 5e993137b9f..b14ee3396fa 100644 --- a/packages/pigeon/lib/cpp_generator.dart +++ b/packages/pigeon/lib/cpp_generator.dart @@ -773,8 +773,11 @@ class CppSourceGenerator extends StructuredGenerator { final HostDatatype hostDatatype = getFieldHostDatatype(field, _shortBaseCppTypeForBuiltinDartType); final String encodableValue = _wrappedHostApiArgumentExpression( - root, _makeInstanceVariableName(field), field.type, hostDatatype, - preSerializeClasses: true); + root, + _makeInstanceVariableName(field), + field.type, + hostDatatype, + ); indent.writeln('list.push_back($encodableValue);'); } indent.writeln('return list;'); @@ -801,21 +804,15 @@ class CppSourceGenerator extends StructuredGenerator { } else { final HostDatatype hostDatatype = getFieldHostDatatype(field, _shortBaseCppTypeForBuiltinDartType); - if (!hostDatatype.isBuiltin && - root.classes - .map((Class x) => x.name) - .contains(field.type.baseName)) { - return '${hostDatatype.datatype}::FromEncodableList(std::get($encodable))'; - } else { - return 'std::get<${hostDatatype.datatype}>($encodable)'; - } + return 'std::get<${hostDatatype.datatype}>($encodable)'; } } _writeFunctionDefinition(indent, 'FromEncodableList', scope: classDefinition.name, returnType: classDefinition.name, - parameters: ['const EncodableList& list'], body: () { + parameters: ['const EncodableList& ${varNamePrefix}list'], + body: () { const String instanceVariable = 'decoded'; final Iterable<_IndexedField> indexedFields = indexMap( getFieldsInSerializationOrder(classDefinition), @@ -827,8 +824,8 @@ class CppSourceGenerator extends StructuredGenerator { // Non-nullable fields must be set via the constructor. String constructorArgs = nonNullableFields - .map((_IndexedField param) => - getValueExpression(param.field, 'list[${param.index}]')) + .map((_IndexedField param) => getValueExpression( + param.field, '${varNamePrefix}list[${param.index}]')) .join(',\n\t'); if (constructorArgs.isNotEmpty) { constructorArgs = '(\n\t$constructorArgs)'; @@ -844,7 +841,8 @@ class CppSourceGenerator extends StructuredGenerator { final String setterName = _makeSetterName(field); final String encodableFieldName = '${_encodablePrefix}_${_makeVariableName(field)}'; - indent.writeln('auto& $encodableFieldName = list[${entry.index}];'); + indent.writeln( + 'auto& $encodableFieldName = ${varNamePrefix}list[${entry.index}];'); final String valueExpression = getValueExpression(field, encodableFieldName); @@ -921,8 +919,11 @@ class CppSourceGenerator extends StructuredGenerator { indent.addScoped('EncodableValue(EncodableList{', '});', () { for (final _HostNamedType param in hostParameters) { final String encodedArgument = _wrappedHostApiArgumentExpression( - root, param.name, param.originalType, param.hostType, - preSerializeClasses: false); + root, + param.name, + param.originalType, + param.hostType, + ); indent.writeln('$encodedArgument,'); } }); @@ -1402,22 +1403,18 @@ ${prefix}reply(EncodableValue(std::move(wrapped)));'''; /// encodable lists rather than CustomEncodableValues; see /// https://github.com/flutter/flutter/issues/119351 for why this is currently /// needed. - String _wrappedHostApiArgumentExpression(Root root, String variableName, - TypeDeclaration dartType, HostDatatype hostType, - {required bool preSerializeClasses}) { + String _wrappedHostApiArgumentExpression( + Root root, + String variableName, + TypeDeclaration dartType, + HostDatatype hostType, + ) { final String encodableValue; if (!hostType.isBuiltin && root.classes.any((Class c) => c.name == dartType.baseName)) { - if (preSerializeClasses) { - final String operator = - hostType.isNullable || _isPointerField(hostType) ? '->' : '.'; - encodableValue = - 'EncodableValue($variableName${operator}ToEncodableList())'; - } else { - final String nonNullValue = - hostType.isNullable ? '*$variableName' : variableName; - encodableValue = 'CustomEncodableValue($nonNullValue)'; - } + final String nonNullValue = + hostType.isNullable ? '*$variableName' : variableName; + encodableValue = 'CustomEncodableValue($nonNullValue)'; } else if (!hostType.isBuiltin && root.enums.any((Enum e) => e.name == dartType.baseName)) { final String nonNullValue = diff --git a/packages/pigeon/lib/dart_generator.dart b/packages/pigeon/lib/dart_generator.dart index 40ce7a6e5df..1de799a6198 100644 --- a/packages/pigeon/lib/dart_generator.dart +++ b/packages/pigeon/lib/dart_generator.dart @@ -15,12 +15,6 @@ import 'generator_tools.dart'; /// Documentation comment open symbol. const String _docCommentPrefix = '///'; -/// Prefix for all local variables in host API methods. -/// -/// This lowers the chances of variable name collisions with -/// user defined parameters. -const String _varNamePrefix = '__pigeon_'; - /// Name of the `InstanceManager` variable for a ProxyApi class; const String _instanceManagerVarName = '${classMemberNamePrefix}instanceManager'; @@ -229,7 +223,7 @@ class DartGenerator extends StructuredGenerator { final String conditional = field.type.isNullable ? '?' : ''; if (field.type.isClass) { indent.writeln( - '${field.name}$conditional.encode(),', + '${field.name},', ); } else if (field.type.isEnum) { indent.writeln( @@ -258,8 +252,7 @@ class DartGenerator extends StructuredGenerator { final String castCall = _makeGenericCastCall(field.type); final String nullableTag = field.type.isNullable ? '?' : ''; if (field.type.isClass) { - final String nonNullValue = - '${field.type.baseName}.decode($resultAt! as List)'; + final String nonNullValue = '$resultAt! as ${field.type.baseName}'; if (field.type.isNullable) { indent.format(''' $resultAt != null @@ -423,8 +416,8 @@ $resultAt != null /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. ${api.name}({BinaryMessenger? binaryMessenger}) -\t\t: ${_varNamePrefix}binaryMessenger = binaryMessenger; -final BinaryMessenger? ${_varNamePrefix}binaryMessenger; +\t\t: ${varNamePrefix}binaryMessenger = binaryMessenger; +final BinaryMessenger? ${varNamePrefix}binaryMessenger; '''); indent.writeln( @@ -502,7 +495,7 @@ final BinaryMessenger? ${_varNamePrefix}binaryMessenger; // Each API has a private codec instance used by every host method, // constructor, or non-static field. - final String codecInstanceName = '${_varNamePrefix}codec${api.name}'; + final String codecInstanceName = '${varNamePrefix}codec${api.name}'; // AST class used by code_builder to generate the code. final cb.Class proxyApi = cb.Class( @@ -782,17 +775,17 @@ PlatformException _createConnectionError(String channelName) { } indent - .writeln("const String ${_varNamePrefix}channelName = '$channelName';"); + .writeln("const String ${varNamePrefix}channelName = '$channelName';"); indent.writeScoped( - 'final BasicMessageChannel ${_varNamePrefix}channel = BasicMessageChannel(', + 'final BasicMessageChannel ${varNamePrefix}channel = BasicMessageChannel(', ');', () { - indent.writeln('${_varNamePrefix}channelName,'); + indent.writeln('${varNamePrefix}channelName,'); indent.writeln('$_pigeonChannelCodec,'); - indent.writeln('binaryMessenger: ${_varNamePrefix}binaryMessenger,'); + indent.writeln('binaryMessenger: ${varNamePrefix}binaryMessenger,'); }); final String returnTypeName = _makeGenericTypeArguments(returnType); final String genericCastCall = _makeGenericCastCall(returnType); - const String accessor = '${_varNamePrefix}replyList[0]'; + const String accessor = '${varNamePrefix}replyList[0]'; // Avoid warnings from pointlessly casting to `Object?`. final String nullablyTypedAccessor = returnTypeName == 'Object' ? accessor @@ -815,22 +808,22 @@ PlatformException _createConnectionError(String channelName) { returnStatement = '$returnStatement;'; indent.format(''' -final List? ${_varNamePrefix}replyList = -\t\tawait ${_varNamePrefix}channel.send($sendArgument) as List?; -if (${_varNamePrefix}replyList == null) { -\tthrow _createConnectionError(${_varNamePrefix}channelName); -} else if (${_varNamePrefix}replyList.length > 1) { +final List? ${varNamePrefix}replyList = +\t\tawait ${varNamePrefix}channel.send($sendArgument) as List?; +if (${varNamePrefix}replyList == null) { +\tthrow _createConnectionError(${varNamePrefix}channelName); +} else if (${varNamePrefix}replyList.length > 1) { \tthrow PlatformException( -\t\tcode: ${_varNamePrefix}replyList[0]! as String, -\t\tmessage: ${_varNamePrefix}replyList[1] as String?, -\t\tdetails: ${_varNamePrefix}replyList[2], +\t\tcode: ${varNamePrefix}replyList[0]! as String, +\t\tmessage: ${varNamePrefix}replyList[1] as String?, +\t\tdetails: ${varNamePrefix}replyList[2], \t);'''); // On iOS we can return nil from functions to accommodate error // handling. Returning a nil value and not returning an error is an // exception. if (!returnType.isNullable && !returnType.isVoid) { indent.format(''' -} else if (${_varNamePrefix}replyList[0] == null) { +} else if (${varNamePrefix}replyList[0] == null) { \tthrow PlatformException( \t\tcode: 'null-error', \t\tmessage: 'Host platform returned null value for non-null return value.', @@ -858,7 +851,7 @@ if (${_varNamePrefix}replyList == null) { indent.write(''); indent.addScoped('{', '}', () { indent.writeln( - 'final BasicMessageChannel ${_varNamePrefix}channel = BasicMessageChannel(', + 'final BasicMessageChannel ${varNamePrefix}channel = BasicMessageChannel(', ); indent.nest(2, () { indent.writeln("'$channelName', $_pigeonChannelCodec,"); @@ -867,8 +860,8 @@ if (${_varNamePrefix}replyList == null) { ); }); final String messageHandlerSetterWithOpeningParentheses = isMockHandler - ? '_testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(${_varNamePrefix}channel, ' - : '${_varNamePrefix}channel.setMessageHandler('; + ? '_testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(${varNamePrefix}channel, ' + : '${varNamePrefix}channel.setMessageHandler('; indent.write('if ($nullHandlerExpression) '); indent.addScoped('{', '}', () { indent.writeln('${messageHandlerSetterWithOpeningParentheses}null);'); @@ -1064,7 +1057,7 @@ if (${_varNamePrefix}replyList == null) { channelName: channelName, parameters: [ Parameter( - name: '${_varNamePrefix}instanceIdentifier', + name: '${varNamePrefix}instanceIdentifier', type: const TypeDeclaration( baseName: 'int', isNullable: false, @@ -1083,12 +1076,12 @@ if (${_varNamePrefix}replyList == null) { builder.statements.addAll([ const cb.Code( - 'final int ${_varNamePrefix}instanceIdentifier = $_instanceManagerVarName.addDartCreatedInstance(this);', + 'final int ${varNamePrefix}instanceIdentifier = $_instanceManagerVarName.addDartCreatedInstance(this);', ), cb.Code('final $codecName $_pigeonChannelCodec =\n' ' $codecInstanceName;'), cb.Code( - 'final BinaryMessenger? ${_varNamePrefix}binaryMessenger = ${binaryMessengerParameter.name};', + 'final BinaryMessenger? ${varNamePrefix}binaryMessenger = ${binaryMessengerParameter.name};', ), const cb.Code('() async {'), cb.Code(messageCallSink.toString()), @@ -1341,7 +1334,7 @@ if (${_varNamePrefix}replyList == null) { field.documentationComments, _docCommentSpec, )) - ..assignment = cb.Code('$_varNamePrefix${field.name}()'), + ..assignment = cb.Code('$varNamePrefix${field.name}()'), ); } } @@ -1564,11 +1557,11 @@ if (${_varNamePrefix}replyList == null) { yield cb.Method( (cb.MethodBuilder builder) { final String type = _addGenericTypesNullable(field.type); - const String instanceName = '${_varNamePrefix}instance'; + const String instanceName = '${varNamePrefix}instance'; const String identifierInstanceName = - '${_varNamePrefix}instanceIdentifier'; + '${varNamePrefix}instanceIdentifier'; builder - ..name = '$_varNamePrefix${field.name}' + ..name = '$varNamePrefix${field.name}' ..static = field.isStatic ..returns = cb.refer(type) ..body = cb.Block( @@ -1611,7 +1604,7 @@ if (${_varNamePrefix}replyList == null) { cb.Code('final $codecName $_pigeonChannelCodec =\n' ' $codecInstanceName;'), const cb.Code( - 'final BinaryMessenger? ${_varNamePrefix}binaryMessenger = ${classMemberNamePrefix}binaryMessenger;', + 'final BinaryMessenger? ${varNamePrefix}binaryMessenger = ${classMemberNamePrefix}binaryMessenger;', ), const cb.Code( 'final int $identifierInstanceName = $_instanceManagerVarName.addDartCreatedInstance($instanceName);', @@ -1624,7 +1617,7 @@ if (${_varNamePrefix}replyList == null) { 'final $codecName $_pigeonChannelCodec = $codecName($instanceManagerClassName.instance);', ), const cb.Code( - 'final BinaryMessenger ${_varNamePrefix}binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger;', + 'final BinaryMessenger ${varNamePrefix}binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger;', ), const cb.Code( 'final int $identifierInstanceName = $instanceManagerClassName.instance.addDartCreatedInstance($instanceName);', @@ -1724,7 +1717,7 @@ if (${_varNamePrefix}replyList == null) { 'final $codecName $_pigeonChannelCodec = $codecName($_instanceManagerVarName ?? $instanceManagerClassName.instance);', ), const cb.Code( - 'final BinaryMessenger? ${_varNamePrefix}binaryMessenger = ${classMemberNamePrefix}binaryMessenger;', + 'final BinaryMessenger? ${varNamePrefix}binaryMessenger = ${classMemberNamePrefix}binaryMessenger;', ), cb.Code(messageCallSink.toString()), ]); diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index 4540b5d04d8..58fcf48d897 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -15,6 +15,12 @@ import 'ast.dart'; /// This must match the version in pubspec.yaml. const String pigeonVersion = '17.3.0'; +/// Prefix for all local variables in methods. +/// +/// This lowers the chances of variable name collisions with +/// user defined parameters. +const String varNamePrefix = '__pigeon_'; + /// Read all the content from [stdin] to a String. String readStdin() { final List bytes = []; diff --git a/packages/pigeon/lib/java_generator.dart b/packages/pigeon/lib/java_generator.dart index 0758071e943..10dff1ba790 100644 --- a/packages/pigeon/lib/java_generator.dart +++ b/packages/pigeon/lib/java_generator.dart @@ -341,9 +341,7 @@ class JavaGenerator extends StructuredGenerator { in getFieldsInSerializationOrder(classDefinition)) { String toWriteValue = ''; final String fieldName = field.name; - if (field.type.isClass) { - toWriteValue = '($fieldName == null) ? null : $fieldName.toList()'; - } else if (field.type.isEnum) { + if (field.type.isEnum) { toWriteValue = '$fieldName == null ? null : $fieldName.index'; } else { toWriteValue = field.name; @@ -364,7 +362,7 @@ class JavaGenerator extends StructuredGenerator { }) { indent.newln(); indent.write( - 'static @NonNull ${classDefinition.name} fromList(@NonNull ArrayList list) '); + 'static @NonNull ${classDefinition.name} fromList(@NonNull ArrayList ${varNamePrefix}list) '); indent.addScoped('{', '}', () { const String result = 'pigeonResult'; indent.writeln( @@ -373,7 +371,8 @@ class JavaGenerator extends StructuredGenerator { (int index, final NamedType field) { final String fieldVariable = field.name; final String setter = _makeSetter(field); - indent.writeln('Object $fieldVariable = list.get($index);'); + indent.writeln( + 'Object $fieldVariable = ${varNamePrefix}list.get($index);'); if (field.type.isEnum) { indent.writeln( '$result.$setter(${_intToEnum(fieldVariable, field.type.baseName, field.type.isNullable)});'); @@ -1107,8 +1106,6 @@ String _castObject(NamedType field, String varName) { field, (TypeDeclaration x) => _javaTypeForBuiltinDartType(x)); if (field.type.baseName == 'int') { return '($varName == null) ? null : (($varName instanceof Integer) ? (Integer) $varName : (${hostDatatype.datatype}) $varName)'; - } else if (field.type.isClass) { - return '($varName == null) ? null : ${hostDatatype.datatype}.fromList((ArrayList) $varName)'; } else { return _cast(varName, javaType: hostDatatype.datatype); } diff --git a/packages/pigeon/lib/kotlin_generator.dart b/packages/pigeon/lib/kotlin_generator.dart index 39697fa3242..1895aafdd21 100644 --- a/packages/pigeon/lib/kotlin_generator.dart +++ b/packages/pigeon/lib/kotlin_generator.dart @@ -224,9 +224,7 @@ class KotlinGenerator extends StructuredGenerator { String toWriteValue = ''; final String fieldName = field.name; final String safeCall = field.type.isNullable ? '?' : ''; - if (field.type.isClass) { - toWriteValue = '$fieldName$safeCall.toList()'; - } else if (!hostDatatype.isBuiltin && field.type.isEnum) { + if (!hostDatatype.isBuiltin && field.type.isEnum) { toWriteValue = '$fieldName$safeCall.raw'; } else { toWriteValue = fieldName; @@ -250,22 +248,17 @@ class KotlinGenerator extends StructuredGenerator { indent.write('companion object '); indent.addScoped('{', '}', () { indent.writeln('@Suppress("UNCHECKED_CAST")'); - indent.write('fun fromList(list: List): $className '); + indent + .write('fun fromList(${varNamePrefix}list: List): $className '); indent.addScoped('{', '}', () { enumerate(getFieldsInSerializationOrder(classDefinition), (int index, final NamedType field) { - final String listValue = 'list[$index]'; + final String listValue = '${varNamePrefix}list[$index]'; final String fieldType = _kotlinTypeForDartType(field.type); if (field.type.isNullable) { - if (field.type.isClass) { - indent.write('val ${field.name}: $fieldType? = '); - indent.add('($listValue as List?)?.let '); - indent.addScoped('{', '}', () { - indent.writeln('$fieldType.fromList(it)'); - }); - } else if (field.type.isEnum) { + if (field.type.isEnum) { indent.write('val ${field.name}: $fieldType? = '); indent.add('($listValue as Int?)?.let '); indent.addScoped('{', '}', () { @@ -276,10 +269,7 @@ class KotlinGenerator extends StructuredGenerator { 'val ${field.name} = ${_cast(indent, listValue, type: field.type)}'); } } else { - if (field.type.isClass) { - indent.writeln( - 'val ${field.name} = $fieldType.fromList($listValue as List)'); - } else if (field.type.isEnum) { + if (field.type.isEnum) { indent.writeln( 'val ${field.name} = $fieldType.ofRaw($listValue as Int)!!'); } else { @@ -730,24 +720,22 @@ class KotlinGenerator extends StructuredGenerator { }); }); } else { - indent.writeln('var wrapped: List'); - indent.write('try '); - indent.addScoped('{', '}', () { + indent.addScoped('val wrapped: List = try {', '}', () { if (returnType.isVoid) { indent.writeln(call); - indent.writeln('wrapped = listOf(null)'); + indent.writeln('listOf(null)'); } else { String enumTag = ''; if (returnType.isEnum) { final String safeUnwrap = returnType.isNullable ? '?' : ''; enumTag = '$safeUnwrap.raw'; } - indent.writeln('wrapped = listOf($call$enumTag)'); + indent.writeln('listOf($call$enumTag)'); } }, addTrailingNewline: false); indent.add(' catch (exception: Throwable) '); indent.addScoped('{', '}', () { - indent.writeln('wrapped = wrapError(exception)'); + indent.writeln('wrapError(exception)'); }); indent.writeln('reply.reply(wrapped)'); } diff --git a/packages/pigeon/lib/objc_generator.dart b/packages/pigeon/lib/objc_generator.dart index 67c93a74f3a..eaa3ee9b03c 100644 --- a/packages/pigeon/lib/objc_generator.dart +++ b/packages/pigeon/lib/objc_generator.dart @@ -568,15 +568,15 @@ class ObjcSourceGenerator extends StructuredGenerator { }) { final String className = _className(generatorOptions.prefix, classDefinition.name); - indent.write('+ ($className *)fromList:(NSArray *)list '); + indent.write('+ ($className *)fromList:(NSArray *)${varNamePrefix}list '); indent.addScoped('{', '}', () { const String resultName = 'pigeonResult'; indent.writeln('$className *$resultName = [[$className alloc] init];'); enumerate(getFieldsInSerializationOrder(classDefinition), (int index, final NamedType field) { final bool isEnumType = field.type.isEnum; - final String valueGetter = - _listGetter('list', field, index, generatorOptions.prefix); + final String valueGetter = _listGetter( + '${varNamePrefix}list', field, index, generatorOptions.prefix); final String? primitiveExtractionMethod = _nsnumberExtractionMethod(field.type); final String ivarValueExpression; @@ -595,9 +595,11 @@ class ObjcSourceGenerator extends StructuredGenerator { indent.writeln('return $resultName;'); }); - indent.write('+ (nullable $className *)nullableFromList:(NSArray *)list '); + indent.write( + '+ (nullable $className *)nullableFromList:(NSArray *)${varNamePrefix}list '); indent.addScoped('{', '}', () { - indent.writeln('return (list) ? [$className fromList:list] : nil;'); + indent.writeln( + 'return (${varNamePrefix}list) ? [$className fromList:${varNamePrefix}list] : nil;'); }); } @@ -917,9 +919,9 @@ static FlutterError *createConnectionError(NSString *channelName) { _className(languageOptions.prefix, classDefinition.name); indent.newln(); indent.writeln('@interface $className ()'); - indent.writeln('+ ($className *)fromList:(NSArray *)list;'); - indent - .writeln('+ (nullable $className *)nullableFromList:(NSArray *)list;'); + indent.writeln('+ ($className *)fromList:(NSArray *)${varNamePrefix}list;'); + indent.writeln( + '+ (nullable $className *)nullableFromList:(NSArray *)${varNamePrefix}list;'); indent.writeln('- (NSArray *)toList;'); indent.writeln('@end'); } @@ -1488,21 +1490,11 @@ String _makeObjcSignature({ void generateObjcHeader(ObjcOptions options, Root root, Indent indent) {} String _listGetter(String list, NamedType field, int index, String? prefix) { - if (field.type.isClass) { - String className = field.type.baseName; - if (prefix != null) { - className = '$prefix$className'; - } - return '[$className nullableFromList:(GetNullableObjectAtIndex($list, $index))]'; - } else { - return 'GetNullableObjectAtIndex($list, $index)'; - } + return 'GetNullableObjectAtIndex($list, $index)'; } String _arrayValue(NamedType field) { - if (field.type.isClass) { - return '(self.${field.name} ? [self.${field.name} toList] : [NSNull null])'; - } else if (field.type.isEnum) { + if (field.type.isEnum) { if (field.type.isNullable) { return '(self.${field.name} == nil ? [NSNull null] : [NSNumber numberWithInteger:self.${field.name}.value])'; } diff --git a/packages/pigeon/lib/pigeon_lib.dart b/packages/pigeon/lib/pigeon_lib.dart index addce55d54a..d8b799b4836 100644 --- a/packages/pigeon/lib/pigeon_lib.dart +++ b/packages/pigeon/lib/pigeon_lib.dart @@ -838,13 +838,6 @@ List _validateAst(Root root, String source) { lineNumber: _calculateLineNumberNullable(source, field.offset), )); } - if (customEnums.contains(typeArgument.baseName)) { - result.add(Error( - message: - 'Enum types aren\'t supported in type arguments in "${field.name}" in class "${classDefinition.name}".', - lineNumber: _calculateLineNumberNullable(source, field.offset), - )); - } } if (!(validTypes.contains(field.type.baseName) || customClasses.contains(field.type.baseName) || diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index 791cdd2e936..a203bc4063c 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -214,7 +214,7 @@ class SwiftGenerator extends StructuredGenerator { final String fieldName = field.name; final String nullsafe = field.type.isNullable ? '?' : ''; if (field.type.isClass) { - toWriteValue = '$fieldName$nullsafe.toList()'; + toWriteValue = fieldName; } else if (field.type.isEnum) { toWriteValue = '$fieldName$nullsafe.rawValue'; } else { @@ -236,12 +236,14 @@ class SwiftGenerator extends StructuredGenerator { required String dartPackageName, }) { final String className = classDefinition.name; - indent.write('static func fromList(_ list: [Any?]) -> $className? '); + indent.writeln('// swift-format-ignore: AlwaysUseLowerCamelCase'); + indent.write( + 'static func fromList(_ ${varNamePrefix}list: [Any?]) -> $className? '); indent.addScoped('{', '}', () { enumerate(getFieldsInSerializationOrder(classDefinition), (int index, final NamedType field) { - final String listValue = 'list[$index]'; + final String listValue = '${varNamePrefix}list[$index]'; _writeDecodeCasting( indent: indent, @@ -576,11 +578,10 @@ class SwiftGenerator extends StructuredGenerator { if (type.isNullable) { if (type.isClass) { indent.writeln('var $variableName: $fieldType? = nil'); - indent - .write('if let ${variableName}List: [Any?] = nilOrValue($value) '); + indent.write( + 'if let ${variableName}List: $fieldType = nilOrValue($value) '); indent.addScoped('{', '}', () { - indent.writeln( - '$variableName = $fieldType.fromList(${variableName}List)'); + indent.writeln('$variableName = ${variableName}List as $fieldType'); }); } else if (type.isEnum) { indent.writeln('var $variableName: $fieldType? = nil'); @@ -603,8 +604,7 @@ class SwiftGenerator extends StructuredGenerator { } } else { if (type.isClass) { - indent.writeln( - 'let $variableName = $fieldType.fromList($value as! [Any?])!'); + indent.writeln('let $variableName = $value as! $fieldType'); } else { _writeGenericCasting( indent: indent, @@ -917,7 +917,8 @@ String _flattenTypeArguments(List args) { } String _swiftTypeForBuiltinGenericDartType(TypeDeclaration type) { - if (type.typeArguments.isEmpty) { + if (type.typeArguments.isEmpty || + (type.typeArguments.first.baseName == 'Object')) { if (type.baseName == 'List') { return '[Any?]'; } else if (type.baseName == 'Map') { @@ -965,6 +966,9 @@ String _swiftTypeForDartType(TypeDeclaration type) { String _nullsafeSwiftTypeForDartType(TypeDeclaration type) { final String nullSafe = type.isNullable ? '?' : ''; + if (type.baseName == 'Map') { + return '${_swiftTypeForBuiltinGenericDartType(type)}$nullSafe'; + } return '${_swiftTypeForDartType(type)}$nullSafe'; } 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 93dad382878..959eaeab41e 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 @@ -410,37 +410,37 @@ ArrayList toList() { return toListResult; } - static @NonNull AllTypes fromList(@NonNull ArrayList list) { + static @NonNull AllTypes fromList(@NonNull ArrayList __pigeon_list) { AllTypes pigeonResult = new AllTypes(); - Object aBool = list.get(0); + Object aBool = __pigeon_list.get(0); pigeonResult.setABool((Boolean) aBool); - Object anInt = list.get(1); + Object anInt = __pigeon_list.get(1); pigeonResult.setAnInt( (anInt == null) ? null : ((anInt instanceof Integer) ? (Integer) anInt : (Long) anInt)); - Object anInt64 = list.get(2); + Object anInt64 = __pigeon_list.get(2); pigeonResult.setAnInt64( (anInt64 == null) ? null : ((anInt64 instanceof Integer) ? (Integer) anInt64 : (Long) anInt64)); - Object aDouble = list.get(3); + Object aDouble = __pigeon_list.get(3); pigeonResult.setADouble((Double) aDouble); - Object aByteArray = list.get(4); + Object aByteArray = __pigeon_list.get(4); pigeonResult.setAByteArray((byte[]) aByteArray); - Object a4ByteArray = list.get(5); + Object a4ByteArray = __pigeon_list.get(5); pigeonResult.setA4ByteArray((int[]) a4ByteArray); - Object a8ByteArray = list.get(6); + Object a8ByteArray = __pigeon_list.get(6); pigeonResult.setA8ByteArray((long[]) a8ByteArray); - Object aFloatArray = list.get(7); + Object aFloatArray = __pigeon_list.get(7); pigeonResult.setAFloatArray((double[]) aFloatArray); - Object aList = list.get(8); + Object aList = __pigeon_list.get(8); pigeonResult.setAList((List) aList); - Object aMap = list.get(9); + Object aMap = __pigeon_list.get(9); pigeonResult.setAMap((Map) aMap); - Object anEnum = list.get(10); + Object anEnum = __pigeon_list.get(10); pigeonResult.setAnEnum(AnEnum.values()[(int) anEnum]); - Object aString = list.get(11); + Object aString = __pigeon_list.get(11); pigeonResult.setAString((String) aString); - Object anObject = list.get(12); + Object anObject = __pigeon_list.get(12); pigeonResult.setAnObject(anObject); return pigeonResult; } @@ -803,58 +803,55 @@ ArrayList toList() { toListResult.add(aNullableEnum == null ? null : aNullableEnum.index); toListResult.add(aNullableString); toListResult.add(aNullableObject); - toListResult.add((allNullableTypes == null) ? null : allNullableTypes.toList()); + toListResult.add(allNullableTypes); return toListResult; } - static @NonNull AllNullableTypes fromList(@NonNull ArrayList list) { + static @NonNull AllNullableTypes fromList(@NonNull ArrayList __pigeon_list) { AllNullableTypes pigeonResult = new AllNullableTypes(); - Object aNullableBool = list.get(0); + Object aNullableBool = __pigeon_list.get(0); pigeonResult.setANullableBool((Boolean) aNullableBool); - Object aNullableInt = list.get(1); + Object aNullableInt = __pigeon_list.get(1); pigeonResult.setANullableInt( (aNullableInt == null) ? null : ((aNullableInt instanceof Integer) ? (Integer) aNullableInt : (Long) aNullableInt)); - Object aNullableInt64 = list.get(2); + Object aNullableInt64 = __pigeon_list.get(2); pigeonResult.setANullableInt64( (aNullableInt64 == null) ? null : ((aNullableInt64 instanceof Integer) ? (Integer) aNullableInt64 : (Long) aNullableInt64)); - Object aNullableDouble = list.get(3); + Object aNullableDouble = __pigeon_list.get(3); pigeonResult.setANullableDouble((Double) aNullableDouble); - Object aNullableByteArray = list.get(4); + Object aNullableByteArray = __pigeon_list.get(4); pigeonResult.setANullableByteArray((byte[]) aNullableByteArray); - Object aNullable4ByteArray = list.get(5); + Object aNullable4ByteArray = __pigeon_list.get(5); pigeonResult.setANullable4ByteArray((int[]) aNullable4ByteArray); - Object aNullable8ByteArray = list.get(6); + Object aNullable8ByteArray = __pigeon_list.get(6); pigeonResult.setANullable8ByteArray((long[]) aNullable8ByteArray); - Object aNullableFloatArray = list.get(7); + Object aNullableFloatArray = __pigeon_list.get(7); pigeonResult.setANullableFloatArray((double[]) aNullableFloatArray); - Object aNullableList = list.get(8); + Object aNullableList = __pigeon_list.get(8); pigeonResult.setANullableList((List) aNullableList); - Object aNullableMap = list.get(9); + Object aNullableMap = __pigeon_list.get(9); pigeonResult.setANullableMap((Map) aNullableMap); - Object nullableNestedList = list.get(10); + Object nullableNestedList = __pigeon_list.get(10); pigeonResult.setNullableNestedList((List>) nullableNestedList); - Object nullableMapWithAnnotations = list.get(11); + Object nullableMapWithAnnotations = __pigeon_list.get(11); pigeonResult.setNullableMapWithAnnotations((Map) nullableMapWithAnnotations); - Object nullableMapWithObject = list.get(12); + Object nullableMapWithObject = __pigeon_list.get(12); pigeonResult.setNullableMapWithObject((Map) nullableMapWithObject); - Object aNullableEnum = list.get(13); + Object aNullableEnum = __pigeon_list.get(13); pigeonResult.setANullableEnum( aNullableEnum == null ? null : AnEnum.values()[(int) aNullableEnum]); - Object aNullableString = list.get(14); + Object aNullableString = __pigeon_list.get(14); pigeonResult.setANullableString((String) aNullableString); - Object aNullableObject = list.get(15); + Object aNullableObject = __pigeon_list.get(15); pigeonResult.setANullableObject(aNullableObject); - Object allNullableTypes = list.get(16); - pigeonResult.setAllNullableTypes( - (allNullableTypes == null) - ? null - : AllNullableTypes.fromList((ArrayList) allNullableTypes)); + Object allNullableTypes = __pigeon_list.get(16); + pigeonResult.setAllNullableTypes((AllNullableTypes) allNullableTypes); return pigeonResult; } } @@ -1201,48 +1198,49 @@ ArrayList toList() { return toListResult; } - static @NonNull AllNullableTypesWithoutRecursion fromList(@NonNull ArrayList list) { + static @NonNull AllNullableTypesWithoutRecursion fromList( + @NonNull ArrayList __pigeon_list) { AllNullableTypesWithoutRecursion pigeonResult = new AllNullableTypesWithoutRecursion(); - Object aNullableBool = list.get(0); + Object aNullableBool = __pigeon_list.get(0); pigeonResult.setANullableBool((Boolean) aNullableBool); - Object aNullableInt = list.get(1); + Object aNullableInt = __pigeon_list.get(1); pigeonResult.setANullableInt( (aNullableInt == null) ? null : ((aNullableInt instanceof Integer) ? (Integer) aNullableInt : (Long) aNullableInt)); - Object aNullableInt64 = list.get(2); + Object aNullableInt64 = __pigeon_list.get(2); pigeonResult.setANullableInt64( (aNullableInt64 == null) ? null : ((aNullableInt64 instanceof Integer) ? (Integer) aNullableInt64 : (Long) aNullableInt64)); - Object aNullableDouble = list.get(3); + Object aNullableDouble = __pigeon_list.get(3); pigeonResult.setANullableDouble((Double) aNullableDouble); - Object aNullableByteArray = list.get(4); + Object aNullableByteArray = __pigeon_list.get(4); pigeonResult.setANullableByteArray((byte[]) aNullableByteArray); - Object aNullable4ByteArray = list.get(5); + Object aNullable4ByteArray = __pigeon_list.get(5); pigeonResult.setANullable4ByteArray((int[]) aNullable4ByteArray); - Object aNullable8ByteArray = list.get(6); + Object aNullable8ByteArray = __pigeon_list.get(6); pigeonResult.setANullable8ByteArray((long[]) aNullable8ByteArray); - Object aNullableFloatArray = list.get(7); + Object aNullableFloatArray = __pigeon_list.get(7); pigeonResult.setANullableFloatArray((double[]) aNullableFloatArray); - Object aNullableList = list.get(8); + Object aNullableList = __pigeon_list.get(8); pigeonResult.setANullableList((List) aNullableList); - Object aNullableMap = list.get(9); + Object aNullableMap = __pigeon_list.get(9); pigeonResult.setANullableMap((Map) aNullableMap); - Object nullableNestedList = list.get(10); + Object nullableNestedList = __pigeon_list.get(10); pigeonResult.setNullableNestedList((List>) nullableNestedList); - Object nullableMapWithAnnotations = list.get(11); + Object nullableMapWithAnnotations = __pigeon_list.get(11); pigeonResult.setNullableMapWithAnnotations((Map) nullableMapWithAnnotations); - Object nullableMapWithObject = list.get(12); + Object nullableMapWithObject = __pigeon_list.get(12); pigeonResult.setNullableMapWithObject((Map) nullableMapWithObject); - Object aNullableEnum = list.get(13); + Object aNullableEnum = __pigeon_list.get(13); pigeonResult.setANullableEnum( aNullableEnum == null ? null : AnEnum.values()[(int) aNullableEnum]); - Object aNullableString = list.get(14); + Object aNullableString = __pigeon_list.get(14); pigeonResult.setANullableString((String) aNullableString); - Object aNullableObject = list.get(15); + Object aNullableObject = __pigeon_list.get(15); pigeonResult.setANullableObject(aNullableObject); return pigeonResult; } @@ -1334,31 +1332,21 @@ public static final class Builder { @NonNull ArrayList toList() { ArrayList toListResult = new ArrayList(3); - toListResult.add((allNullableTypes == null) ? null : allNullableTypes.toList()); - toListResult.add( - (allNullableTypesWithoutRecursion == null) - ? null - : allNullableTypesWithoutRecursion.toList()); - toListResult.add((allTypes == null) ? null : allTypes.toList()); + toListResult.add(allNullableTypes); + toListResult.add(allNullableTypesWithoutRecursion); + toListResult.add(allTypes); return toListResult; } - static @NonNull AllClassesWrapper fromList(@NonNull ArrayList list) { + static @NonNull AllClassesWrapper fromList(@NonNull ArrayList __pigeon_list) { AllClassesWrapper pigeonResult = new AllClassesWrapper(); - Object allNullableTypes = list.get(0); - pigeonResult.setAllNullableTypes( - (allNullableTypes == null) - ? null - : AllNullableTypes.fromList((ArrayList) allNullableTypes)); - Object allNullableTypesWithoutRecursion = list.get(1); + Object allNullableTypes = __pigeon_list.get(0); + pigeonResult.setAllNullableTypes((AllNullableTypes) allNullableTypes); + Object allNullableTypesWithoutRecursion = __pigeon_list.get(1); pigeonResult.setAllNullableTypesWithoutRecursion( - (allNullableTypesWithoutRecursion == null) - ? null - : AllNullableTypesWithoutRecursion.fromList( - (ArrayList) allNullableTypesWithoutRecursion)); - Object allTypes = list.get(2); - pigeonResult.setAllTypes( - (allTypes == null) ? null : AllTypes.fromList((ArrayList) allTypes)); + (AllNullableTypesWithoutRecursion) allNullableTypesWithoutRecursion); + Object allTypes = __pigeon_list.get(2); + pigeonResult.setAllTypes((AllTypes) allTypes); return pigeonResult; } } @@ -1403,9 +1391,9 @@ ArrayList toList() { return toListResult; } - static @NonNull TestMessage fromList(@NonNull ArrayList list) { + static @NonNull TestMessage fromList(@NonNull ArrayList __pigeon_list) { TestMessage pigeonResult = new TestMessage(); - Object testList = list.get(0); + Object testList = __pigeon_list.get(0); pigeonResult.setTestList((List) testList); return pigeonResult; } 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 2861a888048..abfb4735b7d 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 @@ -51,32 +51,32 @@ - (instancetype)initWithValue:(FLTAnEnum)value { @end @interface FLTAllTypes () -+ (FLTAllTypes *)fromList:(NSArray *)list; -+ (nullable FLTAllTypes *)nullableFromList:(NSArray *)list; ++ (FLTAllTypes *)fromList:(NSArray *)__pigeon_list; ++ (nullable FLTAllTypes *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @interface FLTAllNullableTypes () -+ (FLTAllNullableTypes *)fromList:(NSArray *)list; -+ (nullable FLTAllNullableTypes *)nullableFromList:(NSArray *)list; ++ (FLTAllNullableTypes *)fromList:(NSArray *)__pigeon_list; ++ (nullable FLTAllNullableTypes *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @interface FLTAllNullableTypesWithoutRecursion () -+ (FLTAllNullableTypesWithoutRecursion *)fromList:(NSArray *)list; -+ (nullable FLTAllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list; ++ (FLTAllNullableTypesWithoutRecursion *)fromList:(NSArray *)__pigeon_list; ++ (nullable FLTAllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @interface FLTAllClassesWrapper () -+ (FLTAllClassesWrapper *)fromList:(NSArray *)list; -+ (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)list; ++ (FLTAllClassesWrapper *)fromList:(NSArray *)__pigeon_list; ++ (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @interface FLTTestMessage () -+ (FLTTestMessage *)fromList:(NSArray *)list; -+ (nullable FLTTestMessage *)nullableFromList:(NSArray *)list; ++ (FLTTestMessage *)fromList:(NSArray *)__pigeon_list; ++ (nullable FLTTestMessage *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @@ -110,25 +110,25 @@ + (instancetype)makeWithABool:(BOOL)aBool pigeonResult.anObject = anObject; return pigeonResult; } -+ (FLTAllTypes *)fromList:(NSArray *)list { ++ (FLTAllTypes *)fromList:(NSArray *)__pigeon_list { FLTAllTypes *pigeonResult = [[FLTAllTypes alloc] init]; - pigeonResult.aBool = [GetNullableObjectAtIndex(list, 0) boolValue]; - pigeonResult.anInt = [GetNullableObjectAtIndex(list, 1) integerValue]; - pigeonResult.anInt64 = [GetNullableObjectAtIndex(list, 2) integerValue]; - pigeonResult.aDouble = [GetNullableObjectAtIndex(list, 3) doubleValue]; - pigeonResult.aByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.a4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.a8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.aList = GetNullableObjectAtIndex(list, 8); - pigeonResult.aMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.anEnum = [GetNullableObjectAtIndex(list, 10) integerValue]; - pigeonResult.aString = GetNullableObjectAtIndex(list, 11); - pigeonResult.anObject = GetNullableObjectAtIndex(list, 12); + pigeonResult.aBool = [GetNullableObjectAtIndex(__pigeon_list, 0) boolValue]; + pigeonResult.anInt = [GetNullableObjectAtIndex(__pigeon_list, 1) integerValue]; + pigeonResult.anInt64 = [GetNullableObjectAtIndex(__pigeon_list, 2) integerValue]; + pigeonResult.aDouble = [GetNullableObjectAtIndex(__pigeon_list, 3) doubleValue]; + pigeonResult.aByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); + pigeonResult.a4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); + pigeonResult.a8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); + pigeonResult.aFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); + pigeonResult.aList = GetNullableObjectAtIndex(__pigeon_list, 8); + pigeonResult.aMap = GetNullableObjectAtIndex(__pigeon_list, 9); + pigeonResult.anEnum = [GetNullableObjectAtIndex(__pigeon_list, 10) integerValue]; + pigeonResult.aString = GetNullableObjectAtIndex(__pigeon_list, 11); + pigeonResult.anObject = GetNullableObjectAtIndex(__pigeon_list, 12); return pigeonResult; } -+ (nullable FLTAllTypes *)nullableFromList:(NSArray *)list { - return (list) ? [FLTAllTypes fromList:list] : nil; ++ (nullable FLTAllTypes *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [FLTAllTypes fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ @@ -188,35 +188,34 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool pigeonResult.allNullableTypes = allNullableTypes; return pigeonResult; } -+ (FLTAllNullableTypes *)fromList:(NSArray *)list { ++ (FLTAllNullableTypes *)fromList:(NSArray *)__pigeon_list { FLTAllNullableTypes *pigeonResult = [[FLTAllNullableTypes alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(__pigeon_list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(__pigeon_list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(__pigeon_list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(__pigeon_list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(__pigeon_list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(__pigeon_list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(__pigeon_list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(__pigeon_list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(__pigeon_list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(__pigeon_list, 13); FLTAnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[FLTAnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); - pigeonResult.allNullableTypes = - [FLTAllNullableTypes nullableFromList:(GetNullableObjectAtIndex(list, 16))]; + pigeonResult.aNullableString = GetNullableObjectAtIndex(__pigeon_list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(__pigeon_list, 15); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(__pigeon_list, 16); return pigeonResult; } -+ (nullable FLTAllNullableTypes *)nullableFromList:(NSArray *)list { - return (list) ? [FLTAllNullableTypes fromList:list] : nil; ++ (nullable FLTAllNullableTypes *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [FLTAllNullableTypes fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ @@ -237,7 +236,7 @@ - (NSArray *)toList { : [NSNumber numberWithInteger:self.aNullableEnum.value]), self.aNullableString ?: [NSNull null], self.aNullableObject ?: [NSNull null], - (self.allNullableTypes ? [self.allNullableTypes toList] : [NSNull null]), + self.allNullableTypes ?: [NSNull null], ]; } @end @@ -280,34 +279,34 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool pigeonResult.aNullableObject = aNullableObject; return pigeonResult; } -+ (FLTAllNullableTypesWithoutRecursion *)fromList:(NSArray *)list { ++ (FLTAllNullableTypesWithoutRecursion *)fromList:(NSArray *)__pigeon_list { FLTAllNullableTypesWithoutRecursion *pigeonResult = [[FLTAllNullableTypesWithoutRecursion alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(__pigeon_list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(__pigeon_list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(__pigeon_list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(__pigeon_list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(__pigeon_list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(__pigeon_list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(__pigeon_list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(__pigeon_list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(__pigeon_list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(__pigeon_list, 13); FLTAnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[FLTAnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); + pigeonResult.aNullableString = GetNullableObjectAtIndex(__pigeon_list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(__pigeon_list, 15); return pigeonResult; } -+ (nullable FLTAllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list { - return (list) ? [FLTAllNullableTypesWithoutRecursion fromList:list] : nil; ++ (nullable FLTAllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [FLTAllNullableTypesWithoutRecursion fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ @@ -343,24 +342,21 @@ + (instancetype)makeWithAllNullableTypes:(FLTAllNullableTypes *)allNullableTypes pigeonResult.allTypes = allTypes; return pigeonResult; } -+ (FLTAllClassesWrapper *)fromList:(NSArray *)list { ++ (FLTAllClassesWrapper *)fromList:(NSArray *)__pigeon_list { FLTAllClassesWrapper *pigeonResult = [[FLTAllClassesWrapper alloc] init]; - pigeonResult.allNullableTypes = - [FLTAllNullableTypes nullableFromList:(GetNullableObjectAtIndex(list, 0))]; - pigeonResult.allNullableTypesWithoutRecursion = - [FLTAllNullableTypesWithoutRecursion nullableFromList:(GetNullableObjectAtIndex(list, 1))]; - pigeonResult.allTypes = [FLTAllTypes nullableFromList:(GetNullableObjectAtIndex(list, 2))]; + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(__pigeon_list, 0); + pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex(__pigeon_list, 1); + pigeonResult.allTypes = GetNullableObjectAtIndex(__pigeon_list, 2); return pigeonResult; } -+ (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)list { - return (list) ? [FLTAllClassesWrapper fromList:list] : nil; ++ (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [FLTAllClassesWrapper fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ - (self.allNullableTypes ? [self.allNullableTypes toList] : [NSNull null]), - (self.allNullableTypesWithoutRecursion ? [self.allNullableTypesWithoutRecursion toList] - : [NSNull null]), - (self.allTypes ? [self.allTypes toList] : [NSNull null]), + self.allNullableTypes ?: [NSNull null], + self.allNullableTypesWithoutRecursion ?: [NSNull null], + self.allTypes ?: [NSNull null], ]; } @end @@ -371,13 +367,13 @@ + (instancetype)makeWithTestList:(nullable NSArray *)testList { pigeonResult.testList = testList; return pigeonResult; } -+ (FLTTestMessage *)fromList:(NSArray *)list { ++ (FLTTestMessage *)fromList:(NSArray *)__pigeon_list { FLTTestMessage *pigeonResult = [[FLTTestMessage alloc] init]; - pigeonResult.testList = GetNullableObjectAtIndex(list, 0); + pigeonResult.testList = GetNullableObjectAtIndex(__pigeon_list, 0); return pigeonResult; } -+ (nullable FLTTestMessage *)nullableFromList:(NSArray *)list { - return (list) ? [FLTTestMessage fromList:list] : nil; ++ (nullable FLTTestMessage *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [FLTTestMessage fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m index b90345836c5..d63ce8bcfe8 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m @@ -51,32 +51,32 @@ - (instancetype)initWithValue:(AnEnum)value { @end @interface AllTypes () -+ (AllTypes *)fromList:(NSArray *)list; -+ (nullable AllTypes *)nullableFromList:(NSArray *)list; ++ (AllTypes *)fromList:(NSArray *)__pigeon_list; ++ (nullable AllTypes *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @interface AllNullableTypes () -+ (AllNullableTypes *)fromList:(NSArray *)list; -+ (nullable AllNullableTypes *)nullableFromList:(NSArray *)list; ++ (AllNullableTypes *)fromList:(NSArray *)__pigeon_list; ++ (nullable AllNullableTypes *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @interface AllNullableTypesWithoutRecursion () -+ (AllNullableTypesWithoutRecursion *)fromList:(NSArray *)list; -+ (nullable AllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list; ++ (AllNullableTypesWithoutRecursion *)fromList:(NSArray *)__pigeon_list; ++ (nullable AllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @interface AllClassesWrapper () -+ (AllClassesWrapper *)fromList:(NSArray *)list; -+ (nullable AllClassesWrapper *)nullableFromList:(NSArray *)list; ++ (AllClassesWrapper *)fromList:(NSArray *)__pigeon_list; ++ (nullable AllClassesWrapper *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @interface TestMessage () -+ (TestMessage *)fromList:(NSArray *)list; -+ (nullable TestMessage *)nullableFromList:(NSArray *)list; ++ (TestMessage *)fromList:(NSArray *)__pigeon_list; ++ (nullable TestMessage *)nullableFromList:(NSArray *)__pigeon_list; - (NSArray *)toList; @end @@ -110,25 +110,25 @@ + (instancetype)makeWithABool:(BOOL)aBool pigeonResult.anObject = anObject; return pigeonResult; } -+ (AllTypes *)fromList:(NSArray *)list { ++ (AllTypes *)fromList:(NSArray *)__pigeon_list { AllTypes *pigeonResult = [[AllTypes alloc] init]; - pigeonResult.aBool = [GetNullableObjectAtIndex(list, 0) boolValue]; - pigeonResult.anInt = [GetNullableObjectAtIndex(list, 1) integerValue]; - pigeonResult.anInt64 = [GetNullableObjectAtIndex(list, 2) integerValue]; - pigeonResult.aDouble = [GetNullableObjectAtIndex(list, 3) doubleValue]; - pigeonResult.aByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.a4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.a8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.aList = GetNullableObjectAtIndex(list, 8); - pigeonResult.aMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.anEnum = [GetNullableObjectAtIndex(list, 10) integerValue]; - pigeonResult.aString = GetNullableObjectAtIndex(list, 11); - pigeonResult.anObject = GetNullableObjectAtIndex(list, 12); + pigeonResult.aBool = [GetNullableObjectAtIndex(__pigeon_list, 0) boolValue]; + pigeonResult.anInt = [GetNullableObjectAtIndex(__pigeon_list, 1) integerValue]; + pigeonResult.anInt64 = [GetNullableObjectAtIndex(__pigeon_list, 2) integerValue]; + pigeonResult.aDouble = [GetNullableObjectAtIndex(__pigeon_list, 3) doubleValue]; + pigeonResult.aByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); + pigeonResult.a4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); + pigeonResult.a8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); + pigeonResult.aFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); + pigeonResult.aList = GetNullableObjectAtIndex(__pigeon_list, 8); + pigeonResult.aMap = GetNullableObjectAtIndex(__pigeon_list, 9); + pigeonResult.anEnum = [GetNullableObjectAtIndex(__pigeon_list, 10) integerValue]; + pigeonResult.aString = GetNullableObjectAtIndex(__pigeon_list, 11); + pigeonResult.anObject = GetNullableObjectAtIndex(__pigeon_list, 12); return pigeonResult; } -+ (nullable AllTypes *)nullableFromList:(NSArray *)list { - return (list) ? [AllTypes fromList:list] : nil; ++ (nullable AllTypes *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [AllTypes fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ @@ -188,35 +188,34 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool pigeonResult.allNullableTypes = allNullableTypes; return pigeonResult; } -+ (AllNullableTypes *)fromList:(NSArray *)list { ++ (AllNullableTypes *)fromList:(NSArray *)__pigeon_list { AllNullableTypes *pigeonResult = [[AllNullableTypes alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(__pigeon_list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(__pigeon_list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(__pigeon_list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(__pigeon_list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(__pigeon_list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(__pigeon_list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(__pigeon_list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(__pigeon_list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(__pigeon_list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(__pigeon_list, 13); AnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[AnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); - pigeonResult.allNullableTypes = - [AllNullableTypes nullableFromList:(GetNullableObjectAtIndex(list, 16))]; + pigeonResult.aNullableString = GetNullableObjectAtIndex(__pigeon_list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(__pigeon_list, 15); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(__pigeon_list, 16); return pigeonResult; } -+ (nullable AllNullableTypes *)nullableFromList:(NSArray *)list { - return (list) ? [AllNullableTypes fromList:list] : nil; ++ (nullable AllNullableTypes *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [AllNullableTypes fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ @@ -237,7 +236,7 @@ - (NSArray *)toList { : [NSNumber numberWithInteger:self.aNullableEnum.value]), self.aNullableString ?: [NSNull null], self.aNullableObject ?: [NSNull null], - (self.allNullableTypes ? [self.allNullableTypes toList] : [NSNull null]), + self.allNullableTypes ?: [NSNull null], ]; } @end @@ -279,33 +278,33 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool pigeonResult.aNullableObject = aNullableObject; return pigeonResult; } -+ (AllNullableTypesWithoutRecursion *)fromList:(NSArray *)list { ++ (AllNullableTypesWithoutRecursion *)fromList:(NSArray *)__pigeon_list { AllNullableTypesWithoutRecursion *pigeonResult = [[AllNullableTypesWithoutRecursion alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(__pigeon_list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(__pigeon_list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(__pigeon_list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(__pigeon_list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(__pigeon_list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(__pigeon_list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(__pigeon_list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(__pigeon_list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(__pigeon_list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(__pigeon_list, 13); AnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[AnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); + pigeonResult.aNullableString = GetNullableObjectAtIndex(__pigeon_list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(__pigeon_list, 15); return pigeonResult; } -+ (nullable AllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list { - return (list) ? [AllNullableTypesWithoutRecursion fromList:list] : nil; ++ (nullable AllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [AllNullableTypesWithoutRecursion fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ @@ -341,24 +340,21 @@ + (instancetype)makeWithAllNullableTypes:(AllNullableTypes *)allNullableTypes pigeonResult.allTypes = allTypes; return pigeonResult; } -+ (AllClassesWrapper *)fromList:(NSArray *)list { ++ (AllClassesWrapper *)fromList:(NSArray *)__pigeon_list { AllClassesWrapper *pigeonResult = [[AllClassesWrapper alloc] init]; - pigeonResult.allNullableTypes = - [AllNullableTypes nullableFromList:(GetNullableObjectAtIndex(list, 0))]; - pigeonResult.allNullableTypesWithoutRecursion = - [AllNullableTypesWithoutRecursion nullableFromList:(GetNullableObjectAtIndex(list, 1))]; - pigeonResult.allTypes = [AllTypes nullableFromList:(GetNullableObjectAtIndex(list, 2))]; + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(__pigeon_list, 0); + pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex(__pigeon_list, 1); + pigeonResult.allTypes = GetNullableObjectAtIndex(__pigeon_list, 2); return pigeonResult; } -+ (nullable AllClassesWrapper *)nullableFromList:(NSArray *)list { - return (list) ? [AllClassesWrapper fromList:list] : nil; ++ (nullable AllClassesWrapper *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [AllClassesWrapper fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ - (self.allNullableTypes ? [self.allNullableTypes toList] : [NSNull null]), - (self.allNullableTypesWithoutRecursion ? [self.allNullableTypesWithoutRecursion toList] - : [NSNull null]), - (self.allTypes ? [self.allTypes toList] : [NSNull null]), + self.allNullableTypes ?: [NSNull null], + self.allNullableTypesWithoutRecursion ?: [NSNull null], + self.allTypes ?: [NSNull null], ]; } @end @@ -369,13 +365,13 @@ + (instancetype)makeWithTestList:(nullable NSArray *)testList { pigeonResult.testList = testList; return pigeonResult; } -+ (TestMessage *)fromList:(NSArray *)list { ++ (TestMessage *)fromList:(NSArray *)__pigeon_list { TestMessage *pigeonResult = [[TestMessage alloc] init]; - pigeonResult.testList = GetNullableObjectAtIndex(list, 0); + pigeonResult.testList = GetNullableObjectAtIndex(__pigeon_list, 0); return pigeonResult; } -+ (nullable TestMessage *)nullableFromList:(NSArray *)list { - return (list) ? [TestMessage fromList:list] : nil; ++ (nullable TestMessage *)nullableFromList:(NSArray *)__pigeon_list { + return (__pigeon_list) ? [TestMessage fromList:__pigeon_list] : nil; } - (NSArray *)toList { return @[ 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 1b3bc1f5304..90de1326fe5 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 @@ -194,7 +194,7 @@ class AllNullableTypes { aNullableEnum?.index, aNullableString, aNullableObject, - allNullableTypes?.encode(), + allNullableTypes, ]; } @@ -220,9 +220,8 @@ class AllNullableTypes { result[13] != null ? AnEnum.values[result[13]! as int] : null, aNullableString: result[14] as String?, aNullableObject: result[15], - allNullableTypes: result[16] != null - ? AllNullableTypes.decode(result[16]! as List) - : null, + allNullableTypes: + result[16] != null ? result[16]! as AllNullableTypes : null, ); } } @@ -349,22 +348,20 @@ class AllClassesWrapper { Object encode() { return [ - allNullableTypes.encode(), - allNullableTypesWithoutRecursion?.encode(), - allTypes?.encode(), + allNullableTypes, + allNullableTypesWithoutRecursion, + allTypes, ]; } static AllClassesWrapper decode(Object result) { result as List; return AllClassesWrapper( - allNullableTypes: AllNullableTypes.decode(result[0]! as List), + allNullableTypes: result[0]! as AllNullableTypes, allNullableTypesWithoutRecursion: result[1] != null - ? AllNullableTypesWithoutRecursion.decode(result[1]! as List) - : null, - allTypes: result[2] != null - ? AllTypes.decode(result[2]! as List) + ? result[1]! as AllNullableTypesWithoutRecursion : null, + allTypes: result[2] != null ? result[2]! as AllTypes : null, ); } } diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart index cc7b8b53c36..ca9604cf820 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart @@ -130,16 +130,14 @@ class MessageNested { Object encode() { return [ - request?.encode(), + request, ]; } static MessageNested decode(Object result) { result as List; return MessageNested( - request: result[0] != null - ? MessageSearchRequest.decode(result[0]! as List) - : null, + request: result[0] != null ? result[0]! as MessageSearchRequest : null, ); } } diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/non_null_fields.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/non_null_fields.gen.dart index 7279e85c40e..d8711ff2203 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/non_null_fields.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/non_null_fields.gen.dart @@ -106,7 +106,7 @@ class NonNullFieldSearchReply { result, error, indices, - extraData.encode(), + extraData, type.index, ]; } @@ -117,7 +117,7 @@ class NonNullFieldSearchReply { result: result[0]! as String, error: result[1]! as String, indices: (result[2] as List?)!.cast(), - extraData: ExtraData.decode(result[3]! as List), + extraData: result[3]! as ExtraData, type: ReplyType.values[result[4]! as int], ); } diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart index ecf7c7f7e97..30ceaf68f94 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart @@ -85,7 +85,7 @@ class NullFieldsSearchReply { result, error, indices, - request?.encode(), + request, type?.index, ]; } @@ -96,9 +96,7 @@ class NullFieldsSearchReply { result: result[0] as String?, error: result[1] as String?, indices: (result[2] as List?)?.cast(), - request: result[3] != null - ? NullFieldsSearchRequest.decode(result[3]! as List) - : null, + request: result[3] != null ? result[3]! as NullFieldsSearchRequest : null, type: result[4] != null ? NullFieldsSearchReplyType.values[result[4]! as int] : null, 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 002c621784a..fccb7574c95 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 @@ -71,20 +71,20 @@ data class AllTypes( ) { companion object { @Suppress("UNCHECKED_CAST") - fun fromList(list: List): AllTypes { - val aBool = list[0] as Boolean - val anInt = list[1].let { if (it is Int) it.toLong() else it as Long } - val anInt64 = list[2].let { if (it is Int) it.toLong() else it as Long } - val aDouble = list[3] as Double - val aByteArray = list[4] as ByteArray - val a4ByteArray = list[5] as IntArray - val a8ByteArray = list[6] as LongArray - val aFloatArray = list[7] as DoubleArray - val aList = list[8] as List - val aMap = list[9] as Map - val anEnum = AnEnum.ofRaw(list[10] as Int)!! - val aString = list[11] as String - val anObject = list[12] as Any + fun fromList(__pigeon_list: List): AllTypes { + val aBool = __pigeon_list[0] as Boolean + val anInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long } + val anInt64 = __pigeon_list[2].let { if (it is Int) it.toLong() else it as Long } + val aDouble = __pigeon_list[3] as Double + val aByteArray = __pigeon_list[4] as ByteArray + val a4ByteArray = __pigeon_list[5] as IntArray + val a8ByteArray = __pigeon_list[6] as LongArray + val aFloatArray = __pigeon_list[7] as DoubleArray + val aList = __pigeon_list[8] as List + val aMap = __pigeon_list[9] as Map + val anEnum = AnEnum.ofRaw(__pigeon_list[10] as Int)!! + val aString = __pigeon_list[11] as String + val anObject = __pigeon_list[12] as Any return AllTypes( aBool, anInt, @@ -147,25 +147,24 @@ data class AllNullableTypes( ) { companion object { @Suppress("UNCHECKED_CAST") - fun fromList(list: List): AllNullableTypes { - val aNullableBool = list[0] as Boolean? - val aNullableInt = list[1].let { if (it is Int) it.toLong() else it as Long? } - val aNullableInt64 = list[2].let { if (it is Int) it.toLong() else it as Long? } - val aNullableDouble = list[3] as Double? - val aNullableByteArray = list[4] as ByteArray? - val aNullable4ByteArray = list[5] as IntArray? - val aNullable8ByteArray = list[6] as LongArray? - val aNullableFloatArray = list[7] as DoubleArray? - val aNullableList = list[8] as List? - val aNullableMap = list[9] as Map? - val nullableNestedList = list[10] as List?>? - val nullableMapWithAnnotations = list[11] as Map? - val nullableMapWithObject = list[12] as Map? - val aNullableEnum: AnEnum? = (list[13] as Int?)?.let { AnEnum.ofRaw(it) } - val aNullableString = list[14] as String? - val aNullableObject = list[15] - val allNullableTypes: AllNullableTypes? = - (list[16] as List?)?.let { AllNullableTypes.fromList(it) } + fun fromList(__pigeon_list: List): AllNullableTypes { + val aNullableBool = __pigeon_list[0] as Boolean? + val aNullableInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long? } + val aNullableInt64 = __pigeon_list[2].let { if (it is Int) it.toLong() else it as Long? } + val aNullableDouble = __pigeon_list[3] as Double? + val aNullableByteArray = __pigeon_list[4] as ByteArray? + val aNullable4ByteArray = __pigeon_list[5] as IntArray? + val aNullable8ByteArray = __pigeon_list[6] as LongArray? + val aNullableFloatArray = __pigeon_list[7] as DoubleArray? + val aNullableList = __pigeon_list[8] as List? + val aNullableMap = __pigeon_list[9] as Map? + val nullableNestedList = __pigeon_list[10] as List?>? + val nullableMapWithAnnotations = __pigeon_list[11] as Map? + val nullableMapWithObject = __pigeon_list[12] as Map? + val aNullableEnum: AnEnum? = (__pigeon_list[13] as Int?)?.let { AnEnum.ofRaw(it) } + val aNullableString = __pigeon_list[14] as String? + val aNullableObject = __pigeon_list[15] + val allNullableTypes = __pigeon_list[16] as AllNullableTypes? return AllNullableTypes( aNullableBool, aNullableInt, @@ -205,7 +204,7 @@ data class AllNullableTypes( aNullableEnum?.raw, aNullableString, aNullableObject, - allNullableTypes?.toList(), + allNullableTypes, ) } } @@ -236,23 +235,23 @@ data class AllNullableTypesWithoutRecursion( ) { companion object { @Suppress("UNCHECKED_CAST") - fun fromList(list: List): AllNullableTypesWithoutRecursion { - val aNullableBool = list[0] as Boolean? - val aNullableInt = list[1].let { if (it is Int) it.toLong() else it as Long? } - val aNullableInt64 = list[2].let { if (it is Int) it.toLong() else it as Long? } - val aNullableDouble = list[3] as Double? - val aNullableByteArray = list[4] as ByteArray? - val aNullable4ByteArray = list[5] as IntArray? - val aNullable8ByteArray = list[6] as LongArray? - val aNullableFloatArray = list[7] as DoubleArray? - val aNullableList = list[8] as List? - val aNullableMap = list[9] as Map? - val nullableNestedList = list[10] as List?>? - val nullableMapWithAnnotations = list[11] as Map? - val nullableMapWithObject = list[12] as Map? - val aNullableEnum: AnEnum? = (list[13] as Int?)?.let { AnEnum.ofRaw(it) } - val aNullableString = list[14] as String? - val aNullableObject = list[15] + fun fromList(__pigeon_list: List): AllNullableTypesWithoutRecursion { + val aNullableBool = __pigeon_list[0] as Boolean? + val aNullableInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long? } + val aNullableInt64 = __pigeon_list[2].let { if (it is Int) it.toLong() else it as Long? } + val aNullableDouble = __pigeon_list[3] as Double? + val aNullableByteArray = __pigeon_list[4] as ByteArray? + val aNullable4ByteArray = __pigeon_list[5] as IntArray? + val aNullable8ByteArray = __pigeon_list[6] as LongArray? + val aNullableFloatArray = __pigeon_list[7] as DoubleArray? + val aNullableList = __pigeon_list[8] as List? + val aNullableMap = __pigeon_list[9] as Map? + val nullableNestedList = __pigeon_list[10] as List?>? + val nullableMapWithAnnotations = __pigeon_list[11] as Map? + val nullableMapWithObject = __pigeon_list[12] as Map? + val aNullableEnum: AnEnum? = (__pigeon_list[13] as Int?)?.let { AnEnum.ofRaw(it) } + val aNullableString = __pigeon_list[14] as String? + val aNullableObject = __pigeon_list[15] return AllNullableTypesWithoutRecursion( aNullableBool, aNullableInt, @@ -311,20 +310,19 @@ data class AllClassesWrapper( ) { companion object { @Suppress("UNCHECKED_CAST") - fun fromList(list: List): AllClassesWrapper { - val allNullableTypes = AllNullableTypes.fromList(list[0] as List) - val allNullableTypesWithoutRecursion: AllNullableTypesWithoutRecursion? = - (list[1] as List?)?.let { AllNullableTypesWithoutRecursion.fromList(it) } - val allTypes: AllTypes? = (list[2] as List?)?.let { AllTypes.fromList(it) } + fun fromList(__pigeon_list: List): AllClassesWrapper { + val allNullableTypes = __pigeon_list[0] as AllNullableTypes + val allNullableTypesWithoutRecursion = __pigeon_list[1] as AllNullableTypesWithoutRecursion? + val allTypes = __pigeon_list[2] as AllTypes? return AllClassesWrapper(allNullableTypes, allNullableTypesWithoutRecursion, allTypes) } } fun toList(): List { return listOf( - allNullableTypes.toList(), - allNullableTypesWithoutRecursion?.toList(), - allTypes?.toList(), + allNullableTypes, + allNullableTypesWithoutRecursion, + allTypes, ) } } @@ -338,8 +336,8 @@ data class TestMessage(val testList: List? = null) { companion object { @Suppress("UNCHECKED_CAST") - fun fromList(list: List): TestMessage { - val testList = list[0] as List? + fun fromList(__pigeon_list: List): TestMessage { + val testList = __pigeon_list[0] as List? return TestMessage(testList) } } @@ -641,13 +639,13 @@ interface HostIntegrationCoreApi { codec) if (api != null) { channel.setMessageHandler { _, reply -> - var wrapped: List - try { - api.noop() - wrapped = listOf(null) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + api.noop() + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -664,12 +662,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val everythingArg = args[0] as AllTypes - var wrapped: List - try { - wrapped = listOf(api.echoAllTypes(everythingArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoAllTypes(everythingArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -684,12 +682,12 @@ interface HostIntegrationCoreApi { codec) if (api != null) { channel.setMessageHandler { _, reply -> - var wrapped: List - try { - wrapped = listOf(api.throwError()) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.throwError()) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -704,13 +702,13 @@ interface HostIntegrationCoreApi { codec) if (api != null) { channel.setMessageHandler { _, reply -> - var wrapped: List - try { - api.throwErrorFromVoid() - wrapped = listOf(null) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + api.throwErrorFromVoid() + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -725,12 +723,12 @@ interface HostIntegrationCoreApi { codec) if (api != null) { channel.setMessageHandler { _, reply -> - var wrapped: List - try { - wrapped = listOf(api.throwFlutterError()) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.throwFlutterError()) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -747,12 +745,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val anIntArg = args[0].let { if (it is Int) it.toLong() else it as Long } - var wrapped: List - try { - wrapped = listOf(api.echoInt(anIntArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoInt(anIntArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -769,12 +767,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aDoubleArg = args[0] as Double - var wrapped: List - try { - wrapped = listOf(api.echoDouble(aDoubleArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoDouble(aDoubleArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -791,12 +789,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aBoolArg = args[0] as Boolean - var wrapped: List - try { - wrapped = listOf(api.echoBool(aBoolArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoBool(aBoolArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -813,12 +811,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aStringArg = args[0] as String - var wrapped: List - try { - wrapped = listOf(api.echoString(aStringArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoString(aStringArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -835,12 +833,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aUint8ListArg = args[0] as ByteArray - var wrapped: List - try { - wrapped = listOf(api.echoUint8List(aUint8ListArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoUint8List(aUint8ListArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -857,12 +855,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val anObjectArg = args[0] as Any - var wrapped: List - try { - wrapped = listOf(api.echoObject(anObjectArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoObject(anObjectArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -879,12 +877,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aListArg = args[0] as List - var wrapped: List - try { - wrapped = listOf(api.echoList(aListArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoList(aListArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -901,12 +899,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aMapArg = args[0] as Map - var wrapped: List - try { - wrapped = listOf(api.echoMap(aMapArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoMap(aMapArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -923,12 +921,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val wrapperArg = args[0] as AllClassesWrapper - var wrapped: List - try { - wrapped = listOf(api.echoClassWrapper(wrapperArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoClassWrapper(wrapperArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -945,12 +943,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val anEnumArg = AnEnum.ofRaw(args[0] as Int)!! - var wrapped: List - try { - wrapped = listOf(api.echoEnum(anEnumArg).raw) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoEnum(anEnumArg).raw) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -967,12 +965,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aStringArg = args[0] as String - var wrapped: List - try { - wrapped = listOf(api.echoNamedDefaultString(aStringArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNamedDefaultString(aStringArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -989,12 +987,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aDoubleArg = args[0] as Double - var wrapped: List - try { - wrapped = listOf(api.echoOptionalDefaultDouble(aDoubleArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoOptionalDefaultDouble(aDoubleArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1011,12 +1009,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val anIntArg = args[0].let { if (it is Int) it.toLong() else it as Long } - var wrapped: List - try { - wrapped = listOf(api.echoRequiredInt(anIntArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoRequiredInt(anIntArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1033,12 +1031,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val everythingArg = args[0] as AllNullableTypes? - var wrapped: List - try { - wrapped = listOf(api.echoAllNullableTypes(everythingArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoAllNullableTypes(everythingArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1055,12 +1053,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val everythingArg = args[0] as AllNullableTypesWithoutRecursion? - var wrapped: List - try { - wrapped = listOf(api.echoAllNullableTypesWithoutRecursion(everythingArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoAllNullableTypesWithoutRecursion(everythingArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1077,12 +1075,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val wrapperArg = args[0] as AllClassesWrapper - var wrapped: List - try { - wrapped = listOf(api.extractNestedNullableString(wrapperArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.extractNestedNullableString(wrapperArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1099,12 +1097,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val nullableStringArg = args[0] as String? - var wrapped: List - try { - wrapped = listOf(api.createNestedNullableString(nullableStringArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.createNestedNullableString(nullableStringArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1123,15 +1121,14 @@ interface HostIntegrationCoreApi { val aNullableBoolArg = args[0] as Boolean? val aNullableIntArg = args[1].let { if (it is Int) it.toLong() else it as Long? } val aNullableStringArg = args[2] as String? - var wrapped: List - try { - wrapped = + val wrapped: List = + try { listOf( api.sendMultipleNullableTypes( aNullableBoolArg, aNullableIntArg, aNullableStringArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1150,15 +1147,14 @@ interface HostIntegrationCoreApi { val aNullableBoolArg = args[0] as Boolean? val aNullableIntArg = args[1].let { if (it is Int) it.toLong() else it as Long? } val aNullableStringArg = args[2] as String? - var wrapped: List - try { - wrapped = + val wrapped: List = + try { listOf( api.sendMultipleNullableTypesWithoutRecursion( aNullableBoolArg, aNullableIntArg, aNullableStringArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1175,12 +1171,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableIntArg = args[0].let { if (it is Int) it.toLong() else it as Long? } - var wrapped: List - try { - wrapped = listOf(api.echoNullableInt(aNullableIntArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNullableInt(aNullableIntArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1197,12 +1193,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableDoubleArg = args[0] as Double? - var wrapped: List - try { - wrapped = listOf(api.echoNullableDouble(aNullableDoubleArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNullableDouble(aNullableDoubleArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1219,12 +1215,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableBoolArg = args[0] as Boolean? - var wrapped: List - try { - wrapped = listOf(api.echoNullableBool(aNullableBoolArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNullableBool(aNullableBoolArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1241,12 +1237,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableStringArg = args[0] as String? - var wrapped: List - try { - wrapped = listOf(api.echoNullableString(aNullableStringArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNullableString(aNullableStringArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1263,12 +1259,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableUint8ListArg = args[0] as ByteArray? - var wrapped: List - try { - wrapped = listOf(api.echoNullableUint8List(aNullableUint8ListArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNullableUint8List(aNullableUint8ListArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1285,12 +1281,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableObjectArg = args[0] - var wrapped: List - try { - wrapped = listOf(api.echoNullableObject(aNullableObjectArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNullableObject(aNullableObjectArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1307,12 +1303,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableListArg = args[0] as List? - var wrapped: List - try { - wrapped = listOf(api.echoNullableList(aNullableListArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNullableList(aNullableListArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1329,12 +1325,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableMapArg = args[0] as Map? - var wrapped: List - try { - wrapped = listOf(api.echoNullableMap(aNullableMapArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNullableMap(aNullableMapArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1351,12 +1347,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val anEnumArg = if (args[0] == null) null else AnEnum.ofRaw(args[0] as Int) - var wrapped: List - try { - wrapped = listOf(api.echoNullableEnum(anEnumArg)?.raw) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNullableEnum(anEnumArg)?.raw) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1373,12 +1369,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableIntArg = args[0].let { if (it is Int) it.toLong() else it as Long? } - var wrapped: List - try { - wrapped = listOf(api.echoOptionalNullableInt(aNullableIntArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoOptionalNullableInt(aNullableIntArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -1395,12 +1391,12 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableStringArg = args[0] as String? - var wrapped: List - try { - wrapped = listOf(api.echoNamedNullableString(aNullableStringArg)) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + listOf(api.echoNamedNullableString(aNullableStringArg)) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { @@ -3246,13 +3242,13 @@ interface HostTrivialApi { codec) if (api != null) { channel.setMessageHandler { _, reply -> - var wrapped: List - try { - api.noop() - wrapped = listOf(null) - } catch (exception: Throwable) { - wrapped = wrapError(exception) - } + val wrapped: List = + try { + api.noop() + listOf(null) + } catch (exception: Throwable) { + wrapError(exception) + } reply.reply(wrapped) } } else { diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt index c64aab7d34f..6b51157f130 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt @@ -8,7 +8,7 @@ import io.flutter.embedding.engine.plugins.FlutterPlugin /** This plugin handles the native side of the integration tests in example/integration_test/. */ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { - var flutterApi: FlutterIntegrationCoreApi? = null + private var flutterApi: FlutterIntegrationCoreApi? = null override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) { HostIntegrationCoreApi.setUp(binding.binaryMessenger, this) 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 3a45a12a40f..6d0398cd795 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 @@ -75,20 +75,23 @@ struct AllTypes { var aString: String var anObject: Any - static func fromList(_ list: [Any?]) -> AllTypes? { - let aBool = list[0] as! Bool - let anInt = list[1] is Int64 ? list[1] as! Int64 : Int64(list[1] as! Int32) - let anInt64 = list[2] is Int64 ? list[2] as! Int64 : Int64(list[2] as! Int32) - let aDouble = list[3] as! Double - let aByteArray = list[4] as! FlutterStandardTypedData - let a4ByteArray = list[5] as! FlutterStandardTypedData - let a8ByteArray = list[6] as! FlutterStandardTypedData - let aFloatArray = list[7] as! FlutterStandardTypedData - let aList = list[8] as! [Any?] - let aMap = list[9] as! [AnyHashable: Any?] - let anEnum = AnEnum(rawValue: list[10] as! Int)! - let aString = list[11] as! String - let anObject = list[12]! + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> AllTypes? { + let aBool = __pigeon_list[0] as! Bool + let anInt = + __pigeon_list[1] is Int64 ? __pigeon_list[1] as! Int64 : Int64(__pigeon_list[1] as! Int32) + let anInt64 = + __pigeon_list[2] is Int64 ? __pigeon_list[2] as! Int64 : Int64(__pigeon_list[2] as! Int32) + let aDouble = __pigeon_list[3] as! Double + let aByteArray = __pigeon_list[4] as! FlutterStandardTypedData + let a4ByteArray = __pigeon_list[5] as! FlutterStandardTypedData + let a8ByteArray = __pigeon_list[6] as! FlutterStandardTypedData + let aFloatArray = __pigeon_list[7] as! FlutterStandardTypedData + let aList = __pigeon_list[8] as! [Any?] + let aMap = __pigeon_list[9] as! [AnyHashable: Any?] + let anEnum = AnEnum(rawValue: __pigeon_list[10] as! Int)! + let aString = __pigeon_list[11] as! String + let anObject = __pigeon_list[12]! return AllTypes( aBool: aBool, @@ -184,32 +187,39 @@ class AllNullableTypes { var aNullableObject: Any? var allNullableTypes: AllNullableTypes? - static func fromList(_ list: [Any?]) -> AllNullableTypes? { - let aNullableBool: Bool? = nilOrValue(list[0]) + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> AllNullableTypes? { + let aNullableBool: Bool? = nilOrValue(__pigeon_list[0]) let aNullableInt: Int64? = - isNullish(list[1]) ? nil : (list[1] is Int64? ? list[1] as! Int64? : Int64(list[1] as! Int32)) + isNullish(__pigeon_list[1]) + ? nil + : (__pigeon_list[1] is Int64? + ? __pigeon_list[1] as! Int64? : Int64(__pigeon_list[1] as! Int32)) let aNullableInt64: Int64? = - isNullish(list[2]) ? nil : (list[2] is Int64? ? list[2] as! Int64? : Int64(list[2] as! Int32)) - let aNullableDouble: Double? = nilOrValue(list[3]) - let aNullableByteArray: FlutterStandardTypedData? = nilOrValue(list[4]) - let aNullable4ByteArray: FlutterStandardTypedData? = nilOrValue(list[5]) - let aNullable8ByteArray: FlutterStandardTypedData? = nilOrValue(list[6]) - let aNullableFloatArray: FlutterStandardTypedData? = nilOrValue(list[7]) - let aNullableList: [Any?]? = nilOrValue(list[8]) - let aNullableMap: [AnyHashable: Any?]? = nilOrValue(list[9]) - let nullableNestedList: [[Bool?]?]? = nilOrValue(list[10]) - let nullableMapWithAnnotations: [String?: String?]? = nilOrValue(list[11]) - let nullableMapWithObject: [String?: Any?]? = nilOrValue(list[12]) + isNullish(__pigeon_list[2]) + ? nil + : (__pigeon_list[2] is Int64? + ? __pigeon_list[2] as! Int64? : Int64(__pigeon_list[2] as! Int32)) + let aNullableDouble: Double? = nilOrValue(__pigeon_list[3]) + let aNullableByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[4]) + let aNullable4ByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[5]) + let aNullable8ByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[6]) + let aNullableFloatArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[7]) + let aNullableList: [Any?]? = nilOrValue(__pigeon_list[8]) + let aNullableMap: [AnyHashable: Any?]? = nilOrValue(__pigeon_list[9]) + let nullableNestedList: [[Bool?]?]? = nilOrValue(__pigeon_list[10]) + let nullableMapWithAnnotations: [String?: String?]? = nilOrValue(__pigeon_list[11]) + let nullableMapWithObject: [String?: Any?]? = nilOrValue(__pigeon_list[12]) var aNullableEnum: AnEnum? = nil - let aNullableEnumEnumVal: Int? = nilOrValue(list[13]) + let aNullableEnumEnumVal: Int? = nilOrValue(__pigeon_list[13]) if let aNullableEnumRawValue = aNullableEnumEnumVal { aNullableEnum = AnEnum(rawValue: aNullableEnumRawValue)! } - let aNullableString: String? = nilOrValue(list[14]) - let aNullableObject: Any? = list[15] + let aNullableString: String? = nilOrValue(__pigeon_list[14]) + let aNullableObject: Any? = __pigeon_list[15] var allNullableTypes: AllNullableTypes? = nil - if let allNullableTypesList: [Any?] = nilOrValue(list[16]) { - allNullableTypes = AllNullableTypes.fromList(allNullableTypesList) + if let allNullableTypesList: AllNullableTypes = nilOrValue(__pigeon_list[16]) { + allNullableTypes = allNullableTypesList as AllNullableTypes } return AllNullableTypes( @@ -250,7 +260,7 @@ class AllNullableTypes { aNullableEnum?.rawValue, aNullableString, aNullableObject, - allNullableTypes?.toList(), + allNullableTypes, ] } } @@ -278,29 +288,36 @@ struct AllNullableTypesWithoutRecursion { var aNullableString: String? = nil var aNullableObject: Any? = nil - static func fromList(_ list: [Any?]) -> AllNullableTypesWithoutRecursion? { - let aNullableBool: Bool? = nilOrValue(list[0]) + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> AllNullableTypesWithoutRecursion? { + let aNullableBool: Bool? = nilOrValue(__pigeon_list[0]) let aNullableInt: Int64? = - isNullish(list[1]) ? nil : (list[1] is Int64? ? list[1] as! Int64? : Int64(list[1] as! Int32)) + isNullish(__pigeon_list[1]) + ? nil + : (__pigeon_list[1] is Int64? + ? __pigeon_list[1] as! Int64? : Int64(__pigeon_list[1] as! Int32)) let aNullableInt64: Int64? = - isNullish(list[2]) ? nil : (list[2] is Int64? ? list[2] as! Int64? : Int64(list[2] as! Int32)) - let aNullableDouble: Double? = nilOrValue(list[3]) - let aNullableByteArray: FlutterStandardTypedData? = nilOrValue(list[4]) - let aNullable4ByteArray: FlutterStandardTypedData? = nilOrValue(list[5]) - let aNullable8ByteArray: FlutterStandardTypedData? = nilOrValue(list[6]) - let aNullableFloatArray: FlutterStandardTypedData? = nilOrValue(list[7]) - let aNullableList: [Any?]? = nilOrValue(list[8]) - let aNullableMap: [AnyHashable: Any?]? = nilOrValue(list[9]) - let nullableNestedList: [[Bool?]?]? = nilOrValue(list[10]) - let nullableMapWithAnnotations: [String?: String?]? = nilOrValue(list[11]) - let nullableMapWithObject: [String?: Any?]? = nilOrValue(list[12]) + isNullish(__pigeon_list[2]) + ? nil + : (__pigeon_list[2] is Int64? + ? __pigeon_list[2] as! Int64? : Int64(__pigeon_list[2] as! Int32)) + let aNullableDouble: Double? = nilOrValue(__pigeon_list[3]) + let aNullableByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[4]) + let aNullable4ByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[5]) + let aNullable8ByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[6]) + let aNullableFloatArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[7]) + let aNullableList: [Any?]? = nilOrValue(__pigeon_list[8]) + let aNullableMap: [AnyHashable: Any?]? = nilOrValue(__pigeon_list[9]) + let nullableNestedList: [[Bool?]?]? = nilOrValue(__pigeon_list[10]) + let nullableMapWithAnnotations: [String?: String?]? = nilOrValue(__pigeon_list[11]) + let nullableMapWithObject: [String?: Any?]? = nilOrValue(__pigeon_list[12]) var aNullableEnum: AnEnum? = nil - let aNullableEnumEnumVal: Int? = nilOrValue(list[13]) + let aNullableEnumEnumVal: Int? = nilOrValue(__pigeon_list[13]) if let aNullableEnumRawValue = aNullableEnumEnumVal { aNullableEnum = AnEnum(rawValue: aNullableEnumRawValue)! } - let aNullableString: String? = nilOrValue(list[14]) - let aNullableObject: Any? = list[15] + let aNullableString: String? = nilOrValue(__pigeon_list[14]) + let aNullableObject: Any? = __pigeon_list[15] return AllNullableTypesWithoutRecursion( aNullableBool: aNullableBool, @@ -355,16 +372,19 @@ struct AllClassesWrapper { var allNullableTypesWithoutRecursion: AllNullableTypesWithoutRecursion? = nil var allTypes: AllTypes? = nil - static func fromList(_ list: [Any?]) -> AllClassesWrapper? { - let allNullableTypes = AllNullableTypes.fromList(list[0] as! [Any?])! + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> AllClassesWrapper? { + let allNullableTypes = __pigeon_list[0] as! AllNullableTypes var allNullableTypesWithoutRecursion: AllNullableTypesWithoutRecursion? = nil - if let allNullableTypesWithoutRecursionList: [Any?] = nilOrValue(list[1]) { - allNullableTypesWithoutRecursion = AllNullableTypesWithoutRecursion.fromList( - allNullableTypesWithoutRecursionList) + if let allNullableTypesWithoutRecursionList: AllNullableTypesWithoutRecursion = nilOrValue( + __pigeon_list[1]) + { + allNullableTypesWithoutRecursion = + allNullableTypesWithoutRecursionList as AllNullableTypesWithoutRecursion } var allTypes: AllTypes? = nil - if let allTypesList: [Any?] = nilOrValue(list[2]) { - allTypes = AllTypes.fromList(allTypesList) + if let allTypesList: AllTypes = nilOrValue(__pigeon_list[2]) { + allTypes = allTypesList as AllTypes } return AllClassesWrapper( @@ -375,9 +395,9 @@ struct AllClassesWrapper { } func toList() -> [Any?] { return [ - allNullableTypes.toList(), - allNullableTypesWithoutRecursion?.toList(), - allTypes?.toList(), + allNullableTypes, + allNullableTypesWithoutRecursion, + allTypes, ] } } @@ -388,8 +408,9 @@ struct AllClassesWrapper { struct TestMessage { var testList: [Any?]? = nil - static func fromList(_ list: [Any?]) -> TestMessage? { - let testList: [Any?]? = nilOrValue(list[0]) + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> TestMessage? { + let testList: [Any?]? = nilOrValue(__pigeon_list[0]) return TestMessage( testList: testList 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 3a45a12a40f..6d0398cd795 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 @@ -75,20 +75,23 @@ struct AllTypes { var aString: String var anObject: Any - static func fromList(_ list: [Any?]) -> AllTypes? { - let aBool = list[0] as! Bool - let anInt = list[1] is Int64 ? list[1] as! Int64 : Int64(list[1] as! Int32) - let anInt64 = list[2] is Int64 ? list[2] as! Int64 : Int64(list[2] as! Int32) - let aDouble = list[3] as! Double - let aByteArray = list[4] as! FlutterStandardTypedData - let a4ByteArray = list[5] as! FlutterStandardTypedData - let a8ByteArray = list[6] as! FlutterStandardTypedData - let aFloatArray = list[7] as! FlutterStandardTypedData - let aList = list[8] as! [Any?] - let aMap = list[9] as! [AnyHashable: Any?] - let anEnum = AnEnum(rawValue: list[10] as! Int)! - let aString = list[11] as! String - let anObject = list[12]! + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> AllTypes? { + let aBool = __pigeon_list[0] as! Bool + let anInt = + __pigeon_list[1] is Int64 ? __pigeon_list[1] as! Int64 : Int64(__pigeon_list[1] as! Int32) + let anInt64 = + __pigeon_list[2] is Int64 ? __pigeon_list[2] as! Int64 : Int64(__pigeon_list[2] as! Int32) + let aDouble = __pigeon_list[3] as! Double + let aByteArray = __pigeon_list[4] as! FlutterStandardTypedData + let a4ByteArray = __pigeon_list[5] as! FlutterStandardTypedData + let a8ByteArray = __pigeon_list[6] as! FlutterStandardTypedData + let aFloatArray = __pigeon_list[7] as! FlutterStandardTypedData + let aList = __pigeon_list[8] as! [Any?] + let aMap = __pigeon_list[9] as! [AnyHashable: Any?] + let anEnum = AnEnum(rawValue: __pigeon_list[10] as! Int)! + let aString = __pigeon_list[11] as! String + let anObject = __pigeon_list[12]! return AllTypes( aBool: aBool, @@ -184,32 +187,39 @@ class AllNullableTypes { var aNullableObject: Any? var allNullableTypes: AllNullableTypes? - static func fromList(_ list: [Any?]) -> AllNullableTypes? { - let aNullableBool: Bool? = nilOrValue(list[0]) + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> AllNullableTypes? { + let aNullableBool: Bool? = nilOrValue(__pigeon_list[0]) let aNullableInt: Int64? = - isNullish(list[1]) ? nil : (list[1] is Int64? ? list[1] as! Int64? : Int64(list[1] as! Int32)) + isNullish(__pigeon_list[1]) + ? nil + : (__pigeon_list[1] is Int64? + ? __pigeon_list[1] as! Int64? : Int64(__pigeon_list[1] as! Int32)) let aNullableInt64: Int64? = - isNullish(list[2]) ? nil : (list[2] is Int64? ? list[2] as! Int64? : Int64(list[2] as! Int32)) - let aNullableDouble: Double? = nilOrValue(list[3]) - let aNullableByteArray: FlutterStandardTypedData? = nilOrValue(list[4]) - let aNullable4ByteArray: FlutterStandardTypedData? = nilOrValue(list[5]) - let aNullable8ByteArray: FlutterStandardTypedData? = nilOrValue(list[6]) - let aNullableFloatArray: FlutterStandardTypedData? = nilOrValue(list[7]) - let aNullableList: [Any?]? = nilOrValue(list[8]) - let aNullableMap: [AnyHashable: Any?]? = nilOrValue(list[9]) - let nullableNestedList: [[Bool?]?]? = nilOrValue(list[10]) - let nullableMapWithAnnotations: [String?: String?]? = nilOrValue(list[11]) - let nullableMapWithObject: [String?: Any?]? = nilOrValue(list[12]) + isNullish(__pigeon_list[2]) + ? nil + : (__pigeon_list[2] is Int64? + ? __pigeon_list[2] as! Int64? : Int64(__pigeon_list[2] as! Int32)) + let aNullableDouble: Double? = nilOrValue(__pigeon_list[3]) + let aNullableByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[4]) + let aNullable4ByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[5]) + let aNullable8ByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[6]) + let aNullableFloatArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[7]) + let aNullableList: [Any?]? = nilOrValue(__pigeon_list[8]) + let aNullableMap: [AnyHashable: Any?]? = nilOrValue(__pigeon_list[9]) + let nullableNestedList: [[Bool?]?]? = nilOrValue(__pigeon_list[10]) + let nullableMapWithAnnotations: [String?: String?]? = nilOrValue(__pigeon_list[11]) + let nullableMapWithObject: [String?: Any?]? = nilOrValue(__pigeon_list[12]) var aNullableEnum: AnEnum? = nil - let aNullableEnumEnumVal: Int? = nilOrValue(list[13]) + let aNullableEnumEnumVal: Int? = nilOrValue(__pigeon_list[13]) if let aNullableEnumRawValue = aNullableEnumEnumVal { aNullableEnum = AnEnum(rawValue: aNullableEnumRawValue)! } - let aNullableString: String? = nilOrValue(list[14]) - let aNullableObject: Any? = list[15] + let aNullableString: String? = nilOrValue(__pigeon_list[14]) + let aNullableObject: Any? = __pigeon_list[15] var allNullableTypes: AllNullableTypes? = nil - if let allNullableTypesList: [Any?] = nilOrValue(list[16]) { - allNullableTypes = AllNullableTypes.fromList(allNullableTypesList) + if let allNullableTypesList: AllNullableTypes = nilOrValue(__pigeon_list[16]) { + allNullableTypes = allNullableTypesList as AllNullableTypes } return AllNullableTypes( @@ -250,7 +260,7 @@ class AllNullableTypes { aNullableEnum?.rawValue, aNullableString, aNullableObject, - allNullableTypes?.toList(), + allNullableTypes, ] } } @@ -278,29 +288,36 @@ struct AllNullableTypesWithoutRecursion { var aNullableString: String? = nil var aNullableObject: Any? = nil - static func fromList(_ list: [Any?]) -> AllNullableTypesWithoutRecursion? { - let aNullableBool: Bool? = nilOrValue(list[0]) + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> AllNullableTypesWithoutRecursion? { + let aNullableBool: Bool? = nilOrValue(__pigeon_list[0]) let aNullableInt: Int64? = - isNullish(list[1]) ? nil : (list[1] is Int64? ? list[1] as! Int64? : Int64(list[1] as! Int32)) + isNullish(__pigeon_list[1]) + ? nil + : (__pigeon_list[1] is Int64? + ? __pigeon_list[1] as! Int64? : Int64(__pigeon_list[1] as! Int32)) let aNullableInt64: Int64? = - isNullish(list[2]) ? nil : (list[2] is Int64? ? list[2] as! Int64? : Int64(list[2] as! Int32)) - let aNullableDouble: Double? = nilOrValue(list[3]) - let aNullableByteArray: FlutterStandardTypedData? = nilOrValue(list[4]) - let aNullable4ByteArray: FlutterStandardTypedData? = nilOrValue(list[5]) - let aNullable8ByteArray: FlutterStandardTypedData? = nilOrValue(list[6]) - let aNullableFloatArray: FlutterStandardTypedData? = nilOrValue(list[7]) - let aNullableList: [Any?]? = nilOrValue(list[8]) - let aNullableMap: [AnyHashable: Any?]? = nilOrValue(list[9]) - let nullableNestedList: [[Bool?]?]? = nilOrValue(list[10]) - let nullableMapWithAnnotations: [String?: String?]? = nilOrValue(list[11]) - let nullableMapWithObject: [String?: Any?]? = nilOrValue(list[12]) + isNullish(__pigeon_list[2]) + ? nil + : (__pigeon_list[2] is Int64? + ? __pigeon_list[2] as! Int64? : Int64(__pigeon_list[2] as! Int32)) + let aNullableDouble: Double? = nilOrValue(__pigeon_list[3]) + let aNullableByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[4]) + let aNullable4ByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[5]) + let aNullable8ByteArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[6]) + let aNullableFloatArray: FlutterStandardTypedData? = nilOrValue(__pigeon_list[7]) + let aNullableList: [Any?]? = nilOrValue(__pigeon_list[8]) + let aNullableMap: [AnyHashable: Any?]? = nilOrValue(__pigeon_list[9]) + let nullableNestedList: [[Bool?]?]? = nilOrValue(__pigeon_list[10]) + let nullableMapWithAnnotations: [String?: String?]? = nilOrValue(__pigeon_list[11]) + let nullableMapWithObject: [String?: Any?]? = nilOrValue(__pigeon_list[12]) var aNullableEnum: AnEnum? = nil - let aNullableEnumEnumVal: Int? = nilOrValue(list[13]) + let aNullableEnumEnumVal: Int? = nilOrValue(__pigeon_list[13]) if let aNullableEnumRawValue = aNullableEnumEnumVal { aNullableEnum = AnEnum(rawValue: aNullableEnumRawValue)! } - let aNullableString: String? = nilOrValue(list[14]) - let aNullableObject: Any? = list[15] + let aNullableString: String? = nilOrValue(__pigeon_list[14]) + let aNullableObject: Any? = __pigeon_list[15] return AllNullableTypesWithoutRecursion( aNullableBool: aNullableBool, @@ -355,16 +372,19 @@ struct AllClassesWrapper { var allNullableTypesWithoutRecursion: AllNullableTypesWithoutRecursion? = nil var allTypes: AllTypes? = nil - static func fromList(_ list: [Any?]) -> AllClassesWrapper? { - let allNullableTypes = AllNullableTypes.fromList(list[0] as! [Any?])! + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> AllClassesWrapper? { + let allNullableTypes = __pigeon_list[0] as! AllNullableTypes var allNullableTypesWithoutRecursion: AllNullableTypesWithoutRecursion? = nil - if let allNullableTypesWithoutRecursionList: [Any?] = nilOrValue(list[1]) { - allNullableTypesWithoutRecursion = AllNullableTypesWithoutRecursion.fromList( - allNullableTypesWithoutRecursionList) + if let allNullableTypesWithoutRecursionList: AllNullableTypesWithoutRecursion = nilOrValue( + __pigeon_list[1]) + { + allNullableTypesWithoutRecursion = + allNullableTypesWithoutRecursionList as AllNullableTypesWithoutRecursion } var allTypes: AllTypes? = nil - if let allTypesList: [Any?] = nilOrValue(list[2]) { - allTypes = AllTypes.fromList(allTypesList) + if let allTypesList: AllTypes = nilOrValue(__pigeon_list[2]) { + allTypes = allTypesList as AllTypes } return AllClassesWrapper( @@ -375,9 +395,9 @@ struct AllClassesWrapper { } func toList() -> [Any?] { return [ - allNullableTypes.toList(), - allNullableTypesWithoutRecursion?.toList(), - allTypes?.toList(), + allNullableTypes, + allNullableTypesWithoutRecursion, + allTypes, ] } } @@ -388,8 +408,9 @@ struct AllClassesWrapper { struct TestMessage { var testList: [Any?]? = nil - static func fromList(_ list: [Any?]) -> TestMessage? { - let testList: [Any?]? = nilOrValue(list[0]) + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ __pigeon_list: [Any?]) -> TestMessage? { + let testList: [Any?]? = nilOrValue(__pigeon_list[0]) return TestMessage( testList: testList 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 fd12459454a..fa3d7026fd2 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 @@ -149,15 +149,18 @@ EncodableList AllTypes::ToEncodableList() const { return list; } -AllTypes AllTypes::FromEncodableList(const EncodableList& list) { - AllTypes decoded( - std::get(list[0]), list[1].LongValue(), list[2].LongValue(), - std::get(list[3]), std::get>(list[4]), - std::get>(list[5]), - std::get>(list[6]), - std::get>(list[7]), std::get(list[8]), - std::get(list[9]), (AnEnum)(std::get(list[10])), - std::get(list[11]), list[12]); +AllTypes AllTypes::FromEncodableList(const EncodableList& __pigeon_list) { + AllTypes decoded(std::get(__pigeon_list[0]), + __pigeon_list[1].LongValue(), __pigeon_list[2].LongValue(), + std::get(__pigeon_list[3]), + std::get>(__pigeon_list[4]), + std::get>(__pigeon_list[5]), + std::get>(__pigeon_list[6]), + std::get>(__pigeon_list[7]), + std::get(__pigeon_list[8]), + std::get(__pigeon_list[9]), + (AnEnum)(std::get(__pigeon_list[10])), + std::get(__pigeon_list[11]), __pigeon_list[12]); return decoded; } @@ -605,94 +608,94 @@ EncodableList AllNullableTypes::ToEncodableList() const { : EncodableValue()); list.push_back(a_nullable_object_ ? *a_nullable_object_ : EncodableValue()); list.push_back(all_nullable_types_ - ? EncodableValue(all_nullable_types_->ToEncodableList()) + ? CustomEncodableValue(*all_nullable_types_) : EncodableValue()); return list; } AllNullableTypes AllNullableTypes::FromEncodableList( - const EncodableList& list) { + const EncodableList& __pigeon_list) { AllNullableTypes decoded; - auto& encodable_a_nullable_bool = list[0]; + auto& encodable_a_nullable_bool = __pigeon_list[0]; if (!encodable_a_nullable_bool.IsNull()) { decoded.set_a_nullable_bool(std::get(encodable_a_nullable_bool)); } - auto& encodable_a_nullable_int = list[1]; + auto& encodable_a_nullable_int = __pigeon_list[1]; if (!encodable_a_nullable_int.IsNull()) { decoded.set_a_nullable_int(encodable_a_nullable_int.LongValue()); } - auto& encodable_a_nullable_int64 = list[2]; + auto& encodable_a_nullable_int64 = __pigeon_list[2]; if (!encodable_a_nullable_int64.IsNull()) { decoded.set_a_nullable_int64(encodable_a_nullable_int64.LongValue()); } - auto& encodable_a_nullable_double = list[3]; + auto& encodable_a_nullable_double = __pigeon_list[3]; if (!encodable_a_nullable_double.IsNull()) { decoded.set_a_nullable_double( std::get(encodable_a_nullable_double)); } - auto& encodable_a_nullable_byte_array = list[4]; + auto& encodable_a_nullable_byte_array = __pigeon_list[4]; if (!encodable_a_nullable_byte_array.IsNull()) { decoded.set_a_nullable_byte_array( std::get>(encodable_a_nullable_byte_array)); } - auto& encodable_a_nullable4_byte_array = list[5]; + auto& encodable_a_nullable4_byte_array = __pigeon_list[5]; if (!encodable_a_nullable4_byte_array.IsNull()) { decoded.set_a_nullable4_byte_array( std::get>(encodable_a_nullable4_byte_array)); } - auto& encodable_a_nullable8_byte_array = list[6]; + auto& encodable_a_nullable8_byte_array = __pigeon_list[6]; if (!encodable_a_nullable8_byte_array.IsNull()) { decoded.set_a_nullable8_byte_array( std::get>(encodable_a_nullable8_byte_array)); } - auto& encodable_a_nullable_float_array = list[7]; + auto& encodable_a_nullable_float_array = __pigeon_list[7]; if (!encodable_a_nullable_float_array.IsNull()) { decoded.set_a_nullable_float_array( std::get>(encodable_a_nullable_float_array)); } - auto& encodable_a_nullable_list = list[8]; + auto& encodable_a_nullable_list = __pigeon_list[8]; if (!encodable_a_nullable_list.IsNull()) { decoded.set_a_nullable_list( std::get(encodable_a_nullable_list)); } - auto& encodable_a_nullable_map = list[9]; + auto& encodable_a_nullable_map = __pigeon_list[9]; if (!encodable_a_nullable_map.IsNull()) { decoded.set_a_nullable_map( std::get(encodable_a_nullable_map)); } - auto& encodable_nullable_nested_list = list[10]; + auto& encodable_nullable_nested_list = __pigeon_list[10]; if (!encodable_nullable_nested_list.IsNull()) { decoded.set_nullable_nested_list( std::get(encodable_nullable_nested_list)); } - auto& encodable_nullable_map_with_annotations = list[11]; + auto& encodable_nullable_map_with_annotations = __pigeon_list[11]; if (!encodable_nullable_map_with_annotations.IsNull()) { decoded.set_nullable_map_with_annotations( std::get(encodable_nullable_map_with_annotations)); } - auto& encodable_nullable_map_with_object = list[12]; + auto& encodable_nullable_map_with_object = __pigeon_list[12]; if (!encodable_nullable_map_with_object.IsNull()) { decoded.set_nullable_map_with_object( std::get(encodable_nullable_map_with_object)); } - auto& encodable_a_nullable_enum = list[13]; + auto& encodable_a_nullable_enum = __pigeon_list[13]; if (!encodable_a_nullable_enum.IsNull()) { decoded.set_a_nullable_enum( (AnEnum)(std::get(encodable_a_nullable_enum))); } - auto& encodable_a_nullable_string = list[14]; + auto& encodable_a_nullable_string = __pigeon_list[14]; if (!encodable_a_nullable_string.IsNull()) { decoded.set_a_nullable_string( std::get(encodable_a_nullable_string)); } - auto& encodable_a_nullable_object = list[15]; + auto& encodable_a_nullable_object = __pigeon_list[15]; if (!encodable_a_nullable_object.IsNull()) { decoded.set_a_nullable_object(encodable_a_nullable_object); } - auto& encodable_all_nullable_types = list[16]; + auto& encodable_all_nullable_types = __pigeon_list[16]; if (!encodable_all_nullable_types.IsNull()) { - decoded.set_all_nullable_types(AllNullableTypes::FromEncodableList( - std::get(encodable_all_nullable_types))); + decoded.set_all_nullable_types( + std::get(encodable_all_nullable_types)); } return decoded; } @@ -1057,81 +1060,82 @@ EncodableList AllNullableTypesWithoutRecursion::ToEncodableList() const { } AllNullableTypesWithoutRecursion -AllNullableTypesWithoutRecursion::FromEncodableList(const EncodableList& list) { +AllNullableTypesWithoutRecursion::FromEncodableList( + const EncodableList& __pigeon_list) { AllNullableTypesWithoutRecursion decoded; - auto& encodable_a_nullable_bool = list[0]; + auto& encodable_a_nullable_bool = __pigeon_list[0]; if (!encodable_a_nullable_bool.IsNull()) { decoded.set_a_nullable_bool(std::get(encodable_a_nullable_bool)); } - auto& encodable_a_nullable_int = list[1]; + auto& encodable_a_nullable_int = __pigeon_list[1]; if (!encodable_a_nullable_int.IsNull()) { decoded.set_a_nullable_int(encodable_a_nullable_int.LongValue()); } - auto& encodable_a_nullable_int64 = list[2]; + auto& encodable_a_nullable_int64 = __pigeon_list[2]; if (!encodable_a_nullable_int64.IsNull()) { decoded.set_a_nullable_int64(encodable_a_nullable_int64.LongValue()); } - auto& encodable_a_nullable_double = list[3]; + auto& encodable_a_nullable_double = __pigeon_list[3]; if (!encodable_a_nullable_double.IsNull()) { decoded.set_a_nullable_double( std::get(encodable_a_nullable_double)); } - auto& encodable_a_nullable_byte_array = list[4]; + auto& encodable_a_nullable_byte_array = __pigeon_list[4]; if (!encodable_a_nullable_byte_array.IsNull()) { decoded.set_a_nullable_byte_array( std::get>(encodable_a_nullable_byte_array)); } - auto& encodable_a_nullable4_byte_array = list[5]; + auto& encodable_a_nullable4_byte_array = __pigeon_list[5]; if (!encodable_a_nullable4_byte_array.IsNull()) { decoded.set_a_nullable4_byte_array( std::get>(encodable_a_nullable4_byte_array)); } - auto& encodable_a_nullable8_byte_array = list[6]; + auto& encodable_a_nullable8_byte_array = __pigeon_list[6]; if (!encodable_a_nullable8_byte_array.IsNull()) { decoded.set_a_nullable8_byte_array( std::get>(encodable_a_nullable8_byte_array)); } - auto& encodable_a_nullable_float_array = list[7]; + auto& encodable_a_nullable_float_array = __pigeon_list[7]; if (!encodable_a_nullable_float_array.IsNull()) { decoded.set_a_nullable_float_array( std::get>(encodable_a_nullable_float_array)); } - auto& encodable_a_nullable_list = list[8]; + auto& encodable_a_nullable_list = __pigeon_list[8]; if (!encodable_a_nullable_list.IsNull()) { decoded.set_a_nullable_list( std::get(encodable_a_nullable_list)); } - auto& encodable_a_nullable_map = list[9]; + auto& encodable_a_nullable_map = __pigeon_list[9]; if (!encodable_a_nullable_map.IsNull()) { decoded.set_a_nullable_map( std::get(encodable_a_nullable_map)); } - auto& encodable_nullable_nested_list = list[10]; + auto& encodable_nullable_nested_list = __pigeon_list[10]; if (!encodable_nullable_nested_list.IsNull()) { decoded.set_nullable_nested_list( std::get(encodable_nullable_nested_list)); } - auto& encodable_nullable_map_with_annotations = list[11]; + auto& encodable_nullable_map_with_annotations = __pigeon_list[11]; if (!encodable_nullable_map_with_annotations.IsNull()) { decoded.set_nullable_map_with_annotations( std::get(encodable_nullable_map_with_annotations)); } - auto& encodable_nullable_map_with_object = list[12]; + auto& encodable_nullable_map_with_object = __pigeon_list[12]; if (!encodable_nullable_map_with_object.IsNull()) { decoded.set_nullable_map_with_object( std::get(encodable_nullable_map_with_object)); } - auto& encodable_a_nullable_enum = list[13]; + auto& encodable_a_nullable_enum = __pigeon_list[13]; if (!encodable_a_nullable_enum.IsNull()) { decoded.set_a_nullable_enum( (AnEnum)(std::get(encodable_a_nullable_enum))); } - auto& encodable_a_nullable_string = list[14]; + auto& encodable_a_nullable_string = __pigeon_list[14]; if (!encodable_a_nullable_string.IsNull()) { decoded.set_a_nullable_string( std::get(encodable_a_nullable_string)); } - auto& encodable_a_nullable_object = list[15]; + auto& encodable_a_nullable_object = __pigeon_list[15]; if (!encodable_a_nullable_object.IsNull()) { decoded.set_a_nullable_object(encodable_a_nullable_object); } @@ -1226,32 +1230,28 @@ void AllClassesWrapper::set_all_types(const AllTypes& value_arg) { EncodableList AllClassesWrapper::ToEncodableList() const { EncodableList list; list.reserve(3); - list.push_back(EncodableValue(all_nullable_types_->ToEncodableList())); + list.push_back(CustomEncodableValue(all_nullable_types_)); list.push_back( all_nullable_types_without_recursion_ - ? EncodableValue( - all_nullable_types_without_recursion_->ToEncodableList()) + ? CustomEncodableValue(*all_nullable_types_without_recursion_) : EncodableValue()); - list.push_back(all_types_ ? EncodableValue(all_types_->ToEncodableList()) + list.push_back(all_types_ ? CustomEncodableValue(*all_types_) : EncodableValue()); return list; } AllClassesWrapper AllClassesWrapper::FromEncodableList( - const EncodableList& list) { - AllClassesWrapper decoded( - AllNullableTypes::FromEncodableList(std::get(list[0]))); - auto& encodable_all_nullable_types_without_recursion = list[1]; + const EncodableList& __pigeon_list) { + AllClassesWrapper decoded(std::get(__pigeon_list[0])); + auto& encodable_all_nullable_types_without_recursion = __pigeon_list[1]; if (!encodable_all_nullable_types_without_recursion.IsNull()) { decoded.set_all_nullable_types_without_recursion( - AllNullableTypesWithoutRecursion::FromEncodableList( - std::get( - encodable_all_nullable_types_without_recursion))); + std::get( + encodable_all_nullable_types_without_recursion)); } - auto& encodable_all_types = list[2]; + auto& encodable_all_types = __pigeon_list[2]; if (!encodable_all_types.IsNull()) { - decoded.set_all_types(AllTypes::FromEncodableList( - std::get(encodable_all_types))); + decoded.set_all_types(std::get(encodable_all_types)); } return decoded; } @@ -1284,9 +1284,9 @@ EncodableList TestMessage::ToEncodableList() const { return list; } -TestMessage TestMessage::FromEncodableList(const EncodableList& list) { +TestMessage TestMessage::FromEncodableList(const EncodableList& __pigeon_list) { TestMessage decoded; - auto& encodable_test_list = list[0]; + auto& encodable_test_list = __pigeon_list[0]; if (!encodable_test_list.IsNull()) { decoded.set_test_list(std::get(encodable_test_list)); } From 66b79863d20cb70a4661921851ffa9eda8b7913e Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Thu, 28 Mar 2024 13:13:19 -0700 Subject: [PATCH 02/18] update tests --- packages/pigeon/lib/dart_generator.dart | 12 +------ packages/pigeon/lib/kotlin_generator.dart | 2 +- packages/pigeon/lib/pigeon_lib.dart | 7 ++++ .../lib/src/generated/core_tests.gen.dart | 10 +++--- .../lib/src/generated/message.gen.dart | 2 +- .../lib/src/generated/null_fields.gen.dart | 2 +- .../test/null_fields_test.dart | 30 ++++++++-------- packages/pigeon/test/cpp_generator_test.dart | 9 ++--- packages/pigeon/test/dart_generator_test.dart | 12 +++---- packages/pigeon/test/java_generator_test.dart | 7 ++-- .../pigeon/test/kotlin_generator_test.dart | 34 +++++++++---------- packages/pigeon/test/objc_generator_test.dart | 10 +++--- .../pigeon/test/swift_generator_test.dart | 8 +++-- 13 files changed, 69 insertions(+), 76 deletions(-) diff --git a/packages/pigeon/lib/dart_generator.dart b/packages/pigeon/lib/dart_generator.dart index 1de799a6198..d5688ca2162 100644 --- a/packages/pigeon/lib/dart_generator.dart +++ b/packages/pigeon/lib/dart_generator.dart @@ -251,17 +251,7 @@ class DartGenerator extends StructuredGenerator { final String genericType = _makeGenericTypeArguments(field.type); final String castCall = _makeGenericCastCall(field.type); final String nullableTag = field.type.isNullable ? '?' : ''; - if (field.type.isClass) { - final String nonNullValue = '$resultAt! as ${field.type.baseName}'; - if (field.type.isNullable) { - indent.format(''' -$resultAt != null -\t\t? $nonNullValue -\t\t: null''', leadingSpace: false, trailingNewline: false); - } else { - indent.add(nonNullValue); - } - } else if (field.type.isEnum) { + if (field.type.isEnum) { final String nonNullValue = '${field.type.baseName}.values[$resultAt! as int]'; if (field.type.isNullable) { diff --git a/packages/pigeon/lib/kotlin_generator.dart b/packages/pigeon/lib/kotlin_generator.dart index 1895aafdd21..48e453108d0 100644 --- a/packages/pigeon/lib/kotlin_generator.dart +++ b/packages/pigeon/lib/kotlin_generator.dart @@ -720,7 +720,7 @@ class KotlinGenerator extends StructuredGenerator { }); }); } else { - indent.addScoped('val wrapped: List = try {', '}', () { + indent.writeScoped('val wrapped: List = try {', '}', () { if (returnType.isVoid) { indent.writeln(call); indent.writeln('listOf(null)'); diff --git a/packages/pigeon/lib/pigeon_lib.dart b/packages/pigeon/lib/pigeon_lib.dart index d8b799b4836..addce55d54a 100644 --- a/packages/pigeon/lib/pigeon_lib.dart +++ b/packages/pigeon/lib/pigeon_lib.dart @@ -838,6 +838,13 @@ List _validateAst(Root root, String source) { lineNumber: _calculateLineNumberNullable(source, field.offset), )); } + if (customEnums.contains(typeArgument.baseName)) { + result.add(Error( + message: + 'Enum types aren\'t supported in type arguments in "${field.name}" in class "${classDefinition.name}".', + lineNumber: _calculateLineNumberNullable(source, field.offset), + )); + } } if (!(validTypes.contains(field.type.baseName) || customClasses.contains(field.type.baseName) || 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 90de1326fe5..4491365bdf4 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 @@ -220,8 +220,7 @@ class AllNullableTypes { result[13] != null ? AnEnum.values[result[13]! as int] : null, aNullableString: result[14] as String?, aNullableObject: result[15], - allNullableTypes: - result[16] != null ? result[16]! as AllNullableTypes : null, + allNullableTypes: result[16] as AllNullableTypes?, ); } } @@ -358,10 +357,9 @@ class AllClassesWrapper { result as List; return AllClassesWrapper( allNullableTypes: result[0]! as AllNullableTypes, - allNullableTypesWithoutRecursion: result[1] != null - ? result[1]! as AllNullableTypesWithoutRecursion - : null, - allTypes: result[2] != null ? result[2]! as AllTypes : null, + allNullableTypesWithoutRecursion: + result[1] as AllNullableTypesWithoutRecursion?, + allTypes: result[2] as AllTypes?, ); } } diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart index ca9604cf820..9a86943d653 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/message.gen.dart @@ -137,7 +137,7 @@ class MessageNested { static MessageNested decode(Object result) { result as List; return MessageNested( - request: result[0] != null ? result[0]! as MessageSearchRequest : null, + request: result[0] as MessageSearchRequest?, ); } } diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart index 30ceaf68f94..eb5ec19fbd6 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/src/generated/null_fields.gen.dart @@ -96,7 +96,7 @@ class NullFieldsSearchReply { result: result[0] as String?, error: result[1] as String?, indices: (result[2] as List?)?.cast(), - request: result[3] != null ? result[3]! as NullFieldsSearchRequest : null, + request: result[3] as NullFieldsSearchRequest?, type: result[4] != null ? NullFieldsSearchReplyType.values[result[4]! as int] : null, diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/test/null_fields_test.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/test/null_fields_test.dart index 112317a3895..aa0ecb02424 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/test/null_fields_test.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/test/null_fields_test.dart @@ -63,16 +63,17 @@ void main() { }); test('test reply decode with values', () { - final NullFieldsSearchReply reply = NullFieldsSearchReply.decode([ - 'result', - 'error', - [1, 2, 3], - [ - 'query', - 1, - ], - NullFieldsSearchReplyType.success.index, - ]); + final NullFieldsSearchReply reply = + NullFieldsSearchReply.decode(NullFieldsSearchReply( + result: 'result', + error: 'error', + indices: [1, 2, 3], + request: NullFieldsSearchRequest( + query: 'query', + identifier: 1, + ), + type: NullFieldsSearchReplyType.success, + ).encode()); expect(reply.result, 'result'); expect(reply.error, 'error'); @@ -118,11 +119,13 @@ void main() { }); test('test reply encode with values', () { + final NullFieldsSearchRequest request = + NullFieldsSearchRequest(query: 'query', identifier: 1); final NullFieldsSearchReply reply = NullFieldsSearchReply( result: 'result', error: 'error', indices: [1, 2, 3], - request: NullFieldsSearchRequest(query: 'query', identifier: 1), + request: request, type: NullFieldsSearchReplyType.success, ); @@ -130,10 +133,7 @@ void main() { 'result', 'error', [1, 2, 3], - [ - 'query', - 1, - ], + request, NullFieldsSearchReplyType.success.index, ]); }); diff --git a/packages/pigeon/test/cpp_generator_test.dart b/packages/pigeon/test/cpp_generator_test.dart index c2fdcd68f68..24839b52fdf 100644 --- a/packages/pigeon/test/cpp_generator_test.dart +++ b/packages/pigeon/test/cpp_generator_test.dart @@ -651,8 +651,7 @@ void main() { expect( code, contains( - 'nullable_nested_ ? EncodableValue(nullable_nested_->ToEncodableList()) ' - ': EncodableValue()')); + 'nullable_nested_ ? CustomEncodableValue(*nullable_nested_) : EncodableValue())')); // Serialization should use push_back, not initializer lists, to avoid // copies. @@ -805,13 +804,15 @@ void main() { 'non_nullable_nested_ = std::make_unique(value_arg);')); // Serialization uses the value directly. expect(code, contains('EncodableValue(non_nullable_bool_)')); - expect(code, contains('non_nullable_nested_->ToEncodableList()')); + expect(code, contains('CustomEncodableValue(non_nullable_nested_)')); // Serialization should use push_back, not initializer lists, to avoid // copies. expect(code, contains('list.reserve(4)')); expect( - code, contains('list.push_back(EncodableValue(non_nullable_bool_))')); + code, + contains( + 'list.push_back(CustomEncodableValue(non_nullable_nested_))')); } }); diff --git a/packages/pigeon/test/dart_generator_test.dart b/packages/pigeon/test/dart_generator_test.dart index 4c96bd7d74a..b6b6a34283d 100644 --- a/packages/pigeon/test/dart_generator_test.dart +++ b/packages/pigeon/test/dart_generator_test.dart @@ -246,13 +246,13 @@ void main() { expect( code, contains( - 'nested?.encode(),', + 'nested,', ), ); expect( - code.replaceAll('\n', ' ').replaceAll(' ', ''), + code, contains( - 'nested: result[0] != null ? Input.decode(result[0]! as List) : null', + 'nested: result[0] as Input?', ), ); }); @@ -295,13 +295,13 @@ void main() { expect( code, contains( - 'nested.encode(),', + 'nested,', ), ); expect( - code.replaceAll('\n', ' ').replaceAll(' ', ''), + code, contains( - 'nested: Input.decode(result[0]! as List)', + 'nested: result[0]! as Input', ), ); }); diff --git a/packages/pigeon/test/java_generator_test.dart b/packages/pigeon/test/java_generator_test.dart index 97cbfe8b4d0..c3db1f893e0 100644 --- a/packages/pigeon/test/java_generator_test.dart +++ b/packages/pigeon/test/java_generator_test.dart @@ -575,11 +575,8 @@ void main() { expect(code, contains('public static final class Outer')); expect(code, contains('public static final class Nested')); expect(code, contains('private @Nullable Nested nested;')); - expect( - code, - contains( - '(nested == null) ? null : Nested.fromList((ArrayList) nested)')); - expect(code, contains('add((nested == null) ? null : nested.toList());')); + ; + expect(code, contains('add(nested);')); }); test('gen one async Host Api', () { diff --git a/packages/pigeon/test/kotlin_generator_test.dart b/packages/pigeon/test/kotlin_generator_test.dart index d4817bf56e9..469745c6922 100644 --- a/packages/pigeon/test/kotlin_generator_test.dart +++ b/packages/pigeon/test/kotlin_generator_test.dart @@ -51,7 +51,7 @@ void main() { final String code = sink.toString(); expect(code, contains('data class Foobar (')); expect(code, contains('val field1: Long? = null')); - expect(code, contains('fun fromList(list: List): Foobar')); + expect(code, contains('fun fromList(__pigeon_list: List): Foobar')); expect(code, contains('fun toList(): List')); }); @@ -132,9 +132,10 @@ void main() { expect(code, contains('data class Bar (')); expect(code, contains('val field1: Foo,')); expect(code, contains('val field2: String')); - expect(code, contains('fun fromList(list: List): Bar')); - expect(code, contains('val field1 = Foo.ofRaw(list[0] as Int)!!\n')); - expect(code, contains('val field2 = list[1] as String\n')); + expect(code, contains('fun fromList(__pigeon_list: List): Bar')); + expect( + code, contains('val field1 = Foo.ofRaw(__pigeon_list[0] as Int)!!\n')); + expect(code, contains('val field2 = __pigeon_list[1] as String\n')); expect(code, contains('fun toList(): List')); }); @@ -236,11 +237,10 @@ void main() { channel.setMessageHandler { message, reply -> val args = message as List val inputArg = args[0] as Input - var wrapped: List - try { - wrapped = listOf(api.doSomething(inputArg)) + val wrapped: List = try { + listOf(api.doSomething(inputArg)) } catch (exception: Throwable) { - wrapped = wrapError(exception) + wrapError(exception) } reply.reply(wrapped) } @@ -390,7 +390,7 @@ void main() { expect( code, contains( - 'val aInt = list[1].let { if (it is Int) it.toLong() else it as Long }')); + 'val aInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long }')); expect(code, contains('val aNullableBool: Boolean? = null')); expect(code, contains('val aNullableInt: Long? = null')); expect(code, contains('val aNullableDouble: Double? = null')); @@ -402,7 +402,7 @@ void main() { expect( code, contains( - 'val aNullableInt = list[9].let { if (it is Int) it.toLong() else it as Long? }')); + 'val aNullableInt = __pigeon_list[9].let { if (it is Int) it.toLong() else it as Long? }')); }); test('gen one flutter api', () { @@ -589,8 +589,8 @@ void main() { ); final String code = sink.toString(); expect(code, contains('fun doSomething(): Output')); - expect(code, contains('wrapped = listOf(api.doSomething())')); - expect(code, contains('wrapped = wrapError(exception)')); + expect(code, contains('listOf(api.doSomething())')); + expect(code, contains('wrapError(exception)')); expect(code, contains('reply(wrapped)')); }); @@ -730,10 +730,8 @@ void main() { expect(code, contains('data class Outer')); expect(code, contains('data class Nested')); expect(code, contains('val nested: Nested? = null')); - expect(code, contains('fun fromList(list: List): Outer')); - expect( - code, contains('val nested: Nested? = (list[0] as List?)?.let')); - expect(code, contains('Nested.fromList(it)')); + expect(code, contains('fun fromList(__pigeon_list: List): Outer')); + expect(code, contains('val nested = __pigeon_list[0] as Nested?')); expect(code, contains('fun toList(): List')); }); @@ -1089,7 +1087,7 @@ void main() { ); final String code = sink.toString(); expect(code, contains('fun doit(): List')); - expect(code, contains('wrapped = listOf(api.doit())')); + expect(code, contains('listOf(api.doit())')); expect(code, contains('reply.reply(wrapped)')); }); @@ -1167,7 +1165,7 @@ void main() { code, contains( 'val yArg = args[1].let { if (it is Int) it.toLong() else it as Long }')); - expect(code, contains('wrapped = listOf(api.add(xArg, yArg))')); + expect(code, contains('listOf(api.add(xArg, yArg))')); expect(code, contains('reply.reply(wrapped)')); }); diff --git a/packages/pigeon/test/objc_generator_test.dart b/packages/pigeon/test/objc_generator_test.dart index 7717f0ca877..c0d46b12035 100644 --- a/packages/pigeon/test/objc_generator_test.dart +++ b/packages/pigeon/test/objc_generator_test.dart @@ -530,8 +530,10 @@ void main() { ); final String code = sink.toString(); expect(code, contains('@implementation Foobar')); - expect(code, - contains('pigeonResult.aBool = GetNullableObjectAtIndex(list, 0);')); + expect( + code, + contains( + 'pigeonResult.aBool = GetNullableObjectAtIndex(__pigeon_list, 0);')); }); test('nested class header', () { @@ -603,9 +605,7 @@ void main() { expect( code, contains( - 'pigeonResult.nested = [Input nullableFromList:(GetNullableObjectAtIndex(list, 0))];')); - expect( - code, contains('self.nested ? [self.nested toList] : [NSNull null]')); + 'pigeonResult.nested = GetNullableObjectAtIndex(__pigeon_list, 0);')); }); test('prefix class header', () { diff --git a/packages/pigeon/test/swift_generator_test.dart b/packages/pigeon/test/swift_generator_test.dart index 944a4bb2cef..3fcb685518b 100644 --- a/packages/pigeon/test/swift_generator_test.dart +++ b/packages/pigeon/test/swift_generator_test.dart @@ -50,7 +50,8 @@ void main() { final String code = sink.toString(); expect(code, contains('struct Foobar')); expect(code, contains('var field1: Int64? = nil')); - expect(code, contains('static func fromList(_ list: [Any?]) -> Foobar?')); + expect(code, + contains('static func fromList(_ __pigeon_list: [Any?]) -> Foobar?')); expect(code, contains('func toList() -> [Any?]')); expect(code, isNot(contains('if ('))); }); @@ -572,8 +573,9 @@ void main() { expect(code, contains('struct Outer')); expect(code, contains('struct Nested')); expect(code, contains('var nested: Nested? = nil')); - expect(code, contains('static func fromList(_ list: [Any?]) -> Outer?')); - expect(code, contains('nested = Nested.fromList(nestedList)')); + expect(code, + contains('static func fromList(_ __pigeon_list: [Any?]) -> Outer?')); + expect(code, contains('nested = nestedList as Nested')); expect(code, contains('func toList() -> [Any?]')); expect(code, isNot(contains('if ('))); // Single-element list serializations should not have a trailing comma. From 4880fec3a4f7d3315a286297889f8c792a6cc83d Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Thu, 28 Mar 2024 16:18:40 -0700 Subject: [PATCH 03/18] tests, more kotlin stuff --- .../flutter/pigeon_example_app/Messages.g.kt | 11 ++--- packages/pigeon/lib/kotlin_generator.dart | 16 +++---- .../AlternateLanguageTestPlugin.java | 48 +++++++++++++------ .../NullFieldsTest.java | 41 +++++++++------- .../example/ios/RunnerTests/NullFieldsTest.m | 25 +++++----- .../com/example/test_plugin/CoreTests.gen.kt | 20 ++------ packages/pigeon/test/java_generator_test.dart | 1 - 7 files changed, 83 insertions(+), 79 deletions(-) diff --git a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt index 4d3d38220cb..bb23dbf4d54 100644 --- a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt +++ b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt @@ -3,6 +3,7 @@ // found in the LICENSE file. // Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon +@file:Suppress("UNCHECKED_CAST", "LocalVariableName", "ArrayInDataClass") import android.util.Log import io.flutter.plugin.common.BasicMessageChannel @@ -17,10 +18,10 @@ private fun wrapResult(result: Any?): List { } private fun wrapError(exception: Throwable): List { - if (exception is FlutterError) { - return listOf(exception.code, exception.message, exception.details) + return if (exception is FlutterError) { + listOf(exception.code, exception.message, exception.details) } else { - return listOf( + listOf( exception.javaClass.simpleName, exception.toString(), "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)) @@ -64,7 +65,6 @@ data class MessageData( val data: Map ) { companion object { - @Suppress("UNCHECKED_CAST") fun fromList(__pigeon_list: List): MessageData { val name = __pigeon_list[0] as String? val description = __pigeon_list[1] as String? @@ -84,7 +84,6 @@ data class MessageData( } } -@Suppress("UNCHECKED_CAST") private object ExampleHostApiCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return when (type) { @@ -118,7 +117,6 @@ interface ExampleHostApi { /** The codec used by ExampleHostApi. */ val codec: MessageCodec by lazy { ExampleHostApiCodec } /** Sets up an instance of `ExampleHostApi` to handle messages through the `binaryMessenger`. */ - @Suppress("UNCHECKED_CAST") fun setUp(binaryMessenger: BinaryMessenger, api: ExampleHostApi?) { run { val channel = @@ -191,7 +189,6 @@ interface ExampleHostApi { } } /** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ -@Suppress("UNCHECKED_CAST") class MessageFlutterApi(private val binaryMessenger: BinaryMessenger) { companion object { /** The codec used by MessageFlutterApi. */ diff --git a/packages/pigeon/lib/kotlin_generator.dart b/packages/pigeon/lib/kotlin_generator.dart index 48e453108d0..6da2ad6ce72 100644 --- a/packages/pigeon/lib/kotlin_generator.dart +++ b/packages/pigeon/lib/kotlin_generator.dart @@ -97,6 +97,8 @@ class KotlinGenerator extends StructuredGenerator { } indent.writeln('// ${getGeneratedCodeWarning()}'); indent.writeln('// $seeAlsoWarning'); + indent.writeln( + '@file:Suppress("UNCHECKED_CAST", "LocalVariableName", "ArrayInDataClass")'); } @override @@ -247,7 +249,6 @@ class KotlinGenerator extends StructuredGenerator { indent.write('companion object '); indent.addScoped('{', '}', () { - indent.writeln('@Suppress("UNCHECKED_CAST")'); indent .write('fun fromList(${varNamePrefix}list: List): $className '); @@ -343,7 +344,6 @@ class KotlinGenerator extends StructuredGenerator { generatorComments: generatedMessages); final String apiName = api.name; - indent.writeln('@Suppress("UNCHECKED_CAST")'); indent .write('class $apiName(private val binaryMessenger: BinaryMessenger) '); indent.addScoped('{', '}', () { @@ -432,7 +432,6 @@ class KotlinGenerator extends StructuredGenerator { }); indent.writeln( '/** Sets up an instance of `$apiName` to handle messages through the `binaryMessenger`. */'); - indent.writeln('@Suppress("UNCHECKED_CAST")'); indent.write( 'fun setUp(binaryMessenger: BinaryMessenger, api: $apiName?) '); indent.addScoped('{', '}', () { @@ -460,7 +459,6 @@ class KotlinGenerator extends StructuredGenerator { assert(getCodecClasses(api, root).isNotEmpty); final Iterable codecClasses = getCodecClasses(api, root); final String codecName = _getCodecName(api); - indent.writeln('@Suppress("UNCHECKED_CAST")'); indent.write('private object $codecName : StandardMessageCodec() '); indent.addScoped('{', '}', () { indent.write( @@ -512,19 +510,17 @@ class KotlinGenerator extends StructuredGenerator { indent.newln(); indent.write('private fun wrapError(exception: Throwable): List '); indent.addScoped('{', '}', () { - indent - .write('if (exception is ${_getErrorClassName(generatorOptions)}) '); + indent.write( + 'return if (exception is ${_getErrorClassName(generatorOptions)}) '); indent.addScoped('{', '}', () { - indent.write('return '); - indent.addScoped('listOf(', ')', () { + indent.writeScoped('listOf(', ')', () { indent.writeln('exception.code,'); indent.writeln('exception.message,'); indent.writeln('exception.details'); }); }, addTrailingNewline: false); indent.addScoped(' else {', '}', () { - indent.write('return '); - indent.addScoped('listOf(', ')', () { + indent.writeScoped('listOf(', ')', () { indent.writeln('exception.javaClass.simpleName,'); indent.writeln('exception.toString(),'); indent.writeln( diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java index 7a44f6a8883..aa030bb4f42 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java @@ -151,13 +151,11 @@ public void throwErrorFromVoid() { @Nullable Boolean aNullableBool, @Nullable Long aNullableInt, @Nullable String aNullableString) { - AllNullableTypes someThings = - new AllNullableTypes.Builder() - .setANullableBool(aNullableBool) - .setANullableInt(aNullableInt) - .setANullableString(aNullableString) - .build(); - return someThings; + return new AllNullableTypes.Builder() + .setANullableBool(aNullableBool) + .setANullableInt(aNullableInt) + .setANullableString(aNullableString) + .build(); } @Override @@ -165,13 +163,11 @@ public void throwErrorFromVoid() { @Nullable Boolean aNullableBool, @Nullable Long aNullableInt, @Nullable String aNullableString) { - AllNullableTypesWithoutRecursion someThings = - new AllNullableTypesWithoutRecursion.Builder() - .setANullableBool(aNullableBool) - .setANullableInt(aNullableInt) - .setANullableString(aNullableString) - .build(); - return someThings; + return new AllNullableTypesWithoutRecursion.Builder() + .setANullableBool(aNullableBool) + .setANullableInt(aNullableInt) + .setANullableString(aNullableString) + .build(); } @Override @@ -368,28 +364,33 @@ public void echoAsyncNullableEnum( @Override public void callFlutterNoop(@NonNull VoidResult result) { + assert flutterApi != null; flutterApi.noop(result); } @Override public void callFlutterThrowError(@NonNull NullableResult result) { + assert flutterApi != null; flutterApi.throwError(result); } @Override public void callFlutterThrowErrorFromVoid(@NonNull VoidResult result) { + assert flutterApi != null; flutterApi.throwErrorFromVoid(result); } @Override public void callFlutterEchoAllTypes( @NonNull AllTypes everything, @NonNull Result result) { + assert flutterApi != null; flutterApi.echoAllTypes(everything, result); } @Override public void callFlutterEchoAllNullableTypes( @Nullable AllNullableTypes everything, @NonNull NullableResult result) { + assert flutterApi != null; flutterApi.echoAllNullableTypes(everything, result); } @@ -399,6 +400,7 @@ public void callFlutterSendMultipleNullableTypes( @Nullable Long aNullableInt, @Nullable String aNullableString, @NonNull Result result) { + assert flutterApi != null; flutterApi.sendMultipleNullableTypes(aNullableBool, aNullableInt, aNullableString, result); } @@ -406,6 +408,7 @@ public void callFlutterSendMultipleNullableTypes( public void callFlutterEchoAllNullableTypesWithoutRecursion( @Nullable AllNullableTypesWithoutRecursion everything, @NonNull NullableResult result) { + assert flutterApi != null; flutterApi.echoAllNullableTypesWithoutRecursion(everything, result); } @@ -415,97 +418,114 @@ public void callFlutterSendMultipleNullableTypesWithoutRecursion( @Nullable Long aNullableInt, @Nullable String aNullableString, @NonNull Result result) { + assert flutterApi != null; flutterApi.sendMultipleNullableTypesWithoutRecursion( aNullableBool, aNullableInt, aNullableString, result); } @Override public void callFlutterEchoBool(@NonNull Boolean aBool, @NonNull Result result) { + assert flutterApi != null; flutterApi.echoBool(aBool, result); } @Override public void callFlutterEchoInt(@NonNull Long anInt, @NonNull Result result) { + assert flutterApi != null; flutterApi.echoInt(anInt, result); } @Override public void callFlutterEchoDouble(@NonNull Double aDouble, @NonNull Result result) { + assert flutterApi != null; flutterApi.echoDouble(aDouble, result); } @Override public void callFlutterEchoString(@NonNull String aString, @NonNull Result result) { + assert flutterApi != null; flutterApi.echoString(aString, result); } @Override public void callFlutterEchoUint8List(@NonNull byte[] aList, @NonNull Result result) { + assert flutterApi != null; flutterApi.echoUint8List(aList, result); } @Override public void callFlutterEchoList( @NonNull List aList, @NonNull Result> result) { + assert flutterApi != null; flutterApi.echoList(aList, result); } @Override public void callFlutterEchoMap( @NonNull Map aMap, @NonNull Result> result) { + assert flutterApi != null; flutterApi.echoMap(aMap, result); } @Override public void callFlutterEchoEnum(@NonNull AnEnum anEnum, @NonNull Result result) { + assert flutterApi != null; flutterApi.echoEnum(anEnum, result); } @Override public void callFlutterEchoNullableBool( @Nullable Boolean aBool, @NonNull NullableResult result) { + assert flutterApi != null; flutterApi.echoNullableBool(aBool, result); } @Override public void callFlutterEchoNullableInt( @Nullable Long anInt, @NonNull NullableResult result) { + assert flutterApi != null; flutterApi.echoNullableInt(anInt, result); } @Override public void callFlutterEchoNullableDouble( @Nullable Double aDouble, @NonNull NullableResult result) { + assert flutterApi != null; flutterApi.echoNullableDouble(aDouble, result); } @Override public void callFlutterEchoNullableString( @Nullable String aString, @NonNull NullableResult result) { + assert flutterApi != null; flutterApi.echoNullableString(aString, result); } @Override public void callFlutterEchoNullableUint8List( @Nullable byte[] aList, @NonNull NullableResult result) { + assert flutterApi != null; flutterApi.echoNullableUint8List(aList, result); } @Override public void callFlutterEchoNullableList( @Nullable List aList, @NonNull NullableResult> result) { + assert flutterApi != null; flutterApi.echoNullableList(aList, result); } @Override public void callFlutterEchoNullableMap( @Nullable Map aMap, @NonNull NullableResult> result) { + assert flutterApi != null; flutterApi.echoNullableMap(aMap, result); } @Override public void callFlutterEchoNullableEnum( @Nullable AnEnum anEnum, @NonNull NullableResult result) { + assert flutterApi != null; flutterApi.echoNullableEnum(anEnum, result); } } diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/test/java/com/example/alternate_language_test_plugin/NullFieldsTest.java b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/test/java/com/example/alternate_language_test_plugin/NullFieldsTest.java index d581c2d8bc2..621a8a64f83 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/test/java/com/example/alternate_language_test_plugin/NullFieldsTest.java +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/test/java/com/example/alternate_language_test_plugin/NullFieldsTest.java @@ -81,20 +81,23 @@ public void requestFromMapWithNulls() { @Test public void replyFromMapWithValues() { - ArrayList requestList = new ArrayList(); - - requestList.add("hello"); - requestList.add(1L); - - ArrayList list = new ArrayList(); + NullFields.NullFieldsSearchRequest request = + new NullFields.NullFieldsSearchRequest.Builder() + .setQuery("hello") + .setIdentifier(1L) + .build(); - list.add("result"); - list.add("error"); - list.add(Arrays.asList(1L, 2L, 3L)); - list.add(requestList); - list.add(NullFields.NullFieldsSearchReplyType.SUCCESS.ordinal()); + NullFields.NullFieldsSearchReply input = + new NullFields.NullFieldsSearchReply.Builder() + .setResult("result") + .setError("error") + .setIndices(Arrays.asList(1L, 2L, 3L)) + .setRequest(request) + .setType(NullFields.NullFieldsSearchReplyType.SUCCESS) + .build(); - NullFields.NullFieldsSearchReply reply = NullFields.NullFieldsSearchReply.fromList(list); + NullFields.NullFieldsSearchReply reply = + NullFields.NullFieldsSearchReply.fromList(input.toList()); assertEquals(reply.getResult(), "result"); assertEquals(reply.getError(), "error"); assertEquals(reply.getIndices(), Arrays.asList(1L, 2L, 3L)); @@ -143,16 +146,18 @@ public void requestToMapWithNulls() { @Test public void replyToMapWithValues() { + NullFields.NullFieldsSearchRequest request = + new NullFields.NullFieldsSearchRequest.Builder() + .setQuery("hello") + .setIdentifier(1L) + .build(); + NullFields.NullFieldsSearchReply reply = new NullFields.NullFieldsSearchReply.Builder() .setResult("result") .setError("error") .setIndices(Arrays.asList(1L, 2L, 3L)) - .setRequest( - new NullFields.NullFieldsSearchRequest.Builder() - .setQuery("hello") - .setIdentifier(1L) - .build()) + .setRequest(request) .setType(NullFields.NullFieldsSearchReplyType.SUCCESS) .build(); @@ -160,7 +165,7 @@ public void replyToMapWithValues() { assertEquals(list.get(0), "result"); assertEquals(list.get(1), "error"); assertEquals(list.get(2), Arrays.asList(1L, 2L, 3L)); - assertEquals(list.get(3), reply.getRequest().toList()); + assertEquals(list.get(3), reply.getRequest()); assertEquals(list.get(4), NullFields.NullFieldsSearchReplyType.SUCCESS.ordinal()); } diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/RunnerTests/NullFieldsTest.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/RunnerTests/NullFieldsTest.m index e4032dc4cb5..48b48b61a68 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/RunnerTests/NullFieldsTest.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/ios/RunnerTests/NullFieldsTest.m @@ -84,19 +84,18 @@ - (void)testRequestFromListWithNulls { } - (void)testReplyFromListWithValues { - NSArray *list = @[ - @"result", - @"error", - @[ @1, @2, @3 ], - @[ - @"hello", - @1, - ], - @0, - ]; - NSArray *indices = @[ @1, @2, @3 ]; - NullFieldsSearchReply *reply = [NullFieldsSearchReply fromList:list]; + NullFieldsSearchRequest *request = [NullFieldsSearchRequest makeWithQuery:@"hello" identifier:1]; + + NullFieldsSearchReplyTypeBox *typeWrapper = + [[NullFieldsSearchReplyTypeBox alloc] initWithValue:NullFieldsSearchReplyTypeSuccess]; + NullFieldsSearchReply *input = [NullFieldsSearchReply makeWithResult:@"result" + error:@"error" + indices:indices + request:request + type:typeWrapper]; + + NullFieldsSearchReply *reply = [NullFieldsSearchReply fromList:[input toList]]; XCTAssertEqualObjects(@"result", reply.result); XCTAssertEqualObjects(@"error", reply.error); XCTAssertEqualObjects(indices, reply.indices); @@ -146,7 +145,7 @@ - (void)testReplyToListWithValuess { XCTAssertEqualObjects(@"result", list[0]); XCTAssertEqualObjects(@"error", list[1]); XCTAssertEqualObjects(indices, list[2]); - XCTAssertEqualObjects(@"hello", list[3][0]); + XCTAssertEqualObjects(@"hello", ((NullFieldsSearchRequest *)list[3]).query); NSNumber *typeNumber = list[4]; NullFieldsSearchReplyTypeBox *output = [[NullFieldsSearchReplyTypeBox alloc] initWithValue:[typeNumber integerValue]]; 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 fccb7574c95..8268f023542 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 @@ -4,6 +4,7 @@ // // Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon +@file:Suppress("UNCHECKED_CAST", "LocalVariableName", "ArrayInDataClass") package com.example.test_plugin @@ -20,10 +21,10 @@ private fun wrapResult(result: Any?): List { } private fun wrapError(exception: Throwable): List { - if (exception is FlutterError) { - return listOf(exception.code, exception.message, exception.details) + return if (exception is FlutterError) { + listOf(exception.code, exception.message, exception.details) } else { - return listOf( + listOf( exception.javaClass.simpleName, exception.toString(), "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)) @@ -70,7 +71,6 @@ data class AllTypes( val anObject: Any ) { companion object { - @Suppress("UNCHECKED_CAST") fun fromList(__pigeon_list: List): AllTypes { val aBool = __pigeon_list[0] as Boolean val anInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long } @@ -146,7 +146,6 @@ data class AllNullableTypes( val allNullableTypes: AllNullableTypes? = null ) { companion object { - @Suppress("UNCHECKED_CAST") fun fromList(__pigeon_list: List): AllNullableTypes { val aNullableBool = __pigeon_list[0] as Boolean? val aNullableInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long? } @@ -234,7 +233,6 @@ data class AllNullableTypesWithoutRecursion( val aNullableObject: Any? = null ) { companion object { - @Suppress("UNCHECKED_CAST") fun fromList(__pigeon_list: List): AllNullableTypesWithoutRecursion { val aNullableBool = __pigeon_list[0] as Boolean? val aNullableInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long? } @@ -309,7 +307,6 @@ data class AllClassesWrapper( val allTypes: AllTypes? = null ) { companion object { - @Suppress("UNCHECKED_CAST") fun fromList(__pigeon_list: List): AllClassesWrapper { val allNullableTypes = __pigeon_list[0] as AllNullableTypes val allNullableTypesWithoutRecursion = __pigeon_list[1] as AllNullableTypesWithoutRecursion? @@ -335,7 +332,6 @@ data class AllClassesWrapper( data class TestMessage(val testList: List? = null) { companion object { - @Suppress("UNCHECKED_CAST") fun fromList(__pigeon_list: List): TestMessage { val testList = __pigeon_list[0] as List? return TestMessage(testList) @@ -349,7 +345,6 @@ data class TestMessage(val testList: List? = null) { } } -@Suppress("UNCHECKED_CAST") private object HostIntegrationCoreApiCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return when (type) { @@ -629,7 +624,6 @@ interface HostIntegrationCoreApi { * Sets up an instance of `HostIntegrationCoreApi` to handle messages through the * `binaryMessenger`. */ - @Suppress("UNCHECKED_CAST") fun setUp(binaryMessenger: BinaryMessenger, api: HostIntegrationCoreApi?) { run { val channel = @@ -2577,7 +2571,6 @@ interface HostIntegrationCoreApi { } } -@Suppress("UNCHECKED_CAST") private object FlutterIntegrationCoreApiCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return when (type) { @@ -2635,7 +2628,6 @@ private object FlutterIntegrationCoreApiCodec : StandardMessageCodec() { * * Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ -@Suppress("UNCHECKED_CAST") class FlutterIntegrationCoreApi(private val binaryMessenger: BinaryMessenger) { companion object { /** The codec used by FlutterIntegrationCoreApi. */ @@ -3232,7 +3224,6 @@ interface HostTrivialApi { /** The codec used by HostTrivialApi. */ val codec: MessageCodec by lazy { StandardMessageCodec() } /** Sets up an instance of `HostTrivialApi` to handle messages through the `binaryMessenger`. */ - @Suppress("UNCHECKED_CAST") fun setUp(binaryMessenger: BinaryMessenger, api: HostTrivialApi?) { run { val channel = @@ -3272,7 +3263,6 @@ interface HostSmallApi { /** The codec used by HostSmallApi. */ val codec: MessageCodec by lazy { StandardMessageCodec() } /** Sets up an instance of `HostSmallApi` to handle messages through the `binaryMessenger`. */ - @Suppress("UNCHECKED_CAST") fun setUp(binaryMessenger: BinaryMessenger, api: HostSmallApi?) { run { val channel = @@ -3323,7 +3313,6 @@ interface HostSmallApi { } } -@Suppress("UNCHECKED_CAST") private object FlutterSmallApiCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return when (type) { @@ -3350,7 +3339,6 @@ private object FlutterSmallApiCodec : StandardMessageCodec() { * * Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ -@Suppress("UNCHECKED_CAST") class FlutterSmallApi(private val binaryMessenger: BinaryMessenger) { companion object { /** The codec used by FlutterSmallApi. */ diff --git a/packages/pigeon/test/java_generator_test.dart b/packages/pigeon/test/java_generator_test.dart index c3db1f893e0..9431dbf76e5 100644 --- a/packages/pigeon/test/java_generator_test.dart +++ b/packages/pigeon/test/java_generator_test.dart @@ -575,7 +575,6 @@ void main() { expect(code, contains('public static final class Outer')); expect(code, contains('public static final class Nested')); expect(code, contains('private @Nullable Nested nested;')); - ; expect(code, contains('add(nested);')); }); From 058857358e27eb647ecffc16ffe5039dbfe6ee78 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Thu, 28 Mar 2024 18:10:35 -0700 Subject: [PATCH 04/18] some cpp --- packages/pigeon/lib/cpp_generator.dart | 13 ++++++------- packages/pigeon/test/cpp_generator_test.dart | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/pigeon/lib/cpp_generator.dart b/packages/pigeon/lib/cpp_generator.dart index b14ee3396fa..2d1770335c4 100644 --- a/packages/pigeon/lib/cpp_generator.dart +++ b/packages/pigeon/lib/cpp_generator.dart @@ -777,6 +777,7 @@ class CppSourceGenerator extends StructuredGenerator { _makeInstanceVariableName(field), field.type, hostDatatype, + true, ); indent.writeln('list.push_back($encodableValue);'); } @@ -923,6 +924,7 @@ class CppSourceGenerator extends StructuredGenerator { param.name, param.originalType, param.hostType, + false, ); indent.writeln('$encodedArgument,'); } @@ -1398,22 +1400,19 @@ ${prefix}reply(EncodableValue(std::move(wrapped)));'''; /// Returns the expression to create an EncodableValue from a host API argument /// with the given [variableName] and types. - /// - /// If [preSerializeClasses] is true, custom classes will be returned as - /// encodable lists rather than CustomEncodableValues; see - /// https://github.com/flutter/flutter/issues/119351 for why this is currently - /// needed. String _wrappedHostApiArgumentExpression( Root root, String variableName, TypeDeclaration dartType, HostDatatype hostType, + bool isNestedClass, ) { final String encodableValue; if (!hostType.isBuiltin && root.classes.any((Class c) => c.name == dartType.baseName)) { - final String nonNullValue = - hostType.isNullable ? '*$variableName' : variableName; + final String nonNullValue = hostType.isNullable || isNestedClass + ? '*$variableName' + : variableName; encodableValue = 'CustomEncodableValue($nonNullValue)'; } else if (!hostType.isBuiltin && root.enums.any((Enum e) => e.name == dartType.baseName)) { diff --git a/packages/pigeon/test/cpp_generator_test.dart b/packages/pigeon/test/cpp_generator_test.dart index 24839b52fdf..581b8b302f9 100644 --- a/packages/pigeon/test/cpp_generator_test.dart +++ b/packages/pigeon/test/cpp_generator_test.dart @@ -804,7 +804,7 @@ void main() { 'non_nullable_nested_ = std::make_unique(value_arg);')); // Serialization uses the value directly. expect(code, contains('EncodableValue(non_nullable_bool_)')); - expect(code, contains('CustomEncodableValue(non_nullable_nested_)')); + expect(code, contains('CustomEncodableValue(*non_nullable_nested_)')); // Serialization should use push_back, not initializer lists, to avoid // copies. @@ -812,7 +812,7 @@ void main() { expect( code, contains( - 'list.push_back(CustomEncodableValue(non_nullable_nested_))')); + 'list.push_back(CustomEncodableValue(*non_nullable_nested_))')); } }); @@ -1645,7 +1645,7 @@ void main() { expect(code, contains('EncodableValue(a_list_arg)')); expect(code, contains('EncodableValue(a_map_arg)')); // Class types use ToEncodableList. - expect(code, contains('CustomEncodableValue(an_object_arg)')); + expect(code, contains('CustomEncodableValue(*an_object_arg)')); } }); From 01444d0bb392918ed0dd881e37e595796f5eb6e5 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Fri, 29 Mar 2024 12:16:34 -0700 Subject: [PATCH 05/18] remove aList --- packages/pigeon/CHANGELOG.md | 6 + .../example/app/macos/Runner/messages.g.m | 18 +- .../example/app/windows/runner/messages.g.cpp | 10 +- packages/pigeon/lib/cpp_generator.dart | 10 +- packages/pigeon/lib/generator_tools.dart | 2 +- packages/pigeon/lib/objc_generator.dart | 18 +- packages/pigeon/pigeons/core_tests.dart | 26 +-- .../AlternateLanguageTestPlugin.java | 28 +-- .../CoreTests.java | 84 +++---- .../ios/Classes/AlternateLanguageTestPlugin.m | 28 +-- .../ios/Classes/CoreTests.gen.h | 26 +-- .../ios/Classes/CoreTests.gen.m | 200 ++++++++--------- .../Classes/AlternateLanguageTestPlugin.m | 28 +-- .../macos/Classes/CoreTests.gen.h | 26 +-- .../macos/Classes/CoreTests.gen.m | 200 ++++++++--------- .../lib/integration_tests.dart | 12 +- .../lib/src/generated/core_tests.gen.dart | 64 +++--- .../com/example/test_plugin/CoreTests.gen.kt | 66 +++--- .../com/example/test_plugin/TestPlugin.kt | 28 +-- .../example/test_plugin/AllDatatypesTest.kt | 2 +- .../ios/Classes/CoreTests.gen.swift | 74 +++---- .../test_plugin/ios/Classes/TestPlugin.swift | 28 +-- .../macos/Classes/CoreTests.gen.swift | 74 +++---- .../macos/Classes/TestPlugin.swift | 28 +-- .../windows/pigeon/core_tests.gen.cpp | 206 +++++++++--------- .../windows/pigeon/core_tests.gen.h | 30 +-- packages/pigeon/pubspec.yaml | 2 +- 27 files changed, 660 insertions(+), 664 deletions(-) diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index be39b24414c..7fbaa7d828a 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,3 +1,9 @@ +## 17.3.1 + +* Fixes double encode/decode of classes. +* [kotlin] Changes to some code to make it more idiomatic. +* Removes collision with the word `list`. + ## 17.3.0 * [swift] Adds `@SwiftClass` annotation to allow choice between `struct` and `class` for data classes. diff --git a/packages/pigeon/example/app/macos/Runner/messages.g.m b/packages/pigeon/example/app/macos/Runner/messages.g.m index c155efa03b2..90983b10cd2 100644 --- a/packages/pigeon/example/app/macos/Runner/messages.g.m +++ b/packages/pigeon/example/app/macos/Runner/messages.g.m @@ -50,8 +50,8 @@ - (instancetype)initWithValue:(PGNCode)value { @end @interface PGNMessageData () -+ (PGNMessageData *)fromList:(NSArray *)__pigeon_list; -+ (nullable PGNMessageData *)nullableFromList:(NSArray *)__pigeon_list; ++ (PGNMessageData *)fromList:(NSArray *)list; ++ (nullable PGNMessageData *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @@ -67,16 +67,16 @@ + (instancetype)makeWithName:(nullable NSString *)name pigeonResult.data = data; return pigeonResult; } -+ (PGNMessageData *)fromList:(NSArray *)__pigeon_list { ++ (PGNMessageData *)fromList:(NSArray *)list { PGNMessageData *pigeonResult = [[PGNMessageData alloc] init]; - pigeonResult.name = GetNullableObjectAtIndex(__pigeon_list, 0); - pigeonResult.description = GetNullableObjectAtIndex(__pigeon_list, 1); - pigeonResult.code = [GetNullableObjectAtIndex(__pigeon_list, 2) integerValue]; - pigeonResult.data = GetNullableObjectAtIndex(__pigeon_list, 3); + pigeonResult.name = GetNullableObjectAtIndex(list, 0); + pigeonResult.description = GetNullableObjectAtIndex(list, 1); + pigeonResult.code = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.data = GetNullableObjectAtIndex(list, 3); return pigeonResult; } -+ (nullable PGNMessageData *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [PGNMessageData fromList:__pigeon_list] : nil; ++ (nullable PGNMessageData *)nullableFromList:(NSArray *)list { + return (list) ? [PGNMessageData fromList:list] : nil; } - (NSArray *)toList { return @[ diff --git a/packages/pigeon/example/app/windows/runner/messages.g.cpp b/packages/pigeon/example/app/windows/runner/messages.g.cpp index 8ef7584c4e5..97d11da0bdf 100644 --- a/packages/pigeon/example/app/windows/runner/messages.g.cpp +++ b/packages/pigeon/example/app/windows/runner/messages.g.cpp @@ -87,14 +87,14 @@ EncodableList MessageData::ToEncodableList() const { return list; } -MessageData MessageData::FromEncodableList(const EncodableList& __pigeon_list) { - MessageData decoded((Code)(std::get(__pigeon_list[2])), - std::get(__pigeon_list[3])); - auto& encodable_name = __pigeon_list[0]; +MessageData MessageData::FromEncodableList(const EncodableList& list) { + MessageData decoded((Code)(std::get(list[2])), + std::get(list[3])); + auto& encodable_name = list[0]; if (!encodable_name.IsNull()) { decoded.set_name(std::get(encodable_name)); } - auto& encodable_description = __pigeon_list[1]; + auto& encodable_description = list[1]; if (!encodable_description.IsNull()) { decoded.set_description(std::get(encodable_description)); } diff --git a/packages/pigeon/lib/cpp_generator.dart b/packages/pigeon/lib/cpp_generator.dart index 2d1770335c4..1ff6e627904 100644 --- a/packages/pigeon/lib/cpp_generator.dart +++ b/packages/pigeon/lib/cpp_generator.dart @@ -812,8 +812,7 @@ class CppSourceGenerator extends StructuredGenerator { _writeFunctionDefinition(indent, 'FromEncodableList', scope: classDefinition.name, returnType: classDefinition.name, - parameters: ['const EncodableList& ${varNamePrefix}list'], - body: () { + parameters: ['const EncodableList& list'], body: () { const String instanceVariable = 'decoded'; final Iterable<_IndexedField> indexedFields = indexMap( getFieldsInSerializationOrder(classDefinition), @@ -825,8 +824,8 @@ class CppSourceGenerator extends StructuredGenerator { // Non-nullable fields must be set via the constructor. String constructorArgs = nonNullableFields - .map((_IndexedField param) => getValueExpression( - param.field, '${varNamePrefix}list[${param.index}]')) + .map((_IndexedField param) => + getValueExpression(param.field, 'list[${param.index}]')) .join(',\n\t'); if (constructorArgs.isNotEmpty) { constructorArgs = '(\n\t$constructorArgs)'; @@ -842,8 +841,7 @@ class CppSourceGenerator extends StructuredGenerator { final String setterName = _makeSetterName(field); final String encodableFieldName = '${_encodablePrefix}_${_makeVariableName(field)}'; - indent.writeln( - 'auto& $encodableFieldName = ${varNamePrefix}list[${entry.index}];'); + indent.writeln('auto& $encodableFieldName = list[${entry.index}];'); final String valueExpression = getValueExpression(field, encodableFieldName); diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index 58fcf48d897..f4d7d6b5dbb 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -13,7 +13,7 @@ import 'ast.dart'; /// The current version of pigeon. /// /// This must match the version in pubspec.yaml. -const String pigeonVersion = '17.3.0'; +const String pigeonVersion = '17.3.1'; /// Prefix for all local variables in methods. /// diff --git a/packages/pigeon/lib/objc_generator.dart b/packages/pigeon/lib/objc_generator.dart index eaa3ee9b03c..a51537d800f 100644 --- a/packages/pigeon/lib/objc_generator.dart +++ b/packages/pigeon/lib/objc_generator.dart @@ -568,15 +568,15 @@ class ObjcSourceGenerator extends StructuredGenerator { }) { final String className = _className(generatorOptions.prefix, classDefinition.name); - indent.write('+ ($className *)fromList:(NSArray *)${varNamePrefix}list '); + indent.write('+ ($className *)fromList:(NSArray *)list '); indent.addScoped('{', '}', () { const String resultName = 'pigeonResult'; indent.writeln('$className *$resultName = [[$className alloc] init];'); enumerate(getFieldsInSerializationOrder(classDefinition), (int index, final NamedType field) { final bool isEnumType = field.type.isEnum; - final String valueGetter = _listGetter( - '${varNamePrefix}list', field, index, generatorOptions.prefix); + final String valueGetter = + _listGetter('list', field, index, generatorOptions.prefix); final String? primitiveExtractionMethod = _nsnumberExtractionMethod(field.type); final String ivarValueExpression; @@ -595,11 +595,9 @@ class ObjcSourceGenerator extends StructuredGenerator { indent.writeln('return $resultName;'); }); - indent.write( - '+ (nullable $className *)nullableFromList:(NSArray *)${varNamePrefix}list '); + indent.write('+ (nullable $className *)nullableFromList:(NSArray *)list '); indent.addScoped('{', '}', () { - indent.writeln( - 'return (${varNamePrefix}list) ? [$className fromList:${varNamePrefix}list] : nil;'); + indent.writeln('return (list) ? [$className fromList:list] : nil;'); }); } @@ -919,9 +917,9 @@ static FlutterError *createConnectionError(NSString *channelName) { _className(languageOptions.prefix, classDefinition.name); indent.newln(); indent.writeln('@interface $className ()'); - indent.writeln('+ ($className *)fromList:(NSArray *)${varNamePrefix}list;'); - indent.writeln( - '+ (nullable $className *)nullableFromList:(NSArray *)${varNamePrefix}list;'); + indent.writeln('+ ($className *)fromList:(NSArray *)list;'); + indent + .writeln('+ (nullable $className *)nullableFromList:(NSArray *)list;'); indent.writeln('- (NSArray *)toList;'); indent.writeln('@end'); } diff --git a/packages/pigeon/pigeons/core_tests.dart b/packages/pigeon/pigeons/core_tests.dart index 3fbac83fff8..f37191adb9b 100644 --- a/packages/pigeon/pigeons/core_tests.dart +++ b/packages/pigeon/pigeons/core_tests.dart @@ -23,7 +23,7 @@ class AllTypes { required this.a4ByteArray, required this.a8ByteArray, required this.aFloatArray, - this.aList = const [], + this.list = const [], this.aMap = const {}, this.anEnum = AnEnum.one, this.aString = '', @@ -39,7 +39,7 @@ class AllTypes { Int64List a8ByteArray; Float64List aFloatArray; // ignore: always_specify_types, strict_raw_type - List aList; + List list; // ignore: always_specify_types, strict_raw_type Map aMap; AnEnum anEnum; @@ -204,7 +204,7 @@ abstract class HostIntegrationCoreApi { /// Returns the passed list, to test serialization and deserialization. @ObjCSelector('echoList:') @SwiftFunction('echo(_:)') - List echoList(List aList); + List echoList(List list); /// Returns the passed map, to test serialization and deserialization. @ObjCSelector('echoMap:') @@ -375,7 +375,7 @@ abstract class HostIntegrationCoreApi { @async @ObjCSelector('echoAsyncList:') @SwiftFunction('echoAsync(_:)') - List echoAsyncList(List aList); + List echoAsyncList(List list); /// Returns the passed map, to test asynchronous serialization and deserialization. @async @@ -462,7 +462,7 @@ abstract class HostIntegrationCoreApi { @async @ObjCSelector('echoAsyncNullableList:') @SwiftFunction('echoAsyncNullable(_:)') - List? echoAsyncNullableList(List? aList); + List? echoAsyncNullableList(List? list); /// Returns the passed map, to test asynchronous serialization and deserialization. @async @@ -543,12 +543,12 @@ abstract class HostIntegrationCoreApi { @async @ObjCSelector('callFlutterEchoUint8List:') @SwiftFunction('callFlutterEcho(_:)') - Uint8List callFlutterEchoUint8List(Uint8List aList); + Uint8List callFlutterEchoUint8List(Uint8List list); @async @ObjCSelector('callFlutterEchoList:') @SwiftFunction('callFlutterEcho(_:)') - List callFlutterEchoList(List aList); + List callFlutterEchoList(List list); @async @ObjCSelector('callFlutterEchoMap:') @@ -583,12 +583,12 @@ abstract class HostIntegrationCoreApi { @async @ObjCSelector('callFlutterEchoNullableUint8List:') @SwiftFunction('callFlutterEchoNullable(_:)') - Uint8List? callFlutterEchoNullableUint8List(Uint8List? aList); + Uint8List? callFlutterEchoNullableUint8List(Uint8List? list); @async @ObjCSelector('callFlutterEchoNullableList:') @SwiftFunction('callFlutterEchoNullable(_:)') - List? callFlutterEchoNullableList(List? aList); + List? callFlutterEchoNullableList(List? list); @async @ObjCSelector('callFlutterEchoNullableMap:') @@ -674,12 +674,12 @@ abstract class FlutterIntegrationCoreApi { /// Returns the passed byte list, to test serialization and deserialization. @ObjCSelector('echoUint8List:') @SwiftFunction('echo(_:)') - Uint8List echoUint8List(Uint8List aList); + Uint8List echoUint8List(Uint8List list); /// Returns the passed list, to test serialization and deserialization. @ObjCSelector('echoList:') @SwiftFunction('echo(_:)') - List echoList(List aList); + List echoList(List list); /// Returns the passed map, to test serialization and deserialization. @ObjCSelector('echoMap:') @@ -716,12 +716,12 @@ abstract class FlutterIntegrationCoreApi { /// Returns the passed byte list, to test serialization and deserialization. @ObjCSelector('echoNullableUint8List:') @SwiftFunction('echoNullable(_:)') - Uint8List? echoNullableUint8List(Uint8List? aList); + Uint8List? echoNullableUint8List(Uint8List? list); /// Returns the passed list, to test serialization and deserialization. @ObjCSelector('echoNullableList:') @SwiftFunction('echoNullable(_:)') - List? echoNullableList(List? aList); + List? echoNullableList(List? list); /// Returns the passed map, to test serialization and deserialization. @ObjCSelector('echoNullableMap:') diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java index aa030bb4f42..67f4dc84675 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/main/java/com/example/alternate_language_test_plugin/AlternateLanguageTestPlugin.java @@ -100,8 +100,8 @@ public void throwErrorFromVoid() { } @Override - public @NonNull List echoList(@NonNull List aList) { - return aList; + public @NonNull List echoList(@NonNull List list) { + return list; } @Override @@ -294,8 +294,8 @@ public void echoAsyncObject(@NonNull Object anObject, @NonNull Result re } @Override - public void echoAsyncList(@NonNull List aList, @NonNull Result> result) { - result.success(aList); + public void echoAsyncList(@NonNull List list, @NonNull Result> result) { + result.success(list); } @Override @@ -346,8 +346,8 @@ public void echoAsyncNullableObject( @Override public void echoAsyncNullableList( - @Nullable List aList, @NonNull NullableResult> result) { - result.success(aList); + @Nullable List list, @NonNull NullableResult> result) { + result.success(list); } @Override @@ -448,16 +448,16 @@ public void callFlutterEchoString(@NonNull String aString, @NonNull Result result) { + public void callFlutterEchoUint8List(@NonNull byte[] list, @NonNull Result result) { assert flutterApi != null; - flutterApi.echoUint8List(aList, result); + flutterApi.echoUint8List(list, result); } @Override public void callFlutterEchoList( - @NonNull List aList, @NonNull Result> result) { + @NonNull List list, @NonNull Result> result) { assert flutterApi != null; - flutterApi.echoList(aList, result); + flutterApi.echoList(list, result); } @Override @@ -503,16 +503,16 @@ public void callFlutterEchoNullableString( @Override public void callFlutterEchoNullableUint8List( - @Nullable byte[] aList, @NonNull NullableResult result) { + @Nullable byte[] list, @NonNull NullableResult result) { assert flutterApi != null; - flutterApi.echoNullableUint8List(aList, result); + flutterApi.echoNullableUint8List(list, result); } @Override public void callFlutterEchoNullableList( - @Nullable List aList, @NonNull NullableResult> result) { + @Nullable List list, @NonNull NullableResult> result) { assert flutterApi != null; - flutterApi.echoNullableList(aList, result); + flutterApi.echoNullableList(list, result); } @Override 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 959eaeab41e..e209c2281e0 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 @@ -198,17 +198,17 @@ public void setAFloatArray(@NonNull double[] setterArg) { this.aFloatArray = setterArg; } - private @NonNull List aList; + private @NonNull List list; - public @NonNull List getAList() { - return aList; + public @NonNull List getList() { + return list; } - public void setAList(@NonNull List setterArg) { + public void setList(@NonNull List setterArg) { if (setterArg == null) { - throw new IllegalStateException("Nonnull field \"aList\" is null."); + throw new IllegalStateException("Nonnull field \"list\" is null."); } - this.aList = setterArg; + this.list = setterArg; } private @NonNull Map aMap; @@ -332,11 +332,11 @@ public static final class Builder { return this; } - private @Nullable List aList; + private @Nullable List list; @CanIgnoreReturnValue - public @NonNull Builder setAList(@NonNull List setterArg) { - this.aList = setterArg; + public @NonNull Builder setList(@NonNull List setterArg) { + this.list = setterArg; return this; } @@ -382,7 +382,7 @@ public static final class Builder { pigeonReturn.setA4ByteArray(a4ByteArray); pigeonReturn.setA8ByteArray(a8ByteArray); pigeonReturn.setAFloatArray(aFloatArray); - pigeonReturn.setAList(aList); + pigeonReturn.setList(list); pigeonReturn.setAMap(aMap); pigeonReturn.setAnEnum(anEnum); pigeonReturn.setAString(aString); @@ -402,7 +402,7 @@ ArrayList toList() { toListResult.add(a4ByteArray); toListResult.add(a8ByteArray); toListResult.add(aFloatArray); - toListResult.add(aList); + toListResult.add(list); toListResult.add(aMap); toListResult.add(anEnum == null ? null : anEnum.index); toListResult.add(aString); @@ -432,8 +432,8 @@ ArrayList toList() { pigeonResult.setA8ByteArray((long[]) a8ByteArray); Object aFloatArray = __pigeon_list.get(7); pigeonResult.setAFloatArray((double[]) aFloatArray); - Object aList = __pigeon_list.get(8); - pigeonResult.setAList((List) aList); + Object list = __pigeon_list.get(8); + pigeonResult.setList((List) list); Object aMap = __pigeon_list.get(9); pigeonResult.setAMap((Map) aMap); Object anEnum = __pigeon_list.get(10); @@ -1512,7 +1512,7 @@ public interface HostIntegrationCoreApi { Object echoObject(@NonNull Object anObject); /** Returns the passed list, to test serialization and deserialization. */ @NonNull - List echoList(@NonNull List aList); + List echoList(@NonNull List list); /** Returns the passed map, to test serialization and deserialization. */ @NonNull Map echoMap(@NonNull Map aMap); @@ -1611,7 +1611,7 @@ AllNullableTypesWithoutRecursion sendMultipleNullableTypesWithoutRecursion( /** Returns the passed in generic Object asynchronously. */ void echoAsyncObject(@NonNull Object anObject, @NonNull Result result); /** Returns the passed list, to test asynchronous serialization and deserialization. */ - void echoAsyncList(@NonNull List aList, @NonNull Result> result); + void echoAsyncList(@NonNull List list, @NonNull Result> result); /** Returns the passed map, to test asynchronous serialization and deserialization. */ void echoAsyncMap( @NonNull Map aMap, @NonNull Result> result); @@ -1647,7 +1647,7 @@ void echoAsyncNullableUint8List( void echoAsyncNullableObject(@Nullable Object anObject, @NonNull NullableResult result); /** Returns the passed list, to test asynchronous serialization and deserialization. */ void echoAsyncNullableList( - @Nullable List aList, @NonNull NullableResult> result); + @Nullable List list, @NonNull NullableResult> result); /** Returns the passed map, to test asynchronous serialization and deserialization. */ void echoAsyncNullableMap( @Nullable Map aMap, @NonNull NullableResult> result); @@ -1689,9 +1689,9 @@ void callFlutterSendMultipleNullableTypesWithoutRecursion( void callFlutterEchoString(@NonNull String aString, @NonNull Result result); - void callFlutterEchoUint8List(@NonNull byte[] aList, @NonNull Result result); + void callFlutterEchoUint8List(@NonNull byte[] list, @NonNull Result result); - void callFlutterEchoList(@NonNull List aList, @NonNull Result> result); + void callFlutterEchoList(@NonNull List list, @NonNull Result> result); void callFlutterEchoMap( @NonNull Map aMap, @NonNull Result> result); @@ -1710,10 +1710,10 @@ void callFlutterEchoNullableString( @Nullable String aString, @NonNull NullableResult result); void callFlutterEchoNullableUint8List( - @Nullable byte[] aList, @NonNull NullableResult result); + @Nullable byte[] list, @NonNull NullableResult result); void callFlutterEchoNullableList( - @Nullable List aList, @NonNull NullableResult> result); + @Nullable List list, @NonNull NullableResult> result); void callFlutterEchoNullableMap( @Nullable Map aMap, @NonNull NullableResult> result); @@ -2009,9 +2009,9 @@ static void setUp( (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - List aListArg = (List) args.get(0); + List listArg = (List) args.get(0); try { - List output = api.echoList(aListArg); + List output = api.echoList(listArg); wrapped.add(0, output); } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); @@ -2843,7 +2843,7 @@ public void error(Throwable error) { (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - List aListArg = (List) args.get(0); + List listArg = (List) args.get(0); Result> resultCallback = new Result>() { public void success(List result) { @@ -2857,7 +2857,7 @@ public void error(Throwable error) { } }; - api.echoAsyncList(aListArg, resultCallback); + api.echoAsyncList(listArg, resultCallback); }); } else { channel.setMessageHandler(null); @@ -3305,7 +3305,7 @@ public void error(Throwable error) { (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - List aListArg = (List) args.get(0); + List listArg = (List) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(List result) { @@ -3319,7 +3319,7 @@ public void error(Throwable error) { } }; - api.echoAsyncNullableList(aListArg, resultCallback); + api.echoAsyncNullableList(listArg, resultCallback); }); } else { channel.setMessageHandler(null); @@ -3778,7 +3778,7 @@ public void error(Throwable error) { (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - byte[] aListArg = (byte[]) args.get(0); + byte[] listArg = (byte[]) args.get(0); Result resultCallback = new Result() { public void success(byte[] result) { @@ -3792,7 +3792,7 @@ public void error(Throwable error) { } }; - api.callFlutterEchoUint8List(aListArg, resultCallback); + api.callFlutterEchoUint8List(listArg, resultCallback); }); } else { channel.setMessageHandler(null); @@ -3809,7 +3809,7 @@ public void error(Throwable error) { (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - List aListArg = (List) args.get(0); + List listArg = (List) args.get(0); Result> resultCallback = new Result>() { public void success(List result) { @@ -3823,7 +3823,7 @@ public void error(Throwable error) { } }; - api.callFlutterEchoList(aListArg, resultCallback); + api.callFlutterEchoList(listArg, resultCallback); }); } else { channel.setMessageHandler(null); @@ -4027,7 +4027,7 @@ public void error(Throwable error) { (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - byte[] aListArg = (byte[]) args.get(0); + byte[] listArg = (byte[]) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(byte[] result) { @@ -4041,7 +4041,7 @@ public void error(Throwable error) { } }; - api.callFlutterEchoNullableUint8List(aListArg, resultCallback); + api.callFlutterEchoNullableUint8List(listArg, resultCallback); }); } else { channel.setMessageHandler(null); @@ -4058,7 +4058,7 @@ public void error(Throwable error) { (message, reply) -> { ArrayList wrapped = new ArrayList(); ArrayList args = (ArrayList) message; - List aListArg = (List) args.get(0); + List listArg = (List) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(List result) { @@ -4072,7 +4072,7 @@ public void error(Throwable error) { } }; - api.callFlutterEchoNullableList(aListArg, resultCallback); + api.callFlutterEchoNullableList(listArg, resultCallback); }); } else { channel.setMessageHandler(null); @@ -4598,13 +4598,13 @@ public void echoString(@NonNull String aStringArg, @NonNull Result resul }); } /** Returns the passed byte list, to test serialization and deserialization. */ - public void echoUint8List(@NonNull byte[] aListArg, @NonNull Result result) { + public void echoUint8List(@NonNull byte[] listArg, @NonNull Result result) { final String channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List"; BasicMessageChannel channel = new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); channel.send( - new ArrayList(Collections.singletonList(aListArg)), + new ArrayList(Collections.singletonList(listArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; @@ -4631,13 +4631,13 @@ public void echoUint8List(@NonNull byte[] aListArg, @NonNull Result resu }); } /** Returns the passed list, to test serialization and deserialization. */ - public void echoList(@NonNull List aListArg, @NonNull Result> result) { + public void echoList(@NonNull List listArg, @NonNull Result> result) { final String channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList"; BasicMessageChannel channel = new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); channel.send( - new ArrayList(Collections.singletonList(aListArg)), + new ArrayList(Collections.singletonList(listArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; @@ -4844,13 +4844,13 @@ public void echoNullableString( } /** Returns the passed byte list, to test serialization and deserialization. */ public void echoNullableUint8List( - @Nullable byte[] aListArg, @NonNull NullableResult result) { + @Nullable byte[] listArg, @NonNull NullableResult result) { final String channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableUint8List"; BasicMessageChannel channel = new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); channel.send( - new ArrayList(Collections.singletonList(aListArg)), + new ArrayList(Collections.singletonList(listArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; @@ -4872,13 +4872,13 @@ public void echoNullableUint8List( } /** Returns the passed list, to test serialization and deserialization. */ public void echoNullableList( - @Nullable List aListArg, @NonNull NullableResult> result) { + @Nullable List listArg, @NonNull NullableResult> result) { final String channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList"; BasicMessageChannel channel = new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); channel.send( - new ArrayList(Collections.singletonList(aListArg)), + new ArrayList(Collections.singletonList(listArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m index c3501d5ce7a..1ac77f226fb 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/ios/Classes/AlternateLanguageTestPlugin.m @@ -80,9 +80,9 @@ - (nullable id)echoObject:(id)anObject error:(FlutterError *_Nullable *_Nonnull) return anObject; } -- (nullable NSArray *)echoList:(NSArray *)aList +- (nullable NSArray *)echoList:(NSArray *)list error:(FlutterError *_Nullable *_Nonnull)error { - return aList; + return list; } - (nullable NSDictionary *)echoMap:(NSDictionary *)aMap @@ -283,9 +283,9 @@ - (void)echoAsyncObject:(id)anObject completion(anObject, nil); } -- (void)echoAsyncList:(NSArray *)aList +- (void)echoAsyncList:(NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { - completion(aList, nil); + completion(list, nil); } - (void)echoAsyncMap:(NSDictionary *)aMap @@ -330,10 +330,10 @@ - (void)echoAsyncNullableObject:(nullable id)anObject completion(anObject, nil); } -- (void)echoAsyncNullableList:(nullable NSArray *)aList +- (void)echoAsyncNullableList:(nullable NSArray *)list completion: (void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { - completion(aList, nil); + completion(list, nil); } - (void)echoAsyncNullableMap:(nullable NSDictionary *)aMap @@ -441,18 +441,18 @@ - (void)callFlutterEchoString:(NSString *)aString }]; } -- (void)callFlutterEchoUint8List:(FlutterStandardTypedData *)aList +- (void)callFlutterEchoUint8List:(FlutterStandardTypedData *)list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion { - [self.flutterAPI echoUint8List:aList + [self.flutterAPI echoUint8List:list completion:^(FlutterStandardTypedData *value, FlutterError *error) { completion(value, error); }]; } -- (void)callFlutterEchoList:(NSArray *)aList +- (void)callFlutterEchoList:(NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { - [self.flutterAPI echoList:aList + [self.flutterAPI echoList:list completion:^(NSArray *value, FlutterError *error) { completion(value, error); }]; @@ -534,19 +534,19 @@ - (void)callFlutterEchoNullableString:(nullable NSString *)aString }]; } -- (void)callFlutterEchoNullableUint8List:(nullable FlutterStandardTypedData *)aList +- (void)callFlutterEchoNullableUint8List:(nullable FlutterStandardTypedData *)list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion { - [self.flutterAPI echoNullableUint8List:aList + [self.flutterAPI echoNullableUint8List:list completion:^(FlutterStandardTypedData *value, FlutterError *error) { completion(value, error); }]; } -- (void)callFlutterEchoNullableList:(nullable NSArray *)aList +- (void)callFlutterEchoNullableList:(nullable NSArray *)list completion: (void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { - [self.flutterAPI echoNullableList:aList + [self.flutterAPI echoNullableList:list completion:^(NSArray *value, FlutterError *error) { completion(value, error); }]; 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 72c1e9d2ec2..9a3a59d06a9 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 @@ -46,7 +46,7 @@ typedef NS_ENUM(NSUInteger, FLTAnEnum) { a4ByteArray:(FlutterStandardTypedData *)a4ByteArray a8ByteArray:(FlutterStandardTypedData *)a8ByteArray aFloatArray:(FlutterStandardTypedData *)aFloatArray - aList:(NSArray *)aList + list:(NSArray *)list aMap:(NSDictionary *)aMap anEnum:(FLTAnEnum)anEnum aString:(NSString *)aString @@ -59,7 +59,7 @@ typedef NS_ENUM(NSUInteger, FLTAnEnum) { @property(nonatomic, strong) FlutterStandardTypedData *a4ByteArray; @property(nonatomic, strong) FlutterStandardTypedData *a8ByteArray; @property(nonatomic, strong) FlutterStandardTypedData *aFloatArray; -@property(nonatomic, copy) NSArray *aList; +@property(nonatomic, copy) NSArray *list; @property(nonatomic, copy) NSDictionary *aMap; @property(nonatomic, assign) FLTAnEnum anEnum; @property(nonatomic, copy) NSString *aString; @@ -219,7 +219,7 @@ NSObject *FLTHostIntegrationCoreApiGetCodec(void); /// Returns the passed list, to test serialization and deserialization. /// /// @return `nil` only when `error != nil`. -- (nullable NSArray *)echoList:(NSArray *)aList +- (nullable NSArray *)echoList:(NSArray *)list error:(FlutterError *_Nullable *_Nonnull)error; /// Returns the passed map, to test serialization and deserialization. /// @@ -342,7 +342,7 @@ NSObject *FLTHostIntegrationCoreApiGetCodec(void); - (void)echoAsyncObject:(id)anObject completion:(void (^)(id _Nullable, FlutterError *_Nullable))completion; /// Returns the passed list, to test asynchronous serialization and deserialization. -- (void)echoAsyncList:(NSArray *)aList +- (void)echoAsyncList:(NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed map, to test asynchronous serialization and deserialization. - (void)echoAsyncMap:(NSDictionary *)aMap @@ -392,7 +392,7 @@ NSObject *FLTHostIntegrationCoreApiGetCodec(void); - (void)echoAsyncNullableObject:(nullable id)anObject completion:(void (^)(id _Nullable, FlutterError *_Nullable))completion; /// Returns the passed list, to test asynchronous serialization and deserialization. -- (void)echoAsyncNullableList:(nullable NSArray *)aList +- (void)echoAsyncNullableList:(nullable NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed map, to test asynchronous serialization and deserialization. - (void)echoAsyncNullableMap:(nullable NSDictionary *)aMap @@ -440,10 +440,10 @@ NSObject *FLTHostIntegrationCoreApiGetCodec(void); completion:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion; - (void)callFlutterEchoString:(NSString *)aString completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; -- (void)callFlutterEchoUint8List:(FlutterStandardTypedData *)aList +- (void)callFlutterEchoUint8List:(FlutterStandardTypedData *)list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion; -- (void)callFlutterEchoList:(NSArray *)aList +- (void)callFlutterEchoList:(NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; - (void)callFlutterEchoMap:(NSDictionary *)aMap completion:(void (^)(NSDictionary *_Nullable, @@ -462,10 +462,10 @@ NSObject *FLTHostIntegrationCoreApiGetCodec(void); - (void)callFlutterEchoNullableString:(nullable NSString *)aString completion: (void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; -- (void)callFlutterEchoNullableUint8List:(nullable FlutterStandardTypedData *)aList +- (void)callFlutterEchoNullableUint8List:(nullable FlutterStandardTypedData *)list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion; -- (void)callFlutterEchoNullableList:(nullable NSArray *)aList +- (void)callFlutterEchoNullableList:(nullable NSArray *)list completion: (void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; - (void)callFlutterEchoNullableMap:(nullable NSDictionary *)aMap @@ -536,11 +536,11 @@ NSObject *FLTFlutterIntegrationCoreApiGetCodec(void); - (void)echoString:(NSString *)aString completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed byte list, to test serialization and deserialization. -- (void)echoUint8List:(FlutterStandardTypedData *)aList +- (void)echoUint8List:(FlutterStandardTypedData *)list completion: (void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed list, to test serialization and deserialization. -- (void)echoList:(NSArray *)aList +- (void)echoList:(NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed map, to test serialization and deserialization. - (void)echoMap:(NSDictionary *)aMap @@ -562,11 +562,11 @@ NSObject *FLTFlutterIntegrationCoreApiGetCodec(void); - (void)echoNullableString:(nullable NSString *)aString completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed byte list, to test serialization and deserialization. -- (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)aList +- (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed list, to test serialization and deserialization. -- (void)echoNullableList:(nullable NSArray *)aList +- (void)echoNullableList:(nullable NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed map, to test serialization and deserialization. - (void)echoNullableMap:(nullable NSDictionary *)aMap 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 abfb4735b7d..ace6b710668 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 @@ -51,32 +51,32 @@ - (instancetype)initWithValue:(FLTAnEnum)value { @end @interface FLTAllTypes () -+ (FLTAllTypes *)fromList:(NSArray *)__pigeon_list; -+ (nullable FLTAllTypes *)nullableFromList:(NSArray *)__pigeon_list; ++ (FLTAllTypes *)fromList:(NSArray *)list; ++ (nullable FLTAllTypes *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @interface FLTAllNullableTypes () -+ (FLTAllNullableTypes *)fromList:(NSArray *)__pigeon_list; -+ (nullable FLTAllNullableTypes *)nullableFromList:(NSArray *)__pigeon_list; ++ (FLTAllNullableTypes *)fromList:(NSArray *)list; ++ (nullable FLTAllNullableTypes *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @interface FLTAllNullableTypesWithoutRecursion () -+ (FLTAllNullableTypesWithoutRecursion *)fromList:(NSArray *)__pigeon_list; -+ (nullable FLTAllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)__pigeon_list; ++ (FLTAllNullableTypesWithoutRecursion *)fromList:(NSArray *)list; ++ (nullable FLTAllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @interface FLTAllClassesWrapper () -+ (FLTAllClassesWrapper *)fromList:(NSArray *)__pigeon_list; -+ (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)__pigeon_list; ++ (FLTAllClassesWrapper *)fromList:(NSArray *)list; ++ (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @interface FLTTestMessage () -+ (FLTTestMessage *)fromList:(NSArray *)__pigeon_list; -+ (nullable FLTTestMessage *)nullableFromList:(NSArray *)__pigeon_list; ++ (FLTTestMessage *)fromList:(NSArray *)list; ++ (nullable FLTTestMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @@ -89,7 +89,7 @@ + (instancetype)makeWithABool:(BOOL)aBool a4ByteArray:(FlutterStandardTypedData *)a4ByteArray a8ByteArray:(FlutterStandardTypedData *)a8ByteArray aFloatArray:(FlutterStandardTypedData *)aFloatArray - aList:(NSArray *)aList + list:(NSArray *)list aMap:(NSDictionary *)aMap anEnum:(FLTAnEnum)anEnum aString:(NSString *)aString @@ -103,32 +103,32 @@ + (instancetype)makeWithABool:(BOOL)aBool pigeonResult.a4ByteArray = a4ByteArray; pigeonResult.a8ByteArray = a8ByteArray; pigeonResult.aFloatArray = aFloatArray; - pigeonResult.aList = aList; + pigeonResult.list = list; pigeonResult.aMap = aMap; pigeonResult.anEnum = anEnum; pigeonResult.aString = aString; pigeonResult.anObject = anObject; return pigeonResult; } -+ (FLTAllTypes *)fromList:(NSArray *)__pigeon_list { ++ (FLTAllTypes *)fromList:(NSArray *)list { FLTAllTypes *pigeonResult = [[FLTAllTypes alloc] init]; - pigeonResult.aBool = [GetNullableObjectAtIndex(__pigeon_list, 0) boolValue]; - pigeonResult.anInt = [GetNullableObjectAtIndex(__pigeon_list, 1) integerValue]; - pigeonResult.anInt64 = [GetNullableObjectAtIndex(__pigeon_list, 2) integerValue]; - pigeonResult.aDouble = [GetNullableObjectAtIndex(__pigeon_list, 3) doubleValue]; - pigeonResult.aByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); - pigeonResult.a4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); - pigeonResult.a8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); - pigeonResult.aFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); - pigeonResult.aList = GetNullableObjectAtIndex(__pigeon_list, 8); - pigeonResult.aMap = GetNullableObjectAtIndex(__pigeon_list, 9); - pigeonResult.anEnum = [GetNullableObjectAtIndex(__pigeon_list, 10) integerValue]; - pigeonResult.aString = GetNullableObjectAtIndex(__pigeon_list, 11); - pigeonResult.anObject = GetNullableObjectAtIndex(__pigeon_list, 12); + pigeonResult.aBool = [GetNullableObjectAtIndex(list, 0) boolValue]; + pigeonResult.anInt = [GetNullableObjectAtIndex(list, 1) integerValue]; + pigeonResult.anInt64 = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.aDouble = [GetNullableObjectAtIndex(list, 3) doubleValue]; + pigeonResult.aByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.a4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.a8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.list = GetNullableObjectAtIndex(list, 8); + pigeonResult.aMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.anEnum = [GetNullableObjectAtIndex(list, 10) integerValue]; + pigeonResult.aString = GetNullableObjectAtIndex(list, 11); + pigeonResult.anObject = GetNullableObjectAtIndex(list, 12); return pigeonResult; } -+ (nullable FLTAllTypes *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [FLTAllTypes fromList:__pigeon_list] : nil; ++ (nullable FLTAllTypes *)nullableFromList:(NSArray *)list { + return (list) ? [FLTAllTypes fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -140,7 +140,7 @@ - (NSArray *)toList { self.a4ByteArray ?: [NSNull null], self.a8ByteArray ?: [NSNull null], self.aFloatArray ?: [NSNull null], - self.aList ?: [NSNull null], + self.list ?: [NSNull null], self.aMap ?: [NSNull null], @(self.anEnum), self.aString ?: [NSNull null], @@ -188,34 +188,34 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool pigeonResult.allNullableTypes = allNullableTypes; return pigeonResult; } -+ (FLTAllNullableTypes *)fromList:(NSArray *)__pigeon_list { ++ (FLTAllNullableTypes *)fromList:(NSArray *)list { FLTAllNullableTypes *pigeonResult = [[FLTAllNullableTypes alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(__pigeon_list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(__pigeon_list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(__pigeon_list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(__pigeon_list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(__pigeon_list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(__pigeon_list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(__pigeon_list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(__pigeon_list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(__pigeon_list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(__pigeon_list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); FLTAnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[FLTAnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(__pigeon_list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(__pigeon_list, 15); - pigeonResult.allNullableTypes = GetNullableObjectAtIndex(__pigeon_list, 16); + pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 16); return pigeonResult; } -+ (nullable FLTAllNullableTypes *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [FLTAllNullableTypes fromList:__pigeon_list] : nil; ++ (nullable FLTAllNullableTypes *)nullableFromList:(NSArray *)list { + return (list) ? [FLTAllNullableTypes fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -279,34 +279,34 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool pigeonResult.aNullableObject = aNullableObject; return pigeonResult; } -+ (FLTAllNullableTypesWithoutRecursion *)fromList:(NSArray *)__pigeon_list { ++ (FLTAllNullableTypesWithoutRecursion *)fromList:(NSArray *)list { FLTAllNullableTypesWithoutRecursion *pigeonResult = [[FLTAllNullableTypesWithoutRecursion alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(__pigeon_list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(__pigeon_list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(__pigeon_list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(__pigeon_list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(__pigeon_list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(__pigeon_list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(__pigeon_list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(__pigeon_list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(__pigeon_list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(__pigeon_list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); FLTAnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[FLTAnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(__pigeon_list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(__pigeon_list, 15); + pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); return pigeonResult; } -+ (nullable FLTAllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [FLTAllNullableTypesWithoutRecursion fromList:__pigeon_list] : nil; ++ (nullable FLTAllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list { + return (list) ? [FLTAllNullableTypesWithoutRecursion fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -342,15 +342,15 @@ + (instancetype)makeWithAllNullableTypes:(FLTAllNullableTypes *)allNullableTypes pigeonResult.allTypes = allTypes; return pigeonResult; } -+ (FLTAllClassesWrapper *)fromList:(NSArray *)__pigeon_list { ++ (FLTAllClassesWrapper *)fromList:(NSArray *)list { FLTAllClassesWrapper *pigeonResult = [[FLTAllClassesWrapper alloc] init]; - pigeonResult.allNullableTypes = GetNullableObjectAtIndex(__pigeon_list, 0); - pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex(__pigeon_list, 1); - pigeonResult.allTypes = GetNullableObjectAtIndex(__pigeon_list, 2); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 0); + pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex(list, 1); + pigeonResult.allTypes = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [FLTAllClassesWrapper fromList:__pigeon_list] : nil; ++ (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)list { + return (list) ? [FLTAllClassesWrapper fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -367,13 +367,13 @@ + (instancetype)makeWithTestList:(nullable NSArray *)testList { pigeonResult.testList = testList; return pigeonResult; } -+ (FLTTestMessage *)fromList:(NSArray *)__pigeon_list { ++ (FLTTestMessage *)fromList:(NSArray *)list { FLTTestMessage *pigeonResult = [[FLTTestMessage alloc] init]; - pigeonResult.testList = GetNullableObjectAtIndex(__pigeon_list, 0); + pigeonResult.testList = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable FLTTestMessage *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [FLTTestMessage fromList:__pigeon_list] : nil; ++ (nullable FLTTestMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FLTTestMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -707,9 +707,9 @@ void SetUpFLTHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - NSArray *arg_aList = GetNullableObjectAtIndex(args, 0); + NSArray *arg_list = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSArray *output = [api echoList:arg_aList error:&error]; + NSArray *output = [api echoList:arg_list error:&error]; callback(wrapResult(output, error)); }]; } else { @@ -1447,8 +1447,8 @@ void SetUpFLTHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - NSArray *arg_aList = GetNullableObjectAtIndex(args, 0); - [api echoAsyncList:arg_aList + NSArray *arg_list = GetNullableObjectAtIndex(args, 0); + [api echoAsyncList:arg_list completion:^(NSArray *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); }]; @@ -1807,8 +1807,8 @@ void SetUpFLTHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - NSArray *arg_aList = GetNullableObjectAtIndex(args, 0); - [api echoAsyncNullableList:arg_aList + NSArray *arg_list = GetNullableObjectAtIndex(args, 0); + [api echoAsyncNullableList:arg_list completion:^(NSArray *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); }]; @@ -2176,8 +2176,8 @@ void SetUpFLTHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - FlutterStandardTypedData *arg_aList = GetNullableObjectAtIndex(args, 0); - [api callFlutterEchoUint8List:arg_aList + FlutterStandardTypedData *arg_list = GetNullableObjectAtIndex(args, 0); + [api callFlutterEchoUint8List:arg_list completion:^(FlutterStandardTypedData *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); @@ -2200,8 +2200,8 @@ void SetUpFLTHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - NSArray *arg_aList = GetNullableObjectAtIndex(args, 0); - [api callFlutterEchoList:arg_aList + NSArray *arg_list = GetNullableObjectAtIndex(args, 0); + [api callFlutterEchoList:arg_list completion:^(NSArray *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); }]; @@ -2369,8 +2369,8 @@ void SetUpFLTHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - FlutterStandardTypedData *arg_aList = GetNullableObjectAtIndex(args, 0); - [api callFlutterEchoNullableUint8List:arg_aList + FlutterStandardTypedData *arg_list = GetNullableObjectAtIndex(args, 0); + [api callFlutterEchoNullableUint8List:arg_list completion:^(FlutterStandardTypedData *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); @@ -2393,8 +2393,8 @@ void SetUpFLTHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - NSArray *arg_aList = GetNullableObjectAtIndex(args, 0); - [api callFlutterEchoNullableList:arg_aList + NSArray *arg_list = GetNullableObjectAtIndex(args, 0); + [api callFlutterEchoNullableList:arg_list completion:^(NSArray *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); @@ -2844,7 +2844,7 @@ - (void)echoString:(NSString *)arg_aString } }]; } -- (void)echoUint8List:(FlutterStandardTypedData *)arg_aList +- (void)echoUint8List:(FlutterStandardTypedData *)arg_list completion: (void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion { NSString *channelName = @@ -2853,7 +2853,7 @@ - (void)echoUint8List:(FlutterStandardTypedData *)arg_aList [FlutterBasicMessageChannel messageChannelWithName:channelName binaryMessenger:self.binaryMessenger codec:FLTFlutterIntegrationCoreApiGetCodec()]; - [channel sendMessage:@[ arg_aList ?: [NSNull null] ] + [channel sendMessage:@[ arg_list ?: [NSNull null] ] reply:^(NSArray *reply) { if (reply != nil) { if (reply.count > 1) { @@ -2870,7 +2870,7 @@ - (void)echoUint8List:(FlutterStandardTypedData *)arg_aList } }]; } -- (void)echoList:(NSArray *)arg_aList +- (void)echoList:(NSArray *)arg_list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { NSString *channelName = @"dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList"; @@ -2878,7 +2878,7 @@ - (void)echoList:(NSArray *)arg_aList [FlutterBasicMessageChannel messageChannelWithName:channelName binaryMessenger:self.binaryMessenger codec:FLTFlutterIntegrationCoreApiGetCodec()]; - [channel sendMessage:@[ arg_aList ?: [NSNull null] ] + [channel sendMessage:@[ arg_list ?: [NSNull null] ] reply:^(NSArray *reply) { if (reply != nil) { if (reply.count > 1) { @@ -3044,7 +3044,7 @@ - (void)echoNullableString:(nullable NSString *)arg_aString } }]; } -- (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)arg_aList +- (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)arg_list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion { NSString *channelName = @"dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi." @@ -3053,7 +3053,7 @@ - (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)arg_aList [FlutterBasicMessageChannel messageChannelWithName:channelName binaryMessenger:self.binaryMessenger codec:FLTFlutterIntegrationCoreApiGetCodec()]; - [channel sendMessage:@[ arg_aList ?: [NSNull null] ] + [channel sendMessage:@[ arg_list ?: [NSNull null] ] reply:^(NSArray *reply) { if (reply != nil) { if (reply.count > 1) { @@ -3070,7 +3070,7 @@ - (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)arg_aList } }]; } -- (void)echoNullableList:(nullable NSArray *)arg_aList +- (void)echoNullableList:(nullable NSArray *)arg_list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { NSString *channelName = @"dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList"; @@ -3078,7 +3078,7 @@ - (void)echoNullableList:(nullable NSArray *)arg_aList [FlutterBasicMessageChannel messageChannelWithName:channelName binaryMessenger:self.binaryMessenger codec:FLTFlutterIntegrationCoreApiGetCodec()]; - [channel sendMessage:@[ arg_aList ?: [NSNull null] ] + [channel sendMessage:@[ arg_list ?: [NSNull null] ] reply:^(NSArray *reply) { if (reply != nil) { if (reply.count > 1) { diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/AlternateLanguageTestPlugin.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/AlternateLanguageTestPlugin.m index ea91a7eaa1b..6e2c91a27b8 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/AlternateLanguageTestPlugin.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/AlternateLanguageTestPlugin.m @@ -80,9 +80,9 @@ - (nullable id)echoObject:(id)anObject error:(FlutterError *_Nullable *_Nonnull) return anObject; } -- (nullable NSArray *)echoList:(NSArray *)aList +- (nullable NSArray *)echoList:(NSArray *)list error:(FlutterError *_Nullable *_Nonnull)error { - return aList; + return list; } - (nullable NSDictionary *)echoMap:(NSDictionary *)aMap @@ -280,9 +280,9 @@ - (void)echoAsyncObject:(id)anObject completion(anObject, nil); } -- (void)echoAsyncList:(NSArray *)aList +- (void)echoAsyncList:(NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { - completion(aList, nil); + completion(list, nil); } - (void)echoAsyncMap:(NSDictionary *)aMap @@ -327,10 +327,10 @@ - (void)echoAsyncNullableObject:(nullable id)anObject completion(anObject, nil); } -- (void)echoAsyncNullableList:(nullable NSArray *)aList +- (void)echoAsyncNullableList:(nullable NSArray *)list completion: (void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { - completion(aList, nil); + completion(list, nil); } - (void)echoAsyncNullableMap:(nullable NSDictionary *)aMap @@ -435,18 +435,18 @@ - (void)callFlutterEchoString:(NSString *)aString }]; } -- (void)callFlutterEchoUint8List:(FlutterStandardTypedData *)aList +- (void)callFlutterEchoUint8List:(FlutterStandardTypedData *)list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion { - [self.flutterAPI echoUint8List:aList + [self.flutterAPI echoUint8List:list completion:^(FlutterStandardTypedData *value, FlutterError *error) { completion(value, error); }]; } -- (void)callFlutterEchoList:(NSArray *)aList +- (void)callFlutterEchoList:(NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { - [self.flutterAPI echoList:aList + [self.flutterAPI echoList:list completion:^(NSArray *value, FlutterError *error) { completion(value, error); }]; @@ -527,19 +527,19 @@ - (void)callFlutterEchoNullableString:(nullable NSString *)aString }]; } -- (void)callFlutterEchoNullableUint8List:(nullable FlutterStandardTypedData *)aList +- (void)callFlutterEchoNullableUint8List:(nullable FlutterStandardTypedData *)list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion { - [self.flutterAPI echoNullableUint8List:aList + [self.flutterAPI echoNullableUint8List:list completion:^(FlutterStandardTypedData *value, FlutterError *error) { completion(value, error); }]; } -- (void)callFlutterEchoNullableList:(nullable NSArray *)aList +- (void)callFlutterEchoNullableList:(nullable NSArray *)list completion: (void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { - [self.flutterAPI echoNullableList:aList + [self.flutterAPI echoNullableList:list completion:^(NSArray *value, FlutterError *error) { completion(value, error); }]; diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.h b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.h index a7ec37232c1..a7faa7fb4b8 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.h +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.h @@ -46,7 +46,7 @@ typedef NS_ENUM(NSUInteger, AnEnum) { a4ByteArray:(FlutterStandardTypedData *)a4ByteArray a8ByteArray:(FlutterStandardTypedData *)a8ByteArray aFloatArray:(FlutterStandardTypedData *)aFloatArray - aList:(NSArray *)aList + list:(NSArray *)list aMap:(NSDictionary *)aMap anEnum:(AnEnum)anEnum aString:(NSString *)aString @@ -59,7 +59,7 @@ typedef NS_ENUM(NSUInteger, AnEnum) { @property(nonatomic, strong) FlutterStandardTypedData *a4ByteArray; @property(nonatomic, strong) FlutterStandardTypedData *a8ByteArray; @property(nonatomic, strong) FlutterStandardTypedData *aFloatArray; -@property(nonatomic, copy) NSArray *aList; +@property(nonatomic, copy) NSArray *list; @property(nonatomic, copy) NSDictionary *aMap; @property(nonatomic, assign) AnEnum anEnum; @property(nonatomic, copy) NSString *aString; @@ -219,7 +219,7 @@ NSObject *HostIntegrationCoreApiGetCodec(void); /// Returns the passed list, to test serialization and deserialization. /// /// @return `nil` only when `error != nil`. -- (nullable NSArray *)echoList:(NSArray *)aList +- (nullable NSArray *)echoList:(NSArray *)list error:(FlutterError *_Nullable *_Nonnull)error; /// Returns the passed map, to test serialization and deserialization. /// @@ -341,7 +341,7 @@ NSObject *HostIntegrationCoreApiGetCodec(void); - (void)echoAsyncObject:(id)anObject completion:(void (^)(id _Nullable, FlutterError *_Nullable))completion; /// Returns the passed list, to test asynchronous serialization and deserialization. -- (void)echoAsyncList:(NSArray *)aList +- (void)echoAsyncList:(NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed map, to test asynchronous serialization and deserialization. - (void)echoAsyncMap:(NSDictionary *)aMap @@ -391,7 +391,7 @@ NSObject *HostIntegrationCoreApiGetCodec(void); - (void)echoAsyncNullableObject:(nullable id)anObject completion:(void (^)(id _Nullable, FlutterError *_Nullable))completion; /// Returns the passed list, to test asynchronous serialization and deserialization. -- (void)echoAsyncNullableList:(nullable NSArray *)aList +- (void)echoAsyncNullableList:(nullable NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed map, to test asynchronous serialization and deserialization. - (void)echoAsyncNullableMap:(nullable NSDictionary *)aMap @@ -437,10 +437,10 @@ NSObject *HostIntegrationCoreApiGetCodec(void); completion:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion; - (void)callFlutterEchoString:(NSString *)aString completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; -- (void)callFlutterEchoUint8List:(FlutterStandardTypedData *)aList +- (void)callFlutterEchoUint8List:(FlutterStandardTypedData *)list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion; -- (void)callFlutterEchoList:(NSArray *)aList +- (void)callFlutterEchoList:(NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; - (void)callFlutterEchoMap:(NSDictionary *)aMap completion:(void (^)(NSDictionary *_Nullable, @@ -459,10 +459,10 @@ NSObject *HostIntegrationCoreApiGetCodec(void); - (void)callFlutterEchoNullableString:(nullable NSString *)aString completion: (void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; -- (void)callFlutterEchoNullableUint8List:(nullable FlutterStandardTypedData *)aList +- (void)callFlutterEchoNullableUint8List:(nullable FlutterStandardTypedData *)list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion; -- (void)callFlutterEchoNullableList:(nullable NSArray *)aList +- (void)callFlutterEchoNullableList:(nullable NSArray *)list completion: (void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; - (void)callFlutterEchoNullableMap:(nullable NSDictionary *)aMap @@ -532,11 +532,11 @@ NSObject *FlutterIntegrationCoreApiGetCodec(void); - (void)echoString:(NSString *)aString completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed byte list, to test serialization and deserialization. -- (void)echoUint8List:(FlutterStandardTypedData *)aList +- (void)echoUint8List:(FlutterStandardTypedData *)list completion: (void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed list, to test serialization and deserialization. -- (void)echoList:(NSArray *)aList +- (void)echoList:(NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed map, to test serialization and deserialization. - (void)echoMap:(NSDictionary *)aMap @@ -558,11 +558,11 @@ NSObject *FlutterIntegrationCoreApiGetCodec(void); - (void)echoNullableString:(nullable NSString *)aString completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed byte list, to test serialization and deserialization. -- (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)aList +- (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed list, to test serialization and deserialization. -- (void)echoNullableList:(nullable NSArray *)aList +- (void)echoNullableList:(nullable NSArray *)list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion; /// Returns the passed map, to test serialization and deserialization. - (void)echoNullableMap:(nullable NSDictionary *)aMap diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m index d63ce8bcfe8..885935cef5a 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m @@ -51,32 +51,32 @@ - (instancetype)initWithValue:(AnEnum)value { @end @interface AllTypes () -+ (AllTypes *)fromList:(NSArray *)__pigeon_list; -+ (nullable AllTypes *)nullableFromList:(NSArray *)__pigeon_list; ++ (AllTypes *)fromList:(NSArray *)list; ++ (nullable AllTypes *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @interface AllNullableTypes () -+ (AllNullableTypes *)fromList:(NSArray *)__pigeon_list; -+ (nullable AllNullableTypes *)nullableFromList:(NSArray *)__pigeon_list; ++ (AllNullableTypes *)fromList:(NSArray *)list; ++ (nullable AllNullableTypes *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @interface AllNullableTypesWithoutRecursion () -+ (AllNullableTypesWithoutRecursion *)fromList:(NSArray *)__pigeon_list; -+ (nullable AllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)__pigeon_list; ++ (AllNullableTypesWithoutRecursion *)fromList:(NSArray *)list; ++ (nullable AllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @interface AllClassesWrapper () -+ (AllClassesWrapper *)fromList:(NSArray *)__pigeon_list; -+ (nullable AllClassesWrapper *)nullableFromList:(NSArray *)__pigeon_list; ++ (AllClassesWrapper *)fromList:(NSArray *)list; ++ (nullable AllClassesWrapper *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @interface TestMessage () -+ (TestMessage *)fromList:(NSArray *)__pigeon_list; -+ (nullable TestMessage *)nullableFromList:(NSArray *)__pigeon_list; ++ (TestMessage *)fromList:(NSArray *)list; ++ (nullable TestMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end @@ -89,7 +89,7 @@ + (instancetype)makeWithABool:(BOOL)aBool a4ByteArray:(FlutterStandardTypedData *)a4ByteArray a8ByteArray:(FlutterStandardTypedData *)a8ByteArray aFloatArray:(FlutterStandardTypedData *)aFloatArray - aList:(NSArray *)aList + list:(NSArray *)list aMap:(NSDictionary *)aMap anEnum:(AnEnum)anEnum aString:(NSString *)aString @@ -103,32 +103,32 @@ + (instancetype)makeWithABool:(BOOL)aBool pigeonResult.a4ByteArray = a4ByteArray; pigeonResult.a8ByteArray = a8ByteArray; pigeonResult.aFloatArray = aFloatArray; - pigeonResult.aList = aList; + pigeonResult.list = list; pigeonResult.aMap = aMap; pigeonResult.anEnum = anEnum; pigeonResult.aString = aString; pigeonResult.anObject = anObject; return pigeonResult; } -+ (AllTypes *)fromList:(NSArray *)__pigeon_list { ++ (AllTypes *)fromList:(NSArray *)list { AllTypes *pigeonResult = [[AllTypes alloc] init]; - pigeonResult.aBool = [GetNullableObjectAtIndex(__pigeon_list, 0) boolValue]; - pigeonResult.anInt = [GetNullableObjectAtIndex(__pigeon_list, 1) integerValue]; - pigeonResult.anInt64 = [GetNullableObjectAtIndex(__pigeon_list, 2) integerValue]; - pigeonResult.aDouble = [GetNullableObjectAtIndex(__pigeon_list, 3) doubleValue]; - pigeonResult.aByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); - pigeonResult.a4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); - pigeonResult.a8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); - pigeonResult.aFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); - pigeonResult.aList = GetNullableObjectAtIndex(__pigeon_list, 8); - pigeonResult.aMap = GetNullableObjectAtIndex(__pigeon_list, 9); - pigeonResult.anEnum = [GetNullableObjectAtIndex(__pigeon_list, 10) integerValue]; - pigeonResult.aString = GetNullableObjectAtIndex(__pigeon_list, 11); - pigeonResult.anObject = GetNullableObjectAtIndex(__pigeon_list, 12); + pigeonResult.aBool = [GetNullableObjectAtIndex(list, 0) boolValue]; + pigeonResult.anInt = [GetNullableObjectAtIndex(list, 1) integerValue]; + pigeonResult.anInt64 = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.aDouble = [GetNullableObjectAtIndex(list, 3) doubleValue]; + pigeonResult.aByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.a4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.a8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.list = GetNullableObjectAtIndex(list, 8); + pigeonResult.aMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.anEnum = [GetNullableObjectAtIndex(list, 10) integerValue]; + pigeonResult.aString = GetNullableObjectAtIndex(list, 11); + pigeonResult.anObject = GetNullableObjectAtIndex(list, 12); return pigeonResult; } -+ (nullable AllTypes *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [AllTypes fromList:__pigeon_list] : nil; ++ (nullable AllTypes *)nullableFromList:(NSArray *)list { + return (list) ? [AllTypes fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -140,7 +140,7 @@ - (NSArray *)toList { self.a4ByteArray ?: [NSNull null], self.a8ByteArray ?: [NSNull null], self.aFloatArray ?: [NSNull null], - self.aList ?: [NSNull null], + self.list ?: [NSNull null], self.aMap ?: [NSNull null], @(self.anEnum), self.aString ?: [NSNull null], @@ -188,34 +188,34 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool pigeonResult.allNullableTypes = allNullableTypes; return pigeonResult; } -+ (AllNullableTypes *)fromList:(NSArray *)__pigeon_list { ++ (AllNullableTypes *)fromList:(NSArray *)list { AllNullableTypes *pigeonResult = [[AllNullableTypes alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(__pigeon_list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(__pigeon_list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(__pigeon_list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(__pigeon_list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(__pigeon_list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(__pigeon_list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(__pigeon_list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(__pigeon_list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(__pigeon_list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(__pigeon_list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); AnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[AnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(__pigeon_list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(__pigeon_list, 15); - pigeonResult.allNullableTypes = GetNullableObjectAtIndex(__pigeon_list, 16); + pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 16); return pigeonResult; } -+ (nullable AllNullableTypes *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [AllNullableTypes fromList:__pigeon_list] : nil; ++ (nullable AllNullableTypes *)nullableFromList:(NSArray *)list { + return (list) ? [AllNullableTypes fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -278,33 +278,33 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool pigeonResult.aNullableObject = aNullableObject; return pigeonResult; } -+ (AllNullableTypesWithoutRecursion *)fromList:(NSArray *)__pigeon_list { ++ (AllNullableTypesWithoutRecursion *)fromList:(NSArray *)list { AllNullableTypesWithoutRecursion *pigeonResult = [[AllNullableTypesWithoutRecursion alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(__pigeon_list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(__pigeon_list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(__pigeon_list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(__pigeon_list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(__pigeon_list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(__pigeon_list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(__pigeon_list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(__pigeon_list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(__pigeon_list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(__pigeon_list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(__pigeon_list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(__pigeon_list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(__pigeon_list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(__pigeon_list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); AnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[AnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(__pigeon_list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(__pigeon_list, 15); + pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); return pigeonResult; } -+ (nullable AllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [AllNullableTypesWithoutRecursion fromList:__pigeon_list] : nil; ++ (nullable AllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list { + return (list) ? [AllNullableTypesWithoutRecursion fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -340,15 +340,15 @@ + (instancetype)makeWithAllNullableTypes:(AllNullableTypes *)allNullableTypes pigeonResult.allTypes = allTypes; return pigeonResult; } -+ (AllClassesWrapper *)fromList:(NSArray *)__pigeon_list { ++ (AllClassesWrapper *)fromList:(NSArray *)list { AllClassesWrapper *pigeonResult = [[AllClassesWrapper alloc] init]; - pigeonResult.allNullableTypes = GetNullableObjectAtIndex(__pigeon_list, 0); - pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex(__pigeon_list, 1); - pigeonResult.allTypes = GetNullableObjectAtIndex(__pigeon_list, 2); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 0); + pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex(list, 1); + pigeonResult.allTypes = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable AllClassesWrapper *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [AllClassesWrapper fromList:__pigeon_list] : nil; ++ (nullable AllClassesWrapper *)nullableFromList:(NSArray *)list { + return (list) ? [AllClassesWrapper fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -365,13 +365,13 @@ + (instancetype)makeWithTestList:(nullable NSArray *)testList { pigeonResult.testList = testList; return pigeonResult; } -+ (TestMessage *)fromList:(NSArray *)__pigeon_list { ++ (TestMessage *)fromList:(NSArray *)list { TestMessage *pigeonResult = [[TestMessage alloc] init]; - pigeonResult.testList = GetNullableObjectAtIndex(__pigeon_list, 0); + pigeonResult.testList = GetNullableObjectAtIndex(list, 0); return pigeonResult; } -+ (nullable TestMessage *)nullableFromList:(NSArray *)__pigeon_list { - return (__pigeon_list) ? [TestMessage fromList:__pigeon_list] : nil; ++ (nullable TestMessage *)nullableFromList:(NSArray *)list { + return (list) ? [TestMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -702,9 +702,9 @@ void SetUpHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - NSArray *arg_aList = GetNullableObjectAtIndex(args, 0); + NSArray *arg_list = GetNullableObjectAtIndex(args, 0); FlutterError *error; - NSArray *output = [api echoList:arg_aList error:&error]; + NSArray *output = [api echoList:arg_list error:&error]; callback(wrapResult(output, error)); }]; } else { @@ -1442,8 +1442,8 @@ void SetUpHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - NSArray *arg_aList = GetNullableObjectAtIndex(args, 0); - [api echoAsyncList:arg_aList + NSArray *arg_list = GetNullableObjectAtIndex(args, 0); + [api echoAsyncList:arg_list completion:^(NSArray *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); }]; @@ -1802,8 +1802,8 @@ void SetUpHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - NSArray *arg_aList = GetNullableObjectAtIndex(args, 0); - [api echoAsyncNullableList:arg_aList + NSArray *arg_list = GetNullableObjectAtIndex(args, 0); + [api echoAsyncNullableList:arg_list completion:^(NSArray *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); }]; @@ -2170,8 +2170,8 @@ void SetUpHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - FlutterStandardTypedData *arg_aList = GetNullableObjectAtIndex(args, 0); - [api callFlutterEchoUint8List:arg_aList + FlutterStandardTypedData *arg_list = GetNullableObjectAtIndex(args, 0); + [api callFlutterEchoUint8List:arg_list completion:^(FlutterStandardTypedData *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); @@ -2194,8 +2194,8 @@ void SetUpHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - NSArray *arg_aList = GetNullableObjectAtIndex(args, 0); - [api callFlutterEchoList:arg_aList + NSArray *arg_list = GetNullableObjectAtIndex(args, 0); + [api callFlutterEchoList:arg_list completion:^(NSArray *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); }]; @@ -2362,8 +2362,8 @@ void SetUpHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - FlutterStandardTypedData *arg_aList = GetNullableObjectAtIndex(args, 0); - [api callFlutterEchoNullableUint8List:arg_aList + FlutterStandardTypedData *arg_list = GetNullableObjectAtIndex(args, 0); + [api callFlutterEchoNullableUint8List:arg_list completion:^(FlutterStandardTypedData *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); @@ -2386,8 +2386,8 @@ void SetUpHostIntegrationCoreApi(id binaryMessenger, api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; - NSArray *arg_aList = GetNullableObjectAtIndex(args, 0); - [api callFlutterEchoNullableList:arg_aList + NSArray *arg_list = GetNullableObjectAtIndex(args, 0); + [api callFlutterEchoNullableList:arg_list completion:^(NSArray *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); @@ -2836,7 +2836,7 @@ - (void)echoString:(NSString *)arg_aString } }]; } -- (void)echoUint8List:(FlutterStandardTypedData *)arg_aList +- (void)echoUint8List:(FlutterStandardTypedData *)arg_list completion: (void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion { NSString *channelName = @@ -2845,7 +2845,7 @@ - (void)echoUint8List:(FlutterStandardTypedData *)arg_aList [FlutterBasicMessageChannel messageChannelWithName:channelName binaryMessenger:self.binaryMessenger codec:FlutterIntegrationCoreApiGetCodec()]; - [channel sendMessage:@[ arg_aList ?: [NSNull null] ] + [channel sendMessage:@[ arg_list ?: [NSNull null] ] reply:^(NSArray *reply) { if (reply != nil) { if (reply.count > 1) { @@ -2862,7 +2862,7 @@ - (void)echoUint8List:(FlutterStandardTypedData *)arg_aList } }]; } -- (void)echoList:(NSArray *)arg_aList +- (void)echoList:(NSArray *)arg_list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { NSString *channelName = @"dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList"; @@ -2870,7 +2870,7 @@ - (void)echoList:(NSArray *)arg_aList [FlutterBasicMessageChannel messageChannelWithName:channelName binaryMessenger:self.binaryMessenger codec:FlutterIntegrationCoreApiGetCodec()]; - [channel sendMessage:@[ arg_aList ?: [NSNull null] ] + [channel sendMessage:@[ arg_list ?: [NSNull null] ] reply:^(NSArray *reply) { if (reply != nil) { if (reply.count > 1) { @@ -3036,7 +3036,7 @@ - (void)echoNullableString:(nullable NSString *)arg_aString } }]; } -- (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)arg_aList +- (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)arg_list completion:(void (^)(FlutterStandardTypedData *_Nullable, FlutterError *_Nullable))completion { NSString *channelName = @"dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi." @@ -3045,7 +3045,7 @@ - (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)arg_aList [FlutterBasicMessageChannel messageChannelWithName:channelName binaryMessenger:self.binaryMessenger codec:FlutterIntegrationCoreApiGetCodec()]; - [channel sendMessage:@[ arg_aList ?: [NSNull null] ] + [channel sendMessage:@[ arg_list ?: [NSNull null] ] reply:^(NSArray *reply) { if (reply != nil) { if (reply.count > 1) { @@ -3062,7 +3062,7 @@ - (void)echoNullableUint8List:(nullable FlutterStandardTypedData *)arg_aList } }]; } -- (void)echoNullableList:(nullable NSArray *)arg_aList +- (void)echoNullableList:(nullable NSArray *)arg_list completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion { NSString *channelName = @"dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList"; @@ -3070,7 +3070,7 @@ - (void)echoNullableList:(nullable NSArray *)arg_aList [FlutterBasicMessageChannel messageChannelWithName:channelName binaryMessenger:self.binaryMessenger codec:FlutterIntegrationCoreApiGetCodec()]; - [channel sendMessage:@[ arg_aList ?: [NSNull null] ] + [channel sendMessage:@[ arg_list ?: [NSNull null] ] reply:^(NSArray *reply) { if (reply != nil) { if (reply.count > 1) { diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart index 876c3b149d7..f4a06c8d503 100644 --- a/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/lib/integration_tests.dart @@ -49,7 +49,7 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) { expect(allTypesOne.a4ByteArray, allTypesTwo.a4ByteArray); expect(allTypesOne.a8ByteArray, allTypesTwo.a8ByteArray); expect(allTypesOne.aFloatArray, allTypesTwo.aFloatArray); - expect(listEquals(allTypesOne.aList, allTypesTwo.aList), true); + expect(listEquals(allTypesOne.list, allTypesTwo.list), true); expect(mapEquals(allTypesOne.aMap, allTypesTwo.aMap), true); expect(allTypesOne.anEnum, allTypesTwo.anEnum); expect(allTypesOne.anObject, allTypesTwo.anObject); @@ -190,7 +190,7 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) { a4ByteArray: Int32List.fromList([4, 5, 6]), a8ByteArray: Int64List.fromList([7, 8, 9]), aFloatArray: Float64List.fromList([2.71828, _doublePi]), - aList: ['Thing 1', 2, true, 3.14, null], + list: ['Thing 1', 2, true, 3.14, null], aMap: { 'a': 1, 'b': 2.0, @@ -1805,10 +1805,10 @@ class _FlutterApiTestImplementation implements FlutterIntegrationCoreApi { String echoString(String aString) => aString; @override - Uint8List echoUint8List(Uint8List aList) => aList; + Uint8List echoUint8List(Uint8List list) => list; @override - List echoList(List aList) => aList; + List echoList(List list) => list; @override Map echoMap(Map aMap) => aMap; @@ -1826,7 +1826,7 @@ class _FlutterApiTestImplementation implements FlutterIntegrationCoreApi { int? echoNullableInt(int? anInt) => anInt; @override - List? echoNullableList(List? aList) => aList; + List? echoNullableList(List? list) => list; @override Map? echoNullableMap(Map? aMap) => aMap; @@ -1835,7 +1835,7 @@ class _FlutterApiTestImplementation implements FlutterIntegrationCoreApi { String? echoNullableString(String? aString) => aString; @override - Uint8List? echoNullableUint8List(Uint8List? aList) => aList; + Uint8List? echoNullableUint8List(Uint8List? list) => list; @override AnEnum? echoNullableEnum(AnEnum? anEnum) => anEnum; 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 4491365bdf4..db265af824e 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 @@ -49,7 +49,7 @@ class AllTypes { required this.a4ByteArray, required this.a8ByteArray, required this.aFloatArray, - this.aList = const [], + this.list = const [], this.aMap = const {}, this.anEnum = AnEnum.one, this.aString = '', @@ -72,7 +72,7 @@ class AllTypes { Float64List aFloatArray; - List aList; + List list; Map aMap; @@ -92,7 +92,7 @@ class AllTypes { a4ByteArray, a8ByteArray, aFloatArray, - aList, + list, aMap, anEnum.index, aString, @@ -111,7 +111,7 @@ class AllTypes { a4ByteArray: result[5]! as Int32List, a8ByteArray: result[6]! as Int64List, aFloatArray: result[7]! as Float64List, - aList: result[8]! as List, + list: result[8]! as List, aMap: result[9]! as Map, anEnum: AnEnum.values[result[10]! as int], aString: result[11]! as String, @@ -754,7 +754,7 @@ class HostIntegrationCoreApi { } /// Returns the passed list, to test serialization and deserialization. - Future> echoList(List aList) async { + Future> echoList(List list) async { const String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoList'; final BasicMessageChannel __pigeon_channel = @@ -764,7 +764,7 @@ class HostIntegrationCoreApi { binaryMessenger: __pigeon_binaryMessenger, ); final List? __pigeon_replyList = - await __pigeon_channel.send([aList]) as List?; + await __pigeon_channel.send([list]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -1626,7 +1626,7 @@ class HostIntegrationCoreApi { } /// Returns the passed list, to test asynchronous serialization and deserialization. - Future> echoAsyncList(List aList) async { + Future> echoAsyncList(List list) async { const String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncList'; final BasicMessageChannel __pigeon_channel = @@ -1636,7 +1636,7 @@ class HostIntegrationCoreApi { binaryMessenger: __pigeon_binaryMessenger, ); final List? __pigeon_replyList = - await __pigeon_channel.send([aList]) as List?; + await __pigeon_channel.send([list]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2025,7 +2025,7 @@ class HostIntegrationCoreApi { } /// Returns the passed list, to test asynchronous serialization and deserialization. - Future?> echoAsyncNullableList(List? aList) async { + Future?> echoAsyncNullableList(List? list) async { const String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableList'; final BasicMessageChannel __pigeon_channel = @@ -2035,7 +2035,7 @@ class HostIntegrationCoreApi { binaryMessenger: __pigeon_binaryMessenger, ); final List? __pigeon_replyList = - await __pigeon_channel.send([aList]) as List?; + await __pigeon_channel.send([list]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2434,7 +2434,7 @@ class HostIntegrationCoreApi { } } - Future callFlutterEchoUint8List(Uint8List aList) async { + Future callFlutterEchoUint8List(Uint8List list) async { const String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoUint8List'; final BasicMessageChannel __pigeon_channel = @@ -2444,7 +2444,7 @@ class HostIntegrationCoreApi { binaryMessenger: __pigeon_binaryMessenger, ); final List? __pigeon_replyList = - await __pigeon_channel.send([aList]) as List?; + await __pigeon_channel.send([list]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2463,7 +2463,7 @@ class HostIntegrationCoreApi { } } - Future> callFlutterEchoList(List aList) async { + Future> callFlutterEchoList(List list) async { const String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoList'; final BasicMessageChannel __pigeon_channel = @@ -2473,7 +2473,7 @@ class HostIntegrationCoreApi { binaryMessenger: __pigeon_binaryMessenger, ); final List? __pigeon_replyList = - await __pigeon_channel.send([aList]) as List?; + await __pigeon_channel.send([list]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2648,7 +2648,7 @@ class HostIntegrationCoreApi { } } - Future callFlutterEchoNullableUint8List(Uint8List? aList) async { + Future callFlutterEchoNullableUint8List(Uint8List? list) async { const String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableUint8List'; final BasicMessageChannel __pigeon_channel = @@ -2658,7 +2658,7 @@ class HostIntegrationCoreApi { binaryMessenger: __pigeon_binaryMessenger, ); final List? __pigeon_replyList = - await __pigeon_channel.send([aList]) as List?; + await __pigeon_channel.send([list]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2673,7 +2673,7 @@ class HostIntegrationCoreApi { } Future?> callFlutterEchoNullableList( - List? aList) async { + List? list) async { const String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableList'; final BasicMessageChannel __pigeon_channel = @@ -2683,7 +2683,7 @@ class HostIntegrationCoreApi { binaryMessenger: __pigeon_binaryMessenger, ); final List? __pigeon_replyList = - await __pigeon_channel.send([aList]) as List?; + await __pigeon_channel.send([list]) as List?; if (__pigeon_replyList == null) { throw _createConnectionError(__pigeon_channelName); } else if (__pigeon_replyList.length > 1) { @@ -2844,10 +2844,10 @@ abstract class FlutterIntegrationCoreApi { String echoString(String aString); /// Returns the passed byte list, to test serialization and deserialization. - Uint8List echoUint8List(Uint8List aList); + Uint8List echoUint8List(Uint8List list); /// Returns the passed list, to test serialization and deserialization. - List echoList(List aList); + List echoList(List list); /// Returns the passed map, to test serialization and deserialization. Map echoMap(Map aMap); @@ -2868,10 +2868,10 @@ abstract class FlutterIntegrationCoreApi { String? echoNullableString(String? aString); /// Returns the passed byte list, to test serialization and deserialization. - Uint8List? echoNullableUint8List(Uint8List? aList); + Uint8List? echoNullableUint8List(Uint8List? list); /// Returns the passed list, to test serialization and deserialization. - List? echoNullableList(List? aList); + List? echoNullableList(List? list); /// Returns the passed map, to test serialization and deserialization. Map? echoNullableMap(Map? aMap); @@ -3222,11 +3222,11 @@ abstract class FlutterIntegrationCoreApi { assert(message != null, 'Argument for dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List was null.'); final List args = (message as List?)!; - final Uint8List? arg_aList = (args[0] as Uint8List?); - assert(arg_aList != null, + final Uint8List? arg_list = (args[0] as Uint8List?); + assert(arg_list != null, 'Argument for dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List was null, expected non-null Uint8List.'); try { - final Uint8List output = api.echoUint8List(arg_aList!); + final Uint8List output = api.echoUint8List(arg_list!); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -3250,12 +3250,12 @@ abstract class FlutterIntegrationCoreApi { assert(message != null, 'Argument for dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList was null.'); final List args = (message as List?)!; - final List? arg_aList = + final List? arg_list = (args[0] as List?)?.cast(); - assert(arg_aList != null, + assert(arg_list != null, 'Argument for dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList was null, expected non-null List.'); try { - final List output = api.echoList(arg_aList!); + final List output = api.echoList(arg_list!); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -3441,9 +3441,9 @@ abstract class FlutterIntegrationCoreApi { assert(message != null, 'Argument for dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableUint8List was null.'); final List args = (message as List?)!; - final Uint8List? arg_aList = (args[0] as Uint8List?); + final Uint8List? arg_list = (args[0] as Uint8List?); try { - final Uint8List? output = api.echoNullableUint8List(arg_aList); + final Uint8List? output = api.echoNullableUint8List(arg_list); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); @@ -3467,10 +3467,10 @@ abstract class FlutterIntegrationCoreApi { assert(message != null, 'Argument for dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList was null.'); final List args = (message as List?)!; - final List? arg_aList = + final List? arg_list = (args[0] as List?)?.cast(); try { - final List? output = api.echoNullableList(arg_aList); + final List? output = api.echoNullableList(arg_list); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); 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 8268f023542..e04b514013b 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 @@ -64,7 +64,7 @@ data class AllTypes( val a4ByteArray: IntArray, val a8ByteArray: LongArray, val aFloatArray: DoubleArray, - val aList: List, + val list: List, val aMap: Map, val anEnum: AnEnum, val aString: String, @@ -80,7 +80,7 @@ data class AllTypes( val a4ByteArray = __pigeon_list[5] as IntArray val a8ByteArray = __pigeon_list[6] as LongArray val aFloatArray = __pigeon_list[7] as DoubleArray - val aList = __pigeon_list[8] as List + val list = __pigeon_list[8] as List val aMap = __pigeon_list[9] as Map val anEnum = AnEnum.ofRaw(__pigeon_list[10] as Int)!! val aString = __pigeon_list[11] as String @@ -94,7 +94,7 @@ data class AllTypes( a4ByteArray, a8ByteArray, aFloatArray, - aList, + list, aMap, anEnum, aString, @@ -112,7 +112,7 @@ data class AllTypes( a4ByteArray, a8ByteArray, aFloatArray, - aList, + list, aMap, anEnum.raw, aString, @@ -426,7 +426,7 @@ interface HostIntegrationCoreApi { /** Returns the passed in generic Object. */ fun echoObject(anObject: Any): Any /** Returns the passed list, to test serialization and deserialization. */ - fun echoList(aList: List): List + fun echoList(list: List): List /** Returns the passed map, to test serialization and deserialization. */ fun echoMap(aMap: Map): Map /** Returns the passed map to test nested class serialization and deserialization. */ @@ -505,7 +505,7 @@ interface HostIntegrationCoreApi { /** Returns the passed in generic Object asynchronously. */ fun echoAsyncObject(anObject: Any, callback: (Result) -> Unit) /** Returns the passed list, to test asynchronous serialization and deserialization. */ - fun echoAsyncList(aList: List, callback: (Result>) -> Unit) + fun echoAsyncList(list: List, callback: (Result>) -> Unit) /** Returns the passed map, to test asynchronous serialization and deserialization. */ fun echoAsyncMap(aMap: Map, callback: (Result>) -> Unit) /** Returns the passed enum, to test asynchronous serialization and deserialization. */ @@ -541,7 +541,7 @@ interface HostIntegrationCoreApi { /** Returns the passed in generic Object asynchronously. */ fun echoAsyncNullableObject(anObject: Any?, callback: (Result) -> Unit) /** Returns the passed list, to test asynchronous serialization and deserialization. */ - fun echoAsyncNullableList(aList: List?, callback: (Result?>) -> Unit) + fun echoAsyncNullableList(list: List?, callback: (Result?>) -> Unit) /** Returns the passed map, to test asynchronous serialization and deserialization. */ fun echoAsyncNullableMap( aMap: Map?, @@ -590,9 +590,9 @@ interface HostIntegrationCoreApi { fun callFlutterEchoString(aString: String, callback: (Result) -> Unit) - fun callFlutterEchoUint8List(aList: ByteArray, callback: (Result) -> Unit) + fun callFlutterEchoUint8List(list: ByteArray, callback: (Result) -> Unit) - fun callFlutterEchoList(aList: List, callback: (Result>) -> Unit) + fun callFlutterEchoList(list: List, callback: (Result>) -> Unit) fun callFlutterEchoMap(aMap: Map, callback: (Result>) -> Unit) @@ -606,9 +606,9 @@ interface HostIntegrationCoreApi { fun callFlutterEchoNullableString(aString: String?, callback: (Result) -> Unit) - fun callFlutterEchoNullableUint8List(aList: ByteArray?, callback: (Result) -> Unit) + fun callFlutterEchoNullableUint8List(list: ByteArray?, callback: (Result) -> Unit) - fun callFlutterEchoNullableList(aList: List?, callback: (Result?>) -> Unit) + fun callFlutterEchoNullableList(list: List?, callback: (Result?>) -> Unit) fun callFlutterEchoNullableMap( aMap: Map?, @@ -870,10 +870,10 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val aListArg = args[0] as List + val listArg = args[0] as List val wrapped: List = try { - listOf(api.echoList(aListArg)) + listOf(api.echoList(listArg)) } catch (exception: Throwable) { wrapError(exception) } @@ -1571,8 +1571,8 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val aListArg = args[0] as List - api.echoAsyncList(aListArg) { result: Result> -> + val listArg = args[0] as List + api.echoAsyncList(listArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { reply.reply(wrapError(error)) @@ -1926,8 +1926,8 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val aListArg = args[0] as List? - api.echoAsyncNullableList(aListArg) { result: Result?> -> + val listArg = args[0] as List? + api.echoAsyncNullableList(listArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { reply.reply(wrapError(error)) @@ -2288,8 +2288,8 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val aListArg = args[0] as ByteArray - api.callFlutterEchoUint8List(aListArg) { result: Result -> + val listArg = args[0] as ByteArray + api.callFlutterEchoUint8List(listArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { reply.reply(wrapError(error)) @@ -2312,8 +2312,8 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val aListArg = args[0] as List - api.callFlutterEchoList(aListArg) { result: Result> -> + val listArg = args[0] as List + api.callFlutterEchoList(listArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { reply.reply(wrapError(error)) @@ -2480,8 +2480,8 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val aListArg = args[0] as ByteArray? - api.callFlutterEchoNullableUint8List(aListArg) { result: Result -> + val listArg = args[0] as ByteArray? + api.callFlutterEchoNullableUint8List(listArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { reply.reply(wrapError(error)) @@ -2504,8 +2504,8 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val aListArg = args[0] as List? - api.callFlutterEchoNullableList(aListArg) { result: Result?> -> + val listArg = args[0] as List? + api.callFlutterEchoNullableList(listArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { reply.reply(wrapError(error)) @@ -2920,11 +2920,11 @@ class FlutterIntegrationCoreApi(private val binaryMessenger: BinaryMessenger) { } } /** Returns the passed byte list, to test serialization and deserialization. */ - fun echoUint8List(aListArg: ByteArray, callback: (Result) -> Unit) { + fun echoUint8List(listArg: ByteArray, callback: (Result) -> Unit) { val channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) - channel.send(listOf(aListArg)) { + channel.send(listOf(listArg)) { if (it is List<*>) { if (it.size > 1) { callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) @@ -2945,11 +2945,11 @@ class FlutterIntegrationCoreApi(private val binaryMessenger: BinaryMessenger) { } } /** Returns the passed list, to test serialization and deserialization. */ - fun echoList(aListArg: List, callback: (Result>) -> Unit) { + fun echoList(listArg: List, callback: (Result>) -> Unit) { val channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) - channel.send(listOf(aListArg)) { + channel.send(listOf(listArg)) { if (it is List<*>) { if (it.size > 1) { callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) @@ -3092,11 +3092,11 @@ class FlutterIntegrationCoreApi(private val binaryMessenger: BinaryMessenger) { } } /** Returns the passed byte list, to test serialization and deserialization. */ - fun echoNullableUint8List(aListArg: ByteArray?, callback: (Result) -> Unit) { + fun echoNullableUint8List(listArg: ByteArray?, callback: (Result) -> Unit) { val channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableUint8List" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) - channel.send(listOf(aListArg)) { + channel.send(listOf(listArg)) { if (it is List<*>) { if (it.size > 1) { callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) @@ -3110,11 +3110,11 @@ class FlutterIntegrationCoreApi(private val binaryMessenger: BinaryMessenger) { } } /** Returns the passed list, to test serialization and deserialization. */ - fun echoNullableList(aListArg: List?, callback: (Result?>) -> Unit) { + fun echoNullableList(listArg: List?, callback: (Result?>) -> Unit) { val channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) - channel.send(listOf(aListArg)) { + channel.send(listOf(listArg)) { if (it is List<*>) { if (it.size > 1) { callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt index 6b51157f130..9f95fbeea92 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt @@ -71,8 +71,8 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { return anObject } - override fun echoList(aList: List): List { - return aList + override fun echoList(list: List): List { + return list } override fun echoMap(aMap: Map): Map { @@ -231,8 +231,8 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { callback(Result.success(anObject)) } - override fun echoAsyncList(aList: List, callback: (Result>) -> Unit) { - callback(Result.success(aList)) + override fun echoAsyncList(list: List, callback: (Result>) -> Unit) { + callback(Result.success(list)) } override fun echoAsyncMap( @@ -273,8 +273,8 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { callback(Result.success(anObject)) } - override fun echoAsyncNullableList(aList: List?, callback: (Result?>) -> Unit) { - callback(Result.success(aList)) + override fun echoAsyncNullableList(list: List?, callback: (Result?>) -> Unit) { + callback(Result.success(list)) } override fun echoAsyncNullableMap( @@ -350,12 +350,12 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { flutterApi!!.echoString(aString) { echo -> callback(echo) } } - override fun callFlutterEchoUint8List(aList: ByteArray, callback: (Result) -> Unit) { - flutterApi!!.echoUint8List(aList) { echo -> callback(echo) } + override fun callFlutterEchoUint8List(list: ByteArray, callback: (Result) -> Unit) { + flutterApi!!.echoUint8List(list) { echo -> callback(echo) } } - override fun callFlutterEchoList(aList: List, callback: (Result>) -> Unit) { - flutterApi!!.echoList(aList) { echo -> callback(echo) } + override fun callFlutterEchoList(list: List, callback: (Result>) -> Unit) { + flutterApi!!.echoList(list) { echo -> callback(echo) } } override fun callFlutterEchoMap( @@ -399,17 +399,17 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { } override fun callFlutterEchoNullableUint8List( - aList: ByteArray?, + list: ByteArray?, callback: (Result) -> Unit ) { - flutterApi!!.echoNullableUint8List(aList) { echo -> callback(echo) } + flutterApi!!.echoNullableUint8List(list) { echo -> callback(echo) } } override fun callFlutterEchoNullableList( - aList: List?, + list: List?, callback: (Result?>) -> Unit ) { - flutterApi!!.echoNullableList(aList) { echo -> callback(echo) } + flutterApi!!.echoNullableList(list) { echo -> callback(echo) } } override fun callFlutterEchoNullableMap( diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/test/kotlin/com/example/test_plugin/AllDatatypesTest.kt b/packages/pigeon/platform_tests/test_plugin/android/src/test/kotlin/com/example/test_plugin/AllDatatypesTest.kt index 81207b03f58..2560efb65b2 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/test/kotlin/com/example/test_plugin/AllDatatypesTest.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/test/kotlin/com/example/test_plugin/AllDatatypesTest.kt @@ -27,7 +27,7 @@ internal class AllDatatypesTest : TestCase() { assertTrue(firstTypes.a4ByteArray.contentEquals(secondTypes.a4ByteArray)) assertTrue(firstTypes.a8ByteArray.contentEquals(secondTypes.a8ByteArray)) assertTrue(firstTypes.aFloatArray.contentEquals(secondTypes.aFloatArray)) - assertEquals(firstTypes.aList, secondTypes.aList) + assertEquals(firstTypes.list, secondTypes.list) assertEquals(firstTypes.aMap, secondTypes.aMap) assertEquals(firstTypes.anEnum, secondTypes.anEnum) assertEquals(firstTypes.anObject, secondTypes.anObject) 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 6d0398cd795..322bfb4262f 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 @@ -69,7 +69,7 @@ struct AllTypes { var a4ByteArray: FlutterStandardTypedData var a8ByteArray: FlutterStandardTypedData var aFloatArray: FlutterStandardTypedData - var aList: [Any?] + var list: [Any?] var aMap: [AnyHashable: Any?] var anEnum: AnEnum var aString: String @@ -87,7 +87,7 @@ struct AllTypes { let a4ByteArray = __pigeon_list[5] as! FlutterStandardTypedData let a8ByteArray = __pigeon_list[6] as! FlutterStandardTypedData let aFloatArray = __pigeon_list[7] as! FlutterStandardTypedData - let aList = __pigeon_list[8] as! [Any?] + let list = __pigeon_list[8] as! [Any?] let aMap = __pigeon_list[9] as! [AnyHashable: Any?] let anEnum = AnEnum(rawValue: __pigeon_list[10] as! Int)! let aString = __pigeon_list[11] as! String @@ -102,7 +102,7 @@ struct AllTypes { a4ByteArray: a4ByteArray, a8ByteArray: a8ByteArray, aFloatArray: aFloatArray, - aList: aList, + list: list, aMap: aMap, anEnum: anEnum, aString: aString, @@ -119,7 +119,7 @@ struct AllTypes { a4ByteArray, a8ByteArray, aFloatArray, - aList, + list, aMap, anEnum.rawValue, aString, @@ -509,7 +509,7 @@ protocol HostIntegrationCoreApi { /// Returns the passed in generic Object. func echo(_ anObject: Any) throws -> Any /// Returns the passed list, to test serialization and deserialization. - func echo(_ aList: [Any?]) throws -> [Any?] + func echo(_ list: [Any?]) throws -> [Any?] /// Returns the passed map, to test serialization and deserialization. func echo(_ aMap: [String?: Any?]) throws -> [String?: Any?] /// Returns the passed map to test nested class serialization and deserialization. @@ -580,7 +580,7 @@ protocol HostIntegrationCoreApi { /// Returns the passed in generic Object asynchronously. func echoAsync(_ anObject: Any, completion: @escaping (Result) -> Void) /// Returns the passed list, to test asynchronous serialization and deserialization. - func echoAsync(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) + func echoAsync(_ list: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) /// Returns the passed map, to test asynchronous serialization and deserialization. func echoAsync( _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) @@ -617,7 +617,7 @@ protocol HostIntegrationCoreApi { /// Returns the passed in generic Object asynchronously. func echoAsyncNullable(_ anObject: Any?, completion: @escaping (Result) -> Void) /// Returns the passed list, to test asynchronous serialization and deserialization. - func echoAsyncNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) + func echoAsyncNullable(_ list: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) /// Returns the passed map, to test asynchronous serialization and deserialization. func echoAsyncNullable( _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) @@ -645,9 +645,9 @@ protocol HostIntegrationCoreApi { func callFlutterEcho(_ aDouble: Double, completion: @escaping (Result) -> Void) func callFlutterEcho(_ aString: String, completion: @escaping (Result) -> Void) func callFlutterEcho( - _ aList: FlutterStandardTypedData, + _ list: FlutterStandardTypedData, completion: @escaping (Result) -> Void) - func callFlutterEcho(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) + func callFlutterEcho(_ list: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) func callFlutterEcho( _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) func callFlutterEcho(_ anEnum: AnEnum, completion: @escaping (Result) -> Void) @@ -659,10 +659,10 @@ protocol HostIntegrationCoreApi { func callFlutterEchoNullable( _ aString: String?, completion: @escaping (Result) -> Void) func callFlutterEchoNullable( - _ aList: FlutterStandardTypedData?, + _ list: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) func callFlutterEchoNullable( - _ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) + _ list: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) func callFlutterEchoNullable( _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) func callFlutterNullableEcho( @@ -873,9 +873,9 @@ class HostIntegrationCoreApiSetup { if let api = api { echoListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg = args[0] as! [Any?] + let listArg = args[0] as! [Any?] do { - let result = try api.echo(aListArg) + let result = try api.echo(listArg) reply(wrapResult(result)) } catch { reply(wrapError(error)) @@ -1470,8 +1470,8 @@ class HostIntegrationCoreApiSetup { if let api = api { echoAsyncListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg = args[0] as! [Any?] - api.echoAsync(aListArg) { result in + let listArg = args[0] as! [Any?] + api.echoAsync(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -1777,8 +1777,8 @@ class HostIntegrationCoreApiSetup { if let api = api { echoAsyncNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg: [Any?]? = nilOrValue(args[0]) - api.echoAsyncNullable(aListArg) { result in + let listArg: [Any?]? = nilOrValue(args[0]) + api.echoAsyncNullable(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -2084,8 +2084,8 @@ class HostIntegrationCoreApiSetup { if let api = api { callFlutterEchoUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg = args[0] as! FlutterStandardTypedData - api.callFlutterEcho(aListArg) { result in + let listArg = args[0] as! FlutterStandardTypedData + api.callFlutterEcho(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -2104,8 +2104,8 @@ class HostIntegrationCoreApiSetup { if let api = api { callFlutterEchoListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg = args[0] as! [Any?] - api.callFlutterEcho(aListArg) { result in + let listArg = args[0] as! [Any?] + api.callFlutterEcho(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -2245,8 +2245,8 @@ class HostIntegrationCoreApiSetup { if let api = api { callFlutterEchoNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg: FlutterStandardTypedData? = nilOrValue(args[0]) - api.callFlutterEchoNullable(aListArg) { result in + let listArg: FlutterStandardTypedData? = nilOrValue(args[0]) + api.callFlutterEchoNullable(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -2265,8 +2265,8 @@ class HostIntegrationCoreApiSetup { if let api = api { callFlutterEchoNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg: [Any?]? = nilOrValue(args[0]) - api.callFlutterEchoNullable(aListArg) { result in + let listArg: [Any?]? = nilOrValue(args[0]) + api.callFlutterEchoNullable(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -2424,10 +2424,10 @@ protocol FlutterIntegrationCoreApiProtocol { func echo(_ aStringArg: String, completion: @escaping (Result) -> Void) /// Returns the passed byte list, to test serialization and deserialization. func echo( - _ aListArg: FlutterStandardTypedData, + _ listArg: FlutterStandardTypedData, completion: @escaping (Result) -> Void) /// Returns the passed list, to test serialization and deserialization. - func echo(_ aListArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) + func echo(_ listArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) /// Returns the passed map, to test serialization and deserialization. func echo( _ aMapArg: [String?: Any?], @@ -2447,11 +2447,11 @@ protocol FlutterIntegrationCoreApiProtocol { _ aStringArg: String?, completion: @escaping (Result) -> Void) /// Returns the passed byte list, to test serialization and deserialization. func echoNullable( - _ aListArg: FlutterStandardTypedData?, + _ listArg: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) /// Returns the passed list, to test serialization and deserialization. func echoNullable( - _ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void) + _ listArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void) /// Returns the passed map, to test serialization and deserialization. func echoNullable( _ aMapArg: [String?: Any?]?, @@ -2803,14 +2803,14 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed byte list, to test serialization and deserialization. func echo( - _ aListArg: FlutterStandardTypedData, + _ listArg: FlutterStandardTypedData, completion: @escaping (Result) -> Void ) { let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List" let channel = FlutterBasicMessageChannel( name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([aListArg] as [Any?]) { response in + channel.sendMessage([listArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return @@ -2833,12 +2833,12 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed list, to test serialization and deserialization. - func echo(_ aListArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) { + func echo(_ listArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) { let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList" let channel = FlutterBasicMessageChannel( name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([aListArg] as [Any?]) { response in + channel.sendMessage([listArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return @@ -3020,14 +3020,14 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed byte list, to test serialization and deserialization. func echoNullable( - _ aListArg: FlutterStandardTypedData?, + _ listArg: FlutterStandardTypedData?, completion: @escaping (Result) -> Void ) { let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableUint8List" let channel = FlutterBasicMessageChannel( name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([aListArg] as [Any?]) { response in + channel.sendMessage([listArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return @@ -3045,13 +3045,13 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed list, to test serialization and deserialization. func echoNullable( - _ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void + _ listArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void ) { let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList" let channel = FlutterBasicMessageChannel( name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([aListArg] as [Any?]) { response in + channel.sendMessage([listArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return 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 d444e5c0bac..5670757f7cb 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/TestPlugin.swift @@ -77,8 +77,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return anObject } - func echo(_ aList: [Any?]) throws -> [Any?] { - return aList + func echo(_ list: [Any?]) throws -> [Any?] { + return list } func echo(_ aMap: [String?: Any?]) throws -> [String?: Any?] { @@ -234,8 +234,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(anObject)) } - func echoAsync(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { - completion(.success(aList)) + func echoAsync(_ list: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { + completion(.success(list)) } func echoAsync( @@ -277,8 +277,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(anObject)) } - func echoAsyncNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) { - completion(.success(aList)) + func echoAsyncNullable(_ list: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) { + completion(.success(list)) } func echoAsyncNullable( @@ -449,10 +449,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } func callFlutterEcho( - _ aList: FlutterStandardTypedData, + _ list: FlutterStandardTypedData, completion: @escaping (Result) -> Void ) { - flutterAPI.echo(aList) { response in + flutterAPI.echo(list) { response in switch response { case .success(let res): completion(.success(res)) @@ -462,8 +462,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEcho(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { - flutterAPI.echo(aList) { response in + func callFlutterEcho(_ list: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { + flutterAPI.echo(list) { response in switch response { case .success(let res): completion(.success(res)) @@ -549,10 +549,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } func callFlutterEchoNullable( - _ aList: FlutterStandardTypedData?, + _ list: FlutterStandardTypedData?, completion: @escaping (Result) -> Void ) { - flutterAPI.echoNullable(aList) { response in + flutterAPI.echoNullable(list) { response in switch response { case .success(let res): completion(.success(res)) @@ -563,9 +563,9 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } func callFlutterEchoNullable( - _ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void + _ list: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void ) { - flutterAPI.echoNullable(aList) { response in + flutterAPI.echoNullable(list) { response in switch response { case .success(let res): completion(.success(res)) 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 6d0398cd795..322bfb4262f 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 @@ -69,7 +69,7 @@ struct AllTypes { var a4ByteArray: FlutterStandardTypedData var a8ByteArray: FlutterStandardTypedData var aFloatArray: FlutterStandardTypedData - var aList: [Any?] + var list: [Any?] var aMap: [AnyHashable: Any?] var anEnum: AnEnum var aString: String @@ -87,7 +87,7 @@ struct AllTypes { let a4ByteArray = __pigeon_list[5] as! FlutterStandardTypedData let a8ByteArray = __pigeon_list[6] as! FlutterStandardTypedData let aFloatArray = __pigeon_list[7] as! FlutterStandardTypedData - let aList = __pigeon_list[8] as! [Any?] + let list = __pigeon_list[8] as! [Any?] let aMap = __pigeon_list[9] as! [AnyHashable: Any?] let anEnum = AnEnum(rawValue: __pigeon_list[10] as! Int)! let aString = __pigeon_list[11] as! String @@ -102,7 +102,7 @@ struct AllTypes { a4ByteArray: a4ByteArray, a8ByteArray: a8ByteArray, aFloatArray: aFloatArray, - aList: aList, + list: list, aMap: aMap, anEnum: anEnum, aString: aString, @@ -119,7 +119,7 @@ struct AllTypes { a4ByteArray, a8ByteArray, aFloatArray, - aList, + list, aMap, anEnum.rawValue, aString, @@ -509,7 +509,7 @@ protocol HostIntegrationCoreApi { /// Returns the passed in generic Object. func echo(_ anObject: Any) throws -> Any /// Returns the passed list, to test serialization and deserialization. - func echo(_ aList: [Any?]) throws -> [Any?] + func echo(_ list: [Any?]) throws -> [Any?] /// Returns the passed map, to test serialization and deserialization. func echo(_ aMap: [String?: Any?]) throws -> [String?: Any?] /// Returns the passed map to test nested class serialization and deserialization. @@ -580,7 +580,7 @@ protocol HostIntegrationCoreApi { /// Returns the passed in generic Object asynchronously. func echoAsync(_ anObject: Any, completion: @escaping (Result) -> Void) /// Returns the passed list, to test asynchronous serialization and deserialization. - func echoAsync(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) + func echoAsync(_ list: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) /// Returns the passed map, to test asynchronous serialization and deserialization. func echoAsync( _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) @@ -617,7 +617,7 @@ protocol HostIntegrationCoreApi { /// Returns the passed in generic Object asynchronously. func echoAsyncNullable(_ anObject: Any?, completion: @escaping (Result) -> Void) /// Returns the passed list, to test asynchronous serialization and deserialization. - func echoAsyncNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) + func echoAsyncNullable(_ list: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) /// Returns the passed map, to test asynchronous serialization and deserialization. func echoAsyncNullable( _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) @@ -645,9 +645,9 @@ protocol HostIntegrationCoreApi { func callFlutterEcho(_ aDouble: Double, completion: @escaping (Result) -> Void) func callFlutterEcho(_ aString: String, completion: @escaping (Result) -> Void) func callFlutterEcho( - _ aList: FlutterStandardTypedData, + _ list: FlutterStandardTypedData, completion: @escaping (Result) -> Void) - func callFlutterEcho(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) + func callFlutterEcho(_ list: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) func callFlutterEcho( _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) func callFlutterEcho(_ anEnum: AnEnum, completion: @escaping (Result) -> Void) @@ -659,10 +659,10 @@ protocol HostIntegrationCoreApi { func callFlutterEchoNullable( _ aString: String?, completion: @escaping (Result) -> Void) func callFlutterEchoNullable( - _ aList: FlutterStandardTypedData?, + _ list: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) func callFlutterEchoNullable( - _ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) + _ list: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) func callFlutterEchoNullable( _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) func callFlutterNullableEcho( @@ -873,9 +873,9 @@ class HostIntegrationCoreApiSetup { if let api = api { echoListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg = args[0] as! [Any?] + let listArg = args[0] as! [Any?] do { - let result = try api.echo(aListArg) + let result = try api.echo(listArg) reply(wrapResult(result)) } catch { reply(wrapError(error)) @@ -1470,8 +1470,8 @@ class HostIntegrationCoreApiSetup { if let api = api { echoAsyncListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg = args[0] as! [Any?] - api.echoAsync(aListArg) { result in + let listArg = args[0] as! [Any?] + api.echoAsync(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -1777,8 +1777,8 @@ class HostIntegrationCoreApiSetup { if let api = api { echoAsyncNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg: [Any?]? = nilOrValue(args[0]) - api.echoAsyncNullable(aListArg) { result in + let listArg: [Any?]? = nilOrValue(args[0]) + api.echoAsyncNullable(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -2084,8 +2084,8 @@ class HostIntegrationCoreApiSetup { if let api = api { callFlutterEchoUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg = args[0] as! FlutterStandardTypedData - api.callFlutterEcho(aListArg) { result in + let listArg = args[0] as! FlutterStandardTypedData + api.callFlutterEcho(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -2104,8 +2104,8 @@ class HostIntegrationCoreApiSetup { if let api = api { callFlutterEchoListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg = args[0] as! [Any?] - api.callFlutterEcho(aListArg) { result in + let listArg = args[0] as! [Any?] + api.callFlutterEcho(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -2245,8 +2245,8 @@ class HostIntegrationCoreApiSetup { if let api = api { callFlutterEchoNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg: FlutterStandardTypedData? = nilOrValue(args[0]) - api.callFlutterEchoNullable(aListArg) { result in + let listArg: FlutterStandardTypedData? = nilOrValue(args[0]) + api.callFlutterEchoNullable(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -2265,8 +2265,8 @@ class HostIntegrationCoreApiSetup { if let api = api { callFlutterEchoNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aListArg: [Any?]? = nilOrValue(args[0]) - api.callFlutterEchoNullable(aListArg) { result in + let listArg: [Any?]? = nilOrValue(args[0]) + api.callFlutterEchoNullable(listArg) { result in switch result { case .success(let res): reply(wrapResult(res)) @@ -2424,10 +2424,10 @@ protocol FlutterIntegrationCoreApiProtocol { func echo(_ aStringArg: String, completion: @escaping (Result) -> Void) /// Returns the passed byte list, to test serialization and deserialization. func echo( - _ aListArg: FlutterStandardTypedData, + _ listArg: FlutterStandardTypedData, completion: @escaping (Result) -> Void) /// Returns the passed list, to test serialization and deserialization. - func echo(_ aListArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) + func echo(_ listArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) /// Returns the passed map, to test serialization and deserialization. func echo( _ aMapArg: [String?: Any?], @@ -2447,11 +2447,11 @@ protocol FlutterIntegrationCoreApiProtocol { _ aStringArg: String?, completion: @escaping (Result) -> Void) /// Returns the passed byte list, to test serialization and deserialization. func echoNullable( - _ aListArg: FlutterStandardTypedData?, + _ listArg: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) /// Returns the passed list, to test serialization and deserialization. func echoNullable( - _ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void) + _ listArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void) /// Returns the passed map, to test serialization and deserialization. func echoNullable( _ aMapArg: [String?: Any?]?, @@ -2803,14 +2803,14 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed byte list, to test serialization and deserialization. func echo( - _ aListArg: FlutterStandardTypedData, + _ listArg: FlutterStandardTypedData, completion: @escaping (Result) -> Void ) { let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List" let channel = FlutterBasicMessageChannel( name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([aListArg] as [Any?]) { response in + channel.sendMessage([listArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return @@ -2833,12 +2833,12 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed list, to test serialization and deserialization. - func echo(_ aListArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) { + func echo(_ listArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) { let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList" let channel = FlutterBasicMessageChannel( name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([aListArg] as [Any?]) { response in + channel.sendMessage([listArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return @@ -3020,14 +3020,14 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed byte list, to test serialization and deserialization. func echoNullable( - _ aListArg: FlutterStandardTypedData?, + _ listArg: FlutterStandardTypedData?, completion: @escaping (Result) -> Void ) { let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableUint8List" let channel = FlutterBasicMessageChannel( name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([aListArg] as [Any?]) { response in + channel.sendMessage([listArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return @@ -3045,13 +3045,13 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed list, to test serialization and deserialization. func echoNullable( - _ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void + _ listArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void ) { let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList" let channel = FlutterBasicMessageChannel( name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([aListArg] as [Any?]) { response in + channel.sendMessage([listArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) return 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 01986439465..39c0d214c7e 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/TestPlugin.swift @@ -76,8 +76,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return anObject } - func echo(_ aList: [Any?]) throws -> [Any?] { - return aList + func echo(_ list: [Any?]) throws -> [Any?] { + return list } func echo(_ aMap: [String?: Any?]) throws -> [String?: Any?] { @@ -233,8 +233,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(anObject)) } - func echoAsync(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { - completion(.success(aList)) + func echoAsync(_ list: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { + completion(.success(list)) } func echoAsync( @@ -276,8 +276,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { completion(.success(anObject)) } - func echoAsyncNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) { - completion(.success(aList)) + func echoAsyncNullable(_ list: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) { + completion(.success(list)) } func echoAsyncNullable( @@ -448,10 +448,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } func callFlutterEcho( - _ aList: FlutterStandardTypedData, + _ list: FlutterStandardTypedData, completion: @escaping (Result) -> Void ) { - flutterAPI.echo(aList) { response in + flutterAPI.echo(list) { response in switch response { case .success(let res): completion(.success(res)) @@ -461,8 +461,8 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } } - func callFlutterEcho(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { - flutterAPI.echo(aList) { response in + func callFlutterEcho(_ list: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) { + flutterAPI.echo(list) { response in switch response { case .success(let res): completion(.success(res)) @@ -548,10 +548,10 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } func callFlutterEchoNullable( - _ aList: FlutterStandardTypedData?, + _ list: FlutterStandardTypedData?, completion: @escaping (Result) -> Void ) { - flutterAPI.echoNullable(aList) { response in + flutterAPI.echoNullable(list) { response in switch response { case .success(let res): completion(.success(res)) @@ -562,9 +562,9 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { } func callFlutterEchoNullable( - _ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void + _ list: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void ) { - flutterAPI.echoNullable(aList) { response in + flutterAPI.echoNullable(list) { response in switch response { case .success(let res): completion(.success(res)) 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 fa3d7026fd2..60b19ceb2ba 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 @@ -39,7 +39,7 @@ AllTypes::AllTypes(bool a_bool, int64_t an_int, int64_t an_int64, const std::vector& a4_byte_array, const std::vector& a8_byte_array, const std::vector& a_float_array, - const EncodableList& a_list, const EncodableMap& a_map, + const EncodableList& list, const EncodableMap& a_map, const AnEnum& an_enum, const std::string& a_string, const EncodableValue& an_object) : a_bool_(a_bool), @@ -50,7 +50,7 @@ AllTypes::AllTypes(bool a_bool, int64_t an_int, int64_t an_int64, a4_byte_array_(a4_byte_array), a8_byte_array_(a8_byte_array), a_float_array_(a_float_array), - a_list_(a_list), + list_(list), a_map_(a_map), an_enum_(an_enum), a_string_(a_string), @@ -104,11 +104,9 @@ void AllTypes::set_a_float_array(const std::vector& value_arg) { a_float_array_ = value_arg; } -const EncodableList& AllTypes::a_list() const { return a_list_; } +const EncodableList& AllTypes::list() const { return list_; } -void AllTypes::set_a_list(const EncodableList& value_arg) { - a_list_ = value_arg; -} +void AllTypes::set_list(const EncodableList& value_arg) { list_ = value_arg; } const EncodableMap& AllTypes::a_map() const { return a_map_; } @@ -141,7 +139,7 @@ EncodableList AllTypes::ToEncodableList() const { list.push_back(EncodableValue(a4_byte_array_)); list.push_back(EncodableValue(a8_byte_array_)); list.push_back(EncodableValue(a_float_array_)); - list.push_back(EncodableValue(a_list_)); + list.push_back(EncodableValue(list_)); list.push_back(EncodableValue(a_map_)); list.push_back(EncodableValue((int)an_enum_)); list.push_back(EncodableValue(a_string_)); @@ -149,18 +147,15 @@ EncodableList AllTypes::ToEncodableList() const { return list; } -AllTypes AllTypes::FromEncodableList(const EncodableList& __pigeon_list) { - AllTypes decoded(std::get(__pigeon_list[0]), - __pigeon_list[1].LongValue(), __pigeon_list[2].LongValue(), - std::get(__pigeon_list[3]), - std::get>(__pigeon_list[4]), - std::get>(__pigeon_list[5]), - std::get>(__pigeon_list[6]), - std::get>(__pigeon_list[7]), - std::get(__pigeon_list[8]), - std::get(__pigeon_list[9]), - (AnEnum)(std::get(__pigeon_list[10])), - std::get(__pigeon_list[11]), __pigeon_list[12]); +AllTypes AllTypes::FromEncodableList(const EncodableList& list) { + AllTypes decoded( + std::get(list[0]), list[1].LongValue(), list[2].LongValue(), + std::get(list[3]), std::get>(list[4]), + std::get>(list[5]), + std::get>(list[6]), + std::get>(list[7]), std::get(list[8]), + std::get(list[9]), (AnEnum)(std::get(list[10])), + std::get(list[11]), list[12]); return decoded; } @@ -614,85 +609,85 @@ EncodableList AllNullableTypes::ToEncodableList() const { } AllNullableTypes AllNullableTypes::FromEncodableList( - const EncodableList& __pigeon_list) { + const EncodableList& list) { AllNullableTypes decoded; - auto& encodable_a_nullable_bool = __pigeon_list[0]; + auto& encodable_a_nullable_bool = list[0]; if (!encodable_a_nullable_bool.IsNull()) { decoded.set_a_nullable_bool(std::get(encodable_a_nullable_bool)); } - auto& encodable_a_nullable_int = __pigeon_list[1]; + auto& encodable_a_nullable_int = list[1]; if (!encodable_a_nullable_int.IsNull()) { decoded.set_a_nullable_int(encodable_a_nullable_int.LongValue()); } - auto& encodable_a_nullable_int64 = __pigeon_list[2]; + auto& encodable_a_nullable_int64 = list[2]; if (!encodable_a_nullable_int64.IsNull()) { decoded.set_a_nullable_int64(encodable_a_nullable_int64.LongValue()); } - auto& encodable_a_nullable_double = __pigeon_list[3]; + auto& encodable_a_nullable_double = list[3]; if (!encodable_a_nullable_double.IsNull()) { decoded.set_a_nullable_double( std::get(encodable_a_nullable_double)); } - auto& encodable_a_nullable_byte_array = __pigeon_list[4]; + auto& encodable_a_nullable_byte_array = list[4]; if (!encodable_a_nullable_byte_array.IsNull()) { decoded.set_a_nullable_byte_array( std::get>(encodable_a_nullable_byte_array)); } - auto& encodable_a_nullable4_byte_array = __pigeon_list[5]; + auto& encodable_a_nullable4_byte_array = list[5]; if (!encodable_a_nullable4_byte_array.IsNull()) { decoded.set_a_nullable4_byte_array( std::get>(encodable_a_nullable4_byte_array)); } - auto& encodable_a_nullable8_byte_array = __pigeon_list[6]; + auto& encodable_a_nullable8_byte_array = list[6]; if (!encodable_a_nullable8_byte_array.IsNull()) { decoded.set_a_nullable8_byte_array( std::get>(encodable_a_nullable8_byte_array)); } - auto& encodable_a_nullable_float_array = __pigeon_list[7]; + auto& encodable_a_nullable_float_array = list[7]; if (!encodable_a_nullable_float_array.IsNull()) { decoded.set_a_nullable_float_array( std::get>(encodable_a_nullable_float_array)); } - auto& encodable_a_nullable_list = __pigeon_list[8]; + auto& encodable_a_nullable_list = list[8]; if (!encodable_a_nullable_list.IsNull()) { decoded.set_a_nullable_list( std::get(encodable_a_nullable_list)); } - auto& encodable_a_nullable_map = __pigeon_list[9]; + auto& encodable_a_nullable_map = list[9]; if (!encodable_a_nullable_map.IsNull()) { decoded.set_a_nullable_map( std::get(encodable_a_nullable_map)); } - auto& encodable_nullable_nested_list = __pigeon_list[10]; + auto& encodable_nullable_nested_list = list[10]; if (!encodable_nullable_nested_list.IsNull()) { decoded.set_nullable_nested_list( std::get(encodable_nullable_nested_list)); } - auto& encodable_nullable_map_with_annotations = __pigeon_list[11]; + auto& encodable_nullable_map_with_annotations = list[11]; if (!encodable_nullable_map_with_annotations.IsNull()) { decoded.set_nullable_map_with_annotations( std::get(encodable_nullable_map_with_annotations)); } - auto& encodable_nullable_map_with_object = __pigeon_list[12]; + auto& encodable_nullable_map_with_object = list[12]; if (!encodable_nullable_map_with_object.IsNull()) { decoded.set_nullable_map_with_object( std::get(encodable_nullable_map_with_object)); } - auto& encodable_a_nullable_enum = __pigeon_list[13]; + auto& encodable_a_nullable_enum = list[13]; if (!encodable_a_nullable_enum.IsNull()) { decoded.set_a_nullable_enum( (AnEnum)(std::get(encodable_a_nullable_enum))); } - auto& encodable_a_nullable_string = __pigeon_list[14]; + auto& encodable_a_nullable_string = list[14]; if (!encodable_a_nullable_string.IsNull()) { decoded.set_a_nullable_string( std::get(encodable_a_nullable_string)); } - auto& encodable_a_nullable_object = __pigeon_list[15]; + auto& encodable_a_nullable_object = list[15]; if (!encodable_a_nullable_object.IsNull()) { decoded.set_a_nullable_object(encodable_a_nullable_object); } - auto& encodable_all_nullable_types = __pigeon_list[16]; + auto& encodable_all_nullable_types = list[16]; if (!encodable_all_nullable_types.IsNull()) { decoded.set_all_nullable_types( std::get(encodable_all_nullable_types)); @@ -1060,82 +1055,81 @@ EncodableList AllNullableTypesWithoutRecursion::ToEncodableList() const { } AllNullableTypesWithoutRecursion -AllNullableTypesWithoutRecursion::FromEncodableList( - const EncodableList& __pigeon_list) { +AllNullableTypesWithoutRecursion::FromEncodableList(const EncodableList& list) { AllNullableTypesWithoutRecursion decoded; - auto& encodable_a_nullable_bool = __pigeon_list[0]; + auto& encodable_a_nullable_bool = list[0]; if (!encodable_a_nullable_bool.IsNull()) { decoded.set_a_nullable_bool(std::get(encodable_a_nullable_bool)); } - auto& encodable_a_nullable_int = __pigeon_list[1]; + auto& encodable_a_nullable_int = list[1]; if (!encodable_a_nullable_int.IsNull()) { decoded.set_a_nullable_int(encodable_a_nullable_int.LongValue()); } - auto& encodable_a_nullable_int64 = __pigeon_list[2]; + auto& encodable_a_nullable_int64 = list[2]; if (!encodable_a_nullable_int64.IsNull()) { decoded.set_a_nullable_int64(encodable_a_nullable_int64.LongValue()); } - auto& encodable_a_nullable_double = __pigeon_list[3]; + auto& encodable_a_nullable_double = list[3]; if (!encodable_a_nullable_double.IsNull()) { decoded.set_a_nullable_double( std::get(encodable_a_nullable_double)); } - auto& encodable_a_nullable_byte_array = __pigeon_list[4]; + auto& encodable_a_nullable_byte_array = list[4]; if (!encodable_a_nullable_byte_array.IsNull()) { decoded.set_a_nullable_byte_array( std::get>(encodable_a_nullable_byte_array)); } - auto& encodable_a_nullable4_byte_array = __pigeon_list[5]; + auto& encodable_a_nullable4_byte_array = list[5]; if (!encodable_a_nullable4_byte_array.IsNull()) { decoded.set_a_nullable4_byte_array( std::get>(encodable_a_nullable4_byte_array)); } - auto& encodable_a_nullable8_byte_array = __pigeon_list[6]; + auto& encodable_a_nullable8_byte_array = list[6]; if (!encodable_a_nullable8_byte_array.IsNull()) { decoded.set_a_nullable8_byte_array( std::get>(encodable_a_nullable8_byte_array)); } - auto& encodable_a_nullable_float_array = __pigeon_list[7]; + auto& encodable_a_nullable_float_array = list[7]; if (!encodable_a_nullable_float_array.IsNull()) { decoded.set_a_nullable_float_array( std::get>(encodable_a_nullable_float_array)); } - auto& encodable_a_nullable_list = __pigeon_list[8]; + auto& encodable_a_nullable_list = list[8]; if (!encodable_a_nullable_list.IsNull()) { decoded.set_a_nullable_list( std::get(encodable_a_nullable_list)); } - auto& encodable_a_nullable_map = __pigeon_list[9]; + auto& encodable_a_nullable_map = list[9]; if (!encodable_a_nullable_map.IsNull()) { decoded.set_a_nullable_map( std::get(encodable_a_nullable_map)); } - auto& encodable_nullable_nested_list = __pigeon_list[10]; + auto& encodable_nullable_nested_list = list[10]; if (!encodable_nullable_nested_list.IsNull()) { decoded.set_nullable_nested_list( std::get(encodable_nullable_nested_list)); } - auto& encodable_nullable_map_with_annotations = __pigeon_list[11]; + auto& encodable_nullable_map_with_annotations = list[11]; if (!encodable_nullable_map_with_annotations.IsNull()) { decoded.set_nullable_map_with_annotations( std::get(encodable_nullable_map_with_annotations)); } - auto& encodable_nullable_map_with_object = __pigeon_list[12]; + auto& encodable_nullable_map_with_object = list[12]; if (!encodable_nullable_map_with_object.IsNull()) { decoded.set_nullable_map_with_object( std::get(encodable_nullable_map_with_object)); } - auto& encodable_a_nullable_enum = __pigeon_list[13]; + auto& encodable_a_nullable_enum = list[13]; if (!encodable_a_nullable_enum.IsNull()) { decoded.set_a_nullable_enum( (AnEnum)(std::get(encodable_a_nullable_enum))); } - auto& encodable_a_nullable_string = __pigeon_list[14]; + auto& encodable_a_nullable_string = list[14]; if (!encodable_a_nullable_string.IsNull()) { decoded.set_a_nullable_string( std::get(encodable_a_nullable_string)); } - auto& encodable_a_nullable_object = __pigeon_list[15]; + auto& encodable_a_nullable_object = list[15]; if (!encodable_a_nullable_object.IsNull()) { decoded.set_a_nullable_object(encodable_a_nullable_object); } @@ -1230,7 +1224,7 @@ void AllClassesWrapper::set_all_types(const AllTypes& value_arg) { EncodableList AllClassesWrapper::ToEncodableList() const { EncodableList list; list.reserve(3); - list.push_back(CustomEncodableValue(all_nullable_types_)); + list.push_back(CustomEncodableValue(*all_nullable_types_)); list.push_back( all_nullable_types_without_recursion_ ? CustomEncodableValue(*all_nullable_types_without_recursion_) @@ -1241,15 +1235,15 @@ EncodableList AllClassesWrapper::ToEncodableList() const { } AllClassesWrapper AllClassesWrapper::FromEncodableList( - const EncodableList& __pigeon_list) { - AllClassesWrapper decoded(std::get(__pigeon_list[0])); - auto& encodable_all_nullable_types_without_recursion = __pigeon_list[1]; + const EncodableList& list) { + AllClassesWrapper decoded(std::get(list[0])); + auto& encodable_all_nullable_types_without_recursion = list[1]; if (!encodable_all_nullable_types_without_recursion.IsNull()) { decoded.set_all_nullable_types_without_recursion( std::get( encodable_all_nullable_types_without_recursion)); } - auto& encodable_all_types = __pigeon_list[2]; + auto& encodable_all_types = list[2]; if (!encodable_all_types.IsNull()) { decoded.set_all_types(std::get(encodable_all_types)); } @@ -1284,9 +1278,9 @@ EncodableList TestMessage::ToEncodableList() const { return list; } -TestMessage TestMessage::FromEncodableList(const EncodableList& __pigeon_list) { +TestMessage TestMessage::FromEncodableList(const EncodableList& list) { TestMessage decoded; - auto& encodable_test_list = __pigeon_list[0]; + auto& encodable_test_list = list[0]; if (!encodable_test_list.IsNull()) { decoded.set_test_list(std::get(encodable_test_list)); } @@ -1741,14 +1735,14 @@ void HostIntegrationCoreApi::SetUp(flutter::BinaryMessenger* binary_messenger, const flutter::MessageReply& reply) { try { const auto& args = std::get(message); - const auto& encodable_a_list_arg = args.at(0); - if (encodable_a_list_arg.IsNull()) { - reply(WrapError("a_list_arg unexpectedly null.")); + const auto& encodable_list_arg = args.at(0); + if (encodable_list_arg.IsNull()) { + reply(WrapError("list_arg unexpectedly null.")); return; } - const auto& a_list_arg = - std::get(encodable_a_list_arg); - ErrorOr output = api->EchoList(a_list_arg); + const auto& list_arg = + std::get(encodable_list_arg); + ErrorOr output = api->EchoList(list_arg); if (output.has_error()) { reply(WrapError(output.error())); return; @@ -2907,15 +2901,15 @@ void HostIntegrationCoreApi::SetUp(flutter::BinaryMessenger* binary_messenger, const flutter::MessageReply& reply) { try { const auto& args = std::get(message); - const auto& encodable_a_list_arg = args.at(0); - if (encodable_a_list_arg.IsNull()) { - reply(WrapError("a_list_arg unexpectedly null.")); + const auto& encodable_list_arg = args.at(0); + if (encodable_list_arg.IsNull()) { + reply(WrapError("list_arg unexpectedly null.")); return; } - const auto& a_list_arg = - std::get(encodable_a_list_arg); + const auto& list_arg = + std::get(encodable_list_arg); api->EchoAsyncList( - a_list_arg, [reply](ErrorOr&& output) { + list_arg, [reply](ErrorOr&& output) { if (output.has_error()) { reply(WrapError(output.error())); return; @@ -3481,11 +3475,11 @@ void HostIntegrationCoreApi::SetUp(flutter::BinaryMessenger* binary_messenger, const flutter::MessageReply& reply) { try { const auto& args = std::get(message); - const auto& encodable_a_list_arg = args.at(0); - const auto* a_list_arg = - std::get_if(&encodable_a_list_arg); + const auto& encodable_list_arg = args.at(0); + const auto* list_arg = + std::get_if(&encodable_list_arg); api->EchoAsyncNullableList( - a_list_arg, + list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { reply(WrapError(output.error())); @@ -4067,15 +4061,15 @@ void HostIntegrationCoreApi::SetUp(flutter::BinaryMessenger* binary_messenger, const flutter::MessageReply& reply) { try { const auto& args = std::get(message); - const auto& encodable_a_list_arg = args.at(0); - if (encodable_a_list_arg.IsNull()) { - reply(WrapError("a_list_arg unexpectedly null.")); + const auto& encodable_list_arg = args.at(0); + if (encodable_list_arg.IsNull()) { + reply(WrapError("list_arg unexpectedly null.")); return; } - const auto& a_list_arg = - std::get>(encodable_a_list_arg); + const auto& list_arg = + std::get>(encodable_list_arg); api->CallFlutterEchoUint8List( - a_list_arg, [reply](ErrorOr>&& output) { + list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { reply(WrapError(output.error())); return; @@ -4104,15 +4098,15 @@ void HostIntegrationCoreApi::SetUp(flutter::BinaryMessenger* binary_messenger, const flutter::MessageReply& reply) { try { const auto& args = std::get(message); - const auto& encodable_a_list_arg = args.at(0); - if (encodable_a_list_arg.IsNull()) { - reply(WrapError("a_list_arg unexpectedly null.")); + const auto& encodable_list_arg = args.at(0); + if (encodable_list_arg.IsNull()) { + reply(WrapError("list_arg unexpectedly null.")); return; } - const auto& a_list_arg = - std::get(encodable_a_list_arg); + const auto& list_arg = + std::get(encodable_list_arg); api->CallFlutterEchoList( - a_list_arg, [reply](ErrorOr&& output) { + list_arg, [reply](ErrorOr&& output) { if (output.has_error()) { reply(WrapError(output.error())); return; @@ -4378,11 +4372,11 @@ void HostIntegrationCoreApi::SetUp(flutter::BinaryMessenger* binary_messenger, const flutter::MessageReply& reply) { try { const auto& args = std::get(message); - const auto& encodable_a_list_arg = args.at(0); - const auto* a_list_arg = - std::get_if>(&encodable_a_list_arg); + const auto& encodable_list_arg = args.at(0); + const auto* list_arg = + std::get_if>(&encodable_list_arg); api->CallFlutterEchoNullableUint8List( - a_list_arg, + list_arg, [reply]( ErrorOr>>&& output) { if (output.has_error()) { @@ -4419,11 +4413,11 @@ void HostIntegrationCoreApi::SetUp(flutter::BinaryMessenger* binary_messenger, const flutter::MessageReply& reply) { try { const auto& args = std::get(message); - const auto& encodable_a_list_arg = args.at(0); - const auto* a_list_arg = - std::get_if(&encodable_a_list_arg); + const auto& encodable_list_arg = args.at(0); + const auto* list_arg = + std::get_if(&encodable_list_arg); api->CallFlutterEchoNullableList( - a_list_arg, + list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { reply(WrapError(output.error())); @@ -5072,7 +5066,7 @@ void FlutterIntegrationCoreApi::EchoString( } void FlutterIntegrationCoreApi::EchoUint8List( - const std::vector& a_list_arg, + const std::vector& list_arg, std::function&)>&& on_success, std::function&& on_error) { const std::string channel_name = @@ -5080,7 +5074,7 @@ void FlutterIntegrationCoreApi::EchoUint8List( "echoUint8List"; BasicMessageChannel<> channel(binary_messenger_, channel_name, &GetCodec()); EncodableValue encoded_api_arguments = EncodableValue(EncodableList{ - EncodableValue(a_list_arg), + EncodableValue(list_arg), }); channel.Send( encoded_api_arguments, [channel_name, on_success = std::move(on_success), @@ -5109,7 +5103,7 @@ void FlutterIntegrationCoreApi::EchoUint8List( } void FlutterIntegrationCoreApi::EchoList( - const EncodableList& a_list_arg, + const EncodableList& list_arg, std::function&& on_success, std::function&& on_error) { const std::string channel_name = @@ -5117,7 +5111,7 @@ void FlutterIntegrationCoreApi::EchoList( "echoList"; BasicMessageChannel<> channel(binary_messenger_, channel_name, &GetCodec()); EncodableValue encoded_api_arguments = EncodableValue(EncodableList{ - EncodableValue(a_list_arg), + EncodableValue(list_arg), }); channel.Send( encoded_api_arguments, [channel_name, on_success = std::move(on_success), @@ -5367,7 +5361,7 @@ void FlutterIntegrationCoreApi::EchoNullableString( } void FlutterIntegrationCoreApi::EchoNullableUint8List( - const std::vector* a_list_arg, + const std::vector* list_arg, std::function*)>&& on_success, std::function&& on_error) { const std::string channel_name = @@ -5375,7 +5369,7 @@ void FlutterIntegrationCoreApi::EchoNullableUint8List( "echoNullableUint8List"; BasicMessageChannel<> channel(binary_messenger_, channel_name, &GetCodec()); EncodableValue encoded_api_arguments = EncodableValue(EncodableList{ - a_list_arg ? EncodableValue(*a_list_arg) : EncodableValue(), + list_arg ? EncodableValue(*list_arg) : EncodableValue(), }); channel.Send( encoded_api_arguments, [channel_name, on_success = std::move(on_success), @@ -5404,7 +5398,7 @@ void FlutterIntegrationCoreApi::EchoNullableUint8List( } void FlutterIntegrationCoreApi::EchoNullableList( - const EncodableList* a_list_arg, + const EncodableList* list_arg, std::function&& on_success, std::function&& on_error) { const std::string channel_name = @@ -5412,7 +5406,7 @@ void FlutterIntegrationCoreApi::EchoNullableList( "echoNullableList"; BasicMessageChannel<> channel(binary_messenger_, channel_name, &GetCodec()); EncodableValue encoded_api_arguments = EncodableValue(EncodableList{ - a_list_arg ? EncodableValue(*a_list_arg) : EncodableValue(), + list_arg ? EncodableValue(*list_arg) : EncodableValue(), }); channel.Send( encoded_api_arguments, [channel_name, on_success = std::move(on_success), 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 4b15d9dbbe7..cb5e24bbe1e 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 @@ -84,7 +84,7 @@ class AllTypes { const std::vector& a4_byte_array, const std::vector& a8_byte_array, const std::vector& a_float_array, - const flutter::EncodableList& a_list, + const flutter::EncodableList& list, const flutter::EncodableMap& a_map, const AnEnum& an_enum, const std::string& a_string, const flutter::EncodableValue& an_object); @@ -113,8 +113,8 @@ class AllTypes { const std::vector& a_float_array() const; void set_a_float_array(const std::vector& value_arg); - const flutter::EncodableList& a_list() const; - void set_a_list(const flutter::EncodableList& value_arg); + const flutter::EncodableList& list() const; + void set_list(const flutter::EncodableList& value_arg); const flutter::EncodableMap& a_map() const; void set_a_map(const flutter::EncodableMap& value_arg); @@ -151,7 +151,7 @@ class AllTypes { std::vector a4_byte_array_; std::vector a8_byte_array_; std::vector a_float_array_; - flutter::EncodableList a_list_; + flutter::EncodableList list_; flutter::EncodableMap a_map_; AnEnum an_enum_; std::string a_string_; @@ -563,7 +563,7 @@ class HostIntegrationCoreApi { const flutter::EncodableValue& an_object) = 0; // Returns the passed list, to test serialization and deserialization. virtual ErrorOr EchoList( - const flutter::EncodableList& a_list) = 0; + const flutter::EncodableList& list) = 0; // Returns the passed map, to test serialization and deserialization. virtual ErrorOr EchoMap( const flutter::EncodableMap& a_map) = 0; @@ -664,7 +664,7 @@ class HostIntegrationCoreApi { // Returns the passed list, to test asynchronous serialization and // deserialization. virtual void EchoAsyncList( - const flutter::EncodableList& a_list, + const flutter::EncodableList& list, std::function reply)> result) = 0; // Returns the passed map, to test asynchronous serialization and // deserialization. @@ -732,7 +732,7 @@ class HostIntegrationCoreApi { // Returns the passed list, to test asynchronous serialization and // deserialization. virtual void EchoAsyncNullableList( - const flutter::EncodableList* a_list, + const flutter::EncodableList* list, std::function> reply)> result) = 0; // Returns the passed map, to test asynchronous serialization and @@ -784,10 +784,10 @@ class HostIntegrationCoreApi { const std::string& a_string, std::function reply)> result) = 0; virtual void CallFlutterEchoUint8List( - const std::vector& a_list, + const std::vector& list, std::function> reply)> result) = 0; virtual void CallFlutterEchoList( - const flutter::EncodableList& a_list, + const flutter::EncodableList& list, std::function reply)> result) = 0; virtual void CallFlutterEchoMap( const flutter::EncodableMap& a_map, @@ -809,11 +809,11 @@ class HostIntegrationCoreApi { std::function> reply)> result) = 0; virtual void CallFlutterEchoNullableUint8List( - const std::vector* a_list, + const std::vector* list, std::function>> reply)> result) = 0; virtual void CallFlutterEchoNullableList( - const flutter::EncodableList* a_list, + const flutter::EncodableList* list, std::function> reply)> result) = 0; virtual void CallFlutterEchoNullableMap( @@ -918,11 +918,11 @@ class FlutterIntegrationCoreApi { std::function&& on_error); // Returns the passed byte list, to test serialization and deserialization. void EchoUint8List( - const std::vector& a_list, + const std::vector& list, std::function&)>&& on_success, std::function&& on_error); // Returns the passed list, to test serialization and deserialization. - void EchoList(const flutter::EncodableList& a_list, + void EchoList(const flutter::EncodableList& list, std::function&& on_success, std::function&& on_error); // Returns the passed map, to test serialization and deserialization. @@ -951,12 +951,12 @@ class FlutterIntegrationCoreApi { std::function&& on_error); // Returns the passed byte list, to test serialization and deserialization. void EchoNullableUint8List( - const std::vector* a_list, + const std::vector* list, std::function*)>&& on_success, std::function&& on_error); // Returns the passed list, to test serialization and deserialization. void EchoNullableList( - const flutter::EncodableList* a_list, + const flutter::EncodableList* list, std::function&& on_success, std::function&& on_error); // Returns the passed map, to test serialization and deserialization. diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index b4912fd3262..0c4ab4a959e 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -2,7 +2,7 @@ name: pigeon description: Code generator tool to make communication between Flutter and the host platform type-safe and easier. repository: https://github.com/flutter/packages/tree/main/packages/pigeon issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+pigeon%22 -version: 17.3.0 # This must match the version in lib/generator_tools.dart +version: 17.3.1 # This must match the version in lib/generator_tools.dart environment: sdk: ^3.1.0 From 6b224fe5f27e84569aa6e6f5cda1024874e52ae4 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Fri, 29 Mar 2024 12:34:43 -0700 Subject: [PATCH 06/18] AList --- .../alternate_language_test_plugin/AllDatatypesTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/test/java/com/example/alternate_language_test_plugin/AllDatatypesTest.java b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/test/java/com/example/alternate_language_test_plugin/AllDatatypesTest.java index 6f2fdf16e90..b15c2bfa682 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/test/java/com/example/alternate_language_test_plugin/AllDatatypesTest.java +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/src/test/java/com/example/alternate_language_test_plugin/AllDatatypesTest.java @@ -33,7 +33,7 @@ void compareAllTypes(AllTypes firstTypes, AllTypes secondTypes) { assertArrayEquals(firstTypes.getA4ByteArray(), secondTypes.getA4ByteArray()); assertArrayEquals(firstTypes.getA8ByteArray(), secondTypes.getA8ByteArray()); assertTrue(floatArraysEqual(firstTypes.getAFloatArray(), secondTypes.getAFloatArray())); - assertArrayEquals(firstTypes.getAList().toArray(), secondTypes.getAList().toArray()); + assertArrayEquals(firstTypes.getList().toArray(), secondTypes.getList().toArray()); assertArrayEquals( firstTypes.getAMap().keySet().toArray(), secondTypes.getAMap().keySet().toArray()); assertArrayEquals( @@ -154,7 +154,7 @@ public void hasValues() { .setA4ByteArray(new int[] {1, 2, 3, 4}) .setA8ByteArray(new long[] {1, 2, 3, 4}) .setAFloatArray(new double[] {0.5, 0.25, 1.5, 1.25}) - .setAList(Arrays.asList(new int[] {1, 2, 3})) + .setList(Arrays.asList(new int[] {1, 2, 3})) .setAMap(makeMap("hello", 1234)) .setAnEnum(CoreTests.AnEnum.ONE) .setAnObject(0) From da44ff7facf6226df1d0751293c0b524ca2d36d3 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Thu, 4 Apr 2024 15:30:07 -0400 Subject: [PATCH 07/18] Fix custom class reference extraction in deserialization --- packages/pigeon/lib/cpp_generator.dart | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/pigeon/lib/cpp_generator.dart b/packages/pigeon/lib/cpp_generator.dart index 1ff6e627904..27e02c9b553 100644 --- a/packages/pigeon/lib/cpp_generator.dart +++ b/packages/pigeon/lib/cpp_generator.dart @@ -805,7 +805,11 @@ class CppSourceGenerator extends StructuredGenerator { } else { final HostDatatype hostDatatype = getFieldHostDatatype(field, _shortBaseCppTypeForBuiltinDartType); - return 'std::get<${hostDatatype.datatype}>($encodable)'; + if (field.type.isClass) { + return _classReferenceFromEncodableValue(hostDatatype, encodable); + } else { + return 'std::get<${hostDatatype.datatype}>($encodable)'; + } } } @@ -1476,7 +1480,7 @@ ${prefix}reply(EncodableValue(std::move(wrapped)));'''; } } else { indent.writeln( - 'const auto* $argName = &(std::any_cast(std::get($encodableArgName)));'); + 'const auto* $argName = &(${_classReferenceFromEncodableValue(hostType, encodableArgName)});'); } } else { // Non-nullable arguments are either passed by value or reference, but the @@ -1501,7 +1505,7 @@ ${prefix}reply(EncodableValue(std::move(wrapped)));'''; 'const ${hostType.datatype}& $argName = (${hostType.datatype})$encodableArgName.LongValue();'); } else { indent.writeln( - 'const auto& $argName = std::any_cast(std::get($encodableArgName));'); + 'const auto& $argName = ${_classReferenceFromEncodableValue(hostType, encodableArgName)};'); } } } @@ -1512,6 +1516,13 @@ ${prefix}reply(EncodableValue(std::move(wrapped)));'''; String? _shortBaseCppTypeForBuiltinDartType(TypeDeclaration type) { return _baseCppTypeForBuiltinDartType(type, includeFlutterNamespace: false); } + + /// Returns the code to extract a `const {type.datatype}&` from an EncodableValue + /// variable [variableName] that contains an instance of [type]. + String _classReferenceFromEncodableValue( + HostDatatype type, String variableName) { + return 'std::any_cast(std::get($variableName))'; + } } /// Contains information about a host function argument. From 78b954866e336fbafd21a5137a7f5b174a5d9209 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Thu, 4 Apr 2024 15:30:25 -0400 Subject: [PATCH 08/18] Fix Dart unit test --- packages/pigeon/test/cpp_generator_test.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/pigeon/test/cpp_generator_test.dart b/packages/pigeon/test/cpp_generator_test.dart index 581b8b302f9..8695ae45e96 100644 --- a/packages/pigeon/test/cpp_generator_test.dart +++ b/packages/pigeon/test/cpp_generator_test.dart @@ -1638,14 +1638,14 @@ void main() { dartPackageName: DEFAULT_PACKAGE_NAME, ); final String code = sink.toString(); - // Standard types are wrapped an EncodableValues. + // Standard types are wrapped in EncodableValues. expect(code, contains('EncodableValue(a_bool_arg)')); expect(code, contains('EncodableValue(an_int_arg)')); expect(code, contains('EncodableValue(a_string_arg)')); expect(code, contains('EncodableValue(a_list_arg)')); expect(code, contains('EncodableValue(a_map_arg)')); - // Class types use ToEncodableList. - expect(code, contains('CustomEncodableValue(*an_object_arg)')); + // Class types are wrapped in CustomEncodableValues. + expect(code, contains('CustomEncodableValue(an_object_arg)')); } }); From 022d46344ce28a0a49b12cd600c9210d0f411aa6 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Thu, 4 Apr 2024 15:49:22 -0400 Subject: [PATCH 09/18] Update encoding-sensitive native unit tests --- .../windows/test/null_fields_test.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/pigeon/platform_tests/test_plugin/windows/test/null_fields_test.cpp b/packages/pigeon/platform_tests/test_plugin/windows/test/null_fields_test.cpp index fa21a9619ac..d0c04561882 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/test/null_fields_test.cpp +++ b/packages/pigeon/platform_tests/test_plugin/windows/test/null_fields_test.cpp @@ -11,6 +11,7 @@ namespace null_fields_pigeontest { namespace { +using flutter::CustomEncodableValue; using flutter::EncodableList; using flutter::EncodableMap; using flutter::EncodableValue; @@ -113,6 +114,8 @@ TEST_F(NullFieldsTest, RequestFromListWithNulls) { } TEST_F(NullFieldsTest, ReplyFromListWithValues) { + NullFieldsSearchRequest request(1); + request.set_query("hello"); EncodableList list{ EncodableValue("result"), EncodableValue("error"), @@ -121,10 +124,7 @@ TEST_F(NullFieldsTest, ReplyFromListWithValues) { EncodableValue(2), EncodableValue(3), }), - EncodableValue(EncodableList{ - EncodableValue("hello"), - EncodableValue(1), - }), + CustomEncodableValue(request), EncodableValue(0), }; NullFieldsSearchReply reply = ReplyFromList(list); @@ -194,10 +194,11 @@ TEST_F(NullFieldsTest, ReplyToMapWithValues) { EXPECT_EQ(indices[0].LongValue(), 1L); EXPECT_EQ(indices[1].LongValue(), 2L); EXPECT_EQ(indices[2].LongValue(), 3L); - const EncodableList& request_list = - *ExpectAndGetIndex(list, 3); - EXPECT_EQ(*ExpectAndGetIndex(request_list, 0), "hello"); - EXPECT_EQ(*ExpectAndGetIndex(request_list, 1), 1); + const NullFieldsSearchRequest& request_from_list = + std::any_cast( + *ExpectAndGetIndex(list, 3)); + EXPECT_EQ(*request_from_list.query(), "hello"); + EXPECT_EQ(request_from_list.identifier(), 1); } TEST_F(NullFieldsTest, ReplyToListWithNulls) { From 06653f2341d7a4b7e06f08e7176ba5b29b19134a Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Thu, 4 Apr 2024 15:49:59 -0400 Subject: [PATCH 10/18] Update generated file --- .../test_plugin/windows/pigeon/core_tests.gen.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 60b19ceb2ba..4fd09dabafb 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 @@ -689,8 +689,8 @@ AllNullableTypes AllNullableTypes::FromEncodableList( } auto& encodable_all_nullable_types = list[16]; if (!encodable_all_nullable_types.IsNull()) { - decoded.set_all_nullable_types( - std::get(encodable_all_nullable_types)); + decoded.set_all_nullable_types(std::any_cast( + std::get(encodable_all_nullable_types))); } return decoded; } @@ -1236,16 +1236,19 @@ EncodableList AllClassesWrapper::ToEncodableList() const { AllClassesWrapper AllClassesWrapper::FromEncodableList( const EncodableList& list) { - AllClassesWrapper decoded(std::get(list[0])); + AllClassesWrapper decoded(std::any_cast( + std::get(list[0]))); auto& encodable_all_nullable_types_without_recursion = list[1]; if (!encodable_all_nullable_types_without_recursion.IsNull()) { decoded.set_all_nullable_types_without_recursion( - std::get( - encodable_all_nullable_types_without_recursion)); + std::any_cast( + std::get( + encodable_all_nullable_types_without_recursion))); } auto& encodable_all_types = list[2]; if (!encodable_all_types.IsNull()) { - decoded.set_all_types(std::get(encodable_all_types)); + decoded.set_all_types(std::any_cast( + std::get(encodable_all_types))); } return decoded; } From b4468eb4e01fc5356268847ce1a144463277b937 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 22 Apr 2024 16:53:16 -0700 Subject: [PATCH 11/18] nits and such --- packages/pigeon/CHANGELOG.md | 4 +- .../flutter/pigeon_example_app/Messages.g.kt | 7 +- .../example/app/macos/Runner/messages.g.m | 8 +- packages/pigeon/lib/kotlin_generator.dart | 21 ++-- packages/pigeon/lib/objc_generator.dart | 7 +- packages/pigeon/lib/swift_generator.dart | 57 +++------- packages/pigeon/pigeons/core_tests.dart | 2 + .../ios/Classes/CoreTests.gen.m | 100 +++++++++--------- .../macos/Classes/CoreTests.gen.m | 100 +++++++++--------- .../com/example/test_plugin/CoreTests.gen.kt | 63 ++++++----- .../ios/Classes/CoreTests.gen.swift | 17 +-- .../macos/Classes/CoreTests.gen.swift | 17 +-- 12 files changed, 184 insertions(+), 219 deletions(-) diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index 7fbaa7d828a..8483cbe6613 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,8 +1,8 @@ ## 17.3.1 -* Fixes double encode/decode of classes. +* Fixes unnecessary calls of `toList` and `fromList` when encoding/decoding data classes. * [kotlin] Changes to some code to make it more idiomatic. -* Removes collision with the word `list`. +* Removes collisions with the word `list`. ## 17.3.0 diff --git a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt index bb23dbf4d54..5fc9669a44e 100644 --- a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt +++ b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt @@ -3,7 +3,7 @@ // found in the LICENSE file. // Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon -@file:Suppress("UNCHECKED_CAST", "LocalVariableName", "ArrayInDataClass") +@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") import android.util.Log import io.flutter.plugin.common.BasicMessageChannel @@ -65,6 +65,7 @@ data class MessageData( val data: Map ) { companion object { + @Suppress("LocalVariableName") fun fromList(__pigeon_list: List): MessageData { val name = __pigeon_list[0] as String? val description = __pigeon_list[1] as String? @@ -147,8 +148,8 @@ interface ExampleHostApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val aArg = args[0].let { if (it is Int) it.toLong() else it as Long } - val bArg = args[1].let { if (it is Int) it.toLong() else it as Long } + val aArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long } + val bArg = args[1].let { num -> if (num is Int) num.toLong() else num as Long } val wrapped: List = try { listOf(api.add(aArg, bArg)) diff --git a/packages/pigeon/example/app/macos/Runner/messages.g.m b/packages/pigeon/example/app/macos/Runner/messages.g.m index 90983b10cd2..f6cb2a31753 100644 --- a/packages/pigeon/example/app/macos/Runner/messages.g.m +++ b/packages/pigeon/example/app/macos/Runner/messages.g.m @@ -69,10 +69,10 @@ + (instancetype)makeWithName:(nullable NSString *)name } + (PGNMessageData *)fromList:(NSArray *)list { PGNMessageData *pigeonResult = [[PGNMessageData alloc] init]; - pigeonResult.name = GetNullableObjectAtIndex(list, 0); - pigeonResult.description = GetNullableObjectAtIndex(list, 1); - pigeonResult.code = [GetNullableObjectAtIndex(list, 2) integerValue]; - pigeonResult.data = GetNullableObjectAtIndex(list, 3); + pigeonResult.name = GetNullableObjectAtIndex('list', 0); + pigeonResult.description = GetNullableObjectAtIndex('list', 1); + pigeonResult.code = [GetNullableObjectAtIndex('list', 2) integerValue]; + pigeonResult.data = GetNullableObjectAtIndex('list', 3); return pigeonResult; } + (nullable PGNMessageData *)nullableFromList:(NSArray *)list { diff --git a/packages/pigeon/lib/kotlin_generator.dart b/packages/pigeon/lib/kotlin_generator.dart index 6da2ad6ce72..e08e52c19e8 100644 --- a/packages/pigeon/lib/kotlin_generator.dart +++ b/packages/pigeon/lib/kotlin_generator.dart @@ -97,8 +97,7 @@ class KotlinGenerator extends StructuredGenerator { } indent.writeln('// ${getGeneratedCodeWarning()}'); indent.writeln('// $seeAlsoWarning'); - indent.writeln( - '@file:Suppress("UNCHECKED_CAST", "LocalVariableName", "ArrayInDataClass")'); + indent.writeln('@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")'); } @override @@ -176,7 +175,6 @@ class KotlinGenerator extends StructuredGenerator { addDocumentationComments( indent, classDefinition.documentationComments, _docCommentSpec, generatorComments: generatedMessages); - indent.write('data class ${classDefinition.name} '); indent.addScoped('(', '', () { for (final NamedType element @@ -249,6 +247,7 @@ class KotlinGenerator extends StructuredGenerator { indent.write('companion object '); indent.addScoped('{', '}', () { + indent.writeln('@Suppress("LocalVariableName")'); indent .write('fun fromList(${varNamePrefix}list: List): $className '); @@ -262,8 +261,8 @@ class KotlinGenerator extends StructuredGenerator { if (field.type.isEnum) { indent.write('val ${field.name}: $fieldType? = '); indent.add('($listValue as Int?)?.let '); - indent.addScoped('{', '}', () { - indent.writeln('$fieldType.ofRaw(it)'); + indent.addScoped('{ num ->', '}', () { + indent.writeln('$fieldType.ofRaw(num)'); }); } else { indent.writeln( @@ -826,9 +825,9 @@ class KotlinGenerator extends StructuredGenerator { const String output = 'output'; // Nullable enums require special handling. if (returnType.isEnum && returnType.isNullable) { - indent.writeScoped('val $output = (it[0] as Int?)?.let {', '}', - () { - indent.writeln('${returnType.baseName}.ofRaw(it)'); + indent.writeScoped( + 'val $output = (it[0] as Int?)?.let { num ->', '}', () { + indent.writeln('${returnType.baseName}.ofRaw(num)'); }); } else { indent.writeln( @@ -958,8 +957,8 @@ String _cast(Indent indent, String variable, {required TypeDeclaration type}) { } if (type.isEnum) { if (type.isNullable) { - return '($variable as Int?)?.let {\n' - '${indent.str} $typeString.ofRaw(it)\n' + return '($variable as Int?)?.let { num ->\n' + '${indent.str} $typeString.ofRaw(num)\n' '${indent.str}}'; } return '${type.baseName}.ofRaw($variable as Int)!!'; @@ -969,5 +968,5 @@ String _cast(Indent indent, String variable, {required TypeDeclaration type}) { String _castInt(bool isNullable) { final String nullability = isNullable ? '?' : ''; - return '.let { if (it is Int) it.toLong() else it as Long$nullability }'; + return '.let { num -> if (num is Int) num.toLong() else num as Long$nullability }'; } diff --git a/packages/pigeon/lib/objc_generator.dart b/packages/pigeon/lib/objc_generator.dart index a51537d800f..82889bc4b9e 100644 --- a/packages/pigeon/lib/objc_generator.dart +++ b/packages/pigeon/lib/objc_generator.dart @@ -575,8 +575,7 @@ class ObjcSourceGenerator extends StructuredGenerator { enumerate(getFieldsInSerializationOrder(classDefinition), (int index, final NamedType field) { final bool isEnumType = field.type.isEnum; - final String valueGetter = - _listGetter('list', field, index, generatorOptions.prefix); + final String valueGetter = "GetNullableObjectAtIndex('list', $index)"; final String? primitiveExtractionMethod = _nsnumberExtractionMethod(field.type); final String ivarValueExpression; @@ -1487,10 +1486,6 @@ String _makeObjcSignature({ /// provided [options]. void generateObjcHeader(ObjcOptions options, Root root, Indent indent) {} -String _listGetter(String list, NamedType field, int index, String? prefix) { - return 'GetNullableObjectAtIndex($list, $index)'; -} - String _arrayValue(NamedType field) { if (field.type.isEnum) { if (field.type.isNullable) { diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index a203bc4063c..475e1b811d9 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -213,9 +213,7 @@ class SwiftGenerator extends StructuredGenerator { String toWriteValue = ''; final String fieldName = field.name; final String nullsafe = field.type.isNullable ? '?' : ''; - if (field.type.isClass) { - toWriteValue = fieldName; - } else if (field.type.isEnum) { + if (field.type.isEnum) { toWriteValue = '$fieldName$nullsafe.rawValue'; } else { toWriteValue = field.name; @@ -574,46 +572,23 @@ class SwiftGenerator extends StructuredGenerator { required TypeDeclaration type, }) { final String fieldType = _swiftTypeForDartType(type); - - if (type.isNullable) { - if (type.isClass) { - indent.writeln('var $variableName: $fieldType? = nil'); - indent.write( - 'if let ${variableName}List: $fieldType = nilOrValue($value) '); - indent.addScoped('{', '}', () { - indent.writeln('$variableName = ${variableName}List as $fieldType'); - }); - } else if (type.isEnum) { - indent.writeln('var $variableName: $fieldType? = nil'); + if (type.isNullable && type.isEnum) { + indent.writeln('var $variableName: $fieldType? = nil'); + indent.writeln( + 'let ${variableName}EnumVal: Int? = ${_castForceUnwrap(value, const TypeDeclaration(baseName: 'Int', isNullable: true))}'); + indent.write('if let ${variableName}RawValue = ${variableName}EnumVal '); + indent.addScoped('{', '}', () { indent.writeln( - 'let ${variableName}EnumVal: Int? = ${_castForceUnwrap(value, const TypeDeclaration(baseName: 'Int', isNullable: true))}'); - indent - .write('if let ${variableName}RawValue = ${variableName}EnumVal '); - indent.addScoped('{', '}', () { - indent.writeln( - '$variableName = $fieldType(rawValue: ${variableName}RawValue)!'); - }); - } else { - _writeGenericCasting( - indent: indent, - value: value, - variableName: variableName, - fieldType: fieldType, - type: type, - ); - } + '$variableName = $fieldType(rawValue: ${variableName}RawValue)!'); + }); } else { - if (type.isClass) { - indent.writeln('let $variableName = $value as! $fieldType'); - } else { - _writeGenericCasting( - indent: indent, - value: value, - variableName: variableName, - fieldType: fieldType, - type: type, - ); - } + _writeGenericCasting( + indent: indent, + value: value, + variableName: variableName, + fieldType: fieldType, + type: type, + ); } } diff --git a/packages/pigeon/pigeons/core_tests.dart b/packages/pigeon/pigeons/core_tests.dart index f37191adb9b..5061a152194 100644 --- a/packages/pigeon/pigeons/core_tests.dart +++ b/packages/pigeon/pigeons/core_tests.dart @@ -38,6 +38,8 @@ class AllTypes { Int32List a4ByteArray; Int64List a8ByteArray; Float64List aFloatArray; + // This name is in a different format than the others to ensure that name + // collision with the work 'list' doesn't occur in the generated files. // ignore: always_specify_types, strict_raw_type List list; // ignore: always_specify_types, strict_raw_type 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 ace6b710668..e69283ab594 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 @@ -112,19 +112,19 @@ + (instancetype)makeWithABool:(BOOL)aBool } + (FLTAllTypes *)fromList:(NSArray *)list { FLTAllTypes *pigeonResult = [[FLTAllTypes alloc] init]; - pigeonResult.aBool = [GetNullableObjectAtIndex(list, 0) boolValue]; - pigeonResult.anInt = [GetNullableObjectAtIndex(list, 1) integerValue]; - pigeonResult.anInt64 = [GetNullableObjectAtIndex(list, 2) integerValue]; - pigeonResult.aDouble = [GetNullableObjectAtIndex(list, 3) doubleValue]; - pigeonResult.aByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.a4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.a8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.list = GetNullableObjectAtIndex(list, 8); - pigeonResult.aMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.anEnum = [GetNullableObjectAtIndex(list, 10) integerValue]; - pigeonResult.aString = GetNullableObjectAtIndex(list, 11); - pigeonResult.anObject = GetNullableObjectAtIndex(list, 12); + pigeonResult.aBool = [GetNullableObjectAtIndex('list', 0) boolValue]; + pigeonResult.anInt = [GetNullableObjectAtIndex('list', 1) integerValue]; + pigeonResult.anInt64 = [GetNullableObjectAtIndex('list', 2) integerValue]; + pigeonResult.aDouble = [GetNullableObjectAtIndex('list', 3) doubleValue]; + pigeonResult.aByteArray = GetNullableObjectAtIndex('list', 4); + pigeonResult.a4ByteArray = GetNullableObjectAtIndex('list', 5); + pigeonResult.a8ByteArray = GetNullableObjectAtIndex('list', 6); + pigeonResult.aFloatArray = GetNullableObjectAtIndex('list', 7); + pigeonResult.list = GetNullableObjectAtIndex('list', 8); + pigeonResult.aMap = GetNullableObjectAtIndex('list', 9); + pigeonResult.anEnum = [GetNullableObjectAtIndex('list', 10) integerValue]; + pigeonResult.aString = GetNullableObjectAtIndex('list', 11); + pigeonResult.anObject = GetNullableObjectAtIndex('list', 12); return pigeonResult; } + (nullable FLTAllTypes *)nullableFromList:(NSArray *)list { @@ -190,28 +190,28 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool } + (FLTAllNullableTypes *)fromList:(NSArray *)list { FLTAllNullableTypes *pigeonResult = [[FLTAllNullableTypes alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex('list', 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex('list', 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex('list', 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex('list', 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex('list', 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex('list', 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex('list', 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex('list', 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex('list', 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex('list', 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex('list', 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex('list', 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex('list', 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex('list', 13); FLTAnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[FLTAnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); - pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 16); + pigeonResult.aNullableString = GetNullableObjectAtIndex('list', 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex('list', 15); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex('list', 16); return pigeonResult; } + (nullable FLTAllNullableTypes *)nullableFromList:(NSArray *)list { @@ -282,27 +282,27 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool + (FLTAllNullableTypesWithoutRecursion *)fromList:(NSArray *)list { FLTAllNullableTypesWithoutRecursion *pigeonResult = [[FLTAllNullableTypesWithoutRecursion alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex('list', 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex('list', 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex('list', 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex('list', 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex('list', 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex('list', 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex('list', 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex('list', 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex('list', 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex('list', 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex('list', 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex('list', 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex('list', 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex('list', 13); FLTAnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[FLTAnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); + pigeonResult.aNullableString = GetNullableObjectAtIndex('list', 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex('list', 15); return pigeonResult; } + (nullable FLTAllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list { @@ -344,9 +344,9 @@ + (instancetype)makeWithAllNullableTypes:(FLTAllNullableTypes *)allNullableTypes } + (FLTAllClassesWrapper *)fromList:(NSArray *)list { FLTAllClassesWrapper *pigeonResult = [[FLTAllClassesWrapper alloc] init]; - pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 0); - pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex(list, 1); - pigeonResult.allTypes = GetNullableObjectAtIndex(list, 2); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex('list', 0); + pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex('list', 1); + pigeonResult.allTypes = GetNullableObjectAtIndex('list', 2); return pigeonResult; } + (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)list { @@ -369,7 +369,7 @@ + (instancetype)makeWithTestList:(nullable NSArray *)testList { } + (FLTTestMessage *)fromList:(NSArray *)list { FLTTestMessage *pigeonResult = [[FLTTestMessage alloc] init]; - pigeonResult.testList = GetNullableObjectAtIndex(list, 0); + pigeonResult.testList = GetNullableObjectAtIndex('list', 0); return pigeonResult; } + (nullable FLTTestMessage *)nullableFromList:(NSArray *)list { diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m index 885935cef5a..acf2e2f093c 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m @@ -112,19 +112,19 @@ + (instancetype)makeWithABool:(BOOL)aBool } + (AllTypes *)fromList:(NSArray *)list { AllTypes *pigeonResult = [[AllTypes alloc] init]; - pigeonResult.aBool = [GetNullableObjectAtIndex(list, 0) boolValue]; - pigeonResult.anInt = [GetNullableObjectAtIndex(list, 1) integerValue]; - pigeonResult.anInt64 = [GetNullableObjectAtIndex(list, 2) integerValue]; - pigeonResult.aDouble = [GetNullableObjectAtIndex(list, 3) doubleValue]; - pigeonResult.aByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.a4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.a8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.list = GetNullableObjectAtIndex(list, 8); - pigeonResult.aMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.anEnum = [GetNullableObjectAtIndex(list, 10) integerValue]; - pigeonResult.aString = GetNullableObjectAtIndex(list, 11); - pigeonResult.anObject = GetNullableObjectAtIndex(list, 12); + pigeonResult.aBool = [GetNullableObjectAtIndex('list', 0) boolValue]; + pigeonResult.anInt = [GetNullableObjectAtIndex('list', 1) integerValue]; + pigeonResult.anInt64 = [GetNullableObjectAtIndex('list', 2) integerValue]; + pigeonResult.aDouble = [GetNullableObjectAtIndex('list', 3) doubleValue]; + pigeonResult.aByteArray = GetNullableObjectAtIndex('list', 4); + pigeonResult.a4ByteArray = GetNullableObjectAtIndex('list', 5); + pigeonResult.a8ByteArray = GetNullableObjectAtIndex('list', 6); + pigeonResult.aFloatArray = GetNullableObjectAtIndex('list', 7); + pigeonResult.list = GetNullableObjectAtIndex('list', 8); + pigeonResult.aMap = GetNullableObjectAtIndex('list', 9); + pigeonResult.anEnum = [GetNullableObjectAtIndex('list', 10) integerValue]; + pigeonResult.aString = GetNullableObjectAtIndex('list', 11); + pigeonResult.anObject = GetNullableObjectAtIndex('list', 12); return pigeonResult; } + (nullable AllTypes *)nullableFromList:(NSArray *)list { @@ -190,28 +190,28 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool } + (AllNullableTypes *)fromList:(NSArray *)list { AllNullableTypes *pigeonResult = [[AllNullableTypes alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex('list', 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex('list', 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex('list', 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex('list', 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex('list', 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex('list', 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex('list', 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex('list', 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex('list', 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex('list', 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex('list', 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex('list', 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex('list', 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex('list', 13); AnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[AnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); - pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 16); + pigeonResult.aNullableString = GetNullableObjectAtIndex('list', 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex('list', 15); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex('list', 16); return pigeonResult; } + (nullable AllNullableTypes *)nullableFromList:(NSArray *)list { @@ -280,27 +280,27 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool } + (AllNullableTypesWithoutRecursion *)fromList:(NSArray *)list { AllNullableTypesWithoutRecursion *pigeonResult = [[AllNullableTypesWithoutRecursion alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex('list', 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex('list', 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex('list', 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex('list', 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex('list', 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex('list', 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex('list', 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex('list', 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex('list', 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex('list', 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex('list', 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex('list', 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex('list', 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex('list', 13); AnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[AnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); + pigeonResult.aNullableString = GetNullableObjectAtIndex('list', 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex('list', 15); return pigeonResult; } + (nullable AllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list { @@ -342,9 +342,9 @@ + (instancetype)makeWithAllNullableTypes:(AllNullableTypes *)allNullableTypes } + (AllClassesWrapper *)fromList:(NSArray *)list { AllClassesWrapper *pigeonResult = [[AllClassesWrapper alloc] init]; - pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 0); - pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex(list, 1); - pigeonResult.allTypes = GetNullableObjectAtIndex(list, 2); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex('list', 0); + pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex('list', 1); + pigeonResult.allTypes = GetNullableObjectAtIndex('list', 2); return pigeonResult; } + (nullable AllClassesWrapper *)nullableFromList:(NSArray *)list { @@ -367,7 +367,7 @@ + (instancetype)makeWithTestList:(nullable NSArray *)testList { } + (TestMessage *)fromList:(NSArray *)list { TestMessage *pigeonResult = [[TestMessage alloc] init]; - pigeonResult.testList = GetNullableObjectAtIndex(list, 0); + pigeonResult.testList = GetNullableObjectAtIndex('list', 0); return pigeonResult; } + (nullable TestMessage *)nullableFromList:(NSArray *)list { 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 e04b514013b..6eaa872105d 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 @@ -4,7 +4,7 @@ // // Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon -@file:Suppress("UNCHECKED_CAST", "LocalVariableName", "ArrayInDataClass") +@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") package com.example.test_plugin @@ -71,10 +71,11 @@ data class AllTypes( val anObject: Any ) { companion object { + @Suppress("LocalVariableName") fun fromList(__pigeon_list: List): AllTypes { val aBool = __pigeon_list[0] as Boolean - val anInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long } - val anInt64 = __pigeon_list[2].let { if (it is Int) it.toLong() else it as Long } + val anInt = __pigeon_list[1].let { num -> if (num is Int) num.toLong() else num as Long } + val anInt64 = __pigeon_list[2].let { num -> if (num is Int) num.toLong() else num as Long } val aDouble = __pigeon_list[3] as Double val aByteArray = __pigeon_list[4] as ByteArray val a4ByteArray = __pigeon_list[5] as IntArray @@ -146,10 +147,13 @@ data class AllNullableTypes( val allNullableTypes: AllNullableTypes? = null ) { companion object { + @Suppress("LocalVariableName") fun fromList(__pigeon_list: List): AllNullableTypes { val aNullableBool = __pigeon_list[0] as Boolean? - val aNullableInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long? } - val aNullableInt64 = __pigeon_list[2].let { if (it is Int) it.toLong() else it as Long? } + val aNullableInt = + __pigeon_list[1].let { num -> if (num is Int) num.toLong() else num as Long? } + val aNullableInt64 = + __pigeon_list[2].let { num -> if (num is Int) num.toLong() else num as Long? } val aNullableDouble = __pigeon_list[3] as Double? val aNullableByteArray = __pigeon_list[4] as ByteArray? val aNullable4ByteArray = __pigeon_list[5] as IntArray? @@ -160,7 +164,7 @@ data class AllNullableTypes( val nullableNestedList = __pigeon_list[10] as List?>? val nullableMapWithAnnotations = __pigeon_list[11] as Map? val nullableMapWithObject = __pigeon_list[12] as Map? - val aNullableEnum: AnEnum? = (__pigeon_list[13] as Int?)?.let { AnEnum.ofRaw(it) } + val aNullableEnum: AnEnum? = (__pigeon_list[13] as Int?)?.let { num -> AnEnum.ofRaw(num) } val aNullableString = __pigeon_list[14] as String? val aNullableObject = __pigeon_list[15] val allNullableTypes = __pigeon_list[16] as AllNullableTypes? @@ -233,10 +237,13 @@ data class AllNullableTypesWithoutRecursion( val aNullableObject: Any? = null ) { companion object { + @Suppress("LocalVariableName") fun fromList(__pigeon_list: List): AllNullableTypesWithoutRecursion { val aNullableBool = __pigeon_list[0] as Boolean? - val aNullableInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long? } - val aNullableInt64 = __pigeon_list[2].let { if (it is Int) it.toLong() else it as Long? } + val aNullableInt = + __pigeon_list[1].let { num -> if (num is Int) num.toLong() else num as Long? } + val aNullableInt64 = + __pigeon_list[2].let { num -> if (num is Int) num.toLong() else num as Long? } val aNullableDouble = __pigeon_list[3] as Double? val aNullableByteArray = __pigeon_list[4] as ByteArray? val aNullable4ByteArray = __pigeon_list[5] as IntArray? @@ -247,7 +254,7 @@ data class AllNullableTypesWithoutRecursion( val nullableNestedList = __pigeon_list[10] as List?>? val nullableMapWithAnnotations = __pigeon_list[11] as Map? val nullableMapWithObject = __pigeon_list[12] as Map? - val aNullableEnum: AnEnum? = (__pigeon_list[13] as Int?)?.let { AnEnum.ofRaw(it) } + val aNullableEnum: AnEnum? = (__pigeon_list[13] as Int?)?.let { num -> AnEnum.ofRaw(num) } val aNullableString = __pigeon_list[14] as String? val aNullableObject = __pigeon_list[15] return AllNullableTypesWithoutRecursion( @@ -307,6 +314,7 @@ data class AllClassesWrapper( val allTypes: AllTypes? = null ) { companion object { + @Suppress("LocalVariableName") fun fromList(__pigeon_list: List): AllClassesWrapper { val allNullableTypes = __pigeon_list[0] as AllNullableTypes val allNullableTypesWithoutRecursion = __pigeon_list[1] as AllNullableTypesWithoutRecursion? @@ -332,6 +340,7 @@ data class AllClassesWrapper( data class TestMessage(val testList: List? = null) { companion object { + @Suppress("LocalVariableName") fun fromList(__pigeon_list: List): TestMessage { val testList = __pigeon_list[0] as List? return TestMessage(testList) @@ -738,7 +747,7 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val anIntArg = args[0].let { if (it is Int) it.toLong() else it as Long } + val anIntArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long } val wrapped: List = try { listOf(api.echoInt(anIntArg)) @@ -1002,7 +1011,7 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val anIntArg = args[0].let { if (it is Int) it.toLong() else it as Long } + val anIntArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long } val wrapped: List = try { listOf(api.echoRequiredInt(anIntArg)) @@ -1113,7 +1122,8 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableBoolArg = args[0] as Boolean? - val aNullableIntArg = args[1].let { if (it is Int) it.toLong() else it as Long? } + val aNullableIntArg = + args[1].let { num -> if (num is Int) num.toLong() else num as Long? } val aNullableStringArg = args[2] as String? val wrapped: List = try { @@ -1139,7 +1149,8 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableBoolArg = args[0] as Boolean? - val aNullableIntArg = args[1].let { if (it is Int) it.toLong() else it as Long? } + val aNullableIntArg = + args[1].let { num -> if (num is Int) num.toLong() else num as Long? } val aNullableStringArg = args[2] as String? val wrapped: List = try { @@ -1164,7 +1175,8 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val aNullableIntArg = args[0].let { if (it is Int) it.toLong() else it as Long? } + val aNullableIntArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long? } val wrapped: List = try { listOf(api.echoNullableInt(aNullableIntArg)) @@ -1362,7 +1374,8 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val aNullableIntArg = args[0].let { if (it is Int) it.toLong() else it as Long? } + val aNullableIntArg = + args[0].let { num -> if (num is Int) num.toLong() else num as Long? } val wrapped: List = try { listOf(api.echoOptionalNullableInt(aNullableIntArg)) @@ -1427,7 +1440,7 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val anIntArg = args[0].let { if (it is Int) it.toLong() else it as Long } + val anIntArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long } api.echoAsyncInt(anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { @@ -1782,7 +1795,7 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val anIntArg = args[0].let { if (it is Int) it.toLong() else it as Long? } + val anIntArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long? } api.echoAsyncNullableInt(anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { @@ -2112,7 +2125,8 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableBoolArg = args[0] as Boolean? - val aNullableIntArg = args[1].let { if (it is Int) it.toLong() else it as Long? } + val aNullableIntArg = + args[1].let { num -> if (num is Int) num.toLong() else num as Long? } val aNullableStringArg = args[2] as String? api.callFlutterSendMultipleNullableTypes( aNullableBoolArg, aNullableIntArg, aNullableStringArg) { @@ -2165,7 +2179,8 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { message, reply -> val args = message as List val aNullableBoolArg = args[0] as Boolean? - val aNullableIntArg = args[1].let { if (it is Int) it.toLong() else it as Long? } + val aNullableIntArg = + args[1].let { num -> if (num is Int) num.toLong() else num as Long? } val aNullableStringArg = args[2] as String? api.callFlutterSendMultipleNullableTypesWithoutRecursion( aNullableBoolArg, aNullableIntArg, aNullableStringArg) { @@ -2216,7 +2231,7 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val anIntArg = args[0].let { if (it is Int) it.toLong() else it as Long } + val anIntArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long } api.callFlutterEchoInt(anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { @@ -2408,7 +2423,7 @@ interface HostIntegrationCoreApi { if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List - val anIntArg = args[0].let { if (it is Int) it.toLong() else it as Long? } + val anIntArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long? } api.callFlutterEchoNullableInt(anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { @@ -2861,7 +2876,7 @@ class FlutterIntegrationCoreApi(private val binaryMessenger: BinaryMessenger) { "Flutter api returned null value for non-null return value.", ""))) } else { - val output = it[0].let { if (it is Int) it.toLong() else it as Long } + val output = it[0].let { num -> if (num is Int) num.toLong() else num as Long } callback(Result.success(output)) } } else { @@ -3047,7 +3062,7 @@ class FlutterIntegrationCoreApi(private val binaryMessenger: BinaryMessenger) { if (it.size > 1) { callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) } else { - val output = it[0].let { if (it is Int) it.toLong() else it as Long? } + val output = it[0].let { num -> if (num is Int) num.toLong() else num as Long? } callback(Result.success(output)) } } else { @@ -3158,7 +3173,7 @@ class FlutterIntegrationCoreApi(private val binaryMessenger: BinaryMessenger) { if (it.size > 1) { callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?))) } else { - val output = (it[0] as Int?)?.let { AnEnum.ofRaw(it) } + val output = (it[0] as Int?)?.let { num -> AnEnum.ofRaw(num) } callback(Result.success(output)) } } else { 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 322bfb4262f..f4d8b30bc77 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 @@ -217,10 +217,7 @@ class AllNullableTypes { } let aNullableString: String? = nilOrValue(__pigeon_list[14]) let aNullableObject: Any? = __pigeon_list[15] - var allNullableTypes: AllNullableTypes? = nil - if let allNullableTypesList: AllNullableTypes = nilOrValue(__pigeon_list[16]) { - allNullableTypes = allNullableTypesList as AllNullableTypes - } + let allNullableTypes: AllNullableTypes? = nilOrValue(__pigeon_list[16]) return AllNullableTypes( aNullableBool: aNullableBool, @@ -375,17 +372,9 @@ struct AllClassesWrapper { // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ __pigeon_list: [Any?]) -> AllClassesWrapper? { let allNullableTypes = __pigeon_list[0] as! AllNullableTypes - var allNullableTypesWithoutRecursion: AllNullableTypesWithoutRecursion? = nil - if let allNullableTypesWithoutRecursionList: AllNullableTypesWithoutRecursion = nilOrValue( + let allNullableTypesWithoutRecursion: AllNullableTypesWithoutRecursion? = nilOrValue( __pigeon_list[1]) - { - allNullableTypesWithoutRecursion = - allNullableTypesWithoutRecursionList as AllNullableTypesWithoutRecursion - } - var allTypes: AllTypes? = nil - if let allTypesList: AllTypes = nilOrValue(__pigeon_list[2]) { - allTypes = allTypesList as AllTypes - } + let allTypes: AllTypes? = nilOrValue(__pigeon_list[2]) return AllClassesWrapper( allNullableTypes: allNullableTypes, 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 322bfb4262f..f4d8b30bc77 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 @@ -217,10 +217,7 @@ class AllNullableTypes { } let aNullableString: String? = nilOrValue(__pigeon_list[14]) let aNullableObject: Any? = __pigeon_list[15] - var allNullableTypes: AllNullableTypes? = nil - if let allNullableTypesList: AllNullableTypes = nilOrValue(__pigeon_list[16]) { - allNullableTypes = allNullableTypesList as AllNullableTypes - } + let allNullableTypes: AllNullableTypes? = nilOrValue(__pigeon_list[16]) return AllNullableTypes( aNullableBool: aNullableBool, @@ -375,17 +372,9 @@ struct AllClassesWrapper { // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ __pigeon_list: [Any?]) -> AllClassesWrapper? { let allNullableTypes = __pigeon_list[0] as! AllNullableTypes - var allNullableTypesWithoutRecursion: AllNullableTypesWithoutRecursion? = nil - if let allNullableTypesWithoutRecursionList: AllNullableTypesWithoutRecursion = nilOrValue( + let allNullableTypesWithoutRecursion: AllNullableTypesWithoutRecursion? = nilOrValue( __pigeon_list[1]) - { - allNullableTypesWithoutRecursion = - allNullableTypesWithoutRecursionList as AllNullableTypesWithoutRecursion - } - var allTypes: AllTypes? = nil - if let allTypesList: AllTypes = nilOrValue(__pigeon_list[2]) { - allTypes = allTypesList as AllTypes - } + let allTypes: AllTypes? = nilOrValue(__pigeon_list[2]) return AllClassesWrapper( allNullableTypes: allNullableTypes, From 60d0efc4bc79db966e3d3b4a293df0c9e9e0b6a3 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 22 Apr 2024 17:16:11 -0700 Subject: [PATCH 12/18] gen --- .../flutter/pigeon_example_app/Messages.g.kt | 10 ----- packages/pigeon/lib/kotlin_generator.dart | 1 - .../lib/src/generated/core_tests.gen.dart | 42 ------------------- .../com/example/test_plugin/CoreTests.gen.kt | 41 ------------------ .../com/example/test_plugin/TestPlugin.kt | 3 -- 5 files changed, 97 deletions(-) diff --git a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt index fba0afc7853..48981666f24 100644 --- a/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt +++ b/packages/pigeon/example/app/android/app/src/main/kotlin/dev/flutter/pigeon_example_app/Messages.g.kt @@ -118,10 +118,6 @@ interface ExampleHostApi { /** The codec used by ExampleHostApi. */ val codec: MessageCodec by lazy { ExampleHostApiCodec } /** Sets up an instance of `ExampleHostApi` to handle messages through the `binaryMessenger`. */ -<<<<<<< HEAD - fun setUp(binaryMessenger: BinaryMessenger, api: ExampleHostApi?) { -======= - @Suppress("UNCHECKED_CAST") fun setUp( binaryMessenger: BinaryMessenger, api: ExampleHostApi?, @@ -129,7 +125,6 @@ interface ExampleHostApi { ) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af run { val channel = BasicMessageChannel( @@ -201,15 +196,10 @@ interface ExampleHostApi { } } /** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ -<<<<<<< HEAD -class MessageFlutterApi(private val binaryMessenger: BinaryMessenger) { -======= -@Suppress("UNCHECKED_CAST") class MessageFlutterApi( private val binaryMessenger: BinaryMessenger, private val messageChannelSuffix: String = "" ) { ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af companion object { /** The codec used by MessageFlutterApi. */ val codec: MessageCodec by lazy { StandardMessageCodec() } diff --git a/packages/pigeon/lib/kotlin_generator.dart b/packages/pigeon/lib/kotlin_generator.dart index 069b9f6c816..59ed2aeea5a 100644 --- a/packages/pigeon/lib/kotlin_generator.dart +++ b/packages/pigeon/lib/kotlin_generator.dart @@ -343,7 +343,6 @@ class KotlinGenerator extends StructuredGenerator { generatorComments: generatedMessages); final String apiName = api.name; - indent.writeln('@Suppress("UNCHECKED_CAST")'); indent.write( 'class $apiName(private val binaryMessenger: BinaryMessenger, private val messageChannelSuffix: String = "") '); indent.addScoped('{', '}', () { 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 8b89125b0d9..2f24cdcb2ca 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 @@ -759,15 +759,9 @@ class HostIntegrationCoreApi { } /// Returns the passed list, to test serialization and deserialization. -<<<<<<< HEAD Future> echoList(List list) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoList'; -======= - Future> echoList(List aList) async { final String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoList$__pigeon_messageChannelSuffix'; ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, @@ -1637,15 +1631,9 @@ class HostIntegrationCoreApi { } /// Returns the passed list, to test asynchronous serialization and deserialization. -<<<<<<< HEAD Future> echoAsyncList(List list) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncList'; -======= - Future> echoAsyncList(List aList) async { final String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncList$__pigeon_messageChannelSuffix'; ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, @@ -2042,15 +2030,9 @@ class HostIntegrationCoreApi { } /// Returns the passed list, to test asynchronous serialization and deserialization. -<<<<<<< HEAD Future?> echoAsyncNullableList(List? list) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableList'; -======= - Future?> echoAsyncNullableList(List? aList) async { final String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableList$__pigeon_messageChannelSuffix'; ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, @@ -2457,15 +2439,9 @@ class HostIntegrationCoreApi { } } -<<<<<<< HEAD Future callFlutterEchoUint8List(Uint8List list) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoUint8List'; -======= - Future callFlutterEchoUint8List(Uint8List aList) async { final String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoUint8List$__pigeon_messageChannelSuffix'; ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, @@ -2492,15 +2468,9 @@ class HostIntegrationCoreApi { } } -<<<<<<< HEAD Future> callFlutterEchoList(List list) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoList'; -======= - Future> callFlutterEchoList(List aList) async { final String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoList$__pigeon_messageChannelSuffix'; ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, @@ -2683,15 +2653,9 @@ class HostIntegrationCoreApi { } } -<<<<<<< HEAD Future callFlutterEchoNullableUint8List(Uint8List? list) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableUint8List'; -======= - Future callFlutterEchoNullableUint8List(Uint8List? aList) async { final String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableUint8List$__pigeon_messageChannelSuffix'; ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, @@ -2714,15 +2678,9 @@ class HostIntegrationCoreApi { } Future?> callFlutterEchoNullableList( -<<<<<<< HEAD List? list) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableList'; -======= - List? aList) async { final String __pigeon_channelName = 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableList$__pigeon_messageChannelSuffix'; ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af final BasicMessageChannel __pigeon_channel = BasicMessageChannel( __pigeon_channelName, 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 656ae969801..3668ec94738 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 @@ -635,10 +635,6 @@ interface HostIntegrationCoreApi { * Sets up an instance of `HostIntegrationCoreApi` to handle messages through the * `binaryMessenger`. */ -<<<<<<< HEAD - fun setUp(binaryMessenger: BinaryMessenger, api: HostIntegrationCoreApi?) { -======= - @Suppress("UNCHECKED_CAST") fun setUp( binaryMessenger: BinaryMessenger, api: HostIntegrationCoreApi?, @@ -646,7 +642,6 @@ interface HostIntegrationCoreApi { ) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af run { val channel = BasicMessageChannel( @@ -2680,15 +2675,10 @@ private object FlutterIntegrationCoreApiCodec : StandardMessageCodec() { * * Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ -<<<<<<< HEAD -class FlutterIntegrationCoreApi(private val binaryMessenger: BinaryMessenger) { -======= -@Suppress("UNCHECKED_CAST") class FlutterIntegrationCoreApi( private val binaryMessenger: BinaryMessenger, private val messageChannelSuffix: String = "" ) { ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af companion object { /** The codec used by FlutterIntegrationCoreApi. */ val codec: MessageCodec by lazy { FlutterIntegrationCoreApiCodec } @@ -3005,13 +2995,9 @@ class FlutterIntegrationCoreApi( } } /** Returns the passed byte list, to test serialization and deserialization. */ -<<<<<<< HEAD fun echoUint8List(listArg: ByteArray, callback: (Result) -> Unit) { -======= - fun echoUint8List(aListArg: ByteArray, callback: (Result) -> Unit) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af val channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List$separatedMessageChannelSuffix" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) @@ -3036,13 +3022,9 @@ class FlutterIntegrationCoreApi( } } /** Returns the passed list, to test serialization and deserialization. */ -<<<<<<< HEAD fun echoList(listArg: List, callback: (Result>) -> Unit) { -======= - fun echoList(aListArg: List, callback: (Result>) -> Unit) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af val channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList$separatedMessageChannelSuffix" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) @@ -3201,13 +3183,9 @@ class FlutterIntegrationCoreApi( } } /** Returns the passed byte list, to test serialization and deserialization. */ -<<<<<<< HEAD fun echoNullableUint8List(listArg: ByteArray?, callback: (Result) -> Unit) { -======= - fun echoNullableUint8List(aListArg: ByteArray?, callback: (Result) -> Unit) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af val channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableUint8List$separatedMessageChannelSuffix" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) @@ -3225,13 +3203,9 @@ class FlutterIntegrationCoreApi( } } /** Returns the passed list, to test serialization and deserialization. */ -<<<<<<< HEAD fun echoNullableList(listArg: List?, callback: (Result?>) -> Unit) { -======= - fun echoNullableList(aListArg: List?, callback: (Result?>) -> Unit) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af val channelName = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList$separatedMessageChannelSuffix" val channel = BasicMessageChannel(binaryMessenger, channelName, codec) @@ -3353,10 +3327,6 @@ interface HostTrivialApi { /** The codec used by HostTrivialApi. */ val codec: MessageCodec by lazy { StandardMessageCodec() } /** Sets up an instance of `HostTrivialApi` to handle messages through the `binaryMessenger`. */ -<<<<<<< HEAD - fun setUp(binaryMessenger: BinaryMessenger, api: HostTrivialApi?) { -======= - @Suppress("UNCHECKED_CAST") fun setUp( binaryMessenger: BinaryMessenger, api: HostTrivialApi?, @@ -3364,7 +3334,6 @@ interface HostTrivialApi { ) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af run { val channel = BasicMessageChannel( @@ -3403,10 +3372,6 @@ interface HostSmallApi { /** The codec used by HostSmallApi. */ val codec: MessageCodec by lazy { StandardMessageCodec() } /** Sets up an instance of `HostSmallApi` to handle messages through the `binaryMessenger`. */ -<<<<<<< HEAD - fun setUp(binaryMessenger: BinaryMessenger, api: HostSmallApi?) { -======= - @Suppress("UNCHECKED_CAST") fun setUp( binaryMessenger: BinaryMessenger, api: HostSmallApi?, @@ -3414,7 +3379,6 @@ interface HostSmallApi { ) { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af run { val channel = BasicMessageChannel( @@ -3490,15 +3454,10 @@ private object FlutterSmallApiCodec : StandardMessageCodec() { * * Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ -<<<<<<< HEAD -class FlutterSmallApi(private val binaryMessenger: BinaryMessenger) { -======= -@Suppress("UNCHECKED_CAST") class FlutterSmallApi( private val binaryMessenger: BinaryMessenger, private val messageChannelSuffix: String = "" ) { ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af companion object { /** The codec used by FlutterSmallApi. */ val codec: MessageCodec by lazy { FlutterSmallApiCodec } diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt index 25b1fbd9e5b..97236e316bb 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/TestPlugin.kt @@ -10,11 +10,8 @@ import io.flutter.embedding.engine.plugins.FlutterPlugin.FlutterPluginBinding /** This plugin handles the native side of the integration tests in example/integration_test/. */ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { private var flutterApi: FlutterIntegrationCoreApi? = null -<<<<<<< HEAD -======= private var flutterSmallApiOne: FlutterSmallApi? = null private var flutterSmallApiTwo: FlutterSmallApi? = null ->>>>>>> 88572212ae3fc45d634a31e2328d77651121f1af override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) { HostIntegrationCoreApi.setUp(binding.binaryMessenger, this) From 1cdfc2a8bbc5d338dbdd004a32598c215fe23240 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 22 Apr 2024 17:41:09 -0700 Subject: [PATCH 13/18] oops --- .../example/app/macos/Runner/messages.g.m | 8 +- packages/pigeon/lib/objc_generator.dart | 2 +- .../ios/Classes/CoreTests.gen.m | 100 +++++++++--------- .../macos/Classes/CoreTests.gen.m | 100 +++++++++--------- 4 files changed, 105 insertions(+), 105 deletions(-) diff --git a/packages/pigeon/example/app/macos/Runner/messages.g.m b/packages/pigeon/example/app/macos/Runner/messages.g.m index 3c18e50cb23..90bd065401c 100644 --- a/packages/pigeon/example/app/macos/Runner/messages.g.m +++ b/packages/pigeon/example/app/macos/Runner/messages.g.m @@ -69,10 +69,10 @@ + (instancetype)makeWithName:(nullable NSString *)name } + (PGNMessageData *)fromList:(NSArray *)list { PGNMessageData *pigeonResult = [[PGNMessageData alloc] init]; - pigeonResult.name = GetNullableObjectAtIndex('list', 0); - pigeonResult.description = GetNullableObjectAtIndex('list', 1); - pigeonResult.code = [GetNullableObjectAtIndex('list', 2) integerValue]; - pigeonResult.data = GetNullableObjectAtIndex('list', 3); + pigeonResult.name = GetNullableObjectAtIndex(list, 0); + pigeonResult.description = GetNullableObjectAtIndex(list, 1); + pigeonResult.code = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.data = GetNullableObjectAtIndex(list, 3); return pigeonResult; } + (nullable PGNMessageData *)nullableFromList:(NSArray *)list { diff --git a/packages/pigeon/lib/objc_generator.dart b/packages/pigeon/lib/objc_generator.dart index 5bd93ba97ab..a35cfe6106e 100644 --- a/packages/pigeon/lib/objc_generator.dart +++ b/packages/pigeon/lib/objc_generator.dart @@ -580,7 +580,7 @@ class ObjcSourceGenerator extends StructuredGenerator { enumerate(getFieldsInSerializationOrder(classDefinition), (int index, final NamedType field) { final bool isEnumType = field.type.isEnum; - final String valueGetter = "GetNullableObjectAtIndex('list', $index)"; + final String valueGetter = "GetNullableObjectAtIndex(list, $index)"; final String? primitiveExtractionMethod = _nsnumberExtractionMethod(field.type); final String ivarValueExpression; 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 a6608ab5567..92c72d59598 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 @@ -112,19 +112,19 @@ + (instancetype)makeWithABool:(BOOL)aBool } + (FLTAllTypes *)fromList:(NSArray *)list { FLTAllTypes *pigeonResult = [[FLTAllTypes alloc] init]; - pigeonResult.aBool = [GetNullableObjectAtIndex('list', 0) boolValue]; - pigeonResult.anInt = [GetNullableObjectAtIndex('list', 1) integerValue]; - pigeonResult.anInt64 = [GetNullableObjectAtIndex('list', 2) integerValue]; - pigeonResult.aDouble = [GetNullableObjectAtIndex('list', 3) doubleValue]; - pigeonResult.aByteArray = GetNullableObjectAtIndex('list', 4); - pigeonResult.a4ByteArray = GetNullableObjectAtIndex('list', 5); - pigeonResult.a8ByteArray = GetNullableObjectAtIndex('list', 6); - pigeonResult.aFloatArray = GetNullableObjectAtIndex('list', 7); - pigeonResult.list = GetNullableObjectAtIndex('list', 8); - pigeonResult.aMap = GetNullableObjectAtIndex('list', 9); - pigeonResult.anEnum = [GetNullableObjectAtIndex('list', 10) integerValue]; - pigeonResult.aString = GetNullableObjectAtIndex('list', 11); - pigeonResult.anObject = GetNullableObjectAtIndex('list', 12); + pigeonResult.aBool = [GetNullableObjectAtIndex(list, 0) boolValue]; + pigeonResult.anInt = [GetNullableObjectAtIndex(list, 1) integerValue]; + pigeonResult.anInt64 = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.aDouble = [GetNullableObjectAtIndex(list, 3) doubleValue]; + pigeonResult.aByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.a4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.a8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.list = GetNullableObjectAtIndex(list, 8); + pigeonResult.aMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.anEnum = [GetNullableObjectAtIndex(list, 10) integerValue]; + pigeonResult.aString = GetNullableObjectAtIndex(list, 11); + pigeonResult.anObject = GetNullableObjectAtIndex(list, 12); return pigeonResult; } + (nullable FLTAllTypes *)nullableFromList:(NSArray *)list { @@ -190,28 +190,28 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool } + (FLTAllNullableTypes *)fromList:(NSArray *)list { FLTAllNullableTypes *pigeonResult = [[FLTAllNullableTypes alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex('list', 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex('list', 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex('list', 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex('list', 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex('list', 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex('list', 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex('list', 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex('list', 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex('list', 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex('list', 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex('list', 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex('list', 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex('list', 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex('list', 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); FLTAnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[FLTAnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex('list', 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex('list', 15); - pigeonResult.allNullableTypes = GetNullableObjectAtIndex('list', 16); + pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 16); return pigeonResult; } + (nullable FLTAllNullableTypes *)nullableFromList:(NSArray *)list { @@ -282,27 +282,27 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool + (FLTAllNullableTypesWithoutRecursion *)fromList:(NSArray *)list { FLTAllNullableTypesWithoutRecursion *pigeonResult = [[FLTAllNullableTypesWithoutRecursion alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex('list', 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex('list', 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex('list', 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex('list', 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex('list', 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex('list', 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex('list', 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex('list', 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex('list', 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex('list', 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex('list', 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex('list', 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex('list', 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex('list', 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); FLTAnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[FLTAnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex('list', 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex('list', 15); + pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); return pigeonResult; } + (nullable FLTAllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list { @@ -344,9 +344,9 @@ + (instancetype)makeWithAllNullableTypes:(FLTAllNullableTypes *)allNullableTypes } + (FLTAllClassesWrapper *)fromList:(NSArray *)list { FLTAllClassesWrapper *pigeonResult = [[FLTAllClassesWrapper alloc] init]; - pigeonResult.allNullableTypes = GetNullableObjectAtIndex('list', 0); - pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex('list', 1); - pigeonResult.allTypes = GetNullableObjectAtIndex('list', 2); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 0); + pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex(list, 1); + pigeonResult.allTypes = GetNullableObjectAtIndex(list, 2); return pigeonResult; } + (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)list { @@ -369,7 +369,7 @@ + (instancetype)makeWithTestList:(nullable NSArray *)testList { } + (FLTTestMessage *)fromList:(NSArray *)list { FLTTestMessage *pigeonResult = [[FLTTestMessage alloc] init]; - pigeonResult.testList = GetNullableObjectAtIndex('list', 0); + pigeonResult.testList = GetNullableObjectAtIndex(list, 0); return pigeonResult; } + (nullable FLTTestMessage *)nullableFromList:(NSArray *)list { diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m index 9c68ac45b47..fafcbcf7d73 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/macos/Classes/CoreTests.gen.m @@ -112,19 +112,19 @@ + (instancetype)makeWithABool:(BOOL)aBool } + (AllTypes *)fromList:(NSArray *)list { AllTypes *pigeonResult = [[AllTypes alloc] init]; - pigeonResult.aBool = [GetNullableObjectAtIndex('list', 0) boolValue]; - pigeonResult.anInt = [GetNullableObjectAtIndex('list', 1) integerValue]; - pigeonResult.anInt64 = [GetNullableObjectAtIndex('list', 2) integerValue]; - pigeonResult.aDouble = [GetNullableObjectAtIndex('list', 3) doubleValue]; - pigeonResult.aByteArray = GetNullableObjectAtIndex('list', 4); - pigeonResult.a4ByteArray = GetNullableObjectAtIndex('list', 5); - pigeonResult.a8ByteArray = GetNullableObjectAtIndex('list', 6); - pigeonResult.aFloatArray = GetNullableObjectAtIndex('list', 7); - pigeonResult.list = GetNullableObjectAtIndex('list', 8); - pigeonResult.aMap = GetNullableObjectAtIndex('list', 9); - pigeonResult.anEnum = [GetNullableObjectAtIndex('list', 10) integerValue]; - pigeonResult.aString = GetNullableObjectAtIndex('list', 11); - pigeonResult.anObject = GetNullableObjectAtIndex('list', 12); + pigeonResult.aBool = [GetNullableObjectAtIndex(list, 0) boolValue]; + pigeonResult.anInt = [GetNullableObjectAtIndex(list, 1) integerValue]; + pigeonResult.anInt64 = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.aDouble = [GetNullableObjectAtIndex(list, 3) doubleValue]; + pigeonResult.aByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.a4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.a8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.list = GetNullableObjectAtIndex(list, 8); + pigeonResult.aMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.anEnum = [GetNullableObjectAtIndex(list, 10) integerValue]; + pigeonResult.aString = GetNullableObjectAtIndex(list, 11); + pigeonResult.anObject = GetNullableObjectAtIndex(list, 12); return pigeonResult; } + (nullable AllTypes *)nullableFromList:(NSArray *)list { @@ -190,28 +190,28 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool } + (AllNullableTypes *)fromList:(NSArray *)list { AllNullableTypes *pigeonResult = [[AllNullableTypes alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex('list', 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex('list', 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex('list', 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex('list', 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex('list', 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex('list', 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex('list', 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex('list', 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex('list', 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex('list', 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex('list', 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex('list', 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex('list', 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex('list', 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); AnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[AnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex('list', 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex('list', 15); - pigeonResult.allNullableTypes = GetNullableObjectAtIndex('list', 16); + pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 16); return pigeonResult; } + (nullable AllNullableTypes *)nullableFromList:(NSArray *)list { @@ -280,27 +280,27 @@ + (instancetype)makeWithANullableBool:(nullable NSNumber *)aNullableBool } + (AllNullableTypesWithoutRecursion *)fromList:(NSArray *)list { AllNullableTypesWithoutRecursion *pigeonResult = [[AllNullableTypesWithoutRecursion alloc] init]; - pigeonResult.aNullableBool = GetNullableObjectAtIndex('list', 0); - pigeonResult.aNullableInt = GetNullableObjectAtIndex('list', 1); - pigeonResult.aNullableInt64 = GetNullableObjectAtIndex('list', 2); - pigeonResult.aNullableDouble = GetNullableObjectAtIndex('list', 3); - pigeonResult.aNullableByteArray = GetNullableObjectAtIndex('list', 4); - pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex('list', 5); - pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex('list', 6); - pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex('list', 7); - pigeonResult.aNullableList = GetNullableObjectAtIndex('list', 8); - pigeonResult.aNullableMap = GetNullableObjectAtIndex('list', 9); - pigeonResult.nullableNestedList = GetNullableObjectAtIndex('list', 10); - pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex('list', 11); - pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex('list', 12); - NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex('list', 13); + pigeonResult.aNullableBool = GetNullableObjectAtIndex(list, 0); + pigeonResult.aNullableInt = GetNullableObjectAtIndex(list, 1); + pigeonResult.aNullableInt64 = GetNullableObjectAtIndex(list, 2); + pigeonResult.aNullableDouble = GetNullableObjectAtIndex(list, 3); + pigeonResult.aNullableByteArray = GetNullableObjectAtIndex(list, 4); + pigeonResult.aNullable4ByteArray = GetNullableObjectAtIndex(list, 5); + pigeonResult.aNullable8ByteArray = GetNullableObjectAtIndex(list, 6); + pigeonResult.aNullableFloatArray = GetNullableObjectAtIndex(list, 7); + pigeonResult.aNullableList = GetNullableObjectAtIndex(list, 8); + pigeonResult.aNullableMap = GetNullableObjectAtIndex(list, 9); + pigeonResult.nullableNestedList = GetNullableObjectAtIndex(list, 10); + pigeonResult.nullableMapWithAnnotations = GetNullableObjectAtIndex(list, 11); + pigeonResult.nullableMapWithObject = GetNullableObjectAtIndex(list, 12); + NSNumber *aNullableEnumAsNumber = GetNullableObjectAtIndex(list, 13); AnEnumBox *aNullableEnum = aNullableEnumAsNumber == nil ? nil : [[AnEnumBox alloc] initWithValue:[aNullableEnumAsNumber integerValue]]; pigeonResult.aNullableEnum = aNullableEnum; - pigeonResult.aNullableString = GetNullableObjectAtIndex('list', 14); - pigeonResult.aNullableObject = GetNullableObjectAtIndex('list', 15); + pigeonResult.aNullableString = GetNullableObjectAtIndex(list, 14); + pigeonResult.aNullableObject = GetNullableObjectAtIndex(list, 15); return pigeonResult; } + (nullable AllNullableTypesWithoutRecursion *)nullableFromList:(NSArray *)list { @@ -342,9 +342,9 @@ + (instancetype)makeWithAllNullableTypes:(AllNullableTypes *)allNullableTypes } + (AllClassesWrapper *)fromList:(NSArray *)list { AllClassesWrapper *pigeonResult = [[AllClassesWrapper alloc] init]; - pigeonResult.allNullableTypes = GetNullableObjectAtIndex('list', 0); - pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex('list', 1); - pigeonResult.allTypes = GetNullableObjectAtIndex('list', 2); + pigeonResult.allNullableTypes = GetNullableObjectAtIndex(list, 0); + pigeonResult.allNullableTypesWithoutRecursion = GetNullableObjectAtIndex(list, 1); + pigeonResult.allTypes = GetNullableObjectAtIndex(list, 2); return pigeonResult; } + (nullable AllClassesWrapper *)nullableFromList:(NSArray *)list { @@ -367,7 +367,7 @@ + (instancetype)makeWithTestList:(nullable NSArray *)testList { } + (TestMessage *)fromList:(NSArray *)list { TestMessage *pigeonResult = [[TestMessage alloc] init]; - pigeonResult.testList = GetNullableObjectAtIndex('list', 0); + pigeonResult.testList = GetNullableObjectAtIndex(list, 0); return pigeonResult; } + (nullable TestMessage *)nullableFromList:(NSArray *)list { From 42e6773053e1c7898c450d6d4f80b2482f1e77c7 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Tue, 23 Apr 2024 12:05:30 -0700 Subject: [PATCH 14/18] fix tests --- packages/pigeon/lib/objc_generator.dart | 2 +- packages/pigeon/test/kotlin_generator_test.dart | 12 ++++++------ packages/pigeon/test/objc_generator_test.dart | 12 ++++-------- packages/pigeon/test/swift_generator_test.dart | 3 ++- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/packages/pigeon/lib/objc_generator.dart b/packages/pigeon/lib/objc_generator.dart index a35cfe6106e..5e7784bf8ba 100644 --- a/packages/pigeon/lib/objc_generator.dart +++ b/packages/pigeon/lib/objc_generator.dart @@ -580,7 +580,7 @@ class ObjcSourceGenerator extends StructuredGenerator { enumerate(getFieldsInSerializationOrder(classDefinition), (int index, final NamedType field) { final bool isEnumType = field.type.isEnum; - final String valueGetter = "GetNullableObjectAtIndex(list, $index)"; + final String valueGetter = 'GetNullableObjectAtIndex(list, $index)'; final String? primitiveExtractionMethod = _nsnumberExtractionMethod(field.type); final String ivarValueExpression; diff --git a/packages/pigeon/test/kotlin_generator_test.dart b/packages/pigeon/test/kotlin_generator_test.dart index 736875f5556..2051e4a12a5 100644 --- a/packages/pigeon/test/kotlin_generator_test.dart +++ b/packages/pigeon/test/kotlin_generator_test.dart @@ -390,7 +390,7 @@ void main() { expect( code, contains( - 'val aInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long }')); + 'val aInt = __pigeon_list[1].let { num -> if (num is Int) num.toLong() else num as Long }')); expect(code, contains('val aNullableBool: Boolean? = null')); expect(code, contains('val aNullableInt: Long? = null')); expect(code, contains('val aNullableDouble: Double? = null')); @@ -402,7 +402,7 @@ void main() { expect( code, contains( - 'val aNullableInt = __pigeon_list[9].let { if (it is Int) it.toLong() else it as Long? }')); + 'val aNullableInt = __pigeon_list[9].let { num -> if (num is Int) num.toLong() else num as Long? }')); }); test('gen one flutter api', () { @@ -1162,11 +1162,11 @@ void main() { expect( code, contains( - 'val xArg = args[0].let { if (it is Int) it.toLong() else it as Long }')); + 'val xArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long }')); expect( code, contains( - 'val yArg = args[1].let { if (it is Int) it.toLong() else it as Long }')); + 'val yArg = args[1].let { num -> if (num is Int) num.toLong() else num as Long }')); expect(code, contains('listOf(api.add(xArg, yArg))')); expect(code, contains('reply.reply(wrapped)')); }); @@ -1205,7 +1205,7 @@ void main() { expect( code, contains( - 'val output = it[0].let { if (it is Int) it.toLong() else it as Long }'), + 'val output = it[0].let { num -> if (num is Int) num.toLong() else num as Long }'), ); expect(code, contains('callback(Result.success(output))')); expect( @@ -1310,7 +1310,7 @@ void main() { expect( code, contains( - 'val fooArg = args[0].let { if (it is Int) it.toLong() else it as Long? }')); + 'val fooArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long? }')); }); test('nullable argument flutter', () { diff --git a/packages/pigeon/test/objc_generator_test.dart b/packages/pigeon/test/objc_generator_test.dart index c0d46b12035..49ab94b78bc 100644 --- a/packages/pigeon/test/objc_generator_test.dart +++ b/packages/pigeon/test/objc_generator_test.dart @@ -530,10 +530,8 @@ void main() { ); final String code = sink.toString(); expect(code, contains('@implementation Foobar')); - expect( - code, - contains( - 'pigeonResult.aBool = GetNullableObjectAtIndex(__pigeon_list, 0);')); + expect(code, + contains('pigeonResult.aBool = GetNullableObjectAtIndex(list, 0);')); }); test('nested class header', () { @@ -602,10 +600,8 @@ void main() { dartPackageName: DEFAULT_PACKAGE_NAME, ); final String code = sink.toString(); - expect( - code, - contains( - 'pigeonResult.nested = GetNullableObjectAtIndex(__pigeon_list, 0);')); + expect(code, + contains('pigeonResult.nested = GetNullableObjectAtIndex(list, 0);')); }); test('prefix class header', () { diff --git a/packages/pigeon/test/swift_generator_test.dart b/packages/pigeon/test/swift_generator_test.dart index 253546aaeaa..8fb544bbedb 100644 --- a/packages/pigeon/test/swift_generator_test.dart +++ b/packages/pigeon/test/swift_generator_test.dart @@ -578,7 +578,8 @@ void main() { expect(code, contains('var nested: Nested? = nil')); expect(code, contains('static func fromList(_ __pigeon_list: [Any?]) -> Outer?')); - expect(code, contains('nested = nestedList as Nested')); + expect( + code, contains('let nested: Nested? = nilOrValue(__pigeon_list[0])')); expect(code, contains('func toList() -> [Any?]')); expect(code, isNot(contains('if ('))); // Single-element list serializations should not have a trailing comma. From b40283875c37c9940fb65c1804198fe3955b8e6f Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Fri, 26 Apr 2024 16:47:46 -0400 Subject: [PATCH 15/18] VS 2019 workaround --- .../pigeon/platform_tests/test_plugin/windows/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/pigeon/platform_tests/test_plugin/windows/CMakeLists.txt b/packages/pigeon/platform_tests/test_plugin/windows/CMakeLists.txt index 30e26d2bb1b..f4a7ad4da2c 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/CMakeLists.txt +++ b/packages/pigeon/platform_tests/test_plugin/windows/CMakeLists.txt @@ -62,6 +62,10 @@ target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) +# Override apply_standard_settings for exceptions due to +# https://developercommunity.visualstudio.com/t/stdany-doesnt-link-when-exceptions-are-disabled/376072 +# TODO(stuartmorgan): Remove this once CI is using VS 2022 or later. +target_compile_definitions(${PLUGIN_NAME} PRIVATE "_HAS_EXCEPTIONS=1") # List of absolute paths to libraries that should be bundled with the plugin. # This list could contain prebuilt libraries, or libraries created by an From 0c032c6e69cef3987901761dae2b62ea93adad55 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Tue, 30 Apr 2024 09:51:50 -0400 Subject: [PATCH 16/18] Apply workaround to unit test binary --- .../pigeon/platform_tests/test_plugin/windows/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/pigeon/platform_tests/test_plugin/windows/CMakeLists.txt b/packages/pigeon/platform_tests/test_plugin/windows/CMakeLists.txt index f4a7ad4da2c..e69e6bc7513 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/CMakeLists.txt +++ b/packages/pigeon/platform_tests/test_plugin/windows/CMakeLists.txt @@ -122,6 +122,10 @@ add_custom_command(TARGET ${TEST_RUNNER} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${FLUTTER_LIBRARY}" $ ) +# Override apply_standard_settings for exceptions due to +# https://developercommunity.visualstudio.com/t/stdany-doesnt-link-when-exceptions-are-disabled/376072 +# TODO(stuartmorgan): Remove this once CI is using VS 2022 or later. +target_compile_definitions(${TEST_RUNNER} PRIVATE "_HAS_EXCEPTIONS=1") include(GoogleTest) gtest_discover_tests(${TEST_RUNNER}) From df349c9621c2d382d5e53d3711ecd6fe90017dad Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 6 May 2024 01:20:45 -0700 Subject: [PATCH 17/18] cleaner --- packages/pigeon/lib/dart_generator.dart | 6 +----- packages/pigeon/lib/kotlin_generator.dart | 3 +-- packages/pigeon/lib/swift_generator.dart | 3 --- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/pigeon/lib/dart_generator.dart b/packages/pigeon/lib/dart_generator.dart index e3183a3a359..0129ae4210d 100644 --- a/packages/pigeon/lib/dart_generator.dart +++ b/packages/pigeon/lib/dart_generator.dart @@ -230,11 +230,7 @@ class DartGenerator extends StructuredGenerator { for (final NamedType field in getFieldsInSerializationOrder(classDefinition)) { final String conditional = field.type.isNullable ? '?' : ''; - if (field.type.isClass) { - indent.writeln( - '${field.name},', - ); - } else if (field.type.isEnum) { + if (field.type.isEnum) { indent.writeln( '${field.name}$conditional.index,', ); diff --git a/packages/pigeon/lib/kotlin_generator.dart b/packages/pigeon/lib/kotlin_generator.dart index 59ed2aeea5a..6542b13dadf 100644 --- a/packages/pigeon/lib/kotlin_generator.dart +++ b/packages/pigeon/lib/kotlin_generator.dart @@ -220,11 +220,10 @@ class KotlinGenerator extends StructuredGenerator { indent.addScoped('(', ')', () { for (final NamedType field in getFieldsInSerializationOrder(classDefinition)) { - final HostDatatype hostDatatype = _getHostDatatype(root, field); String toWriteValue = ''; final String fieldName = field.name; final String safeCall = field.type.isNullable ? '?' : ''; - if (!hostDatatype.isBuiltin && field.type.isEnum) { + if (field.type.isEnum) { toWriteValue = '$fieldName$safeCall.raw'; } else { toWriteValue = fieldName; diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index 25443939635..b644e561d5e 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -945,9 +945,6 @@ String _swiftTypeForDartType(TypeDeclaration type) { String _nullsafeSwiftTypeForDartType(TypeDeclaration type) { final String nullSafe = type.isNullable ? '?' : ''; - if (type.baseName == 'Map') { - return '${_swiftTypeForBuiltinGenericDartType(type)}$nullSafe'; - } return '${_swiftTypeForDartType(type)}$nullSafe'; } From 34f9dca37de8a8dbc180b3978176eed22cd23d50 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 6 May 2024 02:29:48 -0700 Subject: [PATCH 18/18] analyze --- packages/pigeon/lib/kotlin_generator.dart | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/pigeon/lib/kotlin_generator.dart b/packages/pigeon/lib/kotlin_generator.dart index 6542b13dadf..18df439d740 100644 --- a/packages/pigeon/lib/kotlin_generator.dart +++ b/packages/pigeon/lib/kotlin_generator.dart @@ -841,11 +841,6 @@ class KotlinGenerator extends StructuredGenerator { } } -HostDatatype _getHostDatatype(Root root, NamedType field) { - return getFieldHostDatatype( - field, (TypeDeclaration x) => _kotlinTypeForBuiltinDartType(x)); -} - /// Calculates the name of the codec that will be generated for [api]. String _getCodecName(Api api) => '${api.name}Codec';