diff --git a/runtime/api/runtime.api b/runtime/api/runtime.api index 04c69741..9a457b05 100644 --- a/runtime/api/runtime.api +++ b/runtime/api/runtime.api @@ -1210,11 +1210,12 @@ public final class pbandk/wkt/Field$Kind$UNRECOGNIZED : pbandk/wkt/Field$Kind { public final class pbandk/wkt/FieldDescriptorProto : pbandk/Message { public static final field Companion Lpbandk/wkt/FieldDescriptorProto$Companion; public fun ()V - public fun (Ljava/lang/String;Ljava/lang/Integer;Lpbandk/wkt/FieldDescriptorProto$Label;Lpbandk/wkt/FieldDescriptorProto$Type;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lpbandk/wkt/FieldOptions;Ljava/util/Map;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/Integer;Lpbandk/wkt/FieldDescriptorProto$Label;Lpbandk/wkt/FieldDescriptorProto$Type;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lpbandk/wkt/FieldOptions;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Ljava/lang/Integer;Lpbandk/wkt/FieldDescriptorProto$Label;Lpbandk/wkt/FieldDescriptorProto$Type;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lpbandk/wkt/FieldOptions;Ljava/lang/Boolean;Ljava/util/Map;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/Integer;Lpbandk/wkt/FieldDescriptorProto$Label;Lpbandk/wkt/FieldDescriptorProto$Type;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lpbandk/wkt/FieldOptions;Ljava/lang/Boolean;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/lang/String; public final fun component10 ()Lpbandk/wkt/FieldOptions; - public final fun component11 ()Ljava/util/Map; + public final fun component11 ()Ljava/lang/Boolean; + public final fun component12 ()Ljava/util/Map; public final fun component2 ()Ljava/lang/Integer; public final fun component3 ()Lpbandk/wkt/FieldDescriptorProto$Label; public final fun component4 ()Lpbandk/wkt/FieldDescriptorProto$Type; @@ -1223,8 +1224,8 @@ public final class pbandk/wkt/FieldDescriptorProto : pbandk/Message { public final fun component7 ()Ljava/lang/String; public final fun component8 ()Ljava/lang/Integer; public final fun component9 ()Ljava/lang/String; - public final fun copy (Ljava/lang/String;Ljava/lang/Integer;Lpbandk/wkt/FieldDescriptorProto$Label;Lpbandk/wkt/FieldDescriptorProto$Type;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lpbandk/wkt/FieldOptions;Ljava/util/Map;)Lpbandk/wkt/FieldDescriptorProto; - public static synthetic fun copy$default (Lpbandk/wkt/FieldDescriptorProto;Ljava/lang/String;Ljava/lang/Integer;Lpbandk/wkt/FieldDescriptorProto$Label;Lpbandk/wkt/FieldDescriptorProto$Type;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lpbandk/wkt/FieldOptions;Ljava/util/Map;ILjava/lang/Object;)Lpbandk/wkt/FieldDescriptorProto; + public final fun copy (Ljava/lang/String;Ljava/lang/Integer;Lpbandk/wkt/FieldDescriptorProto$Label;Lpbandk/wkt/FieldDescriptorProto$Type;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lpbandk/wkt/FieldOptions;Ljava/lang/Boolean;Ljava/util/Map;)Lpbandk/wkt/FieldDescriptorProto; + public static synthetic fun copy$default (Lpbandk/wkt/FieldDescriptorProto;Ljava/lang/String;Ljava/lang/Integer;Lpbandk/wkt/FieldDescriptorProto$Label;Lpbandk/wkt/FieldDescriptorProto$Type;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Lpbandk/wkt/FieldOptions;Ljava/lang/Boolean;Ljava/util/Map;ILjava/lang/Object;)Lpbandk/wkt/FieldDescriptorProto; public fun equals (Ljava/lang/Object;)Z public final fun getDefaultValue ()Ljava/lang/String; public fun getDescriptor ()Lpbandk/MessageDescriptor; @@ -1235,6 +1236,7 @@ public final class pbandk/wkt/FieldDescriptorProto : pbandk/Message { public final fun getNumber ()Ljava/lang/Integer; public final fun getOneofIndex ()Ljava/lang/Integer; public final fun getOptions ()Lpbandk/wkt/FieldOptions; + public final fun getProto3Optional ()Ljava/lang/Boolean; public fun getProtoSize ()I public final fun getType ()Lpbandk/wkt/FieldDescriptorProto$Type; public final fun getTypeName ()Ljava/lang/String; diff --git a/runtime/build.gradle.kts b/runtime/build.gradle.kts index d3dac501..1ca50fb2 100644 --- a/runtime/build.gradle.kts +++ b/runtime/build.gradle.kts @@ -142,11 +142,7 @@ android { tasks { val generateWellKnownTypes by registering(KotlinProtocTask::class) { - val protocPath = provider { - System.getProperty("protoc.path") - ?: throw InvalidUserDataException("System property protoc.path must be set") - }.map { rootProject.layout.projectDirectory.dir(it) } - includeDir.set(protocPath.map { it.dir("include") }) + includeDir.set(layout.dir(extractWellKnownTypeProtos.map { it.destinationDir })) outputDir.set(project.file("src/commonMain/kotlin")) kotlinPackage.set("pbandk.wkt") logLevel.set("debug") diff --git a/runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt b/runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt index 33a57519..03c0de49 100644 --- a/runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt +++ b/runtime/src/commonMain/kotlin/pbandk/wkt/descriptor.kt @@ -472,6 +472,7 @@ data class FieldDescriptorProto( val oneofIndex: Int? = null, val jsonName: String? = null, val options: pbandk.wkt.FieldOptions? = null, + val proto3Optional: Boolean? = null, override val unknownFields: Map = emptyMap() ) : pbandk.Message { override operator fun plus(other: pbandk.Message?) = protoMergeImpl(other) @@ -482,7 +483,7 @@ data class FieldDescriptorProto( override fun decodeWith(u: pbandk.MessageDecoder) = pbandk.wkt.FieldDescriptorProto.decodeWithImpl(u) override val descriptor: pbandk.MessageDescriptor by lazy { - val fieldsList = ArrayList>(10) + val fieldsList = ArrayList>(11) fieldsList.apply { add( pbandk.FieldDescriptor( @@ -584,6 +585,16 @@ data class FieldDescriptorProto( value = pbandk.wkt.FieldDescriptorProto::jsonName ) ) + add( + pbandk.FieldDescriptor( + messageDescriptor = this@Companion::descriptor, + name = "proto3_optional", + number = 17, + type = pbandk.FieldDescriptor.Type.Primitive.Bool(hasPresence = true), + jsonName = "proto3Optional", + value = pbandk.wkt.FieldDescriptorProto::proto3Optional + ) + ) } pbandk.MessageDescriptor( messageClass = pbandk.wkt.FieldDescriptorProto::class, @@ -2338,6 +2349,7 @@ private fun FieldDescriptorProto.protoMergeImpl(plus: pbandk.Message?): FieldDes oneofIndex = plus.oneofIndex ?: oneofIndex, jsonName = plus.jsonName ?: jsonName, options = options?.plus(plus.options) ?: plus.options, + proto3Optional = plus.proto3Optional ?: proto3Optional, unknownFields = unknownFields + plus.unknownFields ) } ?: this @@ -2354,6 +2366,7 @@ private fun FieldDescriptorProto.Companion.decodeWithImpl(u: pbandk.MessageDecod var oneofIndex: Int? = null var jsonName: String? = null var options: pbandk.wkt.FieldOptions? = null + var proto3Optional: Boolean? = null val unknownFields = u.readMessage(this) { _fieldNumber, _fieldValue -> when (_fieldNumber) { @@ -2367,11 +2380,12 @@ private fun FieldDescriptorProto.Companion.decodeWithImpl(u: pbandk.MessageDecod 8 -> options = _fieldValue as pbandk.wkt.FieldOptions 9 -> oneofIndex = _fieldValue as Int 10 -> jsonName = _fieldValue as String + 17 -> proto3Optional = _fieldValue as Boolean } } return FieldDescriptorProto(name, number, label, type, typeName, extendee, defaultValue, oneofIndex, - jsonName, options, unknownFields) + jsonName, options, proto3Optional, unknownFields) } fun OneofDescriptorProto?.orDefault() = this ?: OneofDescriptorProto.defaultInstance