insert a new second rule for tagged union discovery

1. if the field name ends in "data" and there is a field with the same
   prefix ending in "type", the field ending in "type" is the tag.
2. if the field name ends in "_target" and the previous field has the
   same prefix and no suffix, the previous field is the tag.
3. if the field is not the last field in the structure, the next field
   is the tag.
develop
Ben Lubar 2020-02-29 18:46:34 -06:00
parent b0699a1b5e
commit cc2c732dd5
No known key found for this signature in database
GPG Key ID: 92939677AB59EDA4
1 changed files with 8 additions and 0 deletions

@ -110,6 +110,10 @@ static const struct_field_info *find_union_tag(const struct_field_info *fields,
} }
} }
} }
else if (name.length() > 7 && name.substr(name.length() - 7) == "_target" && fields != union_field && (union_field - 1)->name == name.substr(0, name.length() - 7))
{
tag_field = union_field - 1;
}
if (tag_field->mode != struct_field_info::PRIMITIVE || if (tag_field->mode != struct_field_info::PRIMITIVE ||
!tag_field->type || !tag_field->type ||
@ -165,6 +169,10 @@ static const struct_field_info *find_union_vector_tag_vector(const struct_field_
} }
} }
} }
else if (name.length() > 7 && name.substr(name.length() - 7) == "_target" && fields != union_field && (union_field - 1)->name == name.substr(0, name.length() - 7))
{
tag_field = union_field - 1;
}
if (tag_field->mode != struct_field_info::CONTAINER || if (tag_field->mode != struct_field_info::CONTAINER ||
!tag_field->type || !tag_field->type ||