• Home
  • Raw
  • Download

Lines Matching +full:- +full:hashfile

8  *     http://www.apache.org/licenses/LICENSE-2.0
31 // clang-format off in FLATBUFFERS_VERSION()
36 // clang-format on in FLATBUFFERS_VERSION()
84 for (uoffset_t index = 0; index < documentation->size(); index++) in DeserializeDoc()
85 doc.push_back(documentation->Get(index)->str()); in DeserializeDoc()
135 const auto N = components.size() - skip_top; in LookupTableByName()
141 for (size_t i = N; i > 0; i--) { in LookupTableByName()
145 auto len = full_name.size() - components[i - 1].size() - 1 - name.size(); in LookupTableByName()
154 // clang-format off
162 __extension__ // Stop GCC complaining about trailing comma with -Wpendantic.
185 return tokens[t - 256]; in TokenToString()
188 // clang-format on
222 a = reinterpret_cast<const Table *>(a)->GetAddressOf(offset); in CompareTablesByScalarKey()
223 b = reinterpret_cast<const Table *>(b)->GetAddressOf(offset); in CompareTablesByScalarKey()
235 a = reinterpret_cast<const Table *>(a)->GetAddressOf(offset); in CompareTablesByStringKey()
236 b = reinterpret_cast<const Table *>(b)->GetAddressOf(offset); in CompareTablesByStringKey()
251 ptrdiff_t diff = (b - a) * sizeof(Offset<Table>); in SwapSerializedTables()
254 a->o = EndianScalar(ReadScalar<uoffset_t>(a) - udiff); in SwapSerializedTables()
255 b->o = EndianScalar(ReadScalar<uoffset_t>(b) + udiff); in SwapSerializedTables()
262 if (end - begin <= static_cast<ptrdiff_t>(width)) return; in SimpleQsort()
267 r -= width; in SimpleQsort()
273 l -= width; in SimpleQsort()
287 // Normalize defaults NaN to unsigned quiet-NaN(0) if value was parsed from
288 // hex-float literal.
301 // The unsigned overflow is well-defined by C++ standard (modulo 2^n). in EnumDistanceImpl()
302 return static_cast<uint64_t>(e1) - static_cast<uint64_t>(e2); in EnumDistanceImpl()
306 auto a_id = atoi(a->attributes.Lookup("id")->constant.c_str()); in compareFieldDefs()
307 auto b_id = atoi(b->attributes.Lookup("id")->constant.c_str()); in compareFieldDefs()
329 ns->components.push_back(qualified_name.substr(pos, dot - pos)); in GetNamespace()
338 static uint64_t HashFile(const char *source_filename, const char *source) { in HashFile() function
351 return a->defined_namespace->GetFullyQualifiedName(a->name) < in compareName()
352 b->defined_namespace->GetFullyQualifiedName(b->name); in compareName()
357 // Pre-sort these vectors, such that we can set the correct indices for them. in AssignIndices()
360 for (int i = 0; i < static_cast<int>(vec.size()); i++) vec[i]->index = i; in AssignIndices()
370 // clang-format off
385 // clang-format on
391 // clang-format off in Message()
400 // clang-format on in Message()
434 ~ParseDepthGuard() { parser_.parse_depth_counter_ -= 1; } in ~ParseDepthGuard()
490 return Error("invalid utf-8 byte order mark"); in SkipByteOrderMark()
493 return Error("invalid utf-8 byte order mark"); in SkipByteOrderMark()
508 cursor_--; in Next()
530 int unicode_high_surrogate = -1; in Next()
538 if (unicode_high_surrogate != -1 && *cursor_ != 'u') { in Next()
591 if (unicode_high_surrogate != -1) { in Next()
598 if (unicode_high_surrogate == -1) { in Next()
606 unicode_high_surrogate = -1; in Next()
609 if (unicode_high_surrogate != -1) { in Next()
619 } else { // printable chars + UTF-8 bytes in Next()
620 if (unicode_high_surrogate != -1) { in Next()
624 // reset if non-printable in Next()
631 if (unicode_high_surrogate != -1) { in Next()
637 return Error("illegal UTF-8 sequence"); in Next()
668 const char *start = cursor_ - 1; in Next()
675 const auto has_sign = (c == '+') || (c == '-'); in Next()
677 // Check for +/-inf which is considered a float constant. in Next()
680 attribute_.assign(cursor_ - 1, cursor_ + 3); in Next()
687 // '-'/'+' and following identifier - it could be a predefined in Next()
696 // Parser accepts hexadecimal-floating-literal (see C++ 5.13.4). in Next()
698 const auto start = cursor_ - 1; in Next()
699 auto start_digits = !is_digit(c) ? cursor_ : cursor_ - 1; in Next()
704 // hex-float can't begind with '.' in Next()
707 // Read an integer number or mantisa of float-point number. in Next()
714 } while ((*cursor_ == '.') && (++cursor_) && (--dot_lvl >= 0)); in Next()
715 // Exponent of float-point number. in Next()
721 dot_lvl = 0; // Emulate dot to signal about float-point number. in Next()
723 if (*cursor_ == '+' || *cursor_ == '-') cursor_++; in Next()
724 start_digits = cursor_; // the exponent-part has to have digits in Next()
729 dot_lvl = -1; // Fall thru to Error(). in Next()
786 if (sd) sd->refcount++; in LookupStruct()
793 if (sd) sd->refcount++; in LookupStructThruParentNamespaces()
803 type = enum_def->underlying_type; in ParseTypeIdent()
804 if (enum_def->is_union) type.base_type = BASE_TYPE_UNION; in ParseTypeIdent()
868 return Error("length of fixed-length array must be an integer value"); in ParseType()
874 "length of fixed-length array must be positive and fit to " in ParseType()
942 return Error("fixed-length array in table must be wrapped in struct"); in ParseField()
955 // For union fields, add a second auto-generated field to hold the type, in ParseField()
958 type.enum_def->underlying_type, &typefield)); in ParseField()
967 // For vector of union fields, add a second auto-generated vector field to in ParseField()
980 ECHECK(ParseSingleValue(&field->name, field->value, true)); in ParseField()
981 if (IsStruct(type) || (struct_def.fixed && field->value.constant != "0")) in ParseField()
987 if (field->value.constant != "0" && !SupportsDefaultVectorsAndStrings()) { in ParseField()
994 if (IsVector(type) && field->value.constant != "0" && in ParseField()
995 field->value.constant != "[]") { in ParseField()
1003 auto &text = field->value.constant; in ParseField()
1007 if (*s == '-' || *s == '+') s++; in ParseField()
1011 (std::string::npos == field->value.constant.find_first_of(".eEpP"))) { in ParseField()
1012 field->value.constant += ".0"; in ParseField()
1016 field->doc_comment = dc; in ParseField()
1017 ECHECK(ParseMetaData(&field->attributes)); in ParseField()
1018 field->deprecated = field->attributes.Lookup("deprecated") != nullptr; in ParseField()
1019 auto hash_name = field->attributes.Lookup("hash"); in ParseField()
1024 if (FindHashFunction16(hash_name->constant.c_str()) == nullptr) in ParseField()
1026 hash_name->constant); in ParseField()
1031 if (FindHashFunction32(hash_name->constant.c_str()) == nullptr) in ParseField()
1033 hash_name->constant); in ParseField()
1038 if (FindHashFunction64(hash_name->constant.c_str()) == nullptr) in ParseField()
1040 hash_name->constant); in ParseField()
1053 field->key = field->attributes.Lookup("key") != nullptr; in ParseField()
1054 const bool required = field->attributes.Lookup("required") != nullptr || in ParseField()
1055 (IsString(type) && field->key); in ParseField()
1057 ((IsString(type) || IsVector(type)) && field->value.constant != "0"); in ParseField()
1059 ? (field->value.constant == "null") in ParseField()
1064 field->presence = FieldDef::MakeFieldPresence(optional, required); in ParseField()
1067 return Error("only non-scalar fields in tables may be 'required'"); in ParseField()
1069 if (field->key) { in ParseField()
1077 if (field->IsScalarOptional()) { in ParseField()
1079 if (type.enum_def && type.enum_def->Lookup("null")) { in ParseField()
1084 type.enum_def->name + "'."); in ParseField()
1086 if (field->attributes.Lookup("key")) { in ParseField()
1088 "only a non-optional scalar field can be used as a 'key' field"); in ParseField()
1099 const std::string &constant = field->value.constant; in ParseField()
1116 if (!field->IsOptional() && in ParseField()
1117 type.enum_def->attributes.Lookup("bit_flags") == nullptr) { in ParseField()
1118 if (type.enum_def->FindByValue(constant) == nullptr) { in ParseField()
1120 name + "` is not part of enum `" + type.enum_def->name + in ParseField()
1127 if (field->deprecated && struct_def.fixed) in ParseField()
1130 auto cpp_type = field->attributes.Lookup("cpp_type"); in ParseField()
1135 auto cpp_ptr_type = field->attributes.Lookup("cpp_ptr_type"); in ParseField()
1138 val->type = cpp_type->type; in ParseField()
1139 val->constant = "naked"; in ParseField()
1140 field->attributes.Add("cpp_ptr_type", val); in ParseField()
1144 field->shared = field->attributes.Lookup("shared") != nullptr; in ParseField()
1145 if (field->shared && field->value.type.base_type != BASE_TYPE_STRING) in ParseField()
1149 field->attributes.Lookup("native_custom_alloc"); in ParseField()
1155 field->native_inline = field->attributes.Lookup("native_inline") != nullptr; in ParseField()
1156 if (field->native_inline && !IsStruct(field->value.type)) in ParseField()
1159 auto nested = field->attributes.Lookup("nested_flatbuffer"); in ParseField()
1161 if (nested->type.base_type != BASE_TYPE_STRING) in ParseField()
1169 field->nested_flatbuffer = LookupCreateStruct(nested->constant); in ParseField()
1172 if (field->attributes.Lookup("flexbuffer")) { in ParseField()
1173 field->flexbuffer = true; in ParseField()
1180 if (!IsScalar(typefield->value.type.base_type)) { in ParseField()
1182 typefield->presence = field->presence; in ParseField()
1185 // the automatically added type field should have an id as well (of N - 1). in ParseField()
1186 auto attr = field->attributes.Lookup("id"); in ParseField()
1188 const auto &id_str = attr->constant; in ParseField()
1193 val->type = attr->type; in ParseField()
1194 val->constant = NumToString(id - 1); in ParseField()
1195 typefield->attributes.Add("id", val); in ParseField()
1198 "a union type effectively adds two fields with non-negative ids, " in ParseField()
1202 field->name + ", id: " + id_str); in ParseField()
1207 if (field->deprecated) { typefield->deprecated = true; } in ParseField()
1242 auto &type = elem->second->value.type; in ParseAnyValue()
1248 ECHECK(atot(elem->first.constant.c_str(), *this, &offset)); in ParseAnyValue()
1250 builder_.GetCurrentBufferPointer() + builder_.GetSize() - in ParseAnyValue()
1257 constant = elem->first.constant; in ParseAnyValue()
1269 auto type_name = field->name + UnionTypeFieldSuffix(); in ParseAnyValue()
1271 auto type_field = parent_struct_def->fields.Lookup(type_name); in ParseAnyValue()
1287 Value type_val = type_field->value; in ParseAnyValue()
1295 return Error("missing type field for this union value: " + field->name); in ParseAnyValue()
1299 if (vector_of_union_types->size() <= count) in ParseAnyValue()
1302 field->name); in ParseAnyValue()
1303 enum_idx = vector_of_union_types->Get(count); in ParseAnyValue()
1307 auto enum_val = val.type.enum_def->ReverseLookup(enum_idx, true); in ParseAnyValue()
1308 if (!enum_val) return Error("illegal type id for: " + field->name); in ParseAnyValue()
1309 if (enum_val->union_type.base_type == BASE_TYPE_STRUCT) { in ParseAnyValue()
1310 ECHECK(ParseTable(*enum_val->union_type.struct_def, &val.constant, in ParseAnyValue()
1312 if (enum_val->union_type.struct_def->fixed) { in ParseAnyValue()
1314 SerializeStruct(*enum_val->union_type.struct_def, val); in ParseAnyValue()
1318 } else if (IsString(enum_val->union_type)) { in ParseAnyValue()
1319 ECHECK(ParseString(val, field->shared)); in ParseAnyValue()
1329 ECHECK(ParseString(val, field->shared)); in ParseAnyValue()
1346 if (field && field->attributes.Lookup("hash") && in ParseAnyValue()
1350 ECHECK(ParseSingleValue(field ? &field->name : nullptr, val, false)); in ParseAnyValue()
1355 ECHECK(ParseSingleValue(field ? &field->name : nullptr, val, false)); in ParseAnyValue()
1391 if (fieldn >= struct_def->fields.vec.size()) { in ParseTableDelimiters()
1394 name = struct_def->fields.vec[fieldn]->name; in ParseTableDelimiters()
1409 if (is_nested_vector && fieldn != struct_def->fields.vec.size()) { in ParseTableDelimiters()
1424 const StructDef *struct_def_inner) -> CheckedError { in ParseTable()
1429 auto field = struct_def_inner->fields.Lookup(name); in ParseTable()
1437 if (IsIdent("null") && !IsScalar(field->value.type.base_type)) { in ParseTable()
1440 Value val = field->value; in ParseTable()
1441 if (field->flexbuffer) { in ParseTable()
1451 } else if (field->nested_flatbuffer) { in ParseTable()
1457 // Hardcoded insertion-sort with error-check. in ParseTable()
1462 auto existing_field = elem->second; in ParseTable()
1464 return Error("field set more than once: " + field->name); in ParseTable()
1465 if (existing_field->value.offset < field->value.offset) break; in ParseTable()
1481 if (!required_field->IsRequired()) { continue; } in ParseTable()
1483 for (auto pf_it = field_stack_.end() - fieldn_outer; in ParseTable()
1485 auto parsed_field = pf_it->second; in ParseTable()
1492 return Error("required field is missing: " + required_field->name + in ParseTable()
1508 auto &field_value = it->first; in ParseTable()
1509 auto field = it->second; in ParseTable()
1513 // clang-format off in ParseTable()
1516 builder_.Pad(field->padding); \ in ParseTable()
1522 if (field->IsScalarOptional()) { \ in ParseTable()
1531 ECHECK(atot(field->value.constant.c_str(), *this, &valdef)); \ in ParseTable()
1540 builder_.Pad(field->padding); \ in ParseTable()
1541 if (IsStruct(field->value.type)) { \ in ParseTable()
1542 SerializeStruct(*field->value.type.struct_def, field_value); \ in ParseTable()
1552 builder_.Pad(field->padding); in ParseTable()
1557 // clang-format on in ParseTable()
1569 // be serialized in-place elsewhere. in ParseTable()
1570 value->assign( in ParseTable()
1618 auto err = ParseVectorDelimiters(count, [&](uoffset_t &) -> CheckedError { in ParseVector()
1629 const auto force_align = field->attributes.Lookup("force_align"); in ParseVector()
1632 ECHECK(ParseAlignAttribute(force_align->constant, 1, &align)); in ParseVector()
1641 // clang-format off in ParseVector()
1653 // clang-format on in ParseVector()
1661 if (type.base_type == BASE_TYPE_STRUCT && type.struct_def->has_key) { in ParseVector()
1664 for (auto it = type.struct_def->fields.vec.begin(); in ParseVector()
1665 it != type.struct_def->fields.vec.end(); ++it) { in ParseVector()
1666 if ((*it)->key) { in ParseVector()
1677 // globals, making parsing thread-unsafe. in ParseVector()
1681 if (type.struct_def->fixed) { in ParseVector()
1682 const voffset_t offset = key->value.offset; in ParseVector()
1683 const size_t struct_size = type.struct_def->bytesize; in ParseVector()
1687 v->Data(), v->Data() + v->size() * type.struct_def->bytesize, in ParseVector()
1688 type.struct_def->bytesize, in ParseVector()
1689 [offset, key](const uint8_t *a, const uint8_t *b) -> bool { in ParseVector()
1700 // but it is non-standard as it will dereference the offsets, and thus in ParseVector()
1702 if (key->value.type.base_type == BASE_TYPE_STRING) { in ParseVector()
1704 v->data(), v->data() + v->size(), 1, in ParseVector()
1705 [key](const Offset<Table> *_a, const Offset<Table> *_b) -> bool { in ParseVector()
1711 v->data(), v->data() + v->size(), 1, in ParseVector()
1712 [key](const Offset<Table> *_a, const Offset<Table> *_b) -> bool { in ParseVector()
1728 auto err = ParseVectorDelimiters(count, [&](uoffset_t &) -> CheckedError { in ParseArray()
1740 if (length != count) return Error("Fixed-length array size is incorrect."); in ParseArray()
1744 // clang-format off in ParseArray()
1760 // clang-format on in ParseArray()
1778 " --json-nested-bytes is set"); in ParseNestedFlatbuffer()
1783 std::string substring(cursor_at_value_begin - 1, cursor_ - 1); in ParseNestedFlatbuffer()
1787 FLATBUFFERS_ASSERT(field->nested_flatbuffer); in ParseNestedFlatbuffer()
1788 nested_parser.root_struct_def_ = field->nested_flatbuffer; in ParseNestedFlatbuffer()
1827 if (attributes->Add(name, e)) Warning("attribute already found: " + name); in ParseMetaData()
1845 type.enum_def ? type.enum_def->underlying_type.base_type : type.base_type; in ParseEnumFromString()
1851 auto word = attribute_.substr(pos, !last ? delim - pos : std::string::npos); in ParseEnumFromString()
1855 ev = type.enum_def->Lookup(word); in ParseEnumFromString()
1864 ev = enum_def->Lookup(enum_val_str); in ParseEnumFromString()
1867 u64 |= ev->GetAsUInt64(); in ParseEnumFromString()
1876 Value *hash_name = field->attributes.Lookup("hash"); in ParseHash()
1879 auto hash = FindHashFunction16(hash_name->constant.c_str()); in ParseHash()
1885 auto hash = FindHashFunction16(hash_name->constant.c_str()); in ParseHash()
1891 auto hash = FindHashFunction32(hash_name->constant.c_str()); in ParseHash()
1897 auto hash = FindHashFunction32(hash_name->constant.c_str()); in ParseHash()
1903 auto hash = FindHashFunction64(hash_name->constant.c_str()); in ParseHash()
1909 auto hash = FindHashFunction64(hash_name->constant.c_str()); in ParseHash()
1943 // clang-format off in ParseFunction()
1957 // clang-format on in ParseFunction()
1984 // The exponent suffix of hexadecimal float-point number is mandatory. in TryTypedValue()
1985 // A hex-integer constant is forbidden as an initializer of float number. in TryTypedValue()
1994 "floating-point literals is mandatory: \"" + in TryTypedValue()
2004 if (token_ == '+' || token_ == '-') { in ParseSingleValue()
2019 // clang-format off in ParseSingleValue()
2027 // clang-format on in ParseSingleValue()
2035 // avoid escaped and non-ascii in the string in ParseSingleValue()
2040 "non-string field must be trivial ASCII string: type: ") + in ParseSingleValue()
2069 // A "scalar-in-string" value needs extra checks. in ParseSingleValue()
2097 // Match empty vectors for default-empty-vectors. in ParseSingleValue()
2117 // The check_now flag must be true when parse a fbs-schema. in ParseSingleValue()
2123 // clang-format off in ParseSingleValue()
2135 // clang-format on in ParseSingleValue()
2142 std::string qualified_name = current_namespace_->GetFullyQualifiedName(name); in LookupCreateStruct()
2143 // See if it exists pre-declared by an unqualified use. in LookupCreateStruct()
2145 if (struct_def && struct_def->predecl) { in LookupCreateStruct()
2149 struct_def->defined_namespace = current_namespace_; in LookupCreateStruct()
2154 // See if it exists pre-declared by an qualified use. in LookupCreateStruct()
2156 if (struct_def && struct_def->predecl) { in LookupCreateStruct()
2159 struct_def->defined_namespace = current_namespace_; in LookupCreateStruct()
2170 struct_def->name = name; in LookupCreateStruct()
2171 struct_def->defined_namespace = current_namespace_; in LookupCreateStruct()
2179 struct_def->name = name; in LookupCreateStruct()
2180 struct_def->defined_namespace = current_namespace_; in LookupCreateStruct()
2181 struct_def->original_location.reset( in LookupCreateStruct()
2196 return IsUInt64() ? EnumDistanceImpl(v1->GetAsUInt64(), v2->GetAsUInt64()) in Distance()
2197 : EnumDistanceImpl(v1->GetAsInt64(), v2->GetAsInt64()); in Distance()
2204 u64 |= (*it)->GetAsUInt64(); in AllFlags()
2213 if ((*it)->GetAsInt64() == enum_idx) { return *it; } in ReverseLookup()
2237 if (e1->GetAsUInt64() == e2->GetAsUInt64()) { in SortByValue()
2238 return e1->name < e2->name; in SortByValue()
2240 return e1->GetAsUInt64() < e2->GetAsUInt64(); in SortByValue()
2244 if (e1->GetAsInt64() == e2->GetAsInt64()) { return e1->name < e2->name; } in SortByValue()
2245 return e1->GetAsInt64() < e2->GetAsInt64(); in SortByValue()
2251 // 1) vals.vec - owner (raw pointer) in RemoveDuplicates()
2252 // 2) vals.dict - access map in RemoveDuplicates()
2258 if ((*result)->value != (*first)->value) { in RemoveDuplicates()
2263 if (it->second == ev) it->second = *result; // reassign in RemoveDuplicates()
2273 ev->value = static_cast<int64_t>(new_value); in ChangeEnumValue()
2286 temp = new EnumVal(ev_name, first ? 0 : enum_def.vals.vec.back()->value); in CreateEnumerator()
2299 ECHECK(ValidateValue(&temp->value, false == user_value)); in AcceptEnumerator()
2300 FLATBUFFERS_ASSERT((temp->union_type.enum_def == nullptr) || in AcceptEnumerator()
2301 (temp->union_type.enum_def == &enum_def)); in AcceptEnumerator()
2309 return AcceptEnumerator(temp->name); in AcceptEnumerator()
2318 temp->value = static_cast<int64_t>(u64); // well-defined since C++20. in AssignEnumeratorValue()
2322 temp->value = i64; in AssignEnumeratorValue()
2335 if (v < dn || v > (up - m)) { in ValidateImpl()
2340 *ev = static_cast<int64_t>(v + m); // well-defined since C++20. in ValidateImpl()
2345 // clang-format off in ValidateValue()
2356 // clang-format on in ValidateValue()
2383 enum_def->declaration_file = in ParseEnum()
2386 enum_def->doc_comment = enum_comment; in ParseEnum()
2398 ECHECK(ParseType(enum_def->underlying_type)); in ParseEnum()
2399 if (!IsInteger(enum_def->underlying_type.base_type) || in ParseEnum()
2400 IsBool(enum_def->underlying_type.base_type)) in ParseEnum()
2403 enum_def->underlying_type.enum_def = enum_def; in ParseEnum()
2405 ECHECK(ParseMetaData(&enum_def->attributes)); in ParseEnum()
2406 const auto underlying_type = enum_def->underlying_type.base_type; in ParseEnum()
2407 if (enum_def->attributes.Lookup("bit_flags") && in ParseEnum()
2414 // A lot of code generatos expect that an enum is not-empty. in ParseEnum()
2445 if (!enum_def->uses_multiple_type_instances) { in ParseEnum()
2448 enum_def->uses_multiple_type_instances = (false == ins.second); in ParseEnum()
2472 // At this point, the enum can be empty if input is invalid proto-file. in ParseEnum()
2473 if (!enum_def->size()) in ParseEnum()
2476 if (enum_def->attributes.Lookup("bit_flags")) { in ParseEnum()
2478 for (auto it = enum_def->Vals().begin(); it != enum_def->Vals().end(); in ParseEnum()
2481 const auto u = ev->GetAsUInt64(); in ParseEnum()
2483 if (!IsUnsigned(underlying_type) && u == (base_width - 1)) in ParseEnum()
2487 enum_def->ChangeEnumValue(ev, 1ULL << u); in ParseEnum()
2491 enum_def->SortByValue(); // Must be sorted to use MinValue/MaxValue. in ParseEnum()
2494 auto prev_it = enum_def->Vals().begin(); in ParseEnum()
2495 for (auto it = prev_it + 1; it != enum_def->Vals().end(); ++it) { in ParseEnum()
2498 if (prev_ev->GetAsUInt64() == ev->GetAsUInt64()) in ParseEnum()
2499 return Error("all enum values must be unique: " + prev_ev->name + in ParseEnum()
2500 " and " + ev->name + " are both " + in ParseEnum()
2501 NumToString(ev->GetAsInt64())); in ParseEnum()
2506 current_namespace_->GetFullyQualifiedName(enum_def->name); in ParseEnum()
2516 current_namespace_->GetFullyQualifiedName(name)); in StartStruct()
2533 auto &fname = (*it)->name; in CheckClash()
2535 fname.compare(fname.length() - len, len, suffix) == 0 && in CheckClash()
2536 (*it)->value.type.base_type != BASE_TYPE_UTYPE) { in CheckClash()
2538 struct_def->fields.Lookup(fname.substr(0, fname.length() - len)); in CheckClash()
2539 if (field && field->value.type.base_type == basetype) in CheckClash()
2542 field->name); in CheckClash()
2552 return { it->second.cbegin(), it->second.cend() }; in GetIncludedFiles()
2591 if (ns->components == (*it)->components) { in UniqueNamespace()
2606 ns->components.push_back( in UnqualifiedName()
2607 full_qualified_name.substr(previous, current - previous)); in UnqualifiedName()
2612 return full_qualified_name.substr(previous, current - previous); in UnqualifiedName()
2624 struct_def->doc_comment = dc; in ParseDecl()
2625 struct_def->fixed = fixed; in ParseDecl()
2627 struct_def->declaration_file = in ParseDecl()
2630 ECHECK(ParseMetaData(&struct_def->attributes)); in ParseDecl()
2631 struct_def->sortbysize = in ParseDecl()
2632 struct_def->attributes.Lookup("original_order") == nullptr && !fixed; in ParseDecl()
2636 const auto force_align = struct_def->attributes.Lookup("force_align"); in ParseDecl()
2639 ECHECK(ParseAlignAttribute(force_align->constant, struct_def->minalign, in ParseDecl()
2641 struct_def->minalign = align; in ParseDecl()
2643 if (!struct_def->bytesize) return Error("size 0 structs not allowed"); in ParseDecl()
2645 struct_def->PadLastField(struct_def->minalign); in ParseDecl()
2647 auto &fields = struct_def->fields.vec; in ParseDecl()
2651 if ((*it)->attributes.Lookup("id")) num_id_fields++; in ParseDecl()
2660 "--require-explicit-ids is used"); in ParseDecl()
2674 const auto &id_str = field.attributes.Lookup("id")->constant; in ParseDecl()
2682 return Error("field id\'s must be non-negative number, field: " + in ParseDecl()
2702 current_namespace_->GetFullyQualifiedName(struct_def->name); in ParseDecl()
2723 if (services_.Add(current_namespace_->GetFullyQualifiedName(service_name), in ParseService()
2738 if (reqtype.base_type != BASE_TYPE_STRUCT || reqtype.struct_def->fixed || in ParseService()
2739 resptype.base_type != BASE_TYPE_STRUCT || resptype.struct_def->fixed) in ParseService()
2759 LookupStruct(current_namespace_->GetFullyQualifiedName(name)); in SetRootType()
2768 (*it)->generated = true; in MarkGenerated()
2771 if (!(*it)->predecl) { (*it)->generated = true; } in MarkGenerated()
2774 (*it)->generated = true; in MarkGenerated()
2784 ns->components.push_back(attribute_); in ParseNamespace()
2826 ns->components.push_back(name); in ParseProtoDecl()
2827 ns->from_table++; in ParseProtoDecl()
2831 struct_def->doc_comment = struct_comment; in ParseProtoDecl()
2841 enum_def->RemoveDuplicates(); in ParseProtoDecl()
2869 const auto qualified_name = current_namespace_->GetFullyQualifiedName(name); in StartEnum()
2964 // We allow a field to be re-defined when extending. in ParseProtoFields()
2966 field = struct_def->fields.Lookup(name); in ParseProtoFields()
2969 field->doc_comment = field_comment; in ParseProtoFields()
2971 field->presence = FieldDef::kRequired; in ParseProtoFields()
2983 // Temp: skip non-numeric and non-boolean defaults (enums). in ParseProtoFields()
2984 auto numeric = strpbrk(val.c_str(), "0123456789-+."); in ParseProtoFields()
2986 (val == "inf" || val == "+inf" || val == "-inf")) { in ParseProtoFields()
2988 field->value.constant = val == "inf" ? "+inf" : val; in ParseProtoFields()
2990 field->value.constant = val; in ParseProtoFields()
2992 field->value.constant = val; in ParseProtoFields()
2995 field->deprecated = val == "true"; in ParseProtoFields()
3016 !oneof_type.struct_def || oneof_type.struct_def->fixed) in ParseProtoFields()
3021 auto ev = evb.CreateEnumerator(oneof_type.struct_def->name); in ParseProtoFields()
3022 ev->union_type = oneof_type; in ParseProtoFields()
3023 ev->doc_comment = oneof_field.doc_comment; in ParseProtoFields()
3058 nesting--; in ParseProtoCurliesOrIdent()
3099 for (auto tl = lookup; tl->proto_type; tl++) { in ParseTypeFromProtoType()
3100 if (attribute_ == tl->proto_type) { in ParseTypeFromProtoType()
3101 type->base_type = tl->fb_type; in ParseTypeFromProtoType()
3102 type->element = tl->element; in ParseTypeFromProtoType()
3121 const StructDef *) -> CheckedError { in SkipAnyJsonValue()
3129 return ParseVectorDelimiters(count, [&](uoffset_t &) -> CheckedError { in SkipAnyJsonValue()
3150 return Error("unexpected floating-point constant: " + attribute_); in ParseFlexBufferNumericConstant()
3151 builder->Double(d); in ParseFlexBufferNumericConstant()
3161 auto start = builder->StartMap(); in ParseFlexBufferValue()
3166 const StructDef *) -> CheckedError { in ParseFlexBufferValue()
3167 builder->Key(name); in ParseFlexBufferValue()
3173 builder->EndMap(start); in ParseFlexBufferValue()
3174 if (builder->HasDuplicateKeys()) in ParseFlexBufferValue()
3179 auto start = builder->StartVector(); in ParseFlexBufferValue()
3181 ECHECK(ParseVectorDelimiters(count, [&](uoffset_t &) -> CheckedError { in ParseFlexBufferValue()
3184 builder->EndVector(start, false, false); in ParseFlexBufferValue()
3188 builder->String(attribute_); in ParseFlexBufferValue()
3192 builder->Int(StringToInt(attribute_.c_str())); in ParseFlexBufferValue()
3198 builder->Double(d); in ParseFlexBufferValue()
3202 case '-': in ParseFlexBufferValue()
3204 // `[-+]?(nan|inf|infinity)`, see ParseSingleValue(). in ParseFlexBufferValue()
3208 return Error("floating-point constant expected"); in ParseFlexBufferValue()
3216 builder->Bool(true); in ParseFlexBufferValue()
3219 builder->Bool(false); in ParseFlexBufferValue()
3222 builder->Null(); in ParseFlexBufferValue()
3239 if (ok) builder->Finish(); in ParseFlexBuffer()
3294 struct_def.defined_namespace->components.size() + 1; in ParseRoot()
3295 components && !enum_def; components--) { in ParseRoot()
3297 struct_def.defined_namespace->GetFullyQualifiedName( in ParseRoot()
3298 struct_def.name, components - 1); in ParseRoot()
3317 bt = enum_def->underlying_type.base_type; in ParseRoot()
3318 struct_def.refcount--; in ParseRoot()
3319 enum_def->refcount++; in ParseRoot()
3326 " use(s) of pre-declaration enum not accounted for: " + in ParseRoot()
3327 enum_def->name); in ParseRoot()
3429 // If the file is in-memory, don't include its contents in the hash as we in DoParse()
3432 source_hash = HashFile(source_filename, source); in DoParse()
3434 source_hash = HashFile(source_filename, nullptr); in DoParse()
3456 // Parse pre-include proto statements if any: in DoParse()
3495 if (included_files_.find(HashFile(filepath.c_str(), contents.c_str())) == in DoParse()
3545 if (root_struct_def_->fixed) return Error("root type must be a table"); in DoParse()
3631 if (included_files.find(it->filename) == included_files.end()) in GetIncludedFilesRecursive()
3632 to_process.push_back(it->filename); in GetIncludedFilesRecursive()
3648 auto offset = (*it)->Serialize(&builder_, *this); in Serialize()
3650 (*it)->serialized_location = offset.o; in Serialize()
3651 const std::string *file = (*it)->declaration_file; in Serialize()
3656 auto offset = (*it)->Serialize(&builder_, *this); in Serialize()
3658 const std::string *file = (*it)->declaration_file; in Serialize()
3663 auto offset = (*it)->Serialize(&builder_, *this); in Serialize()
3665 const std::string *file = (*it)->declaration_file; in Serialize()
3679 RelativeToRootPath(opts.project_root, f->first)); in Serialize()
3680 for (auto i = f->second.begin(); i != f->second.end(); i++) { in Serialize()
3682 RelativeToRootPath(opts.project_root, i->filename))); in Serialize()
3700 (root_struct_def_ ? root_struct_def_->serialized_location : 0), serv__, in Serialize()
3714 field_offsets.push_back((*it)->Serialize( in Serialize()
3715 builder, static_cast<uint16_t>(it - fields.vec.begin()), parser)); in Serialize()
3717 const auto qualified_name = defined_namespace->GetFullyQualifiedName(name); in Serialize()
3718 const auto name__ = builder->CreateString(qualified_name); in Serialize()
3719 const auto flds__ = builder->CreateVectorOfSortedTables(&field_offsets); in Serialize()
3722 ? builder->CreateVectorOfStrings(doc_comment) in Serialize()
3725 const auto file__ = builder->CreateSharedString(decl_file_in_project); in Serialize()
3732 if (!DeserializeAttributes(parser, object->attributes())) return false; in Deserialize()
3733 DeserializeDoc(doc_comment, object->documentation()); in Deserialize()
3734 name = parser.UnqualifiedName(object->name()->str()); in Deserialize()
3737 const auto &of = *(object->fields()); in Deserialize()
3739 for (uoffset_t i = 0; i < of.size(); i++) indexes[of.Get(i)->id()] = i; in Deserialize()
3744 if (!field_def->Deserialize(parser, field) || in Deserialize()
3745 fields.Add(field_def->name, field_def)) { in Deserialize()
3749 if (field_def->key) { in Deserialize()
3759 auto size = InlineSize(field_def->value.type); in Deserialize()
3763 field_def->padding = in Deserialize()
3764 next_field ? (next_field->offset() - field_def->value.offset) - size in Deserialize()
3766 tmp_struct_size += field_def->padding; in Deserialize()
3769 FLATBUFFERS_ASSERT(static_cast<int>(tmp_struct_size) == object->bytesize()); in Deserialize()
3776 auto name__ = builder->CreateString(name); in Serialize()
3780 ? builder->CreateVectorOfStrings(doc_comment) in Serialize()
3788 // result may be platform-dependent if underlying is float (not double) in Serialize()
3796 name = field->name()->str(); in Deserialize()
3798 if (!value.type.Deserialize(parser, field->type())) return false; in Deserialize()
3799 value.offset = field->offset(); in Deserialize()
3801 value.constant = NumToString(field->default_integer()); in Deserialize()
3803 value.constant = FloatToString(field->default_real(), 16); in Deserialize()
3805 presence = FieldDef::MakeFieldPresence(field->optional(), field->required()); in Deserialize()
3806 padding = field->padding(); in Deserialize()
3807 key = field->key(); in Deserialize()
3808 if (!DeserializeAttributes(parser, field->attributes())) return false; in Deserialize()
3819 parser.current_namespace_->GetFullyQualifiedName(nested->constant); in Deserialize()
3824 DeserializeDoc(doc_comment, field->documentation()); in Deserialize()
3830 auto name__ = builder->CreateString(name); in Serialize()
3833 ? builder->CreateVectorOfStrings(doc_comment) in Serialize()
3836 *builder, name__, request->serialized_location, in Serialize()
3837 response->serialized_location, attr__, docs__); in Serialize()
3841 name = call->name()->str(); in Deserialize()
3842 if (!DeserializeAttributes(parser, call->attributes())) return false; in Deserialize()
3843 DeserializeDoc(doc_comment, call->documentation()); in Deserialize()
3844 request = parser.structs_.Lookup(call->request()->name()->str()); in Deserialize()
3845 response = parser.structs_.Lookup(call->response()->name()->str()); in Deserialize()
3854 servicecall_offsets.push_back((*it)->Serialize(builder, parser)); in Serialize()
3856 const auto qualified_name = defined_namespace->GetFullyQualifiedName(name); in Serialize()
3857 const auto name__ = builder->CreateString(qualified_name); in Serialize()
3858 const auto call__ = builder->CreateVector(servicecall_offsets); in Serialize()
3861 ? builder->CreateVectorOfStrings(doc_comment) in Serialize()
3864 const auto file__ = builder->CreateSharedString(decl_file_in_project); in Serialize()
3871 name = parser.UnqualifiedName(service->name()->str()); in Deserialize()
3872 if (service->calls()) { in Deserialize()
3873 for (uoffset_t i = 0; i < service->calls()->size(); ++i) { in Deserialize()
3875 if (!call->Deserialize(parser, service->calls()->Get(i)) || in Deserialize()
3876 calls.Add(call->name, call)) { in Deserialize()
3882 if (!DeserializeAttributes(parser, service->attributes())) return false; in Deserialize()
3883 DeserializeDoc(doc_comment, service->documentation()); in Deserialize()
3891 enumval_offsets.push_back((*it)->Serialize(builder, parser)); in Serialize()
3893 const auto qualified_name = defined_namespace->GetFullyQualifiedName(name); in Serialize()
3894 const auto name__ = builder->CreateString(qualified_name); in Serialize()
3895 const auto vals__ = builder->CreateVector(enumval_offsets); in Serialize()
3899 ? builder->CreateVectorOfStrings(doc_comment) in Serialize()
3902 const auto file__ = builder->CreateSharedString(decl_file_in_project); in Serialize()
3908 name = parser.UnqualifiedName(_enum->name()->str()); in Deserialize()
3909 for (uoffset_t i = 0; i < _enum->values()->size(); ++i) { in Deserialize()
3911 if (!val->Deserialize(parser, _enum->values()->Get(i)) || in Deserialize()
3912 vals.Add(val->name, val)) { in Deserialize()
3917 is_union = _enum->is_union(); in Deserialize()
3918 if (!underlying_type.Deserialize(parser, _enum->underlying_type())) { in Deserialize()
3921 if (!DeserializeAttributes(parser, _enum->attributes())) return false; in Deserialize()
3922 DeserializeDoc(doc_comment, _enum->documentation()); in Deserialize()
3928 auto name__ = builder->CreateString(name); in Serialize()
3931 ? builder->CreateVectorOfStrings(doc_comment) in Serialize()
3938 name = val->name()->str(); in Deserialize()
3939 value = val->value(); in Deserialize()
3940 if (!union_type.Deserialize(parser, val->union_type())) return false; in Deserialize()
3941 DeserializeDoc(doc_comment, val->documentation()); in Deserialize()
3949 struct_def ? struct_def->index : (enum_def ? enum_def->index : -1), in Serialize()
3956 base_type = static_cast<BaseType>(type->base_type()); in Deserialize()
3957 element = static_cast<BaseType>(type->element()); in Deserialize()
3958 fixed_length = type->fixed_length(); in Deserialize()
3959 if (type->index() >= 0) { in Deserialize()
3960 bool is_series = type->base_type() == reflection::Vector || in Deserialize()
3961 type->base_type() == reflection::Array; in Deserialize()
3962 if (type->base_type() == reflection::Obj || in Deserialize()
3963 (is_series && type->element() == reflection::Obj)) { in Deserialize()
3964 if (static_cast<size_t>(type->index()) < parser.structs_.vec.size()) { in Deserialize()
3965 struct_def = parser.structs_.vec[type->index()]; in Deserialize()
3966 struct_def->refcount++; in Deserialize()
3971 if (static_cast<size_t>(type->index()) < parser.enums_.vec.size()) { in Deserialize()
3972 enum_def = parser.enums_.vec[type->index()]; in Deserialize()
3987 auto it = parser.known_attributes_.find(kv->first); in SerializeAttributes()
3989 if (parser.opts.binary_schema_builtins || !it->second) { in SerializeAttributes()
3990 auto key = builder->CreateString(kv->first); in SerializeAttributes()
3991 auto val = builder->CreateString(kv->second->constant); in SerializeAttributes()
3996 return builder->CreateVectorOfSortedTables(&attrs); in SerializeAttributes()
4005 for (uoffset_t i = 0; i < attrs->size(); ++i) { in DeserializeAttributes()
4006 auto kv = attrs->Get(i); in DeserializeAttributes()
4008 if (kv->value()) { value->constant = kv->value()->str(); } in DeserializeAttributes()
4009 if (attributes.Add(kv->key()->str(), value)) { in DeserializeAttributes()
4013 parser.known_attributes_[kv->key()->str()]; in DeserializeAttributes()
4040 file_identifier_ = schema->file_ident() ? schema->file_ident()->str() : ""; in Deserialize()
4041 file_extension_ = schema->file_ext() ? schema->file_ext()->str() : ""; in Deserialize()
4046 for (auto it = schema->objects()->begin(); it != schema->objects()->end(); in Deserialize()
4049 struct_def->bytesize = it->bytesize(); in Deserialize()
4050 struct_def->fixed = it->is_struct(); in Deserialize()
4051 struct_def->minalign = it->minalign(); in Deserialize()
4052 if (structs_.Add(it->name()->str(), struct_def)) { in Deserialize()
4057 if (types_.Add(it->name()->str(), type)) { in Deserialize()
4062 for (auto it = schema->enums()->begin(); it != schema->enums()->end(); ++it) { in Deserialize()
4064 if (enums_.Add(it->name()->str(), enum_def)) { in Deserialize()
4069 if (types_.Add(it->name()->str(), type)) { in Deserialize()
4076 for (auto it = schema->objects()->begin(); it != schema->objects()->end(); in Deserialize()
4078 std::string qualified_name = it->name()->str(); in Deserialize()
4080 struct_def->defined_namespace = in Deserialize()
4082 if (!struct_def->Deserialize(*this, *it)) { return false; } in Deserialize()
4083 if (schema->root_table() == *it) { root_struct_def_ = struct_def; } in Deserialize()
4085 for (auto it = schema->enums()->begin(); it != schema->enums()->end(); ++it) { in Deserialize()
4086 std::string qualified_name = it->name()->str(); in Deserialize()
4088 enum_def->defined_namespace = in Deserialize()
4090 if (!enum_def->Deserialize(*this, *it)) { return false; } in Deserialize()
4093 if (schema->services()) { in Deserialize()
4094 for (auto it = schema->services()->begin(); it != schema->services()->end(); in Deserialize()
4096 std::string qualified_name = it->name()->str(); in Deserialize()
4098 service_def->defined_namespace = in Deserialize()
4100 if (!service_def->Deserialize(*this, *it) || in Deserialize()
4107 advanced_features_ = schema->advanced_features(); in Deserialize()
4109 if (schema->fbs_files()) in Deserialize()
4110 for (auto s = schema->fbs_files()->begin(); s != schema->fbs_files()->end(); in Deserialize()
4112 for (auto f = s->included_filenames()->begin(); in Deserialize()
4113 f != s->included_filenames()->end(); ++f) { in Deserialize()
4115 included_file.filename = f->str(); in Deserialize()
4116 files_included_per_file_[s->filename()->str()].insert(included_file); in Deserialize()
4127 struct_def.defined_namespace->GetFullyQualifiedName(struct_def.name); in ConformTo()
4133 auto field_base = struct_def_base->fields.Lookup(field.name); in ConformTo()
4135 if (field.value.offset != field_base->value.offset) in ConformTo()
4137 if (field.value.constant != field_base->value.constant) in ConformTo()
4139 if (!EqualByName(field.value.type, field_base->value.type)) in ConformTo()
4145 for (auto fbit = struct_def_base->fields.vec.begin(); in ConformTo()
4146 fbit != struct_def_base->fields.vec.end(); ++fbit) { in ConformTo()
4148 if (field.value.offset == field_base->value.offset) { in ConformTo()
4149 if (!EqualByName(field.value.type, field_base->value.type)) in ConformTo()
4160 enum_def.defined_namespace->GetFullyQualifiedName(enum_def.name); in ConformTo()
4166 auto enum_val_base = enum_def_base->Lookup(enum_val.name); in ConformTo()