|
|
@ -128,7 +128,8 @@ void WriteFieldAccessorsInHeader(const protobuf::Descriptor* desc, |
|
|
|
inline $0 $1() const { return $2_$3(msg_); } |
|
|
|
inline $0 $1() const { return $2_$3(msg_); } |
|
|
|
inline void set_$1($0 value) { return $2_set_$3(msg_, value); } |
|
|
|
inline void set_$1($0 value) { return $2_set_$3(msg_, value); } |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
CppConstType(field), resolved_field_name, MessageName(desc), |
|
|
|
CppConstType(field), resolved_field_name, |
|
|
|
|
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
resolved_upbc_name); |
|
|
|
resolved_upbc_name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -144,7 +145,9 @@ void WriteFieldAccessorHazzer(const protobuf::Descriptor* desc, |
|
|
|
if (field->has_presence()) { |
|
|
|
if (field->has_presence()) { |
|
|
|
// Has presence.
|
|
|
|
// Has presence.
|
|
|
|
ctx.EmitLegacy("inline bool has_$0() const { return $1_has_$2(msg_); }\n", |
|
|
|
ctx.EmitLegacy("inline bool has_$0() const { return $1_has_$2(msg_); }\n", |
|
|
|
resolved_field_name, MessageName(desc), resolved_upbc_name); |
|
|
|
resolved_field_name, |
|
|
|
|
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
|
|
|
|
resolved_upbc_name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -155,7 +158,8 @@ void WriteFieldAccessorClear(const protobuf::Descriptor* desc, |
|
|
|
Context& ctx) { |
|
|
|
Context& ctx) { |
|
|
|
if (field->has_presence()) { |
|
|
|
if (field->has_presence()) { |
|
|
|
ctx.EmitLegacy("void clear_$0() { $2_clear_$1(msg_); }\n", |
|
|
|
ctx.EmitLegacy("void clear_$0() { $2_clear_$1(msg_); }\n", |
|
|
|
resolved_field_name, resolved_upbc_name, MessageName(desc)); |
|
|
|
resolved_field_name, resolved_upbc_name, |
|
|
|
|
|
|
|
upb::generator::CApiMessageType(desc->full_name())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -173,8 +177,8 @@ void WriteMapFieldAccessors(const protobuf::Descriptor* desc, |
|
|
|
inline void clear_$0() { $1_clear_$3(msg_); } |
|
|
|
inline void clear_$0() { $1_clear_$3(msg_); } |
|
|
|
void delete_$0($2 key); |
|
|
|
void delete_$0($2 key); |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
resolved_field_name, MessageName(desc), CppConstType(key), |
|
|
|
resolved_field_name, upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
resolved_upbc_name); |
|
|
|
CppConstType(key), resolved_upbc_name); |
|
|
|
|
|
|
|
|
|
|
|
if (val->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_MESSAGE) { |
|
|
|
if (val->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_MESSAGE) { |
|
|
|
ctx.Emit({{"field_name", resolved_field_name}, |
|
|
|
ctx.Emit({{"field_name", resolved_field_name}, |
|
|
@ -240,7 +244,8 @@ void WriteAccessorsInSource(const protobuf::Descriptor* desc, Context& ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, CppConstType(field), resolved_field_name, |
|
|
|
class_name, CppConstType(field), resolved_field_name, |
|
|
|
MessageName(desc), resolved_upbc_name); |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
|
|
|
|
resolved_upbc_name); |
|
|
|
// Set string.
|
|
|
|
// Set string.
|
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
@ -249,7 +254,9 @@ void WriteAccessorsInSource(const protobuf::Descriptor* desc, Context& ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, CppConstType(field), resolved_field_name, |
|
|
|
class_name, CppConstType(field), resolved_field_name, |
|
|
|
resolved_upbc_name, MessageName(desc), arena_expression); |
|
|
|
resolved_upbc_name, |
|
|
|
|
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
|
|
|
|
arena_expression); |
|
|
|
} else if (field->cpp_type() == |
|
|
|
} else if (field->cpp_type() == |
|
|
|
protobuf::FieldDescriptor::CPPTYPE_MESSAGE) { |
|
|
|
protobuf::FieldDescriptor::CPPTYPE_MESSAGE) { |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
@ -263,7 +270,8 @@ void WriteAccessorsInSource(const protobuf::Descriptor* desc, Context& ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, MessagePtrConstType(field, /* is_const */ true), |
|
|
|
class_name, MessagePtrConstType(field, /* is_const */ true), |
|
|
|
resolved_field_name, MessageName(desc), |
|
|
|
resolved_field_name, |
|
|
|
|
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
MessageBaseType(field, /* maybe_const */ false), |
|
|
|
MessageBaseType(field, /* maybe_const */ false), |
|
|
|
resolved_upbc_name); |
|
|
|
resolved_upbc_name); |
|
|
|
|
|
|
|
|
|
|
@ -282,7 +290,8 @@ void WriteAccessorsInSource(const protobuf::Descriptor* desc, Context& ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, MessagePtrConstType(field, /* is_const */ false), |
|
|
|
class_name, MessagePtrConstType(field, /* is_const */ false), |
|
|
|
resolved_field_name, MessageName(desc), |
|
|
|
resolved_field_name, |
|
|
|
|
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
MessageBaseType(field, /* maybe_const */ false), resolved_upbc_name, |
|
|
|
MessageBaseType(field, /* maybe_const */ false), resolved_upbc_name, |
|
|
|
arena_expression, ClassName(desc), field->index()); |
|
|
|
arena_expression, ClassName(desc), field->index()); |
|
|
|
} |
|
|
|
} |
|
|
@ -292,7 +301,7 @@ void WriteAccessorsInSource(const protobuf::Descriptor* desc, Context& ctx) { |
|
|
|
ctx.Emit("} // namespace internal\n\n"); |
|
|
|
ctx.Emit("} // namespace internal\n\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
void WriteMapAccessorDefinitions(const protobuf::Descriptor* desc, |
|
|
|
const protobuf::FieldDescriptor* field, |
|
|
|
const protobuf::FieldDescriptor* field, |
|
|
|
const absl::string_view resolved_field_name, |
|
|
|
const absl::string_view resolved_field_name, |
|
|
|
const absl::string_view class_name, |
|
|
|
const absl::string_view class_name, |
|
|
@ -322,9 +331,10 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
MessagePtrConstType(val, /* is_const */ true), MessageName(message), |
|
|
|
MessagePtrConstType(val, /* is_const */ true), |
|
|
|
MessageName(val->message_type()), optional_conversion_code, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
converted_key_name, upbc_name, |
|
|
|
upb::generator::CApiMessageType(val->message_type()->full_name()), |
|
|
|
|
|
|
|
optional_conversion_code, converted_key_name, upbc_name, |
|
|
|
::upb::generator::MiniTableMessageVarName( |
|
|
|
::upb::generator::MiniTableMessageVarName( |
|
|
|
val->message_type()->full_name())); |
|
|
|
val->message_type()->full_name())); |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
@ -337,9 +347,10 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
MessagePtrConstType(val, /* is_const */ false), MessageName(message), |
|
|
|
MessagePtrConstType(val, /* is_const */ false), |
|
|
|
MessageName(val->message_type()), optional_conversion_code, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
converted_key_name, upbc_name, |
|
|
|
upb::generator::CApiMessageType(val->message_type()->full_name()), |
|
|
|
|
|
|
|
optional_conversion_code, converted_key_name, upbc_name, |
|
|
|
::upb::generator::MiniTableMessageVarName( |
|
|
|
::upb::generator::MiniTableMessageVarName( |
|
|
|
val->message_type()->full_name())); |
|
|
|
val->message_type()->full_name())); |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
@ -350,9 +361,10 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
MessagePtrConstType(val, /* is_const */ true), MessageName(message), |
|
|
|
MessagePtrConstType(val, /* is_const */ true), |
|
|
|
MessageName(val->message_type()), optional_conversion_code, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
converted_key_name, upbc_name); |
|
|
|
upb::generator::CApiMessageType(val->message_type()->full_name()), |
|
|
|
|
|
|
|
optional_conversion_code, converted_key_name, upbc_name); |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
|
bool $0::set_alias_$1($2 key, $3 value) { |
|
|
|
bool $0::set_alias_$1($2 key, $3 value) { |
|
|
@ -361,9 +373,10 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
MessagePtrConstType(val, /* is_const */ false), MessageName(message), |
|
|
|
MessagePtrConstType(val, /* is_const */ false), |
|
|
|
MessageName(val->message_type()), optional_conversion_code, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
converted_key_name, upbc_name); |
|
|
|
upb::generator::CApiMessageType(val->message_type()->full_name()), |
|
|
|
|
|
|
|
optional_conversion_code, converted_key_name, upbc_name); |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
|
absl::StatusOr<$3> $0::get_$1($2 key) { |
|
|
|
absl::StatusOr<$3> $0::get_$1($2 key) { |
|
|
@ -376,8 +389,9 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
MessagePtrConstType(val, /* is_const */ true), MessageName(message), |
|
|
|
MessagePtrConstType(val, /* is_const */ true), |
|
|
|
MessageName(val->message_type()), |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
|
|
|
|
upb::generator::CApiMessageType(val->message_type()->full_name()), |
|
|
|
QualifiedClassName(val->message_type()), optional_conversion_code, |
|
|
|
QualifiedClassName(val->message_type()), optional_conversion_code, |
|
|
|
converted_key_name, upbc_name); |
|
|
|
converted_key_name, upbc_name); |
|
|
|
ctx.Emit( |
|
|
|
ctx.Emit( |
|
|
@ -385,8 +399,9 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
{"hpb_field_name", resolved_field_name}, |
|
|
|
{"hpb_field_name", resolved_field_name}, |
|
|
|
{"const_key", CppConstType(key)}, |
|
|
|
{"const_key", CppConstType(key)}, |
|
|
|
{"PtrMut", MessagePtrConstType(val, false)}, |
|
|
|
{"PtrMut", MessagePtrConstType(val, false)}, |
|
|
|
{"upb_msg_name", MessageName(message)}, |
|
|
|
{"upb_msg_name", upb::generator::CApiMessageType(desc->full_name())}, |
|
|
|
{"return_type", MessageName(val->message_type())}, |
|
|
|
{"return_type", |
|
|
|
|
|
|
|
upb::generator::CApiMessageType(val->message_type()->full_name())}, |
|
|
|
{"proto_class", QualifiedClassName(val->message_type())}, |
|
|
|
{"proto_class", QualifiedClassName(val->message_type())}, |
|
|
|
{"optional_conversion_code", optional_conversion_code}, |
|
|
|
{"optional_conversion_code", optional_conversion_code}, |
|
|
|
{"converted_key_name", converted_key_name}, |
|
|
|
{"converted_key_name", converted_key_name}, |
|
|
@ -410,9 +425,10 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
void $0::delete_$1($2 key) { $6$4_$8_delete(msg_, $7); } |
|
|
|
void $0::delete_$1($2 key) { $6$4_$8_delete(msg_, $7); } |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
class_name, resolved_field_name, CppConstType(key), |
|
|
|
MessagePtrConstType(val, /* is_const */ false), MessageName(message), |
|
|
|
MessagePtrConstType(val, /* is_const */ false), |
|
|
|
MessageName(val->message_type()), optional_conversion_code, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
converted_key_name, upbc_name); |
|
|
|
upb::generator::CApiMessageType(val->message_type()->full_name()), |
|
|
|
|
|
|
|
optional_conversion_code, converted_key_name, upbc_name); |
|
|
|
} else if (val->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_STRING) { |
|
|
|
} else if (val->cpp_type() == protobuf::FieldDescriptor::CPPTYPE_STRING) { |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
@ -423,8 +439,8 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
MessageName(message), optional_conversion_code, converted_key_name, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
upbc_name); |
|
|
|
optional_conversion_code, converted_key_name, upbc_name); |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
|
absl::StatusOr<$3> $0::get_$1($2 key) { |
|
|
|
absl::StatusOr<$3> $0::get_$1($2 key) { |
|
|
@ -437,15 +453,15 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
MessageName(message), optional_conversion_code, converted_key_name, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
upbc_name); |
|
|
|
optional_conversion_code, converted_key_name, upbc_name); |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
|
void $0::delete_$1($2 key) { $5$4_$7_delete(msg_, $6); } |
|
|
|
void $0::delete_$1($2 key) { $5$4_$7_delete(msg_, $6); } |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
MessageName(message), optional_conversion_code, converted_key_name, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
upbc_name); |
|
|
|
optional_conversion_code, converted_key_name, upbc_name); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
@ -454,8 +470,8 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
MessageName(message), optional_conversion_code, converted_key_name, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
upbc_name); |
|
|
|
optional_conversion_code, converted_key_name, upbc_name); |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
|
absl::StatusOr<$3> $0::get_$1($2 key) { |
|
|
|
absl::StatusOr<$3> $0::get_$1($2 key) { |
|
|
@ -468,15 +484,15 @@ void WriteMapAccessorDefinitions(const protobuf::Descriptor* message, |
|
|
|
} |
|
|
|
} |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
MessageName(message), optional_conversion_code, converted_key_name, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
upbc_name); |
|
|
|
optional_conversion_code, converted_key_name, upbc_name); |
|
|
|
ctx.EmitLegacy( |
|
|
|
ctx.EmitLegacy( |
|
|
|
R"cc( |
|
|
|
R"cc( |
|
|
|
void $0::delete_$1($2 key) { $5$4_$7_delete(msg_, $6); } |
|
|
|
void $0::delete_$1($2 key) { $5$4_$7_delete(msg_, $6); } |
|
|
|
)cc", |
|
|
|
)cc", |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
class_name, resolved_field_name, CppConstType(key), CppConstType(val), |
|
|
|
MessageName(message), optional_conversion_code, converted_key_name, |
|
|
|
upb::generator::CApiMessageType(desc->full_name()), |
|
|
|
upbc_name); |
|
|
|
optional_conversion_code, converted_key_name, upbc_name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|