* 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.
void DecrementIdentLevel() {
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_;
static inline flatbuffers::string_view GetStringView(const String *str) {
return str ? str->string_view() : flatbuffers::string_view();
}
-#endif // FLATBUFFERS_HAS_STRING_VIEW
+#endif // FLATBUFFERS_HAS_STRING_VIEW
// Allocator interface. This is flatbuffers-specific and meant only for
// `vector_downward` usage.
return a.KeyCompareLessThan(&b);
}
- FLATBUFFERS_DELETE_FUNC(StructKeyComparator &operator=(const StructKeyComparator &))
+ FLATBUFFERS_DELETE_FUNC(
+ StructKeyComparator &operator=(const StructKeyComparator &))
};
/// @endcond
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);
// 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
*/
// 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"
}
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,
- std::end(struct_def.fields.vec),
- [](const FieldDef *f) -> bool {
- FLATBUFFERS_ASSERT(f != nullptr);
- return f->value.type.base_type != BASE_TYPE_STRUCT;
- });
+ // 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);
+ return f->value.type.base_type != BASE_TYPE_STRUCT;
+ });
}
// Generate an accessor struct with constructor for a flatbuffers struct.
std::string paramDoc =
GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder");
for (auto it = struct_def.fields.vec.begin();
- it != struct_def.fields.vec.end(); ++it) {
+ it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (field.deprecated) continue;
paramDoc +=
code += " = function(builder";
}
for (auto it = struct_def.fields.vec.begin();
- it != struct_def.fields.vec.end(); ++it) {
+ it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (field.deprecated) continue;
std::string methodPrefix =
lang_.language == IDLOptions::kTs ? struct_def.name : object_name;
for (auto it = struct_def.fields.vec.begin();
- it != struct_def.fields.vec.end(); ++it) {
+ it != struct_def.fields.vec.end(); ++it) {
const auto &field = **it;
if (field.deprecated) continue;
code_ += " Some({{U_ELEMENT_TABLE_TYPE}}::init_from_table(u))";
} else {
code_ +=
- " self.{{FIELD_NAME}}().map(|u| "
- "{{U_ELEMENT_TABLE_TYPE}}::init_from_table(u))";
+ " self.{{FIELD_NAME}}().map(|u| "
+ "{{U_ELEMENT_TABLE_TYPE}}::init_from_table(u))";
}
code_ += " } else {";
code_ += " None";
code_ += "";
if (!parser_.opts.generate_all) {
for (auto it = parser_.included_files_.begin();
- it != parser_.included_files_.end(); ++it) {
+ it != parser_.included_files_.end(); ++it) {
if (it->second.empty()) continue;
auto noext = flatbuffers::StripExtension(it->second);
auto basename = flatbuffers::StripPath(noext);
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;
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
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: {
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;
}
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);