From f6d7ef1bb5efff1cd353a5003b5aec13c10c8047 Mon Sep 17 00:00:00 2001 From: Marco Ferrer <35935108+marcoferrer@users.noreply.github.com> Date: Mon, 3 Dec 2018 12:52:50 -0500 Subject: [PATCH 1/2] start 0.2.2 dev cycle --- CHANGELOG.md | 3 +++ build.gradle | 2 +- community-scripts/extendable-messages/build.gradle | 2 +- community-scripts/var-arg-extensions/build.gradle | 2 +- example-project/build.gradle | 3 ++- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c9dacd..cd45b6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## Version 0.2.2 +_2018-12-3_ + ## Version 0.2.1 _2018-11-02_ * Fix: Address regression in file filter matching diff --git a/build.gradle b/build.gradle index a39608a..e50cb27 100644 --- a/build.gradle +++ b/build.gradle @@ -44,7 +44,7 @@ subprojects{ subproject -> apply plugin: 'kotlin' group = 'com.github.marcoferrer.krotoplus' - version = '0.2.1' + version = '0.2.2-SNAPSHOT' compileKotlin { kotlinOptions.jvmTarget = "1.8" diff --git a/community-scripts/extendable-messages/build.gradle b/community-scripts/extendable-messages/build.gradle index 8947369..9322451 100644 --- a/community-scripts/extendable-messages/build.gradle +++ b/community-scripts/extendable-messages/build.gradle @@ -1,4 +1,4 @@ -def krotoPlusVersion = '0.2.1' +def krotoPlusVersion = '0.2.2-SNAPSHOT' plugins { id "org.jetbrains.kotlin.jvm" version "1.3.0" diff --git a/community-scripts/var-arg-extensions/build.gradle b/community-scripts/var-arg-extensions/build.gradle index 0298b22..46809d8 100644 --- a/community-scripts/var-arg-extensions/build.gradle +++ b/community-scripts/var-arg-extensions/build.gradle @@ -1,4 +1,4 @@ -def krotoPlusVersion = '0.2.1' +def krotoPlusVersion = '0.2.2.-SNAPSHOT' plugins { id "org.jetbrains.kotlin.jvm" version "1.3.0" diff --git a/example-project/build.gradle b/example-project/build.gradle index 9158f29..8cec9d3 100644 --- a/example-project/build.gradle +++ b/example-project/build.gradle @@ -5,7 +5,7 @@ buildscript { "grpc": '1.15.1', "kotlin": '1.3.0', "coroutines": '1.0.0', - "krotoplus": '0.2.1' + "krotoplus": '0.2.2-SNAPSHOT' ] } @@ -44,6 +44,7 @@ allprojects { repositories { jcenter() maven { url 'http://dl.bintray.com/kotlin/kotlin-eap' } + maven { url "https://kotlin.bintray.com/kotlinx" } if(versions.krotoplus.endsWith("SNAPSHOT")) { flatDir dirs: "${rootDir}/../kroto-plus-message/build/libs/" flatDir dirs: "${rootDir}/../kroto-plus-coroutines/build/libs/" From 720fdf37db11bfa9c7d433e2d83eac4d55746b4f Mon Sep 17 00:00:00 2001 From: Marco Ferrer <35935108+marcoferrer@users.noreply.github.com> Date: Mon, 3 Dec 2018 12:59:26 -0500 Subject: [PATCH 2/2] initial prototype for kotlinx serialization codegen --- example-project/build.gradle | 3 + example-project/settings.gradle | 8 + .../proto/test/message/nested_messages.proto | 23 + example-project/testing.asciipb | 7 + .../krotoplus/config/CompilerConfig.java | 435 ++++++++++++ .../config/CompilerConfigOrBuilder.java | 44 ++ .../marcoferrer/krotoplus/config/Config.java | 21 +- .../config/MPProtobufMessagesGenOptions.java | 663 ++++++++++++++++++ ...MPProtobufMessagesGenOptionsOrBuilder.java | 37 + .../krotoplus/KrotoPlusProtoCMain.kt | 1 + .../generators/MPProtobufMessageGenerator.kt | 155 ++++ .../marcoferrer/krotoplus/proto/ProtoField.kt | 113 ++- .../proto/krotoplus/compiler/config.proto | 12 + 13 files changed, 1499 insertions(+), 23 deletions(-) create mode 100644 example-project/testing.asciipb create mode 100644 protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/MPProtobufMessagesGenOptions.java create mode 100644 protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/MPProtobufMessagesGenOptionsOrBuilder.java create mode 100644 protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/generators/MPProtobufMessageGenerator.kt diff --git a/example-project/build.gradle b/example-project/build.gradle index 8cec9d3..d37141f 100644 --- a/example-project/build.gradle +++ b/example-project/build.gradle @@ -19,6 +19,7 @@ buildscript { plugins{ id 'idea' id 'com.google.protobuf' version '0.8.6' + id 'kotlinx-serialization' version '1.3.0' id "org.jetbrains.kotlin.jvm" version "1.3.0" } @@ -57,6 +58,8 @@ allprojects { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.coroutines}" + implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.9.0" + implementation "com.google.protobuf:protobuf-java:${versions.protobuf}" implementation "com.github.marcoferrer.krotoplus:kroto-plus-coroutines:${versions.krotoplus}" implementation "com.github.marcoferrer.krotoplus:kroto-plus-test:${versions.krotoplus}" diff --git a/example-project/settings.gradle b/example-project/settings.gradle index 1e40aa0..6503b85 100644 --- a/example-project/settings.gradle +++ b/example-project/settings.gradle @@ -5,5 +5,13 @@ pluginManagement{ maven { url 'http://dl.bintray.com/kotlin/kotlin-eap' } maven { url 'https://plugins.gradle.org/m2/' } } + + resolutionStrategy { + eachPlugin { + if (requested.id.id == "kotlinx-serialization") { + useModule("org.jetbrains.kotlin:kotlin-serialization:${requested.version}") + } + } + } } include 'kp-scripts' \ No newline at end of file diff --git a/example-project/src/main/proto/test/message/nested_messages.proto b/example-project/src/main/proto/test/message/nested_messages.proto index 0bfd65b..8a1a603 100644 --- a/example-project/src/main/proto/test/message/nested_messages.proto +++ b/example-project/src/main/proto/test/message/nested_messages.proto @@ -78,4 +78,27 @@ message TestRepeated { repeated string string_field = 15; repeated bytes bytes_field = 16; repeated L1Message1 message_field = 17; +} + +message SimpleTest { + string a = 1; + string b = 2; +} + +message OneOfMessage{ + + oneof value1 { + string value1_string = 1; + SimpleTest value1_message = 2; + int32 value1_int32 = 3; + TestEnum value1_enum = 4; + } + + oneof value2 { + string value2_string = 5; + SimpleTest value2_message = 6; + int32 value2_int32 = 7; + TestEnum value2_enum = 8; + } + } \ No newline at end of file diff --git a/example-project/testing.asciipb b/example-project/testing.asciipb new file mode 100644 index 0000000..1881daa --- /dev/null +++ b/example-project/testing.asciipb @@ -0,0 +1,7 @@ +proto_builders { + filter { + include_path: "test" + include_path: "asdasd" + } + unwrap_builders: true +} diff --git a/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/CompilerConfig.java b/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/CompilerConfig.java index a1eec03..419b4f8 100644 --- a/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/CompilerConfig.java +++ b/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/CompilerConfig.java @@ -26,6 +26,7 @@ private CompilerConfig() { extendableMessages_ = java.util.Collections.emptyList(); insertions_ = java.util.Collections.emptyList(); generatorScripts_ = java.util.Collections.emptyList(); + mpProtobufMessages_ = java.util.Collections.emptyList(); } @java.lang.Override @@ -106,6 +107,15 @@ private CompilerConfig( input.readMessage(com.github.marcoferrer.krotoplus.config.GeneratorScriptsGenOptions.parser(), extensionRegistry)); break; } + case 210: { + if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + mpProtobufMessages_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000040; + } + mpProtobufMessages_.add( + input.readMessage(com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.parser(), extensionRegistry)); + break; + } default: { if (!parseUnknownFieldProto3( input, unknownFields, extensionRegistry, tag)) { @@ -139,6 +149,9 @@ private CompilerConfig( if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { generatorScripts_ = java.util.Collections.unmodifiableList(generatorScripts_); } + if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { + mpProtobufMessages_ = java.util.Collections.unmodifiableList(mpProtobufMessages_); + } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } @@ -486,6 +499,61 @@ public com.github.marcoferrer.krotoplus.config.GeneratorScriptsGenOptionsOrBuild return generatorScripts_.get(index); } + public static final int MP_PROTOBUF_MESSAGES_FIELD_NUMBER = 26; + private java.util.List mpProtobufMessages_; + /** + *
+   * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+   * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public java.util.List getMpProtobufMessagesList() { + return mpProtobufMessages_; + } + /** + *
+   * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+   * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public java.util.List + getMpProtobufMessagesOrBuilderList() { + return mpProtobufMessages_; + } + /** + *
+   * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+   * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public int getMpProtobufMessagesCount() { + return mpProtobufMessages_.size(); + } + /** + *
+   * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+   * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions getMpProtobufMessages(int index) { + return mpProtobufMessages_.get(index); + } + /** + *
+   * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+   * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptionsOrBuilder getMpProtobufMessagesOrBuilder( + int index) { + return mpProtobufMessages_.get(index); + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -518,6 +586,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < generatorScripts_.size(); i++) { output.writeMessage(25, generatorScripts_.get(i)); } + for (int i = 0; i < mpProtobufMessages_.size(); i++) { + output.writeMessage(26, mpProtobufMessages_.get(i)); + } unknownFields.writeTo(output); } @@ -551,6 +622,10 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(25, generatorScripts_.get(i)); } + for (int i = 0; i < mpProtobufMessages_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(26, mpProtobufMessages_.get(i)); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -579,6 +654,8 @@ public boolean equals(final java.lang.Object obj) { .equals(other.getInsertionsList()); result = result && getGeneratorScriptsList() .equals(other.getGeneratorScriptsList()); + result = result && getMpProtobufMessagesList() + .equals(other.getMpProtobufMessagesList()); result = result && unknownFields.equals(other.unknownFields); return result; } @@ -614,6 +691,10 @@ public int hashCode() { hash = (37 * hash) + GENERATOR_SCRIPTS_FIELD_NUMBER; hash = (53 * hash) + getGeneratorScriptsList().hashCode(); } + if (getMpProtobufMessagesCount() > 0) { + hash = (37 * hash) + MP_PROTOBUF_MESSAGES_FIELD_NUMBER; + hash = (53 * hash) + getMpProtobufMessagesList().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -752,6 +833,7 @@ private void maybeForceBuilderInitialization() { getExtendableMessagesFieldBuilder(); getInsertionsFieldBuilder(); getGeneratorScriptsFieldBuilder(); + getMpProtobufMessagesFieldBuilder(); } } @java.lang.Override @@ -793,6 +875,12 @@ public Builder clear() { } else { generatorScriptsBuilder_.clear(); } + if (mpProtobufMessagesBuilder_ == null) { + mpProtobufMessages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + } else { + mpProtobufMessagesBuilder_.clear(); + } return this; } @@ -874,6 +962,15 @@ public com.github.marcoferrer.krotoplus.config.CompilerConfig buildPartial() { } else { result.generatorScripts_ = generatorScriptsBuilder_.build(); } + if (mpProtobufMessagesBuilder_ == null) { + if (((bitField0_ & 0x00000040) == 0x00000040)) { + mpProtobufMessages_ = java.util.Collections.unmodifiableList(mpProtobufMessages_); + bitField0_ = (bitField0_ & ~0x00000040); + } + result.mpProtobufMessages_ = mpProtobufMessages_; + } else { + result.mpProtobufMessages_ = mpProtobufMessagesBuilder_.build(); + } onBuilt(); return result; } @@ -1078,6 +1175,32 @@ public Builder mergeFrom(com.github.marcoferrer.krotoplus.config.CompilerConfig } } } + if (mpProtobufMessagesBuilder_ == null) { + if (!other.mpProtobufMessages_.isEmpty()) { + if (mpProtobufMessages_.isEmpty()) { + mpProtobufMessages_ = other.mpProtobufMessages_; + bitField0_ = (bitField0_ & ~0x00000040); + } else { + ensureMpProtobufMessagesIsMutable(); + mpProtobufMessages_.addAll(other.mpProtobufMessages_); + } + onChanged(); + } + } else { + if (!other.mpProtobufMessages_.isEmpty()) { + if (mpProtobufMessagesBuilder_.isEmpty()) { + mpProtobufMessagesBuilder_.dispose(); + mpProtobufMessagesBuilder_ = null; + mpProtobufMessages_ = other.mpProtobufMessages_; + bitField0_ = (bitField0_ & ~0x00000040); + mpProtobufMessagesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getMpProtobufMessagesFieldBuilder() : null; + } else { + mpProtobufMessagesBuilder_.addAllMessages(other.mpProtobufMessages_); + } + } + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -2979,6 +3102,318 @@ public com.github.marcoferrer.krotoplus.config.GeneratorScriptsGenOptions.Builde } return generatorScriptsBuilder_; } + + private java.util.List mpProtobufMessages_ = + java.util.Collections.emptyList(); + private void ensureMpProtobufMessagesIsMutable() { + if (!((bitField0_ & 0x00000040) == 0x00000040)) { + mpProtobufMessages_ = new java.util.ArrayList(mpProtobufMessages_); + bitField0_ |= 0x00000040; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptionsOrBuilder> mpProtobufMessagesBuilder_; + + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public java.util.List getMpProtobufMessagesList() { + if (mpProtobufMessagesBuilder_ == null) { + return java.util.Collections.unmodifiableList(mpProtobufMessages_); + } else { + return mpProtobufMessagesBuilder_.getMessageList(); + } + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public int getMpProtobufMessagesCount() { + if (mpProtobufMessagesBuilder_ == null) { + return mpProtobufMessages_.size(); + } else { + return mpProtobufMessagesBuilder_.getCount(); + } + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions getMpProtobufMessages(int index) { + if (mpProtobufMessagesBuilder_ == null) { + return mpProtobufMessages_.get(index); + } else { + return mpProtobufMessagesBuilder_.getMessage(index); + } + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public Builder setMpProtobufMessages( + int index, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions value) { + if (mpProtobufMessagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMpProtobufMessagesIsMutable(); + mpProtobufMessages_.set(index, value); + onChanged(); + } else { + mpProtobufMessagesBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public Builder setMpProtobufMessages( + int index, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder builderForValue) { + if (mpProtobufMessagesBuilder_ == null) { + ensureMpProtobufMessagesIsMutable(); + mpProtobufMessages_.set(index, builderForValue.build()); + onChanged(); + } else { + mpProtobufMessagesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public Builder addMpProtobufMessages(com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions value) { + if (mpProtobufMessagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMpProtobufMessagesIsMutable(); + mpProtobufMessages_.add(value); + onChanged(); + } else { + mpProtobufMessagesBuilder_.addMessage(value); + } + return this; + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public Builder addMpProtobufMessages( + int index, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions value) { + if (mpProtobufMessagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMpProtobufMessagesIsMutable(); + mpProtobufMessages_.add(index, value); + onChanged(); + } else { + mpProtobufMessagesBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public Builder addMpProtobufMessages( + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder builderForValue) { + if (mpProtobufMessagesBuilder_ == null) { + ensureMpProtobufMessagesIsMutable(); + mpProtobufMessages_.add(builderForValue.build()); + onChanged(); + } else { + mpProtobufMessagesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public Builder addMpProtobufMessages( + int index, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder builderForValue) { + if (mpProtobufMessagesBuilder_ == null) { + ensureMpProtobufMessagesIsMutable(); + mpProtobufMessages_.add(index, builderForValue.build()); + onChanged(); + } else { + mpProtobufMessagesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public Builder addAllMpProtobufMessages( + java.lang.Iterable values) { + if (mpProtobufMessagesBuilder_ == null) { + ensureMpProtobufMessagesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, mpProtobufMessages_); + onChanged(); + } else { + mpProtobufMessagesBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public Builder clearMpProtobufMessages() { + if (mpProtobufMessagesBuilder_ == null) { + mpProtobufMessages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + } else { + mpProtobufMessagesBuilder_.clear(); + } + return this; + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public Builder removeMpProtobufMessages(int index) { + if (mpProtobufMessagesBuilder_ == null) { + ensureMpProtobufMessagesIsMutable(); + mpProtobufMessages_.remove(index); + onChanged(); + } else { + mpProtobufMessagesBuilder_.remove(index); + } + return this; + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder getMpProtobufMessagesBuilder( + int index) { + return getMpProtobufMessagesFieldBuilder().getBuilder(index); + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptionsOrBuilder getMpProtobufMessagesOrBuilder( + int index) { + if (mpProtobufMessagesBuilder_ == null) { + return mpProtobufMessages_.get(index); } else { + return mpProtobufMessagesBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public java.util.List + getMpProtobufMessagesOrBuilderList() { + if (mpProtobufMessagesBuilder_ != null) { + return mpProtobufMessagesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(mpProtobufMessages_); + } + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder addMpProtobufMessagesBuilder() { + return getMpProtobufMessagesFieldBuilder().addBuilder( + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.getDefaultInstance()); + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder addMpProtobufMessagesBuilder( + int index) { + return getMpProtobufMessagesFieldBuilder().addBuilder( + index, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.getDefaultInstance()); + } + /** + *
+     * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+     * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + public java.util.List + getMpProtobufMessagesBuilderList() { + return getMpProtobufMessagesFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptionsOrBuilder> + getMpProtobufMessagesFieldBuilder() { + if (mpProtobufMessagesBuilder_ == null) { + mpProtobufMessagesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptionsOrBuilder>( + mpProtobufMessages_, + ((bitField0_ & 0x00000040) == 0x00000040), + getParentForChildren(), + isClean()); + mpProtobufMessages_ = null; + } + return mpProtobufMessagesBuilder_; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/CompilerConfigOrBuilder.java b/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/CompilerConfigOrBuilder.java index 2fe5a0a..e2c0cc8 100644 --- a/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/CompilerConfigOrBuilder.java +++ b/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/CompilerConfigOrBuilder.java @@ -270,4 +270,48 @@ com.github.marcoferrer.krotoplus.config.InsertionsGenOptionsOrBuilder getInserti */ com.github.marcoferrer.krotoplus.config.GeneratorScriptsGenOptionsOrBuilder getGeneratorScriptsOrBuilder( int index); + + /** + *
+   * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+   * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + java.util.List + getMpProtobufMessagesList(); + /** + *
+   * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+   * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions getMpProtobufMessages(int index); + /** + *
+   * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+   * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + int getMpProtobufMessagesCount(); + /** + *
+   * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+   * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + java.util.List + getMpProtobufMessagesOrBuilderList(); + /** + *
+   * Configuration entries for the 'Multi-Platform Protobuf Messages' code generator.
+   * 
+ * + * repeated .krotoplus.compiler.MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + */ + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptionsOrBuilder getMpProtobufMessagesOrBuilder( + int index); } diff --git a/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/Config.java b/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/Config.java index 9273fde..a4d09aa 100644 --- a/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/Config.java +++ b/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/Config.java @@ -59,6 +59,11 @@ public static void registerAllExtensions( static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_krotoplus_compiler_MockServicesGenOptions_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_krotoplus_compiler_MPProtobufMessagesGenOptions_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_krotoplus_compiler_MPProtobufMessagesGenOptions_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -70,7 +75,7 @@ public static void registerAllExtensions( java.lang.String[] descriptorData = { "\n\037krotoplus/compiler/config.proto\022\022kroto" + "plus.compiler\032 google/protobuf/descripto" + - "r.proto\"\263\003\n\016CompilerConfig\022B\n\016grpc_stub_" + + "r.proto\"\203\004\n\016CompilerConfig\022B\n\016grpc_stub_" + "exts\030\024 \003(\0132*.krotoplus.compiler.GrpcStub" + "ExtsGenOptions\022A\n\rmock_services\030\025 \003(\0132*." + "krotoplus.compiler.MockServicesGenOption" + @@ -81,6 +86,8 @@ public static void registerAllExtensions( "ns\030\030 \003(\0132(.krotoplus.compiler.Insertions" + "GenOptions\022I\n\021generator_scripts\030\031 \003(\0132.." + "krotoplus.compiler.GeneratorScriptsGenOp" + + "tions\022N\n\024mp_protobuf_messages\030\032 \003(\01320.kr" + + "otoplus.compiler.MPProtobufMessagesGenOp" + "tions\"8\n\nFileFilter\022\024\n\014include_path\030\001 \003(" + "\t\022\024\n\014exclude_path\030\002 \003(\t\"d\n\026GrpcStubExtsG" + "enOptions\022.\n\006filter\030\001 \001(\0132\036.krotoplus.co" + @@ -107,7 +114,9 @@ public static void registerAllExtensions( "s.compiler.FileFilter\022\033\n\023implement_as_ob" + "ject\030\002 \001(\010\022\035\n\025generate_service_list\030\003 \001(" + "\010\022\034\n\024service_list_package\030\004 \001(\t\022\031\n\021servi" + - "ce_list_name\030\005 \001(\t*\257\001\n\016InsertionPoint\022\013\n" + + "ce_list_name\030\005 \001(\t\"N\n\034MPProtobufMessages" + + "GenOptions\022.\n\006filter\030\001 \001(\0132\036.krotoplus.c" + + "ompiler.FileFilter*\257\001\n\016InsertionPoint\022\013\n" + "\007UNKNOWN\020\000\022\025\n\021INTERFACE_EXTENDS\020\001\022\026\n\022MES" + "SAGE_IMPLEMENTS\020\002\022\026\n\022BUILDER_IMPLEMENTS\020" + "\003\022\021\n\rBUILDER_SCOPE\020\004\022\017\n\013CLASS_SCOPE\020\005\022\016\n" + @@ -133,7 +142,7 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( internal_static_krotoplus_compiler_CompilerConfig_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_krotoplus_compiler_CompilerConfig_descriptor, - new java.lang.String[] { "GrpcStubExts", "MockServices", "ProtoBuilders", "ExtendableMessages", "Insertions", "GeneratorScripts", }); + new java.lang.String[] { "GrpcStubExts", "MockServices", "ProtoBuilders", "ExtendableMessages", "Insertions", "GeneratorScripts", "MpProtobufMessages", }); internal_static_krotoplus_compiler_FileFilter_descriptor = getDescriptor().getMessageTypes().get(1); internal_static_krotoplus_compiler_FileFilter_fieldAccessorTable = new @@ -182,6 +191,12 @@ public com.google.protobuf.ExtensionRegistry assignDescriptors( com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_krotoplus_compiler_MockServicesGenOptions_descriptor, new java.lang.String[] { "Filter", "ImplementAsObject", "GenerateServiceList", "ServiceListPackage", "ServiceListName", }); + internal_static_krotoplus_compiler_MPProtobufMessagesGenOptions_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_krotoplus_compiler_MPProtobufMessagesGenOptions_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_krotoplus_compiler_MPProtobufMessagesGenOptions_descriptor, + new java.lang.String[] { "Filter", }); com.google.protobuf.DescriptorProtos.getDescriptor(); } diff --git a/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/MPProtobufMessagesGenOptions.java b/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/MPProtobufMessagesGenOptions.java new file mode 100644 index 0000000..616b005 --- /dev/null +++ b/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/MPProtobufMessagesGenOptions.java @@ -0,0 +1,663 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: krotoplus/compiler/config.proto + +package com.github.marcoferrer.krotoplus.config; + +/** + *
+ * Configuration used by the 'Mock Services' code generator.
+ * 
+ * + * Protobuf type {@code krotoplus.compiler.MPProtobufMessagesGenOptions} + */ +public final class MPProtobufMessagesGenOptions extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:krotoplus.compiler.MPProtobufMessagesGenOptions) + MPProtobufMessagesGenOptionsOrBuilder { +private static final long serialVersionUID = 0L; + // Use MPProtobufMessagesGenOptions.newBuilder() to construct. + private MPProtobufMessagesGenOptions(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private MPProtobufMessagesGenOptions() { + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MPProtobufMessagesGenOptions( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + com.github.marcoferrer.krotoplus.config.FileFilter.Builder subBuilder = null; + if (filter_ != null) { + subBuilder = filter_.toBuilder(); + } + filter_ = input.readMessage(com.github.marcoferrer.krotoplus.config.FileFilter.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(filter_); + filter_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.github.marcoferrer.krotoplus.config.Config.internal_static_krotoplus_compiler_MPProtobufMessagesGenOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.github.marcoferrer.krotoplus.config.Config.internal_static_krotoplus_compiler_MPProtobufMessagesGenOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.class, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder.class); + } + + public static final int FILTER_FIELD_NUMBER = 1; + private com.github.marcoferrer.krotoplus.config.FileFilter filter_; + /** + *
+   * Filter used for limiting the input files that are processed by the code generator
+   * The default filter will match true against all input files.
+   * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public boolean hasFilter() { + return filter_ != null; + } + /** + *
+   * Filter used for limiting the input files that are processed by the code generator
+   * The default filter will match true against all input files.
+   * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public com.github.marcoferrer.krotoplus.config.FileFilter getFilter() { + return filter_ == null ? com.github.marcoferrer.krotoplus.config.FileFilter.getDefaultInstance() : filter_; + } + /** + *
+   * Filter used for limiting the input files that are processed by the code generator
+   * The default filter will match true against all input files.
+   * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public com.github.marcoferrer.krotoplus.config.FileFilterOrBuilder getFilterOrBuilder() { + return getFilter(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (filter_ != null) { + output.writeMessage(1, getFilter()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (filter_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getFilter()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions)) { + return super.equals(obj); + } + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions other = (com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions) obj; + + boolean result = true; + result = result && (hasFilter() == other.hasFilter()); + if (hasFilter()) { + result = result && getFilter() + .equals(other.getFilter()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasFilter()) { + hash = (37 * hash) + FILTER_FIELD_NUMBER; + hash = (53 * hash) + getFilter().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * Configuration used by the 'Mock Services' code generator.
+   * 
+ * + * Protobuf type {@code krotoplus.compiler.MPProtobufMessagesGenOptions} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:krotoplus.compiler.MPProtobufMessagesGenOptions) + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.github.marcoferrer.krotoplus.config.Config.internal_static_krotoplus_compiler_MPProtobufMessagesGenOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.github.marcoferrer.krotoplus.config.Config.internal_static_krotoplus_compiler_MPProtobufMessagesGenOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.class, com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.Builder.class); + } + + // Construct using com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (filterBuilder_ == null) { + filter_ = null; + } else { + filter_ = null; + filterBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.github.marcoferrer.krotoplus.config.Config.internal_static_krotoplus_compiler_MPProtobufMessagesGenOptions_descriptor; + } + + @java.lang.Override + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions getDefaultInstanceForType() { + return com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.getDefaultInstance(); + } + + @java.lang.Override + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions build() { + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions buildPartial() { + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions result = new com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions(this); + if (filterBuilder_ == null) { + result.filter_ = filter_; + } else { + result.filter_ = filterBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions) { + return mergeFrom((com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions other) { + if (other == com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions.getDefaultInstance()) return this; + if (other.hasFilter()) { + mergeFilter(other.getFilter()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.github.marcoferrer.krotoplus.config.FileFilter filter_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + com.github.marcoferrer.krotoplus.config.FileFilter, com.github.marcoferrer.krotoplus.config.FileFilter.Builder, com.github.marcoferrer.krotoplus.config.FileFilterOrBuilder> filterBuilder_; + /** + *
+     * Filter used for limiting the input files that are processed by the code generator
+     * The default filter will match true against all input files.
+     * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public boolean hasFilter() { + return filterBuilder_ != null || filter_ != null; + } + /** + *
+     * Filter used for limiting the input files that are processed by the code generator
+     * The default filter will match true against all input files.
+     * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public com.github.marcoferrer.krotoplus.config.FileFilter getFilter() { + if (filterBuilder_ == null) { + return filter_ == null ? com.github.marcoferrer.krotoplus.config.FileFilter.getDefaultInstance() : filter_; + } else { + return filterBuilder_.getMessage(); + } + } + /** + *
+     * Filter used for limiting the input files that are processed by the code generator
+     * The default filter will match true against all input files.
+     * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public Builder setFilter(com.github.marcoferrer.krotoplus.config.FileFilter value) { + if (filterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + filter_ = value; + onChanged(); + } else { + filterBuilder_.setMessage(value); + } + + return this; + } + /** + *
+     * Filter used for limiting the input files that are processed by the code generator
+     * The default filter will match true against all input files.
+     * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public Builder setFilter( + com.github.marcoferrer.krotoplus.config.FileFilter.Builder builderForValue) { + if (filterBuilder_ == null) { + filter_ = builderForValue.build(); + onChanged(); + } else { + filterBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+     * Filter used for limiting the input files that are processed by the code generator
+     * The default filter will match true against all input files.
+     * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public Builder mergeFilter(com.github.marcoferrer.krotoplus.config.FileFilter value) { + if (filterBuilder_ == null) { + if (filter_ != null) { + filter_ = + com.github.marcoferrer.krotoplus.config.FileFilter.newBuilder(filter_).mergeFrom(value).buildPartial(); + } else { + filter_ = value; + } + onChanged(); + } else { + filterBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+     * Filter used for limiting the input files that are processed by the code generator
+     * The default filter will match true against all input files.
+     * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public Builder clearFilter() { + if (filterBuilder_ == null) { + filter_ = null; + onChanged(); + } else { + filter_ = null; + filterBuilder_ = null; + } + + return this; + } + /** + *
+     * Filter used for limiting the input files that are processed by the code generator
+     * The default filter will match true against all input files.
+     * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public com.github.marcoferrer.krotoplus.config.FileFilter.Builder getFilterBuilder() { + + onChanged(); + return getFilterFieldBuilder().getBuilder(); + } + /** + *
+     * Filter used for limiting the input files that are processed by the code generator
+     * The default filter will match true against all input files.
+     * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + public com.github.marcoferrer.krotoplus.config.FileFilterOrBuilder getFilterOrBuilder() { + if (filterBuilder_ != null) { + return filterBuilder_.getMessageOrBuilder(); + } else { + return filter_ == null ? + com.github.marcoferrer.krotoplus.config.FileFilter.getDefaultInstance() : filter_; + } + } + /** + *
+     * Filter used for limiting the input files that are processed by the code generator
+     * The default filter will match true against all input files.
+     * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.github.marcoferrer.krotoplus.config.FileFilter, com.github.marcoferrer.krotoplus.config.FileFilter.Builder, com.github.marcoferrer.krotoplus.config.FileFilterOrBuilder> + getFilterFieldBuilder() { + if (filterBuilder_ == null) { + filterBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.github.marcoferrer.krotoplus.config.FileFilter, com.github.marcoferrer.krotoplus.config.FileFilter.Builder, com.github.marcoferrer.krotoplus.config.FileFilterOrBuilder>( + getFilter(), + getParentForChildren(), + isClean()); + filter_ = null; + } + return filterBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:krotoplus.compiler.MPProtobufMessagesGenOptions) + } + + // @@protoc_insertion_point(class_scope:krotoplus.compiler.MPProtobufMessagesGenOptions) + private static final com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions(); + } + + public static com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MPProtobufMessagesGenOptions parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MPProtobufMessagesGenOptions(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.github.marcoferrer.krotoplus.config.MPProtobufMessagesGenOptions getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/MPProtobufMessagesGenOptionsOrBuilder.java b/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/MPProtobufMessagesGenOptionsOrBuilder.java new file mode 100644 index 0000000..08ae6ce --- /dev/null +++ b/protoc-gen-kroto-plus/src/main/generated/com/github/marcoferrer/krotoplus/config/MPProtobufMessagesGenOptionsOrBuilder.java @@ -0,0 +1,37 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: krotoplus/compiler/config.proto + +package com.github.marcoferrer.krotoplus.config; + +public interface MPProtobufMessagesGenOptionsOrBuilder extends + // @@protoc_insertion_point(interface_extends:krotoplus.compiler.MPProtobufMessagesGenOptions) + com.google.protobuf.MessageOrBuilder { + + /** + *
+   * Filter used for limiting the input files that are processed by the code generator
+   * The default filter will match true against all input files.
+   * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + boolean hasFilter(); + /** + *
+   * Filter used for limiting the input files that are processed by the code generator
+   * The default filter will match true against all input files.
+   * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + com.github.marcoferrer.krotoplus.config.FileFilter getFilter(); + /** + *
+   * Filter used for limiting the input files that are processed by the code generator
+   * The default filter will match true against all input files.
+   * 
+ * + * .krotoplus.compiler.FileFilter filter = 1; + */ + com.github.marcoferrer.krotoplus.config.FileFilterOrBuilder getFilterOrBuilder(); +} diff --git a/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/KrotoPlusProtoCMain.kt b/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/KrotoPlusProtoCMain.kt index 9ea8c4d..e47d975 100644 --- a/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/KrotoPlusProtoCMain.kt +++ b/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/KrotoPlusProtoCMain.kt @@ -18,6 +18,7 @@ fun main(args: Array) = runBlocking { GrpcStubExtsGenerator, ProtoBuildersGenerator, ExtendableMessagesGenerator, + MPProtobufMessageGenerator, MockServicesGenerator, InsertionsGenerator, GeneratorScriptsGenerator diff --git a/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/generators/MPProtobufMessageGenerator.kt b/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/generators/MPProtobufMessageGenerator.kt new file mode 100644 index 0000000..cd2d486 --- /dev/null +++ b/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/generators/MPProtobufMessageGenerator.kt @@ -0,0 +1,155 @@ +package com.github.marcoferrer.krotoplus.generators + +import com.github.marcoferrer.krotoplus.proto.* +import com.github.marcoferrer.krotoplus.utils.memoize +import com.google.protobuf.compiler.PluginProtos +import com.squareup.kotlinpoet.* + + +object MPProtobufMessageGenerator : Generator { + + override val isEnabled: Boolean + get() = context.config.mpProtobufMessagesList.isNotEmpty() + + override fun invoke(): PluginProtos.CodeGeneratorResponse { + + val responseBuilder = PluginProtos.CodeGeneratorResponse.newBuilder() + context.schema.protoFiles.forEach { protoFile -> + + val typeSpecs = + protoFile.protoMessages.map { it.buildType() } + protoFile.protoEnums.map { it.buildType() } + + + if (protoFile.javaMultipleFiles) for (typeSpec in typeSpecs) { + responseBuilder.addFile(FileSpec + .builder(protoFile.javaPackage,typeSpec.name!!) + .addType(typeSpec) + .build() + .toResponseFileProto()) + + } else { + + FileSpec.builder(protoFile.javaPackage,protoFile.javaOuterClassname) + .addType(TypeSpec + .objectBuilder(protoFile.javaOuterClassname) + .addTypes(typeSpecs) + .build()) + .build() + .also { + responseBuilder.addFile(it.toResponseFileProto()) + } + } + + } + + return responseBuilder.build() + } + + + private fun ProtoEnum.buildType(): TypeSpec { + + val enumSpec = TypeSpec.enumBuilder(name) + .primaryConstructor(FunSpec.constructorBuilder() + .addParameter(ParameterSpec.builder("val number",Int::class.asClassName()) + .build()) + .build()) + + val companionSpec = TypeSpec.companionObjectBuilder() + + descriptorProto.valueList.forEach { enumDescriptor -> + + enumSpec.addEnumConstant("${enumDescriptor.name}(${enumDescriptor.number})") + + companionSpec.addProperty(PropertySpec + .builder(enumDescriptor.name,Int::class.asClassName()) + .initializer(enumDescriptor.number.toString()) + .build() + ) + } + + enumSpec.addEnumConstant("UNRECOGNIZED(-1)") + + return enumSpec + .companionObject(companionSpec.build()) + .build() + } + + private fun ProtoMessage.buildType(): TypeSpec { + + //Check field count before applying data modifier + + val classSpecBuilder = TypeSpec.classBuilder(name) + .addModifiers(KModifier.DATA) + .addAnnotation(ANNO_SPEC_SERIAL_SERIALIZABLE) + + val constructorSpec = FunSpec.constructorBuilder() + + descriptorProto.fieldList + .forEach { fieldDescriptor -> + + val fieldName = camelCaseFieldName(fieldDescriptor.name).decapitalize() + val className = fieldDescriptor.getFieldClassName(context.schema) + + val parameterBuilder = when{ + fieldDescriptor.isMapField(context.schema) || + fieldDescriptor.isRepeated -> ParameterSpec + .builder("val $fieldName",fieldDescriptor.getParamaterizeTypeName(context.schema)) + + else -> ParameterSpec.builder("val $fieldName",className) + } + + parameterBuilder + .defaultValue(fieldDescriptor.getDefaultInitializer(context.schema)) + .addAnnotation(ANNO_SPEC_SERIAL_OPTIONAL) + .addAnnotation(AnnotationSpec.builder(ANNO_CN_SERIAL_SERIAL_ID) + .addMember(fieldDescriptor.number.toString()) + .build()) + + constructorSpec.addParameter(parameterBuilder.build()) + } + + classSpecBuilder.primaryConstructor(constructorSpec.build()) + .companionObject(TypeSpec.companionObjectBuilder() + .addProperty(PropertySpec + .builder("defaultInstance",className) + .initializer("%T()",className) + .build()) + .build()) + + nestedMessageTypes.filterNot { it.isMapEntry }.forEach { nestedMessage -> + classSpecBuilder.addType(nestedMessage.buildType()) + } + + nestedEnumTypes.forEach { nestedEnum -> + classSpecBuilder.addType(nestedEnum.buildType()) + } + + return classSpecBuilder.build() + } +} + + + +val ANNO_CN_SERIAL_SERIALIZABLE = + ClassName("kotlinx.serialization","Serializable") + +val ANNO_SPEC_SERIAL_SERIALIZABLE = + AnnotationSpec.builder(ANNO_CN_SERIAL_SERIALIZABLE).build() + +val ANNO_CN_SERIAL_OPTIONAL = + ClassName("kotlinx.serialization","Optional") + +val ANNO_SPEC_SERIAL_OPTIONAL = + AnnotationSpec.builder(ANNO_CN_SERIAL_OPTIONAL).build() + +val ANNO_CN_SERIAL_SERIAL_ID = + ClassName("kotlinx.serialization","SerialId") + +private val camelCaseFieldName = { it: String -> + // We cant use CaseFormat.UPPER_CAMEL since + // protoc is lenient with malformed field names + if (it.contains("_")) + it.split("_").joinToString(separator = "") { it.capitalize() } else + it.capitalize() + +}.memoize() \ No newline at end of file diff --git a/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/proto/ProtoField.kt b/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/proto/ProtoField.kt index 9c0ca9a..5af35b3 100644 --- a/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/proto/ProtoField.kt +++ b/protoc-gen-kroto-plus/src/main/kotlin/com/github/marcoferrer/krotoplus/proto/ProtoField.kt @@ -2,30 +2,103 @@ package com.github.marcoferrer.krotoplus.proto import com.google.protobuf.ByteString import com.google.protobuf.DescriptorProtos +import com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Label.* +import com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Type.* import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.ParameterizedTypeName import com.squareup.kotlinpoet.asClassName +import java.lang.IllegalArgumentException fun DescriptorProtos.FieldDescriptorProto.getFieldClassName(schema: Schema): ClassName = when (type!!) { - DescriptorProtos.FieldDescriptorProto.Type.TYPE_INT64, - DescriptorProtos.FieldDescriptorProto.Type.TYPE_FIXED64, - DescriptorProtos.FieldDescriptorProto.Type.TYPE_SFIXED64, - DescriptorProtos.FieldDescriptorProto.Type.TYPE_SINT64, - DescriptorProtos.FieldDescriptorProto.Type.TYPE_UINT64 -> Long::class.asClassName() - DescriptorProtos.FieldDescriptorProto.Type.TYPE_INT32, - DescriptorProtos.FieldDescriptorProto.Type.TYPE_UINT32, - DescriptorProtos.FieldDescriptorProto.Type.TYPE_SFIXED32, - DescriptorProtos.FieldDescriptorProto.Type.TYPE_SINT32, - DescriptorProtos.FieldDescriptorProto.Type.TYPE_FIXED32 -> Int::class.asClassName() - DescriptorProtos.FieldDescriptorProto.Type.TYPE_DOUBLE -> Double::class.asClassName() - DescriptorProtos.FieldDescriptorProto.Type.TYPE_FLOAT -> Float::class.asClassName() - DescriptorProtos.FieldDescriptorProto.Type.TYPE_BOOL -> Boolean::class.asClassName() - DescriptorProtos.FieldDescriptorProto.Type.TYPE_STRING -> String::class.asClassName() - DescriptorProtos.FieldDescriptorProto.Type.TYPE_GROUP -> TODO() - DescriptorProtos.FieldDescriptorProto.Type.TYPE_BYTES -> ByteString::class.asClassName() - DescriptorProtos.FieldDescriptorProto.Type.TYPE_MESSAGE -> - (schema.protoTypes[typeName] as ProtoMessage).className - DescriptorProtos.FieldDescriptorProto.Type.TYPE_ENUM -> - (schema.protoTypes[typeName] as ProtoEnum).className + TYPE_INT64, + TYPE_FIXED64, + TYPE_SFIXED64, + TYPE_SINT64, + TYPE_UINT64 -> Long::class.asClassName() + TYPE_INT32, + TYPE_UINT32, + TYPE_SFIXED32, + TYPE_SINT32, + TYPE_FIXED32 -> Int::class.asClassName() + TYPE_DOUBLE -> Double::class.asClassName() + TYPE_FLOAT -> Float::class.asClassName() + TYPE_BOOL -> Boolean::class.asClassName() + TYPE_STRING -> String::class.asClassName() + TYPE_BYTES -> ByteString::class.asClassName() + + TYPE_GROUP -> + TODO("ClassName for field type 'GROUP' is not yet implemented") + + TYPE_MESSAGE -> (schema.protoTypes[typeName] as ProtoMessage).className + TYPE_ENUM -> (schema.protoTypes[typeName] as ProtoEnum).className + } + +//need to check the actual message in schema +fun DescriptorProtos.FieldDescriptorProto.isMapField(schema:Schema): Boolean = + type == TYPE_MESSAGE && getFieldProtoMessage(schema).isMapEntry + +val DescriptorProtos.FieldDescriptorProto.isRepeated: Boolean + get() = label == LABEL_REPEATED + + +fun DescriptorProtos.FieldDescriptorProto.getParamaterizeTypeName(schema: Schema): ParameterizedTypeName = + when{ + isMapField(schema) -> { + val message = getFieldProtoMessage(schema) + val keyCn = message.descriptorProto.getField(0) + .getFieldClassName(schema) + + val valueCn = message.descriptorProto.getField(1) + .getFieldClassName(schema) + + ParameterizedTypeName.get(Map::class.asClassName(), keyCn, valueCn) + } + label == LABEL_REPEATED -> { + + ParameterizedTypeName.get(List::class.asClassName(), getFieldClassName(schema)) + } + else -> throw IllegalArgumentException("Only 'REPEATED' or 'MapEntry' fields can be parameterized") + } + + +fun DescriptorProtos.FieldDescriptorProto.getFieldProtoMessage(schema: Schema): ProtoMessage = + requireNotNull(schema.protoTypes[typeName] as? ProtoMessage){ + "$typeName was not found in schema type map." + } + + +fun DescriptorProtos.FieldDescriptorProto.getDefaultInitializer(schema: Schema): String = + when { + isMapField(schema) -> "emptyMap()" + isRepeated -> "emptyList()" + else -> when (type!!) { + TYPE_INT64, + TYPE_FIXED64, + TYPE_SFIXED64, + TYPE_SINT64, + TYPE_UINT64, + TYPE_INT32, + TYPE_UINT32, + TYPE_SFIXED32, + TYPE_SINT32, + TYPE_FIXED32, + TYPE_DOUBLE, + TYPE_FLOAT -> "0" + TYPE_BOOL -> "false" + TYPE_STRING -> "\"\"" + TYPE_BYTES, + TYPE_GROUP -> + TODO("DefaultInitializer for field type '${type.name}' is not yet implemented") + + TYPE_MESSAGE -> (schema.protoTypes[typeName] as ProtoMessage) + .let { it.canonicalJavaName + ".defaultInstance" } + + + TYPE_ENUM -> (schema.protoTypes[typeName] as ProtoEnum) + .let { enum -> + "${enum.canonicalJavaName}.${enum.descriptorProto.valueList.first().name}" + } + } } \ No newline at end of file diff --git a/protoc-gen-kroto-plus/src/main/proto/krotoplus/compiler/config.proto b/protoc-gen-kroto-plus/src/main/proto/krotoplus/compiler/config.proto index 08a4135..31e6d9b 100644 --- a/protoc-gen-kroto-plus/src/main/proto/krotoplus/compiler/config.proto +++ b/protoc-gen-kroto-plus/src/main/proto/krotoplus/compiler/config.proto @@ -33,6 +33,9 @@ message CompilerConfig { // Configuration entries for the 'Generator Scripts' code generator. repeated GeneratorScriptsGenOptions generator_scripts = 25; + // Configuration entries for the 'Multi-Platform Protobuf Messages' code generator. + repeated MPProtobufMessagesGenOptions mp_protobuf_messages = 26; + } // Represent a filter used for including and excluding source files from @@ -215,3 +218,12 @@ message MockServicesGenOptions { } + +// Configuration used by the 'Mock Services' code generator. +message MPProtobufMessagesGenOptions { + + // Filter used for limiting the input files that are processed by the code generator + // The default filter will match true against all input files. + FileFilter filter = 1; +} +