| Index: third_party/protobuf/src/google/protobuf/metadata.h
|
| diff --git a/third_party/protobuf/src/google/protobuf/metadata.h b/third_party/protobuf/src/google/protobuf/metadata.h
|
| index f9257534eecf4f5589dceb39b308f3779f64ef57..fdee150b44f5c7d92ba1ccf0fc062c4887e65b8c 100644
|
| --- a/third_party/protobuf/src/google/protobuf/metadata.h
|
| +++ b/third_party/protobuf/src/google/protobuf/metadata.h
|
| @@ -40,8 +40,6 @@
|
|
|
| #include <google/protobuf/stubs/common.h>
|
| #include <google/protobuf/arena.h>
|
| -#include <google/protobuf/arenastring.h>
|
| -#include <google/protobuf/generated_message_util.h>
|
| #include <google/protobuf/unknown_field_set.h>
|
|
|
| namespace google {
|
| @@ -58,30 +56,30 @@ namespace internal {
|
| // The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to
|
| // indicate an arena pointer and bit 0 == 1 to indicate a UFS+Arena-container
|
| // pointer.
|
| -template <class T, class Derived>
|
| -class InternalMetadataWithArenaBase {
|
| +class LIBPROTOBUF_EXPORT InternalMetadataWithArena {
|
| public:
|
| - InternalMetadataWithArenaBase() : ptr_(NULL) {}
|
| - explicit InternalMetadataWithArenaBase(Arena* arena) : ptr_(arena) {}
|
| + InternalMetadataWithArena() : ptr_(NULL) {}
|
| + explicit InternalMetadataWithArena(Arena* arena)
|
| + : ptr_ (arena) {}
|
|
|
| - ~InternalMetadataWithArenaBase() {
|
| + ~InternalMetadataWithArena() {
|
| if (have_unknown_fields() && arena() == NULL) {
|
| delete PtrValue<Container>();
|
| }
|
| ptr_ = NULL;
|
| }
|
|
|
| - GOOGLE_ATTRIBUTE_ALWAYS_INLINE const T& unknown_fields() const {
|
| + GOOGLE_ATTRIBUTE_ALWAYS_INLINE const UnknownFieldSet& unknown_fields() const {
|
| if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {
|
| - return PtrValue<Container>()->unknown_fields;
|
| + return PtrValue<Container>()->unknown_fields_;
|
| } else {
|
| - return Derived::default_instance();
|
| + return *UnknownFieldSet::default_instance();
|
| }
|
| }
|
|
|
| - GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* mutable_unknown_fields() {
|
| + GOOGLE_ATTRIBUTE_ALWAYS_INLINE UnknownFieldSet* mutable_unknown_fields() {
|
| if (GOOGLE_PREDICT_TRUE(have_unknown_fields())) {
|
| - return &PtrValue<Container>()->unknown_fields;
|
| + return &PtrValue<Container>()->unknown_fields_;
|
| } else {
|
| return mutable_unknown_fields_slow();
|
| }
|
| @@ -89,7 +87,7 @@ class InternalMetadataWithArenaBase {
|
|
|
| GOOGLE_ATTRIBUTE_ALWAYS_INLINE Arena* arena() const {
|
| if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {
|
| - return PtrValue<Container>()->arena;
|
| + return PtrValue<Container>()->arena_;
|
| } else {
|
| return PtrValue<Arena>();
|
| }
|
| @@ -99,7 +97,7 @@ class InternalMetadataWithArenaBase {
|
| return PtrTag() == kTagContainer;
|
| }
|
|
|
| - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(Derived* other) {
|
| + GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(InternalMetadataWithArena* other) {
|
| // Semantics here are that we swap only the unknown fields, not the arena
|
| // pointer. We cannot simply swap ptr_ with other->ptr_ because we need to
|
| // maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in
|
| @@ -107,19 +105,7 @@ class InternalMetadataWithArenaBase {
|
| // cannot simply swap ptr_ and then restore the arena pointers. We reuse
|
| // UFS's swap implementation instead.
|
| if (have_unknown_fields() || other->have_unknown_fields()) {
|
| - static_cast<Derived*>(this)->DoSwap(other->mutable_unknown_fields());
|
| - }
|
| - }
|
| -
|
| - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void MergeFrom(const Derived& other) {
|
| - if (other.have_unknown_fields()) {
|
| - static_cast<Derived*>(this)->DoMergeFrom(other.unknown_fields());
|
| - }
|
| - }
|
| -
|
| - GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Clear() {
|
| - if (have_unknown_fields()) {
|
| - static_cast<Derived*>(this)->DoClear();
|
| + mutable_unknown_fields()->Swap(other->mutable_unknown_fields());
|
| }
|
| }
|
|
|
| @@ -145,80 +131,30 @@ class InternalMetadataWithArenaBase {
|
| return reinterpret_cast<intptr_t>(ptr_) & kPtrTagMask;
|
| }
|
|
|
| - template<typename U> U* PtrValue() const {
|
| - return reinterpret_cast<U*>(
|
| + template<typename T> T* PtrValue() const {
|
| + return reinterpret_cast<T*>(
|
| reinterpret_cast<intptr_t>(ptr_) & kPtrValueMask);
|
| }
|
|
|
| // If ptr_'s tag is kTagContainer, it points to an instance of this struct.
|
| struct Container {
|
| - T unknown_fields;
|
| - Arena* arena;
|
| + UnknownFieldSet unknown_fields_;
|
| + Arena* arena_;
|
| };
|
|
|
| - GOOGLE_ATTRIBUTE_NOINLINE T* mutable_unknown_fields_slow() {
|
| + GOOGLE_ATTRIBUTE_NOINLINE UnknownFieldSet* mutable_unknown_fields_slow() {
|
| Arena* my_arena = arena();
|
| Container* container = Arena::Create<Container>(my_arena);
|
| ptr_ = reinterpret_cast<void*>(
|
| reinterpret_cast<intptr_t>(container) | kTagContainer);
|
| - container->arena = my_arena;
|
| - return &(container->unknown_fields);
|
| - }
|
| -};
|
| -
|
| -class InternalMetadataWithArena
|
| - : public InternalMetadataWithArenaBase<UnknownFieldSet,
|
| - InternalMetadataWithArena> {
|
| - public:
|
| - InternalMetadataWithArena() {}
|
| - explicit InternalMetadataWithArena(Arena* arena)
|
| - : InternalMetadataWithArenaBase(arena) {}
|
| -
|
| - void DoSwap(UnknownFieldSet* other) {
|
| - mutable_unknown_fields()->Swap(other);
|
| - }
|
| -
|
| - void DoMergeFrom(const UnknownFieldSet& other) {
|
| - mutable_unknown_fields()->MergeFrom(other);
|
| - }
|
| -
|
| - void DoClear() {
|
| - mutable_unknown_fields()->Clear();
|
| - }
|
| -
|
| - static const UnknownFieldSet& default_instance() {
|
| - return *UnknownFieldSet::default_instance();
|
| + container->arena_ = my_arena;
|
| + return &(container->unknown_fields_);
|
| }
|
| };
|
|
|
| -// We store unknown fields as a string right now, because there is currently no
|
| -// good interface for reading unknown fields into an ArenaString. We may want
|
| -// to revisit this to allow unknown fields to be parsed onto the Arena.
|
| -class InternalMetadataWithArenaLite
|
| - : public InternalMetadataWithArenaBase<string,
|
| - InternalMetadataWithArenaLite> {
|
| - public:
|
| - InternalMetadataWithArenaLite() {}
|
| -
|
| - explicit InternalMetadataWithArenaLite(Arena* arena)
|
| - : InternalMetadataWithArenaBase(arena) {}
|
| -
|
| - void DoSwap(string* other) {
|
| - mutable_unknown_fields()->swap(*other);
|
| - }
|
| -
|
| - void DoMergeFrom(const string& other) {
|
| - mutable_unknown_fields()->append(other);
|
| - }
|
| -
|
| - void DoClear() {
|
| - mutable_unknown_fields()->clear();
|
| - }
|
| -
|
| - static const string& default_instance() {
|
| - return GetEmptyStringAlreadyInited();
|
| - }
|
| -};
|
| +// Temporary compatibility typedef. Remove once this is released in components
|
| +// and upb CL is submitted.
|
| +typedef InternalMetadataWithArena InternalMetadata;
|
|
|
| } // namespace internal
|
| } // namespace protobuf
|
|
|