Codegen implementation of SizeBytes for everything#4758
Conversation
Size changes
|
e6c3f75 to
74864ae
Compare
| // TODO(cmc): Implementing SizeBytes for this type would require a lot of effort, | ||
| // which would be wasted since this is supposed to go away very soon. | ||
| #[allow(clippy::manual_assert)] // readability | ||
| if cfg!(debug_assertions) { | ||
| panic!("EntityPropertiesComponent does not report its size properly"); | ||
| } |
There was a problem hiding this comment.
I'm not Jeremy, but confirmed nonetheless :)
| // TODO(cmc): Implementing SizeBytes for this type would require a lot of effort, | ||
| // which would be wasted since this is supposed to go away very soon. | ||
| #[allow(clippy::manual_assert)] // readability | ||
| if cfg!(debug_assertions) { | ||
| panic!("ViewportLayout does not report its size properly"); | ||
| } |
Wumpf
left a comment
There was a problem hiding this comment.
Looking great!
What I didn't understand is how the generated code knows when it has to yield to a manual implementation. E.g. ViewportLayout has no generated SizeBytes but only a manually implemented one in _ext - what magic removes the generated version?
For a while I considered asking heap_size_bytes to default zero because that's common in manual implementations. But I figure the explicitness is better as is
| quote!(self.0.heap_size_bytes()) | ||
| } else { | ||
| let quoted_heap_size_bytes = obj.fields.iter().map(|obj_field| { | ||
| let field_name = format_ident!("{}", obj_field.name); |
There was a problem hiding this comment.
the later incarnation did crate::to_pascal_case(. This probably should as well
There was a problem hiding this comment.
The other does that because it's enumerating enum variants! This one is generating struct field names, so not pascal case.
|
- `Loggable: SizeBytes` - Generate `SizeBytes` implementation for absolutely everything - Improved blanket `SizeBytes` implementations
Loggable: SizeBytesSizeBytesimplementation for absolutely everythingSizeBytesimplementationsSizeBytesimplementation for all components and datatypes #4690Checklist
mainbuild: app.rerun.ionightlybuild: app.rerun.io