Skip to content
Merged
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
8 changes: 4 additions & 4 deletions wire-compiler/api/wire-compiler.api
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public final class com/squareup/wire/schema/JavaTarget : com/squareup/wire/schem
}

public final class com/squareup/wire/schema/KotlinTarget : com/squareup/wire/schema/Target {
public fun <init> (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZZZZLcom/squareup/wire/kotlin/RpcCallStyle;Lcom/squareup/wire/kotlin/RpcRole;ZILjava/lang/String;ZZLcom/squareup/wire/kotlin/EnumMode;Z)V
public synthetic fun <init> (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZZZZLcom/squareup/wire/kotlin/RpcCallStyle;Lcom/squareup/wire/kotlin/RpcRole;ZILjava/lang/String;ZZLcom/squareup/wire/kotlin/EnumMode;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZZZZLcom/squareup/wire/kotlin/RpcCallStyle;Lcom/squareup/wire/kotlin/RpcRole;ZILjava/lang/String;ZZLcom/squareup/wire/kotlin/EnumMode;ZZ)V
public synthetic fun <init> (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZZZZLcom/squareup/wire/kotlin/RpcCallStyle;Lcom/squareup/wire/kotlin/RpcRole;ZILjava/lang/String;ZZLcom/squareup/wire/kotlin/EnumMode;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/util/List;
public final fun component10 ()Lcom/squareup/wire/kotlin/RpcRole;
public final fun component11 ()Z
Expand All @@ -134,8 +134,8 @@ public final class com/squareup/wire/schema/KotlinTarget : com/squareup/wire/sch
public final fun component7 ()Z
public final fun component8 ()Z
public final fun component9 ()Lcom/squareup/wire/kotlin/RpcCallStyle;
public final fun copy (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZZZZLcom/squareup/wire/kotlin/RpcCallStyle;Lcom/squareup/wire/kotlin/RpcRole;ZILjava/lang/String;ZZLcom/squareup/wire/kotlin/EnumMode;Z)Lcom/squareup/wire/schema/KotlinTarget;
public static synthetic fun copy$default (Lcom/squareup/wire/schema/KotlinTarget;Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZZZZLcom/squareup/wire/kotlin/RpcCallStyle;Lcom/squareup/wire/kotlin/RpcRole;ZILjava/lang/String;ZZLcom/squareup/wire/kotlin/EnumMode;ZILjava/lang/Object;)Lcom/squareup/wire/schema/KotlinTarget;
public final fun copy (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZZZZLcom/squareup/wire/kotlin/RpcCallStyle;Lcom/squareup/wire/kotlin/RpcRole;ZILjava/lang/String;ZZLcom/squareup/wire/kotlin/EnumMode;ZZ)Lcom/squareup/wire/schema/KotlinTarget;
public static synthetic fun copy$default (Lcom/squareup/wire/schema/KotlinTarget;Ljava/util/List;Ljava/util/List;ZLjava/lang/String;ZZZZLcom/squareup/wire/kotlin/RpcCallStyle;Lcom/squareup/wire/kotlin/RpcRole;ZILjava/lang/String;ZZLcom/squareup/wire/kotlin/EnumMode;ZZILjava/lang/Object;)Lcom/squareup/wire/schema/KotlinTarget;
public fun copyTarget (Ljava/util/List;Ljava/util/List;ZLjava/lang/String;)Lcom/squareup/wire/schema/Target;
public fun equals (Ljava/lang/Object;)Z
public final fun getAndroid ()Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ data class KotlinTarget(
* when targeting Kotlin/JS, where `Long` cursors are inefficient.
*/
private val emitProtoReader32: Boolean = false,

/**
* If true, the generated classes will be mutable..
*/
private val mutableTypes: Boolean = false,
) : Target() {
override fun newHandler(): SchemaHandler {
return KotlinSchemaHandler(
Expand All @@ -159,6 +164,7 @@ data class KotlinTarget(
escapeKotlinKeywords = escapeKotlinKeywords,
enumMode = enumMode,
emitProtoReader32 = emitProtoReader32,
mutableTypes = mutableTypes,
)
}

Expand Down
6 changes: 6 additions & 0 deletions wire-golden-files/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ plugins {
}

wire {
kotlin {
includes = listOf("squareup.wire.mutable.*")
out = "src/main/kotlin"
mutableTypes = true
}

kotlin {
includes = listOf("squareup.wire.unrecognized_constant.*")
out = "src/main/kotlin"
Expand Down
3 changes: 0 additions & 3 deletions wire-golden-files/src/main/kotlin/HundredsFields.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import kotlin.String
import kotlin.Suppress
import okio.ByteString

/**
* import "google/protobuf/descriptor.proto";
*/
public class HundredsFields(
@field:WireField(
tag = 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source: squareup.wire.mutable.Header in squareup/wire/mutable_types.proto
@file:Suppress(
"DEPRECATION",
"RUNTIME_ANNOTATION_NOT_SUPPORTED",
)

package squareup.wire.mutable

import com.squareup.wire.FieldEncoding
import com.squareup.wire.Message
import com.squareup.wire.ProtoAdapter
import com.squareup.wire.ProtoReader
import com.squareup.wire.ProtoWriter
import com.squareup.wire.ReverseProtoWriter
import com.squareup.wire.Syntax.PROTO_2
import com.squareup.wire.WireField
import com.squareup.wire.`internal`.JvmField
import kotlin.Any
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.DeprecationLevel
import kotlin.Int
import kotlin.Long
import kotlin.Nothing
import kotlin.String
import kotlin.Suppress
import kotlin.UnsupportedOperationException
import okio.ByteString

public class MutableHeader(
@field:WireField(
tag = 1,
adapter = "com.squareup.wire.ProtoAdapter#UINT64",
schemaIndex = 0,
)
public var id: Long? = null,
override var unknownFields: ByteString = ByteString.EMPTY,
) : Message<MutableHeader, Nothing>(ADAPTER, unknownFields) {
@Deprecated(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw UnsupportedOperationException("newBuilder() is unsupported for mutable message types")

override fun equals(other: Any?): Boolean {

Choose a reason for hiding this comment

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

should this be by-identity rather than by-value? Equals is weird on mutable things

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you mean that we should only support referential equality ?

I think it's also okay for us to also compare the values. Otherwise it might just end up being confusing.

Choose a reason for hiding this comment

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

Sounds good.

if (other === this) return true
if (other !is MutableHeader) return false
if (unknownFields != other.unknownFields) return false
if (id != other.id) return false
return true
}

override fun hashCode(): Int {
var result = 0
result = unknownFields.hashCode()
result = result * 37 + (id?.hashCode() ?: 0)
return result
}

override fun toString(): String {
val result = mutableListOf<String>()
if (id != null) result += """id=$id"""
return result.joinToString(prefix = "MutableHeader{", separator = ", ", postfix = "}")
}

public companion object {
@JvmField
public val ADAPTER: ProtoAdapter<MutableHeader> = object : ProtoAdapter<MutableHeader>(
FieldEncoding.LENGTH_DELIMITED,
MutableHeader::class,
"type.googleapis.com/squareup.wire.mutable.Header",
PROTO_2,
null,
"squareup/wire/mutable_types.proto"
) {
override fun encodedSize(`value`: MutableHeader): Int {
var size = value.unknownFields.size
size += ProtoAdapter.UINT64.encodedSizeWithTag(1, value.id)
return size
}

override fun encode(writer: ProtoWriter, `value`: MutableHeader) {
ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.id)
writer.writeBytes(value.unknownFields)
}

override fun encode(writer: ReverseProtoWriter, `value`: MutableHeader) {
writer.writeBytes(value.unknownFields)
ProtoAdapter.UINT64.encodeWithTag(writer, 1, value.id)
}

override fun decode(reader: ProtoReader): MutableHeader {
var id: Long? = null
val unknownFields = reader.forEachTag { tag ->
when (tag) {
1 -> id = ProtoAdapter.UINT64.decode(reader)
else -> reader.readUnknownField(tag)
}
}
return MutableHeader(
id = id,
unknownFields = unknownFields
)
}

override fun redact(`value`: MutableHeader): MutableHeader = throw UnsupportedOperationException("redact() is unsupported for mutable message types")
}

private const val serialVersionUID: Long = 0L
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source: squareup.wire.mutable.Packet in squareup/wire/mutable_types.proto
@file:Suppress(
"DEPRECATION",
"RUNTIME_ANNOTATION_NOT_SUPPORTED",
)

package squareup.wire.mutable

import com.squareup.wire.FieldEncoding
import com.squareup.wire.Message
import com.squareup.wire.ProtoAdapter
import com.squareup.wire.ProtoReader
import com.squareup.wire.ProtoWriter
import com.squareup.wire.ReverseProtoWriter
import com.squareup.wire.Syntax.PROTO_2
import com.squareup.wire.WireField
import com.squareup.wire.`internal`.JvmField
import kotlin.Any
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.DeprecationLevel
import kotlin.Int
import kotlin.Long
import kotlin.Nothing
import kotlin.String
import kotlin.Suppress
import kotlin.UnsupportedOperationException
import okio.ByteString

public class MutablePacket(
@field:WireField(
tag = 1,
adapter = "squareup.wire.mutable.MutableHeader#ADAPTER",
declaredName = "header",
schemaIndex = 0,
)
public var header_: MutableHeader? = null,
@field:WireField(
tag = 2,
adapter = "squareup.wire.mutable.MutablePayload#ADAPTER",
schemaIndex = 1,
)
public var payload: MutablePayload? = null,
override var unknownFields: ByteString = ByteString.EMPTY,
) : Message<MutablePacket, Nothing>(ADAPTER, unknownFields) {
@Deprecated(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw UnsupportedOperationException("newBuilder() is unsupported for mutable message types")

override fun equals(other: Any?): Boolean {
if (other === this) return true
if (other !is MutablePacket) return false
if (unknownFields != other.unknownFields) return false
if (header_ != other.header_) return false
if (payload != other.payload) return false
return true
}

override fun hashCode(): Int {
var result = 0
result = unknownFields.hashCode()
result = result * 37 + (header_?.hashCode() ?: 0)
result = result * 37 + (payload?.hashCode() ?: 0)
return result
}

override fun toString(): String {
val result = mutableListOf<String>()
if (header_ != null) result += """header_=$header_"""
if (payload != null) result += """payload=$payload"""
return result.joinToString(prefix = "MutablePacket{", separator = ", ", postfix = "}")
}

public companion object {
@JvmField
public val ADAPTER: ProtoAdapter<MutablePacket> = object : ProtoAdapter<MutablePacket>(
FieldEncoding.LENGTH_DELIMITED,
MutablePacket::class,
"type.googleapis.com/squareup.wire.mutable.Packet",
PROTO_2,
null,
"squareup/wire/mutable_types.proto"
) {
override fun encodedSize(`value`: MutablePacket): Int {
var size = value.unknownFields.size
size += MutableHeader.ADAPTER.encodedSizeWithTag(1, value.header_)
size += MutablePayload.ADAPTER.encodedSizeWithTag(2, value.payload)
return size
}

override fun encode(writer: ProtoWriter, `value`: MutablePacket) {
MutableHeader.ADAPTER.encodeWithTag(writer, 1, value.header_)
MutablePayload.ADAPTER.encodeWithTag(writer, 2, value.payload)
writer.writeBytes(value.unknownFields)
}

override fun encode(writer: ReverseProtoWriter, `value`: MutablePacket) {
writer.writeBytes(value.unknownFields)
MutablePayload.ADAPTER.encodeWithTag(writer, 2, value.payload)
MutableHeader.ADAPTER.encodeWithTag(writer, 1, value.header_)
}

override fun decode(reader: ProtoReader): MutablePacket {
var header_: MutableHeader? = null
var payload: MutablePayload? = null
val unknownFields = reader.forEachTag { tag ->
when (tag) {
1 -> header_ = MutableHeader.ADAPTER.decode(reader)
2 -> payload = MutablePayload.ADAPTER.decode(reader)
else -> reader.readUnknownField(tag)
}
}
return MutablePacket(
header_ = header_,
payload = payload,
unknownFields = unknownFields
)
}

override fun redact(`value`: MutablePacket): MutablePacket = throw UnsupportedOperationException("redact() is unsupported for mutable message types")
}

private const val serialVersionUID: Long = 0L
}
}
Loading
Loading