Fixes for Windows compiler errors.
Change-Id: I909ea6866089f36f9cb79d435bbecd29623fd8f7
This commit is contained in:
parent
f878024d0b
commit
c57ab92e60
|
@ -141,8 +141,8 @@ inline uint64_t ReadUInt64(const uint8_t *data, uint8_t byte_width) {
|
|||
// the conditionals in ReadSizedScalar. Can also use inline asm.
|
||||
#ifdef _MSC_VER
|
||||
uint64_t u = 0;
|
||||
__movsb(reinterpret_cast<int8_t *>(&u),
|
||||
reinterpret_cast<const int8_t *>(data), byte_width);
|
||||
__movsb(reinterpret_cast<uint8_t *>(&u),
|
||||
reinterpret_cast<const uint8_t *>(data), byte_width);
|
||||
return flatbuffers::EndianScalar(u);
|
||||
#else
|
||||
return ReadSizedScalar<uint64_t, uint8_t, uint16_t, uint32_t, uint64_t>(
|
||||
|
@ -307,7 +307,8 @@ class Map : public Vector {
|
|||
const size_t num_prefixed_fields = 3;
|
||||
auto keys_offset = data_ - byte_width_ * num_prefixed_fields;
|
||||
return TypedVector(Indirect(keys_offset, byte_width_),
|
||||
ReadUInt64(keys_offset + byte_width_, byte_width_),
|
||||
static_cast<uint8_t>(
|
||||
ReadUInt64(keys_offset + byte_width_, byte_width_)),
|
||||
TYPE_KEY);
|
||||
}
|
||||
|
||||
|
@ -878,7 +879,7 @@ class Builder FLATBUFFERS_FINAL_CLASS {
|
|||
// Remove temp elements and return vector.
|
||||
stack_.resize(start);
|
||||
stack_.push_back(vec);
|
||||
return vec.u_;
|
||||
return static_cast<size_t>(vec.u_);
|
||||
}
|
||||
|
||||
size_t EndMap(size_t start) {
|
||||
|
@ -904,7 +905,8 @@ class Builder FLATBUFFERS_FINAL_CLASS {
|
|||
// sorted fashion.
|
||||
// std::sort is typically already a lot faster on sorted data though.
|
||||
auto dict = reinterpret_cast<TwoValue *>(stack_.data() + start);
|
||||
std::sort(dict, dict + len, [&](const TwoValue &a, const TwoValue &b) {
|
||||
std::sort(dict, dict + len,
|
||||
[&](const TwoValue &a, const TwoValue &b) -> bool {
|
||||
auto as = reinterpret_cast<const char *>(buf_.data() + a.key.u_);
|
||||
auto bs = reinterpret_cast<const char *>(buf_.data() + b.key.u_);
|
||||
auto comp = strcmp(as, bs);
|
||||
|
@ -921,7 +923,7 @@ class Builder FLATBUFFERS_FINAL_CLASS {
|
|||
// Remove temp elements and return map.
|
||||
stack_.resize(start);
|
||||
stack_.push_back(vec);
|
||||
return vec.u_;
|
||||
return static_cast<size_t>(vec.u_);
|
||||
}
|
||||
|
||||
template<typename F> size_t Vector(F f) {
|
||||
|
|
|
@ -1372,9 +1372,9 @@ void FlexBuffersTest() {
|
|||
slb += "Fred";
|
||||
slb.IndirectFloat(4.0f);
|
||||
});
|
||||
std::vector<int> ints = { 1, 2, 3 };
|
||||
int ints[] = { 1, 2, 3 };
|
||||
slb.Add("bar", ints);
|
||||
slb.FixedTypedVector("bar3", ints.data(), ints.size()); // Static size.
|
||||
slb.FixedTypedVector("bar3", ints, sizeof(ints) / sizeof(int));
|
||||
slb.Double("foo", 100);
|
||||
slb.Map("mymap", [&]() {
|
||||
slb.String("foo", "Fred"); // Testing key and string reuse.
|
||||
|
|
Loading…
Reference in New Issue