diff --git a/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/conformance.kt b/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/conformance.kt index dc411beb..0a155377 100644 --- a/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/conformance.kt +++ b/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/conformance.kt @@ -4,7 +4,7 @@ package pbandk.conformance.pb @pbandk.Export public sealed class WireFormat(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is WireFormat && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.conformance.pb.WireFormat && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "WireFormat.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -15,16 +15,16 @@ public sealed class WireFormat(override val value: Int, override val name: Strin public object TEXT_FORMAT : WireFormat(4, "TEXT_FORMAT") public class UNRECOGNIZED(value: Int) : WireFormat(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(UNSPECIFIED, PROTOBUF, JSON, JSPB, TEXT_FORMAT) } - override fun fromValue(value: Int): WireFormat = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): WireFormat = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No WireFormat with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(UNSPECIFIED, PROTOBUF, JSON, JSPB, TEXT_FORMAT) } + override fun fromValue(value: Int): pbandk.conformance.pb.WireFormat = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.conformance.pb.WireFormat = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No WireFormat with name: $name") } } @pbandk.Export public sealed class TestCategory(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is TestCategory && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.conformance.pb.TestCategory && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "TestCategory.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -36,10 +36,10 @@ public sealed class TestCategory(override val value: Int, override val name: Str public object TEXT_FORMAT_TEST : TestCategory(5, "TEXT_FORMAT_TEST") public class UNRECOGNIZED(value: Int) : TestCategory(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(UNSPECIFIED_TEST, BINARY_TEST, JSON_TEST, JSON_IGNORE_UNKNOWN_PARSING_TEST, JSPB_TEST, TEXT_FORMAT_TEST) } - override fun fromValue(value: Int): TestCategory = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): TestCategory = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No TestCategory with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(UNSPECIFIED_TEST, BINARY_TEST, JSON_TEST, JSON_IGNORE_UNKNOWN_PARSING_TEST, JSPB_TEST, TEXT_FORMAT_TEST) } + override fun fromValue(value: Int): pbandk.conformance.pb.TestCategory = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.conformance.pb.TestCategory = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No TestCategory with name: $name") } } diff --git a/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/test_messages_proto2.kt b/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/test_messages_proto2.kt index 1de67db9..e931d4cc 100644 --- a/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/test_messages_proto2.kt +++ b/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/test_messages_proto2.kt @@ -4,7 +4,7 @@ package pbandk.conformance.pb @pbandk.Export public sealed class ForeignEnumProto2(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is ForeignEnumProto2 && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.conformance.pb.ForeignEnumProto2 && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "ForeignEnumProto2.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -13,10 +13,10 @@ public sealed class ForeignEnumProto2(override val value: Int, override val name public object FOREIGN_BAZ : ForeignEnumProto2(2, "FOREIGN_BAZ") public class UNRECOGNIZED(value: Int) : ForeignEnumProto2(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(FOREIGN_FOO, FOREIGN_BAR, FOREIGN_BAZ) } - override fun fromValue(value: Int): ForeignEnumProto2 = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): ForeignEnumProto2 = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No ForeignEnumProto2 with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(FOREIGN_FOO, FOREIGN_BAR, FOREIGN_BAZ) } + override fun fromValue(value: Int): pbandk.conformance.pb.ForeignEnumProto2 = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.conformance.pb.ForeignEnumProto2 = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No ForeignEnumProto2 with name: $name") } } @@ -1366,7 +1366,7 @@ public data class TestAllTypesProto2( } public sealed class NestedEnum(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is TestAllTypesProto2.NestedEnum && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.conformance.pb.TestAllTypesProto2.NestedEnum && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "TestAllTypesProto2.NestedEnum.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -1376,10 +1376,10 @@ public data class TestAllTypesProto2( public object NEG : NestedEnum(-1, "NEG") public class UNRECOGNIZED(value: Int) : NestedEnum(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(FOO, BAR, BAZ, NEG) } - override fun fromValue(value: Int): TestAllTypesProto2.NestedEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): TestAllTypesProto2.NestedEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No NestedEnum with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(FOO, BAR, BAZ, NEG) } + override fun fromValue(value: Int): pbandk.conformance.pb.TestAllTypesProto2.NestedEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.conformance.pb.TestAllTypesProto2.NestedEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No NestedEnum with name: $name") } } diff --git a/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/test_messages_proto3.kt b/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/test_messages_proto3.kt index 645c9efb..0b498a64 100644 --- a/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/test_messages_proto3.kt +++ b/conformance/lib/src/commonMain/kotlin/pbandk/conformance/pb/test_messages_proto3.kt @@ -4,7 +4,7 @@ package pbandk.conformance.pb @pbandk.Export public sealed class ForeignEnum(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is ForeignEnum && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.conformance.pb.ForeignEnum && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "ForeignEnum.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -13,10 +13,10 @@ public sealed class ForeignEnum(override val value: Int, override val name: Stri public object FOREIGN_BAZ : ForeignEnum(2, "FOREIGN_BAZ") public class UNRECOGNIZED(value: Int) : ForeignEnum(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(FOREIGN_FOO, FOREIGN_BAR, FOREIGN_BAZ) } - override fun fromValue(value: Int): ForeignEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): ForeignEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No ForeignEnum with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(FOREIGN_FOO, FOREIGN_BAR, FOREIGN_BAZ) } + override fun fromValue(value: Int): pbandk.conformance.pb.ForeignEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.conformance.pb.ForeignEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No ForeignEnum with name: $name") } } @@ -1716,7 +1716,7 @@ public data class TestAllTypesProto3( } public sealed class NestedEnum(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is TestAllTypesProto3.NestedEnum && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.conformance.pb.TestAllTypesProto3.NestedEnum && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "TestAllTypesProto3.NestedEnum.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -1726,15 +1726,15 @@ public data class TestAllTypesProto3( public object NEG : NestedEnum(-1, "NEG") public class UNRECOGNIZED(value: Int) : NestedEnum(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(FOO, BAR, BAZ, NEG) } - override fun fromValue(value: Int): TestAllTypesProto3.NestedEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): TestAllTypesProto3.NestedEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No NestedEnum with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(FOO, BAR, BAZ, NEG) } + override fun fromValue(value: Int): pbandk.conformance.pb.TestAllTypesProto3.NestedEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.conformance.pb.TestAllTypesProto3.NestedEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No NestedEnum with name: $name") } } public sealed class AliasedEnum(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is TestAllTypesProto3.AliasedEnum && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.conformance.pb.TestAllTypesProto3.AliasedEnum && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "TestAllTypesProto3.AliasedEnum.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -1746,10 +1746,10 @@ public data class TestAllTypesProto3( public object B_AZ : AliasedEnum(2, "bAz") public class UNRECOGNIZED(value: Int) : AliasedEnum(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(ALIAS_FOO, ALIAS_BAR, ALIAS_BAZ, QUX, QUX_, B_AZ) } - override fun fromValue(value: Int): TestAllTypesProto3.AliasedEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): TestAllTypesProto3.AliasedEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No AliasedEnum with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(ALIAS_FOO, ALIAS_BAR, ALIAS_BAZ, QUX, QUX_, B_AZ) } + override fun fromValue(value: Int): pbandk.conformance.pb.TestAllTypesProto3.AliasedEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.conformance.pb.TestAllTypesProto3.AliasedEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No AliasedEnum with name: $name") } } diff --git a/protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/CodeGenerator.kt b/protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/CodeGenerator.kt index 31bc1acd..23f2510b 100644 --- a/protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/CodeGenerator.kt +++ b/protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/CodeGenerator.kt @@ -77,17 +77,17 @@ public open class CodeGenerator( // Enums are sealed classes w/ a value and a name, and a companion object with all values line("$visibility sealed class ${type.kotlinTypeName}(override val value: Int, override val name: String? = null) : pbandk.Message.Enum {") .indented { - line("override fun equals(other: kotlin.Any?): Boolean = other is ${type.kotlinFullTypeName} && other.value == value") + line("override fun equals(other: kotlin.Any?): Boolean = other is ${file.kotlinPackageName}.${type.kotlinFullTypeName} && other.value == value") line("override fun hashCode(): Int = value.hashCode()") line("override fun toString(): String = \"${type.kotlinFullTypeName}.\${name ?: \"UNRECOGNIZED\"}(value=\$value)\"") line() type.values.forEach { line("$visibility object ${it.kotlinValueTypeName} : ${type.kotlinTypeName}(${it.number}, \"${it.name}\")") } line("$visibility class UNRECOGNIZED(value: Int) : ${type.kotlinTypeName}(value)") line() - line("$visibility companion object : pbandk.Message.Enum.Companion<${type.kotlinFullTypeName}> {").indented { - line("$visibility val values: List<${type.kotlinFullTypeName}> by lazy { listOf(${type.values.joinToString(", ") { it.kotlinValueTypeName }}) }") - line("override fun fromValue(value: Int): ${type.kotlinFullTypeName} = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value)") - line("override fun fromName(name: String): ${type.kotlinFullTypeName} = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException(\"No ${type.kotlinTypeName} with name: \$name\")") + line("$visibility companion object : pbandk.Message.Enum.Companion<${file.kotlinPackageName}.${type.kotlinFullTypeName}> {").indented { + line("$visibility val values: List<${file.kotlinPackageName}.${type.kotlinFullTypeName}> by lazy { listOf(${type.values.joinToString(", ") { it.kotlinValueTypeName }}) }") + line("override fun fromValue(value: Int): ${file.kotlinPackageName}.${type.kotlinFullTypeName} = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value)") + line("override fun fromName(name: String): ${file.kotlinPackageName}.${type.kotlinFullTypeName} = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException(\"No ${type.kotlinTypeName} with name: \$name\")") }.line("}") }.line("}") } diff --git a/protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/pb/plugin.kt b/protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/pb/plugin.kt index c3b8e228..3dd12412 100644 --- a/protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/pb/plugin.kt +++ b/protoc-gen-pbandk/lib/src/commonMain/kotlin/pbandk/gen/pb/plugin.kt @@ -198,7 +198,7 @@ public data class CodeGeneratorResponse( } public sealed class Feature(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is CodeGeneratorResponse.Feature && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.gen.pb.CodeGeneratorResponse.Feature && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "CodeGeneratorResponse.Feature.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -206,10 +206,10 @@ public data class CodeGeneratorResponse( public object PROTO3_OPTIONAL : Feature(1, "FEATURE_PROTO3_OPTIONAL") public class UNRECOGNIZED(value: Int) : Feature(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(NONE, PROTO3_OPTIONAL) } - override fun fromValue(value: Int): CodeGeneratorResponse.Feature = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): CodeGeneratorResponse.Feature = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Feature with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(NONE, PROTO3_OPTIONAL) } + override fun fromValue(value: Int): pbandk.gen.pb.CodeGeneratorResponse.Feature = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.gen.pb.CodeGeneratorResponse.Feature = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Feature with name: $name") } } diff --git a/protoc-gen-pbandk/lib/src/jvmTest/kotlin/CodeGeneratorTest.kt b/protoc-gen-pbandk/lib/src/jvmTest/kotlin/CodeGeneratorTest.kt index e950f8b4..96f28a08 100644 --- a/protoc-gen-pbandk/lib/src/jvmTest/kotlin/CodeGeneratorTest.kt +++ b/protoc-gen-pbandk/lib/src/jvmTest/kotlin/CodeGeneratorTest.kt @@ -57,6 +57,20 @@ class CodeGeneratorTest { valueClazz.classLoader.loadClass("foobar.Value\$Value") } + @Test + fun testOneOf_Enum_SameNameField() { + val result = compileProto("oneof_enum_same_name.proto") + + assertEquals(ExitCode.OK, result.exitCode, result.messages) + + // Ensure the oneof with the same name as its containing message was generated correctly + val actionClazz = result.classLoader.loadClass("foobar.Action") + + // Ensure the message with a same named enum in the message was generated correctly + val enumClazz = actionClazz.classLoader.loadClass("foobar.Action\$ActionV1").kotlin + enumClazz.declaredMemberProperties.single { it.name == "type" } + } + @Test fun testKotlinBuiltinNames() { val result = compileProto("kotlin_builtin_names.proto") diff --git a/protoc-gen-pbandk/lib/src/jvmTest/resources/protos/oneof_enum_same_name.proto b/protoc-gen-pbandk/lib/src/jvmTest/resources/protos/oneof_enum_same_name.proto new file mode 100644 index 00000000..929a58f6 --- /dev/null +++ b/protoc-gen-pbandk/lib/src/jvmTest/resources/protos/oneof_enum_same_name.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package foobar; + + +message Action { + oneof action { + ActionV1 action_v1 = 1; + } + message ActionV1 { + Type type = 1; + enum Type { + TYPE_UNSPECIFIED = 0; + } + } +} \ No newline at end of file diff --git a/runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt b/runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt index 30bce26d..5280abc4 100644 --- a/runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt +++ b/runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt @@ -617,7 +617,7 @@ public data class FieldDescriptorProto( } public sealed class Type(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is FieldDescriptorProto.Type && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.wkt.FieldDescriptorProto.Type && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "FieldDescriptorProto.Type.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -641,15 +641,15 @@ public data class FieldDescriptorProto( public object SINT64 : Type(18, "TYPE_SINT64") public class UNRECOGNIZED(value: Int) : Type(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(DOUBLE, FLOAT, INT64, UINT64, INT32, FIXED64, FIXED32, BOOL, STRING, GROUP, MESSAGE, BYTES, UINT32, ENUM, SFIXED32, SFIXED64, SINT32, SINT64) } - override fun fromValue(value: Int): FieldDescriptorProto.Type = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): FieldDescriptorProto.Type = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Type with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(DOUBLE, FLOAT, INT64, UINT64, INT32, FIXED64, FIXED32, BOOL, STRING, GROUP, MESSAGE, BYTES, UINT32, ENUM, SFIXED32, SFIXED64, SINT32, SINT64) } + override fun fromValue(value: Int): pbandk.wkt.FieldDescriptorProto.Type = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.wkt.FieldDescriptorProto.Type = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Type with name: $name") } } public sealed class Label(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is FieldDescriptorProto.Label && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.wkt.FieldDescriptorProto.Label && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "FieldDescriptorProto.Label.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -658,10 +658,10 @@ public data class FieldDescriptorProto( public object REPEATED : Label(3, "LABEL_REPEATED") public class UNRECOGNIZED(value: Int) : Label(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(OPTIONAL, REQUIRED, REPEATED) } - override fun fromValue(value: Int): FieldDescriptorProto.Label = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): FieldDescriptorProto.Label = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Label with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(OPTIONAL, REQUIRED, REPEATED) } + override fun fromValue(value: Int): pbandk.wkt.FieldDescriptorProto.Label = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.wkt.FieldDescriptorProto.Label = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Label with name: $name") } } } @@ -1309,7 +1309,7 @@ public data class FileOptions( } public sealed class OptimizeMode(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is FileOptions.OptimizeMode && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.wkt.FileOptions.OptimizeMode && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "FileOptions.OptimizeMode.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -1318,10 +1318,10 @@ public data class FileOptions( public object LITE_RUNTIME : OptimizeMode(3, "LITE_RUNTIME") public class UNRECOGNIZED(value: Int) : OptimizeMode(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(SPEED, CODE_SIZE, LITE_RUNTIME) } - override fun fromValue(value: Int): FileOptions.OptimizeMode = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): FileOptions.OptimizeMode = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No OptimizeMode with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(SPEED, CODE_SIZE, LITE_RUNTIME) } + override fun fromValue(value: Int): pbandk.wkt.FileOptions.OptimizeMode = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.wkt.FileOptions.OptimizeMode = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No OptimizeMode with name: $name") } } } @@ -1512,7 +1512,7 @@ public data class FieldOptions( } public sealed class CType(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is FieldOptions.CType && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.wkt.FieldOptions.CType && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "FieldOptions.CType.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -1521,15 +1521,15 @@ public data class FieldOptions( public object STRING_PIECE : CType(2, "STRING_PIECE") public class UNRECOGNIZED(value: Int) : CType(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(STRING, CORD, STRING_PIECE) } - override fun fromValue(value: Int): FieldOptions.CType = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): FieldOptions.CType = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No CType with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(STRING, CORD, STRING_PIECE) } + override fun fromValue(value: Int): pbandk.wkt.FieldOptions.CType = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.wkt.FieldOptions.CType = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No CType with name: $name") } } public sealed class JSType(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is FieldOptions.JSType && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.wkt.FieldOptions.JSType && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "FieldOptions.JSType.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -1538,10 +1538,10 @@ public data class FieldOptions( public object JS_NUMBER : JSType(2, "JS_NUMBER") public class UNRECOGNIZED(value: Int) : JSType(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(JS_NORMAL, JS_STRING, JS_NUMBER) } - override fun fromValue(value: Int): FieldOptions.JSType = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): FieldOptions.JSType = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No JSType with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(JS_NORMAL, JS_STRING, JS_NUMBER) } + override fun fromValue(value: Int): pbandk.wkt.FieldOptions.JSType = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.wkt.FieldOptions.JSType = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No JSType with name: $name") } } } @@ -1802,7 +1802,7 @@ public data class MethodOptions( } public sealed class IdempotencyLevel(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is MethodOptions.IdempotencyLevel && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.wkt.MethodOptions.IdempotencyLevel && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "MethodOptions.IdempotencyLevel.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -1811,10 +1811,10 @@ public data class MethodOptions( public object IDEMPOTENT : IdempotencyLevel(2, "IDEMPOTENT") public class UNRECOGNIZED(value: Int) : IdempotencyLevel(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(IDEMPOTENCY_UNKNOWN, NO_SIDE_EFFECTS, IDEMPOTENT) } - override fun fromValue(value: Int): MethodOptions.IdempotencyLevel = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): MethodOptions.IdempotencyLevel = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No IdempotencyLevel with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(IDEMPOTENCY_UNKNOWN, NO_SIDE_EFFECTS, IDEMPOTENT) } + override fun fromValue(value: Int): pbandk.wkt.MethodOptions.IdempotencyLevel = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.wkt.MethodOptions.IdempotencyLevel = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No IdempotencyLevel with name: $name") } } } diff --git a/runtime/src/commonMain/kotlin/pbandk/wkt/struct.kt b/runtime/src/commonMain/kotlin/pbandk/wkt/struct.kt index 45d22c4a..8b7eaaf0 100644 --- a/runtime/src/commonMain/kotlin/pbandk/wkt/struct.kt +++ b/runtime/src/commonMain/kotlin/pbandk/wkt/struct.kt @@ -4,17 +4,17 @@ package pbandk.wkt @pbandk.Export public sealed class NullValue(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is NullValue && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.wkt.NullValue && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "NullValue.${name ?: "UNRECOGNIZED"}(value=$value)" public object NULL_VALUE : NullValue(0, "NULL_VALUE") public class UNRECOGNIZED(value: Int) : NullValue(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(NULL_VALUE) } - override fun fromValue(value: Int): NullValue = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): NullValue = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No NullValue with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(NULL_VALUE) } + override fun fromValue(value: Int): pbandk.wkt.NullValue = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.wkt.NullValue = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No NullValue with name: $name") } } diff --git a/runtime/src/commonMain/kotlin/pbandk/wkt/type.kt b/runtime/src/commonMain/kotlin/pbandk/wkt/type.kt index cf0e9379..7c8f11df 100644 --- a/runtime/src/commonMain/kotlin/pbandk/wkt/type.kt +++ b/runtime/src/commonMain/kotlin/pbandk/wkt/type.kt @@ -4,7 +4,7 @@ package pbandk.wkt @pbandk.Export public sealed class Syntax(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is Syntax && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.wkt.Syntax && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "Syntax.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -12,10 +12,10 @@ public sealed class Syntax(override val value: Int, override val name: String? = public object PROTO3 : Syntax(1, "SYNTAX_PROTO3") public class UNRECOGNIZED(value: Int) : Syntax(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(PROTO2, PROTO3) } - override fun fromValue(value: Int): Syntax = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): Syntax = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Syntax with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(PROTO2, PROTO3) } + override fun fromValue(value: Int): pbandk.wkt.Syntax = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.wkt.Syntax = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Syntax with name: $name") } } @@ -245,7 +245,7 @@ public data class Field( } public sealed class Kind(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is Field.Kind && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.wkt.Field.Kind && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "Field.Kind.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -270,15 +270,15 @@ public data class Field( public object TYPE_SINT64 : Kind(18, "TYPE_SINT64") public class UNRECOGNIZED(value: Int) : Kind(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(TYPE_UNKNOWN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT64, TYPE_UINT64, TYPE_INT32, TYPE_FIXED64, TYPE_FIXED32, TYPE_BOOL, TYPE_STRING, TYPE_GROUP, TYPE_MESSAGE, TYPE_BYTES, TYPE_UINT32, TYPE_ENUM, TYPE_SFIXED32, TYPE_SFIXED64, TYPE_SINT32, TYPE_SINT64) } - override fun fromValue(value: Int): Field.Kind = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): Field.Kind = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Kind with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(TYPE_UNKNOWN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT64, TYPE_UINT64, TYPE_INT32, TYPE_FIXED64, TYPE_FIXED32, TYPE_BOOL, TYPE_STRING, TYPE_GROUP, TYPE_MESSAGE, TYPE_BYTES, TYPE_UINT32, TYPE_ENUM, TYPE_SFIXED32, TYPE_SFIXED64, TYPE_SINT32, TYPE_SINT64) } + override fun fromValue(value: Int): pbandk.wkt.Field.Kind = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.wkt.Field.Kind = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Kind with name: $name") } } public sealed class Cardinality(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is Field.Cardinality && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.wkt.Field.Cardinality && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "Field.Cardinality.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -288,10 +288,10 @@ public data class Field( public object REPEATED : Cardinality(3, "CARDINALITY_REPEATED") public class UNRECOGNIZED(value: Int) : Cardinality(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(UNKNOWN, OPTIONAL, REQUIRED, REPEATED) } - override fun fromValue(value: Int): Field.Cardinality = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): Field.Cardinality = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Cardinality with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(UNKNOWN, OPTIONAL, REQUIRED, REPEATED) } + override fun fromValue(value: Int): pbandk.wkt.Field.Cardinality = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.wkt.Field.Cardinality = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Cardinality with name: $name") } } } diff --git a/test-types/src/commonMain/kotlin/pbandk/testpb/proto_3_presence.kt b/test-types/src/commonMain/kotlin/pbandk/testpb/proto_3_presence.kt index e125b4f8..cc70aacf 100644 --- a/test-types/src/commonMain/kotlin/pbandk/testpb/proto_3_presence.kt +++ b/test-types/src/commonMain/kotlin/pbandk/testpb/proto_3_presence.kt @@ -4,7 +4,7 @@ package pbandk.testpb @pbandk.Export public sealed class Proto3PresenceEnum(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is Proto3PresenceEnum && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.testpb.Proto3PresenceEnum && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "Proto3PresenceEnum.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -12,10 +12,10 @@ public sealed class Proto3PresenceEnum(override val value: Int, override val nam public object PROTO3_PRESENCE_ENUM_SPECIFIED : Proto3PresenceEnum(1, "PROTO3_PRESENCE_ENUM_SPECIFIED") public class UNRECOGNIZED(value: Int) : Proto3PresenceEnum(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(PROTO3_PRESENCE_ENUM_UNSPECIFIED, PROTO3_PRESENCE_ENUM_SPECIFIED) } - override fun fromValue(value: Int): Proto3PresenceEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): Proto3PresenceEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Proto3PresenceEnum with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(PROTO3_PRESENCE_ENUM_UNSPECIFIED, PROTO3_PRESENCE_ENUM_SPECIFIED) } + override fun fromValue(value: Int): pbandk.testpb.Proto3PresenceEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.testpb.Proto3PresenceEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No Proto3PresenceEnum with name: $name") } } diff --git a/test-types/src/commonMain/kotlin/pbandk/testpb/test_compiler_limits.kt b/test-types/src/commonMain/kotlin/pbandk/testpb/test_compiler_limits.kt index 3df3108e..50947236 100644 --- a/test-types/src/commonMain/kotlin/pbandk/testpb/test_compiler_limits.kt +++ b/test-types/src/commonMain/kotlin/pbandk/testpb/test_compiler_limits.kt @@ -4,7 +4,7 @@ package pbandk.testpb @pbandk.Export public sealed class HugeEnum(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is HugeEnum && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.testpb.HugeEnum && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "HugeEnum.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -1011,10 +1011,10 @@ public sealed class HugeEnum(override val value: Int, override val name: String? public object HE1999 : HugeEnum(1999, "HUGE_ENUM_HE1999") public class UNRECOGNIZED(value: Int) : HugeEnum(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(HE0, HE1000, HE1001, HE1002, HE1003, HE1004, HE1005, HE1006, HE1007, HE1008, HE1009, HE1010, HE1011, HE1012, HE1013, HE1014, HE1015, HE1016, HE1017, HE1018, HE1019, HE1020, HE1021, HE1022, HE1023, HE1024, HE1025, HE1026, HE1027, HE1028, HE1029, HE1030, HE1031, HE1032, HE1033, HE1034, HE1035, HE1036, HE1037, HE1038, HE1039, HE1040, HE1041, HE1042, HE1043, HE1044, HE1045, HE1046, HE1047, HE1048, HE1049, HE1050, HE1051, HE1052, HE1053, HE1054, HE1055, HE1056, HE1057, HE1058, HE1059, HE1060, HE1061, HE1062, HE1063, HE1064, HE1065, HE1066, HE1067, HE1068, HE1069, HE1070, HE1071, HE1072, HE1073, HE1074, HE1075, HE1076, HE1077, HE1078, HE1079, HE1080, HE1081, HE1082, HE1083, HE1084, HE1085, HE1086, HE1087, HE1088, HE1089, HE1090, HE1091, HE1092, HE1093, HE1094, HE1095, HE1096, HE1097, HE1098, HE1099, HE1100, HE1101, HE1102, HE1103, HE1104, HE1105, HE1106, HE1107, HE1108, HE1109, HE1110, HE1111, HE1112, HE1113, HE1114, HE1115, HE1116, HE1117, HE1118, HE1119, HE1120, HE1121, HE1122, HE1123, HE1124, HE1125, HE1126, HE1127, HE1128, HE1129, HE1130, HE1131, HE1132, HE1133, HE1134, HE1135, HE1136, HE1137, HE1138, HE1139, HE1140, HE1141, HE1142, HE1143, HE1144, HE1145, HE1146, HE1147, HE1148, HE1149, HE1150, HE1151, HE1152, HE1153, HE1154, HE1155, HE1156, HE1157, HE1158, HE1159, HE1160, HE1161, HE1162, HE1163, HE1164, HE1165, HE1166, HE1167, HE1168, HE1169, HE1170, HE1171, HE1172, HE1173, HE1174, HE1175, HE1176, HE1177, HE1178, HE1179, HE1180, HE1181, HE1182, HE1183, HE1184, HE1185, HE1186, HE1187, HE1188, HE1189, HE1190, HE1191, HE1192, HE1193, HE1194, HE1195, HE1196, HE1197, HE1198, HE1199, HE1200, HE1201, HE1202, HE1203, HE1204, HE1205, HE1206, HE1207, HE1208, HE1209, HE1210, HE1211, HE1212, HE1213, HE1214, HE1215, HE1216, HE1217, HE1218, HE1219, HE1220, HE1221, HE1222, HE1223, HE1224, HE1225, HE1226, HE1227, HE1228, HE1229, HE1230, HE1231, HE1232, HE1233, HE1234, HE1235, HE1236, HE1237, HE1238, HE1239, HE1240, HE1241, HE1242, HE1243, HE1244, HE1245, HE1246, HE1247, HE1248, HE1249, HE1250, HE1251, HE1252, HE1253, HE1254, HE1255, HE1256, HE1257, HE1258, HE1259, HE1260, HE1261, HE1262, HE1263, HE1264, HE1265, HE1266, HE1267, HE1268, HE1269, HE1270, HE1271, HE1272, HE1273, HE1274, HE1275, HE1276, HE1277, HE1278, HE1279, HE1280, HE1281, HE1282, HE1283, HE1284, HE1285, HE1286, HE1287, HE1288, HE1289, HE1290, HE1291, HE1292, HE1293, HE1294, HE1295, HE1296, HE1297, HE1298, HE1299, HE1300, HE1301, HE1302, HE1303, HE1304, HE1305, HE1306, HE1307, HE1308, HE1309, HE1310, HE1311, HE1312, HE1313, HE1314, HE1315, HE1316, HE1317, HE1318, HE1319, HE1320, HE1321, HE1322, HE1323, HE1324, HE1325, HE1326, HE1327, HE1328, HE1329, HE1330, HE1331, HE1332, HE1333, HE1334, HE1335, HE1336, HE1337, HE1338, HE1339, HE1340, HE1341, HE1342, HE1343, HE1344, HE1345, HE1346, HE1347, HE1348, HE1349, HE1350, HE1351, HE1352, HE1353, HE1354, HE1355, HE1356, HE1357, HE1358, HE1359, HE1360, HE1361, HE1362, HE1363, HE1364, HE1365, HE1366, HE1367, HE1368, HE1369, HE1370, HE1371, HE1372, HE1373, HE1374, HE1375, HE1376, HE1377, HE1378, HE1379, HE1380, HE1381, HE1382, HE1383, HE1384, HE1385, HE1386, HE1387, HE1388, HE1389, HE1390, HE1391, HE1392, HE1393, HE1394, HE1395, HE1396, HE1397, HE1398, HE1399, HE1400, HE1401, HE1402, HE1403, HE1404, HE1405, HE1406, HE1407, HE1408, HE1409, HE1410, HE1411, HE1412, HE1413, HE1414, HE1415, HE1416, HE1417, HE1418, HE1419, HE1420, HE1421, HE1422, HE1423, HE1424, HE1425, HE1426, HE1427, HE1428, HE1429, HE1430, HE1431, HE1432, HE1433, HE1434, HE1435, HE1436, HE1437, HE1438, HE1439, HE1440, HE1441, HE1442, HE1443, HE1444, HE1445, HE1446, HE1447, HE1448, HE1449, HE1450, HE1451, HE1452, HE1453, HE1454, HE1455, HE1456, HE1457, HE1458, HE1459, HE1460, HE1461, HE1462, HE1463, HE1464, HE1465, HE1466, HE1467, HE1468, HE1469, HE1470, HE1471, HE1472, HE1473, HE1474, HE1475, HE1476, HE1477, HE1478, HE1479, HE1480, HE1481, HE1482, HE1483, HE1484, HE1485, HE1486, HE1487, HE1488, HE1489, HE1490, HE1491, HE1492, HE1493, HE1494, HE1495, HE1496, HE1497, HE1498, HE1499, HE1500, HE1501, HE1502, HE1503, HE1504, HE1505, HE1506, HE1507, HE1508, HE1509, HE1510, HE1511, HE1512, HE1513, HE1514, HE1515, HE1516, HE1517, HE1518, HE1519, HE1520, HE1521, HE1522, HE1523, HE1524, HE1525, HE1526, HE1527, HE1528, HE1529, HE1530, HE1531, HE1532, HE1533, HE1534, HE1535, HE1536, HE1537, HE1538, HE1539, HE1540, HE1541, HE1542, HE1543, HE1544, HE1545, HE1546, HE1547, HE1548, HE1549, HE1550, HE1551, HE1552, HE1553, HE1554, HE1555, HE1556, HE1557, HE1558, HE1559, HE1560, HE1561, HE1562, HE1563, HE1564, HE1565, HE1566, HE1567, HE1568, HE1569, HE1570, HE1571, HE1572, HE1573, HE1574, HE1575, HE1576, HE1577, HE1578, HE1579, HE1580, HE1581, HE1582, HE1583, HE1584, HE1585, HE1586, HE1587, HE1588, HE1589, HE1590, HE1591, HE1592, HE1593, HE1594, HE1595, HE1596, HE1597, HE1598, HE1599, HE1600, HE1601, HE1602, HE1603, HE1604, HE1605, HE1606, HE1607, HE1608, HE1609, HE1610, HE1611, HE1612, HE1613, HE1614, HE1615, HE1616, HE1617, HE1618, HE1619, HE1620, HE1621, HE1622, HE1623, HE1624, HE1625, HE1626, HE1627, HE1628, HE1629, HE1630, HE1631, HE1632, HE1633, HE1634, HE1635, HE1636, HE1637, HE1638, HE1639, HE1640, HE1641, HE1642, HE1643, HE1644, HE1645, HE1646, HE1647, HE1648, HE1649, HE1650, HE1651, HE1652, HE1653, HE1654, HE1655, HE1656, HE1657, HE1658, HE1659, HE1660, HE1661, HE1662, HE1663, HE1664, HE1665, HE1666, HE1667, HE1668, HE1669, HE1670, HE1671, HE1672, HE1673, HE1674, HE1675, HE1676, HE1677, HE1678, HE1679, HE1680, HE1681, HE1682, HE1683, HE1684, HE1685, HE1686, HE1687, HE1688, HE1689, HE1690, HE1691, HE1692, HE1693, HE1694, HE1695, HE1696, HE1697, HE1698, HE1699, HE1700, HE1701, HE1702, HE1703, HE1704, HE1705, HE1706, HE1707, HE1708, HE1709, HE1710, HE1711, HE1712, HE1713, HE1714, HE1715, HE1716, HE1717, HE1718, HE1719, HE1720, HE1721, HE1722, HE1723, HE1724, HE1725, HE1726, HE1727, HE1728, HE1729, HE1730, HE1731, HE1732, HE1733, HE1734, HE1735, HE1736, HE1737, HE1738, HE1739, HE1740, HE1741, HE1742, HE1743, HE1744, HE1745, HE1746, HE1747, HE1748, HE1749, HE1750, HE1751, HE1752, HE1753, HE1754, HE1755, HE1756, HE1757, HE1758, HE1759, HE1760, HE1761, HE1762, HE1763, HE1764, HE1765, HE1766, HE1767, HE1768, HE1769, HE1770, HE1771, HE1772, HE1773, HE1774, HE1775, HE1776, HE1777, HE1778, HE1779, HE1780, HE1781, HE1782, HE1783, HE1784, HE1785, HE1786, HE1787, HE1788, HE1789, HE1790, HE1791, HE1792, HE1793, HE1794, HE1795, HE1796, HE1797, HE1798, HE1799, HE1800, HE1801, HE1802, HE1803, HE1804, HE1805, HE1806, HE1807, HE1808, HE1809, HE1810, HE1811, HE1812, HE1813, HE1814, HE1815, HE1816, HE1817, HE1818, HE1819, HE1820, HE1821, HE1822, HE1823, HE1824, HE1825, HE1826, HE1827, HE1828, HE1829, HE1830, HE1831, HE1832, HE1833, HE1834, HE1835, HE1836, HE1837, HE1838, HE1839, HE1840, HE1841, HE1842, HE1843, HE1844, HE1845, HE1846, HE1847, HE1848, HE1849, HE1850, HE1851, HE1852, HE1853, HE1854, HE1855, HE1856, HE1857, HE1858, HE1859, HE1860, HE1861, HE1862, HE1863, HE1864, HE1865, HE1866, HE1867, HE1868, HE1869, HE1870, HE1871, HE1872, HE1873, HE1874, HE1875, HE1876, HE1877, HE1878, HE1879, HE1880, HE1881, HE1882, HE1883, HE1884, HE1885, HE1886, HE1887, HE1888, HE1889, HE1890, HE1891, HE1892, HE1893, HE1894, HE1895, HE1896, HE1897, HE1898, HE1899, HE1900, HE1901, HE1902, HE1903, HE1904, HE1905, HE1906, HE1907, HE1908, HE1909, HE1910, HE1911, HE1912, HE1913, HE1914, HE1915, HE1916, HE1917, HE1918, HE1919, HE1920, HE1921, HE1922, HE1923, HE1924, HE1925, HE1926, HE1927, HE1928, HE1929, HE1930, HE1931, HE1932, HE1933, HE1934, HE1935, HE1936, HE1937, HE1938, HE1939, HE1940, HE1941, HE1942, HE1943, HE1944, HE1945, HE1946, HE1947, HE1948, HE1949, HE1950, HE1951, HE1952, HE1953, HE1954, HE1955, HE1956, HE1957, HE1958, HE1959, HE1960, HE1961, HE1962, HE1963, HE1964, HE1965, HE1966, HE1967, HE1968, HE1969, HE1970, HE1971, HE1972, HE1973, HE1974, HE1975, HE1976, HE1977, HE1978, HE1979, HE1980, HE1981, HE1982, HE1983, HE1984, HE1985, HE1986, HE1987, HE1988, HE1989, HE1990, HE1991, HE1992, HE1993, HE1994, HE1995, HE1996, HE1997, HE1998, HE1999) } - override fun fromValue(value: Int): HugeEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): HugeEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No HugeEnum with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(HE0, HE1000, HE1001, HE1002, HE1003, HE1004, HE1005, HE1006, HE1007, HE1008, HE1009, HE1010, HE1011, HE1012, HE1013, HE1014, HE1015, HE1016, HE1017, HE1018, HE1019, HE1020, HE1021, HE1022, HE1023, HE1024, HE1025, HE1026, HE1027, HE1028, HE1029, HE1030, HE1031, HE1032, HE1033, HE1034, HE1035, HE1036, HE1037, HE1038, HE1039, HE1040, HE1041, HE1042, HE1043, HE1044, HE1045, HE1046, HE1047, HE1048, HE1049, HE1050, HE1051, HE1052, HE1053, HE1054, HE1055, HE1056, HE1057, HE1058, HE1059, HE1060, HE1061, HE1062, HE1063, HE1064, HE1065, HE1066, HE1067, HE1068, HE1069, HE1070, HE1071, HE1072, HE1073, HE1074, HE1075, HE1076, HE1077, HE1078, HE1079, HE1080, HE1081, HE1082, HE1083, HE1084, HE1085, HE1086, HE1087, HE1088, HE1089, HE1090, HE1091, HE1092, HE1093, HE1094, HE1095, HE1096, HE1097, HE1098, HE1099, HE1100, HE1101, HE1102, HE1103, HE1104, HE1105, HE1106, HE1107, HE1108, HE1109, HE1110, HE1111, HE1112, HE1113, HE1114, HE1115, HE1116, HE1117, HE1118, HE1119, HE1120, HE1121, HE1122, HE1123, HE1124, HE1125, HE1126, HE1127, HE1128, HE1129, HE1130, HE1131, HE1132, HE1133, HE1134, HE1135, HE1136, HE1137, HE1138, HE1139, HE1140, HE1141, HE1142, HE1143, HE1144, HE1145, HE1146, HE1147, HE1148, HE1149, HE1150, HE1151, HE1152, HE1153, HE1154, HE1155, HE1156, HE1157, HE1158, HE1159, HE1160, HE1161, HE1162, HE1163, HE1164, HE1165, HE1166, HE1167, HE1168, HE1169, HE1170, HE1171, HE1172, HE1173, HE1174, HE1175, HE1176, HE1177, HE1178, HE1179, HE1180, HE1181, HE1182, HE1183, HE1184, HE1185, HE1186, HE1187, HE1188, HE1189, HE1190, HE1191, HE1192, HE1193, HE1194, HE1195, HE1196, HE1197, HE1198, HE1199, HE1200, HE1201, HE1202, HE1203, HE1204, HE1205, HE1206, HE1207, HE1208, HE1209, HE1210, HE1211, HE1212, HE1213, HE1214, HE1215, HE1216, HE1217, HE1218, HE1219, HE1220, HE1221, HE1222, HE1223, HE1224, HE1225, HE1226, HE1227, HE1228, HE1229, HE1230, HE1231, HE1232, HE1233, HE1234, HE1235, HE1236, HE1237, HE1238, HE1239, HE1240, HE1241, HE1242, HE1243, HE1244, HE1245, HE1246, HE1247, HE1248, HE1249, HE1250, HE1251, HE1252, HE1253, HE1254, HE1255, HE1256, HE1257, HE1258, HE1259, HE1260, HE1261, HE1262, HE1263, HE1264, HE1265, HE1266, HE1267, HE1268, HE1269, HE1270, HE1271, HE1272, HE1273, HE1274, HE1275, HE1276, HE1277, HE1278, HE1279, HE1280, HE1281, HE1282, HE1283, HE1284, HE1285, HE1286, HE1287, HE1288, HE1289, HE1290, HE1291, HE1292, HE1293, HE1294, HE1295, HE1296, HE1297, HE1298, HE1299, HE1300, HE1301, HE1302, HE1303, HE1304, HE1305, HE1306, HE1307, HE1308, HE1309, HE1310, HE1311, HE1312, HE1313, HE1314, HE1315, HE1316, HE1317, HE1318, HE1319, HE1320, HE1321, HE1322, HE1323, HE1324, HE1325, HE1326, HE1327, HE1328, HE1329, HE1330, HE1331, HE1332, HE1333, HE1334, HE1335, HE1336, HE1337, HE1338, HE1339, HE1340, HE1341, HE1342, HE1343, HE1344, HE1345, HE1346, HE1347, HE1348, HE1349, HE1350, HE1351, HE1352, HE1353, HE1354, HE1355, HE1356, HE1357, HE1358, HE1359, HE1360, HE1361, HE1362, HE1363, HE1364, HE1365, HE1366, HE1367, HE1368, HE1369, HE1370, HE1371, HE1372, HE1373, HE1374, HE1375, HE1376, HE1377, HE1378, HE1379, HE1380, HE1381, HE1382, HE1383, HE1384, HE1385, HE1386, HE1387, HE1388, HE1389, HE1390, HE1391, HE1392, HE1393, HE1394, HE1395, HE1396, HE1397, HE1398, HE1399, HE1400, HE1401, HE1402, HE1403, HE1404, HE1405, HE1406, HE1407, HE1408, HE1409, HE1410, HE1411, HE1412, HE1413, HE1414, HE1415, HE1416, HE1417, HE1418, HE1419, HE1420, HE1421, HE1422, HE1423, HE1424, HE1425, HE1426, HE1427, HE1428, HE1429, HE1430, HE1431, HE1432, HE1433, HE1434, HE1435, HE1436, HE1437, HE1438, HE1439, HE1440, HE1441, HE1442, HE1443, HE1444, HE1445, HE1446, HE1447, HE1448, HE1449, HE1450, HE1451, HE1452, HE1453, HE1454, HE1455, HE1456, HE1457, HE1458, HE1459, HE1460, HE1461, HE1462, HE1463, HE1464, HE1465, HE1466, HE1467, HE1468, HE1469, HE1470, HE1471, HE1472, HE1473, HE1474, HE1475, HE1476, HE1477, HE1478, HE1479, HE1480, HE1481, HE1482, HE1483, HE1484, HE1485, HE1486, HE1487, HE1488, HE1489, HE1490, HE1491, HE1492, HE1493, HE1494, HE1495, HE1496, HE1497, HE1498, HE1499, HE1500, HE1501, HE1502, HE1503, HE1504, HE1505, HE1506, HE1507, HE1508, HE1509, HE1510, HE1511, HE1512, HE1513, HE1514, HE1515, HE1516, HE1517, HE1518, HE1519, HE1520, HE1521, HE1522, HE1523, HE1524, HE1525, HE1526, HE1527, HE1528, HE1529, HE1530, HE1531, HE1532, HE1533, HE1534, HE1535, HE1536, HE1537, HE1538, HE1539, HE1540, HE1541, HE1542, HE1543, HE1544, HE1545, HE1546, HE1547, HE1548, HE1549, HE1550, HE1551, HE1552, HE1553, HE1554, HE1555, HE1556, HE1557, HE1558, HE1559, HE1560, HE1561, HE1562, HE1563, HE1564, HE1565, HE1566, HE1567, HE1568, HE1569, HE1570, HE1571, HE1572, HE1573, HE1574, HE1575, HE1576, HE1577, HE1578, HE1579, HE1580, HE1581, HE1582, HE1583, HE1584, HE1585, HE1586, HE1587, HE1588, HE1589, HE1590, HE1591, HE1592, HE1593, HE1594, HE1595, HE1596, HE1597, HE1598, HE1599, HE1600, HE1601, HE1602, HE1603, HE1604, HE1605, HE1606, HE1607, HE1608, HE1609, HE1610, HE1611, HE1612, HE1613, HE1614, HE1615, HE1616, HE1617, HE1618, HE1619, HE1620, HE1621, HE1622, HE1623, HE1624, HE1625, HE1626, HE1627, HE1628, HE1629, HE1630, HE1631, HE1632, HE1633, HE1634, HE1635, HE1636, HE1637, HE1638, HE1639, HE1640, HE1641, HE1642, HE1643, HE1644, HE1645, HE1646, HE1647, HE1648, HE1649, HE1650, HE1651, HE1652, HE1653, HE1654, HE1655, HE1656, HE1657, HE1658, HE1659, HE1660, HE1661, HE1662, HE1663, HE1664, HE1665, HE1666, HE1667, HE1668, HE1669, HE1670, HE1671, HE1672, HE1673, HE1674, HE1675, HE1676, HE1677, HE1678, HE1679, HE1680, HE1681, HE1682, HE1683, HE1684, HE1685, HE1686, HE1687, HE1688, HE1689, HE1690, HE1691, HE1692, HE1693, HE1694, HE1695, HE1696, HE1697, HE1698, HE1699, HE1700, HE1701, HE1702, HE1703, HE1704, HE1705, HE1706, HE1707, HE1708, HE1709, HE1710, HE1711, HE1712, HE1713, HE1714, HE1715, HE1716, HE1717, HE1718, HE1719, HE1720, HE1721, HE1722, HE1723, HE1724, HE1725, HE1726, HE1727, HE1728, HE1729, HE1730, HE1731, HE1732, HE1733, HE1734, HE1735, HE1736, HE1737, HE1738, HE1739, HE1740, HE1741, HE1742, HE1743, HE1744, HE1745, HE1746, HE1747, HE1748, HE1749, HE1750, HE1751, HE1752, HE1753, HE1754, HE1755, HE1756, HE1757, HE1758, HE1759, HE1760, HE1761, HE1762, HE1763, HE1764, HE1765, HE1766, HE1767, HE1768, HE1769, HE1770, HE1771, HE1772, HE1773, HE1774, HE1775, HE1776, HE1777, HE1778, HE1779, HE1780, HE1781, HE1782, HE1783, HE1784, HE1785, HE1786, HE1787, HE1788, HE1789, HE1790, HE1791, HE1792, HE1793, HE1794, HE1795, HE1796, HE1797, HE1798, HE1799, HE1800, HE1801, HE1802, HE1803, HE1804, HE1805, HE1806, HE1807, HE1808, HE1809, HE1810, HE1811, HE1812, HE1813, HE1814, HE1815, HE1816, HE1817, HE1818, HE1819, HE1820, HE1821, HE1822, HE1823, HE1824, HE1825, HE1826, HE1827, HE1828, HE1829, HE1830, HE1831, HE1832, HE1833, HE1834, HE1835, HE1836, HE1837, HE1838, HE1839, HE1840, HE1841, HE1842, HE1843, HE1844, HE1845, HE1846, HE1847, HE1848, HE1849, HE1850, HE1851, HE1852, HE1853, HE1854, HE1855, HE1856, HE1857, HE1858, HE1859, HE1860, HE1861, HE1862, HE1863, HE1864, HE1865, HE1866, HE1867, HE1868, HE1869, HE1870, HE1871, HE1872, HE1873, HE1874, HE1875, HE1876, HE1877, HE1878, HE1879, HE1880, HE1881, HE1882, HE1883, HE1884, HE1885, HE1886, HE1887, HE1888, HE1889, HE1890, HE1891, HE1892, HE1893, HE1894, HE1895, HE1896, HE1897, HE1898, HE1899, HE1900, HE1901, HE1902, HE1903, HE1904, HE1905, HE1906, HE1907, HE1908, HE1909, HE1910, HE1911, HE1912, HE1913, HE1914, HE1915, HE1916, HE1917, HE1918, HE1919, HE1920, HE1921, HE1922, HE1923, HE1924, HE1925, HE1926, HE1927, HE1928, HE1929, HE1930, HE1931, HE1932, HE1933, HE1934, HE1935, HE1936, HE1937, HE1938, HE1939, HE1940, HE1941, HE1942, HE1943, HE1944, HE1945, HE1946, HE1947, HE1948, HE1949, HE1950, HE1951, HE1952, HE1953, HE1954, HE1955, HE1956, HE1957, HE1958, HE1959, HE1960, HE1961, HE1962, HE1963, HE1964, HE1965, HE1966, HE1967, HE1968, HE1969, HE1970, HE1971, HE1972, HE1973, HE1974, HE1975, HE1976, HE1977, HE1978, HE1979, HE1980, HE1981, HE1982, HE1983, HE1984, HE1985, HE1986, HE1987, HE1988, HE1989, HE1990, HE1991, HE1992, HE1993, HE1994, HE1995, HE1996, HE1997, HE1998, HE1999) } + override fun fromValue(value: Int): pbandk.testpb.HugeEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.testpb.HugeEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No HugeEnum with name: $name") } } diff --git a/test-types/src/commonMain/kotlin/pbandk/testpb/test_messages_proto3.kt b/test-types/src/commonMain/kotlin/pbandk/testpb/test_messages_proto3.kt index e81fd523..4c063c9b 100644 --- a/test-types/src/commonMain/kotlin/pbandk/testpb/test_messages_proto3.kt +++ b/test-types/src/commonMain/kotlin/pbandk/testpb/test_messages_proto3.kt @@ -4,7 +4,7 @@ package pbandk.testpb @pbandk.Export public sealed class ForeignEnum(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is ForeignEnum && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.testpb.ForeignEnum && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "ForeignEnum.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -13,10 +13,10 @@ public sealed class ForeignEnum(override val value: Int, override val name: Stri public object FOREIGN_BAZ : ForeignEnum(2, "FOREIGN_BAZ") public class UNRECOGNIZED(value: Int) : ForeignEnum(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(FOREIGN_FOO, FOREIGN_BAR, FOREIGN_BAZ) } - override fun fromValue(value: Int): ForeignEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): ForeignEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No ForeignEnum with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(FOREIGN_FOO, FOREIGN_BAR, FOREIGN_BAZ) } + override fun fromValue(value: Int): pbandk.testpb.ForeignEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.testpb.ForeignEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No ForeignEnum with name: $name") } } @@ -1716,7 +1716,7 @@ public data class TestAllTypesProto3( } public sealed class NestedEnum(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is TestAllTypesProto3.NestedEnum && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.testpb.TestAllTypesProto3.NestedEnum && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "TestAllTypesProto3.NestedEnum.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -1726,15 +1726,15 @@ public data class TestAllTypesProto3( public object NEG : NestedEnum(-1, "NEG") public class UNRECOGNIZED(value: Int) : NestedEnum(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(FOO, BAR, BAZ, NEG) } - override fun fromValue(value: Int): TestAllTypesProto3.NestedEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): TestAllTypesProto3.NestedEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No NestedEnum with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(FOO, BAR, BAZ, NEG) } + override fun fromValue(value: Int): pbandk.testpb.TestAllTypesProto3.NestedEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.testpb.TestAllTypesProto3.NestedEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No NestedEnum with name: $name") } } public sealed class AliasedEnum(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is TestAllTypesProto3.AliasedEnum && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.testpb.TestAllTypesProto3.AliasedEnum && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "TestAllTypesProto3.AliasedEnum.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -1746,10 +1746,10 @@ public data class TestAllTypesProto3( public object B_AZ : AliasedEnum(2, "bAz") public class UNRECOGNIZED(value: Int) : AliasedEnum(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(ALIAS_FOO, ALIAS_BAR, ALIAS_BAZ, QUX, QUX_, B_AZ) } - override fun fromValue(value: Int): TestAllTypesProto3.AliasedEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): TestAllTypesProto3.AliasedEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No AliasedEnum with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(ALIAS_FOO, ALIAS_BAR, ALIAS_BAZ, QUX, QUX_, B_AZ) } + override fun fromValue(value: Int): pbandk.testpb.TestAllTypesProto3.AliasedEnum = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.testpb.TestAllTypesProto3.AliasedEnum = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No AliasedEnum with name: $name") } } diff --git a/test-types/src/commonMain/kotlin/pbandk/testpb/test_proto2.kt b/test-types/src/commonMain/kotlin/pbandk/testpb/test_proto2.kt index 606e83bd..c243282f 100644 --- a/test-types/src/commonMain/kotlin/pbandk/testpb/test_proto2.kt +++ b/test-types/src/commonMain/kotlin/pbandk/testpb/test_proto2.kt @@ -73,7 +73,7 @@ public data class MessageWithEnum( } public sealed class EnumType(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is MessageWithEnum.EnumType && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.testpb.MessageWithEnum.EnumType && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "MessageWithEnum.EnumType.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -81,10 +81,10 @@ public data class MessageWithEnum( public object BAR : EnumType(1, "BAR") public class UNRECOGNIZED(value: Int) : EnumType(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(FOO, BAR) } - override fun fromValue(value: Int): MessageWithEnum.EnumType = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): MessageWithEnum.EnumType = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No EnumType with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(FOO, BAR) } + override fun fromValue(value: Int): pbandk.testpb.MessageWithEnum.EnumType = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.testpb.MessageWithEnum.EnumType = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No EnumType with name: $name") } } } diff --git a/test-types/src/commonMain/kotlin/pbandk/testpb/validate.kt b/test-types/src/commonMain/kotlin/pbandk/testpb/validate.kt index d06efe21..a485482b 100644 --- a/test-types/src/commonMain/kotlin/pbandk/testpb/validate.kt +++ b/test-types/src/commonMain/kotlin/pbandk/testpb/validate.kt @@ -4,7 +4,7 @@ package pbandk.testpb @pbandk.Export public sealed class KnownRegex(override val value: Int, override val name: String? = null) : pbandk.Message.Enum { - override fun equals(other: kotlin.Any?): Boolean = other is KnownRegex && other.value == value + override fun equals(other: kotlin.Any?): Boolean = other is pbandk.testpb.KnownRegex && other.value == value override fun hashCode(): Int = value.hashCode() override fun toString(): String = "KnownRegex.${name ?: "UNRECOGNIZED"}(value=$value)" @@ -13,10 +13,10 @@ public sealed class KnownRegex(override val value: Int, override val name: Strin public object HTTP_HEADER_VALUE : KnownRegex(2, "HTTP_HEADER_VALUE") public class UNRECOGNIZED(value: Int) : KnownRegex(value) - public companion object : pbandk.Message.Enum.Companion { - public val values: List by lazy { listOf(UNKNOWN, HTTP_HEADER_NAME, HTTP_HEADER_VALUE) } - override fun fromValue(value: Int): KnownRegex = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) - override fun fromName(name: String): KnownRegex = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No KnownRegex with name: $name") + public companion object : pbandk.Message.Enum.Companion { + public val values: List by lazy { listOf(UNKNOWN, HTTP_HEADER_NAME, HTTP_HEADER_VALUE) } + override fun fromValue(value: Int): pbandk.testpb.KnownRegex = values.firstOrNull { it.value == value } ?: UNRECOGNIZED(value) + override fun fromName(name: String): pbandk.testpb.KnownRegex = values.firstOrNull { it.name == name } ?: throw IllegalArgumentException("No KnownRegex with name: $name") } }