Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 5 additions & 2 deletions packages/pigeon/lib/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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',
);
Expand Down
3 changes: 3 additions & 0 deletions packages/pigeon/pigeons/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
// Copyright 2013 The Flutter Authors. All rights reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are all these added files? Were these added by mistake?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's really strange, these weren't in my local git info. I'll fix it.

// 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<Any?>? = null,
val aMap: Map<Any, Any?>? = null,
val nestedList: List<List<Boolean?>?>? = null,
val mapWithAnnotations: Map<String?, String?>? = null,
val mapWithObject: Map<String?, Any?>? = null

) {
companion object {
@Suppress("UNCHECKED_CAST")
fun fromList(result: List<Any?>): Everything {
val list = result.first() as List<Any?>
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<Any?>
val aMap = list[9] as? Map<Any, Any?>
val nestedList = list[10] as? List<List<Boolean?>?>
val mapWithAnnotations = list[11] as? Map<String?, String?>
val mapWithObject = list[12] as? Map<String?, Any?>

return Everything(aBool, anInt, aDouble, aString, aByteArray, a4ByteArray, a8ByteArray, aFloatArray, aList, aMap, nestedList, mapWithAnnotations, mapWithObject)
}
}
fun toList(): MutableList<MutableList<Any?>> {
val list = mutableListOf<Any?>()
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<MutableList<Any?>>(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<Any?>)?.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<Any?> 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<Any?>(binaryMessenger, "dev.flutter.pigeon.HostEverything.giveMeEverything", codec)
if (api != null) {
channel.setMessageHandler { _, reply ->
val wrapped = mutableListOf<Any?>()
try {
wrapped.add(api.giveMeEverything())
} catch (exception: Error) {
wrapped.add(wrapError(exception))

reply.reply(wrapped)
}
}} else {
channel.setMessageHandler(null)
}
}
run {
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.HostEverything.echo", codec)
if (api != null) {
channel.setMessageHandler { message, reply ->
val wrapped = mutableListOf<Any?>()
try {
val args = message as List<Any?>
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<Any?>)?.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<Any?> by lazy {
FlutterEverythingCodec
}
}
fun giveMeEverything(callback: (Everything) -> Unit) {
val channel = BasicMessageChannel<Any?>(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<Any?>(binaryMessenger, "dev.flutter.pigeon.FlutterEverything.echo", codec)
channel.send(listOf(everythingArg)) {
val result = it as Everything
callback(result)
}
}
}

private fun wrapResult(result: Any?): List<Any?> {
return listOf(result)
}

private fun wrapError(exception: Throwable): List<Any> {
return listOf<Any>(
exception.javaClass.simpleName,
exception.toString(),
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)
)
}
Original file line number Diff line number Diff line change
@@ -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<Any?> by lazy {
StandardMessageCodec()
}
}
fun doit(callback: () -> Unit) {
val channel = BasicMessageChannel<Any?>(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<Any?> 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<Any?>(binaryMessenger, "dev.flutter.pigeon.AllVoidHostApi.doit", codec)
if (api != null) {
channel.setMessageHandler { _, reply ->
val wrapped = mutableListOf<Any?>()
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<Any?> {
return listOf(result)
}

private fun wrapError(exception: Throwable): List<Any> {
return listOf<Any>(
exception.javaClass.simpleName,
exception.toString(),
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)
)
}
Loading