mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-25 19:18:39 +00:00
[C++] Update to address comparator failure in big endian (#7681)
* update unit test and generated file to test is extra endianswap can help resolve issue * remove EndianScalar wrapper from Get method * remove endianscalar wrapper * update * update * use Array instead * clang format * address error * clang * update * manually generate * Move Nim to completed language * Add swift link * address comments * update unit test * address comment * address comment * regenerate file * use auto instead of size_t * use uint32_t instead * update * format * delete extra whitespace Co-authored-by: Wen Sun <sunwen@google.com> Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
@@ -67,12 +67,13 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) Baz FLATBUFFERS_FINAL_CLASS {
|
||||
bool KeyCompareLessThan(const Baz * const o) const {
|
||||
return KeyCompareWithValue(o->a()) < 0;
|
||||
}
|
||||
int KeyCompareWithValue(const flatbuffers::Array<uint8_t, 4> *_a) const {
|
||||
for (auto i = 0; i < a()->size(); i++) {
|
||||
const auto a_l = a_[i];
|
||||
const auto a_r = _a->Get(i);
|
||||
if(a_l != a_r)
|
||||
return static_cast<int>(a_l > a_r) - static_cast<int>(a_l < a_r);
|
||||
int KeyCompareWithValue(const flatbuffers::Array<uint8_t, 4> *_a) const {
|
||||
const flatbuffers::Array<uint8_t, 4> *curr_a = a();
|
||||
for (flatbuffers::uoffset_t i = 0; i < curr_a->size(); i++) {
|
||||
const auto lhs = curr_a->Get(i);
|
||||
const auto rhs = _a->Get(i);
|
||||
if(lhs != rhs)
|
||||
return static_cast<int>(lhs > rhs) - static_cast<int>(lhs < rhs);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -139,12 +140,13 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Bar FLATBUFFERS_FINAL_CLASS {
|
||||
bool KeyCompareLessThan(const Bar * const o) const {
|
||||
return KeyCompareWithValue(o->a()) < 0;
|
||||
}
|
||||
int KeyCompareWithValue(const flatbuffers::Array<float, 3> *_a) const {
|
||||
for (auto i = 0; i < a()->size(); i++) {
|
||||
const auto a_l = a_[i];
|
||||
const auto a_r = _a->Get(i);
|
||||
if(a_l != a_r)
|
||||
return static_cast<int>(a_l > a_r) - static_cast<int>(a_l < a_r);
|
||||
int KeyCompareWithValue(const flatbuffers::Array<float, 3> *_a) const {
|
||||
const flatbuffers::Array<float, 3> *curr_a = a();
|
||||
for (flatbuffers::uoffset_t i = 0; i < curr_a->size(); i++) {
|
||||
const auto lhs = curr_a->Get(i);
|
||||
const auto rhs = _a->Get(i);
|
||||
if(lhs != rhs)
|
||||
return static_cast<int>(lhs > rhs) - static_cast<int>(lhs < rhs);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user