From 04902ded8febffbb83e82f382595e37fc0b6b364 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 13 Apr 2026 15:13:54 -0700 Subject: [PATCH 1/7] add error class and prologue to Generator class. Clean up some repeated code/method definitions and fixed bug in snake case logic (breaking change) --- .../java/io/flutter/plugins/Messages.java | 32 +- .../example/app/ios/Runner/Messages.g.swift | 36 +- .../example/app/windows/runner/messages.g.h | 38 +- .../pigeon/lib/src/cpp/cpp_generator.dart | 165 +++-- .../pigeon/lib/src/dart/dart_generator.dart | 83 ++- packages/pigeon/lib/src/generator.dart | 34 +- packages/pigeon/lib/src/generator_tools.dart | 31 +- .../lib/src/gobject/gobject_generator.dart | 1 + .../pigeon/lib/src/java/java_generator.dart | 130 ++-- .../lib/src/kotlin/kotlin_generator.dart | 102 +-- .../pigeon/lib/src/objc/objc_generator.dart | 58 +- .../pigeon/lib/src/swift/swift_generator.dart | 148 +++-- packages/pigeon/pigeons/core_tests.dart | 28 + .../AlternateLanguageTestPlugin.java | 52 ++ .../CoreTests.java | 305 ++++++++- .../AlternateLanguageTestPlugin.m | 46 ++ .../CoreTests.gen.m | 183 +++++- .../CoreTests.gen.h | 36 ++ .../lib/integration_tests.dart | 39 ++ .../lib/src/generated/core_tests.gen.dart | 157 ++++- .../test/acronyms_test.dart | 114 ++++ .../com/example/test_plugin/CoreTests.gen.kt | 169 ++++- .../com/example/test_plugin/TestPlugin.kt | 32 + .../Sources/test_plugin/CoreTests.gen.swift | 184 +++++- .../test_plugin/EventChannelTests.gen.swift | 36 +- .../test_plugin/ProxyApiTests.gen.swift | 35 +- .../Sources/test_plugin/TestPlugin.swift | 38 ++ .../linux/pigeon/core_tests.gen.cc | 606 +++++++++++++++++- .../test_plugin/linux/pigeon/core_tests.gen.h | 213 ++++++ .../test_plugin/linux/test_plugin.cc | 76 +++ .../windows/pigeon/core_tests.gen.cpp | 264 +++++++- .../windows/pigeon/core_tests.gen.h | 97 ++- .../test_plugin/windows/test_plugin.cpp | 38 ++ .../test_plugin/windows/test_plugin.h | 6 + .../pigeon/test/generator_tools_test.dart | 28 + 35 files changed, 3075 insertions(+), 565 deletions(-) create mode 100644 packages/pigeon/platform_tests/shared_test_plugin_code/test/acronyms_test.dart 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 751c1f5dc3b0..c53785c76098 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 @@ -185,22 +185,6 @@ static int pigeonDeepHashCode(Object value) { return value.hashCode(); } - /** Error class for passing custom error details to Flutter via a thrown PlatformException. */ - public static class FlutterError extends RuntimeException { - - /** The error code. */ - public final String code; - - /** The error details. Must be a datatype supported by the api codec. */ - public final Object details; - - public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) { - super(message); - this.code = code; - this.details = details; - } - } - @NonNull protected static ArrayList wrapError(@NonNull Throwable exception) { ArrayList errorList = new ArrayList<>(3); @@ -228,6 +212,22 @@ protected static FlutterError createConnectionError(@NonNull String channelName) @Retention(CLASS) @interface CanIgnoreReturnValue {} + /** Error class for passing custom error details to Flutter via a thrown PlatformException. */ + public static class FlutterError extends RuntimeException { + + /** The error code. */ + public final String code; + + /** The error details. Must be a datatype supported by the api codec. */ + public final Object details; + + public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) { + super(message); + this.code = code; + this.details = details; + } + } + public enum Code { ONE(0), TWO(1); diff --git a/packages/pigeon/example/app/ios/Runner/Messages.g.swift b/packages/pigeon/example/app/ios/Runner/Messages.g.swift index f8b12f846c22..378fea40d4bf 100644 --- a/packages/pigeon/example/app/ios/Runner/Messages.g.swift +++ b/packages/pigeon/example/app/ios/Runner/Messages.g.swift @@ -14,24 +14,6 @@ import Foundation #error("Unsupported platform.") #endif -/// Error class for passing custom error details to Dart side. -final class PigeonError: Error { - let code: String - let message: String? - let details: Sendable? - - init(code: String, message: String?, details: Sendable?) { - self.code = code - self.message = message - self.details = details - } - - var localizedDescription: String { - return - "PigeonError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" - } -} - private func wrapResult(_ result: Any?) -> [Any?] { return [result] } @@ -182,6 +164,24 @@ func deepHashMessages(value: Any?, hasher: inout Hasher) { } } +/// Error class for passing custom error details to Dart side. +final class PigeonError: Error { + let code: String + let message: String? + let details: Sendable? + + init(code: String, message: String?, details: Sendable?) { + self.code = code + self.message = message + self.details = details + } + + var localizedDescription: String { + return + "PigeonError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" + } +} + enum Code: Int { case one = 0 case two = 1 diff --git a/packages/pigeon/example/app/windows/runner/messages.g.h b/packages/pigeon/example/app/windows/runner/messages.g.h index b23312baccff..4693fdcbda48 100644 --- a/packages/pigeon/example/app/windows/runner/messages.g.h +++ b/packages/pigeon/example/app/windows/runner/messages.g.h @@ -19,25 +19,6 @@ namespace pigeon_example { // Generated class from Pigeon. -class FlutterError { - public: - explicit FlutterError(const std::string& code) : code_(code) {} - explicit FlutterError(const std::string& code, const std::string& message) - : code_(code), message_(message) {} - explicit FlutterError(const std::string& code, const std::string& message, - const ::flutter::EncodableValue& details) - : code_(code), message_(message), details_(details) {} - - const std::string& code() const { return code_; } - const std::string& message() const { return message_; } - const ::flutter::EncodableValue& details() const { return details_; } - - private: - std::string code_; - std::string message_; - ::flutter::EncodableValue details_; -}; - template class ErrorOr { public: @@ -59,6 +40,25 @@ class ErrorOr { std::variant v_; }; +class FlutterError { + public: + explicit FlutterError(const std::string& code) : code_(code) {} + explicit FlutterError(const std::string& code, const std::string& message) + : code_(code), message_(message) {} + explicit FlutterError(const std::string& code, const std::string& message, + const ::flutter::EncodableValue& details) + : code_(code), message_(message), details_(details) {} + + const std::string& code() const { return code_; } + const std::string& message() const { return message_; } + const ::flutter::EncodableValue& details() const { return details_; } + + private: + std::string code_; + std::string message_; + ::flutter::EncodableValue details_; +}; + enum class Code { kOne = 0, kTwo = 1 }; // Generated class from Pigeon that represents data sent in messages. diff --git a/packages/pigeon/lib/src/cpp/cpp_generator.dart b/packages/pigeon/lib/src/cpp/cpp_generator.dart index ffaf56787d66..21c39fd97299 100644 --- a/packages/pigeon/lib/src/cpp/cpp_generator.dart +++ b/packages/pigeon/lib/src/cpp/cpp_generator.dart @@ -17,7 +17,7 @@ const String _voidType = 'void'; /// Documentation comment spec. const DocumentCommentSpecification _docCommentSpec = - DocumentCommentSpecification(_commentPrefix); + doubleSlashStyleDocCommentSpec; /// The default serializer for Flutter. const String _standardCodecSerializer = '::flutter::StandardCodecSerializer'; @@ -142,6 +142,7 @@ class InternalCppOptions extends InternalOptions { final String? namespace; /// A copyright header that will get prepended to generated code. + @override final Iterable? copyrightHeader; /// The path to the output header file location. @@ -195,11 +196,12 @@ class CppHeaderGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - if (generatorOptions.copyrightHeader != null) { - addLines(indent, generatorOptions.copyrightHeader!, linePrefix: '// '); - } - indent.writeln('$_commentPrefix ${getGeneratedCodeWarning()}'); - indent.writeln('$_commentPrefix $seeAlsoWarning'); + super.writeFilePrologue( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); indent.newln(); } @@ -233,7 +235,7 @@ class CppHeaderGenerator extends StructuredGenerator { indent.newln(); if (generatorOptions.namespace?.endsWith('_pigeontest') ?? false) { final testFixtureClass = - '${_pascalCaseFromSnakeCase(generatorOptions.namespace!.replaceAll('_pigeontest', ''))}Test'; + '${toUpperCamelCase(generatorOptions.namespace!.replaceAll('_pigeontest', ''))}Test'; indent.writeln('class $testFixtureClass;'); } indent.newln(); @@ -262,7 +264,7 @@ class CppHeaderGenerator extends StructuredGenerator { member.documentationComments, _docCommentSpec, ); - final valueName = 'k${_pascalCaseFromCamelCase(member.name)}'; + final valueName = 'k${toUpperCamelCase(member.name)}'; indent.writeln( '$valueName = $index${index == anEnum.members.length - 1 ? '' : ','}', ); @@ -277,7 +279,6 @@ class CppHeaderGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - _writeFlutterError(indent); if (root.containsHostApi) { _writeErrorOr( indent, @@ -288,6 +289,35 @@ class CppHeaderGenerator extends StructuredGenerator { } } + @override + void writeErrorClass( + InternalCppOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { + indent.format(''' + +class FlutterError { + public: +\texplicit FlutterError(const std::string& code) +\t\t: code_(code) {} +\texplicit FlutterError(const std::string& code, const std::string& message) +\t\t: code_(code), message_(message) {} +\texplicit FlutterError(const std::string& code, const std::string& message, const ::flutter::EncodableValue& details) +\t\t: code_(code), message_(message), details_(details) {} + +\tconst std::string& code() const { return code_; } +\tconst std::string& message() const { return message_; } +\tconst ::flutter::EncodableValue& details() const { return details_; } + + private: +\tstd::string code_; +\tstd::string message_; +\t::flutter::EncodableValue details_; +};'''); + } + @override void writeDataClasses( InternalCppOptions generatorOptions, @@ -329,7 +359,7 @@ class CppHeaderGenerator extends StructuredGenerator { String? testFixtureClass; if (generatorOptions.namespace?.endsWith('_pigeontest') ?? false) { testFixtureClass = - '${_pascalCaseFromSnakeCase(generatorOptions.namespace!.replaceAll('_pigeontest', ''))}Test'; + '${toUpperCamelCase(generatorOptions.namespace!.replaceAll('_pigeontest', ''))}Test'; } indent.newln(); @@ -854,29 +884,6 @@ class CppHeaderGenerator extends StructuredGenerator { indent.newln(); } - void _writeFlutterError(Indent indent) { - indent.format(''' - -class FlutterError { - public: -\texplicit FlutterError(const std::string& code) -\t\t: code_(code) {} -\texplicit FlutterError(const std::string& code, const std::string& message) -\t\t: code_(code), message_(message) {} -\texplicit FlutterError(const std::string& code, const std::string& message, const ::flutter::EncodableValue& details) -\t\t: code_(code), message_(message), details_(details) {} - -\tconst std::string& code() const { return code_; } -\tconst std::string& message() const { return message_; } -\tconst ::flutter::EncodableValue& details() const { return details_; } - - private: -\tstd::string code_; -\tstd::string message_; -\t::flutter::EncodableValue details_; -};'''); - } - void _writeErrorOr( Indent indent, { Iterable friends = const [], @@ -934,11 +941,12 @@ class CppSourceGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - if (generatorOptions.copyrightHeader != null) { - addLines(indent, generatorOptions.copyrightHeader!, linePrefix: '// '); - } - indent.writeln('$_commentPrefix ${getGeneratedCodeWarning()}'); - indent.writeln('$_commentPrefix $seeAlsoWarning'); + super.writeFilePrologue( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); indent.newln(); indent.addln('#undef _HAS_EXCEPTIONS'); indent.newln(); @@ -1476,6 +1484,11 @@ size_t PigeonInternalDeepHash(const ::flutter::EncodableValue& v) { List types, { required String dartPackageName, }) { + if (types.length <= totalCustomCodecKeysAllowed) { + return; + } + indent.newln(); + _writeClassConstructor(root, indent, _overflowClass, _overflowFields); // Getters and setters. for (final NamedType field in _overflowFields) { @@ -1589,31 +1602,33 @@ EncodableValue $_overflowClassName::FromEncodableList( ], isConst: true, body: () { + const readValueCall = + 'return $_standardCodecSerializer::ReadValueOfType(type, stream);'; if (enumeratedTypes.isNotEmpty) { - indent.writeln('switch (type) {'); - indent.inc(); - for (final customType in enumeratedTypes) { - if (customType.enumeration < maximumCodecFieldKey) { - indent.write('case ${customType.enumeration}: '); - indent.nest(1, () { - _writeCodecDecode(indent, customType, 'ReadValue(stream)'); - }); + indent.writeScoped('switch (type) {', '}', () { + for (final customType in enumeratedTypes) { + if (customType.enumeration < maximumCodecFieldKey) { + indent.write('case ${customType.enumeration}: '); + indent.nest(1, () { + _writeCodecDecode(indent, customType, 'ReadValue(stream)'); + }); + } } - } - if (root.requiresOverflowClass) { - indent.write('case $maximumCodecFieldKey:'); - _writeCodecDecode(indent, _enumeratedOverflow, 'ReadValue(stream)'); - } - indent.writeln('default:'); - indent.inc(); - } - indent.writeln( - 'return $_standardCodecSerializer::ReadValueOfType(type, stream);', - ); - if (enumeratedTypes.isNotEmpty) { - indent.dec(); - indent.writeln('}'); - indent.dec(); + if (root.requiresOverflowClass) { + indent.write('case $maximumCodecFieldKey:'); + _writeCodecDecode( + indent, + _enumeratedOverflow, + 'ReadValue(stream)', + ); + } + indent.writeln('default:'); + indent.nest(1, () { + indent.writeln(readValueCall); + }); + }); + } else { + indent.writeln(readValueCall); } }, ); @@ -2418,33 +2433,13 @@ HostDatatype _nonNullableType(HostDatatype type) { ); } -String _pascalCaseFromCamelCase(String camelCase) => - camelCase[0].toUpperCase() + camelCase.substring(1); - -String _snakeCaseFromCamelCase(String camelCase) { - return camelCase.replaceAllMapped( - RegExp(r'[A-Z]'), - (Match m) => '${m.start == 0 ? '' : '_'}${m[0]!.toLowerCase()}', - ); -} - -String _pascalCaseFromSnakeCase(String snakeCase) { - final String camelCase = snakeCase.replaceAllMapped( - RegExp(r'_([a-z])'), - (Match m) => m[1]!.toUpperCase(), - ); - return _pascalCaseFromCamelCase(camelCase); -} - -String _makeMethodName(Method method) => _pascalCaseFromCamelCase(method.name); +String _makeMethodName(Method method) => toUpperCamelCase(method.name); -String _makeGetterName(NamedType field) => _snakeCaseFromCamelCase(field.name); +String _makeGetterName(NamedType field) => toSnakeCase(field.name); -String _makeSetterName(NamedType field) => - 'set_${_snakeCaseFromCamelCase(field.name)}'; +String _makeSetterName(NamedType field) => 'set_${toSnakeCase(field.name)}'; -String _makeVariableName(NamedType field) => - _snakeCaseFromCamelCase(field.name); +String _makeVariableName(NamedType field) => toSnakeCase(field.name); String _makeInstanceVariableName(NamedType field) => '${_makeVariableName(field)}_'; diff --git a/packages/pigeon/lib/src/dart/dart_generator.dart b/packages/pigeon/lib/src/dart/dart_generator.dart index 435df247c0c2..ea654df4da6f 100644 --- a/packages/pigeon/lib/src/dart/dart_generator.dart +++ b/packages/pigeon/lib/src/dart/dart_generator.dart @@ -14,9 +14,6 @@ import '../generator_tools.dart'; import 'proxy_api_generator_helper.dart' as proxy_api_helper; import 'templates.dart'; -/// Documentation comment open symbol. -const String _docCommentPrefix = '///'; - /// Name of the variable that contains the message channel suffix for APIs. const String _suffixVarName = '${varNamePrefix}messageChannelSuffix'; @@ -28,7 +25,7 @@ const String pigeonChannelCodec = 'pigeonChannelCodec'; /// Documentation comment spec. const DocumentCommentSpecification docCommentSpec = - DocumentCommentSpecification(_docCommentPrefix); + tripleSlashStyleDocCommentSpec; /// The custom codec used for all pigeon APIs. const String _pigeonMessageCodec = '_PigeonCodec'; @@ -117,6 +114,7 @@ class InternalDartOptions extends InternalOptions { _ignoreLints = options._ignoreLints; /// A copyright header that will get prepended to generated code. + @override final Iterable? copyrightHeader; /// Path to output generated Dart file. @@ -146,11 +144,12 @@ class DartGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - if (generatorOptions.copyrightHeader != null) { - addLines(indent, generatorOptions.copyrightHeader!, linePrefix: '// '); - } - indent.writeln('// ${getGeneratedCodeWarning()}'); - indent.writeln('// $seeAlsoWarning'); + super.writeFilePrologue( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); indent.writeln('// ignore_for_file: unused_import, unused_shown_name'); if (generatorOptions._ignoreLints) { indent.writeln('// ignore_for_file: type=lint'); @@ -1287,7 +1286,11 @@ Object? _extractReplyValueOrThrow( } void _writeCodecOverflowUtilities(Indent indent, List types) { + if (types.length <= totalCustomCodecKeysAllowed) { + return; + } indent.newln(); + indent.writeln('// ignore: camel_case_types'); indent.writeScoped('class $_overflowClassName {', '}', () { indent.format(''' @@ -1308,6 +1311,7 @@ static $_overflowClassName decode(Object result) { ); } '''); + indent.writeScoped('Object? unwrap() {', '}', () { indent.format(''' if (wrapped == null) { @@ -1315,28 +1319,21 @@ if (wrapped == null) { } '''); indent.writeScoped('switch (type) {', '}', () { - var nonSerializedClassCount = 0; for (int i = totalCustomCodecKeysAllowed; i < types.length; i++) { - if (types[i].associatedClass?.isSealed ?? false) { - nonSerializedClassCount++; - } else { - indent.writeScoped( - 'case ${i - nonSerializedClassCount - totalCustomCodecKeysAllowed}:', - '', - () { - if (types[i].type == CustomTypes.customClass) { - indent.writeln('return ${types[i].name}.decode(wrapped!);'); - } else if (types[i].type == CustomTypes.customEnum) { - indent.writeln( - 'return ${types[i].name}.values[wrapped! as int];', - ); - } - }, - ); - } + final int caseIndex = i - totalCustomCodecKeysAllowed; + final EnumeratedType type = types[i]; + indent.writeScoped('case $caseIndex:', '', () { + if (type.type == CustomTypes.customClass) { + indent.writeln('return ${type.name}.decode(wrapped!);'); + } else if (type.type == CustomTypes.customEnum) { + indent.writeln('return ${type.name}.values[wrapped! as int];'); + } + }); } + indent.writeScoped('default:', '', () { + indent.writeln('return null;'); + }); }); - indent.writeln('return null;'); }); }); } @@ -1408,33 +1405,31 @@ if (wrapped == null) { // If the message call is not made inside of an async method, this creates // an anonymous function to handle the send future. - if (!insideAsyncMethod) { - indent.writeln('() async {'); - indent.inc(); - } - - indent.format(''' + void writeBody() { + indent.format(''' final ${varNamePrefix}replyList = await $sendFutureVar as List?; '''); - final extractCall = - ''' + final extractCall = + ''' _extractReplyValueOrThrow( \t\t${varNamePrefix}replyList, \t\t${varNamePrefix}channelName, \t\tisNullValid: ${returnType.isNullable || returnType.isVoid}, ) '''; - if (returnType.isVoid) { - indent.format('$extractCall;'); - } else { - const accessor = '${varNamePrefix}replyValue'; - indent.format('final Object? $accessor = $extractCall;'); - indent.format('return ${_castValue(accessor, returnType)};'); + if (returnType.isVoid) { + indent.format('$extractCall;'); + } else { + const accessor = '${varNamePrefix}replyValue'; + indent.format('final Object? $accessor = $extractCall;'); + indent.format('return ${_castValue(accessor, returnType)};'); + } } if (!insideAsyncMethod) { - indent.dec(); - indent.writeln('}();'); + indent.writeScoped('() async {', '}();', writeBody); + } else { + writeBody(); } } diff --git a/packages/pigeon/lib/src/generator.dart b/packages/pigeon/lib/src/generator.dart index e0c240b9b794..e08382d20f7a 100644 --- a/packages/pigeon/lib/src/generator.dart +++ b/packages/pigeon/lib/src/generator.dart @@ -9,6 +9,9 @@ import 'generator_tools.dart'; abstract class InternalOptions { /// Constructor. const InternalOptions(); + + /// A copyright header that will get prepended to generated code. + Iterable? get copyrightHeader; } /// An abstract base class of generators. @@ -70,6 +73,13 @@ abstract class StructuredGenerator dartPackageName: dartPackageName, ); + writeErrorClass( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); + if (root.apis.any((Api api) => api is AstProxyApi)) { writeInstanceManager( generatorOptions, @@ -122,12 +132,26 @@ abstract class StructuredGenerator } /// Adds specified headers to [indent]. + /// + /// This provides a default implementation of `writeFilePrologue` directly in + /// `StructuredGenerator`. It handles appending the user-defined + /// `copyrightHeader`, followed by the standard autogenerated warning. + /// + /// Languages needing additional specific lines (like Dart or Kotlin adding + /// `@Suppress` or `ignore_for_file`) should override this method, call + /// `super.writeFilePrologue(...)`, and then append their specific lines. void writeFilePrologue( T generatorOptions, Root root, Indent indent, { required String dartPackageName, - }); + }) { + if (generatorOptions.copyrightHeader != null) { + addLines(indent, generatorOptions.copyrightHeader!, linePrefix: '// '); + } + indent.writeln('// ${getGeneratedCodeWarning()}'); + indent.writeln('// $seeAlsoWarning'); + } /// Writes specified imports to [indent]. void writeFileImports( @@ -167,6 +191,14 @@ abstract class StructuredGenerator required String dartPackageName, }) {} + /// Writes error class to [indent]. + void writeErrorClass( + T generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) {} + /// Writes all enums to [indent]. /// /// Can be overridden to add extra code before/after enums. diff --git a/packages/pigeon/lib/src/generator_tools.dart b/packages/pigeon/lib/src/generator_tools.dart index 55874a95684a..aeb92a4a03bb 100644 --- a/packages/pigeon/lib/src/generator_tools.dart +++ b/packages/pigeon/lib/src/generator_tools.dart @@ -684,6 +684,22 @@ bool customTypeOverflowCheck(Root root) { maximumCodecFieldKey - minimumCodecFieldKey; } +/// Documentation comment specification for C-style comments (/** ... */). +const DocumentCommentSpecification cStyleDocCommentSpec = + DocumentCommentSpecification( + '/**', + closeCommentToken: ' */', + blockContinuationToken: ' *', + ); + +/// Documentation comment specification for slash-style comments (/// ...). +const DocumentCommentSpecification tripleSlashStyleDocCommentSpec = + DocumentCommentSpecification('///'); + +/// Documentation comment specification for slash-slash-style comments (// ...). +const DocumentCommentSpecification doubleSlashStyleDocCommentSpec = + DocumentCommentSpecification('//'); + /// Describes how to format a document comment. class DocumentCommentSpecification { /// Constructor for [DocumentationCommentSpecification] @@ -838,6 +854,9 @@ class OutputFileOptions extends InternalOptions { /// Options for specified language across all file types. T languageOptions; + + @override + Iterable? get copyrightHeader => languageOptions.copyrightHeader; } /// Converts strings to Upper Camel Case. @@ -870,12 +889,22 @@ String toLowerCamelCase(String text) { String toScreamingSnakeCase(String string) { return string .replaceAllMapped( - RegExp(r'(?<=[a-z])[A-Z]'), + RegExp(r'(?<=[a-z0-9])[A-Z]|(?<=[A-Z])[A-Z](?=[a-z])'), (Match m) => '_${m.group(0)}', ) .toUpperCase(); } +/// Converts string to snake_case. +String toSnakeCase(String string) { + return string + .replaceAllMapped( + RegExp(r'(?<=[a-z0-9])[A-Z]|(?<=[A-Z])[A-Z](?=[a-z])'), + (Match m) => '_${m.group(0)}', + ) + .toLowerCase(); +} + /// The channel name for the `removeStrongReference` method of the /// `InstanceManager` API. /// diff --git a/packages/pigeon/lib/src/gobject/gobject_generator.dart b/packages/pigeon/lib/src/gobject/gobject_generator.dart index 0906c005d78a..50d6355b9822 100644 --- a/packages/pigeon/lib/src/gobject/gobject_generator.dart +++ b/packages/pigeon/lib/src/gobject/gobject_generator.dart @@ -113,6 +113,7 @@ class InternalGObjectOptions extends InternalOptions { final String? module; /// A copyright header that will get prepended to generated code. + @override final Iterable? copyrightHeader; /// The path to the output header file location. diff --git a/packages/pigeon/lib/src/java/java_generator.dart b/packages/pigeon/lib/src/java/java_generator.dart index 4b7f792dc1c3..701c7cb8eb3f 100644 --- a/packages/pigeon/lib/src/java/java_generator.dart +++ b/packages/pigeon/lib/src/java/java_generator.dart @@ -10,22 +10,8 @@ import '../generator.dart'; import '../generator_tools.dart'; import '../types/task_queue.dart'; -/// Documentation open symbol. -const String _docCommentPrefix = '/**'; - -/// Documentation continuation symbol. -const String _docCommentContinuation = ' *'; - -/// Documentation close symbol. -const String _docCommentSuffix = ' */'; - /// Documentation comment spec. -const DocumentCommentSpecification _docCommentSpec = - DocumentCommentSpecification( - _docCommentPrefix, - closeCommentToken: _docCommentSuffix, - blockContinuationToken: _docCommentContinuation, - ); +const DocumentCommentSpecification _docCommentSpec = cStyleDocCommentSpec; /// The standard codec for Flutter, used for any non custom codecs and extended for custom codecs. const String _codecName = 'PigeonCodec'; @@ -119,6 +105,7 @@ class InternalJavaOptions extends InternalOptions { final String? package; /// A copyright header that will get prepended to generated code. + @override final Iterable? copyrightHeader; /// Determines if the `javax.annotation.Generated` is used in the output. This @@ -139,11 +126,12 @@ class JavaGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - if (generatorOptions.copyrightHeader != null) { - addLines(indent, generatorOptions.copyrightHeader!, linePrefix: '// '); - } - indent.writeln('// ${getGeneratedCodeWarning()}'); - indent.writeln('// $seeAlsoWarning'); + super.writeFilePrologue( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); indent.newln(); } @@ -195,9 +183,7 @@ class JavaGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - indent.writeln( - '$_docCommentPrefix Generated class from Pigeon.$_docCommentSuffix', - ); + indent.writeln('/** Generated class from Pigeon. */'); indent.writeln( '@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression", "serial"})', ); @@ -221,13 +207,6 @@ class JavaGenerator extends StructuredGenerator { Enum anEnum, { required String dartPackageName, }) { - String camelToSnake(String camelCase) { - final regex = RegExp('([a-z])([A-Z]+)'); - return camelCase - .replaceAllMapped(regex, (Match m) => '${m[1]}_${m[2]}') - .toUpperCase(); - } - indent.newln(); addDocumentationComments( indent, @@ -244,7 +223,7 @@ class JavaGenerator extends StructuredGenerator { _docCommentSpec, ); indent.writeln( - '${camelToSnake(member.name)}($index)${index == anEnum.members.length - 1 ? ';' : ','}', + '${toScreamingSnakeCase(member.name)}($index)${index == anEnum.members.length - 1 ? ';' : ','}', ); }); indent.newln(); @@ -283,7 +262,7 @@ class JavaGenerator extends StructuredGenerator { classDefinition, ).map((NamedType e) => !e.type.isNullable).any((bool e) => e)) { indent.writeln( - '$_docCommentPrefix Constructor is non-public to enforce null safety; use Builder.$_docCommentSuffix', + '/** Constructor is non-public to enforce null safety; use Builder. */', ); indent.writeln('${classDefinition.name}() {}'); indent.newln(); @@ -901,6 +880,11 @@ class JavaGenerator extends StructuredGenerator { List types, { required String dartPackageName, }) { + if (types.length <= totalCustomCodecKeysAllowed) { + return; + } + indent.newln(); + final overflowInteration = NamedType( name: 'type', type: const TypeDeclaration(baseName: 'int', isNullable: false), @@ -938,24 +922,27 @@ static @Nullable Object fromList(@NonNull ArrayList ${varNamePrefix}list if (wrapped == null) { return null; } - '''); +'''); indent.writeScoped('switch (type.intValue()) {', '}', () { for (int i = totalCustomCodecKeysAllowed; i < types.length; i++) { - indent.writeln('case ${i - totalCustomCodecKeysAllowed}:'); - indent.nest(1, () { - if (types[i].type == CustomTypes.customClass) { + final int caseIndex = i - totalCustomCodecKeysAllowed; + final EnumeratedType type = types[i]; + indent.writeScoped('case $caseIndex:', '', () { + if (type.type == CustomTypes.customClass) { indent.writeln( - 'return ${types[i].name}.fromList((ArrayList) wrapped);', + 'return ${type.name}.fromList((ArrayList) wrapped);', ); - } else if (types[i].type == CustomTypes.customEnum) { + } else if (type.type == CustomTypes.customEnum) { indent.writeln( - 'return ${_intToEnum('wrapped', types[i].name, false)};', + 'return ${_intToEnum('wrapped', type.name, false)};', ); } }); } + indent.writeScoped('default:', '', () { + indent.writeln('return null;'); + }); }); - indent.writeln('return null;'); }); }, private: true); } @@ -1203,7 +1190,7 @@ if (wrapped == null) { }); indent.writeln( - '${_docCommentPrefix}Sets up an instance of `${api.name}` to handle messages through the `binaryMessenger`.$_docCommentSuffix', + '/** Sets up an instance of `${api.name}` to handle messages through the `binaryMessenger`. */', ); indent.writeScoped( 'static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable ${api.name} api) {', @@ -1458,32 +1445,6 @@ $resultType $resultName = }); } - void _writeErrorClass(Indent indent) { - indent.writeln( - '/** Error class for passing custom error details to Flutter via a thrown PlatformException. */', - ); - indent.write('public static class FlutterError extends RuntimeException '); - indent.addScoped('{', '}', () { - indent.newln(); - indent.writeln('/** The error code. */'); - indent.writeln('public final String code;'); - indent.newln(); - indent.writeln( - '/** The error details. Must be a datatype supported by the api codec. */', - ); - indent.writeln('public final Object details;'); - indent.newln(); - indent.writeln( - 'public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) ', - ); - indent.writeScoped('{', '}', () { - indent.writeln('super(message);'); - indent.writeln('this.code = code;'); - indent.writeln('this.details = details;'); - }); - }); - } - void _writeWrapError(Indent indent) { indent.format(''' @NonNull @@ -1538,8 +1499,6 @@ protected static ArrayList wrapError(@NonNull Throwable exception) { Indent indent, { required String dartPackageName, }) { - indent.newln(); - _writeErrorClass(indent); if (root.containsHostApi) { indent.newln(); _writeWrapError(indent); @@ -1553,6 +1512,39 @@ protected static ArrayList wrapError(@NonNull Throwable exception) { } } + @override + void writeErrorClass( + InternalJavaOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { + indent.newln(); + indent.writeln( + '/** Error class for passing custom error details to Flutter via a thrown PlatformException. */', + ); + indent.write('public static class FlutterError extends RuntimeException '); + indent.addScoped('{', '}', () { + indent.newln(); + indent.writeln('/** The error code. */'); + indent.writeln('public final String code;'); + indent.newln(); + indent.writeln( + '/** The error details. Must be a datatype supported by the api codec. */', + ); + indent.writeln('public final Object details;'); + indent.newln(); + indent.writeln( + 'public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) ', + ); + indent.writeScoped('{', '}', () { + indent.writeln('super(message);'); + indent.writeln('this.code = code;'); + indent.writeln('this.details = details;'); + }); + }); + } + @override void writeCloseNamespace( InternalJavaOptions generatorOptions, diff --git a/packages/pigeon/lib/src/kotlin/kotlin_generator.dart b/packages/pigeon/lib/src/kotlin/kotlin_generator.dart index 41e6a880f0a2..69aa2f69ed24 100644 --- a/packages/pigeon/lib/src/kotlin/kotlin_generator.dart +++ b/packages/pigeon/lib/src/kotlin/kotlin_generator.dart @@ -11,22 +11,8 @@ import '../generator_tools.dart'; import '../types/task_queue.dart'; import 'templates.dart'; -/// Documentation open symbol. -const String _docCommentPrefix = '/**'; - -/// Documentation continuation symbol. -const String _docCommentContinuation = ' *'; - -/// Documentation close symbol. -const String _docCommentSuffix = ' */'; - /// Documentation comment spec. -const DocumentCommentSpecification _docCommentSpec = - DocumentCommentSpecification( - _docCommentPrefix, - closeCommentToken: _docCommentSuffix, - blockContinuationToken: _docCommentContinuation, - ); +const DocumentCommentSpecification _docCommentSpec = cStyleDocCommentSpec; const String _codecName = 'PigeonCodec'; @@ -144,6 +130,7 @@ class InternalKotlinOptions extends InternalOptions { final String kotlinOut; /// A copyright header that will get prepended to generated code. + @override final Iterable? copyrightHeader; /// The name of the error class used for passing custom error parameters. @@ -205,11 +192,12 @@ class KotlinGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - if (generatorOptions.copyrightHeader != null) { - addLines(indent, generatorOptions.copyrightHeader!, linePrefix: '// '); - } - indent.writeln('// ${getGeneratedCodeWarning()}'); - indent.writeln('// $seeAlsoWarning'); + super.writeFilePrologue( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); indent.writeln('@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")'); if (generatorOptions.useGeneratedAnnotation) { indent.writeln(kotlinGeneratedAnnotation); @@ -641,6 +629,11 @@ class KotlinGenerator extends StructuredGenerator { List types, { required String dartPackageName, }) { + if (types.length <= totalCustomCodecKeysAllowed) { + return; + } + indent.newln(); + final overflowInt = NamedType( name: 'type', type: const TypeDeclaration(baseName: 'int', isNullable: false), @@ -650,9 +643,10 @@ class KotlinGenerator extends StructuredGenerator { type: const TypeDeclaration(baseName: 'Object', isNullable: true), ); final overflowFields = [overflowInt, overflowObject]; + final overflowClassName = + '${generatorOptions.fileSpecificClassNameComponent}$_overflowClassName'; final overflowClass = Class( - name: - '${generatorOptions.fileSpecificClassNameComponent}$_overflowClassName', + name: overflowClassName, fields: overflowFields, ); @@ -669,7 +663,7 @@ class KotlinGenerator extends StructuredGenerator { indent.format(''' companion object { fun fromList(${varNamePrefix}list: List): Any? { - val wrapper = ${generatorOptions.fileSpecificClassNameComponent}$_overflowClassName( + val wrapper = $overflowClassName( type = ${varNamePrefix}list[0] as Long, wrapped = ${varNamePrefix}list[1], ); @@ -683,17 +677,19 @@ companion object { if (wrapped == null) { return null } - '''); +'''); indent.writeScoped('when (type.toInt()) {', '}', () { for (int i = totalCustomCodecKeysAllowed; i < types.length; i++) { - indent.writeScoped('${i - totalCustomCodecKeysAllowed} ->', '', () { - if (types[i].type == CustomTypes.customClass) { + final int caseIndex = i - totalCustomCodecKeysAllowed; + final EnumeratedType type = types[i]; + indent.writeScoped('$caseIndex ->', '', () { + if (type.type == CustomTypes.customClass) { indent.writeln( - 'return ${types[i].name}.fromList(wrapped as List)', + 'return ${type.name}.fromList(wrapped as List)', ); - } else if (types[i].type == CustomTypes.customEnum) { + } else if (type.type == CustomTypes.customEnum) { indent.writeln( - 'return ${types[i].name}.ofRaw((wrapped as Long).toInt())', + 'return ${type.name}.ofRaw((wrapped as Long).toInt())', ); } }); @@ -1332,27 +1328,6 @@ if (wrapped == null) { }); } - void _writeErrorClass(InternalKotlinOptions generatorOptions, Indent indent) { - indent.newln(); - indent.writeln('/**'); - indent.writeln( - ' * Error class for passing custom error details to Flutter via a thrown PlatformException.', - ); - indent.writeln(' * @property code The error code.'); - indent.writeln(' * @property message The error message.'); - indent.writeln( - ' * @property details The error details. Must be a datatype supported by the api codec.', - ); - indent.writeln(' */'); - indent.write('class ${_getErrorClassName(generatorOptions)} '); - indent.addScoped('(', ')', () { - indent.writeln('val code: String,'); - indent.writeln('override val message: String? = null,'); - indent.writeln('val details: Any? = null'); - }, addTrailingNewline: false); - indent.addln(' : RuntimeException()'); - } - void _writeCreateConnectionError( InternalKotlinOptions generatorOptions, Indent indent, @@ -1550,9 +1525,34 @@ fun floatHash(f: Float): Int { } }, ); + } + @override + void writeErrorClass( + InternalKotlinOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { if (generatorOptions.includeErrorClass) { - _writeErrorClass(generatorOptions, indent); + indent.newln(); + indent.writeln('/**'); + indent.writeln( + ' * Error class for passing custom error details to Flutter via a thrown PlatformException.', + ); + indent.writeln(' * @property code The error code.'); + indent.writeln(' * @property message The error message.'); + indent.writeln( + ' * @property details The error details. Must be a datatype supported by the api codec.', + ); + indent.writeln(' */'); + indent.write('class ${_getErrorClassName(generatorOptions)} '); + indent.addScoped('(', ')', () { + indent.writeln('val code: String,'); + indent.writeln('override val message: String? = null,'); + indent.writeln('val details: Any? = null'); + }, addTrailingNewline: false); + indent.addln(' : RuntimeException()'); } } diff --git a/packages/pigeon/lib/src/objc/objc_generator.dart b/packages/pigeon/lib/src/objc/objc_generator.dart index af0ad6d1ea2a..9c907b412ff3 100644 --- a/packages/pigeon/lib/src/objc/objc_generator.dart +++ b/packages/pigeon/lib/src/objc/objc_generator.dart @@ -10,12 +10,9 @@ import '../generator.dart'; import '../generator_tools.dart'; import '../pigeon_lib.dart'; -/// Documentation comment open symbol. -const String _docCommentPrefix = '///'; - /// Documentation comment spec. const DocumentCommentSpecification _docCommentSpec = - DocumentCommentSpecification(_docCommentPrefix); + tripleSlashStyleDocCommentSpec; const String _overflowClassName = '${classNamePrefix}CodecOverflow'; @@ -139,6 +136,7 @@ class InternalObjcOptions extends InternalOptions { final String? prefix; /// A copyright header that will get prepended to generated code. + @override final Iterable? copyrightHeader; /// A String to augment class names to avoid cross file collisions. @@ -188,11 +186,12 @@ class ObjcHeaderGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - if (generatorOptions.copyrightHeader != null) { - addLines(indent, generatorOptions.copyrightHeader!, linePrefix: '// '); - } - indent.writeln('// ${getGeneratedCodeWarning()}'); - indent.writeln('// $seeAlsoWarning'); + super.writeFilePrologue( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); indent.newln(); } @@ -319,7 +318,7 @@ class ObjcHeaderGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - indent.writeln('$_docCommentPrefix The codec used by all APIs.'); + indent.writeln('/// The codec used by all APIs.'); indent.writeln( 'NSObject *${generatorOptions.prefix}Get${toUpperCamelCase(generatorOptions.fileSpecificClassNameComponent ?? '')}Codec(void);', ); @@ -495,11 +494,12 @@ class ObjcSourceGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - if (generatorOptions.copyrightHeader != null) { - addLines(indent, generatorOptions.copyrightHeader!, linePrefix: '// '); - } - indent.writeln('// ${getGeneratedCodeWarning()}'); - indent.writeln('// $seeAlsoWarning'); + super.writeFilePrologue( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); indent.newln(); } @@ -766,6 +766,16 @@ class ObjcSourceGenerator extends StructuredGenerator { List types, { required String dartPackageName, }) { + if (types.length <= totalCustomCodecKeysAllowed) { + return; + } + indent.newln(); + + final String className = _className( + generatorOptions.prefix, + _overflowClassName, + ); + _writeObjcSourceDataClassExtension( generatorOptions, indent, @@ -774,16 +784,14 @@ class ObjcSourceGenerator extends StructuredGenerator { isOverflowClass: true, ); indent.newln(); - indent.writeln( - '@implementation ${_className(generatorOptions.prefix, _overflowClassName)}', - ); + indent.writeln('@implementation $className'); _writeObjcSourceClassInitializer( generatorOptions, root, indent, _overflowClass, - _className(generatorOptions.prefix, _overflowClassName), + className, ); writeClassEncode( generatorOptions, @@ -795,7 +803,7 @@ class ObjcSourceGenerator extends StructuredGenerator { indent.format(''' + (id)fromList:(NSArray *)list { - ${_className(generatorOptions.prefix, _overflowClassName)} *wrapper = [[${_className(generatorOptions.prefix, _overflowClassName)} alloc] init]; + $className *wrapper = [[$className alloc] init]; wrapper.type = [GetNullableObjectAtIndex(list, 0) integerValue]; wrapper.wrapped = GetNullableObjectAtIndex(list, 1); return [wrapper unwrap]; @@ -807,13 +815,15 @@ class ObjcSourceGenerator extends StructuredGenerator { if (self.wrapped == nil) { return nil; } - '''); +'''); indent.writeScoped('switch (self.type) {', '}', () { for (int i = totalCustomCodecKeysAllowed; i < types.length; i++) { - indent.write('case ${i - totalCustomCodecKeysAllowed}:'); + final int caseIndex = i - totalCustomCodecKeysAllowed; + final EnumeratedType type = types[i]; + indent.write('case $caseIndex:'); _writeCodecDecode( indent, - types[i], + type, generatorOptions.prefix ?? '', isOverflowClass: true, ); @@ -2123,7 +2133,7 @@ void _writeDataClassDeclaration( classDefinition, ).map((NamedType e) => !e.type.isNullable).any((bool e) => e)) { indent.writeln( - '$_docCommentPrefix `init` unavailable to enforce nonnull fields, see the `make` class method.', + '/// `init` unavailable to enforce nonnull fields, see the `make` class method.', ); indent.writeln('- (instancetype)init NS_UNAVAILABLE;'); } diff --git a/packages/pigeon/lib/src/swift/swift_generator.dart b/packages/pigeon/lib/src/swift/swift_generator.dart index 45b968ed4d10..8e8fd012e604 100644 --- a/packages/pigeon/lib/src/swift/swift_generator.dart +++ b/packages/pigeon/lib/src/swift/swift_generator.dart @@ -12,12 +12,9 @@ import '../generator_tools.dart'; import '../types/task_queue.dart'; import 'templates.dart'; -/// Documentation comment open symbol. -const String _docCommentPrefix = '///'; - /// Documentation comment spec. const DocumentCommentSpecification _docCommentSpec = - DocumentCommentSpecification(_docCommentPrefix); + tripleSlashStyleDocCommentSpec; const String _overflowClassName = '${classNamePrefix}CodecOverflow'; @@ -103,6 +100,7 @@ class InternalSwiftOptions extends InternalOptions { includeErrorClass = options.includeErrorClass; /// A copyright header that will get prepended to generated code. + @override final Iterable? copyrightHeader; /// Path to the swift file that will be generated. @@ -193,11 +191,12 @@ class SwiftGenerator extends StructuredGenerator { Indent indent, { required String dartPackageName, }) { - if (generatorOptions.copyrightHeader != null) { - addLines(indent, generatorOptions.copyrightHeader!, linePrefix: '// '); - } - indent.writeln('// ${getGeneratedCodeWarning()}'); - indent.writeln('// $seeAlsoWarning'); + super.writeFilePrologue( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); indent.newln(); } @@ -246,7 +245,7 @@ class SwiftGenerator extends StructuredGenerator { member.documentationComments, _docCommentSpec, ); - indent.writeln('case ${_camelCase(member.name)} = $index'); + indent.writeln('case ${toLowerCamelCase(member.name)} = $index'); }); }); } @@ -466,6 +465,11 @@ class SwiftGenerator extends StructuredGenerator { List types, { required String dartPackageName, }) { + if (types.length <= totalCustomCodecKeysAllowed) { + return; + } + indent.newln(); + final overflowInt = NamedType( name: 'type', type: const TypeDeclaration(baseName: 'Int', isNullable: false), @@ -479,7 +483,7 @@ class SwiftGenerator extends StructuredGenerator { name: _overflowClassName, fields: overflowFields, ); - indent.newln(); + _writeDataClassSignature( indent, overflowClass, @@ -515,25 +519,22 @@ static func fromList(_ ${varNamePrefix}list: [Any?]) -> Any? { if (wrapped == nil) { return nil; } - '''); +'''); indent.writeScoped('switch type {', '}', () { for (int i = totalCustomCodecKeysAllowed; i < types.length; i++) { - indent.writeScoped( - 'case ${i - totalCustomCodecKeysAllowed}:', - '', - () { - if (types[i].type == CustomTypes.customClass) { - indent.writeln( - 'return ${types[i].name}.fromList(wrapped as! [Any?]);', - ); - } else if (types[i].type == CustomTypes.customEnum) { - indent.writeln( - 'return ${types[i].name}(rawValue: wrapped as! Int);', - ); - } - }, - addTrailingNewline: false, - ); + final int caseIndex = i - totalCustomCodecKeysAllowed; + final EnumeratedType type = types[i]; + indent.writeScoped('case $caseIndex:', '', () { + if (type.type == CustomTypes.customClass) { + indent.writeln( + 'return ${type.name}.fromList(wrapped as! [Any?]);', + ); + } else if (type.type == CustomTypes.customEnum) { + indent.writeln( + 'return ${type.name}(rawValue: wrapped as! Int);', + ); + } + }, addTrailingNewline: false); } indent.writeScoped('default: ', '', () { indent.writeln('return nil'); @@ -917,7 +918,7 @@ if (wrapped == nil) { indent.newln(); indent.writeln( - '$_docCommentPrefix Generated setup class from Pigeon to handle messages through the `binaryMessenger`.', + '/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.', ); indent.write('class ${apiName}Setup '); indent.addScoped('{', '}', () { @@ -925,7 +926,7 @@ if (wrapped == nil) { 'static var codec: FlutterStandardMessageCodec { ${_getMessageCodecName(generatorOptions)}.shared }', ); indent.writeln( - '$_docCommentPrefix Sets up an instance of `$apiName` to handle messages through the `binaryMessenger`.', + '/// Sets up an instance of `$apiName` to handle messages through the `binaryMessenger`.', ); indent.write( 'static func setUp(binaryMessenger: FlutterBinaryMessenger, api: $apiName?, messageChannelSuffix: String = "") ', @@ -1634,10 +1635,6 @@ func $deepHashName(value: Any?, hasher: inout Hasher) { Indent indent, { required String dartPackageName, }) { - if (generatorOptions.includeErrorClass) { - _writePigeonError(generatorOptions, indent); - } - if (root.containsHostApi || root.containsProxyApi) { _writeWrapResult(indent); _writeWrapError(generatorOptions, indent); @@ -1653,6 +1650,48 @@ func $deepHashName(value: Any?, hasher: inout Hasher) { } } + @override + void writeErrorClass( + InternalSwiftOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { + if (generatorOptions.includeErrorClass) { + indent.newln(); + indent.writeln( + '/// Error class for passing custom error details to Dart side.', + ); + indent.writeScoped( + 'final class ${_getErrorClassName(generatorOptions)}: Error {', + '}', + () { + indent.writeln('let code: String'); + indent.writeln('let message: String?'); + indent.writeln('let details: Sendable?'); + indent.newln(); + indent.writeScoped( + 'init(code: String, message: String?, details: Sendable?) {', + '}', + () { + indent.writeln('self.code = code'); + indent.writeln('self.message = message'); + indent.writeln('self.details = details'); + }, + ); + indent.newln(); + indent.writeScoped('var localizedDescription: String {', '}', () { + indent.writeScoped('return', '', () { + indent.writeln( + '"${_getErrorClassName(generatorOptions)}(code: \\(code), message: \\(message ?? ""), details: \\(details ?? "")"', + ); + }, addTrailingNewline: false); + }); + }, + ); + } + } + @override void writeEventChannelApi( InternalSwiftOptions generatorOptions, @@ -2815,40 +2854,6 @@ func $deepHashName(value: Any?, hasher: inout Hasher) { } } - void _writePigeonError(InternalSwiftOptions generatorOptions, Indent indent) { - indent.newln(); - indent.writeln( - '/// Error class for passing custom error details to Dart side.', - ); - indent.writeScoped( - 'final class ${_getErrorClassName(generatorOptions)}: Error {', - '}', - () { - indent.writeln('let code: String'); - indent.writeln('let message: String?'); - indent.writeln('let details: Sendable?'); - indent.newln(); - indent.writeScoped( - 'init(code: String, message: String?, details: Sendable?) {', - '}', - () { - indent.writeln('self.code = code'); - indent.writeln('self.message = message'); - indent.writeln('self.details = details'); - }, - ); - indent.newln(); - indent.writeScoped('var localizedDescription: String {', '}', () { - indent.writeScoped('return', '', () { - indent.writeln( - '"${_getErrorClassName(generatorOptions)}(code: \\(code), message: \\(message ?? ""), details: \\(details ?? "")"', - ); - }, addTrailingNewline: false); - }); - }, - ); - } - void _writeProxyApiImports(Indent indent, Iterable apis) { final apisOfImports = >{}; for (final proxyApi in apis) { @@ -3002,13 +3007,6 @@ String _getSafeArgumentName(int count, NamedType argument) { return '${_getArgumentName(count, argument)}Arg'; } -String _camelCase(String text) { - final String pascal = text.split('_').map((String part) { - return part.isEmpty ? '' : part[0].toUpperCase() + part.substring(1); - }).join(); - return pascal[0].toLowerCase() + pascal.substring(1); -} - /// Converts a [List] of [TypeDeclaration]s to a comma separated [String] to be /// used in Swift code. String _flattenTypeArguments(List args) { diff --git a/packages/pigeon/pigeons/core_tests.dart b/packages/pigeon/pigeons/core_tests.dart index f55c0bbfd519..a1dd884366b1 100644 --- a/packages/pigeon/pigeons/core_tests.dart +++ b/packages/pigeon/pigeons/core_tests.dart @@ -275,6 +275,21 @@ class AllClassesWrapper { Map? nullableClassMap; } +enum AcronymsEnum { HTTPResponse, JSONParser } + +class AcronymsAndTestCase { + AcronymsAndTestCase({ + this.httpResponse = '', + this.jsonParser = '', + this.xmlNode = '', + this.acronymsEnum, + }); + String httpResponse; + String jsonParser; + String xmlNode; + AcronymsEnum? acronymsEnum; +} + /// The core interface that each host language plugin must implement in /// platform_test integration tests. @HostApi() @@ -408,6 +423,19 @@ abstract class HostIntegrationCoreApi { @SwiftFunction('echo(_:)') AllClassesWrapper echoClassWrapper(AllClassesWrapper wrapper); + /// Returns the passed acronyms object. + @ObjCSelector('echoAcronyms:') + @SwiftFunction('echo(_:)') + AcronymsAndTestCase echoAcronyms(AcronymsAndTestCase acronyms); + + @ObjCSelector('hostHTTPResponse:') + @SwiftFunction('hostHTTPResponse(_:)') + AcronymsAndTestCase hostHTTPResponse(AcronymsAndTestCase acronyms); + + @ObjCSelector('sendJSONParser:') + @SwiftFunction('sendJSONParser(_:)') + AcronymsAndTestCase sendJSONParser(AcronymsAndTestCase acronyms); + /// Returns the passed enum to test serialization and deserialization. @ObjCSelector('echoEnum:') @SwiftFunction('echo(_:)') 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 5c46688a6d95..a1d9ab5d2920 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 @@ -7,6 +7,8 @@ import android.os.Looper; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.example.alternate_language_test_plugin.CoreTests.AcronymsAndTestCase; +import com.example.alternate_language_test_plugin.CoreTests.AcronymsEnum; import com.example.alternate_language_test_plugin.CoreTests.AllClassesWrapper; import com.example.alternate_language_test_plugin.CoreTests.AllNullableTypes; import com.example.alternate_language_test_plugin.CoreTests.AllNullableTypesWithoutRecursion; @@ -408,6 +410,56 @@ public Map echoNullableNonNullClassMap( return aNullableString; } + // This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. + @Override + public @NonNull AcronymsAndTestCase hostHTTPResponse(@NonNull AcronymsAndTestCase acronyms) { + AcronymsEnum enumVal = null; + AcronymsEnum incomingEnum = acronyms.getAcronymsEnum(); + if (incomingEnum != null) { + switch (incomingEnum) { + case HTTP_RESPONSE: + enumVal = AcronymsEnum.HTTP_RESPONSE; + break; + case JSON_PARSER: + enumVal = AcronymsEnum.JSON_PARSER; + break; + default: + throw new IllegalArgumentException("Unexpected enum value: " + incomingEnum); + } + } + return new AcronymsAndTestCase.Builder() + .setHttpResponse(acronyms.getHttpResponse()) + .setJsonParser(acronyms.getJsonParser()) + .setXmlNode(acronyms.getXmlNode()) + .setAcronymsEnum(enumVal) + .build(); + } + + // This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. + @Override + public @NonNull AcronymsAndTestCase sendJSONParser(@NonNull AcronymsAndTestCase acronyms) { + AcronymsEnum enumVal = null; + AcronymsEnum incomingEnum = acronyms.getAcronymsEnum(); + if (incomingEnum != null) { + switch (incomingEnum) { + case HTTP_RESPONSE: + enumVal = AcronymsEnum.HTTP_RESPONSE; + break; + case JSON_PARSER: + enumVal = AcronymsEnum.JSON_PARSER; + break; + default: + throw new IllegalArgumentException("Unexpected enum value: " + incomingEnum); + } + } + return new AcronymsAndTestCase.Builder() + .setHttpResponse(acronyms.getHttpResponse()) + .setJsonParser(acronyms.getJsonParser()) + .setXmlNode(acronyms.getXmlNode()) + .setAcronymsEnum(enumVal) + .build(); + } + @Override public void noopAsync(@NonNull VoidResult result) { result.success(); 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 8b3825849e95..3dc0b0545c28 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 @@ -188,22 +188,6 @@ static int pigeonDeepHashCode(Object value) { return value.hashCode(); } - /** Error class for passing custom error details to Flutter via a thrown PlatformException. */ - public static class FlutterError extends RuntimeException { - - /** The error code. */ - public final String code; - - /** The error details. Must be a datatype supported by the api codec. */ - public final Object details; - - public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) { - super(message); - this.code = code; - this.details = details; - } - } - @NonNull protected static ArrayList wrapError(@NonNull Throwable exception) { ArrayList errorList = new ArrayList<>(3); @@ -231,6 +215,22 @@ protected static FlutterError createConnectionError(@NonNull String channelName) @Retention(CLASS) @interface CanIgnoreReturnValue {} + /** Error class for passing custom error details to Flutter via a thrown PlatformException. */ + public static class FlutterError extends RuntimeException { + + /** The error code. */ + public final String code; + + /** The error details. Must be a datatype supported by the api codec. */ + public final Object details; + + public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) { + super(message); + this.code = code; + this.details = details; + } + } + public enum AnEnum { ONE(0), TWO(1), @@ -255,6 +255,17 @@ public enum AnotherEnum { } } + public enum AcronymsEnum { + HTTP_RESPONSE(0), + JSON_PARSER(1); + + final int index; + + AcronymsEnum(final int index) { + this.index = index; + } + } + /** Generated class from Pigeon that represents data sent in messages. */ public static final class UnusedClass { private @Nullable Object aField; @@ -2871,6 +2882,149 @@ ArrayList toList() { } } + /** Generated class from Pigeon that represents data sent in messages. */ + public static final class AcronymsAndTestCase { + private @NonNull String httpResponse; + + public @NonNull String getHttpResponse() { + return httpResponse; + } + + public void setHttpResponse(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"httpResponse\" is null."); + } + this.httpResponse = setterArg; + } + + private @NonNull String jsonParser; + + public @NonNull String getJsonParser() { + return jsonParser; + } + + public void setJsonParser(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"jsonParser\" is null."); + } + this.jsonParser = setterArg; + } + + private @NonNull String xmlNode; + + public @NonNull String getXmlNode() { + return xmlNode; + } + + public void setXmlNode(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"xmlNode\" is null."); + } + this.xmlNode = setterArg; + } + + private @Nullable AcronymsEnum acronymsEnum; + + public @Nullable AcronymsEnum getAcronymsEnum() { + return acronymsEnum; + } + + public void setAcronymsEnum(@Nullable AcronymsEnum setterArg) { + this.acronymsEnum = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + AcronymsAndTestCase() {} + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AcronymsAndTestCase that = (AcronymsAndTestCase) o; + return pigeonDeepEquals(httpResponse, that.httpResponse) + && pigeonDeepEquals(jsonParser, that.jsonParser) + && pigeonDeepEquals(xmlNode, that.xmlNode) + && pigeonDeepEquals(acronymsEnum, that.acronymsEnum); + } + + @Override + public int hashCode() { + Object[] fields = new Object[] {getClass(), httpResponse, jsonParser, xmlNode, acronymsEnum}; + return pigeonDeepHashCode(fields); + } + + public static final class Builder { + + private @Nullable String httpResponse; + + @CanIgnoreReturnValue + public @NonNull Builder setHttpResponse(@NonNull String setterArg) { + this.httpResponse = setterArg; + return this; + } + + private @Nullable String jsonParser; + + @CanIgnoreReturnValue + public @NonNull Builder setJsonParser(@NonNull String setterArg) { + this.jsonParser = setterArg; + return this; + } + + private @Nullable String xmlNode; + + @CanIgnoreReturnValue + public @NonNull Builder setXmlNode(@NonNull String setterArg) { + this.xmlNode = setterArg; + return this; + } + + private @Nullable AcronymsEnum acronymsEnum; + + @CanIgnoreReturnValue + public @NonNull Builder setAcronymsEnum(@Nullable AcronymsEnum setterArg) { + this.acronymsEnum = setterArg; + return this; + } + + public @NonNull AcronymsAndTestCase build() { + AcronymsAndTestCase pigeonReturn = new AcronymsAndTestCase(); + pigeonReturn.setHttpResponse(httpResponse); + pigeonReturn.setJsonParser(jsonParser); + pigeonReturn.setXmlNode(xmlNode); + pigeonReturn.setAcronymsEnum(acronymsEnum); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(4); + toListResult.add(httpResponse); + toListResult.add(jsonParser); + toListResult.add(xmlNode); + toListResult.add(acronymsEnum); + return toListResult; + } + + static @NonNull AcronymsAndTestCase fromList(@NonNull ArrayList pigeonVar_list) { + AcronymsAndTestCase pigeonResult = new AcronymsAndTestCase(); + Object httpResponse = pigeonVar_list.get(0); + pigeonResult.setHttpResponse((String) httpResponse); + Object jsonParser = pigeonVar_list.get(1); + pigeonResult.setJsonParser((String) jsonParser); + Object xmlNode = pigeonVar_list.get(2); + pigeonResult.setXmlNode((String) xmlNode); + Object acronymsEnum = pigeonVar_list.get(3); + pigeonResult.setAcronymsEnum((AcronymsEnum) acronymsEnum); + return pigeonResult; + } + } + /** * A data class containing a List, used in unit tests. * @@ -2956,16 +3110,23 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { return value == null ? null : AnotherEnum.values()[((Long) value).intValue()]; } case (byte) 131: - return UnusedClass.fromList((ArrayList) readValue(buffer)); + { + Object value = readValue(buffer); + return value == null ? null : AcronymsEnum.values()[((Long) value).intValue()]; + } case (byte) 132: - return AllTypes.fromList((ArrayList) readValue(buffer)); + return UnusedClass.fromList((ArrayList) readValue(buffer)); case (byte) 133: - return AllNullableTypes.fromList((ArrayList) readValue(buffer)); + return AllTypes.fromList((ArrayList) readValue(buffer)); case (byte) 134: - return AllNullableTypesWithoutRecursion.fromList((ArrayList) readValue(buffer)); + return AllNullableTypes.fromList((ArrayList) readValue(buffer)); case (byte) 135: - return AllClassesWrapper.fromList((ArrayList) readValue(buffer)); + return AllNullableTypesWithoutRecursion.fromList((ArrayList) readValue(buffer)); case (byte) 136: + return AllClassesWrapper.fromList((ArrayList) readValue(buffer)); + case (byte) 137: + return AcronymsAndTestCase.fromList((ArrayList) readValue(buffer)); + case (byte) 138: return TestMessage.fromList((ArrayList) readValue(buffer)); default: return super.readValueOfType(type, buffer); @@ -2980,23 +3141,29 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { } else if (value instanceof AnotherEnum) { stream.write(130); writeValue(stream, value == null ? null : ((AnotherEnum) value).index); - } else if (value instanceof UnusedClass) { + } else if (value instanceof AcronymsEnum) { stream.write(131); + writeValue(stream, value == null ? null : ((AcronymsEnum) value).index); + } else if (value instanceof UnusedClass) { + stream.write(132); writeValue(stream, ((UnusedClass) value).toList()); } else if (value instanceof AllTypes) { - stream.write(132); + stream.write(133); writeValue(stream, ((AllTypes) value).toList()); } else if (value instanceof AllNullableTypes) { - stream.write(133); + stream.write(134); writeValue(stream, ((AllNullableTypes) value).toList()); } else if (value instanceof AllNullableTypesWithoutRecursion) { - stream.write(134); + stream.write(135); writeValue(stream, ((AllNullableTypesWithoutRecursion) value).toList()); } else if (value instanceof AllClassesWrapper) { - stream.write(135); + stream.write(136); writeValue(stream, ((AllClassesWrapper) value).toList()); + } else if (value instanceof AcronymsAndTestCase) { + stream.write(137); + writeValue(stream, ((AcronymsAndTestCase) value).toList()); } else if (value instanceof TestMessage) { - stream.write(136); + stream.write(138); writeValue(stream, ((TestMessage) value).toList()); } else { super.writeValue(stream, value); @@ -3113,6 +3280,15 @@ public interface HostIntegrationCoreApi { /** Returns the passed class to test nested class serialization and deserialization. */ @NonNull AllClassesWrapper echoClassWrapper(@NonNull AllClassesWrapper wrapper); + /** Returns the passed acronyms object. */ + @NonNull + AcronymsAndTestCase echoAcronyms(@NonNull AcronymsAndTestCase acronyms); + + @NonNull + AcronymsAndTestCase hostHTTPResponse(@NonNull AcronymsAndTestCase acronyms); + + @NonNull + AcronymsAndTestCase sendJSONParser(@NonNull AcronymsAndTestCase acronyms); /** Returns the passed enum to test serialization and deserialization. */ @NonNull AnEnum echoEnum(@NonNull AnEnum anEnum); @@ -4173,6 +4349,81 @@ static void setUp( channel.setMessageHandler(null); } } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAcronyms" + + messageChannelSuffix, + getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + ArrayList args = (ArrayList) message; + AcronymsAndTestCase acronymsArg = (AcronymsAndTestCase) args.get(0); + try { + AcronymsAndTestCase output = api.echoAcronyms(acronymsArg); + wrapped.add(0, output); + } catch (Throwable exception) { + wrapped = wrapError(exception); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.hostHTTPResponse" + + messageChannelSuffix, + getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + ArrayList args = (ArrayList) message; + AcronymsAndTestCase acronymsArg = (AcronymsAndTestCase) args.get(0); + try { + AcronymsAndTestCase output = api.hostHTTPResponse(acronymsArg); + wrapped.add(0, output); + } catch (Throwable exception) { + wrapped = wrapError(exception); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.sendJSONParser" + + messageChannelSuffix, + getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + ArrayList args = (ArrayList) message; + AcronymsAndTestCase acronymsArg = (AcronymsAndTestCase) args.get(0); + try { + AcronymsAndTestCase output = api.sendJSONParser(acronymsArg); + wrapped.add(0, output); + } catch (Throwable exception) { + wrapped = wrapError(exception); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } { BasicMessageChannel channel = new BasicMessageChannel<>( diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m index fdd0a0563ae5..85e3cb3e7744 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m @@ -398,6 +398,52 @@ - (nullable NSString *)echoNamedNullableString:(nullable NSString *)aNullableStr return aNullableString; } +// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +- (nullable FLTAcronymsAndTestCase *)hostHTTPResponse:(FLTAcronymsAndTestCase *)acronyms + error:(FlutterError *_Nullable *_Nonnull)error { + FLTAcronymsEnumBox *enumBox = nil; + if (acronyms.acronymsEnum) { + FLTAcronymsEnum enumVal; + switch (acronyms.acronymsEnum.value) { + case FLTAcronymsEnumHTTPResponse: + enumVal = FLTAcronymsEnumHTTPResponse; + break; + case FLTAcronymsEnumJSONParser: + enumVal = FLTAcronymsEnumJSONParser; + break; + } + enumBox = [[FLTAcronymsEnumBox alloc] initWithValue:enumVal]; + } + return [FLTAcronymsAndTestCase + makeWithHttpResponse:acronyms.httpResponse + jsonParser:acronyms.jsonParser + xmlNode:acronyms.xmlNode + acronymsEnum:enumBox]; +} + +// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +- (nullable FLTAcronymsAndTestCase *)sendJSONParser:(FLTAcronymsAndTestCase *)acronyms + error:(FlutterError *_Nullable *_Nonnull)error { + FLTAcronymsEnumBox *enumBox = nil; + if (acronyms.acronymsEnum) { + FLTAcronymsEnum enumVal; + switch (acronyms.acronymsEnum.value) { + case FLTAcronymsEnumHTTPResponse: + enumVal = FLTAcronymsEnumHTTPResponse; + break; + case FLTAcronymsEnumJSONParser: + enumVal = FLTAcronymsEnumJSONParser; + break; + } + enumBox = [[FLTAcronymsEnumBox alloc] initWithValue:enumVal]; + } + return [FLTAcronymsAndTestCase + makeWithHttpResponse:acronyms.httpResponse + jsonParser:acronyms.jsonParser + xmlNode:acronyms.xmlNode + acronymsEnum:enumBox]; +} + - (void)noopAsyncWithCompletion:(void (^)(FlutterError *_Nullable))completion { completion(nil); } diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/CoreTests.gen.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/CoreTests.gen.m index 7c114f8fa47b..2d19db0ca893 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/CoreTests.gen.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/CoreTests.gen.m @@ -147,6 +147,16 @@ - (instancetype)initWithValue:(FLTAnotherEnum)value { } @end +@implementation FLTAcronymsEnumBox +- (instancetype)initWithValue:(FLTAcronymsEnum)value { + self = [super init]; + if (self) { + _value = value; + } + return self; +} +@end + @interface FLTUnusedClass () + (FLTUnusedClass *)fromList:(NSArray *)list; + (nullable FLTUnusedClass *)nullableFromList:(NSArray *)list; @@ -177,6 +187,12 @@ + (nullable FLTAllClassesWrapper *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end +@interface FLTAcronymsAndTestCase () ++ (FLTAcronymsAndTestCase *)fromList:(NSArray *)list; ++ (nullable FLTAcronymsAndTestCase *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + @interface FLTTestMessage () + (FLTTestMessage *)fromList:(NSArray *)list; + (nullable FLTTestMessage *)nullableFromList:(NSArray *)list; @@ -919,6 +935,61 @@ - (NSUInteger)hash { } @end +@implementation FLTAcronymsAndTestCase ++ (instancetype)makeWithHttpResponse:(NSString *)httpResponse + jsonParser:(NSString *)jsonParser + xmlNode:(NSString *)xmlNode + acronymsEnum:(nullable FLTAcronymsEnumBox *)acronymsEnum { + FLTAcronymsAndTestCase *pigeonResult = [[FLTAcronymsAndTestCase alloc] init]; + pigeonResult.httpResponse = httpResponse; + pigeonResult.jsonParser = jsonParser; + pigeonResult.xmlNode = xmlNode; + pigeonResult.acronymsEnum = acronymsEnum; + return pigeonResult; +} ++ (FLTAcronymsAndTestCase *)fromList:(NSArray *)list { + FLTAcronymsAndTestCase *pigeonResult = [[FLTAcronymsAndTestCase alloc] init]; + pigeonResult.httpResponse = GetNullableObjectAtIndex(list, 0); + pigeonResult.jsonParser = GetNullableObjectAtIndex(list, 1); + pigeonResult.xmlNode = GetNullableObjectAtIndex(list, 2); + pigeonResult.acronymsEnum = GetNullableObjectAtIndex(list, 3); + return pigeonResult; +} ++ (nullable FLTAcronymsAndTestCase *)nullableFromList:(NSArray *)list { + return (list) ? [FLTAcronymsAndTestCase fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.httpResponse ?: [NSNull null], + self.jsonParser ?: [NSNull null], + self.xmlNode ?: [NSNull null], + self.acronymsEnum ?: [NSNull null], + ]; +} +- (BOOL)isEqual:(id)object { + if (self == object) { + return YES; + } + if (![object isKindOfClass:[self class]]) { + return NO; + } + FLTAcronymsAndTestCase *other = (FLTAcronymsAndTestCase *)object; + return FLTPigeonDeepEquals(self.httpResponse, other.httpResponse) && + FLTPigeonDeepEquals(self.jsonParser, other.jsonParser) && + FLTPigeonDeepEquals(self.xmlNode, other.xmlNode) && + FLTPigeonDeepEquals(self.acronymsEnum, other.acronymsEnum); +} + +- (NSUInteger)hash { + NSUInteger result = [self class].hash; + result = result * 31 + FLTPigeonDeepHash(self.httpResponse); + result = result * 31 + FLTPigeonDeepHash(self.jsonParser); + result = result * 31 + FLTPigeonDeepHash(self.xmlNode); + result = result * 31 + FLTPigeonDeepHash(self.acronymsEnum); + return result; +} +@end + @implementation FLTTestMessage + (instancetype)makeWithTestList:(nullable NSArray *)testList { FLTTestMessage *pigeonResult = [[FLTTestMessage alloc] init]; @@ -972,17 +1043,25 @@ - (nullable id)readValueOfType:(UInt8)type { ? nil : [[FLTAnotherEnumBox alloc] initWithValue:[enumAsNumber integerValue]]; } - case 131: - return [FLTUnusedClass fromList:[self readValue]]; + case 131: { + NSNumber *enumAsNumber = [self readValue]; + return enumAsNumber == nil + ? nil + : [[FLTAcronymsEnumBox alloc] initWithValue:[enumAsNumber integerValue]]; + } case 132: - return [FLTAllTypes fromList:[self readValue]]; + return [FLTUnusedClass fromList:[self readValue]]; case 133: - return [FLTAllNullableTypes fromList:[self readValue]]; + return [FLTAllTypes fromList:[self readValue]]; case 134: - return [FLTAllNullableTypesWithoutRecursion fromList:[self readValue]]; + return [FLTAllNullableTypes fromList:[self readValue]]; case 135: - return [FLTAllClassesWrapper fromList:[self readValue]]; + return [FLTAllNullableTypesWithoutRecursion fromList:[self readValue]]; case 136: + return [FLTAllClassesWrapper fromList:[self readValue]]; + case 137: + return [FLTAcronymsAndTestCase fromList:[self readValue]]; + case 138: return [FLTTestMessage fromList:[self readValue]]; default: return [super readValueOfType:type]; @@ -1002,23 +1081,30 @@ - (void)writeValue:(id)value { FLTAnotherEnumBox *box = (FLTAnotherEnumBox *)value; [self writeByte:130]; [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; - } else if ([value isKindOfClass:[FLTUnusedClass class]]) { + } else if ([value isKindOfClass:[FLTAcronymsEnumBox class]]) { + FLTAcronymsEnumBox *box = (FLTAcronymsEnumBox *)value; [self writeByte:131]; + [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; + } else if ([value isKindOfClass:[FLTUnusedClass class]]) { + [self writeByte:132]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTAllTypes class]]) { - [self writeByte:132]; + [self writeByte:133]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTAllNullableTypes class]]) { - [self writeByte:133]; + [self writeByte:134]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTAllNullableTypesWithoutRecursion class]]) { - [self writeByte:134]; + [self writeByte:135]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTAllClassesWrapper class]]) { - [self writeByte:135]; + [self writeByte:136]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FLTAcronymsAndTestCase class]]) { + [self writeByte:137]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTTestMessage class]]) { - [self writeByte:136]; + [self writeByte:138]; [self writeValue:[value toList]]; } else { [super writeValue:value]; @@ -1713,6 +1799,79 @@ void SetUpFLTHostIntegrationCoreApiWithSuffix(id binaryM [channel setMessageHandler:nil]; } } + /// Returns the passed acronyms object. + { + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.pigeon_integration_tests." + @"HostIntegrationCoreApi.echoAcronyms", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:FLTGetCoreTestsCodec()]; + if (api) { + NSCAssert( + [api respondsToSelector:@selector(echoAcronyms:error:)], + @"FLTHostIntegrationCoreApi api (%@) doesn't respond to @selector(echoAcronyms:error:)", + api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + FLTAcronymsAndTestCase *arg_acronyms = GetNullableObjectAtIndex(args, 0); + FlutterError *error; + FLTAcronymsAndTestCase *output = [api echoAcronyms:arg_acronyms error:&error]; + callback(wrapResult(output, error)); + }]; + } else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.pigeon_integration_tests." + @"HostIntegrationCoreApi.hostHTTPResponse", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:FLTGetCoreTestsCodec()]; + if (api) { + NSCAssert([api respondsToSelector:@selector(hostHTTPResponse:error:)], + @"FLTHostIntegrationCoreApi api (%@) doesn't respond to " + @"@selector(hostHTTPResponse:error:)", + api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + FLTAcronymsAndTestCase *arg_acronyms = GetNullableObjectAtIndex(args, 0); + FlutterError *error; + FLTAcronymsAndTestCase *output = [api hostHTTPResponse:arg_acronyms error:&error]; + callback(wrapResult(output, error)); + }]; + } else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.pigeon_integration_tests." + @"HostIntegrationCoreApi.sendJSONParser", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:FLTGetCoreTestsCodec()]; + if (api) { + NSCAssert( + [api respondsToSelector:@selector(sendJSONParser:error:)], + @"FLTHostIntegrationCoreApi api (%@) doesn't respond to @selector(sendJSONParser:error:)", + api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + FLTAcronymsAndTestCase *arg_acronyms = GetNullableObjectAtIndex(args, 0); + FlutterError *error; + FLTAcronymsAndTestCase *output = [api sendJSONParser:arg_acronyms error:&error]; + callback(wrapResult(output, error)); + }]; + } else { + [channel setMessageHandler:nil]; + } + } /// Returns the passed enum to test serialization and deserialization. { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/include/alternate_language_test_plugin/CoreTests.gen.h b/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/include/alternate_language_test_plugin/CoreTests.gen.h index 2b620a11104a..c4dd8c331d86 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/include/alternate_language_test_plugin/CoreTests.gen.h +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/include/alternate_language_test_plugin/CoreTests.gen.h @@ -38,11 +38,23 @@ typedef NS_ENUM(NSUInteger, FLTAnotherEnum) { - (instancetype)initWithValue:(FLTAnotherEnum)value; @end +typedef NS_ENUM(NSUInteger, FLTAcronymsEnum) { + FLTAcronymsEnumHTTPResponse = 0, + FLTAcronymsEnumJSONParser = 1, +}; + +/// Wrapper for FLTAcronymsEnum to allow for nullability. +@interface FLTAcronymsEnumBox : NSObject +@property(nonatomic, assign) FLTAcronymsEnum value; +- (instancetype)initWithValue:(FLTAcronymsEnum)value; +@end + @class FLTUnusedClass; @class FLTAllTypes; @class FLTAllNullableTypes; @class FLTAllNullableTypesWithoutRecursion; @class FLTAllClassesWrapper; +@class FLTAcronymsAndTestCase; @class FLTTestMessage; @interface FLTUnusedClass : NSObject @@ -276,6 +288,19 @@ typedef NS_ENUM(NSUInteger, FLTAnotherEnum) { NSDictionary *nullableClassMap; @end +@interface FLTAcronymsAndTestCase : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithHttpResponse:(NSString *)httpResponse + jsonParser:(NSString *)jsonParser + xmlNode:(NSString *)xmlNode + acronymsEnum:(nullable FLTAcronymsEnumBox *)acronymsEnum; +@property(nonatomic, copy) NSString *httpResponse; +@property(nonatomic, copy) NSString *jsonParser; +@property(nonatomic, copy) NSString *xmlNode; +@property(nonatomic, strong, nullable) FLTAcronymsEnumBox *acronymsEnum; +@end + /// A data class containing a List, used in unit tests. @interface FLTTestMessage : NSObject + (instancetype)makeWithTestList:(nullable NSArray *)testList; @@ -413,6 +438,17 @@ NSObject *FLTGetCoreTestsCodec(void); /// @return `nil` only when `error != nil`. - (nullable FLTAllClassesWrapper *)echoClassWrapper:(FLTAllClassesWrapper *)wrapper error:(FlutterError *_Nullable *_Nonnull)error; +/// Returns the passed acronyms object. +/// +/// @return `nil` only when `error != nil`. +- (nullable FLTAcronymsAndTestCase *)echoAcronyms:(FLTAcronymsAndTestCase *)acronyms + error:(FlutterError *_Nullable *_Nonnull)error; +/// @return `nil` only when `error != nil`. +- (nullable FLTAcronymsAndTestCase *)hostHTTPResponse:(FLTAcronymsAndTestCase *)acronyms + error:(FlutterError *_Nullable *_Nonnull)error; +/// @return `nil` only when `error != nil`. +- (nullable FLTAcronymsAndTestCase *)sendJSONParser:(FLTAcronymsAndTestCase *)acronyms + error:(FlutterError *_Nullable *_Nonnull)error; /// Returns the passed enum to test serialization and deserialization. /// /// @return `nil` only when `error != nil`. 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 9ed43123a701..8ca262c57018 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 @@ -241,6 +241,45 @@ void runPigeonIntegrationTests(TargetGenerator targetGenerator) { expect(classWrapper, receivedClassWrapper); }); + testWidgets('acronyms serialize and deserialize correctly', ( + WidgetTester _, + ) async { + final api = HostIntegrationCoreApi(); + final acronyms = AcronymsAndTestCase( + httpResponse: 'HTTP_RESPONSE', + jsonParser: 'JSON_PARSER', + xmlNode: 'XML_NODE', + ); + final AcronymsAndTestCase received = await api.echoAcronyms(acronyms); + expect(received.httpResponse, acronyms.httpResponse); + expect(received.jsonParser, acronyms.jsonParser); + expect(received.xmlNode, acronyms.xmlNode); + }); + + testWidgets('acronyms methods and enums work correctly', ( + WidgetTester _, + ) async { + final api = HostIntegrationCoreApi(); + final acronyms = AcronymsAndTestCase( + httpResponse: 'HTTP_RESPONSE', + jsonParser: 'JSON_PARSER', + xmlNode: 'XML_NODE', + acronymsEnum: AcronymsEnum.HTTPResponse, + ); + + final AcronymsAndTestCase receivedHttp = await api.hostHTTPResponse( + acronyms, + ); + expect(receivedHttp.httpResponse, acronyms.httpResponse); + expect(receivedHttp.acronymsEnum, acronyms.acronymsEnum); + + final AcronymsAndTestCase receivedJson = await api.sendJSONParser( + acronyms, + ); + expect(receivedJson.jsonParser, acronyms.jsonParser); + expect(receivedJson.acronymsEnum, acronyms.acronymsEnum); + }); + testWidgets('nested null classes can serialize and deserialize correctly', ( WidgetTester _, ) async { 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 482368add83b..cff028bc9aa5 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 @@ -119,6 +119,8 @@ enum AnEnum { one, two, three, fortyTwo, fourHundredTwentyTwo } enum AnotherEnum { justInCase } +enum AcronymsEnum { HTTPResponse, JSONParser } + class UnusedClass { UnusedClass({this.aField}); @@ -885,6 +887,60 @@ class AllClassesWrapper { int get hashCode => _deepHash([runtimeType, ..._toList()]); } +class AcronymsAndTestCase { + AcronymsAndTestCase({ + this.httpResponse = '', + this.jsonParser = '', + this.xmlNode = '', + this.acronymsEnum, + }); + + String httpResponse; + + String jsonParser; + + String xmlNode; + + AcronymsEnum? acronymsEnum; + + List _toList() { + return [httpResponse, jsonParser, xmlNode, acronymsEnum]; + } + + Object encode() { + return _toList(); + } + + static AcronymsAndTestCase decode(Object result) { + result as List; + return AcronymsAndTestCase( + httpResponse: result[0]! as String, + jsonParser: result[1]! as String, + xmlNode: result[2]! as String, + acronymsEnum: result[3] as AcronymsEnum?, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! AcronymsAndTestCase || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(httpResponse, other.httpResponse) && + _deepEquals(jsonParser, other.jsonParser) && + _deepEquals(xmlNode, other.xmlNode) && + _deepEquals(acronymsEnum, other.acronymsEnum); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); +} + /// A data class containing a List, used in unit tests. class TestMessage { TestMessage({this.testList}); @@ -934,23 +990,29 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is AnotherEnum) { buffer.putUint8(130); writeValue(buffer, value.index); - } else if (value is UnusedClass) { + } else if (value is AcronymsEnum) { buffer.putUint8(131); + writeValue(buffer, value.index); + } else if (value is UnusedClass) { + buffer.putUint8(132); writeValue(buffer, value.encode()); } else if (value is AllTypes) { - buffer.putUint8(132); + buffer.putUint8(133); writeValue(buffer, value.encode()); } else if (value is AllNullableTypes) { - buffer.putUint8(133); + buffer.putUint8(134); writeValue(buffer, value.encode()); } else if (value is AllNullableTypesWithoutRecursion) { - buffer.putUint8(134); + buffer.putUint8(135); writeValue(buffer, value.encode()); } else if (value is AllClassesWrapper) { - buffer.putUint8(135); + buffer.putUint8(136); + writeValue(buffer, value.encode()); + } else if (value is AcronymsAndTestCase) { + buffer.putUint8(137); writeValue(buffer, value.encode()); } else if (value is TestMessage) { - buffer.putUint8(136); + buffer.putUint8(138); writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); @@ -967,16 +1029,21 @@ class _PigeonCodec extends StandardMessageCodec { final value = readValue(buffer) as int?; return value == null ? null : AnotherEnum.values[value]; case 131: - return UnusedClass.decode(readValue(buffer)!); + final value = readValue(buffer) as int?; + return value == null ? null : AcronymsEnum.values[value]; case 132: - return AllTypes.decode(readValue(buffer)!); + return UnusedClass.decode(readValue(buffer)!); case 133: - return AllNullableTypes.decode(readValue(buffer)!); + return AllTypes.decode(readValue(buffer)!); case 134: - return AllNullableTypesWithoutRecursion.decode(readValue(buffer)!); + return AllNullableTypes.decode(readValue(buffer)!); case 135: - return AllClassesWrapper.decode(readValue(buffer)!); + return AllNullableTypesWithoutRecursion.decode(readValue(buffer)!); case 136: + return AllClassesWrapper.decode(readValue(buffer)!); + case 137: + return AcronymsAndTestCase.decode(readValue(buffer)!); + case 138: return TestMessage.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1588,6 +1655,74 @@ class HostIntegrationCoreApi { return pigeonVar_replyValue! as AllClassesWrapper; } + /// Returns the passed acronyms object. + Future echoAcronyms(AcronymsAndTestCase acronyms) async { + final pigeonVar_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAcronyms$pigeonVar_messageChannelSuffix'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [acronyms], + ); + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as AcronymsAndTestCase; + } + + Future hostHTTPResponse( + AcronymsAndTestCase acronyms, + ) async { + final pigeonVar_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.hostHTTPResponse$pigeonVar_messageChannelSuffix'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [acronyms], + ); + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as AcronymsAndTestCase; + } + + Future sendJSONParser( + AcronymsAndTestCase acronyms, + ) async { + final pigeonVar_channelName = + 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.sendJSONParser$pigeonVar_messageChannelSuffix'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [acronyms], + ); + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return pigeonVar_replyValue! as AcronymsAndTestCase; + } + /// Returns the passed enum to test serialization and deserialization. Future echoEnum(AnEnum anEnum) async { final pigeonVar_channelName = diff --git a/packages/pigeon/platform_tests/shared_test_plugin_code/test/acronyms_test.dart b/packages/pigeon/platform_tests/shared_test_plugin_code/test/acronyms_test.dart new file mode 100644 index 000000000000..d5baec8c3798 --- /dev/null +++ b/packages/pigeon/platform_tests/shared_test_plugin_code/test/acronyms_test.dart @@ -0,0 +1,114 @@ +// Copyright 2013 The Flutter Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:shared_test_plugin_code/generated.dart'; + +import 'null_safe_test.mocks.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + test('echoAcronyms sends correct message', () async { + final BinaryMessenger mockMessenger = MockBinaryMessenger(); + final completer = Completer(); + + final acronyms = AcronymsAndTestCase( + httpResponse: 'HTTP_RESPONSE', + jsonParser: 'JSON_PARSER', + xmlNode: 'XML_NODE', + ); + + completer.complete( + HostIntegrationCoreApi.pigeonChannelCodec.encodeMessage([ + acronyms, + ]), + ); + final Future sendResult = completer.future; + + when( + mockMessenger.send( + 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAcronyms', + any, + ), + ).thenAnswer((Invocation realInvocation) => sendResult); + + final api = HostIntegrationCoreApi(binaryMessenger: mockMessenger); + final AcronymsAndTestCase received = await api.echoAcronyms(acronyms); + + expect(received, isNotNull); + expect(received.httpResponse, acronyms.httpResponse); + expect(received.jsonParser, acronyms.jsonParser); + expect(received.xmlNode, acronyms.xmlNode); + }); + + test('hostHTTPResponse sends correct message', () async { + final BinaryMessenger mockMessenger = MockBinaryMessenger(); + final completer = Completer(); + + final acronyms = AcronymsAndTestCase( + httpResponse: 'HTTP_RESPONSE', + jsonParser: 'JSON_PARSER', + xmlNode: 'XML_NODE', + acronymsEnum: AcronymsEnum.HTTPResponse, + ); + + completer.complete( + HostIntegrationCoreApi.pigeonChannelCodec.encodeMessage([ + acronyms, + ]), + ); + final Future sendResult = completer.future; + + when( + mockMessenger.send( + 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.hostHTTPResponse', + any, + ), + ).thenAnswer((Invocation realInvocation) => sendResult); + + final api = HostIntegrationCoreApi(binaryMessenger: mockMessenger); + final AcronymsAndTestCase received = await api.hostHTTPResponse(acronyms); + + expect(received, isNotNull); + expect(received.httpResponse, acronyms.httpResponse); + expect(received.acronymsEnum, acronyms.acronymsEnum); + }); + + test('sendJSONParser sends correct message', () async { + final BinaryMessenger mockMessenger = MockBinaryMessenger(); + final completer = Completer(); + + final acronyms = AcronymsAndTestCase( + httpResponse: 'HTTP_RESPONSE', + jsonParser: 'JSON_PARSER', + xmlNode: 'XML_NODE', + acronymsEnum: AcronymsEnum.JSONParser, + ); + + completer.complete( + HostIntegrationCoreApi.pigeonChannelCodec.encodeMessage([ + acronyms, + ]), + ); + final Future sendResult = completer.future; + + when( + mockMessenger.send( + 'dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.sendJSONParser', + any, + ), + ).thenAnswer((Invocation realInvocation) => sendResult); + + final api = HostIntegrationCoreApi(binaryMessenger: mockMessenger); + final AcronymsAndTestCase received = await api.sendJSONParser(acronyms); + + expect(received, isNotNull); + expect(received.jsonParser, acronyms.jsonParser); + expect(received.acronymsEnum, acronyms.acronymsEnum); + }); +} 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 938204b49782..1ec5f61626cd 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 @@ -220,6 +220,17 @@ enum class AnotherEnum(val raw: Int) { } } +enum class AcronymsEnum(val raw: Int) { + HTTP_RESPONSE(0), + JSON_PARSER(1); + + companion object { + fun ofRaw(raw: Int): AcronymsEnum? { + return values().firstOrNull { it.raw == raw } + } + } +} + /** Generated class from Pigeon that represents data sent in messages. */ data class UnusedClass(val aField: Any? = null) { companion object { @@ -959,6 +970,56 @@ data class AllClassesWrapper( } } +/** Generated class from Pigeon that represents data sent in messages. */ +data class AcronymsAndTestCase( + val httpResponse: String, + val jsonParser: String, + val xmlNode: String, + val acronymsEnum: AcronymsEnum? = null +) { + companion object { + fun fromList(pigeonVar_list: List): AcronymsAndTestCase { + val httpResponse = pigeonVar_list[0] as String + val jsonParser = pigeonVar_list[1] as String + val xmlNode = pigeonVar_list[2] as String + val acronymsEnum = pigeonVar_list[3] as AcronymsEnum? + return AcronymsAndTestCase(httpResponse, jsonParser, xmlNode, acronymsEnum) + } + } + + fun toList(): List { + return listOf( + httpResponse, + jsonParser, + xmlNode, + acronymsEnum, + ) + } + + override fun equals(other: Any?): Boolean { + if (other == null || other.javaClass != javaClass) { + return false + } + if (this === other) { + return true + } + val other = other as AcronymsAndTestCase + return CoreTestsPigeonUtils.deepEquals(this.httpResponse, other.httpResponse) && + CoreTestsPigeonUtils.deepEquals(this.jsonParser, other.jsonParser) && + CoreTestsPigeonUtils.deepEquals(this.xmlNode, other.xmlNode) && + CoreTestsPigeonUtils.deepEquals(this.acronymsEnum, other.acronymsEnum) + } + + override fun hashCode(): Int { + var result = javaClass.hashCode() + result = 31 * result + CoreTestsPigeonUtils.deepHash(this.httpResponse) + result = 31 * result + CoreTestsPigeonUtils.deepHash(this.jsonParser) + result = 31 * result + CoreTestsPigeonUtils.deepHash(this.xmlNode) + result = 31 * result + CoreTestsPigeonUtils.deepHash(this.acronymsEnum) + return result + } +} + /** * A data class containing a List, used in unit tests. * @@ -1006,23 +1067,29 @@ private open class CoreTestsPigeonCodec : StandardMessageCodec() { return (readValue(buffer) as Long?)?.let { AnotherEnum.ofRaw(it.toInt()) } } 131.toByte() -> { - return (readValue(buffer) as? List)?.let { UnusedClass.fromList(it) } + return (readValue(buffer) as Long?)?.let { AcronymsEnum.ofRaw(it.toInt()) } } 132.toByte() -> { - return (readValue(buffer) as? List)?.let { AllTypes.fromList(it) } + return (readValue(buffer) as? List)?.let { UnusedClass.fromList(it) } } 133.toByte() -> { - return (readValue(buffer) as? List)?.let { AllNullableTypes.fromList(it) } + return (readValue(buffer) as? List)?.let { AllTypes.fromList(it) } } 134.toByte() -> { + return (readValue(buffer) as? List)?.let { AllNullableTypes.fromList(it) } + } + 135.toByte() -> { return (readValue(buffer) as? List)?.let { AllNullableTypesWithoutRecursion.fromList(it) } } - 135.toByte() -> { + 136.toByte() -> { return (readValue(buffer) as? List)?.let { AllClassesWrapper.fromList(it) } } - 136.toByte() -> { + 137.toByte() -> { + return (readValue(buffer) as? List)?.let { AcronymsAndTestCase.fromList(it) } + } + 138.toByte() -> { return (readValue(buffer) as? List)?.let { TestMessage.fromList(it) } } else -> super.readValueOfType(type, buffer) @@ -1039,28 +1106,36 @@ private open class CoreTestsPigeonCodec : StandardMessageCodec() { stream.write(130) writeValue(stream, value.raw.toLong()) } - is UnusedClass -> { + is AcronymsEnum -> { stream.write(131) + writeValue(stream, value.raw.toLong()) + } + is UnusedClass -> { + stream.write(132) writeValue(stream, value.toList()) } is AllTypes -> { - stream.write(132) + stream.write(133) writeValue(stream, value.toList()) } is AllNullableTypes -> { - stream.write(133) + stream.write(134) writeValue(stream, value.toList()) } is AllNullableTypesWithoutRecursion -> { - stream.write(134) + stream.write(135) writeValue(stream, value.toList()) } is AllClassesWrapper -> { - stream.write(135) + stream.write(136) + writeValue(stream, value.toList()) + } + is AcronymsAndTestCase -> { + stream.write(137) writeValue(stream, value.toList()) } is TestMessage -> { - stream.write(136) + stream.write(138) writeValue(stream, value.toList()) } else -> super.writeValue(stream, value) @@ -1127,6 +1202,12 @@ interface HostIntegrationCoreApi { fun echoNonNullClassMap(classMap: Map): Map /** Returns the passed class to test nested class serialization and deserialization. */ fun echoClassWrapper(wrapper: AllClassesWrapper): AllClassesWrapper + /** Returns the passed acronyms object. */ + fun echoAcronyms(acronyms: AcronymsAndTestCase): AcronymsAndTestCase + + fun hostHTTPResponse(acronyms: AcronymsAndTestCase): AcronymsAndTestCase + + fun sendJSONParser(acronyms: AcronymsAndTestCase): AcronymsAndTestCase /** Returns the passed enum to test serialization and deserialization. */ fun echoEnum(anEnum: AnEnum): AnEnum /** Returns the passed enum to test serialization and deserialization. */ @@ -2125,6 +2206,72 @@ interface HostIntegrationCoreApi { channel.setMessageHandler(null) } } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAcronyms$separatedMessageChannelSuffix", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val acronymsArg = args[0] as AcronymsAndTestCase + val wrapped: List = + try { + listOf(api.echoAcronyms(acronymsArg)) + } catch (exception: Throwable) { + CoreTestsPigeonUtils.wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.hostHTTPResponse$separatedMessageChannelSuffix", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val acronymsArg = args[0] as AcronymsAndTestCase + val wrapped: List = + try { + listOf(api.hostHTTPResponse(acronymsArg)) + } catch (exception: Throwable) { + CoreTestsPigeonUtils.wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.sendJSONParser$separatedMessageChannelSuffix", + codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val acronymsArg = args[0] as AcronymsAndTestCase + val wrapped: List = + try { + listOf(api.sendJSONParser(acronymsArg)) + } catch (exception: Throwable) { + CoreTestsPigeonUtils.wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } run { val channel = BasicMessageChannel( 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 ea402e91d7a4..396c76af83af 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 @@ -173,6 +173,38 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { return wrapper } + override fun echoAcronyms(acronyms: AcronymsAndTestCase): AcronymsAndTestCase { + return acronyms + } + + // This uses a when statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. + override fun hostHTTPResponse(acronyms: AcronymsAndTestCase): AcronymsAndTestCase { + val enumVal = when (acronyms.acronymsEnum) { + AcronymsEnum.HTTP_RESPONSE -> AcronymsEnum.HTTP_RESPONSE + AcronymsEnum.JSON_PARSER -> AcronymsEnum.JSON_PARSER + null -> null + } + return AcronymsAndTestCase( + httpResponse = acronyms.httpResponse, + jsonParser = acronyms.jsonParser, + xmlNode = acronyms.xmlNode, + acronymsEnum = enumVal) + } + + // This uses a when statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. + override fun sendJSONParser(acronyms: AcronymsAndTestCase): AcronymsAndTestCase { + val enumVal = when (acronyms.acronymsEnum) { + AcronymsEnum.HTTP_RESPONSE -> AcronymsEnum.HTTP_RESPONSE + AcronymsEnum.JSON_PARSER -> AcronymsEnum.JSON_PARSER + null -> null + } + return AcronymsAndTestCase( + httpResponse = acronyms.httpResponse, + jsonParser = acronyms.jsonParser, + xmlNode = acronyms.xmlNode, + acronymsEnum = enumVal) + } + override fun echoEnum(anEnum: AnEnum): AnEnum { return anEnum } diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift index 606d58783837..d672845b1067 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift @@ -15,24 +15,6 @@ import Foundation #error("Unsupported platform.") #endif -/// Error class for passing custom error details to Dart side. -final class PigeonError: Error { - let code: String - let message: String? - let details: Sendable? - - init(code: String, message: String?, details: Sendable?) { - self.code = code - self.message = message - self.details = details - } - - var localizedDescription: String { - return - "PigeonError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" - } -} - private func wrapResult(_ result: Any?) -> [Any?] { return [result] } @@ -183,6 +165,24 @@ func deepHashCoreTests(value: Any?, hasher: inout Hasher) { } } +/// Error class for passing custom error details to Dart side. +final class PigeonError: Error { + let code: String + let message: String? + let details: Sendable? + + init(code: String, message: String?, details: Sendable?) { + self.code = code + self.message = message + self.details = details + } + + var localizedDescription: String { + return + "PigeonError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" + } +} + enum AnEnum: Int { case one = 0 case two = 1 @@ -195,6 +195,11 @@ enum AnotherEnum: Int { case justInCase = 0 } +enum AcronymsEnum: Int { + case hTTPResponse = 0 + case jSONParser = 1 +} + /// Generated class from Pigeon that represents data sent in messages. struct UnusedClass: Hashable { var aField: Any? = nil @@ -967,6 +972,54 @@ struct AllClassesWrapper: Hashable { } } +/// Generated class from Pigeon that represents data sent in messages. +struct AcronymsAndTestCase: Hashable { + var httpResponse: String + var jsonParser: String + var xmlNode: String + var acronymsEnum: AcronymsEnum? = nil + + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ pigeonVar_list: [Any?]) -> AcronymsAndTestCase? { + let httpResponse = pigeonVar_list[0] as! String + let jsonParser = pigeonVar_list[1] as! String + let xmlNode = pigeonVar_list[2] as! String + let acronymsEnum: AcronymsEnum? = nilOrValue(pigeonVar_list[3]) + + return AcronymsAndTestCase( + httpResponse: httpResponse, + jsonParser: jsonParser, + xmlNode: xmlNode, + acronymsEnum: acronymsEnum + ) + } + func toList() -> [Any?] { + return [ + httpResponse, + jsonParser, + xmlNode, + acronymsEnum, + ] + } + static func == (lhs: AcronymsAndTestCase, rhs: AcronymsAndTestCase) -> Bool { + if Swift.type(of: lhs) != Swift.type(of: rhs) { + return false + } + return deepEqualsCoreTests(lhs.httpResponse, rhs.httpResponse) + && deepEqualsCoreTests(lhs.jsonParser, rhs.jsonParser) + && deepEqualsCoreTests(lhs.xmlNode, rhs.xmlNode) + && deepEqualsCoreTests(lhs.acronymsEnum, rhs.acronymsEnum) + } + + func hash(into hasher: inout Hasher) { + hasher.combine("AcronymsAndTestCase") + deepHashCoreTests(value: httpResponse, hasher: &hasher) + deepHashCoreTests(value: jsonParser, hasher: &hasher) + deepHashCoreTests(value: xmlNode, hasher: &hasher) + deepHashCoreTests(value: acronymsEnum, hasher: &hasher) + } +} + /// A data class containing a List, used in unit tests. /// /// Generated class from Pigeon that represents data sent in messages. @@ -1015,16 +1068,24 @@ private class CoreTestsPigeonCodecReader: FlutterStandardReader { } return nil case 131: - return UnusedClass.fromList(self.readValue() as! [Any?]) + let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) + if let enumResultAsInt = enumResultAsInt { + return AcronymsEnum(rawValue: enumResultAsInt) + } + return nil case 132: - return AllTypes.fromList(self.readValue() as! [Any?]) + return UnusedClass.fromList(self.readValue() as! [Any?]) case 133: - return AllNullableTypes.fromList(self.readValue() as! [Any?]) + return AllTypes.fromList(self.readValue() as! [Any?]) case 134: - return AllNullableTypesWithoutRecursion.fromList(self.readValue() as! [Any?]) + return AllNullableTypes.fromList(self.readValue() as! [Any?]) case 135: - return AllClassesWrapper.fromList(self.readValue() as! [Any?]) + return AllNullableTypesWithoutRecursion.fromList(self.readValue() as! [Any?]) case 136: + return AllClassesWrapper.fromList(self.readValue() as! [Any?]) + case 137: + return AcronymsAndTestCase.fromList(self.readValue() as! [Any?]) + case 138: return TestMessage.fromList(self.readValue() as! [Any?]) default: return super.readValue(ofType: type) @@ -1040,23 +1101,29 @@ private class CoreTestsPigeonCodecWriter: FlutterStandardWriter { } else if let value = value as? AnotherEnum { super.writeByte(130) super.writeValue(value.rawValue) - } else if let value = value as? UnusedClass { + } else if let value = value as? AcronymsEnum { super.writeByte(131) + super.writeValue(value.rawValue) + } else if let value = value as? UnusedClass { + super.writeByte(132) super.writeValue(value.toList()) } else if let value = value as? AllTypes { - super.writeByte(132) + super.writeByte(133) super.writeValue(value.toList()) } else if let value = value as? AllNullableTypes { - super.writeByte(133) + super.writeByte(134) super.writeValue(value.toList()) } else if let value = value as? AllNullableTypesWithoutRecursion { - super.writeByte(134) + super.writeByte(135) super.writeValue(value.toList()) } else if let value = value as? AllClassesWrapper { - super.writeByte(135) + super.writeByte(136) + super.writeValue(value.toList()) + } else if let value = value as? AcronymsAndTestCase { + super.writeByte(137) super.writeValue(value.toList()) } else if let value = value as? TestMessage { - super.writeByte(136) + super.writeByte(138) super.writeValue(value.toList()) } else { super.writeValue(value) @@ -1136,6 +1203,10 @@ protocol HostIntegrationCoreApi { func echoNonNull(classMap: [Int64: AllNullableTypes]) throws -> [Int64: AllNullableTypes] /// Returns the passed class to test nested class serialization and deserialization. func echo(_ wrapper: AllClassesWrapper) throws -> AllClassesWrapper + /// Returns the passed acronyms object. + func echo(_ acronyms: AcronymsAndTestCase) throws -> AcronymsAndTestCase + func hostHTTPResponse(_ acronyms: AcronymsAndTestCase) throws -> AcronymsAndTestCase + func sendJSONParser(_ acronyms: AcronymsAndTestCase) throws -> AcronymsAndTestCase /// Returns the passed enum to test serialization and deserialization. func echo(_ anEnum: AnEnum) throws -> AnEnum /// Returns the passed enum to test serialization and deserialization. @@ -1950,6 +2021,61 @@ class HostIntegrationCoreApiSetup { } else { echoClassWrapperChannel.setMessageHandler(nil) } + /// Returns the passed acronyms object. + let echoAcronymsChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAcronyms\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + echoAcronymsChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let acronymsArg = args[0] as! AcronymsAndTestCase + do { + let result = try api.echo(acronymsArg) + reply(wrapResult(result)) + } catch { + reply(wrapError(error)) + } + } + } else { + echoAcronymsChannel.setMessageHandler(nil) + } + let hostHTTPResponseChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.hostHTTPResponse\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + hostHTTPResponseChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let acronymsArg = args[0] as! AcronymsAndTestCase + do { + let result = try api.hostHTTPResponse(acronymsArg) + reply(wrapResult(result)) + } catch { + reply(wrapError(error)) + } + } + } else { + hostHTTPResponseChannel.setMessageHandler(nil) + } + let sendJSONParserChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.sendJSONParser\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + sendJSONParserChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let acronymsArg = args[0] as! AcronymsAndTestCase + do { + let result = try api.sendJSONParser(acronymsArg) + reply(wrapResult(result)) + } catch { + reply(wrapError(error)) + } + } + } else { + sendJSONParserChannel.setMessageHandler(nil) + } /// Returns the passed enum to test serialization and deserialization. let echoEnumChannel = FlutterBasicMessageChannel( name: diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/EventChannelTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/EventChannelTests.gen.swift index da3e19626382..93a2006b0624 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/EventChannelTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/EventChannelTests.gen.swift @@ -15,24 +15,6 @@ import Foundation #error("Unsupported platform.") #endif -/// Error class for passing custom error details to Dart side. -final class EventChannelTestsError: Error { - let code: String - let message: String? - let details: Sendable? - - init(code: String, message: String?, details: Sendable?) { - self.code = code - self.message = message - self.details = details - } - - var localizedDescription: String { - return - "EventChannelTestsError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" - } -} - private func isNullish(_ value: Any?) -> Bool { return value is NSNull || value == nil } @@ -151,6 +133,24 @@ func deepHashEventChannelTests(value: Any?, hasher: inout Hasher) { } } +/// Error class for passing custom error details to Dart side. +final class EventChannelTestsError: Error { + let code: String + let message: String? + let details: Sendable? + + init(code: String, message: String?, details: Sendable?) { + self.code = code + self.message = message + self.details = details + } + + var localizedDescription: String { + return + "EventChannelTestsError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" + } +} + enum EventEnum: Int { case one = 0 case two = 1 diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift index 5eb4b81803ad..d0a4af42234b 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift @@ -15,24 +15,6 @@ import Foundation #error("Unsupported platform.") #endif -/// Error class for passing custom error details to Dart side. -final class ProxyApiTestsError: Error { - let code: String - let message: String? - let details: Sendable? - - init(code: String, message: String?, details: Sendable?) { - self.code = code - self.message = message - self.details = details - } - - var localizedDescription: String { - return - "ProxyApiTestsError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" - } -} - private func wrapResult(_ result: Any?) -> [Any?] { return [result] } @@ -74,6 +56,23 @@ private func nilOrValue(_ value: Any?) -> T? { return value as! T? } +/// Error class for passing custom error details to Dart side. +final class ProxyApiTestsError: Error { + let code: String + let message: String? + let details: Sendable? + + init(code: String, message: String?, details: Sendable?) { + self.code = code + self.message = message + self.details = details + } + + var localizedDescription: String { + return + "ProxyApiTestsError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" + } +} /// Handles the callback when an object is deallocated. protocol ProxyApiTestsPigeonInternalFinalizerDelegate: AnyObject { /// Invoked when the strong reference of an object is deallocated in an `InstanceManager`. diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/TestPlugin.swift index 89d25d32f58e..fc1b17657f83 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/TestPlugin.swift @@ -188,6 +188,44 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { return wrapper } + func echo(_ acronyms: AcronymsAndTestCase) throws -> AcronymsAndTestCase { + return acronyms + } + + // This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. + func hostHTTPResponse(_ acronyms: AcronymsAndTestCase) throws -> AcronymsAndTestCase { + let enumVal: AcronymsEnum + switch acronyms.acronymsEnum { + case .httpResponse: + enumVal = .httpResponse + case .jsonParser: + enumVal = .jsonParser + } + return AcronymsAndTestCase( + httpResponse: acronyms.httpResponse, + jsonParser: acronyms.jsonParser, + xmlNode: acronyms.xmlNode, + acronymsEnum: enumVal + ) + } + + // This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. + func sendJSONParser(_ acronyms: AcronymsAndTestCase) throws -> AcronymsAndTestCase { + let enumVal: AcronymsEnum + switch acronyms.acronymsEnum { + case .httpResponse: + enumVal = .httpResponse + case .jsonParser: + enumVal = .jsonParser + } + return AcronymsAndTestCase( + httpResponse: acronyms.httpResponse, + jsonParser: acronyms.jsonParser, + xmlNode: acronyms.xmlNode, + acronymsEnum: enumVal + ) + } + func echo(_ anEnum: AnEnum) throws -> AnEnum { return anEnum } diff --git a/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.cc b/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.cc index 023cd1ed85db..2f33470c9120 100644 --- a/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.cc +++ b/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.cc @@ -3315,6 +3315,170 @@ guint core_tests_pigeon_test_all_classes_wrapper_hash( return result; } +struct _CoreTestsPigeonTestAcronymsAndTestCase { + GObject parent_instance; + + gchar* http_response; + gchar* json_parser; + gchar* xml_node; + CoreTestsPigeonTestAcronymsEnum* acronyms_enum; +}; + +G_DEFINE_TYPE(CoreTestsPigeonTestAcronymsAndTestCase, + core_tests_pigeon_test_acronyms_and_test_case, G_TYPE_OBJECT) + +static void core_tests_pigeon_test_acronyms_and_test_case_dispose( + GObject* object) { + CoreTestsPigeonTestAcronymsAndTestCase* self = + CORE_TESTS_PIGEON_TEST_ACRONYMS_AND_TEST_CASE(object); + g_clear_pointer(&self->http_response, g_free); + g_clear_pointer(&self->json_parser, g_free); + g_clear_pointer(&self->xml_node, g_free); + g_clear_pointer(&self->acronyms_enum, g_free); + G_OBJECT_CLASS(core_tests_pigeon_test_acronyms_and_test_case_parent_class) + ->dispose(object); +} + +static void core_tests_pigeon_test_acronyms_and_test_case_init( + CoreTestsPigeonTestAcronymsAndTestCase* self) {} + +static void core_tests_pigeon_test_acronyms_and_test_case_class_init( + CoreTestsPigeonTestAcronymsAndTestCaseClass* klass) { + G_OBJECT_CLASS(klass)->dispose = + core_tests_pigeon_test_acronyms_and_test_case_dispose; +} + +CoreTestsPigeonTestAcronymsAndTestCase* +core_tests_pigeon_test_acronyms_and_test_case_new( + const gchar* http_response, const gchar* json_parser, const gchar* xml_node, + CoreTestsPigeonTestAcronymsEnum* acronyms_enum) { + CoreTestsPigeonTestAcronymsAndTestCase* self = + CORE_TESTS_PIGEON_TEST_ACRONYMS_AND_TEST_CASE(g_object_new( + core_tests_pigeon_test_acronyms_and_test_case_get_type(), nullptr)); + self->http_response = g_strdup(http_response); + self->json_parser = g_strdup(json_parser); + self->xml_node = g_strdup(xml_node); + if (acronyms_enum != nullptr) { + self->acronyms_enum = static_cast( + malloc(sizeof(CoreTestsPigeonTestAcronymsEnum))); + *self->acronyms_enum = *acronyms_enum; + } else { + self->acronyms_enum = nullptr; + } + return self; +} + +const gchar* core_tests_pigeon_test_acronyms_and_test_case_get_http_response( + CoreTestsPigeonTestAcronymsAndTestCase* self) { + g_return_val_if_fail(CORE_TESTS_PIGEON_TEST_IS_ACRONYMS_AND_TEST_CASE(self), + nullptr); + return self->http_response; +} + +const gchar* core_tests_pigeon_test_acronyms_and_test_case_get_json_parser( + CoreTestsPigeonTestAcronymsAndTestCase* self) { + g_return_val_if_fail(CORE_TESTS_PIGEON_TEST_IS_ACRONYMS_AND_TEST_CASE(self), + nullptr); + return self->json_parser; +} + +const gchar* core_tests_pigeon_test_acronyms_and_test_case_get_xml_node( + CoreTestsPigeonTestAcronymsAndTestCase* self) { + g_return_val_if_fail(CORE_TESTS_PIGEON_TEST_IS_ACRONYMS_AND_TEST_CASE(self), + nullptr); + return self->xml_node; +} + +CoreTestsPigeonTestAcronymsEnum* +core_tests_pigeon_test_acronyms_and_test_case_get_acronyms_enum( + CoreTestsPigeonTestAcronymsAndTestCase* self) { + g_return_val_if_fail(CORE_TESTS_PIGEON_TEST_IS_ACRONYMS_AND_TEST_CASE(self), + nullptr); + return self->acronyms_enum; +} + +static FlValue* core_tests_pigeon_test_acronyms_and_test_case_to_list( + CoreTestsPigeonTestAcronymsAndTestCase* self) { + FlValue* values = fl_value_new_list(); + fl_value_append_take(values, fl_value_new_string(self->http_response)); + fl_value_append_take(values, fl_value_new_string(self->json_parser)); + fl_value_append_take(values, fl_value_new_string(self->xml_node)); + fl_value_append_take( + values, + self->acronyms_enum != nullptr + ? fl_value_new_custom(core_tests_pigeon_test_acronyms_enum_type_id, + fl_value_new_int(*self->acronyms_enum), + (GDestroyNotify)fl_value_unref) + : fl_value_new_null()); + return values; +} + +static CoreTestsPigeonTestAcronymsAndTestCase* +core_tests_pigeon_test_acronyms_and_test_case_new_from_list(FlValue* values) { + FlValue* value0 = fl_value_get_list_value(values, 0); + const gchar* http_response = fl_value_get_string(value0); + FlValue* value1 = fl_value_get_list_value(values, 1); + const gchar* json_parser = fl_value_get_string(value1); + FlValue* value2 = fl_value_get_list_value(values, 2); + const gchar* xml_node = fl_value_get_string(value2); + FlValue* value3 = fl_value_get_list_value(values, 3); + CoreTestsPigeonTestAcronymsEnum* acronyms_enum = nullptr; + CoreTestsPigeonTestAcronymsEnum acronyms_enum_value; + if (fl_value_get_type(value3) != FL_VALUE_TYPE_NULL) { + acronyms_enum_value = static_cast( + fl_value_get_int(reinterpret_cast( + const_cast(fl_value_get_custom_value(value3))))); + acronyms_enum = &acronyms_enum_value; + } + return core_tests_pigeon_test_acronyms_and_test_case_new( + http_response, json_parser, xml_node, acronyms_enum); +} + +gboolean core_tests_pigeon_test_acronyms_and_test_case_equals( + CoreTestsPigeonTestAcronymsAndTestCase* a, + CoreTestsPigeonTestAcronymsAndTestCase* b) { + if (a == b) { + return TRUE; + } + if (a == nullptr || b == nullptr) { + return FALSE; + } + if (g_strcmp0(a->http_response, b->http_response) != 0) { + return FALSE; + } + if (g_strcmp0(a->json_parser, b->json_parser) != 0) { + return FALSE; + } + if (g_strcmp0(a->xml_node, b->xml_node) != 0) { + return FALSE; + } + if ((a->acronyms_enum == nullptr) != (b->acronyms_enum == nullptr)) { + return FALSE; + } + if (a->acronyms_enum != nullptr && *a->acronyms_enum != *b->acronyms_enum) { + return FALSE; + } + return TRUE; +} + +guint core_tests_pigeon_test_acronyms_and_test_case_hash( + CoreTestsPigeonTestAcronymsAndTestCase* self) { + g_return_val_if_fail(CORE_TESTS_PIGEON_TEST_IS_ACRONYMS_AND_TEST_CASE(self), + 0); + guint result = 0; + result = + result * 31 + + (self->http_response != nullptr ? g_str_hash(self->http_response) : 0); + result = result * 31 + + (self->json_parser != nullptr ? g_str_hash(self->json_parser) : 0); + result = result * 31 + + (self->xml_node != nullptr ? g_str_hash(self->xml_node) : 0); + result = result * 31 + (self->acronyms_enum != nullptr + ? static_cast(*self->acronyms_enum) + : 0); + return result; +} + struct _CoreTestsPigeonTestTestMessage { GObject parent_instance; @@ -3409,13 +3573,15 @@ G_DEFINE_TYPE(CoreTestsPigeonTestMessageCodec, const int core_tests_pigeon_test_an_enum_type_id = 129; const int core_tests_pigeon_test_another_enum_type_id = 130; -const int core_tests_pigeon_test_unused_class_type_id = 131; -const int core_tests_pigeon_test_all_types_type_id = 132; -const int core_tests_pigeon_test_all_nullable_types_type_id = 133; +const int core_tests_pigeon_test_acronyms_enum_type_id = 131; +const int core_tests_pigeon_test_unused_class_type_id = 132; +const int core_tests_pigeon_test_all_types_type_id = 133; +const int core_tests_pigeon_test_all_nullable_types_type_id = 134; const int core_tests_pigeon_test_all_nullable_types_without_recursion_type_id = - 134; -const int core_tests_pigeon_test_all_classes_wrapper_type_id = 135; -const int core_tests_pigeon_test_test_message_type_id = 136; + 135; +const int core_tests_pigeon_test_all_classes_wrapper_type_id = 136; +const int core_tests_pigeon_test_acronyms_and_test_case_type_id = 137; +const int core_tests_pigeon_test_test_message_type_id = 138; static gboolean core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_an_enum( @@ -3435,6 +3601,15 @@ core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_another_enum( return fl_standard_message_codec_write_value(codec, buffer, value, error); } +static gboolean +core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_acronyms_enum( + FlStandardMessageCodec* codec, GByteArray* buffer, FlValue* value, + GError** error) { + uint8_t type = core_tests_pigeon_test_acronyms_enum_type_id; + g_byte_array_append(buffer, &type, sizeof(uint8_t)); + return fl_standard_message_codec_write_value(codec, buffer, value, error); +} + static gboolean core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_unused_class( FlStandardMessageCodec* codec, GByteArray* buffer, @@ -3492,6 +3667,17 @@ core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_all_classes_wr return fl_standard_message_codec_write_value(codec, buffer, values, error); } +static gboolean +core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_acronyms_and_test_case( + FlStandardMessageCodec* codec, GByteArray* buffer, + CoreTestsPigeonTestAcronymsAndTestCase* value, GError** error) { + uint8_t type = core_tests_pigeon_test_acronyms_and_test_case_type_id; + g_byte_array_append(buffer, &type, sizeof(uint8_t)); + g_autoptr(FlValue) values = + core_tests_pigeon_test_acronyms_and_test_case_to_list(value); + return fl_standard_message_codec_write_value(codec, buffer, values, error); +} + static gboolean core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_test_message( FlStandardMessageCodec* codec, GByteArray* buffer, @@ -3520,6 +3706,12 @@ static gboolean core_tests_pigeon_test_message_codec_write_value( reinterpret_cast( const_cast(fl_value_get_custom_value(value))), error); + case core_tests_pigeon_test_acronyms_enum_type_id: + return core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_acronyms_enum( + codec, buffer, + reinterpret_cast( + const_cast(fl_value_get_custom_value(value))), + error); case core_tests_pigeon_test_unused_class_type_id: return core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_unused_class( codec, buffer, @@ -3550,6 +3742,12 @@ static gboolean core_tests_pigeon_test_message_codec_write_value( CORE_TESTS_PIGEON_TEST_ALL_CLASSES_WRAPPER( fl_value_get_custom_value_object(value)), error); + case core_tests_pigeon_test_acronyms_and_test_case_type_id: + return core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_acronyms_and_test_case( + codec, buffer, + CORE_TESTS_PIGEON_TEST_ACRONYMS_AND_TEST_CASE( + fl_value_get_custom_value_object(value)), + error); case core_tests_pigeon_test_test_message_type_id: return core_tests_pigeon_test_message_codec_write_core_tests_pigeon_test_test_message( codec, buffer, @@ -3584,6 +3782,16 @@ core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_another_enum( (GDestroyNotify)fl_value_unref); } +static FlValue* +core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_acronyms_enum( + FlStandardMessageCodec* codec, GBytes* buffer, size_t* offset, + GError** error) { + return fl_value_new_custom( + core_tests_pigeon_test_acronyms_enum_type_id, + fl_standard_message_codec_read_value(codec, buffer, offset, error), + (GDestroyNotify)fl_value_unref); +} + static FlValue* core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_unused_class( FlStandardMessageCodec* codec, GBytes* buffer, size_t* offset, @@ -3696,6 +3904,28 @@ core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_all_classes_wra core_tests_pigeon_test_all_classes_wrapper_type_id, G_OBJECT(value)); } +static FlValue* +core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_acronyms_and_test_case( + FlStandardMessageCodec* codec, GBytes* buffer, size_t* offset, + GError** error) { + g_autoptr(FlValue) values = + fl_standard_message_codec_read_value(codec, buffer, offset, error); + if (values == nullptr) { + return nullptr; + } + + g_autoptr(CoreTestsPigeonTestAcronymsAndTestCase) value = + core_tests_pigeon_test_acronyms_and_test_case_new_from_list(values); + if (value == nullptr) { + g_set_error(error, FL_MESSAGE_CODEC_ERROR, FL_MESSAGE_CODEC_ERROR_FAILED, + "Invalid data received for MessageData"); + return nullptr; + } + + return fl_value_new_custom_object( + core_tests_pigeon_test_acronyms_and_test_case_type_id, G_OBJECT(value)); +} + static FlValue* core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_test_message( FlStandardMessageCodec* codec, GBytes* buffer, size_t* offset, @@ -3728,6 +3958,9 @@ static FlValue* core_tests_pigeon_test_message_codec_read_value_of_type( case core_tests_pigeon_test_another_enum_type_id: return core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_another_enum( codec, buffer, offset, error); + case core_tests_pigeon_test_acronyms_enum_type_id: + return core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_acronyms_enum( + codec, buffer, offset, error); case core_tests_pigeon_test_unused_class_type_id: return core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_unused_class( codec, buffer, offset, error); @@ -3743,6 +3976,9 @@ static FlValue* core_tests_pigeon_test_message_codec_read_value_of_type( case core_tests_pigeon_test_all_classes_wrapper_type_id: return core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_all_classes_wrapper( codec, buffer, offset, error); + case core_tests_pigeon_test_acronyms_and_test_case_type_id: + return core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_acronyms_and_test_case( + codec, buffer, offset, error); case core_tests_pigeon_test_test_message_type_id: return core_tests_pigeon_test_message_codec_read_core_tests_pigeon_test_test_message( codec, buffer, offset, error); @@ -5497,6 +5733,209 @@ core_tests_pigeon_test_host_integration_core_api_echo_class_wrapper_response_new return self; } +struct _CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse { + GObject parent_instance; + + FlValue* value; +}; + +G_DEFINE_TYPE( + CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse, + core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response, + G_TYPE_OBJECT) + +static void +core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_dispose( + GObject* object) { + CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API_ECHO_ACRONYMS_RESPONSE( + object); + g_clear_pointer(&self->value, fl_value_unref); + G_OBJECT_CLASS( + core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_parent_class) + ->dispose(object); +} + +static void +core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_init( + CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse* self) {} + +static void +core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_class_init( + CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponseClass* klass) { + G_OBJECT_CLASS(klass)->dispose = + core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_dispose; +} + +CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse* +core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_new( + CoreTestsPigeonTestAcronymsAndTestCase* return_value) { + CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API_ECHO_ACRONYMS_RESPONSE( + g_object_new( + core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_get_type(), + nullptr)); + self->value = fl_value_new_list(); + fl_value_append_take( + self->value, fl_value_new_custom_object( + core_tests_pigeon_test_acronyms_and_test_case_type_id, + G_OBJECT(return_value))); + return self; +} + +CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse* +core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_new_error( + const gchar* code, const gchar* message, FlValue* details) { + CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API_ECHO_ACRONYMS_RESPONSE( + g_object_new( + core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_get_type(), + nullptr)); + self->value = fl_value_new_list(); + fl_value_append_take(self->value, fl_value_new_string(code)); + fl_value_append_take(self->value, + fl_value_new_string(message != nullptr ? message : "")); + fl_value_append_take(self->value, details != nullptr ? fl_value_ref(details) + : fl_value_new_null()); + return self; +} + +struct _CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse { + GObject parent_instance; + + FlValue* value; +}; + +G_DEFINE_TYPE( + CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse, + core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response, + G_TYPE_OBJECT) + +static void +core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_dispose( + GObject* object) { + CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API_HOST_H_T_T_P_RESPONSE_RESPONSE( + object); + g_clear_pointer(&self->value, fl_value_unref); + G_OBJECT_CLASS( + core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_parent_class) + ->dispose(object); +} + +static void +core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_init( + CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* self) {} + +static void +core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_class_init( + CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponseClass* + klass) { + G_OBJECT_CLASS(klass)->dispose = + core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_dispose; +} + +CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* +core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_new( + CoreTestsPigeonTestAcronymsAndTestCase* return_value) { + CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API_HOST_H_T_T_P_RESPONSE_RESPONSE( + g_object_new( + core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_get_type(), + nullptr)); + self->value = fl_value_new_list(); + fl_value_append_take( + self->value, fl_value_new_custom_object( + core_tests_pigeon_test_acronyms_and_test_case_type_id, + G_OBJECT(return_value))); + return self; +} + +CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* +core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_new_error( + const gchar* code, const gchar* message, FlValue* details) { + CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API_HOST_H_T_T_P_RESPONSE_RESPONSE( + g_object_new( + core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_get_type(), + nullptr)); + self->value = fl_value_new_list(); + fl_value_append_take(self->value, fl_value_new_string(code)); + fl_value_append_take(self->value, + fl_value_new_string(message != nullptr ? message : "")); + fl_value_append_take(self->value, details != nullptr ? fl_value_ref(details) + : fl_value_new_null()); + return self; +} + +struct _CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse { + GObject parent_instance; + + FlValue* value; +}; + +G_DEFINE_TYPE( + CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse, + core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response, + G_TYPE_OBJECT) + +static void +core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_dispose( + GObject* object) { + CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API_SEND_J_S_O_N_PARSER_RESPONSE( + object); + g_clear_pointer(&self->value, fl_value_unref); + G_OBJECT_CLASS( + core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_parent_class) + ->dispose(object); +} + +static void +core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_init( + CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* self) {} + +static void +core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_class_init( + CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponseClass* + klass) { + G_OBJECT_CLASS(klass)->dispose = + core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_dispose; +} + +CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* +core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_new( + CoreTestsPigeonTestAcronymsAndTestCase* return_value) { + CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API_SEND_J_S_O_N_PARSER_RESPONSE( + g_object_new( + core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_get_type(), + nullptr)); + self->value = fl_value_new_list(); + fl_value_append_take( + self->value, fl_value_new_custom_object( + core_tests_pigeon_test_acronyms_and_test_case_type_id, + G_OBJECT(return_value))); + return self; +} + +CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* +core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_new_error( + const gchar* code, const gchar* message, FlValue* details) { + CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API_SEND_J_S_O_N_PARSER_RESPONSE( + g_object_new( + core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_get_type(), + nullptr)); + self->value = fl_value_new_list(); + fl_value_append_take(self->value, fl_value_new_string(code)); + fl_value_append_take(self->value, + fl_value_new_string(message != nullptr ? message : "")); + fl_value_append_take(self->value, details != nullptr ? fl_value_ref(details) + : fl_value_new_null()); + return self; +} + struct _CoreTestsPigeonTestHostIntegrationCoreApiEchoEnumResponse { GObject parent_instance; @@ -15763,6 +16202,99 @@ core_tests_pigeon_test_host_integration_core_api_echo_class_wrapper_cb( } } +static void core_tests_pigeon_test_host_integration_core_api_echo_acronyms_cb( + FlBasicMessageChannel* channel, FlValue* message_, + FlBasicMessageChannelResponseHandle* response_handle, gpointer user_data) { + CoreTestsPigeonTestHostIntegrationCoreApi* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API(user_data); + + if (self->vtable == nullptr || self->vtable->echo_acronyms == nullptr) { + return; + } + + FlValue* value0 = fl_value_get_list_value(message_, 0); + CoreTestsPigeonTestAcronymsAndTestCase* acronyms = + CORE_TESTS_PIGEON_TEST_ACRONYMS_AND_TEST_CASE( + fl_value_get_custom_value_object(value0)); + g_autoptr(CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse) + response = self->vtable->echo_acronyms(acronyms, self->user_data); + if (response == nullptr) { + g_warning("No response returned to %s.%s", "HostIntegrationCoreApi", + "echoAcronyms"); + return; + } + + g_autoptr(GError) error = NULL; + if (!fl_basic_message_channel_respond(channel, response_handle, + response->value, &error)) { + g_warning("Failed to send response to %s.%s: %s", "HostIntegrationCoreApi", + "echoAcronyms", error->message); + } +} + +static void +core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_cb( + FlBasicMessageChannel* channel, FlValue* message_, + FlBasicMessageChannelResponseHandle* response_handle, gpointer user_data) { + CoreTestsPigeonTestHostIntegrationCoreApi* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API(user_data); + + if (self->vtable == nullptr || + self->vtable->host_h_t_t_p_response == nullptr) { + return; + } + + FlValue* value0 = fl_value_get_list_value(message_, 0); + CoreTestsPigeonTestAcronymsAndTestCase* acronyms = + CORE_TESTS_PIGEON_TEST_ACRONYMS_AND_TEST_CASE( + fl_value_get_custom_value_object(value0)); + g_autoptr(CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse) + response = self->vtable->host_h_t_t_p_response(acronyms, self->user_data); + if (response == nullptr) { + g_warning("No response returned to %s.%s", "HostIntegrationCoreApi", + "hostHTTPResponse"); + return; + } + + g_autoptr(GError) error = NULL; + if (!fl_basic_message_channel_respond(channel, response_handle, + response->value, &error)) { + g_warning("Failed to send response to %s.%s: %s", "HostIntegrationCoreApi", + "hostHTTPResponse", error->message); + } +} + +static void +core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_cb( + FlBasicMessageChannel* channel, FlValue* message_, + FlBasicMessageChannelResponseHandle* response_handle, gpointer user_data) { + CoreTestsPigeonTestHostIntegrationCoreApi* self = + CORE_TESTS_PIGEON_TEST_HOST_INTEGRATION_CORE_API(user_data); + + if (self->vtable == nullptr || self->vtable->send_j_s_o_n_parser == nullptr) { + return; + } + + FlValue* value0 = fl_value_get_list_value(message_, 0); + CoreTestsPigeonTestAcronymsAndTestCase* acronyms = + CORE_TESTS_PIGEON_TEST_ACRONYMS_AND_TEST_CASE( + fl_value_get_custom_value_object(value0)); + g_autoptr(CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse) + response = self->vtable->send_j_s_o_n_parser(acronyms, self->user_data); + if (response == nullptr) { + g_warning("No response returned to %s.%s", "HostIntegrationCoreApi", + "sendJSONParser"); + return; + } + + g_autoptr(GError) error = NULL; + if (!fl_basic_message_channel_respond(channel, response_handle, + response->value, &error)) { + g_warning("Failed to send response to %s.%s: %s", "HostIntegrationCoreApi", + "sendJSONParser", error->message); + } +} + static void core_tests_pigeon_test_host_integration_core_api_echo_enum_cb( FlBasicMessageChannel* channel, FlValue* message_, FlBasicMessageChannelResponseHandle* response_handle, gpointer user_data) { @@ -19323,6 +19855,40 @@ void core_tests_pigeon_test_host_integration_core_api_set_method_handlers( echo_class_wrapper_channel, core_tests_pigeon_test_host_integration_core_api_echo_class_wrapper_cb, g_object_ref(api_data), g_object_unref); + g_autofree gchar* echo_acronyms_channel_name = g_strdup_printf( + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi." + "echoAcronyms%s", + dot_suffix); + g_autoptr(FlBasicMessageChannel) echo_acronyms_channel = + fl_basic_message_channel_new(messenger, echo_acronyms_channel_name, + FL_MESSAGE_CODEC(codec)); + fl_basic_message_channel_set_message_handler( + echo_acronyms_channel, + core_tests_pigeon_test_host_integration_core_api_echo_acronyms_cb, + g_object_ref(api_data), g_object_unref); + g_autofree gchar* host_h_t_t_p_response_channel_name = g_strdup_printf( + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi." + "hostHTTPResponse%s", + dot_suffix); + g_autoptr(FlBasicMessageChannel) host_h_t_t_p_response_channel = + fl_basic_message_channel_new(messenger, + host_h_t_t_p_response_channel_name, + FL_MESSAGE_CODEC(codec)); + fl_basic_message_channel_set_message_handler( + host_h_t_t_p_response_channel, + core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_cb, + g_object_ref(api_data), g_object_unref); + g_autofree gchar* send_j_s_o_n_parser_channel_name = g_strdup_printf( + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi." + "sendJSONParser%s", + dot_suffix); + g_autoptr(FlBasicMessageChannel) send_j_s_o_n_parser_channel = + fl_basic_message_channel_new(messenger, send_j_s_o_n_parser_channel_name, + FL_MESSAGE_CODEC(codec)); + fl_basic_message_channel_set_message_handler( + send_j_s_o_n_parser_channel, + core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_cb, + g_object_ref(api_data), g_object_unref); g_autofree gchar* echo_enum_channel_name = g_strdup_printf( "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi." "echoEnum%s", @@ -21207,6 +21773,34 @@ void core_tests_pigeon_test_host_integration_core_api_clear_method_handlers( FL_MESSAGE_CODEC(codec)); fl_basic_message_channel_set_message_handler(echo_class_wrapper_channel, nullptr, nullptr, nullptr); + g_autofree gchar* echo_acronyms_channel_name = g_strdup_printf( + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi." + "echoAcronyms%s", + dot_suffix); + g_autoptr(FlBasicMessageChannel) echo_acronyms_channel = + fl_basic_message_channel_new(messenger, echo_acronyms_channel_name, + FL_MESSAGE_CODEC(codec)); + fl_basic_message_channel_set_message_handler(echo_acronyms_channel, nullptr, + nullptr, nullptr); + g_autofree gchar* host_h_t_t_p_response_channel_name = g_strdup_printf( + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi." + "hostHTTPResponse%s", + dot_suffix); + g_autoptr(FlBasicMessageChannel) host_h_t_t_p_response_channel = + fl_basic_message_channel_new(messenger, + host_h_t_t_p_response_channel_name, + FL_MESSAGE_CODEC(codec)); + fl_basic_message_channel_set_message_handler(host_h_t_t_p_response_channel, + nullptr, nullptr, nullptr); + g_autofree gchar* send_j_s_o_n_parser_channel_name = g_strdup_printf( + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi." + "sendJSONParser%s", + dot_suffix); + g_autoptr(FlBasicMessageChannel) send_j_s_o_n_parser_channel = + fl_basic_message_channel_new(messenger, send_j_s_o_n_parser_channel_name, + FL_MESSAGE_CODEC(codec)); + fl_basic_message_channel_set_message_handler(send_j_s_o_n_parser_channel, + nullptr, nullptr, nullptr); g_autofree gchar* echo_enum_channel_name = g_strdup_printf( "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi." "echoEnum%s", diff --git a/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.h b/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.h index 322b9bc8a6b5..50844b09c72a 100644 --- a/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.h +++ b/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.h @@ -38,6 +38,17 @@ typedef enum { PIGEON_INTEGRATION_TESTS_ANOTHER_ENUM_JUST_IN_CASE = 0 } CoreTestsPigeonTestAnotherEnum; +/** + * CoreTestsPigeonTestAcronymsEnum: + * PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_H_T_T_P_RESPONSE: + * PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_J_S_O_N_PARSER: + * + */ +typedef enum { + PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_H_T_T_P_RESPONSE = 0, + PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_J_S_O_N_PARSER = 1 +} CoreTestsPigeonTestAcronymsEnum; + /** * CoreTestsPigeonTestUnusedClass: * @@ -1516,6 +1527,100 @@ gboolean core_tests_pigeon_test_all_classes_wrapper_equals( guint core_tests_pigeon_test_all_classes_wrapper_hash( CoreTestsPigeonTestAllClassesWrapper* object); +/** + * CoreTestsPigeonTestAcronymsAndTestCase: + * + */ + +G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestAcronymsAndTestCase, + core_tests_pigeon_test_acronyms_and_test_case, + CORE_TESTS_PIGEON_TEST, ACRONYMS_AND_TEST_CASE, GObject) + +/** + * core_tests_pigeon_test_acronyms_and_test_case_new: + * http_response: field in this object. + * json_parser: field in this object. + * xml_node: field in this object. + * acronyms_enum: field in this object. + * + * Creates a new #AcronymsAndTestCase object. + * + * Returns: a new #CoreTestsPigeonTestAcronymsAndTestCase + */ +CoreTestsPigeonTestAcronymsAndTestCase* +core_tests_pigeon_test_acronyms_and_test_case_new( + const gchar* http_response, const gchar* json_parser, const gchar* xml_node, + CoreTestsPigeonTestAcronymsEnum* acronyms_enum); + +/** + * core_tests_pigeon_test_acronyms_and_test_case_get_http_response + * @object: a #CoreTestsPigeonTestAcronymsAndTestCase. + * + * Gets the value of the httpResponse field of @object. + * + * Returns: the field value. + */ +const gchar* core_tests_pigeon_test_acronyms_and_test_case_get_http_response( + CoreTestsPigeonTestAcronymsAndTestCase* object); + +/** + * core_tests_pigeon_test_acronyms_and_test_case_get_json_parser + * @object: a #CoreTestsPigeonTestAcronymsAndTestCase. + * + * Gets the value of the jsonParser field of @object. + * + * Returns: the field value. + */ +const gchar* core_tests_pigeon_test_acronyms_and_test_case_get_json_parser( + CoreTestsPigeonTestAcronymsAndTestCase* object); + +/** + * core_tests_pigeon_test_acronyms_and_test_case_get_xml_node + * @object: a #CoreTestsPigeonTestAcronymsAndTestCase. + * + * Gets the value of the xmlNode field of @object. + * + * Returns: the field value. + */ +const gchar* core_tests_pigeon_test_acronyms_and_test_case_get_xml_node( + CoreTestsPigeonTestAcronymsAndTestCase* object); + +/** + * core_tests_pigeon_test_acronyms_and_test_case_get_acronyms_enum + * @object: a #CoreTestsPigeonTestAcronymsAndTestCase. + * + * Gets the value of the acronymsEnum field of @object. + * + * Returns: the field value. + */ +CoreTestsPigeonTestAcronymsEnum* +core_tests_pigeon_test_acronyms_and_test_case_get_acronyms_enum( + CoreTestsPigeonTestAcronymsAndTestCase* object); + +/** + * core_tests_pigeon_test_acronyms_and_test_case_equals: + * @a: a #CoreTestsPigeonTestAcronymsAndTestCase. + * @b: another #CoreTestsPigeonTestAcronymsAndTestCase. + * + * Checks if two #CoreTestsPigeonTestAcronymsAndTestCase objects are equal. + * + * Returns: TRUE if @a and @b are equal. + */ +gboolean core_tests_pigeon_test_acronyms_and_test_case_equals( + CoreTestsPigeonTestAcronymsAndTestCase* a, + CoreTestsPigeonTestAcronymsAndTestCase* b); + +/** + * core_tests_pigeon_test_acronyms_and_test_case_hash: + * @object: a #CoreTestsPigeonTestAcronymsAndTestCase. + * + * Calculates a hash code for a #CoreTestsPigeonTestAcronymsAndTestCase object. + * + * Returns: the hash code. + */ +guint core_tests_pigeon_test_acronyms_and_test_case_hash( + CoreTestsPigeonTestAcronymsAndTestCase* object); + /** * CoreTestsPigeonTestTestMessage: * @@ -1585,12 +1690,14 @@ G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestMessageCodec, */ extern const int core_tests_pigeon_test_an_enum_type_id; extern const int core_tests_pigeon_test_another_enum_type_id; +extern const int core_tests_pigeon_test_acronyms_enum_type_id; extern const int core_tests_pigeon_test_unused_class_type_id; extern const int core_tests_pigeon_test_all_types_type_id; extern const int core_tests_pigeon_test_all_nullable_types_type_id; extern const int core_tests_pigeon_test_all_nullable_types_without_recursion_type_id; extern const int core_tests_pigeon_test_all_classes_wrapper_type_id; +extern const int core_tests_pigeon_test_acronyms_and_test_case_type_id; extern const int core_tests_pigeon_test_test_message_type_id; G_DECLARE_FINAL_TYPE(CoreTestsPigeonTestHostIntegrationCoreApi, @@ -2429,6 +2536,103 @@ CoreTestsPigeonTestHostIntegrationCoreApiEchoClassWrapperResponse* core_tests_pigeon_test_host_integration_core_api_echo_class_wrapper_response_new_error( const gchar* code, const gchar* message, FlValue* details); +G_DECLARE_FINAL_TYPE( + CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse, + core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response, + CORE_TESTS_PIGEON_TEST, HOST_INTEGRATION_CORE_API_ECHO_ACRONYMS_RESPONSE, + GObject) + +/** + * core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_new: + * + * Creates a new response to HostIntegrationCoreApi.echoAcronyms. + * + * Returns: a new #CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse + */ +CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse* +core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_new( + CoreTestsPigeonTestAcronymsAndTestCase* return_value); + +/** + * core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_new_error: + * @code: error code. + * @message: error message. + * @details: (allow-none): error details or %NULL. + * + * Creates a new error response to HostIntegrationCoreApi.echoAcronyms. + * + * Returns: a new #CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse + */ +CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse* +core_tests_pigeon_test_host_integration_core_api_echo_acronyms_response_new_error( + const gchar* code, const gchar* message, FlValue* details); + +G_DECLARE_FINAL_TYPE( + CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse, + core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response, + CORE_TESTS_PIGEON_TEST, + HOST_INTEGRATION_CORE_API_HOST_H_T_T_P_RESPONSE_RESPONSE, GObject) + +/** + * core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_new: + * + * Creates a new response to HostIntegrationCoreApi.hostHTTPResponse. + * + * Returns: a new + * #CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse + */ +CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* +core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_new( + CoreTestsPigeonTestAcronymsAndTestCase* return_value); + +/** + * core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_new_error: + * @code: error code. + * @message: error message. + * @details: (allow-none): error details or %NULL. + * + * Creates a new error response to HostIntegrationCoreApi.hostHTTPResponse. + * + * Returns: a new + * #CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse + */ +CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* +core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_new_error( + const gchar* code, const gchar* message, FlValue* details); + +G_DECLARE_FINAL_TYPE( + CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse, + core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response, + CORE_TESTS_PIGEON_TEST, + HOST_INTEGRATION_CORE_API_SEND_J_S_O_N_PARSER_RESPONSE, GObject) + +/** + * core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_new: + * + * Creates a new response to HostIntegrationCoreApi.sendJSONParser. + * + * Returns: a new + * #CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse + */ +CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* +core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_new( + CoreTestsPigeonTestAcronymsAndTestCase* return_value); + +/** + * core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_new_error: + * @code: error code. + * @message: error message. + * @details: (allow-none): error details or %NULL. + * + * Creates a new error response to HostIntegrationCoreApi.sendJSONParser. + * + * Returns: a new + * #CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse + */ +CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* +core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_new_error( + const gchar* code, const gchar* message, FlValue* details); + G_DECLARE_FINAL_TYPE( CoreTestsPigeonTestHostIntegrationCoreApiEchoEnumResponse, core_tests_pigeon_test_host_integration_core_api_echo_enum_response, @@ -3841,6 +4045,15 @@ typedef struct { CoreTestsPigeonTestHostIntegrationCoreApiEchoClassWrapperResponse* ( *echo_class_wrapper)(CoreTestsPigeonTestAllClassesWrapper* wrapper, gpointer user_data); + CoreTestsPigeonTestHostIntegrationCoreApiEchoAcronymsResponse* ( + *echo_acronyms)(CoreTestsPigeonTestAcronymsAndTestCase* acronyms, + gpointer user_data); + CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* ( + *host_h_t_t_p_response)(CoreTestsPigeonTestAcronymsAndTestCase* acronyms, + gpointer user_data); + CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* ( + *send_j_s_o_n_parser)(CoreTestsPigeonTestAcronymsAndTestCase* acronyms, + gpointer user_data); CoreTestsPigeonTestHostIntegrationCoreApiEchoEnumResponse* (*echo_enum)( CoreTestsPigeonTestAnEnum an_enum, gpointer user_data); CoreTestsPigeonTestHostIntegrationCoreApiEchoAnotherEnumResponse* ( diff --git a/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc b/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc index 693bb17eefee..c2390e4dbfd4 100644 --- a/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc +++ b/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc @@ -213,6 +213,80 @@ echo_class_wrapper(CoreTestsPigeonTestAllClassesWrapper* wrapper, wrapper); } +// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +static CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* +host_h_t_t_p_response(CoreTestsPigeonTestAcronymsAndTestCase* acronyms, + gpointer user_data) { + const gchar* http_response = + core_tests_pigeon_test_acronyms_and_test_case_get_http_response(acronyms); + const gchar* json_parser = + core_tests_pigeon_test_acronyms_and_test_case_get_json_parser(acronyms); + const gchar* xml_node = + core_tests_pigeon_test_acronyms_and_test_case_get_xml_node(acronyms); + + CoreTestsPigeonTestAcronymsEnum* incoming_enum = + core_tests_pigeon_test_acronyms_and_test_case_get_acronyms_enum(acronyms); + CoreTestsPigeonTestAcronymsEnum enum_val; + CoreTestsPigeonTestAcronymsEnum* enum_ptr = NULL; + + if (incoming_enum) { + switch (*incoming_enum) { + case PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_H_T_T_P_RESPONSE: + enum_val = PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_H_T_T_P_RESPONSE; + enum_ptr = &enum_val; + break; + case PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_J_S_O_N_PARSER: + enum_val = PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_J_S_O_N_PARSER; + enum_ptr = &enum_val; + break; + } + } + + g_autoptr(CoreTestsPigeonTestAcronymsAndTestCase) result = + core_tests_pigeon_test_acronyms_and_test_case_new( + http_response, json_parser, xml_node, enum_ptr); + + return core_tests_pigeon_test_host_integration_core_api_host_h_t_t_p_response_response_new( + result); +} + +// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +static CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* +send_j_s_o_n_parser(CoreTestsPigeonTestAcronymsAndTestCase* acronyms, + gpointer user_data) { + const gchar* http_response = + core_tests_pigeon_test_acronyms_and_test_case_get_http_response(acronyms); + const gchar* json_parser = + core_tests_pigeon_test_acronyms_and_test_case_get_json_parser(acronyms); + const gchar* xml_node = + core_tests_pigeon_test_acronyms_and_test_case_get_xml_node(acronyms); + + CoreTestsPigeonTestAcronymsEnum* incoming_enum = + core_tests_pigeon_test_acronyms_and_test_case_get_acronyms_enum(acronyms); + CoreTestsPigeonTestAcronymsEnum enum_val; + CoreTestsPigeonTestAcronymsEnum* enum_ptr = NULL; + + if (incoming_enum) { + switch (*incoming_enum) { + case PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_H_T_T_P_RESPONSE: + enum_val = PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_H_T_T_P_RESPONSE; + enum_ptr = &enum_val; + break; + case PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_J_S_O_N_PARSER: + enum_val = PIGEON_INTEGRATION_TESTS_ACRONYMS_ENUM_J_S_O_N_PARSER; + enum_ptr = &enum_val; + break; + } + } + + g_autoptr(CoreTestsPigeonTestAcronymsAndTestCase) result = + core_tests_pigeon_test_acronyms_and_test_case_new( + http_response, json_parser, xml_node, enum_ptr); + + return core_tests_pigeon_test_host_integration_core_api_send_j_s_o_n_parser_response_new( + result); +} + static CoreTestsPigeonTestHostIntegrationCoreApiEchoEnumResponse* echo_enum( CoreTestsPigeonTestAnEnum an_enum, gpointer user_data) { @@ -3242,6 +3316,8 @@ static CoreTestsPigeonTestHostIntegrationCoreApiVTable host_core_api_vtable = { .echo_non_null_enum_map = echo_non_null_enum_map, .echo_non_null_class_map = echo_non_null_class_map, .echo_class_wrapper = echo_class_wrapper, + .host_h_t_t_p_response = host_h_t_t_p_response, + .send_j_s_o_n_parser = send_j_s_o_n_parser, .echo_enum = echo_enum, .echo_another_enum = echo_another_enum, .echo_named_default_string = echo_named_default_string, 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 f50c8eff918c..8b837f83e579 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 @@ -2576,6 +2576,106 @@ size_t AllClassesWrapper::Hash() const { size_t PigeonInternalDeepHash(const AllClassesWrapper& v) { return v.Hash(); } +// AcronymsAndTestCase + +AcronymsAndTestCase::AcronymsAndTestCase(const std::string& http_response, + const std::string& json_parser, + const std::string& xml_node) + : http_response_(http_response), + json_parser_(json_parser), + xml_node_(xml_node) {} + +AcronymsAndTestCase::AcronymsAndTestCase(const std::string& http_response, + const std::string& json_parser, + const std::string& xml_node, + const AcronymsEnum* acronyms_enum) + : http_response_(http_response), + json_parser_(json_parser), + xml_node_(xml_node), + acronyms_enum_(acronyms_enum ? std::optional(*acronyms_enum) + : std::nullopt) {} + +const std::string& AcronymsAndTestCase::http_response() const { + return http_response_; +} + +void AcronymsAndTestCase::set_http_response(std::string_view value_arg) { + http_response_ = value_arg; +} + +const std::string& AcronymsAndTestCase::json_parser() const { + return json_parser_; +} + +void AcronymsAndTestCase::set_json_parser(std::string_view value_arg) { + json_parser_ = value_arg; +} + +const std::string& AcronymsAndTestCase::xml_node() const { return xml_node_; } + +void AcronymsAndTestCase::set_xml_node(std::string_view value_arg) { + xml_node_ = value_arg; +} + +const AcronymsEnum* AcronymsAndTestCase::acronyms_enum() const { + return acronyms_enum_ ? &(*acronyms_enum_) : nullptr; +} + +void AcronymsAndTestCase::set_acronyms_enum(const AcronymsEnum* value_arg) { + acronyms_enum_ = + value_arg ? std::optional(*value_arg) : std::nullopt; +} + +void AcronymsAndTestCase::set_acronyms_enum(const AcronymsEnum& value_arg) { + acronyms_enum_ = value_arg; +} + +EncodableList AcronymsAndTestCase::ToEncodableList() const { + EncodableList list; + list.reserve(4); + list.push_back(EncodableValue(http_response_)); + list.push_back(EncodableValue(json_parser_)); + list.push_back(EncodableValue(xml_node_)); + list.push_back(acronyms_enum_ ? CustomEncodableValue(*acronyms_enum_) + : EncodableValue()); + return list; +} + +AcronymsAndTestCase AcronymsAndTestCase::FromEncodableList( + const EncodableList& list) { + AcronymsAndTestCase decoded(std::get(list[0]), + std::get(list[1]), + std::get(list[2])); + auto& encodable_acronyms_enum = list[3]; + if (!encodable_acronyms_enum.IsNull()) { + decoded.set_acronyms_enum(std::any_cast( + std::get(encodable_acronyms_enum))); + } + return decoded; +} + +bool AcronymsAndTestCase::operator==(const AcronymsAndTestCase& other) const { + return PigeonInternalDeepEquals(http_response_, other.http_response_) && + PigeonInternalDeepEquals(json_parser_, other.json_parser_) && + PigeonInternalDeepEquals(xml_node_, other.xml_node_) && + PigeonInternalDeepEquals(acronyms_enum_, other.acronyms_enum_); +} + +bool AcronymsAndTestCase::operator!=(const AcronymsAndTestCase& other) const { + return !(*this == other); +} + +size_t AcronymsAndTestCase::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(http_response_); + result = result * 31 + PigeonInternalDeepHash(json_parser_); + result = result * 31 + PigeonInternalDeepHash(xml_node_); + result = result * 31 + PigeonInternalDeepHash(acronyms_enum_); + return result; +} + +size_t PigeonInternalDeepHash(const AcronymsAndTestCase& v) { return v.Hash(); } + // TestMessage TestMessage::TestMessage() {} @@ -2652,27 +2752,40 @@ EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( static_cast(enum_arg_value)); } case 131: { + const auto& encodable_enum_arg = ReadValue(stream); + const int64_t enum_arg_value = + encodable_enum_arg.IsNull() ? 0 : encodable_enum_arg.LongValue(); + return encodable_enum_arg.IsNull() + ? EncodableValue() + : CustomEncodableValue( + static_cast(enum_arg_value)); + } + case 132: { return CustomEncodableValue(UnusedClass::FromEncodableList( std::get(ReadValue(stream)))); } - case 132: { + case 133: { return CustomEncodableValue(AllTypes::FromEncodableList( std::get(ReadValue(stream)))); } - case 133: { + case 134: { return CustomEncodableValue(AllNullableTypes::FromEncodableList( std::get(ReadValue(stream)))); } - case 134: { + case 135: { return CustomEncodableValue( AllNullableTypesWithoutRecursion::FromEncodableList( std::get(ReadValue(stream)))); } - case 135: { + case 136: { return CustomEncodableValue(AllClassesWrapper::FromEncodableList( std::get(ReadValue(stream)))); } - case 136: { + case 137: { + return CustomEncodableValue(AcronymsAndTestCase::FromEncodableList( + std::get(ReadValue(stream)))); + } + case 138: { return CustomEncodableValue(TestMessage::FromEncodableList( std::get(ReadValue(stream)))); } @@ -2699,8 +2812,15 @@ void PigeonInternalCodecSerializer::WriteValue( stream); return; } - if (custom_value->type() == typeid(UnusedClass)) { + if (custom_value->type() == typeid(AcronymsEnum)) { stream->WriteByte(131); + WriteValue(EncodableValue(static_cast( + std::any_cast(*custom_value))), + stream); + return; + } + if (custom_value->type() == typeid(UnusedClass)) { + stream->WriteByte(132); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), @@ -2708,14 +2828,14 @@ void PigeonInternalCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(AllTypes)) { - stream->WriteByte(132); + stream->WriteByte(133); WriteValue(EncodableValue( std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(AllNullableTypes)) { - stream->WriteByte(133); + stream->WriteByte(134); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), @@ -2723,7 +2843,7 @@ void PigeonInternalCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(AllNullableTypesWithoutRecursion)) { - stream->WriteByte(134); + stream->WriteByte(135); WriteValue(EncodableValue(std::any_cast( *custom_value) .ToEncodableList()), @@ -2731,14 +2851,22 @@ void PigeonInternalCodecSerializer::WriteValue( return; } if (custom_value->type() == typeid(AllClassesWrapper)) { - stream->WriteByte(135); + stream->WriteByte(136); WriteValue(EncodableValue(std::any_cast(*custom_value) .ToEncodableList()), stream); return; } + if (custom_value->type() == typeid(AcronymsAndTestCase)) { + stream->WriteByte(137); + WriteValue( + EncodableValue(std::any_cast(*custom_value) + .ToEncodableList()), + stream); + return; + } if (custom_value->type() == typeid(TestMessage)) { - stream->WriteByte(136); + stream->WriteByte(138); WriteValue( EncodableValue( std::any_cast(*custom_value).ToEncodableList()), @@ -3669,6 +3797,120 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, channel.SetMessageHandler(nullptr); } } + { + BasicMessageChannel<> channel(binary_messenger, + "dev.flutter.pigeon.pigeon_integration_tests." + "HostIntegrationCoreApi.echoAcronyms" + + prepended_suffix, + &GetCodec()); + if (api != nullptr) { + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_acronyms_arg = args.at(0); + if (encodable_acronyms_arg.IsNull()) { + reply(WrapError("acronyms_arg unexpectedly null.")); + return; + } + const auto& acronyms_arg = + std::any_cast( + std::get(encodable_acronyms_arg)); + ErrorOr output = + api->EchoAcronyms(acronyms_arg); + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back( + CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel.SetMessageHandler(nullptr); + } + } + { + BasicMessageChannel<> channel(binary_messenger, + "dev.flutter.pigeon.pigeon_integration_tests." + "HostIntegrationCoreApi.hostHTTPResponse" + + prepended_suffix, + &GetCodec()); + if (api != nullptr) { + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_acronyms_arg = args.at(0); + if (encodable_acronyms_arg.IsNull()) { + reply(WrapError("acronyms_arg unexpectedly null.")); + return; + } + const auto& acronyms_arg = + std::any_cast( + std::get(encodable_acronyms_arg)); + ErrorOr output = + api->HostHTTPResponse(acronyms_arg); + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back( + CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel.SetMessageHandler(nullptr); + } + } + { + BasicMessageChannel<> channel(binary_messenger, + "dev.flutter.pigeon.pigeon_integration_tests." + "HostIntegrationCoreApi.sendJSONParser" + + prepended_suffix, + &GetCodec()); + if (api != nullptr) { + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_acronyms_arg = args.at(0); + if (encodable_acronyms_arg.IsNull()) { + reply(WrapError("acronyms_arg unexpectedly null.")); + return; + } + const auto& acronyms_arg = + std::any_cast( + std::get(encodable_acronyms_arg)); + ErrorOr output = + api->SendJSONParser(acronyms_arg); + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back( + CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel.SetMessageHandler(nullptr); + } + } { BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.pigeon_integration_tests." 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 24ca4540d6a8..10d972c84698 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 @@ -22,25 +22,6 @@ class CoreTestsTest; // Generated class from Pigeon. -class FlutterError { - public: - explicit FlutterError(const std::string& code) : code_(code) {} - explicit FlutterError(const std::string& code, const std::string& message) - : code_(code), message_(message) {} - explicit FlutterError(const std::string& code, const std::string& message, - const ::flutter::EncodableValue& details) - : code_(code), message_(message), details_(details) {} - - const std::string& code() const { return code_; } - const std::string& message() const { return message_; } - const ::flutter::EncodableValue& details() const { return details_; } - - private: - std::string code_; - std::string message_; - ::flutter::EncodableValue details_; -}; - template class ErrorOr { public: @@ -65,6 +46,25 @@ class ErrorOr { std::variant v_; }; +class FlutterError { + public: + explicit FlutterError(const std::string& code) : code_(code) {} + explicit FlutterError(const std::string& code, const std::string& message) + : code_(code), message_(message) {} + explicit FlutterError(const std::string& code, const std::string& message, + const ::flutter::EncodableValue& details) + : code_(code), message_(message), details_(details) {} + + const std::string& code() const { return code_; } + const std::string& message() const { return message_; } + const ::flutter::EncodableValue& details() const { return details_; } + + private: + std::string code_; + std::string message_; + ::flutter::EncodableValue details_; +}; + enum class AnEnum { kOne = 0, kTwo = 1, @@ -75,6 +75,8 @@ enum class AnEnum { enum class AnotherEnum { kJustInCase = 0 }; +enum class AcronymsEnum { kHTTPResponse = 0, kJSONParser = 1 }; + // Generated class from Pigeon that represents data sent in messages. class UnusedClass { public: @@ -770,6 +772,56 @@ class AllClassesWrapper { std::optional<::flutter::EncodableMap> nullable_class_map_; }; +// Generated class from Pigeon that represents data sent in messages. +class AcronymsAndTestCase { + public: + // Constructs an object setting all non-nullable fields. + explicit AcronymsAndTestCase(const std::string& http_response, + const std::string& json_parser, + const std::string& xml_node); + + // Constructs an object setting all fields. + explicit AcronymsAndTestCase(const std::string& http_response, + const std::string& json_parser, + const std::string& xml_node, + const AcronymsEnum* acronyms_enum); + + const std::string& http_response() const; + void set_http_response(std::string_view value_arg); + + const std::string& json_parser() const; + void set_json_parser(std::string_view value_arg); + + const std::string& xml_node() const; + void set_xml_node(std::string_view value_arg); + + const AcronymsEnum* acronyms_enum() const; + void set_acronyms_enum(const AcronymsEnum* value_arg); + void set_acronyms_enum(const AcronymsEnum& value_arg); + + bool operator==(const AcronymsAndTestCase& other) const; + bool operator!=(const AcronymsAndTestCase& other) const; + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. + size_t Hash() const; + + private: + static AcronymsAndTestCase FromEncodableList( + const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; + friend class HostIntegrationCoreApi; + friend class FlutterIntegrationCoreApi; + friend class HostTrivialApi; + friend class HostSmallApi; + friend class FlutterSmallApi; + friend class PigeonInternalCodecSerializer; + friend class CoreTestsTest; + std::string http_response_; + std::string json_parser_; + std::string xml_node_; + std::optional acronyms_enum_; +}; + // A data class containing a List, used in unit tests. // // Generated class from Pigeon that represents data sent in messages. @@ -903,6 +955,13 @@ class HostIntegrationCoreApi { // deserialization. virtual ErrorOr EchoClassWrapper( const AllClassesWrapper& wrapper) = 0; + // Returns the passed acronyms object. + virtual ErrorOr EchoAcronyms( + const AcronymsAndTestCase& acronyms) = 0; + virtual ErrorOr HostHTTPResponse( + const AcronymsAndTestCase& acronyms) = 0; + virtual ErrorOr SendJSONParser( + const AcronymsAndTestCase& acronyms) = 0; // Returns the passed enum to test serialization and deserialization. virtual ErrorOr EchoEnum(const AnEnum& an_enum) = 0; // Returns the passed enum to test serialization and deserialization. diff --git a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp index 3e6056f3a810..0796242985d0 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp +++ b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp @@ -17,6 +17,8 @@ namespace test_plugin { +using core_tests_pigeontest::AcronymsAndTestCase; +using core_tests_pigeontest::AcronymsEnum; using core_tests_pigeontest::AllClassesWrapper; using core_tests_pigeontest::AllNullableTypes; using core_tests_pigeontest::AllNullableTypesWithoutRecursion; @@ -224,6 +226,42 @@ ErrorOr TestPlugin::EchoClassWrapper( return wrapper; } +// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +ErrorOr TestPlugin::HostHTTPResponse( + const AcronymsAndTestCase& acronyms) { + AcronymsAndTestCase result(acronyms.http_response(), acronyms.json_parser(), + acronyms.xml_node()); + if (acronyms.acronyms_enum()) { + switch (*acronyms.acronyms_enum()) { + case AcronymsEnum::kHTTPResponse: + result.set_acronyms_enum(AcronymsEnum::kHTTPResponse); + break; + case AcronymsEnum::kJSONParser: + result.set_acronyms_enum(AcronymsEnum::kJSONParser); + break; + } + } + return result; +} + +// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +ErrorOr TestPlugin::SendJSONParser( + const AcronymsAndTestCase& acronyms) { + AcronymsAndTestCase result(acronyms.http_response(), acronyms.json_parser(), + acronyms.xml_node()); + if (acronyms.acronyms_enum()) { + switch (*acronyms.acronyms_enum()) { + case AcronymsEnum::kHTTPResponse: + result.set_acronyms_enum(AcronymsEnum::kHTTPResponse); + break; + case AcronymsEnum::kJSONParser: + result.set_acronyms_enum(AcronymsEnum::kJSONParser); + break; + } + } + return result; +} + ErrorOr TestPlugin::EchoEnum(const AnEnum& an_enum) { return an_enum; } ErrorOr TestPlugin::EchoAnotherEnum( diff --git a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h index a52bd83f03a2..5fff528ca8fc 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h +++ b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.h @@ -120,6 +120,12 @@ class TestPlugin : public flutter::Plugin, core_tests_pigeontest::ErrorOr EchoClassWrapper( const core_tests_pigeontest::AllClassesWrapper& wrapper) override; + core_tests_pigeontest::ErrorOr + HostHTTPResponse( + const core_tests_pigeontest::AcronymsAndTestCase& acronyms) override; + core_tests_pigeontest::ErrorOr + SendJSONParser( + const core_tests_pigeontest::AcronymsAndTestCase& acronyms) override; core_tests_pigeontest::ErrorOr EchoEnum( const core_tests_pigeontest::AnEnum& an_enum) override; core_tests_pigeontest::ErrorOr diff --git a/packages/pigeon/test/generator_tools_test.dart b/packages/pigeon/test/generator_tools_test.dart index 183865f1e3f3..e2f1bf4629a9 100644 --- a/packages/pigeon/test/generator_tools_test.dart +++ b/packages/pigeon/test/generator_tools_test.dart @@ -515,4 +515,32 @@ void myMethod() { } '''); }); + + test('toScreamingSnakeCase handles acronyms', () { + expect(toScreamingSnakeCase('camelCase'), 'CAMEL_CASE'); + expect(toScreamingSnakeCase('PascalCase'), 'PASCAL_CASE'); + expect(toScreamingSnakeCase('HTTPResponse'), 'HTTP_RESPONSE'); + expect(toScreamingSnakeCase('JSONParser'), 'JSON_PARSER'); + }); + + test('toSnakeCase handles acronyms', () { + expect(toSnakeCase('camelCase'), 'camel_case'); + expect(toSnakeCase('PascalCase'), 'pascal_case'); + expect(toSnakeCase('HTTPResponse'), 'http_response'); + expect(toSnakeCase('JSONParser'), 'json_parser'); + }); + + test('toUpperCamelCase converts strings correctly', () { + expect(toUpperCamelCase('hello_world'), 'HelloWorld'); + expect(toUpperCamelCase('hello world'), 'HelloWorld'); + expect(toUpperCamelCase('hello-world'), 'HelloWorld'); + expect(toUpperCamelCase('HelloWorld'), 'HelloWorld'); + }); + + test('toLowerCamelCase converts strings correctly', () { + expect(toLowerCamelCase('hello_world'), 'helloWorld'); + expect(toLowerCamelCase('hello world'), 'helloWorld'); + expect(toLowerCamelCase('hello-world'), 'helloWorld'); + expect(toLowerCamelCase('HelloWorld'), 'helloWorld'); + }); } From 7f1160afbbf66c3e94293a6311517b16a01beee7 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Mon, 13 Apr 2026 22:41:02 -0700 Subject: [PATCH 2/7] refactor: unify Pigeon response handling by replacing wrapResult and wrapError with a single wrapResponse method across all generators. --- .../java/io/flutter/plugins/Messages.java | 48 +- .../flutter/pigeon_example_app/Messages.g.kt | 34 +- .../example/app/ios/Runner/Messages.g.swift | 54 +- .../example/app/windows/runner/messages.g.cpp | 57 +- .../pigeon/lib/src/cpp/cpp_generator.dart | 100 +- .../pigeon/lib/src/dart/dart_generator.dart | 42 +- packages/pigeon/lib/src/generator.dart | 8 + .../pigeon/lib/src/java/java_generator.dart | 161 +- .../lib/src/kotlin/kotlin_generator.dart | 136 +- .../pigeon/lib/src/objc/objc_generator.dart | 35 +- .../pigeon/lib/src/swift/swift_generator.dart | 83 +- .../CoreTests.java | 1093 +++------ .../AlternateLanguageTestPlugin.m | 24 +- .../com/example/test_plugin/CoreTests.gen.kt | 692 +++--- .../example/test_plugin/ProxyApiTests.gen.kt | 395 +-- .../com/example/test_plugin/TestPlugin.kt | 28 +- .../Sources/test_plugin/CoreTests.gen.swift | 690 +++--- .../test_plugin/ProxyApiTests.gen.swift | 386 +-- .../test_plugin/linux/test_plugin.cc | 6 +- .../windows/pigeon/core_tests.gen.cpp | 2108 +++++++++-------- .../test_plugin/windows/test_plugin.cpp | 6 +- packages/pigeon/test/cpp_generator_test.dart | 2 +- packages/pigeon/test/java_generator_test.dart | 2 +- .../pigeon/test/kotlin_generator_test.dart | 22 +- .../pigeon/test/swift_generator_test.dart | 8 +- 25 files changed, 3089 insertions(+), 3131 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 c53785c76098..181441d8ff84 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,20 +186,25 @@ static int pigeonDeepHashCode(Object value) { } @NonNull - protected static ArrayList wrapError(@NonNull Throwable exception) { - ArrayList errorList = new ArrayList<>(3); - if (exception instanceof FlutterError) { - FlutterError error = (FlutterError) exception; - errorList.add(error.code); - errorList.add(error.getMessage()); - errorList.add(error.details); + protected static ArrayList wrapResponse( + @Nullable Object result, @Nullable Throwable error) { + ArrayList response = new ArrayList<>(); + if (error != null) { + if (error instanceof FlutterError) { + FlutterError flutterError = (FlutterError) error; + response.add(flutterError.code); + response.add(flutterError.getMessage()); + response.add(flutterError.details); + } else { + response.add(error.toString()); + response.add(error.getClass().getSimpleName()); + response.add( + "Cause: " + error.getCause() + ", Stacktrace: " + Log.getStackTraceString(error)); + } } else { - errorList.add(exception.toString()); - errorList.add(exception.getClass().getSimpleName()); - errorList.add( - "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + response.add(result); } - return errorList; + return response; } @NonNull @@ -472,14 +477,12 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); try { String output = api.getHostLanguage(); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -495,17 +498,15 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Long aArg = (Long) args.get(0); Long bArg = (Long) args.get(1); try { Long output = api.add(aArg, bArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -521,19 +522,16 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; MessageData messageArg = (MessageData) args.get(0); Result resultCallback = new Result() { public void success(Boolean result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; 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 9557d8c13297..7ba57d64b89d 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 @@ -20,18 +20,18 @@ private object MessagesPigeonUtils { "channel-error", "Unable to establish connection on channel: '$channelName'.", "") } - fun wrapResult(result: Any?): List { - return listOf(result) - } - - fun wrapError(exception: Throwable): List { - return if (exception is FlutterError) { - listOf(exception.code, exception.message, exception.details) + fun wrapResponse(result: Any?, error: Throwable?): List { + return if (error != null) { + if (error is FlutterError) { + listOf(error.code, error.message, error.details) + } else { + listOf( + error.javaClass.simpleName, + error.toString(), + "Cause: " + error.cause + ", Stacktrace: " + Log.getStackTraceString(error)) + } } else { - listOf( - exception.javaClass.simpleName, - exception.toString(), - "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)) + listOf(result) } } @@ -312,9 +312,9 @@ interface ExampleHostApi { channel.setMessageHandler { _, reply -> val wrapped: List = try { - listOf(api.getHostLanguage()) + MessagesPigeonUtils.wrapResponse(api.getHostLanguage(), null) } catch (exception: Throwable) { - MessagesPigeonUtils.wrapError(exception) + MessagesPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -335,9 +335,9 @@ interface ExampleHostApi { val bArg = args[1] as Long val wrapped: List = try { - listOf(api.add(aArg, bArg)) + MessagesPigeonUtils.wrapResponse(api.add(aArg, bArg), null) } catch (exception: Throwable) { - MessagesPigeonUtils.wrapError(exception) + MessagesPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -358,10 +358,10 @@ interface ExampleHostApi { api.sendMessage(messageArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(MessagesPigeonUtils.wrapError(error)) + reply.reply(MessagesPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(MessagesPigeonUtils.wrapResult(data)) + reply.reply(MessagesPigeonUtils.wrapResponse(data, null)) } } } diff --git a/packages/pigeon/example/app/ios/Runner/Messages.g.swift b/packages/pigeon/example/app/ios/Runner/Messages.g.swift index 378fea40d4bf..e6c58f524c4c 100644 --- a/packages/pigeon/example/app/ios/Runner/Messages.g.swift +++ b/packages/pigeon/example/app/ios/Runner/Messages.g.swift @@ -14,30 +14,30 @@ import Foundation #error("Unsupported platform.") #endif -private func wrapResult(_ result: Any?) -> [Any?] { - return [result] -} - -private func wrapError(_ error: Any) -> [Any?] { - if let pigeonError = error as? PigeonError { - return [ - pigeonError.code, - pigeonError.message, - pigeonError.details, - ] - } - if let flutterError = error as? FlutterError { +private func wrapResponse(_ result: Any?, _ error: Any?) -> [Any?] { + if let error = error { + if let pigeonError = error as? PigeonError { + return [ + pigeonError.code, + pigeonError.message, + pigeonError.details, + ] + } + if let flutterError = error as? FlutterError { + return [ + flutterError.code, + flutterError.message, + flutterError.details, + ] + } return [ - flutterError.code, - flutterError.message, - flutterError.details, + "\(error)", + "\(Swift.type(of: error))", + "Stacktrace: \(Thread.callStackSymbols)", ] + } else { + return [result] } - return [ - "\(error)", - "\(Swift.type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)", - ] } private func createConnectionError(withChannelName channelName: String) -> PigeonError { @@ -302,9 +302,9 @@ class ExampleHostApiSetup { getHostLanguageChannel.setMessageHandler { _, reply in do { let result = try api.getHostLanguage() - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -320,9 +320,9 @@ class ExampleHostApiSetup { let bArg = args[1] as! Int64 do { let result = try api.add(aArg, to: bArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -338,9 +338,9 @@ class ExampleHostApiSetup { api.sendMessage(message: messageArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } diff --git a/packages/pigeon/example/app/windows/runner/messages.g.cpp b/packages/pigeon/example/app/windows/runner/messages.g.cpp index 11453da4e053..f8404524858b 100644 --- a/packages/pigeon/example/app/windows/runner/messages.g.cpp +++ b/packages/pigeon/example/app/windows/runner/messages.g.cpp @@ -26,6 +26,19 @@ using ::flutter::EncodableList; using ::flutter::EncodableMap; using ::flutter::EncodableValue; +static EncodableValue WrapResponse(const EncodableValue* result, + const FlutterError* error) { + if (error) { + return EncodableValue(EncodableList{EncodableValue(error->code()), + EncodableValue(error->message()), + error->details()}); + } + if (result) { + return EncodableValue(EncodableList{*result}); + } + return EncodableValue(EncodableList{EncodableValue()}); +} + FlutterError CreateConnectionError(const std::string channel_name) { return FlutterError( "channel-error", @@ -410,14 +423,15 @@ void ExampleHostApi::SetUp(::flutter::BinaryMessenger* binary_messenger, try { ErrorOr output = api->GetHostLanguage(); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -438,26 +452,31 @@ void ExampleHostApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_arg = args.at(0); if (encodable_a_arg.IsNull()) { - reply(WrapError("a_arg unexpectedly null.")); + FlutterError error("Error", "a_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const int64_t a_arg = encodable_a_arg.LongValue(); const auto& encodable_b_arg = args.at(1); if (encodable_b_arg.IsNull()) { - reply(WrapError("b_arg unexpectedly null.")); + FlutterError error("Error", "b_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const int64_t b_arg = encodable_b_arg.LongValue(); ErrorOr output = api->Add(a_arg, b_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -478,23 +497,25 @@ void ExampleHostApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_message_arg = args.at(0); if (encodable_message_arg.IsNull()) { - reply(WrapError("message_arg unexpectedly null.")); + FlutterError error("Error", "message_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& message_arg = std::any_cast( std::get(encodable_message_arg)); api->SendMessage(message_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { diff --git a/packages/pigeon/lib/src/cpp/cpp_generator.dart b/packages/pigeon/lib/src/cpp/cpp_generator.dart index 21c39fd97299..3d4bb370a9b2 100644 --- a/packages/pigeon/lib/src/cpp/cpp_generator.dart +++ b/packages/pigeon/lib/src/cpp/cpp_generator.dart @@ -952,6 +952,32 @@ class CppSourceGenerator extends StructuredGenerator { indent.newln(); } + @override + void writeWrapResponse( + InternalCppOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { + indent.newln(); + indent.format(''' +static EncodableValue WrapResponse(const EncodableValue* result, const FlutterError* error) { +\tif (error) { +\t\treturn EncodableValue(EncodableList{ +\t\t\tEncodableValue(error->code()), +\t\t\tEncodableValue(error->message()), +\t\t\terror->details() +\t\t}); +\t} +\tif (result) { +\t\treturn EncodableValue(EncodableList{ +\t\t\t*result +\t\t}); +\t} +\treturn EncodableValue(EncodableList{EncodableValue()}); +}'''); + } + @override void writeFileImports( InternalCppOptions generatorOptions, @@ -1009,6 +1035,13 @@ class CppSourceGenerator extends StructuredGenerator { indent.writeln('using $using;'); } indent.newln(); + writeWrapResponse( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); + indent.newln(); _writeFunctionDefinition( indent, 'CreateConnectionError', @@ -1932,7 +1965,10 @@ EncodableValue $_overflowClassName::FromEncodableList( '}', () { indent.writeln( - 'reply(WrapError("$argName unexpectedly null."));', + 'FlutterError error("Error", "$argName unexpectedly null.", EncodableValue());', + ); + indent.writeln( + 'reply(WrapResponse(nullptr, &error));', ); indent.writeln('return;'); }, @@ -1986,7 +2022,10 @@ EncodableValue $_overflowClassName::FromEncodableList( // side of potential double-call rather than no call (which is // also an API violation) so that unexpected errors have a better // chance of being caught and handled in a useful way. - indent.writeln('reply(WrapError(exception.what()));'); + indent.writeln( + 'FlutterError error("Error", exception.what(), EncodableValue());', + ); + indent.writeln('reply(WrapResponse(nullptr, &error));'); }); }); }); @@ -2223,55 +2262,50 @@ return EncodableValue(EncodableList{ TypeDeclaration returnType, { String prefix = '', }) { - final String nonErrorPath; - final String errorCondition; - final String errorGetter; - - const nullValue = 'EncodableValue()'; + // Ideally this code would use an initializer list to create + // an EncodableList inline, which would be less code. However, + // that would always copy the element, so the slightly more + // verbose create-and-push approach is used instead. if (returnType.isVoid) { - nonErrorPath = '${prefix}wrapped.push_back($nullValue);'; - errorCondition = 'output.has_value()'; - errorGetter = 'value'; + return ''' +${prefix}if (output.has_value()) { +$prefix\treply(WrapResponse(nullptr, &output.value())); +$prefix\treturn; +$prefix} +${prefix}reply(WrapResponse(nullptr, nullptr));'''; } else { final HostDatatype hostType = getHostDatatype( returnType, _shortBaseCppTypeForBuiltinDartType, ); - const extractedValue = 'std::move(output).TakeValue()'; final wrapperType = hostType.isBuiltin ? 'EncodableValue' : 'CustomEncodableValue'; + if (returnType.isNullable) { - // The value is a std::optional, so needs an extra layer of - // handling. - nonErrorPath = - ''' + return ''' +${prefix}if (output.has_error()) { +$prefix\treply(WrapResponse(nullptr, &output.error())); +$prefix\treturn; +$prefix} ${prefix}auto output_optional = $extractedValue; ${prefix}if (output_optional) { -$prefix\twrapped.push_back($wrapperType(std::move(output_optional).value())); +$prefix\tEncodableValue result_value($wrapperType(std::move(output_optional).value())); +$prefix\treply(WrapResponse(&result_value, nullptr)); $prefix} else { -$prefix\twrapped.push_back($nullValue); +$prefix\treply(WrapResponse(nullptr, nullptr)); $prefix}'''; } else { - nonErrorPath = - '${prefix}wrapped.push_back($wrapperType($extractedValue));'; - } - errorCondition = 'output.has_error()'; - errorGetter = 'error'; - } - // Ideally this code would use an initializer list to create - // an EncodableList inline, which would be less code. However, - // that would always copy the element, so the slightly more - // verbose create-and-push approach is used instead. - return ''' -${prefix}if ($errorCondition) { -$prefix\treply(WrapError(output.$errorGetter())); + return ''' +${prefix}if (output.has_error()) { +$prefix\treply(WrapResponse(nullptr, &output.error())); $prefix\treturn; $prefix} -${prefix}EncodableList wrapped; -$nonErrorPath -${prefix}reply(EncodableValue(std::move(wrapped)));'''; +${prefix}EncodableValue result_value($wrapperType($extractedValue)); +${prefix}reply(WrapResponse(&result_value, nullptr));'''; + } + } } @override diff --git a/packages/pigeon/lib/src/dart/dart_generator.dart b/packages/pigeon/lib/src/dart/dart_generator.dart index ea654df4da6f..536d0810953b 100644 --- a/packages/pigeon/lib/src/dart/dart_generator.dart +++ b/packages/pigeon/lib/src/dart/dart_generator.dart @@ -575,14 +575,9 @@ class DartGenerator extends StructuredGenerator { docCommentSpec, ); - final bool isAsync = func.isAsynchronous; - final String returnType = isAsync - ? 'Future<${addGenericTypes(func.returnType)}>' - : addGenericTypes(func.returnType); - final String argSignature = _getMethodParameterSignature( - func.parameters, + indent.writeln( + '${_getMethodSignature(name: func.name, parameters: func.parameters, returnType: func.returnType, isAsynchronous: func.isAsynchronous)};', ); - indent.writeln('$returnType ${func.name}($argSignature);'); indent.newln(); } indent.write( @@ -1146,7 +1141,12 @@ final BinaryMessenger? ${varNamePrefix}binaryMessenger; if (root.containsFlutterApi || root.containsProxyApi || generatorOptions.testOut != null) { - _writeWrapResponse(generatorOptions, root, indent); + writeWrapResponse( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); } if (root.classes.isNotEmpty) { _writeDeepEquals(indent); @@ -1161,8 +1161,13 @@ final BinaryMessenger? ${varNamePrefix}binaryMessenger; } } - /// Writes the `wrapResponse` method. - void _writeWrapResponse(InternalDartOptions opt, Root root, Indent indent) { + @override + void writeWrapResponse( + InternalDartOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { indent.newln(); indent.writeScoped( 'List wrapResponse({Object? result, PlatformException? error, bool empty = false}) {', @@ -1348,9 +1353,8 @@ if (wrapped == null) { required bool addSuffixVariable, }) { addDocumentationComments(indent, documentationComments, docCommentSpec); - final String argSignature = _getMethodParameterSignature(parameters); indent.write( - 'Future<${addGenericTypes(returnType)}> $name($argSignature) async ', + '${_getMethodSignature(name: name, parameters: parameters, returnType: returnType, isAsynchronous: true)} async ', ); indent.addScoped('{', '}', () { writeHostMethodMessageCall( @@ -1601,6 +1605,20 @@ String _castValue(String value, TypeDeclaration type) { String _getSafeArgumentName(int count, NamedType field) => field.name.isEmpty ? 'arg$count' : 'arg_${field.name}'; +/// Returns the method signature for a Dart method. +String _getMethodSignature({ + required String name, + required Iterable parameters, + required TypeDeclaration returnType, + bool isAsynchronous = false, +}) { + final String returnTypeString = isAsynchronous + ? 'Future<${addGenericTypes(returnType)}>' + : addGenericTypes(returnType); + final String argSignature = _getMethodParameterSignature(parameters); + return '$returnTypeString $name($argSignature)'; +} + /// Generates a parameter name if one isn't defined. String getParameterName(int count, NamedType field) => field.name.isEmpty ? 'arg$count' : field.name; diff --git a/packages/pigeon/lib/src/generator.dart b/packages/pigeon/lib/src/generator.dart index e08382d20f7a..9ed1c63f3bd0 100644 --- a/packages/pigeon/lib/src/generator.dart +++ b/packages/pigeon/lib/src/generator.dart @@ -161,6 +161,14 @@ abstract class StructuredGenerator required String dartPackageName, }); + /// Writes the helper method to wrap responses (success and error). + void writeWrapResponse( + T generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) {} + /// Writes code to [indent] that opens file namespace if needed. /// /// This method is not required, and does not need to be overridden. diff --git a/packages/pigeon/lib/src/java/java_generator.dart b/packages/pigeon/lib/src/java/java_generator.dart index 701c7cb8eb3f..97a9a84a8c45 100644 --- a/packages/pigeon/lib/src/java/java_generator.dart +++ b/packages/pigeon/lib/src/java/java_generator.dart @@ -1017,7 +1017,6 @@ if (wrapped == null) { }); for (final Method func in api.methods) { - final String resultType = _getResultType(func.returnType); final String returnType = func.returnType.isVoid ? 'Void' : _javaTypeForDartType(func.returnType); @@ -1028,18 +1027,8 @@ if (wrapped == null) { _docCommentSpec, ); if (func.parameters.isEmpty) { - indent.write( - 'public void ${func.name}(@NonNull $resultType result) ', - ); sendArgument = 'null'; } else { - final Iterable argTypes = func.parameters.map( - (NamedType e) => _nullsafeJavaTypeForDartType(e.type), - ); - final Iterable argNames = indexMap( - func.parameters, - _getSafeArgumentName, - ); final Iterable enumSafeArgNames = indexMap( func.parameters, getSafeArgumentExpression, @@ -1051,15 +1040,8 @@ if (wrapped == null) { sendArgument = 'new ArrayList<>(Arrays.asList(${enumSafeArgNames.join(', ')}))'; } - final String argsSignature = map2( - argTypes, - argNames, - (String x, String y) => '$x $y', - ).join(', '); - indent.write( - 'public void ${func.name}($argsSignature, @NonNull $resultType result) ', - ); } + indent.write('public ${_getMethodSignature(func, isHostApi: false)} '); indent.addScoped('{', '}', () { const channel = 'channel'; indent.writeln( @@ -1243,30 +1225,6 @@ if (wrapped == null) { Api api, final Method method, ) { - final String resultType = _getResultType(method.returnType); - final String nullableType = method.isAsynchronous - ? '' - : _nullabilityAnnotationFromType(method.returnType); - final String returnType = method.isAsynchronous - ? 'void' - : _javaTypeForDartType(method.returnType); - final argSignature = []; - if (method.parameters.isNotEmpty) { - final Iterable argTypes = method.parameters.map( - (NamedType e) => _nullsafeJavaTypeForDartType(e.type), - ); - final Iterable argNames = method.parameters.map( - (NamedType e) => e.name, - ); - argSignature.addAll( - map2(argTypes, argNames, (String argType, String argName) { - return '$argType $argName'; - }), - ); - } - if (method.isAsynchronous) { - argSignature.add('@NonNull $resultType result'); - } if (method.documentationComments.isNotEmpty) { addDocumentationComments( indent, @@ -1276,10 +1234,7 @@ if (wrapped == null) { } else { indent.newln(); } - if (nullableType != '') { - indent.writeln(nullableType); - } - indent.writeln('$returnType ${method.name}(${argSignature.join(', ')});'); + indent.writeln('${_getMethodSignature(method, isHostApi: true)};'); } /// Write a single method's handler for the setUp function. @@ -1318,7 +1273,6 @@ if (wrapped == null) { final String returnType = method.returnType.isVoid ? 'Void' : _javaTypeForDartType(method.returnType); - indent.writeln('ArrayList wrapped = new ArrayList<>();'); final methodArgument = []; if (method.parameters.isNotEmpty) { indent.writeln( @@ -1348,17 +1302,15 @@ if (wrapped == null) { const resultName = 'resultCallback'; indent.format(''' $resultType $resultName = -\t\tnew $resultType() { -\t\t\tpublic void success($resultParam) { -\t\t\t\twrapped.add(0, $addResultArg); -\t\t\t\treply.reply(wrapped); -\t\t\t} - -\t\t\tpublic void error(Throwable error) { -\t\t\t\tArrayList wrappedError = wrapError(error); -\t\t\t\treply.reply(wrappedError); -\t\t\t} -\t\t}; + new $resultType() { + public void success($resultParam) { + reply.reply(wrapResponse($addResultArg, null)); + } + + public void error(Throwable error) { + reply.reply(wrapResponse(null, error)); + } + }; '''); methodArgument.add(resultName); } @@ -1370,21 +1322,16 @@ $resultType $resultName = indent.addScoped('{', '}', () { if (method.returnType.isVoid) { indent.writeln('$call;'); - indent.writeln('wrapped.add(0, null);'); + indent.writeln('reply.reply(wrapResponse(null, null));'); } else { indent.writeln('$returnType output = $call;'); - indent.writeln('wrapped.add(0, output);'); + indent.writeln('reply.reply(wrapResponse(output, null));'); } }); indent.add(' catch (Throwable exception) '); indent.addScoped('{', '}', () { - if (method.isAsynchronous) { - indent.writeln('reply.reply(wrapError(exception));'); - } else { - indent.writeln('wrapped = wrapError(exception);'); - } + indent.writeln('reply.reply(wrapResponse(null, exception));'); }); - indent.writeln('reply.reply(wrapped);'); } }); }); @@ -1445,23 +1392,33 @@ $resultType $resultName = }); } - void _writeWrapError(Indent indent) { + @override + void writeWrapResponse( + InternalJavaOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { indent.format(''' @NonNull -protected static ArrayList wrapError(@NonNull Throwable exception) { -\tArrayList errorList = new ArrayList<>(3); -\tif (exception instanceof FlutterError) { -\t\tFlutterError error = (FlutterError) exception; -\t\terrorList.add(error.code); -\t\terrorList.add(error.getMessage()); -\t\terrorList.add(error.details); +protected static ArrayList wrapResponse(@Nullable Object result, @Nullable Throwable error) { +\tArrayList response = new ArrayList<>(); +\tif (error != null) { +\t\tif (error instanceof FlutterError) { +\t\t\tFlutterError flutterError = (FlutterError) error; +\t\t\tresponse.add(flutterError.code); +\t\t\tresponse.add(flutterError.getMessage()); +\t\t\tresponse.add(flutterError.details); +\t\t} else { +\t\t\tresponse.add(error.toString()); +\t\t\tresponse.add(error.getClass().getSimpleName()); +\t\t\tresponse.add( +\t\t\t\t"Cause: " + error.getCause() + ", Stacktrace: " + Log.getStackTraceString(error)); +\t\t} \t} else { -\t\terrorList.add(exception.toString()); -\t\terrorList.add(exception.getClass().getSimpleName()); -\t\terrorList.add( -\t\t\t"Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); +\t\tresponse.add(result); \t} -\treturn errorList; +\treturn response; }'''); } @@ -1501,7 +1458,12 @@ protected static ArrayList wrapError(@NonNull Throwable exception) { }) { if (root.containsHostApi) { indent.newln(); - _writeWrapError(indent); + writeWrapResponse( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); } if (root.containsFlutterApi) { indent.newln(); @@ -1564,6 +1526,43 @@ String _intToEnum(String expression, String enumName, bool nullable) { return nullable ? '$expression == null ? null : $toEnum' : toEnum; } +/// Returns the method signature for [method]. +String _getMethodSignature(Method method, {required bool isHostApi}) { + final String resultType = _getResultType(method.returnType); + final String nullableType = + method.isAsynchronous || !isHostApi || method.returnType.isVoid + ? '' + : _nullabilityAnnotationFromType(method.returnType); + final String returnType = method.isAsynchronous || !isHostApi + ? 'void' + : _javaTypeForDartType(method.returnType); + + final argSignature = []; + if (method.parameters.isNotEmpty) { + final Iterable argTypes = method.parameters.map( + (NamedType e) => _nullsafeJavaTypeForDartType(e.type), + ); + final Iterable argNames = indexMap( + method.parameters, + (int index, Parameter e) => isHostApi + ? _getArgumentName(index, e) + : _getSafeArgumentName(index, e), + ); + argSignature.addAll( + map2(argTypes, argNames, (String argType, String argName) { + return '$argType $argName'; + }), + ); + } + + if (method.isAsynchronous || !isHostApi) { + argSignature.add('@NonNull $resultType result'); + } + + final nullablePrefix = nullableType.isNotEmpty ? '$nullableType ' : ''; + return '$nullablePrefix$returnType ${method.name}(${argSignature.join(', ')})'; +} + String _getArgumentName(int count, NamedType argument) => argument.name.isEmpty ? 'arg$count' : argument.name; diff --git a/packages/pigeon/lib/src/kotlin/kotlin_generator.dart b/packages/pigeon/lib/src/kotlin/kotlin_generator.dart index 69aa2f69ed24..c909e533c5c4 100644 --- a/packages/pigeon/lib/src/kotlin/kotlin_generator.dart +++ b/packages/pigeon/lib/src/kotlin/kotlin_generator.dart @@ -1294,36 +1294,39 @@ if (wrapped == null) { } } - void _writeWrapResult(Indent indent) { - indent.newln(); - indent.write('fun wrapResult(result: Any?): List '); - indent.addScoped('{', '}', () { - indent.writeln('return listOf(result)'); - }); - } - - void _writeWrapError(InternalKotlinOptions generatorOptions, Indent indent) { + @override + void writeWrapResponse( + InternalKotlinOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { indent.newln(); - indent.write('fun wrapError(exception: Throwable): List '); + indent.write( + 'fun wrapResponse(result: Any?, error: Throwable?): List ', + ); indent.addScoped('{', '}', () { - indent.write( - 'return if (exception is ${_getErrorClassName(generatorOptions)}) ', - ); - indent.addScoped('{', '}', () { - indent.writeScoped('listOf(', ')', () { - indent.writeln('exception.code,'); - indent.writeln('exception.message,'); - indent.writeln('exception.details'); + indent.writeScoped('return if (error != null) {', '}', () { + indent.write('if (error is ${_getErrorClassName(generatorOptions)}) '); + indent.addScoped('{', '}', () { + indent.writeScoped('listOf(', ')', () { + indent.writeln('error.code,'); + indent.writeln('error.message,'); + indent.writeln('error.details'); + }); + }, addTrailingNewline: false); + indent.addScoped(' else {', '}', () { + indent.writeScoped('listOf(', ')', () { + indent.writeln('error.javaClass.simpleName,'); + indent.writeln('error.toString(),'); + indent.writeln( + '"Cause: " + error.cause + ", Stacktrace: " + Log.getStackTraceString(error)', + ); + }); }); - }, addTrailingNewline: false); + }); indent.addScoped(' else {', '}', () { - indent.writeScoped('listOf(', ')', () { - indent.writeln('exception.javaClass.simpleName,'); - indent.writeln('exception.toString(),'); - indent.writeln( - '"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)', - ); - }); + indent.writeln('listOf(result)'); }); }); } @@ -1515,8 +1518,12 @@ fun floatHash(f: Float): Int { _writeCreateConnectionError(generatorOptions, indent); } if (root.containsHostApi || root.containsProxyApi) { - _writeWrapResult(indent); - _writeWrapError(generatorOptions, indent); + writeWrapResponse( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); } if (root.classes.isNotEmpty) { _writeNumberHelpers(indent); @@ -1556,13 +1563,11 @@ fun floatHash(f: Float): Int { } } - static void _writeMethodDeclaration( - Indent indent, { + /// Returns the method signature for a Kotlin method. + static String _getMethodSignature({ required String name, required TypeDeclaration returnType, required List parameters, - List documentationComments = const [], - int? minApiRequirement, bool isAsynchronous = false, bool isOpen = false, bool isAbstract = false, @@ -1587,31 +1592,52 @@ fun floatHash(f: Float): Int { : _nullSafeKotlinTypeForDartType(returnType); final resultType = returnType.isVoid ? 'Unit' : returnTypeString; - addDocumentationComments(indent, documentationComments, _docCommentSpec); - - if (minApiRequirement != null) { - indent.writeln( - '@androidx.annotation.RequiresApi(api = $minApiRequirement)', - ); - } final openKeyword = isOpen ? 'open ' : ''; final abstractKeyword = isAbstract ? 'abstract ' : ''; if (isAsynchronous) { argSignature.add('callback: (Result<$resultType>) -> Unit'); - indent.writeln( - '$openKeyword${abstractKeyword}fun $name(${argSignature.join(', ')})', - ); + return '$openKeyword${abstractKeyword}fun $name(${argSignature.join(', ')})'; } else if (returnType.isVoid) { - indent.writeln( - '$openKeyword${abstractKeyword}fun $name(${argSignature.join(', ')})', - ); + return '$openKeyword${abstractKeyword}fun $name(${argSignature.join(', ')})'; } else { + return '$openKeyword${abstractKeyword}fun $name(${argSignature.join(', ')}): $returnTypeString'; + } + } + + static void _writeMethodDeclaration( + Indent indent, { + required String name, + required TypeDeclaration returnType, + required List parameters, + List documentationComments = const [], + int? minApiRequirement, + bool isAsynchronous = false, + bool isOpen = false, + bool isAbstract = false, + String Function(int index, NamedType type) getArgumentName = + _getArgumentName, + }) { + addDocumentationComments(indent, documentationComments, _docCommentSpec); + + if (minApiRequirement != null) { indent.writeln( - '$openKeyword${abstractKeyword}fun $name(${argSignature.join(', ')}): $returnTypeString', + '@androidx.annotation.RequiresApi(api = $minApiRequirement)', ); } + + indent.writeln( + _getMethodSignature( + name: name, + returnType: returnType, + parameters: parameters, + isAsynchronous: isAsynchronous, + isOpen: isOpen, + isAbstract: isAbstract, + getArgumentName: getArgumentName, + ), + ); } void _writeHostMethodMessageHandler( @@ -1671,18 +1697,18 @@ fun floatHash(f: Float): Int { indent.writeln('val error = result.exceptionOrNull()'); indent.writeScoped('if (error != null) {', '}', () { indent.writeln( - 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapError(error))', + 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResponse(null, error))', ); }, addTrailingNewline: false); indent.addScoped(' else {', '}', () { if (returnType.isVoid) { indent.writeln( - 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResult(null))', + 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResponse(null, null))', ); } else { indent.writeln('val data = result.getOrNull()'); indent.writeln( - 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResult(data))', + 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResponse(data, null))', ); } }); @@ -1691,15 +1717,19 @@ fun floatHash(f: Float): Int { indent.writeScoped('val wrapped: List = try {', '}', () { if (returnType.isVoid) { indent.writeln(call); - indent.writeln('listOf(null)'); + indent.writeln( + '${_getUtilsClassName(generatorOptions)}.wrapResponse(null, null)', + ); } else { - indent.writeln('listOf($call)'); + indent.writeln( + '${_getUtilsClassName(generatorOptions)}.wrapResponse($call, null)', + ); } }, addTrailingNewline: false); indent.add(' catch (exception: Throwable) '); indent.addScoped('{', '}', () { indent.writeln( - '${_getUtilsClassName(generatorOptions)}.wrapError(exception)', + '${_getUtilsClassName(generatorOptions)}.wrapResponse(null, exception)', ); }); indent.writeln('reply.reply(wrapped)'); @@ -2103,7 +2133,7 @@ fun floatHash(f: Float): Int { ) if (api != null) { channel.setMessageHandler { _, reply -> - reply.reply(${_getUtilsClassName(generatorOptions)}.wrapError(UnsupportedOperationException( + reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResponse(null, UnsupportedOperationException( "Call references class `$className`, which requires api version $apiRequirement." ))) } diff --git a/packages/pigeon/lib/src/objc/objc_generator.dart b/packages/pigeon/lib/src/objc/objc_generator.dart index 9c907b412ff3..85b04a53b335 100644 --- a/packages/pigeon/lib/src/objc/objc_generator.dart +++ b/packages/pigeon/lib/src/objc/objc_generator.dart @@ -382,7 +382,7 @@ class ObjcHeaderGenerator extends StructuredGenerator { ); indent.writeln( - '${_makeObjcSignature(func: func, options: generatorOptions, returnType: 'void', lastArgName: 'completion', lastArgType: callbackType)};', + '${_getMethodSignature(func: func, options: generatorOptions, returnType: 'void', lastArgName: 'completion', lastArgType: callbackType)};', ); } indent.writeln('@end'); @@ -460,7 +460,7 @@ class ObjcHeaderGenerator extends StructuredGenerator { generatorComments: generatorComments, ); - final String signature = _makeObjcSignature( + final String signature = _getMethodSignature( func: func, options: generatorOptions, returnType: returnType, @@ -1134,7 +1134,12 @@ if (self.wrapped == nil) { required String dartPackageName, }) { if (root.containsHostApi) { - _writeWrapError(indent); + writeWrapResponse( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); indent.newln(); } if (root.containsFlutterApi) { @@ -1156,15 +1161,21 @@ if (self.wrapped == nil) { } } - void _writeWrapError(Indent indent) { + @override + void writeWrapResponse( + InternalObjcOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { indent.format(''' static NSArray *wrapResult(id result, FlutterError *error) { -\tif (error) { -\t\treturn @[ -\t\t\terror.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] -\t\t]; -\t} -\treturn @[ result ?: [NSNull null] ]; + if (error) { + return @[ + error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] + ]; + } + return @[ result ?: [NSNull null] ]; }'''); } @@ -1491,7 +1502,7 @@ void _writeMethod( '@[${func.parameters.map(makeVarOrNSNullExpression).join(', ')}]'; } indent.write( - _makeObjcSignature( + _getMethodSignature( func: func, options: languageOptions, returnType: 'void', @@ -1963,7 +1974,7 @@ Iterable _getSelectorComponents( /// arguments that don't exist in the pigeon file but are required in the objc /// output. [argNameFunc] is the function used to generate the argument name /// [func.parameters]. -String _makeObjcSignature({ +String _getMethodSignature({ required Method func, required InternalObjcOptions options, required String returnType, diff --git a/packages/pigeon/lib/src/swift/swift_generator.dart b/packages/pigeon/lib/src/swift/swift_generator.dart index 8e8fd012e604..cf6c6a924025 100644 --- a/packages/pigeon/lib/src/swift/swift_generator.dart +++ b/packages/pigeon/lib/src/swift/swift_generator.dart @@ -1440,43 +1440,48 @@ if (wrapped == nil) { }); } - void _writeWrapResult(Indent indent) { - indent.newln(); - indent.write('private func wrapResult(_ result: Any?) -> [Any?] '); - indent.addScoped('{', '}', () { - indent.writeln('return [result]'); - }); - } - - void _writeWrapError(InternalSwiftOptions generatorOptions, Indent indent) { + @override + void writeWrapResponse( + InternalSwiftOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, + }) { indent.newln(); - indent.write('private func wrapError(_ error: Any) -> [Any?] '); + indent.write( + 'private func wrapResponse(_ result: Any?, _ error: Any?) -> [Any?] ', + ); indent.addScoped('{', '}', () { - indent.write( - 'if let pigeonError = error as? ${_getErrorClassName(generatorOptions)} ', - ); - indent.addScoped('{', '}', () { - indent.write('return '); - indent.addScoped('[', ']', () { - indent.writeln('pigeonError.code,'); - indent.writeln('pigeonError.message,'); - indent.writeln('pigeonError.details,'); + indent.writeScoped('if let error = error {', '}', () { + indent.write( + 'if let pigeonError = error as? ${_getErrorClassName(generatorOptions)} ', + ); + indent.addScoped('{', '}', () { + indent.write('return '); + indent.addScoped('[', ']', () { + indent.writeln('pigeonError.code,'); + indent.writeln('pigeonError.message,'); + indent.writeln('pigeonError.details,'); + }); + }); + indent.write('if let flutterError = error as? FlutterError '); + indent.addScoped('{', '}', () { + indent.write('return '); + indent.addScoped('[', ']', () { + indent.writeln('flutterError.code,'); + indent.writeln('flutterError.message,'); + indent.writeln('flutterError.details,'); + }); }); - }); - indent.write('if let flutterError = error as? FlutterError '); - indent.addScoped('{', '}', () { indent.write('return '); indent.addScoped('[', ']', () { - indent.writeln('flutterError.code,'); - indent.writeln('flutterError.message,'); - indent.writeln('flutterError.details,'); + indent.writeln(r'"\(error)",'); + indent.writeln(r'"\(Swift.type(of: error))",'); + indent.writeln(r'"Stacktrace: \(Thread.callStackSymbols)",'); }); }); - indent.write('return '); - indent.addScoped('[', ']', () { - indent.writeln(r'"\(error)",'); - indent.writeln(r'"\(Swift.type(of: error))",'); - indent.writeln(r'"Stacktrace: \(Thread.callStackSymbols)",'); + indent.addScoped(' else {', '}', () { + indent.writeln('return [result]'); }); }); } @@ -1636,8 +1641,12 @@ func $deepHashName(value: Any?, hasher: inout Hasher) { required String dartPackageName, }) { if (root.containsHostApi || root.containsProxyApi) { - _writeWrapResult(indent); - _writeWrapError(generatorOptions, indent); + writeWrapResponse( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); } if (root.containsFlutterApi || root.containsProxyApi) { _writeCreateConnectionError(generatorOptions, indent); @@ -1997,11 +2006,11 @@ func $deepHashName(value: Any?, hasher: inout Hasher) { indent.addScoped('{', '}', nestCount: 0, () { indent.writeln('case .success$successVariableInit:'); indent.nest(1, () { - indent.writeln('reply(wrapResult($resultName))'); + indent.writeln('reply(wrapResponse($resultName, nil))'); }); indent.writeln('case .failure(let error):'); indent.nest(1, () { - indent.writeln('reply(wrapError(error))'); + indent.writeln('reply(wrapResponse(nil, error))'); }); }); }); @@ -2010,14 +2019,14 @@ func $deepHashName(value: Any?, hasher: inout Hasher) { indent.addScoped('{', '}', () { if (returnType.isVoid) { indent.writeln(call); - indent.writeln('reply(wrapResult(nil))'); + indent.writeln('reply(wrapResponse(nil, nil))'); } else { indent.writeln('let result = $call'); - indent.writeln('reply(wrapResult(result))'); + indent.writeln('reply(wrapResponse(result, nil))'); } }, addTrailingNewline: false); indent.addScoped(' catch {', '}', () { - indent.writeln('reply(wrapError(error))'); + indent.writeln('reply(wrapResponse(nil, error))'); }); } }); 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 3dc0b0545c28..91021f5b22f3 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 @@ -189,20 +189,25 @@ static int pigeonDeepHashCode(Object value) { } @NonNull - protected static ArrayList wrapError(@NonNull Throwable exception) { - ArrayList errorList = new ArrayList<>(3); - if (exception instanceof FlutterError) { - FlutterError error = (FlutterError) exception; - errorList.add(error.code); - errorList.add(error.getMessage()); - errorList.add(error.details); + protected static ArrayList wrapResponse( + @Nullable Object result, @Nullable Throwable error) { + ArrayList response = new ArrayList<>(); + if (error != null) { + if (error instanceof FlutterError) { + FlutterError flutterError = (FlutterError) error; + response.add(flutterError.code); + response.add(flutterError.getMessage()); + response.add(flutterError.details); + } else { + response.add(error.toString()); + response.add(error.getClass().getSimpleName()); + response.add( + "Cause: " + error.getCause() + ", Stacktrace: " + Log.getStackTraceString(error)); + } } else { - errorList.add(exception.toString()); - errorList.add(exception.getClass().getSimpleName()); - errorList.add( - "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + response.add(result); } - return errorList; + return response; } @NonNull @@ -3717,14 +3722,12 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); try { api.noop(); - wrapped.add(0, null); + reply.reply(wrapResponse(null, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3740,16 +3743,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllTypes everythingArg = (AllTypes) args.get(0); try { AllTypes output = api.echoAllTypes(everythingArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3765,14 +3766,12 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); try { Object output = api.throwError(); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3788,14 +3787,12 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); try { api.throwErrorFromVoid(); - wrapped.add(0, null); + reply.reply(wrapResponse(null, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3811,14 +3808,12 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); try { Object output = api.throwFlutterError(); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3834,16 +3829,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Long anIntArg = (Long) args.get(0); try { Long output = api.echoInt(anIntArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3859,16 +3852,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Double aDoubleArg = (Double) args.get(0); try { Double output = api.echoDouble(aDoubleArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3884,16 +3875,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Boolean aBoolArg = (Boolean) args.get(0); try { Boolean output = api.echoBool(aBoolArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3909,16 +3898,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String aStringArg = (String) args.get(0); try { String output = api.echoString(aStringArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3934,16 +3921,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; byte[] aUint8ListArg = (byte[]) args.get(0); try { byte[] output = api.echoUint8List(aUint8ListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3959,16 +3944,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Object anObjectArg = args.get(0); try { Object output = api.echoObject(anObjectArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -3984,16 +3967,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List listArg = (List) args.get(0); try { List output = api.echoList(listArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4009,16 +3990,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List enumListArg = (List) args.get(0); try { List output = api.echoEnumList(enumListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4034,16 +4013,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List classListArg = (List) args.get(0); try { List output = api.echoClassList(classListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4059,16 +4036,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List enumListArg = (List) args.get(0); try { List output = api.echoNonNullEnumList(enumListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4084,16 +4059,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List classListArg = (List) args.get(0); try { List output = api.echoNonNullClassList(classListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4109,16 +4082,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map mapArg = (Map) args.get(0); try { Map output = api.echoMap(mapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4134,16 +4105,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map stringMapArg = (Map) args.get(0); try { Map output = api.echoStringMap(stringMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4159,16 +4128,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map intMapArg = (Map) args.get(0); try { Map output = api.echoIntMap(intMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4184,16 +4151,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map enumMapArg = (Map) args.get(0); try { Map output = api.echoEnumMap(enumMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4209,16 +4174,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map classMapArg = (Map) args.get(0); try { Map output = api.echoClassMap(classMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4234,16 +4197,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map stringMapArg = (Map) args.get(0); try { Map output = api.echoNonNullStringMap(stringMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4259,16 +4220,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map intMapArg = (Map) args.get(0); try { Map output = api.echoNonNullIntMap(intMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4284,16 +4243,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map enumMapArg = (Map) args.get(0); try { Map output = api.echoNonNullEnumMap(enumMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4309,16 +4266,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map classMapArg = (Map) args.get(0); try { Map output = api.echoNonNullClassMap(classMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4334,16 +4289,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllClassesWrapper wrapperArg = (AllClassesWrapper) args.get(0); try { AllClassesWrapper output = api.echoClassWrapper(wrapperArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4359,16 +4312,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AcronymsAndTestCase acronymsArg = (AcronymsAndTestCase) args.get(0); try { AcronymsAndTestCase output = api.echoAcronyms(acronymsArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4384,16 +4335,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AcronymsAndTestCase acronymsArg = (AcronymsAndTestCase) args.get(0); try { AcronymsAndTestCase output = api.hostHTTPResponse(acronymsArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4409,16 +4358,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AcronymsAndTestCase acronymsArg = (AcronymsAndTestCase) args.get(0); try { AcronymsAndTestCase output = api.sendJSONParser(acronymsArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4434,16 +4381,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnEnum anEnumArg = (AnEnum) args.get(0); try { AnEnum output = api.echoEnum(anEnumArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4459,16 +4404,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnotherEnum anotherEnumArg = (AnotherEnum) args.get(0); try { AnotherEnum output = api.echoAnotherEnum(anotherEnumArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4484,16 +4427,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String aStringArg = (String) args.get(0); try { String output = api.echoNamedDefaultString(aStringArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4509,16 +4450,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Double aDoubleArg = (Double) args.get(0); try { Double output = api.echoOptionalDefaultDouble(aDoubleArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4534,16 +4473,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Long anIntArg = (Long) args.get(0); try { Long output = api.echoRequiredInt(anIntArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4559,17 +4496,15 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllNullableTypes aArg = (AllNullableTypes) args.get(0); AllNullableTypes bArg = (AllNullableTypes) args.get(1); try { Boolean output = api.areAllNullableTypesEqual(aArg, bArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4585,16 +4520,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllNullableTypes valueArg = (AllNullableTypes) args.get(0); try { Long output = api.getAllNullableTypesHash(valueArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4610,17 +4543,15 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllNullableTypesWithoutRecursion valueArg = (AllNullableTypesWithoutRecursion) args.get(0); try { Long output = api.getAllNullableTypesWithoutRecursionHash(valueArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4636,16 +4567,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllNullableTypes everythingArg = (AllNullableTypes) args.get(0); try { AllNullableTypes output = api.echoAllNullableTypes(everythingArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4661,18 +4590,16 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllNullableTypesWithoutRecursion everythingArg = (AllNullableTypesWithoutRecursion) args.get(0); try { AllNullableTypesWithoutRecursion output = api.echoAllNullableTypesWithoutRecursion(everythingArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4688,16 +4615,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllClassesWrapper wrapperArg = (AllClassesWrapper) args.get(0); try { String output = api.extractNestedNullableString(wrapperArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4713,16 +4638,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String nullableStringArg = (String) args.get(0); try { AllClassesWrapper output = api.createNestedNullableString(nullableStringArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4738,7 +4661,6 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Boolean aNullableBoolArg = (Boolean) args.get(0); Long aNullableIntArg = (Long) args.get(1); @@ -4747,11 +4669,10 @@ static void setUp( AllNullableTypes output = api.sendMultipleNullableTypes( aNullableBoolArg, aNullableIntArg, aNullableStringArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4767,7 +4688,6 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Boolean aNullableBoolArg = (Boolean) args.get(0); Long aNullableIntArg = (Long) args.get(1); @@ -4776,11 +4696,10 @@ static void setUp( AllNullableTypesWithoutRecursion output = api.sendMultipleNullableTypesWithoutRecursion( aNullableBoolArg, aNullableIntArg, aNullableStringArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4796,16 +4715,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Long aNullableIntArg = (Long) args.get(0); try { Long output = api.echoNullableInt(aNullableIntArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4821,16 +4738,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Double aNullableDoubleArg = (Double) args.get(0); try { Double output = api.echoNullableDouble(aNullableDoubleArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4846,16 +4761,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Boolean aNullableBoolArg = (Boolean) args.get(0); try { Boolean output = api.echoNullableBool(aNullableBoolArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4871,16 +4784,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String aNullableStringArg = (String) args.get(0); try { String output = api.echoNullableString(aNullableStringArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4896,16 +4807,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; byte[] aNullableUint8ListArg = (byte[]) args.get(0); try { byte[] output = api.echoNullableUint8List(aNullableUint8ListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4921,16 +4830,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Object aNullableObjectArg = args.get(0); try { Object output = api.echoNullableObject(aNullableObjectArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4946,16 +4853,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List aNullableListArg = (List) args.get(0); try { List output = api.echoNullableList(aNullableListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4971,16 +4876,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List enumListArg = (List) args.get(0); try { List output = api.echoNullableEnumList(enumListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4996,16 +4899,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List classListArg = (List) args.get(0); try { List output = api.echoNullableClassList(classListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5021,16 +4922,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List enumListArg = (List) args.get(0); try { List output = api.echoNullableNonNullEnumList(enumListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5046,16 +4945,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List classListArg = (List) args.get(0); try { List output = api.echoNullableNonNullClassList(classListArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5071,16 +4968,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map mapArg = (Map) args.get(0); try { Map output = api.echoNullableMap(mapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5096,16 +4991,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map stringMapArg = (Map) args.get(0); try { Map output = api.echoNullableStringMap(stringMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5121,16 +5014,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map intMapArg = (Map) args.get(0); try { Map output = api.echoNullableIntMap(intMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5146,16 +5037,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map enumMapArg = (Map) args.get(0); try { Map output = api.echoNullableEnumMap(enumMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5171,16 +5060,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map classMapArg = (Map) args.get(0); try { Map output = api.echoNullableClassMap(classMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5196,16 +5083,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map stringMapArg = (Map) args.get(0); try { Map output = api.echoNullableNonNullStringMap(stringMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5221,16 +5106,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map intMapArg = (Map) args.get(0); try { Map output = api.echoNullableNonNullIntMap(intMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5246,16 +5129,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map enumMapArg = (Map) args.get(0); try { Map output = api.echoNullableNonNullEnumMap(enumMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5271,16 +5152,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map classMapArg = (Map) args.get(0); try { Map output = api.echoNullableNonNullClassMap(classMapArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5296,16 +5175,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnEnum anEnumArg = (AnEnum) args.get(0); try { AnEnum output = api.echoNullableEnum(anEnumArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5321,16 +5198,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnotherEnum anotherEnumArg = (AnotherEnum) args.get(0); try { AnotherEnum output = api.echoAnotherNullableEnum(anotherEnumArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5346,16 +5221,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Long aNullableIntArg = (Long) args.get(0); try { Long output = api.echoOptionalNullableInt(aNullableIntArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5371,16 +5244,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String aNullableStringArg = (String) args.get(0); try { String output = api.echoNamedNullableString(aNullableStringArg); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -5396,17 +5267,14 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); VoidResult resultCallback = new VoidResult() { public void success() { - wrapped.add(0, null); - reply.reply(wrapped); + reply.reply(wrapResponse(null, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5426,19 +5294,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Long anIntArg = (Long) args.get(0); Result resultCallback = new Result() { public void success(Long result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5458,19 +5323,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Double aDoubleArg = (Double) args.get(0); Result resultCallback = new Result() { public void success(Double result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5490,19 +5352,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Boolean aBoolArg = (Boolean) args.get(0); Result resultCallback = new Result() { public void success(Boolean result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5522,19 +5381,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String aStringArg = (String) args.get(0); Result resultCallback = new Result() { public void success(String result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5554,19 +5410,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; byte[] aUint8ListArg = (byte[]) args.get(0); Result resultCallback = new Result() { public void success(byte[] result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5586,19 +5439,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Object anObjectArg = args.get(0); Result resultCallback = new Result() { public void success(Object result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5618,19 +5468,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List listArg = (List) args.get(0); Result> resultCallback = new Result>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5650,19 +5497,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List enumListArg = (List) args.get(0); Result> resultCallback = new Result>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5682,19 +5526,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List classListArg = (List) args.get(0); Result> resultCallback = new Result>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5714,19 +5555,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map mapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5746,19 +5584,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map stringMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5778,19 +5613,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map intMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5810,19 +5642,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map enumMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5842,19 +5671,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map classMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5874,19 +5700,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnEnum anEnumArg = (AnEnum) args.get(0); Result resultCallback = new Result() { public void success(AnEnum result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5906,19 +5729,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnotherEnum anotherEnumArg = (AnotherEnum) args.get(0); Result resultCallback = new Result() { public void success(AnotherEnum result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5938,17 +5758,14 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); NullableResult resultCallback = new NullableResult() { public void success(Object result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5968,17 +5785,14 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); VoidResult resultCallback = new VoidResult() { public void success() { - wrapped.add(0, null); - reply.reply(wrapped); + reply.reply(wrapResponse(null, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -5998,17 +5812,14 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); NullableResult resultCallback = new NullableResult() { public void success(Object result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6028,19 +5839,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllTypes everythingArg = (AllTypes) args.get(0); Result resultCallback = new Result() { public void success(AllTypes result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6060,19 +5868,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllNullableTypes everythingArg = (AllNullableTypes) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(AllNullableTypes result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6092,20 +5897,17 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllNullableTypesWithoutRecursion everythingArg = (AllNullableTypesWithoutRecursion) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(AllNullableTypesWithoutRecursion result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6126,19 +5928,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Long anIntArg = (Long) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(Long result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6158,19 +5957,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Double aDoubleArg = (Double) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(Double result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6190,19 +5986,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Boolean aBoolArg = (Boolean) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(Boolean result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6222,19 +6015,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String aStringArg = (String) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(String result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6254,19 +6044,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; byte[] aUint8ListArg = (byte[]) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(byte[] result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6286,19 +6073,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Object anObjectArg = args.get(0); NullableResult resultCallback = new NullableResult() { public void success(Object result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6318,19 +6102,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List listArg = (List) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6350,19 +6131,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List enumListArg = (List) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6382,19 +6160,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List classListArg = (List) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6414,19 +6189,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map mapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6446,19 +6218,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map stringMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6478,19 +6247,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map intMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6510,19 +6276,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map enumMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6542,19 +6305,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map classMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6574,19 +6334,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnEnum anEnumArg = (AnEnum) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(AnEnum result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6606,19 +6363,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnotherEnum anotherEnumArg = (AnotherEnum) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(AnotherEnum result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6638,14 +6392,12 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); try { Boolean output = api.defaultIsMainThread(); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -6662,14 +6414,12 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); try { Boolean output = api.taskQueueIsBackgroundThread(); - wrapped.add(0, output); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -6685,17 +6435,14 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); VoidResult resultCallback = new VoidResult() { public void success() { - wrapped.add(0, null); - reply.reply(wrapped); + reply.reply(wrapResponse(null, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6715,17 +6462,14 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); NullableResult resultCallback = new NullableResult() { public void success(Object result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6745,17 +6489,14 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); VoidResult resultCallback = new VoidResult() { public void success() { - wrapped.add(0, null); - reply.reply(wrapped); + reply.reply(wrapResponse(null, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6775,19 +6516,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllTypes everythingArg = (AllTypes) args.get(0); Result resultCallback = new Result() { public void success(AllTypes result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6807,19 +6545,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllNullableTypes everythingArg = (AllNullableTypes) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(AllNullableTypes result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6839,7 +6574,6 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Boolean aNullableBoolArg = (Boolean) args.get(0); Long aNullableIntArg = (Long) args.get(1); @@ -6847,13 +6581,11 @@ public void error(Throwable error) { Result resultCallback = new Result() { public void success(AllNullableTypes result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6874,20 +6606,17 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AllNullableTypesWithoutRecursion everythingArg = (AllNullableTypesWithoutRecursion) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(AllNullableTypesWithoutRecursion result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6907,7 +6636,6 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Boolean aNullableBoolArg = (Boolean) args.get(0); Long aNullableIntArg = (Long) args.get(1); @@ -6915,13 +6643,11 @@ public void error(Throwable error) { Result resultCallback = new Result() { public void success(AllNullableTypesWithoutRecursion result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6942,19 +6668,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Boolean aBoolArg = (Boolean) args.get(0); Result resultCallback = new Result() { public void success(Boolean result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -6974,19 +6697,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Long anIntArg = (Long) args.get(0); Result resultCallback = new Result() { public void success(Long result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7006,19 +6726,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Double aDoubleArg = (Double) args.get(0); Result resultCallback = new Result() { public void success(Double result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7038,19 +6755,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String aStringArg = (String) args.get(0); Result resultCallback = new Result() { public void success(String result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7070,19 +6784,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; byte[] listArg = (byte[]) args.get(0); Result resultCallback = new Result() { public void success(byte[] result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7102,19 +6813,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List listArg = (List) args.get(0); Result> resultCallback = new Result>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7134,19 +6842,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List enumListArg = (List) args.get(0); Result> resultCallback = new Result>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7166,19 +6871,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List classListArg = (List) args.get(0); Result> resultCallback = new Result>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7198,19 +6900,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List enumListArg = (List) args.get(0); Result> resultCallback = new Result>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7230,19 +6929,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List classListArg = (List) args.get(0); Result> resultCallback = new Result>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7262,19 +6958,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map mapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7294,19 +6987,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map stringMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7326,19 +7016,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map intMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7358,19 +7045,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map enumMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7390,19 +7074,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map classMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7422,19 +7103,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map stringMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7454,19 +7132,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map intMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7486,19 +7161,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map enumMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7518,19 +7190,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map classMapArg = (Map) args.get(0); Result> resultCallback = new Result>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7550,19 +7219,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnEnum anEnumArg = (AnEnum) args.get(0); Result resultCallback = new Result() { public void success(AnEnum result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7582,19 +7248,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnotherEnum anotherEnumArg = (AnotherEnum) args.get(0); Result resultCallback = new Result() { public void success(AnotherEnum result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7614,19 +7277,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Boolean aBoolArg = (Boolean) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(Boolean result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7646,19 +7306,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Long anIntArg = (Long) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(Long result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7678,19 +7335,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Double aDoubleArg = (Double) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(Double result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7710,19 +7364,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String aStringArg = (String) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(String result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7742,19 +7393,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; byte[] listArg = (byte[]) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(byte[] result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7774,19 +7422,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List listArg = (List) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7806,19 +7451,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List enumListArg = (List) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7838,19 +7480,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List classListArg = (List) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7870,19 +7509,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List enumListArg = (List) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7902,19 +7538,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; List classListArg = (List) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(List result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7934,19 +7567,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map mapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7966,19 +7596,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map stringMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -7998,19 +7625,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map intMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -8030,19 +7654,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map enumMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -8062,19 +7683,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map classMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -8094,19 +7712,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map stringMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -8126,19 +7741,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map intMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -8158,19 +7770,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map enumMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -8190,19 +7799,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; Map classMapArg = (Map) args.get(0); NullableResult> resultCallback = new NullableResult>() { public void success(Map result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -8222,19 +7828,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnEnum anEnumArg = (AnEnum) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(AnEnum result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -8254,19 +7857,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; AnotherEnum anotherEnumArg = (AnotherEnum) args.get(0); NullableResult resultCallback = new NullableResult() { public void success(AnotherEnum result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -8286,19 +7886,16 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String aStringArg = (String) args.get(0); Result resultCallback = new Result() { public void success(String result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -9937,14 +9534,12 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); try { api.noop(); - wrapped.add(0, null); + reply.reply(wrapResponse(null, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -9987,19 +9582,16 @@ static void setUp( if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; String aStringArg = (String) args.get(0); Result resultCallback = new Result() { public void success(String result) { - wrapped.add(0, result); - reply.reply(wrapped); + reply.reply(wrapResponse(result, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; @@ -10019,17 +9611,14 @@ public void error(Throwable error) { if (api != null) { channel.setMessageHandler( (message, reply) -> { - ArrayList wrapped = new ArrayList<>(); VoidResult resultCallback = new VoidResult() { public void success() { - wrapped.add(0, null); - reply.reply(wrapped); + reply.reply(wrapResponse(null, null)); } public void error(Throwable error) { - ArrayList wrappedError = wrapError(error); - reply.reply(wrappedError); + reply.reply(wrapResponse(null, error)); } }; diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m index 85e3cb3e7744..4538189392ea 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m @@ -398,7 +398,8 @@ - (nullable NSString *)echoNamedNullableString:(nullable NSString *)aNullableStr return aNullableString; } -// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +// This uses a switch statement to explicitly map the enum value to verify that all generated enum +// constants are valid and usable. - (nullable FLTAcronymsAndTestCase *)hostHTTPResponse:(FLTAcronymsAndTestCase *)acronyms error:(FlutterError *_Nullable *_Nonnull)error { FLTAcronymsEnumBox *enumBox = nil; @@ -414,14 +415,14 @@ - (nullable FLTAcronymsAndTestCase *)hostHTTPResponse:(FLTAcronymsAndTestCase *) } enumBox = [[FLTAcronymsEnumBox alloc] initWithValue:enumVal]; } - return [FLTAcronymsAndTestCase - makeWithHttpResponse:acronyms.httpResponse - jsonParser:acronyms.jsonParser - xmlNode:acronyms.xmlNode - acronymsEnum:enumBox]; + return [FLTAcronymsAndTestCase makeWithHttpResponse:acronyms.httpResponse + jsonParser:acronyms.jsonParser + xmlNode:acronyms.xmlNode + acronymsEnum:enumBox]; } -// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +// This uses a switch statement to explicitly map the enum value to verify that all generated enum +// constants are valid and usable. - (nullable FLTAcronymsAndTestCase *)sendJSONParser:(FLTAcronymsAndTestCase *)acronyms error:(FlutterError *_Nullable *_Nonnull)error { FLTAcronymsEnumBox *enumBox = nil; @@ -437,11 +438,10 @@ - (nullable FLTAcronymsAndTestCase *)sendJSONParser:(FLTAcronymsAndTestCase *)ac } enumBox = [[FLTAcronymsEnumBox alloc] initWithValue:enumVal]; } - return [FLTAcronymsAndTestCase - makeWithHttpResponse:acronyms.httpResponse - jsonParser:acronyms.jsonParser - xmlNode:acronyms.xmlNode - acronymsEnum:enumBox]; + return [FLTAcronymsAndTestCase makeWithHttpResponse:acronyms.httpResponse + jsonParser:acronyms.jsonParser + xmlNode:acronyms.xmlNode + acronymsEnum:enumBox]; } - (void)noopAsyncWithCompletion:(void (^)(FlutterError *_Nullable))completion { 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 1ec5f61626cd..2300e32f4db0 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 @@ -23,18 +23,18 @@ private object CoreTestsPigeonUtils { "channel-error", "Unable to establish connection on channel: '$channelName'.", "") } - fun wrapResult(result: Any?): List { - return listOf(result) - } - - fun wrapError(exception: Throwable): List { - return if (exception is FlutterError) { - listOf(exception.code, exception.message, exception.details) + fun wrapResponse(result: Any?, error: Throwable?): List { + return if (error != null) { + if (error is FlutterError) { + listOf(error.code, error.message, error.details) + } else { + listOf( + error.javaClass.simpleName, + error.toString(), + "Cause: " + error.cause + ", Stacktrace: " + Log.getStackTraceString(error)) + } } else { - listOf( - exception.javaClass.simpleName, - exception.toString(), - "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)) + listOf(result) } } @@ -1651,9 +1651,9 @@ interface HostIntegrationCoreApi { val wrapped: List = try { api.noop() - listOf(null) + CoreTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1673,9 +1673,9 @@ interface HostIntegrationCoreApi { val everythingArg = args[0] as AllTypes val wrapped: List = try { - listOf(api.echoAllTypes(everythingArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoAllTypes(everythingArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1693,9 +1693,9 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { _, reply -> val wrapped: List = try { - listOf(api.throwError()) + CoreTestsPigeonUtils.wrapResponse(api.throwError(), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1714,9 +1714,9 @@ interface HostIntegrationCoreApi { val wrapped: List = try { api.throwErrorFromVoid() - listOf(null) + CoreTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1734,9 +1734,9 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { _, reply -> val wrapped: List = try { - listOf(api.throwFlutterError()) + CoreTestsPigeonUtils.wrapResponse(api.throwFlutterError(), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1756,9 +1756,9 @@ interface HostIntegrationCoreApi { val anIntArg = args[0] as Long val wrapped: List = try { - listOf(api.echoInt(anIntArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoInt(anIntArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1778,9 +1778,9 @@ interface HostIntegrationCoreApi { val aDoubleArg = args[0] as Double val wrapped: List = try { - listOf(api.echoDouble(aDoubleArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoDouble(aDoubleArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1800,9 +1800,9 @@ interface HostIntegrationCoreApi { val aBoolArg = args[0] as Boolean val wrapped: List = try { - listOf(api.echoBool(aBoolArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoBool(aBoolArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1822,9 +1822,9 @@ interface HostIntegrationCoreApi { val aStringArg = args[0] as String val wrapped: List = try { - listOf(api.echoString(aStringArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoString(aStringArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1844,9 +1844,9 @@ interface HostIntegrationCoreApi { val aUint8ListArg = args[0] as ByteArray val wrapped: List = try { - listOf(api.echoUint8List(aUint8ListArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoUint8List(aUint8ListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1866,9 +1866,9 @@ interface HostIntegrationCoreApi { val anObjectArg = args[0] as Any val wrapped: List = try { - listOf(api.echoObject(anObjectArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoObject(anObjectArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1888,9 +1888,9 @@ interface HostIntegrationCoreApi { val listArg = args[0] as List val wrapped: List = try { - listOf(api.echoList(listArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoList(listArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1910,9 +1910,9 @@ interface HostIntegrationCoreApi { val enumListArg = args[0] as List val wrapped: List = try { - listOf(api.echoEnumList(enumListArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoEnumList(enumListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1932,9 +1932,9 @@ interface HostIntegrationCoreApi { val classListArg = args[0] as List val wrapped: List = try { - listOf(api.echoClassList(classListArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoClassList(classListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1954,9 +1954,9 @@ interface HostIntegrationCoreApi { val enumListArg = args[0] as List val wrapped: List = try { - listOf(api.echoNonNullEnumList(enumListArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNonNullEnumList(enumListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1976,9 +1976,9 @@ interface HostIntegrationCoreApi { val classListArg = args[0] as List val wrapped: List = try { - listOf(api.echoNonNullClassList(classListArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNonNullClassList(classListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1998,9 +1998,9 @@ interface HostIntegrationCoreApi { val mapArg = args[0] as Map val wrapped: List = try { - listOf(api.echoMap(mapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoMap(mapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2020,9 +2020,9 @@ interface HostIntegrationCoreApi { val stringMapArg = args[0] as Map val wrapped: List = try { - listOf(api.echoStringMap(stringMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoStringMap(stringMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2042,9 +2042,9 @@ interface HostIntegrationCoreApi { val intMapArg = args[0] as Map val wrapped: List = try { - listOf(api.echoIntMap(intMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoIntMap(intMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2064,9 +2064,9 @@ interface HostIntegrationCoreApi { val enumMapArg = args[0] as Map val wrapped: List = try { - listOf(api.echoEnumMap(enumMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoEnumMap(enumMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2086,9 +2086,9 @@ interface HostIntegrationCoreApi { val classMapArg = args[0] as Map val wrapped: List = try { - listOf(api.echoClassMap(classMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoClassMap(classMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2108,9 +2108,9 @@ interface HostIntegrationCoreApi { val stringMapArg = args[0] as Map val wrapped: List = try { - listOf(api.echoNonNullStringMap(stringMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNonNullStringMap(stringMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2130,9 +2130,9 @@ interface HostIntegrationCoreApi { val intMapArg = args[0] as Map val wrapped: List = try { - listOf(api.echoNonNullIntMap(intMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNonNullIntMap(intMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2152,9 +2152,9 @@ interface HostIntegrationCoreApi { val enumMapArg = args[0] as Map val wrapped: List = try { - listOf(api.echoNonNullEnumMap(enumMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNonNullEnumMap(enumMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2174,9 +2174,9 @@ interface HostIntegrationCoreApi { val classMapArg = args[0] as Map val wrapped: List = try { - listOf(api.echoNonNullClassMap(classMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNonNullClassMap(classMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2196,9 +2196,9 @@ interface HostIntegrationCoreApi { val wrapperArg = args[0] as AllClassesWrapper val wrapped: List = try { - listOf(api.echoClassWrapper(wrapperArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoClassWrapper(wrapperArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2218,9 +2218,9 @@ interface HostIntegrationCoreApi { val acronymsArg = args[0] as AcronymsAndTestCase val wrapped: List = try { - listOf(api.echoAcronyms(acronymsArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoAcronyms(acronymsArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2240,9 +2240,9 @@ interface HostIntegrationCoreApi { val acronymsArg = args[0] as AcronymsAndTestCase val wrapped: List = try { - listOf(api.hostHTTPResponse(acronymsArg)) + CoreTestsPigeonUtils.wrapResponse(api.hostHTTPResponse(acronymsArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2262,9 +2262,9 @@ interface HostIntegrationCoreApi { val acronymsArg = args[0] as AcronymsAndTestCase val wrapped: List = try { - listOf(api.sendJSONParser(acronymsArg)) + CoreTestsPigeonUtils.wrapResponse(api.sendJSONParser(acronymsArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2284,9 +2284,9 @@ interface HostIntegrationCoreApi { val anEnumArg = args[0] as AnEnum val wrapped: List = try { - listOf(api.echoEnum(anEnumArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoEnum(anEnumArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2306,9 +2306,9 @@ interface HostIntegrationCoreApi { val anotherEnumArg = args[0] as AnotherEnum val wrapped: List = try { - listOf(api.echoAnotherEnum(anotherEnumArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoAnotherEnum(anotherEnumArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2328,9 +2328,9 @@ interface HostIntegrationCoreApi { val aStringArg = args[0] as String val wrapped: List = try { - listOf(api.echoNamedDefaultString(aStringArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNamedDefaultString(aStringArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2350,9 +2350,9 @@ interface HostIntegrationCoreApi { val aDoubleArg = args[0] as Double val wrapped: List = try { - listOf(api.echoOptionalDefaultDouble(aDoubleArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoOptionalDefaultDouble(aDoubleArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2372,9 +2372,9 @@ interface HostIntegrationCoreApi { val anIntArg = args[0] as Long val wrapped: List = try { - listOf(api.echoRequiredInt(anIntArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoRequiredInt(anIntArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2395,9 +2395,9 @@ interface HostIntegrationCoreApi { val bArg = args[1] as AllNullableTypes val wrapped: List = try { - listOf(api.areAllNullableTypesEqual(aArg, bArg)) + CoreTestsPigeonUtils.wrapResponse(api.areAllNullableTypesEqual(aArg, bArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2417,9 +2417,9 @@ interface HostIntegrationCoreApi { val valueArg = args[0] as AllNullableTypes val wrapped: List = try { - listOf(api.getAllNullableTypesHash(valueArg)) + CoreTestsPigeonUtils.wrapResponse(api.getAllNullableTypesHash(valueArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2439,9 +2439,10 @@ interface HostIntegrationCoreApi { val valueArg = args[0] as AllNullableTypesWithoutRecursion val wrapped: List = try { - listOf(api.getAllNullableTypesWithoutRecursionHash(valueArg)) + CoreTestsPigeonUtils.wrapResponse( + api.getAllNullableTypesWithoutRecursionHash(valueArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2461,9 +2462,9 @@ interface HostIntegrationCoreApi { val everythingArg = args[0] as AllNullableTypes? val wrapped: List = try { - listOf(api.echoAllNullableTypes(everythingArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoAllNullableTypes(everythingArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2483,9 +2484,10 @@ interface HostIntegrationCoreApi { val everythingArg = args[0] as AllNullableTypesWithoutRecursion? val wrapped: List = try { - listOf(api.echoAllNullableTypesWithoutRecursion(everythingArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoAllNullableTypesWithoutRecursion(everythingArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2505,9 +2507,10 @@ interface HostIntegrationCoreApi { val wrapperArg = args[0] as AllClassesWrapper val wrapped: List = try { - listOf(api.extractNestedNullableString(wrapperArg)) + CoreTestsPigeonUtils.wrapResponse( + api.extractNestedNullableString(wrapperArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2527,9 +2530,10 @@ interface HostIntegrationCoreApi { val nullableStringArg = args[0] as String? val wrapped: List = try { - listOf(api.createNestedNullableString(nullableStringArg)) + CoreTestsPigeonUtils.wrapResponse( + api.createNestedNullableString(nullableStringArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2551,11 +2555,12 @@ interface HostIntegrationCoreApi { val aNullableStringArg = args[2] as String? val wrapped: List = try { - listOf( + CoreTestsPigeonUtils.wrapResponse( api.sendMultipleNullableTypes( - aNullableBoolArg, aNullableIntArg, aNullableStringArg)) + aNullableBoolArg, aNullableIntArg, aNullableStringArg), + null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2577,11 +2582,12 @@ interface HostIntegrationCoreApi { val aNullableStringArg = args[2] as String? val wrapped: List = try { - listOf( + CoreTestsPigeonUtils.wrapResponse( api.sendMultipleNullableTypesWithoutRecursion( - aNullableBoolArg, aNullableIntArg, aNullableStringArg)) + aNullableBoolArg, aNullableIntArg, aNullableStringArg), + null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2601,9 +2607,9 @@ interface HostIntegrationCoreApi { val aNullableIntArg = args[0] as Long? val wrapped: List = try { - listOf(api.echoNullableInt(aNullableIntArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableInt(aNullableIntArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2623,9 +2629,10 @@ interface HostIntegrationCoreApi { val aNullableDoubleArg = args[0] as Double? val wrapped: List = try { - listOf(api.echoNullableDouble(aNullableDoubleArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoNullableDouble(aNullableDoubleArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2645,9 +2652,9 @@ interface HostIntegrationCoreApi { val aNullableBoolArg = args[0] as Boolean? val wrapped: List = try { - listOf(api.echoNullableBool(aNullableBoolArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableBool(aNullableBoolArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2667,9 +2674,10 @@ interface HostIntegrationCoreApi { val aNullableStringArg = args[0] as String? val wrapped: List = try { - listOf(api.echoNullableString(aNullableStringArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoNullableString(aNullableStringArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2689,9 +2697,10 @@ interface HostIntegrationCoreApi { val aNullableUint8ListArg = args[0] as ByteArray? val wrapped: List = try { - listOf(api.echoNullableUint8List(aNullableUint8ListArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoNullableUint8List(aNullableUint8ListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2711,9 +2720,10 @@ interface HostIntegrationCoreApi { val aNullableObjectArg = args[0] val wrapped: List = try { - listOf(api.echoNullableObject(aNullableObjectArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoNullableObject(aNullableObjectArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2733,9 +2743,9 @@ interface HostIntegrationCoreApi { val aNullableListArg = args[0] as List? val wrapped: List = try { - listOf(api.echoNullableList(aNullableListArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableList(aNullableListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2755,9 +2765,9 @@ interface HostIntegrationCoreApi { val enumListArg = args[0] as List? val wrapped: List = try { - listOf(api.echoNullableEnumList(enumListArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableEnumList(enumListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2777,9 +2787,9 @@ interface HostIntegrationCoreApi { val classListArg = args[0] as List? val wrapped: List = try { - listOf(api.echoNullableClassList(classListArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableClassList(classListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2799,9 +2809,10 @@ interface HostIntegrationCoreApi { val enumListArg = args[0] as List? val wrapped: List = try { - listOf(api.echoNullableNonNullEnumList(enumListArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoNullableNonNullEnumList(enumListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2821,9 +2832,10 @@ interface HostIntegrationCoreApi { val classListArg = args[0] as List? val wrapped: List = try { - listOf(api.echoNullableNonNullClassList(classListArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoNullableNonNullClassList(classListArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2843,9 +2855,9 @@ interface HostIntegrationCoreApi { val mapArg = args[0] as Map? val wrapped: List = try { - listOf(api.echoNullableMap(mapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableMap(mapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2865,9 +2877,9 @@ interface HostIntegrationCoreApi { val stringMapArg = args[0] as Map? val wrapped: List = try { - listOf(api.echoNullableStringMap(stringMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableStringMap(stringMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2887,9 +2899,9 @@ interface HostIntegrationCoreApi { val intMapArg = args[0] as Map? val wrapped: List = try { - listOf(api.echoNullableIntMap(intMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableIntMap(intMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2909,9 +2921,9 @@ interface HostIntegrationCoreApi { val enumMapArg = args[0] as Map? val wrapped: List = try { - listOf(api.echoNullableEnumMap(enumMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableEnumMap(enumMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2931,9 +2943,9 @@ interface HostIntegrationCoreApi { val classMapArg = args[0] as Map? val wrapped: List = try { - listOf(api.echoNullableClassMap(classMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableClassMap(classMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2953,9 +2965,10 @@ interface HostIntegrationCoreApi { val stringMapArg = args[0] as Map? val wrapped: List = try { - listOf(api.echoNullableNonNullStringMap(stringMapArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoNullableNonNullStringMap(stringMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2975,9 +2988,9 @@ interface HostIntegrationCoreApi { val intMapArg = args[0] as Map? val wrapped: List = try { - listOf(api.echoNullableNonNullIntMap(intMapArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableNonNullIntMap(intMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2997,9 +3010,10 @@ interface HostIntegrationCoreApi { val enumMapArg = args[0] as Map? val wrapped: List = try { - listOf(api.echoNullableNonNullEnumMap(enumMapArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoNullableNonNullEnumMap(enumMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -3019,9 +3033,10 @@ interface HostIntegrationCoreApi { val classMapArg = args[0] as Map? val wrapped: List = try { - listOf(api.echoNullableNonNullClassMap(classMapArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoNullableNonNullClassMap(classMapArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -3041,9 +3056,9 @@ interface HostIntegrationCoreApi { val anEnumArg = args[0] as AnEnum? val wrapped: List = try { - listOf(api.echoNullableEnum(anEnumArg)) + CoreTestsPigeonUtils.wrapResponse(api.echoNullableEnum(anEnumArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -3063,9 +3078,10 @@ interface HostIntegrationCoreApi { val anotherEnumArg = args[0] as AnotherEnum? val wrapped: List = try { - listOf(api.echoAnotherNullableEnum(anotherEnumArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoAnotherNullableEnum(anotherEnumArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -3085,9 +3101,10 @@ interface HostIntegrationCoreApi { val aNullableIntArg = args[0] as Long? val wrapped: List = try { - listOf(api.echoOptionalNullableInt(aNullableIntArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoOptionalNullableInt(aNullableIntArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -3107,9 +3124,10 @@ interface HostIntegrationCoreApi { val aNullableStringArg = args[0] as String? val wrapped: List = try { - listOf(api.echoNamedNullableString(aNullableStringArg)) + CoreTestsPigeonUtils.wrapResponse( + api.echoNamedNullableString(aNullableStringArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -3128,9 +3146,9 @@ interface HostIntegrationCoreApi { api.noopAsync { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(CoreTestsPigeonUtils.wrapResult(null)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, null)) } } } @@ -3151,10 +3169,10 @@ interface HostIntegrationCoreApi { api.echoAsyncInt(anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3175,10 +3193,10 @@ interface HostIntegrationCoreApi { api.echoAsyncDouble(aDoubleArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3199,10 +3217,10 @@ interface HostIntegrationCoreApi { api.echoAsyncBool(aBoolArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3223,10 +3241,10 @@ interface HostIntegrationCoreApi { api.echoAsyncString(aStringArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3247,10 +3265,10 @@ interface HostIntegrationCoreApi { api.echoAsyncUint8List(aUint8ListArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3271,10 +3289,10 @@ interface HostIntegrationCoreApi { api.echoAsyncObject(anObjectArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3295,10 +3313,10 @@ interface HostIntegrationCoreApi { api.echoAsyncList(listArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3319,10 +3337,10 @@ interface HostIntegrationCoreApi { api.echoAsyncEnumList(enumListArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3343,10 +3361,10 @@ interface HostIntegrationCoreApi { api.echoAsyncClassList(classListArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3367,10 +3385,10 @@ interface HostIntegrationCoreApi { api.echoAsyncMap(mapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3391,10 +3409,10 @@ interface HostIntegrationCoreApi { api.echoAsyncStringMap(stringMapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3415,10 +3433,10 @@ interface HostIntegrationCoreApi { api.echoAsyncIntMap(intMapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3439,10 +3457,10 @@ interface HostIntegrationCoreApi { api.echoAsyncEnumMap(enumMapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3463,10 +3481,10 @@ interface HostIntegrationCoreApi { api.echoAsyncClassMap(classMapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3487,10 +3505,10 @@ interface HostIntegrationCoreApi { api.echoAsyncEnum(anEnumArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3511,10 +3529,10 @@ interface HostIntegrationCoreApi { api.echoAnotherAsyncEnum(anotherEnumArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3533,10 +3551,10 @@ interface HostIntegrationCoreApi { api.throwAsyncError { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3555,9 +3573,9 @@ interface HostIntegrationCoreApi { api.throwAsyncErrorFromVoid { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(CoreTestsPigeonUtils.wrapResult(null)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, null)) } } } @@ -3576,10 +3594,10 @@ interface HostIntegrationCoreApi { api.throwAsyncFlutterError { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3600,10 +3618,10 @@ interface HostIntegrationCoreApi { api.echoAsyncAllTypes(everythingArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3625,10 +3643,10 @@ interface HostIntegrationCoreApi { -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3650,10 +3668,10 @@ interface HostIntegrationCoreApi { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3674,10 +3692,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableInt(anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3698,10 +3716,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableDouble(aDoubleArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3722,10 +3740,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableBool(aBoolArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3746,10 +3764,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableString(aStringArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3770,10 +3788,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableUint8List(aUint8ListArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3794,10 +3812,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableObject(anObjectArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3818,10 +3836,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableList(listArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3842,10 +3860,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableEnumList(enumListArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3867,10 +3885,10 @@ interface HostIntegrationCoreApi { -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3891,10 +3909,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableMap(mapArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3915,10 +3933,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableStringMap(stringMapArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3939,10 +3957,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableIntMap(intMapArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3963,10 +3981,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableEnumMap(enumMapArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3988,10 +4006,10 @@ interface HostIntegrationCoreApi { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4012,10 +4030,10 @@ interface HostIntegrationCoreApi { api.echoAsyncNullableEnum(anEnumArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4036,10 +4054,10 @@ interface HostIntegrationCoreApi { api.echoAnotherAsyncNullableEnum(anotherEnumArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4057,9 +4075,9 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { _, reply -> val wrapped: List = try { - listOf(api.defaultIsMainThread()) + CoreTestsPigeonUtils.wrapResponse(api.defaultIsMainThread(), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -4078,9 +4096,9 @@ interface HostIntegrationCoreApi { channel.setMessageHandler { _, reply -> val wrapped: List = try { - listOf(api.taskQueueIsBackgroundThread()) + CoreTestsPigeonUtils.wrapResponse(api.taskQueueIsBackgroundThread(), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -4099,9 +4117,9 @@ interface HostIntegrationCoreApi { api.callFlutterNoop { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(CoreTestsPigeonUtils.wrapResult(null)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, null)) } } } @@ -4120,10 +4138,10 @@ interface HostIntegrationCoreApi { api.callFlutterThrowError { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4142,9 +4160,9 @@ interface HostIntegrationCoreApi { api.callFlutterThrowErrorFromVoid { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(CoreTestsPigeonUtils.wrapResult(null)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, null)) } } } @@ -4165,10 +4183,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoAllTypes(everythingArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4190,10 +4208,10 @@ interface HostIntegrationCoreApi { -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4218,10 +4236,10 @@ interface HostIntegrationCoreApi { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4243,10 +4261,10 @@ interface HostIntegrationCoreApi { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4271,10 +4289,10 @@ interface HostIntegrationCoreApi { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4295,10 +4313,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoBool(aBoolArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4319,10 +4337,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoInt(anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4343,10 +4361,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoDouble(aDoubleArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4367,10 +4385,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoString(aStringArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4391,10 +4409,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoUint8List(listArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4415,10 +4433,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoList(listArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4439,10 +4457,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoEnumList(enumListArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4463,10 +4481,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoClassList(classListArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4487,10 +4505,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNonNullEnumList(enumListArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4512,10 +4530,10 @@ interface HostIntegrationCoreApi { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4536,10 +4554,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoMap(mapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4560,10 +4578,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoStringMap(stringMapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4584,10 +4602,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoIntMap(intMapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4608,10 +4626,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoEnumMap(enumMapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4633,10 +4651,10 @@ interface HostIntegrationCoreApi { -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4658,10 +4676,10 @@ interface HostIntegrationCoreApi { -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4682,10 +4700,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNonNullIntMap(intMapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4706,10 +4724,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNonNullEnumMap(enumMapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4731,10 +4749,10 @@ interface HostIntegrationCoreApi { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4755,10 +4773,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoEnum(anEnumArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4779,10 +4797,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoAnotherEnum(anotherEnumArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4803,10 +4821,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNullableBool(aBoolArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4827,10 +4845,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNullableInt(anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4851,10 +4869,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNullableDouble(aDoubleArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4875,10 +4893,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNullableString(aStringArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4899,10 +4917,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNullableUint8List(listArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4923,10 +4941,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNullableList(listArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4947,10 +4965,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNullableEnumList(enumListArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4972,10 +4990,10 @@ interface HostIntegrationCoreApi { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4997,10 +5015,10 @@ interface HostIntegrationCoreApi { -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5022,10 +5040,10 @@ interface HostIntegrationCoreApi { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5046,10 +5064,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNullableMap(mapArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5071,10 +5089,10 @@ interface HostIntegrationCoreApi { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5095,10 +5113,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNullableIntMap(intMapArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5120,10 +5138,10 @@ interface HostIntegrationCoreApi { -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5145,10 +5163,10 @@ interface HostIntegrationCoreApi { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5170,10 +5188,10 @@ interface HostIntegrationCoreApi { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5195,10 +5213,10 @@ interface HostIntegrationCoreApi { -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5220,10 +5238,10 @@ interface HostIntegrationCoreApi { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5245,10 +5263,10 @@ interface HostIntegrationCoreApi { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5269,10 +5287,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoNullableEnum(anEnumArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5293,10 +5311,10 @@ interface HostIntegrationCoreApi { api.callFlutterEchoAnotherNullableEnum(anotherEnumArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -5317,10 +5335,10 @@ interface HostIntegrationCoreApi { api.callFlutterSmallApiEchoString(aStringArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -6679,9 +6697,9 @@ interface HostTrivialApi { val wrapped: List = try { api.noop() - listOf(null) + CoreTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -6727,10 +6745,10 @@ interface HostSmallApi { api.echo(aStringArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(CoreTestsPigeonUtils.wrapResult(data)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -6749,9 +6767,9 @@ interface HostSmallApi { api.voidVoid { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(CoreTestsPigeonUtils.wrapError(error)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(CoreTestsPigeonUtils.wrapResult(null)) + reply.reply(CoreTestsPigeonUtils.wrapResponse(null, null)) } } } diff --git a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/ProxyApiTests.gen.kt b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/ProxyApiTests.gen.kt index 27ced4fade57..cb33bc9a5227 100644 --- a/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/ProxyApiTests.gen.kt +++ b/packages/pigeon/platform_tests/test_plugin/android/src/main/kotlin/com/example/test_plugin/ProxyApiTests.gen.kt @@ -23,18 +23,18 @@ private object ProxyApiTestsPigeonUtils { "channel-error", "Unable to establish connection on channel: '$channelName'.", "") } - fun wrapResult(result: Any?): List { - return listOf(result) - } - - fun wrapError(exception: Throwable): List { - return if (exception is ProxyApiTestsError) { - listOf(exception.code, exception.message, exception.details) + fun wrapResponse(result: Any?, error: Throwable?): List { + return if (error != null) { + if (error is ProxyApiTestsError) { + listOf(error.code, error.message, error.details) + } else { + listOf( + error.javaClass.simpleName, + error.toString(), + "Cause: " + error.cause + ", Stacktrace: " + Log.getStackTraceString(error)) + } } else { - listOf( - exception.javaClass.simpleName, - exception.toString(), - "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)) + listOf(result) } } } @@ -324,9 +324,9 @@ private class ProxyApiTestsPigeonInstanceManagerApi(val binaryMessenger: BinaryM val wrapped: List = try { instanceManager.remove(identifierArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -345,9 +345,9 @@ private class ProxyApiTestsPigeonInstanceManagerApi(val binaryMessenger: BinaryM val wrapped: List = try { instanceManager.clear() - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1144,9 +1144,9 @@ abstract class PigeonApiProxyApiTestClass( nullableEnumParamArg, nullableProxyApiParamArg), pigeon_identifierArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1205,9 +1205,9 @@ abstract class PigeonApiProxyApiTestClass( aNullableEnumArg, aNullableProxyApiArg), pigeon_identifierArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1230,9 +1230,9 @@ abstract class PigeonApiProxyApiTestClass( try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.attachedField(pigeon_instanceArg), pigeon_identifierArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1254,9 +1254,9 @@ abstract class PigeonApiProxyApiTestClass( try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.staticAttachedField(), pigeon_identifierArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1277,9 +1277,9 @@ abstract class PigeonApiProxyApiTestClass( val wrapped: List = try { api.noop(pigeon_instanceArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1299,9 +1299,9 @@ abstract class PigeonApiProxyApiTestClass( val pigeon_instanceArg = args[0] as ProxyApiTestClass val wrapped: List = try { - listOf(api.throwError(pigeon_instanceArg)) + ProxyApiTestsPigeonUtils.wrapResponse(api.throwError(pigeon_instanceArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1322,9 +1322,9 @@ abstract class PigeonApiProxyApiTestClass( val wrapped: List = try { api.throwErrorFromVoid(pigeon_instanceArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1344,9 +1344,10 @@ abstract class PigeonApiProxyApiTestClass( val pigeon_instanceArg = args[0] as ProxyApiTestClass val wrapped: List = try { - listOf(api.throwFlutterError(pigeon_instanceArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.throwFlutterError(pigeon_instanceArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1367,9 +1368,10 @@ abstract class PigeonApiProxyApiTestClass( val anIntArg = args[1] as Long val wrapped: List = try { - listOf(api.echoInt(pigeon_instanceArg, anIntArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoInt(pigeon_instanceArg, anIntArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1390,9 +1392,10 @@ abstract class PigeonApiProxyApiTestClass( val aDoubleArg = args[1] as Double val wrapped: List = try { - listOf(api.echoDouble(pigeon_instanceArg, aDoubleArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoDouble(pigeon_instanceArg, aDoubleArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1413,9 +1416,10 @@ abstract class PigeonApiProxyApiTestClass( val aBoolArg = args[1] as Boolean val wrapped: List = try { - listOf(api.echoBool(pigeon_instanceArg, aBoolArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoBool(pigeon_instanceArg, aBoolArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1436,9 +1440,10 @@ abstract class PigeonApiProxyApiTestClass( val aStringArg = args[1] as String val wrapped: List = try { - listOf(api.echoString(pigeon_instanceArg, aStringArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoString(pigeon_instanceArg, aStringArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1459,9 +1464,10 @@ abstract class PigeonApiProxyApiTestClass( val aUint8ListArg = args[1] as ByteArray val wrapped: List = try { - listOf(api.echoUint8List(pigeon_instanceArg, aUint8ListArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoUint8List(pigeon_instanceArg, aUint8ListArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1482,9 +1488,10 @@ abstract class PigeonApiProxyApiTestClass( val anObjectArg = args[1] as Any val wrapped: List = try { - listOf(api.echoObject(pigeon_instanceArg, anObjectArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoObject(pigeon_instanceArg, anObjectArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1505,9 +1512,10 @@ abstract class PigeonApiProxyApiTestClass( val aListArg = args[1] as List val wrapped: List = try { - listOf(api.echoList(pigeon_instanceArg, aListArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoList(pigeon_instanceArg, aListArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1528,9 +1536,10 @@ abstract class PigeonApiProxyApiTestClass( val aListArg = args[1] as List val wrapped: List = try { - listOf(api.echoProxyApiList(pigeon_instanceArg, aListArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoProxyApiList(pigeon_instanceArg, aListArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1551,9 +1560,10 @@ abstract class PigeonApiProxyApiTestClass( val aMapArg = args[1] as Map val wrapped: List = try { - listOf(api.echoMap(pigeon_instanceArg, aMapArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoMap(pigeon_instanceArg, aMapArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1574,9 +1584,10 @@ abstract class PigeonApiProxyApiTestClass( val aMapArg = args[1] as Map val wrapped: List = try { - listOf(api.echoProxyApiMap(pigeon_instanceArg, aMapArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoProxyApiMap(pigeon_instanceArg, aMapArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1597,9 +1608,10 @@ abstract class PigeonApiProxyApiTestClass( val anEnumArg = args[1] as ProxyApiTestEnum val wrapped: List = try { - listOf(api.echoEnum(pigeon_instanceArg, anEnumArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoEnum(pigeon_instanceArg, anEnumArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1620,9 +1632,10 @@ abstract class PigeonApiProxyApiTestClass( val aProxyApiArg = args[1] as com.example.test_plugin.ProxyApiSuperClass val wrapped: List = try { - listOf(api.echoProxyApi(pigeon_instanceArg, aProxyApiArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoProxyApi(pigeon_instanceArg, aProxyApiArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1643,9 +1656,10 @@ abstract class PigeonApiProxyApiTestClass( val aNullableIntArg = args[1] as Long? val wrapped: List = try { - listOf(api.echoNullableInt(pigeon_instanceArg, aNullableIntArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoNullableInt(pigeon_instanceArg, aNullableIntArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1666,9 +1680,10 @@ abstract class PigeonApiProxyApiTestClass( val aNullableDoubleArg = args[1] as Double? val wrapped: List = try { - listOf(api.echoNullableDouble(pigeon_instanceArg, aNullableDoubleArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoNullableDouble(pigeon_instanceArg, aNullableDoubleArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1689,9 +1704,10 @@ abstract class PigeonApiProxyApiTestClass( val aNullableBoolArg = args[1] as Boolean? val wrapped: List = try { - listOf(api.echoNullableBool(pigeon_instanceArg, aNullableBoolArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoNullableBool(pigeon_instanceArg, aNullableBoolArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1712,9 +1728,10 @@ abstract class PigeonApiProxyApiTestClass( val aNullableStringArg = args[1] as String? val wrapped: List = try { - listOf(api.echoNullableString(pigeon_instanceArg, aNullableStringArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoNullableString(pigeon_instanceArg, aNullableStringArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1735,9 +1752,10 @@ abstract class PigeonApiProxyApiTestClass( val aNullableUint8ListArg = args[1] as ByteArray? val wrapped: List = try { - listOf(api.echoNullableUint8List(pigeon_instanceArg, aNullableUint8ListArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoNullableUint8List(pigeon_instanceArg, aNullableUint8ListArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1758,9 +1776,10 @@ abstract class PigeonApiProxyApiTestClass( val aNullableObjectArg = args[1] val wrapped: List = try { - listOf(api.echoNullableObject(pigeon_instanceArg, aNullableObjectArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoNullableObject(pigeon_instanceArg, aNullableObjectArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1781,9 +1800,10 @@ abstract class PigeonApiProxyApiTestClass( val aNullableListArg = args[1] as List? val wrapped: List = try { - listOf(api.echoNullableList(pigeon_instanceArg, aNullableListArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoNullableList(pigeon_instanceArg, aNullableListArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1804,9 +1824,10 @@ abstract class PigeonApiProxyApiTestClass( val aNullableMapArg = args[1] as Map? val wrapped: List = try { - listOf(api.echoNullableMap(pigeon_instanceArg, aNullableMapArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoNullableMap(pigeon_instanceArg, aNullableMapArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1827,9 +1848,10 @@ abstract class PigeonApiProxyApiTestClass( val aNullableEnumArg = args[1] as ProxyApiTestEnum? val wrapped: List = try { - listOf(api.echoNullableEnum(pigeon_instanceArg, aNullableEnumArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoNullableEnum(pigeon_instanceArg, aNullableEnumArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1850,9 +1872,10 @@ abstract class PigeonApiProxyApiTestClass( val aNullableProxyApiArg = args[1] as com.example.test_plugin.ProxyApiSuperClass? val wrapped: List = try { - listOf(api.echoNullableProxyApi(pigeon_instanceArg, aNullableProxyApiArg)) + ProxyApiTestsPigeonUtils.wrapResponse( + api.echoNullableProxyApi(pigeon_instanceArg, aNullableProxyApiArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -1873,9 +1896,9 @@ abstract class PigeonApiProxyApiTestClass( api.noopAsync(pigeon_instanceArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(null)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, null)) } } } @@ -1897,10 +1920,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncInt(pigeon_instanceArg, anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -1922,10 +1945,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncDouble(pigeon_instanceArg, aDoubleArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -1947,10 +1970,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncBool(pigeon_instanceArg, aBoolArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -1972,10 +1995,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncString(pigeon_instanceArg, aStringArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -1997,10 +2020,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncUint8List(pigeon_instanceArg, aUint8ListArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2022,10 +2045,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncObject(pigeon_instanceArg, anObjectArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2047,10 +2070,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncList(pigeon_instanceArg, aListArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2072,10 +2095,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncMap(pigeon_instanceArg, aMapArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2097,10 +2120,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncEnum(pigeon_instanceArg, anEnumArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2121,10 +2144,10 @@ abstract class PigeonApiProxyApiTestClass( api.throwAsyncError(pigeon_instanceArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2145,9 +2168,9 @@ abstract class PigeonApiProxyApiTestClass( api.throwAsyncErrorFromVoid(pigeon_instanceArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(null)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, null)) } } } @@ -2168,10 +2191,10 @@ abstract class PigeonApiProxyApiTestClass( api.throwAsyncFlutterError(pigeon_instanceArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2193,10 +2216,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncNullableInt(pigeon_instanceArg, anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2218,10 +2241,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncNullableDouble(pigeon_instanceArg, aDoubleArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2243,10 +2266,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncNullableBool(pigeon_instanceArg, aBoolArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2268,10 +2291,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncNullableString(pigeon_instanceArg, aStringArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2294,10 +2317,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2319,10 +2342,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncNullableObject(pigeon_instanceArg, anObjectArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2344,10 +2367,10 @@ abstract class PigeonApiProxyApiTestClass( api.echoAsyncNullableList(pigeon_instanceArg, aListArg) { result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2370,10 +2393,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2396,10 +2419,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2418,9 +2441,9 @@ abstract class PigeonApiProxyApiTestClass( val wrapped: List = try { api.staticNoop() - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2440,9 +2463,9 @@ abstract class PigeonApiProxyApiTestClass( val aStringArg = args[0] as String val wrapped: List = try { - listOf(api.echoStaticString(aStringArg)) + ProxyApiTestsPigeonUtils.wrapResponse(api.echoStaticString(aStringArg), null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2461,9 +2484,9 @@ abstract class PigeonApiProxyApiTestClass( api.staticAsyncNoop { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(null)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, null)) } } } @@ -2484,9 +2507,9 @@ abstract class PigeonApiProxyApiTestClass( api.callFlutterNoop(pigeon_instanceArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(null)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, null)) } } } @@ -2507,10 +2530,10 @@ abstract class PigeonApiProxyApiTestClass( api.callFlutterThrowError(pigeon_instanceArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2531,9 +2554,9 @@ abstract class PigeonApiProxyApiTestClass( api.callFlutterThrowErrorFromVoid(pigeon_instanceArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(null)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, null)) } } } @@ -2555,10 +2578,10 @@ abstract class PigeonApiProxyApiTestClass( api.callFlutterEchoBool(pigeon_instanceArg, aBoolArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2580,10 +2603,10 @@ abstract class PigeonApiProxyApiTestClass( api.callFlutterEchoInt(pigeon_instanceArg, anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2605,10 +2628,10 @@ abstract class PigeonApiProxyApiTestClass( api.callFlutterEchoDouble(pigeon_instanceArg, aDoubleArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2630,10 +2653,10 @@ abstract class PigeonApiProxyApiTestClass( api.callFlutterEchoString(pigeon_instanceArg, aStringArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2656,10 +2679,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2681,10 +2704,10 @@ abstract class PigeonApiProxyApiTestClass( api.callFlutterEchoList(pigeon_instanceArg, aListArg) { result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2707,10 +2730,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2733,10 +2756,10 @@ abstract class PigeonApiProxyApiTestClass( -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2759,10 +2782,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2785,10 +2808,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2811,10 +2834,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2837,10 +2860,10 @@ abstract class PigeonApiProxyApiTestClass( -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2862,10 +2885,10 @@ abstract class PigeonApiProxyApiTestClass( api.callFlutterEchoNullableInt(pigeon_instanceArg, anIntArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2888,10 +2911,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2914,10 +2937,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2940,10 +2963,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2966,10 +2989,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -2992,10 +3015,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result?> -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3018,10 +3041,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3044,10 +3067,10 @@ abstract class PigeonApiProxyApiTestClass( result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -3068,9 +3091,9 @@ abstract class PigeonApiProxyApiTestClass( api.callFlutterNoopAsync(pigeon_instanceArg) { result: Result -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(null)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, null)) } } } @@ -3093,10 +3116,10 @@ abstract class PigeonApiProxyApiTestClass( -> val error = result.exceptionOrNull() if (error != null) { - reply.reply(ProxyApiTestsPigeonUtils.wrapError(error)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(null, error)) } else { val data = result.getOrNull() - reply.reply(ProxyApiTestsPigeonUtils.wrapResult(data)) + reply.reply(ProxyApiTestsPigeonUtils.wrapResponse(data, null)) } } } @@ -4258,9 +4281,9 @@ abstract class PigeonApiProxyApiSuperClass( try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.pigeon_defaultConstructor(), pigeon_identifierArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -4281,9 +4304,9 @@ abstract class PigeonApiProxyApiSuperClass( val wrapped: List = try { api.aSuperMethod(pigeon_instanceArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -4436,9 +4459,9 @@ abstract class PigeonApiClassWithApiRequirement( try { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( api.pigeon_defaultConstructor(), pigeon_identifierArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -4455,7 +4478,8 @@ abstract class PigeonApiClassWithApiRequirement( if (api != null) { channel.setMessageHandler { _, reply -> reply.reply( - ProxyApiTestsPigeonUtils.wrapError( + ProxyApiTestsPigeonUtils.wrapResponse( + null, UnsupportedOperationException( "Call references class `ClassWithApiRequirement`, which requires api version 25."))) } @@ -4477,9 +4501,9 @@ abstract class PigeonApiClassWithApiRequirement( val wrapped: List = try { api.aMethod(pigeon_instanceArg) - listOf(null) + ProxyApiTestsPigeonUtils.wrapResponse(null, null) } catch (exception: Throwable) { - ProxyApiTestsPigeonUtils.wrapError(exception) + ProxyApiTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -4496,7 +4520,8 @@ abstract class PigeonApiClassWithApiRequirement( if (api != null) { channel.setMessageHandler { _, reply -> reply.reply( - ProxyApiTestsPigeonUtils.wrapError( + ProxyApiTestsPigeonUtils.wrapResponse( + null, UnsupportedOperationException( "Call references class `ClassWithApiRequirement`, which requires api version 25."))) } 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 396c76af83af..3ed15dc1fe32 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 @@ -177,13 +177,15 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { return acronyms } - // This uses a when statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. + // This uses a when statement to explicitly map the enum value to verify that all generated enum + // constants are valid and usable. override fun hostHTTPResponse(acronyms: AcronymsAndTestCase): AcronymsAndTestCase { - val enumVal = when (acronyms.acronymsEnum) { - AcronymsEnum.HTTP_RESPONSE -> AcronymsEnum.HTTP_RESPONSE - AcronymsEnum.JSON_PARSER -> AcronymsEnum.JSON_PARSER - null -> null - } + val enumVal = + when (acronyms.acronymsEnum) { + AcronymsEnum.HTTP_RESPONSE -> AcronymsEnum.HTTP_RESPONSE + AcronymsEnum.JSON_PARSER -> AcronymsEnum.JSON_PARSER + null -> null + } return AcronymsAndTestCase( httpResponse = acronyms.httpResponse, jsonParser = acronyms.jsonParser, @@ -191,13 +193,15 @@ class TestPlugin : FlutterPlugin, HostIntegrationCoreApi { acronymsEnum = enumVal) } - // This uses a when statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. + // This uses a when statement to explicitly map the enum value to verify that all generated enum + // constants are valid and usable. override fun sendJSONParser(acronyms: AcronymsAndTestCase): AcronymsAndTestCase { - val enumVal = when (acronyms.acronymsEnum) { - AcronymsEnum.HTTP_RESPONSE -> AcronymsEnum.HTTP_RESPONSE - AcronymsEnum.JSON_PARSER -> AcronymsEnum.JSON_PARSER - null -> null - } + val enumVal = + when (acronyms.acronymsEnum) { + AcronymsEnum.HTTP_RESPONSE -> AcronymsEnum.HTTP_RESPONSE + AcronymsEnum.JSON_PARSER -> AcronymsEnum.JSON_PARSER + null -> null + } return AcronymsAndTestCase( httpResponse = acronyms.httpResponse, jsonParser = acronyms.jsonParser, diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift index d672845b1067..11ee475a7738 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/CoreTests.gen.swift @@ -15,30 +15,30 @@ import Foundation #error("Unsupported platform.") #endif -private func wrapResult(_ result: Any?) -> [Any?] { - return [result] -} - -private func wrapError(_ error: Any) -> [Any?] { - if let pigeonError = error as? PigeonError { - return [ - pigeonError.code, - pigeonError.message, - pigeonError.details, - ] - } - if let flutterError = error as? FlutterError { +private func wrapResponse(_ result: Any?, _ error: Any?) -> [Any?] { + if let error = error { + if let pigeonError = error as? PigeonError { + return [ + pigeonError.code, + pigeonError.message, + pigeonError.details, + ] + } + if let flutterError = error as? FlutterError { + return [ + flutterError.code, + flutterError.message, + flutterError.details, + ] + } return [ - flutterError.code, - flutterError.message, - flutterError.details, + "\(error)", + "\(Swift.type(of: error))", + "Stacktrace: \(Thread.callStackSymbols)", ] + } else { + return [result] } - return [ - "\(error)", - "\(Swift.type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)", - ] } private func createConnectionError(withChannelName channelName: String) -> PigeonError { @@ -1544,9 +1544,9 @@ class HostIntegrationCoreApiSetup { noopChannel.setMessageHandler { _, reply in do { try api.noop() - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1563,9 +1563,9 @@ class HostIntegrationCoreApiSetup { let everythingArg = args[0] as! AllTypes do { let result = try api.echo(everythingArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1580,9 +1580,9 @@ class HostIntegrationCoreApiSetup { throwErrorChannel.setMessageHandler { _, reply in do { let result = try api.throwError() - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1597,9 +1597,9 @@ class HostIntegrationCoreApiSetup { throwErrorFromVoidChannel.setMessageHandler { _, reply in do { try api.throwErrorFromVoid() - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1614,9 +1614,9 @@ class HostIntegrationCoreApiSetup { throwFlutterErrorChannel.setMessageHandler { _, reply in do { let result = try api.throwFlutterError() - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1633,9 +1633,9 @@ class HostIntegrationCoreApiSetup { let anIntArg = args[0] as! Int64 do { let result = try api.echo(anIntArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1652,9 +1652,9 @@ class HostIntegrationCoreApiSetup { let aDoubleArg = args[0] as! Double do { let result = try api.echo(aDoubleArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1671,9 +1671,9 @@ class HostIntegrationCoreApiSetup { let aBoolArg = args[0] as! Bool do { let result = try api.echo(aBoolArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1690,9 +1690,9 @@ class HostIntegrationCoreApiSetup { let aStringArg = args[0] as! String do { let result = try api.echo(aStringArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1709,9 +1709,9 @@ class HostIntegrationCoreApiSetup { let aUint8ListArg = args[0] as! FlutterStandardTypedData do { let result = try api.echo(aUint8ListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1728,9 +1728,9 @@ class HostIntegrationCoreApiSetup { let anObjectArg = args[0]! do { let result = try api.echo(anObjectArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1747,9 +1747,9 @@ class HostIntegrationCoreApiSetup { let listArg = args[0] as! [Any?] do { let result = try api.echo(listArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1766,9 +1766,9 @@ class HostIntegrationCoreApiSetup { let enumListArg = args[0] as! [AnEnum?] do { let result = try api.echo(enumList: enumListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1785,9 +1785,9 @@ class HostIntegrationCoreApiSetup { let classListArg = args[0] as! [AllNullableTypes?] do { let result = try api.echo(classList: classListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1804,9 +1804,9 @@ class HostIntegrationCoreApiSetup { let enumListArg = args[0] as! [AnEnum] do { let result = try api.echoNonNull(enumList: enumListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1823,9 +1823,9 @@ class HostIntegrationCoreApiSetup { let classListArg = args[0] as! [AllNullableTypes] do { let result = try api.echoNonNull(classList: classListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1842,9 +1842,9 @@ class HostIntegrationCoreApiSetup { let mapArg = args[0] as! [AnyHashable?: Any?] do { let result = try api.echo(mapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1861,9 +1861,9 @@ class HostIntegrationCoreApiSetup { let stringMapArg = args[0] as! [String?: String?] do { let result = try api.echo(stringMap: stringMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1880,9 +1880,9 @@ class HostIntegrationCoreApiSetup { let intMapArg = args[0] as! [Int64?: Int64?] do { let result = try api.echo(intMap: intMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1899,9 +1899,9 @@ class HostIntegrationCoreApiSetup { let enumMapArg = args[0] as? [AnEnum?: AnEnum?] do { let result = try api.echo(enumMap: enumMapArg!) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1918,9 +1918,9 @@ class HostIntegrationCoreApiSetup { let classMapArg = args[0] as! [Int64?: AllNullableTypes?] do { let result = try api.echo(classMap: classMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1937,9 +1937,9 @@ class HostIntegrationCoreApiSetup { let stringMapArg = args[0] as! [String: String] do { let result = try api.echoNonNull(stringMap: stringMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1956,9 +1956,9 @@ class HostIntegrationCoreApiSetup { let intMapArg = args[0] as! [Int64: Int64] do { let result = try api.echoNonNull(intMap: intMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1975,9 +1975,9 @@ class HostIntegrationCoreApiSetup { let enumMapArg = args[0] as? [AnEnum: AnEnum] do { let result = try api.echoNonNull(enumMap: enumMapArg!) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1994,9 +1994,9 @@ class HostIntegrationCoreApiSetup { let classMapArg = args[0] as! [Int64: AllNullableTypes] do { let result = try api.echoNonNull(classMap: classMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2013,9 +2013,9 @@ class HostIntegrationCoreApiSetup { let wrapperArg = args[0] as! AllClassesWrapper do { let result = try api.echo(wrapperArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2032,9 +2032,9 @@ class HostIntegrationCoreApiSetup { let acronymsArg = args[0] as! AcronymsAndTestCase do { let result = try api.echo(acronymsArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2050,9 +2050,9 @@ class HostIntegrationCoreApiSetup { let acronymsArg = args[0] as! AcronymsAndTestCase do { let result = try api.hostHTTPResponse(acronymsArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2068,9 +2068,9 @@ class HostIntegrationCoreApiSetup { let acronymsArg = args[0] as! AcronymsAndTestCase do { let result = try api.sendJSONParser(acronymsArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2087,9 +2087,9 @@ class HostIntegrationCoreApiSetup { let anEnumArg = args[0] as! AnEnum do { let result = try api.echo(anEnumArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2106,9 +2106,9 @@ class HostIntegrationCoreApiSetup { let anotherEnumArg = args[0] as! AnotherEnum do { let result = try api.echo(anotherEnumArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2125,9 +2125,9 @@ class HostIntegrationCoreApiSetup { let aStringArg = args[0] as! String do { let result = try api.echoNamedDefault(aStringArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2144,9 +2144,9 @@ class HostIntegrationCoreApiSetup { let aDoubleArg = args[0] as! Double do { let result = try api.echoOptionalDefault(aDoubleArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2163,9 +2163,9 @@ class HostIntegrationCoreApiSetup { let anIntArg = args[0] as! Int64 do { let result = try api.echoRequired(anIntArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2183,9 +2183,9 @@ class HostIntegrationCoreApiSetup { let bArg = args[1] as! AllNullableTypes do { let result = try api.areAllNullableTypesEqual(a: aArg, b: bArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2202,9 +2202,9 @@ class HostIntegrationCoreApiSetup { let valueArg = args[0] as! AllNullableTypes do { let result = try api.getAllNullableTypesHash(value: valueArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2221,9 +2221,9 @@ class HostIntegrationCoreApiSetup { let valueArg = args[0] as! AllNullableTypesWithoutRecursion do { let result = try api.getAllNullableTypesWithoutRecursionHash(value: valueArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2240,9 +2240,9 @@ class HostIntegrationCoreApiSetup { let everythingArg: AllNullableTypes? = nilOrValue(args[0]) do { let result = try api.echo(everythingArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2259,9 +2259,9 @@ class HostIntegrationCoreApiSetup { let everythingArg: AllNullableTypesWithoutRecursion? = nilOrValue(args[0]) do { let result = try api.echo(everythingArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2279,9 +2279,9 @@ class HostIntegrationCoreApiSetup { let wrapperArg = args[0] as! AllClassesWrapper do { let result = try api.extractNestedNullableString(from: wrapperArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2299,9 +2299,9 @@ class HostIntegrationCoreApiSetup { let nullableStringArg: String? = nilOrValue(args[0]) do { let result = try api.createNestedObject(with: nullableStringArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2321,9 +2321,9 @@ class HostIntegrationCoreApiSetup { do { let result = try api.sendMultipleNullableTypes( aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2343,9 +2343,9 @@ class HostIntegrationCoreApiSetup { do { let result = try api.sendMultipleNullableTypesWithoutRecursion( aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2362,9 +2362,9 @@ class HostIntegrationCoreApiSetup { let aNullableIntArg: Int64? = nilOrValue(args[0]) do { let result = try api.echo(aNullableIntArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2381,9 +2381,9 @@ class HostIntegrationCoreApiSetup { let aNullableDoubleArg: Double? = nilOrValue(args[0]) do { let result = try api.echo(aNullableDoubleArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2400,9 +2400,9 @@ class HostIntegrationCoreApiSetup { let aNullableBoolArg: Bool? = nilOrValue(args[0]) do { let result = try api.echo(aNullableBoolArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2419,9 +2419,9 @@ class HostIntegrationCoreApiSetup { let aNullableStringArg: String? = nilOrValue(args[0]) do { let result = try api.echo(aNullableStringArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2438,9 +2438,9 @@ class HostIntegrationCoreApiSetup { let aNullableUint8ListArg: FlutterStandardTypedData? = nilOrValue(args[0]) do { let result = try api.echo(aNullableUint8ListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2457,9 +2457,9 @@ class HostIntegrationCoreApiSetup { let aNullableObjectArg: Any? = args[0] do { let result = try api.echo(aNullableObjectArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2476,9 +2476,9 @@ class HostIntegrationCoreApiSetup { let aNullableListArg: [Any?]? = nilOrValue(args[0]) do { let result = try api.echoNullable(aNullableListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2495,9 +2495,9 @@ class HostIntegrationCoreApiSetup { let enumListArg: [AnEnum?]? = nilOrValue(args[0]) do { let result = try api.echoNullable(enumList: enumListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2514,9 +2514,9 @@ class HostIntegrationCoreApiSetup { let classListArg: [AllNullableTypes?]? = nilOrValue(args[0]) do { let result = try api.echoNullable(classList: classListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2533,9 +2533,9 @@ class HostIntegrationCoreApiSetup { let enumListArg: [AnEnum]? = nilOrValue(args[0]) do { let result = try api.echoNullableNonNull(enumList: enumListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2552,9 +2552,9 @@ class HostIntegrationCoreApiSetup { let classListArg: [AllNullableTypes]? = nilOrValue(args[0]) do { let result = try api.echoNullableNonNull(classList: classListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2571,9 +2571,9 @@ class HostIntegrationCoreApiSetup { let mapArg: [AnyHashable?: Any?]? = nilOrValue(args[0]) do { let result = try api.echoNullable(mapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2590,9 +2590,9 @@ class HostIntegrationCoreApiSetup { let stringMapArg: [String?: String?]? = nilOrValue(args[0]) do { let result = try api.echoNullable(stringMap: stringMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2609,9 +2609,9 @@ class HostIntegrationCoreApiSetup { let intMapArg: [Int64?: Int64?]? = nilOrValue(args[0]) do { let result = try api.echoNullable(intMap: intMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2628,9 +2628,9 @@ class HostIntegrationCoreApiSetup { let enumMapArg: [AnEnum?: AnEnum?]? = args[0] as? [AnEnum?: AnEnum?] do { let result = try api.echoNullable(enumMap: enumMapArg!) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2647,9 +2647,9 @@ class HostIntegrationCoreApiSetup { let classMapArg: [Int64?: AllNullableTypes?]? = nilOrValue(args[0]) do { let result = try api.echoNullable(classMap: classMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2666,9 +2666,9 @@ class HostIntegrationCoreApiSetup { let stringMapArg: [String: String]? = nilOrValue(args[0]) do { let result = try api.echoNullableNonNull(stringMap: stringMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2685,9 +2685,9 @@ class HostIntegrationCoreApiSetup { let intMapArg: [Int64: Int64]? = nilOrValue(args[0]) do { let result = try api.echoNullableNonNull(intMap: intMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2704,9 +2704,9 @@ class HostIntegrationCoreApiSetup { let enumMapArg: [AnEnum: AnEnum]? = args[0] as? [AnEnum: AnEnum] do { let result = try api.echoNullableNonNull(enumMap: enumMapArg!) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2723,9 +2723,9 @@ class HostIntegrationCoreApiSetup { let classMapArg: [Int64: AllNullableTypes]? = nilOrValue(args[0]) do { let result = try api.echoNullableNonNull(classMap: classMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2741,9 +2741,9 @@ class HostIntegrationCoreApiSetup { let anEnumArg: AnEnum? = nilOrValue(args[0]) do { let result = try api.echoNullable(anEnumArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2759,9 +2759,9 @@ class HostIntegrationCoreApiSetup { let anotherEnumArg: AnotherEnum? = nilOrValue(args[0]) do { let result = try api.echoNullable(anotherEnumArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2778,9 +2778,9 @@ class HostIntegrationCoreApiSetup { let aNullableIntArg: Int64? = nilOrValue(args[0]) do { let result = try api.echoOptional(aNullableIntArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2797,9 +2797,9 @@ class HostIntegrationCoreApiSetup { let aNullableStringArg: String? = nilOrValue(args[0]) do { let result = try api.echoNamed(aNullableStringArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2816,9 +2816,9 @@ class HostIntegrationCoreApiSetup { api.noopAsync { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2837,9 +2837,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(anIntArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2858,9 +2858,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(aDoubleArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2879,9 +2879,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(aBoolArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2900,9 +2900,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(aStringArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2921,9 +2921,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(aUint8ListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2942,9 +2942,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(anObjectArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2963,9 +2963,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(listArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2984,9 +2984,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(enumList: enumListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3005,9 +3005,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(classList: classListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3026,9 +3026,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(mapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3047,9 +3047,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(stringMap: stringMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3068,9 +3068,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(intMap: intMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3089,9 +3089,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(enumMap: enumMapArg!) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3110,9 +3110,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(classMap: classMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3131,9 +3131,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(anEnumArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3152,9 +3152,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(anotherEnumArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3171,9 +3171,9 @@ class HostIntegrationCoreApiSetup { api.throwAsyncError { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3190,9 +3190,9 @@ class HostIntegrationCoreApiSetup { api.throwAsyncErrorFromVoid { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3209,9 +3209,9 @@ class HostIntegrationCoreApiSetup { api.throwAsyncFlutterError { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3230,9 +3230,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(everythingArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3251,9 +3251,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(everythingArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3272,9 +3272,9 @@ class HostIntegrationCoreApiSetup { api.echoAsync(everythingArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3293,9 +3293,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(anIntArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3314,9 +3314,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(aDoubleArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3335,9 +3335,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(aBoolArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3356,9 +3356,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(aStringArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3377,9 +3377,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(aUint8ListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3398,9 +3398,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(anObjectArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3419,9 +3419,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(listArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3440,9 +3440,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(enumList: enumListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3461,9 +3461,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(classList: classListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3482,9 +3482,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(mapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3503,9 +3503,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(stringMap: stringMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3524,9 +3524,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(intMap: intMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3545,9 +3545,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(enumMap: enumMapArg!) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3566,9 +3566,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(classMap: classMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3587,9 +3587,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(anEnumArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3608,9 +3608,9 @@ class HostIntegrationCoreApiSetup { api.echoAsyncNullable(anotherEnumArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3627,9 +3627,9 @@ class HostIntegrationCoreApiSetup { defaultIsMainThreadChannel.setMessageHandler { _, reply in do { let result = try api.defaultIsMainThread() - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -3651,9 +3651,9 @@ class HostIntegrationCoreApiSetup { taskQueueIsBackgroundThreadChannel.setMessageHandler { _, reply in do { let result = try api.taskQueueIsBackgroundThread() - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -3668,9 +3668,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterNoop { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3686,9 +3686,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterThrowError { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3704,9 +3704,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterThrowErrorFromVoid { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3724,9 +3724,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(everythingArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3744,9 +3744,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(everythingArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3768,9 +3768,9 @@ class HostIntegrationCoreApiSetup { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3788,9 +3788,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(everythingArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3813,9 +3813,9 @@ class HostIntegrationCoreApiSetup { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3833,9 +3833,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(aBoolArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3853,9 +3853,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(anIntArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3873,9 +3873,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(aDoubleArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3893,9 +3893,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(aStringArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3913,9 +3913,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(listArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3933,9 +3933,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(listArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3953,9 +3953,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(enumList: enumListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3973,9 +3973,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(classList: classListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -3993,9 +3993,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNonNull(enumList: enumListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4013,9 +4013,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNonNull(classList: classListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4033,9 +4033,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(mapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4053,9 +4053,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(stringMap: stringMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4073,9 +4073,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(intMap: intMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4093,9 +4093,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(enumMap: enumMapArg!) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4113,9 +4113,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(classMap: classMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4133,9 +4133,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNonNull(stringMap: stringMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4153,9 +4153,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNonNull(intMap: intMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4173,9 +4173,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNonNull(enumMap: enumMapArg!) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4193,9 +4193,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNonNull(classMap: classMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4213,9 +4213,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(anEnumArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4233,9 +4233,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEcho(anotherEnumArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4253,9 +4253,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(aBoolArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4273,9 +4273,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(anIntArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4293,9 +4293,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(aDoubleArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4313,9 +4313,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(aStringArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4333,9 +4333,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(listArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4353,9 +4353,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(listArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4373,9 +4373,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(enumList: enumListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4393,9 +4393,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(classList: classListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4413,9 +4413,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullableNonNull(enumList: enumListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4433,9 +4433,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullableNonNull(classList: classListArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4453,9 +4453,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(mapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4473,9 +4473,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(stringMap: stringMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4493,9 +4493,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(intMap: intMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4513,9 +4513,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(enumMap: enumMapArg!) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4533,9 +4533,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(classMap: classMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4553,9 +4553,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullableNonNull(stringMap: stringMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4573,9 +4573,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullableNonNull(intMap: intMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4593,9 +4593,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullableNonNull(enumMap: enumMapArg!) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4613,9 +4613,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullableNonNull(classMap: classMapArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4633,9 +4633,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(anEnumArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4653,9 +4653,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterEchoNullable(anotherEnumArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4673,9 +4673,9 @@ class HostIntegrationCoreApiSetup { api.callFlutterSmallApiEcho(aStringArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -6315,9 +6315,9 @@ class HostTrivialApiSetup { noopChannel.setMessageHandler { _, reply in do { try api.noop() - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -6351,9 +6351,9 @@ class HostSmallApiSetup { api.echo(aString: aStringArg) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -6368,9 +6368,9 @@ class HostSmallApiSetup { api.voidVoid { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift index d0a4af42234b..2d2c842c4023 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift @@ -15,30 +15,30 @@ import Foundation #error("Unsupported platform.") #endif -private func wrapResult(_ result: Any?) -> [Any?] { - return [result] -} - -private func wrapError(_ error: Any) -> [Any?] { - if let pigeonError = error as? ProxyApiTestsError { - return [ - pigeonError.code, - pigeonError.message, - pigeonError.details, - ] - } - if let flutterError = error as? FlutterError { +private func wrapResponse(_ result: Any?, _ error: Any?) -> [Any?] { + if let error = error { + if let pigeonError = error as? ProxyApiTestsError { + return [ + pigeonError.code, + pigeonError.message, + pigeonError.details, + ] + } + if let flutterError = error as? FlutterError { + return [ + flutterError.code, + flutterError.message, + flutterError.details, + ] + } return [ - flutterError.code, - flutterError.message, - flutterError.details, + "\(error)", + "\(Swift.type(of: error))", + "Stacktrace: \(Thread.callStackSymbols)", ] + } else { + return [result] } - return [ - "\(error)", - "\(Swift.type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)", - ] } private func createConnectionError(withChannelName channelName: String) -> ProxyApiTestsError { @@ -327,9 +327,9 @@ private class ProxyApiTestsPigeonInstanceManagerApi { let identifierArg = args[0] as! Int64 do { let _: AnyObject? = try instanceManager.removeInstance(withIdentifier: identifierArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -342,9 +342,9 @@ private class ProxyApiTestsPigeonInstanceManagerApi { clearChannel.setMessageHandler { _, reply in do { try instanceManager.removeAllObjects() - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1146,9 +1146,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { nullableEnumParam: nullableEnumParamArg, nullableProxyApiParam: nullableProxyApiParamArg), withIdentifier: pigeonIdentifierArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1190,9 +1190,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { aNullableList: aNullableListArg, aNullableMap: aNullableMapArg, aNullableEnum: aNullableEnumArg, aNullableProxyApi: aNullableProxyApiArg), withIdentifier: pigeonIdentifierArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1210,9 +1210,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( try api.pigeonDelegate.attachedField(pigeonApi: api, pigeonInstance: pigeonInstanceArg), withIdentifier: pigeonIdentifierArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1229,9 +1229,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( try api.pigeonDelegate.staticAttachedField(pigeonApi: api), withIdentifier: pigeonIdentifierArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1246,9 +1246,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { let pigeonInstanceArg = args[0] as! ProxyApiTestClass do { try api.pigeonDelegate.noop(pigeonApi: api, pigeonInstance: pigeonInstanceArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1264,9 +1264,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.throwError( pigeonApi: api, pigeonInstance: pigeonInstanceArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1282,9 +1282,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { try api.pigeonDelegate.throwErrorFromVoid( pigeonApi: api, pigeonInstance: pigeonInstanceArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1300,9 +1300,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.throwFlutterError( pigeonApi: api, pigeonInstance: pigeonInstanceArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1319,9 +1319,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoInt( pigeonApi: api, pigeonInstance: pigeonInstanceArg, anInt: anIntArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1338,9 +1338,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoDouble( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aDouble: aDoubleArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1357,9 +1357,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoBool( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aBool: aBoolArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1376,9 +1376,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoString( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aString: aStringArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1395,9 +1395,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoUint8List( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aUint8List: aUint8ListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1414,9 +1414,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoObject( pigeonApi: api, pigeonInstance: pigeonInstanceArg, anObject: anObjectArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1433,9 +1433,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoList( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aList: aListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1452,9 +1452,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoProxyApiList( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aList: aListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1471,9 +1471,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoMap( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aMap: aMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1490,9 +1490,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoProxyApiMap( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aMap: aMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1509,9 +1509,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoEnum( pigeonApi: api, pigeonInstance: pigeonInstanceArg, anEnum: anEnumArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1528,9 +1528,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoProxyApi( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aProxyApi: aProxyApiArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1547,9 +1547,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoNullableInt( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableInt: aNullableIntArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1566,9 +1566,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoNullableDouble( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableDouble: aNullableDoubleArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1585,9 +1585,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoNullableBool( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableBool: aNullableBoolArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1604,9 +1604,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoNullableString( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableString: aNullableStringArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1624,9 +1624,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { let result = try api.pigeonDelegate.echoNullableUint8List( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableUint8List: aNullableUint8ListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1643,9 +1643,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoNullableObject( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableObject: aNullableObjectArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1662,9 +1662,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoNullableList( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableList: aNullableListArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1681,9 +1681,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoNullableMap( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableMap: aNullableMapArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1700,9 +1700,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { do { let result = try api.pigeonDelegate.echoNullableEnum( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableEnum: aNullableEnumArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1720,9 +1720,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { let result = try api.pigeonDelegate.echoNullableProxyApi( pigeonApi: api, pigeonInstance: pigeonInstanceArg, aNullableProxyApi: aNullableProxyApiArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -1738,9 +1738,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { api.pigeonDelegate.noopAsync(pigeonApi: api, pigeonInstance: pigeonInstanceArg) { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1760,9 +1760,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1782,9 +1782,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1804,9 +1804,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1826,9 +1826,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1848,9 +1848,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1870,9 +1870,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1892,9 +1892,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1914,9 +1914,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1936,9 +1936,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1956,9 +1956,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1977,9 +1977,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -1997,9 +1997,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2019,9 +2019,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2041,9 +2041,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2063,9 +2063,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2085,9 +2085,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2108,9 +2108,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2130,9 +2130,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2152,9 +2152,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2174,9 +2174,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2196,9 +2196,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2212,9 +2212,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { staticNoopChannel.setMessageHandler { _, reply in do { try api.pigeonDelegate.staticNoop(pigeonApi: api) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2229,9 +2229,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { let aStringArg = args[0] as! String do { let result = try api.pigeonDelegate.echoStaticString(pigeonApi: api, aString: aStringArg) - reply(wrapResult(result)) + reply(wrapResponse(result, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -2245,9 +2245,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { api.pigeonDelegate.staticAsyncNoop(pigeonApi: api) { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2265,9 +2265,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2285,9 +2285,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2307,9 +2307,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2329,9 +2329,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2351,9 +2351,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2373,9 +2373,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2395,9 +2395,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2418,9 +2418,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2440,9 +2440,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2463,9 +2463,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2485,9 +2485,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2508,9 +2508,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2530,9 +2530,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2552,9 +2552,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2575,9 +2575,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2598,9 +2598,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2621,9 +2621,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2644,9 +2644,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2667,9 +2667,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2690,9 +2690,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2713,9 +2713,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2736,9 +2736,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2759,9 +2759,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2779,9 +2779,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { result in switch result { case .success: - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -2802,9 +2802,9 @@ final class PigeonApiProxyApiTestClass: PigeonApiProtocolProxyApiTestClass { ) { result in switch result { case .success(let res): - reply(wrapResult(res)) + reply(wrapResponse(res, nil)) case .failure(let error): - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } @@ -4077,9 +4077,9 @@ final class PigeonApiProxyApiSuperClass: PigeonApiProtocolProxyApiSuperClass { api.pigeonRegistrar.instanceManager.addDartCreatedInstance( try api.pigeonDelegate.pigeonDefaultConstructor(pigeonApi: api), withIdentifier: pigeonIdentifierArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -4094,9 +4094,9 @@ final class PigeonApiProxyApiSuperClass: PigeonApiProtocolProxyApiSuperClass { let pigeonInstanceArg = args[0] as! ProxyApiSuperClass do { try api.pigeonDelegate.aSuperMethod(pigeonApi: api, pigeonInstance: pigeonInstanceArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -4288,9 +4288,9 @@ final class PigeonApiClassWithApiRequirement: PigeonApiProtocolClassWithApiRequi api.pigeonRegistrar.instanceManager.addDartCreatedInstance( try api.pigeonDelegate.pigeonDefaultConstructor(pigeonApi: api), withIdentifier: pigeonIdentifierArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { @@ -4326,9 +4326,9 @@ final class PigeonApiClassWithApiRequirement: PigeonApiProtocolClassWithApiRequi let pigeonInstanceArg = args[0] as! ClassWithApiRequirement do { try api.pigeonDelegate.aMethod(pigeonApi: api, pigeonInstance: pigeonInstanceArg) - reply(wrapResult(nil)) + reply(wrapResponse(nil, nil)) } catch { - reply(wrapError(error)) + reply(wrapResponse(nil, error)) } } } else { diff --git a/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc b/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc index c2390e4dbfd4..0ca62889ee69 100644 --- a/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc +++ b/packages/pigeon/platform_tests/test_plugin/linux/test_plugin.cc @@ -213,7 +213,8 @@ echo_class_wrapper(CoreTestsPigeonTestAllClassesWrapper* wrapper, wrapper); } -// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +// This uses a switch statement to explicitly map the enum value to verify that +// all generated enum constants are valid and usable. static CoreTestsPigeonTestHostIntegrationCoreApiHostHTTPResponseResponse* host_h_t_t_p_response(CoreTestsPigeonTestAcronymsAndTestCase* acronyms, gpointer user_data) { @@ -250,7 +251,8 @@ host_h_t_t_p_response(CoreTestsPigeonTestAcronymsAndTestCase* acronyms, result); } -// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +// This uses a switch statement to explicitly map the enum value to verify that +// all generated enum constants are valid and usable. static CoreTestsPigeonTestHostIntegrationCoreApiSendJSONParserResponse* send_j_s_o_n_parser(CoreTestsPigeonTestAcronymsAndTestCase* acronyms, gpointer user_data) { 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 8b837f83e579..b2f282d2e7b9 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 @@ -27,6 +27,19 @@ using ::flutter::EncodableList; using ::flutter::EncodableMap; using ::flutter::EncodableValue; +static EncodableValue WrapResponse(const EncodableValue* result, + const FlutterError* error) { + if (error) { + return EncodableValue(EncodableList{EncodableValue(error->code()), + EncodableValue(error->message()), + error->details()}); + } + if (result) { + return EncodableValue(EncodableList{*result}); + } + return EncodableValue(EncodableList{EncodableValue()}); +} + FlutterError CreateConnectionError(const std::string channel_name) { return FlutterError( "channel-error", @@ -2910,14 +2923,13 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, try { std::optional output = api->Noop(); if (output.has_value()) { - reply(WrapError(output.value())); + reply(WrapResponse(nullptr, &output.value())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(nullptr, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -2938,22 +2950,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_everything_arg = args.at(0); if (encodable_everything_arg.IsNull()) { - reply(WrapError("everything_arg unexpectedly null.")); + FlutterError error("Error", "everything_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& everything_arg = std::any_cast( std::get(encodable_everything_arg)); ErrorOr output = api->EchoAllTypes(everything_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -2973,20 +2987,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, try { ErrorOr> output = api->ThrowError(); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3006,14 +3020,13 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, try { std::optional output = api->ThrowErrorFromVoid(); if (output.has_value()) { - reply(WrapError(output.value())); + reply(WrapResponse(nullptr, &output.value())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(nullptr, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3034,20 +3047,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->ThrowFlutterError(); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3068,20 +3081,23 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_an_int_arg = args.at(0); if (encodable_an_int_arg.IsNull()) { - reply(WrapError("an_int_arg unexpectedly null.")); + FlutterError error("Error", "an_int_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const int64_t an_int_arg = encodable_an_int_arg.LongValue(); ErrorOr output = api->EchoInt(an_int_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3102,21 +3118,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_double_arg = args.at(0); if (encodable_a_double_arg.IsNull()) { - reply(WrapError("a_double_arg unexpectedly null.")); + FlutterError error("Error", "a_double_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_double_arg = std::get(encodable_a_double_arg); ErrorOr output = api->EchoDouble(a_double_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3137,20 +3156,23 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_bool_arg = args.at(0); if (encodable_a_bool_arg.IsNull()) { - reply(WrapError("a_bool_arg unexpectedly null.")); + FlutterError error("Error", "a_bool_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_bool_arg = std::get(encodable_a_bool_arg); ErrorOr output = api->EchoBool(a_bool_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3171,21 +3193,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_string_arg = args.at(0); if (encodable_a_string_arg.IsNull()) { - reply(WrapError("a_string_arg unexpectedly null.")); + FlutterError error("Error", "a_string_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_string_arg = std::get(encodable_a_string_arg); ErrorOr output = api->EchoString(a_string_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3206,7 +3231,10 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_uint8_list_arg = args.at(0); if (encodable_a_uint8_list_arg.IsNull()) { - reply(WrapError("a_uint8_list_arg unexpectedly null.")); + FlutterError error("Error", + "a_uint8_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_uint8_list_arg = @@ -3214,14 +3242,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoUint8List(a_uint8_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3242,20 +3271,23 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_an_object_arg = args.at(0); if (encodable_an_object_arg.IsNull()) { - reply(WrapError("an_object_arg unexpectedly null.")); + FlutterError error("Error", "an_object_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& an_object_arg = encodable_an_object_arg; ErrorOr output = api->EchoObject(an_object_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3276,21 +3308,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_list_arg = args.at(0); if (encodable_list_arg.IsNull()) { - reply(WrapError("list_arg unexpectedly null.")); + FlutterError error("Error", "list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& list_arg = std::get(encodable_list_arg); ErrorOr output = api->EchoList(list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3311,21 +3346,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_enum_list_arg = args.at(0); if (encodable_enum_list_arg.IsNull()) { - reply(WrapError("enum_list_arg unexpectedly null.")); + FlutterError error("Error", "enum_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& enum_list_arg = std::get(encodable_enum_list_arg); ErrorOr output = api->EchoEnumList(enum_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3346,7 +3384,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_class_list_arg = args.at(0); if (encodable_class_list_arg.IsNull()) { - reply(WrapError("class_list_arg unexpectedly null.")); + FlutterError error("Error", "class_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& class_list_arg = @@ -3354,14 +3394,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoClassList(class_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3382,7 +3423,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_enum_list_arg = args.at(0); if (encodable_enum_list_arg.IsNull()) { - reply(WrapError("enum_list_arg unexpectedly null.")); + FlutterError error("Error", "enum_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& enum_list_arg = @@ -3390,14 +3433,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoNonNullEnumList(enum_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3419,7 +3463,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_class_list_arg = args.at(0); if (encodable_class_list_arg.IsNull()) { - reply(WrapError("class_list_arg unexpectedly null.")); + FlutterError error("Error", "class_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& class_list_arg = @@ -3427,14 +3473,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoNonNullClassList(class_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3455,20 +3502,23 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_map_arg = args.at(0); if (encodable_map_arg.IsNull()) { - reply(WrapError("map_arg unexpectedly null.")); + FlutterError error("Error", "map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& map_arg = std::get(encodable_map_arg); ErrorOr output = api->EchoMap(map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3489,21 +3539,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_string_map_arg = args.at(0); if (encodable_string_map_arg.IsNull()) { - reply(WrapError("string_map_arg unexpectedly null.")); + FlutterError error("Error", "string_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& string_map_arg = std::get(encodable_string_map_arg); ErrorOr output = api->EchoStringMap(string_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3524,21 +3577,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_int_map_arg = args.at(0); if (encodable_int_map_arg.IsNull()) { - reply(WrapError("int_map_arg unexpectedly null.")); + FlutterError error("Error", "int_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& int_map_arg = std::get(encodable_int_map_arg); ErrorOr output = api->EchoIntMap(int_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3559,21 +3615,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_enum_map_arg = args.at(0); if (encodable_enum_map_arg.IsNull()) { - reply(WrapError("enum_map_arg unexpectedly null.")); + FlutterError error("Error", "enum_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& enum_map_arg = std::get(encodable_enum_map_arg); ErrorOr output = api->EchoEnumMap(enum_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3594,21 +3653,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_class_map_arg = args.at(0); if (encodable_class_map_arg.IsNull()) { - reply(WrapError("class_map_arg unexpectedly null.")); + FlutterError error("Error", "class_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& class_map_arg = std::get(encodable_class_map_arg); ErrorOr output = api->EchoClassMap(class_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3630,7 +3692,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_string_map_arg = args.at(0); if (encodable_string_map_arg.IsNull()) { - reply(WrapError("string_map_arg unexpectedly null.")); + FlutterError error("Error", "string_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& string_map_arg = @@ -3638,14 +3702,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoNonNullStringMap(string_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3666,7 +3731,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_int_map_arg = args.at(0); if (encodable_int_map_arg.IsNull()) { - reply(WrapError("int_map_arg unexpectedly null.")); + FlutterError error("Error", "int_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& int_map_arg = @@ -3674,14 +3741,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoNonNullIntMap(int_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3702,7 +3770,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_enum_map_arg = args.at(0); if (encodable_enum_map_arg.IsNull()) { - reply(WrapError("enum_map_arg unexpectedly null.")); + FlutterError error("Error", "enum_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& enum_map_arg = @@ -3710,14 +3780,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoNonNullEnumMap(enum_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3738,7 +3809,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_class_map_arg = args.at(0); if (encodable_class_map_arg.IsNull()) { - reply(WrapError("class_map_arg unexpectedly null.")); + FlutterError error("Error", "class_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& class_map_arg = @@ -3746,14 +3819,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoNonNullClassMap(class_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3774,7 +3848,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_wrapper_arg = args.at(0); if (encodable_wrapper_arg.IsNull()) { - reply(WrapError("wrapper_arg unexpectedly null.")); + FlutterError error("Error", "wrapper_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& wrapper_arg = std::any_cast( @@ -3782,15 +3858,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoClassWrapper(wrapper_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3811,7 +3887,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_acronyms_arg = args.at(0); if (encodable_acronyms_arg.IsNull()) { - reply(WrapError("acronyms_arg unexpectedly null.")); + FlutterError error("Error", "acronyms_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& acronyms_arg = @@ -3820,15 +3898,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoAcronyms(acronyms_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3849,7 +3927,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_acronyms_arg = args.at(0); if (encodable_acronyms_arg.IsNull()) { - reply(WrapError("acronyms_arg unexpectedly null.")); + FlutterError error("Error", "acronyms_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& acronyms_arg = @@ -3858,15 +3938,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->HostHTTPResponse(acronyms_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3887,7 +3967,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_acronyms_arg = args.at(0); if (encodable_acronyms_arg.IsNull()) { - reply(WrapError("acronyms_arg unexpectedly null.")); + FlutterError error("Error", "acronyms_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& acronyms_arg = @@ -3896,15 +3978,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->SendJSONParser(acronyms_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3925,22 +4007,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_an_enum_arg = args.at(0); if (encodable_an_enum_arg.IsNull()) { - reply(WrapError("an_enum_arg unexpectedly null.")); + FlutterError error("Error", "an_enum_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& an_enum_arg = std::any_cast( std::get(encodable_an_enum_arg)); ErrorOr output = api->EchoEnum(an_enum_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3961,7 +4045,10 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_another_enum_arg = args.at(0); if (encodable_another_enum_arg.IsNull()) { - reply(WrapError("another_enum_arg unexpectedly null.")); + FlutterError error("Error", + "another_enum_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& another_enum_arg = std::any_cast( @@ -3969,15 +4056,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoAnotherEnum(another_enum_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -3999,7 +4086,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_string_arg = args.at(0); if (encodable_a_string_arg.IsNull()) { - reply(WrapError("a_string_arg unexpectedly null.")); + FlutterError error("Error", "a_string_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_string_arg = @@ -4007,14 +4096,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoNamedDefaultString(a_string_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4036,7 +4126,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_double_arg = args.at(0); if (encodable_a_double_arg.IsNull()) { - reply(WrapError("a_double_arg unexpectedly null.")); + FlutterError error("Error", "a_double_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_double_arg = @@ -4044,14 +4136,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->EchoOptionalDefaultDouble(a_double_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4072,20 +4165,23 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_an_int_arg = args.at(0); if (encodable_an_int_arg.IsNull()) { - reply(WrapError("an_int_arg unexpectedly null.")); + FlutterError error("Error", "an_int_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const int64_t an_int_arg = encodable_an_int_arg.LongValue(); ErrorOr output = api->EchoRequiredInt(an_int_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4107,14 +4203,18 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_arg = args.at(0); if (encodable_a_arg.IsNull()) { - reply(WrapError("a_arg unexpectedly null.")); + FlutterError error("Error", "a_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_arg = std::any_cast( std::get(encodable_a_arg)); const auto& encodable_b_arg = args.at(1); if (encodable_b_arg.IsNull()) { - reply(WrapError("b_arg unexpectedly null.")); + FlutterError error("Error", "b_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& b_arg = std::any_cast( @@ -4122,14 +4222,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->AreAllNullableTypesEqual(a_arg, b_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4151,21 +4252,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_value_arg = args.at(0); if (encodable_value_arg.IsNull()) { - reply(WrapError("value_arg unexpectedly null.")); + FlutterError error("Error", "value_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& value_arg = std::any_cast( std::get(encodable_value_arg)); ErrorOr output = api->GetAllNullableTypesHash(value_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4187,7 +4291,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_value_arg = args.at(0); if (encodable_value_arg.IsNull()) { - reply(WrapError("value_arg unexpectedly null.")); + FlutterError error("Error", "value_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& value_arg = @@ -4196,14 +4302,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->GetAllNullableTypesWithoutRecursionHash(value_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4233,20 +4340,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoAllNullableTypes(everything_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4276,20 +4383,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoAllNullableTypesWithoutRecursion(everything_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4311,7 +4418,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_wrapper_arg = args.at(0); if (encodable_wrapper_arg.IsNull()) { - reply(WrapError("wrapper_arg unexpectedly null.")); + FlutterError error("Error", "wrapper_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& wrapper_arg = std::any_cast( @@ -4319,20 +4428,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->ExtractNestedNullableString(wrapper_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4358,15 +4467,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr output = api->CreateNestedNullableString(nullable_string_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4399,15 +4508,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, a_nullable_bool_arg, a_nullable_int_arg, a_nullable_string_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4441,15 +4550,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, a_nullable_bool_arg, a_nullable_int_arg, a_nullable_string_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4474,20 +4583,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableInt(a_nullable_int_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4512,20 +4621,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableDouble(a_nullable_double_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4550,20 +4659,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableBool(a_nullable_bool_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4588,20 +4697,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableString(a_nullable_string_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4628,20 +4737,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr>> output = api->EchoNullableUint8List(a_nullable_uint8_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4666,20 +4775,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableObject(a_nullable_object_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4704,20 +4813,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableList(a_nullable_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4743,20 +4852,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableEnumList(enum_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4782,20 +4891,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableClassList(class_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4821,20 +4930,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableNonNullEnumList(enum_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4860,20 +4969,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableNonNullClassList(class_list_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4898,20 +5007,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableMap(map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4937,20 +5046,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableStringMap(string_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -4975,20 +5084,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableIntMap(int_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5013,20 +5122,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableEnumMap(enum_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5052,20 +5161,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableClassMap(class_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5091,20 +5200,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableNonNullStringMap(string_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5130,20 +5239,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableNonNullIntMap(int_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5169,20 +5278,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableNonNullEnumMap(enum_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5208,20 +5317,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableNonNullClassMap(class_map_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5251,20 +5360,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNullableEnum( an_enum_arg ? &(*an_enum_arg) : nullptr); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5296,20 +5405,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAnotherNullableEnum( another_enum_arg ? &(*another_enum_arg) : nullptr); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5335,20 +5444,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoOptionalNullableInt(a_nullable_int_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5374,20 +5483,20 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, ErrorOr> output = api->EchoNamedNullableString(a_nullable_string_arg); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5407,15 +5516,14 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, try { api->NoopAsync([reply](std::optional&& output) { if (output.has_value()) { - reply(WrapError(output.value())); + reply(WrapResponse(nullptr, &output.value())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(nullptr, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5436,22 +5544,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_an_int_arg = args.at(0); if (encodable_an_int_arg.IsNull()) { - reply(WrapError("an_int_arg unexpectedly null.")); + FlutterError error("Error", "an_int_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const int64_t an_int_arg = encodable_an_int_arg.LongValue(); api->EchoAsyncInt(an_int_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5472,7 +5582,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_double_arg = args.at(0); if (encodable_a_double_arg.IsNull()) { - reply(WrapError("a_double_arg unexpectedly null.")); + FlutterError error("Error", "a_double_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_double_arg = @@ -5480,16 +5592,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncDouble( a_double_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5510,22 +5622,24 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_bool_arg = args.at(0); if (encodable_a_bool_arg.IsNull()) { - reply(WrapError("a_bool_arg unexpectedly null.")); + FlutterError error("Error", "a_bool_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_bool_arg = std::get(encodable_a_bool_arg); api->EchoAsyncBool(a_bool_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5546,7 +5660,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_string_arg = args.at(0); if (encodable_a_string_arg.IsNull()) { - reply(WrapError("a_string_arg unexpectedly null.")); + FlutterError error("Error", "a_string_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_string_arg = @@ -5554,16 +5670,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncString( a_string_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5584,7 +5700,10 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_uint8_list_arg = args.at(0); if (encodable_a_uint8_list_arg.IsNull()) { - reply(WrapError("a_uint8_list_arg unexpectedly null.")); + FlutterError error("Error", + "a_uint8_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_uint8_list_arg = @@ -5593,16 +5712,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, a_uint8_list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5623,23 +5742,25 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_an_object_arg = args.at(0); if (encodable_an_object_arg.IsNull()) { - reply(WrapError("an_object_arg unexpectedly null.")); + FlutterError error("Error", "an_object_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& an_object_arg = encodable_an_object_arg; api->EchoAsyncObject( an_object_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5660,7 +5781,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_list_arg = args.at(0); if (encodable_list_arg.IsNull()) { - reply(WrapError("list_arg unexpectedly null.")); + FlutterError error("Error", "list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& list_arg = @@ -5668,16 +5791,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncList( list_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5698,7 +5821,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_enum_list_arg = args.at(0); if (encodable_enum_list_arg.IsNull()) { - reply(WrapError("enum_list_arg unexpectedly null.")); + FlutterError error("Error", "enum_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& enum_list_arg = @@ -5706,16 +5831,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncEnumList( enum_list_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5736,7 +5861,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_class_list_arg = args.at(0); if (encodable_class_list_arg.IsNull()) { - reply(WrapError("class_list_arg unexpectedly null.")); + FlutterError error("Error", "class_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& class_list_arg = @@ -5744,16 +5871,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncClassList( class_list_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5774,23 +5901,25 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_map_arg = args.at(0); if (encodable_map_arg.IsNull()) { - reply(WrapError("map_arg unexpectedly null.")); + FlutterError error("Error", "map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& map_arg = std::get(encodable_map_arg); api->EchoAsyncMap( map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5811,7 +5940,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_string_map_arg = args.at(0); if (encodable_string_map_arg.IsNull()) { - reply(WrapError("string_map_arg unexpectedly null.")); + FlutterError error("Error", "string_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& string_map_arg = @@ -5819,16 +5950,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncStringMap( string_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5849,7 +5980,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_int_map_arg = args.at(0); if (encodable_int_map_arg.IsNull()) { - reply(WrapError("int_map_arg unexpectedly null.")); + FlutterError error("Error", "int_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& int_map_arg = @@ -5857,16 +5990,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncIntMap( int_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5887,7 +6020,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_enum_map_arg = args.at(0); if (encodable_enum_map_arg.IsNull()) { - reply(WrapError("enum_map_arg unexpectedly null.")); + FlutterError error("Error", "enum_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& enum_map_arg = @@ -5895,16 +6030,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncEnumMap( enum_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5925,7 +6060,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_class_map_arg = args.at(0); if (encodable_class_map_arg.IsNull()) { - reply(WrapError("class_map_arg unexpectedly null.")); + FlutterError error("Error", "class_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& class_map_arg = @@ -5933,16 +6070,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncClassMap( class_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -5963,7 +6100,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_an_enum_arg = args.at(0); if (encodable_an_enum_arg.IsNull()) { - reply(WrapError("an_enum_arg unexpectedly null.")); + FlutterError error("Error", "an_enum_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& an_enum_arg = std::any_cast( @@ -5971,16 +6110,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncEnum( an_enum_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6002,7 +6141,10 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_another_enum_arg = args.at(0); if (encodable_another_enum_arg.IsNull()) { - reply(WrapError("another_enum_arg unexpectedly null.")); + FlutterError error("Error", + "another_enum_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& another_enum_arg = std::any_cast( @@ -6010,16 +6152,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAnotherAsyncEnum( another_enum_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6040,21 +6182,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->ThrowAsyncError( [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6076,15 +6218,14 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->ThrowAsyncErrorFromVoid( [reply](std::optional&& output) { if (output.has_value()) { - reply(WrapError(output.value())); + reply(WrapResponse(nullptr, &output.value())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(nullptr, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6106,21 +6247,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->ThrowAsyncFlutterError( [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6141,7 +6282,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_everything_arg = args.at(0); if (encodable_everything_arg.IsNull()) { - reply(WrapError("everything_arg unexpectedly null.")); + FlutterError error("Error", "everything_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& everything_arg = std::any_cast( @@ -6149,16 +6292,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncAllTypes( everything_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6189,21 +6332,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, everything_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back(CustomEncodableValue( + EncodableValue result_value(CustomEncodableValue( std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6235,21 +6378,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6276,21 +6419,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, an_int_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6317,21 +6460,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, a_double_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6356,21 +6499,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->EchoAsyncNullableBool( a_bool_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6397,21 +6540,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, a_string_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6439,21 +6582,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, [reply]( ErrorOr>>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6479,21 +6622,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, an_object_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6520,21 +6663,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6561,21 +6704,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, enum_list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6602,21 +6745,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, class_list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6643,21 +6786,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6684,21 +6827,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, string_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6725,21 +6868,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, int_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6766,21 +6909,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, enum_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6807,21 +6950,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, class_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6853,21 +6996,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, an_enum_arg ? &(*an_enum_arg) : nullptr, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back(CustomEncodableValue( + EncodableValue result_value(CustomEncodableValue( std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6899,21 +7042,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, another_enum_arg ? &(*another_enum_arg) : nullptr, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back(CustomEncodableValue( + EncodableValue result_value(CustomEncodableValue( std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6933,14 +7076,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, try { ErrorOr output = api->DefaultIsMainThread(); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6961,14 +7105,15 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, try { ErrorOr output = api->TaskQueueIsBackgroundThread(); if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + EncodableValue result_value( + EncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -6989,15 +7134,14 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterNoop( [reply](std::optional&& output) { if (output.has_value()) { - reply(WrapError(output.value())); + reply(WrapResponse(nullptr, &output.value())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(nullptr, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7019,21 +7163,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterThrowError( [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7055,15 +7199,14 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterThrowErrorFromVoid( [reply](std::optional&& output) { if (output.has_value()) { - reply(WrapError(output.value())); + reply(WrapResponse(nullptr, &output.value())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(nullptr, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7085,7 +7228,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_everything_arg = args.at(0); if (encodable_everything_arg.IsNull()) { - reply(WrapError("everything_arg unexpectedly null.")); + FlutterError error("Error", "everything_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& everything_arg = std::any_cast( @@ -7093,16 +7238,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoAllTypes( everything_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7133,21 +7278,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, everything_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back(CustomEncodableValue( + EncodableValue result_value(CustomEncodableValue( std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7181,16 +7326,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, a_nullable_string_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7222,21 +7367,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7270,16 +7415,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, a_nullable_string_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7300,23 +7445,25 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_bool_arg = args.at(0); if (encodable_a_bool_arg.IsNull()) { - reply(WrapError("a_bool_arg unexpectedly null.")); + FlutterError error("Error", "a_bool_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_bool_arg = std::get(encodable_a_bool_arg); api->CallFlutterEchoBool( a_bool_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7337,23 +7484,25 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_an_int_arg = args.at(0); if (encodable_an_int_arg.IsNull()) { - reply(WrapError("an_int_arg unexpectedly null.")); + FlutterError error("Error", "an_int_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const int64_t an_int_arg = encodable_an_int_arg.LongValue(); api->CallFlutterEchoInt( an_int_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7375,7 +7524,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_double_arg = args.at(0); if (encodable_a_double_arg.IsNull()) { - reply(WrapError("a_double_arg unexpectedly null.")); + FlutterError error("Error", "a_double_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_double_arg = @@ -7383,16 +7534,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoDouble( a_double_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7414,7 +7565,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_string_arg = args.at(0); if (encodable_a_string_arg.IsNull()) { - reply(WrapError("a_string_arg unexpectedly null.")); + FlutterError error("Error", "a_string_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_string_arg = @@ -7422,16 +7575,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoString( a_string_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7453,7 +7606,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_list_arg = args.at(0); if (encodable_list_arg.IsNull()) { - reply(WrapError("list_arg unexpectedly null.")); + FlutterError error("Error", "list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& list_arg = @@ -7461,16 +7616,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoUint8List( list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7491,7 +7646,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_list_arg = args.at(0); if (encodable_list_arg.IsNull()) { - reply(WrapError("list_arg unexpectedly null.")); + FlutterError error("Error", "list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& list_arg = @@ -7499,16 +7656,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoList( list_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7530,7 +7687,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_enum_list_arg = args.at(0); if (encodable_enum_list_arg.IsNull()) { - reply(WrapError("enum_list_arg unexpectedly null.")); + FlutterError error("Error", "enum_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& enum_list_arg = @@ -7538,16 +7697,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoEnumList( enum_list_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7569,7 +7728,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_class_list_arg = args.at(0); if (encodable_class_list_arg.IsNull()) { - reply(WrapError("class_list_arg unexpectedly null.")); + FlutterError error("Error", "class_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& class_list_arg = @@ -7577,16 +7738,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoClassList( class_list_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7608,7 +7769,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_enum_list_arg = args.at(0); if (encodable_enum_list_arg.IsNull()) { - reply(WrapError("enum_list_arg unexpectedly null.")); + FlutterError error("Error", "enum_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& enum_list_arg = @@ -7616,16 +7779,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoNonNullEnumList( enum_list_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7647,7 +7810,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_class_list_arg = args.at(0); if (encodable_class_list_arg.IsNull()) { - reply(WrapError("class_list_arg unexpectedly null.")); + FlutterError error("Error", "class_list_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& class_list_arg = @@ -7655,16 +7820,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoNonNullClassList( class_list_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7685,23 +7850,25 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_map_arg = args.at(0); if (encodable_map_arg.IsNull()) { - reply(WrapError("map_arg unexpectedly null.")); + FlutterError error("Error", "map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& map_arg = std::get(encodable_map_arg); api->CallFlutterEchoMap( map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7723,7 +7890,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_string_map_arg = args.at(0); if (encodable_string_map_arg.IsNull()) { - reply(WrapError("string_map_arg unexpectedly null.")); + FlutterError error("Error", "string_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& string_map_arg = @@ -7731,16 +7900,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoStringMap( string_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7762,7 +7931,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_int_map_arg = args.at(0); if (encodable_int_map_arg.IsNull()) { - reply(WrapError("int_map_arg unexpectedly null.")); + FlutterError error("Error", "int_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& int_map_arg = @@ -7770,16 +7941,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoIntMap( int_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7801,7 +7972,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_enum_map_arg = args.at(0); if (encodable_enum_map_arg.IsNull()) { - reply(WrapError("enum_map_arg unexpectedly null.")); + FlutterError error("Error", "enum_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& enum_map_arg = @@ -7809,16 +7982,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoEnumMap( enum_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7840,7 +8013,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_class_map_arg = args.at(0); if (encodable_class_map_arg.IsNull()) { - reply(WrapError("class_map_arg unexpectedly null.")); + FlutterError error("Error", "class_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& class_map_arg = @@ -7848,16 +8023,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoClassMap( class_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7879,7 +8054,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_string_map_arg = args.at(0); if (encodable_string_map_arg.IsNull()) { - reply(WrapError("string_map_arg unexpectedly null.")); + FlutterError error("Error", "string_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& string_map_arg = @@ -7887,16 +8064,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoNonNullStringMap( string_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7918,7 +8095,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_int_map_arg = args.at(0); if (encodable_int_map_arg.IsNull()) { - reply(WrapError("int_map_arg unexpectedly null.")); + FlutterError error("Error", "int_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& int_map_arg = @@ -7926,16 +8105,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoNonNullIntMap( int_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7957,7 +8136,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_enum_map_arg = args.at(0); if (encodable_enum_map_arg.IsNull()) { - reply(WrapError("enum_map_arg unexpectedly null.")); + FlutterError error("Error", "enum_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& enum_map_arg = @@ -7965,16 +8146,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoNonNullEnumMap( enum_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -7996,7 +8177,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_class_map_arg = args.at(0); if (encodable_class_map_arg.IsNull()) { - reply(WrapError("class_map_arg unexpectedly null.")); + FlutterError error("Error", "class_map_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& class_map_arg = @@ -8004,16 +8187,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoNonNullClassMap( class_map_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8034,7 +8217,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_an_enum_arg = args.at(0); if (encodable_an_enum_arg.IsNull()) { - reply(WrapError("an_enum_arg unexpectedly null.")); + FlutterError error("Error", "an_enum_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& an_enum_arg = std::any_cast( @@ -8042,16 +8227,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoEnum( an_enum_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8073,7 +8258,10 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_another_enum_arg = args.at(0); if (encodable_another_enum_arg.IsNull()) { - reply(WrapError("another_enum_arg unexpectedly null.")); + FlutterError error("Error", + "another_enum_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& another_enum_arg = std::any_cast( @@ -8081,16 +8269,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoAnotherEnum( another_enum_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8115,21 +8303,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterEchoNullableBool( a_bool_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8156,21 +8344,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, an_int_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8197,21 +8385,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, a_double_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8238,21 +8426,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, a_string_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8280,21 +8468,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, [reply]( ErrorOr>>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8321,21 +8509,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8362,21 +8550,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, enum_list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8403,21 +8591,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, class_list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8444,21 +8632,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, enum_list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8485,21 +8673,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, class_list_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8526,21 +8714,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8567,21 +8755,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, string_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8608,21 +8796,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, int_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8649,21 +8837,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, enum_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8690,21 +8878,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, class_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8731,21 +8919,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, string_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8772,21 +8960,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, int_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8813,21 +9001,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, enum_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8854,21 +9042,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, class_map_arg, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8900,21 +9088,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, an_enum_arg ? &(*an_enum_arg) : nullptr, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back(CustomEncodableValue( + EncodableValue result_value(CustomEncodableValue( std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8946,21 +9134,21 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, another_enum_arg ? &(*another_enum_arg) : nullptr, [reply](ErrorOr>&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; auto output_optional = std::move(output).TakeValue(); if (output_optional) { - wrapped.push_back(CustomEncodableValue( + EncodableValue result_value(CustomEncodableValue( std::move(output_optional).value())); + reply(WrapResponse(&result_value, nullptr)); } else { - wrapped.push_back(EncodableValue()); + reply(WrapResponse(nullptr, nullptr)); } - reply(EncodableValue(std::move(wrapped))); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -8982,7 +9170,9 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_string_arg = args.at(0); if (encodable_a_string_arg.IsNull()) { - reply(WrapError("a_string_arg unexpectedly null.")); + FlutterError error("Error", "a_string_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_string_arg = @@ -8990,16 +9180,16 @@ void HostIntegrationCoreApi::SetUp(::flutter::BinaryMessenger* binary_messenger, api->CallFlutterSmallApiEchoString( a_string_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -11050,14 +11240,13 @@ void HostTrivialApi::SetUp(::flutter::BinaryMessenger* binary_messenger, try { std::optional output = api->Noop(); if (output.has_value()) { - reply(WrapError(output.value())); + reply(WrapResponse(nullptr, &output.value())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(nullptr, nullptr)); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -11112,23 +11301,25 @@ void HostSmallApi::SetUp(::flutter::BinaryMessenger* binary_messenger, const auto& args = std::get(message); const auto& encodable_a_string_arg = args.at(0); if (encodable_a_string_arg.IsNull()) { - reply(WrapError("a_string_arg unexpectedly null.")); + FlutterError error("Error", "a_string_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); return; } const auto& a_string_arg = std::get(encodable_a_string_arg); api->Echo(a_string_arg, [reply](ErrorOr&& output) { if (output.has_error()) { - reply(WrapError(output.error())); + reply(WrapResponse(nullptr, &output.error())); return; } - EncodableList wrapped; - wrapped.push_back( + EncodableValue result_value( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(&result_value, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { @@ -11148,15 +11339,14 @@ void HostSmallApi::SetUp(::flutter::BinaryMessenger* binary_messenger, try { api->VoidVoid([reply](std::optional&& output) { if (output.has_value()) { - reply(WrapError(output.value())); + reply(WrapResponse(nullptr, &output.value())); return; } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); + reply(WrapResponse(nullptr, nullptr)); }); } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); } }); } else { diff --git a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp index 0796242985d0..0430b9956f90 100644 --- a/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp +++ b/packages/pigeon/platform_tests/test_plugin/windows/test_plugin.cpp @@ -226,7 +226,8 @@ ErrorOr TestPlugin::EchoClassWrapper( return wrapper; } -// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +// This uses a switch statement to explicitly map the enum value to verify that +// all generated enum constants are valid and usable. ErrorOr TestPlugin::HostHTTPResponse( const AcronymsAndTestCase& acronyms) { AcronymsAndTestCase result(acronyms.http_response(), acronyms.json_parser(), @@ -244,7 +245,8 @@ ErrorOr TestPlugin::HostHTTPResponse( return result; } -// This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. +// This uses a switch statement to explicitly map the enum value to verify that +// all generated enum constants are valid and usable. ErrorOr TestPlugin::SendJSONParser( const AcronymsAndTestCase& acronyms) { AcronymsAndTestCase result(acronyms.http_response(), acronyms.json_parser(), diff --git a/packages/pigeon/test/cpp_generator_test.dart b/packages/pigeon/test/cpp_generator_test.dart index 0c77bed2b1de..85c10d958efd 100644 --- a/packages/pigeon/test/cpp_generator_test.dart +++ b/packages/pigeon/test/cpp_generator_test.dart @@ -2415,7 +2415,7 @@ void main() { ); final code = sink.toString(); expect(code, isNot(contains('reply(wrap'))); - expect(code, contains('reply(EncodableValue(')); + expect(code, contains('reply(WrapResponse(')); }); test('does not keep unowned references in async handlers', () { diff --git a/packages/pigeon/test/java_generator_test.dart b/packages/pigeon/test/java_generator_test.dart index a5f0708abf58..510cebe7f465 100644 --- a/packages/pigeon/test/java_generator_test.dart +++ b/packages/pigeon/test/java_generator_test.dart @@ -199,7 +199,7 @@ void main() { code, contains( RegExp( - r'@NonNull\s*protected static ArrayList wrapError\(@NonNull Throwable exception\)', + r'@NonNull\s*protected static ArrayList wrapResponse\(@Nullable Object result, @Nullable Throwable error\)', ), ), ); diff --git a/packages/pigeon/test/kotlin_generator_test.dart b/packages/pigeon/test/kotlin_generator_test.dart index fe9600e81bc1..d7163cd744ec 100644 --- a/packages/pigeon/test/kotlin_generator_test.dart +++ b/packages/pigeon/test/kotlin_generator_test.dart @@ -263,9 +263,9 @@ void main() { val args = message as List val inputArg = args[0] as Input val wrapped: List = try { - listOf(api.doSomething(inputArg)) + PigeonUtils.wrapResponse(api.doSomething(inputArg), null) } catch (exception: Throwable) { - PigeonUtils.wrapError(exception) + PigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -628,8 +628,8 @@ void main() { ); final code = sink.toString(); expect(code, contains('fun doSomething(): Output')); - expect(code, contains('listOf(api.doSomething())')); - expect(code, contains('wrapError(exception)')); + expect(code, contains('wrapResponse(api.doSomething(), null)')); + expect(code, contains('wrapResponse(null, exception)')); expect(code, contains('reply(wrapped)')); }); @@ -851,7 +851,7 @@ void main() { final code = sink.toString(); expect(code, contains('interface Api')); expect(code, contains('api.doSomething(argArg) {')); - expect(code, contains('reply.reply(PigeonUtils.wrapResult(data))')); + expect(code, contains('reply.reply(PigeonUtils.wrapResponse(data, null))')); }); test('gen one async Flutter Api', () { @@ -1215,7 +1215,7 @@ void main() { ); final code = sink.toString(); expect(code, contains('fun doit(): List')); - expect(code, contains('listOf(api.doit())')); + expect(code, contains('wrapResponse(api.doit(), null)')); expect(code, contains('reply.reply(wrapped)')); }); @@ -1306,7 +1306,7 @@ void main() { final code = sink.toString(); expect(code, contains('fun add(x: Long, y: Long): Long')); expect(code, contains('val args = message as List')); - expect(code, contains('listOf(api.add(xArg, yArg))')); + expect(code, contains('wrapResponse(api.add(xArg, yArg), null)')); expect(code, contains('reply.reply(wrapped)')); }); @@ -1760,10 +1760,10 @@ void main() { ); final code = sink.toString(); expect(code, contains('class SomeError')); - expect(code, contains('if (exception is SomeError)')); - expect(code, contains('exception.code,')); - expect(code, contains('exception.message,')); - expect(code, contains('exception.details')); + expect(code, contains('if (error is SomeError)')); + expect(code, contains('error.code,')); + expect(code, contains('error.message,')); + expect(code, contains('error.details')); }); test('connection error contains channel name', () { diff --git a/packages/pigeon/test/swift_generator_test.dart b/packages/pigeon/test/swift_generator_test.dart index fa567e2b02c8..099b8348d41f 100644 --- a/packages/pigeon/test/swift_generator_test.dart +++ b/packages/pigeon/test/swift_generator_test.dart @@ -530,7 +530,7 @@ void main() { final code = sink.toString(); expect(code, contains('func doSomething() throws -> Output')); expect(code, contains('let result = try api.doSomething()')); - expect(code, contains('reply(wrapResult(result))')); + expect(code, contains('reply(wrapResponse(result, nil))')); expect(code, isNot(contains('if ('))); }); @@ -766,7 +766,7 @@ void main() { final code = sink.toString(); expect(code, contains('protocol Api')); expect(code, contains('api.doSomething(arg: argArg) { result in')); - expect(code, contains('reply(wrapResult(res))')); + expect(code, contains('reply(wrapResponse(res, nil))')); expect(code, isNot(contains('if ('))); }); @@ -1089,7 +1089,7 @@ void main() { final code = sink.toString(); expect(code, contains('func doit() throws -> [Int64?]')); expect(code, contains('let result = try api.doit()')); - expect(code, contains('reply(wrapResult(result))')); + expect(code, contains('reply(wrapResponse(result, nil))')); }); test('flutter generics return', () { @@ -1187,7 +1187,7 @@ void main() { expect(code, contains('let xArg = args[0] as! Int64')); expect(code, contains('let yArg = args[1] as! Int64')); expect(code, contains('let result = try api.add(x: xArg, y: yArg)')); - expect(code, contains('reply(wrapResult(result))')); + expect(code, contains('reply(wrapResponse(result, nil))')); }); test('flutter multiple args', () { From 6dea86e7d19d6c1a57f66622dbce674a11f12085 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Tue, 14 Apr 2026 13:55:28 -0700 Subject: [PATCH 3/7] bug fixes --- .../example/app/windows/runner/messages.g.h | 38 +++++++++---------- .../pigeon/lib/src/cpp/cpp_generator.dart | 19 +++++----- .../pigeon/lib/src/swift/swift_generator.dart | 8 ++-- .../AlternateLanguageTestPlugin.java | 5 +++ .../AlternateLanguageTestPlugin.m | 5 +++ .../test_plugin/ProxyApiTests.gen.swift | 6 ++- .../Sources/test_plugin/TestPlugin.swift | 24 +++++++----- .../windows/pigeon/core_tests.gen.h | 38 +++++++++---------- 8 files changed, 79 insertions(+), 64 deletions(-) diff --git a/packages/pigeon/example/app/windows/runner/messages.g.h b/packages/pigeon/example/app/windows/runner/messages.g.h index 4693fdcbda48..b23312baccff 100644 --- a/packages/pigeon/example/app/windows/runner/messages.g.h +++ b/packages/pigeon/example/app/windows/runner/messages.g.h @@ -19,6 +19,25 @@ namespace pigeon_example { // Generated class from Pigeon. +class FlutterError { + public: + explicit FlutterError(const std::string& code) : code_(code) {} + explicit FlutterError(const std::string& code, const std::string& message) + : code_(code), message_(message) {} + explicit FlutterError(const std::string& code, const std::string& message, + const ::flutter::EncodableValue& details) + : code_(code), message_(message), details_(details) {} + + const std::string& code() const { return code_; } + const std::string& message() const { return message_; } + const ::flutter::EncodableValue& details() const { return details_; } + + private: + std::string code_; + std::string message_; + ::flutter::EncodableValue details_; +}; + template class ErrorOr { public: @@ -40,25 +59,6 @@ class ErrorOr { std::variant v_; }; -class FlutterError { - public: - explicit FlutterError(const std::string& code) : code_(code) {} - explicit FlutterError(const std::string& code, const std::string& message) - : code_(code), message_(message) {} - explicit FlutterError(const std::string& code, const std::string& message, - const ::flutter::EncodableValue& details) - : code_(code), message_(message), details_(details) {} - - const std::string& code() const { return code_; } - const std::string& message() const { return message_; } - const ::flutter::EncodableValue& details() const { return details_; } - - private: - std::string code_; - std::string message_; - ::flutter::EncodableValue details_; -}; - enum class Code { kOne = 0, kTwo = 1 }; // Generated class from Pigeon that represents data sent in messages. diff --git a/packages/pigeon/lib/src/cpp/cpp_generator.dart b/packages/pigeon/lib/src/cpp/cpp_generator.dart index 3d4bb370a9b2..d5c3aaf3a769 100644 --- a/packages/pigeon/lib/src/cpp/cpp_generator.dart +++ b/packages/pigeon/lib/src/cpp/cpp_generator.dart @@ -278,16 +278,7 @@ class CppHeaderGenerator extends StructuredGenerator { Root root, Indent indent, { required String dartPackageName, - }) { - if (root.containsHostApi) { - _writeErrorOr( - indent, - friends: root.apis - .where((Api api) => api is AstFlutterApi || api is AstHostApi) - .map((Api api) => api.name), - ); - } - } + }) {} @override void writeErrorClass( @@ -316,6 +307,14 @@ class FlutterError { \tstd::string message_; \t::flutter::EncodableValue details_; };'''); + if (root.containsHostApi) { + _writeErrorOr( + indent, + friends: root.apis + .where((Api api) => api is AstFlutterApi || api is AstHostApi) + .map((Api api) => api.name), + ); + } } @override diff --git a/packages/pigeon/lib/src/swift/swift_generator.dart b/packages/pigeon/lib/src/swift/swift_generator.dart index cf6c6a924025..b96097935fdf 100644 --- a/packages/pigeon/lib/src/swift/swift_generator.dart +++ b/packages/pigeon/lib/src/swift/swift_generator.dart @@ -2469,10 +2469,10 @@ func $deepHashName(value: Any?, hasher: inout Hasher) { binaryMessenger: binaryMessenger, codec: codec) if api != nil { $varChannelName.setMessageHandler { message, reply in - reply(wrapError(FlutterError(code: "PigeonUnsupportedOperationError", - message: "Call to $methodName requires @$availableAnnotation.", - details: nil - ))) + reply(wrapResponse(nil, FlutterError(code: "PigeonUnsupportedOperationError", + message: "Call to $methodName requires @$availableAnnotation.", + details: nil + ))) } } else { $varChannelName.setMessageHandler(nil) 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 a1d9ab5d2920..26b39b9361e2 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 @@ -460,6 +460,11 @@ public Map echoNullableNonNullClassMap( .build(); } + @Override + public @NonNull AcronymsAndTestCase echoAcronyms(@NonNull AcronymsAndTestCase acronyms) { + return acronyms; + } + @Override public void noopAsync(@NonNull VoidResult result) { result.success(); diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m b/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m index 4538189392ea..5d62a5d725be 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/darwin/alternate_language_test_plugin/Sources/alternate_language_test_plugin/AlternateLanguageTestPlugin.m @@ -444,6 +444,11 @@ - (nullable FLTAcronymsAndTestCase *)sendJSONParser:(FLTAcronymsAndTestCase *)ac acronymsEnum:enumBox]; } +- (nullable FLTAcronymsAndTestCase *)echoAcronyms:(FLTAcronymsAndTestCase *)acronyms + error:(FlutterError *_Nullable *_Nonnull)error { + return acronyms; +} + - (void)noopAsyncWithCompletion:(void (^)(FlutterError *_Nullable))completion { completion(nil); } diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift index 2d2c842c4023..9582c64651ab 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/ProxyApiTests.gen.swift @@ -4304,7 +4304,8 @@ final class PigeonApiClassWithApiRequirement: PigeonApiProtocolClassWithApiRequi if api != nil { pigeonDefaultConstructorChannel.setMessageHandler { message, reply in reply( - wrapError( + wrapResponse( + nil, FlutterError( code: "PigeonUnsupportedOperationError", message: @@ -4341,7 +4342,8 @@ final class PigeonApiClassWithApiRequirement: PigeonApiProtocolClassWithApiRequi if api != nil { aMethodChannel.setMessageHandler { message, reply in reply( - wrapError( + wrapResponse( + nil, FlutterError( code: "PigeonUnsupportedOperationError", message: "Call to aMethod requires @available(iOS 15.0.0, macOS 10.0.0, *).", diff --git a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/TestPlugin.swift b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/TestPlugin.swift index fc1b17657f83..9141cebc2d67 100644 --- a/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/TestPlugin.swift +++ b/packages/pigeon/platform_tests/test_plugin/darwin/test_plugin/Sources/test_plugin/TestPlugin.swift @@ -194,12 +194,14 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { // This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. func hostHTTPResponse(_ acronyms: AcronymsAndTestCase) throws -> AcronymsAndTestCase { - let enumVal: AcronymsEnum + let enumVal: AcronymsEnum? switch acronyms.acronymsEnum { - case .httpResponse: - enumVal = .httpResponse - case .jsonParser: - enumVal = .jsonParser + case .hTTPResponse: + enumVal = .hTTPResponse + case .jSONParser: + enumVal = .jSONParser + case nil: + enumVal = nil } return AcronymsAndTestCase( httpResponse: acronyms.httpResponse, @@ -211,12 +213,14 @@ public class TestPlugin: NSObject, FlutterPlugin, HostIntegrationCoreApi { // This uses a switch statement to explicitly map the enum value to verify that all generated enum constants are valid and usable. func sendJSONParser(_ acronyms: AcronymsAndTestCase) throws -> AcronymsAndTestCase { - let enumVal: AcronymsEnum + let enumVal: AcronymsEnum? switch acronyms.acronymsEnum { - case .httpResponse: - enumVal = .httpResponse - case .jsonParser: - enumVal = .jsonParser + case .hTTPResponse: + enumVal = .hTTPResponse + case .jSONParser: + enumVal = .jSONParser + case nil: + enumVal = nil } return AcronymsAndTestCase( httpResponse: acronyms.httpResponse, 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 10d972c84698..af44357872a6 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 @@ -22,6 +22,25 @@ class CoreTestsTest; // Generated class from Pigeon. +class FlutterError { + public: + explicit FlutterError(const std::string& code) : code_(code) {} + explicit FlutterError(const std::string& code, const std::string& message) + : code_(code), message_(message) {} + explicit FlutterError(const std::string& code, const std::string& message, + const ::flutter::EncodableValue& details) + : code_(code), message_(message), details_(details) {} + + const std::string& code() const { return code_; } + const std::string& message() const { return message_; } + const ::flutter::EncodableValue& details() const { return details_; } + + private: + std::string code_; + std::string message_; + ::flutter::EncodableValue details_; +}; + template class ErrorOr { public: @@ -46,25 +65,6 @@ class ErrorOr { std::variant v_; }; -class FlutterError { - public: - explicit FlutterError(const std::string& code) : code_(code) {} - explicit FlutterError(const std::string& code, const std::string& message) - : code_(code), message_(message) {} - explicit FlutterError(const std::string& code, const std::string& message, - const ::flutter::EncodableValue& details) - : code_(code), message_(message), details_(details) {} - - const std::string& code() const { return code_; } - const std::string& message() const { return message_; } - const ::flutter::EncodableValue& details() const { return details_; } - - private: - std::string code_; - std::string message_; - ::flutter::EncodableValue details_; -}; - enum class AnEnum { kOne = 0, kTwo = 1, From b5a2afbd8fe18104a9b9c3c0d38f13d8faf5e710 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Tue, 14 Apr 2026 14:06:39 -0700 Subject: [PATCH 4/7] changelog --- packages/pigeon/CHANGELOG.md | 6 ++++++ packages/pigeon/lib/src/generator_tools.dart | 2 +- packages/pigeon/pubspec.yaml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index 1d8884d3e71c..d986692bc859 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,3 +1,9 @@ +## 27.0.0 + +* **BREAKING CHANGE**: Adds support for acronyms in snake_case conversion in generators. This may change the generated output for symbols containing acronyms. +* Refactors response handling across all generators to use a single `wrapResponse` method instead of `wrapResult` and `wrapError`. +* Cleans up repeated code and adds an error class and prologue to the base `Generator` class. + ## 26.3.4 * [kotlin] Updates generated error class to inherit from `RuntimeException` diff --git a/packages/pigeon/lib/src/generator_tools.dart b/packages/pigeon/lib/src/generator_tools.dart index aeb92a4a03bb..6af8f3a537fc 100644 --- a/packages/pigeon/lib/src/generator_tools.dart +++ b/packages/pigeon/lib/src/generator_tools.dart @@ -15,7 +15,7 @@ import 'generator.dart'; /// The current version of pigeon. /// /// This must match the version in pubspec.yaml. -const String pigeonVersion = '26.3.4'; +const String pigeonVersion = '27.0.0'; /// Default plugin package name. const String defaultPluginPackageName = 'dev.flutter.pigeon'; diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index 804181258e69..4842bea01476 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: 26.3.4 # This must match the version in lib/src/generator_tools.dart +version: 27.0.0 # This must match the version in lib/src/generator_tools.dart environment: sdk: ^3.9.0 From 089b254b10c3da85ca54acd021b602b76f8bce75 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Tue, 14 Apr 2026 16:27:21 -0700 Subject: [PATCH 5/7] more saming of method names --- .../pigeon/lib/src/cpp/cpp_generator.dart | 12 ++--- .../pigeon/lib/src/objc/objc_generator.dart | 12 ++--- .../pigeon/lib/src/swift/swift_generator.dart | 45 ++++++++++--------- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/packages/pigeon/lib/src/cpp/cpp_generator.dart b/packages/pigeon/lib/src/cpp/cpp_generator.dart index d5c3aaf3a769..b93558ca0d6c 100644 --- a/packages/pigeon/lib/src/cpp/cpp_generator.dart +++ b/packages/pigeon/lib/src/cpp/cpp_generator.dart @@ -1561,7 +1561,7 @@ EncodableValue $_overflowClassName::FromEncodableList( indent.write( 'case ${types[i].enumeration - maximumCodecFieldKey}: ', ); - _writeCodecDecode(indent, types[i], 'wrapped_'); + _writeDecodeLogic(indent, types[i], 'wrapped_'); } }); indent.writeln('return EncodableValue();'); @@ -1569,7 +1569,7 @@ EncodableValue $_overflowClassName::FromEncodableList( ); } - void _writeCodecDecode( + void _writeDecodeLogic( Indent indent, EnumeratedType customType, String value, @@ -1642,13 +1642,13 @@ EncodableValue $_overflowClassName::FromEncodableList( if (customType.enumeration < maximumCodecFieldKey) { indent.write('case ${customType.enumeration}: '); indent.nest(1, () { - _writeCodecDecode(indent, customType, 'ReadValue(stream)'); + _writeDecodeLogic(indent, customType, 'ReadValue(stream)'); }); } } if (root.requiresOverflowClass) { indent.write('case $maximumCodecFieldKey:'); - _writeCodecDecode( + _writeDecodeLogic( indent, _enumeratedOverflow, 'ReadValue(stream)', @@ -1680,7 +1680,7 @@ EncodableValue $_overflowClassName::FromEncodableList( 'if (const CustomEncodableValue* custom_value = std::get_if(&value)) ', ); indent.addScoped('{', '}', () { - for (final customType in enumeratedTypes) { + void writeEncodeLogic(EnumeratedType customType) { final encodeString = customType.type == CustomTypes.customClass ? 'std::any_cast<${customType.name}>(*custom_value).ToEncodableList()' : 'static_cast(std::any_cast<${customType.name}>(*custom_value))'; @@ -1707,6 +1707,8 @@ EncodableValue $_overflowClassName::FromEncodableList( indent.writeln('return;'); }); } + + enumeratedTypes.forEach(writeEncodeLogic); }); } indent.writeln('$_standardCodecSerializer::WriteValue(value, stream);'); diff --git a/packages/pigeon/lib/src/objc/objc_generator.dart b/packages/pigeon/lib/src/objc/objc_generator.dart index 85b04a53b335..8c38c83b5553 100644 --- a/packages/pigeon/lib/src/objc/objc_generator.dart +++ b/packages/pigeon/lib/src/objc/objc_generator.dart @@ -821,7 +821,7 @@ if (self.wrapped == nil) { final int caseIndex = i - totalCustomCodecKeysAllowed; final EnumeratedType type = types[i]; indent.write('case $caseIndex:'); - _writeCodecDecode( + _writeDecodeLogic( indent, type, generatorOptions.prefix ?? '', @@ -836,7 +836,7 @@ if (self.wrapped == nil) { indent.writeln('@end'); } - void _writeCodecDecode( + void _writeDecodeLogic( Indent indent, EnumeratedType customType, String? prefix, { @@ -912,7 +912,7 @@ if (self.wrapped == nil) { for (final customType in enumeratedTypes) { if (customType.enumeration < maximumCodecFieldKey) { indent.write('case ${customType.enumeration}: '); - _writeCodecDecode( + _writeDecodeLogic( indent, customType, generatorOptions.prefix ?? '', @@ -921,7 +921,7 @@ if (self.wrapped == nil) { } if (root.requiresOverflowClass) { indent.write('case $maximumCodecFieldKey: '); - _writeCodecDecode( + _writeDecodeLogic( indent, _enumeratedOverflow, generatorOptions.prefix, @@ -941,7 +941,7 @@ if (self.wrapped == nil) { indent.write('- (void)writeValue:(id)value '); indent.addScoped('{', '}', () { indent.write(''); - for (final customType in enumeratedTypes) { + void writeEncodeLogic(EnumeratedType customType) { final encodeString = customType.type == CustomTypes.customClass ? '[value toList]' : '(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])'; @@ -977,6 +977,8 @@ if (self.wrapped == nil) { addTrailingNewline: false, ); } + + enumeratedTypes.forEach(writeEncodeLogic); indent.addScoped('{', '}', () { indent.writeln('[super writeValue:value];'); }); diff --git a/packages/pigeon/lib/src/swift/swift_generator.dart b/packages/pigeon/lib/src/swift/swift_generator.dart index b96097935fdf..d0f4fc1468b1 100644 --- a/packages/pigeon/lib/src/swift/swift_generator.dart +++ b/packages/pigeon/lib/src/swift/swift_generator.dart @@ -292,6 +292,28 @@ class SwiftGenerator extends StructuredGenerator { }); } + void writeEncodeLogic(EnumeratedType customType) { + indent.add('if let value = value as? ${customType.name} '); + indent.addScoped('{', '} else ', () { + final encodeString = customType.type == CustomTypes.customClass + ? 'toList()' + : 'rawValue'; + final valueString = customType.enumeration < maximumCodecFieldKey + ? 'value.$encodeString' + : 'wrap.toList()'; + final int enumeration = customType.enumeration < maximumCodecFieldKey + ? customType.enumeration + : maximumCodecFieldKey; + if (customType.enumeration >= maximumCodecFieldKey) { + indent.writeln( + 'let wrap = $_overflowClassName(type: ${customType.enumeration - maximumCodecFieldKey}, wrapped: value.$encodeString)', + ); + } + indent.writeln('super.writeByte($enumeration)'); + indent.writeln('super.writeValue($valueString)'); + }, addTrailingNewline: false); + } + final overflowClass = EnumeratedType( _overflowClassName, maximumCodecFieldKey, @@ -343,28 +365,7 @@ class SwiftGenerator extends StructuredGenerator { indent.write('override func writeValue(_ value: Any) '); indent.addScoped('{', '}', () { indent.write(''); - for (final customType in enumeratedTypes) { - indent.add('if let value = value as? ${customType.name} '); - indent.addScoped('{', '} else ', () { - final encodeString = customType.type == CustomTypes.customClass - ? 'toList()' - : 'rawValue'; - final valueString = customType.enumeration < maximumCodecFieldKey - ? 'value.$encodeString' - : 'wrap.toList()'; - final int enumeration = - customType.enumeration < maximumCodecFieldKey - ? customType.enumeration - : maximumCodecFieldKey; - if (customType.enumeration >= maximumCodecFieldKey) { - indent.writeln( - 'let wrap = $_overflowClassName(type: ${customType.enumeration - maximumCodecFieldKey}, wrapped: value.$encodeString)', - ); - } - indent.writeln('super.writeByte($enumeration)'); - indent.writeln('super.writeValue($valueString)'); - }, addTrailingNewline: false); - } + enumeratedTypes.forEach(writeEncodeLogic); indent.addScoped('{', '}', () { indent.writeln('super.writeValue(value)'); }); From 74aba514d5d4ffe03a3294ead0aee36a3b2eff97 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Tue, 14 Apr 2026 17:55:41 -0700 Subject: [PATCH 6/7] fix gobject? --- .../pigeon/example/app/linux/messages.g.cc | 4 +- .../pigeon/lib/src/cpp/cpp_generator.dart | 209 +++++++++-------- .../lib/src/gobject/gobject_generator.dart | 16 +- .../linux/pigeon/core_tests.gen.cc | 222 +++++++++++++----- 4 files changed, 287 insertions(+), 164 deletions(-) diff --git a/packages/pigeon/example/app/linux/messages.g.cc b/packages/pigeon/example/app/linux/messages.g.cc index f1b0e818d11f..74683ef3aec0 100644 --- a/packages/pigeon/example/app/linux/messages.g.cc +++ b/packages/pigeon/example/app/linux/messages.g.cc @@ -1008,7 +1008,9 @@ pigeon_example_package_message_flutter_api_flutter_method_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } diff --git a/packages/pigeon/lib/src/cpp/cpp_generator.dart b/packages/pigeon/lib/src/cpp/cpp_generator.dart index b93558ca0d6c..83c2f034fef7 100644 --- a/packages/pigeon/lib/src/cpp/cpp_generator.dart +++ b/packages/pigeon/lib/src/cpp/cpp_generator.dart @@ -1931,109 +1931,13 @@ EncodableValue $_overflowClassName::FromEncodableList( method, dartPackageName, ); - indent.writeScoped('{', '}', () { - indent.writeln( - 'BasicMessageChannel<> channel(binary_messenger, ' - '"$channelName" + prepended_suffix, &GetCodec());', - ); - indent.writeScoped('if (api != nullptr) {', '} else {', () { - indent.write( - 'channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) ', - ); - indent.addScoped('{', '});', () { - indent.writeScoped('try {', '}', () { - final methodArgument = []; - if (method.parameters.isNotEmpty) { - indent.writeln( - 'const auto& args = std::get(message);', - ); - - enumerate(method.parameters, (int index, NamedType arg) { - final HostDatatype hostType = getHostDatatype( - arg.type, - (TypeDeclaration x) => - _shortBaseCppTypeForBuiltinDartType(x), - ); - final String argName = _getSafeArgumentName(index, arg); - - final encodableArgName = '${_encodablePrefix}_$argName'; - indent.writeln( - 'const auto& $encodableArgName = args.at($index);', - ); - if (!arg.type.isNullable) { - indent.writeScoped( - 'if ($encodableArgName.IsNull()) {', - '}', - () { - indent.writeln( - 'FlutterError error("Error", "$argName unexpectedly null.", EncodableValue());', - ); - indent.writeln( - 'reply(WrapResponse(nullptr, &error));', - ); - indent.writeln('return;'); - }, - ); - } - _writeEncodableValueArgumentUnwrapping( - indent, - root, - hostType, - argName: argName, - encodableArgName: encodableArgName, - apiType: ApiType.host, - ); - final unwrapEnum = arg.type.isEnum && arg.type.isNullable - ? ' ? &(*$argName) : nullptr' - : ''; - methodArgument.add('$argName$unwrapEnum'); - }); - } - - final HostDatatype returnType = getHostDatatype( - method.returnType, - _shortBaseCppTypeForBuiltinDartType, - ); - final String returnTypeName = _hostApiReturnType(returnType); - if (method.isAsynchronous) { - methodArgument.add( - '[reply]($returnTypeName&& output) {${indent.newline}' - '${_wrapResponse(indent, root, method.returnType, prefix: '\t')}${indent.newline}' - '}', - ); - } - final call = - 'api->${_makeMethodName(method)}(${methodArgument.join(', ')})'; - if (method.isAsynchronous) { - indent.format('$call;'); - } else { - indent.writeln('$returnTypeName output = $call;'); - indent.format( - _wrapResponse(indent, root, method.returnType), - ); - } - }, addTrailingNewline: false); - indent.add(' catch (const std::exception& exception) '); - indent.addScoped('{', '}', () { - // There is a potential here for `reply` to be called twice, which - // is a violation of the API contract, because there's no way of - // knowing whether or not the plugin code called `reply` before - // throwing. Since use of `@async` suggests that the reply is - // probably not sent within the scope of the stack, err on the - // side of potential double-call rather than no call (which is - // also an API violation) so that unexpected errors have a better - // chance of being caught and handled in a useful way. - indent.writeln( - 'FlutterError error("Error", exception.what(), EncodableValue());', - ); - indent.writeln('reply(WrapResponse(nullptr, &error));'); - }); - }); - }); - indent.addScoped(null, '}', () { - indent.writeln('channel.SetMessageHandler(nullptr);'); - }); - }); + _writeHostMethodMessageHandler( + indent, + root, + api, + method, + channelName, + ); } }, ); @@ -2070,6 +1974,105 @@ return EncodableValue(EncodableList{ ); } + void _writeHostMethodMessageHandler( + Indent indent, + Root root, + AstHostApi api, + Method method, + String channelName, + ) { + indent.writeScoped('{', '}', () { + indent.writeln( + 'BasicMessageChannel<> channel(binary_messenger, ' + '"$channelName" + prepended_suffix, &GetCodec());', + ); + indent.writeScoped('if (api != nullptr) {', '} else {', () { + indent.write( + 'channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) ', + ); + indent.addScoped('{', '});', () { + indent.writeScoped('try {', '}', () { + final methodArgument = []; + if (method.parameters.isNotEmpty) { + indent.writeln( + 'const auto& args = std::get(message);', + ); + + enumerate(method.parameters, (int index, NamedType arg) { + final HostDatatype hostType = getHostDatatype( + arg.type, + (TypeDeclaration x) => _shortBaseCppTypeForBuiltinDartType(x), + ); + final String argName = _getSafeArgumentName(index, arg); + + final encodableArgName = '${_encodablePrefix}_$argName'; + indent.writeln( + 'const auto& $encodableArgName = args.at($index);', + ); + if (!arg.type.isNullable) { + indent.writeScoped( + 'if ($encodableArgName.IsNull()) {', + '}', + () { + indent.writeln( + 'FlutterError error("Error", "$argName unexpectedly null.", EncodableValue());', + ); + indent.writeln('reply(WrapResponse(nullptr, &error));'); + indent.writeln('return;'); + }, + ); + } + _writeEncodableValueArgumentUnwrapping( + indent, + root, + hostType, + argName: argName, + encodableArgName: encodableArgName, + apiType: ApiType.host, + ); + final unwrapEnum = arg.type.isEnum && arg.type.isNullable + ? ' ? &(*$argName) : nullptr' + : ''; + methodArgument.add('$argName$unwrapEnum'); + }); + } + + final HostDatatype returnType = getHostDatatype( + method.returnType, + _shortBaseCppTypeForBuiltinDartType, + ); + final String returnTypeName = _hostApiReturnType(returnType); + if (method.isAsynchronous) { + methodArgument.add( + '[reply]($returnTypeName&& output) {${indent.newline}' + '${_wrapResponse(indent, root, method.returnType, prefix: '\t')}${indent.newline}' + '}', + ); + } + final call = + 'api->${_makeMethodName(method)}(${methodArgument.join(', ')})'; + if (method.isAsynchronous) { + indent.format('$call;'); + } else { + indent.writeln('$returnTypeName output = $call;'); + indent.format(_wrapResponse(indent, root, method.returnType)); + } + }, addTrailingNewline: false); + indent.add(' catch (const std::exception& exception) '); + indent.addScoped('{', '}', () { + indent.writeln( + 'FlutterError error("Error", exception.what(), EncodableValue());', + ); + indent.writeln('reply(WrapResponse(nullptr, &error));'); + }); + }); + }); + indent.addScoped(null, '}', () { + indent.writeln('channel.SetMessageHandler(nullptr);'); + }); + }); + } + void _writeClassConstructor( Root root, Indent indent, diff --git a/packages/pigeon/lib/src/gobject/gobject_generator.dart b/packages/pigeon/lib/src/gobject/gobject_generator.dart index 50d6355b9822..6805e6720395 100644 --- a/packages/pigeon/lib/src/gobject/gobject_generator.dart +++ b/packages/pigeon/lib/src/gobject/gobject_generator.dart @@ -1273,9 +1273,15 @@ class GObjectSourceGenerator module, field.type.baseName, ); - indent.writeln( - 'result = result * 31 + ${fieldMethodPrefix}_hash(self->$fieldName);', - ); + if (field.type.isNullable) { + indent.writeln( + 'result = result * 31 + (self->$fieldName != nullptr ? ${fieldMethodPrefix}_hash(self->$fieldName) : 0);', + ); + } else { + indent.writeln( + 'result = result * 31 + ${fieldMethodPrefix}_hash(self->$fieldName);', + ); + } } else if (field.type.isEnum) { if (field.type.isNullable) { indent.writeln( @@ -1693,7 +1699,9 @@ class GObjectSourceGenerator indent.writeln( 'FlValue* value = fl_value_get_list_value(response, 0);', ); - indent.writeln('self->return_value = fl_value_ref(value);'); + indent.writeScoped('if (value != nullptr) {', '}', () { + indent.writeln('self->return_value = fl_value_ref(value);'); + }); }); } indent.writeln('return self;'); diff --git a/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.cc b/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.cc index 2f33470c9120..ab1ff22513a5 100644 --- a/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.cc +++ b/packages/pigeon/platform_tests/test_plugin/linux/pigeon/core_tests.gen.cc @@ -1978,8 +1978,10 @@ guint core_tests_pigeon_test_all_nullable_types_hash( ? g_str_hash(self->a_nullable_string) : 0); result = result * 31 + flpigeon_deep_hash(self->a_nullable_object); - result = result * 31 + core_tests_pigeon_test_all_nullable_types_hash( - self->all_nullable_types); + result = result * 31 + (self->all_nullable_types != nullptr + ? core_tests_pigeon_test_all_nullable_types_hash( + self->all_nullable_types) + : 0); result = result * 31 + flpigeon_deep_hash(self->list); result = result * 31 + flpigeon_deep_hash(self->string_list); result = result * 31 + flpigeon_deep_hash(self->int_list); @@ -3304,10 +3306,16 @@ guint core_tests_pigeon_test_all_classes_wrapper_hash( guint result = 0; result = result * 31 + core_tests_pigeon_test_all_nullable_types_hash( self->all_nullable_types); + result = + result * 31 + + (self->all_nullable_types_without_recursion != nullptr + ? core_tests_pigeon_test_all_nullable_types_without_recursion_hash( + self->all_nullable_types_without_recursion) + : 0); result = result * 31 + - core_tests_pigeon_test_all_nullable_types_without_recursion_hash( - self->all_nullable_types_without_recursion); - result = result * 31 + core_tests_pigeon_test_all_types_hash(self->all_types); + (self->all_types != nullptr + ? core_tests_pigeon_test_all_types_hash(self->all_types) + : 0); result = result * 31 + flpigeon_deep_hash(self->class_list); result = result * 31 + flpigeon_deep_hash(self->nullable_class_list); result = result * 31 + flpigeon_deep_hash(self->class_map); @@ -26439,7 +26447,9 @@ core_tests_pigeon_test_flutter_integration_core_api_throw_error_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -26749,7 +26759,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_all_types_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -26916,7 +26928,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_all_nullable_types_resp self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -27095,7 +27109,9 @@ core_tests_pigeon_test_flutter_integration_core_api_send_multiple_nullable_types self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -27275,7 +27291,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_all_nullable_types_with self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -27456,7 +27474,9 @@ core_tests_pigeon_test_flutter_integration_core_api_send_multiple_nullable_types self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -27632,7 +27652,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_bool_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -27791,7 +27813,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_int_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -27951,7 +27975,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_double_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -28111,7 +28137,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_string_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -28271,7 +28299,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_uint8_list_response_new self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -28436,7 +28466,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_list_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -28596,7 +28628,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_enum_list_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -28758,7 +28792,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_class_list_response_new self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -28922,7 +28958,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_non_null_enum_list_resp self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -29091,7 +29129,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_non_null_class_list_res self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -29257,7 +29297,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_map_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -29417,7 +29459,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_string_map_response_new self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -29579,7 +29623,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_int_map_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -29740,7 +29786,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_enum_map_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -29902,7 +29950,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_class_map_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -30066,7 +30116,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_non_null_string_map_res self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -30234,7 +30286,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_non_null_int_map_respon self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -30402,7 +30456,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_non_null_enum_map_respo self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -30571,7 +30627,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_non_null_class_map_resp self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -30737,7 +30795,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_enum_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -30903,7 +30963,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_another_enum_response_n self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -31072,7 +31134,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_bool_response_ self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -31246,7 +31310,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_int_response_n self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -31415,7 +31481,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_double_respons self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -31588,7 +31656,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_string_respons self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -31761,7 +31831,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_uint8_list_res self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -31938,7 +32010,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_list_response_ self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -32111,7 +32185,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_enum_list_resp self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -32284,7 +32360,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_class_list_res self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -32458,7 +32536,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_ self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -32632,7 +32712,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -32804,7 +32886,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_map_response_n self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -32972,7 +33056,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_string_map_res self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -33144,7 +33230,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_int_map_respon self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -33317,7 +33405,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_enum_map_respo self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -33490,7 +33580,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_class_map_resp self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -33664,7 +33756,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_strin self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -33838,7 +33932,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_int_m self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -34012,7 +34108,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_enum_ self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -34186,7 +34284,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_non_null_class self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -34359,7 +34459,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_nullable_enum_response_ self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -34540,7 +34642,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_another_nullable_enum_r self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -34860,7 +34964,9 @@ core_tests_pigeon_test_flutter_integration_core_api_echo_async_string_response_n self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -35580,7 +35686,9 @@ core_tests_pigeon_test_flutter_small_api_echo_wrapped_list_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } @@ -35738,7 +35846,9 @@ core_tests_pigeon_test_flutter_small_api_echo_string_response_new( self->error = fl_value_ref(response); } else { FlValue* value = fl_value_get_list_value(response, 0); - self->return_value = fl_value_ref(value); + if (value != nullptr) { + self->return_value = fl_value_ref(value); + } } return self; } From df74d725407ce424b3cae5c84bae2814054607a0 Mon Sep 17 00:00:00 2001 From: tarrinneal Date: Wed, 15 Apr 2026 14:12:45 -0700 Subject: [PATCH 7/7] split up host api --- .../java/io/flutter/plugins/Messages.java | 1 - .../pigeon/lib/src/cpp/cpp_generator.dart | 217 ++++++---- .../lib/src/gobject/gobject_generator.dart | 197 +++++---- .../pigeon/lib/src/java/java_generator.dart | 392 ++++++++++++------ .../lib/src/kotlin/kotlin_generator.dart | 347 +++++++++++----- .../pigeon/lib/src/objc/objc_generator.dart | 363 +++++++++------- .../pigeon/lib/src/swift/swift_generator.dart | 296 +++++++++---- .../CoreTests.java | 92 ---- 8 files changed, 1174 insertions(+), 731 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 181441d8ff84..deaa4456f44f 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 @@ -534,7 +534,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.sendMessage(messageArg, resultCallback); }); } else { diff --git a/packages/pigeon/lib/src/cpp/cpp_generator.dart b/packages/pigeon/lib/src/cpp/cpp_generator.dart index 83c2f034fef7..cdd59b1263a0 100644 --- a/packages/pigeon/lib/src/cpp/cpp_generator.dart +++ b/packages/pigeon/lib/src/cpp/cpp_generator.dart @@ -1982,95 +1982,152 @@ return EncodableValue(EncodableList{ String channelName, ) { indent.writeScoped('{', '}', () { - indent.writeln( - 'BasicMessageChannel<> channel(binary_messenger, ' - '"$channelName" + prepended_suffix, &GetCodec());', + final varChannelName = 'channel'; + _writeChannelAllocation( + indent, + varChannelName: varChannelName, + channelName: channelName, ); - indent.writeScoped('if (api != nullptr) {', '} else {', () { - indent.write( - 'channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) ', - ); - indent.addScoped('{', '});', () { - indent.writeScoped('try {', '}', () { - final methodArgument = []; - if (method.parameters.isNotEmpty) { - indent.writeln( - 'const auto& args = std::get(message);', - ); - enumerate(method.parameters, (int index, NamedType arg) { - final HostDatatype hostType = getHostDatatype( - arg.type, - (TypeDeclaration x) => _shortBaseCppTypeForBuiltinDartType(x), - ); - final String argName = _getSafeArgumentName(index, arg); + final HostDatatype returnType = getHostDatatype( + method.returnType, + _shortBaseCppTypeForBuiltinDartType, + ); + final String returnTypeName = _hostApiReturnType(returnType); - final encodableArgName = '${_encodablePrefix}_$argName'; - indent.writeln( - 'const auto& $encodableArgName = args.at($index);', - ); - if (!arg.type.isNullable) { - indent.writeScoped( - 'if ($encodableArgName.IsNull()) {', - '}', - () { - indent.writeln( - 'FlutterError error("Error", "$argName unexpectedly null.", EncodableValue());', - ); - indent.writeln('reply(WrapResponse(nullptr, &error));'); - indent.writeln('return;'); - }, - ); - } - _writeEncodableValueArgumentUnwrapping( - indent, - root, - hostType, - argName: argName, - encodableArgName: encodableArgName, - apiType: ApiType.host, - ); - final unwrapEnum = arg.type.isEnum && arg.type.isNullable - ? ' ? &(*$argName) : nullptr' - : ''; - methodArgument.add('$argName$unwrapEnum'); - }); - } + _writeMessageHandlerRegistration( + indent, + varChannelName: varChannelName, + setHandlerCondition: 'api != nullptr', + messageVarName: 'message', + body: () { + final methodArgument = []; + _writeArgumentUnpacking( + indent, + root: root, + method: method, + methodArgument: methodArgument, + ); - final HostDatatype returnType = getHostDatatype( - method.returnType, - _shortBaseCppTypeForBuiltinDartType, - ); - final String returnTypeName = _hostApiReturnType(returnType); - if (method.isAsynchronous) { - methodArgument.add( - '[reply]($returnTypeName&& output) {${indent.newline}' - '${_wrapResponse(indent, root, method.returnType, prefix: '\t')}${indent.newline}' - '}', - ); - } - final call = - 'api->${_makeMethodName(method)}(${methodArgument.join(', ')})'; - if (method.isAsynchronous) { - indent.format('$call;'); - } else { - indent.writeln('$returnTypeName output = $call;'); - indent.format(_wrapResponse(indent, root, method.returnType)); - } - }, addTrailingNewline: false); - indent.add(' catch (const std::exception& exception) '); - indent.addScoped('{', '}', () { + _writeApiInvocation( + indent, + root: root, + isAsynchronous: method.isAsynchronous, + method: method, + returnTypeName: returnTypeName, + methodArgument: methodArgument, + ); + }, + ); + }); + } + + void _writeChannelAllocation( + Indent indent, { + required String varChannelName, + required String channelName, + }) { + indent.writeln( + 'BasicMessageChannel<> $varChannelName(binary_messenger, ' + '"$channelName" + prepended_suffix, &GetCodec());', + ); + } + + void _writeMessageHandlerRegistration( + Indent indent, { + required String varChannelName, + required String setHandlerCondition, + required String messageVarName, + required void Function() body, + }) { + indent.writeScoped('if ($setHandlerCondition) {', '} else {', () { + indent.write( + '$varChannelName.SetMessageHandler([api](const EncodableValue& $messageVarName, const ::flutter::MessageReply& reply) ', + ); + indent.addScoped('{', '});', () { + indent.writeScoped('try {', '}', () { + body(); + }, addTrailingNewline: false); + indent.add(' catch (const std::exception& exception) '); + indent.addScoped('{', '}', () { + indent.writeln( + 'FlutterError error("Error", exception.what(), EncodableValue());', + ); + indent.writeln('reply(WrapResponse(nullptr, &error));'); + }); + }); + }); + indent.addScoped(null, '}', () { + indent.writeln('$varChannelName.SetMessageHandler(nullptr);'); + }); + } + + void _writeArgumentUnpacking( + Indent indent, { + required Root root, + required Method method, + required List methodArgument, + }) { + if (method.parameters.isNotEmpty) { + indent.writeln('const auto& args = std::get(message);'); + + enumerate(method.parameters, (int index, NamedType arg) { + final HostDatatype hostType = getHostDatatype( + arg.type, + (TypeDeclaration x) => _shortBaseCppTypeForBuiltinDartType(x), + ); + final String argName = _getSafeArgumentName(index, arg); + + final encodableArgName = '${_encodablePrefix}_$argName'; + indent.writeln('const auto& $encodableArgName = args.at($index);'); + if (!arg.type.isNullable) { + indent.writeScoped('if ($encodableArgName.IsNull()) {', '}', () { indent.writeln( - 'FlutterError error("Error", exception.what(), EncodableValue());', + 'FlutterError error("Error", "$argName unexpectedly null.", EncodableValue());', ); indent.writeln('reply(WrapResponse(nullptr, &error));'); + indent.writeln('return;'); }); - }); - }); - indent.addScoped(null, '}', () { - indent.writeln('channel.SetMessageHandler(nullptr);'); + } + _writeEncodableValueArgumentUnwrapping( + indent, + root, + hostType, + argName: argName, + encodableArgName: encodableArgName, + apiType: ApiType.host, + ); + final unwrapEnum = arg.type.isEnum && arg.type.isNullable + ? ' ? &(*$argName) : nullptr' + : ''; + methodArgument.add('$argName$unwrapEnum'); }); - }); + } + } + + void _writeApiInvocation( + Indent indent, { + required Root root, + required bool isAsynchronous, + required Method method, + required String returnTypeName, + required List methodArgument, + }) { + if (isAsynchronous) { + methodArgument.add( + '[reply]($returnTypeName&& output) {${indent.newline}' + '${_wrapResponse(indent, root, method.returnType, prefix: '\t')}${indent.newline}' + '}', + ); + } + final call = + 'api->${_makeMethodName(method)}(${methodArgument.join(', ')})'; + if (isAsynchronous) { + indent.format('$call;'); + } else { + indent.writeln('$returnTypeName output = $call;'); + indent.format(_wrapResponse(indent, root, method.returnType)); + } } void _writeClassConstructor( diff --git a/packages/pigeon/lib/src/gobject/gobject_generator.dart b/packages/pigeon/lib/src/gobject/gobject_generator.dart index 6805e6720395..ef644b8bd16f 100644 --- a/packages/pigeon/lib/src/gobject/gobject_generator.dart +++ b/packages/pigeon/lib/src/gobject/gobject_generator.dart @@ -2109,86 +2109,24 @@ class GObjectSourceGenerator indent.newln(); final methodArgs = []; - for (var i = 0; i < method.parameters.length; i++) { - final Parameter param = method.parameters[i]; - final String paramName = _snakeCaseFromCamelCase(param.name); - final String paramType = _getType(module, param.type); - indent.writeln( - 'FlValue* value$i = fl_value_get_list_value(message_, $i);', - ); - if (_isNullablePrimitiveType(param.type)) { - final String primitiveType = _getType( - module, - param.type, - primitive: true, - ); - indent.writeln('$paramType $paramName = nullptr;'); - indent.writeln('$primitiveType ${paramName}_value;'); - indent.writeScoped( - 'if (fl_value_get_type(value$i) != FL_VALUE_TYPE_NULL) {', - '}', - () { - final String paramValue = _fromFlValue( - module, - method.parameters[i].type, - 'value$i', - ); - indent.writeln('${paramName}_value = $paramValue;'); - indent.writeln('$paramName = &${paramName}_value;'); - }, - ); - } else { - final String paramValue = _fromFlValue( - module, - method.parameters[i].type, - 'value$i', - ); - indent.writeln('$paramType $paramName = $paramValue;'); - } - methodArgs.add(paramName); - if (_isNumericListType(method.parameters[i].type)) { - indent.writeln( - 'size_t ${paramName}_length = fl_value_get_length(value$i);', - ); - methodArgs.add('${paramName}_length'); - } - } - if (method.isAsynchronous) { - final vfuncArgs = []; - vfuncArgs.addAll(methodArgs); - vfuncArgs.addAll(['handle', 'self->user_data']); - indent.writeln( - 'g_autoptr(${className}ResponseHandle) handle = ${methodPrefix}_response_handle_new(channel, response_handle);', - ); - indent.writeln( - "self->vtable->$methodName(${vfuncArgs.join(', ')});", - ); - } else { - final vfuncArgs = []; - vfuncArgs.addAll(methodArgs); - vfuncArgs.add('self->user_data'); - indent.writeln( - "g_autoptr($responseClassName) response = self->vtable->$methodName(${vfuncArgs.join(', ')});", - ); - indent.writeScoped('if (response == nullptr) {', '}', () { - indent.writeln( - 'g_warning("No response returned to %s.%s", "${api.name}", "${method.name}");', - ); - indent.writeln('return;'); - }); + _writeArgumentUnpacking( + indent, + root: root, + method: method, + module: module, + methodArgs: methodArgs, + ); - indent.newln(); - indent.writeln('g_autoptr(GError) error = NULL;'); - indent.writeScoped( - 'if (!fl_basic_message_channel_respond(channel, response_handle, response->value, &error)) {', - '}', - () { - indent.writeln( - 'g_warning("Failed to send response to %s.%s: %s", "${api.name}", "${method.name}", error->message);', - ); - }, - ); - } + _writeApiInvocation( + indent, + method: method, + module: module, + className: className, + methodPrefix: methodPrefix, + responseClassName: responseClassName, + methodArgs: methodArgs, + apiName: api.name, + ); }, ); } @@ -2332,6 +2270,107 @@ class GObjectSourceGenerator ); } } + + void _writeArgumentUnpacking( + Indent indent, { + required Root root, + required Method method, + required String module, + required List methodArgs, + }) { + for (var i = 0; i < method.parameters.length; i++) { + final Parameter param = method.parameters[i]; + final String paramName = _snakeCaseFromCamelCase(param.name); + final String paramType = _getType(module, param.type); + indent.writeln( + 'FlValue* value$i = fl_value_get_list_value(message_, $i);', + ); + if (_isNullablePrimitiveType(param.type)) { + final String primitiveType = _getType( + module, + param.type, + primitive: true, + ); + indent.writeln('$paramType $paramName = nullptr;'); + indent.writeln('$primitiveType ${paramName}_value;'); + indent.writeScoped( + 'if (fl_value_get_type(value$i) != FL_VALUE_TYPE_NULL) {', + '}', + () { + final String paramValue = _fromFlValue( + module, + method.parameters[i].type, + 'value$i', + ); + indent.writeln('${paramName}_value = $paramValue;'); + indent.writeln('$paramName = &${paramName}_value;'); + }, + ); + } else { + final String paramValue = _fromFlValue( + module, + method.parameters[i].type, + 'value$i', + ); + indent.writeln('$paramType $paramName = $paramValue;'); + } + methodArgs.add(paramName); + if (_isNumericListType(method.parameters[i].type)) { + indent.writeln( + 'size_t ${paramName}_length = fl_value_get_length(value$i);', + ); + methodArgs.add('${paramName}_length'); + } + } + } + + void _writeApiInvocation( + Indent indent, { + required Method method, + required String module, + required String className, + required String methodPrefix, + required String responseClassName, + required List methodArgs, + required String apiName, + }) { + if (method.isAsynchronous) { + final vfuncArgs = []; + vfuncArgs.addAll(methodArgs); + vfuncArgs.addAll(['handle', 'self->user_data']); + indent.writeln( + 'g_autoptr(${className}ResponseHandle) handle = ${methodPrefix}_response_handle_new(channel, response_handle);', + ); + indent.writeln( + "self->vtable->${_getMethodName(method.name)}(${vfuncArgs.join(', ')});", + ); + } else { + final vfuncArgs = []; + vfuncArgs.addAll(methodArgs); + vfuncArgs.add('self->user_data'); + indent.writeln( + 'g_autoptr($responseClassName) response = self->vtable->${_getMethodName(method.name)}(${vfuncArgs.join(', ')});', + ); + indent.writeScoped('if (response == nullptr) {', '}', () { + indent.writeln( + 'g_warning("No response returned to %s.%s", "$apiName", "${method.name}");', + ); + indent.writeln('return;'); + }); + + indent.newln(); + indent.writeln('g_autoptr(GError) error = NULL;'); + indent.writeScoped( + 'if (!fl_basic_message_channel_respond(channel, response_handle, response->value, &error)) {', + '}', + () { + indent.writeln( + 'g_warning("Failed to send response to %s.%s: %s", "$apiName", "${method.name}", error->message);', + ); + }, + ); + } + } } // Returns the module name to use. diff --git a/packages/pigeon/lib/src/java/java_generator.dart b/packages/pigeon/lib/src/java/java_generator.dart index 97a9a84a8c45..1a21c3f6180f 100644 --- a/packages/pigeon/lib/src/java/java_generator.dart +++ b/packages/pigeon/lib/src/java/java_generator.dart @@ -1142,6 +1142,7 @@ if (wrapped == null) { /// static void setUp(BinaryMessenger binaryMessenger, Foo api) {...} /// } @override + @override void writeHostApi( InternalJavaOptions generatorOptions, Root root, @@ -1149,6 +1150,24 @@ if (wrapped == null) { AstHostApi api, { required String dartPackageName, }) { + _generateInterface(generatorOptions, root, indent, api, () { + _generateSetupMethod( + generatorOptions, + root, + indent, + api, + dartPackageName: dartPackageName, + ); + }); + } + + void _generateInterface( + InternalJavaOptions generatorOptions, + Root root, + Indent indent, + AstHostApi api, + void Function() body, + ) { const generatedMessages = [ ' Generated interface from Pigeon that represents a handler of messages from Flutter.', ]; @@ -1164,54 +1183,64 @@ if (wrapped == null) { for (final Method method in api.methods) { _writeInterfaceMethod(generatorOptions, root, indent, api, method); } - indent.newln(); - indent.writeln('/** The codec used by ${api.name}. */'); - indent.write('static @NonNull MessageCodec getCodec() '); - indent.addScoped('{', '}', () { - indent.writeln('return $_codecName.INSTANCE;'); - }); + body(); + }); + } + + void _generateSetupMethod( + InternalJavaOptions generatorOptions, + Root root, + Indent indent, + AstHostApi api, { + required String dartPackageName, + }) { + indent.newln(); + indent.writeln('/** The codec used by ${api.name}. */'); + indent.write('static @NonNull MessageCodec getCodec() '); + indent.addScoped('{', '}', () { + indent.writeln('return $_codecName.INSTANCE;'); + }); + indent.writeln( + '/** Sets up an instance of `${api.name}` to handle messages through the `binaryMessenger`. */', + ); + indent.writeScoped( + 'static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable ${api.name} api) {', + '}', + () { + indent.writeln('setUp(binaryMessenger, "", api);'); + }, + ); + indent.write( + 'static void setUp(@NonNull BinaryMessenger binaryMessenger, @NonNull String messageChannelSuffix, @Nullable ${api.name} api) ', + ); + indent.addScoped('{', '}', () { indent.writeln( - '/** Sets up an instance of `${api.name}` to handle messages through the `binaryMessenger`. */', - ); - indent.writeScoped( - 'static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable ${api.name} api) {', - '}', - () { - indent.writeln('setUp(binaryMessenger, "", api);'); - }, + 'messageChannelSuffix = messageChannelSuffix.isEmpty() ? "" : "." + messageChannelSuffix;', ); - indent.write( - 'static void setUp(@NonNull BinaryMessenger binaryMessenger, @NonNull String messageChannelSuffix, @Nullable ${api.name} api) ', - ); - indent.addScoped('{', '}', () { + String? serialBackgroundQueue; + if (api.methods.any( + (Method m) => m.taskQueueType == TaskQueueType.serialBackgroundThread, + )) { + serialBackgroundQueue = 'taskQueue'; indent.writeln( - 'messageChannelSuffix = messageChannelSuffix.isEmpty() ? "" : "." + messageChannelSuffix;', + 'BinaryMessenger.TaskQueue $serialBackgroundQueue = binaryMessenger.makeBackgroundTaskQueue();', ); - String? serialBackgroundQueue; - if (api.methods.any( - (Method m) => m.taskQueueType == TaskQueueType.serialBackgroundThread, - )) { - serialBackgroundQueue = 'taskQueue'; - indent.writeln( - 'BinaryMessenger.TaskQueue $serialBackgroundQueue = binaryMessenger.makeBackgroundTaskQueue();', - ); - } - for (final Method method in api.methods) { - _writeHostMethodMessageHandler( - generatorOptions, - root, - indent, - api, - method, - dartPackageName: dartPackageName, - serialBackgroundQueue: - method.taskQueueType == TaskQueueType.serialBackgroundThread - ? serialBackgroundQueue - : null, - ); - } - }); + } + for (final Method method in api.methods) { + _writeHostMethodMessageHandler( + generatorOptions, + root, + indent, + api, + method, + dartPackageName: dartPackageName, + serialBackgroundQueue: + method.taskQueueType == TaskQueueType.serialBackgroundThread + ? serialBackgroundQueue + : null, + ); + } }); } @@ -1250,96 +1279,209 @@ if (wrapped == null) { final String channelName = makeChannelName(api, method, dartPackageName); indent.write(''); indent.addScoped('{', '}', () { - indent.writeln('BasicMessageChannel channel ='); - indent.nest(2, () { - indent.writeln('new BasicMessageChannel<>('); - indent.nest(2, () { - indent.write( - 'binaryMessenger, "$channelName" + messageChannelSuffix, getCodec()', + final varChannelName = 'channel'; + _writeChannelAllocation( + indent, + varChannelName: varChannelName, + channelName: channelName, + serialBackgroundQueue: serialBackgroundQueue, + ); + + final String returnType = method.returnType.isVoid + ? 'Void' + : _javaTypeForDartType(method.returnType); + _writeMessageHandlerRegistration( + indent, + varChannelName: varChannelName, + setHandlerCondition: 'api != null', + messageVarName: 'message', + body: () { + final methodArgument = []; + _writeArgumentUnpacking( + indent, + parameters: method.parameters, + methodArgument: methodArgument, ); - if (serialBackgroundQueue != null) { - indent.addln(', $serialBackgroundQueue);'); - } else { - indent.addln(');'); - } + + final call = 'api.${method.name}(${methodArgument.join(', ')})'; + + _writeApiInvocation( + indent, + isAsynchronous: method.isAsynchronous, + call: call, + method: method, + returnType: returnType, + methodArgument: methodArgument, + ); + }, + ); + }); + } + + void _writeChannelAllocation( + Indent indent, { + required String varChannelName, + required String channelName, + required String? serialBackgroundQueue, + }) { + indent.writeln('BasicMessageChannel $varChannelName ='); + indent.nest(2, () { + indent.writeln('new BasicMessageChannel<>('); + indent.nest(2, () { + indent.write( + 'binaryMessenger, "$channelName" + messageChannelSuffix, getCodec()', + ); + if (serialBackgroundQueue != null) { + indent.addln(', $serialBackgroundQueue);'); + } else { + indent.addln(');'); + } + }); + }); + } + + void _writeMessageHandlerRegistration( + Indent indent, { + required String varChannelName, + required String setHandlerCondition, + required String messageVarName, + required void Function() body, + }) { + indent.write('if ($setHandlerCondition) '); + indent.addScoped('{', '} else {', () { + indent.writeln('$varChannelName.setMessageHandler('); + indent.nest(2, () { + indent.write('($messageVarName, reply) -> '); + indent.addScoped('{', '});', () { + body(); }); }); - indent.write('if (api != null) '); - indent.addScoped('{', '} else {', () { - indent.writeln('channel.setMessageHandler('); + }); + indent.addScoped(null, '}', () { + indent.writeln('$varChannelName.setMessageHandler(null);'); + }); + } + + void _writeArgumentUnpacking( + Indent indent, { + required List parameters, + required List methodArgument, + }) { + if (parameters.isNotEmpty) { + indent.writeln('ArrayList args = (ArrayList) message;'); + enumerate(parameters, (int index, NamedType arg) { + final String argType = _javaTypeForDartType(arg.type); + final String argName = _getSafeArgumentName(index, arg); + final argExpression = argName; + var accessor = 'args.get($index)'; + if (argType != 'Object') { + accessor = _cast(accessor, javaType: argType); + } + indent.writeln('$argType $argName = $accessor;'); + methodArgument.add(argExpression); + }); + } + } + + void _writeApiInvocation( + Indent indent, { + required bool isAsynchronous, + required String call, + required Method method, + required String returnType, + required List methodArgument, + }) { + if (isAsynchronous) { + final resultValue = method.returnType.isVoid ? 'null' : 'result'; + final String resultType = _getResultType(method.returnType); + final resultParam = method.returnType.isVoid ? '' : '$returnType result'; + final addResultArg = method.returnType.isVoid ? 'null' : resultValue; + const resultName = 'resultCallback'; + + indent.writeln('$resultType $resultName ='); + indent.nest(2, () { + indent.writeln('new $resultType() {'); indent.nest(2, () { - indent.write('(message, reply) -> '); - indent.addScoped('{', '});', () { - final String returnType = method.returnType.isVoid - ? 'Void' - : _javaTypeForDartType(method.returnType); - final methodArgument = []; - if (method.parameters.isNotEmpty) { - indent.writeln( - 'ArrayList args = (ArrayList) message;', - ); - enumerate(method.parameters, (int index, NamedType arg) { - final String argType = _javaTypeForDartType(arg.type); - final String argName = _getSafeArgumentName(index, arg); - final argExpression = argName; - var accessor = 'args.get($index)'; - if (argType != 'Object') { - accessor = _cast(accessor, javaType: argType); - } - indent.writeln('$argType $argName = $accessor;'); - methodArgument.add(argExpression); - }); - } - if (method.isAsynchronous) { - final resultValue = method.returnType.isVoid ? 'null' : 'result'; - final String resultType = _getResultType(method.returnType); - final resultParam = method.returnType.isVoid - ? '' - : '$returnType result'; - final addResultArg = method.returnType.isVoid - ? 'null' - : resultValue; - const resultName = 'resultCallback'; - indent.format(''' -$resultType $resultName = - new $resultType() { - public void success($resultParam) { - reply.reply(wrapResponse($addResultArg, null)); - } - - public void error(Throwable error) { - reply.reply(wrapResponse(null, error)); - } - }; -'''); - methodArgument.add(resultName); - } - final call = 'api.${method.name}(${methodArgument.join(', ')})'; - if (method.isAsynchronous) { - indent.writeln('$call;'); - } else { - indent.write('try '); - indent.addScoped('{', '}', () { - if (method.returnType.isVoid) { - indent.writeln('$call;'); - indent.writeln('reply.reply(wrapResponse(null, null));'); - } else { - indent.writeln('$returnType output = $call;'); - indent.writeln('reply.reply(wrapResponse(output, null));'); - } - }); - indent.add(' catch (Throwable exception) '); - indent.addScoped('{', '}', () { - indent.writeln('reply.reply(wrapResponse(null, exception));'); - }); - } + indent.writeln('public void success($resultParam) {'); + indent.nest(2, () { + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + resultName: addResultArg, + errorName: null, + ), + ); }); + indent.writeln('}'); + indent.newln(); + indent.writeln('public void error(Throwable error) {'); + indent.nest(2, () { + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + resultName: null, + errorName: 'error', + ), + ); + }); + indent.writeln('}'); }); + indent.writeln('};'); }); - indent.addScoped(null, '}', () { - indent.writeln('channel.setMessageHandler(null);'); + + methodArgument.add(resultName); + indent.writeln('api.${method.name}(${methodArgument.join(', ')});'); + } else { + indent.write('try '); + indent.addScoped('{', '}', () { + if (method.returnType.isVoid) { + indent.writeln('$call;'); + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + resultName: null, + errorName: null, + ), + ); + } else { + indent.writeln('$returnType output = $call;'); + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + resultName: 'output', + errorName: null, + ), + ); + } }); - }); + indent.add(' catch (Throwable exception) '); + indent.addScoped('{', '}', () { + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + resultName: null, + errorName: 'exception', + ), + ); + }); + } + } + + String _writeResultWrapping( + Indent indent, { + required String? resultName, + required String? errorName, + }) { + return 'wrapResponse(${resultName ?? 'null'}, ${errorName ?? 'null'})'; + } + + void _writeReplying(Indent indent, {required String response}) { + indent.writeln('reply.reply($response);'); } void _writeResultInterfaces(Indent indent) { diff --git a/packages/pigeon/lib/src/kotlin/kotlin_generator.dart b/packages/pigeon/lib/src/kotlin/kotlin_generator.dart index c909e533c5c4..e75bace3d06c 100644 --- a/packages/pigeon/lib/src/kotlin/kotlin_generator.dart +++ b/packages/pigeon/lib/src/kotlin/kotlin_generator.dart @@ -785,6 +785,7 @@ if (wrapped == null) { /// } /// @override + @override void writeHostApi( InternalKotlinOptions generatorOptions, Root root, @@ -792,6 +793,18 @@ if (wrapped == null) { AstHostApi api, { required String dartPackageName, }) { + _generateInterface(indent, api, () { + _generateSetupMethod( + generatorOptions, + root, + indent, + api, + dartPackageName: dartPackageName, + ); + }); + } + + void _generateInterface(Indent indent, AstHostApi api, void Function() body) { final String apiName = api.name; const generatedMessages = [ @@ -816,56 +829,65 @@ if (wrapped == null) { isAsynchronous: method.isAsynchronous, ); } + body(); + }); + } - indent.newln(); - indent.write('companion object '); + void _generateSetupMethod( + InternalKotlinOptions generatorOptions, + Root root, + Indent indent, + AstHostApi api, { + required String dartPackageName, + }) { + final String apiName = api.name; + indent.newln(); + indent.write('companion object '); + indent.addScoped('{', '}', () { + indent.writeln('/** The codec used by $apiName. */'); + indent.write('val codec: MessageCodec by lazy '); indent.addScoped('{', '}', () { - indent.writeln('/** The codec used by $apiName. */'); - indent.write('val codec: MessageCodec by lazy '); - indent.addScoped('{', '}', () { - indent.writeln( - '${generatorOptions.fileSpecificClassNameComponent}$_codecName()', - ); - }); indent.writeln( - '/** Sets up an instance of `$apiName` to handle messages through the `binaryMessenger`. */', + '${generatorOptions.fileSpecificClassNameComponent}$_codecName()', ); - indent.writeln('@JvmOverloads'); - indent.write( - 'fun setUp(binaryMessenger: BinaryMessenger, api: $apiName?, messageChannelSuffix: String = "") ', + }); + indent.writeln( + '/** Sets up an instance of `$apiName` to handle messages through the `binaryMessenger`. */', + ); + indent.writeln('@JvmOverloads'); + indent.write( + 'fun setUp(binaryMessenger: BinaryMessenger, api: $apiName?, messageChannelSuffix: String = "") ', + ); + indent.addScoped('{', '}', () { + indent.writeln( + r'val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""', ); - indent.addScoped('{', '}', () { + String? serialBackgroundQueue; + if (api.methods.any( + (Method m) => m.taskQueueType == TaskQueueType.serialBackgroundThread, + )) { + serialBackgroundQueue = 'taskQueue'; indent.writeln( - r'val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""', + 'val $serialBackgroundQueue = binaryMessenger.makeBackgroundTaskQueue()', ); - String? serialBackgroundQueue; - if (api.methods.any( - (Method m) => - m.taskQueueType == TaskQueueType.serialBackgroundThread, - )) { - serialBackgroundQueue = 'taskQueue'; - indent.writeln( - 'val $serialBackgroundQueue = binaryMessenger.makeBackgroundTaskQueue()', - ); - } - for (final Method method in api.methods) { - _writeHostMethodMessageHandler( - indent, - generatorOptions: generatorOptions, - name: method.name, - channelName: - '${makeChannelName(api, method, dartPackageName)}\$separatedMessageChannelSuffix', - taskQueueType: method.taskQueueType, - parameters: method.parameters, - returnType: method.returnType, - isAsynchronous: method.isAsynchronous, - serialBackgroundQueue: - method.taskQueueType == TaskQueueType.serialBackgroundThread - ? serialBackgroundQueue - : null, - ); - } - }); + } + for (final Method method in api.methods) { + _writeHostMethodMessageHandler( + indent, + generatorOptions: generatorOptions, + name: method.name, + channelName: + '${makeChannelName(api, method, dartPackageName)}\$separatedMessageChannelSuffix', + taskQueueType: method.taskQueueType, + parameters: method.parameters, + returnType: method.returnType, + isAsynchronous: method.isAsynchronous, + serialBackgroundQueue: + method.taskQueueType == TaskQueueType.serialBackgroundThread + ? serialBackgroundQueue + : null, + ); + } }); }); } @@ -1656,90 +1678,187 @@ fun floatHash(f: Float): Int { }) { indent.write('run '); indent.addScoped('{', '}', () { - indent.write( - 'val channel = BasicMessageChannel(binaryMessenger, "$channelName", codec', + final varChannelName = 'channel'; + _writeChannelAllocation( + indent, + varChannelName: varChannelName, + channelName: channelName, + serialBackgroundQueue: serialBackgroundQueue, ); - if (serialBackgroundQueue != null) { - indent.addln(', $serialBackgroundQueue)'); - } else { - indent.addln(')'); - } - - indent.write('if ($setHandlerCondition) '); - indent.addScoped('{', '}', () { - final messageVarName = parameters.isNotEmpty ? 'message' : '_'; + final messageVarName = parameters.isNotEmpty ? 'message' : '_'; - indent.write('channel.setMessageHandler '); - indent.addScoped('{ $messageVarName, reply ->', '}', () { + _writeMessageHandlerRegistration( + indent, + varChannelName: varChannelName, + setHandlerCondition: setHandlerCondition, + messageVarName: messageVarName, + body: () { final methodArguments = []; - if (parameters.isNotEmpty) { - indent.writeln('val args = message as List'); - enumerate(parameters, (int index, NamedType arg) { - final String argName = _getSafeArgumentName(index, arg); - final argIndex = 'args[$index]'; - indent.writeln( - 'val $argName = ${_castForceUnwrap(argIndex, arg.type, indent)}', - ); - methodArguments.add(argName); - }); - } + _writeArgumentUnpacking( + indent, + parameters: parameters, + methodArguments: methodArguments, + ); + final String call = onCreateCall != null ? onCreateCall(methodArguments, apiVarName: 'api') : 'api.$name(${methodArguments.join(', ')})'; - if (isAsynchronous) { - final String resultType = returnType.isVoid - ? 'Unit' - : _nullSafeKotlinTypeForDartType(returnType); - indent.write(methodArguments.isNotEmpty ? '$call ' : 'api.$name'); - indent.addScoped('{ result: Result<$resultType> ->', '}', () { - indent.writeln('val error = result.exceptionOrNull()'); - indent.writeScoped('if (error != null) {', '}', () { - indent.writeln( - 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResponse(null, error))', - ); - }, addTrailingNewline: false); - indent.addScoped(' else {', '}', () { - if (returnType.isVoid) { - indent.writeln( - 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResponse(null, null))', - ); - } else { - indent.writeln('val data = result.getOrNull()'); - indent.writeln( - 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResponse(data, null))', - ); - } - }); - }); + _writeApiInvocation( + indent, + generatorOptions: generatorOptions, + isAsynchronous: isAsynchronous, + call: call, + name: name, + returnType: returnType, + methodArguments: methodArguments, + ); + }, + ); + }); + } + + void _writeChannelAllocation( + Indent indent, { + required String varChannelName, + required String channelName, + required String? serialBackgroundQueue, + }) { + indent.write( + 'val $varChannelName = BasicMessageChannel(binaryMessenger, "$channelName", codec', + ); + + if (serialBackgroundQueue != null) { + indent.addln(', $serialBackgroundQueue)'); + } else { + indent.addln(')'); + } + } + + void _writeMessageHandlerRegistration( + Indent indent, { + required String varChannelName, + required String setHandlerCondition, + required String messageVarName, + required void Function() body, + }) { + indent.write('if ($setHandlerCondition) '); + indent.addScoped('{', '}', () { + indent.write('$varChannelName.setMessageHandler '); + indent.addScoped('{ $messageVarName, reply ->', '}', () { + body(); + }); + }, addTrailingNewline: false); + indent.addScoped(' else {', '}', () { + indent.writeln('$varChannelName.setMessageHandler(null)'); + }); + } + + void _writeArgumentUnpacking( + Indent indent, { + required List parameters, + required List methodArguments, + }) { + if (parameters.isNotEmpty) { + indent.writeln('val args = message as List'); + enumerate(parameters, (int index, NamedType arg) { + final String argName = _getSafeArgumentName(index, arg); + final argIndex = 'args[$index]'; + indent.writeln( + 'val $argName = ${_castForceUnwrap(argIndex, arg.type, indent)}', + ); + methodArguments.add(argName); + }); + } + } + + void _writeApiInvocation( + Indent indent, { + required InternalKotlinOptions generatorOptions, + required bool isAsynchronous, + required String call, + required String name, + required TypeDeclaration returnType, + required List methodArguments, + }) { + if (isAsynchronous) { + final String resultType = returnType.isVoid + ? 'Unit' + : _nullSafeKotlinTypeForDartType(returnType); + indent.write(methodArguments.isNotEmpty ? '$call ' : 'api.$name'); + indent.addScoped('{ result: Result<$resultType> ->', '}', () { + indent.writeln('val error = result.exceptionOrNull()'); + indent.writeScoped('if (error != null) {', '}', () { + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + generatorOptions: generatorOptions, + resultName: null, + errorName: 'error', + ), + ); + }, addTrailingNewline: false); + indent.addScoped(' else {', '}', () { + if (returnType.isVoid) { + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + generatorOptions: generatorOptions, + resultName: null, + errorName: null, + ), + ); } else { - indent.writeScoped('val wrapped: List = try {', '}', () { - if (returnType.isVoid) { - indent.writeln(call); - indent.writeln( - '${_getUtilsClassName(generatorOptions)}.wrapResponse(null, null)', - ); - } else { - indent.writeln( - '${_getUtilsClassName(generatorOptions)}.wrapResponse($call, null)', - ); - } - }, addTrailingNewline: false); - indent.add(' catch (exception: Throwable) '); - indent.addScoped('{', '}', () { - indent.writeln( - '${_getUtilsClassName(generatorOptions)}.wrapResponse(null, exception)', - ); - }); - indent.writeln('reply.reply(wrapped)'); + indent.writeln('val data = result.getOrNull()'); + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + generatorOptions: generatorOptions, + resultName: 'data', + errorName: null, + ), + ); } }); + }); + } else { + indent.writeScoped('val wrapped: List = try {', '}', () { + if (returnType.isVoid) { + indent.writeln(call); + indent.writeln( + '${_getUtilsClassName(generatorOptions)}.wrapResponse(null, null)', + ); + } else { + indent.writeln( + '${_getUtilsClassName(generatorOptions)}.wrapResponse($call, null)', + ); + } }, addTrailingNewline: false); - indent.addScoped(' else {', '}', () { - indent.writeln('channel.setMessageHandler(null)'); + indent.add(' catch (exception: Throwable) '); + indent.addScoped('{', '}', () { + indent.writeln( + '${_getUtilsClassName(generatorOptions)}.wrapResponse(null, exception)', + ); }); - }); + indent.writeln('reply.reply(wrapped)'); + } + } + + String _writeResultWrapping( + Indent indent, { + required InternalKotlinOptions generatorOptions, + required String? resultName, + required String? errorName, + }) { + return '${_getUtilsClassName(generatorOptions)}.wrapResponse(${resultName ?? 'null'}, ${errorName ?? 'null'})'; + } + + void _writeReplying(Indent indent, {required String response}) { + indent.writeln('reply.reply($response)'); } void _writeFlutterMethod( diff --git a/packages/pigeon/lib/src/objc/objc_generator.dart b/packages/pigeon/lib/src/objc/objc_generator.dart index 8c38c83b5553..66993fce4c80 100644 --- a/packages/pigeon/lib/src/objc/objc_generator.dart +++ b/packages/pigeon/lib/src/objc/objc_generator.dart @@ -1204,162 +1204,58 @@ static FlutterError *createConnectionError(NSString *channelName) { Method func, String channel, ) { - void unpackArgs(String variable) { - indent.writeln('NSArray *args = $variable;'); - var count = 0; - for (final NamedType arg in func.parameters) { - final String argName = _getSafeArgName(count, arg); - final valueGetter = 'GetNullableObjectAtIndex(args, $count)'; - final String? primitiveExtractionMethod = _nsnumberExtractionMethod( - arg.type, - ); - final _ObjcType objcArgType = _objcTypeForDartType( - generatorOptions.prefix, - arg.type, - ); - final String ivarValueExpression; - String beforeString = objcArgType.beforeString; - if (arg.type.isEnum && !arg.type.isNullable) { - final varName = - 'boxed${_enumName(arg.type.baseName, prefix: generatorOptions.prefix)}'; - _writeEnumBoxToEnum( - indent, - arg, - varName, - valueGetter, - prefix: generatorOptions.prefix, - ); - ivarValueExpression = '$varName.value'; - } else if (primitiveExtractionMethod != null) { - ivarValueExpression = '[$valueGetter $primitiveExtractionMethod]'; - } else { - if (arg.type.isEnum) { - beforeString = _enumName( - arg.type.baseName, - prefix: generatorOptions.prefix, - box: true, - suffix: ' *', - ); - } - ivarValueExpression = valueGetter; - } - indent.writeln('$beforeString$argName = $ivarValueExpression;'); - count++; - } - } - - void writeAsyncBindings( - Iterable selectorComponents, - String callSignature, - _ObjcType returnType, - ) { - if (func.returnType.isVoid) { - const callback = 'callback(wrapResult(nil, error));'; - if (func.parameters.isEmpty) { - indent.writeScoped( - '[api ${selectorComponents.first}:^(FlutterError *_Nullable error) {', - '}];', - () { - indent.writeln(callback); - }, - ); - } else { - indent.writeScoped( - '[api $callSignature ${selectorComponents.last}:^(FlutterError *_Nullable error) {', - '}];', - () { - indent.writeln(callback); - }, - ); - } - } else { - const callback = 'callback(wrapResult(output, error));'; - var returnTypeString = '${returnType.beforeString}_Nullable output'; - - if (func.returnType.isEnum) { - returnTypeString = - '${_enumName(func.returnType.baseName, suffix: ' *_Nullable', prefix: generatorOptions.prefix, box: true)} output'; - } - if (func.parameters.isEmpty) { - indent.writeScoped( - '[api ${selectorComponents.first}:^($returnTypeString, FlutterError *_Nullable error) {', - '}];', - () { - indent.writeln(callback); - }, - ); - } else { - indent.writeScoped( - '[api $callSignature ${selectorComponents.last}:^($returnTypeString, FlutterError *_Nullable error) {', - '}];', - () { - indent.writeln(callback); - }, - ); - } - } - } - - void writeSyncBindings(String call, _ObjcType returnType) { - indent.writeln('FlutterError *error;'); - if (func.returnType.isVoid) { - indent.writeln('$call;'); - indent.writeln('callback(wrapResult(nil, error));'); - } else { - if (func.returnType.isEnum) { - indent.writeln( - '${_enumName(func.returnType.baseName, suffix: ' *', prefix: generatorOptions.prefix, box: true)} output = $call;', - ); - } else { - indent.writeln('${returnType.beforeString}output = $call;'); - } - indent.writeln('callback(wrapResult(output, error));'); - } - } - // TODO(gaaclarke): Incorporate this into _getSelectorComponents. final lastSelectorComponent = func.isAsynchronous ? 'completion' : 'error'; final String selector = _getSelector(func, lastSelectorComponent); indent.writeln( 'NSCAssert([api respondsToSelector:@selector($selector)], @"$apiName api (%@) doesn\'t respond to @selector($selector)", api);', ); - indent.write( - '[$channel setMessageHandler:^(id _Nullable message, FlutterReply callback) ', + + _writeMessageHandlerRegistration( + indent, + varChannelName: channel, + body: () { + final _ObjcType returnType = _objcTypeForDartType( + generatorOptions.prefix, + func.returnType, + // Nullability is required since the return must be nil if NSError is set. + forceBox: true, + ); + final Iterable selectorComponents = _getSelectorComponents( + func, + lastSelectorComponent, + ); + final Iterable argNames = indexMap( + func.parameters, + _getSafeArgName, + ); + final String callSignature = map2( + selectorComponents.take(argNames.length), + argNames, + (String selectorComponent, String argName) { + return '$selectorComponent:$argName'; + }, + ).join(' '); + + if (func.parameters.isNotEmpty) { + _writeArgumentUnpacking( + indent, + generatorOptions: generatorOptions, + func: func, + variable: 'message', + ); + } + + _writeApiInvocation( + indent, + generatorOptions: generatorOptions, + func: func, + returnType: returnType, + selectorComponents: selectorComponents, + callSignature: callSignature, + ); + }, ); - indent.addScoped('{', '}];', () { - final _ObjcType returnType = _objcTypeForDartType( - generatorOptions.prefix, - func.returnType, - // Nullability is required since the return must be nil if NSError is set. - forceBox: true, - ); - final Iterable selectorComponents = _getSelectorComponents( - func, - lastSelectorComponent, - ); - final Iterable argNames = indexMap( - func.parameters, - _getSafeArgName, - ); - final String callSignature = map2( - selectorComponents.take(argNames.length), - argNames, - (String selectorComponent, String argName) { - return '$selectorComponent:$argName'; - }, - ).join(' '); - if (func.parameters.isNotEmpty) { - unpackArgs('message'); - } - if (func.isAsynchronous) { - writeAsyncBindings(selectorComponents, callSignature, returnType); - } else { - final syncCall = func.parameters.isEmpty - ? '[api ${selectorComponents.first}:&error]' - : '[api $callSignature error:&error]'; - writeSyncBindings(syncCall, returnType); - } - }); } void _writeChannelAllocation( @@ -1402,6 +1298,175 @@ taskQueue:$taskQueue }); } + void _writeMessageHandlerRegistration( + Indent indent, { + required String varChannelName, + required void Function() body, + }) { + indent.write( + '[$varChannelName setMessageHandler:^(id _Nullable message, FlutterReply callback) ', + ); + indent.addScoped('{', '}];', body); + } + + void _writeArgumentUnpacking( + Indent indent, { + required InternalObjcOptions generatorOptions, + required Method func, + required String variable, + }) { + indent.writeln('NSArray *args = $variable;'); + var count = 0; + for (final NamedType arg in func.parameters) { + final String argName = _getSafeArgName(count, arg); + final valueGetter = 'GetNullableObjectAtIndex(args, $count)'; + final String? primitiveExtractionMethod = _nsnumberExtractionMethod( + arg.type, + ); + final _ObjcType objcArgType = _objcTypeForDartType( + generatorOptions.prefix, + arg.type, + ); + final String ivarValueExpression; + String beforeString = objcArgType.beforeString; + if (arg.type.isEnum && !arg.type.isNullable) { + final varName = + 'boxed${_enumName(arg.type.baseName, prefix: generatorOptions.prefix)}'; + _writeEnumBoxToEnum( + indent, + arg, + varName, + valueGetter, + prefix: generatorOptions.prefix, + ); + ivarValueExpression = '$varName.value'; + } else if (primitiveExtractionMethod != null) { + ivarValueExpression = '[$valueGetter $primitiveExtractionMethod]'; + } else { + if (arg.type.isEnum) { + beforeString = _enumName( + arg.type.baseName, + prefix: generatorOptions.prefix, + box: true, + suffix: ' *', + ); + } + ivarValueExpression = valueGetter; + } + indent.writeln('$beforeString$argName = $ivarValueExpression;'); + count++; + } + } + + void _writeApiInvocation( + Indent indent, { + required InternalObjcOptions generatorOptions, + required Method func, + required _ObjcType returnType, + required Iterable selectorComponents, + required String callSignature, + }) { + if (func.isAsynchronous) { + _writeAsyncBindings( + indent, + generatorOptions: generatorOptions, + func: func, + returnType: returnType, + selectorComponents: selectorComponents, + callSignature: callSignature, + ); + } else { + final syncCall = func.parameters.isEmpty + ? '[api ${selectorComponents.first}:&error]' + : '[api $callSignature error:&error]'; + _writeSyncBindings( + indent, + func: func, + syncCall: syncCall, + returnType: returnType, + prefix: generatorOptions.prefix, + ); + } + } + + void _writeAsyncBindings( + Indent indent, { + required InternalObjcOptions generatorOptions, + required Method func, + required _ObjcType returnType, + required Iterable selectorComponents, + required String callSignature, + }) { + if (func.returnType.isVoid) { + const callback = 'callback(wrapResult(nil, error));'; + if (func.parameters.isEmpty) { + indent.writeScoped( + '[api ${selectorComponents.first}:^(FlutterError *_Nullable error) {', + '}];', + () { + indent.writeln(callback); + }, + ); + } else { + indent.writeScoped( + '[api $callSignature ${selectorComponents.last}:^(FlutterError *_Nullable error) {', + '}];', + () { + indent.writeln(callback); + }, + ); + } + } else { + const callback = 'callback(wrapResult(output, error));'; + var returnTypeString = '${returnType.beforeString}_Nullable output'; + + if (func.returnType.isEnum) { + returnTypeString = + '${_enumName(func.returnType.baseName, suffix: ' *_Nullable', prefix: generatorOptions.prefix, box: true)} output'; + } + if (func.parameters.isEmpty) { + indent.writeScoped( + '[api ${selectorComponents.first}:^($returnTypeString, FlutterError *_Nullable error) {', + '}];', + () { + indent.writeln(callback); + }, + ); + } else { + indent.writeScoped( + '[api $callSignature ${selectorComponents.last}:^($returnTypeString, FlutterError *_Nullable error) {', + '}];', + () { + indent.writeln(callback); + }, + ); + } + } + } + + void _writeSyncBindings( + Indent indent, { + required Method func, + required String syncCall, + required _ObjcType returnType, + required String? prefix, + }) { + indent.writeln('FlutterError *error;'); + if (func.returnType.isVoid) { + indent.writeln('$syncCall;'); + indent.writeln('callback(wrapResult(nil, error));'); + } else { + if (func.returnType.isEnum) { + indent.writeln( + '${_enumName(func.returnType.baseName, suffix: ' *', prefix: prefix, box: true)} output = $syncCall;', + ); + } else { + indent.writeln('${returnType.beforeString}output = $syncCall;'); + } + indent.writeln('callback(wrapResult(output, error));'); + } + } + void _writeObjcSourceDataClassExtension( InternalObjcOptions languageOptions, Indent indent, diff --git a/packages/pigeon/lib/src/swift/swift_generator.dart b/packages/pigeon/lib/src/swift/swift_generator.dart index d0f4fc1468b1..477f65816cd6 100644 --- a/packages/pigeon/lib/src/swift/swift_generator.dart +++ b/packages/pigeon/lib/src/swift/swift_generator.dart @@ -884,6 +884,17 @@ if (wrapped == nil) { AstHostApi api, { required String dartPackageName, }) { + _generateInterface(indent, api); + _generateSetupMethod( + generatorOptions, + root, + indent, + api, + dartPackageName: dartPackageName, + ); + } + + void _generateInterface(Indent indent, AstHostApi api) { final String apiName = api.name; const generatedComments = [ @@ -916,7 +927,16 @@ if (wrapped == nil) { ); } }); + } + void _generateSetupMethod( + InternalSwiftOptions generatorOptions, + Root root, + Indent indent, + AstHostApi api, { + required String dartPackageName, + }) { + final String apiName = api.name; indent.newln(); indent.writeln( '/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.', @@ -941,10 +961,6 @@ if (wrapped == nil) { (Method m) => m.taskQueueType == TaskQueueType.serialBackgroundThread, )) { serialBackgroundQueue = 'taskQueue'; - // TODO(stuartmorgan): Remove the ? once macOS supports task queues - // and this is no longer an optional protocol method. - // See https://github.com/flutter/flutter/issues/162613 for why this - // is an ifdef instead of just relying on the optionality check. indent.format(''' #if os(iOS) let $serialBackgroundQueue = binaryMessenger.makeBackgroundTaskQueue?() @@ -1922,13 +1938,57 @@ func $deepHashName(value: Any?, hasher: inout Hasher) { final baseArgs = 'name: "$channelName", ' 'binaryMessenger: binaryMessenger, codec: codec'; - // The version with taskQueue: is an optional protocol method that isn't - // implemented on macOS yet, so the call has to be conditionalized even - // though the taskQueue argument is nullable. The runtime branching can be - // removed once macOS supports task queues. The condition is on the task - // queue variable not being nil because the earlier code to set it will - // return nil on macOS where the optional parts of the protocol are not - // implemented. + + _writeChannelAllocation( + indent, + varChannelName: varChannelName, + baseArgs: baseArgs, + serialBackgroundQueue: serialBackgroundQueue, + ); + + final messageVarName = parameters.isNotEmpty ? 'message' : '_'; + + _writeMessageHandlerRegistration( + indent, + varChannelName: varChannelName, + setHandlerCondition: setHandlerCondition, + messageVarName: messageVarName, + body: () { + final methodArgument = []; + _writeArgumentUnpacking( + indent, + parameters: parameters, + arguments: components.arguments, + methodArgument: methodArgument, + ); + + final tryStatement = isAsynchronous ? '' : 'try '; + late final String call; + if (onCreateCall == null) { + final argumentString = methodArgument.isEmpty && isAsynchronous + ? '' + : '(${methodArgument.join(', ')})'; + call = '${tryStatement}api.${components.name}$argumentString'; + } else { + call = onCreateCall(methodArgument, apiVarName: 'api'); + } + + _writeApiInvocation( + indent, + isAsynchronous: isAsynchronous, + call: call, + returnType: returnType, + ); + }, + ); + } + + void _writeChannelAllocation( + Indent indent, { + required String varChannelName, + required String baseArgs, + required String? serialBackgroundQueue, + }) { final channelCreationWithoutTaskQueue = 'FlutterBasicMessageChannel($baseArgs)'; if (serialBackgroundQueue == null) { @@ -1943,98 +2003,152 @@ func $deepHashName(value: Any?, hasher: inout Hasher) { indent.writeln(': $channelCreationWithTaskQueue'); }); } + } + void _writeMessageHandlerRegistration( + Indent indent, { + required String varChannelName, + required String setHandlerCondition, + required String messageVarName, + required void Function() body, + }) { indent.write('if $setHandlerCondition '); indent.addScoped('{', '}', () { indent.write('$varChannelName.setMessageHandler '); - final messageVarName = parameters.isNotEmpty ? 'message' : '_'; indent.addScoped('{ $messageVarName, reply in', '}', () { - final methodArgument = []; - if (components.arguments.isNotEmpty) { - indent.writeln('let args = message as! [Any?]'); - enumerate(components.arguments, ( - int index, - _SwiftFunctionArgument arg, - ) { - final String argName = _getSafeArgumentName(index, arg.namedType); - final argIndex = 'args[$index]'; - final String fieldType = _swiftTypeForDartType(arg.type); - // There is a swift bug with unwrapping maps of nullable Enums; - final enumMapForceUnwrap = - arg.type.baseName == 'Map' && - arg.type.typeArguments.any( - (TypeDeclaration type) => type.isEnum, - ) - ? '!' - : ''; - - _writeGenericCasting( - indent: indent, - value: argIndex, - variableName: argName, - fieldType: fieldType, - type: arg.type, - ); + body(); + }); + }, addTrailingNewline: false); + indent.addScoped(' else {', '}', () { + indent.writeln('$varChannelName.setMessageHandler(nil)'); + }); + } - if (arg.label == '_') { - methodArgument.add('$argName$enumMapForceUnwrap'); - } else { - methodArgument.add( - '${arg.label ?? arg.name}: $argName$enumMapForceUnwrap', - ); - } - }); - } - final tryStatement = isAsynchronous ? '' : 'try '; - late final String call; - if (onCreateCall == null) { - // Empty parens are not required when calling a method whose only - // argument is a trailing closure. - final argumentString = methodArgument.isEmpty && isAsynchronous - ? '' - : '(${methodArgument.join(', ')})'; - call = '${tryStatement}api.${components.name}$argumentString'; + void _writeArgumentUnpacking( + Indent indent, { + required Iterable parameters, + required List<_SwiftFunctionArgument> arguments, + required List methodArgument, + }) { + if (arguments.isNotEmpty) { + indent.writeln('let args = message as! [Any?]'); + enumerate(arguments, (int index, _SwiftFunctionArgument arg) { + final String argName = _getSafeArgumentName(index, arg.namedType); + final argIndex = 'args[$index]'; + final String fieldType = _swiftTypeForDartType(arg.type); + final enumMapForceUnwrap = + arg.type.baseName == 'Map' && + arg.type.typeArguments.any( + (TypeDeclaration type) => type.isEnum, + ) + ? '!' + : ''; + + _writeGenericCasting( + indent: indent, + value: argIndex, + variableName: argName, + fieldType: fieldType, + type: arg.type, + ); + + if (arg.label == '_') { + methodArgument.add('$argName$enumMapForceUnwrap'); } else { - call = onCreateCall(methodArgument, apiVarName: 'api'); + methodArgument.add( + '${arg.label ?? arg.name}: $argName$enumMapForceUnwrap', + ); } - if (isAsynchronous) { - final resultName = returnType.isVoid ? 'nil' : 'res'; - final successVariableInit = returnType.isVoid ? '' : '(let res)'; - indent.write('$call '); - - indent.addScoped('{ result in', '}', () { - indent.write('switch result '); - indent.addScoped('{', '}', nestCount: 0, () { - indent.writeln('case .success$successVariableInit:'); - indent.nest(1, () { - indent.writeln('reply(wrapResponse($resultName, nil))'); - }); - indent.writeln('case .failure(let error):'); - indent.nest(1, () { - indent.writeln('reply(wrapResponse(nil, error))'); - }); - }); + }); + } + } + + void _writeApiInvocation( + Indent indent, { + required bool isAsynchronous, + required String call, + required TypeDeclaration returnType, + }) { + if (isAsynchronous) { + final resultName = returnType.isVoid ? 'nil' : 'res'; + final successVariableInit = returnType.isVoid ? '' : '(let res)'; + indent.write('$call '); + + indent.addScoped('{ result in', '}', () { + indent.write('switch result '); + indent.addScoped('{', '}', nestCount: 0, () { + indent.writeln('case .success$successVariableInit:'); + indent.nest(1, () { + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + resultName: resultName, + errorName: null, + ), + ); }); - } else { - indent.write('do '); - indent.addScoped('{', '}', () { - if (returnType.isVoid) { - indent.writeln(call); - indent.writeln('reply(wrapResponse(nil, nil))'); - } else { - indent.writeln('let result = $call'); - indent.writeln('reply(wrapResponse(result, nil))'); - } - }, addTrailingNewline: false); - indent.addScoped(' catch {', '}', () { - indent.writeln('reply(wrapResponse(nil, error))'); + indent.writeln('case .failure(let error):'); + indent.nest(1, () { + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + resultName: null, + errorName: 'error', + ), + ); }); + }); + }); + } else { + indent.write('do '); + indent.addScoped('{', '}', () { + if (returnType.isVoid) { + indent.writeln(call); + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + resultName: null, + errorName: null, + ), + ); + } else { + indent.writeln('let result = $call'); + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + resultName: 'result', + errorName: null, + ), + ); } + }, addTrailingNewline: false); + indent.addScoped(' catch {', '}', () { + _writeReplying( + indent, + response: _writeResultWrapping( + indent, + resultName: null, + errorName: 'error', + ), + ); }); - }, addTrailingNewline: false); - indent.addScoped(' else {', '}', () { - indent.writeln('$varChannelName.setMessageHandler(nil)'); - }); + } + } + + String _writeResultWrapping( + Indent indent, { + required String? resultName, + required String? errorName, + }) { + return 'wrapResponse(${resultName ?? 'nil'}, ${errorName ?? 'nil'})'; + } + + void _writeReplying(Indent indent, {required String response}) { + indent.writeln('reply($response)'); } void _writeProxyApiRegistrar( 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 91021f5b22f3..c4aa6548b76f 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 @@ -5277,7 +5277,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.noopAsync(resultCallback); }); } else { @@ -5306,7 +5305,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncInt(anIntArg, resultCallback); }); } else { @@ -5335,7 +5333,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncDouble(aDoubleArg, resultCallback); }); } else { @@ -5364,7 +5361,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncBool(aBoolArg, resultCallback); }); } else { @@ -5393,7 +5389,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncString(aStringArg, resultCallback); }); } else { @@ -5422,7 +5417,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncUint8List(aUint8ListArg, resultCallback); }); } else { @@ -5451,7 +5445,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncObject(anObjectArg, resultCallback); }); } else { @@ -5480,7 +5473,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncList(listArg, resultCallback); }); } else { @@ -5509,7 +5501,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncEnumList(enumListArg, resultCallback); }); } else { @@ -5538,7 +5529,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncClassList(classListArg, resultCallback); }); } else { @@ -5567,7 +5557,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncMap(mapArg, resultCallback); }); } else { @@ -5596,7 +5585,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncStringMap(stringMapArg, resultCallback); }); } else { @@ -5625,7 +5613,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncIntMap(intMapArg, resultCallback); }); } else { @@ -5654,7 +5641,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncEnumMap(enumMapArg, resultCallback); }); } else { @@ -5683,7 +5669,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncClassMap(classMapArg, resultCallback); }); } else { @@ -5712,7 +5697,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncEnum(anEnumArg, resultCallback); }); } else { @@ -5741,7 +5725,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAnotherAsyncEnum(anotherEnumArg, resultCallback); }); } else { @@ -5768,7 +5751,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.throwAsyncError(resultCallback); }); } else { @@ -5795,7 +5777,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.throwAsyncErrorFromVoid(resultCallback); }); } else { @@ -5822,7 +5803,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.throwAsyncFlutterError(resultCallback); }); } else { @@ -5851,7 +5831,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncAllTypes(everythingArg, resultCallback); }); } else { @@ -5880,7 +5859,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableAllNullableTypes(everythingArg, resultCallback); }); } else { @@ -5910,7 +5888,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableAllNullableTypesWithoutRecursion( everythingArg, resultCallback); }); @@ -5940,7 +5917,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableInt(anIntArg, resultCallback); }); } else { @@ -5969,7 +5945,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableDouble(aDoubleArg, resultCallback); }); } else { @@ -5998,7 +5973,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableBool(aBoolArg, resultCallback); }); } else { @@ -6027,7 +6001,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableString(aStringArg, resultCallback); }); } else { @@ -6056,7 +6029,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableUint8List(aUint8ListArg, resultCallback); }); } else { @@ -6085,7 +6057,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableObject(anObjectArg, resultCallback); }); } else { @@ -6114,7 +6085,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableList(listArg, resultCallback); }); } else { @@ -6143,7 +6113,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableEnumList(enumListArg, resultCallback); }); } else { @@ -6172,7 +6141,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableClassList(classListArg, resultCallback); }); } else { @@ -6201,7 +6169,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableMap(mapArg, resultCallback); }); } else { @@ -6230,7 +6197,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableStringMap(stringMapArg, resultCallback); }); } else { @@ -6259,7 +6225,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableIntMap(intMapArg, resultCallback); }); } else { @@ -6288,7 +6253,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableEnumMap(enumMapArg, resultCallback); }); } else { @@ -6317,7 +6281,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableClassMap(classMapArg, resultCallback); }); } else { @@ -6346,7 +6309,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAsyncNullableEnum(anEnumArg, resultCallback); }); } else { @@ -6375,7 +6337,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echoAnotherAsyncNullableEnum(anotherEnumArg, resultCallback); }); } else { @@ -6445,7 +6406,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterNoop(resultCallback); }); } else { @@ -6472,7 +6432,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterThrowError(resultCallback); }); } else { @@ -6499,7 +6458,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterThrowErrorFromVoid(resultCallback); }); } else { @@ -6528,7 +6486,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoAllTypes(everythingArg, resultCallback); }); } else { @@ -6557,7 +6514,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoAllNullableTypes(everythingArg, resultCallback); }); } else { @@ -6588,7 +6544,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterSendMultipleNullableTypes( aNullableBoolArg, aNullableIntArg, aNullableStringArg, resultCallback); }); @@ -6619,7 +6574,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoAllNullableTypesWithoutRecursion(everythingArg, resultCallback); }); } else { @@ -6650,7 +6604,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterSendMultipleNullableTypesWithoutRecursion( aNullableBoolArg, aNullableIntArg, aNullableStringArg, resultCallback); }); @@ -6680,7 +6633,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoBool(aBoolArg, resultCallback); }); } else { @@ -6709,7 +6661,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoInt(anIntArg, resultCallback); }); } else { @@ -6738,7 +6689,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoDouble(aDoubleArg, resultCallback); }); } else { @@ -6767,7 +6717,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoString(aStringArg, resultCallback); }); } else { @@ -6796,7 +6745,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoUint8List(listArg, resultCallback); }); } else { @@ -6825,7 +6773,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoList(listArg, resultCallback); }); } else { @@ -6854,7 +6801,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoEnumList(enumListArg, resultCallback); }); } else { @@ -6883,7 +6829,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoClassList(classListArg, resultCallback); }); } else { @@ -6912,7 +6857,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNonNullEnumList(enumListArg, resultCallback); }); } else { @@ -6941,7 +6885,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNonNullClassList(classListArg, resultCallback); }); } else { @@ -6970,7 +6913,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoMap(mapArg, resultCallback); }); } else { @@ -6999,7 +6941,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoStringMap(stringMapArg, resultCallback); }); } else { @@ -7028,7 +6969,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoIntMap(intMapArg, resultCallback); }); } else { @@ -7057,7 +6997,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoEnumMap(enumMapArg, resultCallback); }); } else { @@ -7086,7 +7025,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoClassMap(classMapArg, resultCallback); }); } else { @@ -7115,7 +7053,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNonNullStringMap(stringMapArg, resultCallback); }); } else { @@ -7144,7 +7081,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNonNullIntMap(intMapArg, resultCallback); }); } else { @@ -7173,7 +7109,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNonNullEnumMap(enumMapArg, resultCallback); }); } else { @@ -7202,7 +7137,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNonNullClassMap(classMapArg, resultCallback); }); } else { @@ -7231,7 +7165,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoEnum(anEnumArg, resultCallback); }); } else { @@ -7260,7 +7193,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoAnotherEnum(anotherEnumArg, resultCallback); }); } else { @@ -7289,7 +7221,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableBool(aBoolArg, resultCallback); }); } else { @@ -7318,7 +7249,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableInt(anIntArg, resultCallback); }); } else { @@ -7347,7 +7277,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableDouble(aDoubleArg, resultCallback); }); } else { @@ -7376,7 +7305,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableString(aStringArg, resultCallback); }); } else { @@ -7405,7 +7333,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableUint8List(listArg, resultCallback); }); } else { @@ -7434,7 +7361,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableList(listArg, resultCallback); }); } else { @@ -7463,7 +7389,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableEnumList(enumListArg, resultCallback); }); } else { @@ -7492,7 +7417,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableClassList(classListArg, resultCallback); }); } else { @@ -7521,7 +7445,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableNonNullEnumList(enumListArg, resultCallback); }); } else { @@ -7550,7 +7473,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableNonNullClassList(classListArg, resultCallback); }); } else { @@ -7579,7 +7501,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableMap(mapArg, resultCallback); }); } else { @@ -7608,7 +7529,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableStringMap(stringMapArg, resultCallback); }); } else { @@ -7637,7 +7557,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableIntMap(intMapArg, resultCallback); }); } else { @@ -7666,7 +7585,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableEnumMap(enumMapArg, resultCallback); }); } else { @@ -7695,7 +7613,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableClassMap(classMapArg, resultCallback); }); } else { @@ -7724,7 +7641,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableNonNullStringMap(stringMapArg, resultCallback); }); } else { @@ -7753,7 +7669,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableNonNullIntMap(intMapArg, resultCallback); }); } else { @@ -7782,7 +7697,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableNonNullEnumMap(enumMapArg, resultCallback); }); } else { @@ -7811,7 +7725,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableNonNullClassMap(classMapArg, resultCallback); }); } else { @@ -7840,7 +7753,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoNullableEnum(anEnumArg, resultCallback); }); } else { @@ -7869,7 +7781,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterEchoAnotherNullableEnum(anotherEnumArg, resultCallback); }); } else { @@ -7898,7 +7809,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.callFlutterSmallApiEchoString(aStringArg, resultCallback); }); } else { @@ -9594,7 +9504,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.echo(aStringArg, resultCallback); }); } else { @@ -9621,7 +9530,6 @@ public void error(Throwable error) { reply.reply(wrapResponse(null, error)); } }; - api.voidVoid(resultCallback); }); } else {