compiler: support proto3 field presence for codegen

Support proto3 field presence #7051.

This is the same change as https://github.com/grpc/grpc/pull/22998/files#diff-6c29ff8771ae54ddf2c14e2ef3eb554fR37-R44
This commit is contained in:
ZHANG Dapeng 2020-05-21 15:39:10 -07:00 committed by GitHub
parent 3601190143
commit 97112b223f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -43,10 +43,14 @@ class JavaGrpcGenerator : public google::protobuf::compiler::CodeGenerator {
JavaGrpcGenerator() {} JavaGrpcGenerator() {}
virtual ~JavaGrpcGenerator() {} virtual ~JavaGrpcGenerator() {}
uint64_t GetSupportedFeatures() const override {
return FEATURE_PROTO3_OPTIONAL;
}
virtual bool Generate(const google::protobuf::FileDescriptor* file, virtual bool Generate(const google::protobuf::FileDescriptor* file,
const std::string& parameter, const std::string& parameter,
google::protobuf::compiler::GeneratorContext* context, google::protobuf::compiler::GeneratorContext* context,
std::string* error) const { std::string* error) const override {
std::vector<std::pair<std::string, std::string> > options; std::vector<std::pair<std::string, std::string> > options;
google::protobuf::compiler::ParseGeneratorParameter(parameter, &options); google::protobuf::compiler::ParseGeneratorParameter(parameter, &options);