diff options
author | pg <[email protected]> | 2023-02-06 20:48:31 +0300 |
---|---|---|
committer | pg <[email protected]> | 2023-02-06 20:48:31 +0300 |
commit | 6cabb77676668397e5ac0afacc8c68b54c41c86b (patch) | |
tree | 8fa149d5288f046e8ecb7944fa299c69f17f86fe /contrib/libs/protoc/src/google/protobuf/compiler/cpp | |
parent | 717dbc4b00249886f789109e9af0432ece4d9586 (diff) |
less shim
К сожалению, люди успели наплодить переменных и методов c именами i64(), ui64(), поэтому для генеренного кода проще всего оказалось завести несколько type alias arc_ui64 -> ui64, и так далее.
Diffstat (limited to 'contrib/libs/protoc/src/google/protobuf/compiler/cpp')
8 files changed, 53 insertions, 53 deletions
diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc index 4f97b1c5e1c..263dff40792 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_enum.cc @@ -53,13 +53,13 @@ namespace { // is kint32max, GOOGLE_ARRAYSIZE will overflow. In such cases we should omit the // generation of the GOOGLE_ARRAYSIZE constant. bool ShouldGenerateArraySize(const EnumDescriptor* descriptor) { - i32 max_value = descriptor->value(0)->number(); + arc_i32 max_value = descriptor->value(0)->number(); for (int i = 0; i < descriptor->value_count(); i++) { if (descriptor->value(i)->number() > max_value) { max_value = descriptor->value(i)->number(); } } - return max_value != std::numeric_limits<i32>::max(); + return max_value != std::numeric_limits<arc_i32>::max(); } // Returns the number of unique numeric enum values. This is less than diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc index 0cc2dc4175b..0a5d2cd7726 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.cc @@ -269,7 +269,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor, (*variables)["}"] = ""; } -void FieldGenerator::SetHasBitIndex(i32 has_bit_index) { +void FieldGenerator::SetHasBitIndex(arc_i32 has_bit_index) { if (!HasHasbit(descriptor_)) { GOOGLE_CHECK_EQ(has_bit_index, -1); return; @@ -282,7 +282,7 @@ void FieldGenerator::SetHasBitIndex(i32 has_bit_index) { strings::Hex(1u << (has_bit_index % 32), strings::ZERO_PAD_8), "u;"); } -void FieldGenerator::SetInlinedStringIndex(i32 inlined_string_index) { +void FieldGenerator::SetInlinedStringIndex(arc_i32 inlined_string_index) { if (!IsStringInlined(descriptor_, options_)) { GOOGLE_CHECK_EQ(inlined_string_index, -1); return; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h index 90236d48ae6..8d50f88f126 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_field.h @@ -183,8 +183,8 @@ class FieldGenerator { virtual bool IsInlined() const { return false; } - void SetHasBitIndex(i32 has_bit_index); - void SetInlinedStringIndex(i32 inlined_string_index); + void SetHasBitIndex(arc_i32 has_bit_index); + void SetInlinedStringIndex(arc_i32 inlined_string_index); protected: const FieldDescriptor* descriptor_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc index 53f46a229b7..c5aa700c24e 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_helpers.cc @@ -635,7 +635,7 @@ const char* DeclaredTypeMethodName(FieldDescriptor::Type type) { } TProtoStringType Int32ToString(int number) { - if (number == std::numeric_limits<i32>::min()) { + if (number == std::numeric_limits<arc_i32>::min()) { // This needs to be special-cased, see explanation here: // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661 return StrCat(number + 1, " - 1"); @@ -644,17 +644,17 @@ TProtoStringType Int32ToString(int number) { } } -static TProtoStringType Int64ToString(i64 number) { - if (number == std::numeric_limits<i64>::min()) { +static TProtoStringType Int64ToString(arc_i64 number) { + if (number == std::numeric_limits<arc_i64>::min()) { // This needs to be special-cased, see explanation here: // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52661 - return StrCat("int64_t{", number + 1, "} - 1"); + return StrCat("arc_i64{", number + 1, "} - 1"); } - return StrCat("int64_t{", number, "}"); + return StrCat("arc_i64{", number, "}"); } -static TProtoStringType UInt64ToString(ui64 number) { - return StrCat("uint64_t{", number, "u}"); +static TProtoStringType UInt64ToString(arc_ui64 number) { + return StrCat("arc_ui64{", number, "u}"); } TProtoStringType DefaultValue(const FieldDescriptor* field) { diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc index 98ba9a393a5..062b2bb7545 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.cc @@ -83,7 +83,7 @@ static constexpr int kNoHasbit = -1; // masks is allowed to be shorter than _has_bits_, but at least one element of // masks must be non-zero. TProtoStringType ConditionalToCheckBitmasks( - const std::vector<ui32>& masks, bool return_success = true, + const std::vector<arc_ui32>& masks, bool return_success = true, StringPiece has_bits_var = "_has_bits_") { std::vector<TProtoStringType> parts; for (int i = 0; i < masks.size(); i++) { @@ -422,23 +422,23 @@ std::vector<std::vector<const FieldDescriptor*>> CollectFields( // Returns a bit mask based on has_bit index of "fields" that are typically on // the same chunk. It is used in a group presence check where _has_bits_ is // masked to tell if any thing in "fields" is present. -ui32 GenChunkMask(const std::vector<const FieldDescriptor*>& fields, +arc_ui32 GenChunkMask(const std::vector<const FieldDescriptor*>& fields, const std::vector<int>& has_bit_indices) { GOOGLE_CHECK(!fields.empty()); int first_index_offset = has_bit_indices[fields.front()->index()] / 32; - ui32 chunk_mask = 0; + arc_ui32 chunk_mask = 0; for (auto field : fields) { // "index" defines where in the _has_bits_ the field appears. int index = has_bit_indices[field->index()]; GOOGLE_CHECK_EQ(first_index_offset, index / 32); - chunk_mask |= static_cast<ui32>(1) << (index % 32); + chunk_mask |= static_cast<arc_ui32>(1) << (index % 32); } GOOGLE_CHECK_NE(0, chunk_mask); return chunk_mask; } // Return the number of bits set in n, a non-negative integer. -static int popcnt(ui32 n) { +static int popcnt(arc_ui32 n) { int result = 0; while (n != 0) { result += (n & 1); @@ -524,7 +524,7 @@ void ColdChunkSkipper::OnStartChunk(int chunk, int cached_has_word_index, format("if (PROTOBUF_PREDICT_FALSE("); int first_word = HasbitWord(chunk, 0); while (chunk < limit_chunk_) { - ui32 mask = 0; + arc_ui32 mask = 0; int this_word = HasbitWord(chunk, 0); // Generate mask for chunks on the same word. for (; chunk < limit_chunk_ && HasbitWord(chunk, 0) == this_word; chunk++) { @@ -2088,7 +2088,7 @@ namespace { // We need to calculate for each field what function the table driven code // should use to serialize it. This returns the index in a lookup table. -ui32 CalcFieldNum(const FieldGenerator& generator, +arc_ui32 CalcFieldNum(const FieldGenerator& generator, const FieldDescriptor* field, const Options& options) { bool is_a_map = IsMapEntryMessage(field->containing_type()); int type = field->type(); @@ -2143,7 +2143,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { const FieldDescriptor* field = sorted[i]; const FieldGenerator& generator = field_generators_.get(field); - ui32 tag = internal::WireFormatLite::MakeTag( + arc_ui32 tag = internal::WireFormatLite::MakeTag( field->number(), WireFormat::WireTypeForFieldType(field->type())); std::map<TProtoStringType, TProtoStringType> vars; @@ -2200,7 +2200,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { if (i == sorted.size()) break; const FieldDescriptor* field = sorted[i]; - ui32 tag = internal::WireFormatLite::MakeTag( + arc_ui32 tag = internal::WireFormatLite::MakeTag( field->number(), WireFormat::WireTypeForFieldType(field->type())); if (field->is_packed()) { tag = internal::WireFormatLite::MakeTag( @@ -2263,7 +2263,7 @@ int MessageGenerator::GenerateFieldMetadata(io::Printer* printer) { tag); } else if (field->real_containing_oneof()) { format.Set("oneofoffset", - sizeof(ui32) * field->containing_oneof()->index()); + sizeof(arc_ui32) * field->containing_oneof()->index()); format( "{PROTOBUF_FIELD_OFFSET($classtype$, $field_name$_), $1$," " PROTOBUF_FIELD_OFFSET($classtype$, _oneof_case_) + " @@ -2374,7 +2374,7 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { } } if (num_required_fields_ > 0) { - const std::vector<ui32> masks_for_has_bits = RequiredFieldsBitMask(); + const std::vector<arc_ui32> masks_for_has_bits = RequiredFieldsBitMask(); format( "static bool MissingRequiredFields(const HasBits& has_bits) " "{\n" @@ -3285,7 +3285,7 @@ void MessageGenerator::GenerateClear(io::Printer* printer) { if (have_outer_if) { // Emit an if() that will let us skip the whole chunk if none are set. - ui32 chunk_mask = GenChunkMask(chunk, has_bit_indices_); + arc_ui32 chunk_mask = GenChunkMask(chunk, has_bit_indices_); TProtoStringType chunk_mask_str = StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8)); @@ -3599,7 +3599,7 @@ void MessageGenerator::GenerateClassSpecificMergeFrom(io::Printer* printer) { if (have_outer_if) { // Emit an if() that will let us skip the whole chunk if none are set. - ui32 chunk_mask = GenChunkMask(chunk, has_bit_indices_); + arc_ui32 chunk_mask = GenChunkMask(chunk, has_bit_indices_); TProtoStringType chunk_mask_str = StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8)); @@ -4220,9 +4220,9 @@ void MessageGenerator::GenerateSerializeWithCachedSizesBodyShuffled( format("}\n"); } -std::vector<ui32> MessageGenerator::RequiredFieldsBitMask() const { +std::vector<arc_ui32> MessageGenerator::RequiredFieldsBitMask() const { const int array_size = HasBitsSize(); - std::vector<ui32> masks(array_size, 0); + std::vector<arc_ui32> masks(array_size, 0); for (auto field : FieldRange(descriptor_)) { if (!field->is_required()) { @@ -4230,7 +4230,7 @@ std::vector<ui32> MessageGenerator::RequiredFieldsBitMask() const { } const int has_bit_index = has_bit_indices_[field->index()]; - masks[has_bit_index / 32] |= static_cast<ui32>(1) + masks[has_bit_index / 32] |= static_cast<arc_ui32>(1) << (has_bit_index % 32); } return masks; @@ -4315,7 +4315,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { // present then the fast path executes; otherwise the slow path executes. if (num_required_fields_ > 1) { // The fast path works if all required fields are present. - const std::vector<ui32> masks_for_has_bits = RequiredFieldsBitMask(); + const std::vector<arc_ui32> masks_for_has_bits = RequiredFieldsBitMask(); format("if ($1$) { // All required fields are present.\n", ConditionalToCheckBitmasks(masks_for_has_bits)); format.Indent(); @@ -4371,7 +4371,7 @@ void MessageGenerator::GenerateByteSize(io::Printer* printer) { if (have_outer_if) { // Emit an if() that will let us skip the whole chunk if none are set. - ui32 chunk_mask = GenChunkMask(chunk, has_bit_indices_); + arc_ui32 chunk_mask = GenChunkMask(chunk, has_bit_indices_); TProtoStringType chunk_mask_str = StrCat(strings::Hex(chunk_mask, strings::ZERO_PAD_8)); diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h index 8bd87df4164..939f21a1dac 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_message.h @@ -183,7 +183,7 @@ class MessageGenerator { int HasByteIndex(const FieldDescriptor* a) const; int HasWordIndex(const FieldDescriptor* a) const; bool SameHasByte(const FieldDescriptor* a, const FieldDescriptor* b) const; - std::vector<ui32> RequiredFieldsBitMask() const; + std::vector<arc_ui32> RequiredFieldsBitMask() const; const Descriptor* descriptor_; int index_in_file_messages_; diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc index d8c87390350..ac3e57cda82 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc @@ -66,7 +66,7 @@ bool HasInternalAccessors(const FieldOptions::CType ctype) { return ctype == FieldOptions::STRING || ctype == FieldOptions::CORD; } -int TagSize(ui32 field_number) { +int TagSize(arc_ui32 field_number) { if (field_number < 16) return 1; GOOGLE_CHECK_LT(field_number, (1 << 14)) << "coded tag for " << field_number << " too big for uint16_t"; @@ -109,7 +109,7 @@ TProtoStringType MessageTcParseFunctionName(const FieldDescriptor* field, TProtoStringType FieldParseFunctionName(const FieldDescriptor* field, const Options& options, - ui32 table_size_log2); + arc_ui32 table_size_log2); } // namespace @@ -152,7 +152,7 @@ TailCallTableInfo::TailCallTableInfo(const Descriptor* descriptor, // byte 0 byte 1 // 1nnnnttt 0nnnnnnn // ^^^^^^^ ^^^^^^^ - ui32 tag = WireFormat::MakeTag(field); + arc_ui32 tag = WireFormat::MakeTag(field); if (tag >= 1 << 14) { continue; } else if (tag >= 1 << 7) { @@ -167,7 +167,7 @@ TailCallTableInfo::TailCallTableInfo(const Descriptor* descriptor, // ^^^^^ // This means that any field number that does not fit in the lower 4 bits // will always have the top bit of its table index asserted: - ui32 idx = (tag >> 3) & (table_size - 1); + arc_ui32 idx = (tag >> 3) & (table_size - 1); // If this entry in the table is already used, then this field will be // handled by the generated fallback function. if (!fast_path_fields[idx].func_name.empty()) continue; @@ -425,7 +425,7 @@ void ParseFunctionGenerator::GenerateTailcallFieldParseFunctions( " PROTOBUF_MUSTTAIL " "return table->fallback(PROTOBUF_TC_PARAM_PASS);\n" " ptr += $1$;\n" - " hasbits |= (uint64_t{1} << data.hasbit_idx());\n" + " hasbits |= (arc_ui64{1} << data.hasbit_idx());\n" " ::$proto_ns$::internal::TcParserBase::SyncHasbits" "(msg, hasbits, table);\n" " auto& field = ::$proto_ns$::internal::TcParserBase::" @@ -834,7 +834,7 @@ void ParseFunctionGenerator::GenerateFieldBody( {{"put_field", StrCat("set_", FieldName(field))}, {"mutable_field", StrCat("mutable_", FieldName(field))}}); } - ui32 tag = WireFormatLite::MakeTag(field->number(), wiretype); + arc_ui32 tag = WireFormatLite::MakeTag(field->number(), wiretype); switch (wiretype) { case WireFormatLite::WIRETYPE_VARINT: { TProtoStringType type = PrimitiveTypeName(options_, field->cpp_type()); @@ -925,15 +925,15 @@ void ParseFunctionGenerator::GenerateFieldBody( // Returns the tag for this field and in case of repeated packable fields, // sets a fallback tag in fallback_tag_ptr. -static ui32 ExpectedTag(const FieldDescriptor* field, - ui32* fallback_tag_ptr) { - ui32 expected_tag; +static arc_ui32 ExpectedTag(const FieldDescriptor* field, + arc_ui32* fallback_tag_ptr) { + arc_ui32 expected_tag; if (field->is_packable()) { auto expected_wiretype = WireFormat::WireTypeForFieldType(field->type()); expected_tag = WireFormatLite::MakeTag(field->number(), expected_wiretype); GOOGLE_CHECK(expected_wiretype != WireFormatLite::WIRETYPE_LENGTH_DELIMITED); auto fallback_wiretype = WireFormatLite::WIRETYPE_LENGTH_DELIMITED; - ui32 fallback_tag = + arc_ui32 fallback_tag = WireFormatLite::MakeTag(field->number(), fallback_wiretype); if (field->is_packed()) std::swap(expected_tag, fallback_tag); @@ -996,9 +996,9 @@ void ParseFunctionGenerator::GenerateParseIterationBody( descriptor->extension_range(i); if (i > 0) format(" ||\n "); - ui32 start_tag = WireFormatLite::MakeTag( + arc_ui32 start_tag = WireFormatLite::MakeTag( range->start, static_cast<WireFormatLite::WireType>(0)); - ui32 end_tag = WireFormatLite::MakeTag( + arc_ui32 end_tag = WireFormatLite::MakeTag( range->end, static_cast<WireFormatLite::WireType>(0)); if (range->end > FieldDescriptor::kMaxNumber) { @@ -1035,13 +1035,13 @@ void ParseFunctionGenerator::GenerateFieldSwitch( PrintFieldComment(format, field); format("case $1$:\n", field->number()); format.Indent(); - ui32 fallback_tag = 0; - ui32 expected_tag = ExpectedTag(field, &fallback_tag); + arc_ui32 fallback_tag = 0; + arc_ui32 expected_tag = ExpectedTag(field, &fallback_tag); format("if (PROTOBUF_PREDICT_TRUE(static_cast<$uint8$>(tag) == $1$)) {\n", expected_tag & 0xFF); format.Indent(); auto wiretype = WireFormatLite::GetTagWireType(expected_tag); - ui32 tag = WireFormatLite::MakeTag(field->number(), wiretype); + arc_ui32 tag = WireFormatLite::MakeTag(field->number(), wiretype); int tag_size = io::CodedOutputStream::VarintSize32(tag); bool is_repeat = ShouldRepeat(field, wiretype); if (is_repeat) { @@ -1087,7 +1087,7 @@ namespace { TProtoStringType FieldParseFunctionName(const FieldDescriptor* field, const Options& options, - ui32 table_size_log2) { + arc_ui32 table_size_log2) { ParseCardinality card = // field->is_packed() ? ParseCardinality::kPacked : field->is_repeated() ? ParseCardinality::kRepeated @@ -1244,20 +1244,20 @@ TProtoStringType GetTailCallFieldHandlerName(ParseCardinality card, switch (type_format) { case TypeFormat::kVar64: case TypeFormat::kFixed64: - name.append("uint64_t, "); + name.append("arc_ui64, "); break; case TypeFormat::kSInt64: - name.append("int64_t, "); + name.append("arc_i64, "); break; case TypeFormat::kVar32: case TypeFormat::kFixed32: - name.append("uint32_t, "); + name.append("arc_ui32, "); break; case TypeFormat::kSInt32: - name.append("int32_t, "); + name.append("arc_i32, "); break; case TypeFormat::kBool: diff --git a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h index 71eb82626f9..820f7b3089b 100644 --- a/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h +++ b/contrib/libs/protoc/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.h @@ -65,7 +65,7 @@ struct TailCallTableInfo { // Table size. int table_size_log2; // Mask for has-bits of required fields. - ui32 has_hasbits_required_mask; + arc_ui32 has_hasbits_required_mask; // True if a generated fallback function is required instead of generic. bool use_generated_fallback; }; |