-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Make class.slots completely immutable #2163
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
Conversation
|
Ooh, better idea: make |
|
oh, that sounds great |
356d500 to
d0573a6
Compare
943db39 to
d7bdaf1
Compare
d7bdaf1 to
43b7a7b
Compare
|
@youknowone can you review? |
|
I will do it soon. I had a few busy days 😵 |
|
No problem, take your time :) |
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.
Everything is pyclass, good!
derive/src/pyclass.rs
Outdated
| } | ||
| iter_chain![ | ||
| parse_quote! { | ||
| fn __extend_py_class( |
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.
can this also become #[extend_class]?
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.
extend_class works by just calling the #[extend_class]-marked method in the generated extend_class method; for a PyClassImpl that's the impl_extend_class method and for a trait/interface that's this "magic" method; extend_class can't substitute for the actual generated method.
| (@extract_slots($ctx:expr, $slots:expr, (slot $slot_name:ident), $value:expr)) => { | ||
| $slots.$slot_name = Some( | ||
| $crate::function::IntoPyNativeFunc::into_func($value) | ||
| ); | ||
| }; | ||
| (@extract_slots($ctx:expr, $class:expr, $name:expr, $value:expr)) => {}; | ||
| (@extract_attrs($ctx:expr, $slots:expr, (slot $slot_name:ident), $value:expr)) => {}; | ||
| (@extract_attrs($ctx:expr, $class:expr, $name:expr, $value:expr)) => { | ||
| $class.set_str_attr($name, $value); | ||
| }; |
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.
is there benefits to keep these parts in the same macro? i am curious if this is a sort of recommended convention or not.
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.
Sort of; I know that tokio does that with their macros; I think it keeps the logic encapsulated so that when there's a @extract_slots inside you know that it's in the same macro definition.


No description provided.