Allow derived structs to override base fields with subtypes#681
Allow derived structs to override base fields with subtypes#681AdamGlustein wants to merge 1 commit intomainfrom
Conversation
Signed-off-by: Adam Glustein <adam.glustein@point72.com>
9d51c23 to
f718205
Compare
| //Setup masking bits for our fields | ||
| //NOTE we can be more efficient by sticking masks into any potential alignment gaps, dont want to spend time on it | ||
| //at this point | ||
| if( m_base ) |
There was a problem hiding this comment.
this diff is hard to read. I think it was moved around to account for duplicate field names being allowed now, but can you explain what the actual diff was in this re-org
There was a problem hiding this comment.
Before, we would create the derived struct field masks for this level of struct before we process the base class fields
Now, since we may need to substitute a derived struct field into a base class field slot, we create the masks after
In the first section (adding in base fields), nothing changed until the loop on line 121 where before we would throw on a name collision, and now we check to see if its a valid override.
In the second (creating the masks), nothing changed except an index shift as we are iterating on the derived fields at the end of m_fields now, not the beginning
Closes #517 , allows for derived struct types to specialize fields iff those fields are Python objects or csp.Structs.
For example,
is allowed, but
or
are not. Note that a lot of the changes in
Struct.cppis just a reordering of when we create the set/none masks; before we did this before adding base class fields, now we do it after.