| OLD | NEW |
| (Empty) | |
| 1 From 6be517aa1ada68d9245c90f82902600ca99bb72f Mon Sep 17 00:00:00 2001 |
| 2 From: Adam Michalik <xyzzyz@google.com> |
| 3 Date: Thu, 19 May 2016 15:00:25 -0700 |
| 4 Subject: [PATCH] Revert "Patch internal change 111557819." |
| 5 |
| 6 This reverts commit 76195058e25d19fc918996d55d3ad69ee55cb77e. |
| 7 --- |
| 8 src/google/protobuf/compiler/cpp/cpp_message.cc | 30 ++------ |
| 9 src/google/protobuf/io/coded_stream.cc | 18 ----- |
| 10 src/google/protobuf/io/coded_stream.h | 1 - |
| 11 .../protobuf/io/zero_copy_stream_impl_lite.cc | 31 -------- |
| 12 .../protobuf/io/zero_copy_stream_impl_lite.h | 24 ------- |
| 13 src/google/protobuf/stubs/callback.h | 83 ---------------------- |
| 14 6 files changed, 5 insertions(+), 182 deletions(-) |
| 15 |
| 16 diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protob
uf/compiler/cpp/cpp_message.cc |
| 17 index da2a4c9..0cefd4e 100644 |
| 18 --- a/src/google/protobuf/compiler/cpp/cpp_message.cc |
| 19 +++ b/src/google/protobuf/compiler/cpp/cpp_message.cc |
| 20 @@ -1775,18 +1775,6 @@ GenerateShutdownCode(io::Printer* printer) { |
| 21 |
| 22 void MessageGenerator:: |
| 23 GenerateClassMethods(io::Printer* printer) { |
| 24 - // mutable_unknown_fields wrapper function for LazyStringOutputStream |
| 25 - // callback. |
| 26 - if (PreserveUnknownFields(descriptor_) && |
| 27 - !UseUnknownFieldSet(descriptor_->file(), options_)) { |
| 28 - printer->Print( |
| 29 - "static ::std::string* MutableUnknownFieldsFor$classname$(\n" |
| 30 - " $classname$* ptr) {\n" |
| 31 - " return ptr->mutable_unknown_fields();\n" |
| 32 - "}\n" |
| 33 - "\n", |
| 34 - "classname", classname_); |
| 35 - } |
| 36 if (IsAnyMessage(descriptor_)) { |
| 37 printer->Print( |
| 38 "void $classname$::PackFrom(const ::google::protobuf::Message& message) {
\n" |
| 39 @@ -2849,9 +2837,7 @@ GenerateMergeFrom(io::Printer* printer) { |
| 40 "}\n"); |
| 41 } else { |
| 42 printer->Print( |
| 43 - "if (!from.unknown_fields().empty()) {\n" |
| 44 - " mutable_unknown_fields()->append(from.unknown_fields());\n" |
| 45 - "}\n"); |
| 46 + "mutable_unknown_fields()->append(from.unknown_fields());\n"); |
| 47 } |
| 48 } |
| 49 |
| 50 @@ -2929,18 +2915,12 @@ GenerateMergeFromCodedStream(io::Printer* printer) { |
| 51 " ::google::protobuf::uint32 tag;\n", |
| 52 "classname", classname_); |
| 53 |
| 54 - if (PreserveUnknownFields(descriptor_) && |
| 55 - !UseUnknownFieldSet(descriptor_->file(), options_)) { |
| 56 - // Use LazyStringOutputString to avoid initializing unknown fields string |
| 57 - // unless it is actually needed. For the same reason, disable eager refresh |
| 58 - // on the CodedOutputStream. |
| 59 + if (!UseUnknownFieldSet(descriptor_->file())) { |
| 60 printer->Print( |
| 61 - " ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(\
n" |
| 62 - " ::google::protobuf::internal::NewPermanentCallback(\n" |
| 63 - " &MutableUnknownFieldsFor$classname$, this));\n" |
| 64 + " ::google::protobuf::io::StringOutputStream unknown_fields_string(\n" |
| 65 + " mutable_unknown_fields());\n" |
| 66 " ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\n" |
| 67 - " &unknown_fields_string, false);\n", |
| 68 - "classname", classname_); |
| 69 + " &unknown_fields_string);\n"); |
| 70 } |
| 71 |
| 72 printer->Print( |
| 73 diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/cod
ed_stream.cc |
| 74 index d8354c1..7df2fed 100644 |
| 75 --- a/src/google/protobuf/io/coded_stream.cc |
| 76 +++ b/src/google/protobuf/io/coded_stream.cc |
| 77 @@ -629,24 +629,6 @@ CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream*
output) |
| 78 had_error_ = false; |
| 79 } |
| 80 |
| 81 -CodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* output, |
| 82 - bool do_eager_refresh) |
| 83 - : output_(output), |
| 84 - buffer_(NULL), |
| 85 - buffer_size_(0), |
| 86 - total_bytes_(0), |
| 87 - had_error_(false), |
| 88 - aliasing_enabled_(false) { |
| 89 - if (do_eager_refresh) { |
| 90 - // Eagerly Refresh() so buffer space is immediately available. |
| 91 - Refresh(); |
| 92 - // The Refresh() may have failed. If the client doesn't write any data, |
| 93 - // though, don't consider this an error. If the client does write data, the
n |
| 94 - // another Refresh() will be attempted and it will set the error once again
. |
| 95 - had_error_ = false; |
| 96 - } |
| 97 -} |
| 98 - |
| 99 CodedOutputStream::~CodedOutputStream() { |
| 100 Trim(); |
| 101 } |
| 102 diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/code
d_stream.h |
| 103 index c81a33a..f211c69 100644 |
| 104 --- a/src/google/protobuf/io/coded_stream.h |
| 105 +++ b/src/google/protobuf/io/coded_stream.h |
| 106 @@ -666,7 +666,6 @@ class LIBPROTOBUF_EXPORT CodedOutputStream { |
| 107 public: |
| 108 // Create an CodedOutputStream that writes to the given ZeroCopyOutputStream. |
| 109 explicit CodedOutputStream(ZeroCopyOutputStream* output); |
| 110 - CodedOutputStream(ZeroCopyOutputStream* output, bool do_eager_refresh); |
| 111 |
| 112 // Destroy the CodedOutputStream and position the underlying |
| 113 // ZeroCopyOutputStream immediately after the last byte written. |
| 114 diff --git a/src/google/protobuf/io/zero_copy_stream_impl_lite.cc b/src/google/p
rotobuf/io/zero_copy_stream_impl_lite.cc |
| 115 index e6ca88c..b6b85f4 100644 |
| 116 --- a/src/google/protobuf/io/zero_copy_stream_impl_lite.cc |
| 117 +++ b/src/google/protobuf/io/zero_copy_stream_impl_lite.cc |
| 118 @@ -157,7 +157,6 @@ StringOutputStream::~StringOutputStream() { |
| 119 } |
| 120 |
| 121 bool StringOutputStream::Next(void** data, int* size) { |
| 122 - GOOGLE_CHECK(target_ != NULL); |
| 123 int old_size = target_->size(); |
| 124 |
| 125 // Grow the string. |
| 126 @@ -189,44 +188,14 @@ bool StringOutputStream::Next(void** data, int* size) { |
| 127 |
| 128 void StringOutputStream::BackUp(int count) { |
| 129 GOOGLE_CHECK_GE(count, 0); |
| 130 - GOOGLE_CHECK(target_ != NULL); |
| 131 GOOGLE_CHECK_LE(count, target_->size()); |
| 132 target_->resize(target_->size() - count); |
| 133 } |
| 134 |
| 135 int64 StringOutputStream::ByteCount() const { |
| 136 - GOOGLE_CHECK(target_ != NULL); |
| 137 return target_->size(); |
| 138 } |
| 139 |
| 140 -void StringOutputStream::SetString(string* target) { |
| 141 - target_ = target; |
| 142 -} |
| 143 - |
| 144 -// =================================================================== |
| 145 - |
| 146 -LazyStringOutputStream::LazyStringOutputStream( |
| 147 - ResultCallback<string*>* callback) |
| 148 - : StringOutputStream(NULL), |
| 149 - callback_(GOOGLE_CHECK_NOTNULL(callback)), |
| 150 - string_is_set_(false) { |
| 151 -} |
| 152 - |
| 153 -LazyStringOutputStream::~LazyStringOutputStream() { |
| 154 -} |
| 155 - |
| 156 -bool LazyStringOutputStream::Next(void** data, int* size) { |
| 157 - if (!string_is_set_) { |
| 158 - SetString(callback_->Run()); |
| 159 - string_is_set_ = true; |
| 160 - } |
| 161 - return StringOutputStream::Next(data, size); |
| 162 -} |
| 163 - |
| 164 -int64 LazyStringOutputStream::ByteCount() const { |
| 165 - return string_is_set_ ? StringOutputStream::ByteCount() : 0; |
| 166 -} |
| 167 - |
| 168 // =================================================================== |
| 169 |
| 170 CopyingInputStream::~CopyingInputStream() {} |
| 171 diff --git a/src/google/protobuf/io/zero_copy_stream_impl_lite.h b/src/google/pr
otobuf/io/zero_copy_stream_impl_lite.h |
| 172 index 9d81ccf..650f4fc 100644 |
| 173 --- a/src/google/protobuf/io/zero_copy_stream_impl_lite.h |
| 174 +++ b/src/google/protobuf/io/zero_copy_stream_impl_lite.h |
| 175 @@ -149,9 +149,6 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCop
yOutputStream { |
| 176 void BackUp(int count); |
| 177 int64 ByteCount() const; |
| 178 |
| 179 - protected: |
| 180 - void SetString(string* target); |
| 181 - |
| 182 private: |
| 183 static const int kMinimumSize = 16; |
| 184 |
| 185 @@ -160,27 +157,6 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCo
pyOutputStream { |
| 186 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream); |
| 187 }; |
| 188 |
| 189 -// LazyStringOutputStream is a StringOutputStream with lazy acquisition of |
| 190 -// the output string from a callback. The string is owned externally, and not |
| 191 -// deleted in the stream destructor. |
| 192 -class LIBPROTOBUF_EXPORT LazyStringOutputStream : public StringOutputStream { |
| 193 - public: |
| 194 - // Callback should be permanent (non-self-deleting). Ownership is transferred |
| 195 - // to the LazyStringOutputStream. |
| 196 - explicit LazyStringOutputStream(ResultCallback<string*>* callback); |
| 197 - ~LazyStringOutputStream(); |
| 198 - |
| 199 - // implements ZeroCopyOutputStream, overriding StringOutputStream ----------- |
| 200 - bool Next(void** data, int* size); |
| 201 - int64 ByteCount() const; |
| 202 - |
| 203 - private: |
| 204 - const google::protobuf::scoped_ptr<ResultCallback<string*> > callback_; |
| 205 - bool string_is_set_; |
| 206 - |
| 207 - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyStringOutputStream); |
| 208 -}; |
| 209 - |
| 210 // Note: There is no StringInputStream. Instead, just create an |
| 211 // ArrayInputStream as follows: |
| 212 // ArrayInputStream input(str.data(), str.size()); |
| 213 diff --git a/src/google/protobuf/stubs/callback.h b/src/google/protobuf/stubs/ca
llback.h |
| 214 index 87271c5..6da530d 100644 |
| 215 --- a/src/google/protobuf/stubs/callback.h |
| 216 +++ b/src/google/protobuf/stubs/callback.h |
| 217 @@ -78,18 +78,6 @@ class LIBPROTOBUF_EXPORT Closure { |
| 218 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Closure); |
| 219 }; |
| 220 |
| 221 -template<typename R> |
| 222 -class ResultCallback { |
| 223 - public: |
| 224 - ResultCallback() {} |
| 225 - virtual ~ResultCallback() {} |
| 226 - |
| 227 - virtual R Run() = 0; |
| 228 - |
| 229 - private: |
| 230 - GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ResultCallback); |
| 231 -}; |
| 232 - |
| 233 template<typename R, typename A1> |
| 234 class LIBPROTOBUF_EXPORT ResultCallback1 { |
| 235 public: |
| 236 @@ -252,50 +240,6 @@ class MethodClosure2 : public Closure { |
| 237 Arg2 arg2_; |
| 238 }; |
| 239 |
| 240 -template<typename R> |
| 241 -class FunctionResultCallback_0_0 : public ResultCallback<R> { |
| 242 - public: |
| 243 - typedef R (*FunctionType)(); |
| 244 - |
| 245 - FunctionResultCallback_0_0(FunctionType function, bool self_deleting) |
| 246 - : function_(function), self_deleting_(self_deleting) {} |
| 247 - ~FunctionResultCallback_0_0() {} |
| 248 - |
| 249 - R Run() { |
| 250 - bool needs_delete = self_deleting_; // read in case callback deletes |
| 251 - R result = function_(); |
| 252 - if (needs_delete) delete this; |
| 253 - return result; |
| 254 - } |
| 255 - |
| 256 - private: |
| 257 - FunctionType function_; |
| 258 - bool self_deleting_; |
| 259 -}; |
| 260 - |
| 261 -template<typename R, typename P1> |
| 262 -class FunctionResultCallback_1_0 : public ResultCallback<R> { |
| 263 - public: |
| 264 - typedef R (*FunctionType)(P1); |
| 265 - |
| 266 - FunctionResultCallback_1_0(FunctionType function, bool self_deleting, |
| 267 - P1 p1) |
| 268 - : function_(function), self_deleting_(self_deleting), p1_(p1) {} |
| 269 - ~FunctionResultCallback_1_0() {} |
| 270 - |
| 271 - R Run() { |
| 272 - bool needs_delete = self_deleting_; // read in case callback deletes |
| 273 - R result = function_(p1_); |
| 274 - if (needs_delete) delete this; |
| 275 - return result; |
| 276 - } |
| 277 - |
| 278 - private: |
| 279 - FunctionType function_; |
| 280 - bool self_deleting_; |
| 281 - P1 p1_; |
| 282 -}; |
| 283 - |
| 284 template<typename R, typename Arg1> |
| 285 class FunctionResultCallback_0_1 : public ResultCallback1<R, Arg1> { |
| 286 public: |
| 287 @@ -464,33 +408,6 @@ inline Closure* NewPermanentCallback( |
| 288 object, method, false, arg1, arg2); |
| 289 } |
| 290 |
| 291 -// See ResultCallback |
| 292 -template<typename R> |
| 293 -inline ResultCallback<R>* NewCallback(R (*function)()) { |
| 294 - return new internal::FunctionResultCallback_0_0<R>(function, true); |
| 295 -} |
| 296 - |
| 297 -// See ResultCallback |
| 298 -template<typename R> |
| 299 -inline ResultCallback<R>* NewPermanentCallback(R (*function)()) { |
| 300 - return new internal::FunctionResultCallback_0_0<R>(function, false); |
| 301 -} |
| 302 - |
| 303 -// See ResultCallback |
| 304 -template<typename R, typename P1> |
| 305 -inline ResultCallback<R>* NewCallback(R (*function)(P1), P1 p1) { |
| 306 - return new internal::FunctionResultCallback_1_0<R, P1>( |
| 307 - function, true, p1); |
| 308 -} |
| 309 - |
| 310 -// See ResultCallback |
| 311 -template<typename R, typename P1> |
| 312 -inline ResultCallback<R>* NewPermanentCallback( |
| 313 - R (*function)(P1), P1 p1) { |
| 314 - return new internal::FunctionResultCallback_1_0<R, P1>( |
| 315 - function, false, p1); |
| 316 -} |
| 317 - |
| 318 // See ResultCallback1 |
| 319 template<typename R, typename A1> |
| 320 inline ResultCallback1<R, A1>* NewCallback(R (*function)(A1)) { |
| 321 -- |
| 322 2.8.0.rc3.226.g39d4020 |
| 323 |
| OLD | NEW |