|
|
@ -102,7 +102,8 @@ std::vector<int32_t> SortedUniqueEnumNumbers( |
|
|
|
values.push_back(e->value(i)->number()); |
|
|
|
values.push_back(e->value(i)->number()); |
|
|
|
} |
|
|
|
} |
|
|
|
std::sort(values.begin(), values.end()); |
|
|
|
std::sort(values.begin(), values.end()); |
|
|
|
std::unique(values.begin(), values.end()); |
|
|
|
auto last = std::unique(values.begin(), values.end()); |
|
|
|
|
|
|
|
values.erase(last, values.end()); |
|
|
|
return values; |
|
|
|
return values; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1311,22 +1312,20 @@ int WriteEnums(const protobuf::FileDescriptor* file, Output& output) { |
|
|
|
|
|
|
|
|
|
|
|
for (const auto* e : this_file_enums) { |
|
|
|
for (const auto* e : this_file_enums) { |
|
|
|
uint64_t mask = 0; |
|
|
|
uint64_t mask = 0; |
|
|
|
absl::flat_hash_set<int32_t> values; |
|
|
|
std::vector<int32_t> values; |
|
|
|
for (auto number : SortedUniqueEnumNumbers(e)) { |
|
|
|
for (auto number : SortedUniqueEnumNumbers(e)) { |
|
|
|
if (static_cast<uint32_t>(number) < 64) { |
|
|
|
if (static_cast<uint32_t>(number) < 64) { |
|
|
|
mask |= 1ULL << number; |
|
|
|
mask |= 1ULL << number; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
values.insert(number); |
|
|
|
values.push_back(number); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
std::vector<int32_t> values_vec(values.begin(), values.end()); |
|
|
|
|
|
|
|
std::sort(values_vec.begin(), values_vec.end()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!values_vec.empty()) { |
|
|
|
if (!values.empty()) { |
|
|
|
values_init = EnumInit(e) + "_values"; |
|
|
|
values_init = EnumInit(e) + "_values"; |
|
|
|
output("static const int32_t $0[$1] = {\n", values_init, |
|
|
|
output("static const int32_t $0[$1] = {\n", values_init, |
|
|
|
values_vec.size()); |
|
|
|
values.size()); |
|
|
|
for (auto value : values_vec) { |
|
|
|
for (auto value : values) { |
|
|
|
output(" $0,\n", value); |
|
|
|
output(" $0,\n", value); |
|
|
|
} |
|
|
|
} |
|
|
|
output("};\n\n"); |
|
|
|
output("};\n\n"); |
|
|
@ -1335,7 +1334,7 @@ int WriteEnums(const protobuf::FileDescriptor* file, Output& output) { |
|
|
|
output("const upb_MiniTable_Enum $0 = {\n", EnumInit(e)); |
|
|
|
output("const upb_MiniTable_Enum $0 = {\n", EnumInit(e)); |
|
|
|
output(" $0,\n", values_init); |
|
|
|
output(" $0,\n", values_init); |
|
|
|
output(" 0x$0ULL,\n", absl::Hex(mask)); |
|
|
|
output(" 0x$0ULL,\n", absl::Hex(mask)); |
|
|
|
output(" $0,\n", values_vec.size()); |
|
|
|
output(" $0,\n", values.size()); |
|
|
|
|
|
|
|
|
|
|
|
output("};\n\n"); |
|
|
|
output("};\n\n"); |
|
|
|
} |
|
|
|
} |
|
|
|