|
|
@ -77,10 +77,10 @@ class CordFieldGenerator : public FieldGeneratorBase { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GenerateMemberConstexprConstructor(io::Printer* p) const override { |
|
|
|
void GenerateMemberConstexprConstructor(io::Printer* p) const override { |
|
|
|
if (descriptor_->default_value_string().empty()) { |
|
|
|
if (field_->default_value_string().empty()) { |
|
|
|
p->Emit("$name$_{}"); |
|
|
|
p->Emit("$name$_{}"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
p->Emit({{"Split", ShouldSplit(descriptor_, options_) ? "Split::" : ""}}, |
|
|
|
p->Emit({{"Split", ShouldSplit(field_, options_) ? "Split::" : ""}}, |
|
|
|
"$name$_{::absl::strings_internal::MakeStringConstant(" |
|
|
|
"$name$_{::absl::strings_internal::MakeStringConstant(" |
|
|
|
"$classname$::Impl_::$Split$_default_$name$_func_{})}"); |
|
|
|
"$classname$::Impl_::$Split$_default_$name$_func_{})}"); |
|
|
|
} |
|
|
|
} |
|
|
@ -88,7 +88,7 @@ class CordFieldGenerator : public FieldGeneratorBase { |
|
|
|
|
|
|
|
|
|
|
|
void GenerateMemberConstructor(io::Printer* p) const override { |
|
|
|
void GenerateMemberConstructor(io::Printer* p) const override { |
|
|
|
auto vars = p->WithVars(variables_); |
|
|
|
auto vars = p->WithVars(variables_); |
|
|
|
if (descriptor_->default_value_string().empty()) { |
|
|
|
if (field_->default_value_string().empty()) { |
|
|
|
p->Emit("$name$_{}"); |
|
|
|
p->Emit("$name$_{}"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
p->Emit("$name$_{::absl::string_view($default$, $default_length$)}"); |
|
|
|
p->Emit("$name$_{::absl::string_view($default$, $default_length$)}"); |
|
|
@ -142,7 +142,7 @@ CordFieldGenerator::CordFieldGenerator(const FieldDescriptor* descriptor, |
|
|
|
void CordFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const { |
|
|
|
void CordFieldGenerator::GeneratePrivateMembers(io::Printer* printer) const { |
|
|
|
Formatter format(printer, variables_); |
|
|
|
Formatter format(printer, variables_); |
|
|
|
format("::absl::Cord $name$_;\n"); |
|
|
|
format("::absl::Cord $name$_;\n"); |
|
|
|
if (!descriptor_->default_value_string().empty()) { |
|
|
|
if (!field_->default_value_string().empty()) { |
|
|
|
format( |
|
|
|
format( |
|
|
|
"struct _default_$name$_func_ {\n" |
|
|
|
"struct _default_$name$_func_ {\n" |
|
|
|
" constexpr absl::string_view operator()() const {\n" |
|
|
|
" constexpr absl::string_view operator()() const {\n" |
|
|
@ -156,18 +156,18 @@ void CordFieldGenerator::GenerateAccessorDeclarations( |
|
|
|
io::Printer* printer) const { |
|
|
|
io::Printer* printer) const { |
|
|
|
Formatter format(printer, variables_); |
|
|
|
Formatter format(printer, variables_); |
|
|
|
format("$deprecated_attr$const ::absl::Cord& ${1$$name$$}$() const;\n", |
|
|
|
format("$deprecated_attr$const ::absl::Cord& ${1$$name$$}$() const;\n", |
|
|
|
descriptor_); |
|
|
|
field_); |
|
|
|
format( |
|
|
|
format( |
|
|
|
"$deprecated_attr$void ${1$set_$name$$}$(const ::absl::Cord& value);\n" |
|
|
|
"$deprecated_attr$void ${1$set_$name$$}$(const ::absl::Cord& value);\n" |
|
|
|
"$deprecated_attr$void ${1$set_$name$$}$(::absl::string_view value);\n", |
|
|
|
"$deprecated_attr$void ${1$set_$name$$}$(::absl::string_view value);\n", |
|
|
|
std::make_tuple(descriptor_, GeneratedCodeInfo::Annotation::SET)); |
|
|
|
std::make_tuple(field_, GeneratedCodeInfo::Annotation::SET)); |
|
|
|
format( |
|
|
|
format( |
|
|
|
"private:\n" |
|
|
|
"private:\n" |
|
|
|
"const ::absl::Cord& ${1$_internal_$name$$}$() const;\n" |
|
|
|
"const ::absl::Cord& ${1$_internal_$name$$}$() const;\n" |
|
|
|
"void ${1$_internal_set_$name$$}$(const ::absl::Cord& value);\n" |
|
|
|
"void ${1$_internal_set_$name$$}$(const ::absl::Cord& value);\n" |
|
|
|
"::absl::Cord* ${1$_internal_mutable_$name$$}$();\n" |
|
|
|
"::absl::Cord* ${1$_internal_mutable_$name$$}$();\n" |
|
|
|
"public:\n", |
|
|
|
"public:\n", |
|
|
|
descriptor_); |
|
|
|
field_); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CordFieldGenerator::GenerateInlineAccessorDefinitions( |
|
|
|
void CordFieldGenerator::GenerateInlineAccessorDefinitions( |
|
|
@ -223,7 +223,7 @@ void CordFieldGenerator::GenerateInlineAccessorDefinitions( |
|
|
|
|
|
|
|
|
|
|
|
void CordFieldGenerator::GenerateClearingCode(io::Printer* printer) const { |
|
|
|
void CordFieldGenerator::GenerateClearingCode(io::Printer* printer) const { |
|
|
|
Formatter format(printer, variables_); |
|
|
|
Formatter format(printer, variables_); |
|
|
|
if (descriptor_->default_value_string().empty()) { |
|
|
|
if (field_->default_value_string().empty()) { |
|
|
|
format("$field$.Clear();\n"); |
|
|
|
format("$field$.Clear();\n"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
format("$field$ = ::absl::string_view($default$, $default_length$);\n"); |
|
|
|
format("$field$ = ::absl::string_view($default$, $default_length$);\n"); |
|
|
@ -243,7 +243,7 @@ void CordFieldGenerator::GenerateSwappingCode(io::Printer* printer) const { |
|
|
|
void CordFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { |
|
|
|
void CordFieldGenerator::GenerateConstructorCode(io::Printer* printer) const { |
|
|
|
ABSL_CHECK(!should_split()); |
|
|
|
ABSL_CHECK(!should_split()); |
|
|
|
Formatter format(printer, variables_); |
|
|
|
Formatter format(printer, variables_); |
|
|
|
if (!descriptor_->default_value_string().empty()) { |
|
|
|
if (!field_->default_value_string().empty()) { |
|
|
|
format("$field$ = ::absl::string_view($default$, $default_length$);\n"); |
|
|
|
format("$field$ = ::absl::string_view($default$, $default_length$);\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -259,9 +259,9 @@ void CordFieldGenerator::GenerateArenaDestructorCode( |
|
|
|
void CordFieldGenerator::GenerateSerializeWithCachedSizesToArray( |
|
|
|
void CordFieldGenerator::GenerateSerializeWithCachedSizesToArray( |
|
|
|
io::Printer* printer) const { |
|
|
|
io::Printer* printer) const { |
|
|
|
Formatter format(printer, variables_); |
|
|
|
Formatter format(printer, variables_); |
|
|
|
if (descriptor_->type() == FieldDescriptor::TYPE_STRING) { |
|
|
|
if (field_->type() == FieldDescriptor::TYPE_STRING) { |
|
|
|
GenerateUtf8CheckCodeForCord( |
|
|
|
GenerateUtf8CheckCodeForCord( |
|
|
|
descriptor_, options_, false, |
|
|
|
field_, options_, false, |
|
|
|
absl::Substitute("this->_internal_$0(), ", printer->LookupVar("name")), |
|
|
|
absl::Substitute("this->_internal_$0(), ", printer->LookupVar("name")), |
|
|
|
format); |
|
|
|
format); |
|
|
|
} |
|
|
|
} |
|
|
@ -281,7 +281,7 @@ void CordFieldGenerator::GenerateByteSize(io::Printer* printer) const { |
|
|
|
|
|
|
|
|
|
|
|
void CordFieldGenerator::GenerateConstexprAggregateInitializer( |
|
|
|
void CordFieldGenerator::GenerateConstexprAggregateInitializer( |
|
|
|
io::Printer* p) const { |
|
|
|
io::Printer* p) const { |
|
|
|
if (descriptor_->default_value_string().empty()) { |
|
|
|
if (field_->default_value_string().empty()) { |
|
|
|
p->Emit(R"cc( |
|
|
|
p->Emit(R"cc( |
|
|
|
/*decltype($field$)*/ {}, |
|
|
|
/*decltype($field$)*/ {}, |
|
|
|
)cc"); |
|
|
|
)cc"); |
|
|
@ -323,7 +323,7 @@ void CordOneofFieldGenerator::GeneratePrivateMembers( |
|
|
|
void CordOneofFieldGenerator::GenerateStaticMembers( |
|
|
|
void CordOneofFieldGenerator::GenerateStaticMembers( |
|
|
|
io::Printer* printer) const { |
|
|
|
io::Printer* printer) const { |
|
|
|
Formatter format(printer, variables_); |
|
|
|
Formatter format(printer, variables_); |
|
|
|
if (!descriptor_->default_value_string().empty()) { |
|
|
|
if (!field_->default_value_string().empty()) { |
|
|
|
format( |
|
|
|
format( |
|
|
|
"struct _default_$name$_func_ {\n" |
|
|
|
"struct _default_$name$_func_ {\n" |
|
|
|
" constexpr absl::string_view operator()() const {\n" |
|
|
|
" constexpr absl::string_view operator()() const {\n" |
|
|
@ -407,7 +407,7 @@ void CordOneofFieldGenerator::GenerateInlineAccessorDefinitions( |
|
|
|
void CordOneofFieldGenerator::GenerateNonInlineAccessorDefinitions( |
|
|
|
void CordOneofFieldGenerator::GenerateNonInlineAccessorDefinitions( |
|
|
|
io::Printer* printer) const { |
|
|
|
io::Printer* printer) const { |
|
|
|
Formatter format(printer, variables_); |
|
|
|
Formatter format(printer, variables_); |
|
|
|
if (!descriptor_->default_value_string().empty()) { |
|
|
|
if (!field_->default_value_string().empty()) { |
|
|
|
format( |
|
|
|
format( |
|
|
|
"PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT " |
|
|
|
"PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT " |
|
|
|
"const ::absl::Cord $classname$::$default_variable_field$(\n" |
|
|
|
"const ::absl::Cord $classname$::$default_variable_field$(\n" |
|
|
|