generated_message_bases.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
32 
33 #include <google/protobuf/parse_context.h>
34 #include <google/protobuf/io/coded_stream.h>
35 #include <google/protobuf/io/zero_copy_stream_impl.h>
36 #include <google/protobuf/unknown_field_set.h>
37 #include <google/protobuf/wire_format.h>
38 #include <google/protobuf/wire_format_lite.h>
39 
40 // Must be last:
41 #include <google/protobuf/port_def.inc>
42 
43 namespace google {
44 namespace protobuf {
45 namespace internal {
46 
47 // =============================================================================
48 // ZeroFieldsBase
49 
52 }
53 
55  if (GetArenaForAllocation() != nullptr) return;
57 }
58 
61 }
62 
63 const char* ZeroFieldsBase::_InternalParse(const char* ptr,
65 #define CHK_(x) \
66  if (PROTOBUF_PREDICT_FALSE(!(x))) { \
67  goto failure; \
68  }
69 
70  while (!ctx->Done(&ptr)) {
71  uint32_t tag;
73  if ((tag == 0) || ((tag & 7) == 4)) {
74  CHK_(ptr);
75  ctx->SetLastTag(tag);
76  goto message_done;
77  }
80  ctx);
81  CHK_(ptr);
82  } // while
83 message_done:
84  return ptr;
85 failure:
86  ptr = nullptr;
87  goto message_done;
88 #undef CHK_
89 }
90 
93  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
97  target, stream);
98  }
99  return target;
100 }
101 
102 void ZeroFieldsBase::MergeImpl(Message* to_param, const Message& from_param) {
103  auto* to = static_cast<ZeroFieldsBase*>(to_param);
104  const auto* from = static_cast<const ZeroFieldsBase*>(&from_param);
106  to->_internal_metadata_.MergeFrom<UnknownFieldSet>(from->_internal_metadata_);
107 }
108 
109 void ZeroFieldsBase::CopyImpl(Message* to_param, const Message& from_param) {
110  auto* to = static_cast<ZeroFieldsBase*>(to_param);
111  const auto* from = static_cast<const ZeroFieldsBase*>(&from_param);
112  if (from == to) return;
113  to->_internal_metadata_.Clear<UnknownFieldSet>();
114  to->_internal_metadata_.MergeFrom<UnknownFieldSet>(from->_internal_metadata_);
115 }
116 
119 }
120 
121 } // namespace internal
122 } // namespace protobuf
123 } // namespace google
124 
125 #include <google/protobuf/port_undef.inc>
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
google::protobuf.internal::ReadTag
const char * ReadTag(const char *p, uint32 *out, uint32 max_tag=0)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:494
GOOGLE_DCHECK_NE
#define GOOGLE_DCHECK_NE
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:197
google::protobuf.internal::ZeroFieldsBase::Clear
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final
Definition: generated_message_bases.cc:50
ctx
Definition: benchmark-async.c:30
google::protobuf.internal::InternalMetadata::Delete
void Delete()
Definition: protobuf/src/google/protobuf/metadata_lite.h:79
google::protobuf.internal::ZeroFieldsBase
Definition: generated_message_bases.h:53
google::protobuf.internal::UnknownFieldParse
const char * UnknownFieldParse(uint32 tag, std::string *unknown, const char *ptr, ParseContext *ctx)
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.cc:606
google::protobuf.internal::ParseContext
Definition: bloaty/third_party/protobuf/src/google/protobuf/parse_context.h:336
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
to
size_t to
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1385
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
google::protobuf.internal::WireFormat::InternalSerializeUnknownFieldsToArray
static uint8 * InternalSerializeUnknownFieldsToArray(const UnknownFieldSet &unknown_fields, uint8 *target, io::EpsCopyOutputStream *stream)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format.cc:192
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
from
size_t from
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1384
google::protobuf::io::EpsCopyOutputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:651
google::protobuf.internal::ZeroFieldsBase::_cached_size_
internal::CachedSize _cached_size_
Definition: generated_message_bases.h:78
google::protobuf::UnknownFieldSet::default_instance
static const UnknownFieldSet * default_instance()
Definition: bloaty/third_party/protobuf/src/google/protobuf/unknown_field_set.cc:53
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
google::protobuf.internal::ZeroFieldsBase::_InternalSerialize
::uint8_t * _InternalSerialize(::uint8_t *target, io::EpsCopyOutputStream *stream) const final
Definition: generated_message_bases.cc:91
google::protobuf.internal::ZeroFieldsBase::InternalSwap
void InternalSwap(ZeroFieldsBase *other)
Definition: generated_message_bases.cc:117
google::protobuf.internal::InternalMetadata::Swap
PROTOBUF_NDEBUG_INLINE void Swap(InternalMetadata *other)
Definition: protobuf/src/google/protobuf/metadata_lite.h:126
google::protobuf.internal::InternalMetadata::mutable_unknown_fields
PROTOBUF_NDEBUG_INLINE T * mutable_unknown_fields()
Definition: protobuf/src/google/protobuf/metadata_lite.h:117
google::protobuf.internal::ZeroFieldsBase::MergeImpl
static void MergeImpl(Message *to, const Message &from)
Definition: generated_message_bases.cc:102
google::protobuf::Message::MaybeComputeUnknownFieldsSize
size_t MaybeComputeUnknownFieldsSize(size_t total_size, internal::CachedSize *cached_size) const
Definition: protobuf/src/google/protobuf/message.cc:195
google::protobuf.internal::ZeroFieldsBase::CopyImpl
static void CopyImpl(Message *to, const Message &from)
Definition: generated_message_bases.cc:109
google::protobuf.internal::InternalMetadata::have_unknown_fields
PROTOBUF_NDEBUG_INLINE bool have_unknown_fields() const
Definition: protobuf/src/google/protobuf/metadata_lite.h:98
google::protobuf.internal::ZeroFieldsBase::_InternalParse
const char * _InternalParse(const char *ptr, internal::ParseContext *ctx) final
Definition: generated_message_bases.cc:63
google::protobuf.internal::ZeroFieldsBase::~ZeroFieldsBase
~ZeroFieldsBase() override
Definition: generated_message_bases.cc:54
google::protobuf::Message
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.h:205
google::protobuf::MessageLite::GetArenaForAllocation
Arena * GetArenaForAllocation() const
Definition: protobuf/src/google/protobuf/message_lite.h:443
generated_message_bases.h
google::protobuf::UnknownFieldSet
Definition: bloaty/third_party/protobuf/src/google/protobuf/unknown_field_set.h:81
google::protobuf::MessageLite::_internal_metadata_
internal::InternalMetadata _internal_metadata_
Definition: protobuf/src/google/protobuf/message_lite.h:445
google::protobuf.internal::InternalMetadata::Clear
PROTOBUF_NDEBUG_INLINE void Clear()
Definition: protobuf/src/google/protobuf/metadata_lite.h:150
internal
Definition: benchmark/test/output_test_helper.cc:20
google::protobuf.internal::ZeroFieldsBase::ByteSizeLong
size_t ByteSizeLong() const final
Definition: generated_message_bases.cc:59
google::protobuf.internal::InternalMetadata::unknown_fields
const PROTOBUF_NDEBUG_INLINE T & unknown_fields(const T &(*default_instance)()) const
Definition: protobuf/src/google/protobuf/metadata_lite.h:107
setup.target
target
Definition: third_party/bloaty/third_party/protobuf/python/setup.py:179
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
CHK_
#define CHK_(x)
stream
voidpf stream
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:23