FromReflect Ergonomics#59
Conversation
PROMETHIA-27
left a comment
There was a problem hiding this comment.
Love this! I am fully behind and have wanted every feature here for a while.
|
|
||
| ## Unresolved questions | ||
|
|
||
| - Should `ReflectFromReflect` be replaced by a method on `TypeRegistration`, such as `TypeRegistration::construct`? |
There was a problem hiding this comment.
I don't think so, but I wouldn't be opposed to adding construct() as a helper function which wraps over ReflectFromReflect.
There was a problem hiding this comment.
Yeah I agree that we should keep RFR. I decided to leave out the Future Possibilities section, but in it I originally described adding a ReflectFromWorldReflect type data to support a proposed FromWorldReflect trait. And my thought was that this would pair nicely with RFR without needing to create another method on TypeRegistration. (Left out that section because it seemed a bit off-topic, though, haha.)
And also, by keeping RFR we keep open the possibility of cloning and storing the type data outside the registry if needed.
alice-i-cecile
left a comment
There was a problem hiding this comment.
Please try to split your lines at the sentence / clause level; it makes reviewing and suggestions much more pleasant :)
Nilirad
left a comment
There was a problem hiding this comment.
Have you considered using the “static type” instead of “real type”? It seems to be a direct translation from dynamic vs static typing.
I did, but chose not to use it. My reasoning was that "static" feels like we should know the exact type at compile time. However, a |
Okay I split bascially every sentence across multiple lines (where I could). Typora hates me now lol, but hopefully that's more readable/reviewable 🙂 |
|
Any update on this? I am trying to deserialize some bevy basic types (eg Transform) but can't rewire the type from DynamicStruct, because it doesn't have ReflectFromReflect. |
Unfortunately, there hasn't been much progress. While One reason I haven't updated it is because after coding the initial implementation in bevyengine/bevy#6056, I just found the RFC to be overkill. The actual changes are only a few hundred lines and most of it is cleanup. On top of that, So I could update this, but I may just close it out in favor of just using bevyengine/bevy#6056 to respond to any feedback. I'll probably rebase and update that PR relatively soon. Thoughts?
If you want to make a PR adding in a In the meantime, however, you can just manually register it for all your known types: app.register_type_data::<Transform, ReflectFromReflect>(); |
|
Didn't know there was a workaround, that's actually great, thanks. |
|
Closing this out. See bevyengine/bevy#6056 (comment) for details. |
RENDERED
Derive
FromReflectby default when derivingReflect, addReflectFromReflecttype data, and makeReflectDeserializereasier to use.