protobuf/src/google/protobuf/extension_set.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // Author: kenton@google.com (Kenton Varda)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 
35 #include <google/protobuf/extension_set.h>
36 
37 #include <tuple>
38 #include <unordered_set>
39 #include <utility>
40 
41 #include <google/protobuf/stubs/common.h>
42 #include <google/protobuf/extension_set_inl.h>
43 #include <google/protobuf/parse_context.h>
44 #include <google/protobuf/io/coded_stream.h>
45 #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
46 #include <google/protobuf/arena.h>
47 #include <google/protobuf/message_lite.h>
48 #include <google/protobuf/metadata_lite.h>
49 #include <google/protobuf/repeated_field.h>
50 #include <google/protobuf/stubs/map_util.h>
51 #include <google/protobuf/stubs/hash.h>
52 
53 // clang-format off
54 #include <google/protobuf/port_def.inc> // must be last.
55 // clang-format on
56 namespace google {
57 namespace protobuf {
58 namespace internal {
59 
60 namespace {
61 
64  return static_cast<WireFormatLite::FieldType>(type);
65 }
66 
69 }
70 
71 inline bool is_packable(WireFormatLite::WireType type) {
72  switch (type) {
76  return true;
80  return false;
81 
82  // Do not add a default statement. Let the compiler complain when someone
83  // adds a new wire type.
84  }
85  GOOGLE_LOG(FATAL) << "can't reach here.";
86  return false;
87 }
88 
89 // Registry stuff.
90 
91 // Note that we cannot use hetererogeneous lookup for std containers since we
92 // need to support C++11.
93 struct ExtensionEq {
94  bool operator()(const ExtensionInfo& lhs, const ExtensionInfo& rhs) const {
95  return lhs.message == rhs.message && lhs.number == rhs.number;
96  }
97 };
98 
99 struct ExtensionHasher {
100  std::size_t operator()(const ExtensionInfo& info) const {
101  return std::hash<const MessageLite*>{}(info.message) ^
102  std::hash<int>{}(info.number);
103  }
104 };
105 
106 using ExtensionRegistry =
107  std::unordered_set<ExtensionInfo, ExtensionHasher, ExtensionEq>;
108 
109 static const ExtensionRegistry* global_registry = nullptr;
110 
111 // This function is only called at startup, so there is no need for thread-
112 // safety.
113 void Register(const ExtensionInfo& info) {
114  static auto local_static_registry = OnShutdownDelete(new ExtensionRegistry);
115  global_registry = local_static_registry;
116  if (!InsertIfNotPresent(local_static_registry, info)) {
117  GOOGLE_LOG(FATAL) << "Multiple extension registrations for type \""
118  << info.message->GetTypeName() << "\", field number "
119  << info.number << ".";
120  }
121 }
122 
123 const ExtensionInfo* FindRegisteredExtension(const MessageLite* extendee,
124  int number) {
125  if (!global_registry) return nullptr;
126 
127  ExtensionInfo info;
128  info.message = extendee;
129  info.number = number;
130 
131  auto it = global_registry->find(info);
132  if (it == global_registry->end()) {
133  return nullptr;
134  } else {
135  return &*it;
136  }
137 }
138 
139 } // namespace
140 
142 
143 bool GeneratedExtensionFinder::Find(int number, ExtensionInfo* output) {
144  const ExtensionInfo* extension = FindRegisteredExtension(extendee_, number);
145  if (extension == nullptr) {
146  return false;
147  } else {
148  *output = *extension;
149  return true;
150  }
151 }
152 
153 void ExtensionSet::RegisterExtension(const MessageLite* extendee, int number,
154  FieldType type, bool is_repeated,
155  bool is_packed) {
159  ExtensionInfo info(extendee, number, type, is_repeated, is_packed);
160  Register(info);
161 }
162 
163 static bool CallNoArgValidityFunc(const void* arg, int number) {
164  // Note: Must use C-style cast here rather than reinterpret_cast because
165  // the C++ standard at one point did not allow casts between function and
166  // data pointers and some compilers enforce this for C++-style casts. No
167  // compiler enforces it for C-style casts since lots of C-style code has
168  // relied on these kinds of casts for a long time, despite being
169  // technically undefined. See:
170  // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#195
171  // Also note: Some compilers do not allow function pointers to be "const".
172  // Which makes sense, I suppose, because it's meaningless.
173  return ((EnumValidityFunc*)arg)(number);
174 }
175 
177  int number, FieldType type,
178  bool is_repeated, bool is_packed,
179  EnumValidityFunc* is_valid) {
181  ExtensionInfo info(extendee, number, type, is_repeated, is_packed);
182  info.enum_validity_check.func = CallNoArgValidityFunc;
183  // See comment in CallNoArgValidityFunc() about why we use a c-style cast.
184  info.enum_validity_check.arg = (void*)is_valid;
185  Register(info);
186 }
187 
189  int number, FieldType type,
190  bool is_repeated, bool is_packed,
191  const MessageLite* prototype) {
194  ExtensionInfo info(extendee, number, type, is_repeated, is_packed);
195  info.message_info = {prototype};
196  Register(info);
197 }
198 
199 // ===================================================================
200 // Constructors and basic methods.
201 
203  : arena_(arena),
204  flat_capacity_(0),
205  flat_size_(0),
206  map_{flat_capacity_ == 0
207  ? nullptr
208  : Arena::CreateArray<KeyValue>(arena_, flat_capacity_)} {}
209 
211  // Deletes all allocated extensions.
212  if (arena_ == nullptr) {
213  ForEach([](int /* number */, Extension& ext) { ext.Free(); });
214  if (PROTOBUF_PREDICT_FALSE(is_large())) {
215  delete map_.large;
216  } else {
218  }
219  }
220 }
221 
222 void ExtensionSet::DeleteFlatMap(const ExtensionSet::KeyValue* flat,
223  uint16_t flat_capacity) {
224 #ifdef __cpp_sized_deallocation
225  // Arena::CreateArray already requires a trivially destructible type, but
226  // ensure this constraint is not violated in the future.
228  "CreateArray requires a trivially destructible type");
229  // A const-cast is needed, but this is safe as we are about to deallocate the
230  // array.
231  ::operator delete[](const_cast<ExtensionSet::KeyValue*>(flat),
232  sizeof(*flat) * flat_capacity);
233 #else // !__cpp_sized_deallocation
234  delete[] flat;
235 #endif // !__cpp_sized_deallocation
236 }
237 
238 // Defined in extension_set_heavy.cc.
239 // void ExtensionSet::AppendToList(const Descriptor* extendee,
240 // const DescriptorPool* pool,
241 // vector<const FieldDescriptor*>* output) const
242 
243 bool ExtensionSet::Has(int number) const {
244  const Extension* ext = FindOrNull(number);
245  if (ext == nullptr) return false;
246  GOOGLE_DCHECK(!ext->is_repeated);
247  return !ext->is_cleared;
248 }
249 
250 bool ExtensionSet::HasLazy(int number) const {
251  return Has(number) && FindOrNull(number)->is_lazy;
252 }
253 
254 int ExtensionSet::NumExtensions() const {
255  int result = 0;
256  ForEach([&result](int /* number */, const Extension& ext) {
257  if (!ext.is_cleared) {
258  ++result;
259  }
260  });
261  return result;
262 }
263 
264 int ExtensionSet::ExtensionSize(int number) const {
265  const Extension* ext = FindOrNull(number);
266  return ext == nullptr ? 0 : ext->GetSize();
267 }
268 
270  const Extension* ext = FindOrNull(number);
271  if (ext == nullptr) {
272  GOOGLE_LOG(DFATAL) << "Don't lookup extension types if they aren't present (1). ";
273  return 0;
274  }
275  if (ext->is_cleared) {
276  GOOGLE_LOG(DFATAL) << "Don't lookup extension types if they aren't present (2). ";
277  }
278  return ext->type;
279 }
280 
282  Extension* ext = FindOrNull(number);
283  if (ext == nullptr) return;
284  ext->Clear();
285 }
286 
287 // ===================================================================
288 // Field accessors
289 
290 namespace {
291 
292 enum { REPEATED_FIELD, OPTIONAL_FIELD };
293 
294 } // namespace
295 
296 #define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE) \
297  GOOGLE_DCHECK_EQ((EXTENSION).is_repeated ? REPEATED_FIELD : OPTIONAL_FIELD, LABEL); \
298  GOOGLE_DCHECK_EQ(cpp_type((EXTENSION).type), WireFormatLite::CPPTYPE_##CPPTYPE)
299 
300 // -------------------------------------------------------------------
301 // Primitives
302 
303 #define PRIMITIVE_ACCESSORS(UPPERCASE, LOWERCASE, CAMELCASE) \
304  \
305  LOWERCASE ExtensionSet::Get##CAMELCASE(int number, LOWERCASE default_value) \
306  const { \
307  const Extension* extension = FindOrNull(number); \
308  if (extension == nullptr || extension->is_cleared) { \
309  return default_value; \
310  } else { \
311  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
312  return extension->LOWERCASE##_value; \
313  } \
314  } \
315  \
316  const LOWERCASE& ExtensionSet::GetRef##CAMELCASE( \
317  int number, const LOWERCASE& default_value) const { \
318  const Extension* extension = FindOrNull(number); \
319  if (extension == nullptr || extension->is_cleared) { \
320  return default_value; \
321  } else { \
322  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
323  return extension->LOWERCASE##_value; \
324  } \
325  } \
326  \
327  void ExtensionSet::Set##CAMELCASE(int number, FieldType type, \
328  LOWERCASE value, \
329  const FieldDescriptor* descriptor) { \
330  Extension* extension; \
331  if (MaybeNewExtension(number, descriptor, &extension)) { \
332  extension->type = type; \
333  GOOGLE_DCHECK_EQ(cpp_type(extension->type), \
334  WireFormatLite::CPPTYPE_##UPPERCASE); \
335  extension->is_repeated = false; \
336  } else { \
337  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, UPPERCASE); \
338  } \
339  extension->is_cleared = false; \
340  extension->LOWERCASE##_value = value; \
341  } \
342  \
343  LOWERCASE ExtensionSet::GetRepeated##CAMELCASE(int number, int index) \
344  const { \
345  const Extension* extension = FindOrNull(number); \
346  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; \
347  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
348  return extension->repeated_##LOWERCASE##_value->Get(index); \
349  } \
350  \
351  const LOWERCASE& ExtensionSet::GetRefRepeated##CAMELCASE(int number, \
352  int index) const { \
353  const Extension* extension = FindOrNull(number); \
354  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; \
355  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
356  return extension->repeated_##LOWERCASE##_value->Get(index); \
357  } \
358  \
359  void ExtensionSet::SetRepeated##CAMELCASE(int number, int index, \
360  LOWERCASE value) { \
361  Extension* extension = FindOrNull(number); \
362  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty)."; \
363  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
364  extension->repeated_##LOWERCASE##_value->Set(index, value); \
365  } \
366  \
367  void ExtensionSet::Add##CAMELCASE(int number, FieldType type, bool packed, \
368  LOWERCASE value, \
369  const FieldDescriptor* descriptor) { \
370  Extension* extension; \
371  if (MaybeNewExtension(number, descriptor, &extension)) { \
372  extension->type = type; \
373  GOOGLE_DCHECK_EQ(cpp_type(extension->type), \
374  WireFormatLite::CPPTYPE_##UPPERCASE); \
375  extension->is_repeated = true; \
376  extension->is_packed = packed; \
377  extension->repeated_##LOWERCASE##_value = \
378  Arena::CreateMessage<RepeatedField<LOWERCASE>>(arena_); \
379  } else { \
380  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, UPPERCASE); \
381  GOOGLE_DCHECK_EQ(extension->is_packed, packed); \
382  } \
383  extension->repeated_##LOWERCASE##_value->Add(value); \
384  }
385 
390 PRIMITIVE_ACCESSORS(FLOAT, float, Float)
391 PRIMITIVE_ACCESSORS(DOUBLE, double, Double)
393 
394 #undef PRIMITIVE_ACCESSORS
395 
397  const void* default_value) const {
398  const Extension* extension = FindOrNull(number);
399  if (extension == nullptr) {
400  return default_value;
401  }
402  // We assume that all the RepeatedField<>* pointers have the same
403  // size and alignment within the anonymous union in Extension.
404  return extension->repeated_int32_t_value;
405 }
406 
408  bool packed,
409  const FieldDescriptor* desc) {
410  Extension* extension;
411 
412  // We instantiate an empty Repeated{,Ptr}Field if one doesn't exist for this
413  // extension.
415  extension->is_repeated = true;
417  extension->is_packed = packed;
418 
420  static_cast<WireFormatLite::FieldType>(field_type))) {
422  extension->repeated_int32_t_value =
423  Arena::CreateMessage<RepeatedField<int32_t>>(arena_);
424  break;
426  extension->repeated_int64_t_value =
427  Arena::CreateMessage<RepeatedField<int64_t>>(arena_);
428  break;
430  extension->repeated_uint32_t_value =
431  Arena::CreateMessage<RepeatedField<uint32_t>>(arena_);
432  break;
434  extension->repeated_uint64_t_value =
435  Arena::CreateMessage<RepeatedField<uint64_t>>(arena_);
436  break;
438  extension->repeated_double_value =
439  Arena::CreateMessage<RepeatedField<double>>(arena_);
440  break;
442  extension->repeated_float_value =
443  Arena::CreateMessage<RepeatedField<float>>(arena_);
444  break;
446  extension->repeated_bool_value =
447  Arena::CreateMessage<RepeatedField<bool>>(arena_);
448  break;
450  extension->repeated_enum_value =
451  Arena::CreateMessage<RepeatedField<int>>(arena_);
452  break;
454  extension->repeated_string_value =
455  Arena::CreateMessage<RepeatedPtrField<std::string>>(arena_);
456  break;
458  extension->repeated_message_value =
459  Arena::CreateMessage<RepeatedPtrField<MessageLite>>(arena_);
460  break;
461  }
462  }
463 
464  // We assume that all the RepeatedField<>* pointers have the same
465  // size and alignment within the anonymous union in Extension.
466  return extension->repeated_int32_t_value;
467 }
468 
469 // Compatible version using old call signature. Does not create extensions when
470 // the don't already exist; instead, just GOOGLE_CHECK-fails.
472  Extension* extension = FindOrNull(number);
473  GOOGLE_CHECK(extension != nullptr) << "Extension not found.";
474  // We assume that all the RepeatedField<>* pointers have the same
475  // size and alignment within the anonymous union in Extension.
476  return extension->repeated_int32_t_value;
477 }
478 
479 // -------------------------------------------------------------------
480 // Enums
481 
482 int ExtensionSet::GetEnum(int number, int default_value) const {
483  const Extension* extension = FindOrNull(number);
484  if (extension == nullptr || extension->is_cleared) {
485  // Not present. Return the default value.
486  return default_value;
487  } else {
488  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
489  return extension->enum_value;
490  }
491 }
492 
494  const int& default_value) const {
496  if (extension == nullptr || extension->is_cleared) {
497  // Not present. Return the default value.
498  return default_value;
499  } else {
500  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
501  return extension->enum_value;
502  }
503 }
504 
506  const FieldDescriptor* descriptor) {
507  Extension* extension;
509  extension->type = type;
511  extension->is_repeated = false;
512  } else {
513  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, ENUM);
514  }
515  extension->is_cleared = false;
516  extension->enum_value = value;
517 }
518 
519 int ExtensionSet::GetRepeatedEnum(int number, int index) const {
520  const Extension* extension = FindOrNull(number);
521  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
522  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
523  return extension->repeated_enum_value->Get(index);
524 }
525 
526 const int& ExtensionSet::GetRefRepeatedEnum(int number, int index) const {
528  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
529  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
530  return extension->repeated_enum_value->Get(index);
531 }
532 
533 void ExtensionSet::SetRepeatedEnum(int number, int index, int value) {
534  Extension* extension = FindOrNull(number);
535  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
536  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
537  extension->repeated_enum_value->Set(index, value);
538 }
539 
540 void ExtensionSet::AddEnum(int number, FieldType type, bool packed, int value,
541  const FieldDescriptor* descriptor) {
542  Extension* extension;
544  extension->type = type;
546  extension->is_repeated = true;
547  extension->is_packed = packed;
548  extension->repeated_enum_value =
549  Arena::CreateMessage<RepeatedField<int>>(arena_);
550  } else {
551  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, ENUM);
552  GOOGLE_DCHECK_EQ(extension->is_packed, packed);
553  }
554  extension->repeated_enum_value->Add(value);
555 }
556 
557 // -------------------------------------------------------------------
558 // Strings
559 
561  int number, const std::string& default_value) const {
562  const Extension* extension = FindOrNull(number);
563  if (extension == nullptr || extension->is_cleared) {
564  // Not present. Return the default value.
565  return default_value;
566  } else {
567  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING);
568  return *extension->string_value;
569  }
570 }
571 
573  const FieldDescriptor* descriptor) {
574  Extension* extension;
576  extension->type = type;
578  extension->is_repeated = false;
579  extension->string_value = Arena::Create<std::string>(arena_);
580  } else {
581  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, STRING);
582  }
583  extension->is_cleared = false;
584  return extension->string_value;
585 }
586 
588  int index) const {
589  const Extension* extension = FindOrNull(number);
590  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
591  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
592  return extension->repeated_string_value->Get(index);
593 }
594 
596  Extension* extension = FindOrNull(number);
597  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
598  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
599  return extension->repeated_string_value->Mutable(index);
600 }
601 
603  const FieldDescriptor* descriptor) {
604  Extension* extension;
606  extension->type = type;
608  extension->is_repeated = true;
609  extension->is_packed = false;
610  extension->repeated_string_value =
611  Arena::CreateMessage<RepeatedPtrField<std::string>>(arena_);
612  } else {
613  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, STRING);
614  }
615  return extension->repeated_string_value->Add();
616 }
617 
618 // -------------------------------------------------------------------
619 // Messages
620 
622  int number, const MessageLite& default_value) const {
623  const Extension* extension = FindOrNull(number);
624  if (extension == nullptr) {
625  // Not present. Return the default value.
626  return default_value;
627  } else {
628  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
629  if (extension->is_lazy) {
630  return extension->lazymessage_value->GetMessage(default_value, arena_);
631  } else {
632  return *extension->message_value;
633  }
634  }
635 }
636 
637 // Defined in extension_set_heavy.cc.
638 // const MessageLite& ExtensionSet::GetMessage(int number,
639 // const Descriptor* message_type,
640 // MessageFactory* factory) const
641 
643  const MessageLite& prototype,
644  const FieldDescriptor* descriptor) {
645  Extension* extension;
647  extension->type = type;
649  extension->is_repeated = false;
650  extension->is_lazy = false;
651  extension->message_value = prototype.New(arena_);
652  extension->is_cleared = false;
653  return extension->message_value;
654  } else {
655  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
656  extension->is_cleared = false;
657  if (extension->is_lazy) {
658  return extension->lazymessage_value->MutableMessage(prototype, arena_);
659  } else {
660  return extension->message_value;
661  }
662  }
663 }
664 
665 // Defined in extension_set_heavy.cc.
666 // MessageLite* ExtensionSet::MutableMessage(int number, FieldType type,
667 // const Descriptor* message_type,
668 // MessageFactory* factory)
669 
672  MessageLite* message) {
673  if (message == nullptr) {
675  return;
676  }
677  GOOGLE_DCHECK(message->GetOwningArena() == nullptr ||
678  message->GetOwningArena() == arena_);
679  Arena* message_arena = message->GetOwningArena();
680  Extension* extension;
682  extension->type = type;
684  extension->is_repeated = false;
685  extension->is_lazy = false;
686  if (message_arena == arena_) {
687  extension->message_value = message;
688  } else if (message_arena == nullptr) {
689  extension->message_value = message;
690  arena_->Own(message); // not nullptr because not equal to message_arena
691  } else {
692  extension->message_value = message->New(arena_);
693  extension->message_value->CheckTypeAndMergeFrom(*message);
694  }
695  } else {
696  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
697  if (extension->is_lazy) {
698  extension->lazymessage_value->SetAllocatedMessage(message, arena_);
699  } else {
700  if (arena_ == nullptr) {
701  delete extension->message_value;
702  }
703  if (message_arena == arena_) {
704  extension->message_value = message;
705  } else if (message_arena == nullptr) {
706  extension->message_value = message;
707  arena_->Own(message); // not nullptr because not equal to message_arena
708  } else {
709  extension->message_value = message->New(arena_);
710  extension->message_value->CheckTypeAndMergeFrom(*message);
711  }
712  }
713  }
714  extension->is_cleared = false;
715 }
716 
719  MessageLite* message) {
720  if (message == nullptr) {
722  return;
723  }
724  Extension* extension;
726  extension->type = type;
728  extension->is_repeated = false;
729  extension->is_lazy = false;
730  extension->message_value = message;
731  } else {
732  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
733  if (extension->is_lazy) {
734  extension->lazymessage_value->UnsafeArenaSetAllocatedMessage(message,
735  arena_);
736  } else {
737  if (arena_ == nullptr) {
738  delete extension->message_value;
739  }
740  extension->message_value = message;
741  }
742  }
743  extension->is_cleared = false;
744 }
745 
747  const MessageLite& prototype) {
748  Extension* extension = FindOrNull(number);
749  if (extension == nullptr) {
750  // Not present. Return nullptr.
751  return nullptr;
752  } else {
753  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
754  MessageLite* ret = nullptr;
755  if (extension->is_lazy) {
756  ret = extension->lazymessage_value->ReleaseMessage(prototype, arena_);
757  if (arena_ == nullptr) {
758  delete extension->lazymessage_value;
759  }
760  } else {
761  if (arena_ == nullptr) {
762  ret = extension->message_value;
763  } else {
764  // ReleaseMessage() always returns a heap-allocated message, and we are
765  // on an arena, so we need to make a copy of this message to return.
766  ret = extension->message_value->New();
767  ret->CheckTypeAndMergeFrom(*extension->message_value);
768  }
769  }
770  Erase(number);
771  return ret;
772  }
773 }
774 
776  int number, const MessageLite& prototype) {
777  Extension* extension = FindOrNull(number);
778  if (extension == nullptr) {
779  // Not present. Return nullptr.
780  return nullptr;
781  } else {
782  GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
783  MessageLite* ret = nullptr;
784  if (extension->is_lazy) {
785  ret = extension->lazymessage_value->UnsafeArenaReleaseMessage(prototype,
786  arena_);
787  if (arena_ == nullptr) {
788  delete extension->lazymessage_value;
789  }
790  } else {
791  ret = extension->message_value;
792  }
793  Erase(number);
794  return ret;
795  }
796 }
797 
798 // Defined in extension_set_heavy.cc.
799 // MessageLite* ExtensionSet::ReleaseMessage(const FieldDescriptor* descriptor,
800 // MessageFactory* factory);
801 
803  int index) const {
804  const Extension* extension = FindOrNull(number);
805  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
806  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
807  return extension->repeated_message_value->Get(index);
808 }
809 
811  Extension* extension = FindOrNull(number);
812  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
813  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
814  return extension->repeated_message_value->Mutable(index);
815 }
816 
818  const MessageLite& prototype,
819  const FieldDescriptor* descriptor) {
820  Extension* extension;
822  extension->type = type;
824  extension->is_repeated = true;
825  extension->repeated_message_value =
826  Arena::CreateMessage<RepeatedPtrField<MessageLite>>(arena_);
827  } else {
828  GOOGLE_DCHECK_TYPE(*extension, REPEATED_FIELD, MESSAGE);
829  }
830 
831  // RepeatedPtrField<MessageLite> does not know how to Add() since it cannot
832  // allocate an abstract object, so we have to be tricky.
833  MessageLite* result = reinterpret_cast<internal::RepeatedPtrFieldBase*>(
834  extension->repeated_message_value)
835  ->AddFromCleared<GenericTypeHandler<MessageLite>>();
836  if (result == nullptr) {
837  result = prototype.New(arena_);
838  extension->repeated_message_value->AddAllocated(result);
839  }
840  return result;
841 }
842 
843 // Defined in extension_set_heavy.cc.
844 // MessageLite* ExtensionSet::AddMessage(int number, FieldType type,
845 // const Descriptor* message_type,
846 // MessageFactory* factory)
847 
848 #undef GOOGLE_DCHECK_TYPE
849 
851  Extension* extension = FindOrNull(number);
852  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
853  GOOGLE_DCHECK(extension->is_repeated);
854 
855  switch (cpp_type(extension->type)) {
857  extension->repeated_int32_t_value->RemoveLast();
858  break;
860  extension->repeated_int64_t_value->RemoveLast();
861  break;
863  extension->repeated_uint32_t_value->RemoveLast();
864  break;
866  extension->repeated_uint64_t_value->RemoveLast();
867  break;
869  extension->repeated_float_value->RemoveLast();
870  break;
872  extension->repeated_double_value->RemoveLast();
873  break;
875  extension->repeated_bool_value->RemoveLast();
876  break;
878  extension->repeated_enum_value->RemoveLast();
879  break;
881  extension->repeated_string_value->RemoveLast();
882  break;
884  extension->repeated_message_value->RemoveLast();
885  break;
886  }
887 }
888 
890  Extension* extension = FindOrNull(number);
891  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
892  GOOGLE_DCHECK(extension->is_repeated);
894  return extension->repeated_message_value->ReleaseLast();
895 }
896 
899  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
900  GOOGLE_DCHECK(extension->is_repeated);
902  return extension->repeated_message_value->UnsafeArenaReleaseLast();
903 }
904 
905 void ExtensionSet::SwapElements(int number, int index1, int index2) {
906  Extension* extension = FindOrNull(number);
907  GOOGLE_CHECK(extension != nullptr) << "Index out-of-bounds (field is empty).";
908  GOOGLE_DCHECK(extension->is_repeated);
909 
910  switch (cpp_type(extension->type)) {
912  extension->repeated_int32_t_value->SwapElements(index1, index2);
913  break;
915  extension->repeated_int64_t_value->SwapElements(index1, index2);
916  break;
918  extension->repeated_uint32_t_value->SwapElements(index1, index2);
919  break;
921  extension->repeated_uint64_t_value->SwapElements(index1, index2);
922  break;
924  extension->repeated_float_value->SwapElements(index1, index2);
925  break;
927  extension->repeated_double_value->SwapElements(index1, index2);
928  break;
930  extension->repeated_bool_value->SwapElements(index1, index2);
931  break;
933  extension->repeated_enum_value->SwapElements(index1, index2);
934  break;
936  extension->repeated_string_value->SwapElements(index1, index2);
937  break;
939  extension->repeated_message_value->SwapElements(index1, index2);
940  break;
941  }
942 }
943 
944 // ===================================================================
945 
946 void ExtensionSet::Clear() {
947  ForEach([](int /* number */, Extension& ext) { ext.Clear(); });
948 }
949 
950 namespace {
951 // Computes the size of a std::set_union without constructing the union.
952 template <typename ItX, typename ItY>
953 size_t SizeOfUnion(ItX it_xs, ItX end_xs, ItY it_ys, ItY end_ys) {
954  size_t result = 0;
955  while (it_xs != end_xs && it_ys != end_ys) {
956  ++result;
957  if (it_xs->first < it_ys->first) {
958  ++it_xs;
959  } else if (it_xs->first == it_ys->first) {
960  ++it_xs;
961  ++it_ys;
962  } else {
963  ++it_ys;
964  }
965  }
966  result += std::distance(it_xs, end_xs);
967  result += std::distance(it_ys, end_ys);
968  return result;
969 }
970 } // namespace
971 
973  const ExtensionSet& other) {
974  if (PROTOBUF_PREDICT_TRUE(!is_large())) {
975  if (PROTOBUF_PREDICT_TRUE(!other.is_large())) {
976  GrowCapacity(SizeOfUnion(flat_begin(), flat_end(), other.flat_begin(),
977  other.flat_end()));
978  } else {
979  GrowCapacity(SizeOfUnion(flat_begin(), flat_end(),
980  other.map_.large->begin(),
981  other.map_.large->end()));
982  }
983  }
984  other.ForEach([extendee, this, &other](int number, const Extension& ext) {
985  this->InternalExtensionMergeFrom(extendee, number, ext, other.arena_);
986  });
987 }
988 
990  int number,
991  const Extension& other_extension,
992  Arena* other_arena) {
993  if (other_extension.is_repeated) {
995  bool is_new =
996  MaybeNewExtension(number, other_extension.descriptor, &extension);
997  if (is_new) {
998  // Extension did not already exist in set.
999  extension->type = other_extension.type;
1000  extension->is_packed = other_extension.is_packed;
1001  extension->is_repeated = true;
1002  } else {
1003  GOOGLE_DCHECK_EQ(extension->type, other_extension.type);
1004  GOOGLE_DCHECK_EQ(extension->is_packed, other_extension.is_packed);
1005  GOOGLE_DCHECK(extension->is_repeated);
1006  }
1007 
1008  switch (cpp_type(other_extension.type)) {
1009 #define HANDLE_TYPE(UPPERCASE, LOWERCASE, REPEATED_TYPE) \
1010  case WireFormatLite::CPPTYPE_##UPPERCASE: \
1011  if (is_new) { \
1012  extension->repeated_##LOWERCASE##_value = \
1013  Arena::CreateMessage<REPEATED_TYPE>(arena_); \
1014  } \
1015  extension->repeated_##LOWERCASE##_value->MergeFrom( \
1016  *other_extension.repeated_##LOWERCASE##_value); \
1017  break;
1018 
1023  HANDLE_TYPE(FLOAT, float, RepeatedField<float>);
1024  HANDLE_TYPE(DOUBLE, double, RepeatedField<double>);
1026  HANDLE_TYPE(ENUM, enum, RepeatedField<int>);
1027  HANDLE_TYPE(STRING, string, RepeatedPtrField<std::string>);
1028 #undef HANDLE_TYPE
1029 
1031  if (is_new) {
1032  extension->repeated_message_value =
1033  Arena::CreateMessage<RepeatedPtrField<MessageLite>>(arena_);
1034  }
1035  // We can't call RepeatedPtrField<MessageLite>::MergeFrom() because
1036  // it would attempt to allocate new objects.
1037  RepeatedPtrField<MessageLite>* other_repeated_message =
1038  other_extension.repeated_message_value;
1039  for (int i = 0; i < other_repeated_message->size(); i++) {
1040  const MessageLite& other_message = other_repeated_message->Get(i);
1041  MessageLite* target =
1042  reinterpret_cast<internal::RepeatedPtrFieldBase*>(
1043  extension->repeated_message_value)
1044  ->AddFromCleared<GenericTypeHandler<MessageLite>>();
1045  if (target == nullptr) {
1046  target = other_message.New(arena_);
1047  extension->repeated_message_value->AddAllocated(target);
1048  }
1049  target->CheckTypeAndMergeFrom(other_message);
1050  }
1051  break;
1052  }
1053  } else {
1054  if (!other_extension.is_cleared) {
1055  switch (cpp_type(other_extension.type)) {
1056 #define HANDLE_TYPE(UPPERCASE, LOWERCASE, CAMELCASE) \
1057  case WireFormatLite::CPPTYPE_##UPPERCASE: \
1058  Set##CAMELCASE(number, other_extension.type, \
1059  other_extension.LOWERCASE##_value, \
1060  other_extension.descriptor); \
1061  break;
1062 
1063  HANDLE_TYPE(INT32, int32_t, Int32);
1064  HANDLE_TYPE(INT64, int64_t, Int64);
1065  HANDLE_TYPE(UINT32, uint32_t, UInt32);
1066  HANDLE_TYPE(UINT64, uint64_t, UInt64);
1067  HANDLE_TYPE(FLOAT, float, Float);
1068  HANDLE_TYPE(DOUBLE, double, Double);
1069  HANDLE_TYPE(BOOL, bool, Bool);
1070  HANDLE_TYPE(ENUM, enum, Enum);
1071 #undef HANDLE_TYPE
1073  SetString(number, other_extension.type, *other_extension.string_value,
1074  other_extension.descriptor);
1075  break;
1078  bool is_new =
1079  MaybeNewExtension(number, other_extension.descriptor, &extension);
1080  if (is_new) {
1081  extension->type = other_extension.type;
1082  extension->is_packed = other_extension.is_packed;
1083  extension->is_repeated = false;
1084  if (other_extension.is_lazy) {
1085  extension->is_lazy = true;
1086  extension->lazymessage_value =
1087  other_extension.lazymessage_value->New(arena_);
1088  extension->lazymessage_value->MergeFrom(
1090  *other_extension.lazymessage_value, arena_);
1091  } else {
1092  extension->is_lazy = false;
1093  extension->message_value =
1094  other_extension.message_value->New(arena_);
1095  extension->message_value->CheckTypeAndMergeFrom(
1096  *other_extension.message_value);
1097  }
1098  } else {
1099  GOOGLE_DCHECK_EQ(extension->type, other_extension.type);
1100  GOOGLE_DCHECK_EQ(extension->is_packed, other_extension.is_packed);
1101  GOOGLE_DCHECK(!extension->is_repeated);
1102  if (other_extension.is_lazy) {
1103  if (extension->is_lazy) {
1104  extension->lazymessage_value->MergeFrom(
1106  *other_extension.lazymessage_value, arena_);
1107  } else {
1108  extension->message_value->CheckTypeAndMergeFrom(
1109  other_extension.lazymessage_value->GetMessage(
1110  *extension->message_value, other_arena));
1111  }
1112  } else {
1113  if (extension->is_lazy) {
1114  extension->lazymessage_value
1115  ->MutableMessage(*other_extension.message_value, arena_)
1116  ->CheckTypeAndMergeFrom(*other_extension.message_value);
1117  } else {
1118  extension->message_value->CheckTypeAndMergeFrom(
1119  *other_extension.message_value);
1120  }
1121  }
1122  }
1123  extension->is_cleared = false;
1124  break;
1125  }
1126  }
1127  }
1128  }
1129 }
1130 
1131 void ExtensionSet::Swap(const MessageLite* extendee, ExtensionSet* other) {
1132 #ifdef PROTOBUF_FORCE_COPY_IN_SWAP
1133  if (GetArena() != nullptr && GetArena() == other->GetArena()) {
1134 #else // PROTOBUF_FORCE_COPY_IN_SWAP
1135  if (GetArena() == other->GetArena()) {
1136 #endif // !PROTOBUF_FORCE_COPY_IN_SWAP
1137  InternalSwap(other);
1138  } else {
1139  // TODO(cfallin, rohananil): We maybe able to optimize a case where we are
1140  // swapping from heap to arena-allocated extension set, by just Own()'ing
1141  // the extensions.
1142  ExtensionSet extension_set;
1143  extension_set.MergeFrom(extendee, *other);
1144  other->Clear();
1145  other->MergeFrom(extendee, *this);
1146  Clear();
1147  MergeFrom(extendee, extension_set);
1148  }
1149 }
1150 
1152  using std::swap;
1153  swap(arena_, other->arena_);
1155  swap(flat_size_, other->flat_size_);
1156  swap(map_, other->map_);
1157 }
1158 
1160  ExtensionSet* other, int number) {
1161  if (this == other) return;
1162 
1163  if (GetArena() == other->GetArena()) {
1165  return;
1166  }
1167 
1168  Extension* this_ext = FindOrNull(number);
1169  Extension* other_ext = other->FindOrNull(number);
1170 
1171  if (this_ext == other_ext) return;
1172 
1173  if (this_ext != nullptr && other_ext != nullptr) {
1174  // TODO(cfallin, rohananil): We could further optimize these cases,
1175  // especially avoid creation of ExtensionSet, and move MergeFrom logic
1176  // into Extensions itself (which takes arena as an argument).
1177  // We do it this way to reuse the copy-across-arenas logic already
1178  // implemented in ExtensionSet's MergeFrom.
1180  temp.InternalExtensionMergeFrom(extendee, number, *other_ext,
1181  other->GetArena());
1182  Extension* temp_ext = temp.FindOrNull(number);
1183 
1184  other_ext->Clear();
1185  other->InternalExtensionMergeFrom(extendee, number, *this_ext,
1186  this->GetArena());
1187  this_ext->Clear();
1188  InternalExtensionMergeFrom(extendee, number, *temp_ext, temp.GetArena());
1189  } else if (this_ext == nullptr) {
1190  InternalExtensionMergeFrom(extendee, number, *other_ext, other->GetArena());
1191  if (other->GetArena() == nullptr) other_ext->Free();
1192  other->Erase(number);
1193  } else {
1194  other->InternalExtensionMergeFrom(extendee, number, *this_ext,
1195  this->GetArena());
1196  if (GetArena() == nullptr) this_ext->Free();
1197  Erase(number);
1198  }
1199 }
1200 
1202  if (this == other) return;
1203 
1204  Extension* this_ext = FindOrNull(number);
1205  Extension* other_ext = other->FindOrNull(number);
1206 
1207  if (this_ext == other_ext) return;
1208 
1209  GOOGLE_DCHECK_EQ(GetArena(), other->GetArena());
1210 
1211  if (this_ext != nullptr && other_ext != nullptr) {
1212  std::swap(*this_ext, *other_ext);
1213  } else if (this_ext == nullptr) {
1214  *Insert(number).first = *other_ext;
1215  other->Erase(number);
1216  } else {
1217  *other->Insert(number).first = *this_ext;
1218  Erase(number);
1219  }
1220 }
1221 
1222 bool ExtensionSet::IsInitialized() const {
1223  // Extensions are never required. However, we need to check that all
1224  // embedded messages are initialized.
1225  if (PROTOBUF_PREDICT_FALSE(is_large())) {
1226  for (const auto& kv : *map_.large) {
1227  if (!kv.second.IsInitialized()) return false;
1228  }
1229  return true;
1230  }
1231  for (const KeyValue* it = flat_begin(); it != flat_end(); ++it) {
1232  if (!it->second.IsInitialized()) return false;
1233  }
1234  return true;
1235 }
1236 
1238  ExtensionFinder* extension_finder,
1239  int* field_number,
1240  ExtensionInfo* extension,
1241  bool* was_packed_on_wire) {
1242  *field_number = WireFormatLite::GetTagFieldNumber(tag);
1244  return FindExtensionInfoFromFieldNumber(wire_type, *field_number,
1245  extension_finder, extension,
1246  was_packed_on_wire);
1247 }
1248 
1250  int wire_type, int field_number, ExtensionFinder* extension_finder,
1251  ExtensionInfo* extension, bool* was_packed_on_wire) const {
1252  if (!extension_finder->Find(field_number, extension)) {
1253  return false;
1254  }
1255 
1256  WireFormatLite::WireType expected_wire_type =
1258 
1259  // Check if this is a packed field.
1260  *was_packed_on_wire = false;
1261  if (extension->is_repeated &&
1263  is_packable(expected_wire_type)) {
1264  *was_packed_on_wire = true;
1265  return true;
1266  }
1267  // Otherwise the wire type must match.
1268  return expected_wire_type == wire_type;
1269 }
1270 
1272  ExtensionFinder* extension_finder,
1273  FieldSkipper* field_skipper) {
1274  int number;
1275  bool was_packed_on_wire;
1277  if (!FindExtensionInfoFromTag(tag, extension_finder, &number, &extension,
1278  &was_packed_on_wire)) {
1279  return field_skipper->SkipField(input, tag);
1280  } else {
1281  return ParseFieldWithExtensionInfo(number, was_packed_on_wire, extension,
1282  input, field_skipper);
1283  }
1284 }
1285 
1286 const char* ExtensionSet::ParseField(uint64_t tag, const char* ptr,
1287  const MessageLite* extendee,
1290  GeneratedExtensionFinder finder(extendee);
1291  int number = tag >> 3;
1292  bool was_packed_on_wire;
1295  &was_packed_on_wire)) {
1296  return UnknownFieldParse(
1297  tag, metadata->mutable_unknown_fields<std::string>(), ptr, ctx);
1298  }
1299  return ParseFieldWithExtensionInfo<std::string>(
1300  number, was_packed_on_wire, extension, metadata, ptr, ctx);
1301 }
1302 
1304  const char* ptr, const MessageLite* extendee,
1306  return ParseMessageSetItemTmpl<MessageLite, std::string>(ptr, extendee,
1307  metadata, ctx);
1308 }
1309 
1311  bool was_packed_on_wire,
1312  const ExtensionInfo& extension,
1314  FieldSkipper* field_skipper) {
1315  // Explicitly not read extension.is_packed, instead check whether the field
1316  // was encoded in packed form on the wire.
1317  if (was_packed_on_wire) {
1318  uint32_t size;
1319  if (!input->ReadVarint32(&size)) return false;
1320  io::CodedInputStream::Limit limit = input->PushLimit(size);
1321 
1322  switch (extension.type) {
1323 #define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE, CPP_LOWERCASE) \
1324  case WireFormatLite::TYPE_##UPPERCASE: \
1325  while (input->BytesUntilLimit() > 0) { \
1326  CPP_LOWERCASE value; \
1327  if (!WireFormatLite::ReadPrimitive<CPP_LOWERCASE, \
1328  WireFormatLite::TYPE_##UPPERCASE>( \
1329  input, &value)) \
1330  return false; \
1331  Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \
1332  extension.is_packed, value, extension.descriptor); \
1333  } \
1334  break
1335 
1336  HANDLE_TYPE(INT32, Int32, int32_t);
1337  HANDLE_TYPE(INT64, Int64, int64_t);
1338  HANDLE_TYPE(UINT32, UInt32, uint32_t);
1339  HANDLE_TYPE(UINT64, UInt64, uint64_t);
1340  HANDLE_TYPE(SINT32, Int32, int32_t);
1341  HANDLE_TYPE(SINT64, Int64, int64_t);
1342  HANDLE_TYPE(FIXED32, UInt32, uint32_t);
1343  HANDLE_TYPE(FIXED64, UInt64, uint64_t);
1344  HANDLE_TYPE(SFIXED32, Int32, int32_t);
1345  HANDLE_TYPE(SFIXED64, Int64, int64_t);
1346  HANDLE_TYPE(FLOAT, Float, float);
1347  HANDLE_TYPE(DOUBLE, Double, double);
1348  HANDLE_TYPE(BOOL, Bool, bool);
1349 #undef HANDLE_TYPE
1350 
1352  while (input->BytesUntilLimit() > 0) {
1353  int value;
1354  if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
1355  input, &value))
1356  return false;
1357  if (extension.enum_validity_check.func(
1358  extension.enum_validity_check.arg, value)) {
1360  value, extension.descriptor);
1361  } else {
1362  // Invalid value. Treat as unknown.
1363  field_skipper->SkipUnknownEnum(number, value);
1364  }
1365  }
1366  break;
1367 
1372  GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
1373  break;
1374  }
1375 
1376  input->PopLimit(limit);
1377  } else {
1378  switch (extension.type) {
1379 #define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE, CPP_LOWERCASE) \
1380  case WireFormatLite::TYPE_##UPPERCASE: { \
1381  CPP_LOWERCASE value; \
1382  if (!WireFormatLite::ReadPrimitive<CPP_LOWERCASE, \
1383  WireFormatLite::TYPE_##UPPERCASE>( \
1384  input, &value)) \
1385  return false; \
1386  if (extension.is_repeated) { \
1387  Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, \
1388  extension.is_packed, value, extension.descriptor); \
1389  } else { \
1390  Set##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, value, \
1391  extension.descriptor); \
1392  } \
1393  } break
1394 
1395  HANDLE_TYPE(INT32, Int32, int32_t);
1396  HANDLE_TYPE(INT64, Int64, int64_t);
1397  HANDLE_TYPE(UINT32, UInt32, uint32_t);
1398  HANDLE_TYPE(UINT64, UInt64, uint64_t);
1399  HANDLE_TYPE(SINT32, Int32, int32_t);
1400  HANDLE_TYPE(SINT64, Int64, int64_t);
1401  HANDLE_TYPE(FIXED32, UInt32, uint32_t);
1402  HANDLE_TYPE(FIXED64, UInt64, uint64_t);
1403  HANDLE_TYPE(SFIXED32, Int32, int32_t);
1404  HANDLE_TYPE(SFIXED64, Int64, int64_t);
1405  HANDLE_TYPE(FLOAT, Float, float);
1406  HANDLE_TYPE(DOUBLE, Double, double);
1407  HANDLE_TYPE(BOOL, Bool, bool);
1408 #undef HANDLE_TYPE
1409 
1411  int value;
1412  if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
1413  input, &value))
1414  return false;
1415 
1416  if (!extension.enum_validity_check.func(
1417  extension.enum_validity_check.arg, value)) {
1418  // Invalid value. Treat as unknown.
1419  field_skipper->SkipUnknownEnum(number, value);
1420  } else if (extension.is_repeated) {
1422  extension.descriptor);
1423  } else {
1425  extension.descriptor);
1426  }
1427  break;
1428  }
1429 
1431  std::string* value =
1432  extension.is_repeated
1434  extension.descriptor)
1435  : MutableString(number, WireFormatLite::TYPE_STRING,
1437  if (!WireFormatLite::ReadString(input, value)) return false;
1438  break;
1439  }
1440 
1442  std::string* value =
1443  extension.is_repeated
1445  extension.descriptor)
1446  : MutableString(number, WireFormatLite::TYPE_BYTES,
1448  if (!WireFormatLite::ReadBytes(input, value)) return false;
1449  break;
1450  }
1451 
1453  MessageLite* value =
1454  extension.is_repeated
1456  *extension.message_info.prototype,
1457  extension.descriptor)
1458  : MutableMessage(number, WireFormatLite::TYPE_GROUP,
1459  *extension.message_info.prototype,
1461  if (!WireFormatLite::ReadGroup(number, input, value)) return false;
1462  break;
1463  }
1464 
1466  MessageLite* value =
1467  extension.is_repeated
1469  *extension.message_info.prototype,
1470  extension.descriptor)
1471  : MutableMessage(number, WireFormatLite::TYPE_MESSAGE,
1472  *extension.message_info.prototype,
1474  if (!WireFormatLite::ReadMessage(input, value)) return false;
1475  break;
1476  }
1477  }
1478  }
1479 
1480  return true;
1481 }
1482 
1484  const MessageLite* extendee) {
1485  FieldSkipper skipper;
1486  GeneratedExtensionFinder finder(extendee);
1487  return ParseField(tag, input, &finder, &skipper);
1488 }
1489 
1491  const MessageLite* extendee,
1492  io::CodedOutputStream* unknown_fields) {
1493  CodedOutputStreamFieldSkipper skipper(unknown_fields);
1494  GeneratedExtensionFinder finder(extendee);
1495  return ParseField(tag, input, &finder, &skipper);
1496 }
1497 
1499  ExtensionFinder* extension_finder,
1500  FieldSkipper* field_skipper) {
1501  while (true) {
1502  const uint32_t tag = input->ReadTag();
1503  switch (tag) {
1504  case 0:
1505  return true;
1507  if (!ParseMessageSetItemLite(input, extension_finder, field_skipper)) {
1508  return false;
1509  }
1510  break;
1511  default:
1512  if (!ParseField(tag, input, extension_finder, field_skipper)) {
1513  return false;
1514  }
1515  break;
1516  }
1517  }
1518 }
1519 
1521  ExtensionFinder* extension_finder,
1522  FieldSkipper* field_skipper) {
1523  struct MSLite {
1524  bool ParseField(int type_id, io::CodedInputStream* input) {
1525  return me->ParseField(
1527  extension_finder, field_skipper);
1528  }
1529 
1531  return field_skipper->SkipField(input, tag);
1532  }
1533 
1534  ExtensionSet* me;
1535  ExtensionFinder* extension_finder;
1536  FieldSkipper* field_skipper;
1537  };
1538 
1540  MSLite{this, extension_finder, field_skipper});
1541 }
1542 
1544  const MessageLite* extendee,
1545  std::string* unknown_fields) {
1546  io::StringOutputStream zcis(unknown_fields);
1548  CodedOutputStreamFieldSkipper skipper(&output);
1549  GeneratedExtensionFinder finder(extendee);
1550  return ParseMessageSetLite(input, &finder, &skipper);
1551 }
1552 
1554  const MessageLite* extendee, int start_field_number, int end_field_number,
1556  if (PROTOBUF_PREDICT_FALSE(is_large())) {
1557  const auto& end = map_.large->end();
1558  for (auto it = map_.large->lower_bound(start_field_number);
1559  it != end && it->first < end_field_number; ++it) {
1560  target = it->second.InternalSerializeFieldWithCachedSizesToArray(
1561  extendee, this, it->first, target, stream);
1562  }
1563  return target;
1564  }
1565  const KeyValue* end = flat_end();
1566  for (const KeyValue* it = std::lower_bound(
1567  flat_begin(), end, start_field_number, KeyValue::FirstComparator());
1568  it != end && it->first < end_field_number; ++it) {
1569  target = it->second.InternalSerializeFieldWithCachedSizesToArray(
1570  extendee, this, it->first, target, stream);
1571  }
1572  return target;
1573 }
1574 
1576  const MessageLite* extendee, uint8_t* target,
1578  const ExtensionSet* extension_set = this;
1579  ForEach([&target, extendee, stream, extension_set](int number,
1580  const Extension& ext) {
1581  target = ext.InternalSerializeMessageSetItemWithCachedSizesToArray(
1582  extendee, extension_set, number, target, stream);
1583  });
1584  return target;
1585 }
1586 
1587 size_t ExtensionSet::ByteSize() const {
1588  size_t total_size = 0;
1589  ForEach([&total_size](int number, const Extension& ext) {
1590  total_size += ext.ByteSize(number);
1591  });
1592  return total_size;
1593 }
1594 
1595 // Defined in extension_set_heavy.cc.
1596 // int ExtensionSet::SpaceUsedExcludingSelf() const
1597 
1599  const FieldDescriptor* descriptor,
1600  Extension** result) {
1601  bool extension_is_new = false;
1602  std::tie(*result, extension_is_new) = Insert(number);
1603  (*result)->descriptor = descriptor;
1604  return extension_is_new;
1605 }
1606 
1607 // ===================================================================
1608 // Methods of ExtensionSet::Extension
1609 
1611  if (is_repeated) {
1612  switch (cpp_type(type)) {
1613 #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
1614  case WireFormatLite::CPPTYPE_##UPPERCASE: \
1615  repeated_##LOWERCASE##_value->Clear(); \
1616  break
1617 
1618  HANDLE_TYPE(INT32, int32_t);
1619  HANDLE_TYPE(INT64, int64_t);
1620  HANDLE_TYPE(UINT32, uint32_t);
1621  HANDLE_TYPE(UINT64, uint64_t);
1622  HANDLE_TYPE(FLOAT, float);
1623  HANDLE_TYPE(DOUBLE, double);
1624  HANDLE_TYPE(BOOL, bool);
1625  HANDLE_TYPE(ENUM, enum);
1626  HANDLE_TYPE(STRING, string);
1628 #undef HANDLE_TYPE
1629  }
1630  } else {
1631  if (!is_cleared) {
1632  switch (cpp_type(type)) {
1634  string_value->clear();
1635  break;
1637  if (is_lazy) {
1638  lazymessage_value->Clear();
1639  } else {
1640  message_value->Clear();
1641  }
1642  break;
1643  default:
1644  // No need to do anything. Get*() will return the default value
1645  // as long as is_cleared is true and Set*() will overwrite the
1646  // previous value.
1647  break;
1648  }
1649 
1650  is_cleared = true;
1651  }
1652  }
1653 }
1654 
1655 size_t ExtensionSet::Extension::ByteSize(int number) const {
1656  size_t result = 0;
1657 
1658  if (is_repeated) {
1659  if (is_packed) {
1660  switch (real_type(type)) {
1661 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \
1662  case WireFormatLite::TYPE_##UPPERCASE: \
1663  for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \
1664  result += WireFormatLite::CAMELCASE##Size( \
1665  repeated_##LOWERCASE##_value->Get(i)); \
1666  } \
1667  break
1668 
1669  HANDLE_TYPE(INT32, Int32, int32_t);
1670  HANDLE_TYPE(INT64, Int64, int64_t);
1671  HANDLE_TYPE(UINT32, UInt32, uint32_t);
1672  HANDLE_TYPE(UINT64, UInt64, uint64_t);
1673  HANDLE_TYPE(SINT32, SInt32, int32_t);
1674  HANDLE_TYPE(SINT64, SInt64, int64_t);
1675  HANDLE_TYPE(ENUM, Enum, enum);
1676 #undef HANDLE_TYPE
1677 
1678  // Stuff with fixed size.
1679 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \
1680  case WireFormatLite::TYPE_##UPPERCASE: \
1681  result += WireFormatLite::k##CAMELCASE##Size * \
1682  FromIntSize(repeated_##LOWERCASE##_value->size()); \
1683  break
1684  HANDLE_TYPE(FIXED32, Fixed32, uint32_t);
1685  HANDLE_TYPE(FIXED64, Fixed64, uint64_t);
1686  HANDLE_TYPE(SFIXED32, SFixed32, int32_t);
1687  HANDLE_TYPE(SFIXED64, SFixed64, int64_t);
1688  HANDLE_TYPE(FLOAT, Float, float);
1689  HANDLE_TYPE(DOUBLE, Double, double);
1690  HANDLE_TYPE(BOOL, Bool, bool);
1691 #undef HANDLE_TYPE
1692 
1697  GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
1698  break;
1699  }
1700 
1701  cached_size = ToCachedSize(result);
1702  if (result > 0) {
1706  }
1707  } else {
1708  size_t tag_size = WireFormatLite::TagSize(number, real_type(type));
1709 
1710  switch (real_type(type)) {
1711 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \
1712  case WireFormatLite::TYPE_##UPPERCASE: \
1713  result += tag_size * FromIntSize(repeated_##LOWERCASE##_value->size()); \
1714  for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \
1715  result += WireFormatLite::CAMELCASE##Size( \
1716  repeated_##LOWERCASE##_value->Get(i)); \
1717  } \
1718  break
1719 
1720  HANDLE_TYPE(INT32, Int32, int32_t);
1721  HANDLE_TYPE(INT64, Int64, int64_t);
1722  HANDLE_TYPE(UINT32, UInt32, uint32_t);
1723  HANDLE_TYPE(UINT64, UInt64, uint64_t);
1724  HANDLE_TYPE(SINT32, SInt32, int32_t);
1725  HANDLE_TYPE(SINT64, SInt64, int64_t);
1726  HANDLE_TYPE(STRING, String, string);
1727  HANDLE_TYPE(BYTES, Bytes, string);
1728  HANDLE_TYPE(ENUM, Enum, enum);
1731 #undef HANDLE_TYPE
1732 
1733  // Stuff with fixed size.
1734 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \
1735  case WireFormatLite::TYPE_##UPPERCASE: \
1736  result += (tag_size + WireFormatLite::k##CAMELCASE##Size) * \
1737  FromIntSize(repeated_##LOWERCASE##_value->size()); \
1738  break
1739  HANDLE_TYPE(FIXED32, Fixed32, uint32_t);
1740  HANDLE_TYPE(FIXED64, Fixed64, uint64_t);
1741  HANDLE_TYPE(SFIXED32, SFixed32, int32_t);
1742  HANDLE_TYPE(SFIXED64, SFixed64, int64_t);
1743  HANDLE_TYPE(FLOAT, Float, float);
1744  HANDLE_TYPE(DOUBLE, Double, double);
1745  HANDLE_TYPE(BOOL, Bool, bool);
1746 #undef HANDLE_TYPE
1747  }
1748  }
1749  } else if (!is_cleared) {
1751  switch (real_type(type)) {
1752 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \
1753  case WireFormatLite::TYPE_##UPPERCASE: \
1754  result += WireFormatLite::CAMELCASE##Size(LOWERCASE); \
1755  break
1756 
1757  HANDLE_TYPE(INT32, Int32, int32_t_value);
1758  HANDLE_TYPE(INT64, Int64, int64_t_value);
1759  HANDLE_TYPE(UINT32, UInt32, uint32_t_value);
1760  HANDLE_TYPE(UINT64, UInt64, uint64_t_value);
1761  HANDLE_TYPE(SINT32, SInt32, int32_t_value);
1762  HANDLE_TYPE(SINT64, SInt64, int64_t_value);
1763  HANDLE_TYPE(STRING, String, *string_value);
1764  HANDLE_TYPE(BYTES, Bytes, *string_value);
1765  HANDLE_TYPE(ENUM, Enum, enum_value);
1766  HANDLE_TYPE(GROUP, Group, *message_value);
1767 #undef HANDLE_TYPE
1769  if (is_lazy) {
1770  size_t size = lazymessage_value->ByteSizeLong();
1772  } else {
1773  result += WireFormatLite::MessageSize(*message_value);
1774  }
1775  break;
1776  }
1777 
1778  // Stuff with fixed size.
1779 #define HANDLE_TYPE(UPPERCASE, CAMELCASE) \
1780  case WireFormatLite::TYPE_##UPPERCASE: \
1781  result += WireFormatLite::k##CAMELCASE##Size; \
1782  break
1783  HANDLE_TYPE(FIXED32, Fixed32);
1784  HANDLE_TYPE(FIXED64, Fixed64);
1785  HANDLE_TYPE(SFIXED32, SFixed32);
1786  HANDLE_TYPE(SFIXED64, SFixed64);
1787  HANDLE_TYPE(FLOAT, Float);
1788  HANDLE_TYPE(DOUBLE, Double);
1789  HANDLE_TYPE(BOOL, Bool);
1790 #undef HANDLE_TYPE
1791  }
1792  }
1793 
1794  return result;
1795 }
1796 
1798  GOOGLE_DCHECK(is_repeated);
1799  switch (cpp_type(type)) {
1800 #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
1801  case WireFormatLite::CPPTYPE_##UPPERCASE: \
1802  return repeated_##LOWERCASE##_value->size()
1803 
1804  HANDLE_TYPE(INT32, int32_t);
1805  HANDLE_TYPE(INT64, int64_t);
1806  HANDLE_TYPE(UINT32, uint32_t);
1807  HANDLE_TYPE(UINT64, uint64_t);
1808  HANDLE_TYPE(FLOAT, float);
1809  HANDLE_TYPE(DOUBLE, double);
1810  HANDLE_TYPE(BOOL, bool);
1811  HANDLE_TYPE(ENUM, enum);
1812  HANDLE_TYPE(STRING, string);
1814 #undef HANDLE_TYPE
1815  }
1816 
1817  GOOGLE_LOG(FATAL) << "Can't get here.";
1818  return 0;
1819 }
1820 
1821 // This function deletes all allocated objects. This function should be only
1822 // called if the Extension was created without an arena.
1824  if (is_repeated) {
1825  switch (cpp_type(type)) {
1826 #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
1827  case WireFormatLite::CPPTYPE_##UPPERCASE: \
1828  delete repeated_##LOWERCASE##_value; \
1829  break
1830 
1831  HANDLE_TYPE(INT32, int32_t);
1832  HANDLE_TYPE(INT64, int64_t);
1833  HANDLE_TYPE(UINT32, uint32_t);
1834  HANDLE_TYPE(UINT64, uint64_t);
1835  HANDLE_TYPE(FLOAT, float);
1836  HANDLE_TYPE(DOUBLE, double);
1837  HANDLE_TYPE(BOOL, bool);
1838  HANDLE_TYPE(ENUM, enum);
1839  HANDLE_TYPE(STRING, string);
1841 #undef HANDLE_TYPE
1842  }
1843  } else {
1844  switch (cpp_type(type)) {
1846  delete string_value;
1847  break;
1849  if (is_lazy) {
1850  delete lazymessage_value;
1851  } else {
1852  delete message_value;
1853  }
1854  break;
1855  default:
1856  break;
1857  }
1858  }
1859 }
1860 
1861 // Defined in extension_set_heavy.cc.
1862 // int ExtensionSet::Extension::SpaceUsedExcludingSelf() const
1863 
1866  if (is_repeated) {
1867  for (int i = 0; i < repeated_message_value->size(); i++) {
1868  if (!repeated_message_value->Get(i).IsInitialized()) {
1869  return false;
1870  }
1871  }
1872  } else {
1873  if (!is_cleared) {
1874  if (is_lazy) {
1875  if (!lazymessage_value->IsInitialized()) return false;
1876  } else {
1877  if (!message_value->IsInitialized()) return false;
1878  }
1879  }
1880  }
1881  }
1882  return true;
1883 }
1884 
1885 // Dummy key method to avoid weak vtable.
1887 
1888 const ExtensionSet::Extension* ExtensionSet::FindOrNull(int key) const {
1889  if (flat_size_ == 0) {
1890  return nullptr;
1891  } else if (PROTOBUF_PREDICT_TRUE(!is_large())) {
1892  auto it = std::lower_bound(flat_begin(), flat_end() - 1, key,
1893  KeyValue::FirstComparator());
1894  return it->first == key ? &it->second : nullptr;
1895  } else {
1896  return FindOrNullInLargeMap(key);
1897  }
1898 }
1899 
1900 const ExtensionSet::Extension* ExtensionSet::FindOrNullInLargeMap(
1901  int key) const {
1902  assert(is_large());
1903  LargeMap::const_iterator it = map_.large->find(key);
1904  if (it != map_.large->end()) {
1905  return &it->second;
1906  }
1907  return nullptr;
1908 }
1909 
1910 ExtensionSet::Extension* ExtensionSet::FindOrNull(int key) {
1911  const auto* const_this = this;
1912  return const_cast<ExtensionSet::Extension*>(const_this->FindOrNull(key));
1913 }
1914 
1915 ExtensionSet::Extension* ExtensionSet::FindOrNullInLargeMap(int key) {
1916  const auto* const_this = this;
1917  return const_cast<ExtensionSet::Extension*>(
1918  const_this->FindOrNullInLargeMap(key));
1919 }
1920 
1921 std::pair<ExtensionSet::Extension*, bool> ExtensionSet::Insert(int key) {
1922  if (PROTOBUF_PREDICT_FALSE(is_large())) {
1923  auto maybe = map_.large->insert({key, Extension()});
1924  return {&maybe.first->second, maybe.second};
1925  }
1926  KeyValue* end = flat_end();
1927  KeyValue* it =
1928  std::lower_bound(flat_begin(), end, key, KeyValue::FirstComparator());
1929  if (it != end && it->first == key) {
1930  return {&it->second, false};
1931  }
1932  if (flat_size_ < flat_capacity_) {
1933  std::copy_backward(it, end, end + 1);
1934  ++flat_size_;
1935  it->first = key;
1936  it->second = Extension();
1937  return {&it->second, true};
1938  }
1939  GrowCapacity(flat_size_ + 1);
1940  return Insert(key);
1941 }
1942 
1943 void ExtensionSet::GrowCapacity(size_t minimum_new_capacity) {
1944  if (PROTOBUF_PREDICT_FALSE(is_large())) {
1945  return; // LargeMap does not have a "reserve" method.
1946  }
1947  if (flat_capacity_ >= minimum_new_capacity) {
1948  return;
1949  }
1950 
1951  auto new_flat_capacity = flat_capacity_;
1952  do {
1953  new_flat_capacity = new_flat_capacity == 0 ? 1 : new_flat_capacity * 4;
1954  } while (new_flat_capacity < minimum_new_capacity);
1955 
1956  const KeyValue* begin = flat_begin();
1957  const KeyValue* end = flat_end();
1958  AllocatedData new_map;
1959  if (new_flat_capacity > kMaximumFlatCapacity) {
1960  new_map.large = Arena::Create<LargeMap>(arena_);
1961  LargeMap::iterator hint = new_map.large->begin();
1962  for (const KeyValue* it = begin; it != end; ++it) {
1963  hint = new_map.large->insert(hint, {it->first, it->second});
1964  }
1965  flat_size_ = static_cast<uint16_t>(-1);
1967  } else {
1968  new_map.flat = Arena::CreateArray<KeyValue>(arena_, new_flat_capacity);
1969  std::copy(begin, end, new_map.flat);
1970  }
1971 
1972  if (arena_ == nullptr) {
1974  }
1975  flat_capacity_ = new_flat_capacity;
1976  map_ = new_map;
1977 }
1978 
1979 #if (__cplusplus < 201703) && \
1980  (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
1981 // static
1983 #endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900
1984  // && _MSC_VER < 1912))
1985 
1986 void ExtensionSet::Erase(int key) {
1987  if (PROTOBUF_PREDICT_FALSE(is_large())) {
1988  map_.large->erase(key);
1989  return;
1990  }
1991  KeyValue* end = flat_end();
1992  KeyValue* it =
1993  std::lower_bound(flat_begin(), end, key, KeyValue::FirstComparator());
1994  if (it != end && it->first == key) {
1995  std::copy(it + 1, end, it);
1996  --flat_size_;
1997  }
1998 }
1999 
2000 // ==================================================================
2001 // Default repeated field instances for iterator-compatible accessors
2002 
2003 const RepeatedPrimitiveDefaults* RepeatedPrimitiveDefaults::default_instance() {
2004  static auto instance = OnShutdownDelete(new RepeatedPrimitiveDefaults);
2005  return instance;
2006 }
2007 
2010  static auto instance = OnShutdownDelete(new RepeatedFieldType);
2011  return instance;
2012 }
2013 
2015  const MessageLite* extendee, const ExtensionSet* extension_set, int number,
2017  if (is_repeated) {
2018  if (is_packed) {
2019  if (cached_size == 0) return target;
2020 
2021  target = stream->EnsureSpace(target);
2025 
2026  switch (real_type(type)) {
2027 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \
2028  case WireFormatLite::TYPE_##UPPERCASE: \
2029  for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \
2030  target = stream->EnsureSpace(target); \
2031  target = WireFormatLite::Write##CAMELCASE##NoTagToArray( \
2032  repeated_##LOWERCASE##_value->Get(i), target); \
2033  } \
2034  break
2035 
2036  HANDLE_TYPE(INT32, Int32, int32_t);
2037  HANDLE_TYPE(INT64, Int64, int64_t);
2038  HANDLE_TYPE(UINT32, UInt32, uint32_t);
2039  HANDLE_TYPE(UINT64, UInt64, uint64_t);
2040  HANDLE_TYPE(SINT32, SInt32, int32_t);
2041  HANDLE_TYPE(SINT64, SInt64, int64_t);
2042  HANDLE_TYPE(FIXED32, Fixed32, uint32_t);
2043  HANDLE_TYPE(FIXED64, Fixed64, uint64_t);
2044  HANDLE_TYPE(SFIXED32, SFixed32, int32_t);
2045  HANDLE_TYPE(SFIXED64, SFixed64, int64_t);
2046  HANDLE_TYPE(FLOAT, Float, float);
2047  HANDLE_TYPE(DOUBLE, Double, double);
2048  HANDLE_TYPE(BOOL, Bool, bool);
2049  HANDLE_TYPE(ENUM, Enum, enum);
2050 #undef HANDLE_TYPE
2051 
2056  GOOGLE_LOG(FATAL) << "Non-primitive types can't be packed.";
2057  break;
2058  }
2059  } else {
2060  switch (real_type(type)) {
2061 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \
2062  case WireFormatLite::TYPE_##UPPERCASE: \
2063  for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \
2064  target = stream->EnsureSpace(target); \
2065  target = WireFormatLite::Write##CAMELCASE##ToArray( \
2066  number, repeated_##LOWERCASE##_value->Get(i), target); \
2067  } \
2068  break
2069 
2070  HANDLE_TYPE(INT32, Int32, int32_t);
2071  HANDLE_TYPE(INT64, Int64, int64_t);
2072  HANDLE_TYPE(UINT32, UInt32, uint32_t);
2073  HANDLE_TYPE(UINT64, UInt64, uint64_t);
2074  HANDLE_TYPE(SINT32, SInt32, int32_t);
2075  HANDLE_TYPE(SINT64, SInt64, int64_t);
2076  HANDLE_TYPE(FIXED32, Fixed32, uint32_t);
2077  HANDLE_TYPE(FIXED64, Fixed64, uint64_t);
2078  HANDLE_TYPE(SFIXED32, SFixed32, int32_t);
2079  HANDLE_TYPE(SFIXED64, SFixed64, int64_t);
2080  HANDLE_TYPE(FLOAT, Float, float);
2081  HANDLE_TYPE(DOUBLE, Double, double);
2082  HANDLE_TYPE(BOOL, Bool, bool);
2083  HANDLE_TYPE(ENUM, Enum, enum);
2084 #undef HANDLE_TYPE
2085 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \
2086  case WireFormatLite::TYPE_##UPPERCASE: \
2087  for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \
2088  target = stream->EnsureSpace(target); \
2089  target = stream->WriteString( \
2090  number, repeated_##LOWERCASE##_value->Get(i), target); \
2091  } \
2092  break
2093  HANDLE_TYPE(STRING, String, string);
2094  HANDLE_TYPE(BYTES, Bytes, string);
2095 #undef HANDLE_TYPE
2096 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE) \
2097  case WireFormatLite::TYPE_##UPPERCASE: \
2098  for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) { \
2099  target = stream->EnsureSpace(target); \
2100  target = WireFormatLite::InternalWrite##CAMELCASE( \
2101  number, repeated_##LOWERCASE##_value->Get(i), target, stream); \
2102  } \
2103  break
2104 
2107 #undef HANDLE_TYPE
2108  }
2109  }
2110  } else if (!is_cleared) {
2111  switch (real_type(type)) {
2112 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, VALUE) \
2113  case WireFormatLite::TYPE_##UPPERCASE: \
2114  target = stream->EnsureSpace(target); \
2115  target = WireFormatLite::Write##CAMELCASE##ToArray(number, VALUE, target); \
2116  break
2117 
2118  HANDLE_TYPE(INT32, Int32, int32_t_value);
2119  HANDLE_TYPE(INT64, Int64, int64_t_value);
2120  HANDLE_TYPE(UINT32, UInt32, uint32_t_value);
2121  HANDLE_TYPE(UINT64, UInt64, uint64_t_value);
2122  HANDLE_TYPE(SINT32, SInt32, int32_t_value);
2123  HANDLE_TYPE(SINT64, SInt64, int64_t_value);
2124  HANDLE_TYPE(FIXED32, Fixed32, uint32_t_value);
2125  HANDLE_TYPE(FIXED64, Fixed64, uint64_t_value);
2126  HANDLE_TYPE(SFIXED32, SFixed32, int32_t_value);
2127  HANDLE_TYPE(SFIXED64, SFixed64, int64_t_value);
2128  HANDLE_TYPE(FLOAT, Float, float_value);
2129  HANDLE_TYPE(DOUBLE, Double, double_value);
2130  HANDLE_TYPE(BOOL, Bool, bool_value);
2131  HANDLE_TYPE(ENUM, Enum, enum_value);
2132 #undef HANDLE_TYPE
2133 #define HANDLE_TYPE(UPPERCASE, CAMELCASE, VALUE) \
2134  case WireFormatLite::TYPE_##UPPERCASE: \
2135  target = stream->EnsureSpace(target); \
2136  target = stream->WriteString(number, VALUE, target); \
2137  break
2138  HANDLE_TYPE(STRING, String, *string_value);
2139  HANDLE_TYPE(BYTES, Bytes, *string_value);
2140 #undef HANDLE_TYPE
2142  target = stream->EnsureSpace(target);
2144  target, stream);
2145  break;
2147  if (is_lazy) {
2148  const auto* prototype =
2149  extension_set->GetPrototypeForLazyMessage(extendee, number);
2150  target = lazymessage_value->WriteMessageToArray(prototype, number,
2151  target, stream);
2152  } else {
2153  target = stream->EnsureSpace(target);
2155  target, stream);
2156  }
2157  break;
2158  }
2159  }
2160  return target;
2161 }
2162 
2164  const MessageLite* extendee, int number) const {
2165  GeneratedExtensionFinder finder(extendee);
2166  bool was_packed_on_wire = false;
2167  ExtensionInfo extension_info;
2170  &extension_info, &was_packed_on_wire)) {
2171  return nullptr;
2172  }
2173  return extension_info.message_info.prototype;
2174 }
2175 
2176 uint8_t*
2178  const MessageLite* extendee, const ExtensionSet* extension_set, int number,
2180  if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {
2181  // Not a valid MessageSet extension, but serialize it the normal way.
2182  GOOGLE_LOG(WARNING) << "Invalid message set extension.";
2183  return InternalSerializeFieldWithCachedSizesToArray(extendee, extension_set,
2184  number, target, stream);
2185  }
2186 
2187  if (is_cleared) return target;
2188 
2189  target = stream->EnsureSpace(target);
2190  // Start group.
2193  // Write type ID.
2196  // Write message.
2197  if (is_lazy) {
2198  const auto* prototype =
2199  extension_set->GetPrototypeForLazyMessage(extendee, number);
2200  target = lazymessage_value->WriteMessageToArray(
2202  } else {
2205  stream);
2206  }
2207  // End group.
2208  target = stream->EnsureSpace(target);
2211  return target;
2212 }
2213 
2215  if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {
2216  // Not a valid MessageSet extension, but compute the byte size for it the
2217  // normal way.
2218  return ByteSize(number);
2219  }
2220 
2221  if (is_cleared) return 0;
2222 
2223  size_t our_size = WireFormatLite::kMessageSetItemTagsSize;
2224 
2225  // type_id
2227 
2228  // message
2229  size_t message_size = 0;
2230  if (is_lazy) {
2231  message_size = lazymessage_value->ByteSizeLong();
2232  } else {
2233  message_size = message_value->ByteSizeLong();
2234  }
2235 
2236  our_size += io::CodedOutputStream::VarintSize32(message_size);
2237  our_size += message_size;
2238 
2239  return our_size;
2240 }
2241 
2242 size_t ExtensionSet::MessageSetByteSize() const {
2243  size_t total_size = 0;
2244  ForEach([&total_size](int number, const Extension& ext) {
2245  total_size += ext.MessageSetItemByteSize(number);
2246  });
2247  return total_size;
2248 }
2249 
2250 
2251 } // namespace internal
2252 } // namespace protobuf
2253 } // namespace google
2254 
2255 #include <google/protobuf/port_undef.inc>
google::protobuf.internal::ExtensionInfo::message_info
MessageInfo message_info
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:124
google::protobuf.internal::WireFormatLite::TYPE_MESSAGE
@ TYPE_MESSAGE
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:122
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
google::protobuf.internal::ExtensionSet::Extension::is_repeated
bool is_repeated
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:580
absl::types_internal::function_support::maybe
@ maybe
google::protobuf.internal::ExtensionSet::~ExtensionSet
~ExtensionSet()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:203
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
google::protobuf.internal::ExtensionSet
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:175
google::protobuf.internal::ExtensionSet::DeleteFlatMap
static void DeleteFlatMap(const KeyValue *flat, uint16 flat_capacity)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:215
google::protobuf::RepeatedPtrField< std::string >
google::protobuf.internal::WireFormatLite::ReadGroup
static bool ReadGroup(int field_number, io::CodedInputStream *input, MessageType *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:1262
google::protobuf.internal::WireFormatLite::WireTypeForFieldType
static WireFormatLite::WireType WireTypeForFieldType(WireFormatLite::FieldType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:152
fix_build_deps.temp
temp
Definition: fix_build_deps.py:488
google::protobuf.internal::ExtensionSet::SetAllocatedMessage
void SetAllocatedMessage(int number, FieldType type, const FieldDescriptor *descriptor, MessageLite *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:621
google::protobuf.internal::ExtensionSet::MaybeNewExtension
bool MaybeNewExtension(int number, const FieldDescriptor *descriptor, Extension **result)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1507
google::protobuf.internal::WireFormatLite::ReadBytes
static bool ReadBytes(io::CodedInputStream *input, std::string *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.cc:559
MESSAGE
static const char MESSAGE[]
Definition: test-callback-stack.c:31
google::protobuf.internal::FieldType
uint8 FieldType
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:83
google::protobuf.internal::ExtensionSet::AllocatedData::flat
KeyValue * flat
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:841
regen-readme.it
it
Definition: regen-readme.py:15
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf::EnumValueDescriptor::type
const EnumDescriptor * type() const
google::protobuf.internal::ExtensionSet::_InternalSerializeImpl
uint8_t * _InternalSerializeImpl(const MessageLite *extendee, int start_field_number, int end_field_number, uint8_t *target, io::EpsCopyOutputStream *stream) const
Definition: protobuf/src/google/protobuf/extension_set.cc:1553
google::protobuf.internal::WireFormatLite::TYPE_ENUM
@ TYPE_ENUM
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:125
Bytes
Definition: boringssl-with-bazel/src/crypto/test/test_util.h:38
google::protobuf::FieldDescriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:515
ctx
Definition: benchmark-async.c:30
google::protobuf.internal::RepeatedStringTypeTraits::GetDefaultRepeatedField
static const RepeatedFieldType * GetDefaultRepeatedField()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1923
testing::internal::Int32
TypeWithSize< 4 >::Int Int32
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2159
metadata
Definition: cq_verifier.cc:48
google::protobuf::extension
const Descriptor::ReservedRange const EnumValueDescriptor const MethodDescriptor extension
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2001
google::protobuf.internal::ExtensionSet::Extension::message_value
MessageLite * message_value
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:564
begin
char * begin
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1007
google::protobuf.internal::WireFormatLite::WriteInt32NoTagToArray
static PROTOBUF_ALWAYS_INLINE uint8 * WriteInt32NoTagToArray(int32 value, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:1379
google::protobuf.internal::ExtensionSet::Extension::is_packed
bool is_packed
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:598
Bool
Definition: bloaty/third_party/googletest/googletest/test/gtest_pred_impl_unittest.cc:56
google::protobuf.internal::ExtensionSet::MergeFrom
void MergeFrom(const ExtensionSet &other)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:911
google::protobuf.internal::WireFormatLite::CPPTYPE_INT32
@ CPPTYPE_INT32
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:135
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
google::protobuf.internal::ExtensionSet::Extension::Free
void Free()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1732
google::protobuf.internal::WireFormatLite::WriteUInt32ToArray
static PROTOBUF_ALWAYS_INLINE uint8 * WriteUInt32ToArray(int field_number, uint32 value, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:1541
Group
TypeAndValue Group(UnknownFields nested)
Definition: upb/upb/util/compare_test.cc:101
google::protobuf.internal::ExtensionSet::RemoveLast
void RemoveLast(int number)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:797
google::protobuf.internal::real_type
FieldDescriptor::Type real_type(FieldType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set_heavy.cc:128
google::protobuf.internal::WireFormatLite::TYPE_BYTES
@ TYPE_BYTES
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:123
google::protobuf.internal::WireFormatLite::CPPTYPE_UINT32
@ CPPTYPE_UINT32
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:137
google::protobuf.internal::WireFormatLite::MessageSize
static size_t MessageSize(const MessageType &value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:1780
GOOGLE_DCHECK
#define GOOGLE_DCHECK
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:194
ext
void * ext
Definition: x509v3.h:87
copy
static int copy(grpc_slice_buffer *input, grpc_slice_buffer *output)
Definition: message_compress.cc:145
google::protobuf.internal::ExtensionSet::FindExtensionInfoFromTag
bool FindExtensionInfoFromTag(uint32 tag, ExtensionFinder *extension_finder, int *field_number, ExtensionInfo *extension, bool *was_packed_on_wire)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1150
google::protobuf.internal::UnknownFieldParse
const char * UnknownFieldParse(uint32 tag, std::string *unknown, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:606
google::protobuf.internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED
@ WIRETYPE_LENGTH_DELIMITED
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:104
Arena
Definition: arena.c:39
google::protobuf.internal::ExtensionSet::Extension::ByteSize
size_t ByteSize(int number) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1564
google::protobuf.internal::ExtensionSet::SetRepeatedEnum
void SetRepeatedEnum(int number, int index, int value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:484
GOOGLE_CHECK_EQ
#define GOOGLE_CHECK_EQ(A, B)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:156
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
google::protobuf.internal::ParseContext
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:336
google::protobuf::RepeatedPtrField::Get
const Element & Get(int index) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:2004
google::protobuf.internal::ExtensionSet::FindOrNull
const Extension * FindOrNull(int key) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1797
google::protobuf.internal::WireFormatLite::CPPTYPE_STRING
@ CPPTYPE_STRING
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:143
testing::internal::UInt64
TypeWithSize< 8 >::UInt UInt64
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2162
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf.internal::WireFormatLite::kMessageSetTypeIdNumber
static const int kMessageSetTypeIdNumber
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:213
google::protobuf.internal::FieldSkipper
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:741
instance
RefCountedPtr< grpc_tls_certificate_provider > instance
Definition: xds_server_config_fetcher.cc:224
google::protobuf.internal::ExtensionSet::Extension::IsInitialized
bool IsInitialized() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1773
google::protobuf.internal::RepeatedPrimitiveDefaults::default_instance
static const RepeatedPrimitiveDefaults * default_instance()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1917
google::protobuf.internal::WireFormatLite::CPPTYPE_MESSAGE
@ CPPTYPE_MESSAGE
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:144
google::protobuf.internal::ExtensionSet::ExtensionSize
int ExtensionSize(int number) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:253
google::protobuf.internal::ExtensionSet::UnsafeArenaSetAllocatedMessage
void UnsafeArenaSetAllocatedMessage(int number, FieldType type, const FieldDescriptor *descriptor, MessageLite *message)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:666
google::protobuf.internal::GeneratedExtensionFinder::extendee_
const MessageLite * extendee_
Definition: protobuf/src/google/protobuf/extension_set.h:163
google::protobuf::RepeatedField< int32_t >
google::protobuf::MessageLite
Definition: bloaty/third_party/protobuf/src/google/protobuf/message_lite.h:184
testing::internal::UInt32
TypeWithSize< 4 >::UInt UInt32
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2160
google::protobuf.internal::ExtensionSet::kMaximumFlatCapacity
static constexpr uint16 kMaximumFlatCapacity
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:667
google::protobuf.internal::WireFormatLite::InternalWriteMessage
static PROTOBUF_NDEBUG_INLINE uint8_t * InternalWriteMessage(int field_number, const MessageType &value, uint8_t *target, io::EpsCopyOutputStream *stream)
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
iterator
const typedef MCPhysReg * iterator
Definition: MCRegisterInfo.h:27
google::protobuf.internal::ExtensionSet::Erase
void Erase(int key)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1900
google::protobuf.internal::WireFormatLite::CPPTYPE_ENUM
@ CPPTYPE_ENUM
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:142
google::protobuf.internal::ExtensionSet::ReleaseMessage
MessageLite * ReleaseMessage(int number, const MessageLite &prototype)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:694
google::protobuf::HANDLE_TYPE
HANDLE_TYPE(int32, FieldDescriptor::CPPTYPE_INT32, -1)
google::protobuf.internal::CallNoArgValidityFunc
static bool CallNoArgValidityFunc(const void *arg, int number)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:147
google::protobuf.internal::WireFormatLite::WIRETYPE_FIXED64
@ WIRETYPE_FIXED64
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:103
google::protobuf.internal::WireFormatLite::CppType
CppType
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:134
google::protobuf.internal::WireFormatLite::TYPE_STRING
@ TYPE_STRING
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:120
google::protobuf.internal::ExtensionSet::Swap
void Swap(ExtensionSet *other)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1065
message
char * message
Definition: libuv/docs/code/tty-gravity/main.c:12
google::protobuf.internal::ExtensionSet::HasLazy
bool HasLazy(int number) const
Definition: protobuf/src/google/protobuf/extension_set.cc:250
BOOL
int BOOL
Definition: undname.c:46
Enum
Definition: bloaty/third_party/protobuf/src/google/protobuf/type.pb.h:867
google::protobuf.internal::OnShutdownDelete
T * OnShutdownDelete(T *p)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/common.h:185
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
google::protobuf.internal::ExtensionSet::MutableRawRepeatedField
void * MutableRawRepeatedField(int number, FieldType field_type, bool packed, const FieldDescriptor *desc)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:377
google::protobuf.internal::WireFormatLite::MAX_FIELD_TYPE
@ MAX_FIELD_TYPE
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:130
google::protobuf.internal::ExtensionSet::Extension::lazymessage_value
LazyMessageExtension * lazymessage_value
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:565
google::protobuf.internal::ExtensionSet::ParseMessageSet
const char * ParseMessageSet(const char *ptr, const Msg *containing_type, Metadata *metadata, internal::ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:408
google::protobuf.internal::ExtensionSet::GetArena
Arena * GetArena() const
Definition: protobuf/src/google/protobuf/extension_set.h:302
google::protobuf.internal::WireFormatLite::MakeTag
constexpr static uint32 MakeTag(int field_number, WireType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:783
google::protobuf.internal::ExtensionSet::Insert
std::pair< Extension *, bool > Insert(int key)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1842
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
google::protobuf.internal::ExtensionSet::ExtensionSet
ExtensionSet()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:195
google::protobuf.internal::WireFormatLite::CPPTYPE_BOOL
@ CPPTYPE_BOOL
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:141
google::protobuf.internal::WireFormatLite::kMessageSetItemEndTag
static const int kMessageSetItemEndTag
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:217
grpc::protobuf::io::StringOutputStream
GRPC_CUSTOM_STRINGOUTPUTSTREAM StringOutputStream
Definition: src/compiler/config.h:56
FieldDescriptor
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:133
google::protobuf::io::EpsCopyOutputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:651
GOOGLE_DCHECK_TYPE
#define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE)
Definition: protobuf/src/google/protobuf/extension_set.cc:296
google::protobuf.internal::ExtensionSet::Extension::is_lazy
bool is_lazy
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:595
google::protobuf.internal::GeneratedExtensionFinder
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:145
google::protobuf.internal::ExtensionSet::GrowCapacity
void GrowCapacity(size_t minimum_new_capacity)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1864
google::protobuf.internal::ExtensionSet::GetPrototypeForLazyMessage
const MessageLite * GetPrototypeForLazyMessage(const MessageLite *extendee, int number) const
Definition: protobuf/src/google/protobuf/extension_set.cc:2163
google::protobuf.internal::WireFormatLite::InternalWriteGroup
static PROTOBUF_NDEBUG_INLINE uint8_t * InternalWriteGroup(int field_number, const MessageType &value, uint8_t *target, io::EpsCopyOutputStream *stream)
arena_
Arena * arena_
Definition: client_channel.cc:391
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
google::protobuf.internal::WireFormatLite::TYPE_GROUP
@ TYPE_GROUP
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:121
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
swap
#define swap(a, b)
Definition: qsort.h:111
google::protobuf.internal::WireFormatLite::FieldTypeToCppType
static CppType FieldTypeToCppType(FieldType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:778
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
google::protobuf.internal::WireFormatLite::WIRETYPE_FIXED32
@ WIRETYPE_FIXED32
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:107
google::protobuf.internal::ExtensionSet::Extension::repeated_message_value
RepeatedPtrField< MessageLite > * repeated_message_value
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:576
google::protobuf.internal::ExtensionSet::RegisterEnumExtension
static void RegisterEnumExtension(const MessageLite *containing_type, int number, FieldType type, bool is_repeated, bool is_packed, EnumValidityFunc *is_valid)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:160
google::protobuf.internal::field_type
WireFormatLite::FieldType field_type(FieldType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set_heavy.cc:138
google::protobuf.internal::ExtensionSet::MutableRepeatedString
std::string * MutableRepeatedString(int number, int index)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:546
google::protobuf.internal::ExtensionSet::Extension::type
FieldType type
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:579
google::protobuf.internal::ExtensionSet::MutableMessage
MessageLite * MutableMessage(int number, FieldType type, const MessageLite &prototype, desc)
google::protobuf.internal::ExtensionSet::arena_
Arena * arena_
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:833
google::protobuf.internal::ExtensionSet::Extension::Clear
void Clear()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1519
google::protobuf.internal::ExtensionSet::GetRefRepeatedEnum
const int & GetRefRepeatedEnum(int number, int index) const
Definition: protobuf/src/google/protobuf/extension_set.cc:526
google::protobuf.internal::ExtensionSet::ForEach
static KeyValueFunctor ForEach(Iterator begin, Iterator end, KeyValueFunctor func)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:681
grpc::protobuf::MessageLite
GRPC_CUSTOM_MESSAGELITE MessageLite
Definition: include/grpcpp/impl/codegen/config_protobuf.h:79
testing::internal::Float
FloatingPoint< float > Float
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:396
google::protobuf.internal::ExtensionSet::KeyValue
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:630
google::protobuf.internal::ExtensionSet::SetString
void SetString(int number, FieldType type, std::string value, desc)
google::protobuf.internal::ExtensionSet::UnsafeShallowSwapExtension
void UnsafeShallowSwapExtension(ExtensionSet *other, int number)
Definition: protobuf/src/google/protobuf/extension_set.cc:1201
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
google::protobuf.internal::WireFormatLite::ReadString
static bool ReadString(io::CodedInputStream *input, std::string *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:893
google::protobuf.internal::WireFormatLite::CPPTYPE_FLOAT
@ CPPTYPE_FLOAT
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:140
google::protobuf.internal::ParseMessageSetItemImpl
bool ParseMessageSetItemImpl(io::CodedInputStream *input, MS ms)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:1808
google::protobuf.internal::ExtensionInfo
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:101
google::protobuf.internal::WireFormatLite::ReadMessage
static bool ReadMessage(io::CodedInputStream *input, MessageType *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:1275
grpc::protobuf::io::CodedInputStream
GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:102
google::protobuf::io::CodedOutputStream::VarintSize32
static size_t VarintSize32(uint32 value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1654
google::protobuf.internal::ExtensionSet::LazyMessageExtension::New
virtual LazyMessageExtension * New(Arena *arena) const =0
google::protobuf.internal::InternalMetadata
Definition: protobuf/src/google/protobuf/metadata_lite.h:62
arg
Definition: cmdline.cc:40
google::protobuf::io::CodedOutputStream::WriteTagToArray
static PROTOBUF_ALWAYS_INLINE uint8 * WriteTagToArray(uint32 value, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1650
number
int32_t number
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
google::protobuf.internal::ExtensionSet::KeyValue::FirstComparator
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:634
google::protobuf.internal::ExtensionSet::Extension::MessageSetItemByteSize
size_t MessageSetItemByteSize(int number) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:2108
google::protobuf.internal::ExtensionSet::GetRepeatedEnum
int GetRepeatedEnum(int number, int index) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:477
std::swap
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:1226
google::protobuf.internal::FieldSkipper::SkipUnknownEnum
virtual void SkipUnknownEnum(int field_number, int value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.cc:276
google::protobuf::WARNING
static const LogLevel WARNING
Definition: bloaty/third_party/protobuf/src/google/protobuf/testing/googletest.h:71
google::protobuf.internal::WireFormatLite::kMessageSetItemStartTag
static const int kMessageSetItemStartTag
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:215
google::protobuf.internal::WireFormatLite::FieldType
FieldType
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:111
google::protobuf.internal.wire_format.WIRETYPE_LENGTH_DELIMITED
int WIRETYPE_LENGTH_DELIMITED
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/wire_format.py:49
google::protobuf.internal::ExtensionSet::RegisterExtension
static void RegisterExtension(const MessageLite *containing_type, int number, FieldType type, bool is_repeated, bool is_packed)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:137
google::protobuf.internal::WireFormatLite::CPPTYPE_INT64
@ CPPTYPE_INT64
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:136
grpc::protobuf::io::CodedOutputStream
GRPC_CUSTOM_CODEDOUTPUTSTREAM CodedOutputStream
Definition: src/compiler/config.h:55
google::protobuf.internal::WireFormatLite::WIRETYPE_VARINT
@ WIRETYPE_VARINT
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:102
google::protobuf.internal::ExtensionSet::GetEnum
int GetEnum(int number, int default_value) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:452
google::protobuf.internal::ExtensionSet::InternalExtensionMergeFrom
void InternalExtensionMergeFrom(int number, const Extension &other_extension)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:927
google::protobuf.internal::ExtensionSet::LazyMessageExtension::GetMessage
virtual const MessageLite & GetMessage(const MessageLite &prototype) const =0
Fixed64
TypeAndValue Fixed64(uint64_t val)
Definition: upb/upb/util/compare_test.cc:83
google::protobuf.internal::ExtensionSet::IsInitialized
bool IsInitialized() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1135
google::protobuf.internal::ExtensionSet::ClearExtension
void ClearExtension(int number)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:270
google::protobuf.internal::ExtensionSet::GetRepeatedMessage
const MessageLite & GetRepeatedMessage(int number, int index) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:749
google::protobuf.internal::ExtensionSet::ParseMessageSetLite
bool ParseMessageSetLite(io::CodedInputStream *input, ExtensionFinder *extension_finder, FieldSkipper *field_skipper)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1410
google::protobuf.internal::ExtensionSet::GetString
const std::string & GetString(int number, const std::string &default_value) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:511
google::protobuf.internal::ExtensionSet::is_large
bool is_large() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:668
google::protobuf.internal::ExtensionFinder
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:135
google::protobuf.internal::WireFormatLite::GetTagFieldNumber
static int GetTagFieldNumber(uint32 tag)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:792
value
const char * value
Definition: hpack_parser_table.cc:165
google::protobuf::RepeatedPtrField::size
int size() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1999
google::protobuf.internal::ExtensionSet::UnsafeArenaReleaseLast
MessageLite * UnsafeArenaReleaseLast(int number)
Definition: protobuf/src/google/protobuf/extension_set.cc:897
google::protobuf.internal::ExtensionSet::InternalSerializeMessageSetWithCachedSizesToArray
uint8 * InternalSerializeMessageSetWithCachedSizesToArray(uint8 *target, io::EpsCopyOutputStream *stream) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1487
FATAL
#define FATAL(msg)
Definition: task.h:88
google::protobuf.internal::ExtensionSet::Has
bool Has(int number) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:236
google::protobuf.internal::WireFormatLite::GetTagWireType
static WireType GetTagWireType(uint32 tag)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:788
google::protobuf.internal::WireFormatLite::kMessageSetMessageNumber
static const int kMessageSetMessageNumber
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:214
google::protobuf::Message
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.h:205
google::protobuf.internal::ExtensionSet::Extension::string_value
std::string * string_value
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:563
key
const char * key
Definition: hpack_parser_table.cc:164
google::protobuf.internal::WireFormatLite::WIRETYPE_START_GROUP
@ WIRETYPE_START_GROUP
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:105
google::protobuf.internal::ExtensionSet::Extension::descriptor
const FieldDescriptor * descriptor
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:608
google::protobuf.internal::ExtensionSet::GetRefEnum
const int & GetRefEnum(int number, const int &default_value) const
Definition: protobuf/src/google/protobuf/extension_set.cc:493
google::protobuf.internal::ExtensionFinder::~ExtensionFinder
virtual ~ExtensionFinder()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:124
google::protobuf.internal::ExtensionSet::SwapElements
void SwapElements(int number, int index1, int index2)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:844
google::protobuf.internal::WireFormatLite::TagSize
static size_t TagSize(int field_number, WireFormatLite::FieldType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:796
google::protobuf.internal::ExtensionSet::flat_capacity_
uint16 flat_capacity_
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:838
google::protobuf.internal::ToCachedSize
int ToCachedSize(size_t size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/message_lite.h:90
google::protobuf.internal::ExtensionSet::AllocatedData::large
LargeMap * large
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:845
google::protobuf.internal.decoder.SkipField
def SkipField
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/decoder.py:1036
google::protobuf.internal::ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray
uint8 * InternalSerializeFieldWithCachedSizesToArray(int number, uint8 *target, io::EpsCopyOutputStream *stream) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1928
google::protobuf.internal::FieldSkipper::SkipField
virtual bool SkipField(io::CodedInputStream *input, uint32 tag)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.cc:268
google::protobuf.internal::ExtensionSet::Clear
void Clear()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:885
google::protobuf.internal::ExtensionSet::GetRawRepeatedField
const void * GetRawRepeatedField(int number, const void *default_value) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:366
google::protobuf.internal::ExtensionSet::SwapExtension
void SwapExtension(ExtensionSet *other, int number)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1084
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
google::protobuf.internal::ExtensionFinder::Find
virtual bool Find(int number, ExtensionInfo *output)=0
google::protobuf.internal::ExtensionSet::NumExtensions
int NumExtensions() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:243
google::protobuf.internal::ExtensionSet::Extension::GetSize
int GetSize() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1706
google::protobuf.internal::ExtensionSet::map_
union google::protobuf::internal::ExtensionSet::AllocatedData map_
PRIMITIVE_ACCESSORS
#define PRIMITIVE_ACCESSORS(UPPERCASE, LOWERCASE, CAMELCASE)
Definition: protobuf/src/google/protobuf/extension_set.cc:303
google::protobuf.internal::ExtensionSet::ParseFieldWithExtensionInfo
bool ParseFieldWithExtensionInfo(int field_number, bool was_packed_on_wire, const ExtensionInfo &extension, io::CodedInputStream *input, FieldSkipper *field_skipper)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1222
google::protobuf.internal::ExtensionSet::GetRepeatedString
const std::string & GetRepeatedString(int number, int index) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:538
google::protobuf.internal::EnumValidityFunc
bool EnumValidityFunc(int number)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:94
testing::internal::Double
FloatingPoint< double > Double
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:397
google::protobuf::io::CodedInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:180
google::protobuf.internal::ExtensionSet::LazyMessageExtension::UnusedKeyMethod
virtual void UnusedKeyMethod()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1795
google::protobuf.internal::ExtensionSet::Extension::is_cleared
bool is_cleared
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:588
google::protobuf.internal::ExtensionSet::GetMessage
const MessageLite & GetMessage(int number, const MessageLite &default_value) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:572
google::protobuf.internal::ExtensionSet::InternalSwap
void InternalSwap(ExtensionSet *other)
Definition: protobuf/src/google/protobuf/extension_set.cc:1151
GOOGLE_CHECK
#define GOOGLE_CHECK(EXPRESSION)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:153
google::protobuf.internal::ExtensionSet::RegisterMessageExtension
static void RegisterMessageExtension(const MessageLite *containing_type, int number, FieldType type, bool is_repeated, bool is_packed, const MessageLite *prototype)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:172
desc
#define desc
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:338
google::protobuf.internal::RepeatedStringTypeTraits::RepeatedFieldType
RepeatedPtrField< std::string > RepeatedFieldType
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:1086
make_dist_html.GROUP
string GROUP
Definition: make_dist_html.py:52
GOOGLE_DCHECK_EQ
#define GOOGLE_DCHECK_EQ
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:196
google::protobuf.internal::WireFormatLite::WireType
WireType
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:101
google::protobuf.internal::RepeatedPtrFieldBase
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:451
input
std::string input
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc:197
google::protobuf.internal::ExtensionInfo::MessageInfo::prototype
const MessageLite * prototype
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:119
google::protobuf.internal::GeneratedExtensionFinder::Find
bool Find(int number, ExtensionInfo *output) override
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:126
google::protobuf.internal::ExtensionSet::MutableString
std::string * MutableString(int number, FieldType type, desc)
google::protobuf.internal::ExtensionSet::ExtensionType
FieldType ExtensionType(int number) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:258
google::protobuf.internal::ExtensionSet::UnsafeArenaReleaseMessage
MessageLite * UnsafeArenaReleaseMessage(int number, const MessageLite &prototype)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:723
google::protobuf.internal::WireFormatLite::WIRETYPE_END_GROUP
@ WIRETYPE_END_GROUP
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:106
google::protobuf.internal::ExtensionSet::ReleaseLast
MessageLite * ReleaseLast(int number)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:836
internal
Definition: benchmark/test/output_test_helper.cc:20
GOOGLE_CHECK_NE
#define GOOGLE_CHECK_NE(A, B)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:157
google::protobuf.internal::ExtensionSet::FindExtensionInfoFromFieldNumber
bool FindExtensionInfoFromFieldNumber(int wire_type, int field_number, ExtensionFinder *extension_finder, ExtensionInfo *extension, bool *was_packed_on_wire)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1162
google::protobuf.internal::ExtensionSet::flat_begin
KeyValue * flat_begin()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:816
google::protobuf::io::CodedInputStream::Limit
int Limit
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:348
testing::internal::Int64
TypeWithSize< 8 >::Int Int64
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2161
google::protobuf.internal::ExtensionSet::ParseMessageSetItemLite
bool ParseMessageSetItemLite(io::CodedInputStream *input, ExtensionFinder *extension_finder, FieldSkipper *field_skipper)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1432
google::protobuf.internal::WireFormatLite::WriteTagToArray
static PROTOBUF_ALWAYS_INLINE uint8 * WriteTagToArray(int field_number, WireType type, uint8 *target)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:1373
google::protobuf.internal::GenericTypeHandler
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/arena.h:93
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
google::protobuf.internal::WireFormatLite::CPPTYPE_UINT64
@ CPPTYPE_UINT64
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:138
google::protobuf.internal::ExtensionSet::AddMessage
MessageLite * AddMessage(int number, FieldType type, const MessageLite &prototype, desc)
Fixed32
TypeAndValue Fixed32(uint32_t val)
Definition: upb/upb/util/compare_test.cc:89
google::protobuf.internal::ExtensionSet::Extension
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:551
google::protobuf.internal::ExtensionSet::AddEnum
void AddEnum(int number, FieldType type, bool packed, int value, desc)
google::protobuf.internal::ExtensionSet::ByteSize
size_t ByteSize() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1496
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
google::protobuf.internal::ExtensionSet::flat_size_
uint16 flat_size_
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:839
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:146
google::protobuf.internal::ExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray
uint8 * InternalSerializeMessageSetItemWithCachedSizesToArray(int number, uint8 *target, io::EpsCopyOutputStream *stream) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:2075
google::protobuf.internal::WireFormatLite::CPPTYPE_DOUBLE
@ CPPTYPE_DOUBLE
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:139
google::protobuf.internal::ExtensionSet::AddString
void AddString(int number, FieldType type, std::string value, desc)
google::protobuf.internal::ExtensionSet::MessageSetByteSize
size_t MessageSetByteSize() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:2136
google::protobuf.internal::ExtensionSet::FindOrNullInLargeMap
const Extension * FindOrNullInLargeMap(int key) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1810
descriptor
static const char descriptor[1336]
Definition: certs.upbdefs.c:16
google::protobuf.internal::ExtensionSet::SetEnum
void SetEnum(int number, FieldType type, int value, desc)
setup.target
target
Definition: third_party/bloaty/third_party/protobuf/python/setup.py:179
google::protobuf::InsertIfNotPresent
bool InsertIfNotPresent(Collection *const collection, const typename Collection::value_type &vt)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/map_util.h:321
google::protobuf.internal::WireFormatLite::kMessageSetItemTagsSize
static const size_t kMessageSetItemTagsSize
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:225
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
Message
Definition: protobuf/php/ext/google/protobuf/message.c:53
google::protobuf.internal::ExtensionSet::MutableRepeatedMessage
MessageLite * MutableRepeatedMessage(int number, int index)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:757
google::protobuf.internal::ExtensionSet::ParseMessageSetItem
bool ParseMessageSetItem(io::CodedInputStream *input, ExtensionFinder *extension_finder, MessageSetFieldSkipper *field_skipper)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set_heavy.cc:511
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
google::protobuf.internal::ExtensionSet::ParseField
bool ParseField(uint32 tag, io::CodedInputStream *input, ExtensionFinder *extension_finder, FieldSkipper *field_skipper)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.cc:1184
google::protobuf.internal::cpp_type
FieldDescriptor::CppType cpp_type(FieldType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set_heavy.cc:133
google::protobuf::MessageLite::New
virtual MessageLite * New() const =0
google::protobuf.internal::ExtensionSet::flat_end
KeyValue * flat_end()
Definition: bloaty/third_party/protobuf/src/google/protobuf/extension_set.h:824
stream
voidpf stream
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:21