Clean up left over from the string->string_view API migration.

This change has no effect on APIs. The new behavior was already on everywhere.

PiperOrigin-RevId: 723932806
pull/20244/head
Protobuf Team Bot 3 weeks ago committed by Copybara-Service
parent 9f10aebebc
commit 19eb912a83
  1. 3
      src/google/protobuf/descriptor.cc
  2. 87
      src/google/protobuf/descriptor.h
  3. 4
      src/google/protobuf/message_lite.cc
  4. 8
      src/google/protobuf/message_lite.h
  5. 1
      src/google/protobuf/port_def.inc
  6. 3
      src/google/protobuf/port_undef.inc
  7. 23
      src/google/protobuf/unknown_field_set.h

@ -9711,8 +9711,7 @@ const EnumValueDescriptor* FieldDescriptor::default_value_enum() const {
return default_value_enum_;
}
internal::DescriptorStringView FieldDescriptor::PrintableNameForExtension()
const {
absl::string_view FieldDescriptor::PrintableNameForExtension() const {
const bool is_message_set_extension =
is_extension() &&
containing_type()->options().message_set_wire_format() &&

@ -196,13 +196,6 @@ namespace internal {
#define PROTOBUF_INTERNAL_CHECK_CLASS_SIZE(t, expected)
#endif
// `typedef` instead of `using` for SWIG
#if defined(PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE)
typedef absl::string_view DescriptorStringView;
#else
typedef const std::string& DescriptorStringView;
#endif
class FlatAllocator;
class PROTOBUF_EXPORT LazyDescriptor {
@ -320,14 +313,14 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
#endif
// The name of the message type, not including its scope.
internal::DescriptorStringView name() const;
absl::string_view name() const;
// The fully-qualified name of the message type, scope delimited by
// periods. For example, message type "Foo" which is declared in package
// "bar" has full name "bar.Foo". If a type "Baz" is nested within
// Foo, Baz's full_name is "bar.Foo.Baz". To get only the part that
// comes after the last '.', use name().
internal::DescriptorStringView full_name() const;
absl::string_view full_name() const;
// Index of this descriptor within the file or containing type's message
// type array.
@ -507,12 +500,10 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
const ExtensionRangeOptions& options() const { return *options_; }
// Returns the name of the containing type.
internal::DescriptorStringView name() const {
return containing_type_->name();
}
absl::string_view name() const { return containing_type_->name(); }
// Returns the full name of the containing type.
internal::DescriptorStringView full_name() const {
absl::string_view full_name() const {
return containing_type_->full_name();
}
@ -631,7 +622,7 @@ class PROTOBUF_EXPORT Descriptor : private internal::SymbolBase {
int reserved_name_count() const;
// Gets a reserved name by index, where 0 <= index < reserved_name_count().
internal::DescriptorStringView reserved_name(int index) const;
absl::string_view reserved_name(int index) const;
// Returns true if the field name is reserved.
bool IsReservedName(absl::string_view name) const;
@ -844,11 +835,11 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase,
static const int kLastReservedNumber = 19999;
// Name of this field within the message.
internal::DescriptorStringView name() const;
absl::string_view name() const;
// Fully-qualified name of the field.
internal::DescriptorStringView full_name() const;
absl::string_view full_name() const;
// JSON name of this field.
internal::DescriptorStringView json_name() const;
absl::string_view json_name() const;
const FileDescriptor* file() const; // File in which this field was defined.
bool is_extension() const; // Is this an extension field?
@ -860,7 +851,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase,
// field names should be lowercased anyway according to the protobuf style
// guide, so this only makes a difference when dealing with old .proto files
// which do not follow the guide.)
internal::DescriptorStringView lowercase_name() const;
absl::string_view lowercase_name() const;
// Same as name() except converted to camel-case. In this conversion, any
// time an underscore appears in the name, it is removed and the next
@ -871,7 +862,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase,
// fooBar -> fooBar
// This (and especially the FindFieldByCamelcaseName() method) can be useful
// when parsing formats which prefer to use camel-case naming style.
internal::DescriptorStringView camelcase_name() const;
absl::string_view camelcase_name() const;
Type type() const; // Declared type of this field.
// Name of the declared type.
@ -973,7 +964,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase,
const EnumValueDescriptor* default_value_enum() const;
// Get the field default value if cpp_type() == CPPTYPE_STRING. If no
// explicit default was defined, the default is the empty string.
internal::DescriptorStringView default_value_string() const;
absl::string_view default_value_string() const;
// The Descriptor for the message of which this is a field. For extensions,
// this is the extended type. Never nullptr.
@ -1051,7 +1042,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase,
// its printable name) can be accomplished with
// message->file()->pool()->FindExtensionByPrintableName(message, name)
// where the extension extends "message".
internal::DescriptorStringView PrintableNameForExtension() const;
absl::string_view PrintableNameForExtension() const;
// Source Location ---------------------------------------------------
@ -1217,9 +1208,9 @@ class PROTOBUF_EXPORT OneofDescriptor : private internal::SymbolBase {
#endif
// Name of this oneof.
internal::DescriptorStringView name() const;
absl::string_view name() const;
// Fully-qualified name of the oneof.
internal::DescriptorStringView full_name() const;
absl::string_view full_name() const;
// Index of this oneof within the message's oneof array.
int index() const;
@ -1324,10 +1315,10 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase {
#endif
// The name of this enum type in the containing scope.
internal::DescriptorStringView name() const;
absl::string_view name() const;
// The fully-qualified name of the enum type, scope delimited by periods.
internal::DescriptorStringView full_name() const;
absl::string_view full_name() const;
// Index of this enum within the file or containing message's enum array.
int index() const;
@ -1424,7 +1415,7 @@ class PROTOBUF_EXPORT EnumDescriptor : private internal::SymbolBase {
int reserved_name_count() const;
// Gets a reserved name by index, where 0 <= index < reserved_name_count().
internal::DescriptorStringView reserved_name(int index) const;
absl::string_view reserved_name(int index) const;
// Returns true if the field name is reserved.
bool IsReservedName(absl::string_view name) const;
@ -1537,7 +1528,7 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>,
EnumValueDescriptor& operator=(const EnumValueDescriptor&) = delete;
#endif
internal::DescriptorStringView name() const; // Name of this enum constant.
absl::string_view name() const; // Name of this enum constant.
int index() const; // Index within the enums's Descriptor.
int number() const; // Numeric value of this enum constant.
@ -1546,7 +1537,7 @@ class PROTOBUF_EXPORT EnumValueDescriptor : private internal::SymbolBaseN<0>,
// "google.protobuf.FieldDescriptorProto.TYPE_INT32", NOT
// "google.protobuf.FieldDescriptorProto.Type.TYPE_INT32". This is to conform
// with C++ scoping rules for enums.
internal::DescriptorStringView full_name() const;
absl::string_view full_name() const;
// The .proto file in which this value was defined. Never nullptr.
const FileDescriptor* file() const;
@ -1640,9 +1631,9 @@ class PROTOBUF_EXPORT ServiceDescriptor : private internal::SymbolBase {
#endif
// The name of the service, not including its containing scope.
internal::DescriptorStringView name() const;
absl::string_view name() const;
// The fully-qualified name of the service, scope delimited by periods.
internal::DescriptorStringView full_name() const;
absl::string_view full_name() const;
// Index of this service within the file's services array.
int index() const;
@ -1744,9 +1735,9 @@ class PROTOBUF_EXPORT MethodDescriptor : private internal::SymbolBase {
#endif
// Name of this method, not including containing scope.
internal::DescriptorStringView name() const;
absl::string_view name() const;
// The fully-qualified name of the method, scope delimited by periods.
internal::DescriptorStringView full_name() const;
absl::string_view full_name() const;
// Index within the service's Descriptor.
int index() const;
@ -1852,10 +1843,10 @@ class PROTOBUF_EXPORT FileDescriptor : private internal::SymbolBase {
// The filename, relative to the source tree.
// e.g. "foo/bar/baz.proto"
internal::DescriptorStringView name() const;
absl::string_view name() const;
// The package, e.g. "google.protobuf.compiler".
internal::DescriptorStringView package() const;
absl::string_view package() const;
// The DescriptorPool in which this FileDescriptor and all its contents were
// allocated. Never nullptr.
@ -2613,19 +2604,13 @@ class PROTOBUF_EXPORT DescriptorPool {
inline TYPE CLASS::FIELD() const { return FIELD##_; }
// Strings fields are stored as pointers but returned as const references.
#define PROTOBUF_DEFINE_STRING_ACCESSOR(CLASS, FIELD) \
inline internal::DescriptorStringView CLASS::FIELD() const { \
return *FIELD##_; \
}
#define PROTOBUF_DEFINE_STRING_ACCESSOR(CLASS, FIELD) \
inline absl::string_view CLASS::FIELD() const { return *FIELD##_; }
// Name and full name are stored in a single array to save space.
#define PROTOBUF_DEFINE_NAME_ACCESSOR(CLASS) \
inline internal::DescriptorStringView CLASS::name() const { \
return all_names_[0]; \
} \
inline internal::DescriptorStringView CLASS::full_name() const { \
return all_names_[1]; \
}
#define PROTOBUF_DEFINE_NAME_ACCESSOR(CLASS) \
inline absl::string_view CLASS::name() const { return all_names_[0]; } \
inline absl::string_view CLASS::full_name() const { return all_names_[1]; }
// Arrays take an index parameter, obviously.
#define PROTOBUF_DEFINE_ARRAY_ACCESSOR(CLASS, FIELD, TYPE) \
@ -2774,8 +2759,7 @@ inline bool Descriptor::IsReservedName(absl::string_view name) const {
// Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because reserved_names_ is actually
// an array of pointers rather than the usual array of objects.
inline internal::DescriptorStringView Descriptor::reserved_name(
int index) const {
inline absl::string_view Descriptor::reserved_name(int index) const {
return *reserved_names_[index];
}
@ -2794,20 +2778,19 @@ inline bool EnumDescriptor::IsReservedName(absl::string_view name) const {
// Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because reserved_names_ is actually
// an array of pointers rather than the usual array of objects.
inline internal::DescriptorStringView EnumDescriptor::reserved_name(
int index) const {
inline absl::string_view EnumDescriptor::reserved_name(int index) const {
return *reserved_names_[index];
}
inline internal::DescriptorStringView FieldDescriptor::lowercase_name() const {
inline absl::string_view FieldDescriptor::lowercase_name() const {
return all_names_[lowercase_name_index_];
}
inline internal::DescriptorStringView FieldDescriptor::camelcase_name() const {
inline absl::string_view FieldDescriptor::camelcase_name() const {
return all_names_[camelcase_name_index_];
}
inline internal::DescriptorStringView FieldDescriptor::json_name() const {
inline absl::string_view FieldDescriptor::json_name() const {
return all_names_[json_name_index_];
}

@ -103,8 +103,8 @@ const char* MessageLite::_InternalParse(const char* ptr,
return internal::TcParser::ParseLoop(this, ptr, ctx, GetTcParseTable());
}
internal::GetTypeNameReturnType MessageLite::GetTypeName() const {
return internal::GetTypeNameReturnType(TypeId::Get(*this).name());
absl::string_view MessageLite::GetTypeName() const {
return TypeId::Get(*this).name();
}
absl::string_view TypeId::name() const {

@ -330,12 +330,6 @@ inline int ToIntSize(size_t size) {
return static_cast<int>(size);
}
#if defined(PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE)
using GetTypeNameReturnType = absl::string_view;
#else
using GetTypeNameReturnType = std::string;
#endif
PROTOBUF_EXPORT inline const std::string& GetEmptyStringAlreadyInited() {
return fixed_address_empty_string.get();
@ -539,7 +533,7 @@ class PROTOBUF_EXPORT MessageLite {
// Basic Operations ------------------------------------------------
// Get the name of this message type, e.g. "foo.bar.BazProto".
internal::GetTypeNameReturnType GetTypeName() const;
absl::string_view GetTypeName() const;
// Construct a new instance of the same type. Ownership is passed to the
// caller.

@ -150,7 +150,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
#endif
#define PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE 1
#ifdef PROTOBUF_ALWAYS_INLINE
#error PROTOBUF_ALWAYS_INLINE was previously defined
#endif

@ -73,9 +73,6 @@
#undef PROTOBUF_FUTURE_REMOVE_CREATEMESSAGE
#endif
#undef PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE
#undef PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE_TYPENAME
// Restore macros that may have been #undef'd in port_def.inc.
#ifdef PROTOBUF_DID_UNDEF_noreturn

@ -53,11 +53,6 @@ class MessageSetFieldSkipperUsingCord;
class UnknownFieldParserHelper;
struct UnknownFieldSetTestPeer;
#if defined(PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE)
using UFSStringView = absl::string_view;
#else
using UFSStringView = const std::string&;
#endif
} // namespace internal
class Message; // message.h
@ -85,7 +80,7 @@ class PROTOBUF_EXPORT UnknownField {
inline uint64_t varint() const;
inline uint32_t fixed32() const;
inline uint64_t fixed64() const;
inline internal::UFSStringView length_delimited() const;
inline absl::string_view length_delimited() const;
inline const UnknownFieldSet& group() const;
inline void set_varint(uint64_t value);
@ -96,9 +91,6 @@ class PROTOBUF_EXPORT UnknownField {
template <int&...>
inline void set_length_delimited(std::string&& value);
inline void set_length_delimited(const absl::Cord& value);
#if !defined(PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE)
inline std::string* mutable_length_delimited();
#endif // PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE
inline UnknownFieldSet* mutable_group();
inline size_t GetLengthDelimitedSize() const;
@ -207,9 +199,6 @@ class PROTOBUF_EXPORT UnknownFieldSet {
void AddLengthDelimited(int number, std::string&& value);
void AddLengthDelimited(int number, const absl::Cord& value);
#if !defined(PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE)
std::string* AddLengthDelimited(int number);
#endif // PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE
UnknownFieldSet* AddGroup(int number);
// Adds an unknown field from another set.
@ -255,9 +244,7 @@ class PROTOBUF_EXPORT UnknownFieldSet {
friend internal::UnknownFieldParserHelper;
friend internal::UnknownFieldSetTestPeer;
#if defined(PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE)
std::string* AddLengthDelimited(int number);
#endif // PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE
using InternalArenaConstructable_ = void;
using DestructorSkippable_ = void;
@ -377,7 +364,7 @@ inline uint64_t UnknownField::fixed64() const {
assert(type() == TYPE_FIXED64);
return data_.fixed64;
}
inline internal::UFSStringView UnknownField::length_delimited() const {
inline absl::string_view UnknownField::length_delimited() const {
assert(type() == TYPE_LENGTH_DELIMITED);
return *data_.string_value;
}
@ -411,12 +398,6 @@ inline void UnknownField::set_length_delimited(const absl::Cord& value) {
assert(type() == TYPE_LENGTH_DELIMITED);
absl::CopyCordToString(value, data_.string_value);
}
#if !defined(PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE)
inline std::string* UnknownField::mutable_length_delimited() {
assert(type() == TYPE_LENGTH_DELIMITED);
return data_.string_value;
}
#endif // PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE
inline UnknownFieldSet* UnknownField::mutable_group() {
assert(type() == TYPE_GROUP);
return data_.group;

Loading…
Cancel
Save