Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: third_party/protobuf/src/google/protobuf/wire_format_lite.cc

Issue 2599263002: third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Address comments Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Old version of MSVC doesn't like definitions of inline constants, GCC 54 // Old version of MSVC doesn't like definitions of inline constants, GCC
55 // requires them. 55 // requires them.
56 const int WireFormatLite::kMessageSetItemStartTag; 56 const int WireFormatLite::kMessageSetItemStartTag;
57 const int WireFormatLite::kMessageSetItemEndTag; 57 const int WireFormatLite::kMessageSetItemEndTag;
58 const int WireFormatLite::kMessageSetTypeIdTag; 58 const int WireFormatLite::kMessageSetTypeIdTag;
59 const int WireFormatLite::kMessageSetMessageTag; 59 const int WireFormatLite::kMessageSetMessageTag;
60 60
61 #endif 61 #endif
62 62
63 // IBM xlC requires prefixing constants with WireFormatLite:: 63 // IBM xlC requires prefixing constants with WireFormatLite::
64 const int WireFormatLite::kMessageSetItemTagsSize = 64 const size_t WireFormatLite::kMessageSetItemTagsSize =
65 io::CodedOutputStream::StaticVarintSize32< 65 io::CodedOutputStream::StaticVarintSize32<
66 WireFormatLite::kMessageSetItemStartTag>::value + 66 WireFormatLite::kMessageSetItemStartTag>::value +
67 io::CodedOutputStream::StaticVarintSize32< 67 io::CodedOutputStream::StaticVarintSize32<
68 WireFormatLite::kMessageSetItemEndTag>::value + 68 WireFormatLite::kMessageSetItemEndTag>::value +
69 io::CodedOutputStream::StaticVarintSize32< 69 io::CodedOutputStream::StaticVarintSize32<
70 WireFormatLite::kMessageSetTypeIdTag>::value + 70 WireFormatLite::kMessageSetTypeIdTag>::value +
71 io::CodedOutputStream::StaticVarintSize32< 71 io::CodedOutputStream::StaticVarintSize32<
72 WireFormatLite::kMessageSetMessageTag>::value; 72 WireFormatLite::kMessageSetMessageTag>::value;
73 73
74 const WireFormatLite::CppType 74 const WireFormatLite::CppType
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 value.SerializeWithCachedSizes(output); 459 value.SerializeWithCachedSizes(output);
460 } 460 }
461 461
462 void WireFormatLite::WriteGroupMaybeToArray(int field_number, 462 void WireFormatLite::WriteGroupMaybeToArray(int field_number,
463 const MessageLite& value, 463 const MessageLite& value,
464 io::CodedOutputStream* output) { 464 io::CodedOutputStream* output) {
465 WriteTag(field_number, WIRETYPE_START_GROUP, output); 465 WriteTag(field_number, WIRETYPE_START_GROUP, output);
466 const int size = value.GetCachedSize(); 466 const int size = value.GetCachedSize();
467 uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); 467 uint8* target = output->GetDirectBufferForNBytesAndAdvance(size);
468 if (target != NULL) { 468 if (target != NULL) {
469 uint8* end = value.SerializeWithCachedSizesToArray(target); 469 uint8* end = value.InternalSerializeWithCachedSizesToArray(
470 output->IsSerializationDeterministic(), target);
470 GOOGLE_DCHECK_EQ(end - target, size); 471 GOOGLE_DCHECK_EQ(end - target, size);
471 } else { 472 } else {
472 value.SerializeWithCachedSizes(output); 473 value.SerializeWithCachedSizes(output);
473 } 474 }
474 WriteTag(field_number, WIRETYPE_END_GROUP, output); 475 WriteTag(field_number, WIRETYPE_END_GROUP, output);
475 } 476 }
476 477
477 void WireFormatLite::WriteMessageMaybeToArray(int field_number, 478 void WireFormatLite::WriteMessageMaybeToArray(int field_number,
478 const MessageLite& value, 479 const MessageLite& value,
479 io::CodedOutputStream* output) { 480 io::CodedOutputStream* output) {
480 WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output); 481 WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);
481 const int size = value.GetCachedSize(); 482 const int size = value.GetCachedSize();
482 output->WriteVarint32(size); 483 output->WriteVarint32(size);
483 uint8* target = output->GetDirectBufferForNBytesAndAdvance(size); 484 uint8* target = output->GetDirectBufferForNBytesAndAdvance(size);
484 if (target != NULL) { 485 if (target != NULL) {
485 uint8* end = value.SerializeWithCachedSizesToArray(target); 486 uint8* end = value.InternalSerializeWithCachedSizesToArray(
487 output->IsSerializationDeterministic(), target);
486 GOOGLE_DCHECK_EQ(end - target, size); 488 GOOGLE_DCHECK_EQ(end - target, size);
487 } else { 489 } else {
488 value.SerializeWithCachedSizes(output); 490 value.SerializeWithCachedSizes(output);
489 } 491 }
490 } 492 }
491 493
492 GOOGLE_ATTRIBUTE_ALWAYS_INLINE static bool ReadBytesToString( 494 GOOGLE_ATTRIBUTE_ALWAYS_INLINE static bool ReadBytesToString(
493 io::CodedInputStream* input, string* value); 495 io::CodedInputStream* input, string* value);
494 inline static bool ReadBytesToString(io::CodedInputStream* input, 496 inline static bool ReadBytesToString(io::CodedInputStream* input,
495 string* value) { 497 string* value) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 << "buffer. Use the 'bytes' type if you intend to send raw " 536 << "buffer. Use the 'bytes' type if you intend to send raw "
535 << "bytes. "; 537 << "bytes. ";
536 return false; 538 return false;
537 } 539 }
538 return true; 540 return true;
539 } 541 }
540 542
541 } // namespace internal 543 } // namespace internal
542 } // namespace protobuf 544 } // namespace protobuf
543 } // namespace google 545 } // namespace google
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698