Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/brpc/nonreflectable_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,20 @@ class NonreflectableMessage : public ::google::protobuf::Message {
struct NonreflectableMessageClassData : ClassDataFull {
constexpr NonreflectableMessageClassData()
: ClassDataFull(
# if GOOGLE_PROTOBUF_VERSION >= 5029000
# if GOOGLE_PROTOBUF_VERSION >= 7034000
ClassData{
&_instance, // prototype
nullptr, // tc_table
nullptr, // is_initialized
nullptr, // merge_to_from
::google::protobuf::internal::MessageCreator(), // message_creator
0, // cached_size_offset
false, // is_lite
},
nullptr, // descriptor_methods
nullptr, // descriptor_table
nullptr // get_metadata_tracker
# elif GOOGLE_PROTOBUF_VERSION >= 5029000
ClassData{
&_instance, // prototype
nullptr, // tc_table
Expand Down
2 changes: 1 addition & 1 deletion src/json2pb/json_to_pb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static void string_append_value(const BUTIL_RAPIDJSON_NAMESPACE::Value& value,
//otherwise will append error into error message and return false.
inline bool value_invalid(const google::protobuf::FieldDescriptor* field, const char* type,
const BUTIL_RAPIDJSON_NAMESPACE::Value& value, std::string* err) {
bool optional = field->is_optional();
bool optional = !field->is_required() && !field->is_repeated();
if (err) {
if (!err->empty()) {
err->append(", ");
Expand Down
6 changes: 3 additions & 3 deletions src/mcpack2pb/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ static bool generate_parsing(const google::protobuf::Descriptor* d,
} break;
} // switch
} else {
if (f->is_optional()) {
if (!f->is_required() && !f->is_repeated()) {
impl.Print("// optional $type$ $name$ = $number$;\n"
, "type", field_to_string(f)
, "name", f->name()
Expand Down Expand Up @@ -888,12 +888,12 @@ static bool generate_serializing(const google::protobuf::Descriptor* d,
butil::string_printf(&comment_template,
"// %s $type$ $name$ = $number$;\n",
(f->is_repeated() ? "repeated" :
(f->is_optional() ? "optional" : "required")));
(f->is_required() ? "required" : "optional")));
} else {
butil::string_printf(&comment_template,
"// %s $type$ $name$ = $number$ [(idl_type)=%s];\n",
(f->is_repeated() ? "repeated" :
(f->is_optional() ? "optional" : "required")),
(f->is_required() ? "required" : "optional")),
describe_idl_type(cit));
}
impl.Print(comment_template.c_str()
Expand Down
Loading