mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-05 04:37:06 +00:00
General Codebase clean up (#5939)
* Fixed refractoring issue in reflection/generate_code.sh. Also, mv deletes the original file, so I don't need to clean it up manually in that case. * Ensuring test/generate_code.sh was ran * Fixed Dart Tests by removing code-gen for included files. * General cleanup of codebase.
This commit is contained in:
@@ -76,9 +76,7 @@ class CodeWriter {
|
||||
if (cur_ident_lvl_) cur_ident_lvl_--;
|
||||
}
|
||||
|
||||
void SetPadding(const std::string &padding) {
|
||||
pad_ = padding;
|
||||
}
|
||||
void SetPadding(const std::string &padding) { pad_ = padding; }
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> value_map_;
|
||||
|
||||
@@ -1803,7 +1803,8 @@ class FlatBufferBuilder {
|
||||
return a.KeyCompareLessThan(&b);
|
||||
}
|
||||
|
||||
FLATBUFFERS_DELETE_FUNC(StructKeyComparator &operator=(const StructKeyComparator &))
|
||||
FLATBUFFERS_DELETE_FUNC(
|
||||
StructKeyComparator &operator=(const StructKeyComparator &))
|
||||
};
|
||||
/// @endcond
|
||||
|
||||
|
||||
@@ -410,9 +410,7 @@ struct EnumDef : public Definition {
|
||||
|
||||
size_t size() const { return vals.vec.size(); }
|
||||
|
||||
const std::vector<EnumVal *> &Vals() const {
|
||||
return vals.vec;
|
||||
}
|
||||
const std::vector<EnumVal *> &Vals() const { return vals.vec; }
|
||||
|
||||
const EnumVal *Lookup(const std::string &enum_name) const {
|
||||
return vals.Lookup(enum_name);
|
||||
|
||||
@@ -469,8 +469,7 @@ Offset<const Table *> CopyTable(FlatBufferBuilder &fbb,
|
||||
// buf should point to the start of flatbuffer data.
|
||||
// length specifies the size of the flatbuffer data.
|
||||
bool Verify(const reflection::Schema &schema, const reflection::Object &root,
|
||||
const uint8_t *buf, size_t length,
|
||||
uoffset_t max_depth = 64,
|
||||
const uint8_t *buf, size_t length, uoffset_t max_depth = 64,
|
||||
uoffset_t max_tables = 1000000);
|
||||
|
||||
} // namespace flatbuffers
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
|
||||
// independent from idl_parser, since this code is not needed for most clients
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <algorithm>
|
||||
|
||||
#include "flatbuffers/code_generators.h"
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
@@ -1224,9 +1224,10 @@ class JsTsGenerator : public BaseGenerator {
|
||||
}
|
||||
|
||||
bool CanCreateFactoryMethod(const StructDef &struct_def) {
|
||||
// to preserve backwards compatibility, we allow the first field to be a struct
|
||||
return struct_def.fields.vec.size() < 2 || std::all_of(
|
||||
std::begin(struct_def.fields.vec) + 1,
|
||||
// to preserve backwards compatibility, we allow the first field to be a
|
||||
// struct
|
||||
return struct_def.fields.vec.size() < 2 ||
|
||||
std::all_of(std::begin(struct_def.fields.vec) + 1,
|
||||
std::end(struct_def.fields.vec),
|
||||
[](const FieldDef *f) -> bool {
|
||||
FLATBUFFERS_ASSERT(f != nullptr);
|
||||
|
||||
@@ -1704,9 +1704,7 @@ CheckedError Parser::ParseSingleValue(const std::string *name, Value &e,
|
||||
const auto is_tok_string = (token_ == kTokenStringConstant);
|
||||
|
||||
// First see if this could be a conversion function:
|
||||
if (is_tok_ident && *cursor_ == '(') {
|
||||
return ParseFunction(name, e);
|
||||
}
|
||||
if (is_tok_ident && *cursor_ == '(') { return ParseFunction(name, e); }
|
||||
|
||||
// clang-format off
|
||||
auto match = false;
|
||||
@@ -1757,8 +1755,7 @@ CheckedError Parser::ParseSingleValue(const std::string *name, Value &e,
|
||||
if (!match && is_tok_string && IsScalar(in_type)) {
|
||||
// Strip trailing whitespaces from attribute_.
|
||||
auto last_non_ws = attribute_.find_last_not_of(' ');
|
||||
if (std::string::npos != last_non_ws)
|
||||
attribute_.resize(last_non_ws + 1);
|
||||
if (std::string::npos != last_non_ws) attribute_.resize(last_non_ws + 1);
|
||||
if (IsFloat(e.type.base_type)) {
|
||||
// The functions strtod() and strtof() accept both 'nan' and
|
||||
// 'nan(number)' literals. While 'nan(number)' is rejected by the parser
|
||||
|
||||
@@ -396,17 +396,17 @@ Offset<const Table *> CopyTable(FlatBufferBuilder &fbb,
|
||||
case reflection::Obj: {
|
||||
auto &subobjectdef = *schema.objects()->Get(fielddef.type()->index());
|
||||
if (!subobjectdef.is_struct()) {
|
||||
offset =
|
||||
CopyTable(fbb, schema, subobjectdef,
|
||||
*GetFieldT(table, fielddef), use_string_pooling).o;
|
||||
offset = CopyTable(fbb, schema, subobjectdef,
|
||||
*GetFieldT(table, fielddef), use_string_pooling)
|
||||
.o;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case reflection::Union: {
|
||||
auto &subobjectdef = GetUnionType(schema, objectdef, fielddef, table);
|
||||
offset =
|
||||
CopyTable(fbb, schema, subobjectdef, *GetFieldT(table, fielddef),
|
||||
use_string_pooling).o;
|
||||
offset = CopyTable(fbb, schema, subobjectdef,
|
||||
*GetFieldT(table, fielddef), use_string_pooling)
|
||||
.o;
|
||||
break;
|
||||
}
|
||||
case reflection::Vector: {
|
||||
@@ -433,9 +433,8 @@ Offset<const Table *> CopyTable(FlatBufferBuilder &fbb,
|
||||
if (!elemobjectdef->is_struct()) {
|
||||
std::vector<Offset<const Table *>> elements(vec->size());
|
||||
for (uoffset_t i = 0; i < vec->size(); i++) {
|
||||
elements[i] =
|
||||
CopyTable(fbb, schema, *elemobjectdef, *vec->Get(i),
|
||||
use_string_pooling);
|
||||
elements[i] = CopyTable(fbb, schema, *elemobjectdef,
|
||||
*vec->Get(i), use_string_pooling);
|
||||
}
|
||||
offset = fbb.CreateVector(elements).o;
|
||||
break;
|
||||
@@ -705,8 +704,7 @@ bool VerifyObject(flatbuffers::Verifier &v, const reflection::Schema &schema,
|
||||
}
|
||||
|
||||
bool Verify(const reflection::Schema &schema, const reflection::Object &root,
|
||||
const uint8_t *buf, size_t length,
|
||||
uoffset_t max_depth /*= 64*/,
|
||||
const uint8_t *buf, size_t length, uoffset_t max_depth /*= 64*/,
|
||||
uoffset_t max_tables /*= 1000000*/) {
|
||||
Verifier v(buf, length, max_depth, max_tables);
|
||||
return VerifyObject(v, schema, root, flatbuffers::GetAnyRoot(buf), true);
|
||||
|
||||
Reference in New Issue
Block a user