mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
various fixes for google merge
This commit is contained in:
@@ -330,7 +330,7 @@ typedef uintmax_t largest_scalar_t;
|
||||
|
||||
// We support aligning the contents of buffers up to this size.
|
||||
#ifndef FLATBUFFERS_MAX_ALIGNMENT
|
||||
#define FLATBUFFERS_MAX_ALIGNMENT 16
|
||||
#define FLATBUFFERS_MAX_ALIGNMENT 32
|
||||
#endif
|
||||
|
||||
/// @brief The length of a FlatBuffer file header.
|
||||
|
||||
@@ -442,6 +442,7 @@ class FlatBufferBuilder {
|
||||
// Aligns such that when "len" bytes are written, an object can be written
|
||||
// after it with "alignment" without padding.
|
||||
void PreAlign(size_t len, size_t alignment) {
|
||||
if (len == 0) return;
|
||||
TrackMinAlign(alignment);
|
||||
buf_.fill(PaddingBytes(GetSize() + len, alignment));
|
||||
}
|
||||
@@ -600,12 +601,14 @@ class FlatBufferBuilder {
|
||||
// This is useful when storing a nested_flatbuffer in a vector of bytes,
|
||||
// or when storing SIMD floats, etc.
|
||||
void ForceVectorAlignment(size_t len, size_t elemsize, size_t alignment) {
|
||||
if (len == 0) return;
|
||||
FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment));
|
||||
PreAlign(len * elemsize, alignment);
|
||||
}
|
||||
|
||||
// Similar to ForceVectorAlignment but for String fields.
|
||||
void ForceStringAlignment(size_t len, size_t alignment) {
|
||||
if (len == 0) return;
|
||||
FLATBUFFERS_ASSERT(VerifyAlignmentRequirements(alignment));
|
||||
PreAlign((len + 1) * sizeof(char), alignment);
|
||||
}
|
||||
|
||||
@@ -1102,8 +1102,9 @@ CheckedError Parser::ParseAnyValue(Value &val, FieldDef *field,
|
||||
uint8_t enum_idx;
|
||||
if (vector_of_union_types) {
|
||||
if (vector_of_union_types->size() <= count)
|
||||
return Error("union types vector smaller than union values vector"
|
||||
" for: " + field->name);
|
||||
return Error(
|
||||
"union types vector smaller than union values vector for: " +
|
||||
field->name);
|
||||
enum_idx = vector_of_union_types->Get(count);
|
||||
} else {
|
||||
ECHECK(atot(constant.c_str(), *this, &enum_idx));
|
||||
@@ -2884,7 +2885,8 @@ CheckedError Parser::ParseProtoFields(StructDef *struct_def, bool isextend,
|
||||
if (key == "default") {
|
||||
// Temp: skip non-numeric and non-boolean defaults (enums).
|
||||
auto numeric = strpbrk(val.c_str(), "0123456789-+.");
|
||||
if (IsScalar(type.base_type) && numeric == val.c_str()) {
|
||||
if (IsScalar(type.base_type) &&
|
||||
(numeric == val.c_str() || val == "inf" || val == "-inf")) {
|
||||
field->value.constant = val;
|
||||
} else if (val == "true") {
|
||||
field->value.constant = val;
|
||||
@@ -3255,7 +3257,6 @@ CheckedError Parser::ParseRoot(const char *source, const char **include_paths,
|
||||
}
|
||||
// Parse JSON object only if the scheme has been parsed.
|
||||
if (token_ == '{') { ECHECK(DoParseJson()); }
|
||||
EXPECT(kTokenEof);
|
||||
return NoError();
|
||||
}
|
||||
|
||||
@@ -3423,6 +3424,7 @@ CheckedError Parser::DoParse(const char *source, const char **include_paths,
|
||||
ECHECK(ParseDecl(source_filename));
|
||||
}
|
||||
}
|
||||
EXPECT(kTokenEof);
|
||||
if (opts.warnings_as_errors && has_warning_) {
|
||||
return Error("treating warnings as errors, failed due to above warnings");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user