unittest_drop_unknown_fields.pb.cc 31 KB

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