Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ public class AnyInternal: com.google.protobuf.kotlin.Any, kotlinx.rpc.protobuf.i
}
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public fun copyInternal(body: AnyInternal.() -> Unit): AnyInternal {
val copy = AnyInternal()
copy.typeUrl = typeUrl
copy.value = value.copyOf()
copy.apply(body)
return copy
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Any> {
public override fun encode(value: com.google.protobuf.kotlin.Any): kotlinx.rpc.protobuf.input.stream.InputStream {
Expand Down Expand Up @@ -74,12 +83,32 @@ public class AnyInternal: com.google.protobuf.kotlin.Any, kotlinx.rpc.protobuf.i
public companion object
}

/**
* Constructs a new message.
* ```
* val message = Any {
* typeUrl = ...
* }
* ```
*/
public operator fun com.google.protobuf.kotlin.Any.Companion.invoke(body: com.google.protobuf.kotlin.AnyInternal.() -> Unit): com.google.protobuf.kotlin.Any {
val msg = com.google.protobuf.kotlin.AnyInternal().apply(body)
msg.checkRequiredFields()
return msg
}

/**
* Copies the original message, including unknown fields.
* ```
* val copy = original.copy {
* typeUrl = ...
* }
* ```
*/
public fun com.google.protobuf.kotlin.Any.copy(body: com.google.protobuf.kotlin.AnyInternal.() -> Unit = {}): com.google.protobuf.kotlin.Any {
return this.asInternal().copyInternal(body)
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public fun com.google.protobuf.kotlin.AnyInternal.checkRequiredFields() {
// no required fields to check
Expand All @@ -104,11 +133,9 @@ public fun com.google.protobuf.kotlin.AnyInternal.Companion.decodeWith(msg: com.
tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
msg.typeUrl = decoder.readString()
}

tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
msg.value = decoder.readBytes()
}

else -> {
if (tag.wireType == kotlinx.rpc.protobuf.internal.WireType.END_GROUP) {
throw kotlinx.rpc.protobuf.internal.ProtobufDecodingException("Unexpected END_GROUP tag.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ public class ApiInternal: com.google.protobuf.kotlin.Api, kotlinx.rpc.protobuf.i
}
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public fun copyInternal(body: ApiInternal.() -> Unit): ApiInternal {
val copy = ApiInternal()
copy.name = name
copy.methods = methods.map { it.copy() }
copy.options = options.map { it.copy() }
copy.version = version
if (presenceMask[0]) {
copy.sourceContext = sourceContext.copy()
}

copy.mixins = mixins.map { it.copy() }
copy.syntax = syntax
copy.apply(body)
return copy
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Api> {
public override fun encode(value: com.google.protobuf.kotlin.Api): kotlinx.rpc.protobuf.input.stream.InputStream {
Expand Down Expand Up @@ -165,6 +182,20 @@ public class MethodInternal: com.google.protobuf.kotlin.Method, kotlinx.rpc.prot
}
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public fun copyInternal(body: MethodInternal.() -> Unit): MethodInternal {
val copy = MethodInternal()
copy.name = name
copy.requestTypeUrl = requestTypeUrl
copy.requestStreaming = requestStreaming
copy.responseTypeUrl = responseTypeUrl
copy.responseStreaming = responseStreaming
copy.options = options.map { it.copy() }
copy.syntax = syntax
copy.apply(body)
return copy
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Method> {
public override fun encode(value: com.google.protobuf.kotlin.Method): kotlinx.rpc.protobuf.input.stream.InputStream {
Expand Down Expand Up @@ -234,6 +265,15 @@ public class MixinInternal: com.google.protobuf.kotlin.Mixin, kotlinx.rpc.protob
}
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public fun copyInternal(body: MixinInternal.() -> Unit): MixinInternal {
val copy = MixinInternal()
copy.name = name
copy.root = root
copy.apply(body)
return copy
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Mixin> {
public override fun encode(value: com.google.protobuf.kotlin.Mixin): kotlinx.rpc.protobuf.input.stream.InputStream {
Expand Down Expand Up @@ -262,24 +302,84 @@ public class MixinInternal: com.google.protobuf.kotlin.Mixin, kotlinx.rpc.protob
public companion object
}

/**
* Constructs a new message.
* ```
* val message = Api {
* name = ...
* }
* ```
*/
public operator fun com.google.protobuf.kotlin.Api.Companion.invoke(body: com.google.protobuf.kotlin.ApiInternal.() -> Unit): com.google.protobuf.kotlin.Api {
val msg = com.google.protobuf.kotlin.ApiInternal().apply(body)
msg.checkRequiredFields()
return msg
}

/**
* Copies the original message, including unknown fields.
* ```
* val copy = original.copy {
* name = ...
* }
* ```
*/
public fun com.google.protobuf.kotlin.Api.copy(body: com.google.protobuf.kotlin.ApiInternal.() -> Unit = {}): com.google.protobuf.kotlin.Api {
return this.asInternal().copyInternal(body)
}

/**
* Constructs a new message.
* ```
* val message = Method {
* name = ...
* }
* ```
*/
public operator fun com.google.protobuf.kotlin.Method.Companion.invoke(body: com.google.protobuf.kotlin.MethodInternal.() -> Unit): com.google.protobuf.kotlin.Method {
val msg = com.google.protobuf.kotlin.MethodInternal().apply(body)
msg.checkRequiredFields()
return msg
}

/**
* Copies the original message, including unknown fields.
* ```
* val copy = original.copy {
* name = ...
* }
* ```
*/
public fun com.google.protobuf.kotlin.Method.copy(body: com.google.protobuf.kotlin.MethodInternal.() -> Unit = {}): com.google.protobuf.kotlin.Method {
return this.asInternal().copyInternal(body)
}

/**
* Constructs a new message.
* ```
* val message = Mixin {
* name = ...
* }
* ```
*/
public operator fun com.google.protobuf.kotlin.Mixin.Companion.invoke(body: com.google.protobuf.kotlin.MixinInternal.() -> Unit): com.google.protobuf.kotlin.Mixin {
val msg = com.google.protobuf.kotlin.MixinInternal().apply(body)
msg.checkRequiredFields()
return msg
}

/**
* Copies the original message, including unknown fields.
* ```
* val copy = original.copy {
* name = ...
* }
* ```
*/
public fun com.google.protobuf.kotlin.Mixin.copy(body: com.google.protobuf.kotlin.MixinInternal.() -> Unit = {}): com.google.protobuf.kotlin.Mixin {
return this.asInternal().copyInternal(body)
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public fun com.google.protobuf.kotlin.ApiInternal.checkRequiredFields() {
// no required fields to check
Expand Down Expand Up @@ -345,41 +445,34 @@ public fun com.google.protobuf.kotlin.ApiInternal.Companion.decodeWith(msg: com.
tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
msg.name = decoder.readString()
}

tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
val elem = com.google.protobuf.kotlin.MethodInternal()
decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.MethodInternal::decodeWith)
(msg.methods as MutableList).add(elem)
}

tag.fieldNr == 3 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
val elem = com.google.protobuf.kotlin.OptionInternal()
decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.OptionInternal::decodeWith)
(msg.options as MutableList).add(elem)
}

tag.fieldNr == 4 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
msg.version = decoder.readString()
}

tag.fieldNr == 5 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
if (!msg.presenceMask[0]) {
msg.sourceContext = com.google.protobuf.kotlin.SourceContextInternal()
}

decoder.readMessage(msg.sourceContext.asInternal(), com.google.protobuf.kotlin.SourceContextInternal::decodeWith)
}

tag.fieldNr == 6 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
val elem = com.google.protobuf.kotlin.MixinInternal()
decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.MixinInternal::decodeWith)
(msg.mixins as MutableList).add(elem)
}

tag.fieldNr == 7 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
msg.syntax = com.google.protobuf.kotlin.Syntax.fromNumber(decoder.readEnum())
}

else -> {
if (tag.wireType == kotlinx.rpc.protobuf.internal.WireType.END_GROUP) {
throw kotlinx.rpc.protobuf.internal.ProtobufDecodingException("Unexpected END_GROUP tag.")
Expand Down Expand Up @@ -479,33 +572,26 @@ public fun com.google.protobuf.kotlin.MethodInternal.Companion.decodeWith(msg: c
tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
msg.name = decoder.readString()
}

tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
msg.requestTypeUrl = decoder.readString()
}

tag.fieldNr == 3 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
msg.requestStreaming = decoder.readBool()
}

tag.fieldNr == 4 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
msg.responseTypeUrl = decoder.readString()
}

tag.fieldNr == 5 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
msg.responseStreaming = decoder.readBool()
}

tag.fieldNr == 6 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
val elem = com.google.protobuf.kotlin.OptionInternal()
decoder.readMessage(elem.asInternal(), com.google.protobuf.kotlin.OptionInternal::decodeWith)
(msg.options as MutableList).add(elem)
}

tag.fieldNr == 7 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
msg.syntax = com.google.protobuf.kotlin.Syntax.fromNumber(decoder.readEnum())
}

else -> {
if (tag.wireType == kotlinx.rpc.protobuf.internal.WireType.END_GROUP) {
throw kotlinx.rpc.protobuf.internal.ProtobufDecodingException("Unexpected END_GROUP tag.")
Expand Down Expand Up @@ -580,11 +666,9 @@ public fun com.google.protobuf.kotlin.MixinInternal.Companion.decodeWith(msg: co
tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
msg.name = decoder.readString()
}

tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.LENGTH_DELIMITED -> {
msg.root = decoder.readString()
}

else -> {
if (tag.wireType == kotlinx.rpc.protobuf.internal.WireType.END_GROUP) {
throw kotlinx.rpc.protobuf.internal.ProtobufDecodingException("Unexpected END_GROUP tag.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ public class DurationInternal: com.google.protobuf.kotlin.Duration, kotlinx.rpc.
}
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public fun copyInternal(body: DurationInternal.() -> Unit): DurationInternal {
val copy = DurationInternal()
copy.seconds = seconds
copy.nanos = nanos
copy.apply(body)
return copy
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public object CODEC: kotlinx.rpc.grpc.codec.MessageCodec<com.google.protobuf.kotlin.Duration> {
public override fun encode(value: com.google.protobuf.kotlin.Duration): kotlinx.rpc.protobuf.input.stream.InputStream {
Expand Down Expand Up @@ -74,12 +83,32 @@ public class DurationInternal: com.google.protobuf.kotlin.Duration, kotlinx.rpc.
public companion object
}

/**
* Constructs a new message.
* ```
* val message = Duration {
* seconds = ...
* }
* ```
*/
public operator fun com.google.protobuf.kotlin.Duration.Companion.invoke(body: com.google.protobuf.kotlin.DurationInternal.() -> Unit): com.google.protobuf.kotlin.Duration {
val msg = com.google.protobuf.kotlin.DurationInternal().apply(body)
msg.checkRequiredFields()
return msg
}

/**
* Copies the original message, including unknown fields.
* ```
* val copy = original.copy {
* seconds = ...
* }
* ```
*/
public fun com.google.protobuf.kotlin.Duration.copy(body: com.google.protobuf.kotlin.DurationInternal.() -> Unit = {}): com.google.protobuf.kotlin.Duration {
return this.asInternal().copyInternal(body)
}

@kotlinx.rpc.internal.utils.InternalRpcApi
public fun com.google.protobuf.kotlin.DurationInternal.checkRequiredFields() {
// no required fields to check
Expand All @@ -104,11 +133,9 @@ public fun com.google.protobuf.kotlin.DurationInternal.Companion.decodeWith(msg:
tag.fieldNr == 1 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
msg.seconds = decoder.readInt64()
}

tag.fieldNr == 2 && tag.wireType == kotlinx.rpc.protobuf.internal.WireType.VARINT -> {
msg.nanos = decoder.readInt32()
}

else -> {
if (tag.wireType == kotlinx.rpc.protobuf.internal.WireType.END_GROUP) {
throw kotlinx.rpc.protobuf.internal.ProtobufDecodingException("Unexpected END_GROUP tag.")
Expand Down
Loading
Loading