diff --git a/packages/pigeon/CHANGELOG.md b/packages/pigeon/CHANGELOG.md index cdebafe869a7..5cb782703f4b 100644 --- a/packages/pigeon/CHANGELOG.md +++ b/packages/pigeon/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.2.6 + +* Fixes bug with parsing documentation comments that start with '/'. + ## 4.2.5 * [dart] Fixes enum parameter handling in Dart test API class. diff --git a/packages/pigeon/lib/generator_tools.dart b/packages/pigeon/lib/generator_tools.dart index 7c988f85b332..23641d39d81c 100644 --- a/packages/pigeon/lib/generator_tools.dart +++ b/packages/pigeon/lib/generator_tools.dart @@ -9,7 +9,7 @@ import 'dart:mirrors'; import 'ast.dart'; /// The current version of pigeon. This must match the version in pubspec.yaml. -const String pigeonVersion = '4.2.5'; +const String pigeonVersion = '4.2.6'; /// Read all the content from [stdin] to a String. String readStdin() { @@ -474,7 +474,10 @@ void addDocumentationComments( indent.writeln(commentSpec.openCommentToken); currentLineOpenToken = commentSpec.blockContinuationToken; } - for (final String line in allComments) { + for (String line in allComments) { + if (line.isNotEmpty && line[0] != ' ') { + line = ' $line'; + } indent.writeln( '$currentLineOpenToken$line', ); diff --git a/packages/pigeon/pigeons/message.dart b/packages/pigeon/pigeons/message.dart index 644031cdab68..83c0ac3d9778 100644 --- a/packages/pigeon/pigeons/message.dart +++ b/packages/pigeon/pigeons/message.dart @@ -20,6 +20,9 @@ import 'package:pigeon/pigeon.dart'; /// This comment is to test enum documentation comments. /// /// This comment also tests multiple line comments. +/////////////////////////// +/// This comment also tests comments that start with '/' +/////////////////////////// enum MessageRequestState { pending, success, diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AllDatatypes.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AllDatatypes.kt new file mode 100644 index 000000000000..6cf2e5bacdb0 --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AllDatatypes.kt @@ -0,0 +1,207 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +/** Generated class from Pigeon that represents data sent in messages. */ +data class Everything ( + val aBool: Boolean? = null, + val anInt: Long? = null, + val aDouble: Double? = null, + val aString: String? = null, + val aByteArray: ByteArray? = null, + val a4ByteArray: IntArray? = null, + val a8ByteArray: LongArray? = null, + val aFloatArray: DoubleArray? = null, + val aList: List? = null, + val aMap: Map? = null, + val nestedList: List?>? = null, + val mapWithAnnotations: Map? = null, + val mapWithObject: Map? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): Everything { + val list = result.first() as List + val aBool = list[0] as? Boolean + val anInt = list[1].let { if (it is Int) it.toLong() else it as? Long } + val aDouble = list[2] as? Double + val aString = list[3] as? String + val aByteArray = list[4] as? ByteArray + val a4ByteArray = list[5] as? IntArray + val a8ByteArray = list[6] as? LongArray + val aFloatArray = list[7] as? DoubleArray + val aList = list[8] as? List + val aMap = list[9] as? Map + val nestedList = list[10] as? List?> + val mapWithAnnotations = list[11] as? Map + val mapWithObject = list[12] as? Map + + return Everything(aBool, anInt, aDouble, aString, aByteArray, a4ByteArray, a8ByteArray, aFloatArray, aList, aMap, nestedList, mapWithAnnotations, mapWithObject) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(aBool) + list.add(anInt) + list.add(aDouble) + list.add(aString) + list.add(aByteArray) + list.add(a4ByteArray) + list.add(a8ByteArray) + list.add(aFloatArray) + list.add(aList) + list.add(aMap) + list.add(nestedList) + list.add(mapWithAnnotations) + list.add(mapWithObject) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object HostEverythingCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + Everything.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is Everything -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface HostEverything { + fun giveMeEverything(): Everything + fun echo(everything: Everything): Everything + + companion object { + /** The codec used by HostEverything. */ + val codec: MessageCodec by lazy { + HostEverythingCodec + } + /** Sets up an instance of `HostEverything` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: HostEverything?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.HostEverything.giveMeEverything", codec) + if (api != null) { + channel.setMessageHandler { _, reply -> + val wrapped = mutableListOf() + try { + wrapped.add(api.giveMeEverything()) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.HostEverything.echo", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val everythingArg = args[0] as Everything + wrapped.add(api.echo(everythingArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +@Suppress("UNCHECKED_CAST") +private object FlutterEverythingCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + Everything.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is Everything -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class FlutterEverything(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by FlutterEverything. */ + val codec: MessageCodec by lazy { + FlutterEverythingCodec + } + } + fun giveMeEverything(callback: (Everything) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.FlutterEverything.giveMeEverything", codec) + channel.send(null) { + val result = it as Everything + callback(result) + } + } + fun echo(everythingArg: Everything, callback: (Everything) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.FlutterEverything.echo", codec) + channel.send(listOf(everythingArg)) { + val result = it as Everything + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AllVoid.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AllVoid.kt new file mode 100644 index 000000000000..6a4389986cef --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AllVoid.kt @@ -0,0 +1,78 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class AllVoidFlutterApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by AllVoidFlutterApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + } + fun doit(callback: () -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.AllVoidFlutterApi.doit", codec) + channel.send(null) { + callback() + } + } +} +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface AllVoidHostApi { + fun doit() + + companion object { + /** The codec used by AllVoidHostApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + /** Sets up an instance of `AllVoidHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: AllVoidHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.AllVoidHostApi.doit", codec) + if (api != null) { + channel.setMessageHandler { _, reply -> + val wrapped = mutableListOf() + try { + api.doit() + wrapped.add(null) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AndroidUnittests.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AndroidUnittests.kt new file mode 100644 index 000000000000..b46507d16ebe --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AndroidUnittests.kt @@ -0,0 +1,216 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +enum class AndroidLoadingState(val raw: Int) { + LOADING(0), + COMPLETE(1); + + companion object { + fun ofRaw(raw: Int): AndroidLoadingState? { + return values().firstOrNull { it.raw == raw } + } + } +} + +/** Generated class from Pigeon that represents data sent in messages. */ +data class AndroidSetRequest ( + val value: Long? = null, + val state: AndroidLoadingState? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): AndroidSetRequest { + val list = result.first() as List + val value = list[0].let { if (it is Int) it.toLong() else it as? Long } + val state: AndroidLoadingState? = (list[1] as? Int)?.let { + AndroidLoadingState.ofRaw(it) + } + + return AndroidSetRequest(value, state) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(value) + list.add(state?.raw) + return mutableListOf>(list) + } +} + +/** Generated class from Pigeon that represents data sent in messages. */ +data class AndroidNestedRequest ( + val context: String? = null, + val request: AndroidSetRequest? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): AndroidNestedRequest { + val list = result.first() as List + val context = list[0] as? String + val request: AndroidSetRequest? = (list[1] as? List)?.let { + AndroidSetRequest.fromList(it) + } + + return AndroidNestedRequest(context, request) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(context) + list.add(request?.toList()) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object AndroidApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + AndroidSetRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is AndroidSetRequest -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface AndroidApi { + fun setValue(request: AndroidSetRequest) + + companion object { + /** The codec used by AndroidApi. */ + val codec: MessageCodec by lazy { + AndroidApiCodec + } + /** Sets up an instance of `AndroidApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: AndroidApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.AndroidApi.setValue", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val requestArg = args[0] as AndroidSetRequest + api.setValue(requestArg) + wrapped.add(null) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +@Suppress("UNCHECKED_CAST") +private object AndroidNestedApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + AndroidNestedRequest.fromList(it) + } + } + 129.toByte() -> { + return (readValue(buffer) as? List)?.let { + AndroidSetRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is AndroidNestedRequest -> { + stream.write(128) + writeValue(stream, value.toList()) + } + is AndroidSetRequest -> { + stream.write(129) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface AndroidNestedApi { + fun setValueWithContext(request: AndroidNestedRequest) + + companion object { + /** The codec used by AndroidNestedApi. */ + val codec: MessageCodec by lazy { + AndroidNestedApiCodec + } + /** Sets up an instance of `AndroidNestedApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: AndroidNestedApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.AndroidNestedApi.setValueWithContext", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val requestArg = args[0] as AndroidNestedRequest + api.setValueWithContext(requestArg) + wrapped.add(null) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AsyncHandlers.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AsyncHandlers.kt new file mode 100644 index 000000000000..d5c223e74b01 --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/AsyncHandlers.kt @@ -0,0 +1,169 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +/** Generated class from Pigeon that represents data sent in messages. */ +data class Value ( + val number: Long? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): Value { + val list = result.first() as List + val number = list[0].let { if (it is Int) it.toLong() else it as? Long } + + return Value(number) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(number) + return mutableListOf>(list) + } +} + +@Suppress("UNCHECKED_CAST") +private object Api2HostCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + Value.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is Value -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface Api2Host { + fun calculate(value: Value, callback: (Value) -> Unit) + fun voidVoid(callback: () -> Unit) + + companion object { + /** The codec used by Api2Host. */ + val codec: MessageCodec by lazy { + Api2HostCodec + } + /** Sets up an instance of `Api2Host` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: Api2Host?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.Api2Host.calculate", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val valueArg = args[0] as Value + api.calculate(valueArg) { + reply.reply(wrapResult(it)) + } + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + reply.reply(wrapped) + + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.Api2Host.voidVoid", codec) + if (api != null) { + channel.setMessageHandler { _, reply -> + val wrapped = mutableListOf() + try { + api.voidVoid() { + reply.reply(null) + } + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + reply.reply(wrapped) + + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +@Suppress("UNCHECKED_CAST") +private object Api2FlutterCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + Value.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is Value -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class Api2Flutter(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by Api2Flutter. */ + val codec: MessageCodec by lazy { + Api2FlutterCodec + } + } + fun calculate(valueArg: Value, callback: (Value) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.Api2Flutter.calculate", codec) + channel.send(listOf(valueArg)) { + val result = it as Value + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/BackgroundPlatformChannels.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/BackgroundPlatformChannels.kt new file mode 100644 index 000000000000..0c898aaa2d12 --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/BackgroundPlatformChannels.kt @@ -0,0 +1,65 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface BackgroundApi2Host { + fun add(x: Long, y: Long): Long + + companion object { + /** The codec used by BackgroundApi2Host. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + /** Sets up an instance of `BackgroundApi2Host` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: BackgroundApi2Host?) { + run { + val taskQueue = binaryMessenger.makeBackgroundTaskQueue() + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.BackgroundApi2Host.add", codec, taskQueue) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val xArg = args[0].let { if (it is Int) it.toLong() else it as Long } + val yArg = args[1].let { if (it is Int) it.toLong() else it as Long } + wrapped.add(api.add(xArg, yArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Enum.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Enum.kt new file mode 100644 index 000000000000..b7606082d976 --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Enum.kt @@ -0,0 +1,177 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +/** This comment is to test enum documentation comments. */ +enum class EnumState(val raw: Int) { + PENDING(0), + SUCCESS(1), + ERROR(2); + + companion object { + fun ofRaw(raw: Int): EnumState? { + return values().firstOrNull { it.raw == raw } + } + } +} + +/** + * This comment is to test class documentation comments. + * + * Generated class from Pigeon that represents data sent in messages. + */ +data class DataWithEnum ( + /** This comment is to test field documentation comments. */ + val state: EnumState? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): DataWithEnum { + val list = result.first() as List + val state: EnumState? = (list[0] as? Int)?.let { + EnumState.ofRaw(it) + } + + return DataWithEnum(state) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(state?.raw) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object EnumApi2HostCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + DataWithEnum.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is DataWithEnum -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** + * This comment is to test api documentation comments. + * + * Generated interface from Pigeon that represents a handler of messages from Flutter. + */ +interface EnumApi2Host { + /** This comment is to test method documentation comments. */ + fun echo(data: DataWithEnum): DataWithEnum + + companion object { + /** The codec used by EnumApi2Host. */ + val codec: MessageCodec by lazy { + EnumApi2HostCodec + } + /** Sets up an instance of `EnumApi2Host` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: EnumApi2Host?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.EnumApi2Host.echo", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val dataArg = args[0] as DataWithEnum + wrapped.add(api.echo(dataArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +@Suppress("UNCHECKED_CAST") +private object EnumApi2FlutterCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + DataWithEnum.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is DataWithEnum -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** + * This comment is to test api documentation comments. + * + * Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. + */ +@Suppress("UNCHECKED_CAST") +class EnumApi2Flutter(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by EnumApi2Flutter. */ + val codec: MessageCodec by lazy { + EnumApi2FlutterCodec + } + } + /** This comment is to test method documentation comments. */ + fun echo(dataArg: DataWithEnum, callback: (DataWithEnum) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.EnumApi2Flutter.echo", codec) + channel.send(listOf(dataArg)) { + val result = it as DataWithEnum + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/EnumArgs.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/EnumArgs.kt new file mode 100644 index 000000000000..87b00f5f78e6 --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/EnumArgs.kt @@ -0,0 +1,76 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +enum class EnumArgsState(val raw: Int) { + PENDING(0), + SUCCESS(1), + ERROR(2); + + companion object { + fun ofRaw(raw: Int): EnumArgsState? { + return values().firstOrNull { it.raw == raw } + } + } +} +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface EnumArgs2Host { + fun foo(state: EnumArgsState) + + companion object { + /** The codec used by EnumArgs2Host. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + /** Sets up an instance of `EnumArgs2Host` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: EnumArgs2Host?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.EnumArgs2Host.foo", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val stateArg = EnumArgsState.ofRaw(args[0] as Int)!! + api.foo(stateArg) + wrapped.add(null) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Host2flutter.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Host2flutter.kt new file mode 100644 index 000000000000..01f998a502b0 --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Host2flutter.kt @@ -0,0 +1,121 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +/** Generated class from Pigeon that represents data sent in messages. */ +data class Host2FlutterSearchRequest ( + val query: String? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): Host2FlutterSearchRequest { + val list = result.first() as List + val query = list[0] as? String + + return Host2FlutterSearchRequest(query) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(query) + return mutableListOf>(list) + } +} + +/** Generated class from Pigeon that represents data sent in messages. */ +data class Host2FlutterSearchReply ( + val result: String? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): Host2FlutterSearchReply { + val list = result.first() as List + val result = list[0] as? String + + return Host2FlutterSearchReply(result) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(result) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object H2FApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + Host2FlutterSearchReply.fromList(it) + } + } + 129.toByte() -> { + return (readValue(buffer) as? List)?.let { + Host2FlutterSearchRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is Host2FlutterSearchReply -> { + stream.write(128) + writeValue(stream, value.toList()) + } + is Host2FlutterSearchRequest -> { + stream.write(129) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class H2FApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by H2FApi. */ + val codec: MessageCodec by lazy { + H2FApiCodec + } + } + fun search(requestArg: Host2FlutterSearchRequest, callback: (Host2FlutterSearchReply) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.H2FApi.search", codec) + channel.send(listOf(requestArg)) { + val result = it as Host2FlutterSearchReply + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/List.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/List.kt new file mode 100644 index 000000000000..3a3c5059a11b --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/List.kt @@ -0,0 +1,148 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +/** Generated class from Pigeon that represents data sent in messages. */ +data class TestMessage ( + val testList: List? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): TestMessage { + val list = result.first() as List + val testList = list[0] as? List + + return TestMessage(testList) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(testList) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object TestApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + TestMessage.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is TestMessage -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface TestApi { + fun test(msg: TestMessage) + + companion object { + /** The codec used by TestApi. */ + val codec: MessageCodec by lazy { + TestApiCodec + } + /** Sets up an instance of `TestApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: TestApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.TestApi.test", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val msgArg = args[0] as TestMessage + api.test(msgArg) + wrapped.add(null) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +@Suppress("UNCHECKED_CAST") +private object EchoApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + TestMessage.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is TestMessage -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class EchoApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by EchoApi. */ + val codec: MessageCodec by lazy { + EchoApiCodec + } + } + fun echo(msgArg: TestMessage, callback: (TestMessage) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.EchoApi.echo", codec) + channel.send(listOf(msgArg)) { + val result = it as TestMessage + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Message.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Message.kt new file mode 100644 index 000000000000..51f68a37ee7c --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Message.kt @@ -0,0 +1,383 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +/** + * This comment is to test enum documentation comments. + * + * This comment also tests multiple line comments. + */ +enum class MessageRequestState(val raw: Int) { + PENDING(0), + SUCCESS(1), + FAILURE(2); + + companion object { + fun ofRaw(raw: Int): MessageRequestState? { + return values().firstOrNull { it.raw == raw } + } + } +} + +/** + * This comment is to test class documentation comments. + * + * This comment also tests multiple line comments. + * + * Generated class from Pigeon that represents data sent in messages. + */ +data class MessageSearchRequest ( + /** This comment is to test field documentation comments. */ + val query: String? = null, + /** This comment is to test field documentation comments. */ + val anInt: Long? = null, + /** This comment is to test field documentation comments. */ + val aBool: Boolean? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): MessageSearchRequest { + val list = result.first() as List + val query = list[0] as? String + val anInt = list[1].let { if (it is Int) it.toLong() else it as? Long } + val aBool = list[2] as? Boolean + + return MessageSearchRequest(query, anInt, aBool) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(query) + list.add(anInt) + list.add(aBool) + return mutableListOf>(list) + } +} + +/** + * This comment is to test class documentation comments. + * + * Generated class from Pigeon that represents data sent in messages. + */ +data class MessageSearchReply ( + /** + * This comment is to test field documentation comments. + * + * This comment also tests multiple line comments. + */ + val result: String? = null, + /** This comment is to test field documentation comments. */ + val error: String? = null, + /** This comment is to test field documentation comments. */ + val state: MessageRequestState? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): MessageSearchReply { + val list = result.first() as List + val result = list[0] as? String + val error = list[1] as? String + val state: MessageRequestState? = (list[2] as? Int)?.let { + MessageRequestState.ofRaw(it) + } + + return MessageSearchReply(result, error, state) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(result) + list.add(error) + list.add(state?.raw) + return mutableListOf>(list) + } +} + +/** + * This comment is to test class documentation comments. + * + * Generated class from Pigeon that represents data sent in messages. + */ +data class MessageNested ( + /** This comment is to test field documentation comments. */ + val request: MessageSearchRequest? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): MessageNested { + val list = result.first() as List + val request: MessageSearchRequest? = (list[0] as? List)?.let { + MessageSearchRequest.fromList(it) + } + + return MessageNested(request) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(request?.toList()) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object MessageApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + MessageSearchReply.fromList(it) + } + } + 129.toByte() -> { + return (readValue(buffer) as? List)?.let { + MessageSearchRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is MessageSearchReply -> { + stream.write(128) + writeValue(stream, value.toList()) + } + is MessageSearchRequest -> { + stream.write(129) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** + * This comment is to test api documentation comments. + * + * This comment also tests multiple line comments. + * + * Generated interface from Pigeon that represents a handler of messages from Flutter. + */ +interface MessageApi { + /** + * This comment is to test documentation comments. + * + * This comment also tests multiple line comments. + */ + fun initialize() + /** This comment is to test method documentation comments. */ + fun search(request: MessageSearchRequest): MessageSearchReply + + companion object { + /** The codec used by MessageApi. */ + val codec: MessageCodec by lazy { + MessageApiCodec + } + /** Sets up an instance of `MessageApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: MessageApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.MessageApi.initialize", codec) + if (api != null) { + channel.setMessageHandler { _, reply -> + val wrapped = mutableListOf() + try { + api.initialize() + wrapped.add(null) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.MessageApi.search", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val requestArg = args[0] as MessageSearchRequest + wrapped.add(api.search(requestArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +@Suppress("UNCHECKED_CAST") +private object MessageNestedApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + MessageNested.fromList(it) + } + } + 129.toByte() -> { + return (readValue(buffer) as? List)?.let { + MessageSearchReply.fromList(it) + } + } + 130.toByte() -> { + return (readValue(buffer) as? List)?.let { + MessageSearchRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is MessageNested -> { + stream.write(128) + writeValue(stream, value.toList()) + } + is MessageSearchReply -> { + stream.write(129) + writeValue(stream, value.toList()) + } + is MessageSearchRequest -> { + stream.write(130) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** + * This comment is to test api documentation comments. + * + * Generated interface from Pigeon that represents a handler of messages from Flutter. + */ +interface MessageNestedApi { + /** + * This comment is to test method documentation comments. + * + * This comment also tests multiple line comments. + */ + fun search(nested: MessageNested): MessageSearchReply + + companion object { + /** The codec used by MessageNestedApi. */ + val codec: MessageCodec by lazy { + MessageNestedApiCodec + } + /** Sets up an instance of `MessageNestedApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: MessageNestedApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.MessageNestedApi.search", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val nestedArg = args[0] as MessageNested + wrapped.add(api.search(nestedArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +@Suppress("UNCHECKED_CAST") +private object MessageFlutterSearchApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + MessageSearchReply.fromList(it) + } + } + 129.toByte() -> { + return (readValue(buffer) as? List)?.let { + MessageSearchRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is MessageSearchReply -> { + stream.write(128) + writeValue(stream, value.toList()) + } + is MessageSearchRequest -> { + stream.write(129) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** + * This comment is to test api documentation comments. + * + * Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. + */ +@Suppress("UNCHECKED_CAST") +class MessageFlutterSearchApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by MessageFlutterSearchApi. */ + val codec: MessageCodec by lazy { + MessageFlutterSearchApiCodec + } + } + /** This comment is to test method documentation comments. */ + fun search(requestArg: MessageSearchRequest, callback: (MessageSearchReply) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.MessageFlutterSearchApi.search", codec) + channel.send(listOf(requestArg)) { + val result = it as MessageSearchReply + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/MultipleArity.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/MultipleArity.kt new file mode 100644 index 000000000000..1032502b9c64 --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/MultipleArity.kt @@ -0,0 +1,81 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface MultipleArityHostApi { + fun subtract(x: Long, y: Long): Long + + companion object { + /** The codec used by MultipleArityHostApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + /** Sets up an instance of `MultipleArityHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: MultipleArityHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.MultipleArityHostApi.subtract", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val xArg = args[0].let { if (it is Int) it.toLong() else it as Long } + val yArg = args[1].let { if (it is Int) it.toLong() else it as Long } + wrapped.add(api.subtract(xArg, yArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class MultipleArityFlutterApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by MultipleArityFlutterApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + } + fun subtract(xArg: Long, yArg: Long, callback: (Long) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.MultipleArityFlutterApi.subtract", codec) + channel.send(listOf(xArg, yArg)) { + val result = it as Long + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/NonNullFields.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/NonNullFields.kt new file mode 100644 index 000000000000..8326e0a78f8f --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/NonNullFields.kt @@ -0,0 +1,250 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +enum class ReplyType(val raw: Int) { + SUCCESS(0), + ERROR(1); + + companion object { + fun ofRaw(raw: Int): ReplyType? { + return values().firstOrNull { it.raw == raw } + } + } +} + +/** Generated class from Pigeon that represents data sent in messages. */ +data class NonNullFieldSearchRequest ( + val query: String + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): NonNullFieldSearchRequest { + val list = result.first() as List + val query = list[0] as String + + return NonNullFieldSearchRequest(query) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(query) + return mutableListOf>(list) + } +} + +/** Generated class from Pigeon that represents data sent in messages. */ +data class ExtraData ( + val detailA: String, + val detailB: String + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): ExtraData { + val list = result.first() as List + val detailA = list[0] as String + val detailB = list[1] as String + + return ExtraData(detailA, detailB) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(detailA) + list.add(detailB) + return mutableListOf>(list) + } +} + +/** Generated class from Pigeon that represents data sent in messages. */ +data class NonNullFieldSearchReply ( + val result: String, + val error: String, + val indices: List, + val extraData: ExtraData, + val type: ReplyType + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): NonNullFieldSearchReply { + val list = result.first() as List + val result = list[0] as String + val error = list[1] as String + val indices = list[2] as List + val extraData = ExtraData.fromList(list[3] as List) + val type = ReplyType.ofRaw(list[4] as Int)!! + return NonNullFieldSearchReply(result, error, indices, extraData, type) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(result) + list.add(error) + list.add(indices) + list.add(extraData?.toList()) + list.add(type?.raw) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object NonNullFieldHostApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + ExtraData.fromList(it) + } + } + 129.toByte() -> { + return (readValue(buffer) as? List)?.let { + NonNullFieldSearchReply.fromList(it) + } + } + 130.toByte() -> { + return (readValue(buffer) as? List)?.let { + NonNullFieldSearchRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is ExtraData -> { + stream.write(128) + writeValue(stream, value.toList()) + } + is NonNullFieldSearchReply -> { + stream.write(129) + writeValue(stream, value.toList()) + } + is NonNullFieldSearchRequest -> { + stream.write(130) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface NonNullFieldHostApi { + fun search(nested: NonNullFieldSearchRequest): NonNullFieldSearchReply + + companion object { + /** The codec used by NonNullFieldHostApi. */ + val codec: MessageCodec by lazy { + NonNullFieldHostApiCodec + } + /** Sets up an instance of `NonNullFieldHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: NonNullFieldHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NonNullFieldHostApi.search", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val nestedArg = args[0] as NonNullFieldSearchRequest + wrapped.add(api.search(nestedArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +@Suppress("UNCHECKED_CAST") +private object NonNullFieldFlutterApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + ExtraData.fromList(it) + } + } + 129.toByte() -> { + return (readValue(buffer) as? List)?.let { + NonNullFieldSearchReply.fromList(it) + } + } + 130.toByte() -> { + return (readValue(buffer) as? List)?.let { + NonNullFieldSearchRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is ExtraData -> { + stream.write(128) + writeValue(stream, value.toList()) + } + is NonNullFieldSearchReply -> { + stream.write(129) + writeValue(stream, value.toList()) + } + is NonNullFieldSearchRequest -> { + stream.write(130) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class NonNullFieldFlutterApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by NonNullFieldFlutterApi. */ + val codec: MessageCodec by lazy { + NonNullFieldFlutterApiCodec + } + } + fun search(requestArg: NonNullFieldSearchRequest, callback: (NonNullFieldSearchReply) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NonNullFieldFlutterApi.search", codec) + channel.send(listOf(requestArg)) { + val result = it as NonNullFieldSearchReply + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/NullFields.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/NullFields.kt new file mode 100644 index 000000000000..5c5ce336b82b --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/NullFields.kt @@ -0,0 +1,216 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +enum class NullFieldsSearchReplyType(val raw: Int) { + SUCCESS(0), + FAILURE(1); + + companion object { + fun ofRaw(raw: Int): NullFieldsSearchReplyType? { + return values().firstOrNull { it.raw == raw } + } + } +} + +/** Generated class from Pigeon that represents data sent in messages. */ +data class NullFieldsSearchRequest ( + val query: String? = null, + val identifier: Long + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): NullFieldsSearchRequest { + val list = result.first() as List + val query = list[0] as? String + val identifier = list[1] as Long + + return NullFieldsSearchRequest(query, identifier) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(query) + list.add(identifier) + return mutableListOf>(list) + } +} + +/** Generated class from Pigeon that represents data sent in messages. */ +data class NullFieldsSearchReply ( + val result: String? = null, + val error: String? = null, + val indices: List? = null, + val request: NullFieldsSearchRequest? = null, + val type: NullFieldsSearchReplyType? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): NullFieldsSearchReply { + val list = result.first() as List + val result = list[0] as? String + val error = list[1] as? String + val indices = list[2] as? List + val request: NullFieldsSearchRequest? = (list[3] as? List)?.let { + NullFieldsSearchRequest.fromList(it) + } + val type: NullFieldsSearchReplyType? = (list[4] as? Int)?.let { + NullFieldsSearchReplyType.ofRaw(it) + } + + return NullFieldsSearchReply(result, error, indices, request, type) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(result) + list.add(error) + list.add(indices) + list.add(request?.toList()) + list.add(type?.raw) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object NullFieldsHostApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + NullFieldsSearchReply.fromList(it) + } + } + 129.toByte() -> { + return (readValue(buffer) as? List)?.let { + NullFieldsSearchRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is NullFieldsSearchReply -> { + stream.write(128) + writeValue(stream, value.toList()) + } + is NullFieldsSearchRequest -> { + stream.write(129) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface NullFieldsHostApi { + fun search(nested: NullFieldsSearchRequest): NullFieldsSearchReply + + companion object { + /** The codec used by NullFieldsHostApi. */ + val codec: MessageCodec by lazy { + NullFieldsHostApiCodec + } + /** Sets up an instance of `NullFieldsHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: NullFieldsHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NullFieldsHostApi.search", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val nestedArg = args[0] as NullFieldsSearchRequest + wrapped.add(api.search(nestedArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +@Suppress("UNCHECKED_CAST") +private object NullFieldsFlutterApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + NullFieldsSearchReply.fromList(it) + } + } + 129.toByte() -> { + return (readValue(buffer) as? List)?.let { + NullFieldsSearchRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is NullFieldsSearchReply -> { + stream.write(128) + writeValue(stream, value.toList()) + } + is NullFieldsSearchRequest -> { + stream.write(129) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class NullFieldsFlutterApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by NullFieldsFlutterApi. */ + val codec: MessageCodec by lazy { + NullFieldsFlutterApiCodec + } + } + fun search(requestArg: NullFieldsSearchRequest, callback: (NullFieldsSearchReply) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NullFieldsFlutterApi.search", codec) + channel.send(listOf(requestArg)) { + val result = it as NullFieldsSearchReply + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/NullableReturns.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/NullableReturns.kt new file mode 100644 index 000000000000..33c0ffb0f019 --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/NullableReturns.kt @@ -0,0 +1,226 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface NullableReturnHostApi { + fun doit(): Long? + + companion object { + /** The codec used by NullableReturnHostApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + /** Sets up an instance of `NullableReturnHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: NullableReturnHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NullableReturnHostApi.doit", codec) + if (api != null) { + channel.setMessageHandler { _, reply -> + val wrapped = mutableListOf() + try { + wrapped.add(api.doit()) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class NullableReturnFlutterApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by NullableReturnFlutterApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + } + fun doit(callback: (Long?) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NullableReturnFlutterApi.doit", codec) + channel.send(null) { + val result = it as? Long? + callback(result) + } + } +} +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface NullableArgHostApi { + fun doit(x: Long?): Long + + companion object { + /** The codec used by NullableArgHostApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + /** Sets up an instance of `NullableArgHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: NullableArgHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NullableArgHostApi.doit", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val xArg = args[0].let { if (it is Int) it.toLong() else it as? Long } + wrapped.add(api.doit(xArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class NullableArgFlutterApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by NullableArgFlutterApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + } + fun doit(xArg: Long?, callback: (Long) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NullableArgFlutterApi.doit", codec) + channel.send(listOf(xArg)) { + val result = it as Long + callback(result) + } + } +} +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface NullableCollectionReturnHostApi { + fun doit(): List? + + companion object { + /** The codec used by NullableCollectionReturnHostApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + /** Sets up an instance of `NullableCollectionReturnHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: NullableCollectionReturnHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NullableCollectionReturnHostApi.doit", codec) + if (api != null) { + channel.setMessageHandler { _, reply -> + val wrapped = mutableListOf() + try { + wrapped.add(api.doit()) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class NullableCollectionReturnFlutterApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by NullableCollectionReturnFlutterApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + } + fun doit(callback: (List?) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NullableCollectionReturnFlutterApi.doit", codec) + channel.send(null) { + val result = it as? List? + callback(result) + } + } +} +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface NullableCollectionArgHostApi { + fun doit(x: List?): List + + companion object { + /** The codec used by NullableCollectionArgHostApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + /** Sets up an instance of `NullableCollectionArgHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: NullableCollectionArgHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NullableCollectionArgHostApi.doit", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val xArg = args[0] as? List + wrapped.add(api.doit(xArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class NullableCollectionArgFlutterApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by NullableCollectionArgFlutterApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + } + fun doit(xArg: List?, callback: (List) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.NullableCollectionArgFlutterApi.doit", codec) + channel.send(listOf(xArg)) { + val result = it as List + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Primitive.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Primitive.kt new file mode 100644 index 000000000000..13259065acca --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Primitive.kt @@ -0,0 +1,288 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface PrimitiveHostApi { + fun anInt(value: Long): Long + fun aBool(value: Boolean): Boolean + fun aString(value: String): String + fun aDouble(value: Double): Double + fun aMap(value: Map): Map + fun aList(value: List): List + fun anInt32List(value: IntArray): IntArray + fun aBoolList(value: List): List + fun aStringIntMap(value: Map): Map + + companion object { + /** The codec used by PrimitiveHostApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + /** Sets up an instance of `PrimitiveHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: PrimitiveHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.anInt", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val valueArg = args[0].let { if (it is Int) it.toLong() else it as Long } + wrapped.add(api.anInt(valueArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aBool", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val valueArg = args[0] as Boolean + wrapped.add(api.aBool(valueArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aString", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val valueArg = args[0] as String + wrapped.add(api.aString(valueArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aDouble", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val valueArg = args[0] as Double + wrapped.add(api.aDouble(valueArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aMap", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val valueArg = args[0] as Map + wrapped.add(api.aMap(valueArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aList", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val valueArg = args[0] as List + wrapped.add(api.aList(valueArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.anInt32List", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val valueArg = args[0] as IntArray + wrapped.add(api.anInt32List(valueArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aBoolList", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val valueArg = args[0] as List + wrapped.add(api.aBoolList(valueArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aStringIntMap", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val valueArg = args[0] as Map + wrapped.add(api.aStringIntMap(valueArg)) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class PrimitiveFlutterApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by PrimitiveFlutterApi. */ + val codec: MessageCodec by lazy { + StandardMessageCodec() + } + } + fun anInt(valueArg: Long, callback: (Long) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.anInt", codec) + channel.send(listOf(valueArg)) { + val result = it as Long + callback(result) + } + } + fun aBool(valueArg: Boolean, callback: (Boolean) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aBool", codec) + channel.send(listOf(valueArg)) { + val result = it as Boolean + callback(result) + } + } + fun aString(valueArg: String, callback: (String) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aString", codec) + channel.send(listOf(valueArg)) { + val result = it as String + callback(result) + } + } + fun aDouble(valueArg: Double, callback: (Double) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aDouble", codec) + channel.send(listOf(valueArg)) { + val result = it as Double + callback(result) + } + } + fun aMap(valueArg: Map, callback: (Map) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aMap", codec) + channel.send(listOf(valueArg)) { + val result = it as Map + callback(result) + } + } + fun aList(valueArg: List, callback: (List) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aList", codec) + channel.send(listOf(valueArg)) { + val result = it as List + callback(result) + } + } + fun anInt32List(valueArg: IntArray, callback: (IntArray) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.anInt32List", codec) + channel.send(listOf(valueArg)) { + val result = it as IntArray + callback(result) + } + } + fun aBoolList(valueArg: List, callback: (List) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aBoolList", codec) + channel.send(listOf(valueArg)) { + val result = it as List + callback(result) + } + } + fun aStringIntMap(valueArg: Map, callback: (Map) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aStringIntMap", codec) + channel.send(listOf(valueArg)) { + val result = it as Map + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/VoidArgFlutter.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/VoidArgFlutter.kt new file mode 100644 index 000000000000..b7006ae433fc --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/VoidArgFlutter.kt @@ -0,0 +1,91 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +/** Generated class from Pigeon that represents data sent in messages. */ +data class VoidArgFlutterResult ( + val code: Long? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): VoidArgFlutterResult { + val list = result.first() as List + val code = list[0].let { if (it is Int) it.toLong() else it as? Long } + + return VoidArgFlutterResult(code) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(code) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object VoidArgApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + VoidArgFlutterResult.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is VoidArgFlutterResult -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class VoidArgApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by VoidArgApi. */ + val codec: MessageCodec by lazy { + VoidArgApiCodec + } + } + fun getCode(callback: (VoidArgFlutterResult) -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.VoidArgApi.getCode", codec) + channel.send(null) { + val result = it as VoidArgFlutterResult + callback(result) + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/VoidArgHost.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/VoidArgHost.kt new file mode 100644 index 000000000000..8486d09e0185 --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/VoidArgHost.kt @@ -0,0 +1,105 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +/** Generated class from Pigeon that represents data sent in messages. */ +data class VoidArgHostResult ( + val code: Long? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): VoidArgHostResult { + val list = result.first() as List + val code = list[0].let { if (it is Int) it.toLong() else it as? Long } + + return VoidArgHostResult(code) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(code) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object VoidArgHostApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + VoidArgHostResult.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is VoidArgHostResult -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface VoidArgHostApi { + fun getCode(): VoidArgHostResult + + companion object { + /** The codec used by VoidArgHostApi. */ + val codec: MessageCodec by lazy { + VoidArgHostApiCodec + } + /** Sets up an instance of `VoidArgHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: VoidArgHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.VoidArgHostApi.getCode", codec) + if (api != null) { + channel.setMessageHandler { _, reply -> + val wrapped = mutableListOf() + try { + wrapped.add(api.getCode()) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Voidflutter.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Voidflutter.kt new file mode 100644 index 000000000000..c9578042bae7 --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Voidflutter.kt @@ -0,0 +1,90 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +/** Generated class from Pigeon that represents data sent in messages. */ +data class VoidFlutterSetRequest ( + val value: Long? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): VoidFlutterSetRequest { + val list = result.first() as List + val value = list[0].let { if (it is Int) it.toLong() else it as? Long } + + return VoidFlutterSetRequest(value) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(value) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object VoidFlutterApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + VoidFlutterSetRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is VoidFlutterSetRequest -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */ +@Suppress("UNCHECKED_CAST") +class VoidFlutterApi(private val binaryMessenger: BinaryMessenger) { + companion object { + /** The codec used by VoidFlutterApi. */ + val codec: MessageCodec by lazy { + VoidFlutterApiCodec + } + } + fun setValue(requestArg: VoidFlutterSetRequest, callback: () -> Unit) { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.VoidFlutterApi.setValue", codec) + channel.send(listOf(requestArg)) { + callback() + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Voidhost.kt b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Voidhost.kt new file mode 100644 index 000000000000..90820e20390e --- /dev/null +++ b/packages/pigeon/platform_tests/android_kotlin_unit_tests/android/app/src/main/kotlin/com/example/android_kotlin_unit_tests/Voidhost.kt @@ -0,0 +1,108 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_kotlin_unit_tests + +import android.util.Log +import io.flutter.plugin.common.BasicMessageChannel +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.MessageCodec +import io.flutter.plugin.common.StandardMessageCodec +import java.io.ByteArrayOutputStream +import java.nio.ByteBuffer + +/** Generated class from Pigeon. */ + +/** Generated class from Pigeon that represents data sent in messages. */ +data class VoidHostSetRequest ( + val value: Long? = null + +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(result: List): VoidHostSetRequest { + val list = result.first() as List + val value = list[0].let { if (it is Int) it.toLong() else it as? Long } + + return VoidHostSetRequest(value) + } + } + fun toList(): MutableList> { + val list = mutableListOf() + list.add(value) + return mutableListOf>(list) + } +} +@Suppress("UNCHECKED_CAST") +private object VoidHostApiCodec : StandardMessageCodec() { + override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { + return when (type) { + 128.toByte() -> { + return (readValue(buffer) as? List)?.let { + VoidHostSetRequest.fromList(it) + } + } + else -> super.readValueOfType(type, buffer) + } + } + override fun writeValue(stream: ByteArrayOutputStream, value: Any?) { + when (value) { + is VoidHostSetRequest -> { + stream.write(128) + writeValue(stream, value.toList()) + } + else -> super.writeValue(stream, value) + } + } +} + +/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ +interface VoidHostApi { + fun setValue(request: VoidHostSetRequest) + + companion object { + /** The codec used by VoidHostApi. */ + val codec: MessageCodec by lazy { + VoidHostApiCodec + } + /** Sets up an instance of `VoidHostApi` to handle messages through the `binaryMessenger`. */ + @Suppress("UNCHECKED_CAST") + fun setUp(binaryMessenger: BinaryMessenger, api: VoidHostApi?) { + run { + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.VoidHostApi.setValue", codec) + if (api != null) { + channel.setMessageHandler { message, reply -> + val wrapped = mutableListOf() + try { + val args = message as List + val requestArg = args[0] as VoidHostSetRequest + api.setValue(requestArg) + wrapped.add(null) + } catch (exception: Error) { + wrapped.add(wrapError(exception)) + + reply.reply(wrapped) + } + }} else { + channel.setMessageHandler(null) + } + } + } + } +} + +private fun wrapResult(result: Any?): List { + return listOf(result) +} + +private fun wrapError(exception: Throwable): List { + return listOf( + exception.javaClass.simpleName, + exception.toString(), + "Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) + ) +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/AllDatatypes.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/AllDatatypes.java new file mode 100644 index 000000000000..e2df289888c9 --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/AllDatatypes.java @@ -0,0 +1,502 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class AllDatatypes { + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class Everything { + private @Nullable Boolean aBool; + + public @Nullable Boolean getABool() { + return aBool; + } + + public void setABool(@Nullable Boolean setterArg) { + this.aBool = setterArg; + } + + private @Nullable Long anInt; + + public @Nullable Long getAnInt() { + return anInt; + } + + public void setAnInt(@Nullable Long setterArg) { + this.anInt = setterArg; + } + + private @Nullable Double aDouble; + + public @Nullable Double getADouble() { + return aDouble; + } + + public void setADouble(@Nullable Double setterArg) { + this.aDouble = setterArg; + } + + private @Nullable String aString; + + public @Nullable String getAString() { + return aString; + } + + public void setAString(@Nullable String setterArg) { + this.aString = setterArg; + } + + private @Nullable byte[] aByteArray; + + public @Nullable byte[] getAByteArray() { + return aByteArray; + } + + public void setAByteArray(@Nullable byte[] setterArg) { + this.aByteArray = setterArg; + } + + private @Nullable int[] a4ByteArray; + + public @Nullable int[] getA4ByteArray() { + return a4ByteArray; + } + + public void setA4ByteArray(@Nullable int[] setterArg) { + this.a4ByteArray = setterArg; + } + + private @Nullable long[] a8ByteArray; + + public @Nullable long[] getA8ByteArray() { + return a8ByteArray; + } + + public void setA8ByteArray(@Nullable long[] setterArg) { + this.a8ByteArray = setterArg; + } + + private @Nullable double[] aFloatArray; + + public @Nullable double[] getAFloatArray() { + return aFloatArray; + } + + public void setAFloatArray(@Nullable double[] setterArg) { + this.aFloatArray = setterArg; + } + + private @Nullable List aList; + + public @Nullable List getAList() { + return aList; + } + + public void setAList(@Nullable List setterArg) { + this.aList = setterArg; + } + + private @Nullable Map aMap; + + public @Nullable Map getAMap() { + return aMap; + } + + public void setAMap(@Nullable Map setterArg) { + this.aMap = setterArg; + } + + private @Nullable List> nestedList; + + public @Nullable List> getNestedList() { + return nestedList; + } + + public void setNestedList(@Nullable List> setterArg) { + this.nestedList = setterArg; + } + + private @Nullable Map mapWithAnnotations; + + public @Nullable Map getMapWithAnnotations() { + return mapWithAnnotations; + } + + public void setMapWithAnnotations(@Nullable Map setterArg) { + this.mapWithAnnotations = setterArg; + } + + private @Nullable Map mapWithObject; + + public @Nullable Map getMapWithObject() { + return mapWithObject; + } + + public void setMapWithObject(@Nullable Map setterArg) { + this.mapWithObject = setterArg; + } + + public static final class Builder { + private @Nullable Boolean aBool; + + public @NonNull Builder setABool(@Nullable Boolean setterArg) { + this.aBool = setterArg; + return this; + } + + private @Nullable Long anInt; + + public @NonNull Builder setAnInt(@Nullable Long setterArg) { + this.anInt = setterArg; + return this; + } + + private @Nullable Double aDouble; + + public @NonNull Builder setADouble(@Nullable Double setterArg) { + this.aDouble = setterArg; + return this; + } + + private @Nullable String aString; + + public @NonNull Builder setAString(@Nullable String setterArg) { + this.aString = setterArg; + return this; + } + + private @Nullable byte[] aByteArray; + + public @NonNull Builder setAByteArray(@Nullable byte[] setterArg) { + this.aByteArray = setterArg; + return this; + } + + private @Nullable int[] a4ByteArray; + + public @NonNull Builder setA4ByteArray(@Nullable int[] setterArg) { + this.a4ByteArray = setterArg; + return this; + } + + private @Nullable long[] a8ByteArray; + + public @NonNull Builder setA8ByteArray(@Nullable long[] setterArg) { + this.a8ByteArray = setterArg; + return this; + } + + private @Nullable double[] aFloatArray; + + public @NonNull Builder setAFloatArray(@Nullable double[] setterArg) { + this.aFloatArray = setterArg; + return this; + } + + private @Nullable List aList; + + public @NonNull Builder setAList(@Nullable List setterArg) { + this.aList = setterArg; + return this; + } + + private @Nullable Map aMap; + + public @NonNull Builder setAMap(@Nullable Map setterArg) { + this.aMap = setterArg; + return this; + } + + private @Nullable List> nestedList; + + public @NonNull Builder setNestedList(@Nullable List> setterArg) { + this.nestedList = setterArg; + return this; + } + + private @Nullable Map mapWithAnnotations; + + public @NonNull Builder setMapWithAnnotations(@Nullable Map setterArg) { + this.mapWithAnnotations = setterArg; + return this; + } + + private @Nullable Map mapWithObject; + + public @NonNull Builder setMapWithObject(@Nullable Map setterArg) { + this.mapWithObject = setterArg; + return this; + } + + public @NonNull Everything build() { + Everything pigeonReturn = new Everything(); + pigeonReturn.setABool(aBool); + pigeonReturn.setAnInt(anInt); + pigeonReturn.setADouble(aDouble); + pigeonReturn.setAString(aString); + pigeonReturn.setAByteArray(aByteArray); + pigeonReturn.setA4ByteArray(a4ByteArray); + pigeonReturn.setA8ByteArray(a8ByteArray); + pigeonReturn.setAFloatArray(aFloatArray); + pigeonReturn.setAList(aList); + pigeonReturn.setAMap(aMap); + pigeonReturn.setNestedList(nestedList); + pigeonReturn.setMapWithAnnotations(mapWithAnnotations); + pigeonReturn.setMapWithObject(mapWithObject); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(aBool); + toListResult.add(anInt); + toListResult.add(aDouble); + toListResult.add(aString); + toListResult.add(aByteArray); + toListResult.add(a4ByteArray); + toListResult.add(a8ByteArray); + toListResult.add(aFloatArray); + toListResult.add(aList); + toListResult.add(aMap); + toListResult.add(nestedList); + toListResult.add(mapWithAnnotations); + toListResult.add(mapWithObject); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull Everything fromList(@NonNull ArrayList list) { + Everything pigeonResult = new Everything(); + ArrayList unwrapped = list.get(0); + + Object aBool = unwrapped.get(0); + pigeonResult.setABool((Boolean) aBool); + Object anInt = unwrapped.get(1); + pigeonResult.setAnInt( + (anInt == null) ? null : ((anInt instanceof Integer) ? (Integer) anInt : (Long) anInt)); + Object aDouble = unwrapped.get(2); + pigeonResult.setADouble((Double) aDouble); + Object aString = unwrapped.get(3); + pigeonResult.setAString((String) aString); + Object aByteArray = unwrapped.get(4); + pigeonResult.setAByteArray((byte[]) aByteArray); + Object a4ByteArray = unwrapped.get(5); + pigeonResult.setA4ByteArray((int[]) a4ByteArray); + Object a8ByteArray = unwrapped.get(6); + pigeonResult.setA8ByteArray((long[]) a8ByteArray); + Object aFloatArray = unwrapped.get(7); + pigeonResult.setAFloatArray((double[]) aFloatArray); + Object aList = unwrapped.get(8); + pigeonResult.setAList((List) aList); + Object aMap = unwrapped.get(9); + pigeonResult.setAMap((Map) aMap); + Object nestedList = unwrapped.get(10); + pigeonResult.setNestedList((List>) nestedList); + Object mapWithAnnotations = unwrapped.get(11); + pigeonResult.setMapWithAnnotations((Map) mapWithAnnotations); + Object mapWithObject = unwrapped.get(12); + pigeonResult.setMapWithObject((Map) mapWithObject); + return pigeonResult; + } + } + + private static class HostEverythingCodec extends StandardMessageCodec { + public static final HostEverythingCodec INSTANCE = new HostEverythingCodec(); + + private HostEverythingCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return Everything.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof Everything) { + stream.write(128); + writeValue(stream, ((Everything) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface HostEverything { + @NonNull + Everything giveMeEverything(); + + @NonNull + Everything echo(@NonNull Everything everything); + + /** The codec used by HostEverything. */ + static MessageCodec getCodec() { + return HostEverythingCodec.INSTANCE; + } + /** Sets up an instance of `HostEverything` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, HostEverything api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.HostEverything.giveMeEverything", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + Everything output = api.giveMeEverything(); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.HostEverything.echo", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + Everything everythingArg = (Everything) args.get(0); + if (everythingArg == null) { + throw new NullPointerException("everythingArg unexpectedly null."); + } + Everything output = api.echo(everythingArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + private static class FlutterEverythingCodec extends StandardMessageCodec { + public static final FlutterEverythingCodec INSTANCE = new FlutterEverythingCodec(); + + private FlutterEverythingCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return Everything.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof Everything) { + stream.write(128); + writeValue(stream, ((Everything) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class FlutterEverything { + private final BinaryMessenger binaryMessenger; + + public FlutterEverything(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by FlutterEverything. */ + static MessageCodec getCodec() { + return FlutterEverythingCodec.INSTANCE; + } + + public void giveMeEverything(Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.FlutterEverything.giveMeEverything", getCodec()); + channel.send( + null, + channelReply -> { + @SuppressWarnings("ConstantConditions") + Everything output = (Everything) channelReply; + callback.reply(output); + }); + } + + public void echo(@NonNull Everything everythingArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.FlutterEverything.echo", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(everythingArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + Everything output = (Everything) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/AllVoid.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/AllVoid.java new file mode 100644 index 000000000000..8590088488ab --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/AllVoid.java @@ -0,0 +1,93 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.util.ArrayList; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class AllVoid { + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class AllVoidFlutterApi { + private final BinaryMessenger binaryMessenger; + + public AllVoidFlutterApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by AllVoidFlutterApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + + public void doit(Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.AllVoidFlutterApi.doit", getCodec()); + channel.send( + null, + channelReply -> { + callback.reply(null); + }); + } + } + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface AllVoidHostApi { + void doit(); + + /** The codec used by AllVoidHostApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + /** Sets up an instance of `AllVoidHostApi` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, AllVoidHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.AllVoidHostApi.doit", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + api.doit(); + wrapped.add(null); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/AsyncHandlers.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/AsyncHandlers.java new file mode 100644 index 000000000000..b2b44329358b --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/AsyncHandlers.java @@ -0,0 +1,271 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class AsyncHandlers { + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class Value { + private @Nullable Long number; + + public @Nullable Long getNumber() { + return number; + } + + public void setNumber(@Nullable Long setterArg) { + this.number = setterArg; + } + + public static final class Builder { + private @Nullable Long number; + + public @NonNull Builder setNumber(@Nullable Long setterArg) { + this.number = setterArg; + return this; + } + + public @NonNull Value build() { + Value pigeonReturn = new Value(); + pigeonReturn.setNumber(number); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(number); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull Value fromList(@NonNull ArrayList list) { + Value pigeonResult = new Value(); + ArrayList unwrapped = list.get(0); + + Object number = unwrapped.get(0); + pigeonResult.setNumber( + (number == null) + ? null + : ((number instanceof Integer) ? (Integer) number : (Long) number)); + return pigeonResult; + } + } + + public interface Result { + void success(T result); + + void error(Throwable error); + } + + private static class Api2HostCodec extends StandardMessageCodec { + public static final Api2HostCodec INSTANCE = new Api2HostCodec(); + + private Api2HostCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return Value.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof Value) { + stream.write(128); + writeValue(stream, ((Value) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface Api2Host { + void calculate(@NonNull Value value, Result result); + + void voidVoid(Result result); + + /** The codec used by Api2Host. */ + static MessageCodec getCodec() { + return Api2HostCodec.INSTANCE; + } + /** Sets up an instance of `Api2Host` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, Api2Host api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.Api2Host.calculate", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + Value valueArg = (Value) args.get(0); + if (valueArg == null) { + throw new NullPointerException("valueArg unexpectedly null."); + } + Result resultCallback = + new Result() { + public void success(Value result) { + wrapped.add(result); + reply.reply(wrapped); + } + + public void error(Throwable error) { + ArrayList wrappedError = wrapError(error); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + reply.reply(wrapped); + } + }; + + api.calculate(valueArg, resultCallback); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + reply.reply(wrapped); + } + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.Api2Host.voidVoid", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + Result resultCallback = + new Result() { + public void success(Void result) { + wrapped.add(null); + reply.reply(wrapped); + } + + public void error(Throwable error) { + ArrayList wrappedError = wrapError(error); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + reply.reply(wrapped); + } + }; + + api.voidVoid(resultCallback); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + reply.reply(wrapped); + } + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + private static class Api2FlutterCodec extends StandardMessageCodec { + public static final Api2FlutterCodec INSTANCE = new Api2FlutterCodec(); + + private Api2FlutterCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return Value.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof Value) { + stream.write(128); + writeValue(stream, ((Value) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class Api2Flutter { + private final BinaryMessenger binaryMessenger; + + public Api2Flutter(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by Api2Flutter. */ + static MessageCodec getCodec() { + return Api2FlutterCodec.INSTANCE; + } + + public void calculate(@NonNull Value valueArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.Api2Flutter.calculate", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(valueArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + Value output = (Value) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/BackgroundPlatformChannels.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/BackgroundPlatformChannels.java new file mode 100644 index 000000000000..48e9bff4ca25 --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/BackgroundPlatformChannels.java @@ -0,0 +1,86 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.util.ArrayList; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class BackgroundPlatformChannels { + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface BackgroundApi2Host { + @NonNull + Long add(@NonNull Long x, @NonNull Long y); + + /** The codec used by BackgroundApi2Host. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + /** + * Sets up an instance of `BackgroundApi2Host` to handle messages through the `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, BackgroundApi2Host api) { + { + BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue(); + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.BackgroundApi2Host.add", + getCodec(), + taskQueue); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + Number xArg = (Number) args.get(0); + if (xArg == null) { + throw new NullPointerException("xArg unexpectedly null."); + } + Number yArg = (Number) args.get(1); + if (yArg == null) { + throw new NullPointerException("yArg unexpectedly null."); + } + Long output = + api.add( + (xArg == null) ? null : xArg.longValue(), + (yArg == null) ? null : yArg.longValue()); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Enum.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Enum.java new file mode 100644 index 000000000000..3d20075682e7 --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Enum.java @@ -0,0 +1,235 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class Enum { + + /** This comment is to test enum documentation comments. */ + public enum EnumState { + PENDING(0), + SUCCESS(1), + ERROR(2); + + private int index; + + private EnumState(final int index) { + this.index = index; + } + } + + /** + * This comment is to test class documentation comments. + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static class DataWithEnum { + /** This comment is to test field documentation comments. */ + private @Nullable EnumState state; + + public @Nullable EnumState getState() { + return state; + } + + public void setState(@Nullable EnumState setterArg) { + this.state = setterArg; + } + + public static final class Builder { + private @Nullable EnumState state; + + public @NonNull Builder setState(@Nullable EnumState setterArg) { + this.state = setterArg; + return this; + } + + public @NonNull DataWithEnum build() { + DataWithEnum pigeonReturn = new DataWithEnum(); + pigeonReturn.setState(state); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(state == null ? null : state.index); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull DataWithEnum fromList(@NonNull ArrayList list) { + DataWithEnum pigeonResult = new DataWithEnum(); + ArrayList unwrapped = list.get(0); + + Object state = unwrapped.get(0); + pigeonResult.setState(state == null ? null : EnumState.values()[(int) state]); + return pigeonResult; + } + } + + private static class EnumApi2HostCodec extends StandardMessageCodec { + public static final EnumApi2HostCodec INSTANCE = new EnumApi2HostCodec(); + + private EnumApi2HostCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return DataWithEnum.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof DataWithEnum) { + stream.write(128); + writeValue(stream, ((DataWithEnum) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** + * This comment is to test api documentation comments. + * + *

Generated interface from Pigeon that represents a handler of messages from Flutter. + */ + public interface EnumApi2Host { + /** This comment is to test method documentation comments. */ + @NonNull + DataWithEnum echo(@NonNull DataWithEnum data); + + /** The codec used by EnumApi2Host. */ + static MessageCodec getCodec() { + return EnumApi2HostCodec.INSTANCE; + } + /** Sets up an instance of `EnumApi2Host` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, EnumApi2Host api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.EnumApi2Host.echo", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + DataWithEnum dataArg = (DataWithEnum) args.get(0); + if (dataArg == null) { + throw new NullPointerException("dataArg unexpectedly null."); + } + DataWithEnum output = api.echo(dataArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + private static class EnumApi2FlutterCodec extends StandardMessageCodec { + public static final EnumApi2FlutterCodec INSTANCE = new EnumApi2FlutterCodec(); + + private EnumApi2FlutterCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return DataWithEnum.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof DataWithEnum) { + stream.write(128); + writeValue(stream, ((DataWithEnum) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** + * This comment is to test api documentation comments. + * + *

Generated class from Pigeon that represents Flutter messages that can be called from Java. + */ + public static class EnumApi2Flutter { + private final BinaryMessenger binaryMessenger; + + public EnumApi2Flutter(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by EnumApi2Flutter. */ + static MessageCodec getCodec() { + return EnumApi2FlutterCodec.INSTANCE; + } + /** This comment is to test method documentation comments. */ + public void echo(@NonNull DataWithEnum dataArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.EnumApi2Flutter.echo", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(dataArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + DataWithEnum output = (DataWithEnum) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/EnumArgs.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/EnumArgs.java new file mode 100644 index 000000000000..c6ec4dbc728c --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/EnumArgs.java @@ -0,0 +1,85 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.util.ArrayList; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class EnumArgs { + + public enum EnumArgsState { + PENDING(0), + SUCCESS(1), + ERROR(2); + + private int index; + + private EnumArgsState(final int index) { + this.index = index; + } + } + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface EnumArgs2Host { + void foo(@NonNull EnumArgsState state); + + /** The codec used by EnumArgs2Host. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + /** Sets up an instance of `EnumArgs2Host` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, EnumArgs2Host api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.EnumArgs2Host.foo", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + EnumArgsState stateArg = + args.get(0) == null ? null : EnumArgsState.values()[(int) args.get(0)]; + if (stateArg == null) { + throw new NullPointerException("stateArg unexpectedly null."); + } + api.foo(stateArg); + wrapped.add(null); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Host2Flutter.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Host2Flutter.java new file mode 100644 index 000000000000..620befa3bbab --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Host2Flutter.java @@ -0,0 +1,191 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class Host2Flutter { + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class Host2FlutterSearchRequest { + private @Nullable String query; + + public @Nullable String getQuery() { + return query; + } + + public void setQuery(@Nullable String setterArg) { + this.query = setterArg; + } + + public static final class Builder { + private @Nullable String query; + + public @NonNull Builder setQuery(@Nullable String setterArg) { + this.query = setterArg; + return this; + } + + public @NonNull Host2FlutterSearchRequest build() { + Host2FlutterSearchRequest pigeonReturn = new Host2FlutterSearchRequest(); + pigeonReturn.setQuery(query); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(query); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull Host2FlutterSearchRequest fromList(@NonNull ArrayList list) { + Host2FlutterSearchRequest pigeonResult = new Host2FlutterSearchRequest(); + ArrayList unwrapped = list.get(0); + + Object query = unwrapped.get(0); + pigeonResult.setQuery((String) query); + return pigeonResult; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class Host2FlutterSearchReply { + private @Nullable String result; + + public @Nullable String getResult() { + return result; + } + + public void setResult(@Nullable String setterArg) { + this.result = setterArg; + } + + public static final class Builder { + private @Nullable String result; + + public @NonNull Builder setResult(@Nullable String setterArg) { + this.result = setterArg; + return this; + } + + public @NonNull Host2FlutterSearchReply build() { + Host2FlutterSearchReply pigeonReturn = new Host2FlutterSearchReply(); + pigeonReturn.setResult(result); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(result); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull Host2FlutterSearchReply fromList(@NonNull ArrayList list) { + Host2FlutterSearchReply pigeonResult = new Host2FlutterSearchReply(); + ArrayList unwrapped = list.get(0); + + Object result = unwrapped.get(0); + pigeonResult.setResult((String) result); + return pigeonResult; + } + } + + private static class H2FApiCodec extends StandardMessageCodec { + public static final H2FApiCodec INSTANCE = new H2FApiCodec(); + + private H2FApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return Host2FlutterSearchReply.fromList((ArrayList) readValue(buffer)); + + case (byte) 129: + return Host2FlutterSearchRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof Host2FlutterSearchReply) { + stream.write(128); + writeValue(stream, ((Host2FlutterSearchReply) value).toList()); + } else if (value instanceof Host2FlutterSearchRequest) { + stream.write(129); + writeValue(stream, ((Host2FlutterSearchRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class H2FApi { + private final BinaryMessenger binaryMessenger; + + public H2FApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by H2FApi. */ + static MessageCodec getCodec() { + return H2FApiCodec.INSTANCE; + } + + public void search( + @NonNull Host2FlutterSearchRequest requestArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.H2FApi.search", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(requestArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + Host2FlutterSearchReply output = (Host2FlutterSearchReply) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/JavaDoubleHostApi.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/JavaDoubleHostApi.java new file mode 100644 index 000000000000..be4c1f157eb5 --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/JavaDoubleHostApi.java @@ -0,0 +1,245 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class JavaDoubleHostApi { + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class BridgeResponse { + private @Nullable Long result; + + public @Nullable Long getResult() { + return result; + } + + public void setResult(@Nullable Long setterArg) { + this.result = setterArg; + } + + public static final class Builder { + private @Nullable Long result; + + public @NonNull Builder setResult(@Nullable Long setterArg) { + this.result = setterArg; + return this; + } + + public @NonNull BridgeResponse build() { + BridgeResponse pigeonReturn = new BridgeResponse(); + pigeonReturn.setResult(result); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(result); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull BridgeResponse fromList(@NonNull ArrayList list) { + BridgeResponse pigeonResult = new BridgeResponse(); + ArrayList unwrapped = list.get(0); + + Object result = unwrapped.get(0); + pigeonResult.setResult( + (result == null) + ? null + : ((result instanceof Integer) ? (Integer) result : (Long) result)); + return pigeonResult; + } + } + + public interface Result { + void success(T result); + + void error(Throwable error); + } + + private static class BridgeApi1Codec extends StandardMessageCodec { + public static final BridgeApi1Codec INSTANCE = new BridgeApi1Codec(); + + private BridgeApi1Codec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return BridgeResponse.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof BridgeResponse) { + stream.write(128); + writeValue(stream, ((BridgeResponse) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface BridgeApi1 { + void call(Result result); + + /** The codec used by BridgeApi1. */ + static MessageCodec getCodec() { + return BridgeApi1Codec.INSTANCE; + } + /** Sets up an instance of `BridgeApi1` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, BridgeApi1 api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.BridgeApi1.call", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + Result resultCallback = + new Result() { + public void success(BridgeResponse result) { + wrapped.add(result); + reply.reply(wrapped); + } + + public void error(Throwable error) { + ArrayList wrappedError = wrapError(error); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + reply.reply(wrapped); + } + }; + + api.call(resultCallback); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + reply.reply(wrapped); + } + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + private static class BridgeApi2Codec extends StandardMessageCodec { + public static final BridgeApi2Codec INSTANCE = new BridgeApi2Codec(); + + private BridgeApi2Codec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return BridgeResponse.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof BridgeResponse) { + stream.write(128); + writeValue(stream, ((BridgeResponse) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface BridgeApi2 { + void call(Result result); + + /** The codec used by BridgeApi2. */ + static MessageCodec getCodec() { + return BridgeApi2Codec.INSTANCE; + } + /** Sets up an instance of `BridgeApi2` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, BridgeApi2 api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.BridgeApi2.call", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + Result resultCallback = + new Result() { + public void success(BridgeResponse result) { + wrapped.add(result); + reply.reply(wrapped); + } + + public void error(Throwable error) { + ArrayList wrappedError = wrapError(error); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + reply.reply(wrapped); + } + }; + + api.call(resultCallback); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + reply.reply(wrapped); + } + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/MessagePigeon.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/MessagePigeon.java new file mode 100644 index 000000000000..231fc4cbcfd9 --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/MessagePigeon.java @@ -0,0 +1,574 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package dev.flutter.aaclarke.pigeon; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class MessagePigeon { + + /** + * This comment is to test enum documentation comments. + * + *

This comment also tests multiple line comments. + */ + public enum MessageRequestState { + PENDING(0), + SUCCESS(1), + FAILURE(2); + + private int index; + + private MessageRequestState(final int index) { + this.index = index; + } + } + + /** + * This comment is to test class documentation comments. + * + *

This comment also tests multiple line comments. + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static class MessageSearchRequest { + /** This comment is to test field documentation comments. */ + private @Nullable String query; + + public @Nullable String getQuery() { + return query; + } + + public void setQuery(@Nullable String setterArg) { + this.query = setterArg; + } + + /** This comment is to test field documentation comments. */ + private @Nullable Long anInt; + + public @Nullable Long getAnInt() { + return anInt; + } + + public void setAnInt(@Nullable Long setterArg) { + this.anInt = setterArg; + } + + /** This comment is to test field documentation comments. */ + private @Nullable Boolean aBool; + + public @Nullable Boolean getABool() { + return aBool; + } + + public void setABool(@Nullable Boolean setterArg) { + this.aBool = setterArg; + } + + public static final class Builder { + private @Nullable String query; + + public @NonNull Builder setQuery(@Nullable String setterArg) { + this.query = setterArg; + return this; + } + + private @Nullable Long anInt; + + public @NonNull Builder setAnInt(@Nullable Long setterArg) { + this.anInt = setterArg; + return this; + } + + private @Nullable Boolean aBool; + + public @NonNull Builder setABool(@Nullable Boolean setterArg) { + this.aBool = setterArg; + return this; + } + + public @NonNull MessageSearchRequest build() { + MessageSearchRequest pigeonReturn = new MessageSearchRequest(); + pigeonReturn.setQuery(query); + pigeonReturn.setAnInt(anInt); + pigeonReturn.setABool(aBool); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(query); + toListResult.add(anInt); + toListResult.add(aBool); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull MessageSearchRequest fromList(@NonNull ArrayList list) { + MessageSearchRequest pigeonResult = new MessageSearchRequest(); + ArrayList unwrapped = list.get(0); + + Object query = unwrapped.get(0); + pigeonResult.setQuery((String) query); + Object anInt = unwrapped.get(1); + pigeonResult.setAnInt( + (anInt == null) ? null : ((anInt instanceof Integer) ? (Integer) anInt : (Long) anInt)); + Object aBool = unwrapped.get(2); + pigeonResult.setABool((Boolean) aBool); + return pigeonResult; + } + } + + /** + * This comment is to test class documentation comments. + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static class MessageSearchReply { + /** + * This comment is to test field documentation comments. + * + *

This comment also tests multiple line comments. + */ + private @Nullable String result; + + public @Nullable String getResult() { + return result; + } + + public void setResult(@Nullable String setterArg) { + this.result = setterArg; + } + + /** This comment is to test field documentation comments. */ + private @Nullable String error; + + public @Nullable String getError() { + return error; + } + + public void setError(@Nullable String setterArg) { + this.error = setterArg; + } + + /** This comment is to test field documentation comments. */ + private @Nullable MessageRequestState state; + + public @Nullable MessageRequestState getState() { + return state; + } + + public void setState(@Nullable MessageRequestState setterArg) { + this.state = setterArg; + } + + public static final class Builder { + private @Nullable String result; + + public @NonNull Builder setResult(@Nullable String setterArg) { + this.result = setterArg; + return this; + } + + private @Nullable String error; + + public @NonNull Builder setError(@Nullable String setterArg) { + this.error = setterArg; + return this; + } + + private @Nullable MessageRequestState state; + + public @NonNull Builder setState(@Nullable MessageRequestState setterArg) { + this.state = setterArg; + return this; + } + + public @NonNull MessageSearchReply build() { + MessageSearchReply pigeonReturn = new MessageSearchReply(); + pigeonReturn.setResult(result); + pigeonReturn.setError(error); + pigeonReturn.setState(state); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(result); + toListResult.add(error); + toListResult.add(state == null ? null : state.index); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull MessageSearchReply fromList(@NonNull ArrayList list) { + MessageSearchReply pigeonResult = new MessageSearchReply(); + ArrayList unwrapped = list.get(0); + + Object result = unwrapped.get(0); + pigeonResult.setResult((String) result); + Object error = unwrapped.get(1); + pigeonResult.setError((String) error); + Object state = unwrapped.get(2); + pigeonResult.setState(state == null ? null : MessageRequestState.values()[(int) state]); + return pigeonResult; + } + } + + /** + * This comment is to test class documentation comments. + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static class MessageNested { + /** This comment is to test field documentation comments. */ + private @Nullable MessageSearchRequest request; + + public @Nullable MessageSearchRequest getRequest() { + return request; + } + + public void setRequest(@Nullable MessageSearchRequest setterArg) { + this.request = setterArg; + } + + public static final class Builder { + private @Nullable MessageSearchRequest request; + + public @NonNull Builder setRequest(@Nullable MessageSearchRequest setterArg) { + this.request = setterArg; + return this; + } + + public @NonNull MessageNested build() { + MessageNested pigeonReturn = new MessageNested(); + pigeonReturn.setRequest(request); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add((request == null) ? null : request.toList()); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull MessageNested fromList(@NonNull ArrayList list) { + MessageNested pigeonResult = new MessageNested(); + ArrayList unwrapped = list.get(0); + + Object request = unwrapped.get(0); + pigeonResult.setRequest( + (request == null) ? null : MessageSearchRequest.fromList((ArrayList) request)); + return pigeonResult; + } + } + + private static class MessageApiCodec extends StandardMessageCodec { + public static final MessageApiCodec INSTANCE = new MessageApiCodec(); + + private MessageApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return MessageSearchReply.fromList((ArrayList) readValue(buffer)); + + case (byte) 129: + return MessageSearchRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof MessageSearchReply) { + stream.write(128); + writeValue(stream, ((MessageSearchReply) value).toList()); + } else if (value instanceof MessageSearchRequest) { + stream.write(129); + writeValue(stream, ((MessageSearchRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** + * This comment is to test api documentation comments. + * + *

This comment also tests multiple line comments. + * + *

Generated interface from Pigeon that represents a handler of messages from Flutter. + */ + public interface MessageApi { + /** + * This comment is to test documentation comments. + * + *

This comment also tests multiple line comments. + */ + void initialize(); + /** This comment is to test method documentation comments. */ + @NonNull + MessageSearchReply search(@NonNull MessageSearchRequest request); + + /** The codec used by MessageApi. */ + static MessageCodec getCodec() { + return MessageApiCodec.INSTANCE; + } + /** Sets up an instance of `MessageApi` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, MessageApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.MessageApi.initialize", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + api.initialize(); + wrapped.add(null); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.MessageApi.search", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + MessageSearchRequest requestArg = (MessageSearchRequest) args.get(0); + if (requestArg == null) { + throw new NullPointerException("requestArg unexpectedly null."); + } + MessageSearchReply output = api.search(requestArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + private static class MessageNestedApiCodec extends StandardMessageCodec { + public static final MessageNestedApiCodec INSTANCE = new MessageNestedApiCodec(); + + private MessageNestedApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return MessageNested.fromList((ArrayList) readValue(buffer)); + + case (byte) 129: + return MessageSearchReply.fromList((ArrayList) readValue(buffer)); + + case (byte) 130: + return MessageSearchRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof MessageNested) { + stream.write(128); + writeValue(stream, ((MessageNested) value).toList()); + } else if (value instanceof MessageSearchReply) { + stream.write(129); + writeValue(stream, ((MessageSearchReply) value).toList()); + } else if (value instanceof MessageSearchRequest) { + stream.write(130); + writeValue(stream, ((MessageSearchRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** + * This comment is to test api documentation comments. + * + *

Generated interface from Pigeon that represents a handler of messages from Flutter. + */ + public interface MessageNestedApi { + /** + * This comment is to test method documentation comments. + * + *

This comment also tests multiple line comments. + */ + @NonNull + MessageSearchReply search(@NonNull MessageNested nested); + + /** The codec used by MessageNestedApi. */ + static MessageCodec getCodec() { + return MessageNestedApiCodec.INSTANCE; + } + /** + * Sets up an instance of `MessageNestedApi` to handle messages through the `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, MessageNestedApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.MessageNestedApi.search", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + MessageNested nestedArg = (MessageNested) args.get(0); + if (nestedArg == null) { + throw new NullPointerException("nestedArg unexpectedly null."); + } + MessageSearchReply output = api.search(nestedArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + private static class MessageFlutterSearchApiCodec extends StandardMessageCodec { + public static final MessageFlutterSearchApiCodec INSTANCE = new MessageFlutterSearchApiCodec(); + + private MessageFlutterSearchApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return MessageSearchReply.fromList((ArrayList) readValue(buffer)); + + case (byte) 129: + return MessageSearchRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof MessageSearchReply) { + stream.write(128); + writeValue(stream, ((MessageSearchReply) value).toList()); + } else if (value instanceof MessageSearchRequest) { + stream.write(129); + writeValue(stream, ((MessageSearchRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** + * This comment is to test api documentation comments. + * + *

Generated class from Pigeon that represents Flutter messages that can be called from Java. + */ + public static class MessageFlutterSearchApi { + private final BinaryMessenger binaryMessenger; + + public MessageFlutterSearchApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by MessageFlutterSearchApi. */ + static MessageCodec getCodec() { + return MessageFlutterSearchApiCodec.INSTANCE; + } + /** This comment is to test method documentation comments. */ + public void search( + @NonNull MessageSearchRequest requestArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.MessageFlutterSearchApi.search", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(requestArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + MessageSearchReply output = (MessageSearchReply) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/MultipleArity.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/MultipleArity.java new file mode 100644 index 000000000000..df894ea9b7e1 --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/MultipleArity.java @@ -0,0 +1,113 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.util.ArrayList; +import java.util.Arrays; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class MultipleArity { + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface MultipleArityHostApi { + @NonNull + Long subtract(@NonNull Long x, @NonNull Long y); + + /** The codec used by MultipleArityHostApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + /** + * Sets up an instance of `MultipleArityHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, MultipleArityHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.MultipleArityHostApi.subtract", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + Number xArg = (Number) args.get(0); + if (xArg == null) { + throw new NullPointerException("xArg unexpectedly null."); + } + Number yArg = (Number) args.get(1); + if (yArg == null) { + throw new NullPointerException("yArg unexpectedly null."); + } + Long output = + api.subtract( + (xArg == null) ? null : xArg.longValue(), + (yArg == null) ? null : yArg.longValue()); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class MultipleArityFlutterApi { + private final BinaryMessenger binaryMessenger; + + public MultipleArityFlutterApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by MultipleArityFlutterApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + + public void subtract(@NonNull Long xArg, @NonNull Long yArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.MultipleArityFlutterApi.subtract", getCodec()); + channel.send( + new ArrayList(Arrays.asList(xArg, yArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + Long output = channelReply == null ? null : ((Number) channelReply).longValue(); + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/NonNullFields.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/NonNullFields.java new file mode 100644 index 000000000000..8f7dfb57c0ef --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/NonNullFields.java @@ -0,0 +1,479 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class NonNullFields { + + public enum ReplyType { + SUCCESS(0), + ERROR(1); + + private int index; + + private ReplyType(final int index) { + this.index = index; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class NonNullFieldSearchRequest { + private @NonNull String query; + + public @NonNull String getQuery() { + return query; + } + + public void setQuery(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"query\" is null."); + } + this.query = setterArg; + } + + /** Constructor is private to enforce null safety; use Builder. */ + private NonNullFieldSearchRequest() {} + + public static final class Builder { + private @Nullable String query; + + public @NonNull Builder setQuery(@NonNull String setterArg) { + this.query = setterArg; + return this; + } + + public @NonNull NonNullFieldSearchRequest build() { + NonNullFieldSearchRequest pigeonReturn = new NonNullFieldSearchRequest(); + pigeonReturn.setQuery(query); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(query); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull NonNullFieldSearchRequest fromList(@NonNull ArrayList list) { + NonNullFieldSearchRequest pigeonResult = new NonNullFieldSearchRequest(); + ArrayList unwrapped = list.get(0); + + Object query = unwrapped.get(0); + pigeonResult.setQuery((String) query); + return pigeonResult; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class ExtraData { + private @NonNull String detailA; + + public @NonNull String getDetailA() { + return detailA; + } + + public void setDetailA(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"detailA\" is null."); + } + this.detailA = setterArg; + } + + private @NonNull String detailB; + + public @NonNull String getDetailB() { + return detailB; + } + + public void setDetailB(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"detailB\" is null."); + } + this.detailB = setterArg; + } + + /** Constructor is private to enforce null safety; use Builder. */ + private ExtraData() {} + + public static final class Builder { + private @Nullable String detailA; + + public @NonNull Builder setDetailA(@NonNull String setterArg) { + this.detailA = setterArg; + return this; + } + + private @Nullable String detailB; + + public @NonNull Builder setDetailB(@NonNull String setterArg) { + this.detailB = setterArg; + return this; + } + + public @NonNull ExtraData build() { + ExtraData pigeonReturn = new ExtraData(); + pigeonReturn.setDetailA(detailA); + pigeonReturn.setDetailB(detailB); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(detailA); + toListResult.add(detailB); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull ExtraData fromList(@NonNull ArrayList list) { + ExtraData pigeonResult = new ExtraData(); + ArrayList unwrapped = list.get(0); + + Object detailA = unwrapped.get(0); + pigeonResult.setDetailA((String) detailA); + Object detailB = unwrapped.get(1); + pigeonResult.setDetailB((String) detailB); + return pigeonResult; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class NonNullFieldSearchReply { + private @NonNull String result; + + public @NonNull String getResult() { + return result; + } + + public void setResult(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"result\" is null."); + } + this.result = setterArg; + } + + private @NonNull String error; + + public @NonNull String getError() { + return error; + } + + public void setError(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"error\" is null."); + } + this.error = setterArg; + } + + private @NonNull List indices; + + public @NonNull List getIndices() { + return indices; + } + + public void setIndices(@NonNull List setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"indices\" is null."); + } + this.indices = setterArg; + } + + private @NonNull ExtraData extraData; + + public @NonNull ExtraData getExtraData() { + return extraData; + } + + public void setExtraData(@NonNull ExtraData setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"extraData\" is null."); + } + this.extraData = setterArg; + } + + private @NonNull ReplyType type; + + public @NonNull ReplyType getType() { + return type; + } + + public void setType(@NonNull ReplyType setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"type\" is null."); + } + this.type = setterArg; + } + + /** Constructor is private to enforce null safety; use Builder. */ + private NonNullFieldSearchReply() {} + + public static final class Builder { + private @Nullable String result; + + public @NonNull Builder setResult(@NonNull String setterArg) { + this.result = setterArg; + return this; + } + + private @Nullable String error; + + public @NonNull Builder setError(@NonNull String setterArg) { + this.error = setterArg; + return this; + } + + private @Nullable List indices; + + public @NonNull Builder setIndices(@NonNull List setterArg) { + this.indices = setterArg; + return this; + } + + private @Nullable ExtraData extraData; + + public @NonNull Builder setExtraData(@NonNull ExtraData setterArg) { + this.extraData = setterArg; + return this; + } + + private @Nullable ReplyType type; + + public @NonNull Builder setType(@NonNull ReplyType setterArg) { + this.type = setterArg; + return this; + } + + public @NonNull NonNullFieldSearchReply build() { + NonNullFieldSearchReply pigeonReturn = new NonNullFieldSearchReply(); + pigeonReturn.setResult(result); + pigeonReturn.setError(error); + pigeonReturn.setIndices(indices); + pigeonReturn.setExtraData(extraData); + pigeonReturn.setType(type); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(result); + toListResult.add(error); + toListResult.add(indices); + toListResult.add((extraData == null) ? null : extraData.toList()); + toListResult.add(type == null ? null : type.index); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull NonNullFieldSearchReply fromList(@NonNull ArrayList list) { + NonNullFieldSearchReply pigeonResult = new NonNullFieldSearchReply(); + ArrayList unwrapped = list.get(0); + + Object result = unwrapped.get(0); + pigeonResult.setResult((String) result); + Object error = unwrapped.get(1); + pigeonResult.setError((String) error); + Object indices = unwrapped.get(2); + pigeonResult.setIndices((List) indices); + Object extraData = unwrapped.get(3); + pigeonResult.setExtraData( + (extraData == null) ? null : ExtraData.fromList((ArrayList) extraData)); + Object type = unwrapped.get(4); + pigeonResult.setType(type == null ? null : ReplyType.values()[(int) type]); + return pigeonResult; + } + } + + private static class NonNullFieldHostApiCodec extends StandardMessageCodec { + public static final NonNullFieldHostApiCodec INSTANCE = new NonNullFieldHostApiCodec(); + + private NonNullFieldHostApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return ExtraData.fromList((ArrayList) readValue(buffer)); + + case (byte) 129: + return NonNullFieldSearchReply.fromList((ArrayList) readValue(buffer)); + + case (byte) 130: + return NonNullFieldSearchRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof ExtraData) { + stream.write(128); + writeValue(stream, ((ExtraData) value).toList()); + } else if (value instanceof NonNullFieldSearchReply) { + stream.write(129); + writeValue(stream, ((NonNullFieldSearchReply) value).toList()); + } else if (value instanceof NonNullFieldSearchRequest) { + stream.write(130); + writeValue(stream, ((NonNullFieldSearchRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface NonNullFieldHostApi { + @NonNull + NonNullFieldSearchReply search(@NonNull NonNullFieldSearchRequest nested); + + /** The codec used by NonNullFieldHostApi. */ + static MessageCodec getCodec() { + return NonNullFieldHostApiCodec.INSTANCE; + } + /** + * Sets up an instance of `NonNullFieldHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, NonNullFieldHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.NonNullFieldHostApi.search", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + NonNullFieldSearchRequest nestedArg = (NonNullFieldSearchRequest) args.get(0); + if (nestedArg == null) { + throw new NullPointerException("nestedArg unexpectedly null."); + } + NonNullFieldSearchReply output = api.search(nestedArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + private static class NonNullFieldFlutterApiCodec extends StandardMessageCodec { + public static final NonNullFieldFlutterApiCodec INSTANCE = new NonNullFieldFlutterApiCodec(); + + private NonNullFieldFlutterApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return ExtraData.fromList((ArrayList) readValue(buffer)); + + case (byte) 129: + return NonNullFieldSearchReply.fromList((ArrayList) readValue(buffer)); + + case (byte) 130: + return NonNullFieldSearchRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof ExtraData) { + stream.write(128); + writeValue(stream, ((ExtraData) value).toList()); + } else if (value instanceof NonNullFieldSearchReply) { + stream.write(129); + writeValue(stream, ((NonNullFieldSearchReply) value).toList()); + } else if (value instanceof NonNullFieldSearchRequest) { + stream.write(130); + writeValue(stream, ((NonNullFieldSearchRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class NonNullFieldFlutterApi { + private final BinaryMessenger binaryMessenger; + + public NonNullFieldFlutterApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by NonNullFieldFlutterApi. */ + static MessageCodec getCodec() { + return NonNullFieldFlutterApiCodec.INSTANCE; + } + + public void search( + @NonNull NonNullFieldSearchRequest requestArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.NonNullFieldFlutterApi.search", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(requestArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + NonNullFieldSearchReply output = (NonNullFieldSearchReply) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/NullFields.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/NullFields.java new file mode 100644 index 000000000000..e00bfdcf816c --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/NullFields.java @@ -0,0 +1,398 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class NullFields { + + public enum NullFieldsSearchReplyType { + SUCCESS(0), + FAILURE(1); + + private int index; + + private NullFieldsSearchReplyType(final int index) { + this.index = index; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class NullFieldsSearchRequest { + private @Nullable String query; + + public @Nullable String getQuery() { + return query; + } + + public void setQuery(@Nullable String setterArg) { + this.query = setterArg; + } + + private @NonNull Long identifier; + + public @NonNull Long getIdentifier() { + return identifier; + } + + public void setIdentifier(@NonNull Long setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"identifier\" is null."); + } + this.identifier = setterArg; + } + + /** Constructor is private to enforce null safety; use Builder. */ + private NullFieldsSearchRequest() {} + + public static final class Builder { + private @Nullable String query; + + public @NonNull Builder setQuery(@Nullable String setterArg) { + this.query = setterArg; + return this; + } + + private @Nullable Long identifier; + + public @NonNull Builder setIdentifier(@NonNull Long setterArg) { + this.identifier = setterArg; + return this; + } + + public @NonNull NullFieldsSearchRequest build() { + NullFieldsSearchRequest pigeonReturn = new NullFieldsSearchRequest(); + pigeonReturn.setQuery(query); + pigeonReturn.setIdentifier(identifier); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(query); + toListResult.add(identifier); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull NullFieldsSearchRequest fromList(@NonNull ArrayList list) { + NullFieldsSearchRequest pigeonResult = new NullFieldsSearchRequest(); + ArrayList unwrapped = list.get(0); + + Object query = unwrapped.get(0); + pigeonResult.setQuery((String) query); + Object identifier = unwrapped.get(1); + pigeonResult.setIdentifier( + (identifier == null) + ? null + : ((identifier instanceof Integer) ? (Integer) identifier : (Long) identifier)); + return pigeonResult; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class NullFieldsSearchReply { + private @Nullable String result; + + public @Nullable String getResult() { + return result; + } + + public void setResult(@Nullable String setterArg) { + this.result = setterArg; + } + + private @Nullable String error; + + public @Nullable String getError() { + return error; + } + + public void setError(@Nullable String setterArg) { + this.error = setterArg; + } + + private @Nullable List indices; + + public @Nullable List getIndices() { + return indices; + } + + public void setIndices(@Nullable List setterArg) { + this.indices = setterArg; + } + + private @Nullable NullFieldsSearchRequest request; + + public @Nullable NullFieldsSearchRequest getRequest() { + return request; + } + + public void setRequest(@Nullable NullFieldsSearchRequest setterArg) { + this.request = setterArg; + } + + private @Nullable NullFieldsSearchReplyType type; + + public @Nullable NullFieldsSearchReplyType getType() { + return type; + } + + public void setType(@Nullable NullFieldsSearchReplyType setterArg) { + this.type = setterArg; + } + + public static final class Builder { + private @Nullable String result; + + public @NonNull Builder setResult(@Nullable String setterArg) { + this.result = setterArg; + return this; + } + + private @Nullable String error; + + public @NonNull Builder setError(@Nullable String setterArg) { + this.error = setterArg; + return this; + } + + private @Nullable List indices; + + public @NonNull Builder setIndices(@Nullable List setterArg) { + this.indices = setterArg; + return this; + } + + private @Nullable NullFieldsSearchRequest request; + + public @NonNull Builder setRequest(@Nullable NullFieldsSearchRequest setterArg) { + this.request = setterArg; + return this; + } + + private @Nullable NullFieldsSearchReplyType type; + + public @NonNull Builder setType(@Nullable NullFieldsSearchReplyType setterArg) { + this.type = setterArg; + return this; + } + + public @NonNull NullFieldsSearchReply build() { + NullFieldsSearchReply pigeonReturn = new NullFieldsSearchReply(); + pigeonReturn.setResult(result); + pigeonReturn.setError(error); + pigeonReturn.setIndices(indices); + pigeonReturn.setRequest(request); + pigeonReturn.setType(type); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(result); + toListResult.add(error); + toListResult.add(indices); + toListResult.add((request == null) ? null : request.toList()); + toListResult.add(type == null ? null : type.index); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull NullFieldsSearchReply fromList(@NonNull ArrayList list) { + NullFieldsSearchReply pigeonResult = new NullFieldsSearchReply(); + ArrayList unwrapped = list.get(0); + + Object result = unwrapped.get(0); + pigeonResult.setResult((String) result); + Object error = unwrapped.get(1); + pigeonResult.setError((String) error); + Object indices = unwrapped.get(2); + pigeonResult.setIndices((List) indices); + Object request = unwrapped.get(3); + pigeonResult.setRequest( + (request == null) + ? null + : NullFieldsSearchRequest.fromList((ArrayList) request)); + Object type = unwrapped.get(4); + pigeonResult.setType(type == null ? null : NullFieldsSearchReplyType.values()[(int) type]); + return pigeonResult; + } + } + + private static class NullFieldsHostApiCodec extends StandardMessageCodec { + public static final NullFieldsHostApiCodec INSTANCE = new NullFieldsHostApiCodec(); + + private NullFieldsHostApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return NullFieldsSearchReply.fromList((ArrayList) readValue(buffer)); + + case (byte) 129: + return NullFieldsSearchRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof NullFieldsSearchReply) { + stream.write(128); + writeValue(stream, ((NullFieldsSearchReply) value).toList()); + } else if (value instanceof NullFieldsSearchRequest) { + stream.write(129); + writeValue(stream, ((NullFieldsSearchRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface NullFieldsHostApi { + @NonNull + NullFieldsSearchReply search(@NonNull NullFieldsSearchRequest nested); + + /** The codec used by NullFieldsHostApi. */ + static MessageCodec getCodec() { + return NullFieldsHostApiCodec.INSTANCE; + } + /** + * Sets up an instance of `NullFieldsHostApi` to handle messages through the `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, NullFieldsHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.NullFieldsHostApi.search", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + NullFieldsSearchRequest nestedArg = (NullFieldsSearchRequest) args.get(0); + if (nestedArg == null) { + throw new NullPointerException("nestedArg unexpectedly null."); + } + NullFieldsSearchReply output = api.search(nestedArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + private static class NullFieldsFlutterApiCodec extends StandardMessageCodec { + public static final NullFieldsFlutterApiCodec INSTANCE = new NullFieldsFlutterApiCodec(); + + private NullFieldsFlutterApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return NullFieldsSearchReply.fromList((ArrayList) readValue(buffer)); + + case (byte) 129: + return NullFieldsSearchRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof NullFieldsSearchReply) { + stream.write(128); + writeValue(stream, ((NullFieldsSearchReply) value).toList()); + } else if (value instanceof NullFieldsSearchRequest) { + stream.write(129); + writeValue(stream, ((NullFieldsSearchRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class NullFieldsFlutterApi { + private final BinaryMessenger binaryMessenger; + + public NullFieldsFlutterApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by NullFieldsFlutterApi. */ + static MessageCodec getCodec() { + return NullFieldsFlutterApiCodec.INSTANCE; + } + + public void search( + @NonNull NullFieldsSearchRequest requestArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.NullFieldsFlutterApi.search", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(requestArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + NullFieldsSearchReply output = (NullFieldsSearchReply) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/NullableReturns.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/NullableReturns.java new file mode 100644 index 000000000000..20d13f71cb1a --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/NullableReturns.java @@ -0,0 +1,319 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class NullableReturns { + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface NullableReturnHostApi { + @Nullable + Long doit(); + + /** The codec used by NullableReturnHostApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + /** + * Sets up an instance of `NullableReturnHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, NullableReturnHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.NullableReturnHostApi.doit", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + Long output = api.doit(); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class NullableReturnFlutterApi { + private final BinaryMessenger binaryMessenger; + + public NullableReturnFlutterApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by NullableReturnFlutterApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + + public void doit(Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.NullableReturnFlutterApi.doit", getCodec()); + channel.send( + null, + channelReply -> { + @SuppressWarnings("ConstantConditions") + Long output = channelReply == null ? null : ((Number) channelReply).longValue(); + callback.reply(output); + }); + } + } + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface NullableArgHostApi { + @NonNull + Long doit(@Nullable Long x); + + /** The codec used by NullableArgHostApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + /** + * Sets up an instance of `NullableArgHostApi` to handle messages through the `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, NullableArgHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.NullableArgHostApi.doit", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + Number xArg = (Number) args.get(0); + Long output = api.doit((xArg == null) ? null : xArg.longValue()); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class NullableArgFlutterApi { + private final BinaryMessenger binaryMessenger; + + public NullableArgFlutterApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by NullableArgFlutterApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + + public void doit(@Nullable Long xArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.NullableArgFlutterApi.doit", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(xArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + Long output = channelReply == null ? null : ((Number) channelReply).longValue(); + callback.reply(output); + }); + } + } + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface NullableCollectionReturnHostApi { + @Nullable + List doit(); + + /** The codec used by NullableCollectionReturnHostApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + /** + * Sets up an instance of `NullableCollectionReturnHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, NullableCollectionReturnHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.NullableCollectionReturnHostApi.doit", + getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + List output = api.doit(); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class NullableCollectionReturnFlutterApi { + private final BinaryMessenger binaryMessenger; + + public NullableCollectionReturnFlutterApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by NullableCollectionReturnFlutterApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + + public void doit(Reply> callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.NullableCollectionReturnFlutterApi.doit", + getCodec()); + channel.send( + null, + channelReply -> { + @SuppressWarnings("ConstantConditions") + List output = (List) channelReply; + callback.reply(output); + }); + } + } + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface NullableCollectionArgHostApi { + @NonNull + List doit(@Nullable List x); + + /** The codec used by NullableCollectionArgHostApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + /** + * Sets up an instance of `NullableCollectionArgHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, NullableCollectionArgHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.NullableCollectionArgHostApi.doit", + getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + List xArg = (List) args.get(0); + List output = api.doit(xArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class NullableCollectionArgFlutterApi { + private final BinaryMessenger binaryMessenger; + + public NullableCollectionArgFlutterApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by NullableCollectionArgFlutterApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + + public void doit(@Nullable List xArg, Reply> callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.NullableCollectionArgFlutterApi.doit", + getCodec()); + channel.send( + new ArrayList(Collections.singletonList(xArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + List output = (List) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Pigeon.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Pigeon.java new file mode 100644 index 000000000000..579b3234e39a --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Pigeon.java @@ -0,0 +1,329 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class Pigeon { + + public enum AndroidLoadingState { + LOADING(0), + COMPLETE(1); + + private int index; + + private AndroidLoadingState(final int index) { + this.index = index; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class AndroidSetRequest { + private @Nullable Long value; + + public @Nullable Long getValue() { + return value; + } + + public void setValue(@Nullable Long setterArg) { + this.value = setterArg; + } + + private @Nullable AndroidLoadingState state; + + public @Nullable AndroidLoadingState getState() { + return state; + } + + public void setState(@Nullable AndroidLoadingState setterArg) { + this.state = setterArg; + } + + public static final class Builder { + private @Nullable Long value; + + public @NonNull Builder setValue(@Nullable Long setterArg) { + this.value = setterArg; + return this; + } + + private @Nullable AndroidLoadingState state; + + public @NonNull Builder setState(@Nullable AndroidLoadingState setterArg) { + this.state = setterArg; + return this; + } + + public @NonNull AndroidSetRequest build() { + AndroidSetRequest pigeonReturn = new AndroidSetRequest(); + pigeonReturn.setValue(value); + pigeonReturn.setState(state); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(value); + toListResult.add(state == null ? null : state.index); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull AndroidSetRequest fromList(@NonNull ArrayList list) { + AndroidSetRequest pigeonResult = new AndroidSetRequest(); + ArrayList unwrapped = list.get(0); + + Object value = unwrapped.get(0); + pigeonResult.setValue( + (value == null) ? null : ((value instanceof Integer) ? (Integer) value : (Long) value)); + Object state = unwrapped.get(1); + pigeonResult.setState(state == null ? null : AndroidLoadingState.values()[(int) state]); + return pigeonResult; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class AndroidNestedRequest { + private @Nullable String context; + + public @Nullable String getContext() { + return context; + } + + public void setContext(@Nullable String setterArg) { + this.context = setterArg; + } + + private @Nullable AndroidSetRequest request; + + public @Nullable AndroidSetRequest getRequest() { + return request; + } + + public void setRequest(@Nullable AndroidSetRequest setterArg) { + this.request = setterArg; + } + + public static final class Builder { + private @Nullable String context; + + public @NonNull Builder setContext(@Nullable String setterArg) { + this.context = setterArg; + return this; + } + + private @Nullable AndroidSetRequest request; + + public @NonNull Builder setRequest(@Nullable AndroidSetRequest setterArg) { + this.request = setterArg; + return this; + } + + public @NonNull AndroidNestedRequest build() { + AndroidNestedRequest pigeonReturn = new AndroidNestedRequest(); + pigeonReturn.setContext(context); + pigeonReturn.setRequest(request); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(context); + toListResult.add((request == null) ? null : request.toList()); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull AndroidNestedRequest fromList(@NonNull ArrayList list) { + AndroidNestedRequest pigeonResult = new AndroidNestedRequest(); + ArrayList unwrapped = list.get(0); + + Object context = unwrapped.get(0); + pigeonResult.setContext((String) context); + Object request = unwrapped.get(1); + pigeonResult.setRequest( + (request == null) ? null : AndroidSetRequest.fromList((ArrayList) request)); + return pigeonResult; + } + } + + private static class AndroidApiCodec extends StandardMessageCodec { + public static final AndroidApiCodec INSTANCE = new AndroidApiCodec(); + + private AndroidApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return AndroidSetRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof AndroidSetRequest) { + stream.write(128); + writeValue(stream, ((AndroidSetRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface AndroidApi { + void setValue(@NonNull AndroidSetRequest request); + + /** The codec used by AndroidApi. */ + static MessageCodec getCodec() { + return AndroidApiCodec.INSTANCE; + } + /** Sets up an instance of `AndroidApi` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, AndroidApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.AndroidApi.setValue", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + AndroidSetRequest requestArg = (AndroidSetRequest) args.get(0); + if (requestArg == null) { + throw new NullPointerException("requestArg unexpectedly null."); + } + api.setValue(requestArg); + wrapped.add(null); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + private static class AndroidNestedApiCodec extends StandardMessageCodec { + public static final AndroidNestedApiCodec INSTANCE = new AndroidNestedApiCodec(); + + private AndroidNestedApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return AndroidNestedRequest.fromList((ArrayList) readValue(buffer)); + + case (byte) 129: + return AndroidSetRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof AndroidNestedRequest) { + stream.write(128); + writeValue(stream, ((AndroidNestedRequest) value).toList()); + } else if (value instanceof AndroidSetRequest) { + stream.write(129); + writeValue(stream, ((AndroidSetRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface AndroidNestedApi { + void setValueWithContext(@NonNull AndroidNestedRequest request); + + /** The codec used by AndroidNestedApi. */ + static MessageCodec getCodec() { + return AndroidNestedApiCodec.INSTANCE; + } + /** + * Sets up an instance of `AndroidNestedApi` to handle messages through the `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, AndroidNestedApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.AndroidNestedApi.setValueWithContext", + getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + AndroidNestedRequest requestArg = (AndroidNestedRequest) args.get(0); + if (requestArg == null) { + throw new NullPointerException("requestArg unexpectedly null."); + } + api.setValueWithContext(requestArg); + wrapped.add(null); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/PigeonList.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/PigeonList.java new file mode 100644 index 000000000000..211b77234f26 --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/PigeonList.java @@ -0,0 +1,207 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class PigeonList { + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class TestMessage { + private @Nullable List testList; + + public @Nullable List getTestList() { + return testList; + } + + public void setTestList(@Nullable List setterArg) { + this.testList = setterArg; + } + + public static final class Builder { + private @Nullable List testList; + + public @NonNull Builder setTestList(@Nullable List setterArg) { + this.testList = setterArg; + return this; + } + + public @NonNull TestMessage build() { + TestMessage pigeonReturn = new TestMessage(); + pigeonReturn.setTestList(testList); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(testList); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull TestMessage fromList(@NonNull ArrayList list) { + TestMessage pigeonResult = new TestMessage(); + ArrayList unwrapped = list.get(0); + + Object testList = unwrapped.get(0); + pigeonResult.setTestList((List) testList); + return pigeonResult; + } + } + + private static class TestApiCodec extends StandardMessageCodec { + public static final TestApiCodec INSTANCE = new TestApiCodec(); + + private TestApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return TestMessage.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof TestMessage) { + stream.write(128); + writeValue(stream, ((TestMessage) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface TestApi { + void test(@NonNull TestMessage msg); + + /** The codec used by TestApi. */ + static MessageCodec getCodec() { + return TestApiCodec.INSTANCE; + } + /** Sets up an instance of `TestApi` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, TestApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.TestApi.test", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + TestMessage msgArg = (TestMessage) args.get(0); + if (msgArg == null) { + throw new NullPointerException("msgArg unexpectedly null."); + } + api.test(msgArg); + wrapped.add(null); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + private static class EchoApiCodec extends StandardMessageCodec { + public static final EchoApiCodec INSTANCE = new EchoApiCodec(); + + private EchoApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return TestMessage.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof TestMessage) { + stream.write(128); + writeValue(stream, ((TestMessage) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class EchoApi { + private final BinaryMessenger binaryMessenger; + + public EchoApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by EchoApi. */ + static MessageCodec getCodec() { + return EchoApiCodec.INSTANCE; + } + + public void echo(@NonNull TestMessage msgArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.EchoApi.echo", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(msgArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + TestMessage output = (TestMessage) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Primitive.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Primitive.java new file mode 100644 index 000000000000..1e57866f78ea --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/Primitive.java @@ -0,0 +1,468 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class Primitive { + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface PrimitiveHostApi { + @NonNull + Long anInt(@NonNull Long value); + + @NonNull + Boolean aBool(@NonNull Boolean value); + + @NonNull + String aString(@NonNull String value); + + @NonNull + Double aDouble(@NonNull Double value); + + @NonNull + Map aMap(@NonNull Map value); + + @NonNull + List aList(@NonNull List value); + + @NonNull + int[] anInt32List(@NonNull int[] value); + + @NonNull + List aBoolList(@NonNull List value); + + @NonNull + Map aStringIntMap(@NonNull Map value); + + /** The codec used by PrimitiveHostApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + /** + * Sets up an instance of `PrimitiveHostApi` to handle messages through the `binaryMessenger`. + */ + static void setup(BinaryMessenger binaryMessenger, PrimitiveHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.anInt", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + Number valueArg = (Number) args.get(0); + if (valueArg == null) { + throw new NullPointerException("valueArg unexpectedly null."); + } + Long output = api.anInt((valueArg == null) ? null : valueArg.longValue()); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aBool", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + Boolean valueArg = (Boolean) args.get(0); + if (valueArg == null) { + throw new NullPointerException("valueArg unexpectedly null."); + } + Boolean output = api.aBool(valueArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aString", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + String valueArg = (String) args.get(0); + if (valueArg == null) { + throw new NullPointerException("valueArg unexpectedly null."); + } + String output = api.aString(valueArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aDouble", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + Double valueArg = (Double) args.get(0); + if (valueArg == null) { + throw new NullPointerException("valueArg unexpectedly null."); + } + Double output = api.aDouble(valueArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aMap", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + Map valueArg = (Map) args.get(0); + if (valueArg == null) { + throw new NullPointerException("valueArg unexpectedly null."); + } + Map output = api.aMap(valueArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aList", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + List valueArg = (List) args.get(0); + if (valueArg == null) { + throw new NullPointerException("valueArg unexpectedly null."); + } + List output = api.aList(valueArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.anInt32List", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + int[] valueArg = (int[]) args.get(0); + if (valueArg == null) { + throw new NullPointerException("valueArg unexpectedly null."); + } + int[] output = api.anInt32List(valueArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aBoolList", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + List valueArg = (List) args.get(0); + if (valueArg == null) { + throw new NullPointerException("valueArg unexpectedly null."); + } + List output = api.aBoolList(valueArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveHostApi.aStringIntMap", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + Map valueArg = (Map) args.get(0); + if (valueArg == null) { + throw new NullPointerException("valueArg unexpectedly null."); + } + Map output = api.aStringIntMap(valueArg); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class PrimitiveFlutterApi { + private final BinaryMessenger binaryMessenger; + + public PrimitiveFlutterApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by PrimitiveFlutterApi. */ + static MessageCodec getCodec() { + return new StandardMessageCodec(); + } + + public void anInt(@NonNull Long valueArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.anInt", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(valueArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + Long output = channelReply == null ? null : ((Number) channelReply).longValue(); + callback.reply(output); + }); + } + + public void aBool(@NonNull Boolean valueArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aBool", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(valueArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + Boolean output = (Boolean) channelReply; + callback.reply(output); + }); + } + + public void aString(@NonNull String valueArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aString", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(valueArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + String output = (String) channelReply; + callback.reply(output); + }); + } + + public void aDouble(@NonNull Double valueArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aDouble", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(valueArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + Double output = (Double) channelReply; + callback.reply(output); + }); + } + + public void aMap(@NonNull Map valueArg, Reply> callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aMap", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(valueArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + Map output = (Map) channelReply; + callback.reply(output); + }); + } + + public void aList(@NonNull List valueArg, Reply> callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aList", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(valueArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + List output = (List) channelReply; + callback.reply(output); + }); + } + + public void anInt32List(@NonNull int[] valueArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.anInt32List", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(valueArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + int[] output = (int[]) channelReply; + callback.reply(output); + }); + } + + public void aBoolList(@NonNull List valueArg, Reply> callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aBoolList", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(valueArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + List output = (List) channelReply; + callback.reply(output); + }); + } + + public void aStringIntMap( + @NonNull Map valueArg, Reply> callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.PrimitiveFlutterApi.aStringIntMap", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(valueArg)), + channelReply -> { + @SuppressWarnings("ConstantConditions") + Map output = (Map) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidArgFlutter.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidArgFlutter.java new file mode 100644 index 000000000000..8a74b5962c34 --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidArgFlutter.java @@ -0,0 +1,138 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class VoidArgFlutter { + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class VoidArgFlutterResult { + private @Nullable Long code; + + public @Nullable Long getCode() { + return code; + } + + public void setCode(@Nullable Long setterArg) { + this.code = setterArg; + } + + public static final class Builder { + private @Nullable Long code; + + public @NonNull Builder setCode(@Nullable Long setterArg) { + this.code = setterArg; + return this; + } + + public @NonNull VoidArgFlutterResult build() { + VoidArgFlutterResult pigeonReturn = new VoidArgFlutterResult(); + pigeonReturn.setCode(code); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(code); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull VoidArgFlutterResult fromList(@NonNull ArrayList list) { + VoidArgFlutterResult pigeonResult = new VoidArgFlutterResult(); + ArrayList unwrapped = list.get(0); + + Object code = unwrapped.get(0); + pigeonResult.setCode( + (code == null) ? null : ((code instanceof Integer) ? (Integer) code : (Long) code)); + return pigeonResult; + } + } + + private static class VoidArgApiCodec extends StandardMessageCodec { + public static final VoidArgApiCodec INSTANCE = new VoidArgApiCodec(); + + private VoidArgApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return VoidArgFlutterResult.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof VoidArgFlutterResult) { + stream.write(128); + writeValue(stream, ((VoidArgFlutterResult) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class VoidArgApi { + private final BinaryMessenger binaryMessenger; + + public VoidArgApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by VoidArgApi. */ + static MessageCodec getCodec() { + return VoidArgApiCodec.INSTANCE; + } + + public void getCode(Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.VoidArgApi.getCode", getCodec()); + channel.send( + null, + channelReply -> { + @SuppressWarnings("ConstantConditions") + VoidArgFlutterResult output = (VoidArgFlutterResult) channelReply; + callback.reply(output); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidArgHost.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidArgHost.java new file mode 100644 index 000000000000..f29b588385c2 --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidArgHost.java @@ -0,0 +1,145 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class VoidArgHost { + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class VoidArgHostResult { + private @Nullable Long code; + + public @Nullable Long getCode() { + return code; + } + + public void setCode(@Nullable Long setterArg) { + this.code = setterArg; + } + + public static final class Builder { + private @Nullable Long code; + + public @NonNull Builder setCode(@Nullable Long setterArg) { + this.code = setterArg; + return this; + } + + public @NonNull VoidArgHostResult build() { + VoidArgHostResult pigeonReturn = new VoidArgHostResult(); + pigeonReturn.setCode(code); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(code); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull VoidArgHostResult fromList(@NonNull ArrayList list) { + VoidArgHostResult pigeonResult = new VoidArgHostResult(); + ArrayList unwrapped = list.get(0); + + Object code = unwrapped.get(0); + pigeonResult.setCode( + (code == null) ? null : ((code instanceof Integer) ? (Integer) code : (Long) code)); + return pigeonResult; + } + } + + private static class VoidArgHostApiCodec extends StandardMessageCodec { + public static final VoidArgHostApiCodec INSTANCE = new VoidArgHostApiCodec(); + + private VoidArgHostApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return VoidArgHostResult.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof VoidArgHostResult) { + stream.write(128); + writeValue(stream, ((VoidArgHostResult) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface VoidArgHostApi { + @NonNull + VoidArgHostResult getCode(); + + /** The codec used by VoidArgHostApi. */ + static MessageCodec getCodec() { + return VoidArgHostApiCodec.INSTANCE; + } + /** Sets up an instance of `VoidArgHostApi` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, VoidArgHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.VoidArgHostApi.getCode", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + VoidArgHostResult output = api.getCode(); + wrapped.add(output); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidFlutter.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidFlutter.java new file mode 100644 index 000000000000..9b120eb4f12b --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidFlutter.java @@ -0,0 +1,137 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class VoidFlutter { + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class VoidFlutterSetRequest { + private @Nullable Long value; + + public @Nullable Long getValue() { + return value; + } + + public void setValue(@Nullable Long setterArg) { + this.value = setterArg; + } + + public static final class Builder { + private @Nullable Long value; + + public @NonNull Builder setValue(@Nullable Long setterArg) { + this.value = setterArg; + return this; + } + + public @NonNull VoidFlutterSetRequest build() { + VoidFlutterSetRequest pigeonReturn = new VoidFlutterSetRequest(); + pigeonReturn.setValue(value); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(value); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull VoidFlutterSetRequest fromList(@NonNull ArrayList list) { + VoidFlutterSetRequest pigeonResult = new VoidFlutterSetRequest(); + ArrayList unwrapped = list.get(0); + + Object value = unwrapped.get(0); + pigeonResult.setValue( + (value == null) ? null : ((value instanceof Integer) ? (Integer) value : (Long) value)); + return pigeonResult; + } + } + + private static class VoidFlutterApiCodec extends StandardMessageCodec { + public static final VoidFlutterApiCodec INSTANCE = new VoidFlutterApiCodec(); + + private VoidFlutterApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return VoidFlutterSetRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof VoidFlutterSetRequest) { + stream.write(128); + writeValue(stream, ((VoidFlutterSetRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class VoidFlutterApi { + private final BinaryMessenger binaryMessenger; + + public VoidFlutterApi(BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + public interface Reply { + void reply(T reply); + } + /** The codec used by VoidFlutterApi. */ + static MessageCodec getCodec() { + return VoidFlutterApiCodec.INSTANCE; + } + + public void setValue(@NonNull VoidFlutterSetRequest requestArg, Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.VoidFlutterApi.setValue", getCodec()); + channel.send( + new ArrayList(Collections.singletonList(requestArg)), + channelReply -> { + callback.reply(null); + }); + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidHost.java b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidHost.java new file mode 100644 index 000000000000..aa350919f0d6 --- /dev/null +++ b/packages/pigeon/platform_tests/android_unit_tests/android/app/src/main/java/com/example/android_unit_tests/VoidHost.java @@ -0,0 +1,150 @@ +// 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 (v4.2.3), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package com.example.android_unit_tests; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"}) +public class VoidHost { + + /** Generated class from Pigeon that represents data sent in messages. */ + public static class VoidHostSetRequest { + private @Nullable Long value; + + public @Nullable Long getValue() { + return value; + } + + public void setValue(@Nullable Long setterArg) { + this.value = setterArg; + } + + public static final class Builder { + private @Nullable Long value; + + public @NonNull Builder setValue(@Nullable Long setterArg) { + this.value = setterArg; + return this; + } + + public @NonNull VoidHostSetRequest build() { + VoidHostSetRequest pigeonReturn = new VoidHostSetRequest(); + pigeonReturn.setValue(value); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(); + toListResult.add(value); + ArrayList wrapped = new ArrayList(); + wrapped.add(toListResult); + return wrapped; + } + + static @NonNull VoidHostSetRequest fromList(@NonNull ArrayList list) { + VoidHostSetRequest pigeonResult = new VoidHostSetRequest(); + ArrayList unwrapped = list.get(0); + + Object value = unwrapped.get(0); + pigeonResult.setValue( + (value == null) ? null : ((value instanceof Integer) ? (Integer) value : (Long) value)); + return pigeonResult; + } + } + + private static class VoidHostApiCodec extends StandardMessageCodec { + public static final VoidHostApiCodec INSTANCE = new VoidHostApiCodec(); + + private VoidHostApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return VoidHostSetRequest.fromList((ArrayList) readValue(buffer)); + + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof VoidHostSetRequest) { + stream.write(128); + writeValue(stream, ((VoidHostSetRequest) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface VoidHostApi { + void setValue(@NonNull VoidHostSetRequest request); + + /** The codec used by VoidHostApi. */ + static MessageCodec getCodec() { + return VoidHostApiCodec.INSTANCE; + } + /** Sets up an instance of `VoidHostApi` to handle messages through the `binaryMessenger`. */ + static void setup(BinaryMessenger binaryMessenger, VoidHostApi api) { + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.VoidHostApi.setValue", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + try { + ArrayList args = (ArrayList) message; + assert args != null; + VoidHostSetRequest requestArg = (VoidHostSetRequest) args.get(0); + if (requestArg == null) { + throw new NullPointerException("requestArg unexpectedly null."); + } + api.setValue(requestArg); + wrapped.add(null); + } catch (Error | RuntimeException exception) { + ArrayList wrappedError = wrapError(exception); + wrapped.add(wrappedError.get(0)); + wrapped.add(wrappedError.get(1)); + wrapped.add(wrappedError.get(2)); + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + + @NonNull + private static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(); + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + return errorList; + } +} diff --git a/packages/pigeon/platform_tests/windows_unit_tests/example/windows/flutter/ephemeral/.plugin_symlinks/windows_unit_tests b/packages/pigeon/platform_tests/windows_unit_tests/example/windows/flutter/ephemeral/.plugin_symlinks/windows_unit_tests new file mode 120000 index 000000000000..b1c1e7374e28 --- /dev/null +++ b/packages/pigeon/platform_tests/windows_unit_tests/example/windows/flutter/ephemeral/.plugin_symlinks/windows_unit_tests @@ -0,0 +1 @@ +/Users/tarrinneal/work/packages/packages/pigeon/platform_tests/windows_unit_tests/ \ No newline at end of file diff --git a/packages/pigeon/pubspec.yaml b/packages/pigeon/pubspec.yaml index 7d5060fc0f96..639d3e153fbc 100644 --- a/packages/pigeon/pubspec.yaml +++ b/packages/pigeon/pubspec.yaml @@ -2,7 +2,7 @@ name: pigeon description: Code generator tool to make communication between Flutter and the host platform type-safe and easier. repository: https://github.com/flutter/packages/tree/main/packages/pigeon issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3Apigeon -version: 4.2.5 # This must match the version in lib/generator_tools.dart +version: 4.2.6 # This must match the version in lib/generator_tools.dart environment: sdk: ">=2.12.0 <3.0.0"