|
|
@ -734,10 +734,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 = " |
|
|
@ -759,10 +759,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, |
|
|
@ -783,7 +783,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers( |
|
|
|
io::Printer* printer) const { |
|
|
|
io::Printer* printer) const { |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n" |
|
|
|
"@kotlin.jvm.JvmName(\"-initialize$camelcase_name$\")\n" |
|
|
|
"inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> " |
|
|
|
"public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> " |
|
|
|
"kotlin.Unit): " |
|
|
|
"kotlin.Unit): " |
|
|
|
"$message$ =\n" |
|
|
|
"$message$ =\n" |
|
|
|
" $message_kt$.Dsl._create($message$.newBuilder()).apply { block() " |
|
|
|
" $message_kt$.Dsl._create($message$.newBuilder()).apply { block() " |
|
|
@ -792,7 +792,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers( |
|
|
|
"message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_), |
|
|
|
"message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_), |
|
|
|
"message", name_resolver_->GetClassName(descriptor_, true)); |
|
|
|
"message", name_resolver_->GetClassName(descriptor_, 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++) { |
|
|
@ -807,7 +807,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers( |
|
|
|
void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers( |
|
|
|
void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers( |
|
|
|
io::Printer* printer) const { |
|
|
|
io::Printer* printer) const { |
|
|
|
printer->Print( |
|
|
|
printer->Print( |
|
|
|
"inline fun $message$.copy(block: $message_kt$.Dsl.() -> " |
|
|
|
"public inline fun $message$.copy(block: $message_kt$.Dsl.() -> " |
|
|
|
"kotlin.Unit): " |
|
|
|
"kotlin.Unit): " |
|
|
|
"$message$ =\n" |
|
|
|
"$message$ =\n" |
|
|
|
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() " |
|
|
|
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() " |
|
|
@ -849,7 +849,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$, " |
|
|
@ -865,7 +865,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, " |
|
|
@ -875,7 +875,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" |
|
|
@ -884,7 +884,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" |
|
|
@ -904,7 +904,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" |
|
|
@ -915,7 +915,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" |
|
|
@ -927,7 +927,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" |
|
|
@ -937,7 +937,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", |
|
|
@ -946,7 +946,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" |
|
|
@ -956,7 +956,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" |
|
|
@ -967,7 +967,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" |
|
|
@ -977,7 +977,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" |
|
|
@ -988,7 +988,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", |
|
|
|