diff --git a/.ci.yaml b/.ci.yaml index 96868d5a73e..66f95e165ae 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -1071,7 +1071,11 @@ targets: properties: add_recipes_cq: "true" version_file: flutter_master.version - target_file: macos_check_podspecs.yaml + target_file: macos_repo_checks.yaml + dependencies: > + [ + {"dependency": "swift_format", "version": "build_id:8797338980206841409"} + ] ### macOS desktop tasks ### # macos-platform_tests builds all the packages on ARM, so this build is run @@ -1143,6 +1147,10 @@ targets: { "CHANNEL": "master" } + dependencies: > + [ + {"dependency": "swift_format", "version": "build_id:8797338979890974865"} + ] - name: Mac_arm64 custom_package_tests stable recipe: packages/packages @@ -1156,6 +1164,10 @@ targets: { "CHANNEL": "stable" } + dependencies: > + [ + {"dependency": "swift_format", "version": "build_id:8797338979890974865"} + ] ### iOS tasks ### # ios_platform_tests builds all the packages on ARM, so this build is run diff --git a/.ci/flutter_master.version b/.ci/flutter_master.version index d362631457c..ddee794e68f 100644 --- a/.ci/flutter_master.version +++ b/.ci/flutter_master.version @@ -1 +1 @@ -f77f82435a9725933f4b4db9b35ebeaae87d4b48 +5dea6b994e8ff74c329e5d07a497117578d03710 diff --git a/.ci/flutter_stable.version b/.ci/flutter_stable.version index 50880ebc92e..782df31f91d 100644 --- a/.ci/flutter_stable.version +++ b/.ci/flutter_stable.version @@ -1 +1 @@ -ef1af02aead6fe2414f3aafa5a61087b610e1332 +67457e669f79e9f8d13d7a68fe09775fefbb79f4 diff --git a/.ci/targets/macos_check_podspecs.yaml b/.ci/targets/macos_repo_checks.yaml similarity index 56% rename from .ci/targets/macos_check_podspecs.yaml rename to .ci/targets/macos_repo_checks.yaml index 946ac66f748..7fd858bfe83 100644 --- a/.ci/targets/macos_check_podspecs.yaml +++ b/.ci/targets/macos_repo_checks.yaml @@ -5,6 +5,13 @@ tasks: - name: update pods repo script: .ci/scripts/update_pods.sh infra_step: true # Note infra steps failing prevents "always" from running. + - name: Swift format + script: script/tool_runner.sh + # Non-Swift languages are formatted on Linux builders. + # Skip them on Mac builder to avoid duplication. + args: ["format", "--fail-on-change", "--no-dart", "--no-clang-format", "--no-kotlin", "--no-java" ] + always: true - name: validate iOS and macOS podspecs script: script/tool_runner.sh args: ["podspec-check"] + always: true diff --git a/.ci/targets/repo_checks.yaml b/.ci/targets/repo_checks.yaml index 5989a5efed7..37d9f0a1008 100644 --- a/.ci/targets/repo_checks.yaml +++ b/.ci/targets/repo_checks.yaml @@ -4,7 +4,8 @@ tasks: infra_step: true # Note infra steps failing prevents "always" from running. - name: format script: script/tool_runner.sh - args: ["format", "--fail-on-change"] + # Skip Swift formatting on Linux builders. + args: ["format", "--fail-on-change", "--no-swift"] always: true - name: license validation script: script/tool_runner.sh diff --git a/.github/labeler.yml b/.github/labeler.yml index a6b295e0166..a967a52b74c 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -212,9 +212,13 @@ 'platform-ios': - changed-files: - any-glob-to-any-file: + - packages/*/*_avfoundation/**/* + - packages/*/*_darwin/**/* + - packages/*/*_foundation/**/* - packages/*/*_ios/**/* - packages/*/*_storekit/**/* - packages/*/*_wkwebview/**/* + - packages/**/darwin/**/* - packages/**/ios/**/* 'platform-linux': @@ -226,7 +230,12 @@ 'platform-macos': - changed-files: - any-glob-to-any-file: + - packages/*/*_avfoundation/**/* + - packages/*/*_darwin/**/* + - packages/*/*_foundation/**/* - packages/*/*_macos/**/* + - packages/*/*_storekit/**/* + - packages/**/darwin/**/* - packages/**/macos/**/* 'platform-web': diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index e68c8e8b75d..d765bb04c6e 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -41,7 +41,7 @@ jobs: # Upload the results as artifacts (optional). - name: "Upload artifact" - uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 # v2.3.1 + uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v2.3.1 with: name: SARIF file path: results.sarif diff --git a/packages/camera/camera_avfoundation/CHANGELOG.md b/packages/camera/camera_avfoundation/CHANGELOG.md index b8d61cb0b33..dae480a6b16 100644 --- a/packages/camera/camera_avfoundation/CHANGELOG.md +++ b/packages/camera/camera_avfoundation/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 0.9.13+11 -* Remove development team from example app. +* Fixes a memory leak of sample buffer when pause and resume the video recording. +* Removes development team from example app. * Updates minimum iOS version to 12.0 and minimum Flutter version to 3.16.6. ## 0.9.13+10 diff --git a/packages/camera/camera_avfoundation/example/ios/RunnerTests/FLTCamSampleBufferTests.m b/packages/camera/camera_avfoundation/example/ios/RunnerTests/FLTCamSampleBufferTests.m index 6f0a4edab08..24e35449114 100644 --- a/packages/camera/camera_avfoundation/example/ios/RunnerTests/FLTCamSampleBufferTests.m +++ b/packages/camera/camera_avfoundation/example/ios/RunnerTests/FLTCamSampleBufferTests.m @@ -38,6 +38,41 @@ - (void)testCopyPixelBuffer { CFRelease(deliveriedPixelBuffer); } +- (void)testDidOutputSampleBuffer_mustNotChangeSampleBufferRetainCountAfterPauseResumeRecording { + FLTCam *cam = FLTCreateCamWithCaptureSessionQueue(dispatch_queue_create("test", NULL)); + CMSampleBufferRef sampleBuffer = FLTCreateTestSampleBuffer(); + + id writerMock = OCMClassMock([AVAssetWriter class]); + OCMStub([writerMock alloc]).andReturn(writerMock); + OCMStub([writerMock initWithURL:OCMOCK_ANY fileType:OCMOCK_ANY error:[OCMArg setTo:nil]]) + .andReturn(writerMock); + __block AVAssetWriterStatus status = AVAssetWriterStatusUnknown; + OCMStub([writerMock startWriting]).andDo(^(NSInvocation *invocation) { + status = AVAssetWriterStatusWriting; + }); + OCMStub([writerMock status]).andDo(^(NSInvocation *invocation) { + [invocation setReturnValue:&status]; + }); + + FLTThreadSafeFlutterResult *result = + [[FLTThreadSafeFlutterResult alloc] initWithResult:^(id result){ + // no-op + }]; + + // Pause then resume the recording. + [cam startVideoRecordingWithResult:result]; + [cam pauseVideoRecordingWithResult:result]; + [cam resumeVideoRecordingWithResult:result]; + + [cam captureOutput:cam.captureVideoOutput + didOutputSampleBuffer:sampleBuffer + fromConnection:OCMClassMock([AVCaptureConnection class])]; + XCTAssertEqual(CFGetRetainCount(sampleBuffer), 1, + @"didOutputSampleBuffer must not change the sample buffer retain count after " + @"pause resume recording."); + CFRelease(sampleBuffer); +} + - (void)testDidOutputSampleBufferIgnoreAudioSamplesBeforeVideoSamples { FLTCam *cam = FLTCreateCamWithCaptureSessionQueue(dispatch_queue_create("testing", NULL)); CMSampleBufferRef videoSample = FLTCreateTestSampleBuffer(); diff --git a/packages/camera/camera_avfoundation/ios/Classes/FLTCam.m b/packages/camera/camera_avfoundation/ios/Classes/FLTCam.m index 1f940403320..b3dd9c53e2b 100644 --- a/packages/camera/camera_avfoundation/ios/Classes/FLTCam.m +++ b/packages/camera/camera_avfoundation/ios/Classes/FLTCam.m @@ -514,7 +514,6 @@ - (void)captureOutput:(AVCaptureOutput *)output return; } - CFRetain(sampleBuffer); CMTime currentSampleTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer); if (_videoWriter.status != AVAssetWriterStatusWriting) { @@ -564,18 +563,18 @@ - (void)captureOutput:(AVCaptureOutput *)output _lastAudioSampleTime = currentSampleTime; if (_audioTimeOffset.value != 0) { - CFRelease(sampleBuffer); - sampleBuffer = [self adjustTime:sampleBuffer by:_audioTimeOffset]; + CMSampleBufferRef adjustedSampleBuffer = + [self copySampleBufferWithAdjustedTime:sampleBuffer by:_audioTimeOffset]; + [self newAudioSample:adjustedSampleBuffer]; + CFRelease(adjustedSampleBuffer); + } else { + [self newAudioSample:sampleBuffer]; } - - [self newAudioSample:sampleBuffer]; } - - CFRelease(sampleBuffer); } } -- (CMSampleBufferRef)adjustTime:(CMSampleBufferRef)sample by:(CMTime)offset CF_RETURNS_RETAINED { +- (CMSampleBufferRef)copySampleBufferWithAdjustedTime:(CMSampleBufferRef)sample by:(CMTime)offset { CMItemCount count; CMSampleBufferGetSampleTimingInfoArray(sample, 0, nil, &count); CMSampleTimingInfo *pInfo = malloc(sizeof(CMSampleTimingInfo) * count); diff --git a/packages/camera/camera_avfoundation/pubspec.yaml b/packages/camera/camera_avfoundation/pubspec.yaml index 175213883b1..e3845c4f5ea 100644 --- a/packages/camera/camera_avfoundation/pubspec.yaml +++ b/packages/camera/camera_avfoundation/pubspec.yaml @@ -2,7 +2,7 @@ name: camera_avfoundation description: iOS implementation of the camera plugin. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_avfoundation issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.9.13+10 +version: 0.9.13+11 environment: sdk: ^3.2.3 diff --git a/packages/file_selector/file_selector_macos/example/macos/RunnerTests/RunnerTests.swift b/packages/file_selector/file_selector_macos/example/macos/RunnerTests/RunnerTests.swift index 53081ed6548..304646a9b59 100644 --- a/packages/file_selector/file_selector_macos/example/macos/RunnerTests/RunnerTests.swift +++ b/packages/file_selector/file_selector_macos/example/macos/RunnerTests/RunnerTests.swift @@ -40,7 +40,7 @@ class TestViewProvider: NSObject, ViewProvider { var window: NSWindow? = NSWindow() } -class exampleTests: XCTestCase { +class ExampleTests: XCTestCase { func testOpenSimple() throws { let panelController = TestPanelController() diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index 6a901e11287..6c26d0287fd 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,3 +1,7 @@ +## 16.0.4 + +* [swift] Improve style of Swift output. + ## 16.0.3 * [kotlin] Separates message call code generation into separate methods. diff --git a/packages/pigeon/example/app/ios/Runner/Messages.g.swift b/packages/pigeon/example/app/ios/Runner/Messages.g.swift index ad6a337a6db..3acc38b2cb6 100644 --- a/packages/pigeon/example/app/ios/Runner/Messages.g.swift +++ b/packages/pigeon/example/app/ios/Runner/Messages.g.swift @@ -5,12 +5,13 @@ // See also: https://pub.dev/packages/pigeon import Foundation + #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #else -#error("Unsupported platform.") + #error("Unsupported platform.") #endif private func wrapResult(_ result: Any?) -> [Any?] { @@ -22,18 +23,20 @@ private func wrapError(_ error: Any) -> [Any?] { return [ flutterError.code, flutterError.message, - flutterError.details + flutterError.details, ] } return [ "\(error)", "\(type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)" + "Stacktrace: \(Thread.callStackSymbols)", ] } private func createConnectionError(withChannelName channelName: String) -> FlutterError { - return FlutterError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") + return FlutterError( + code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", + details: "") } private func isNullish(_ value: Any?) -> Bool { @@ -83,10 +86,10 @@ struct MessageData { private class ExampleHostApiCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { - case 128: - return MessageData.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) + case 128: + return MessageData.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) } } } @@ -129,7 +132,9 @@ class ExampleHostApiSetup { static var codec: FlutterStandardMessageCodec { ExampleHostApiCodec.shared } /// Sets up an instance of `ExampleHostApi` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: ExampleHostApi?) { - let getHostLanguageChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage", binaryMessenger: binaryMessenger, codec: codec) + let getHostLanguageChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { getHostLanguageChannel.setMessageHandler { _, reply in do { @@ -142,7 +147,9 @@ class ExampleHostApiSetup { } else { getHostLanguageChannel.setMessageHandler(nil) } - let addChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add", binaryMessenger: binaryMessenger, codec: codec) + let addChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { addChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -158,17 +165,19 @@ class ExampleHostApiSetup { } else { addChannel.setMessageHandler(nil) } - let sendMessageChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage", binaryMessenger: binaryMessenger, codec: codec) + let sendMessageChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { sendMessageChannel.setMessageHandler { message, reply in let args = message as! [Any?] let messageArg = args[0] as! MessageData api.sendMessage(message: messageArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -179,28 +188,36 @@ class ExampleHostApiSetup { } /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol MessageFlutterApiProtocol { - func flutterMethod(aString aStringArg: String?, completion: @escaping (Result) -> Void) + func flutterMethod( + aString aStringArg: String?, completion: @escaping (Result) -> Void) } class MessageFlutterApi: MessageFlutterApiProtocol { private let binaryMessenger: FlutterBinaryMessenger - init(binaryMessenger: FlutterBinaryMessenger){ + init(binaryMessenger: FlutterBinaryMessenger) { self.binaryMessenger = binaryMessenger } - func flutterMethod(aString aStringArg: String?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod" + func flutterMethod( + aString aStringArg: String?, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod" let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger) channel.sendMessage([aStringArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! String completion(.success(result)) diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index 31a4d0e778b..a399c62f1be 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -13,7 +13,7 @@ import 'ast.dart'; /// The current version of pigeon. /// /// This must match the version in pubspec.yaml. -const String pigeonVersion = '16.0.3'; +const String pigeonVersion = '16.0.4'; /// Read all the content from [stdin] to a String. String readStdin() { @@ -309,7 +309,7 @@ bool isVoid(TypeMirror type) { void addLines(Indent indent, Iterable lines, {String? linePrefix}) { final String prefix = linePrefix ?? ''; for (final String line in lines) { - indent.writeln('$prefix$line'); + indent.writeln(line.isNotEmpty ? '$prefix$line' : prefix.trimRight()); } } diff --git a/packages/pigeon/lib/swift_generator.dart b/packages/pigeon/lib/swift_generator.dart index ae869426e62..91319402c4f 100644 --- a/packages/pigeon/lib/swift_generator.dart +++ b/packages/pigeon/lib/swift_generator.dart @@ -76,13 +76,14 @@ class SwiftGenerator extends StructuredGenerator { required String dartPackageName, }) { indent.writeln('import Foundation'); + indent.newln(); indent.format(''' #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #else -#error("Unsupported platform.") + #error("Unsupported platform.") #endif'''); } @@ -160,6 +161,9 @@ import FlutterMacOS indent.addScoped('{', '}', () { indent.write('return '); indent.addScoped('[', ']', () { + // Follow swift-format style, which is to use a trailing comma unless + // there is only one element. + final String separator = classDefinition.fields.length > 1 ? ',' : ''; for (final NamedType field in getFieldsInSerializationOrder(classDefinition)) { String toWriteValue = ''; @@ -173,7 +177,7 @@ import FlutterMacOS toWriteValue = field.name; } - indent.writeln('$toWriteValue,'); + indent.writeln('$toWriteValue$separator'); } }); }); @@ -294,7 +298,7 @@ import FlutterMacOS indent.write('class ${api.name}: ${api.name}Protocol '); indent.addScoped('{', '}', () { indent.writeln('private let binaryMessenger: FlutterBinaryMessenger'); - indent.write('init(binaryMessenger: FlutterBinaryMessenger)'); + indent.write('init(binaryMessenger: FlutterBinaryMessenger) '); indent.addScoped('{', '}', () { indent.writeln('self.binaryMessenger = binaryMessenger'); }); @@ -330,20 +334,20 @@ import FlutterMacOS indent.writeScoped( 'guard let listResponse = response as? [Any?] else {', '}', () { indent.writeln( - 'completion(.failure(createConnectionError(withChannelName:channelName)))'); + 'completion(.failure(createConnectionError(withChannelName: channelName)))'); indent.writeln('return'); }); - indent.writeScoped('if (listResponse.count > 1) {', '} ', () { + indent.writeScoped('if listResponse.count > 1 {', '} ', () { indent.writeln('let code: String = listResponse[0] as! String'); indent.writeln( 'let message: String? = nilOrValue(listResponse[1])'); indent.writeln( 'let details: String? = nilOrValue(listResponse[2])'); indent.writeln( - 'completion(.failure(FlutterError(code: code, message: message, details: details)));'); + 'completion(.failure(FlutterError(code: code, message: message, details: details)))'); }, addTrailingNewline: false); if (!func.returnType.isNullable && !func.returnType.isVoid) { - indent.addScoped('else if (listResponse[0] == nil) {', '} ', () { + indent.addScoped('else if listResponse[0] == nil {', '} ', () { indent.writeln( 'completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: "")))'); }, addTrailingNewline: false); @@ -495,8 +499,14 @@ import FlutterMacOS }); } final String tryStatement = method.isAsynchronous ? '' : 'try '; + // Empty parens are not required when calling a method whose only + // argument is a trailing closure. + final String argumentString = + methodArgument.isEmpty && method.isAsynchronous + ? '' + : '(${methodArgument.join(', ')})'; final String call = - '${tryStatement}api.${components.name}(${methodArgument.join(', ')})'; + '${tryStatement}api.${components.name}$argumentString'; if (method.isAsynchronous) { final String resultName = method.returnType.isVoid ? 'nil' : 'res'; @@ -506,7 +516,7 @@ import FlutterMacOS indent.addScoped('{ result in', '}', () { indent.write('switch result '); - indent.addScoped('{', '}', () { + indent.addScoped('{', '}', nestCount: 0, () { final String nullsafe = method.returnType.isNullable ? '?' : ''; final String enumTag = @@ -573,7 +583,7 @@ import FlutterMacOS indent.write('override func readValue(ofType type: UInt8) -> Any? '); indent.addScoped('{', '}', () { indent.write('switch type '); - indent.addScoped('{', '}', () { + indent.addScoped('{', '}', nestCount: 0, () { for (final EnumeratedClass customClass in getCodecClasses(api, root)) { indent.writeln('case ${customClass.enumeration}:'); @@ -764,14 +774,14 @@ import FlutterMacOS indent.addScoped('[', ']', () { indent.writeln('flutterError.code,'); indent.writeln('flutterError.message,'); - indent.writeln('flutterError.details'); + indent.writeln('flutterError.details,'); }); }); indent.write('return '); indent.addScoped('[', ']', () { indent.writeln(r'"\(error)",'); indent.writeln(r'"\(type(of: error))",'); - indent.writeln(r'"Stacktrace: \(Thread.callStackSymbols)"'); + indent.writeln(r'"Stacktrace: \(Thread.callStackSymbols)",'); }); }); } diff --git a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift index 773b6e5c12e..14bcb9a4113 100644 --- a/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/ios/Classes/CoreTests.gen.swift @@ -1,17 +1,18 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// +// // Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation + #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #else -#error("Unsupported platform.") + #error("Unsupported platform.") #endif private func wrapResult(_ result: Any?) -> [Any?] { @@ -23,18 +24,20 @@ private func wrapError(_ error: Any) -> [Any?] { return [ flutterError.code, flutterError.message, - flutterError.details + flutterError.details, ] } return [ "\(error)", "\(type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)" + "Stacktrace: \(Thread.callStackSymbols)", ] } private func createConnectionError(withChannelName channelName: String) -> FlutterError { - return FlutterError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") + return FlutterError( + code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", + details: "") } private func isNullish(_ value: Any?) -> Bool { @@ -143,8 +146,10 @@ struct AllNullableTypes { static func fromList(_ list: [Any?]) -> AllNullableTypes? { let aNullableBool: Bool? = nilOrValue(list[0]) - let aNullableInt: Int64? = isNullish(list[1]) ? nil : (list[1] is Int64? ? list[1] as! Int64? : Int64(list[1] as! Int32)) - let aNullableInt64: Int64? = isNullish(list[2]) ? nil : (list[2] is Int64? ? list[2] as! Int64? : Int64(list[2] as! Int32)) + let aNullableInt: Int64? = + isNullish(list[1]) ? nil : (list[1] is Int64? ? list[1] as! Int64? : Int64(list[1] as! Int32)) + let aNullableInt64: Int64? = + isNullish(list[2]) ? nil : (list[2] is Int64? ? list[2] as! Int64? : Int64(list[2] as! Int32)) let aNullableDouble: Double? = nilOrValue(list[3]) let aNullableByteArray: FlutterStandardTypedData? = nilOrValue(list[4]) let aNullable4ByteArray: FlutterStandardTypedData? = nilOrValue(list[5]) @@ -250,7 +255,7 @@ struct TestMessage { } func toList() -> [Any?] { return [ - testList, + testList ] } } @@ -258,16 +263,16 @@ struct TestMessage { private class HostIntegrationCoreApiCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { - case 128: - return AllClassesWrapper.fromList(self.readValue() as! [Any?]) - case 129: - return AllNullableTypes.fromList(self.readValue() as! [Any?]) - case 130: - return AllTypes.fromList(self.readValue() as! [Any?]) - case 131: - return TestMessage.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) + case 128: + return AllClassesWrapper.fromList(self.readValue() as! [Any?]) + case 129: + return AllNullableTypes.fromList(self.readValue() as! [Any?]) + case 130: + return AllTypes.fromList(self.readValue() as! [Any?]) + case 131: + return TestMessage.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) } } } @@ -303,7 +308,8 @@ private class HostIntegrationCoreApiCodecReaderWriter: FlutterStandardReaderWrit } class HostIntegrationCoreApiCodec: FlutterStandardMessageCodec { - static let shared = HostIntegrationCoreApiCodec(readerWriter: HostIntegrationCoreApiCodecReaderWriter()) + static let shared = HostIntegrationCoreApiCodec( + readerWriter: HostIntegrationCoreApiCodecReaderWriter()) } /// The core interface that each host language plugin must implement in @@ -357,7 +363,9 @@ protocol HostIntegrationCoreApi { /// sending of nested objects. func createNestedObject(with nullableString: String?) throws -> AllClassesWrapper /// Returns passed in arguments of multiple types. - func sendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String?) throws -> AllNullableTypes + func sendMultipleNullableTypes( + aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String? + ) throws -> AllNullableTypes /// Returns passed in int. func echo(_ aNullableInt: Int64?) throws -> Int64? /// Returns passed in double. @@ -391,13 +399,16 @@ protocol HostIntegrationCoreApi { /// Returns the passed string asynchronously. func echoAsync(_ aString: String, completion: @escaping (Result) -> Void) /// Returns the passed in Uint8List asynchronously. - func echoAsync(_ aUint8List: FlutterStandardTypedData, completion: @escaping (Result) -> Void) + func echoAsync( + _ aUint8List: FlutterStandardTypedData, + completion: @escaping (Result) -> Void) /// Returns the passed in generic Object asynchronously. func echoAsync(_ anObject: Any, completion: @escaping (Result) -> Void) /// Returns the passed list, to test asynchronous serialization and deserialization. func echoAsync(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) /// Returns the passed map, to test asynchronous serialization and deserialization. - func echoAsync(_ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) + func echoAsync( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) /// Returns the passed enum, to test asynchronous serialization and deserialization. func echoAsync(_ anEnum: AnEnum, completion: @escaping (Result) -> Void) /// Responds with an error from an async function returning a value. @@ -409,7 +420,9 @@ protocol HostIntegrationCoreApi { /// Returns the passed object, to test async serialization and deserialization. func echoAsync(_ everything: AllTypes, completion: @escaping (Result) -> Void) /// Returns the passed object, to test serialization and deserialization. - func echoAsync(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) + func echoAsync( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void) /// Returns passed in int asynchronously. func echoAsyncNullable(_ anInt: Int64?, completion: @escaping (Result) -> Void) /// Returns passed in double asynchronously. @@ -419,37 +432,56 @@ protocol HostIntegrationCoreApi { /// Returns the passed string asynchronously. func echoAsyncNullable(_ aString: String?, completion: @escaping (Result) -> Void) /// Returns the passed in Uint8List asynchronously. - func echoAsyncNullable(_ aUint8List: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) + func echoAsyncNullable( + _ aUint8List: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void) /// Returns the passed in generic Object asynchronously. func echoAsyncNullable(_ anObject: Any?, completion: @escaping (Result) -> Void) /// Returns the passed list, to test asynchronous serialization and deserialization. func echoAsyncNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) /// Returns the passed map, to test asynchronous serialization and deserialization. - func echoAsyncNullable(_ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) + func echoAsyncNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) /// Returns the passed enum, to test asynchronous serialization and deserialization. func echoAsyncNullable(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) func callFlutterNoop(completion: @escaping (Result) -> Void) func callFlutterThrowError(completion: @escaping (Result) -> Void) func callFlutterThrowErrorFromVoid(completion: @escaping (Result) -> Void) - func callFlutterEcho(_ everything: AllTypes, completion: @escaping (Result) -> Void) - func callFlutterEcho(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) - func callFlutterSendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String?, completion: @escaping (Result) -> Void) + func callFlutterEcho( + _ everything: AllTypes, completion: @escaping (Result) -> Void) + func callFlutterEcho( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void) + func callFlutterSendMultipleNullableTypes( + aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String?, + completion: @escaping (Result) -> Void) func callFlutterEcho(_ aBool: Bool, completion: @escaping (Result) -> Void) func callFlutterEcho(_ anInt: Int64, completion: @escaping (Result) -> Void) func callFlutterEcho(_ aDouble: Double, completion: @escaping (Result) -> Void) func callFlutterEcho(_ aString: String, completion: @escaping (Result) -> Void) - func callFlutterEcho(_ aList: FlutterStandardTypedData, completion: @escaping (Result) -> Void) + func callFlutterEcho( + _ aList: FlutterStandardTypedData, + completion: @escaping (Result) -> Void) func callFlutterEcho(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) - func callFlutterEcho(_ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) + func callFlutterEcho( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) func callFlutterEcho(_ anEnum: AnEnum, completion: @escaping (Result) -> Void) func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Result) -> Void) - func callFlutterEchoNullable(_ anInt: Int64?, completion: @escaping (Result) -> Void) - func callFlutterEchoNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) - func callFlutterEchoNullable(_ aString: String?, completion: @escaping (Result) -> Void) - func callFlutterEchoNullable(_ aList: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) - func callFlutterEchoNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) - func callFlutterEchoNullable(_ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) - func callFlutterNullableEcho(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) + func callFlutterEchoNullable( + _ anInt: Int64?, completion: @escaping (Result) -> Void) + func callFlutterEchoNullable( + _ aDouble: Double?, completion: @escaping (Result) -> Void) + func callFlutterEchoNullable( + _ aString: String?, completion: @escaping (Result) -> Void) + func callFlutterEchoNullable( + _ aList: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void) + func callFlutterEchoNullable( + _ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) + func callFlutterEchoNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) + func callFlutterNullableEcho( + _ anEnum: AnEnum?, completion: @escaping (Result) -> Void) } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. @@ -460,7 +492,9 @@ class HostIntegrationCoreApiSetup { static func setUp(binaryMessenger: FlutterBinaryMessenger, api: HostIntegrationCoreApi?) { /// A no-op function taking no arguments and returning no value, to sanity /// test basic calling. - let noopChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.noop", binaryMessenger: binaryMessenger, codec: codec) + let noopChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.noop", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { noopChannel.setMessageHandler { _, reply in do { @@ -474,7 +508,9 @@ class HostIntegrationCoreApiSetup { noopChannel.setMessageHandler(nil) } /// Returns the passed object, to test serialization and deserialization. - let echoAllTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAllTypes", binaryMessenger: binaryMessenger, codec: codec) + let echoAllTypesChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAllTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAllTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -490,7 +526,9 @@ class HostIntegrationCoreApiSetup { echoAllTypesChannel.setMessageHandler(nil) } /// Returns an error, to test error handling. - let throwErrorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwError", binaryMessenger: binaryMessenger, codec: codec) + let throwErrorChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwError", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwErrorChannel.setMessageHandler { _, reply in do { @@ -504,7 +542,9 @@ class HostIntegrationCoreApiSetup { throwErrorChannel.setMessageHandler(nil) } /// Returns an error from a void function, to test error handling. - let throwErrorFromVoidChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwErrorFromVoid", binaryMessenger: binaryMessenger, codec: codec) + let throwErrorFromVoidChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwErrorFromVoid", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwErrorFromVoidChannel.setMessageHandler { _, reply in do { @@ -518,7 +558,9 @@ class HostIntegrationCoreApiSetup { throwErrorFromVoidChannel.setMessageHandler(nil) } /// Returns a Flutter error, to test error handling. - let throwFlutterErrorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwFlutterError", binaryMessenger: binaryMessenger, codec: codec) + let throwFlutterErrorChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwFlutterError", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwFlutterErrorChannel.setMessageHandler { _, reply in do { @@ -532,7 +574,9 @@ class HostIntegrationCoreApiSetup { throwFlutterErrorChannel.setMessageHandler(nil) } /// Returns passed in int. - let echoIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoInt", binaryMessenger: binaryMessenger, codec: codec) + let echoIntChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -548,7 +592,9 @@ class HostIntegrationCoreApiSetup { echoIntChannel.setMessageHandler(nil) } /// Returns passed in double. - let echoDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoDouble", binaryMessenger: binaryMessenger, codec: codec) + let echoDoubleChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -564,7 +610,9 @@ class HostIntegrationCoreApiSetup { echoDoubleChannel.setMessageHandler(nil) } /// Returns the passed in boolean. - let echoBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoBool", binaryMessenger: binaryMessenger, codec: codec) + let echoBoolChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -580,7 +628,9 @@ class HostIntegrationCoreApiSetup { echoBoolChannel.setMessageHandler(nil) } /// Returns the passed in string. - let echoStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoString", binaryMessenger: binaryMessenger, codec: codec) + let echoStringChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -596,7 +646,9 @@ class HostIntegrationCoreApiSetup { echoStringChannel.setMessageHandler(nil) } /// Returns the passed in Uint8List. - let echoUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoUint8List", binaryMessenger: binaryMessenger, codec: codec) + let echoUint8ListChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -612,7 +664,9 @@ class HostIntegrationCoreApiSetup { echoUint8ListChannel.setMessageHandler(nil) } /// Returns the passed in generic Object. - let echoObjectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoObject", binaryMessenger: binaryMessenger, codec: codec) + let echoObjectChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoObject", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -628,7 +682,9 @@ class HostIntegrationCoreApiSetup { echoObjectChannel.setMessageHandler(nil) } /// Returns the passed list, to test serialization and deserialization. - let echoListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoList", binaryMessenger: binaryMessenger, codec: codec) + let echoListChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoListChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -644,7 +700,9 @@ class HostIntegrationCoreApiSetup { echoListChannel.setMessageHandler(nil) } /// Returns the passed map, to test serialization and deserialization. - let echoMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoMap", binaryMessenger: binaryMessenger, codec: codec) + let echoMapChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -660,7 +718,9 @@ class HostIntegrationCoreApiSetup { echoMapChannel.setMessageHandler(nil) } /// Returns the passed map to test nested class serialization and deserialization. - let echoClassWrapperChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoClassWrapper", binaryMessenger: binaryMessenger, codec: codec) + let echoClassWrapperChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoClassWrapper", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoClassWrapperChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -676,7 +736,9 @@ class HostIntegrationCoreApiSetup { echoClassWrapperChannel.setMessageHandler(nil) } /// Returns the passed enum to test serialization and deserialization. - let echoEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoEnum", binaryMessenger: binaryMessenger, codec: codec) + let echoEnumChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -692,7 +754,10 @@ class HostIntegrationCoreApiSetup { echoEnumChannel.setMessageHandler(nil) } /// Returns the default string. - let echoNamedDefaultStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNamedDefaultString", binaryMessenger: binaryMessenger, codec: codec) + let echoNamedDefaultStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNamedDefaultString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNamedDefaultStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -708,7 +773,10 @@ class HostIntegrationCoreApiSetup { echoNamedDefaultStringChannel.setMessageHandler(nil) } /// Returns passed in double. - let echoOptionalDefaultDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoOptionalDefaultDouble", binaryMessenger: binaryMessenger, codec: codec) + let echoOptionalDefaultDoubleChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoOptionalDefaultDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoOptionalDefaultDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -724,7 +792,9 @@ class HostIntegrationCoreApiSetup { echoOptionalDefaultDoubleChannel.setMessageHandler(nil) } /// Returns passed in int. - let echoRequiredIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoRequiredInt", binaryMessenger: binaryMessenger, codec: codec) + let echoRequiredIntChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoRequiredInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoRequiredIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -740,7 +810,10 @@ class HostIntegrationCoreApiSetup { echoRequiredIntChannel.setMessageHandler(nil) } /// Returns the passed object, to test serialization and deserialization. - let echoAllNullableTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAllNullableTypes", binaryMessenger: binaryMessenger, codec: codec) + let echoAllNullableTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAllNullableTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAllNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -757,7 +830,10 @@ class HostIntegrationCoreApiSetup { } /// Returns the inner `aString` value from the wrapped object, to test /// sending of nested objects. - let extractNestedNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.extractNestedNullableString", binaryMessenger: binaryMessenger, codec: codec) + let extractNestedNullableStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.extractNestedNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { extractNestedNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -774,7 +850,10 @@ class HostIntegrationCoreApiSetup { } /// Returns the inner `aString` value from the wrapped object, to test /// sending of nested objects. - let createNestedNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.createNestedNullableString", binaryMessenger: binaryMessenger, codec: codec) + let createNestedNullableStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.createNestedNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { createNestedNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -790,15 +869,21 @@ class HostIntegrationCoreApiSetup { createNestedNullableStringChannel.setMessageHandler(nil) } /// Returns passed in arguments of multiple types. - let sendMultipleNullableTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.sendMultipleNullableTypes", binaryMessenger: binaryMessenger, codec: codec) + let sendMultipleNullableTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.sendMultipleNullableTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { sendMultipleNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableBoolArg: Bool? = nilOrValue(args[0]) - let aNullableIntArg: Int64? = isNullish(args[1]) ? nil : (args[1] is Int64? ? args[1] as! Int64? : Int64(args[1] as! Int32)) + let aNullableIntArg: Int64? = + isNullish(args[1]) + ? nil : (args[1] is Int64? ? args[1] as! Int64? : Int64(args[1] as! Int32)) let aNullableStringArg: String? = nilOrValue(args[2]) do { - let result = try api.sendMultipleNullableTypes(aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) + let result = try api.sendMultipleNullableTypes( + aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) reply(wrapResult(result)) } catch { reply(wrapError(error)) @@ -808,11 +893,15 @@ class HostIntegrationCoreApiSetup { sendMultipleNullableTypesChannel.setMessageHandler(nil) } /// Returns passed in int. - let echoNullableIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableInt", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableIntChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aNullableIntArg: Int64? = isNullish(args[0]) ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) + let aNullableIntArg: Int64? = + isNullish(args[0]) + ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) do { let result = try api.echo(aNullableIntArg) reply(wrapResult(result)) @@ -824,7 +913,9 @@ class HostIntegrationCoreApiSetup { echoNullableIntChannel.setMessageHandler(nil) } /// Returns passed in double. - let echoNullableDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableDouble", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableDoubleChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -840,7 +931,9 @@ class HostIntegrationCoreApiSetup { echoNullableDoubleChannel.setMessageHandler(nil) } /// Returns the passed in boolean. - let echoNullableBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableBool", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableBoolChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -856,7 +949,9 @@ class HostIntegrationCoreApiSetup { echoNullableBoolChannel.setMessageHandler(nil) } /// Returns the passed in string. - let echoNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableString", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableStringChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -872,7 +967,10 @@ class HostIntegrationCoreApiSetup { echoNullableStringChannel.setMessageHandler(nil) } /// Returns the passed in Uint8List. - let echoNullableUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableUint8List", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableUint8ListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -888,7 +986,9 @@ class HostIntegrationCoreApiSetup { echoNullableUint8ListChannel.setMessageHandler(nil) } /// Returns the passed in generic Object. - let echoNullableObjectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableObject", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableObjectChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableObject", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -904,7 +1004,9 @@ class HostIntegrationCoreApiSetup { echoNullableObjectChannel.setMessageHandler(nil) } /// Returns the passed list, to test serialization and deserialization. - let echoNullableListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableList", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableListChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -920,7 +1022,9 @@ class HostIntegrationCoreApiSetup { echoNullableListChannel.setMessageHandler(nil) } /// Returns the passed map, to test serialization and deserialization. - let echoNullableMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableMap", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableMapChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -935,7 +1039,9 @@ class HostIntegrationCoreApiSetup { } else { echoNullableMapChannel.setMessageHandler(nil) } - let echoNullableEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableEnum", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableEnumChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -951,11 +1057,16 @@ class HostIntegrationCoreApiSetup { echoNullableEnumChannel.setMessageHandler(nil) } /// Returns passed in int. - let echoOptionalNullableIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoOptionalNullableInt", binaryMessenger: binaryMessenger, codec: codec) + let echoOptionalNullableIntChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoOptionalNullableInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoOptionalNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aNullableIntArg: Int64? = isNullish(args[0]) ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) + let aNullableIntArg: Int64? = + isNullish(args[0]) + ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) do { let result = try api.echoOptional(aNullableIntArg) reply(wrapResult(result)) @@ -967,7 +1078,10 @@ class HostIntegrationCoreApiSetup { echoOptionalNullableIntChannel.setMessageHandler(nil) } /// Returns the passed in string. - let echoNamedNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNamedNullableString", binaryMessenger: binaryMessenger, codec: codec) + let echoNamedNullableStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNamedNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNamedNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -984,15 +1098,17 @@ class HostIntegrationCoreApiSetup { } /// A no-op function taking no arguments and returning no value, to sanity /// test basic asynchronous calling. - let noopAsyncChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.noopAsync", binaryMessenger: binaryMessenger, codec: codec) + let noopAsyncChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.noopAsync", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { noopAsyncChannel.setMessageHandler { _, reply in - api.noopAsync() { result in + api.noopAsync { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1000,17 +1116,19 @@ class HostIntegrationCoreApiSetup { noopAsyncChannel.setMessageHandler(nil) } /// Returns passed in int asynchronously. - let echoAsyncIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncInt", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncIntChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anIntArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) api.echoAsync(anIntArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1018,17 +1136,19 @@ class HostIntegrationCoreApiSetup { echoAsyncIntChannel.setMessageHandler(nil) } /// Returns passed in double asynchronously. - let echoAsyncDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncDouble", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncDoubleChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg = args[0] as! Double api.echoAsync(aDoubleArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1036,17 +1156,19 @@ class HostIntegrationCoreApiSetup { echoAsyncDoubleChannel.setMessageHandler(nil) } /// Returns the passed in boolean asynchronously. - let echoAsyncBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncBool", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncBoolChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg = args[0] as! Bool api.echoAsync(aBoolArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1054,17 +1176,19 @@ class HostIntegrationCoreApiSetup { echoAsyncBoolChannel.setMessageHandler(nil) } /// Returns the passed string asynchronously. - let echoAsyncStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncString", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncStringChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String api.echoAsync(aStringArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1072,17 +1196,19 @@ class HostIntegrationCoreApiSetup { echoAsyncStringChannel.setMessageHandler(nil) } /// Returns the passed in Uint8List asynchronously. - let echoAsyncUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncUint8List", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncUint8ListChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aUint8ListArg = args[0] as! FlutterStandardTypedData api.echoAsync(aUint8ListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1090,17 +1216,19 @@ class HostIntegrationCoreApiSetup { echoAsyncUint8ListChannel.setMessageHandler(nil) } /// Returns the passed in generic Object asynchronously. - let echoAsyncObjectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncObject", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncObjectChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncObject", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anObjectArg = args[0]! api.echoAsync(anObjectArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1108,17 +1236,19 @@ class HostIntegrationCoreApiSetup { echoAsyncObjectChannel.setMessageHandler(nil) } /// Returns the passed list, to test asynchronous serialization and deserialization. - let echoAsyncListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncList", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncListChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as! [Any?] api.echoAsync(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1126,17 +1256,19 @@ class HostIntegrationCoreApiSetup { echoAsyncListChannel.setMessageHandler(nil) } /// Returns the passed map, to test asynchronous serialization and deserialization. - let echoAsyncMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncMap", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncMapChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg = args[0] as! [String?: Any?] api.echoAsync(aMapArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1144,17 +1276,19 @@ class HostIntegrationCoreApiSetup { echoAsyncMapChannel.setMessageHandler(nil) } /// Returns the passed enum, to test asynchronous serialization and deserialization. - let echoAsyncEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncEnum", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncEnumChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anEnumArg = AnEnum(rawValue: args[0] as! Int)! api.echoAsync(anEnumArg) { result in switch result { - case .success(let res): - reply(wrapResult(res.rawValue)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res.rawValue)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1162,15 +1296,17 @@ class HostIntegrationCoreApiSetup { echoAsyncEnumChannel.setMessageHandler(nil) } /// Responds with an error from an async function returning a value. - let throwAsyncErrorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncError", binaryMessenger: binaryMessenger, codec: codec) + let throwAsyncErrorChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncError", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwAsyncErrorChannel.setMessageHandler { _, reply in - api.throwAsyncError() { result in + api.throwAsyncError { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1178,15 +1314,18 @@ class HostIntegrationCoreApiSetup { throwAsyncErrorChannel.setMessageHandler(nil) } /// Responds with an error from an async void function. - let throwAsyncErrorFromVoidChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncErrorFromVoid", binaryMessenger: binaryMessenger, codec: codec) + let throwAsyncErrorFromVoidChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncErrorFromVoid", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwAsyncErrorFromVoidChannel.setMessageHandler { _, reply in - api.throwAsyncErrorFromVoid() { result in + api.throwAsyncErrorFromVoid { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1194,15 +1333,18 @@ class HostIntegrationCoreApiSetup { throwAsyncErrorFromVoidChannel.setMessageHandler(nil) } /// Responds with a Flutter error from an async function returning a value. - let throwAsyncFlutterErrorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncFlutterError", binaryMessenger: binaryMessenger, codec: codec) + let throwAsyncFlutterErrorChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncFlutterError", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwAsyncFlutterErrorChannel.setMessageHandler { _, reply in - api.throwAsyncFlutterError() { result in + api.throwAsyncFlutterError { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1210,17 +1352,19 @@ class HostIntegrationCoreApiSetup { throwAsyncFlutterErrorChannel.setMessageHandler(nil) } /// Returns the passed object, to test async serialization and deserialization. - let echoAsyncAllTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncAllTypes", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncAllTypesChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncAllTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncAllTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg = args[0] as! AllTypes api.echoAsync(everythingArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1228,17 +1372,20 @@ class HostIntegrationCoreApiSetup { echoAsyncAllTypesChannel.setMessageHandler(nil) } /// Returns the passed object, to test serialization and deserialization. - let echoAsyncNullableAllNullableTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableAllNullableTypes", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableAllNullableTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableAllNullableTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableAllNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg: AllNullableTypes? = nilOrValue(args[0]) api.echoAsync(everythingArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1246,17 +1393,22 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableAllNullableTypesChannel.setMessageHandler(nil) } /// Returns passed in int asynchronously. - let echoAsyncNullableIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableInt", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableIntChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let anIntArg: Int64? = isNullish(args[0]) ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) + let anIntArg: Int64? = + isNullish(args[0]) + ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) api.echoAsyncNullable(anIntArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1264,17 +1416,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableIntChannel.setMessageHandler(nil) } /// Returns passed in double asynchronously. - let echoAsyncNullableDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableDouble", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableDoubleChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg: Double? = nilOrValue(args[0]) api.echoAsyncNullable(aDoubleArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1282,17 +1437,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableDoubleChannel.setMessageHandler(nil) } /// Returns the passed in boolean asynchronously. - let echoAsyncNullableBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableBool", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableBoolChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg: Bool? = nilOrValue(args[0]) api.echoAsyncNullable(aBoolArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1300,17 +1458,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableBoolChannel.setMessageHandler(nil) } /// Returns the passed string asynchronously. - let echoAsyncNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableString", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg: String? = nilOrValue(args[0]) api.echoAsyncNullable(aStringArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1318,17 +1479,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableStringChannel.setMessageHandler(nil) } /// Returns the passed in Uint8List asynchronously. - let echoAsyncNullableUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableUint8List", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableUint8ListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aUint8ListArg: FlutterStandardTypedData? = nilOrValue(args[0]) api.echoAsyncNullable(aUint8ListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1336,17 +1500,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableUint8ListChannel.setMessageHandler(nil) } /// Returns the passed in generic Object asynchronously. - let echoAsyncNullableObjectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableObject", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableObjectChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableObject", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anObjectArg: Any? = args[0] api.echoAsyncNullable(anObjectArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1354,17 +1521,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableObjectChannel.setMessageHandler(nil) } /// Returns the passed list, to test asynchronous serialization and deserialization. - let echoAsyncNullableListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableList", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg: [Any?]? = nilOrValue(args[0]) api.echoAsyncNullable(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1372,17 +1542,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableListChannel.setMessageHandler(nil) } /// Returns the passed map, to test asynchronous serialization and deserialization. - let echoAsyncNullableMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableMap", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableMapChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg: [String?: Any?]? = nilOrValue(args[0]) api.echoAsyncNullable(aMapArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1390,387 +1563,459 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableMapChannel.setMessageHandler(nil) } /// Returns the passed enum, to test asynchronous serialization and deserialization. - let echoAsyncNullableEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableEnum", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableEnumChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anEnumArg: AnEnum? = isNullish(args[0]) ? nil : AnEnum(rawValue: args[0] as! Int)! api.echoAsyncNullable(anEnumArg) { result in switch result { - case .success(let res): - reply(wrapResult(res?.rawValue)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res?.rawValue)) + case .failure(let error): + reply(wrapError(error)) } } } } else { echoAsyncNullableEnumChannel.setMessageHandler(nil) } - let callFlutterNoopChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterNoop", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterNoopChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterNoop", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterNoopChannel.setMessageHandler { _, reply in - api.callFlutterNoop() { result in + api.callFlutterNoop { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterNoopChannel.setMessageHandler(nil) } - let callFlutterThrowErrorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterThrowError", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterThrowErrorChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterThrowError", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterThrowErrorChannel.setMessageHandler { _, reply in - api.callFlutterThrowError() { result in + api.callFlutterThrowError { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterThrowErrorChannel.setMessageHandler(nil) } - let callFlutterThrowErrorFromVoidChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterThrowErrorFromVoid", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterThrowErrorFromVoidChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterThrowErrorFromVoid", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterThrowErrorFromVoidChannel.setMessageHandler { _, reply in - api.callFlutterThrowErrorFromVoid() { result in + api.callFlutterThrowErrorFromVoid { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterThrowErrorFromVoidChannel.setMessageHandler(nil) } - let callFlutterEchoAllTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoAllTypes", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoAllTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoAllTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoAllTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg = args[0] as! AllTypes api.callFlutterEcho(everythingArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoAllTypesChannel.setMessageHandler(nil) } - let callFlutterEchoAllNullableTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoAllNullableTypes", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoAllNullableTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoAllNullableTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoAllNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg: AllNullableTypes? = nilOrValue(args[0]) api.callFlutterEcho(everythingArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoAllNullableTypesChannel.setMessageHandler(nil) } - let callFlutterSendMultipleNullableTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterSendMultipleNullableTypes", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterSendMultipleNullableTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterSendMultipleNullableTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterSendMultipleNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableBoolArg: Bool? = nilOrValue(args[0]) - let aNullableIntArg: Int64? = isNullish(args[1]) ? nil : (args[1] is Int64? ? args[1] as! Int64? : Int64(args[1] as! Int32)) + let aNullableIntArg: Int64? = + isNullish(args[1]) + ? nil : (args[1] is Int64? ? args[1] as! Int64? : Int64(args[1] as! Int32)) let aNullableStringArg: String? = nilOrValue(args[2]) - api.callFlutterSendMultipleNullableTypes(aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) { result in + api.callFlutterSendMultipleNullableTypes( + aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg + ) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterSendMultipleNullableTypesChannel.setMessageHandler(nil) } - let callFlutterEchoBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoBool", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoBoolChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg = args[0] as! Bool api.callFlutterEcho(aBoolArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoBoolChannel.setMessageHandler(nil) } - let callFlutterEchoIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoInt", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoIntChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anIntArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) api.callFlutterEcho(anIntArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoIntChannel.setMessageHandler(nil) } - let callFlutterEchoDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoDouble", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoDoubleChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg = args[0] as! Double api.callFlutterEcho(aDoubleArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoDoubleChannel.setMessageHandler(nil) } - let callFlutterEchoStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoString", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String api.callFlutterEcho(aStringArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoStringChannel.setMessageHandler(nil) } - let callFlutterEchoUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoUint8List", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoUint8ListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as! FlutterStandardTypedData api.callFlutterEcho(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoUint8ListChannel.setMessageHandler(nil) } - let callFlutterEchoListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoList", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as! [Any?] api.callFlutterEcho(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoListChannel.setMessageHandler(nil) } - let callFlutterEchoMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoMap", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoMapChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg = args[0] as! [String?: Any?] api.callFlutterEcho(aMapArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoMapChannel.setMessageHandler(nil) } - let callFlutterEchoEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoEnum", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoEnumChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anEnumArg = AnEnum(rawValue: args[0] as! Int)! api.callFlutterEcho(anEnumArg) { result in switch result { - case .success(let res): - reply(wrapResult(res.rawValue)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res.rawValue)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoEnumChannel.setMessageHandler(nil) } - let callFlutterEchoNullableBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableBool", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableBoolChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg: Bool? = nilOrValue(args[0]) api.callFlutterEchoNullable(aBoolArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableBoolChannel.setMessageHandler(nil) } - let callFlutterEchoNullableIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableInt", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableIntChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let anIntArg: Int64? = isNullish(args[0]) ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) + let anIntArg: Int64? = + isNullish(args[0]) + ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) api.callFlutterEchoNullable(anIntArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableIntChannel.setMessageHandler(nil) } - let callFlutterEchoNullableDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableDouble", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableDoubleChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg: Double? = nilOrValue(args[0]) api.callFlutterEchoNullable(aDoubleArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableDoubleChannel.setMessageHandler(nil) } - let callFlutterEchoNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableString", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg: String? = nilOrValue(args[0]) api.callFlutterEchoNullable(aStringArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableStringChannel.setMessageHandler(nil) } - let callFlutterEchoNullableUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableUint8List", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableUint8ListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg: FlutterStandardTypedData? = nilOrValue(args[0]) api.callFlutterEchoNullable(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableUint8ListChannel.setMessageHandler(nil) } - let callFlutterEchoNullableListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableList", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg: [Any?]? = nilOrValue(args[0]) api.callFlutterEchoNullable(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableListChannel.setMessageHandler(nil) } - let callFlutterEchoNullableMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableMap", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableMapChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg: [String?: Any?]? = nilOrValue(args[0]) api.callFlutterEchoNullable(aMapArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableMapChannel.setMessageHandler(nil) } - let callFlutterEchoNullableEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableEnum", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableEnumChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anEnumArg: AnEnum? = isNullish(args[0]) ? nil : AnEnum(rawValue: args[0] as! Int)! api.callFlutterNullableEcho(anEnumArg) { result in switch result { - case .success(let res): - reply(wrapResult(res?.rawValue)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res?.rawValue)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1782,16 +2027,16 @@ class HostIntegrationCoreApiSetup { private class FlutterIntegrationCoreApiCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { - case 128: - return AllClassesWrapper.fromList(self.readValue() as! [Any?]) - case 129: - return AllNullableTypes.fromList(self.readValue() as! [Any?]) - case 130: - return AllTypes.fromList(self.readValue() as! [Any?]) - case 131: - return TestMessage.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) + case 128: + return AllClassesWrapper.fromList(self.readValue() as! [Any?]) + case 129: + return AllNullableTypes.fromList(self.readValue() as! [Any?]) + case 130: + return AllTypes.fromList(self.readValue() as! [Any?]) + case 131: + return TestMessage.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) } } } @@ -1827,7 +2072,8 @@ private class FlutterIntegrationCoreApiCodecReaderWriter: FlutterStandardReaderW } class FlutterIntegrationCoreApiCodec: FlutterStandardMessageCodec { - static let shared = FlutterIntegrationCoreApiCodec(readerWriter: FlutterIntegrationCoreApiCodecReaderWriter()) + static let shared = FlutterIntegrationCoreApiCodec( + readerWriter: FlutterIntegrationCoreApiCodecReaderWriter()) } /// The core interface that the Dart platform_test code implements for host @@ -1843,13 +2089,19 @@ protocol FlutterIntegrationCoreApiProtocol { /// Responds with an error from an async void function. func throwErrorFromVoid(completion: @escaping (Result) -> Void) /// Returns the passed object, to test serialization and deserialization. - func echo(_ everythingArg: AllTypes, completion: @escaping (Result) -> Void) + func echo( + _ everythingArg: AllTypes, completion: @escaping (Result) -> Void) /// Returns the passed object, to test serialization and deserialization. - func echoNullable(_ everythingArg: AllNullableTypes?, completion: @escaping (Result) -> Void) + func echoNullable( + _ everythingArg: AllNullableTypes?, + completion: @escaping (Result) -> Void) /// Returns passed in arguments of multiple types. /// /// Tests multiple-arity FlutterApi handling. - func sendMultipleNullableTypes(aBool aNullableBoolArg: Bool?, anInt aNullableIntArg: Int64?, aString aNullableStringArg: String?, completion: @escaping (Result) -> Void) + func sendMultipleNullableTypes( + aBool aNullableBoolArg: Bool?, anInt aNullableIntArg: Int64?, + aString aNullableStringArg: String?, + completion: @escaping (Result) -> Void) /// Returns the passed boolean, to test serialization and deserialization. func echo(_ aBoolArg: Bool, completion: @escaping (Result) -> Void) /// Returns the passed int, to test serialization and deserialization. @@ -1859,29 +2111,42 @@ protocol FlutterIntegrationCoreApiProtocol { /// Returns the passed string, to test serialization and deserialization. func echo(_ aStringArg: String, completion: @escaping (Result) -> Void) /// Returns the passed byte list, to test serialization and deserialization. - func echo(_ aListArg: FlutterStandardTypedData, completion: @escaping (Result) -> Void) + func echo( + _ aListArg: FlutterStandardTypedData, + completion: @escaping (Result) -> Void) /// Returns the passed list, to test serialization and deserialization. func echo(_ aListArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) /// Returns the passed map, to test serialization and deserialization. - func echo(_ aMapArg: [String?: Any?], completion: @escaping (Result<[String?: Any?], FlutterError>) -> Void) + func echo( + _ aMapArg: [String?: Any?], + completion: @escaping (Result<[String?: Any?], FlutterError>) -> Void) /// Returns the passed enum to test serialization and deserialization. func echo(_ anEnumArg: AnEnum, completion: @escaping (Result) -> Void) /// Returns the passed boolean, to test serialization and deserialization. func echoNullable(_ aBoolArg: Bool?, completion: @escaping (Result) -> Void) /// Returns the passed int, to test serialization and deserialization. - func echoNullable(_ anIntArg: Int64?, completion: @escaping (Result) -> Void) + func echoNullable( + _ anIntArg: Int64?, completion: @escaping (Result) -> Void) /// Returns the passed double, to test serialization and deserialization. - func echoNullable(_ aDoubleArg: Double?, completion: @escaping (Result) -> Void) + func echoNullable( + _ aDoubleArg: Double?, completion: @escaping (Result) -> Void) /// Returns the passed string, to test serialization and deserialization. - func echoNullable(_ aStringArg: String?, completion: @escaping (Result) -> Void) + func echoNullable( + _ aStringArg: String?, completion: @escaping (Result) -> Void) /// Returns the passed byte list, to test serialization and deserialization. - func echoNullable(_ aListArg: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) + func echoNullable( + _ aListArg: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void) /// Returns the passed list, to test serialization and deserialization. - func echoNullable(_ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void) + func echoNullable( + _ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void) /// Returns the passed map, to test serialization and deserialization. - func echoNullable(_ aMapArg: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, FlutterError>) -> Void) + func echoNullable( + _ aMapArg: [String?: Any?]?, + completion: @escaping (Result<[String?: Any?]?, FlutterError>) -> Void) /// Returns the passed enum to test serialization and deserialization. - func echoNullable(_ anEnumArg: AnEnum?, completion: @escaping (Result) -> Void) + func echoNullable( + _ anEnumArg: AnEnum?, completion: @escaping (Result) -> Void) /// A no-op function taking no arguments and returning no value, to sanity /// test basic asynchronous calling. func noopAsync(completion: @escaping (Result) -> Void) @@ -1890,7 +2155,7 @@ protocol FlutterIntegrationCoreApiProtocol { } class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { private let binaryMessenger: FlutterBinaryMessenger - init(binaryMessenger: FlutterBinaryMessenger){ + init(binaryMessenger: FlutterBinaryMessenger) { self.binaryMessenger = binaryMessenger } var codec: FlutterStandardMessageCodec { @@ -1899,18 +2164,20 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { /// A no-op function taking no arguments and returning no value, to sanity /// test basic calling. func noop(completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.noop" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.noop" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage(nil) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { completion(.success(Void())) } @@ -1918,18 +2185,20 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Responds with an error from an async function returning a value. func throwError(completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.throwError" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.throwError" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage(nil) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: Any? = listResponse[0] completion(.success(result)) @@ -1938,39 +2207,49 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Responds with an error from an async void function. func throwErrorFromVoid(completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.throwErrorFromVoid" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.throwErrorFromVoid" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage(nil) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { completion(.success(Void())) } } } /// Returns the passed object, to test serialization and deserialization. - func echo(_ everythingArg: AllTypes, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAllTypes" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echo( + _ everythingArg: AllTypes, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAllTypes" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([everythingArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! AllTypes completion(.success(result)) @@ -1978,19 +2257,24 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed object, to test serialization and deserialization. - func echoNullable(_ everythingArg: AllNullableTypes?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAllNullableTypes" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ everythingArg: AllNullableTypes?, + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAllNullableTypes" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([everythingArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: AllNullableTypes? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2000,21 +2284,32 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { /// Returns passed in arguments of multiple types. /// /// Tests multiple-arity FlutterApi handling. - func sendMultipleNullableTypes(aBool aNullableBoolArg: Bool?, anInt aNullableIntArg: Int64?, aString aNullableStringArg: String?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.sendMultipleNullableTypes" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([aNullableBoolArg, aNullableIntArg, aNullableStringArg] as [Any?]) { response in + func sendMultipleNullableTypes( + aBool aNullableBoolArg: Bool?, anInt aNullableIntArg: Int64?, + aString aNullableStringArg: String?, + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.sendMultipleNullableTypes" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([aNullableBoolArg, aNullableIntArg, aNullableStringArg] as [Any?]) { + response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! AllNullableTypes completion(.success(result)) @@ -2023,20 +2318,26 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed boolean, to test serialization and deserialization. func echo(_ aBoolArg: Bool, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoBool" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoBool" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aBoolArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! Bool completion(.success(result)) @@ -2045,42 +2346,55 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed int, to test serialization and deserialization. func echo(_ anIntArg: Int64, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoInt" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoInt" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anIntArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { - let result = listResponse[0] is Int64 ? listResponse[0] as! Int64 : Int64(listResponse[0] as! Int32) + let result = + listResponse[0] is Int64 ? listResponse[0] as! Int64 : Int64(listResponse[0] as! Int32) completion(.success(result)) } } } /// Returns the passed double, to test serialization and deserialization. func echo(_ aDoubleArg: Double, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoDouble" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoDouble" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aDoubleArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! Double completion(.success(result)) @@ -2089,20 +2403,26 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed string, to test serialization and deserialization. func echo(_ aStringArg: String, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoString" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoString" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! String completion(.success(result)) @@ -2110,21 +2430,30 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed byte list, to test serialization and deserialization. - func echo(_ aListArg: FlutterStandardTypedData, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echo( + _ aListArg: FlutterStandardTypedData, + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! FlutterStandardTypedData completion(.success(result)) @@ -2133,20 +2462,26 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed list, to test serialization and deserialization. func echo(_ aListArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! [Any?] completion(.success(result)) @@ -2154,21 +2489,30 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed map, to test serialization and deserialization. - func echo(_ aMapArg: [String?: Any?], completion: @escaping (Result<[String?: Any?], FlutterError>) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoMap" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echo( + _ aMapArg: [String?: Any?], + completion: @escaping (Result<[String?: Any?], FlutterError>) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoMap" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aMapArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! [String?: Any?] completion(.success(result)) @@ -2177,20 +2521,26 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed enum to test serialization and deserialization. func echo(_ anEnumArg: AnEnum, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoEnum" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoEnum" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anEnumArg.rawValue] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = AnEnum(rawValue: listResponse[0] as! Int)! completion(.success(result)) @@ -2198,19 +2548,22 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed boolean, to test serialization and deserialization. - func echoNullable(_ aBoolArg: Bool?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableBool" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable(_ aBoolArg: Bool?, completion: @escaping (Result) -> Void) + { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableBool" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aBoolArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: Bool? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2218,39 +2571,51 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed int, to test serialization and deserialization. - func echoNullable(_ anIntArg: Int64?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableInt" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ anIntArg: Int64?, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableInt" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anIntArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { - let result: Int64? = isNullish(listResponse[0]) ? nil : (listResponse[0] is Int64? ? listResponse[0] as! Int64? : Int64(listResponse[0] as! Int32)) + let result: Int64? = + isNullish(listResponse[0]) + ? nil + : (listResponse[0] is Int64? + ? listResponse[0] as! Int64? : Int64(listResponse[0] as! Int32)) completion(.success(result)) } } } /// Returns the passed double, to test serialization and deserialization. - func echoNullable(_ aDoubleArg: Double?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableDouble" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ aDoubleArg: Double?, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableDouble" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aDoubleArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: Double? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2258,19 +2623,23 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed string, to test serialization and deserialization. - func echoNullable(_ aStringArg: String?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableString" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ aStringArg: String?, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableString" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: String? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2278,19 +2647,24 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed byte list, to test serialization and deserialization. - func echoNullable(_ aListArg: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableUint8List" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ aListArg: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableUint8List" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: FlutterStandardTypedData? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2298,19 +2672,23 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed list, to test serialization and deserialization. - func echoNullable(_ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: [Any?]? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2318,19 +2696,24 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed map, to test serialization and deserialization. - func echoNullable(_ aMapArg: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, FlutterError>) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableMap" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ aMapArg: [String?: Any?]?, + completion: @escaping (Result<[String?: Any?]?, FlutterError>) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableMap" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aMapArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: [String?: Any?]? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2338,21 +2721,26 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed enum to test serialization and deserialization. - func echoNullable(_ anEnumArg: AnEnum?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableEnum" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ anEnumArg: AnEnum?, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableEnum" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anEnumArg?.rawValue] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { - let result: AnEnum? = isNullish(listResponse[0]) ? nil : AnEnum(rawValue: listResponse[0] as! Int)! + let result: AnEnum? = + isNullish(listResponse[0]) ? nil : AnEnum(rawValue: listResponse[0] as! Int)! completion(.success(result)) } } @@ -2360,39 +2748,48 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { /// A no-op function taking no arguments and returning no value, to sanity /// test basic asynchronous calling. func noopAsync(completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.noopAsync" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.noopAsync" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage(nil) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { completion(.success(Void())) } } } /// Returns the passed in generic Object asynchronously. - func echoAsync(_ aStringArg: String, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAsyncString" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoAsync(_ aStringArg: String, completion: @escaping (Result) -> Void) + { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAsyncString" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! String completion(.success(result)) @@ -2412,7 +2809,9 @@ class HostTrivialApiSetup { /// The codec used by HostTrivialApi. /// Sets up an instance of `HostTrivialApi` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: HostTrivialApi?) { - let noopChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostTrivialApi.noop", binaryMessenger: binaryMessenger) + let noopChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostTrivialApi.noop", + binaryMessenger: binaryMessenger) if let api = api { noopChannel.setMessageHandler { _, reply in do { @@ -2440,32 +2839,36 @@ class HostSmallApiSetup { /// The codec used by HostSmallApi. /// Sets up an instance of `HostSmallApi` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: HostSmallApi?) { - let echoChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostSmallApi.echo", binaryMessenger: binaryMessenger) + let echoChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostSmallApi.echo", + binaryMessenger: binaryMessenger) if let api = api { echoChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String api.echo(aString: aStringArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { echoChannel.setMessageHandler(nil) } - let voidVoidChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostSmallApi.voidVoid", binaryMessenger: binaryMessenger) + let voidVoidChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostSmallApi.voidVoid", + binaryMessenger: binaryMessenger) if let api = api { voidVoidChannel.setMessageHandler { _, reply in - api.voidVoid() { result in + api.voidVoid { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -2477,10 +2880,10 @@ class HostSmallApiSetup { private class FlutterSmallApiCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { - case 128: - return TestMessage.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) + case 128: + return TestMessage.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) } } } @@ -2514,32 +2917,41 @@ class FlutterSmallApiCodec: FlutterStandardMessageCodec { /// /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol FlutterSmallApiProtocol { - func echo(_ msgArg: TestMessage, completion: @escaping (Result) -> Void) + func echo( + _ msgArg: TestMessage, completion: @escaping (Result) -> Void) func echo(_ aStringArg: String, completion: @escaping (Result) -> Void) } class FlutterSmallApi: FlutterSmallApiProtocol { private let binaryMessenger: FlutterBinaryMessenger - init(binaryMessenger: FlutterBinaryMessenger){ + init(binaryMessenger: FlutterBinaryMessenger) { self.binaryMessenger = binaryMessenger } var codec: FlutterStandardMessageCodec { return FlutterSmallApiCodec.shared } - func echo(_ msgArg: TestMessage, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterSmallApi.echoWrappedList" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echo( + _ msgArg: TestMessage, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterSmallApi.echoWrappedList" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([msgArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! TestMessage completion(.success(result)) @@ -2547,20 +2959,26 @@ class FlutterSmallApi: FlutterSmallApiProtocol { } } func echo(_ aStringArg: String, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterSmallApi.echoString" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterSmallApi.echoString" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! String completion(.success(result)) diff --git a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift index 773b6e5c12e..14bcb9a4113 100644 --- a/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift +++ b/packages/pigeon/platform_tests/test_plugin/macos/Classes/CoreTests.gen.swift @@ -1,17 +1,18 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// +// // Autogenerated from Pigeon, do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation + #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #else -#error("Unsupported platform.") + #error("Unsupported platform.") #endif private func wrapResult(_ result: Any?) -> [Any?] { @@ -23,18 +24,20 @@ private func wrapError(_ error: Any) -> [Any?] { return [ flutterError.code, flutterError.message, - flutterError.details + flutterError.details, ] } return [ "\(error)", "\(type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)" + "Stacktrace: \(Thread.callStackSymbols)", ] } private func createConnectionError(withChannelName channelName: String) -> FlutterError { - return FlutterError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") + return FlutterError( + code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", + details: "") } private func isNullish(_ value: Any?) -> Bool { @@ -143,8 +146,10 @@ struct AllNullableTypes { static func fromList(_ list: [Any?]) -> AllNullableTypes? { let aNullableBool: Bool? = nilOrValue(list[0]) - let aNullableInt: Int64? = isNullish(list[1]) ? nil : (list[1] is Int64? ? list[1] as! Int64? : Int64(list[1] as! Int32)) - let aNullableInt64: Int64? = isNullish(list[2]) ? nil : (list[2] is Int64? ? list[2] as! Int64? : Int64(list[2] as! Int32)) + let aNullableInt: Int64? = + isNullish(list[1]) ? nil : (list[1] is Int64? ? list[1] as! Int64? : Int64(list[1] as! Int32)) + let aNullableInt64: Int64? = + isNullish(list[2]) ? nil : (list[2] is Int64? ? list[2] as! Int64? : Int64(list[2] as! Int32)) let aNullableDouble: Double? = nilOrValue(list[3]) let aNullableByteArray: FlutterStandardTypedData? = nilOrValue(list[4]) let aNullable4ByteArray: FlutterStandardTypedData? = nilOrValue(list[5]) @@ -250,7 +255,7 @@ struct TestMessage { } func toList() -> [Any?] { return [ - testList, + testList ] } } @@ -258,16 +263,16 @@ struct TestMessage { private class HostIntegrationCoreApiCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { - case 128: - return AllClassesWrapper.fromList(self.readValue() as! [Any?]) - case 129: - return AllNullableTypes.fromList(self.readValue() as! [Any?]) - case 130: - return AllTypes.fromList(self.readValue() as! [Any?]) - case 131: - return TestMessage.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) + case 128: + return AllClassesWrapper.fromList(self.readValue() as! [Any?]) + case 129: + return AllNullableTypes.fromList(self.readValue() as! [Any?]) + case 130: + return AllTypes.fromList(self.readValue() as! [Any?]) + case 131: + return TestMessage.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) } } } @@ -303,7 +308,8 @@ private class HostIntegrationCoreApiCodecReaderWriter: FlutterStandardReaderWrit } class HostIntegrationCoreApiCodec: FlutterStandardMessageCodec { - static let shared = HostIntegrationCoreApiCodec(readerWriter: HostIntegrationCoreApiCodecReaderWriter()) + static let shared = HostIntegrationCoreApiCodec( + readerWriter: HostIntegrationCoreApiCodecReaderWriter()) } /// The core interface that each host language plugin must implement in @@ -357,7 +363,9 @@ protocol HostIntegrationCoreApi { /// sending of nested objects. func createNestedObject(with nullableString: String?) throws -> AllClassesWrapper /// Returns passed in arguments of multiple types. - func sendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String?) throws -> AllNullableTypes + func sendMultipleNullableTypes( + aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String? + ) throws -> AllNullableTypes /// Returns passed in int. func echo(_ aNullableInt: Int64?) throws -> Int64? /// Returns passed in double. @@ -391,13 +399,16 @@ protocol HostIntegrationCoreApi { /// Returns the passed string asynchronously. func echoAsync(_ aString: String, completion: @escaping (Result) -> Void) /// Returns the passed in Uint8List asynchronously. - func echoAsync(_ aUint8List: FlutterStandardTypedData, completion: @escaping (Result) -> Void) + func echoAsync( + _ aUint8List: FlutterStandardTypedData, + completion: @escaping (Result) -> Void) /// Returns the passed in generic Object asynchronously. func echoAsync(_ anObject: Any, completion: @escaping (Result) -> Void) /// Returns the passed list, to test asynchronous serialization and deserialization. func echoAsync(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) /// Returns the passed map, to test asynchronous serialization and deserialization. - func echoAsync(_ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) + func echoAsync( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) /// Returns the passed enum, to test asynchronous serialization and deserialization. func echoAsync(_ anEnum: AnEnum, completion: @escaping (Result) -> Void) /// Responds with an error from an async function returning a value. @@ -409,7 +420,9 @@ protocol HostIntegrationCoreApi { /// Returns the passed object, to test async serialization and deserialization. func echoAsync(_ everything: AllTypes, completion: @escaping (Result) -> Void) /// Returns the passed object, to test serialization and deserialization. - func echoAsync(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) + func echoAsync( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void) /// Returns passed in int asynchronously. func echoAsyncNullable(_ anInt: Int64?, completion: @escaping (Result) -> Void) /// Returns passed in double asynchronously. @@ -419,37 +432,56 @@ protocol HostIntegrationCoreApi { /// Returns the passed string asynchronously. func echoAsyncNullable(_ aString: String?, completion: @escaping (Result) -> Void) /// Returns the passed in Uint8List asynchronously. - func echoAsyncNullable(_ aUint8List: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) + func echoAsyncNullable( + _ aUint8List: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void) /// Returns the passed in generic Object asynchronously. func echoAsyncNullable(_ anObject: Any?, completion: @escaping (Result) -> Void) /// Returns the passed list, to test asynchronous serialization and deserialization. func echoAsyncNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) /// Returns the passed map, to test asynchronous serialization and deserialization. - func echoAsyncNullable(_ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) + func echoAsyncNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) /// Returns the passed enum, to test asynchronous serialization and deserialization. func echoAsyncNullable(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) func callFlutterNoop(completion: @escaping (Result) -> Void) func callFlutterThrowError(completion: @escaping (Result) -> Void) func callFlutterThrowErrorFromVoid(completion: @escaping (Result) -> Void) - func callFlutterEcho(_ everything: AllTypes, completion: @escaping (Result) -> Void) - func callFlutterEcho(_ everything: AllNullableTypes?, completion: @escaping (Result) -> Void) - func callFlutterSendMultipleNullableTypes(aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String?, completion: @escaping (Result) -> Void) + func callFlutterEcho( + _ everything: AllTypes, completion: @escaping (Result) -> Void) + func callFlutterEcho( + _ everything: AllNullableTypes?, + completion: @escaping (Result) -> Void) + func callFlutterSendMultipleNullableTypes( + aBool aNullableBool: Bool?, anInt aNullableInt: Int64?, aString aNullableString: String?, + completion: @escaping (Result) -> Void) func callFlutterEcho(_ aBool: Bool, completion: @escaping (Result) -> Void) func callFlutterEcho(_ anInt: Int64, completion: @escaping (Result) -> Void) func callFlutterEcho(_ aDouble: Double, completion: @escaping (Result) -> Void) func callFlutterEcho(_ aString: String, completion: @escaping (Result) -> Void) - func callFlutterEcho(_ aList: FlutterStandardTypedData, completion: @escaping (Result) -> Void) + func callFlutterEcho( + _ aList: FlutterStandardTypedData, + completion: @escaping (Result) -> Void) func callFlutterEcho(_ aList: [Any?], completion: @escaping (Result<[Any?], Error>) -> Void) - func callFlutterEcho(_ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) + func callFlutterEcho( + _ aMap: [String?: Any?], completion: @escaping (Result<[String?: Any?], Error>) -> Void) func callFlutterEcho(_ anEnum: AnEnum, completion: @escaping (Result) -> Void) func callFlutterEchoNullable(_ aBool: Bool?, completion: @escaping (Result) -> Void) - func callFlutterEchoNullable(_ anInt: Int64?, completion: @escaping (Result) -> Void) - func callFlutterEchoNullable(_ aDouble: Double?, completion: @escaping (Result) -> Void) - func callFlutterEchoNullable(_ aString: String?, completion: @escaping (Result) -> Void) - func callFlutterEchoNullable(_ aList: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) - func callFlutterEchoNullable(_ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) - func callFlutterEchoNullable(_ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) - func callFlutterNullableEcho(_ anEnum: AnEnum?, completion: @escaping (Result) -> Void) + func callFlutterEchoNullable( + _ anInt: Int64?, completion: @escaping (Result) -> Void) + func callFlutterEchoNullable( + _ aDouble: Double?, completion: @escaping (Result) -> Void) + func callFlutterEchoNullable( + _ aString: String?, completion: @escaping (Result) -> Void) + func callFlutterEchoNullable( + _ aList: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void) + func callFlutterEchoNullable( + _ aList: [Any?]?, completion: @escaping (Result<[Any?]?, Error>) -> Void) + func callFlutterEchoNullable( + _ aMap: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, Error>) -> Void) + func callFlutterNullableEcho( + _ anEnum: AnEnum?, completion: @escaping (Result) -> Void) } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. @@ -460,7 +492,9 @@ class HostIntegrationCoreApiSetup { static func setUp(binaryMessenger: FlutterBinaryMessenger, api: HostIntegrationCoreApi?) { /// A no-op function taking no arguments and returning no value, to sanity /// test basic calling. - let noopChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.noop", binaryMessenger: binaryMessenger, codec: codec) + let noopChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.noop", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { noopChannel.setMessageHandler { _, reply in do { @@ -474,7 +508,9 @@ class HostIntegrationCoreApiSetup { noopChannel.setMessageHandler(nil) } /// Returns the passed object, to test serialization and deserialization. - let echoAllTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAllTypes", binaryMessenger: binaryMessenger, codec: codec) + let echoAllTypesChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAllTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAllTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -490,7 +526,9 @@ class HostIntegrationCoreApiSetup { echoAllTypesChannel.setMessageHandler(nil) } /// Returns an error, to test error handling. - let throwErrorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwError", binaryMessenger: binaryMessenger, codec: codec) + let throwErrorChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwError", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwErrorChannel.setMessageHandler { _, reply in do { @@ -504,7 +542,9 @@ class HostIntegrationCoreApiSetup { throwErrorChannel.setMessageHandler(nil) } /// Returns an error from a void function, to test error handling. - let throwErrorFromVoidChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwErrorFromVoid", binaryMessenger: binaryMessenger, codec: codec) + let throwErrorFromVoidChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwErrorFromVoid", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwErrorFromVoidChannel.setMessageHandler { _, reply in do { @@ -518,7 +558,9 @@ class HostIntegrationCoreApiSetup { throwErrorFromVoidChannel.setMessageHandler(nil) } /// Returns a Flutter error, to test error handling. - let throwFlutterErrorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwFlutterError", binaryMessenger: binaryMessenger, codec: codec) + let throwFlutterErrorChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwFlutterError", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwFlutterErrorChannel.setMessageHandler { _, reply in do { @@ -532,7 +574,9 @@ class HostIntegrationCoreApiSetup { throwFlutterErrorChannel.setMessageHandler(nil) } /// Returns passed in int. - let echoIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoInt", binaryMessenger: binaryMessenger, codec: codec) + let echoIntChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -548,7 +592,9 @@ class HostIntegrationCoreApiSetup { echoIntChannel.setMessageHandler(nil) } /// Returns passed in double. - let echoDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoDouble", binaryMessenger: binaryMessenger, codec: codec) + let echoDoubleChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -564,7 +610,9 @@ class HostIntegrationCoreApiSetup { echoDoubleChannel.setMessageHandler(nil) } /// Returns the passed in boolean. - let echoBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoBool", binaryMessenger: binaryMessenger, codec: codec) + let echoBoolChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -580,7 +628,9 @@ class HostIntegrationCoreApiSetup { echoBoolChannel.setMessageHandler(nil) } /// Returns the passed in string. - let echoStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoString", binaryMessenger: binaryMessenger, codec: codec) + let echoStringChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -596,7 +646,9 @@ class HostIntegrationCoreApiSetup { echoStringChannel.setMessageHandler(nil) } /// Returns the passed in Uint8List. - let echoUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoUint8List", binaryMessenger: binaryMessenger, codec: codec) + let echoUint8ListChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -612,7 +664,9 @@ class HostIntegrationCoreApiSetup { echoUint8ListChannel.setMessageHandler(nil) } /// Returns the passed in generic Object. - let echoObjectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoObject", binaryMessenger: binaryMessenger, codec: codec) + let echoObjectChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoObject", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -628,7 +682,9 @@ class HostIntegrationCoreApiSetup { echoObjectChannel.setMessageHandler(nil) } /// Returns the passed list, to test serialization and deserialization. - let echoListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoList", binaryMessenger: binaryMessenger, codec: codec) + let echoListChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoListChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -644,7 +700,9 @@ class HostIntegrationCoreApiSetup { echoListChannel.setMessageHandler(nil) } /// Returns the passed map, to test serialization and deserialization. - let echoMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoMap", binaryMessenger: binaryMessenger, codec: codec) + let echoMapChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -660,7 +718,9 @@ class HostIntegrationCoreApiSetup { echoMapChannel.setMessageHandler(nil) } /// Returns the passed map to test nested class serialization and deserialization. - let echoClassWrapperChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoClassWrapper", binaryMessenger: binaryMessenger, codec: codec) + let echoClassWrapperChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoClassWrapper", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoClassWrapperChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -676,7 +736,9 @@ class HostIntegrationCoreApiSetup { echoClassWrapperChannel.setMessageHandler(nil) } /// Returns the passed enum to test serialization and deserialization. - let echoEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoEnum", binaryMessenger: binaryMessenger, codec: codec) + let echoEnumChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -692,7 +754,10 @@ class HostIntegrationCoreApiSetup { echoEnumChannel.setMessageHandler(nil) } /// Returns the default string. - let echoNamedDefaultStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNamedDefaultString", binaryMessenger: binaryMessenger, codec: codec) + let echoNamedDefaultStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNamedDefaultString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNamedDefaultStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -708,7 +773,10 @@ class HostIntegrationCoreApiSetup { echoNamedDefaultStringChannel.setMessageHandler(nil) } /// Returns passed in double. - let echoOptionalDefaultDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoOptionalDefaultDouble", binaryMessenger: binaryMessenger, codec: codec) + let echoOptionalDefaultDoubleChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoOptionalDefaultDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoOptionalDefaultDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -724,7 +792,9 @@ class HostIntegrationCoreApiSetup { echoOptionalDefaultDoubleChannel.setMessageHandler(nil) } /// Returns passed in int. - let echoRequiredIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoRequiredInt", binaryMessenger: binaryMessenger, codec: codec) + let echoRequiredIntChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoRequiredInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoRequiredIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -740,7 +810,10 @@ class HostIntegrationCoreApiSetup { echoRequiredIntChannel.setMessageHandler(nil) } /// Returns the passed object, to test serialization and deserialization. - let echoAllNullableTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAllNullableTypes", binaryMessenger: binaryMessenger, codec: codec) + let echoAllNullableTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAllNullableTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAllNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -757,7 +830,10 @@ class HostIntegrationCoreApiSetup { } /// Returns the inner `aString` value from the wrapped object, to test /// sending of nested objects. - let extractNestedNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.extractNestedNullableString", binaryMessenger: binaryMessenger, codec: codec) + let extractNestedNullableStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.extractNestedNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { extractNestedNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -774,7 +850,10 @@ class HostIntegrationCoreApiSetup { } /// Returns the inner `aString` value from the wrapped object, to test /// sending of nested objects. - let createNestedNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.createNestedNullableString", binaryMessenger: binaryMessenger, codec: codec) + let createNestedNullableStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.createNestedNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { createNestedNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -790,15 +869,21 @@ class HostIntegrationCoreApiSetup { createNestedNullableStringChannel.setMessageHandler(nil) } /// Returns passed in arguments of multiple types. - let sendMultipleNullableTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.sendMultipleNullableTypes", binaryMessenger: binaryMessenger, codec: codec) + let sendMultipleNullableTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.sendMultipleNullableTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { sendMultipleNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableBoolArg: Bool? = nilOrValue(args[0]) - let aNullableIntArg: Int64? = isNullish(args[1]) ? nil : (args[1] is Int64? ? args[1] as! Int64? : Int64(args[1] as! Int32)) + let aNullableIntArg: Int64? = + isNullish(args[1]) + ? nil : (args[1] is Int64? ? args[1] as! Int64? : Int64(args[1] as! Int32)) let aNullableStringArg: String? = nilOrValue(args[2]) do { - let result = try api.sendMultipleNullableTypes(aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) + let result = try api.sendMultipleNullableTypes( + aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) reply(wrapResult(result)) } catch { reply(wrapError(error)) @@ -808,11 +893,15 @@ class HostIntegrationCoreApiSetup { sendMultipleNullableTypesChannel.setMessageHandler(nil) } /// Returns passed in int. - let echoNullableIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableInt", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableIntChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aNullableIntArg: Int64? = isNullish(args[0]) ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) + let aNullableIntArg: Int64? = + isNullish(args[0]) + ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) do { let result = try api.echo(aNullableIntArg) reply(wrapResult(result)) @@ -824,7 +913,9 @@ class HostIntegrationCoreApiSetup { echoNullableIntChannel.setMessageHandler(nil) } /// Returns passed in double. - let echoNullableDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableDouble", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableDoubleChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -840,7 +931,9 @@ class HostIntegrationCoreApiSetup { echoNullableDoubleChannel.setMessageHandler(nil) } /// Returns the passed in boolean. - let echoNullableBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableBool", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableBoolChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -856,7 +949,9 @@ class HostIntegrationCoreApiSetup { echoNullableBoolChannel.setMessageHandler(nil) } /// Returns the passed in string. - let echoNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableString", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableStringChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -872,7 +967,10 @@ class HostIntegrationCoreApiSetup { echoNullableStringChannel.setMessageHandler(nil) } /// Returns the passed in Uint8List. - let echoNullableUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableUint8List", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableUint8ListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -888,7 +986,9 @@ class HostIntegrationCoreApiSetup { echoNullableUint8ListChannel.setMessageHandler(nil) } /// Returns the passed in generic Object. - let echoNullableObjectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableObject", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableObjectChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableObject", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -904,7 +1004,9 @@ class HostIntegrationCoreApiSetup { echoNullableObjectChannel.setMessageHandler(nil) } /// Returns the passed list, to test serialization and deserialization. - let echoNullableListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableList", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableListChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -920,7 +1022,9 @@ class HostIntegrationCoreApiSetup { echoNullableListChannel.setMessageHandler(nil) } /// Returns the passed map, to test serialization and deserialization. - let echoNullableMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableMap", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableMapChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -935,7 +1039,9 @@ class HostIntegrationCoreApiSetup { } else { echoNullableMapChannel.setMessageHandler(nil) } - let echoNullableEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableEnum", binaryMessenger: binaryMessenger, codec: codec) + let echoNullableEnumChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNullableEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNullableEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -951,11 +1057,16 @@ class HostIntegrationCoreApiSetup { echoNullableEnumChannel.setMessageHandler(nil) } /// Returns passed in int. - let echoOptionalNullableIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoOptionalNullableInt", binaryMessenger: binaryMessenger, codec: codec) + let echoOptionalNullableIntChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoOptionalNullableInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoOptionalNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let aNullableIntArg: Int64? = isNullish(args[0]) ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) + let aNullableIntArg: Int64? = + isNullish(args[0]) + ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) do { let result = try api.echoOptional(aNullableIntArg) reply(wrapResult(result)) @@ -967,7 +1078,10 @@ class HostIntegrationCoreApiSetup { echoOptionalNullableIntChannel.setMessageHandler(nil) } /// Returns the passed in string. - let echoNamedNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNamedNullableString", binaryMessenger: binaryMessenger, codec: codec) + let echoNamedNullableStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoNamedNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoNamedNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -984,15 +1098,17 @@ class HostIntegrationCoreApiSetup { } /// A no-op function taking no arguments and returning no value, to sanity /// test basic asynchronous calling. - let noopAsyncChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.noopAsync", binaryMessenger: binaryMessenger, codec: codec) + let noopAsyncChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.noopAsync", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { noopAsyncChannel.setMessageHandler { _, reply in - api.noopAsync() { result in + api.noopAsync { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1000,17 +1116,19 @@ class HostIntegrationCoreApiSetup { noopAsyncChannel.setMessageHandler(nil) } /// Returns passed in int asynchronously. - let echoAsyncIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncInt", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncIntChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anIntArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) api.echoAsync(anIntArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1018,17 +1136,19 @@ class HostIntegrationCoreApiSetup { echoAsyncIntChannel.setMessageHandler(nil) } /// Returns passed in double asynchronously. - let echoAsyncDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncDouble", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncDoubleChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg = args[0] as! Double api.echoAsync(aDoubleArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1036,17 +1156,19 @@ class HostIntegrationCoreApiSetup { echoAsyncDoubleChannel.setMessageHandler(nil) } /// Returns the passed in boolean asynchronously. - let echoAsyncBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncBool", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncBoolChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg = args[0] as! Bool api.echoAsync(aBoolArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1054,17 +1176,19 @@ class HostIntegrationCoreApiSetup { echoAsyncBoolChannel.setMessageHandler(nil) } /// Returns the passed string asynchronously. - let echoAsyncStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncString", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncStringChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String api.echoAsync(aStringArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1072,17 +1196,19 @@ class HostIntegrationCoreApiSetup { echoAsyncStringChannel.setMessageHandler(nil) } /// Returns the passed in Uint8List asynchronously. - let echoAsyncUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncUint8List", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncUint8ListChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aUint8ListArg = args[0] as! FlutterStandardTypedData api.echoAsync(aUint8ListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1090,17 +1216,19 @@ class HostIntegrationCoreApiSetup { echoAsyncUint8ListChannel.setMessageHandler(nil) } /// Returns the passed in generic Object asynchronously. - let echoAsyncObjectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncObject", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncObjectChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncObject", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anObjectArg = args[0]! api.echoAsync(anObjectArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1108,17 +1236,19 @@ class HostIntegrationCoreApiSetup { echoAsyncObjectChannel.setMessageHandler(nil) } /// Returns the passed list, to test asynchronous serialization and deserialization. - let echoAsyncListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncList", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncListChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as! [Any?] api.echoAsync(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1126,17 +1256,19 @@ class HostIntegrationCoreApiSetup { echoAsyncListChannel.setMessageHandler(nil) } /// Returns the passed map, to test asynchronous serialization and deserialization. - let echoAsyncMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncMap", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncMapChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg = args[0] as! [String?: Any?] api.echoAsync(aMapArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1144,17 +1276,19 @@ class HostIntegrationCoreApiSetup { echoAsyncMapChannel.setMessageHandler(nil) } /// Returns the passed enum, to test asynchronous serialization and deserialization. - let echoAsyncEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncEnum", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncEnumChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anEnumArg = AnEnum(rawValue: args[0] as! Int)! api.echoAsync(anEnumArg) { result in switch result { - case .success(let res): - reply(wrapResult(res.rawValue)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res.rawValue)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1162,15 +1296,17 @@ class HostIntegrationCoreApiSetup { echoAsyncEnumChannel.setMessageHandler(nil) } /// Responds with an error from an async function returning a value. - let throwAsyncErrorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncError", binaryMessenger: binaryMessenger, codec: codec) + let throwAsyncErrorChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncError", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwAsyncErrorChannel.setMessageHandler { _, reply in - api.throwAsyncError() { result in + api.throwAsyncError { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1178,15 +1314,18 @@ class HostIntegrationCoreApiSetup { throwAsyncErrorChannel.setMessageHandler(nil) } /// Responds with an error from an async void function. - let throwAsyncErrorFromVoidChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncErrorFromVoid", binaryMessenger: binaryMessenger, codec: codec) + let throwAsyncErrorFromVoidChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncErrorFromVoid", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwAsyncErrorFromVoidChannel.setMessageHandler { _, reply in - api.throwAsyncErrorFromVoid() { result in + api.throwAsyncErrorFromVoid { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1194,15 +1333,18 @@ class HostIntegrationCoreApiSetup { throwAsyncErrorFromVoidChannel.setMessageHandler(nil) } /// Responds with a Flutter error from an async function returning a value. - let throwAsyncFlutterErrorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncFlutterError", binaryMessenger: binaryMessenger, codec: codec) + let throwAsyncFlutterErrorChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.throwAsyncFlutterError", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { throwAsyncFlutterErrorChannel.setMessageHandler { _, reply in - api.throwAsyncFlutterError() { result in + api.throwAsyncFlutterError { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1210,17 +1352,19 @@ class HostIntegrationCoreApiSetup { throwAsyncFlutterErrorChannel.setMessageHandler(nil) } /// Returns the passed object, to test async serialization and deserialization. - let echoAsyncAllTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncAllTypes", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncAllTypesChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncAllTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncAllTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg = args[0] as! AllTypes api.echoAsync(everythingArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1228,17 +1372,20 @@ class HostIntegrationCoreApiSetup { echoAsyncAllTypesChannel.setMessageHandler(nil) } /// Returns the passed object, to test serialization and deserialization. - let echoAsyncNullableAllNullableTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableAllNullableTypes", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableAllNullableTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableAllNullableTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableAllNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg: AllNullableTypes? = nilOrValue(args[0]) api.echoAsync(everythingArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1246,17 +1393,22 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableAllNullableTypesChannel.setMessageHandler(nil) } /// Returns passed in int asynchronously. - let echoAsyncNullableIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableInt", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableIntChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let anIntArg: Int64? = isNullish(args[0]) ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) + let anIntArg: Int64? = + isNullish(args[0]) + ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) api.echoAsyncNullable(anIntArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1264,17 +1416,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableIntChannel.setMessageHandler(nil) } /// Returns passed in double asynchronously. - let echoAsyncNullableDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableDouble", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableDoubleChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg: Double? = nilOrValue(args[0]) api.echoAsyncNullable(aDoubleArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1282,17 +1437,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableDoubleChannel.setMessageHandler(nil) } /// Returns the passed in boolean asynchronously. - let echoAsyncNullableBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableBool", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableBoolChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg: Bool? = nilOrValue(args[0]) api.echoAsyncNullable(aBoolArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1300,17 +1458,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableBoolChannel.setMessageHandler(nil) } /// Returns the passed string asynchronously. - let echoAsyncNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableString", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg: String? = nilOrValue(args[0]) api.echoAsyncNullable(aStringArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1318,17 +1479,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableStringChannel.setMessageHandler(nil) } /// Returns the passed in Uint8List asynchronously. - let echoAsyncNullableUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableUint8List", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableUint8ListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aUint8ListArg: FlutterStandardTypedData? = nilOrValue(args[0]) api.echoAsyncNullable(aUint8ListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1336,17 +1500,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableUint8ListChannel.setMessageHandler(nil) } /// Returns the passed in generic Object asynchronously. - let echoAsyncNullableObjectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableObject", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableObjectChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableObject", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableObjectChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anObjectArg: Any? = args[0] api.echoAsyncNullable(anObjectArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1354,17 +1521,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableObjectChannel.setMessageHandler(nil) } /// Returns the passed list, to test asynchronous serialization and deserialization. - let echoAsyncNullableListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableList", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg: [Any?]? = nilOrValue(args[0]) api.echoAsyncNullable(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1372,17 +1542,20 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableListChannel.setMessageHandler(nil) } /// Returns the passed map, to test asynchronous serialization and deserialization. - let echoAsyncNullableMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableMap", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableMapChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg: [String?: Any?]? = nilOrValue(args[0]) api.echoAsyncNullable(aMapArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1390,387 +1563,459 @@ class HostIntegrationCoreApiSetup { echoAsyncNullableMapChannel.setMessageHandler(nil) } /// Returns the passed enum, to test asynchronous serialization and deserialization. - let echoAsyncNullableEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableEnum", binaryMessenger: binaryMessenger, codec: codec) + let echoAsyncNullableEnumChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.echoAsyncNullableEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { echoAsyncNullableEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anEnumArg: AnEnum? = isNullish(args[0]) ? nil : AnEnum(rawValue: args[0] as! Int)! api.echoAsyncNullable(anEnumArg) { result in switch result { - case .success(let res): - reply(wrapResult(res?.rawValue)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res?.rawValue)) + case .failure(let error): + reply(wrapError(error)) } } } } else { echoAsyncNullableEnumChannel.setMessageHandler(nil) } - let callFlutterNoopChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterNoop", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterNoopChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterNoop", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterNoopChannel.setMessageHandler { _, reply in - api.callFlutterNoop() { result in + api.callFlutterNoop { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterNoopChannel.setMessageHandler(nil) } - let callFlutterThrowErrorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterThrowError", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterThrowErrorChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterThrowError", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterThrowErrorChannel.setMessageHandler { _, reply in - api.callFlutterThrowError() { result in + api.callFlutterThrowError { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterThrowErrorChannel.setMessageHandler(nil) } - let callFlutterThrowErrorFromVoidChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterThrowErrorFromVoid", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterThrowErrorFromVoidChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterThrowErrorFromVoid", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterThrowErrorFromVoidChannel.setMessageHandler { _, reply in - api.callFlutterThrowErrorFromVoid() { result in + api.callFlutterThrowErrorFromVoid { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterThrowErrorFromVoidChannel.setMessageHandler(nil) } - let callFlutterEchoAllTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoAllTypes", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoAllTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoAllTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoAllTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg = args[0] as! AllTypes api.callFlutterEcho(everythingArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoAllTypesChannel.setMessageHandler(nil) } - let callFlutterEchoAllNullableTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoAllNullableTypes", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoAllNullableTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoAllNullableTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoAllNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let everythingArg: AllNullableTypes? = nilOrValue(args[0]) api.callFlutterEcho(everythingArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoAllNullableTypesChannel.setMessageHandler(nil) } - let callFlutterSendMultipleNullableTypesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterSendMultipleNullableTypes", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterSendMultipleNullableTypesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterSendMultipleNullableTypes", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterSendMultipleNullableTypesChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aNullableBoolArg: Bool? = nilOrValue(args[0]) - let aNullableIntArg: Int64? = isNullish(args[1]) ? nil : (args[1] is Int64? ? args[1] as! Int64? : Int64(args[1] as! Int32)) + let aNullableIntArg: Int64? = + isNullish(args[1]) + ? nil : (args[1] is Int64? ? args[1] as! Int64? : Int64(args[1] as! Int32)) let aNullableStringArg: String? = nilOrValue(args[2]) - api.callFlutterSendMultipleNullableTypes(aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg) { result in + api.callFlutterSendMultipleNullableTypes( + aBool: aNullableBoolArg, anInt: aNullableIntArg, aString: aNullableStringArg + ) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterSendMultipleNullableTypesChannel.setMessageHandler(nil) } - let callFlutterEchoBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoBool", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoBoolChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg = args[0] as! Bool api.callFlutterEcho(aBoolArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoBoolChannel.setMessageHandler(nil) } - let callFlutterEchoIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoInt", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoIntChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anIntArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) api.callFlutterEcho(anIntArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoIntChannel.setMessageHandler(nil) } - let callFlutterEchoDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoDouble", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoDoubleChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg = args[0] as! Double api.callFlutterEcho(aDoubleArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoDoubleChannel.setMessageHandler(nil) } - let callFlutterEchoStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoString", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String api.callFlutterEcho(aStringArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoStringChannel.setMessageHandler(nil) } - let callFlutterEchoUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoUint8List", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoUint8ListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as! FlutterStandardTypedData api.callFlutterEcho(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoUint8ListChannel.setMessageHandler(nil) } - let callFlutterEchoListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoList", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg = args[0] as! [Any?] api.callFlutterEcho(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoListChannel.setMessageHandler(nil) } - let callFlutterEchoMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoMap", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoMapChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg = args[0] as! [String?: Any?] api.callFlutterEcho(aMapArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoMapChannel.setMessageHandler(nil) } - let callFlutterEchoEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoEnum", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoEnumChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anEnumArg = AnEnum(rawValue: args[0] as! Int)! api.callFlutterEcho(anEnumArg) { result in switch result { - case .success(let res): - reply(wrapResult(res.rawValue)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res.rawValue)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoEnumChannel.setMessageHandler(nil) } - let callFlutterEchoNullableBoolChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableBool", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableBoolChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableBool", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableBoolChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aBoolArg: Bool? = nilOrValue(args[0]) api.callFlutterEchoNullable(aBoolArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableBoolChannel.setMessageHandler(nil) } - let callFlutterEchoNullableIntChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableInt", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableIntChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableInt", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableIntChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let anIntArg: Int64? = isNullish(args[0]) ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) + let anIntArg: Int64? = + isNullish(args[0]) + ? nil : (args[0] is Int64? ? args[0] as! Int64? : Int64(args[0] as! Int32)) api.callFlutterEchoNullable(anIntArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableIntChannel.setMessageHandler(nil) } - let callFlutterEchoNullableDoubleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableDouble", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableDoubleChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableDouble", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableDoubleChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aDoubleArg: Double? = nilOrValue(args[0]) api.callFlutterEchoNullable(aDoubleArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableDoubleChannel.setMessageHandler(nil) } - let callFlutterEchoNullableStringChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableString", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableStringChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableString", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableStringChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg: String? = nilOrValue(args[0]) api.callFlutterEchoNullable(aStringArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableStringChannel.setMessageHandler(nil) } - let callFlutterEchoNullableUint8ListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableUint8List", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableUint8ListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableUint8List", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableUint8ListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg: FlutterStandardTypedData? = nilOrValue(args[0]) api.callFlutterEchoNullable(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableUint8ListChannel.setMessageHandler(nil) } - let callFlutterEchoNullableListChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableList", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableListChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableList", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableListChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aListArg: [Any?]? = nilOrValue(args[0]) api.callFlutterEchoNullable(aListArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableListChannel.setMessageHandler(nil) } - let callFlutterEchoNullableMapChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableMap", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableMapChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableMap", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableMapChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aMapArg: [String?: Any?]? = nilOrValue(args[0]) api.callFlutterEchoNullable(aMapArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { callFlutterEchoNullableMapChannel.setMessageHandler(nil) } - let callFlutterEchoNullableEnumChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableEnum", binaryMessenger: binaryMessenger, codec: codec) + let callFlutterEchoNullableEnumChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.pigeon_integration_tests.HostIntegrationCoreApi.callFlutterEchoNullableEnum", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { callFlutterEchoNullableEnumChannel.setMessageHandler { message, reply in let args = message as! [Any?] let anEnumArg: AnEnum? = isNullish(args[0]) ? nil : AnEnum(rawValue: args[0] as! Int)! api.callFlutterNullableEcho(anEnumArg) { result in switch result { - case .success(let res): - reply(wrapResult(res?.rawValue)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res?.rawValue)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -1782,16 +2027,16 @@ class HostIntegrationCoreApiSetup { private class FlutterIntegrationCoreApiCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { - case 128: - return AllClassesWrapper.fromList(self.readValue() as! [Any?]) - case 129: - return AllNullableTypes.fromList(self.readValue() as! [Any?]) - case 130: - return AllTypes.fromList(self.readValue() as! [Any?]) - case 131: - return TestMessage.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) + case 128: + return AllClassesWrapper.fromList(self.readValue() as! [Any?]) + case 129: + return AllNullableTypes.fromList(self.readValue() as! [Any?]) + case 130: + return AllTypes.fromList(self.readValue() as! [Any?]) + case 131: + return TestMessage.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) } } } @@ -1827,7 +2072,8 @@ private class FlutterIntegrationCoreApiCodecReaderWriter: FlutterStandardReaderW } class FlutterIntegrationCoreApiCodec: FlutterStandardMessageCodec { - static let shared = FlutterIntegrationCoreApiCodec(readerWriter: FlutterIntegrationCoreApiCodecReaderWriter()) + static let shared = FlutterIntegrationCoreApiCodec( + readerWriter: FlutterIntegrationCoreApiCodecReaderWriter()) } /// The core interface that the Dart platform_test code implements for host @@ -1843,13 +2089,19 @@ protocol FlutterIntegrationCoreApiProtocol { /// Responds with an error from an async void function. func throwErrorFromVoid(completion: @escaping (Result) -> Void) /// Returns the passed object, to test serialization and deserialization. - func echo(_ everythingArg: AllTypes, completion: @escaping (Result) -> Void) + func echo( + _ everythingArg: AllTypes, completion: @escaping (Result) -> Void) /// Returns the passed object, to test serialization and deserialization. - func echoNullable(_ everythingArg: AllNullableTypes?, completion: @escaping (Result) -> Void) + func echoNullable( + _ everythingArg: AllNullableTypes?, + completion: @escaping (Result) -> Void) /// Returns passed in arguments of multiple types. /// /// Tests multiple-arity FlutterApi handling. - func sendMultipleNullableTypes(aBool aNullableBoolArg: Bool?, anInt aNullableIntArg: Int64?, aString aNullableStringArg: String?, completion: @escaping (Result) -> Void) + func sendMultipleNullableTypes( + aBool aNullableBoolArg: Bool?, anInt aNullableIntArg: Int64?, + aString aNullableStringArg: String?, + completion: @escaping (Result) -> Void) /// Returns the passed boolean, to test serialization and deserialization. func echo(_ aBoolArg: Bool, completion: @escaping (Result) -> Void) /// Returns the passed int, to test serialization and deserialization. @@ -1859,29 +2111,42 @@ protocol FlutterIntegrationCoreApiProtocol { /// Returns the passed string, to test serialization and deserialization. func echo(_ aStringArg: String, completion: @escaping (Result) -> Void) /// Returns the passed byte list, to test serialization and deserialization. - func echo(_ aListArg: FlutterStandardTypedData, completion: @escaping (Result) -> Void) + func echo( + _ aListArg: FlutterStandardTypedData, + completion: @escaping (Result) -> Void) /// Returns the passed list, to test serialization and deserialization. func echo(_ aListArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) /// Returns the passed map, to test serialization and deserialization. - func echo(_ aMapArg: [String?: Any?], completion: @escaping (Result<[String?: Any?], FlutterError>) -> Void) + func echo( + _ aMapArg: [String?: Any?], + completion: @escaping (Result<[String?: Any?], FlutterError>) -> Void) /// Returns the passed enum to test serialization and deserialization. func echo(_ anEnumArg: AnEnum, completion: @escaping (Result) -> Void) /// Returns the passed boolean, to test serialization and deserialization. func echoNullable(_ aBoolArg: Bool?, completion: @escaping (Result) -> Void) /// Returns the passed int, to test serialization and deserialization. - func echoNullable(_ anIntArg: Int64?, completion: @escaping (Result) -> Void) + func echoNullable( + _ anIntArg: Int64?, completion: @escaping (Result) -> Void) /// Returns the passed double, to test serialization and deserialization. - func echoNullable(_ aDoubleArg: Double?, completion: @escaping (Result) -> Void) + func echoNullable( + _ aDoubleArg: Double?, completion: @escaping (Result) -> Void) /// Returns the passed string, to test serialization and deserialization. - func echoNullable(_ aStringArg: String?, completion: @escaping (Result) -> Void) + func echoNullable( + _ aStringArg: String?, completion: @escaping (Result) -> Void) /// Returns the passed byte list, to test serialization and deserialization. - func echoNullable(_ aListArg: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) + func echoNullable( + _ aListArg: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void) /// Returns the passed list, to test serialization and deserialization. - func echoNullable(_ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void) + func echoNullable( + _ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void) /// Returns the passed map, to test serialization and deserialization. - func echoNullable(_ aMapArg: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, FlutterError>) -> Void) + func echoNullable( + _ aMapArg: [String?: Any?]?, + completion: @escaping (Result<[String?: Any?]?, FlutterError>) -> Void) /// Returns the passed enum to test serialization and deserialization. - func echoNullable(_ anEnumArg: AnEnum?, completion: @escaping (Result) -> Void) + func echoNullable( + _ anEnumArg: AnEnum?, completion: @escaping (Result) -> Void) /// A no-op function taking no arguments and returning no value, to sanity /// test basic asynchronous calling. func noopAsync(completion: @escaping (Result) -> Void) @@ -1890,7 +2155,7 @@ protocol FlutterIntegrationCoreApiProtocol { } class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { private let binaryMessenger: FlutterBinaryMessenger - init(binaryMessenger: FlutterBinaryMessenger){ + init(binaryMessenger: FlutterBinaryMessenger) { self.binaryMessenger = binaryMessenger } var codec: FlutterStandardMessageCodec { @@ -1899,18 +2164,20 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { /// A no-op function taking no arguments and returning no value, to sanity /// test basic calling. func noop(completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.noop" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.noop" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage(nil) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { completion(.success(Void())) } @@ -1918,18 +2185,20 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Responds with an error from an async function returning a value. func throwError(completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.throwError" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.throwError" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage(nil) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: Any? = listResponse[0] completion(.success(result)) @@ -1938,39 +2207,49 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Responds with an error from an async void function. func throwErrorFromVoid(completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.throwErrorFromVoid" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.throwErrorFromVoid" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage(nil) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { completion(.success(Void())) } } } /// Returns the passed object, to test serialization and deserialization. - func echo(_ everythingArg: AllTypes, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAllTypes" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echo( + _ everythingArg: AllTypes, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAllTypes" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([everythingArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! AllTypes completion(.success(result)) @@ -1978,19 +2257,24 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed object, to test serialization and deserialization. - func echoNullable(_ everythingArg: AllNullableTypes?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAllNullableTypes" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ everythingArg: AllNullableTypes?, + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAllNullableTypes" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([everythingArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: AllNullableTypes? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2000,21 +2284,32 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { /// Returns passed in arguments of multiple types. /// /// Tests multiple-arity FlutterApi handling. - func sendMultipleNullableTypes(aBool aNullableBoolArg: Bool?, anInt aNullableIntArg: Int64?, aString aNullableStringArg: String?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.sendMultipleNullableTypes" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) - channel.sendMessage([aNullableBoolArg, aNullableIntArg, aNullableStringArg] as [Any?]) { response in + func sendMultipleNullableTypes( + aBool aNullableBoolArg: Bool?, anInt aNullableIntArg: Int64?, + aString aNullableStringArg: String?, + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.sendMultipleNullableTypes" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([aNullableBoolArg, aNullableIntArg, aNullableStringArg] as [Any?]) { + response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! AllNullableTypes completion(.success(result)) @@ -2023,20 +2318,26 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed boolean, to test serialization and deserialization. func echo(_ aBoolArg: Bool, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoBool" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoBool" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aBoolArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! Bool completion(.success(result)) @@ -2045,42 +2346,55 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed int, to test serialization and deserialization. func echo(_ anIntArg: Int64, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoInt" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoInt" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anIntArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { - let result = listResponse[0] is Int64 ? listResponse[0] as! Int64 : Int64(listResponse[0] as! Int32) + let result = + listResponse[0] is Int64 ? listResponse[0] as! Int64 : Int64(listResponse[0] as! Int32) completion(.success(result)) } } } /// Returns the passed double, to test serialization and deserialization. func echo(_ aDoubleArg: Double, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoDouble" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoDouble" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aDoubleArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! Double completion(.success(result)) @@ -2089,20 +2403,26 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed string, to test serialization and deserialization. func echo(_ aStringArg: String, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoString" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoString" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! String completion(.success(result)) @@ -2110,21 +2430,30 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed byte list, to test serialization and deserialization. - func echo(_ aListArg: FlutterStandardTypedData, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echo( + _ aListArg: FlutterStandardTypedData, + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoUint8List" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! FlutterStandardTypedData completion(.success(result)) @@ -2133,20 +2462,26 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed list, to test serialization and deserialization. func echo(_ aListArg: [Any?], completion: @escaping (Result<[Any?], FlutterError>) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoList" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! [Any?] completion(.success(result)) @@ -2154,21 +2489,30 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed map, to test serialization and deserialization. - func echo(_ aMapArg: [String?: Any?], completion: @escaping (Result<[String?: Any?], FlutterError>) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoMap" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echo( + _ aMapArg: [String?: Any?], + completion: @escaping (Result<[String?: Any?], FlutterError>) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoMap" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aMapArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! [String?: Any?] completion(.success(result)) @@ -2177,20 +2521,26 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } /// Returns the passed enum to test serialization and deserialization. func echo(_ anEnumArg: AnEnum, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoEnum" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoEnum" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anEnumArg.rawValue] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = AnEnum(rawValue: listResponse[0] as! Int)! completion(.success(result)) @@ -2198,19 +2548,22 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed boolean, to test serialization and deserialization. - func echoNullable(_ aBoolArg: Bool?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableBool" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable(_ aBoolArg: Bool?, completion: @escaping (Result) -> Void) + { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableBool" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aBoolArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: Bool? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2218,39 +2571,51 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed int, to test serialization and deserialization. - func echoNullable(_ anIntArg: Int64?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableInt" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ anIntArg: Int64?, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableInt" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anIntArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { - let result: Int64? = isNullish(listResponse[0]) ? nil : (listResponse[0] is Int64? ? listResponse[0] as! Int64? : Int64(listResponse[0] as! Int32)) + let result: Int64? = + isNullish(listResponse[0]) + ? nil + : (listResponse[0] is Int64? + ? listResponse[0] as! Int64? : Int64(listResponse[0] as! Int32)) completion(.success(result)) } } } /// Returns the passed double, to test serialization and deserialization. - func echoNullable(_ aDoubleArg: Double?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableDouble" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ aDoubleArg: Double?, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableDouble" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aDoubleArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: Double? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2258,19 +2623,23 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed string, to test serialization and deserialization. - func echoNullable(_ aStringArg: String?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableString" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ aStringArg: String?, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableString" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: String? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2278,19 +2647,24 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed byte list, to test serialization and deserialization. - func echoNullable(_ aListArg: FlutterStandardTypedData?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableUint8List" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ aListArg: FlutterStandardTypedData?, + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableUint8List" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: FlutterStandardTypedData? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2298,19 +2672,23 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed list, to test serialization and deserialization. - func echoNullable(_ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ aListArg: [Any?]?, completion: @escaping (Result<[Any?]?, FlutterError>) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableList" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aListArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: [Any?]? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2318,19 +2696,24 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed map, to test serialization and deserialization. - func echoNullable(_ aMapArg: [String?: Any?]?, completion: @escaping (Result<[String?: Any?]?, FlutterError>) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableMap" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ aMapArg: [String?: Any?]?, + completion: @escaping (Result<[String?: Any?]?, FlutterError>) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableMap" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aMapArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { let result: [String?: Any?]? = nilOrValue(listResponse[0]) completion(.success(result)) @@ -2338,21 +2721,26 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { } } /// Returns the passed enum to test serialization and deserialization. - func echoNullable(_ anEnumArg: AnEnum?, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableEnum" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoNullable( + _ anEnumArg: AnEnum?, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoNullableEnum" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([anEnumArg?.rawValue] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { - let result: AnEnum? = isNullish(listResponse[0]) ? nil : AnEnum(rawValue: listResponse[0] as! Int)! + let result: AnEnum? = + isNullish(listResponse[0]) ? nil : AnEnum(rawValue: listResponse[0] as! Int)! completion(.success(result)) } } @@ -2360,39 +2748,48 @@ class FlutterIntegrationCoreApi: FlutterIntegrationCoreApiProtocol { /// A no-op function taking no arguments and returning no value, to sanity /// test basic asynchronous calling. func noopAsync(completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.noopAsync" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.noopAsync" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage(nil) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); + completion(.failure(FlutterError(code: code, message: message, details: details))) } else { completion(.success(Void())) } } } /// Returns the passed in generic Object asynchronously. - func echoAsync(_ aStringArg: String, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAsyncString" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echoAsync(_ aStringArg: String, completion: @escaping (Result) -> Void) + { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterIntegrationCoreApi.echoAsyncString" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! String completion(.success(result)) @@ -2412,7 +2809,9 @@ class HostTrivialApiSetup { /// The codec used by HostTrivialApi. /// Sets up an instance of `HostTrivialApi` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: HostTrivialApi?) { - let noopChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostTrivialApi.noop", binaryMessenger: binaryMessenger) + let noopChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostTrivialApi.noop", + binaryMessenger: binaryMessenger) if let api = api { noopChannel.setMessageHandler { _, reply in do { @@ -2440,32 +2839,36 @@ class HostSmallApiSetup { /// The codec used by HostSmallApi. /// Sets up an instance of `HostSmallApi` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: HostSmallApi?) { - let echoChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostSmallApi.echo", binaryMessenger: binaryMessenger) + let echoChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostSmallApi.echo", + binaryMessenger: binaryMessenger) if let api = api { echoChannel.setMessageHandler { message, reply in let args = message as! [Any?] let aStringArg = args[0] as! String api.echo(aString: aStringArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) } } } } else { echoChannel.setMessageHandler(nil) } - let voidVoidChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.pigeon_integration_tests.HostSmallApi.voidVoid", binaryMessenger: binaryMessenger) + let voidVoidChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.pigeon_integration_tests.HostSmallApi.voidVoid", + binaryMessenger: binaryMessenger) if let api = api { voidVoidChannel.setMessageHandler { _, reply in - api.voidVoid() { result in + api.voidVoid { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) } } } @@ -2477,10 +2880,10 @@ class HostSmallApiSetup { private class FlutterSmallApiCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { - case 128: - return TestMessage.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) + case 128: + return TestMessage.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) } } } @@ -2514,32 +2917,41 @@ class FlutterSmallApiCodec: FlutterStandardMessageCodec { /// /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol FlutterSmallApiProtocol { - func echo(_ msgArg: TestMessage, completion: @escaping (Result) -> Void) + func echo( + _ msgArg: TestMessage, completion: @escaping (Result) -> Void) func echo(_ aStringArg: String, completion: @escaping (Result) -> Void) } class FlutterSmallApi: FlutterSmallApiProtocol { private let binaryMessenger: FlutterBinaryMessenger - init(binaryMessenger: FlutterBinaryMessenger){ + init(binaryMessenger: FlutterBinaryMessenger) { self.binaryMessenger = binaryMessenger } var codec: FlutterStandardMessageCodec { return FlutterSmallApiCodec.shared } - func echo(_ msgArg: TestMessage, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterSmallApi.echoWrappedList" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func echo( + _ msgArg: TestMessage, completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterSmallApi.echoWrappedList" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([msgArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! TestMessage completion(.success(result)) @@ -2547,20 +2959,26 @@ class FlutterSmallApi: FlutterSmallApiProtocol { } } func echo(_ aStringArg: String, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.pigeon_integration_tests.FlutterSmallApi.echoString" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + let channelName: String = + "dev.flutter.pigeon.pigeon_integration_tests.FlutterSmallApi.echoString" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([aStringArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { - completion(.failure(createConnectionError(withChannelName:channelName))) + completion(.failure(createConnectionError(withChannelName: channelName))) return } - if (listResponse.count > 1) { + if listResponse.count > 1 { let code: String = listResponse[0] as! String let message: String? = nilOrValue(listResponse[1]) let details: String? = nilOrValue(listResponse[2]) - completion(.failure(FlutterError(code: code, message: message, details: details))); - } else if (listResponse[0] == nil) { - completion(.failure(FlutterError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(FlutterError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion( + .failure( + FlutterError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", details: ""))) } else { let result = listResponse[0] as! String completion(.success(result)) diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index c6029d4ed30..6ac3bb29449 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: 16.0.3 # This must match the version in lib/generator_tools.dart +version: 16.0.4 # This must match the version in lib/generator_tools.dart environment: sdk: ">=3.0.0 <4.0.0" diff --git a/packages/pigeon/test/swift_generator_test.dart b/packages/pigeon/test/swift_generator_test.dart index 4c07b784eb7..b39909be32b 100644 --- a/packages/pigeon/test/swift_generator_test.dart +++ b/packages/pigeon/test/swift_generator_test.dart @@ -52,6 +52,7 @@ void main() { expect(code, contains('var field1: Int64? = nil')); expect(code, contains('static func fromList(_ list: [Any?]) -> Foobar?')); expect(code, contains('func toList() -> [Any?]')); + expect(code, isNot(contains('if ('))); }); test('gen one enum', () { @@ -80,6 +81,7 @@ void main() { expect(code, contains('enum Foobar: Int')); expect(code, contains(' case one = 0')); expect(code, contains(' case two = 1')); + expect(code, isNot(contains('if ('))); }); test('primitive enum host', () { @@ -116,6 +118,7 @@ void main() { final String code = sink.toString(); expect(code, contains('enum Foo: Int')); expect(code, contains('let fooArg = Foo(rawValue: args[0] as! Int)!')); + expect(code, isNot(contains('if ('))); }); test('gen one host api', () { @@ -170,6 +173,7 @@ void main() { expect(code, contains('protocol Api')); expect(code, matches('func doSomething.*Input.*Output')); expect(code, contains('doSomethingChannel.setMessageHandler')); + expect(code, isNot(contains('if ('))); }); test('all the simple datatypes header', () { @@ -298,6 +302,8 @@ void main() { expect(code, contains('class Api')); expect(code, contains('init(binaryMessenger: FlutterBinaryMessenger)')); expect(code, matches('func doSomething.*Input.*Output')); + expect(code, isNot(contains('if ('))); + expect(code, isNot(matches(RegExp(r';$', multiLine: true)))); }); test('gen host void api', () { @@ -339,6 +345,7 @@ void main() { final String code = sink.toString(); expect(code, isNot(matches('.*doSomething(.*) ->'))); expect(code, matches('doSomething(.*)')); + expect(code, isNot(contains('if ('))); }); test('gen flutter void return api', () { @@ -381,6 +388,7 @@ void main() { expect(code, contains('completion: @escaping (Result) -> Void')); expect(code, contains('completion(.success(Void()))')); + expect(code, isNot(contains('if ('))); }); test('gen host void argument api', () { @@ -419,6 +427,7 @@ void main() { expect(code, contains('func doSomething() throws -> Output')); expect(code, contains('let result = try api.doSomething()')); expect(code, contains('reply(wrapResult(result))')); + expect(code, isNot(contains('if ('))); }); test('gen flutter void argument api', () { @@ -459,6 +468,7 @@ void main() { contains( 'func doSomething(completion: @escaping (Result) -> Void)')); expect(code, contains('channel.sendMessage(nil')); + expect(code, isNot(contains('if ('))); }); test('gen list', () { @@ -484,6 +494,7 @@ void main() { final String code = sink.toString(); expect(code, contains('struct Foobar')); expect(code, contains('var field1: [Any?]? = nil')); + expect(code, isNot(contains('if ('))); }); test('gen map', () { @@ -509,6 +520,7 @@ void main() { final String code = sink.toString(); expect(code, contains('struct Foobar')); expect(code, contains('var field1: [AnyHashable: Any?]? = nil')); + expect(code, isNot(contains('if ('))); }); test('gen nested', () { @@ -556,6 +568,9 @@ void main() { expect(code, contains('static func fromList(_ list: [Any?]) -> Outer?')); expect(code, contains('nested = Nested.fromList(nestedList)')); expect(code, contains('func toList() -> [Any?]')); + expect(code, isNot(contains('if ('))); + // Single-element list serializations should not have a trailing comma. + expect(code, matches(RegExp(r'return \[\s*data\s*]'))); }); test('gen one async Host Api', () { @@ -611,6 +626,7 @@ void main() { expect(code, contains('protocol Api')); expect(code, contains('api.doSomething(arg: argArg) { result in')); expect(code, contains('reply(wrapResult(res))')); + expect(code, isNot(contains('if ('))); }); test('gen one async Flutter Api', () { @@ -665,6 +681,7 @@ void main() { final String code = sink.toString(); expect(code, contains('class Api')); expect(code, matches('func doSomething.*Input.*completion.*Output.*Void')); + expect(code, isNot(contains('if ('))); }); test('gen one enum class', () { @@ -705,17 +722,14 @@ void main() { expect(code, contains('enum Enum1: Int')); expect(code, contains('case one = 0')); expect(code, contains('case two = 1')); + expect(code, isNot(contains('if ('))); }); - Iterable makeIterable(String string) sync* { - yield string; - } - test('header', () { final Root root = Root(apis: [], classes: [], enums: []); final StringBuffer sink = StringBuffer(); - final SwiftOptions swiftOptions = SwiftOptions( - copyrightHeader: makeIterable('hello world'), + const SwiftOptions swiftOptions = SwiftOptions( + copyrightHeader: ['hello world', ''], ); const SwiftGenerator generator = SwiftGenerator(); generator.generate( @@ -726,6 +740,8 @@ void main() { ); final String code = sink.toString(); expect(code, startsWith('// hello world')); + // There should be no trailing whitespace on generated comments. + expect(code, isNot(matches(RegExp(r'^//.* $', multiLine: true)))); }); test('generics - list', () { @@ -1522,7 +1538,7 @@ void main() { expect( code, contains( - 'completion(.failure(createConnectionError(withChannelName:channelName)))')); + 'completion(.failure(createConnectionError(withChannelName: channelName)))')); expect( code, contains( diff --git a/packages/pigeon/tool/run_tests.dart b/packages/pigeon/tool/run_tests.dart index 6d663924610..ffcbe78887b 100644 --- a/packages/pigeon/tool/run_tests.dart +++ b/packages/pigeon/tool/run_tests.dart @@ -13,6 +13,7 @@ library; import 'dart:io'; +import 'package:collection/collection.dart'; import 'package:path/path.dart' as p; import 'shared/generation.dart'; @@ -35,62 +36,55 @@ void _validateTestCoverage(List> shards) { } Future _validateGeneratedTestFiles() async { - final String baseDir = p.dirname(p.dirname(Platform.script.toFilePath())); - final String repositoryRoot = p.dirname(p.dirname(baseDir)); - final String relativePigeonPath = p.relative(baseDir, from: repositoryRoot); - - print('Validating generated files:'); - print(' Generating test output...'); - final int generateExitCode = await generateTestPigeons(baseDir: baseDir); - if (generateExitCode != 0) { - print('Generation failed; see above for errors.'); - exit(generateExitCode); - } - - print(' Formatting output...'); - final int formatExitCode = - await formatAllFiles(repositoryRoot: repositoryRoot); - if (formatExitCode != 0) { - print('Formatting failed; see above for errors.'); - exit(formatExitCode); - } + await _validateGeneratedFiles( + (String baseDir) => generateTestPigeons(baseDir: baseDir), + generationMessage: 'Generating test output', + incorrectFilesMessage: + 'The following files are not updated, or not formatted correctly:', + ); +} - print(' Checking for changes...'); - final List modifiedFiles = await _modifiedFiles( - repositoryRoot: repositoryRoot, relativePigeonPath: relativePigeonPath); +Future _validateGeneratedExampleFiles() async { + await _validateGeneratedFiles( + (String _) => generateExamplePigeons(), + generationMessage: 'Generating example output', + incorrectFilesMessage: + 'Either messages.dart and messages_test.dart have non-matching definitions or\n' + 'the following files are not updated, or not formatted correctly:', + ); +} - if (modifiedFiles.isEmpty) { +Future _validateGeneratedFiles( + Future Function(String baseDirectory) generator, { + required String generationMessage, + required String incorrectFilesMessage, +}) async { + // Generated file validation is split by platform, both to avoid duplication + // of work, and to avoid issues if different CI configurations have different + // setups (e.g., different clang-format versions or no clang-format at all). + final Set languagesToValidate; + if (Platform.isLinux) { + languagesToValidate = { + GeneratorLanguage.cpp, + GeneratorLanguage.dart, + GeneratorLanguage.java, + GeneratorLanguage.kotlin, + GeneratorLanguage.objc, + }; + } else if (Platform.isMacOS) { + languagesToValidate = { + GeneratorLanguage.swift, + }; + } else { return; } - print('The following files are not updated, or not formatted correctly:'); - modifiedFiles.map((String line) => ' $line').forEach(print); - - print('\nTo fix run "dart run tool/generate.dart --format" from the pigeon/ ' - 'directory, or apply the diff with the command below.\n'); - - final ProcessResult diffResult = await Process.run( - 'git', - ['diff', relativePigeonPath], - workingDirectory: repositoryRoot, - ); - if (diffResult.exitCode != 0) { - print('Unable to determine diff.'); - exit(1); - } - print('patch -p1 < _validateGeneratedExampleFiles() async { final String baseDir = p.dirname(p.dirname(Platform.script.toFilePath())); final String repositoryRoot = p.dirname(p.dirname(baseDir)); final String relativePigeonPath = p.relative(baseDir, from: repositoryRoot); print('Validating generated files:'); - print(' Generating example output...'); + print(' $generationMessage...'); final int generateExitCode = await generateExamplePigeons(); @@ -100,8 +94,8 @@ Future _validateGeneratedExampleFiles() async { } print(' Formatting output...'); - final int formatExitCode = - await formatAllFiles(repositoryRoot: repositoryRoot); + final int formatExitCode = await formatAllFiles( + repositoryRoot: repositoryRoot, languages: languagesToValidate); if (formatExitCode != 0) { print('Formatting failed; see above for errors.'); exit(formatExitCode); @@ -110,22 +104,26 @@ Future _validateGeneratedExampleFiles() async { print(' Checking for changes...'); final List modifiedFiles = await _modifiedFiles( repositoryRoot: repositoryRoot, relativePigeonPath: relativePigeonPath); - - if (modifiedFiles.isEmpty) { + final Set extensions = languagesToValidate + .map((GeneratorLanguage lang) => _extensionsForLanguage(lang)) + .flattened + .toSet(); + final Iterable filteredFiles = modifiedFiles.where((String path) => + extensions.contains(p.extension(path).replaceFirst('.', ''))); + + if (filteredFiles.isEmpty) { return; } - print( - 'Either messages.dart and messages_test.dart have non-matching definitions or'); - print('the following files are not updated, or not formatted correctly:'); - modifiedFiles.map((String line) => ' $line').forEach(print); + print(incorrectFilesMessage); + filteredFiles.map((String line) => ' $line').forEach(print); print('\nTo fix run "dart run tool/generate.dart --format" from the pigeon/ ' 'directory, or apply the diff with the command below.\n'); final ProcessResult diffResult = await Process.run( 'git', - ['diff', relativePigeonPath], + ['diff', ...filteredFiles], workingDirectory: repositoryRoot, ); if (diffResult.exitCode != 0) { @@ -138,6 +136,17 @@ Future _validateGeneratedExampleFiles() async { exit(1); } +Set _extensionsForLanguage(GeneratorLanguage language) { + return switch (language) { + GeneratorLanguage.cpp => {'cc', 'cpp', 'h'}, + GeneratorLanguage.dart => {'dart'}, + GeneratorLanguage.java => {'java'}, + GeneratorLanguage.kotlin => {'kt'}, + GeneratorLanguage.swift => {'swift'}, + GeneratorLanguage.objc => {'h', 'm', 'mm'}, + }; +} + Future> _modifiedFiles( {required String repositoryRoot, required String relativePigeonPath}) async { @@ -204,20 +213,13 @@ Future main(List args) async { ], ]); - // Ensure that all generated files are up to date. This is run only on Linux - // both to avoid duplication of work, and to avoid issues if different CI - // configurations have different setups (e.g., different clang-format versions - // or no clang-format at all). - if (Platform.isLinux) { - // Only run on master, since Dart format can change between versions. - // TODO(stuartmorgan): Make a more generic way to run this check only on - // master; this currently won't work for anything but Cirrus. - if (Platform.environment['CHANNEL'] == 'stable') { - print('Skipping generated file validation on stable.'); - } else { - await _validateGeneratedTestFiles(); - await _validateGeneratedExampleFiles(); - } + // Ensure that all generated files are up to date. + // Only run on master, since Dart format can change between versions. + if (Platform.environment['CHANNEL'] == 'stable') { + print('Skipping generated file validation on stable.'); + } else { + await _validateGeneratedTestFiles(); + await _validateGeneratedExampleFiles(); } final List testsToRun; diff --git a/packages/pigeon/tool/shared/generation.dart b/packages/pigeon/tool/shared/generation.dart index 1ae5a45edc3..9915e26aa57 100644 --- a/packages/pigeon/tool/shared/generation.dart +++ b/packages/pigeon/tool/shared/generation.dart @@ -10,8 +10,9 @@ import 'package:pigeon/pigeon.dart'; import 'process_utils.dart'; -enum GeneratorLanguages { +enum GeneratorLanguage { cpp, + dart, java, kotlin, objc, @@ -20,8 +21,8 @@ enum GeneratorLanguages { // A map of pigeons/ files to the languages that they can't yet be generated // for due to limitations of that generator. -const Map> _unsupportedFiles = - >{}; +const Map> _unsupportedFiles = + >{}; String _snakeToPascalCase(String snake) { final List parts = snake.split('_'); @@ -77,28 +78,28 @@ Future generateTestPigeons({required String baseDir}) async { for (final String input in inputs) { final String pascalCaseName = _snakeToPascalCase(input); - final Set skipLanguages = - _unsupportedFiles[input] ?? {}; + final Set skipLanguages = + _unsupportedFiles[input] ?? {}; // Generate the default language test plugin output. int generateCode = await runPigeon( input: './pigeons/$input.dart', dartOut: '$sharedDartOutputBase/lib/src/generated/$input.gen.dart', // Android - kotlinOut: skipLanguages.contains(GeneratorLanguages.kotlin) + kotlinOut: skipLanguages.contains(GeneratorLanguage.kotlin) ? null : '$outputBase/android/src/main/kotlin/com/example/test_plugin/$pascalCaseName.gen.kt', kotlinPackage: 'com.example.test_plugin', kotlinErrorClassName: '${pascalCaseName}Error', // iOS - swiftOut: skipLanguages.contains(GeneratorLanguages.swift) + swiftOut: skipLanguages.contains(GeneratorLanguage.swift) ? null : '$outputBase/ios/Classes/$pascalCaseName.gen.swift', // Windows - cppHeaderOut: skipLanguages.contains(GeneratorLanguages.cpp) + cppHeaderOut: skipLanguages.contains(GeneratorLanguage.cpp) ? null : '$outputBase/windows/pigeon/$input.gen.h', - cppSourceOut: skipLanguages.contains(GeneratorLanguages.cpp) + cppSourceOut: skipLanguages.contains(GeneratorLanguage.cpp) ? null : '$outputBase/windows/pigeon/$input.gen.cpp', cppNamespace: '${input}_pigeontest', @@ -114,7 +115,7 @@ Future generateTestPigeons({required String baseDir}) async { // single invocation. generateCode = await runPigeon( input: './pigeons/$input.dart', - swiftOut: skipLanguages.contains(GeneratorLanguages.swift) + swiftOut: skipLanguages.contains(GeneratorLanguage.swift) ? null : '$outputBase/macos/Classes/$pascalCaseName.gen.swift', suppressVersion: true, @@ -130,16 +131,16 @@ Future generateTestPigeons({required String baseDir}) async { // Android // This doesn't use the '.gen' suffix since Java has strict file naming // rules. - javaOut: skipLanguages.contains(GeneratorLanguages.java) + javaOut: skipLanguages.contains(GeneratorLanguage.java) ? null : '$alternateOutputBase/android/src/main/java/com/example/' 'alternate_language_test_plugin/${_javaFilenameForName(input)}.java', javaPackage: 'com.example.alternate_language_test_plugin', // iOS - objcHeaderOut: skipLanguages.contains(GeneratorLanguages.objc) + objcHeaderOut: skipLanguages.contains(GeneratorLanguage.objc) ? null : '$alternateOutputBase/ios/Classes/$pascalCaseName.gen.h', - objcSourceOut: skipLanguages.contains(GeneratorLanguages.objc) + objcSourceOut: skipLanguages.contains(GeneratorLanguage.objc) ? null : '$alternateOutputBase/ios/Classes/$pascalCaseName.gen.m', suppressVersion: true, @@ -154,10 +155,10 @@ Future generateTestPigeons({required String baseDir}) async { // single invocation. generateCode = await runPigeon( input: './pigeons/$input.dart', - objcHeaderOut: skipLanguages.contains(GeneratorLanguages.objc) + objcHeaderOut: skipLanguages.contains(GeneratorLanguage.objc) ? null : '$alternateOutputBase/macos/Classes/$pascalCaseName.gen.h', - objcSourceOut: skipLanguages.contains(GeneratorLanguages.objc) + objcSourceOut: skipLanguages.contains(GeneratorLanguage.objc) ? null : '$alternateOutputBase/macos/Classes/$pascalCaseName.gen.m', suppressVersion: true, @@ -234,7 +235,17 @@ Future runPigeon({ /// This is intended for formatting generated output, but since there's no /// way to filter to specific files in with the repo tooling it runs over the /// entire package. -Future formatAllFiles({required String repositoryRoot}) { +Future formatAllFiles({ + required String repositoryRoot, + Set languages = const { + GeneratorLanguage.cpp, + GeneratorLanguage.dart, + GeneratorLanguage.java, + GeneratorLanguage.kotlin, + GeneratorLanguage.objc, + GeneratorLanguage.swift, + }, +}) { final String dartCommand = Platform.isWindows ? 'dart.exe' : 'dart'; return runProcess( dartCommand, @@ -243,6 +254,27 @@ Future formatAllFiles({required String repositoryRoot}) { 'script/tool/bin/flutter_plugin_tools.dart', 'format', '--packages=pigeon', + if (languages.contains(GeneratorLanguage.cpp) || + languages.contains(GeneratorLanguage.objc)) + '--clang-format' + else + '--no-clang-format', + if (languages.contains(GeneratorLanguage.java)) + '--java' + else + '--no-java', + if (languages.contains(GeneratorLanguage.dart)) + '--dart' + else + '--no-dart', + if (languages.contains(GeneratorLanguage.kotlin)) + '--kotlin' + else + '--no-kotlin', + if (languages.contains(GeneratorLanguage.swift)) + '--swift' + else + '--no-swift', ], workingDirectory: repositoryRoot, streamOutput: false, diff --git a/packages/quick_actions/quick_actions_ios/ios/Classes/messages.g.swift b/packages/quick_actions/quick_actions_ios/ios/Classes/messages.g.swift index 0dec7a61994..ed2b5828085 100644 --- a/packages/quick_actions/quick_actions_ios/ios/Classes/messages.g.swift +++ b/packages/quick_actions/quick_actions_ios/ios/Classes/messages.g.swift @@ -5,12 +5,13 @@ // See also: https://pub.dev/packages/pigeon import Foundation + #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #else -#error("Unsupported platform.") + #error("Unsupported platform.") #endif extension FlutterError: Error {} @@ -28,13 +29,13 @@ private func wrapError(_ error: Any) -> [Any?] { return [ flutterError.code, flutterError.message, - flutterError.details + flutterError.details, ] } return [ "\(error)", "\(type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)" + "Stacktrace: \(Thread.callStackSymbols)", ] } @@ -76,10 +77,10 @@ struct ShortcutItemMessage { private class IOSQuickActionsApiCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { - case 128: - return ShortcutItemMessage.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) + case 128: + return ShortcutItemMessage.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) } } } @@ -124,7 +125,9 @@ class IOSQuickActionsApiSetup { /// Sets up an instance of `IOSQuickActionsApi` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: IOSQuickActionsApi?) { /// Sets the dynamic shortcuts for the app. - let setShortcutItemsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsApi.setShortcutItems", binaryMessenger: binaryMessenger, codec: codec) + let setShortcutItemsChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsApi.setShortcutItems", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { setShortcutItemsChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -140,7 +143,9 @@ class IOSQuickActionsApiSetup { setShortcutItemsChannel.setMessageHandler(nil) } /// Removes all dynamic shortcuts. - let clearShortcutItemsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsApi.clearShortcutItems", binaryMessenger: binaryMessenger, codec: codec) + let clearShortcutItemsChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsApi.clearShortcutItems", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { clearShortcutItemsChannel.setMessageHandler { _, reply in do { @@ -158,16 +163,21 @@ class IOSQuickActionsApiSetup { /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol IOSQuickActionsFlutterApiProtocol { /// Sends a string representing a shortcut from the native platform to the app. - func launchAction(action actionArg: String, completion: @escaping (Result) -> Void) + func launchAction( + action actionArg: String, completion: @escaping (Result) -> Void) } class IOSQuickActionsFlutterApi: IOSQuickActionsFlutterApiProtocol { private let binaryMessenger: FlutterBinaryMessenger - init(binaryMessenger: FlutterBinaryMessenger){ + init(binaryMessenger: FlutterBinaryMessenger) { self.binaryMessenger = binaryMessenger } /// Sends a string representing a shortcut from the native platform to the app. - func launchAction(action actionArg: String, completion: @escaping (Result) -> Void) { - let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsFlutterApi.launchAction", binaryMessenger: binaryMessenger) + func launchAction( + action actionArg: String, completion: @escaping (Result) -> Void + ) { + let channel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.quick_actions_ios.IOSQuickActionsFlutterApi.launchAction", + binaryMessenger: binaryMessenger) channel.sendMessage([actionArg] as [Any?]) { _ in completion(.success(Void())) } diff --git a/packages/rfw/CHANGELOG.md b/packages/rfw/CHANGELOG.md index ae217df2218..99ff72ef28d 100644 --- a/packages/rfw/CHANGELOG.md +++ b/packages/rfw/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.0.18 + +* Exposes `WidgetLibrary`s registered in `Runtime`. +* Exposes widgets map in `LocalWidgetLibrary`. + ## 1.0.17 * Adds support for tracking source locations of `BlobNode`s and diff --git a/packages/rfw/lib/src/flutter/runtime.dart b/packages/rfw/lib/src/flutter/runtime.dart index aabbba4fcde..a610a762ce9 100644 --- a/packages/rfw/lib/src/flutter/runtime.dart +++ b/packages/rfw/lib/src/flutter/runtime.dart @@ -4,10 +4,13 @@ // This file is hand-formatted. +import 'dart:collection'; + import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; -import '../dart/model.dart'; +import '../../formats.dart'; + import 'content.dart'; /// Signature of builders for local widgets. @@ -169,6 +172,22 @@ class LocalWidgetLibrary extends WidgetLibrary { LocalWidgetBuilder? findConstructor(String name) { return _widgets[name]; } + + /// The widgets defined by this [LocalWidgetLibrary]. + /// + /// The returned map is an immutable view of the map provided to the constructor. + /// They keys are the unqualified widget names, and the values are the corresponding + /// [LocalWidgetBuilder]s. + /// + /// The map never changes during the lifetime of the [LocalWidgetLibrary], but a new + /// instance of an [UnmodifiableMapView] is returned each time this getter is used. + /// + /// See also: + /// + /// * [createCoreWidgets], a function that creates a [Map] of local widgets. + UnmodifiableMapView get widgets { + return UnmodifiableMapView(_widgets); + } } class _ResolvedConstructor { @@ -226,6 +245,24 @@ class Runtime extends ChangeNotifier { _clearCache(); } + /// The widget libraries imported in this [Runtime]. + /// + /// The returned map is an immutable view of the map updated by calls to + /// [update] and [clearLibraries]. + /// + /// The keys are instances [LibraryName] which encode fully qualified library + /// names, and the values are the corresponding [WidgetLibrary]s. + /// + /// The returned map is an immutable copy of the registered libraries + /// at the time of this call. + /// + /// See also: + /// + /// * [update] and [clearLibraries], functions that populate this map. + UnmodifiableMapView get libraries { + return UnmodifiableMapView(Map.from(_libraries)); + } + final Map _cachedConstructors = {}; final Map _widgets = {}; diff --git a/packages/rfw/pubspec.yaml b/packages/rfw/pubspec.yaml index 21e215372b5..0d22097d9ec 100644 --- a/packages/rfw/pubspec.yaml +++ b/packages/rfw/pubspec.yaml @@ -2,7 +2,7 @@ name: rfw description: "Remote Flutter widgets: a library for rendering declarative widget description files at runtime." repository: https://github.com/flutter/packages/tree/main/packages/rfw issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+rfw%22 -version: 1.0.17 +version: 1.0.18 environment: sdk: ">=3.0.0 <4.0.0" diff --git a/packages/rfw/test/runtime_test.dart b/packages/rfw/test/runtime_test.dart index 15b2d3c55b2..476c472af95 100644 --- a/packages/rfw/test/runtime_test.dart +++ b/packages/rfw/test/runtime_test.dart @@ -347,6 +347,18 @@ void main() { expect(tester.widget(find.byType(ColoredBox)).color, const Color(0x00000002)); }); + testWidgets('Runtime', (WidgetTester tester) async { + final Runtime runtime = Runtime() + ..update(const LibraryName(['core']), createCoreWidgets()); + expect(runtime.libraries.length, 1); + final LibraryName libraryName = runtime.libraries.entries.first.key; + expect('$libraryName', 'core'); + final WidgetLibrary widgetLibrary = runtime.libraries.entries.first.value; + expect(widgetLibrary, isA()); + widgetLibrary as LocalWidgetLibrary; + expect(widgetLibrary.widgets.length, greaterThan(1)); + }); + testWidgets('Runtime', (WidgetTester tester) async { final Runtime runtime = Runtime() ..update(const LibraryName(['core']), createCoreWidgets()); diff --git a/packages/rfw/test_coverage/bin/test_coverage.dart b/packages/rfw/test_coverage/bin/test_coverage.dart index 392ed70519a..e925d98cd0e 100644 --- a/packages/rfw/test_coverage/bin/test_coverage.dart +++ b/packages/rfw/test_coverage/bin/test_coverage.dart @@ -20,7 +20,7 @@ import 'package:meta/meta.dart'; // Please update these targets when you update this package. // Please ensure that test coverage continues to be 100%. -const int targetLines = 3219; +const int targetLines = 3223; const String targetPercent = '100'; const String lastUpdate = '2023-06-29'; diff --git a/script/tool/lib/src/format_command.dart b/script/tool/lib/src/format_command.dart index aa19bc96af1..f2713666435 100644 --- a/script/tool/lib/src/format_command.dart +++ b/script/tool/lib/src/format_command.dart @@ -54,7 +54,8 @@ class FormatCommand extends PackageCommand { argParser.addFlag(_kotlinArg, help: 'Format Kotlin files', defaultsTo: true); argParser.addFlag(_javaArg, help: 'Format Java files', defaultsTo: true); - argParser.addFlag(_swiftArg, help: 'Format Swift files'); + argParser.addFlag(_swiftArg, + help: 'Format and lint Swift files', defaultsTo: true); argParser.addOption(_clangFormatPathArg, defaultsTo: 'clang-format', help: 'Path to "clang-format" executable.'); argParser.addOption(_javaPathArg, @@ -105,7 +106,7 @@ class FormatCommand extends PackageCommand { await _formatCppAndObjectiveC(files); } if (getBoolArg(_swiftArg)) { - await _formatSwift(files); + await _formatAndLintSwift(files); } if (getBoolArg('fail-on-change')) { @@ -177,16 +178,30 @@ class FormatCommand extends PackageCommand { } } - Future _formatSwift(Iterable files) async { - final String swiftFormat = await _findValidSwiftFormat(); + Future _formatAndLintSwift(Iterable files) async { final Iterable swiftFiles = _getPathsWithExtensions(files, {'.swift'}); if (swiftFiles.isNotEmpty) { + final String swiftFormat = await _findValidSwiftFormat(); print('Formatting .swift files...'); - final int exitCode = + final int formatExitCode = await _runBatched(swiftFormat, ['-i'], files: swiftFiles); - if (exitCode != 0) { - printError('Failed to format Swift files: exit code $exitCode.'); + if (formatExitCode != 0) { + printError('Failed to format Swift files: exit code $formatExitCode.'); + throw ToolExit(_exitSwiftFormatFailed); + } + + print('Linting .swift files...'); + final int lintExitCode = await _runBatched( + swiftFormat, + [ + 'lint', + '--parallel', + '--strict', + ], + files: swiftFiles); + if (lintExitCode != 0) { + printError('Failed to lint Swift files: exit code $lintExitCode.'); throw ToolExit(_exitSwiftFormatFailed); } } diff --git a/script/tool/test/format_command_test.dart b/script/tool/test/format_command_test.dart index 73d1864322a..cc6019862ba 100644 --- a/script/tool/test/format_command_test.dart +++ b/script/tool/test/format_command_test.dart @@ -551,15 +551,29 @@ void main() { processRunner.recordedCalls, orderedEquals([ const ProcessCall( - '/path/to/swift-format', ['--version'], null), + '/path/to/swift-format', + ['--version'], + null, + ), ProcessCall( - '/path/to/swift-format', - ['-i', ...getPackagesDirRelativePaths(plugin, files)], - packagesDir.path), + '/path/to/swift-format', + ['-i', ...getPackagesDirRelativePaths(plugin, files)], + packagesDir.path, + ), + ProcessCall( + '/path/to/swift-format', + [ + 'lint', + '--parallel', + '--strict', + ...getPackagesDirRelativePaths(plugin, files), + ], + packagesDir.path, + ), ])); }); - test('skips Swift if --swift flag is not provided', () async { + test('skips Swift if --no-swift flag is provided', () async { const List files = [ 'macos/foo.swift', ]; @@ -569,7 +583,7 @@ void main() { extraFiles: files, ); - await runCapturingPrint(runner, ['format']); + await runCapturingPrint(runner, ['format', '--no-swift']); expect(processRunner.recordedCalls, orderedEquals([])); }); @@ -601,6 +615,40 @@ void main() { ])); }); + test('fails if swift-format lint fails', () async { + const List files = [ + 'macos/foo.swift', + ]; + createFakePlugin('a_plugin', packagesDir, extraFiles: files); + + processRunner.mockProcessesForExecutable['swift-format'] = + [ + FakeProcessInfo(MockProcess(), + ['--version']), // check for working swift-format + FakeProcessInfo(MockProcess(), ['-i']), + FakeProcessInfo(MockProcess(exitCode: 1), [ + 'lint', + '--parallel', + '--strict', + ]), + ]; + Error? commandError; + final List output = await runCapturingPrint(runner, [ + 'format', + '--swift', + '--swift-format-path=swift-format' + ], errorHandler: (Error e) { + commandError = e; + }); + + expect(commandError, isA()); + expect( + output, + containsAllInOrder([ + contains('Failed to lint Swift files: exit code 1.'), + ])); + }); + test('fails if swift-format fails', () async { const List files = [ 'macos/foo.swift',