generated_message_reflection.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 <algorithm>
36 #include <set>
37 
51 
52 
53 #include <google/protobuf/port_def.inc>
54 
55 #define GOOGLE_PROTOBUF_HAS_ONEOF
56 
64 using google::protobuf::internal::LazyField;
71 using google::protobuf::internal::WrappedMutex;
72 
73 namespace google {
74 namespace protobuf {
75 
76 namespace {
77 bool IsMapFieldInApi(const FieldDescriptor* field) { return field->is_map(); }
78 } // anonymous namespace
79 
80 namespace internal {
81 
83  int* value) {
84  const EnumValueDescriptor* d = descriptor->FindValueByName(name);
85  if (d == nullptr) return false;
86  *value = d->number();
87  return true;
88 }
89 
91  const EnumValueDescriptor* d = descriptor->FindValueByNumber(value);
92  return (d == nullptr ? GetEmptyString() : d->name());
93 }
94 
95 } // namespace internal
96 
97 // ===================================================================
98 // Helpers for reporting usage errors (e.g. trying to use GetInt32() on
99 // a string field).
100 
101 namespace {
102 
103 template <class To>
104 To* GetPointerAtOffset(Message* message, uint32 offset) {
105  return reinterpret_cast<To*>(reinterpret_cast<char*>(message) + offset);
106 }
107 
108 template <class To>
109 const To* GetConstPointerAtOffset(const Message* message, uint32 offset) {
110  return reinterpret_cast<const To*>(reinterpret_cast<const char*>(message) +
111  offset);
112 }
113 
114 template <class To>
115 const To& GetConstRefAtOffset(const Message& message, uint32 offset) {
116  return *GetConstPointerAtOffset<To>(&message, offset);
117 }
118 
119 void ReportReflectionUsageError(const Descriptor* descriptor,
120  const FieldDescriptor* field,
121  const char* method, const char* description) {
122  GOOGLE_LOG(FATAL) << "Protocol Buffer reflection usage error:\n"
123  " Method : google::protobuf::Reflection::"
124  << method
125  << "\n"
126  " Message type: "
127  << descriptor->full_name()
128  << "\n"
129  " Field : "
130  << field->full_name()
131  << "\n"
132  " Problem : "
133  << description;
134 }
135 
136 const char* cpptype_names_[FieldDescriptor::MAX_CPPTYPE + 1] = {
137  "INVALID_CPPTYPE", "CPPTYPE_INT32", "CPPTYPE_INT64", "CPPTYPE_UINT32",
138  "CPPTYPE_UINT64", "CPPTYPE_DOUBLE", "CPPTYPE_FLOAT", "CPPTYPE_BOOL",
139  "CPPTYPE_ENUM", "CPPTYPE_STRING", "CPPTYPE_MESSAGE"};
140 
141 static void ReportReflectionUsageTypeError(
143  const char* method, FieldDescriptor::CppType expected_type) {
145  << "Protocol Buffer reflection usage error:\n"
146  " Method : google::protobuf::Reflection::"
147  << method
148  << "\n"
149  " Message type: "
150  << descriptor->full_name()
151  << "\n"
152  " Field : "
153  << field->full_name()
154  << "\n"
155  " Problem : Field is not the right type for this message:\n"
156  " Expected : "
157  << cpptype_names_[expected_type]
158  << "\n"
159  " Field type: "
160  << cpptype_names_[field->cpp_type()];
161 }
162 
163 static void ReportReflectionUsageEnumTypeError(
165  const char* method, const EnumValueDescriptor* value) {
166  GOOGLE_LOG(FATAL) << "Protocol Buffer reflection usage error:\n"
167  " Method : google::protobuf::Reflection::"
168  << method
169  << "\n"
170  " Message type: "
171  << descriptor->full_name()
172  << "\n"
173  " Field : "
174  << field->full_name()
175  << "\n"
176  " Problem : Enum value did not match field type:\n"
177  " Expected : "
178  << field->enum_type()->full_name()
179  << "\n"
180  " Actual : "
181  << value->full_name();
182 }
183 
184 #define USAGE_CHECK(CONDITION, METHOD, ERROR_DESCRIPTION) \
185  if (!(CONDITION)) \
186  ReportReflectionUsageError(descriptor_, field, #METHOD, ERROR_DESCRIPTION)
187 #define USAGE_CHECK_EQ(A, B, METHOD, ERROR_DESCRIPTION) \
188  USAGE_CHECK((A) == (B), METHOD, ERROR_DESCRIPTION)
189 #define USAGE_CHECK_NE(A, B, METHOD, ERROR_DESCRIPTION) \
190  USAGE_CHECK((A) != (B), METHOD, ERROR_DESCRIPTION)
191 
192 #define USAGE_CHECK_TYPE(METHOD, CPPTYPE) \
193  if (field->cpp_type() != FieldDescriptor::CPPTYPE_##CPPTYPE) \
194  ReportReflectionUsageTypeError(descriptor_, field, #METHOD, \
195  FieldDescriptor::CPPTYPE_##CPPTYPE)
196 
197 #define USAGE_CHECK_ENUM_VALUE(METHOD) \
198  if (value->type() != field->enum_type()) \
199  ReportReflectionUsageEnumTypeError(descriptor_, field, #METHOD, value)
200 
201 #define USAGE_CHECK_MESSAGE_TYPE(METHOD) \
202  USAGE_CHECK_EQ(field->containing_type(), descriptor_, METHOD, \
203  "Field does not match message type.");
204 #define USAGE_CHECK_SINGULAR(METHOD) \
205  USAGE_CHECK_NE(field->label(), FieldDescriptor::LABEL_REPEATED, METHOD, \
206  "Field is repeated; the method requires a singular field.")
207 #define USAGE_CHECK_REPEATED(METHOD) \
208  USAGE_CHECK_EQ(field->label(), FieldDescriptor::LABEL_REPEATED, METHOD, \
209  "Field is singular; the method requires a repeated field.")
210 
211 #define USAGE_CHECK_ALL(METHOD, LABEL, CPPTYPE) \
212  USAGE_CHECK_MESSAGE_TYPE(METHOD); \
213  USAGE_CHECK_##LABEL(METHOD); \
214  USAGE_CHECK_TYPE(METHOD, CPPTYPE)
215 
216 } // namespace
217 
218 // ===================================================================
219 
221  const internal::ReflectionSchema& schema,
222  const DescriptorPool* pool, MessageFactory* factory)
224  schema_(schema),
225  descriptor_pool_(
226  (pool == nullptr) ? DescriptorPool::internal_generated_pool() : pool),
227  message_factory_(factory),
228  last_non_weak_field_index_(-1) {
230 }
231 
233  const Message& message) const {
235 }
236 
239 }
240 
242  // object_size_ already includes the in-memory representation of each field
243  // in the message, so we only need to account for additional memory used by
244  // the fields.
245  size_t total_size = schema_.GetObjectSize();
246 
248 
249  if (schema_.HasExtensionSet()) {
251  }
252  for (int i = 0; i <= last_non_weak_field_index_; i++) {
254  if (field->is_repeated()) {
255  switch (field->cpp_type()) {
256 #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
257  case FieldDescriptor::CPPTYPE_##UPPERCASE: \
258  total_size += GetRaw<RepeatedField<LOWERCASE> >(message, field) \
259  .SpaceUsedExcludingSelfLong(); \
260  break
261 
262  HANDLE_TYPE(INT32, int32);
263  HANDLE_TYPE(INT64, int64);
264  HANDLE_TYPE(UINT32, uint32);
265  HANDLE_TYPE(UINT64, uint64);
266  HANDLE_TYPE(DOUBLE, double);
267  HANDLE_TYPE(FLOAT, float);
268  HANDLE_TYPE(BOOL, bool);
269  HANDLE_TYPE(ENUM, int);
270 #undef HANDLE_TYPE
271 
273  switch (field->options().ctype()) {
274  default: // TODO(kenton): Support other string reps.
276  total_size +=
277  GetRaw<RepeatedPtrField<std::string> >(message, field)
278  .SpaceUsedExcludingSelfLong();
279  break;
280  }
281  break;
282 
284  if (IsMapFieldInApi(field)) {
285  total_size += GetRaw<internal::MapFieldBase>(message, field)
286  .SpaceUsedExcludingSelfLong();
287  } else {
288  // We don't know which subclass of RepeatedPtrFieldBase the type is,
289  // so we use RepeatedPtrFieldBase directly.
290  total_size +=
291  GetRaw<RepeatedPtrFieldBase>(message, field)
292  .SpaceUsedExcludingSelfLong<GenericTypeHandler<Message> >();
293  }
294 
295  break;
296  }
297  } else {
298  if (field->containing_oneof() && !HasOneofField(message, field)) {
299  continue;
300  }
301  switch (field->cpp_type()) {
310  // Field is inline, so we've already counted it.
311  break;
312 
314  switch (field->options().ctype()) {
315  default: // TODO(kenton): Support other string reps.
316  case FieldOptions::STRING: {
317  if (IsInlined(field)) {
318  const std::string* ptr =
319  &GetField<InlinedStringField>(message, field).GetNoArena();
320  total_size += StringSpaceUsedExcludingSelfLong(*ptr);
321  break;
322  }
323 
324  // Initially, the string points to the default value stored
325  // in the prototype. Only count the string if it has been
326  // changed from the default value.
327  const std::string* default_ptr =
328  &DefaultRaw<ArenaStringPtr>(field).Get();
329  const std::string* ptr =
330  &GetField<ArenaStringPtr>(message, field).Get();
331 
332  if (ptr != default_ptr) {
333  // string fields are represented by just a pointer, so also
334  // include sizeof(string) as well.
335  total_size +=
336  sizeof(*ptr) + StringSpaceUsedExcludingSelfLong(*ptr);
337  }
338  break;
339  }
340  }
341  break;
342  }
343 
346  // For singular fields, the prototype just stores a pointer to the
347  // external type's prototype, so there is no extra memory usage.
348  } else {
349  const Message* sub_message = GetRaw<const Message*>(message, field);
350  if (sub_message != nullptr) {
351  total_size += sub_message->SpaceUsedLong();
352  }
353  }
354  break;
355  }
356  }
357  }
358  return total_size;
359 }
360 
361 void Reflection::SwapField(Message* message1, Message* message2,
362  const FieldDescriptor* field) const {
363  if (field->is_repeated()) {
364  switch (field->cpp_type()) {
365 #define SWAP_ARRAYS(CPPTYPE, TYPE) \
366  case FieldDescriptor::CPPTYPE_##CPPTYPE: \
367  MutableRaw<RepeatedField<TYPE> >(message1, field) \
368  ->Swap(MutableRaw<RepeatedField<TYPE> >(message2, field)); \
369  break;
370 
371  SWAP_ARRAYS(INT32, int32);
372  SWAP_ARRAYS(INT64, int64);
373  SWAP_ARRAYS(UINT32, uint32);
374  SWAP_ARRAYS(UINT64, uint64);
375  SWAP_ARRAYS(FLOAT, float);
376  SWAP_ARRAYS(DOUBLE, double);
377  SWAP_ARRAYS(BOOL, bool);
378  SWAP_ARRAYS(ENUM, int);
379 #undef SWAP_ARRAYS
380 
382  switch (field->options().ctype()) {
383  default: // TODO(kenton): Support other string reps.
385  MutableRaw<RepeatedPtrFieldBase>(message1, field)
387  MutableRaw<RepeatedPtrFieldBase>(message2, field));
388  break;
389  }
390  break;
392  if (IsMapFieldInApi(field)) {
393  MutableRaw<MapFieldBase>(message1, field)
394  ->Swap(MutableRaw<MapFieldBase>(message2, field));
395  } else {
396  MutableRaw<RepeatedPtrFieldBase>(message1, field)
398  MutableRaw<RepeatedPtrFieldBase>(message2, field));
399  }
400  break;
401 
402  default:
403  GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
404  }
405  } else {
406  switch (field->cpp_type()) {
407 #define SWAP_VALUES(CPPTYPE, TYPE) \
408  case FieldDescriptor::CPPTYPE_##CPPTYPE: \
409  std::swap(*MutableRaw<TYPE>(message1, field), \
410  *MutableRaw<TYPE>(message2, field)); \
411  break;
412 
413  SWAP_VALUES(INT32, int32);
414  SWAP_VALUES(INT64, int64);
415  SWAP_VALUES(UINT32, uint32);
416  SWAP_VALUES(UINT64, uint64);
417  SWAP_VALUES(FLOAT, float);
418  SWAP_VALUES(DOUBLE, double);
419  SWAP_VALUES(BOOL, bool);
420  SWAP_VALUES(ENUM, int);
421 #undef SWAP_VALUES
423  if (GetArena(message1) == GetArena(message2)) {
424  std::swap(*MutableRaw<Message*>(message1, field),
425  *MutableRaw<Message*>(message2, field));
426  } else {
427  Message** sub_msg1 = MutableRaw<Message*>(message1, field);
428  Message** sub_msg2 = MutableRaw<Message*>(message2, field);
429  if (*sub_msg1 == nullptr && *sub_msg2 == nullptr) break;
430  if (*sub_msg1 && *sub_msg2) {
431  (*sub_msg1)->GetReflection()->Swap(*sub_msg1, *sub_msg2);
432  break;
433  }
434  if (*sub_msg1 == nullptr) {
435  *sub_msg1 = (*sub_msg2)->New(message1->GetArena());
436  (*sub_msg1)->CopyFrom(**sub_msg2);
437  ClearField(message2, field);
438  } else {
439  *sub_msg2 = (*sub_msg1)->New(message2->GetArena());
440  (*sub_msg2)->CopyFrom(**sub_msg1);
441  ClearField(message1, field);
442  }
443  }
444  break;
445 
447  switch (field->options().ctype()) {
448  default: // TODO(kenton): Support other string reps.
449  case FieldOptions::STRING: {
450  Arena* arena1 = GetArena(message1);
451  Arena* arena2 = GetArena(message2);
452 
453  if (IsInlined(field)) {
454  InlinedStringField* string1 =
455  MutableRaw<InlinedStringField>(message1, field);
456  InlinedStringField* string2 =
457  MutableRaw<InlinedStringField>(message2, field);
458  string1->Swap(string2);
459  break;
460  }
461 
462  ArenaStringPtr* string1 =
463  MutableRaw<ArenaStringPtr>(message1, field);
464  ArenaStringPtr* string2 =
465  MutableRaw<ArenaStringPtr>(message2, field);
466  const std::string* default_ptr =
467  &DefaultRaw<ArenaStringPtr>(field).Get();
468  if (arena1 == arena2) {
469  string1->Swap(string2, default_ptr, arena1);
470  } else {
471  const std::string temp = string1->Get();
472  string1->Set(default_ptr, string2->Get(), arena1);
473  string2->Set(default_ptr, temp, arena2);
474  }
475  } break;
476  }
477  break;
478 
479  default:
480  GOOGLE_LOG(FATAL) << "Unimplemented type: " << field->cpp_type();
481  }
482  }
483 }
484 
485 void Reflection::SwapOneofField(Message* message1, Message* message2,
486  const OneofDescriptor* oneof_descriptor) const {
487  uint32 oneof_case1 = GetOneofCase(*message1, oneof_descriptor);
488  uint32 oneof_case2 = GetOneofCase(*message2, oneof_descriptor);
489 
490  int32 temp_int32;
491  int64 temp_int64;
492  uint32 temp_uint32;
493  uint64 temp_uint64;
494  float temp_float;
495  double temp_double;
496  bool temp_bool;
497  int temp_int;
498  Message* temp_message = nullptr;
499  std::string temp_string;
500 
501  // Stores message1's oneof field to a temp variable.
502  const FieldDescriptor* field1 = nullptr;
503  if (oneof_case1 > 0) {
504  field1 = descriptor_->FindFieldByNumber(oneof_case1);
505  // oneof_descriptor->field(oneof_case1);
506  switch (field1->cpp_type()) {
507 #define GET_TEMP_VALUE(CPPTYPE, TYPE) \
508  case FieldDescriptor::CPPTYPE_##CPPTYPE: \
509  temp_##TYPE = GetField<TYPE>(*message1, field1); \
510  break;
511 
512  GET_TEMP_VALUE(INT32, int32);
513  GET_TEMP_VALUE(INT64, int64);
514  GET_TEMP_VALUE(UINT32, uint32);
515  GET_TEMP_VALUE(UINT64, uint64);
516  GET_TEMP_VALUE(FLOAT, float);
517  GET_TEMP_VALUE(DOUBLE, double);
518  GET_TEMP_VALUE(BOOL, bool);
519  GET_TEMP_VALUE(ENUM, int);
520 #undef GET_TEMP_VALUE
522  temp_message = ReleaseMessage(message1, field1);
523  break;
524 
526  temp_string = GetString(*message1, field1);
527  break;
528 
529  default:
530  GOOGLE_LOG(FATAL) << "Unimplemented type: " << field1->cpp_type();
531  }
532  }
533 
534  // Sets message1's oneof field from the message2's oneof field.
535  if (oneof_case2 > 0) {
536  const FieldDescriptor* field2 = descriptor_->FindFieldByNumber(oneof_case2);
537  switch (field2->cpp_type()) {
538 #define SET_ONEOF_VALUE1(CPPTYPE, TYPE) \
539  case FieldDescriptor::CPPTYPE_##CPPTYPE: \
540  SetField<TYPE>(message1, field2, GetField<TYPE>(*message2, field2)); \
541  break;
542 
543  SET_ONEOF_VALUE1(INT32, int32);
544  SET_ONEOF_VALUE1(INT64, int64);
545  SET_ONEOF_VALUE1(UINT32, uint32);
546  SET_ONEOF_VALUE1(UINT64, uint64);
547  SET_ONEOF_VALUE1(FLOAT, float);
548  SET_ONEOF_VALUE1(DOUBLE, double);
549  SET_ONEOF_VALUE1(BOOL, bool);
550  SET_ONEOF_VALUE1(ENUM, int);
551 #undef SET_ONEOF_VALUE1
553  SetAllocatedMessage(message1, ReleaseMessage(message2, field2), field2);
554  break;
555 
557  SetString(message1, field2, GetString(*message2, field2));
558  break;
559 
560  default:
561  GOOGLE_LOG(FATAL) << "Unimplemented type: " << field2->cpp_type();
562  }
563  } else {
564  ClearOneof(message1, oneof_descriptor);
565  }
566 
567  // Sets message2's oneof field from the temp variable.
568  if (oneof_case1 > 0) {
569  switch (field1->cpp_type()) {
570 #define SET_ONEOF_VALUE2(CPPTYPE, TYPE) \
571  case FieldDescriptor::CPPTYPE_##CPPTYPE: \
572  SetField<TYPE>(message2, field1, temp_##TYPE); \
573  break;
574 
575  SET_ONEOF_VALUE2(INT32, int32);
576  SET_ONEOF_VALUE2(INT64, int64);
577  SET_ONEOF_VALUE2(UINT32, uint32);
578  SET_ONEOF_VALUE2(UINT64, uint64);
579  SET_ONEOF_VALUE2(FLOAT, float);
580  SET_ONEOF_VALUE2(DOUBLE, double);
581  SET_ONEOF_VALUE2(BOOL, bool);
582  SET_ONEOF_VALUE2(ENUM, int);
583 #undef SET_ONEOF_VALUE2
585  SetAllocatedMessage(message2, temp_message, field1);
586  break;
587 
589  SetString(message2, field1, temp_string);
590  break;
591 
592  default:
593  GOOGLE_LOG(FATAL) << "Unimplemented type: " << field1->cpp_type();
594  }
595  } else {
596  ClearOneof(message2, oneof_descriptor);
597  }
598 }
599 
600 void Reflection::Swap(Message* message1, Message* message2) const {
601  if (message1 == message2) return;
602 
603  // TODO(kenton): Other Reflection methods should probably check this too.
604  GOOGLE_CHECK_EQ(message1->GetReflection(), this)
605  << "First argument to Swap() (of type \""
606  << message1->GetDescriptor()->full_name()
607  << "\") is not compatible with this reflection object (which is for type "
608  "\""
609  << descriptor_->full_name()
610  << "\"). Note that the exact same class is required; not just the same "
611  "descriptor.";
612  GOOGLE_CHECK_EQ(message2->GetReflection(), this)
613  << "Second argument to Swap() (of type \""
614  << message2->GetDescriptor()->full_name()
615  << "\") is not compatible with this reflection object (which is for type "
616  "\""
617  << descriptor_->full_name()
618  << "\"). Note that the exact same class is required; not just the same "
619  "descriptor.";
620 
621  // Check that both messages are in the same arena (or both on the heap). We
622  // need to copy all data if not, due to ownership semantics.
623  if (GetArena(message1) != GetArena(message2)) {
624  // Slow copy path.
625  // Use our arena as temp space, if available.
626  Message* temp = message1->New(GetArena(message1));
627  temp->MergeFrom(*message2);
628  message2->CopyFrom(*message1);
629  Swap(message1, temp);
630  if (GetArena(message1) == nullptr) {
631  delete temp;
632  }
633  return;
634  }
635 
636  if (schema_.HasHasbits()) {
637  uint32* has_bits1 = MutableHasBits(message1);
638  uint32* has_bits2 = MutableHasBits(message2);
639 
640  int fields_with_has_bits = 0;
641  for (int i = 0; i < descriptor_->field_count(); i++) {
643  if (field->is_repeated() || field->containing_oneof()) {
644  continue;
645  }
646  fields_with_has_bits++;
647  }
648 
649  int has_bits_size = (fields_with_has_bits + 31) / 32;
650 
651  for (int i = 0; i < has_bits_size; i++) {
652  std::swap(has_bits1[i], has_bits2[i]);
653  }
654  }
655 
656  for (int i = 0; i <= last_non_weak_field_index_; i++) {
658  if (field->containing_oneof()) continue;
659  SwapField(message1, message2, field);
660  }
661  const int oneof_decl_count = descriptor_->oneof_decl_count();
662  for (int i = 0; i < oneof_decl_count; i++) {
663  SwapOneofField(message1, message2, descriptor_->oneof_decl(i));
664  }
665 
666  if (schema_.HasExtensionSet()) {
667  MutableExtensionSet(message1)->Swap(MutableExtensionSet(message2));
668  }
669 
670  MutableUnknownFields(message1)->Swap(MutableUnknownFields(message2));
671 }
672 
674  Message* message1, Message* message2,
675  const std::vector<const FieldDescriptor*>& fields) const {
676  if (message1 == message2) return;
677 
678  // TODO(kenton): Other Reflection methods should probably check this too.
679  GOOGLE_CHECK_EQ(message1->GetReflection(), this)
680  << "First argument to SwapFields() (of type \""
681  << message1->GetDescriptor()->full_name()
682  << "\") is not compatible with this reflection object (which is for type "
683  "\""
684  << descriptor_->full_name()
685  << "\"). Note that the exact same class is required; not just the same "
686  "descriptor.";
687  GOOGLE_CHECK_EQ(message2->GetReflection(), this)
688  << "Second argument to SwapFields() (of type \""
689  << message2->GetDescriptor()->full_name()
690  << "\") is not compatible with this reflection object (which is for type "
691  "\""
692  << descriptor_->full_name()
693  << "\"). Note that the exact same class is required; not just the same "
694  "descriptor.";
695 
696  std::set<int> swapped_oneof;
697 
698  const int fields_size = static_cast<int>(fields.size());
699  for (int i = 0; i < fields_size; i++) {
700  const FieldDescriptor* field = fields[i];
701  if (field->is_extension()) {
703  MutableExtensionSet(message2), field->number());
704  } else {
705  if (field->containing_oneof()) {
706  int oneof_index = field->containing_oneof()->index();
707  // Only swap the oneof field once.
708  if (swapped_oneof.find(oneof_index) != swapped_oneof.end()) {
709  continue;
710  }
711  swapped_oneof.insert(oneof_index);
712  SwapOneofField(message1, message2, field->containing_oneof());
713  } else {
714  // Swap has bit for non-repeated fields. We have already checked for
715  // oneof already.
716  if (!field->is_repeated()) {
717  SwapBit(message1, message2, field);
718  }
719  // Swap field.
720  SwapField(message1, message2, field);
721  }
722  }
723  }
724 }
725 
726 // -------------------------------------------------------------------
727 
729  const FieldDescriptor* field) const {
732 
733  if (field->is_extension()) {
734  return GetExtensionSet(message).Has(field->number());
735  } else {
736  if (field->containing_oneof()) {
737  return HasOneofField(message, field);
738  } else {
739  return HasBit(message, field);
740  }
741  }
742 }
743 
745  const FieldDescriptor* field) const {
748 
749  if (field->is_extension()) {
750  return GetExtensionSet(message).ExtensionSize(field->number());
751  } else {
752  switch (field->cpp_type()) {
753 #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
754  case FieldDescriptor::CPPTYPE_##UPPERCASE: \
755  return GetRaw<RepeatedField<LOWERCASE> >(message, field).size()
756 
757  HANDLE_TYPE(INT32, int32);
758  HANDLE_TYPE(INT64, int64);
759  HANDLE_TYPE(UINT32, uint32);
760  HANDLE_TYPE(UINT64, uint64);
761  HANDLE_TYPE(DOUBLE, double);
762  HANDLE_TYPE(FLOAT, float);
763  HANDLE_TYPE(BOOL, bool);
764  HANDLE_TYPE(ENUM, int);
765 #undef HANDLE_TYPE
766 
769  if (IsMapFieldInApi(field)) {
770  const internal::MapFieldBase& map =
771  GetRaw<MapFieldBase>(message, field);
772  if (map.IsRepeatedFieldValid()) {
773  return map.GetRepeatedField().size();
774  } else {
775  // No need to materialize the repeated field if it is out of sync:
776  // its size will be the same as the map's size.
777  return map.size();
778  }
779  } else {
780  return GetRaw<RepeatedPtrFieldBase>(message, field).size();
781  }
782  }
783 
784  GOOGLE_LOG(FATAL) << "Can't get here.";
785  return 0;
786  }
787 }
788 
790  const FieldDescriptor* field) const {
792 
793  if (field->is_extension()) {
795  } else if (!field->is_repeated()) {
796  if (field->containing_oneof()) {
798  return;
799  }
800  if (HasBit(*message, field)) {
802 
803  // We need to set the field back to its default value.
804  switch (field->cpp_type()) {
805 #define CLEAR_TYPE(CPPTYPE, TYPE) \
806  case FieldDescriptor::CPPTYPE_##CPPTYPE: \
807  *MutableRaw<TYPE>(message, field) = field->default_value_##TYPE(); \
808  break;
809 
810  CLEAR_TYPE(INT32, int32);
811  CLEAR_TYPE(INT64, int64);
812  CLEAR_TYPE(UINT32, uint32);
813  CLEAR_TYPE(UINT64, uint64);
814  CLEAR_TYPE(FLOAT, float);
815  CLEAR_TYPE(DOUBLE, double);
816  CLEAR_TYPE(BOOL, bool);
817 #undef CLEAR_TYPE
818 
820  *MutableRaw<int>(message, field) =
821  field->default_value_enum()->number();
822  break;
823 
825  switch (field->options().ctype()) {
826  default: // TODO(kenton): Support other string reps.
827  case FieldOptions::STRING: {
828  if (IsInlined(field)) {
829  const std::string* default_ptr =
830  &DefaultRaw<InlinedStringField>(field).GetNoArena();
831  MutableRaw<InlinedStringField>(message, field)
832  ->SetNoArena(default_ptr, *default_ptr);
833  break;
834  }
835 
836  const std::string* default_ptr =
837  &DefaultRaw<ArenaStringPtr>(field).Get();
838  MutableRaw<ArenaStringPtr>(message, field)
839  ->SetAllocated(default_ptr, nullptr, GetArena(message));
840  break;
841  }
842  }
843  break;
844  }
845 
847  if (!schema_.HasHasbits()) {
848  // Proto3 does not have has-bits and we need to set a message field
849  // to nullptr in order to indicate its un-presence.
850  if (GetArena(message) == nullptr) {
851  delete *MutableRaw<Message*>(message, field);
852  }
853  *MutableRaw<Message*>(message, field) = nullptr;
854  } else {
855  (*MutableRaw<Message*>(message, field))->Clear();
856  }
857  break;
858  }
859  }
860  } else {
861  switch (field->cpp_type()) {
862 #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
863  case FieldDescriptor::CPPTYPE_##UPPERCASE: \
864  MutableRaw<RepeatedField<LOWERCASE> >(message, field)->Clear(); \
865  break
866 
867  HANDLE_TYPE(INT32, int32);
868  HANDLE_TYPE(INT64, int64);
869  HANDLE_TYPE(UINT32, uint32);
870  HANDLE_TYPE(UINT64, uint64);
871  HANDLE_TYPE(DOUBLE, double);
872  HANDLE_TYPE(FLOAT, float);
873  HANDLE_TYPE(BOOL, bool);
874  HANDLE_TYPE(ENUM, int);
875 #undef HANDLE_TYPE
876 
878  switch (field->options().ctype()) {
879  default: // TODO(kenton): Support other string reps.
881  MutableRaw<RepeatedPtrField<std::string> >(message, field)->Clear();
882  break;
883  }
884  break;
885  }
886 
888  if (IsMapFieldInApi(field)) {
889  MutableRaw<MapFieldBase>(message, field)->Clear();
890  } else {
891  // We don't know which subclass of RepeatedPtrFieldBase the type is,
892  // so we use RepeatedPtrFieldBase directly.
893  MutableRaw<RepeatedPtrFieldBase>(message, field)
894  ->Clear<GenericTypeHandler<Message> >();
895  }
896  break;
897  }
898  }
899  }
900 }
901 
903  const FieldDescriptor* field) const {
906 
907  if (field->is_extension()) {
909  } else {
910  switch (field->cpp_type()) {
911 #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
912  case FieldDescriptor::CPPTYPE_##UPPERCASE: \
913  MutableRaw<RepeatedField<LOWERCASE> >(message, field)->RemoveLast(); \
914  break
915 
916  HANDLE_TYPE(INT32, int32);
917  HANDLE_TYPE(INT64, int64);
918  HANDLE_TYPE(UINT32, uint32);
919  HANDLE_TYPE(UINT64, uint64);
920  HANDLE_TYPE(DOUBLE, double);
921  HANDLE_TYPE(FLOAT, float);
922  HANDLE_TYPE(BOOL, bool);
923  HANDLE_TYPE(ENUM, int);
924 #undef HANDLE_TYPE
925 
927  switch (field->options().ctype()) {
928  default: // TODO(kenton): Support other string reps.
930  MutableRaw<RepeatedPtrField<std::string> >(message, field)
931  ->RemoveLast();
932  break;
933  }
934  break;
935 
937  if (IsMapFieldInApi(field)) {
938  MutableRaw<MapFieldBase>(message, field)
939  ->MutableRepeatedField()
940  ->RemoveLast<GenericTypeHandler<Message> >();
941  } else {
942  MutableRaw<RepeatedPtrFieldBase>(message, field)
943  ->RemoveLast<GenericTypeHandler<Message> >();
944  }
945  break;
946  }
947  }
948 }
949 
951  const FieldDescriptor* field) const {
952  USAGE_CHECK_ALL(ReleaseLast, REPEATED, MESSAGE);
953 
954  if (field->is_extension()) {
955  return static_cast<Message*>(
957  } else {
958  if (IsMapFieldInApi(field)) {
959  return MutableRaw<MapFieldBase>(message, field)
960  ->MutableRepeatedField()
961  ->ReleaseLast<GenericTypeHandler<Message> >();
962  } else {
963  return MutableRaw<RepeatedPtrFieldBase>(message, field)
964  ->ReleaseLast<GenericTypeHandler<Message> >();
965  }
966  }
967 }
968 
970  int index1, int index2) const {
973 
974  if (field->is_extension()) {
975  MutableExtensionSet(message)->SwapElements(field->number(), index1, index2);
976  } else {
977  switch (field->cpp_type()) {
978 #define HANDLE_TYPE(UPPERCASE, LOWERCASE) \
979  case FieldDescriptor::CPPTYPE_##UPPERCASE: \
980  MutableRaw<RepeatedField<LOWERCASE> >(message, field) \
981  ->SwapElements(index1, index2); \
982  break
983 
984  HANDLE_TYPE(INT32, int32);
985  HANDLE_TYPE(INT64, int64);
986  HANDLE_TYPE(UINT32, uint32);
987  HANDLE_TYPE(UINT64, uint64);
988  HANDLE_TYPE(DOUBLE, double);
989  HANDLE_TYPE(FLOAT, float);
990  HANDLE_TYPE(BOOL, bool);
991  HANDLE_TYPE(ENUM, int);
992 #undef HANDLE_TYPE
993 
996  if (IsMapFieldInApi(field)) {
997  MutableRaw<MapFieldBase>(message, field)
998  ->MutableRepeatedField()
999  ->SwapElements(index1, index2);
1000  } else {
1001  MutableRaw<RepeatedPtrFieldBase>(message, field)
1002  ->SwapElements(index1, index2);
1003  }
1004  break;
1005  }
1006  }
1007 }
1008 
1009 namespace {
1010 // Comparison functor for sorting FieldDescriptors by field number.
1011 struct FieldNumberSorter {
1012  bool operator()(const FieldDescriptor* left,
1013  const FieldDescriptor* right) const {
1014  return left->number() < right->number();
1015  }
1016 };
1017 
1018 bool IsIndexInHasBitSet(const uint32* has_bit_set, uint32 has_bit_index) {
1019  GOOGLE_DCHECK_NE(has_bit_index, ~0u);
1020  return ((has_bit_set[has_bit_index / 32] >> (has_bit_index % 32)) &
1021  static_cast<uint32>(1)) != 0;
1022 }
1023 
1024 bool CreateUnknownEnumValues(const FileDescriptor* file) {
1025  return file->syntax() == FileDescriptor::SYNTAX_PROTO3;
1026 }
1027 } // namespace
1028 
1030  std::vector<const FieldDescriptor*>* output) const {
1031  output->clear();
1032 
1033  // Optimization: The default instance never has any fields set.
1034  if (schema_.IsDefaultInstance(message)) return;
1035 
1036  // Optimization: Avoid calling GetHasBits() and HasOneofField() many times
1037  // within the field loop. We allow this violation of ReflectionSchema
1038  // encapsulation because this function takes a noticable about of CPU
1039  // fleetwide and properly allowing this optimization through public interfaces
1040  // seems more trouble than it is worth.
1041  const uint32* const has_bits =
1042  schema_.HasHasbits() ? GetHasBits(message) : nullptr;
1043  const uint32* const has_bits_indices = schema_.has_bit_indices_;
1044  output->reserve(descriptor_->field_count());
1045  for (int i = 0; i <= last_non_weak_field_index_; i++) {
1047  if (field->is_repeated()) {
1048  if (FieldSize(message, field) > 0) {
1049  output->push_back(field);
1050  }
1051  } else {
1052  const OneofDescriptor* containing_oneof = field->containing_oneof();
1053  if (containing_oneof) {
1054  const uint32* const oneof_case_array = GetConstPointerAtOffset<uint32>(
1056  // Equivalent to: HasOneofField(message, field)
1057  if (oneof_case_array[containing_oneof->index()] == field->number()) {
1058  output->push_back(field);
1059  }
1060  } else if (has_bits) {
1061  // Equivalent to: HasBit(message, field)
1062  if (IsIndexInHasBitSet(has_bits, has_bits_indices[i])) {
1063  output->push_back(field);
1064  }
1065  } else if (HasBit(message, field)) { // Fall back on proto3-style HasBit.
1066  output->push_back(field);
1067  }
1068  }
1069  }
1070  if (schema_.HasExtensionSet()) {
1072  output);
1073  }
1074 
1075  // ListFields() must sort output by field number.
1076  std::sort(output->begin(), output->end(), FieldNumberSorter());
1077 }
1078 
1079 // -------------------------------------------------------------------
1080 
1081 #undef DEFINE_PRIMITIVE_ACCESSORS
1082 #define DEFINE_PRIMITIVE_ACCESSORS(TYPENAME, TYPE, PASSTYPE, CPPTYPE) \
1083  PASSTYPE Reflection::Get##TYPENAME(const Message& message, \
1084  const FieldDescriptor* field) const { \
1085  USAGE_CHECK_ALL(Get##TYPENAME, SINGULAR, CPPTYPE); \
1086  if (field->is_extension()) { \
1087  return GetExtensionSet(message).Get##TYPENAME( \
1088  field->number(), field->default_value_##PASSTYPE()); \
1089  } else { \
1090  return GetField<TYPE>(message, field); \
1091  } \
1092  } \
1093  \
1094  void Reflection::Set##TYPENAME( \
1095  Message* message, const FieldDescriptor* field, PASSTYPE value) const { \
1096  USAGE_CHECK_ALL(Set##TYPENAME, SINGULAR, CPPTYPE); \
1097  if (field->is_extension()) { \
1098  return MutableExtensionSet(message)->Set##TYPENAME( \
1099  field->number(), field->type(), value, field); \
1100  } else { \
1101  SetField<TYPE>(message, field, value); \
1102  } \
1103  } \
1104  \
1105  PASSTYPE Reflection::GetRepeated##TYPENAME( \
1106  const Message& message, const FieldDescriptor* field, int index) const { \
1107  USAGE_CHECK_ALL(GetRepeated##TYPENAME, REPEATED, CPPTYPE); \
1108  if (field->is_extension()) { \
1109  return GetExtensionSet(message).GetRepeated##TYPENAME(field->number(), \
1110  index); \
1111  } else { \
1112  return GetRepeatedField<TYPE>(message, field, index); \
1113  } \
1114  } \
1115  \
1116  void Reflection::SetRepeated##TYPENAME(Message* message, \
1117  const FieldDescriptor* field, \
1118  int index, PASSTYPE value) const { \
1119  USAGE_CHECK_ALL(SetRepeated##TYPENAME, REPEATED, CPPTYPE); \
1120  if (field->is_extension()) { \
1121  MutableExtensionSet(message)->SetRepeated##TYPENAME(field->number(), \
1122  index, value); \
1123  } else { \
1124  SetRepeatedField<TYPE>(message, field, index, value); \
1125  } \
1126  } \
1127  \
1128  void Reflection::Add##TYPENAME( \
1129  Message* message, const FieldDescriptor* field, PASSTYPE value) const { \
1130  USAGE_CHECK_ALL(Add##TYPENAME, REPEATED, CPPTYPE); \
1131  if (field->is_extension()) { \
1132  MutableExtensionSet(message)->Add##TYPENAME( \
1133  field->number(), field->type(), field->options().packed(), value, \
1134  field); \
1135  } else { \
1136  AddField<TYPE>(message, field, value); \
1137  } \
1138  }
1139 
1144 DEFINE_PRIMITIVE_ACCESSORS(Float, float, float, FLOAT)
1145 DEFINE_PRIMITIVE_ACCESSORS(Double, double, double, DOUBLE)
1146 DEFINE_PRIMITIVE_ACCESSORS(Bool, bool, bool, BOOL)
1147 #undef DEFINE_PRIMITIVE_ACCESSORS
1148 
1149 // -------------------------------------------------------------------
1150 
1152  const FieldDescriptor* field) const {
1153  USAGE_CHECK_ALL(GetString, SINGULAR, STRING);
1154  if (field->is_extension()) {
1155  return GetExtensionSet(message).GetString(field->number(),
1156  field->default_value_string());
1157  } else {
1158  switch (field->options().ctype()) {
1159  default: // TODO(kenton): Support other string reps.
1160  case FieldOptions::STRING: {
1161  if (IsInlined(field)) {
1162  return GetField<InlinedStringField>(message, field).GetNoArena();
1163  }
1164 
1165  return GetField<ArenaStringPtr>(message, field).Get();
1166  }
1167  }
1168  }
1169 }
1170 
1172  const FieldDescriptor* field,
1173  std::string* scratch) const {
1174  USAGE_CHECK_ALL(GetStringReference, SINGULAR, STRING);
1175  if (field->is_extension()) {
1176  return GetExtensionSet(message).GetString(field->number(),
1177  field->default_value_string());
1178  } else {
1179  switch (field->options().ctype()) {
1180  default: // TODO(kenton): Support other string reps.
1181  case FieldOptions::STRING: {
1182  if (IsInlined(field)) {
1183  return GetField<InlinedStringField>(message, field).GetNoArena();
1184  }
1185 
1186  return GetField<ArenaStringPtr>(message, field).Get();
1187  }
1188  }
1189  }
1190 }
1191 
1192 
1194  const std::string& value) const {
1195  USAGE_CHECK_ALL(SetString, SINGULAR, STRING);
1196  if (field->is_extension()) {
1197  return MutableExtensionSet(message)->SetString(field->number(),
1198  field->type(), value, field);
1199  } else {
1200  switch (field->options().ctype()) {
1201  default: // TODO(kenton): Support other string reps.
1202  case FieldOptions::STRING: {
1203  if (IsInlined(field)) {
1204  MutableField<InlinedStringField>(message, field)
1205  ->SetNoArena(nullptr, value);
1206  break;
1207  }
1208 
1209  const std::string* default_ptr =
1210  &DefaultRaw<ArenaStringPtr>(field).Get();
1211  if (field->containing_oneof() && !HasOneofField(*message, field)) {
1212  ClearOneof(message, field->containing_oneof());
1213  MutableField<ArenaStringPtr>(message, field)
1214  ->UnsafeSetDefault(default_ptr);
1215  }
1216  MutableField<ArenaStringPtr>(message, field)
1217  ->Mutable(default_ptr, GetArena(message))
1218  ->assign(value);
1219  break;
1220  }
1221  }
1222  }
1223 }
1224 
1225 
1227  const FieldDescriptor* field,
1228  int index) const {
1229  USAGE_CHECK_ALL(GetRepeatedString, REPEATED, STRING);
1230  if (field->is_extension()) {
1231  return GetExtensionSet(message).GetRepeatedString(field->number(), index);
1232  } else {
1233  switch (field->options().ctype()) {
1234  default: // TODO(kenton): Support other string reps.
1235  case FieldOptions::STRING:
1236  return GetRepeatedPtrField<std::string>(message, field, index);
1237  }
1238  }
1239 }
1240 
1242  const Message& message, const FieldDescriptor* field, int index,
1243  std::string* scratch) const {
1244  USAGE_CHECK_ALL(GetRepeatedStringReference, REPEATED, STRING);
1245  if (field->is_extension()) {
1246  return GetExtensionSet(message).GetRepeatedString(field->number(), index);
1247  } else {
1248  switch (field->options().ctype()) {
1249  default: // TODO(kenton): Support other string reps.
1250  case FieldOptions::STRING:
1251  return GetRepeatedPtrField<std::string>(message, field, index);
1252  }
1253  }
1254 }
1255 
1256 
1258  const FieldDescriptor* field, int index,
1259  const std::string& value) const {
1260  USAGE_CHECK_ALL(SetRepeatedString, REPEATED, STRING);
1261  if (field->is_extension()) {
1263  value);
1264  } else {
1265  switch (field->options().ctype()) {
1266  default: // TODO(kenton): Support other string reps.
1267  case FieldOptions::STRING:
1268  *MutableRepeatedField<std::string>(message, field, index) = value;
1269  break;
1270  }
1271  }
1272 }
1273 
1274 
1276  const std::string& value) const {
1277  USAGE_CHECK_ALL(AddString, REPEATED, STRING);
1278  if (field->is_extension()) {
1279  MutableExtensionSet(message)->AddString(field->number(), field->type(),
1280  value, field);
1281  } else {
1282  switch (field->options().ctype()) {
1283  default: // TODO(kenton): Support other string reps.
1284  case FieldOptions::STRING:
1285  *AddField<std::string>(message, field) = value;
1286  break;
1287  }
1288  }
1289 }
1290 
1291 
1292 // -------------------------------------------------------------------
1293 
1295  const Message& message, const FieldDescriptor* field) const {
1296  // Usage checked by GetEnumValue.
1297  int value = GetEnumValue(message, field);
1298  return field->enum_type()->FindValueByNumberCreatingIfUnknown(value);
1299 }
1300 
1302  const FieldDescriptor* field) const {
1303  USAGE_CHECK_ALL(GetEnumValue, SINGULAR, ENUM);
1304 
1305  int32 value;
1306  if (field->is_extension()) {
1308  field->number(), field->default_value_enum()->number());
1309  } else {
1310  value = GetField<int>(message, field);
1311  }
1312  return value;
1313 }
1314 
1316  const EnumValueDescriptor* value) const {
1317  // Usage checked by SetEnumValue.
1319  SetEnumValueInternal(message, field, value->number());
1320 }
1321 
1323  int value) const {
1324  USAGE_CHECK_ALL(SetEnumValue, SINGULAR, ENUM);
1325  if (!CreateUnknownEnumValues(descriptor_->file())) {
1326  // Check that the value is valid if we don't support direct storage of
1327  // unknown enum values.
1328  const EnumValueDescriptor* value_desc =
1329  field->enum_type()->FindValueByNumber(value);
1330  if (value_desc == nullptr) {
1332  return;
1333  }
1334  }
1336 }
1337 
1339  const FieldDescriptor* field,
1340  int value) const {
1341  if (field->is_extension()) {
1342  MutableExtensionSet(message)->SetEnum(field->number(), field->type(), value,
1343  field);
1344  } else {
1345  SetField<int>(message, field, value);
1346  }
1347 }
1348 
1350  const Message& message, const FieldDescriptor* field, int index) const {
1351  // Usage checked by GetRepeatedEnumValue.
1353  return field->enum_type()->FindValueByNumberCreatingIfUnknown(value);
1354 }
1355 
1357  const FieldDescriptor* field,
1358  int index) const {
1359  USAGE_CHECK_ALL(GetRepeatedEnumValue, REPEATED, ENUM);
1360 
1361  int value;
1362  if (field->is_extension()) {
1364  } else {
1365  value = GetRepeatedField<int>(message, field, index);
1366  }
1367  return value;
1368 }
1369 
1371  int index,
1372  const EnumValueDescriptor* value) const {
1373  // Usage checked by SetRepeatedEnumValue.
1376 }
1377 
1379  const FieldDescriptor* field, int index,
1380  int value) const {
1381  USAGE_CHECK_ALL(SetRepeatedEnum, REPEATED, ENUM);
1382  if (!CreateUnknownEnumValues(descriptor_->file())) {
1383  // Check that the value is valid if we don't support direct storage of
1384  // unknown enum values.
1385  const EnumValueDescriptor* value_desc =
1386  field->enum_type()->FindValueByNumber(value);
1387  if (value_desc == nullptr) {
1389  return;
1390  }
1391  }
1393 }
1394 
1396  const FieldDescriptor* field,
1397  int index, int value) const {
1398  if (field->is_extension()) {
1400  value);
1401  } else {
1402  SetRepeatedField<int>(message, field, index, value);
1403  }
1404 }
1405 
1407  const EnumValueDescriptor* value) const {
1408  // Usage checked by AddEnumValue.
1410  AddEnumValueInternal(message, field, value->number());
1411 }
1412 
1414  int value) const {
1415  USAGE_CHECK_ALL(AddEnum, REPEATED, ENUM);
1416  if (!CreateUnknownEnumValues(descriptor_->file())) {
1417  // Check that the value is valid if we don't support direct storage of
1418  // unknown enum values.
1419  const EnumValueDescriptor* value_desc =
1420  field->enum_type()->FindValueByNumber(value);
1421  if (value_desc == nullptr) {
1423  return;
1424  }
1425  }
1427 }
1428 
1430  const FieldDescriptor* field,
1431  int value) const {
1432  if (field->is_extension()) {
1433  MutableExtensionSet(message)->AddEnum(field->number(), field->type(),
1434  field->options().packed(), value,
1435  field);
1436  } else {
1437  AddField<int>(message, field, value);
1438  }
1439 }
1440 
1441 // -------------------------------------------------------------------
1442 
1444  const FieldDescriptor* field,
1445  MessageFactory* factory) const {
1446  USAGE_CHECK_ALL(GetMessage, SINGULAR, MESSAGE);
1447 
1448  if (factory == nullptr) factory = message_factory_;
1449 
1450  if (field->is_extension()) {
1451  return static_cast<const Message&>(GetExtensionSet(message).GetMessage(
1452  field->number(), field->message_type(), factory));
1453  } else {
1454  const Message* result = GetRaw<const Message*>(message, field);
1455  if (result == nullptr) {
1456  result = DefaultRaw<const Message*>(field);
1457  }
1458  return *result;
1459  }
1460 }
1461 
1463  const FieldDescriptor* field,
1464  MessageFactory* factory) const {
1465  USAGE_CHECK_ALL(MutableMessage, SINGULAR, MESSAGE);
1466 
1467  if (factory == nullptr) factory = message_factory_;
1468 
1469  if (field->is_extension()) {
1470  return static_cast<Message*>(
1472  } else {
1473  Message* result;
1474 
1475  Message** result_holder = MutableRaw<Message*>(message, field);
1476 
1477  if (field->containing_oneof()) {
1478  if (!HasOneofField(*message, field)) {
1479  ClearOneof(message, field->containing_oneof());
1480  result_holder = MutableField<Message*>(message, field);
1481  const Message* default_message = DefaultRaw<const Message*>(field);
1482  *result_holder = default_message->New(message->GetArena());
1483  }
1484  } else {
1485  SetBit(message, field);
1486  }
1487 
1488  if (*result_holder == nullptr) {
1489  const Message* default_message = DefaultRaw<const Message*>(field);
1490  *result_holder = default_message->New(message->GetArena());
1491  }
1492  result = *result_holder;
1493  return result;
1494  }
1495 }
1496 
1498  Message* message, Message* sub_message,
1499  const FieldDescriptor* field) const {
1500  USAGE_CHECK_ALL(SetAllocatedMessage, SINGULAR, MESSAGE);
1501 
1502  if (field->is_extension()) {
1504  field->number(), field->type(), field, sub_message);
1505  } else {
1506  if (field->containing_oneof()) {
1507  if (sub_message == nullptr) {
1508  ClearOneof(message, field->containing_oneof());
1509  return;
1510  }
1511  ClearOneof(message, field->containing_oneof());
1512  *MutableRaw<Message*>(message, field) = sub_message;
1514  return;
1515  }
1516 
1517  if (sub_message == nullptr) {
1519  } else {
1520  SetBit(message, field);
1521  }
1522  Message** sub_message_holder = MutableRaw<Message*>(message, field);
1523  if (GetArena(message) == nullptr) {
1524  delete *sub_message_holder;
1525  }
1526  *sub_message_holder = sub_message;
1527  }
1528 }
1529 
1531  const FieldDescriptor* field) const {
1532  // If message and sub-message are in different memory ownership domains
1533  // (different arenas, or one is on heap and one is not), then we may need to
1534  // do a copy.
1535  if (sub_message != nullptr &&
1536  sub_message->GetArena() != message->GetArena()) {
1537  if (sub_message->GetArena() == nullptr && message->GetArena() != nullptr) {
1538  // Case 1: parent is on an arena and child is heap-allocated. We can add
1539  // the child to the arena's Own() list to free on arena destruction, then
1540  // set our pointer.
1541  message->GetArena()->Own(sub_message);
1543  } else {
1544  // Case 2: all other cases. We need to make a copy. MutableMessage() will
1545  // either get the existing message object, or instantiate a new one as
1546  // appropriate w.r.t. our arena.
1547  Message* sub_message_copy = MutableMessage(message, field);
1548  sub_message_copy->CopyFrom(*sub_message);
1549  }
1550  } else {
1551  // Same memory ownership domains.
1553  }
1554 }
1555 
1557  const FieldDescriptor* field,
1558  MessageFactory* factory) const {
1559  USAGE_CHECK_ALL(ReleaseMessage, SINGULAR, MESSAGE);
1560 
1561  if (factory == nullptr) factory = message_factory_;
1562 
1563  if (field->is_extension()) {
1564  return static_cast<Message*>(
1566  factory));
1567  } else {
1568  if (!(field->is_repeated() || field->containing_oneof())) {
1570  }
1571  if (field->containing_oneof()) {
1572  if (HasOneofField(*message, field)) {
1573  *MutableOneofCase(message, field->containing_oneof()) = 0;
1574  } else {
1575  return nullptr;
1576  }
1577  }
1578  Message** result = MutableRaw<Message*>(message, field);
1579  Message* ret = *result;
1580  *result = nullptr;
1581  return ret;
1582  }
1583 }
1584 
1586  const FieldDescriptor* field,
1587  MessageFactory* factory) const {
1588  Message* released = UnsafeArenaReleaseMessage(message, field, factory);
1589  if (GetArena(message) != nullptr && released != nullptr) {
1590  Message* copy_from_arena = released->New();
1591  copy_from_arena->CopyFrom(*released);
1592  released = copy_from_arena;
1593  }
1594  return released;
1595 }
1596 
1598  const FieldDescriptor* field,
1599  int index) const {
1600  USAGE_CHECK_ALL(GetRepeatedMessage, REPEATED, MESSAGE);
1601 
1602  if (field->is_extension()) {
1603  return static_cast<const Message&>(
1605  } else {
1606  if (IsMapFieldInApi(field)) {
1607  return GetRaw<MapFieldBase>(message, field)
1608  .GetRepeatedField()
1610  } else {
1611  return GetRaw<RepeatedPtrFieldBase>(message, field)
1613  }
1614  }
1615 }
1616 
1618  const FieldDescriptor* field,
1619  int index) const {
1620  USAGE_CHECK_ALL(MutableRepeatedMessage, REPEATED, MESSAGE);
1621 
1622  if (field->is_extension()) {
1623  return static_cast<Message*>(
1625  index));
1626  } else {
1627  if (IsMapFieldInApi(field)) {
1628  return MutableRaw<MapFieldBase>(message, field)
1629  ->MutableRepeatedField()
1630  ->Mutable<GenericTypeHandler<Message> >(index);
1631  } else {
1632  return MutableRaw<RepeatedPtrFieldBase>(message, field)
1633  ->Mutable<GenericTypeHandler<Message> >(index);
1634  }
1635  }
1636 }
1637 
1639  MessageFactory* factory) const {
1640  USAGE_CHECK_ALL(AddMessage, REPEATED, MESSAGE);
1641 
1642  if (factory == nullptr) factory = message_factory_;
1643 
1644  if (field->is_extension()) {
1645  return static_cast<Message*>(
1647  } else {
1648  Message* result = nullptr;
1649 
1650  // We can't use AddField<Message>() because RepeatedPtrFieldBase doesn't
1651  // know how to allocate one.
1652  RepeatedPtrFieldBase* repeated = nullptr;
1653  if (IsMapFieldInApi(field)) {
1654  repeated =
1655  MutableRaw<MapFieldBase>(message, field)->MutableRepeatedField();
1656  } else {
1657  repeated = MutableRaw<RepeatedPtrFieldBase>(message, field);
1658  }
1659  result = repeated->AddFromCleared<GenericTypeHandler<Message> >();
1660  if (result == nullptr) {
1661  // We must allocate a new object.
1662  const Message* prototype;
1663  if (repeated->size() == 0) {
1664  prototype = factory->GetPrototype(field->message_type());
1665  } else {
1666  prototype = &repeated->Get<GenericTypeHandler<Message> >(0);
1667  }
1668  result = prototype->New(message->GetArena());
1669  // We can guarantee here that repeated and result are either both heap
1670  // allocated or arena owned. So it is safe to call the unsafe version
1671  // of AddAllocated.
1673  }
1674 
1675  return result;
1676  }
1677 }
1678 
1680  const FieldDescriptor* field,
1681  Message* new_entry) const {
1682  USAGE_CHECK_ALL(AddAllocatedMessage, REPEATED, MESSAGE);
1683 
1684  if (field->is_extension()) {
1686  } else {
1687  RepeatedPtrFieldBase* repeated = nullptr;
1688  if (IsMapFieldInApi(field)) {
1689  repeated =
1690  MutableRaw<MapFieldBase>(message, field)->MutableRepeatedField();
1691  } else {
1692  repeated = MutableRaw<RepeatedPtrFieldBase>(message, field);
1693  }
1694  repeated->AddAllocated<GenericTypeHandler<Message> >(new_entry);
1695  }
1696 }
1697 
1699  const FieldDescriptor* field,
1700  FieldDescriptor::CppType cpptype,
1701  int ctype,
1702  const Descriptor* desc) const {
1703  USAGE_CHECK_REPEATED("MutableRawRepeatedField");
1704  if (field->cpp_type() != cpptype)
1705  ReportReflectionUsageTypeError(descriptor_, field,
1706  "MutableRawRepeatedField", cpptype);
1707  if (desc != nullptr)
1708  GOOGLE_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
1709  if (field->is_extension()) {
1711  field->number(), field->type(), field->is_packed(), field);
1712  } else {
1713  // Trigger transform for MapField
1714  if (IsMapFieldInApi(field)) {
1715  return MutableRawNonOneof<MapFieldBase>(message, field)
1716  ->MutableRepeatedField();
1717  }
1718  return MutableRawNonOneof<void>(message, field);
1719  }
1720 }
1721 
1723  const FieldDescriptor* field,
1724  FieldDescriptor::CppType cpptype,
1725  int ctype,
1726  const Descriptor* desc) const {
1727  USAGE_CHECK_REPEATED("GetRawRepeatedField");
1728  if (field->cpp_type() != cpptype)
1729  ReportReflectionUsageTypeError(descriptor_, field, "GetRawRepeatedField",
1730  cpptype);
1731  if (ctype >= 0)
1732  GOOGLE_CHECK_EQ(field->options().ctype(), ctype) << "subtype mismatch";
1733  if (desc != nullptr)
1734  GOOGLE_CHECK_EQ(field->message_type(), desc) << "wrong submessage type";
1735  if (field->is_extension()) {
1736  // Should use extension_set::GetRawRepeatedField. However, the required
1737  // parameter "default repeated value" is not very easy to get here.
1738  // Map is not supported in extensions, it is acceptable to use
1739  // extension_set::MutableRawRepeatedField which does not change the message.
1740  return MutableExtensionSet(const_cast<Message*>(&message))
1741  ->MutableRawRepeatedField(field->number(), field->type(),
1742  field->is_packed(), field);
1743  } else {
1744  // Trigger transform for MapField
1745  if (IsMapFieldInApi(field)) {
1746  return &(GetRawNonOneof<MapFieldBase>(message, field).GetRepeatedField());
1747  }
1748  return &GetRawNonOneof<char>(message, field);
1749  }
1750 }
1751 
1753  const Message& message, const OneofDescriptor* oneof_descriptor) const {
1754  uint32 field_number = GetOneofCase(message, oneof_descriptor);
1755  if (field_number == 0) {
1756  return nullptr;
1757  }
1758  return descriptor_->FindFieldByNumber(field_number);
1759 }
1760 
1762  const FieldDescriptor* field,
1763  const MapKey& key) const {
1764  USAGE_CHECK(IsMapFieldInApi(field), "LookupMapValue",
1765  "Field is not a map field.");
1766  return GetRaw<MapFieldBase>(message, field).ContainsMapKey(key);
1767 }
1768 
1770  const FieldDescriptor* field,
1771  const MapKey& key,
1772  MapValueRef* val) const {
1773  USAGE_CHECK(IsMapFieldInApi(field), "InsertOrLookupMapValue",
1774  "Field is not a map field.");
1775  val->SetType(field->message_type()->FindFieldByName("value")->cpp_type());
1776  return MutableRaw<MapFieldBase>(message, field)
1777  ->InsertOrLookupMapValue(key, val);
1778 }
1779 
1781  const MapKey& key) const {
1782  USAGE_CHECK(IsMapFieldInApi(field), "DeleteMapValue",
1783  "Field is not a map field.");
1784  return MutableRaw<MapFieldBase>(message, field)->DeleteMapValue(key);
1785 }
1786 
1788  const FieldDescriptor* field) const {
1789  USAGE_CHECK(IsMapFieldInApi(field), "MapBegin", "Field is not a map field.");
1790  MapIterator iter(message, field);
1791  GetRaw<MapFieldBase>(*message, field).MapBegin(&iter);
1792  return iter;
1793 }
1794 
1796  const FieldDescriptor* field) const {
1797  USAGE_CHECK(IsMapFieldInApi(field), "MapEnd", "Field is not a map field.");
1798  MapIterator iter(message, field);
1799  GetRaw<MapFieldBase>(*message, field).MapEnd(&iter);
1800  return iter;
1801 }
1802 
1804  const FieldDescriptor* field) const {
1805  USAGE_CHECK(IsMapFieldInApi(field), "MapSize", "Field is not a map field.");
1806  return GetRaw<MapFieldBase>(message, field).size();
1807 }
1808 
1809 // -----------------------------------------------------------------------------
1810 
1811 const FieldDescriptor* Reflection::FindKnownExtensionByName(
1812  const std::string& name) const {
1813  if (!schema_.HasExtensionSet()) return nullptr;
1815 }
1816 
1817 const FieldDescriptor* Reflection::FindKnownExtensionByNumber(
1818  int number) const {
1819  if (!schema_.HasExtensionSet()) return nullptr;
1821 }
1822 
1824  return CreateUnknownEnumValues(descriptor_->file());
1825 }
1826 
1827 // ===================================================================
1828 // Some private helpers.
1829 
1830 // These simple template accessors obtain pointers (or references) to
1831 // the given field.
1832 
1833 template <class Type>
1835  const FieldDescriptor* field) const {
1836  return GetConstRefAtOffset<Type>(message,
1838 }
1839 
1840 template <class Type>
1842  const FieldDescriptor* field) const {
1843  return GetPointerAtOffset<Type>(message,
1845 }
1846 
1847 template <typename Type>
1849  const FieldDescriptor* field) const {
1850  if (field->containing_oneof() && !HasOneofField(message, field)) {
1851  return DefaultRaw<Type>(field);
1852  }
1853  return GetConstRefAtOffset<Type>(message, schema_.GetFieldOffset(field));
1854 }
1855 
1857  return schema_.IsFieldInlined(field);
1858 }
1859 
1860 template <typename Type>
1862  const FieldDescriptor* field) const {
1863  return GetPointerAtOffset<Type>(message, schema_.GetFieldOffset(field));
1864 }
1865 
1868  return &GetConstRefAtOffset<uint32>(message, schema_.HasBitsOffset());
1869 }
1870 
1873  return GetPointerAtOffset<uint32>(message, schema_.HasBitsOffset());
1874 }
1875 
1877  const OneofDescriptor* oneof_descriptor) const {
1878  return GetConstRefAtOffset<uint32>(
1879  message, schema_.GetOneofCaseOffset(oneof_descriptor));
1880 }
1881 
1883  Message* message, const OneofDescriptor* oneof_descriptor) const {
1884  return GetPointerAtOffset<uint32>(
1885  message, schema_.GetOneofCaseOffset(oneof_descriptor));
1886 }
1887 
1889  return GetConstRefAtOffset<ExtensionSet>(message,
1891 }
1892 
1894  return GetPointerAtOffset<ExtensionSet>(message,
1896 }
1897 
1899  return GetInternalMetadataWithArena(*message).arena();
1900 }
1901 
1903  const Message& message) const {
1904  return GetConstRefAtOffset<InternalMetadataWithArena>(
1906 }
1907 
1909  Message* message) const {
1910  return GetPointerAtOffset<InternalMetadataWithArena>(
1912 }
1913 
1914 template <typename Type>
1916  return *reinterpret_cast<const Type*>(schema_.GetFieldDefault(field));
1917 }
1918 
1919 // Simple accessors for manipulating has_bits_.
1921  const FieldDescriptor* field) const {
1922  GOOGLE_DCHECK(!field->options().weak());
1923  if (schema_.HasHasbits()) {
1924  return IsIndexInHasBitSet(GetHasBits(message), schema_.HasBitIndex(field));
1925  }
1926 
1927  // proto3: no has-bits. All fields present except messages, which are
1928  // present only if their message-field pointer is non-null.
1929  if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
1930  return !schema_.IsDefaultInstance(message) &&
1931  GetRaw<const Message*>(message, field) != nullptr;
1932  } else {
1933  // Non-message field (and non-oneof, since that was handled in HasField()
1934  // before calling us), and singular (again, checked in HasField). So, this
1935  // field must be a scalar.
1936 
1937  // Scalar primitive (numeric or string/bytes) fields are present if
1938  // their value is non-zero (numeric) or non-empty (string/bytes). N.B.:
1939  // we must use this definition here, rather than the "scalar fields
1940  // always present" in the proto3 docs, because MergeFrom() semantics
1941  // require presence as "present on wire", and reflection-based merge
1942  // (which uses HasField()) needs to be consistent with this.
1943  switch (field->cpp_type()) {
1945  switch (field->options().ctype()) {
1946  default: {
1947  if (IsInlined(field)) {
1948  return !GetField<InlinedStringField>(message, field)
1949  .GetNoArena()
1950  .empty();
1951  }
1952  return GetField<ArenaStringPtr>(message, field).Get().size() > 0;
1953  }
1954  }
1955  return false;
1957  return GetRaw<bool>(message, field) != false;
1959  return GetRaw<int32>(message, field) != 0;
1961  return GetRaw<int64>(message, field) != 0;
1963  return GetRaw<uint32>(message, field) != 0;
1965  return GetRaw<uint64>(message, field) != 0;
1967  return GetRaw<float>(message, field) != 0.0;
1969  return GetRaw<double>(message, field) != 0.0;
1971  return GetRaw<int>(message, field) != 0;
1973  // handled above; avoid warning
1974  break;
1975  }
1976  GOOGLE_LOG(FATAL) << "Reached impossible case in HasBit().";
1977  return false;
1978  }
1979 }
1980 
1982  GOOGLE_DCHECK(!field->options().weak());
1983  if (!schema_.HasHasbits()) {
1984  return;
1985  }
1987  MutableHasBits(message)[index / 32] |=
1988  (static_cast<uint32>(1) << (index % 32));
1989 }
1990 
1992  const FieldDescriptor* field) const {
1993  GOOGLE_DCHECK(!field->options().weak());
1994  if (!schema_.HasHasbits()) {
1995  return;
1996  }
1998  MutableHasBits(message)[index / 32] &=
1999  ~(static_cast<uint32>(1) << (index % 32));
2000 }
2001 
2002 void Reflection::SwapBit(Message* message1, Message* message2,
2003  const FieldDescriptor* field) const {
2004  GOOGLE_DCHECK(!field->options().weak());
2005  if (!schema_.HasHasbits()) {
2006  return;
2007  }
2008  bool temp_has_bit = HasBit(*message1, field);
2009  if (HasBit(*message2, field)) {
2010  SetBit(message1, field);
2011  } else {
2012  ClearBit(message1, field);
2013  }
2014  if (temp_has_bit) {
2015  SetBit(message2, field);
2016  } else {
2017  ClearBit(message2, field);
2018  }
2019 }
2020 
2022  const OneofDescriptor* oneof_descriptor) const {
2023  return (GetOneofCase(message, oneof_descriptor) > 0);
2024 }
2025 
2027  const FieldDescriptor* field) const {
2028  return (GetOneofCase(message, field->containing_oneof()) == field->number());
2029 }
2030 
2032  const FieldDescriptor* field) const {
2033  *MutableOneofCase(message, field->containing_oneof()) = field->number();
2034 }
2035 
2037  const FieldDescriptor* field) const {
2038  if (HasOneofField(*message, field)) {
2039  ClearOneof(message, field->containing_oneof());
2040  }
2041 }
2042 
2044  const OneofDescriptor* oneof_descriptor) const {
2045  // TODO(jieluo): Consider to cache the unused object instead of deleting
2046  // it. It will be much faster if an application switches a lot from
2047  // a few oneof fields. Time/space tradeoff
2048  uint32 oneof_case = GetOneofCase(*message, oneof_descriptor);
2049  if (oneof_case > 0) {
2050  const FieldDescriptor* field = descriptor_->FindFieldByNumber(oneof_case);
2051  if (GetArena(message) == nullptr) {
2052  switch (field->cpp_type()) {
2054  switch (field->options().ctype()) {
2055  default: // TODO(kenton): Support other string reps.
2056  case FieldOptions::STRING: {
2057  const std::string* default_ptr =
2058  &DefaultRaw<ArenaStringPtr>(field).Get();
2059  MutableField<ArenaStringPtr>(message, field)
2060  ->Destroy(default_ptr, GetArena(message));
2061  break;
2062  }
2063  }
2064  break;
2065  }
2066 
2068  delete *MutableRaw<Message*>(message, field);
2069  break;
2070  default:
2071  break;
2072  }
2073  }
2074 
2075  *MutableOneofCase(message, oneof_descriptor) = 0;
2076  }
2077 }
2078 
2079 #define HANDLE_TYPE(TYPE, CPPTYPE, CTYPE) \
2080  template <> \
2081  const RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>( \
2082  const Message& message, const FieldDescriptor* field) const { \
2083  return *static_cast<RepeatedField<TYPE>*>(MutableRawRepeatedField( \
2084  const_cast<Message*>(&message), field, CPPTYPE, CTYPE, NULL)); \
2085  } \
2086  \
2087  template <> \
2088  RepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>( \
2089  Message * message, const FieldDescriptor* field) const { \
2090  return static_cast<RepeatedField<TYPE>*>( \
2091  MutableRawRepeatedField(message, field, CPPTYPE, CTYPE, NULL)); \
2092  }
2093 
2101 
2102 
2103 #undef HANDLE_TYPE
2104 
2106  const FieldDescriptor* field,
2107  bool is_string) const {
2111 }
2112 
2113 // Template implementations of basic accessors. Inline because each
2114 // template instance is only called from one location. These are
2115 // used for all types except messages.
2116 template <typename Type>
2118  const FieldDescriptor* field) const {
2119  return GetRaw<Type>(message, field);
2120 }
2121 
2122 template <typename Type>
2124  const Type& value) const {
2125  if (field->containing_oneof() && !HasOneofField(*message, field)) {
2126  ClearOneof(message, field->containing_oneof());
2127  }
2128  *MutableRaw<Type>(message, field) = value;
2129  field->containing_oneof() ? SetOneofCase(message, field)
2130  : SetBit(message, field);
2131 }
2132 
2133 template <typename Type>
2135  const FieldDescriptor* field) const {
2136  field->containing_oneof() ? SetOneofCase(message, field)
2137  : SetBit(message, field);
2138  return MutableRaw<Type>(message, field);
2139 }
2140 
2141 template <typename Type>
2143  const FieldDescriptor* field,
2144  int index) const {
2145  return GetRaw<RepeatedField<Type> >(message, field).Get(index);
2146 }
2147 
2148 template <typename Type>
2150  const FieldDescriptor* field,
2151  int index) const {
2152  return GetRaw<RepeatedPtrField<Type> >(message, field).Get(index);
2153 }
2154 
2155 template <typename Type>
2157  const FieldDescriptor* field, int index,
2158  Type value) const {
2159  MutableRaw<RepeatedField<Type> >(message, field)->Set(index, value);
2160 }
2161 
2162 template <typename Type>
2164  const FieldDescriptor* field,
2165  int index) const {
2166  RepeatedPtrField<Type>* repeated =
2167  MutableRaw<RepeatedPtrField<Type> >(message, field);
2168  return repeated->Mutable(index);
2169 }
2170 
2171 template <typename Type>
2173  const Type& value) const {
2174  MutableRaw<RepeatedField<Type> >(message, field)->Add(value);
2175 }
2176 
2177 template <typename Type>
2179  const FieldDescriptor* field) const {
2180  RepeatedPtrField<Type>* repeated =
2181  MutableRaw<RepeatedPtrField<Type> >(message, field);
2182  return repeated->Add();
2183 }
2184 
2186  return message_factory_;
2187 }
2188 
2190  const FieldDescriptor* field,
2192  const Descriptor* message_type) const {
2193  GOOGLE_CHECK(field->is_repeated());
2194  GOOGLE_CHECK(field->cpp_type() == cpp_type ||
2195  (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM &&
2197  << "The type parameter T in RepeatedFieldRef<T> API doesn't match "
2198  << "the actual field type (for enums T should be the generated enum "
2199  << "type or int32).";
2200  if (message_type != nullptr) {
2201  GOOGLE_CHECK_EQ(message_type, field->message_type());
2202  }
2203  if (field->is_extension()) {
2205  field->number(), field->type(), field->is_packed(), field);
2206  } else {
2207  return MutableRawNonOneof<char>(message, field);
2208  }
2209 }
2210 
2212  const FieldDescriptor* field) const {
2213  USAGE_CHECK(IsMapFieldInApi(field), "GetMapData",
2214  "Field is not a map field.");
2215  return MutableRaw<MapFieldBase>(message, field);
2216 }
2217 
2219  const FieldDescriptor* field) const {
2220  USAGE_CHECK(IsMapFieldInApi(field), "GetMapData",
2221  "Field is not a map field.");
2222  return &(GetRaw<MapFieldBase>(message, field));
2223 }
2224 
2225 namespace {
2226 
2227 // Helper function to transform migration schema into reflection schema.
2228 ReflectionSchema MigrationToReflectionSchema(
2229  const Message* const* default_instance, const uint32* offsets,
2230  MigrationSchema migration_schema) {
2231  ReflectionSchema result;
2232  result.default_instance_ = *default_instance;
2233  // First 6 offsets are offsets to the special fields. The following offsets
2234  // are the proto fields.
2235  result.offsets_ = offsets + migration_schema.offsets_index + 5;
2236  result.has_bit_indices_ = offsets + migration_schema.has_bit_indices_index;
2237  result.has_bits_offset_ = offsets[migration_schema.offsets_index + 0];
2238  result.metadata_offset_ = offsets[migration_schema.offsets_index + 1];
2239  result.extensions_offset_ = offsets[migration_schema.offsets_index + 2];
2240  result.oneof_case_offset_ = offsets[migration_schema.offsets_index + 3];
2241  result.object_size_ = migration_schema.object_size;
2242  result.weak_field_map_offset_ = offsets[migration_schema.offsets_index + 4];
2243  return result;
2244 }
2245 
2246 } // namespace
2247 
2249  public:
2251  Metadata* file_level_metadata,
2252  const EnumDescriptor** file_level_enum_descriptors,
2253  const MigrationSchema* schemas,
2254  const Message* const* default_instance_data,
2255  const uint32* offsets)
2256  : factory_(factory),
2257  file_level_metadata_(file_level_metadata),
2258  file_level_enum_descriptors_(file_level_enum_descriptors),
2259  schemas_(schemas),
2260  default_instance_data_(default_instance_data),
2261  offsets_(offsets) {}
2262 
2264  for (int i = 0; i < descriptor->nested_type_count(); i++) {
2265  AssignMessageDescriptor(descriptor->nested_type(i));
2266  }
2267 
2269 
2271  new Reflection(descriptor,
2272  MigrationToReflectionSchema(default_instance_data_,
2273  offsets_, *schemas_),
2275  for (int i = 0; i < descriptor->enum_type_count(); i++) {
2276  AssignEnumDescriptor(descriptor->enum_type(i));
2277  }
2278  schemas_++;
2281  }
2282 
2286  }
2287 
2289 
2290  private:
2297 };
2298 
2299 namespace {
2300 
2301 // We have the routines that assign descriptors and build reflection
2302 // automatically delete the allocated reflection. MetadataOwner owns
2303 // all the allocated reflection instances.
2304 struct MetadataOwner {
2305  ~MetadataOwner() {
2306  for (auto range : metadata_arrays_) {
2307  for (const Metadata* m = range.first; m < range.second; m++) {
2308  delete m->reflection;
2309  }
2310  }
2311  }
2312 
2313  void AddArray(const Metadata* begin, const Metadata* end) {
2314  mu_.Lock();
2315  metadata_arrays_.push_back(std::make_pair(begin, end));
2316  mu_.Unlock();
2317  }
2318 
2319  static MetadataOwner* Instance() {
2320  static MetadataOwner* res = OnShutdownDelete(new MetadataOwner);
2321  return res;
2322  }
2323 
2324  private:
2325  MetadataOwner() = default; // private because singleton
2326 
2327  WrappedMutex mu_;
2328  std::vector<std::pair<const Metadata*, const Metadata*> > metadata_arrays_;
2329 };
2330 
2331 void AssignDescriptorsImpl(const DescriptorTable* table) {
2332  // Ensure the file descriptor is added to the pool.
2333  {
2334  // This only happens once per proto file. So a global mutex to serialize
2335  // calls to AddDescriptors.
2336  static WrappedMutex mu{GOOGLE_PROTOBUF_LINKER_INITIALIZED};
2337  mu.Lock();
2339  mu.Unlock();
2340  }
2341  // Fill the arrays with pointers to descriptors and reflection classes.
2342  const FileDescriptor* file =
2344  table->filename);
2345  GOOGLE_CHECK(file != nullptr);
2346 
2347  MessageFactory* factory = MessageFactory::generated_factory();
2348 
2349  AssignDescriptorsHelper helper(
2350  factory, table->file_level_metadata, table->file_level_enum_descriptors,
2351  table->schemas, table->default_instances, table->offsets);
2352 
2353  for (int i = 0; i < file->message_type_count(); i++) {
2354  helper.AssignMessageDescriptor(file->message_type(i));
2355  }
2356 
2357  for (int i = 0; i < file->enum_type_count(); i++) {
2358  helper.AssignEnumDescriptor(file->enum_type(i));
2359  }
2360  if (file->options().cc_generic_services()) {
2361  for (int i = 0; i < file->service_count(); i++) {
2362  table->file_level_service_descriptors[i] = file->service(i);
2363  }
2364  }
2365  MetadataOwner::Instance()->AddArray(table->file_level_metadata,
2366  helper.GetCurrentMetadataPtr());
2367 }
2368 
2369 void AddDescriptorsImpl(const DescriptorTable* table) {
2370  // Reflection refers to the default instances so make sure they are
2371  // initialized.
2372  for (int i = 0; i < table->num_sccs; i++) {
2373  internal::InitSCC(table->init_default_instances[i]);
2374  }
2375 
2376  // Ensure all dependent descriptors are registered to the generated descriptor
2377  // pool and message factory.
2378  for (int i = 0; i < table->num_deps; i++) {
2379  // In case of weak fields deps[i] could be null.
2380  if (table->deps[i]) AddDescriptors(table->deps[i]);
2381  }
2382 
2383  // Register the descriptor of this file.
2386 }
2387 
2388 } // namespace
2389 
2390 // Separate function because it needs to be a friend of
2391 // Reflection
2392 void RegisterAllTypesInternal(const Metadata* file_level_metadata, int size) {
2393  for (int i = 0; i < size; i++) {
2394  const Reflection* reflection = file_level_metadata[i].reflection;
2396  file_level_metadata[i].descriptor,
2397  reflection->schema_.default_instance_);
2398  }
2399 }
2400 
2401 namespace internal {
2402 
2404  call_once(*table->once, AssignDescriptorsImpl, table);
2405 }
2406 
2408  // AddDescriptors is not thread safe. Callers need to ensure calls are
2409  // properly serialized. This function is only called pre-main by global
2410  // descriptors and we can assume single threaded access or it's called
2411  // by AssignDescriptorImpl which uses a mutex to sequence calls.
2412  if (*table->is_initialized) return;
2413  *table->is_initialized = true;
2414  AddDescriptorsImpl(table);
2415 }
2416 
2419  RegisterAllTypesInternal(table->file_level_metadata, table->num_messages);
2420 }
2421 
2423  uint32 has_offset,
2425  const void* ptr = base + offset;
2427  static_cast<const InternalMetadataWithArena*>(ptr);
2428  if (metadata->have_unknown_fields()) {
2430  output);
2431  }
2432 }
2433 
2434 } // namespace internal
2435 } // namespace protobuf
2436 } // namespace google
google::protobuf::Descriptor::full_name
const std::string & full_name() const
GET_TEMP_VALUE
#define GET_TEMP_VALUE(CPPTYPE, TYPE)
table
upb_strtable table
Definition: php/ext/google/protobuf/protobuf.h:1065
google::protobuf.internal::ReflectionSchema::GetOneofCaseOffset
uint32 GetOneofCaseOffset(const OneofDescriptor *oneof_descriptor) const
Definition: generated_message_reflection.h:161
google::protobuf::DescriptorPool::FindFileByName
const FileDescriptor * FindFileByName(const std::string &name) const
Definition: src/google/protobuf/descriptor.cc:1389
google::protobuf::Reflection::GetString
std::string GetString(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1151
GOOGLE_CHECK_EQ
#define GOOGLE_CHECK_EQ(A, B)
Definition: logging.h:156
google::protobuf::AssignDescriptorsHelper
Definition: generated_message_reflection.cc:2248
google::protobuf::AssignDescriptorsHelper::AssignEnumDescriptor
void AssignEnumDescriptor(const EnumDescriptor *descriptor)
Definition: generated_message_reflection.cc:2283
google::protobuf.internal::ReflectionSchema::object_size_
int object_size_
Definition: generated_message_reflection.h:229
Json::UInt64
unsigned long long int UInt64
Definition: json.h:241
google::protobuf.internal::ExtensionSet
Definition: extension_set.h:179
google::protobuf::Reflection::GetStringReference
const std::string & GetStringReference(const Message &message, const FieldDescriptor *field, std::string *scratch) const
Definition: generated_message_reflection.cc:1171
google::protobuf.internal::ReflectionSchema::metadata_offset_
int metadata_offset_
Definition: generated_message_reflection.h:226
google::protobuf::Reflection::ClearOneofField
void ClearOneofField(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:2036
google::protobuf::FieldDescriptor::CPPTYPE_ENUM
@ CPPTYPE_ENUM
Definition: src/google/protobuf/descriptor.h:561
google::protobuf::RepeatedPtrField
Definition: command_line_interface.h:62
name
GLuint const GLchar * name
Definition: glcorearb.h:3055
google::protobuf.internal::InternalMetadataWithArenaBase::unknown_fields
const PROTOBUF_ALWAYS_INLINE T & unknown_fields() const
Definition: metadata_lite.h:74
google::protobuf::FieldDescriptor::enum_type
const EnumDescriptor * enum_type() const
Definition: src/google/protobuf/descriptor.cc:7235
google::protobuf::RepeatedPtrField::Add
Element * Add()
Definition: repeated_field.h:2035
USAGE_CHECK_REPEATED
#define USAGE_CHECK_REPEATED(METHOD)
Definition: generated_message_reflection.cc:207
google::protobuf::Reflection::HasOneofField
bool HasOneofField(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:2026
google::protobuf::value
const Descriptor::ReservedRange value
Definition: src/google/protobuf/descriptor.h:1954
google::protobuf::Reflection::MutableMapData
internal::MapFieldBase * MutableMapData(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:2211
google::protobuf::Reflection::ClearOneof
void ClearOneof(Message *message, const OneofDescriptor *oneof_descriptor) const
Definition: generated_message_reflection.cc:2043
google::protobuf::FieldDescriptor::CPPTYPE_STRING
@ CPPTYPE_STRING
Definition: src/google/protobuf/descriptor.h:562
google::protobuf::MessageFactory::InternalRegisterGeneratedFile
static void InternalRegisterGeneratedFile(const google::protobuf::internal::DescriptorTable *table)
Definition: src/google/protobuf/message.cc:659
google::protobuf::FieldDescriptor
Definition: src/google/protobuf/descriptor.h:515
google::protobuf::Message::SpaceUsedLong
virtual size_t SpaceUsedLong() const
Definition: src/google/protobuf/message.cc:552
google::protobuf::AssignDescriptorsHelper::AssignMessageDescriptor
void AssignMessageDescriptor(const Descriptor *descriptor)
Definition: generated_message_reflection.cc:2263
google::protobuf::Reflection::MutableField
Type * MutableField(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:2134
google::protobuf.internal::InternalMetadataWithArena
Definition: metadata.h:52
google::protobuf::Reflection::last_non_weak_field_index_
int last_non_weak_field_index_
Definition: src/google/protobuf/message.h:886
google::protobuf::Reflection::message_factory_
MessageFactory *const message_factory_
Definition: src/google/protobuf/message.h:881
google::protobuf::Reflection::SetRepeatedString
void SetRepeatedString(Message *message, const FieldDescriptor *field, int index, const std::string &value) const
Definition: generated_message_reflection.cc:1257
end
GLuint GLuint end
Definition: glcorearb.h:2858
google::protobuf.internal::RegisterFileLevelMetadata
void RegisterFileLevelMetadata(const DescriptorTable *table)
Definition: generated_message_reflection.cc:2417
SET_ONEOF_VALUE1
#define SET_ONEOF_VALUE1(CPPTYPE, TYPE)
google::protobuf.internal::ParseNamedEnum
PROTOBUF_EXPORT bool ParseNamedEnum(const EnumDescriptor *descriptor, const std::string &name, int *value)
Definition: generated_message_reflection.cc:82
NULL
NULL
Definition: test_security_zap.cpp:405
Bool
Definition: gtest_pred_impl_unittest.cc:56
google::protobuf::int64
int64_t int64
Definition: protobuf/src/google/protobuf/stubs/port.h:151
google::protobuf::AssignDescriptorsHelper::factory_
MessageFactory * factory_
Definition: generated_message_reflection.cc:2291
google::protobuf.internal::ExtensionSet::SpaceUsedExcludingSelfLong
size_t SpaceUsedExcludingSelfLong() const
Definition: extension_set_heavy.cc:409
google::protobuf.internal::ReflectionSchema::GetObjectSize
uint32 GetObjectSize() const
Definition: generated_message_reflection.h:129
map_field_inl.h
google::protobuf::FieldDescriptor::full_name
const std::string & full_name() const
google::protobuf::DescriptorPool::FindExtensionByPrintableName
const FieldDescriptor * FindExtensionByPrintableName(const Descriptor *extendee, const std::string &printable_name) const
Definition: src/google/protobuf/descriptor.cc:1522
google::protobuf::FieldDescriptor::CPPTYPE_UINT64
@ CPPTYPE_UINT64
Definition: src/google/protobuf/descriptor.h:557
google::protobuf::MessageLite::GetArena
virtual Arena * GetArena() const
Definition: message_lite.h:206
google::protobuf.internal::ReflectionSchema::IsFieldInlined
bool IsFieldInlined(const FieldDescriptor *field) const
Definition: generated_message_reflection.h:150
google::protobuf.internal::ExtensionSet::RemoveLast
void RemoveLast(int number)
Definition: extension_set.cc:797
extension_set.h
google::protobuf::AssignDescriptorsHelper::offsets_
const uint32 * offsets_
Definition: generated_message_reflection.cc:2296
base
Definition: logging.cc:2162
inlined_string_field.h
google::protobuf::uint8
uint8_t uint8
Definition: protobuf/src/google/protobuf/stubs/port.h:153
google::protobuf::Reflection::MutableExtensionSet
internal::ExtensionSet * MutableExtensionSet(Message *message) const
Definition: generated_message_reflection.cc:1893
google::protobuf::Reflection::SwapBit
void SwapBit(Message *message1, Message *message2, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:2002
FATAL
const int FATAL
Definition: log_severity.h:60
google::protobuf.internal::ReflectionSchema::GetFieldDefault
const void * GetFieldDefault(const FieldDescriptor *field) const
Definition: generated_message_reflection.h:208
google::protobuf::Reflection::UnsafeArenaSetAllocatedMessage
void UnsafeArenaSetAllocatedMessage(Message *message, Message *sub_message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1497
google::protobuf::Reflection::GetRepeatedStringReference
const std::string & GetRepeatedStringReference(const Message &message, const FieldDescriptor *field, int index, std::string *scratch) const
Definition: generated_message_reflection.cc:1241
GOOGLE_DCHECK
#define GOOGLE_DCHECK
Definition: logging.h:194
google::protobuf.internal::RepeatedPtrFieldBase::UnsafeArenaAddAllocated
void UnsafeArenaAddAllocated(typename TypeHandler::Type *value)
Definition: repeated_field.h:1821
google::protobuf::Message::GetReflection
const Reflection * GetReflection() const
Definition: src/google/protobuf/message.h:335
benchmarks.util.result_uploader.metadata
def metadata
Definition: result_uploader.py:97
google::protobuf::FieldDescriptor::CPPTYPE_INT64
@ CPPTYPE_INT64
Definition: src/google/protobuf/descriptor.h:555
FileDescriptor
Definition: ruby/ext/google/protobuf_c/protobuf.h:125
google::protobuf::python::descriptor::Get
static PyObject * Get(PyContainer *self, PyObject *args)
Definition: descriptor_containers.cc:455
google::protobuf.internal::ExtensionSet::SetRepeatedEnum
void SetRepeatedEnum(int number, int index, int value)
Definition: extension_set.cc:484
google::protobuf::Reflection::GetExtensionSet
const internal::ExtensionSet & GetExtensionSet(const Message &message) const
Definition: generated_message_reflection.cc:1888
google::protobuf::AssignDescriptorsHelper::schemas_
const MigrationSchema * schemas_
Definition: generated_message_reflection.cc:2294
google::protobuf::FieldDescriptor::CPPTYPE_UINT32
@ CPPTYPE_UINT32
Definition: src/google/protobuf/descriptor.h:556
google::protobuf::uint32
uint32_t uint32
Definition: protobuf/src/google/protobuf/stubs/port.h:155
google::protobuf::Reflection::MutableRawRepeatedString
void * MutableRawRepeatedString(Message *message, const FieldDescriptor *field, bool is_string) const
Definition: generated_message_reflection.cc:2105
google::protobuf::Message::CopyFrom
virtual void CopyFrom(const Message &from)
Definition: src/google/protobuf/message.cc:98
google::protobuf::MessageFactory::generated_factory
static MessageFactory * generated_factory()
Definition: src/google/protobuf/message.cc:655
setup.description
description
Definition: compatibility_tests/v2.5.0/setup.py:61
google::protobuf::Descriptor::FindFieldByNumber
const FieldDescriptor * FindFieldByNumber(int number) const
Definition: src/google/protobuf/descriptor.cc:1584
google::protobuf::Reflection::GetInternalMetadataWithArena
const internal::InternalMetadataWithArena & GetInternalMetadataWithArena(const Message &message) const
Definition: generated_message_reflection.cc:1902
google::protobuf.internal::call_once
void call_once(Args &&... args)
Definition: once.h:45
google::protobuf::Reflection::SetRepeatedEnumValueInternal
void SetRepeatedEnumValueInternal(Message *message, const FieldDescriptor *field, int index, int value) const
Definition: generated_message_reflection.cc:1395
desc
#define desc
Definition: extension_set.h:342
google::protobuf::Reflection::SetAllocatedMessage
void SetAllocatedMessage(Message *message, Message *sub_message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1530
google::protobuf::Reflection::GetMessageFactory
MessageFactory * GetMessageFactory() const
Definition: generated_message_reflection.cc:2185
CLEAR_TYPE
#define CLEAR_TYPE(CPPTYPE, TYPE)
google::protobuf::MessageFactory::GetPrototype
virtual const Message * GetPrototype(const Descriptor *type)=0
google::protobuf.internal::ArenaStringPtr::Get
const ::std::string & Get() const
Definition: arenastring.h:84
mu_
WrappedMutex mu_
Definition: generated_message_reflection.cc:2327
google::protobuf::Reflection::SupportsUnknownEnumValues
bool SupportsUnknownEnumValues() const
Definition: generated_message_reflection.cc:1823
google::protobuf::OneofDescriptor
Definition: src/google/protobuf/descriptor.h:843
google::protobuf.internal::ExtensionSet::ExtensionSize
int ExtensionSize(int number) const
Definition: extension_set.cc:253
left
GLint left
Definition: glcorearb.h:4150
google::protobuf.internal::InitSCC
void InitSCC(SCCInfoBase *scc)
Definition: generated_message_util.h:217
google::protobuf.internal::ExtensionSet::UnsafeArenaSetAllocatedMessage
void UnsafeArenaSetAllocatedMessage(int number, FieldType type, const FieldDescriptor *descriptor, MessageLite *message)
Definition: extension_set.cc:666
generated_message_reflection.h
google::protobuf::Reflection::schema_
const internal::ReflectionSchema schema_
Definition: src/google/protobuf/message.h:879
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
google::protobuf::Reflection::GetRepeatedEnum
const EnumValueDescriptor * GetRepeatedEnum(const Message &message, const FieldDescriptor *field, int index) const
Definition: generated_message_reflection.cc:1349
google::protobuf::Reflection::SetString
void SetString(Message *message, const FieldDescriptor *field, const std::string &value) const
Definition: generated_message_reflection.cc:1193
google::protobuf::Reflection::GetRepeatedField
const RepeatedField< T > & GetRepeatedField(const Message &, const FieldDescriptor *) const
google::protobuf::python::cdescriptor_pool::Add
static PyObject * Add(PyObject *self, PyObject *file_descriptor_proto)
Definition: descriptor_pool.cc:621
GOOGLE_PROTOBUF_LINKER_INITIALIZED
#define GOOGLE_PROTOBUF_LINKER_INITIALIZED
Definition: protobuf/src/google/protobuf/stubs/mutex.h:70
google::protobuf.internal::ReflectionSchema::default_instance_
const Message * default_instance_
Definition: generated_message_reflection.h:222
google::protobuf::Reflection::Swap
void Swap(Message *message1, Message *message2) const
Definition: generated_message_reflection.cc:600
google::protobuf::Reflection
Definition: src/google/protobuf/message.h:400
google::protobuf.internal::NameOfEnum
const PROTOBUF_EXPORT std::string & NameOfEnum(const EnumDescriptor *descriptor, int value)
Definition: generated_message_reflection.cc:90
descriptor
Descriptor * descriptor
Definition: php/ext/google/protobuf/protobuf.h:936
map
zval * map
Definition: php/ext/google/protobuf/encode_decode.c:473
google::protobuf.internal::RepeatedPtrFieldBase::Get
const TypeHandler::WeakType & Get(int index) const
Definition: repeated_field.h:1546
google::protobuf::Reflection::HasField
bool HasField(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:728
google::protobuf::Reflection::ContainsMapKey
bool ContainsMapKey(const Message &message, const FieldDescriptor *field, const MapKey &key) const
Definition: generated_message_reflection.cc:1761
google::protobuf::HANDLE_TYPE
HANDLE_TYPE(int32, FieldDescriptor::CPPTYPE_INT32, -1)
google::protobuf.internal::ReflectionSchema::GetFieldOffset
uint32 GetFieldOffset(const FieldDescriptor *field) const
Definition: generated_message_reflection.h:139
testing::internal::Int32
TypeWithSize< 4 >::Int Int32
Definition: gtest-port.h:2241
google::protobuf.internal::ExtensionSet::Swap
void Swap(ExtensionSet *other)
Definition: extension_set.cc:1065
google::protobuf::MessageFactory
Definition: src/google/protobuf/message.h:1069
google::protobuf::Reflection::SpaceUsedLong
size_t SpaceUsedLong(const Message &message) const
Definition: generated_message_reflection.cc:241
google::protobuf::Reflection::MapSize
int MapSize(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1803
google::uint32
uint32_t uint32
Definition: sdk/include/aditof/log.h:59
Descriptor
Definition: ruby/ext/google/protobuf_c/protobuf.h:113
google::protobuf::Reflection::GetOneofFieldDescriptor
const FieldDescriptor * GetOneofFieldDescriptor(const Message &message, const OneofDescriptor *oneof_descriptor) const
Definition: generated_message_reflection.cc:1752
map_field.h
google::protobuf.internal::ExtensionSet::MutableRawRepeatedField
void * MutableRawRepeatedField(int number, FieldType field_type, bool packed, const FieldDescriptor *desc)
Definition: extension_set.cc:377
google::protobuf.internal::ReflectionSchema::has_bits_offset_
int has_bits_offset_
Definition: generated_message_reflection.h:225
google::protobuf::RepeatedPtrField::Mutable
Element * Mutable(int index)
Definition: repeated_field.h:2030
google::protobuf.internal::MigrationSchema::object_size
int object_size
Definition: generated_message_reflection.h:263
SWAP_VALUES
#define SWAP_VALUES(CPPTYPE, TYPE)
GOOGLE_DCHECK_NE
#define GOOGLE_DCHECK_NE
Definition: logging.h:197
google::protobuf::Reflection::SetEnumValueInternal
void SetEnumValueInternal(Message *message, const FieldDescriptor *field, int value) const
Definition: generated_message_reflection.cc:1338
testing::internal::Double
FloatingPoint< double > Double
Definition: gtest-internal.h:429
google::protobuf::Reflection::GetHasBits
const uint32 * GetHasBits(const Message &message) const
Definition: generated_message_reflection.cc:1866
testing::internal::UInt32
TypeWithSize< 4 >::UInt UInt32
Definition: gtest-port.h:2242
google::protobuf::Reflection::AddField
void AddField(Message *message, const FieldDescriptor *field, const Type &value) const
Definition: generated_message_reflection.cc:2172
google::protobuf::MessageFactory::InternalRegisterGeneratedMessage
static void InternalRegisterGeneratedMessage(const Descriptor *descriptor, const Message *prototype)
Definition: src/google/protobuf/message.cc:664
FieldDescriptor
Definition: ruby/ext/google/protobuf_c/protobuf.h:129
google::protobuf.internal::OnShutdownDelete
T * OnShutdownDelete(T *p)
Definition: common.h:185
google::protobuf::Reflection::GetRepeatedString
std::string GetRepeatedString(const Message &message, const FieldDescriptor *field, int index) const
Definition: generated_message_reflection.cc:1226
message_type
zend_class_entry * message_type
Definition: php/ext/google/protobuf/message.c:45
google::protobuf.internal::InternalMetadataWithArenaBase::mutable_unknown_fields
PROTOBUF_ALWAYS_INLINE T * mutable_unknown_fields()
Definition: metadata_lite.h:82
google::protobuf::Descriptor::field
const FieldDescriptor * field(int index) const
range
GLenum GLint * range
Definition: glcorearb.h:3963
begin
static size_t begin(const upb_table *t)
Definition: php/ext/google/protobuf/upb.c:4898
google::protobuf::int32
int32_t int32
Definition: protobuf/src/google/protobuf/stubs/port.h:150
google::protobuf.internal::ReflectionSchema::offsets_
const uint32 * offsets_
Definition: generated_message_reflection.h:223
google::protobuf::Reflection::SwapFields
void SwapFields(Message *message1, Message *message2, const std::vector< const FieldDescriptor * > &fields) const
Definition: generated_message_reflection.cc:673
google::protobuf::AssignDescriptorsHelper::default_instance_data_
const Message *const * default_instance_data_
Definition: generated_message_reflection.cc:2295
google::protobuf::Reflection::descriptor_pool_
const DescriptorPool *const descriptor_pool_
Definition: src/google/protobuf/message.h:880
google::protobuf.internal::ExtensionSet::AppendToList
void AppendToList(const Descriptor *containing_type, const DescriptorPool *pool, std::vector< const FieldDescriptor * > *output) const
Definition: extension_set_heavy.cc:102
google::protobuf::DescriptorPool::InternalAddGeneratedFile
static void InternalAddGeneratedFile(const void *encoded_file_descriptor, int size)
Definition: src/google/protobuf/descriptor.cc:1355
google::protobuf.internal::ExtensionSet::SetRepeatedString
void SetRepeatedString(int number, int index, const std::string &value)
Definition: extension_set.h:866
USAGE_CHECK_SINGULAR
#define USAGE_CHECK_SINGULAR(METHOD)
Definition: generated_message_reflection.cc:204
Type
Definition: type.pb.h:182
google::protobuf.internal::ReflectionSchema::HasBitIndex
uint32 HasBitIndex(const FieldDescriptor *field) const
Definition: generated_message_reflection.h:170
google::protobuf::Reflection::MutableUnknownFields
UnknownFieldSet * MutableUnknownFields(Message *message) const
Definition: generated_message_reflection.cc:237
google::protobuf::Reflection::AddEnum
void AddEnum(Message *message, const FieldDescriptor *field, const EnumValueDescriptor *value) const
Definition: generated_message_reflection.cc:1406
google::protobuf::Reflection::MutableRepeatedField
RepeatedField< T > * MutableRepeatedField(Message *, const FieldDescriptor *) const
google::protobuf.internal::ExtensionSet::MutableMessage
MessageLite * MutableMessage(int number, FieldType type, const MessageLite &prototype, desc)
testing::internal::Float
FloatingPoint< float > Float
Definition: gtest-internal.h:428
offset
GLintptr offset
Definition: glcorearb.h:2944
google::protobuf::Reflection::HasOneof
bool HasOneof(const Message &message, const OneofDescriptor *oneof_descriptor) const
Definition: generated_message_reflection.cc:2021
google::protobuf::DescriptorPool::internal_generated_pool
static DescriptorPool * internal_generated_pool()
Definition: src/google/protobuf/descriptor.cc:1340
google::protobuf::Descriptor::oneof_decl
const OneofDescriptor * oneof_decl(int index) const
google::protobuf.internal::RepeatedPtrFieldBase::size
int size() const
Definition: repeated_field.h:1543
google::protobuf.internal::StringSpaceUsedExcludingSelfLong
size_t StringSpaceUsedExcludingSelfLong(const std::string &str)
Definition: generated_message_util.cc:86
google::protobuf::UnknownFieldSet::AddVarint
void AddVarint(int number, uint64 value)
Definition: unknown_field_set.cc:134
google::protobuf::Reflection::ClearBit
void ClearBit(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1991
google::protobuf::DescriptorPool
Definition: src/google/protobuf/descriptor.h:1539
google::protobuf.internal::ExtensionSet::SetString
void SetString(int number, FieldType type, const std::string &value, desc)
Definition: extension_set.h:861
google::protobuf.internal::ExtensionSet::AddString
void AddString(int number, FieldType type, const std::string &value, desc)
google::protobuf::Reflection::GetUnknownFields
const UnknownFieldSet & GetUnknownFields(const Message &message) const
Definition: generated_message_reflection.cc:232
google::protobuf::Reflection::GetRepeatedEnumValue
int GetRepeatedEnumValue(const Message &message, const FieldDescriptor *field, int index) const
Definition: generated_message_reflection.cc:1356
google::protobuf::Descriptor::oneof_decl_count
int oneof_decl_count() const
google::protobuf::Reflection::AddEnumValue
void AddEnumValue(Message *message, const FieldDescriptor *field, int value) const
Definition: generated_message_reflection.cc:1413
google::protobuf.internal::ExtensionSet::GetRepeatedEnum
int GetRepeatedEnum(int number, int index) const
Definition: extension_set.cc:477
google::protobuf::FieldDescriptor::number
int number() const
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: logging.h:146
google::protobuf::Reflection::ClearField
void ClearField(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:789
std::swap
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
Definition: json.h:1226
google::protobuf.internal::UnknownFieldSetSerializer
void UnknownFieldSetSerializer(const uint8 *base, uint32 offset, uint32 tag, uint32 has_offset, io::CodedOutputStream *output)
Definition: generated_message_reflection.cc:2422
EnumValueDescriptor
struct EnumValueDescriptor EnumValueDescriptor
Definition: php/ext/google/protobuf/protobuf.h:634
google::protobuf::Metadata::descriptor
const Descriptor * descriptor
Definition: src/google/protobuf/message.h:191
google::protobuf::Reflection::GetEnum
const EnumValueDescriptor * GetEnum(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1294
google::protobuf::Reflection::RepeatedFieldData
void * RepeatedFieldData(Message *message, const FieldDescriptor *field, FieldDescriptor::CppType cpp_type, const Descriptor *message_type) const
Definition: generated_message_reflection.cc:2189
google::protobuf::Reflection::MapBegin
MapIterator MapBegin(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1787
google::protobuf::uint64
uint64_t uint64
Definition: protobuf/src/google/protobuf/stubs/port.h:156
google::protobuf::Reflection::SetField
void SetField(Message *message, const FieldDescriptor *field, const Type &value) const
Definition: generated_message_reflection.cc:2123
size
#define size
Definition: glcorearb.h:2944
google::protobuf::Reflection::GetRawRepeatedField
const void * GetRawRepeatedField(const Message &message, const FieldDescriptor *field, FieldDescriptor::CppType cpptype, int ctype, const Descriptor *message_type) const
Definition: generated_message_reflection.cc:1722
google::protobuf::Metadata::reflection
const Reflection * reflection
Definition: src/google/protobuf/message.h:192
repeated_field.h
google::protobuf::Reflection::SetRepeatedEnumValue
void SetRepeatedEnumValue(Message *message, const FieldDescriptor *field, int index, int value) const
Definition: generated_message_reflection.cc:1378
google::protobuf::Reflection::InsertOrLookupMapValue
bool InsertOrLookupMapValue(Message *message, const FieldDescriptor *field, const MapKey &key, MapValueRef *val) const
Definition: generated_message_reflection.cc:1769
google::protobuf::Reflection::SwapElements
void SwapElements(Message *message, const FieldDescriptor *field, int index1, int index2) const
Definition: generated_message_reflection.cc:969
google::protobuf::Reflection::RemoveLast
void RemoveLast(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:902
google::protobuf::Reflection::GetRepeatedPtrField
const RepeatedPtrField< T > & GetRepeatedPtrField(const Message &, const FieldDescriptor *) const
google::protobuf.internal::DescriptorTable
Definition: generated_message_reflection.h:266
google::protobuf.internal::ExtensionSet::GetEnum
int GetEnum(int number, int default_value) const
Definition: extension_set.cc:452
google::protobuf::Descriptor::field_count
int field_count() const
d
d
google::protobuf.internal::MigrationSchema::has_bit_indices_index
int32 has_bit_indices_index
Definition: generated_message_reflection.h:262
google::protobuf.internal::WireFormat::SerializeUnknownFields
static void SerializeUnknownFields(const UnknownFieldSet &unknown_fields, io::CodedOutputStream *output)
Definition: wire_format.cc:191
google::protobuf::Reflection::SetEnum
void SetEnum(Message *message, const FieldDescriptor *field, const EnumValueDescriptor *value) const
Definition: generated_message_reflection.cc:1315
google::protobuf::FileDescriptor::SYNTAX_PROTO3
@ SYNTAX_PROTO3
Definition: src/google/protobuf/descriptor.h:1394
google::protobuf.internal::ExtensionSet::ClearExtension
void ClearExtension(int number)
Definition: extension_set.cc:270
google::protobuf.internal::InlinedStringField::Swap
void Swap(InlinedStringField *from) PROTOBUF_ALWAYS_INLINE
Definition: inlined_string_field.h:226
google::protobuf.internal::ExtensionSet::GetRepeatedMessage
const MessageLite & GetRepeatedMessage(int number, int index) const
Definition: extension_set.cc:749
field
const FieldDescriptor * field
Definition: parser_unittest.cc:2694
google::protobuf::Reflection::AddString
void AddString(Message *message, const FieldDescriptor *field, const std::string &value) const
Definition: generated_message_reflection.cc:1275
google::protobuf::Reflection::FieldSize
int FieldSize(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:744
key
const SETUP_TEARDOWN_TESTCONTEXT char * key
Definition: test_wss_transport.cpp:10
google::protobuf.internal::ReflectionSchema::weak_field_map_offset_
int weak_field_map_offset_
Definition: generated_message_reflection.h:230
google::protobuf.internal::ExtensionSet::GetString
const std::string & GetString(int number, const std::string &default_value) const
Definition: extension_set.cc:511
google::protobuf::AssignDescriptorsHelper::GetCurrentMetadataPtr
const Metadata * GetCurrentMetadataPtr() const
Definition: generated_message_reflection.cc:2288
google::protobuf::Reflection::GetOneofCase
uint32 GetOneofCase(const Message &message, const OneofDescriptor *oneof_descriptor) const
Definition: generated_message_reflection.cc:1876
google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE
@ CPPTYPE_DOUBLE
Definition: src/google/protobuf/descriptor.h:558
google::protobuf.internal::ExtensionSet::AddAllocatedMessage
void AddAllocatedMessage(const FieldDescriptor *descriptor, MessageLite *new_entry)
Definition: extension_set_heavy.cc:283
google::protobuf::Reflection::MutableMessage
Message * MutableMessage(Message *message, const FieldDescriptor *field, MessageFactory *factory=nullptr) const
Definition: generated_message_reflection.cc:1462
google::protobuf::Reflection::GetArena
Arena * GetArena(Message *message) const
Definition: generated_message_reflection.cc:1898
GOOGLE_CHECK
#define GOOGLE_CHECK(EXPRESSION)
Definition: logging.h:153
google::protobuf.internal::InlinedStringField
Definition: inlined_string_field.h:61
pool
InternalDescriptorPool * pool
Definition: php/ext/google/protobuf/protobuf.h:798
metadata_arrays_
std::vector< std::pair< const Metadata *, const Metadata * > > metadata_arrays_
Definition: generated_message_reflection.cc:2328
google::protobuf::io::CodedOutputStream
Definition: coded_stream.h:693
i
int i
Definition: gmock-matchers_test.cc:764
USAGE_CHECK_MESSAGE_TYPE
#define USAGE_CHECK_MESSAGE_TYPE(METHOD)
Definition: generated_message_reflection.cc:201
google::protobuf.internal::ReflectionSchema::oneof_case_offset_
int oneof_case_offset_
Definition: generated_message_reflection.h:228
google::protobuf::Metadata
Definition: src/google/protobuf/message.h:190
google::protobuf.internal::GetEmptyString
const PROTOBUF_EXPORT std::string & GetEmptyString()
Definition: generated_message_util.h:87
USAGE_CHECK
#define USAGE_CHECK(CONDITION, METHOD, ERROR_DESCRIPTION)
Definition: generated_message_reflection.cc:184
google::protobuf.internal::ExtensionSet::Has
bool Has(int number) const
Definition: extension_set.cc:236
google::protobuf.internal::ReflectionSchema::GetMetadataOffset
uint32 GetMetadataOffset() const
Definition: generated_message_reflection.h:185
fields
static const upb_fielddef fields[107]
Definition: ruby/ext/google/protobuf_c/upb.c:7671
google::protobuf::Reflection::MutableRawRepeatedField
void * MutableRawRepeatedField(Message *message, const FieldDescriptor *field, FieldDescriptor::CppType, int ctype, const Descriptor *message_type) const
Definition: generated_message_reflection.cc:1698
google::protobuf::DescriptorPool::FindExtensionByNumber
const FieldDescriptor * FindExtensionByNumber(const Descriptor *extendee, int number) const
Definition: src/google/protobuf/descriptor.cc:1488
google::protobuf::FieldDescriptor::CPPTYPE_FLOAT
@ CPPTYPE_FLOAT
Definition: src/google/protobuf/descriptor.h:559
google::protobuf.internal::ReflectionSchema::GetFieldOffsetNonOneof
uint32 GetFieldOffsetNonOneof(const FieldDescriptor *field) const
Definition: generated_message_reflection.h:133
google::protobuf::FieldDescriptor::CPPTYPE_BOOL
@ CPPTYPE_BOOL
Definition: src/google/protobuf/descriptor.h:560
google::protobuf::Reflection::SwapField
void SwapField(Message *message1, Message *message2, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:361
google::protobuf::Reflection::ReleaseLast
Message * ReleaseLast(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:950
google::protobuf.internal::ArenaStringPtr::Swap
PROTOBUF_ALWAYS_INLINE void Swap(ArenaStringPtr *other)
Definition: arenastring.h:172
google::protobuf::Reflection::MutableHasBits
uint32 * MutableHasBits(Message *message) const
Definition: generated_message_reflection.cc:1871
google::protobuf.internal::ReflectionSchema::HasHasbits
bool HasHasbits() const
Definition: generated_message_reflection.h:167
google::protobuf::Message
Definition: src/google/protobuf/message.h:205
google::protobuf.internal::RepeatedPtrFieldBase::AddFromCleared
TypeHandler::Type * AddFromCleared()
Definition: repeated_field.h:1742
google::protobuf::Message::GetDescriptor
const Descriptor * GetDescriptor() const
Definition: src/google/protobuf/message.h:326
google::protobuf::Reflection::DefaultRaw
const Type & DefaultRaw(const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1915
google::protobuf.internal::ExtensionSet::SwapElements
void SwapElements(int number, int index1, int index2)
Definition: extension_set.cc:844
google::protobuf.internal.python_message.Clear
Clear
Definition: python_message.py:1431
common.h
google::protobuf::Reflection::MutableRepeatedMessage
Message * MutableRepeatedMessage(Message *message, const FieldDescriptor *field, int index) const
Definition: generated_message_reflection.cc:1617
google::protobuf::EnumDescriptor::full_name
const std::string & full_name() const
google::protobuf.internal::MigrationSchema
Definition: generated_message_reflection.h:260
google::protobuf.internal::ExtensionSet::SwapExtension
void SwapExtension(ExtensionSet *other, int number)
Definition: extension_set.cc:1084
google::protobuf::Reflection::descriptor_
const Descriptor *const descriptor_
Definition: src/google/protobuf/message.h:878
google::protobuf::Reflection::SetEnumValue
void SetEnumValue(Message *message, const FieldDescriptor *field, int value) const
Definition: generated_message_reflection.cc:1322
size
GLsizeiptr size
Definition: glcorearb.h:2943
google::protobuf::MapKey
Definition: map_field.h:371
google::protobuf::Reflection::DeleteMapValue
bool DeleteMapValue(Message *message, const FieldDescriptor *field, const MapKey &key) const
Definition: generated_message_reflection.cc:1780
google::protobuf::Reflection::GetRawNonOneof
const T & GetRawNonOneof(const Message &message, const FieldDescriptor *field) const
google::protobuf::Reflection::MutableRawNonOneof
T * MutableRawNonOneof(Message *message, const FieldDescriptor *field) const
google::protobuf::Reflection::UnsafeArenaReleaseMessage
Message * UnsafeArenaReleaseMessage(Message *message, const FieldDescriptor *field, MessageFactory *factory=nullptr) const
Definition: generated_message_reflection.cc:1556
google::protobuf::OneofDescriptor::index
int index() const
Definition: src/google/protobuf/descriptor.h:2103
google::protobuf.internal::ExtensionSet::GetRepeatedString
const std::string & GetRepeatedString(int number, int index) const
Definition: extension_set.cc:538
google::protobuf::Reflection::GetRaw
const Type & GetRaw(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1848
google::protobuf::Reflection::SetOneofCase
void SetOneofCase(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:2031
google::protobuf::UnknownFieldSet
Definition: unknown_field_set.h:86
wire_format.h
m
const upb_json_parsermethod * m
Definition: ruby/ext/google/protobuf_c/upb.h:10501
logging.h
google::protobuf::Message::MergeFrom
virtual void MergeFrom(const Message &from)
Definition: src/google/protobuf/message.cc:82
google::protobuf.internal::InternalMetadataWithArenaBase::arena
PROTOBUF_ALWAYS_INLINE Arena * arena() const
Definition: metadata_lite.h:90
DEFINE_PRIMITIVE_ACCESSORS
#define DEFINE_PRIMITIVE_ACCESSORS(TYPENAME, TYPE, PASSTYPE, CPPTYPE)
Definition: generated_message_reflection.cc:1082
google::protobuf::Descriptor::file
const FileDescriptor * file() const
google::protobuf::FieldDescriptor::MAX_CPPTYPE
@ MAX_CPPTYPE
Definition: src/google/protobuf/descriptor.h:565
google::protobuf::EnumValueDescriptor
Definition: src/google/protobuf/descriptor.h:1075
google::protobuf.internal::ExtensionSet::GetMessage
const MessageLite & GetMessage(int number, const MessageLite &default_value) const
Definition: extension_set.cc:572
google::protobuf::Descriptor
Definition: src/google/protobuf/descriptor.h:231
descriptor.h
google::protobuf::Reflection::Reflection
Reflection(const Descriptor *descriptor, const internal::ReflectionSchema &schema, const DescriptorPool *pool, MessageFactory *factory)
Definition: generated_message_reflection.cc:220
google::protobuf::Reflection::MutableOneofCase
uint32 * MutableOneofCase(Message *message, const OneofDescriptor *oneof_descriptor) const
Definition: generated_message_reflection.cc:1882
google::protobuf::RegisterAllTypesInternal
void RegisterAllTypesInternal(const Metadata *file_level_metadata, int size)
Definition: generated_message_reflection.cc:2392
google::protobuf::AssignDescriptorsHelper::file_level_metadata_
Metadata * file_level_metadata_
Definition: generated_message_reflection.cc:2292
google::protobuf::Message::New
Message * New() const override=0
generated_message_util.h
google::protobuf.internal::RepeatedPtrFieldBase
Definition: repeated_field.h:459
google::protobuf::Reflection::GetField
const Type & GetField(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:2117
google::protobuf::AssignDescriptorsHelper::file_level_enum_descriptors_
const EnumDescriptor ** file_level_enum_descriptors_
Definition: generated_message_reflection.cc:2293
google::protobuf::Reflection::GetEnumValue
int GetEnumValue(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1301
google::protobuf::Reflection::HasBit
bool HasBit(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1920
mutex.h
SWAP_ARRAYS
#define SWAP_ARRAYS(CPPTYPE, TYPE)
google::protobuf::AssignDescriptorsHelper::AssignDescriptorsHelper
AssignDescriptorsHelper(MessageFactory *factory, Metadata *file_level_metadata, const EnumDescriptor **file_level_enum_descriptors, const MigrationSchema *schemas, const Message *const *default_instance_data, const uint32 *offsets)
Definition: generated_message_reflection.cc:2250
google::protobuf::Reflection::SetBit
void SetBit(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1981
google::protobuf.internal::RepeatedPtrFieldBase::AddAllocated
void AddAllocated(typename TypeHandler::Type *value)
Definition: repeated_field.h:547
google::protobuf.internal::ReflectionSchema
Definition: generated_message_reflection.h:126
google::protobuf::Reflection::SetRepeatedField
void SetRepeatedField(Message *message, const FieldDescriptor *field, int index, Type value) const
Definition: generated_message_reflection.cc:2156
google::protobuf::Reflection::MutableInternalMetadataWithArena
internal::InternalMetadataWithArena * MutableInternalMetadataWithArena(Message *message) const
Definition: generated_message_reflection.cc:1908
google::protobuf.internal::ExtensionSet::UnsafeArenaReleaseMessage
MessageLite * UnsafeArenaReleaseMessage(int number, const MessageLite &prototype)
Definition: extension_set.cc:723
FieldOptions::STRING
static constexpr CType STRING
Definition: descriptor.pb.h:4197
google::protobuf::Reflection::MutableRaw
Type * MutableRaw(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1861
google::protobuf.internal::ExtensionSet::ReleaseLast
MessageLite * ReleaseLast(int number)
Definition: extension_set.cc:836
internal
Definition: any.pb.h:40
google::protobuf.internal::MapFieldBase
Definition: map_field.h:69
google::protobuf.internal::AssignDescriptors
void AssignDescriptors(const DescriptorTable *table)
Definition: generated_message_reflection.cc:2403
SET_ONEOF_VALUE2
#define SET_ONEOF_VALUE2(CPPTYPE, TYPE)
USAGE_CHECK_ENUM_VALUE
#define USAGE_CHECK_ENUM_VALUE(METHOD)
Definition: generated_message_reflection.cc:197
val
GLuint GLfloat * val
Definition: glcorearb.h:3604
google::protobuf::Reflection::SwapOneofField
void SwapOneofField(Message *message1, Message *message2, const OneofDescriptor *oneof_descriptor) const
Definition: generated_message_reflection.cc:485
google::protobuf.internal::GenericTypeHandler
Definition: arena.h:91
google::protobuf::Reflection::GetMapData
const internal::MapFieldBase * GetMapData(const Message &message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:2218
google::protobuf::Reflection::IsInlined
bool IsInlined(const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1856
google::protobuf::Reflection::AddAllocatedMessage
void AddAllocatedMessage(Message *message, const FieldDescriptor *field, Message *new_entry) const
Definition: generated_message_reflection.cc:1679
google::protobuf.internal::ExtensionSet::AddMessage
MessageLite * AddMessage(int number, FieldType type, const MessageLite &prototype, desc)
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
descriptor_
const Descriptor * descriptor_
Definition: field_comparator_test.cc:56
descriptor.pb.h
google::protobuf.internal::ReflectionSchema::HasExtensionSet
bool HasExtensionSet() const
Definition: generated_message_reflection.h:190
google::protobuf.internal::ExtensionSet::AddEnum
void AddEnum(int number, FieldType type, bool packed, int value, desc)
Definition: extension_set.cc:491
google::protobuf::Reflection::AddMessage
Message * AddMessage(Message *message, const FieldDescriptor *field, MessageFactory *factory=nullptr) const
Definition: generated_message_reflection.cc:1638
google::protobuf.internal::ReflectionSchema::IsDefaultInstance
bool IsDefaultInstance(const Message &message) const
Definition: generated_message_reflection.h:202
google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE
@ CPPTYPE_MESSAGE
Definition: src/google/protobuf/descriptor.h:563
google::protobuf::Reflection::ReleaseMessage
Message * ReleaseMessage(Message *message, const FieldDescriptor *field, MessageFactory *factory=nullptr) const
Definition: generated_message_reflection.cc:1585
google::protobuf.internal::ReflectionSchema::has_bit_indices_
const uint32 * has_bit_indices_
Definition: generated_message_reflection.h:224
output
const upb_json_parsermethod const upb_symtab upb_sink * output
Definition: ruby/ext/google/protobuf_c/upb.h:10503
google::protobuf.internal::ReflectionSchema::extensions_offset_
int extensions_offset_
Definition: generated_message_reflection.h:227
google::protobuf::MapIterator
Definition: map_field.h:712
google::protobuf::Reflection::SetRepeatedEnum
void SetRepeatedEnum(Message *message, const FieldDescriptor *field, int index, const EnumValueDescriptor *value) const
Definition: generated_message_reflection.cc:1370
google::protobuf.internal::MigrationSchema::offsets_index
int32 offsets_index
Definition: generated_message_reflection.h:261
google::protobuf::FieldDescriptor::CPPTYPE_INT32
@ CPPTYPE_INT32
Definition: src/google/protobuf/descriptor.h:554
google::protobuf::EnumDescriptor
Definition: src/google/protobuf/descriptor.h:918
google::protobuf.internal::ReflectionSchema::GetExtensionSetOffset
uint32 GetExtensionSetOffset() const
Definition: generated_message_reflection.h:193
index
GLuint index
Definition: glcorearb.h:3055
google::protobuf::UnknownFieldSet::Swap
void Swap(UnknownFieldSet *x)
Definition: unknown_field_set.h:307
google::protobuf.internal::ExtensionSet::SetEnum
void SetEnum(int number, FieldType type, int value, desc)
Definition: extension_set.cc:463
google::protobuf::Reflection::ListFields
void ListFields(const Message &message, std::vector< const FieldDescriptor * > *output) const
Definition: generated_message_reflection.cc:1029
USAGE_CHECK_ALL
#define USAGE_CHECK_ALL(METHOD, LABEL, CPPTYPE)
Definition: generated_message_reflection.cc:211
google::protobuf.internal::ReflectionSchema::HasBitsOffset
uint32 HasBitsOffset() const
Definition: generated_message_reflection.h:176
Json::Int64
long long int Int64
Definition: json.h:240
google::protobuf::FieldDescriptor::cpp_type
CppType cpp_type() const
Definition: src/google/protobuf/descriptor.h:2139
number
double number
Definition: cJSON.h:326
google::protobuf::FieldDescriptor::CppType
CppType
Definition: src/google/protobuf/descriptor.h:553
google
Definition: data_proto2_to_proto3_util.h:11
google::protobuf.internal::ArenaStringPtr
Definition: arenastring.h:68
message
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glcorearb.h:2695
google::protobuf.internal::ExtensionSet::MutableRepeatedMessage
MessageLite * MutableRepeatedMessage(int number, int index)
Definition: extension_set.cc:757
google::protobuf.internal::ArenaStringPtr::Set
void Set(const ::std::string *default_value, const ::std::string &value, Arena *arena)
Definition: arenastring.h:69
google::protobuf::Reflection::GetRepeatedMessage
const Message & GetRepeatedMessage(const Message &message, const FieldDescriptor *field, int index) const
Definition: generated_message_reflection.cc:1597
google::protobuf::method
const Descriptor::ReservedRange const EnumValueDescriptor method
Definition: src/google/protobuf/descriptor.h:1973
google::protobuf.internal::cpp_type
FieldDescriptor::CppType cpp_type(FieldType type)
Definition: extension_set_heavy.cc:133
google::protobuf.internal::AddDescriptors
void AddDescriptors(const DescriptorTable *table)
Definition: generated_message_reflection.cc:2407
google::protobuf::UnknownFieldSet::SpaceUsedExcludingSelfLong
size_t SpaceUsedExcludingSelfLong() const
Definition: unknown_field_set.cc:107
google::protobuf::Reflection::AddEnumValueInternal
void AddEnumValueInternal(Message *message, const FieldDescriptor *field, int value) const
Definition: generated_message_reflection.cc:1429
google::protobuf::Reflection::GetMessage
const Message & GetMessage(const Message &message, const FieldDescriptor *field, MessageFactory *factory=nullptr) const
Definition: generated_message_reflection.cc:1443
google::protobuf::MapValueRef
Definition: map_field.h:565
google::protobuf::FieldDescriptor::is_map
bool is_map() const
Definition: src/google/protobuf/descriptor.h:2075
google::protobuf::Reflection::MapEnd
MapIterator MapEnd(Message *message, const FieldDescriptor *field) const
Definition: generated_message_reflection.cc:1795


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:51