unittest_embed_optimize_for.pb.cc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. // Generated by the protocol buffer compiler. DO NOT EDIT!
  2. // source: google/protobuf/unittest_embed_optimize_for.proto
  3. #include <google/protobuf/unittest_embed_optimize_for.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_5foptimize_5ffor_2eproto {
  19. extern PROTOBUF_INTERNAL_EXPORT_protobuf_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto ::google::protobuf::internal::SCCInfo<1> scc_info_TestOptimizedForSize;
  20. } // namespace protobuf_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto
  21. namespace protobuf_unittest {
  22. class TestEmbedOptimizedForSizeDefaultTypeInternal {
  23. public:
  24. ::google::protobuf::internal::ExplicitlyConstructed<TestEmbedOptimizedForSize>
  25. _instance;
  26. } _TestEmbedOptimizedForSize_default_instance_;
  27. } // namespace protobuf_unittest
  28. namespace protobuf_google_2fprotobuf_2funittest_5fembed_5foptimize_5ffor_2eproto {
  29. static void InitDefaultsTestEmbedOptimizedForSize() {
  30. GOOGLE_PROTOBUF_VERIFY_VERSION;
  31. {
  32. void* ptr = &::protobuf_unittest::_TestEmbedOptimizedForSize_default_instance_;
  33. new (ptr) ::protobuf_unittest::TestEmbedOptimizedForSize();
  34. ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  35. }
  36. ::protobuf_unittest::TestEmbedOptimizedForSize::InitAsDefaultInstance();
  37. }
  38. ::google::protobuf::internal::SCCInfo<1> scc_info_TestEmbedOptimizedForSize =
  39. {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsTestEmbedOptimizedForSize}, {
  40. &protobuf_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto::scc_info_TestOptimizedForSize.base,}};
  41. void InitDefaults() {
  42. ::google::protobuf::internal::InitSCC(&scc_info_TestEmbedOptimizedForSize.base);
  43. }
  44. ::google::protobuf::Metadata file_level_metadata[1];
  45. const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  46. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::protobuf_unittest::TestEmbedOptimizedForSize, _has_bits_),
  47. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::protobuf_unittest::TestEmbedOptimizedForSize, _internal_metadata_),
  48. ~0u, // no _extensions_
  49. ~0u, // no _oneof_case_
  50. ~0u, // no _weak_field_map_
  51. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::protobuf_unittest::TestEmbedOptimizedForSize, optional_message_),
  52. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::protobuf_unittest::TestEmbedOptimizedForSize, repeated_message_),
  53. 0,
  54. ~0u,
  55. };
  56. static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  57. { 0, 7, sizeof(::protobuf_unittest::TestEmbedOptimizedForSize)},
  58. };
  59. static ::google::protobuf::Message const * const file_default_instances[] = {
  60. reinterpret_cast<const ::google::protobuf::Message*>(&::protobuf_unittest::_TestEmbedOptimizedForSize_default_instance_),
  61. };
  62. void protobuf_AssignDescriptors() {
  63. AddDescriptors();
  64. AssignDescriptors(
  65. "google/protobuf/unittest_embed_optimize_for.proto", schemas, file_default_instances, TableStruct::offsets,
  66. file_level_metadata, NULL, NULL);
  67. }
  68. void protobuf_AssignDescriptorsOnce() {
  69. static ::google::protobuf::internal::once_flag once;
  70. ::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
  71. }
  72. void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
  73. void protobuf_RegisterTypes(const ::std::string&) {
  74. protobuf_AssignDescriptorsOnce();
  75. ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
  76. }
  77. void AddDescriptorsImpl() {
  78. InitDefaults();
  79. static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  80. "\n1google/protobuf/unittest_embed_optimiz"
  81. "e_for.proto\022\021protobuf_unittest\032+google/p"
  82. "rotobuf/unittest_optimize_for.proto\"\241\001\n\031"
  83. "TestEmbedOptimizedForSize\022A\n\020optional_me"
  84. "ssage\030\001 \001(\0132\'.protobuf_unittest.TestOpti"
  85. "mizedForSize\022A\n\020repeated_message\030\002 \003(\0132\'"
  86. ".protobuf_unittest.TestOptimizedForSizeB"
  87. "\002H\001"
  88. };
  89. ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
  90. descriptor, 283);
  91. ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
  92. "google/protobuf/unittest_embed_optimize_for.proto", &protobuf_RegisterTypes);
  93. ::protobuf_google_2fprotobuf_2funittest_5foptimize_5ffor_2eproto::AddDescriptors();
  94. }
  95. void AddDescriptors() {
  96. static ::google::protobuf::internal::once_flag once;
  97. ::google::protobuf::internal::call_once(once, AddDescriptorsImpl);
  98. }
  99. // Force AddDescriptors() to be called at dynamic initialization time.
  100. struct StaticDescriptorInitializer {
  101. StaticDescriptorInitializer() {
  102. AddDescriptors();
  103. }
  104. } static_descriptor_initializer;
  105. } // namespace protobuf_google_2fprotobuf_2funittest_5fembed_5foptimize_5ffor_2eproto
  106. namespace protobuf_unittest {
  107. // ===================================================================
  108. void TestEmbedOptimizedForSize::InitAsDefaultInstance() {
  109. ::protobuf_unittest::_TestEmbedOptimizedForSize_default_instance_._instance.get_mutable()->optional_message_ = const_cast< ::protobuf_unittest::TestOptimizedForSize*>(
  110. ::protobuf_unittest::TestOptimizedForSize::internal_default_instance());
  111. }
  112. void TestEmbedOptimizedForSize::clear_optional_message() {
  113. if (optional_message_ != NULL) optional_message_->Clear();
  114. clear_has_optional_message();
  115. }
  116. void TestEmbedOptimizedForSize::clear_repeated_message() {
  117. repeated_message_.Clear();
  118. }
  119. #if !defined(_MSC_VER) || _MSC_VER >= 1900
  120. const int TestEmbedOptimizedForSize::kOptionalMessageFieldNumber;
  121. const int TestEmbedOptimizedForSize::kRepeatedMessageFieldNumber;
  122. #endif // !defined(_MSC_VER) || _MSC_VER >= 1900
  123. TestEmbedOptimizedForSize::TestEmbedOptimizedForSize()
  124. : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  125. ::google::protobuf::internal::InitSCC(
  126. &protobuf_google_2fprotobuf_2funittest_5fembed_5foptimize_5ffor_2eproto::scc_info_TestEmbedOptimizedForSize.base);
  127. SharedCtor();
  128. // @@protoc_insertion_point(constructor:protobuf_unittest.TestEmbedOptimizedForSize)
  129. }
  130. TestEmbedOptimizedForSize::TestEmbedOptimizedForSize(const TestEmbedOptimizedForSize& from)
  131. : ::google::protobuf::Message(),
  132. _internal_metadata_(NULL),
  133. _has_bits_(from._has_bits_),
  134. repeated_message_(from.repeated_message_) {
  135. _internal_metadata_.MergeFrom(from._internal_metadata_);
  136. if (from.has_optional_message()) {
  137. optional_message_ = new ::protobuf_unittest::TestOptimizedForSize(*from.optional_message_);
  138. } else {
  139. optional_message_ = NULL;
  140. }
  141. // @@protoc_insertion_point(copy_constructor:protobuf_unittest.TestEmbedOptimizedForSize)
  142. }
  143. void TestEmbedOptimizedForSize::SharedCtor() {
  144. optional_message_ = NULL;
  145. }
  146. TestEmbedOptimizedForSize::~TestEmbedOptimizedForSize() {
  147. // @@protoc_insertion_point(destructor:protobuf_unittest.TestEmbedOptimizedForSize)
  148. SharedDtor();
  149. }
  150. void TestEmbedOptimizedForSize::SharedDtor() {
  151. if (this != internal_default_instance()) delete optional_message_;
  152. }
  153. void TestEmbedOptimizedForSize::SetCachedSize(int size) const {
  154. _cached_size_.Set(size);
  155. }
  156. const ::google::protobuf::Descriptor* TestEmbedOptimizedForSize::descriptor() {
  157. ::protobuf_google_2fprotobuf_2funittest_5fembed_5foptimize_5ffor_2eproto::protobuf_AssignDescriptorsOnce();
  158. return ::protobuf_google_2fprotobuf_2funittest_5fembed_5foptimize_5ffor_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
  159. }
  160. const TestEmbedOptimizedForSize& TestEmbedOptimizedForSize::default_instance() {
  161. ::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2funittest_5fembed_5foptimize_5ffor_2eproto::scc_info_TestEmbedOptimizedForSize.base);
  162. return *internal_default_instance();
  163. }
  164. void TestEmbedOptimizedForSize::Clear() {
  165. // @@protoc_insertion_point(message_clear_start:protobuf_unittest.TestEmbedOptimizedForSize)
  166. ::google::protobuf::uint32 cached_has_bits = 0;
  167. // Prevent compiler warnings about cached_has_bits being unused
  168. (void) cached_has_bits;
  169. repeated_message_.Clear();
  170. cached_has_bits = _has_bits_[0];
  171. if (cached_has_bits & 0x00000001u) {
  172. GOOGLE_DCHECK(optional_message_ != NULL);
  173. optional_message_->Clear();
  174. }
  175. _has_bits_.Clear();
  176. _internal_metadata_.Clear();
  177. }
  178. bool TestEmbedOptimizedForSize::MergePartialFromCodedStream(
  179. ::google::protobuf::io::CodedInputStream* input) {
  180. #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  181. ::google::protobuf::uint32 tag;
  182. // @@protoc_insertion_point(parse_start:protobuf_unittest.TestEmbedOptimizedForSize)
  183. for (;;) {
  184. ::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
  185. tag = p.first;
  186. if (!p.second) goto handle_unusual;
  187. switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
  188. // optional .protobuf_unittest.TestOptimizedForSize optional_message = 1;
  189. case 1: {
  190. if (static_cast< ::google::protobuf::uint8>(tag) ==
  191. static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
  192. DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
  193. input, mutable_optional_message()));
  194. } else {
  195. goto handle_unusual;
  196. }
  197. break;
  198. }
  199. // repeated .protobuf_unittest.TestOptimizedForSize repeated_message = 2;
  200. case 2: {
  201. if (static_cast< ::google::protobuf::uint8>(tag) ==
  202. static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
  203. DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
  204. input, add_repeated_message()));
  205. } else {
  206. goto handle_unusual;
  207. }
  208. break;
  209. }
  210. default: {
  211. handle_unusual:
  212. if (tag == 0) {
  213. goto success;
  214. }
  215. DO_(::google::protobuf::internal::WireFormat::SkipField(
  216. input, tag, _internal_metadata_.mutable_unknown_fields()));
  217. break;
  218. }
  219. }
  220. }
  221. success:
  222. // @@protoc_insertion_point(parse_success:protobuf_unittest.TestEmbedOptimizedForSize)
  223. return true;
  224. failure:
  225. // @@protoc_insertion_point(parse_failure:protobuf_unittest.TestEmbedOptimizedForSize)
  226. return false;
  227. #undef DO_
  228. }
  229. void TestEmbedOptimizedForSize::SerializeWithCachedSizes(
  230. ::google::protobuf::io::CodedOutputStream* output) const {
  231. // @@protoc_insertion_point(serialize_start:protobuf_unittest.TestEmbedOptimizedForSize)
  232. ::google::protobuf::uint32 cached_has_bits = 0;
  233. (void) cached_has_bits;
  234. cached_has_bits = _has_bits_[0];
  235. // optional .protobuf_unittest.TestOptimizedForSize optional_message = 1;
  236. if (cached_has_bits & 0x00000001u) {
  237. ::google::protobuf::internal::WireFormatLite::WriteMessage(
  238. 1, this->_internal_optional_message(), output);
  239. }
  240. // repeated .protobuf_unittest.TestOptimizedForSize repeated_message = 2;
  241. for (unsigned int i = 0,
  242. n = static_cast<unsigned int>(this->repeated_message_size()); i < n; i++) {
  243. ::google::protobuf::internal::WireFormatLite::WriteMessage(
  244. 2,
  245. this->repeated_message(static_cast<int>(i)),
  246. output);
  247. }
  248. if (_internal_metadata_.have_unknown_fields()) {
  249. ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
  250. _internal_metadata_.unknown_fields(), output);
  251. }
  252. // @@protoc_insertion_point(serialize_end:protobuf_unittest.TestEmbedOptimizedForSize)
  253. }
  254. ::google::protobuf::uint8* TestEmbedOptimizedForSize::InternalSerializeWithCachedSizesToArray(
  255. bool deterministic, ::google::protobuf::uint8* target) const {
  256. (void)deterministic; // Unused
  257. // @@protoc_insertion_point(serialize_to_array_start:protobuf_unittest.TestEmbedOptimizedForSize)
  258. ::google::protobuf::uint32 cached_has_bits = 0;
  259. (void) cached_has_bits;
  260. cached_has_bits = _has_bits_[0];
  261. // optional .protobuf_unittest.TestOptimizedForSize optional_message = 1;
  262. if (cached_has_bits & 0x00000001u) {
  263. target = ::google::protobuf::internal::WireFormatLite::
  264. InternalWriteMessageToArray(
  265. 1, this->_internal_optional_message(), deterministic, target);
  266. }
  267. // repeated .protobuf_unittest.TestOptimizedForSize repeated_message = 2;
  268. for (unsigned int i = 0,
  269. n = static_cast<unsigned int>(this->repeated_message_size()); i < n; i++) {
  270. target = ::google::protobuf::internal::WireFormatLite::
  271. InternalWriteMessageToArray(
  272. 2, this->repeated_message(static_cast<int>(i)), deterministic, target);
  273. }
  274. if (_internal_metadata_.have_unknown_fields()) {
  275. target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
  276. _internal_metadata_.unknown_fields(), target);
  277. }
  278. // @@protoc_insertion_point(serialize_to_array_end:protobuf_unittest.TestEmbedOptimizedForSize)
  279. return target;
  280. }
  281. size_t TestEmbedOptimizedForSize::ByteSizeLong() const {
  282. // @@protoc_insertion_point(message_byte_size_start:protobuf_unittest.TestEmbedOptimizedForSize)
  283. size_t total_size = 0;
  284. if (_internal_metadata_.have_unknown_fields()) {
  285. total_size +=
  286. ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
  287. _internal_metadata_.unknown_fields());
  288. }
  289. // repeated .protobuf_unittest.TestOptimizedForSize repeated_message = 2;
  290. {
  291. unsigned int count = static_cast<unsigned int>(this->repeated_message_size());
  292. total_size += 1UL * count;
  293. for (unsigned int i = 0; i < count; i++) {
  294. total_size +=
  295. ::google::protobuf::internal::WireFormatLite::MessageSize(
  296. this->repeated_message(static_cast<int>(i)));
  297. }
  298. }
  299. // optional .protobuf_unittest.TestOptimizedForSize optional_message = 1;
  300. if (has_optional_message()) {
  301. total_size += 1 +
  302. ::google::protobuf::internal::WireFormatLite::MessageSize(
  303. *optional_message_);
  304. }
  305. int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  306. SetCachedSize(cached_size);
  307. return total_size;
  308. }
  309. void TestEmbedOptimizedForSize::MergeFrom(const ::google::protobuf::Message& from) {
  310. // @@protoc_insertion_point(generalized_merge_from_start:protobuf_unittest.TestEmbedOptimizedForSize)
  311. GOOGLE_DCHECK_NE(&from, this);
  312. const TestEmbedOptimizedForSize* source =
  313. ::google::protobuf::internal::DynamicCastToGenerated<const TestEmbedOptimizedForSize>(
  314. &from);
  315. if (source == NULL) {
  316. // @@protoc_insertion_point(generalized_merge_from_cast_fail:protobuf_unittest.TestEmbedOptimizedForSize)
  317. ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  318. } else {
  319. // @@protoc_insertion_point(generalized_merge_from_cast_success:protobuf_unittest.TestEmbedOptimizedForSize)
  320. MergeFrom(*source);
  321. }
  322. }
  323. void TestEmbedOptimizedForSize::MergeFrom(const TestEmbedOptimizedForSize& from) {
  324. // @@protoc_insertion_point(class_specific_merge_from_start:protobuf_unittest.TestEmbedOptimizedForSize)
  325. GOOGLE_DCHECK_NE(&from, this);
  326. _internal_metadata_.MergeFrom(from._internal_metadata_);
  327. ::google::protobuf::uint32 cached_has_bits = 0;
  328. (void) cached_has_bits;
  329. repeated_message_.MergeFrom(from.repeated_message_);
  330. if (from.has_optional_message()) {
  331. mutable_optional_message()->::protobuf_unittest::TestOptimizedForSize::MergeFrom(from.optional_message());
  332. }
  333. }
  334. void TestEmbedOptimizedForSize::CopyFrom(const ::google::protobuf::Message& from) {
  335. // @@protoc_insertion_point(generalized_copy_from_start:protobuf_unittest.TestEmbedOptimizedForSize)
  336. if (&from == this) return;
  337. Clear();
  338. MergeFrom(from);
  339. }
  340. void TestEmbedOptimizedForSize::CopyFrom(const TestEmbedOptimizedForSize& from) {
  341. // @@protoc_insertion_point(class_specific_copy_from_start:protobuf_unittest.TestEmbedOptimizedForSize)
  342. if (&from == this) return;
  343. Clear();
  344. MergeFrom(from);
  345. }
  346. bool TestEmbedOptimizedForSize::IsInitialized() const {
  347. if (!::google::protobuf::internal::AllAreInitialized(this->repeated_message())) return false;
  348. if (has_optional_message()) {
  349. if (!this->optional_message_->IsInitialized()) return false;
  350. }
  351. return true;
  352. }
  353. void TestEmbedOptimizedForSize::Swap(TestEmbedOptimizedForSize* other) {
  354. if (other == this) return;
  355. InternalSwap(other);
  356. }
  357. void TestEmbedOptimizedForSize::InternalSwap(TestEmbedOptimizedForSize* other) {
  358. using std::swap;
  359. CastToBase(&repeated_message_)->InternalSwap(CastToBase(&other->repeated_message_));
  360. swap(optional_message_, other->optional_message_);
  361. swap(_has_bits_[0], other->_has_bits_[0]);
  362. _internal_metadata_.Swap(&other->_internal_metadata_);
  363. }
  364. ::google::protobuf::Metadata TestEmbedOptimizedForSize::GetMetadata() const {
  365. protobuf_google_2fprotobuf_2funittest_5fembed_5foptimize_5ffor_2eproto::protobuf_AssignDescriptorsOnce();
  366. return ::protobuf_google_2fprotobuf_2funittest_5fembed_5foptimize_5ffor_2eproto::file_level_metadata[kIndexInFileMessages];
  367. }
  368. // @@protoc_insertion_point(namespace_scope)
  369. } // namespace protobuf_unittest
  370. namespace google {
  371. namespace protobuf {
  372. template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::protobuf_unittest::TestEmbedOptimizedForSize* Arena::CreateMaybeMessage< ::protobuf_unittest::TestEmbedOptimizedForSize >(Arena* arena) {
  373. return Arena::CreateInternal< ::protobuf_unittest::TestEmbedOptimizedForSize >(arena);
  374. }
  375. } // namespace protobuf
  376. } // namespace google
  377. // @@protoc_insertion_point(global_scope)