-
-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Var
use GodotConvert::Via
to align it with ToGodot
and FromGodot
#595
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-595 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Nice to see that some parts get even simpler 🙂
godot-macros/src/util/mod.rs
Outdated
// `repr` is always going to look like `#[repr()]` | ||
unreachable!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is unreachable -- a user could still specify #[repr = u32]
or something 🤔
So might be better to bail here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any form of #[repr]
that doesn't look like #[repr()]
will give a rust compile time error:
#[repr = i64] // attribute value must be a literal
#[repr = "i64"] // malformed `repr` attribute input
#[repr] // malformed `repr` attribute input
#[repr(i64, i32)] // conflicting representation hints, this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
however #[repr()]
is just a warning apparently:
#[repr()] // unused attribute, attribute `repr` with an empty list has no effect
which surprised me a bit tbh, i'll fix that then ig,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only thing left, otherwise I think it's ready 🙂
godot-macros/src/util/mod.rs
Outdated
let TokenTree::Ident(repr_type) = &repr_value[0] else { | ||
unreachable!() | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, what if the user specifies #[repr()]
or #[repr(+)]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[repr(+)] // expected unsuffixed literal or identifier, found `+`
80011ed
to
71f55d3
Compare
71f55d3
to
79df2b4
Compare
Thank you! |
Var
now depends onGodotConvert
and usesGodotConvert::Via
instead of its own intermediate typeVar
does not depend onToGodot
orFromGodot
to make it possible to have properties that cannot be used as function arguments/return types. This is currently the case forOnReady<T>
. The current implementations do however useToGodot
andFromGodot
to perform the conversions.This also required some changes in the
GodotConvert
andVar
macros to make sure they agree on theVia
type to use for structs/enums.I didn't change the derive macros much beyond making them compatible with each other, as i think they could do with a bigger rewrite later, see for instance #452.
closes #453