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/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..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 @@ -185,6 +185,38 @@ static int pigeonDeepHashCode(Object value) { return value.hashCode(); } + @NonNull + 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 { + response.add(result); + } + return response; + } + + @NonNull + protected static FlutterError createConnectionError(@NonNull String channelName) { + return new FlutterError( + "channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); + } + + @Target(METHOD) + @Retention(CLASS) + @interface CanIgnoreReturnValue {} + /** Error class for passing custom error details to Flutter via a thrown PlatformException. */ public static class FlutterError extends RuntimeException { @@ -201,33 +233,6 @@ public FlutterError(@NonNull String code, @Nullable String message, @Nullable Ob } } - @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); - } else { - errorList.add(exception.toString()); - errorList.add(exception.getClass().getSimpleName()); - errorList.add( - "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); - } - return errorList; - } - - @NonNull - protected static FlutterError createConnectionError(@NonNull String channelName) { - return new FlutterError( - "channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); - } - - @Target(METHOD) - @Retention(CLASS) - @interface CanIgnoreReturnValue {} - public enum Code { ONE(0), TWO(1); @@ -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,22 +522,18 @@ 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)); } }; - api.sendMessage(messageArg, resultCallback); }); } else { 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 f8b12f846c22..e6c58f524c4c 100644 --- a/packages/pigeon/example/app/ios/Runner/Messages.g.swift +++ b/packages/pigeon/example/app/ios/Runner/Messages.g.swift @@ -14,48 +14,30 @@ 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] -} - -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 { @@ -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 @@ -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/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/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 ffaf56787d66..cdd59b1263a0 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 ? '' : ','}', ); @@ -276,8 +278,35 @@ class CppHeaderGenerator extends StructuredGenerator { Root root, Indent indent, { required String dartPackageName, + }) {} + + @override + void writeErrorClass( + InternalCppOptions generatorOptions, + Root root, + Indent indent, { + required String dartPackageName, }) { - _writeFlutterError(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_; +};'''); if (root.containsHostApi) { _writeErrorOr( indent, @@ -329,7 +358,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 +883,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,16 +940,43 @@ 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(); } + @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, @@ -1001,6 +1034,13 @@ class CppSourceGenerator extends StructuredGenerator { indent.writeln('using $using;'); } indent.newln(); + writeWrapResponse( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); + indent.newln(); _writeFunctionDefinition( indent, 'CreateConnectionError', @@ -1476,6 +1516,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) { @@ -1516,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();'); @@ -1524,7 +1569,7 @@ EncodableValue $_overflowClassName::FromEncodableList( ); } - void _writeCodecDecode( + void _writeDecodeLogic( Indent indent, EnumeratedType customType, String value, @@ -1589,31 +1634,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, () { + _writeDecodeLogic(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:'); + _writeDecodeLogic( + indent, + _enumeratedOverflow, + 'ReadValue(stream)', + ); + } + indent.writeln('default:'); + indent.nest(1, () { + indent.writeln(readValueCall); + }); + }); + } else { + indent.writeln(readValueCall); } }, ); @@ -1633,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))'; @@ -1660,6 +1707,8 @@ EncodableValue $_overflowClassName::FromEncodableList( indent.writeln('return;'); }); } + + enumeratedTypes.forEach(writeEncodeLogic); }); } indent.writeln('$_standardCodecSerializer::WriteValue(value, stream);'); @@ -1882,103 +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( - 'reply(WrapError("$argName unexpectedly null."));', - ); - 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('reply(WrapError(exception.what()));'); - }); - }); - }); - indent.addScoped(null, '}', () { - indent.writeln('channel.SetMessageHandler(nullptr);'); - }); - }); + _writeHostMethodMessageHandler( + indent, + root, + api, + method, + channelName, + ); } }, ); @@ -2015,6 +1974,162 @@ return EncodableValue(EncodableList{ ); } + void _writeHostMethodMessageHandler( + Indent indent, + Root root, + AstHostApi api, + Method method, + String channelName, + ) { + indent.writeScoped('{', '}', () { + final varChannelName = 'channel'; + _writeChannelAllocation( + indent, + varChannelName: varChannelName, + channelName: channelName, + ); + + final HostDatatype returnType = getHostDatatype( + method.returnType, + _shortBaseCppTypeForBuiltinDartType, + ); + final String returnTypeName = _hostApiReturnType(returnType); + + _writeMessageHandlerRegistration( + indent, + varChannelName: varChannelName, + setHandlerCondition: 'api != nullptr', + messageVarName: 'message', + body: () { + final methodArgument = []; + _writeArgumentUnpacking( + indent, + root: root, + method: method, + methodArgument: methodArgument, + ); + + _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", "$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'); + }); + } + } + + 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( Root root, Indent indent, @@ -2208,55 +2323,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 @@ -2418,33 +2528,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..536d0810953b 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'); @@ -576,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( @@ -1147,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); @@ -1162,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}) {', @@ -1287,7 +1291,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 +1316,7 @@ static $_overflowClassName decode(Object result) { ); } '''); + indent.writeScoped('Object? unwrap() {', '}', () { indent.format(''' if (wrapped == null) { @@ -1315,28 +1324,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;'); }); }); } @@ -1351,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( @@ -1408,33 +1409,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(); } } @@ -1606,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 e0c240b9b794..9ed1c63f3bd0 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( @@ -137,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. @@ -167,6 +199,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..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'; @@ -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..ef644b8bd16f 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. @@ -1272,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( @@ -1692,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;'); @@ -2100,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, + ); }, ); } @@ -2323,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 4b7f792dc1c3..1a21c3f6180f 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); } @@ -1030,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); @@ -1041,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, @@ -1064,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( @@ -1173,6 +1142,7 @@ if (wrapped == null) { /// static void setUp(BinaryMessenger binaryMessenger, Foo api) {...} /// } @override + @override void writeHostApi( InternalJavaOptions generatorOptions, Root root, @@ -1180,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.', ]; @@ -1195,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( - '${_docCommentPrefix}Sets up an instance of `${api.name}` to handle messages through the `binaryMessenger`.$_docCommentSuffix', - ); - 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, + ); + } }); } @@ -1256,30 +1254,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, @@ -1289,10 +1263,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. @@ -1308,104 +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); - indent.writeln('ArrayList wrapped = new ArrayList<>();'); - 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 = -\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}; -'''); - 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('wrapped.add(0, null);'); - } else { - indent.writeln('$returnType output = $call;'); - indent.writeln('wrapped.add(0, output);'); - } - }); - 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(wrapped);'); - } + 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) { @@ -1458,49 +1534,33 @@ $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) { + @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; }'''); } @@ -1538,11 +1598,14 @@ protected static ArrayList wrapError(@NonNull Throwable exception) { Indent indent, { required String dartPackageName, }) { - indent.newln(); - _writeErrorClass(indent); if (root.containsHostApi) { indent.newln(); - _writeWrapError(indent); + writeWrapResponse( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); } if (root.containsFlutterApi) { indent.newln(); @@ -1553,6 +1616,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, @@ -1572,6 +1668,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 41e6a880f0a2..e75bace3d06c 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())', ); } }); @@ -789,6 +785,7 @@ if (wrapped == null) { /// } /// @override + @override void writeHostApi( InternalKotlinOptions generatorOptions, Root root, @@ -796,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 = [ @@ -820,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, + ); + } }); }); } @@ -1298,61 +1316,43 @@ 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)'); }); }); } - 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, @@ -1540,8 +1540,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); @@ -1550,19 +1554,42 @@ 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()'); } } - 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 +1614,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( @@ -1630,86 +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)}.wrapError(error))', - ); - }, addTrailingNewline: false); - indent.addScoped(' else {', '}', () { - if (returnType.isVoid) { - indent.writeln( - 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResult(null))', - ); - } else { - indent.writeln('val data = result.getOrNull()'); - indent.writeln( - 'reply.reply(${_getUtilsClassName(generatorOptions)}.wrapResult(data))', - ); - } - }); - }); + _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('listOf(null)'); - } else { - indent.writeln('listOf($call)'); - } - }, addTrailingNewline: false); - indent.add(' catch (exception: Throwable) '); - indent.addScoped('{', '}', () { - indent.writeln( - '${_getUtilsClassName(generatorOptions)}.wrapError(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( @@ -2103,7 +2252,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 af0ad6d1ea2a..66993fce4c80 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);', ); @@ -383,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'); @@ -461,7 +460,7 @@ class ObjcHeaderGenerator extends StructuredGenerator { generatorComments: generatorComments, ); - final String signature = _makeObjcSignature( + final String signature = _getMethodSignature( func: func, options: generatorOptions, returnType: returnType, @@ -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}:'); - _writeCodecDecode( + final int caseIndex = i - totalCustomCodecKeysAllowed; + final EnumeratedType type = types[i]; + indent.write('case $caseIndex:'); + _writeDecodeLogic( indent, - types[i], + type, generatorOptions.prefix ?? '', isOverflowClass: true, ); @@ -826,7 +836,7 @@ if (self.wrapped == nil) { indent.writeln('@end'); } - void _writeCodecDecode( + void _writeDecodeLogic( Indent indent, EnumeratedType customType, String? prefix, { @@ -902,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 ?? '', @@ -911,7 +921,7 @@ if (self.wrapped == nil) { } if (root.requiresOverflowClass) { indent.write('case $maximumCodecFieldKey: '); - _writeCodecDecode( + _writeDecodeLogic( indent, _enumeratedOverflow, generatorOptions.prefix, @@ -931,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])'; @@ -967,6 +977,8 @@ if (self.wrapped == nil) { addTrailingNewline: false, ); } + + enumeratedTypes.forEach(writeEncodeLogic); indent.addScoped('{', '}', () { indent.writeln('[super writeValue:value];'); }); @@ -1124,7 +1136,12 @@ if (self.wrapped == nil) { required String dartPackageName, }) { if (root.containsHostApi) { - _writeWrapError(indent); + writeWrapResponse( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); indent.newln(); } if (root.containsFlutterApi) { @@ -1146,15 +1163,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] ]; }'''); } @@ -1181,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( @@ -1379,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, @@ -1481,7 +1569,7 @@ void _writeMethod( '@[${func.parameters.map(makeVarOrNSNullExpression).join(', ')}]'; } indent.write( - _makeObjcSignature( + _getMethodSignature( func: func, options: languageOptions, returnType: 'void', @@ -1953,7 +2041,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, @@ -2123,7 +2211,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..477f65816cd6 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'); }); }); } @@ -293,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, @@ -344,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)'); }); @@ -466,6 +466,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 +484,7 @@ class SwiftGenerator extends StructuredGenerator { name: _overflowClassName, fields: overflowFields, ); - indent.newln(); + _writeDataClassSignature( indent, overflowClass, @@ -515,25 +520,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'); @@ -882,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 = [ @@ -914,10 +927,19 @@ 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( - '$_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 +947,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 = "") ', @@ -939,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?() @@ -1439,43 +1457,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]'); }); }); } @@ -1634,13 +1657,13 @@ 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); + writeWrapResponse( + generatorOptions, + root, + indent, + dartPackageName: dartPackageName, + ); } if (root.containsFlutterApi || root.containsProxyApi) { _writeCreateConnectionError(generatorOptions, indent); @@ -1653,6 +1676,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, @@ -1873,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) { @@ -1894,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(wrapResult($resultName))'); - }); - indent.writeln('case .failure(let error):'); - indent.nest(1, () { - indent.writeln('reply(wrapError(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(wrapResult(nil))'); - } else { - indent.writeln('let result = $call'); - indent.writeln('reply(wrapResult(result))'); - } - }, addTrailingNewline: false); - indent.addScoped(' catch {', '}', () { - indent.writeln('reply(wrapError(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( @@ -2421,10 +2584,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) @@ -2815,40 +2978,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 +3131,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..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 @@ -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,61 @@ 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 @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/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..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 @@ -188,6 +188,38 @@ static int pigeonDeepHashCode(Object value) { return value.hashCode(); } + @NonNull + 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 { + response.add(result); + } + return response; + } + + @NonNull + protected static FlutterError createConnectionError(@NonNull String channelName) { + return new FlutterError( + "channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); + } + + @Target(METHOD) + @Retention(CLASS) + @interface CanIgnoreReturnValue {} + /** Error class for passing custom error details to Flutter via a thrown PlatformException. */ public static class FlutterError extends RuntimeException { @@ -204,33 +236,6 @@ public FlutterError(@NonNull String code, @Nullable String message, @Nullable Ob } } - @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); - } else { - errorList.add(exception.toString()); - errorList.add(exception.getClass().getSimpleName()); - errorList.add( - "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); - } - return errorList; - } - - @NonNull - protected static FlutterError createConnectionError(@NonNull String channelName) { - return new FlutterError( - "channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); - } - - @Target(METHOD) - @Retention(CLASS) - @interface CanIgnoreReturnValue {} - public enum AnEnum { ONE(0), TWO(1), @@ -255,6 +260,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 +2887,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 +3115,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 +3146,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 +3285,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); @@ -3541,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); @@ -3564,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); @@ -3589,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); @@ -3612,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); @@ -3635,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); @@ -3658,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); @@ -3683,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); @@ -3708,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); @@ -3733,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); @@ -3758,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); @@ -3783,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); @@ -3808,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); @@ -3833,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); @@ -3858,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); @@ -3883,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); @@ -3908,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); @@ -3933,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); @@ -3958,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); @@ -3983,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); @@ -4008,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); @@ -4033,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); @@ -4058,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); @@ -4083,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); @@ -4108,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); @@ -4133,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); @@ -4158,16 +4289,83 @@ 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) { + reply.reply(wrapResponse(null, exception)); + } + }); + } else { + 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 args = (ArrayList) message; + AcronymsAndTestCase acronymsArg = (AcronymsAndTestCase) args.get(0); + try { + AcronymsAndTestCase output = api.echoAcronyms(acronymsArg); + reply.reply(wrapResponse(output, null)); + } catch (Throwable exception) { + reply.reply(wrapResponse(null, exception)); + } + }); + } 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 args = (ArrayList) message; + AcronymsAndTestCase acronymsArg = (AcronymsAndTestCase) args.get(0); + try { + AcronymsAndTestCase output = api.hostHTTPResponse(acronymsArg); + reply.reply(wrapResponse(output, null)); } catch (Throwable exception) { - wrapped = wrapError(exception); + reply.reply(wrapResponse(null, exception)); + } + }); + } 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 args = (ArrayList) message; + AcronymsAndTestCase acronymsArg = (AcronymsAndTestCase) args.get(0); + try { + AcronymsAndTestCase output = api.sendJSONParser(acronymsArg); + reply.reply(wrapResponse(output, null)); + } catch (Throwable exception) { + reply.reply(wrapResponse(null, exception)); } - reply.reply(wrapped); }); } else { channel.setMessageHandler(null); @@ -4183,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); @@ -4208,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); @@ -4233,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); @@ -4258,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); @@ -4283,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); @@ -4308,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); @@ -4334,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); @@ -4359,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); @@ -4385,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); @@ -4410,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); @@ -4437,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); @@ -4462,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); @@ -4487,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); @@ -4496,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); @@ -4516,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); @@ -4525,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); @@ -4545,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); @@ -4570,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); @@ -4595,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); @@ -4620,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); @@ -4645,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); @@ -4670,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); @@ -4695,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); @@ -4720,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); @@ -4745,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); @@ -4770,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); @@ -4795,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); @@ -4820,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); @@ -4845,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); @@ -4870,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); @@ -4895,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); @@ -4920,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); @@ -4945,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); @@ -4970,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); @@ -4995,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); @@ -5020,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); @@ -5045,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); @@ -5070,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); @@ -5095,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); @@ -5120,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); @@ -5145,20 +5267,16 @@ 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)); } }; - api.noopAsync(resultCallback); }); } else { @@ -5175,22 +5293,18 @@ 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)); } }; - api.echoAsyncInt(anIntArg, resultCallback); }); } else { @@ -5207,22 +5321,18 @@ 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)); } }; - api.echoAsyncDouble(aDoubleArg, resultCallback); }); } else { @@ -5239,22 +5349,18 @@ 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)); } }; - api.echoAsyncBool(aBoolArg, resultCallback); }); } else { @@ -5271,22 +5377,18 @@ 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)); } }; - api.echoAsyncString(aStringArg, resultCallback); }); } else { @@ -5303,22 +5405,18 @@ 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)); } }; - api.echoAsyncUint8List(aUint8ListArg, resultCallback); }); } else { @@ -5335,22 +5433,18 @@ 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)); } }; - api.echoAsyncObject(anObjectArg, resultCallback); }); } else { @@ -5367,22 +5461,18 @@ 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)); } }; - api.echoAsyncList(listArg, resultCallback); }); } else { @@ -5399,22 +5489,18 @@ 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)); } }; - api.echoAsyncEnumList(enumListArg, resultCallback); }); } else { @@ -5431,22 +5517,18 @@ 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)); } }; - api.echoAsyncClassList(classListArg, resultCallback); }); } else { @@ -5463,22 +5545,18 @@ 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)); } }; - api.echoAsyncMap(mapArg, resultCallback); }); } else { @@ -5495,22 +5573,18 @@ 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)); } }; - api.echoAsyncStringMap(stringMapArg, resultCallback); }); } else { @@ -5527,22 +5601,18 @@ 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)); } }; - api.echoAsyncIntMap(intMapArg, resultCallback); }); } else { @@ -5559,22 +5629,18 @@ 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)); } }; - api.echoAsyncEnumMap(enumMapArg, resultCallback); }); } else { @@ -5591,22 +5657,18 @@ 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)); } }; - api.echoAsyncClassMap(classMapArg, resultCallback); }); } else { @@ -5623,22 +5685,18 @@ 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)); } }; - api.echoAsyncEnum(anEnumArg, resultCallback); }); } else { @@ -5655,22 +5713,18 @@ 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)); } }; - api.echoAnotherAsyncEnum(anotherEnumArg, resultCallback); }); } else { @@ -5687,20 +5741,16 @@ 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)); } }; - api.throwAsyncError(resultCallback); }); } else { @@ -5717,20 +5767,16 @@ 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)); } }; - api.throwAsyncErrorFromVoid(resultCallback); }); } else { @@ -5747,20 +5793,16 @@ 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)); } }; - api.throwAsyncFlutterError(resultCallback); }); } else { @@ -5777,22 +5819,18 @@ 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)); } }; - api.echoAsyncAllTypes(everythingArg, resultCallback); }); } else { @@ -5809,22 +5847,18 @@ 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)); } }; - api.echoAsyncNullableAllNullableTypes(everythingArg, resultCallback); }); } else { @@ -5841,23 +5875,19 @@ 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)); } }; - api.echoAsyncNullableAllNullableTypesWithoutRecursion( everythingArg, resultCallback); }); @@ -5875,22 +5905,18 @@ 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)); } }; - api.echoAsyncNullableInt(anIntArg, resultCallback); }); } else { @@ -5907,22 +5933,18 @@ 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)); } }; - api.echoAsyncNullableDouble(aDoubleArg, resultCallback); }); } else { @@ -5939,22 +5961,18 @@ 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)); } }; - api.echoAsyncNullableBool(aBoolArg, resultCallback); }); } else { @@ -5971,22 +5989,18 @@ 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)); } }; - api.echoAsyncNullableString(aStringArg, resultCallback); }); } else { @@ -6003,22 +6017,18 @@ 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)); } }; - api.echoAsyncNullableUint8List(aUint8ListArg, resultCallback); }); } else { @@ -6035,22 +6045,18 @@ 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)); } }; - api.echoAsyncNullableObject(anObjectArg, resultCallback); }); } else { @@ -6067,22 +6073,18 @@ 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)); } }; - api.echoAsyncNullableList(listArg, resultCallback); }); } else { @@ -6099,22 +6101,18 @@ 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)); } }; - api.echoAsyncNullableEnumList(enumListArg, resultCallback); }); } else { @@ -6131,22 +6129,18 @@ 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)); } }; - api.echoAsyncNullableClassList(classListArg, resultCallback); }); } else { @@ -6163,22 +6157,18 @@ 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)); } }; - api.echoAsyncNullableMap(mapArg, resultCallback); }); } else { @@ -6195,22 +6185,18 @@ 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)); } }; - api.echoAsyncNullableStringMap(stringMapArg, resultCallback); }); } else { @@ -6227,22 +6213,18 @@ 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)); } }; - api.echoAsyncNullableIntMap(intMapArg, resultCallback); }); } else { @@ -6259,22 +6241,18 @@ 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)); } }; - api.echoAsyncNullableEnumMap(enumMapArg, resultCallback); }); } else { @@ -6291,22 +6269,18 @@ 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)); } }; - api.echoAsyncNullableClassMap(classMapArg, resultCallback); }); } else { @@ -6323,22 +6297,18 @@ 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)); } }; - api.echoAsyncNullableEnum(anEnumArg, resultCallback); }); } else { @@ -6355,22 +6325,18 @@ 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)); } }; - api.echoAnotherAsyncNullableEnum(anotherEnumArg, resultCallback); }); } else { @@ -6387,14 +6353,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); @@ -6411,14 +6375,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); @@ -6434,20 +6396,16 @@ 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)); } }; - api.callFlutterNoop(resultCallback); }); } else { @@ -6464,20 +6422,16 @@ 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)); } }; - api.callFlutterThrowError(resultCallback); }); } else { @@ -6494,20 +6448,16 @@ 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)); } }; - api.callFlutterThrowErrorFromVoid(resultCallback); }); } else { @@ -6524,22 +6474,18 @@ 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)); } }; - api.callFlutterEchoAllTypes(everythingArg, resultCallback); }); } else { @@ -6556,22 +6502,18 @@ 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)); } }; - api.callFlutterEchoAllNullableTypes(everythingArg, resultCallback); }); } else { @@ -6588,7 +6530,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); @@ -6596,16 +6537,13 @@ 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)); } }; - api.callFlutterSendMultipleNullableTypes( aNullableBoolArg, aNullableIntArg, aNullableStringArg, resultCallback); }); @@ -6623,23 +6561,19 @@ 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)); } }; - api.callFlutterEchoAllNullableTypesWithoutRecursion(everythingArg, resultCallback); }); } else { @@ -6656,7 +6590,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); @@ -6664,16 +6597,13 @@ 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)); } }; - api.callFlutterSendMultipleNullableTypesWithoutRecursion( aNullableBoolArg, aNullableIntArg, aNullableStringArg, resultCallback); }); @@ -6691,22 +6621,18 @@ 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)); } }; - api.callFlutterEchoBool(aBoolArg, resultCallback); }); } else { @@ -6723,22 +6649,18 @@ 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)); } }; - api.callFlutterEchoInt(anIntArg, resultCallback); }); } else { @@ -6755,22 +6677,18 @@ 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)); } }; - api.callFlutterEchoDouble(aDoubleArg, resultCallback); }); } else { @@ -6787,22 +6705,18 @@ 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)); } }; - api.callFlutterEchoString(aStringArg, resultCallback); }); } else { @@ -6819,22 +6733,18 @@ 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)); } }; - api.callFlutterEchoUint8List(listArg, resultCallback); }); } else { @@ -6851,22 +6761,18 @@ 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)); } }; - api.callFlutterEchoList(listArg, resultCallback); }); } else { @@ -6883,22 +6789,18 @@ 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)); } }; - api.callFlutterEchoEnumList(enumListArg, resultCallback); }); } else { @@ -6915,22 +6817,18 @@ 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)); } }; - api.callFlutterEchoClassList(classListArg, resultCallback); }); } else { @@ -6947,22 +6845,18 @@ 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)); } }; - api.callFlutterEchoNonNullEnumList(enumListArg, resultCallback); }); } else { @@ -6979,22 +6873,18 @@ 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)); } }; - api.callFlutterEchoNonNullClassList(classListArg, resultCallback); }); } else { @@ -7011,22 +6901,18 @@ 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)); } }; - api.callFlutterEchoMap(mapArg, resultCallback); }); } else { @@ -7043,22 +6929,18 @@ 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)); } }; - api.callFlutterEchoStringMap(stringMapArg, resultCallback); }); } else { @@ -7075,22 +6957,18 @@ 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)); } }; - api.callFlutterEchoIntMap(intMapArg, resultCallback); }); } else { @@ -7107,22 +6985,18 @@ 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)); } }; - api.callFlutterEchoEnumMap(enumMapArg, resultCallback); }); } else { @@ -7139,22 +7013,18 @@ 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)); } }; - api.callFlutterEchoClassMap(classMapArg, resultCallback); }); } else { @@ -7171,22 +7041,18 @@ 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)); } }; - api.callFlutterEchoNonNullStringMap(stringMapArg, resultCallback); }); } else { @@ -7203,22 +7069,18 @@ 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)); } }; - api.callFlutterEchoNonNullIntMap(intMapArg, resultCallback); }); } else { @@ -7235,22 +7097,18 @@ 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)); } }; - api.callFlutterEchoNonNullEnumMap(enumMapArg, resultCallback); }); } else { @@ -7267,22 +7125,18 @@ 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)); } }; - api.callFlutterEchoNonNullClassMap(classMapArg, resultCallback); }); } else { @@ -7299,22 +7153,18 @@ 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)); } }; - api.callFlutterEchoEnum(anEnumArg, resultCallback); }); } else { @@ -7331,22 +7181,18 @@ 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)); } }; - api.callFlutterEchoAnotherEnum(anotherEnumArg, resultCallback); }); } else { @@ -7363,22 +7209,18 @@ 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)); } }; - api.callFlutterEchoNullableBool(aBoolArg, resultCallback); }); } else { @@ -7395,22 +7237,18 @@ 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)); } }; - api.callFlutterEchoNullableInt(anIntArg, resultCallback); }); } else { @@ -7427,22 +7265,18 @@ 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)); } }; - api.callFlutterEchoNullableDouble(aDoubleArg, resultCallback); }); } else { @@ -7459,22 +7293,18 @@ 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)); } }; - api.callFlutterEchoNullableString(aStringArg, resultCallback); }); } else { @@ -7491,22 +7321,18 @@ 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)); } }; - api.callFlutterEchoNullableUint8List(listArg, resultCallback); }); } else { @@ -7523,22 +7349,18 @@ 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)); } }; - api.callFlutterEchoNullableList(listArg, resultCallback); }); } else { @@ -7555,22 +7377,18 @@ 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)); } }; - api.callFlutterEchoNullableEnumList(enumListArg, resultCallback); }); } else { @@ -7587,22 +7405,18 @@ 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)); } }; - api.callFlutterEchoNullableClassList(classListArg, resultCallback); }); } else { @@ -7619,22 +7433,18 @@ 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)); } }; - api.callFlutterEchoNullableNonNullEnumList(enumListArg, resultCallback); }); } else { @@ -7651,22 +7461,18 @@ 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)); } }; - api.callFlutterEchoNullableNonNullClassList(classListArg, resultCallback); }); } else { @@ -7683,22 +7489,18 @@ 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)); } }; - api.callFlutterEchoNullableMap(mapArg, resultCallback); }); } else { @@ -7715,22 +7517,18 @@ 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)); } }; - api.callFlutterEchoNullableStringMap(stringMapArg, resultCallback); }); } else { @@ -7747,22 +7545,18 @@ 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)); } }; - api.callFlutterEchoNullableIntMap(intMapArg, resultCallback); }); } else { @@ -7779,22 +7573,18 @@ 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)); } }; - api.callFlutterEchoNullableEnumMap(enumMapArg, resultCallback); }); } else { @@ -7811,22 +7601,18 @@ 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)); } }; - api.callFlutterEchoNullableClassMap(classMapArg, resultCallback); }); } else { @@ -7843,22 +7629,18 @@ 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)); } }; - api.callFlutterEchoNullableNonNullStringMap(stringMapArg, resultCallback); }); } else { @@ -7875,22 +7657,18 @@ 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)); } }; - api.callFlutterEchoNullableNonNullIntMap(intMapArg, resultCallback); }); } else { @@ -7907,22 +7685,18 @@ 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)); } }; - api.callFlutterEchoNullableNonNullEnumMap(enumMapArg, resultCallback); }); } else { @@ -7939,22 +7713,18 @@ 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)); } }; - api.callFlutterEchoNullableNonNullClassMap(classMapArg, resultCallback); }); } else { @@ -7971,22 +7741,18 @@ 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)); } }; - api.callFlutterEchoNullableEnum(anEnumArg, resultCallback); }); } else { @@ -8003,22 +7769,18 @@ 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)); } }; - api.callFlutterEchoAnotherNullableEnum(anotherEnumArg, resultCallback); }); } else { @@ -8035,22 +7797,18 @@ 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)); } }; - api.callFlutterSmallApiEchoString(aStringArg, resultCallback); }); } else { @@ -9686,14 +9444,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); @@ -9736,22 +9492,18 @@ 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)); } }; - api.echo(aStringArg, resultCallback); }); } else { @@ -9768,20 +9520,16 @@ 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)); } }; - api.voidVoid(resultCallback); }); } else { 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..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 @@ -398,6 +398,57 @@ - (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]; +} + +- (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/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..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) } } @@ -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. */ @@ -1570,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) } @@ -1592,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) } @@ -1612,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) } @@ -1633,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) } @@ -1653,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) } @@ -1675,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) } @@ -1697,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) } @@ -1719,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) } @@ -1741,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) } @@ -1763,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) } @@ -1785,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) } @@ -1807,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) } @@ -1829,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) } @@ -1851,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) } @@ -1873,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) } @@ -1895,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) } @@ -1917,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) } @@ -1939,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) } @@ -1961,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) } @@ -1983,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) } @@ -2005,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) } @@ -2027,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) } @@ -2049,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) } @@ -2071,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) } @@ -2093,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) } @@ -2115,9 +2196,75 @@ 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.wrapResponse(null, exception) + } + reply.reply(wrapped) + } + } else { + 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 { + CoreTestsPigeonUtils.wrapResponse(api.echoAcronyms(acronymsArg), null) + } catch (exception: Throwable) { + CoreTestsPigeonUtils.wrapResponse(null, 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 { + CoreTestsPigeonUtils.wrapResponse(api.hostHTTPResponse(acronymsArg), null) + } catch (exception: Throwable) { + CoreTestsPigeonUtils.wrapResponse(null, 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 { + CoreTestsPigeonUtils.wrapResponse(api.sendJSONParser(acronymsArg), null) } catch (exception: Throwable) { - CoreTestsPigeonUtils.wrapError(exception) + CoreTestsPigeonUtils.wrapResponse(null, exception) } reply.reply(wrapped) } @@ -2137,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) } @@ -2159,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) } @@ -2181,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) } @@ -2203,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) } @@ -2225,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) } @@ -2248,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) } @@ -2270,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) } @@ -2292,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) } @@ -2314,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) } @@ -2336,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) } @@ -2358,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) } @@ -2380,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) } @@ -2404,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) } @@ -2430,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) } @@ -2454,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) } @@ -2476,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) } @@ -2498,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) } @@ -2520,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) } @@ -2542,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) } @@ -2564,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) } @@ -2586,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) } @@ -2608,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) } @@ -2630,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) } @@ -2652,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) } @@ -2674,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) } @@ -2696,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) } @@ -2718,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) } @@ -2740,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) } @@ -2762,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) } @@ -2784,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) } @@ -2806,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) } @@ -2828,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) } @@ -2850,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) } @@ -2872,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) } @@ -2894,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) } @@ -2916,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) } @@ -2938,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) } @@ -2960,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) } @@ -2981,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)) } } } @@ -3004,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)) } } } @@ -3028,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)) } } } @@ -3052,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)) } } } @@ -3076,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)) } } } @@ -3100,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)) } } } @@ -3124,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)) } } } @@ -3148,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)) } } } @@ -3172,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)) } } } @@ -3196,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)) } } } @@ -3220,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)) } } } @@ -3244,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)) } } } @@ -3268,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)) } } } @@ -3292,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)) } } } @@ -3316,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)) } } } @@ -3340,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)) } } } @@ -3364,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)) } } } @@ -3386,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)) } } } @@ -3408,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)) } } } @@ -3429,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)) } } } @@ -3453,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)) } } } @@ -3478,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)) } } } @@ -3503,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)) } } } @@ -3527,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)) } } } @@ -3551,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)) } } } @@ -3575,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)) } } } @@ -3599,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)) } } } @@ -3623,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)) } } } @@ -3647,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)) } } } @@ -3671,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)) } } } @@ -3695,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)) } } } @@ -3720,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)) } } } @@ -3744,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)) } } } @@ -3768,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)) } } } @@ -3792,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)) } } } @@ -3816,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)) } } } @@ -3841,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)) } } } @@ -3865,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)) } } } @@ -3889,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)) } } } @@ -3910,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) } @@ -3931,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) } @@ -3952,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)) } } } @@ -3973,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)) } } } @@ -3995,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)) } } } @@ -4018,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)) } } } @@ -4043,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)) } } } @@ -4071,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)) } } } @@ -4096,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)) } } } @@ -4124,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)) } } } @@ -4148,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)) } } } @@ -4172,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)) } } } @@ -4196,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)) } } } @@ -4220,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)) } } } @@ -4244,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)) } } } @@ -4268,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)) } } } @@ -4292,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)) } } } @@ -4316,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)) } } } @@ -4340,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)) } } } @@ -4365,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)) } } } @@ -4389,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)) } } } @@ -4413,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)) } } } @@ -4437,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)) } } } @@ -4461,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)) } } } @@ -4486,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)) } } } @@ -4511,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)) } } } @@ -4535,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)) } } } @@ -4559,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)) } } } @@ -4584,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)) } } } @@ -4608,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)) } } } @@ -4632,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)) } } } @@ -4656,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)) } } } @@ -4680,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)) } } } @@ -4704,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)) } } } @@ -4728,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)) } } } @@ -4752,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)) } } } @@ -4776,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)) } } } @@ -4800,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)) } } } @@ -4825,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)) } } } @@ -4850,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)) } } } @@ -4875,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)) } } } @@ -4899,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)) } } } @@ -4924,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)) } } } @@ -4948,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)) } } } @@ -4973,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)) } } } @@ -4998,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)) } } } @@ -5023,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)) } } } @@ -5048,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)) } } } @@ -5073,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)) } } } @@ -5098,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)) } } } @@ -5122,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)) } } } @@ -5146,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)) } } } @@ -5170,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)) } } } @@ -6532,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) } @@ -6580,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)) } } } @@ -6602,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 ea402e91d7a4..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 @@ -173,6 +173,42 @@ 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..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,48 +15,30 @@ 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] -} - -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 { @@ -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. @@ -1473,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 { @@ -1492,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 { @@ -1509,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 { @@ -1526,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 { @@ -1543,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 { @@ -1562,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 { @@ -1581,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 { @@ -1600,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 { @@ -1619,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 { @@ -1638,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 { @@ -1657,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 { @@ -1676,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 { @@ -1695,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 { @@ -1714,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 { @@ -1733,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 { @@ -1752,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 { @@ -1771,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 { @@ -1790,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 { @@ -1809,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 { @@ -1828,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 { @@ -1847,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 { @@ -1866,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 { @@ -1885,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 { @@ -1904,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 { @@ -1923,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 { @@ -1942,14 +2013,69 @@ 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 { 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(wrapResponse(result, nil)) + } catch { + reply(wrapResponse(nil, 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(wrapResponse(result, nil)) + } catch { + reply(wrapResponse(nil, 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(wrapResponse(result, nil)) + } catch { + reply(wrapResponse(nil, error)) + } + } + } else { + sendJSONParserChannel.setMessageHandler(nil) + } /// Returns the passed enum to test serialization and deserialization. let echoEnumChannel = FlutterBasicMessageChannel( name: @@ -1961,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 { @@ -1980,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 { @@ -1999,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 { @@ -2018,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 { @@ -2037,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 { @@ -2057,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 { @@ -2076,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 { @@ -2095,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 { @@ -2114,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 { @@ -2133,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 { @@ -2153,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 { @@ -2173,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 { @@ -2195,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 { @@ -2217,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 { @@ -2236,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 { @@ -2255,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 { @@ -2274,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 { @@ -2293,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 { @@ -2312,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 { @@ -2331,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 { @@ -2350,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 { @@ -2369,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 { @@ -2388,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 { @@ -2407,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 { @@ -2426,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 { @@ -2445,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 { @@ -2464,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 { @@ -2483,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 { @@ -2502,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 { @@ -2521,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 { @@ -2540,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 { @@ -2559,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 { @@ -2578,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 { @@ -2597,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 { @@ -2615,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 { @@ -2633,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 { @@ -2652,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 { @@ -2671,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 { @@ -2690,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)) } } } @@ -2711,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)) } } } @@ -2732,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)) } } } @@ -2753,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)) } } } @@ -2774,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)) } } } @@ -2795,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)) } } } @@ -2816,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)) } } } @@ -2837,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)) } } } @@ -2858,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)) } } } @@ -2879,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)) } } } @@ -2900,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)) } } } @@ -2921,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)) } } } @@ -2942,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)) } } } @@ -2963,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)) } } } @@ -2984,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)) } } } @@ -3005,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)) } } } @@ -3026,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)) } } } @@ -3045,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)) } } } @@ -3064,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)) } } } @@ -3083,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)) } } } @@ -3104,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)) } } } @@ -3125,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)) } } } @@ -3146,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)) } } } @@ -3167,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)) } } } @@ -3188,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)) } } } @@ -3209,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)) } } } @@ -3230,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)) } } } @@ -3251,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)) } } } @@ -3272,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)) } } } @@ -3293,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)) } } } @@ -3314,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)) } } } @@ -3335,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)) } } } @@ -3356,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)) } } } @@ -3377,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)) } } } @@ -3398,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)) } } } @@ -3419,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)) } } } @@ -3440,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)) } } } @@ -3461,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)) } } } @@ -3482,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)) } } } @@ -3501,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 { @@ -3525,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 { @@ -3542,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)) } } } @@ -3560,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)) } } } @@ -3578,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)) } } } @@ -3598,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)) } } } @@ -3618,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)) } } } @@ -3642,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)) } } } @@ -3662,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)) } } } @@ -3687,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)) } } } @@ -3707,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)) } } } @@ -3727,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)) } } } @@ -3747,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)) } } } @@ -3767,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)) } } } @@ -3787,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)) } } } @@ -3807,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)) } } } @@ -3827,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)) } } } @@ -3847,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)) } } } @@ -3867,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)) } } } @@ -3887,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)) } } } @@ -3907,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)) } } } @@ -3927,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)) } } } @@ -3947,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)) } } } @@ -3967,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)) } } } @@ -3987,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)) } } } @@ -4007,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)) } } } @@ -4027,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)) } } } @@ -4047,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)) } } } @@ -4067,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)) } } } @@ -4087,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)) } } } @@ -4107,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)) } } } @@ -4127,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)) } } } @@ -4147,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)) } } } @@ -4167,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)) } } } @@ -4187,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)) } } } @@ -4207,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)) } } } @@ -4227,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)) } } } @@ -4247,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)) } } } @@ -4267,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)) } } } @@ -4287,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)) } } } @@ -4307,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)) } } } @@ -4327,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)) } } } @@ -4347,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)) } } } @@ -4367,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)) } } } @@ -4387,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)) } } } @@ -4407,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)) } } } @@ -4427,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)) } } } @@ -4447,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)) } } } @@ -4467,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)) } } } @@ -4487,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)) } } } @@ -4507,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)) } } } @@ -4527,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)) } } } @@ -4547,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)) } } } @@ -6189,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 { @@ -6225,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)) } } } @@ -6242,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/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..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 @@ -15,48 +15,30 @@ 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] -} - -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 { @@ -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`. @@ -328,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 { @@ -343,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 { @@ -1147,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 { @@ -1191,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 { @@ -1211,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 { @@ -1230,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 { @@ -1247,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 { @@ -1265,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 { @@ -1283,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 { @@ -1301,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 { @@ -1320,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 { @@ -1339,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 { @@ -1358,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 { @@ -1377,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 { @@ -1396,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 { @@ -1415,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 { @@ -1434,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 { @@ -1453,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 { @@ -1472,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 { @@ -1491,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 { @@ -1510,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 { @@ -1529,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 { @@ -1548,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 { @@ -1567,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 { @@ -1586,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 { @@ -1605,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 { @@ -1625,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 { @@ -1644,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 { @@ -1663,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 { @@ -1682,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 { @@ -1701,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 { @@ -1721,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 { @@ -1739,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)) } } } @@ -1761,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)) } } } @@ -1783,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)) } } } @@ -1805,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)) } } } @@ -1827,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)) } } } @@ -1849,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)) } } } @@ -1871,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)) } } } @@ -1893,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)) } } } @@ -1915,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)) } } } @@ -1937,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)) } } } @@ -1957,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)) } } } @@ -1978,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)) } } } @@ -1998,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)) } } } @@ -2020,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)) } } } @@ -2042,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)) } } } @@ -2064,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)) } } } @@ -2086,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)) } } } @@ -2109,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)) } } } @@ -2131,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)) } } } @@ -2153,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)) } } } @@ -2175,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)) } } } @@ -2197,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)) } } } @@ -2213,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 { @@ -2230,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 { @@ -2246,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)) } } } @@ -2266,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)) } } } @@ -2286,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)) } } } @@ -2308,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)) } } } @@ -2330,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)) } } } @@ -2352,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)) } } } @@ -2374,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)) } } } @@ -2396,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)) } } } @@ -2419,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)) } } } @@ -2441,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)) } } } @@ -2464,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)) } } } @@ -2486,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)) } } } @@ -2509,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)) } } } @@ -2531,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)) } } } @@ -2553,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)) } } } @@ -2576,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)) } } } @@ -2599,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)) } } } @@ -2622,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)) } } } @@ -2645,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)) } } } @@ -2668,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)) } } } @@ -2691,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)) } } } @@ -2714,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)) } } } @@ -2737,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)) } } } @@ -2760,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)) } } } @@ -2780,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)) } } } @@ -2803,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)) } } } @@ -4078,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 { @@ -4095,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 { @@ -4289,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 { @@ -4305,7 +4304,8 @@ final class PigeonApiClassWithApiRequirement: PigeonApiProtocolClassWithApiRequi if api != nil { pigeonDefaultConstructorChannel.setMessageHandler { message, reply in reply( - wrapError( + wrapResponse( + nil, FlutterError( code: "PigeonUnsupportedOperationError", message: @@ -4327,9 +4327,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 { @@ -4342,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 89d25d32f58e..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 @@ -188,6 +188,48 @@ 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 + case nil: + enumVal = nil + } + 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 + case nil: + enumVal = nil + } + 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..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); @@ -3315,6 +3323,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 +3581,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 +3609,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 +3675,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 +3714,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 +3750,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 +3790,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 +3912,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 +3966,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 +3984,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 +5741,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 +16210,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 +19863,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 +21781,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", @@ -25845,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; } @@ -26155,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; } @@ -26322,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; } @@ -26501,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; } @@ -26681,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; } @@ -26862,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; } @@ -27038,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; } @@ -27197,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; } @@ -27357,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; } @@ -27517,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; } @@ -27677,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; } @@ -27842,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; } @@ -28002,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; } @@ -28164,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; } @@ -28328,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; } @@ -28497,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; } @@ -28663,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; } @@ -28823,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; } @@ -28985,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; } @@ -29146,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; } @@ -29308,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; } @@ -29472,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; } @@ -29640,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; } @@ -29808,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; } @@ -29977,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; } @@ -30143,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; } @@ -30309,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; } @@ -30478,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; } @@ -30652,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; } @@ -30821,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; } @@ -30994,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; } @@ -31167,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; } @@ -31344,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; } @@ -31517,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; } @@ -31690,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; } @@ -31864,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; } @@ -32038,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; } @@ -32210,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; } @@ -32378,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; } @@ -32550,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; } @@ -32723,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; } @@ -32896,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; } @@ -33070,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; } @@ -33244,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; } @@ -33418,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; } @@ -33592,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; } @@ -33765,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; } @@ -33946,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; } @@ -34266,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; } @@ -34986,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; } @@ -35144,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; } 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..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,6 +213,82 @@ 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 +3318,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..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", @@ -2576,6 +2589,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 +2765,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 +2825,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 +2841,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 +2856,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 +2864,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()), @@ -2782,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 { @@ -2810,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 { @@ -2845,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 { @@ -2878,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 { @@ -2906,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 { @@ -2940,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 { @@ -2974,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 { @@ -3009,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 { @@ -3043,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 { @@ -3078,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 = @@ -3086,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 { @@ -3114,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 { @@ -3148,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 { @@ -3183,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 { @@ -3218,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 = @@ -3226,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 { @@ -3254,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 = @@ -3262,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 { @@ -3291,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 = @@ -3299,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 { @@ -3327,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 { @@ -3361,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 { @@ -3396,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 { @@ -3431,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 { @@ -3466,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 { @@ -3502,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 = @@ -3510,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 { @@ -3538,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 = @@ -3546,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 { @@ -3574,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 = @@ -3582,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 { @@ -3610,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 = @@ -3618,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 { @@ -3646,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( @@ -3654,15 +3858,135 @@ 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; + } + EncodableValue result_value( + CustomEncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); + } catch (const std::exception& exception) { + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); + } + }); + } else { + 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()) { + FlutterError error("Error", "acronyms_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); + return; + } + const auto& acronyms_arg = + std::any_cast( + std::get(encodable_acronyms_arg)); + ErrorOr output = + api->EchoAcronyms(acronyms_arg); + if (output.has_error()) { + reply(WrapResponse(nullptr, &output.error())); + return; + } + EncodableValue result_value( + CustomEncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); + } catch (const std::exception& exception) { + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); + } + }); + } 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()) { + FlutterError error("Error", "acronyms_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); + return; + } + const auto& acronyms_arg = + std::any_cast( + std::get(encodable_acronyms_arg)); + ErrorOr output = + api->HostHTTPResponse(acronyms_arg); + if (output.has_error()) { + reply(WrapResponse(nullptr, &output.error())); + return; + } + EncodableValue result_value( + CustomEncodableValue(std::move(output).TakeValue())); + reply(WrapResponse(&result_value, nullptr)); + } catch (const std::exception& exception) { + FlutterError error("Error", exception.what(), EncodableValue()); + reply(WrapResponse(nullptr, &error)); + } + }); + } 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()) { + FlutterError error("Error", "acronyms_arg unexpectedly null.", + EncodableValue()); + reply(WrapResponse(nullptr, &error)); + return; + } + const auto& acronyms_arg = + std::any_cast( + std::get(encodable_acronyms_arg)); + ErrorOr output = + api->SendJSONParser(acronyms_arg); + if (output.has_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 { @@ -3683,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 { @@ -3719,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( @@ -3727,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 { @@ -3757,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 = @@ -3765,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 { @@ -3794,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 = @@ -3802,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 { @@ -3830,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 { @@ -3865,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( @@ -3880,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 { @@ -3909,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 { @@ -3945,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 = @@ -3954,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 { @@ -3991,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 { @@ -4034,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 { @@ -4069,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( @@ -4077,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 { @@ -4116,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 { @@ -4157,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 { @@ -4199,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 { @@ -4232,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 { @@ -4270,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 { @@ -4308,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 { @@ -4346,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 { @@ -4386,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 { @@ -4424,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 { @@ -4462,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 { @@ -4501,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 { @@ -4540,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 { @@ -4579,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 { @@ -4618,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 { @@ -4656,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 { @@ -4695,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 { @@ -4733,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 { @@ -4771,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 { @@ -4810,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 { @@ -4849,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 { @@ -4888,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 { @@ -4927,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 { @@ -4966,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 { @@ -5009,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 { @@ -5054,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 { @@ -5093,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 { @@ -5132,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 { @@ -5165,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 { @@ -5194,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 { @@ -5230,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 = @@ -5238,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 { @@ -5268,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 { @@ -5304,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 = @@ -5312,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 { @@ -5342,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 = @@ -5351,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 { @@ -5381,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 { @@ -5418,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 = @@ -5426,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 { @@ -5456,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 = @@ -5464,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 { @@ -5494,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 = @@ -5502,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 { @@ -5532,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 { @@ -5569,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 = @@ -5577,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 { @@ -5607,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 = @@ -5615,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 { @@ -5645,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 = @@ -5653,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 { @@ -5683,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 = @@ -5691,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 { @@ -5721,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( @@ -5729,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 { @@ -5760,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( @@ -5768,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 { @@ -5798,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 { @@ -5834,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 { @@ -5864,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 { @@ -5899,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( @@ -5907,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 { @@ -5947,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 { @@ -5993,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 { @@ -6034,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 { @@ -6075,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 { @@ -6114,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 { @@ -6155,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 { @@ -6197,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 { @@ -6237,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 { @@ -6278,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 { @@ -6319,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 { @@ -6360,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 { @@ -6401,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 { @@ -6442,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 { @@ -6483,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 { @@ -6524,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 { @@ -6565,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 { @@ -6611,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 { @@ -6657,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 { @@ -6691,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 { @@ -6719,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 { @@ -6747,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 { @@ -6777,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 { @@ -6813,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 { @@ -6843,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( @@ -6851,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 { @@ -6891,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 { @@ -6939,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 { @@ -6980,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 { @@ -7028,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 { @@ -7058,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 { @@ -7095,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 { @@ -7133,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 = @@ -7141,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 { @@ -7172,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 = @@ -7180,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 { @@ -7211,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 = @@ -7219,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 { @@ -7249,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 = @@ -7257,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 { @@ -7288,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 = @@ -7296,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 { @@ -7327,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 = @@ -7335,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 { @@ -7366,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 = @@ -7374,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 { @@ -7405,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 = @@ -7413,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 { @@ -7443,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 { @@ -7481,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 = @@ -7489,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 { @@ -7520,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 = @@ -7528,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 { @@ -7559,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 = @@ -7567,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 { @@ -7598,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 = @@ -7606,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 { @@ -7637,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 = @@ -7645,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 { @@ -7676,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 = @@ -7684,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 { @@ -7715,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 = @@ -7723,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 { @@ -7754,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 = @@ -7762,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 { @@ -7792,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( @@ -7800,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 { @@ -7831,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( @@ -7839,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 { @@ -7873,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 { @@ -7914,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 { @@ -7955,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 { @@ -7996,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 { @@ -8038,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 { @@ -8079,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 { @@ -8120,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 { @@ -8161,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 { @@ -8202,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 { @@ -8243,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 { @@ -8284,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 { @@ -8325,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 { @@ -8366,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 { @@ -8407,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 { @@ -8448,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 { @@ -8489,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 { @@ -8530,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 { @@ -8571,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 { @@ -8612,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 { @@ -8658,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 { @@ -8704,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 { @@ -8740,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 = @@ -8748,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 { @@ -10808,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 { @@ -10870,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 { @@ -10906,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/pigeon/core_tests.gen.h b/packages/pigeon/platform_tests/test_plugin/windows/pigeon/core_tests.gen.h index 24ca4540d6a8..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 @@ -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..0430b9956f90 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,44 @@ 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/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 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/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'); + }); } 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', () {