unittest_arena.pb.cc 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. // Generated by the protocol buffer compiler. DO NOT EDIT!
  2. // source: google/protobuf/unittest_arena.proto
  3. #include <google/protobuf/unittest_arena.pb.h>
  4. #include <algorithm>
  5. #include <google/protobuf/stubs/common.h>
  6. #include <google/protobuf/stubs/port.h>
  7. #include <google/protobuf/io/coded_stream.h>
  8. #include <google/protobuf/wire_format_lite_inl.h>
  9. #include <google/protobuf/descriptor.h>
  10. #include <google/protobuf/generated_message_reflection.h>
  11. #include <google/protobuf/reflection_ops.h>
  12. #include <google/protobuf/wire_format.h>
  13. // This is a temporary google only hack
  14. #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  15. #include "third_party/protobuf/version.h"
  16. #endif
  17. // @@protoc_insertion_point(includes)
  18. namespace protobuf_google_2fprotobuf_2funittest_5farena_2eproto {
  19. extern PROTOBUF_INTERNAL_EXPORT_protobuf_google_2fprotobuf_2funittest_5farena_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_NestedMessage;
  20. } // namespace protobuf_google_2fprotobuf_2funittest_5farena_2eproto
  21. namespace protobuf_google_2fprotobuf_2funittest_5fno_5farena_5fimport_2eproto {
  22. extern PROTOBUF_INTERNAL_EXPORT_protobuf_google_2fprotobuf_2funittest_5fno_5farena_5fimport_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_ImportNoArenaNestedMessage;
  23. } // namespace protobuf_google_2fprotobuf_2funittest_5fno_5farena_5fimport_2eproto
  24. namespace proto2_arena_unittest {
  25. class NestedMessageDefaultTypeInternal {
  26. public:
  27. ::google::protobuf::internal::ExplicitlyConstructed<NestedMessage>
  28. _instance;
  29. } _NestedMessage_default_instance_;
  30. class ArenaMessageDefaultTypeInternal {
  31. public:
  32. ::google::protobuf::internal::ExplicitlyConstructed<ArenaMessage>
  33. _instance;
  34. } _ArenaMessage_default_instance_;
  35. } // namespace proto2_arena_unittest
  36. namespace protobuf_google_2fprotobuf_2funittest_5farena_2eproto {
  37. static void InitDefaultsNestedMessage() {
  38. GOOGLE_PROTOBUF_VERIFY_VERSION;
  39. {
  40. void* ptr = &::proto2_arena_unittest::_NestedMessage_default_instance_;
  41. new (ptr) ::proto2_arena_unittest::NestedMessage();
  42. ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  43. }
  44. ::proto2_arena_unittest::NestedMessage::InitAsDefaultInstance();
  45. }
  46. ::google::protobuf::internal::SCCInfo<0> scc_info_NestedMessage =
  47. {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsNestedMessage}, {}};
  48. static void InitDefaultsArenaMessage() {
  49. GOOGLE_PROTOBUF_VERIFY_VERSION;
  50. {
  51. void* ptr = &::proto2_arena_unittest::_ArenaMessage_default_instance_;
  52. new (ptr) ::proto2_arena_unittest::ArenaMessage();
  53. ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  54. }
  55. ::proto2_arena_unittest::ArenaMessage::InitAsDefaultInstance();
  56. }
  57. ::google::protobuf::internal::SCCInfo<2> scc_info_ArenaMessage =
  58. {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 2, InitDefaultsArenaMessage}, {
  59. &protobuf_google_2fprotobuf_2funittest_5farena_2eproto::scc_info_NestedMessage.base,
  60. &protobuf_google_2fprotobuf_2funittest_5fno_5farena_5fimport_2eproto::scc_info_ImportNoArenaNestedMessage.base,}};
  61. void InitDefaults() {
  62. ::google::protobuf::internal::InitSCC(&scc_info_NestedMessage.base);
  63. ::google::protobuf::internal::InitSCC(&scc_info_ArenaMessage.base);
  64. }
  65. ::google::protobuf::Metadata file_level_metadata[2];
  66. const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  67. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_arena_unittest::NestedMessage, _has_bits_),
  68. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_arena_unittest::NestedMessage, _internal_metadata_),
  69. ~0u, // no _extensions_
  70. ~0u, // no _oneof_case_
  71. ~0u, // no _weak_field_map_
  72. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_arena_unittest::NestedMessage, d_),
  73. 0,
  74. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_arena_unittest::ArenaMessage, _has_bits_),
  75. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_arena_unittest::ArenaMessage, _internal_metadata_),
  76. ~0u, // no _extensions_
  77. ~0u, // no _oneof_case_
  78. ~0u, // no _weak_field_map_
  79. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_arena_unittest::ArenaMessage, repeated_nested_message_),
  80. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_arena_unittest::ArenaMessage, repeated_import_no_arena_message_),
  81. ~0u,
  82. ~0u,
  83. };
  84. static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  85. { 0, 6, sizeof(::proto2_arena_unittest::NestedMessage)},
  86. { 7, 14, sizeof(::proto2_arena_unittest::ArenaMessage)},
  87. };
  88. static ::google::protobuf::Message const * const file_default_instances[] = {
  89. reinterpret_cast<const ::google::protobuf::Message*>(&::proto2_arena_unittest::_NestedMessage_default_instance_),
  90. reinterpret_cast<const ::google::protobuf::Message*>(&::proto2_arena_unittest::_ArenaMessage_default_instance_),
  91. };
  92. void protobuf_AssignDescriptors() {
  93. AddDescriptors();
  94. AssignDescriptors(
  95. "google/protobuf/unittest_arena.proto", schemas, file_default_instances, TableStruct::offsets,
  96. file_level_metadata, NULL, NULL);
  97. }
  98. void protobuf_AssignDescriptorsOnce() {
  99. static ::google::protobuf::internal::once_flag once;
  100. ::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
  101. }
  102. void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
  103. void protobuf_RegisterTypes(const ::std::string&) {
  104. protobuf_AssignDescriptorsOnce();
  105. ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 2);
  106. }
  107. void AddDescriptorsImpl() {
  108. InitDefaults();
  109. static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  110. "\n$google/protobuf/unittest_arena.proto\022\025"
  111. "proto2_arena_unittest\032.google/protobuf/u"
  112. "nittest_no_arena_import.proto\"\032\n\rNestedM"
  113. "essage\022\t\n\001d\030\001 \001(\005\"\262\001\n\014ArenaMessage\022E\n\027re"
  114. "peated_nested_message\030\001 \003(\0132$.proto2_are"
  115. "na_unittest.NestedMessage\022[\n repeated_im"
  116. "port_no_arena_message\030\002 \003(\01321.proto2_are"
  117. "na_unittest.ImportNoArenaNestedMessageB\003"
  118. "\370\001\001"
  119. };
  120. ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
  121. descriptor, 323);
  122. ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
  123. "google/protobuf/unittest_arena.proto", &protobuf_RegisterTypes);
  124. ::protobuf_google_2fprotobuf_2funittest_5fno_5farena_5fimport_2eproto::AddDescriptors();
  125. }
  126. void AddDescriptors() {
  127. static ::google::protobuf::internal::once_flag once;
  128. ::google::protobuf::internal::call_once(once, AddDescriptorsImpl);
  129. }
  130. // Force AddDescriptors() to be called at dynamic initialization time.
  131. struct StaticDescriptorInitializer {
  132. StaticDescriptorInitializer() {
  133. AddDescriptors();
  134. }
  135. } static_descriptor_initializer;
  136. } // namespace protobuf_google_2fprotobuf_2funittest_5farena_2eproto
  137. namespace proto2_arena_unittest {
  138. // ===================================================================
  139. void NestedMessage::InitAsDefaultInstance() {
  140. }
  141. #if !defined(_MSC_VER) || _MSC_VER >= 1900
  142. const int NestedMessage::kDFieldNumber;
  143. #endif // !defined(_MSC_VER) || _MSC_VER >= 1900
  144. NestedMessage::NestedMessage()
  145. : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  146. ::google::protobuf::internal::InitSCC(
  147. &protobuf_google_2fprotobuf_2funittest_5farena_2eproto::scc_info_NestedMessage.base);
  148. SharedCtor();
  149. // @@protoc_insertion_point(constructor:proto2_arena_unittest.NestedMessage)
  150. }
  151. NestedMessage::NestedMessage(::google::protobuf::Arena* arena)
  152. : ::google::protobuf::Message(),
  153. _internal_metadata_(arena) {
  154. ::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2funittest_5farena_2eproto::scc_info_NestedMessage.base);
  155. SharedCtor();
  156. RegisterArenaDtor(arena);
  157. // @@protoc_insertion_point(arena_constructor:proto2_arena_unittest.NestedMessage)
  158. }
  159. NestedMessage::NestedMessage(const NestedMessage& from)
  160. : ::google::protobuf::Message(),
  161. _internal_metadata_(NULL),
  162. _has_bits_(from._has_bits_) {
  163. _internal_metadata_.MergeFrom(from._internal_metadata_);
  164. d_ = from.d_;
  165. // @@protoc_insertion_point(copy_constructor:proto2_arena_unittest.NestedMessage)
  166. }
  167. void NestedMessage::SharedCtor() {
  168. d_ = 0;
  169. }
  170. NestedMessage::~NestedMessage() {
  171. // @@protoc_insertion_point(destructor:proto2_arena_unittest.NestedMessage)
  172. SharedDtor();
  173. }
  174. void NestedMessage::SharedDtor() {
  175. GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
  176. }
  177. void NestedMessage::ArenaDtor(void* object) {
  178. NestedMessage* _this = reinterpret_cast< NestedMessage* >(object);
  179. (void)_this;
  180. }
  181. void NestedMessage::RegisterArenaDtor(::google::protobuf::Arena* arena) {
  182. }
  183. void NestedMessage::SetCachedSize(int size) const {
  184. _cached_size_.Set(size);
  185. }
  186. const ::google::protobuf::Descriptor* NestedMessage::descriptor() {
  187. ::protobuf_google_2fprotobuf_2funittest_5farena_2eproto::protobuf_AssignDescriptorsOnce();
  188. return ::protobuf_google_2fprotobuf_2funittest_5farena_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
  189. }
  190. const NestedMessage& NestedMessage::default_instance() {
  191. ::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2funittest_5farena_2eproto::scc_info_NestedMessage.base);
  192. return *internal_default_instance();
  193. }
  194. void NestedMessage::Clear() {
  195. // @@protoc_insertion_point(message_clear_start:proto2_arena_unittest.NestedMessage)
  196. ::google::protobuf::uint32 cached_has_bits = 0;
  197. // Prevent compiler warnings about cached_has_bits being unused
  198. (void) cached_has_bits;
  199. d_ = 0;
  200. _has_bits_.Clear();
  201. _internal_metadata_.Clear();
  202. }
  203. bool NestedMessage::MergePartialFromCodedStream(
  204. ::google::protobuf::io::CodedInputStream* input) {
  205. #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  206. ::google::protobuf::uint32 tag;
  207. // @@protoc_insertion_point(parse_start:proto2_arena_unittest.NestedMessage)
  208. for (;;) {
  209. ::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
  210. tag = p.first;
  211. if (!p.second) goto handle_unusual;
  212. switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
  213. // optional int32 d = 1;
  214. case 1: {
  215. if (static_cast< ::google::protobuf::uint8>(tag) ==
  216. static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
  217. set_has_d();
  218. DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
  219. ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
  220. input, &d_)));
  221. } else {
  222. goto handle_unusual;
  223. }
  224. break;
  225. }
  226. default: {
  227. handle_unusual:
  228. if (tag == 0) {
  229. goto success;
  230. }
  231. DO_(::google::protobuf::internal::WireFormat::SkipField(
  232. input, tag, _internal_metadata_.mutable_unknown_fields()));
  233. break;
  234. }
  235. }
  236. }
  237. success:
  238. // @@protoc_insertion_point(parse_success:proto2_arena_unittest.NestedMessage)
  239. return true;
  240. failure:
  241. // @@protoc_insertion_point(parse_failure:proto2_arena_unittest.NestedMessage)
  242. return false;
  243. #undef DO_
  244. }
  245. void NestedMessage::SerializeWithCachedSizes(
  246. ::google::protobuf::io::CodedOutputStream* output) const {
  247. // @@protoc_insertion_point(serialize_start:proto2_arena_unittest.NestedMessage)
  248. ::google::protobuf::uint32 cached_has_bits = 0;
  249. (void) cached_has_bits;
  250. cached_has_bits = _has_bits_[0];
  251. // optional int32 d = 1;
  252. if (cached_has_bits & 0x00000001u) {
  253. ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->d(), output);
  254. }
  255. if (_internal_metadata_.have_unknown_fields()) {
  256. ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
  257. _internal_metadata_.unknown_fields(), output);
  258. }
  259. // @@protoc_insertion_point(serialize_end:proto2_arena_unittest.NestedMessage)
  260. }
  261. ::google::protobuf::uint8* NestedMessage::InternalSerializeWithCachedSizesToArray(
  262. bool deterministic, ::google::protobuf::uint8* target) const {
  263. (void)deterministic; // Unused
  264. // @@protoc_insertion_point(serialize_to_array_start:proto2_arena_unittest.NestedMessage)
  265. ::google::protobuf::uint32 cached_has_bits = 0;
  266. (void) cached_has_bits;
  267. cached_has_bits = _has_bits_[0];
  268. // optional int32 d = 1;
  269. if (cached_has_bits & 0x00000001u) {
  270. target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->d(), target);
  271. }
  272. if (_internal_metadata_.have_unknown_fields()) {
  273. target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
  274. _internal_metadata_.unknown_fields(), target);
  275. }
  276. // @@protoc_insertion_point(serialize_to_array_end:proto2_arena_unittest.NestedMessage)
  277. return target;
  278. }
  279. size_t NestedMessage::ByteSizeLong() const {
  280. // @@protoc_insertion_point(message_byte_size_start:proto2_arena_unittest.NestedMessage)
  281. size_t total_size = 0;
  282. if (_internal_metadata_.have_unknown_fields()) {
  283. total_size +=
  284. ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
  285. _internal_metadata_.unknown_fields());
  286. }
  287. // optional int32 d = 1;
  288. if (has_d()) {
  289. total_size += 1 +
  290. ::google::protobuf::internal::WireFormatLite::Int32Size(
  291. this->d());
  292. }
  293. int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  294. SetCachedSize(cached_size);
  295. return total_size;
  296. }
  297. void NestedMessage::MergeFrom(const ::google::protobuf::Message& from) {
  298. // @@protoc_insertion_point(generalized_merge_from_start:proto2_arena_unittest.NestedMessage)
  299. GOOGLE_DCHECK_NE(&from, this);
  300. const NestedMessage* source =
  301. ::google::protobuf::internal::DynamicCastToGenerated<const NestedMessage>(
  302. &from);
  303. if (source == NULL) {
  304. // @@protoc_insertion_point(generalized_merge_from_cast_fail:proto2_arena_unittest.NestedMessage)
  305. ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  306. } else {
  307. // @@protoc_insertion_point(generalized_merge_from_cast_success:proto2_arena_unittest.NestedMessage)
  308. MergeFrom(*source);
  309. }
  310. }
  311. void NestedMessage::MergeFrom(const NestedMessage& from) {
  312. // @@protoc_insertion_point(class_specific_merge_from_start:proto2_arena_unittest.NestedMessage)
  313. GOOGLE_DCHECK_NE(&from, this);
  314. _internal_metadata_.MergeFrom(from._internal_metadata_);
  315. ::google::protobuf::uint32 cached_has_bits = 0;
  316. (void) cached_has_bits;
  317. if (from.has_d()) {
  318. set_d(from.d());
  319. }
  320. }
  321. void NestedMessage::CopyFrom(const ::google::protobuf::Message& from) {
  322. // @@protoc_insertion_point(generalized_copy_from_start:proto2_arena_unittest.NestedMessage)
  323. if (&from == this) return;
  324. Clear();
  325. MergeFrom(from);
  326. }
  327. void NestedMessage::CopyFrom(const NestedMessage& from) {
  328. // @@protoc_insertion_point(class_specific_copy_from_start:proto2_arena_unittest.NestedMessage)
  329. if (&from == this) return;
  330. Clear();
  331. MergeFrom(from);
  332. }
  333. bool NestedMessage::IsInitialized() const {
  334. return true;
  335. }
  336. void NestedMessage::Swap(NestedMessage* other) {
  337. if (other == this) return;
  338. if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
  339. InternalSwap(other);
  340. } else {
  341. NestedMessage* temp = New(GetArenaNoVirtual());
  342. temp->MergeFrom(*other);
  343. other->CopyFrom(*this);
  344. InternalSwap(temp);
  345. if (GetArenaNoVirtual() == NULL) {
  346. delete temp;
  347. }
  348. }
  349. }
  350. void NestedMessage::UnsafeArenaSwap(NestedMessage* other) {
  351. if (other == this) return;
  352. GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
  353. InternalSwap(other);
  354. }
  355. void NestedMessage::InternalSwap(NestedMessage* other) {
  356. using std::swap;
  357. swap(d_, other->d_);
  358. swap(_has_bits_[0], other->_has_bits_[0]);
  359. _internal_metadata_.Swap(&other->_internal_metadata_);
  360. }
  361. ::google::protobuf::Metadata NestedMessage::GetMetadata() const {
  362. protobuf_google_2fprotobuf_2funittest_5farena_2eproto::protobuf_AssignDescriptorsOnce();
  363. return ::protobuf_google_2fprotobuf_2funittest_5farena_2eproto::file_level_metadata[kIndexInFileMessages];
  364. }
  365. // ===================================================================
  366. void ArenaMessage::InitAsDefaultInstance() {
  367. }
  368. void ArenaMessage::clear_repeated_import_no_arena_message() {
  369. repeated_import_no_arena_message_.Clear();
  370. }
  371. #if !defined(_MSC_VER) || _MSC_VER >= 1900
  372. const int ArenaMessage::kRepeatedNestedMessageFieldNumber;
  373. const int ArenaMessage::kRepeatedImportNoArenaMessageFieldNumber;
  374. #endif // !defined(_MSC_VER) || _MSC_VER >= 1900
  375. ArenaMessage::ArenaMessage()
  376. : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  377. ::google::protobuf::internal::InitSCC(
  378. &protobuf_google_2fprotobuf_2funittest_5farena_2eproto::scc_info_ArenaMessage.base);
  379. SharedCtor();
  380. // @@protoc_insertion_point(constructor:proto2_arena_unittest.ArenaMessage)
  381. }
  382. ArenaMessage::ArenaMessage(::google::protobuf::Arena* arena)
  383. : ::google::protobuf::Message(),
  384. _internal_metadata_(arena),
  385. repeated_nested_message_(arena),
  386. repeated_import_no_arena_message_(arena) {
  387. ::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2funittest_5farena_2eproto::scc_info_ArenaMessage.base);
  388. SharedCtor();
  389. RegisterArenaDtor(arena);
  390. // @@protoc_insertion_point(arena_constructor:proto2_arena_unittest.ArenaMessage)
  391. }
  392. ArenaMessage::ArenaMessage(const ArenaMessage& from)
  393. : ::google::protobuf::Message(),
  394. _internal_metadata_(NULL),
  395. _has_bits_(from._has_bits_),
  396. repeated_nested_message_(from.repeated_nested_message_),
  397. repeated_import_no_arena_message_(from.repeated_import_no_arena_message_) {
  398. _internal_metadata_.MergeFrom(from._internal_metadata_);
  399. // @@protoc_insertion_point(copy_constructor:proto2_arena_unittest.ArenaMessage)
  400. }
  401. void ArenaMessage::SharedCtor() {
  402. }
  403. ArenaMessage::~ArenaMessage() {
  404. // @@protoc_insertion_point(destructor:proto2_arena_unittest.ArenaMessage)
  405. SharedDtor();
  406. }
  407. void ArenaMessage::SharedDtor() {
  408. GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);
  409. }
  410. void ArenaMessage::ArenaDtor(void* object) {
  411. ArenaMessage* _this = reinterpret_cast< ArenaMessage* >(object);
  412. (void)_this;
  413. }
  414. void ArenaMessage::RegisterArenaDtor(::google::protobuf::Arena* arena) {
  415. }
  416. void ArenaMessage::SetCachedSize(int size) const {
  417. _cached_size_.Set(size);
  418. }
  419. const ::google::protobuf::Descriptor* ArenaMessage::descriptor() {
  420. ::protobuf_google_2fprotobuf_2funittest_5farena_2eproto::protobuf_AssignDescriptorsOnce();
  421. return ::protobuf_google_2fprotobuf_2funittest_5farena_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
  422. }
  423. const ArenaMessage& ArenaMessage::default_instance() {
  424. ::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2funittest_5farena_2eproto::scc_info_ArenaMessage.base);
  425. return *internal_default_instance();
  426. }
  427. void ArenaMessage::Clear() {
  428. // @@protoc_insertion_point(message_clear_start:proto2_arena_unittest.ArenaMessage)
  429. ::google::protobuf::uint32 cached_has_bits = 0;
  430. // Prevent compiler warnings about cached_has_bits being unused
  431. (void) cached_has_bits;
  432. repeated_nested_message_.Clear();
  433. repeated_import_no_arena_message_.Clear();
  434. _has_bits_.Clear();
  435. _internal_metadata_.Clear();
  436. }
  437. bool ArenaMessage::MergePartialFromCodedStream(
  438. ::google::protobuf::io::CodedInputStream* input) {
  439. #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  440. ::google::protobuf::uint32 tag;
  441. // @@protoc_insertion_point(parse_start:proto2_arena_unittest.ArenaMessage)
  442. for (;;) {
  443. ::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
  444. tag = p.first;
  445. if (!p.second) goto handle_unusual;
  446. switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
  447. // repeated .proto2_arena_unittest.NestedMessage repeated_nested_message = 1;
  448. case 1: {
  449. if (static_cast< ::google::protobuf::uint8>(tag) ==
  450. static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
  451. DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
  452. input, add_repeated_nested_message()));
  453. } else {
  454. goto handle_unusual;
  455. }
  456. break;
  457. }
  458. // repeated .proto2_arena_unittest.ImportNoArenaNestedMessage repeated_import_no_arena_message = 2;
  459. case 2: {
  460. if (static_cast< ::google::protobuf::uint8>(tag) ==
  461. static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
  462. DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
  463. input, add_repeated_import_no_arena_message()));
  464. } else {
  465. goto handle_unusual;
  466. }
  467. break;
  468. }
  469. default: {
  470. handle_unusual:
  471. if (tag == 0) {
  472. goto success;
  473. }
  474. DO_(::google::protobuf::internal::WireFormat::SkipField(
  475. input, tag, _internal_metadata_.mutable_unknown_fields()));
  476. break;
  477. }
  478. }
  479. }
  480. success:
  481. // @@protoc_insertion_point(parse_success:proto2_arena_unittest.ArenaMessage)
  482. return true;
  483. failure:
  484. // @@protoc_insertion_point(parse_failure:proto2_arena_unittest.ArenaMessage)
  485. return false;
  486. #undef DO_
  487. }
  488. void ArenaMessage::SerializeWithCachedSizes(
  489. ::google::protobuf::io::CodedOutputStream* output) const {
  490. // @@protoc_insertion_point(serialize_start:proto2_arena_unittest.ArenaMessage)
  491. ::google::protobuf::uint32 cached_has_bits = 0;
  492. (void) cached_has_bits;
  493. // repeated .proto2_arena_unittest.NestedMessage repeated_nested_message = 1;
  494. for (unsigned int i = 0,
  495. n = static_cast<unsigned int>(this->repeated_nested_message_size()); i < n; i++) {
  496. ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
  497. 1,
  498. this->repeated_nested_message(static_cast<int>(i)),
  499. output);
  500. }
  501. // repeated .proto2_arena_unittest.ImportNoArenaNestedMessage repeated_import_no_arena_message = 2;
  502. for (unsigned int i = 0,
  503. n = static_cast<unsigned int>(this->repeated_import_no_arena_message_size()); i < n; i++) {
  504. ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
  505. 2,
  506. this->repeated_import_no_arena_message(static_cast<int>(i)),
  507. output);
  508. }
  509. if (_internal_metadata_.have_unknown_fields()) {
  510. ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
  511. _internal_metadata_.unknown_fields(), output);
  512. }
  513. // @@protoc_insertion_point(serialize_end:proto2_arena_unittest.ArenaMessage)
  514. }
  515. ::google::protobuf::uint8* ArenaMessage::InternalSerializeWithCachedSizesToArray(
  516. bool deterministic, ::google::protobuf::uint8* target) const {
  517. (void)deterministic; // Unused
  518. // @@protoc_insertion_point(serialize_to_array_start:proto2_arena_unittest.ArenaMessage)
  519. ::google::protobuf::uint32 cached_has_bits = 0;
  520. (void) cached_has_bits;
  521. // repeated .proto2_arena_unittest.NestedMessage repeated_nested_message = 1;
  522. for (unsigned int i = 0,
  523. n = static_cast<unsigned int>(this->repeated_nested_message_size()); i < n; i++) {
  524. target = ::google::protobuf::internal::WireFormatLite::
  525. InternalWriteMessageToArray(
  526. 1, this->repeated_nested_message(static_cast<int>(i)), deterministic, target);
  527. }
  528. // repeated .proto2_arena_unittest.ImportNoArenaNestedMessage repeated_import_no_arena_message = 2;
  529. for (unsigned int i = 0,
  530. n = static_cast<unsigned int>(this->repeated_import_no_arena_message_size()); i < n; i++) {
  531. target = ::google::protobuf::internal::WireFormatLite::
  532. InternalWriteMessageToArray(
  533. 2, this->repeated_import_no_arena_message(static_cast<int>(i)), deterministic, target);
  534. }
  535. if (_internal_metadata_.have_unknown_fields()) {
  536. target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
  537. _internal_metadata_.unknown_fields(), target);
  538. }
  539. // @@protoc_insertion_point(serialize_to_array_end:proto2_arena_unittest.ArenaMessage)
  540. return target;
  541. }
  542. size_t ArenaMessage::ByteSizeLong() const {
  543. // @@protoc_insertion_point(message_byte_size_start:proto2_arena_unittest.ArenaMessage)
  544. size_t total_size = 0;
  545. if (_internal_metadata_.have_unknown_fields()) {
  546. total_size +=
  547. ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
  548. _internal_metadata_.unknown_fields());
  549. }
  550. // repeated .proto2_arena_unittest.NestedMessage repeated_nested_message = 1;
  551. {
  552. unsigned int count = static_cast<unsigned int>(this->repeated_nested_message_size());
  553. total_size += 1UL * count;
  554. for (unsigned int i = 0; i < count; i++) {
  555. total_size +=
  556. ::google::protobuf::internal::WireFormatLite::MessageSize(
  557. this->repeated_nested_message(static_cast<int>(i)));
  558. }
  559. }
  560. // repeated .proto2_arena_unittest.ImportNoArenaNestedMessage repeated_import_no_arena_message = 2;
  561. {
  562. unsigned int count = static_cast<unsigned int>(this->repeated_import_no_arena_message_size());
  563. total_size += 1UL * count;
  564. for (unsigned int i = 0; i < count; i++) {
  565. total_size +=
  566. ::google::protobuf::internal::WireFormatLite::MessageSize(
  567. this->repeated_import_no_arena_message(static_cast<int>(i)));
  568. }
  569. }
  570. int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  571. SetCachedSize(cached_size);
  572. return total_size;
  573. }
  574. void ArenaMessage::MergeFrom(const ::google::protobuf::Message& from) {
  575. // @@protoc_insertion_point(generalized_merge_from_start:proto2_arena_unittest.ArenaMessage)
  576. GOOGLE_DCHECK_NE(&from, this);
  577. const ArenaMessage* source =
  578. ::google::protobuf::internal::DynamicCastToGenerated<const ArenaMessage>(
  579. &from);
  580. if (source == NULL) {
  581. // @@protoc_insertion_point(generalized_merge_from_cast_fail:proto2_arena_unittest.ArenaMessage)
  582. ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  583. } else {
  584. // @@protoc_insertion_point(generalized_merge_from_cast_success:proto2_arena_unittest.ArenaMessage)
  585. MergeFrom(*source);
  586. }
  587. }
  588. void ArenaMessage::MergeFrom(const ArenaMessage& from) {
  589. // @@protoc_insertion_point(class_specific_merge_from_start:proto2_arena_unittest.ArenaMessage)
  590. GOOGLE_DCHECK_NE(&from, this);
  591. _internal_metadata_.MergeFrom(from._internal_metadata_);
  592. ::google::protobuf::uint32 cached_has_bits = 0;
  593. (void) cached_has_bits;
  594. repeated_nested_message_.MergeFrom(from.repeated_nested_message_);
  595. repeated_import_no_arena_message_.MergeFrom(from.repeated_import_no_arena_message_);
  596. }
  597. void ArenaMessage::CopyFrom(const ::google::protobuf::Message& from) {
  598. // @@protoc_insertion_point(generalized_copy_from_start:proto2_arena_unittest.ArenaMessage)
  599. if (&from == this) return;
  600. Clear();
  601. MergeFrom(from);
  602. }
  603. void ArenaMessage::CopyFrom(const ArenaMessage& from) {
  604. // @@protoc_insertion_point(class_specific_copy_from_start:proto2_arena_unittest.ArenaMessage)
  605. if (&from == this) return;
  606. Clear();
  607. MergeFrom(from);
  608. }
  609. bool ArenaMessage::IsInitialized() const {
  610. return true;
  611. }
  612. void ArenaMessage::Swap(ArenaMessage* other) {
  613. if (other == this) return;
  614. if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {
  615. InternalSwap(other);
  616. } else {
  617. ArenaMessage* temp = New(GetArenaNoVirtual());
  618. temp->MergeFrom(*other);
  619. other->CopyFrom(*this);
  620. InternalSwap(temp);
  621. if (GetArenaNoVirtual() == NULL) {
  622. delete temp;
  623. }
  624. }
  625. }
  626. void ArenaMessage::UnsafeArenaSwap(ArenaMessage* other) {
  627. if (other == this) return;
  628. GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());
  629. InternalSwap(other);
  630. }
  631. void ArenaMessage::InternalSwap(ArenaMessage* other) {
  632. using std::swap;
  633. CastToBase(&repeated_nested_message_)->InternalSwap(CastToBase(&other->repeated_nested_message_));
  634. CastToBase(&repeated_import_no_arena_message_)->InternalSwap(CastToBase(&other->repeated_import_no_arena_message_));
  635. swap(_has_bits_[0], other->_has_bits_[0]);
  636. _internal_metadata_.Swap(&other->_internal_metadata_);
  637. }
  638. ::google::protobuf::Metadata ArenaMessage::GetMetadata() const {
  639. protobuf_google_2fprotobuf_2funittest_5farena_2eproto::protobuf_AssignDescriptorsOnce();
  640. return ::protobuf_google_2fprotobuf_2funittest_5farena_2eproto::file_level_metadata[kIndexInFileMessages];
  641. }
  642. // @@protoc_insertion_point(namespace_scope)
  643. } // namespace proto2_arena_unittest
  644. namespace google {
  645. namespace protobuf {
  646. template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::proto2_arena_unittest::NestedMessage* Arena::CreateMaybeMessage< ::proto2_arena_unittest::NestedMessage >(Arena* arena) {
  647. return Arena::CreateMessageInternal< ::proto2_arena_unittest::NestedMessage >(arena);
  648. }
  649. template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::proto2_arena_unittest::ArenaMessage* Arena::CreateMaybeMessage< ::proto2_arena_unittest::ArenaMessage >(Arena* arena) {
  650. return Arena::CreateMessageInternal< ::proto2_arena_unittest::ArenaMessage >(arena);
  651. }
  652. } // namespace protobuf
  653. } // namespace google
  654. // @@protoc_insertion_point(global_scope)