MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / AddField

Method AddField

native/thirdpart/flatbuffers/idl_parser.cpp:715–737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

713}
714
715CheckedError Parser::AddField(StructDef &struct_def, const std::string &name,
716 const Type &type, FieldDef **dest) {
717 auto &field = *new FieldDef();
718 field.value.offset =
719 FieldIndexToOffset(static_cast<voffset_t>(struct_def.fields.vec.size()));
720 field.name = name;
721 field.file = struct_def.file;
722 field.value.type = type;
723 if (struct_def.fixed) { // statically compute the field offset
724 auto size = InlineSize(type);
725 auto alignment = InlineAlignment(type);
726 // structs_ need to have a predictable format, so we need to align to
727 // the largest scalar
728 struct_def.minalign = std::max(struct_def.minalign, alignment);
729 struct_def.PadLastField(alignment);
730 field.value.offset = static_cast<voffset_t>(struct_def.bytesize);
731 struct_def.bytesize += size;
732 }
733 if (struct_def.fields.Add(name, &field))
734 return Error("field already exists: " + name);
735 *dest = &field;
736 return NoError();
737}
738
739CheckedError Parser::ParseField(StructDef &struct_def) {
740 std::string name = attribute_;

Callers

nothing calls this directly

Calls 8

FieldIndexToOffsetFunction · 0.85
InlineAlignmentFunction · 0.85
ErrorFunction · 0.85
NoErrorFunction · 0.85
PadLastFieldMethod · 0.80
AddMethod · 0.80
InlineSizeFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected