|
|
@ -746,10 +746,10 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl( |
|
|
|
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" |
|
|
|
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" |
|
|
|
"@com.google.protobuf.kotlin.ProtoDslMarker\n"); |
|
|
|
"@com.google.protobuf.kotlin.ProtoDslMarker\n"); |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"class Dsl private constructor(\n" |
|
|
|
"public class Dsl private constructor(\n" |
|
|
|
" private val _builder: $message$.Builder\n" |
|
|
|
" private val _builder: $message$.Builder\n" |
|
|
|
") {\n" |
|
|
|
") {\n" |
|
|
|
" companion object {\n" |
|
|
|
" public companion object {\n" |
|
|
|
" @kotlin.jvm.JvmSynthetic\n" |
|
|
|
" @kotlin.jvm.JvmSynthetic\n" |
|
|
|
" @kotlin.PublishedApi\n" |
|
|
|
" @kotlin.PublishedApi\n" |
|
|
|
" internal fun _create(builder: $message$.Builder): Dsl = " |
|
|
|
" internal fun _create(builder: $message$.Builder): Dsl = " |
|
|
@ -772,10 +772,10 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl( |
|
|
|
|
|
|
|
|
|
|
|
for (auto oneof : oneofs_) { |
|
|
|
for (auto oneof : oneofs_) { |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n" |
|
|
|
"public val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n" |
|
|
|
" @JvmName(\"get$oneof_capitalized_name$Case\")\n" |
|
|
|
" @JvmName(\"get$oneof_capitalized_name$Case\")\n" |
|
|
|
" get() = _builder.get$oneof_capitalized_name$Case()\n\n" |
|
|
|
" get() = _builder.get$oneof_capitalized_name$Case()\n\n" |
|
|
|
"fun clear$oneof_capitalized_name$() {\n" |
|
|
|
"public fun clear$oneof_capitalized_name$() {\n" |
|
|
|
" _builder.clear$oneof_capitalized_name$()\n" |
|
|
|
" _builder.clear$oneof_capitalized_name$()\n" |
|
|
|
"}\n", |
|
|
|
"}\n", |
|
|
|
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name, |
|
|
|
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name, |
|
|
@ -802,7 +802,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers( |
|
|
|
printer->Print("@com.google.errorprone.annotations.CheckReturnValue\n"); |
|
|
|
printer->Print("@com.google.errorprone.annotations.CheckReturnValue\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> " |
|
|
|
"public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> " |
|
|
|
"kotlin.Unit): $message$ =\n" |
|
|
|
"kotlin.Unit): $message$ =\n" |
|
|
|
" $message_kt$.Dsl._create($message$.newBuilder()).apply { block() " |
|
|
|
" $message_kt$.Dsl._create($message$.newBuilder()).apply { block() " |
|
|
|
"}._build()\n", |
|
|
|
"}._build()\n", |
|
|
@ -814,7 +814,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers( |
|
|
|
EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true))); |
|
|
|
EscapeKotlinKeywords(name_resolver_->GetClassName(descriptor_, true))); |
|
|
|
|
|
|
|
|
|
|
|
WriteMessageDocComment(printer, descriptor_, /* kdoc */ true); |
|
|
|
WriteMessageDocComment(printer, descriptor_, /* kdoc */ true); |
|
|
|
printer->Print("object $name$Kt {\n", "name", descriptor_->name()); |
|
|
|
printer->Print("public object $name$Kt {\n", "name", descriptor_->name()); |
|
|
|
printer->Indent(); |
|
|
|
printer->Indent(); |
|
|
|
GenerateKotlinDsl(printer); |
|
|
|
GenerateKotlinDsl(printer); |
|
|
|
for (int i = 0; i < descriptor_->nested_type_count(); i++) { |
|
|
|
for (int i = 0; i < descriptor_->nested_type_count(); i++) { |
|
|
@ -832,7 +832,7 @@ void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers( |
|
|
|
printer->Print("@com.google.errorprone.annotations.CheckReturnValue\n"); |
|
|
|
printer->Print("@com.google.errorprone.annotations.CheckReturnValue\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"inline fun $message$.copy(block: $message_kt$.Dsl.() -> " |
|
|
|
"public inline fun $message$.copy(block: $message_kt$.Dsl.() -> " |
|
|
|
"kotlin.Unit): $message$ =\n" |
|
|
|
"kotlin.Unit): $message$ =\n" |
|
|
|
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() " |
|
|
|
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() " |
|
|
|
"}._build()\n\n", |
|
|
|
"}._build()\n\n", |
|
|
@ -879,7 +879,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@Suppress(\"UNCHECKED_CAST\")\n" |
|
|
|
"@Suppress(\"UNCHECKED_CAST\")\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"operator fun <T : kotlin.Any> get(extension: " |
|
|
|
"public operator fun <T : kotlin.Any> get(extension: " |
|
|
|
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n" |
|
|
|
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n" |
|
|
|
" return if (extension.isRepeated) {\n" |
|
|
|
" return if (extension.isRepeated) {\n" |
|
|
|
" get(extension as com.google.protobuf.ExtensionLite<$message$, " |
|
|
|
" get(extension as com.google.protobuf.ExtensionLite<$message$, " |
|
|
@ -895,7 +895,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
"@kotlin.OptIn" |
|
|
|
"@kotlin.OptIn" |
|
|
|
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" |
|
|
|
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" |
|
|
|
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n" |
|
|
|
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n" |
|
|
|
"operator fun <E : kotlin.Any> get(\n" |
|
|
|
"public operator fun <E : kotlin.Any> get(\n" |
|
|
|
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n" |
|
|
|
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n" |
|
|
|
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n" |
|
|
|
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n" |
|
|
|
" return com.google.protobuf.kotlin.ExtensionList(extension, " |
|
|
|
" return com.google.protobuf.kotlin.ExtensionList(extension, " |
|
|
@ -905,7 +905,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
|
|
|
|
|
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"operator fun contains(extension: " |
|
|
|
"public operator fun contains(extension: " |
|
|
|
"com.google.protobuf.ExtensionLite<$message$, *>): " |
|
|
|
"com.google.protobuf.ExtensionLite<$message$, *>): " |
|
|
|
"Boolean {\n" |
|
|
|
"Boolean {\n" |
|
|
|
" return _builder.hasExtension(extension)\n" |
|
|
|
" return _builder.hasExtension(extension)\n" |
|
|
@ -914,7 +914,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
|
|
|
|
|
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"fun clear(extension: " |
|
|
|
"public fun clear(extension: " |
|
|
|
"com.google.protobuf.ExtensionLite<$message$, *>) " |
|
|
|
"com.google.protobuf.ExtensionLite<$message$, *>) " |
|
|
|
"{\n" |
|
|
|
"{\n" |
|
|
|
" _builder.clearExtension(extension)\n" |
|
|
|
" _builder.clearExtension(extension)\n" |
|
|
@ -934,7 +934,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"inline operator fun <T : Comparable<T>> set(\n" |
|
|
|
"public inline operator fun <T : Comparable<T>> set(\n" |
|
|
|
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n" |
|
|
|
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n" |
|
|
|
" value: T\n" |
|
|
|
" value: T\n" |
|
|
|
") {\n" |
|
|
|
") {\n" |
|
|
@ -945,7 +945,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"inline operator fun set(\n" |
|
|
|
"public inline operator fun set(\n" |
|
|
|
" extension: com.google.protobuf.ExtensionLite<$message$, " |
|
|
|
" extension: com.google.protobuf.ExtensionLite<$message$, " |
|
|
|
"com.google.protobuf.ByteString>,\n" |
|
|
|
"com.google.protobuf.ByteString>,\n" |
|
|
|
" value: com.google.protobuf.ByteString\n" |
|
|
|
" value: com.google.protobuf.ByteString\n" |
|
|
@ -957,7 +957,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"inline operator fun <T : com.google.protobuf.MessageLite> set(\n" |
|
|
|
"public inline operator fun <T : com.google.protobuf.MessageLite> set(\n" |
|
|
|
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n" |
|
|
|
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n" |
|
|
|
" value: T\n" |
|
|
|
" value: T\n" |
|
|
|
") {\n" |
|
|
|
") {\n" |
|
|
@ -967,7 +967,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
|
|
|
|
|
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, " |
|
|
|
"public fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, " |
|
|
|
"$message$>.add(value: E) {\n" |
|
|
|
"$message$>.add(value: E) {\n" |
|
|
|
" _builder.addExtension(this.extension, value)\n" |
|
|
|
" _builder.addExtension(this.extension, value)\n" |
|
|
|
"}\n\n", |
|
|
|
"}\n\n", |
|
|
@ -976,7 +976,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"inline operator fun <E : kotlin.Any> " |
|
|
|
"public inline operator fun <E : kotlin.Any> " |
|
|
|
"com.google.protobuf.kotlin.ExtensionList<E, " |
|
|
|
"com.google.protobuf.kotlin.ExtensionList<E, " |
|
|
|
"$message$>.plusAssign" |
|
|
|
"$message$>.plusAssign" |
|
|
|
"(value: E) {\n" |
|
|
|
"(value: E) {\n" |
|
|
@ -986,7 +986,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
|
|
|
|
|
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, " |
|
|
|
"public fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, " |
|
|
|
"$message$>.addAll(values: Iterable<E>) {\n" |
|
|
|
"$message$>.addAll(values: Iterable<E>) {\n" |
|
|
|
" for (value in values) {\n" |
|
|
|
" for (value in values) {\n" |
|
|
|
" add(value)\n" |
|
|
|
" add(value)\n" |
|
|
@ -997,7 +997,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"inline operator fun <E : kotlin.Any> " |
|
|
|
"public inline operator fun <E : kotlin.Any> " |
|
|
|
"com.google.protobuf.kotlin.ExtensionList<E, " |
|
|
|
"com.google.protobuf.kotlin.ExtensionList<E, " |
|
|
|
"$message$>.plusAssign(values: " |
|
|
|
"$message$>.plusAssign(values: " |
|
|
|
"Iterable<E>) {\n" |
|
|
|
"Iterable<E>) {\n" |
|
|
@ -1007,7 +1007,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
|
|
|
|
|
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"operator fun <E : kotlin.Any> " |
|
|
|
"public operator fun <E : kotlin.Any> " |
|
|
|
"com.google.protobuf.kotlin.ExtensionList<E, " |
|
|
|
"com.google.protobuf.kotlin.ExtensionList<E, " |
|
|
|
"$message$>.set(index: Int, value: " |
|
|
|
"$message$>.set(index: Int, value: " |
|
|
|
"E) {\n" |
|
|
|
"E) {\n" |
|
|
@ -1018,7 +1018,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions( |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@kotlin.jvm.JvmSynthetic\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"@Suppress(\"NOTHING_TO_INLINE\")\n" |
|
|
|
"inline fun com.google.protobuf.kotlin.ExtensionList<*, " |
|
|
|
"public inline fun com.google.protobuf.kotlin.ExtensionList<*, " |
|
|
|
"$message$>.clear() {\n" |
|
|
|
"$message$>.clear() {\n" |
|
|
|
" clear(extension)\n" |
|
|
|
" clear(extension)\n" |
|
|
|
"}\n\n", |
|
|
|
"}\n\n", |
|
|
|