| 3480 | } |
| 3481 | |
| 3482 | void Parser::Serialize() { |
| 3483 | builder_.Clear(); |
| 3484 | AssignIndices(structs_.vec); |
| 3485 | AssignIndices(enums_.vec); |
| 3486 | std::vector<Offset<reflection::Object>> object_offsets; |
| 3487 | for (auto it = structs_.vec.begin(); it != structs_.vec.end(); ++it) { |
| 3488 | auto offset = (*it)->Serialize(&builder_, *this); |
| 3489 | object_offsets.push_back(offset); |
| 3490 | (*it)->serialized_location = offset.o; |
| 3491 | } |
| 3492 | std::vector<Offset<reflection::Enum>> enum_offsets; |
| 3493 | for (auto it = enums_.vec.begin(); it != enums_.vec.end(); ++it) { |
| 3494 | auto offset = (*it)->Serialize(&builder_, *this); |
| 3495 | enum_offsets.push_back(offset); |
| 3496 | (*it)->serialized_location = offset.o; |
| 3497 | } |
| 3498 | std::vector<Offset<reflection::Service>> service_offsets; |
| 3499 | for (auto it = services_.vec.begin(); it != services_.vec.end(); ++it) { |
| 3500 | auto offset = (*it)->Serialize(&builder_, *this); |
| 3501 | service_offsets.push_back(offset); |
| 3502 | (*it)->serialized_location = offset.o; |
| 3503 | } |
| 3504 | auto objs__ = builder_.CreateVectorOfSortedTables(&object_offsets); |
| 3505 | auto enum__ = builder_.CreateVectorOfSortedTables(&enum_offsets); |
| 3506 | auto fiid__ = builder_.CreateString(file_identifier_); |
| 3507 | auto fext__ = builder_.CreateString(file_extension_); |
| 3508 | auto serv__ = builder_.CreateVectorOfSortedTables(&service_offsets); |
| 3509 | auto schema_offset = reflection::CreateSchema( |
| 3510 | builder_, objs__, enum__, fiid__, fext__, |
| 3511 | (root_struct_def_ ? root_struct_def_->serialized_location : 0), serv__, |
| 3512 | static_cast<reflection::AdvancedFeatures>(advanced_features_)); |
| 3513 | if (opts.size_prefixed) { |
| 3514 | builder_.FinishSizePrefixed(schema_offset, reflection::SchemaIdentifier()); |
| 3515 | } else { |
| 3516 | builder_.Finish(schema_offset, reflection::SchemaIdentifier()); |
| 3517 | } |
| 3518 | } |
| 3519 | |
| 3520 | static Namespace *GetNamespace( |
| 3521 | const std::string &qualified_name, std::vector<Namespace *> &namespaces, |
no test coverage detected