mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 20:31:23 +00:00
Add pointer reference to sibling union field on FieldDef (#7755)
To make it simple to map between a union field and its union type field we are adding a pointer to FieldDef to point to each other. For all other types the pointer will be nullptr. Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
@@ -970,6 +970,14 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
|
||||
FieldDef *field;
|
||||
ECHECK(AddField(struct_def, name, type, &field));
|
||||
|
||||
if (typefield) {
|
||||
// We preserve the relation between the typefield
|
||||
// and field, so we can easily map it in the code
|
||||
// generators.
|
||||
typefield->sibling_union_field = field;
|
||||
field->sibling_union_field = typefield;
|
||||
}
|
||||
|
||||
if (token_ == '=') {
|
||||
NEXT();
|
||||
ECHECK(ParseSingleValue(&field->name, field->value, true));
|
||||
|
||||
Reference in New Issue
Block a user