unittest_preserve_unknown_enum2.pb.cc 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. // Generated by the protocol buffer compiler. DO NOT EDIT!
  2. // source: google/protobuf/unittest_preserve_unknown_enum2.proto
  3. #include <google/protobuf/unittest_preserve_unknown_enum2.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 proto2_preserve_unknown_enum_unittest {
  19. class MyMessageDefaultTypeInternal {
  20. public:
  21. ::google::protobuf::internal::ExplicitlyConstructed<MyMessage>
  22. _instance;
  23. int oneof_e_1_;
  24. int oneof_e_2_;
  25. } _MyMessage_default_instance_;
  26. } // namespace proto2_preserve_unknown_enum_unittest
  27. namespace protobuf_google_2fprotobuf_2funittest_5fpreserve_5funknown_5fenum2_2eproto {
  28. static void InitDefaultsMyMessage() {
  29. GOOGLE_PROTOBUF_VERIFY_VERSION;
  30. {
  31. void* ptr = &::proto2_preserve_unknown_enum_unittest::_MyMessage_default_instance_;
  32. new (ptr) ::proto2_preserve_unknown_enum_unittest::MyMessage();
  33. ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  34. }
  35. ::proto2_preserve_unknown_enum_unittest::MyMessage::InitAsDefaultInstance();
  36. }
  37. ::google::protobuf::internal::SCCInfo<0> scc_info_MyMessage =
  38. {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsMyMessage}, {}};
  39. void InitDefaults() {
  40. ::google::protobuf::internal::InitSCC(&scc_info_MyMessage.base);
  41. }
  42. ::google::protobuf::Metadata file_level_metadata[1];
  43. const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1];
  44. const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  45. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_preserve_unknown_enum_unittest::MyMessage, _has_bits_),
  46. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_preserve_unknown_enum_unittest::MyMessage, _internal_metadata_),
  47. ~0u, // no _extensions_
  48. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_preserve_unknown_enum_unittest::MyMessage, _oneof_case_[0]),
  49. ~0u, // no _weak_field_map_
  50. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_preserve_unknown_enum_unittest::MyMessage, e_),
  51. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_preserve_unknown_enum_unittest::MyMessage, repeated_e_),
  52. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_preserve_unknown_enum_unittest::MyMessage, repeated_packed_e_),
  53. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_preserve_unknown_enum_unittest::MyMessage, repeated_packed_unexpected_e_),
  54. offsetof(::proto2_preserve_unknown_enum_unittest::MyMessageDefaultTypeInternal, oneof_e_1_),
  55. offsetof(::proto2_preserve_unknown_enum_unittest::MyMessageDefaultTypeInternal, oneof_e_2_),
  56. GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::proto2_preserve_unknown_enum_unittest::MyMessage, o_),
  57. 0,
  58. ~0u,
  59. ~0u,
  60. ~0u,
  61. ~0u,
  62. ~0u,
  63. };
  64. static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  65. { 0, 12, sizeof(::proto2_preserve_unknown_enum_unittest::MyMessage)},
  66. };
  67. static ::google::protobuf::Message const * const file_default_instances[] = {
  68. reinterpret_cast<const ::google::protobuf::Message*>(&::proto2_preserve_unknown_enum_unittest::_MyMessage_default_instance_),
  69. };
  70. void protobuf_AssignDescriptors() {
  71. AddDescriptors();
  72. AssignDescriptors(
  73. "google/protobuf/unittest_preserve_unknown_enum2.proto", schemas, file_default_instances, TableStruct::offsets,
  74. file_level_metadata, file_level_enum_descriptors, NULL);
  75. }
  76. void protobuf_AssignDescriptorsOnce() {
  77. static ::google::protobuf::internal::once_flag once;
  78. ::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors);
  79. }
  80. void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
  81. void protobuf_RegisterTypes(const ::std::string&) {
  82. protobuf_AssignDescriptorsOnce();
  83. ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
  84. }
  85. void AddDescriptorsImpl() {
  86. InitDefaults();
  87. static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  88. "\n5google/protobuf/unittest_preserve_unkn"
  89. "own_enum2.proto\022%proto2_preserve_unknown"
  90. "_enum_unittest\"\270\003\n\tMyMessage\0228\n\001e\030\001 \001(\0162"
  91. "-.proto2_preserve_unknown_enum_unittest."
  92. "MyEnum\022A\n\nrepeated_e\030\002 \003(\0162-.proto2_pres"
  93. "erve_unknown_enum_unittest.MyEnum\022L\n\021rep"
  94. "eated_packed_e\030\003 \003(\0162-.proto2_preserve_u"
  95. "nknown_enum_unittest.MyEnumB\002\020\001\022S\n\034repea"
  96. "ted_packed_unexpected_e\030\004 \003(\0162-.proto2_p"
  97. "reserve_unknown_enum_unittest.MyEnum\022B\n\t"
  98. "oneof_e_1\030\005 \001(\0162-.proto2_preserve_unknow"
  99. "n_enum_unittest.MyEnumH\000\022B\n\toneof_e_2\030\006 "
  100. "\001(\0162-.proto2_preserve_unknown_enum_unitt"
  101. "est.MyEnumH\000B\003\n\001o*#\n\006MyEnum\022\007\n\003FOO\020\000\022\007\n\003"
  102. "BAR\020\001\022\007\n\003BAZ\020\002"
  103. };
  104. ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
  105. descriptor, 574);
  106. ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
  107. "google/protobuf/unittest_preserve_unknown_enum2.proto", &protobuf_RegisterTypes);
  108. }
  109. void AddDescriptors() {
  110. static ::google::protobuf::internal::once_flag once;
  111. ::google::protobuf::internal::call_once(once, AddDescriptorsImpl);
  112. }
  113. // Force AddDescriptors() to be called at dynamic initialization time.
  114. struct StaticDescriptorInitializer {
  115. StaticDescriptorInitializer() {
  116. AddDescriptors();
  117. }
  118. } static_descriptor_initializer;
  119. } // namespace protobuf_google_2fprotobuf_2funittest_5fpreserve_5funknown_5fenum2_2eproto
  120. namespace proto2_preserve_unknown_enum_unittest {
  121. const ::google::protobuf::EnumDescriptor* MyEnum_descriptor() {
  122. protobuf_google_2fprotobuf_2funittest_5fpreserve_5funknown_5fenum2_2eproto::protobuf_AssignDescriptorsOnce();
  123. return protobuf_google_2fprotobuf_2funittest_5fpreserve_5funknown_5fenum2_2eproto::file_level_enum_descriptors[0];
  124. }
  125. bool MyEnum_IsValid(int value) {
  126. switch (value) {
  127. case 0:
  128. case 1:
  129. case 2:
  130. return true;
  131. default:
  132. return false;
  133. }
  134. }
  135. // ===================================================================
  136. void MyMessage::InitAsDefaultInstance() {
  137. ::proto2_preserve_unknown_enum_unittest::_MyMessage_default_instance_.oneof_e_1_ = 0;
  138. ::proto2_preserve_unknown_enum_unittest::_MyMessage_default_instance_.oneof_e_2_ = 0;
  139. }
  140. #if !defined(_MSC_VER) || _MSC_VER >= 1900
  141. const int MyMessage::kEFieldNumber;
  142. const int MyMessage::kRepeatedEFieldNumber;
  143. const int MyMessage::kRepeatedPackedEFieldNumber;
  144. const int MyMessage::kRepeatedPackedUnexpectedEFieldNumber;
  145. const int MyMessage::kOneofE1FieldNumber;
  146. const int MyMessage::kOneofE2FieldNumber;
  147. #endif // !defined(_MSC_VER) || _MSC_VER >= 1900
  148. MyMessage::MyMessage()
  149. : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  150. ::google::protobuf::internal::InitSCC(
  151. &protobuf_google_2fprotobuf_2funittest_5fpreserve_5funknown_5fenum2_2eproto::scc_info_MyMessage.base);
  152. SharedCtor();
  153. // @@protoc_insertion_point(constructor:proto2_preserve_unknown_enum_unittest.MyMessage)
  154. }
  155. MyMessage::MyMessage(const MyMessage& from)
  156. : ::google::protobuf::Message(),
  157. _internal_metadata_(NULL),
  158. _has_bits_(from._has_bits_),
  159. repeated_e_(from.repeated_e_),
  160. repeated_packed_e_(from.repeated_packed_e_),
  161. repeated_packed_unexpected_e_(from.repeated_packed_unexpected_e_) {
  162. _internal_metadata_.MergeFrom(from._internal_metadata_);
  163. e_ = from.e_;
  164. clear_has_o();
  165. switch (from.o_case()) {
  166. case kOneofE1: {
  167. set_oneof_e_1(from.oneof_e_1());
  168. break;
  169. }
  170. case kOneofE2: {
  171. set_oneof_e_2(from.oneof_e_2());
  172. break;
  173. }
  174. case O_NOT_SET: {
  175. break;
  176. }
  177. }
  178. // @@protoc_insertion_point(copy_constructor:proto2_preserve_unknown_enum_unittest.MyMessage)
  179. }
  180. void MyMessage::SharedCtor() {
  181. e_ = 0;
  182. clear_has_o();
  183. }
  184. MyMessage::~MyMessage() {
  185. // @@protoc_insertion_point(destructor:proto2_preserve_unknown_enum_unittest.MyMessage)
  186. SharedDtor();
  187. }
  188. void MyMessage::SharedDtor() {
  189. if (has_o()) {
  190. clear_o();
  191. }
  192. }
  193. void MyMessage::SetCachedSize(int size) const {
  194. _cached_size_.Set(size);
  195. }
  196. const ::google::protobuf::Descriptor* MyMessage::descriptor() {
  197. ::protobuf_google_2fprotobuf_2funittest_5fpreserve_5funknown_5fenum2_2eproto::protobuf_AssignDescriptorsOnce();
  198. return ::protobuf_google_2fprotobuf_2funittest_5fpreserve_5funknown_5fenum2_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
  199. }
  200. const MyMessage& MyMessage::default_instance() {
  201. ::google::protobuf::internal::InitSCC(&protobuf_google_2fprotobuf_2funittest_5fpreserve_5funknown_5fenum2_2eproto::scc_info_MyMessage.base);
  202. return *internal_default_instance();
  203. }
  204. void MyMessage::clear_o() {
  205. // @@protoc_insertion_point(one_of_clear_start:proto2_preserve_unknown_enum_unittest.MyMessage)
  206. switch (o_case()) {
  207. case kOneofE1: {
  208. // No need to clear
  209. break;
  210. }
  211. case kOneofE2: {
  212. // No need to clear
  213. break;
  214. }
  215. case O_NOT_SET: {
  216. break;
  217. }
  218. }
  219. _oneof_case_[0] = O_NOT_SET;
  220. }
  221. void MyMessage::Clear() {
  222. // @@protoc_insertion_point(message_clear_start:proto2_preserve_unknown_enum_unittest.MyMessage)
  223. ::google::protobuf::uint32 cached_has_bits = 0;
  224. // Prevent compiler warnings about cached_has_bits being unused
  225. (void) cached_has_bits;
  226. repeated_e_.Clear();
  227. repeated_packed_e_.Clear();
  228. repeated_packed_unexpected_e_.Clear();
  229. e_ = 0;
  230. clear_o();
  231. _has_bits_.Clear();
  232. _internal_metadata_.Clear();
  233. }
  234. bool MyMessage::MergePartialFromCodedStream(
  235. ::google::protobuf::io::CodedInputStream* input) {
  236. #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  237. ::google::protobuf::uint32 tag;
  238. // @@protoc_insertion_point(parse_start:proto2_preserve_unknown_enum_unittest.MyMessage)
  239. for (;;) {
  240. ::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
  241. tag = p.first;
  242. if (!p.second) goto handle_unusual;
  243. switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
  244. // optional .proto2_preserve_unknown_enum_unittest.MyEnum e = 1;
  245. case 1: {
  246. if (static_cast< ::google::protobuf::uint8>(tag) ==
  247. static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
  248. int value;
  249. DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
  250. int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
  251. input, &value)));
  252. if (::proto2_preserve_unknown_enum_unittest::MyEnum_IsValid(value)) {
  253. set_e(static_cast< ::proto2_preserve_unknown_enum_unittest::MyEnum >(value));
  254. } else {
  255. mutable_unknown_fields()->AddVarint(
  256. 1, static_cast< ::google::protobuf::uint64>(value));
  257. }
  258. } else {
  259. goto handle_unusual;
  260. }
  261. break;
  262. }
  263. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_e = 2;
  264. case 2: {
  265. if (static_cast< ::google::protobuf::uint8>(tag) ==
  266. static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
  267. int value;
  268. DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
  269. int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
  270. input, &value)));
  271. if (::proto2_preserve_unknown_enum_unittest::MyEnum_IsValid(value)) {
  272. add_repeated_e(static_cast< ::proto2_preserve_unknown_enum_unittest::MyEnum >(value));
  273. } else {
  274. mutable_unknown_fields()->AddVarint(
  275. 2, static_cast< ::google::protobuf::uint64>(value));
  276. }
  277. } else if (
  278. static_cast< ::google::protobuf::uint8>(tag) ==
  279. static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
  280. DO_((::google::protobuf::internal::WireFormat::ReadPackedEnumPreserveUnknowns(
  281. input,
  282. 2,
  283. ::proto2_preserve_unknown_enum_unittest::MyEnum_IsValid,
  284. mutable_unknown_fields(),
  285. this->mutable_repeated_e())));
  286. } else {
  287. goto handle_unusual;
  288. }
  289. break;
  290. }
  291. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_packed_e = 3 [packed = true];
  292. case 3: {
  293. if (static_cast< ::google::protobuf::uint8>(tag) ==
  294. static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
  295. ::google::protobuf::uint32 length;
  296. DO_(input->ReadVarint32(&length));
  297. ::google::protobuf::io::CodedInputStream::Limit limit = input->PushLimit(static_cast<int>(length));
  298. while (input->BytesUntilLimit() > 0) {
  299. int value;
  300. DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
  301. int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
  302. input, &value)));
  303. if (::proto2_preserve_unknown_enum_unittest::MyEnum_IsValid(value)) {
  304. add_repeated_packed_e(static_cast< ::proto2_preserve_unknown_enum_unittest::MyEnum >(value));
  305. } else {
  306. mutable_unknown_fields()->AddVarint(
  307. 3, static_cast< ::google::protobuf::uint64>(value));
  308. }
  309. }
  310. input->PopLimit(limit);
  311. } else if (
  312. static_cast< ::google::protobuf::uint8>(tag) ==
  313. static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) {
  314. int value;
  315. DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
  316. int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
  317. input, &value)));
  318. if (::proto2_preserve_unknown_enum_unittest::MyEnum_IsValid(value)) {
  319. add_repeated_packed_e(static_cast< ::proto2_preserve_unknown_enum_unittest::MyEnum >(value));
  320. } else {
  321. mutable_unknown_fields()->AddVarint(
  322. 3, static_cast< ::google::protobuf::uint64>(value));
  323. }
  324. } else {
  325. goto handle_unusual;
  326. }
  327. break;
  328. }
  329. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_packed_unexpected_e = 4;
  330. case 4: {
  331. if (static_cast< ::google::protobuf::uint8>(tag) ==
  332. static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) {
  333. int value;
  334. DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
  335. int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
  336. input, &value)));
  337. if (::proto2_preserve_unknown_enum_unittest::MyEnum_IsValid(value)) {
  338. add_repeated_packed_unexpected_e(static_cast< ::proto2_preserve_unknown_enum_unittest::MyEnum >(value));
  339. } else {
  340. mutable_unknown_fields()->AddVarint(
  341. 4, static_cast< ::google::protobuf::uint64>(value));
  342. }
  343. } else if (
  344. static_cast< ::google::protobuf::uint8>(tag) ==
  345. static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) {
  346. DO_((::google::protobuf::internal::WireFormat::ReadPackedEnumPreserveUnknowns(
  347. input,
  348. 4,
  349. ::proto2_preserve_unknown_enum_unittest::MyEnum_IsValid,
  350. mutable_unknown_fields(),
  351. this->mutable_repeated_packed_unexpected_e())));
  352. } else {
  353. goto handle_unusual;
  354. }
  355. break;
  356. }
  357. // optional .proto2_preserve_unknown_enum_unittest.MyEnum oneof_e_1 = 5;
  358. case 5: {
  359. if (static_cast< ::google::protobuf::uint8>(tag) ==
  360. static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) {
  361. int value;
  362. DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
  363. int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
  364. input, &value)));
  365. if (::proto2_preserve_unknown_enum_unittest::MyEnum_IsValid(value)) {
  366. set_oneof_e_1(static_cast< ::proto2_preserve_unknown_enum_unittest::MyEnum >(value));
  367. } else {
  368. mutable_unknown_fields()->AddVarint(
  369. 5, static_cast< ::google::protobuf::uint64>(value));
  370. }
  371. } else {
  372. goto handle_unusual;
  373. }
  374. break;
  375. }
  376. // optional .proto2_preserve_unknown_enum_unittest.MyEnum oneof_e_2 = 6;
  377. case 6: {
  378. if (static_cast< ::google::protobuf::uint8>(tag) ==
  379. static_cast< ::google::protobuf::uint8>(48u /* 48 & 0xFF */)) {
  380. int value;
  381. DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
  382. int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
  383. input, &value)));
  384. if (::proto2_preserve_unknown_enum_unittest::MyEnum_IsValid(value)) {
  385. set_oneof_e_2(static_cast< ::proto2_preserve_unknown_enum_unittest::MyEnum >(value));
  386. } else {
  387. mutable_unknown_fields()->AddVarint(
  388. 6, static_cast< ::google::protobuf::uint64>(value));
  389. }
  390. } else {
  391. goto handle_unusual;
  392. }
  393. break;
  394. }
  395. default: {
  396. handle_unusual:
  397. if (tag == 0) {
  398. goto success;
  399. }
  400. DO_(::google::protobuf::internal::WireFormat::SkipField(
  401. input, tag, _internal_metadata_.mutable_unknown_fields()));
  402. break;
  403. }
  404. }
  405. }
  406. success:
  407. // @@protoc_insertion_point(parse_success:proto2_preserve_unknown_enum_unittest.MyMessage)
  408. return true;
  409. failure:
  410. // @@protoc_insertion_point(parse_failure:proto2_preserve_unknown_enum_unittest.MyMessage)
  411. return false;
  412. #undef DO_
  413. }
  414. void MyMessage::SerializeWithCachedSizes(
  415. ::google::protobuf::io::CodedOutputStream* output) const {
  416. // @@protoc_insertion_point(serialize_start:proto2_preserve_unknown_enum_unittest.MyMessage)
  417. ::google::protobuf::uint32 cached_has_bits = 0;
  418. (void) cached_has_bits;
  419. cached_has_bits = _has_bits_[0];
  420. // optional .proto2_preserve_unknown_enum_unittest.MyEnum e = 1;
  421. if (cached_has_bits & 0x00000001u) {
  422. ::google::protobuf::internal::WireFormatLite::WriteEnum(
  423. 1, this->e(), output);
  424. }
  425. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_e = 2;
  426. for (int i = 0, n = this->repeated_e_size(); i < n; i++) {
  427. ::google::protobuf::internal::WireFormatLite::WriteEnum(
  428. 2, this->repeated_e(i), output);
  429. }
  430. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_packed_e = 3 [packed = true];
  431. if (this->repeated_packed_e_size() > 0) {
  432. ::google::protobuf::internal::WireFormatLite::WriteTag(
  433. 3,
  434. ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
  435. output);
  436. output->WriteVarint32(
  437. static_cast< ::google::protobuf::uint32>(_repeated_packed_e_cached_byte_size_));
  438. }
  439. for (int i = 0, n = this->repeated_packed_e_size(); i < n; i++) {
  440. ::google::protobuf::internal::WireFormatLite::WriteEnumNoTag(
  441. this->repeated_packed_e(i), output);
  442. }
  443. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_packed_unexpected_e = 4;
  444. for (int i = 0, n = this->repeated_packed_unexpected_e_size(); i < n; i++) {
  445. ::google::protobuf::internal::WireFormatLite::WriteEnum(
  446. 4, this->repeated_packed_unexpected_e(i), output);
  447. }
  448. switch (o_case()) {
  449. case kOneofE1:
  450. ::google::protobuf::internal::WireFormatLite::WriteEnum(
  451. 5, this->oneof_e_1(), output);
  452. break;
  453. case kOneofE2:
  454. ::google::protobuf::internal::WireFormatLite::WriteEnum(
  455. 6, this->oneof_e_2(), output);
  456. break;
  457. default: ;
  458. }
  459. if (_internal_metadata_.have_unknown_fields()) {
  460. ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
  461. _internal_metadata_.unknown_fields(), output);
  462. }
  463. // @@protoc_insertion_point(serialize_end:proto2_preserve_unknown_enum_unittest.MyMessage)
  464. }
  465. ::google::protobuf::uint8* MyMessage::InternalSerializeWithCachedSizesToArray(
  466. bool deterministic, ::google::protobuf::uint8* target) const {
  467. (void)deterministic; // Unused
  468. // @@protoc_insertion_point(serialize_to_array_start:proto2_preserve_unknown_enum_unittest.MyMessage)
  469. ::google::protobuf::uint32 cached_has_bits = 0;
  470. (void) cached_has_bits;
  471. cached_has_bits = _has_bits_[0];
  472. // optional .proto2_preserve_unknown_enum_unittest.MyEnum e = 1;
  473. if (cached_has_bits & 0x00000001u) {
  474. target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
  475. 1, this->e(), target);
  476. }
  477. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_e = 2;
  478. target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
  479. 2, this->repeated_e_, target);
  480. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_packed_e = 3 [packed = true];
  481. if (this->repeated_packed_e_size() > 0) {
  482. target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
  483. 3,
  484. ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
  485. target);
  486. target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( static_cast< ::google::protobuf::uint32>(
  487. _repeated_packed_e_cached_byte_size_), target);
  488. target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(
  489. this->repeated_packed_e_, target);
  490. }
  491. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_packed_unexpected_e = 4;
  492. target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
  493. 4, this->repeated_packed_unexpected_e_, target);
  494. switch (o_case()) {
  495. case kOneofE1:
  496. target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
  497. 5, this->oneof_e_1(), target);
  498. break;
  499. case kOneofE2:
  500. target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
  501. 6, this->oneof_e_2(), target);
  502. break;
  503. default: ;
  504. }
  505. if (_internal_metadata_.have_unknown_fields()) {
  506. target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
  507. _internal_metadata_.unknown_fields(), target);
  508. }
  509. // @@protoc_insertion_point(serialize_to_array_end:proto2_preserve_unknown_enum_unittest.MyMessage)
  510. return target;
  511. }
  512. size_t MyMessage::ByteSizeLong() const {
  513. // @@protoc_insertion_point(message_byte_size_start:proto2_preserve_unknown_enum_unittest.MyMessage)
  514. size_t total_size = 0;
  515. if (_internal_metadata_.have_unknown_fields()) {
  516. total_size +=
  517. ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
  518. _internal_metadata_.unknown_fields());
  519. }
  520. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_e = 2;
  521. {
  522. size_t data_size = 0;
  523. unsigned int count = static_cast<unsigned int>(this->repeated_e_size());for (unsigned int i = 0; i < count; i++) {
  524. data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(
  525. this->repeated_e(static_cast<int>(i)));
  526. }
  527. total_size += (1UL * count) + data_size;
  528. }
  529. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_packed_e = 3 [packed = true];
  530. {
  531. size_t data_size = 0;
  532. unsigned int count = static_cast<unsigned int>(this->repeated_packed_e_size());for (unsigned int i = 0; i < count; i++) {
  533. data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(
  534. this->repeated_packed_e(static_cast<int>(i)));
  535. }
  536. if (data_size > 0) {
  537. total_size += 1 +
  538. ::google::protobuf::internal::WireFormatLite::Int32Size(
  539. static_cast< ::google::protobuf::int32>(data_size));
  540. }
  541. int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
  542. GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  543. _repeated_packed_e_cached_byte_size_ = cached_size;
  544. GOOGLE_SAFE_CONCURRENT_WRITES_END();
  545. total_size += data_size;
  546. }
  547. // repeated .proto2_preserve_unknown_enum_unittest.MyEnum repeated_packed_unexpected_e = 4;
  548. {
  549. size_t data_size = 0;
  550. unsigned int count = static_cast<unsigned int>(this->repeated_packed_unexpected_e_size());for (unsigned int i = 0; i < count; i++) {
  551. data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(
  552. this->repeated_packed_unexpected_e(static_cast<int>(i)));
  553. }
  554. total_size += (1UL * count) + data_size;
  555. }
  556. // optional .proto2_preserve_unknown_enum_unittest.MyEnum e = 1;
  557. if (has_e()) {
  558. total_size += 1 +
  559. ::google::protobuf::internal::WireFormatLite::EnumSize(this->e());
  560. }
  561. switch (o_case()) {
  562. // optional .proto2_preserve_unknown_enum_unittest.MyEnum oneof_e_1 = 5;
  563. case kOneofE1: {
  564. total_size += 1 +
  565. ::google::protobuf::internal::WireFormatLite::EnumSize(this->oneof_e_1());
  566. break;
  567. }
  568. // optional .proto2_preserve_unknown_enum_unittest.MyEnum oneof_e_2 = 6;
  569. case kOneofE2: {
  570. total_size += 1 +
  571. ::google::protobuf::internal::WireFormatLite::EnumSize(this->oneof_e_2());
  572. break;
  573. }
  574. case O_NOT_SET: {
  575. break;
  576. }
  577. }
  578. int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  579. SetCachedSize(cached_size);
  580. return total_size;
  581. }
  582. void MyMessage::MergeFrom(const ::google::protobuf::Message& from) {
  583. // @@protoc_insertion_point(generalized_merge_from_start:proto2_preserve_unknown_enum_unittest.MyMessage)
  584. GOOGLE_DCHECK_NE(&from, this);
  585. const MyMessage* source =
  586. ::google::protobuf::internal::DynamicCastToGenerated<const MyMessage>(
  587. &from);
  588. if (source == NULL) {
  589. // @@protoc_insertion_point(generalized_merge_from_cast_fail:proto2_preserve_unknown_enum_unittest.MyMessage)
  590. ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  591. } else {
  592. // @@protoc_insertion_point(generalized_merge_from_cast_success:proto2_preserve_unknown_enum_unittest.MyMessage)
  593. MergeFrom(*source);
  594. }
  595. }
  596. void MyMessage::MergeFrom(const MyMessage& from) {
  597. // @@protoc_insertion_point(class_specific_merge_from_start:proto2_preserve_unknown_enum_unittest.MyMessage)
  598. GOOGLE_DCHECK_NE(&from, this);
  599. _internal_metadata_.MergeFrom(from._internal_metadata_);
  600. ::google::protobuf::uint32 cached_has_bits = 0;
  601. (void) cached_has_bits;
  602. repeated_e_.MergeFrom(from.repeated_e_);
  603. repeated_packed_e_.MergeFrom(from.repeated_packed_e_);
  604. repeated_packed_unexpected_e_.MergeFrom(from.repeated_packed_unexpected_e_);
  605. if (from.has_e()) {
  606. set_e(from.e());
  607. }
  608. switch (from.o_case()) {
  609. case kOneofE1: {
  610. set_oneof_e_1(from.oneof_e_1());
  611. break;
  612. }
  613. case kOneofE2: {
  614. set_oneof_e_2(from.oneof_e_2());
  615. break;
  616. }
  617. case O_NOT_SET: {
  618. break;
  619. }
  620. }
  621. }
  622. void MyMessage::CopyFrom(const ::google::protobuf::Message& from) {
  623. // @@protoc_insertion_point(generalized_copy_from_start:proto2_preserve_unknown_enum_unittest.MyMessage)
  624. if (&from == this) return;
  625. Clear();
  626. MergeFrom(from);
  627. }
  628. void MyMessage::CopyFrom(const MyMessage& from) {
  629. // @@protoc_insertion_point(class_specific_copy_from_start:proto2_preserve_unknown_enum_unittest.MyMessage)
  630. if (&from == this) return;
  631. Clear();
  632. MergeFrom(from);
  633. }
  634. bool MyMessage::IsInitialized() const {
  635. return true;
  636. }
  637. void MyMessage::Swap(MyMessage* other) {
  638. if (other == this) return;
  639. InternalSwap(other);
  640. }
  641. void MyMessage::InternalSwap(MyMessage* other) {
  642. using std::swap;
  643. repeated_e_.InternalSwap(&other->repeated_e_);
  644. repeated_packed_e_.InternalSwap(&other->repeated_packed_e_);
  645. repeated_packed_unexpected_e_.InternalSwap(&other->repeated_packed_unexpected_e_);
  646. swap(e_, other->e_);
  647. swap(o_, other->o_);
  648. swap(_oneof_case_[0], other->_oneof_case_[0]);
  649. swap(_has_bits_[0], other->_has_bits_[0]);
  650. _internal_metadata_.Swap(&other->_internal_metadata_);
  651. }
  652. ::google::protobuf::Metadata MyMessage::GetMetadata() const {
  653. protobuf_google_2fprotobuf_2funittest_5fpreserve_5funknown_5fenum2_2eproto::protobuf_AssignDescriptorsOnce();
  654. return ::protobuf_google_2fprotobuf_2funittest_5fpreserve_5funknown_5fenum2_2eproto::file_level_metadata[kIndexInFileMessages];
  655. }
  656. // @@protoc_insertion_point(namespace_scope)
  657. } // namespace proto2_preserve_unknown_enum_unittest
  658. namespace google {
  659. namespace protobuf {
  660. template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::proto2_preserve_unknown_enum_unittest::MyMessage* Arena::CreateMaybeMessage< ::proto2_preserve_unknown_enum_unittest::MyMessage >(Arena* arena) {
  661. return Arena::CreateInternal< ::proto2_preserve_unknown_enum_unittest::MyMessage >(arena);
  662. }
  663. } // namespace protobuf
  664. } // namespace google
  665. // @@protoc_insertion_point(global_scope)