Index: third_party/protobuf/src/google/protobuf/generated_message_util.h |
diff --git a/third_party/protobuf/src/google/protobuf/generated_message_util.h b/third_party/protobuf/src/google/protobuf/generated_message_util.h |
index 4b03222f922241c9f2717e189aba6088b3451cee..36f18da940b3831808941118c5156a2353d7a0bc 100644 |
--- a/third_party/protobuf/src/google/protobuf/generated_message_util.h |
+++ b/third_party/protobuf/src/google/protobuf/generated_message_util.h |
@@ -41,17 +41,8 @@ |
#include <assert.h> |
#include <string> |
-#include <google/protobuf/stubs/common.h> |
#include <google/protobuf/stubs/once.h> |
-#include <google/protobuf/has_bits.h> |
- |
-#ifndef PROTOBUF_FINAL |
-#if __cplusplus >= 201103L |
-#define PROTOBUF_FINAL final |
-#else |
-#define PROTOBUF_FINAL |
-#endif |
-#endif // !PROTOBUF_FINAL |
+#include <google/protobuf/stubs/common.h> |
namespace google { |
@@ -72,69 +63,30 @@ namespace internal { |
#undef DEPRECATED_PROTOBUF_FIELD |
#define PROTOBUF_DEPRECATED |
-#define GOOGLE_PROTOBUF_DEPRECATED_ATTR |
+#define PROTOBUF_DEPRECATED_ATTR |
// Constants for special floating point values. |
LIBPROTOBUF_EXPORT double Infinity(); |
LIBPROTOBUF_EXPORT double NaN(); |
-// This type is used to define a global variable, without it's constructor |
-// and destructor run on start and end of the program lifetime. This circumvents |
-// the initial construction order fiasco, while keeping the address of the |
-// empty string a compile time constant. |
-template <typename T> |
-class ExplicitlyConstructed { |
- public: |
- void DefaultConstruct() { |
- new (&union_) T(); |
- init_ = true; |
- } |
- |
- bool IsInitialized() { return init_; } |
- void Shutdown() { |
- if (init_) { |
- init_ = false; |
- get_mutable()->~T(); |
- } |
- } |
- |
-#if __cplusplus >= 201103L |
- constexpr |
-#endif |
- const T& |
- get() const { |
- return reinterpret_cast<const T&>(union_); |
- } |
- T* get_mutable() { return reinterpret_cast<T*>(&union_); } |
- |
- private: |
- // Prefer c++14 aligned_storage, but for compatibility this will do. |
- union AlignedUnion { |
- char space[sizeof(T)]; |
- int64 align_to_int64; |
- void* align_to_ptr; |
- } union_; |
- bool init_; // false by linker |
-}; |
- |
// TODO(jieluo): Change to template. We have tried to use template, |
// but it causes net/rpc/python:rpcutil_test fail (the empty string will |
// init twice). It may related to swig. Change to template after we |
// found the solution. |
-// Default empty string object. Don't use this directly. Instead, call |
+// Default empty string object. Don't use the pointer directly. Instead, call |
// GetEmptyString() to get the reference. |
-LIBPROTOBUF_EXPORT extern ExplicitlyConstructed< ::std::string> fixed_address_empty_string; |
+LIBPROTOBUF_EXPORT extern const ::std::string* empty_string_; |
LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_; |
LIBPROTOBUF_EXPORT void InitEmptyString(); |
LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() { |
- return fixed_address_empty_string.get(); |
+ assert(empty_string_ != NULL); |
+ return *empty_string_; |
} |
- |
LIBPROTOBUF_EXPORT const ::std::string& GetEmptyString(); |
LIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str); |
@@ -152,25 +104,14 @@ template <class Type> bool AllAreInitialized(const Type& t) { |
return true; |
} |
-LIBPROTOBUF_EXPORT void InitProtobufDefaults(); |
+class ArenaString; |
-// We compute sizes as size_t but cache them as int. This function converts a |
-// computed size to a cached size. Since we don't proceed with serialization if |
-// the total size was > INT_MAX, it is not important what this function returns |
-// for inputs > INT_MAX. |
-inline int ToCachedSize(size_t size) { |
- return static_cast<int>(size); |
-} |
- |
-// We mainly calculate sizes in terms of size_t, but some functions that compute |
-// sizes return "int". These int sizes are expected to always be positive. |
-// This function is more efficient than casting an int to size_t directly on |
-// 64-bit platforms because it avoids making the compiler emit a sign extending |
-// instruction, which we don't want and don't want to pay for. |
-inline size_t FromIntSize(int size) { |
- // Convert to unsigned before widening so sign extension is not necessary. |
- return static_cast<unsigned int>(size); |
-} |
+// Read a length (varint32), followed by a string, from *input. Return a |
+// pointer to a copy of the string that resides in *arena. Requires both |
+// args to be non-NULL. If something goes wrong while reading the data |
+// then NULL is returned (e.g., input does not start with a valid varint). |
+ArenaString* ReadArenaString(::google::protobuf::io::CodedInputStream* input, |
+ ::google::protobuf::Arena* arena); |
} // namespace internal |
} // namespace protobuf |