-
Notifications
You must be signed in to change notification settings - Fork 76
Feat: create interface #411
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
0a0ec55
to
7e385b0
Compare
86190da
to
79e8a51
Compare
79e8a51
to
e38c821
Compare
@Xenira can i ask you for some advice, how did more better with interface registration? |
@Norbytus first of all, thank you for the contribution! I do not have the time to review it rn, but will try to get to this as soon as possible.
If you have specific questions I am always happy to help out. Not entirely sure what you mean with |
First problem it a interface registration proc_macros for methods. /// It could be a regular php interface, but like in C with need dummy class for ZendEntry
trait SimpleInterface {
pub fn test(&self);
}
/// But this trait could not be php interface it's a abstract class
trait SimpleInterface {
pub fn test(&self) {
/// Some default bhv
}
}
struct Test;
/// Cannot be abstract or interface, only regular class
impl Test {/* Methods */ } Another problem, its registration interface in module. If we wanna make beauty and cool like
In proc_macro we should generate a dummy struct like
|
I would like to do this in two steps. In a first step we should only allow traits without default implementations.
While that would be the nicer version I would go with the same approach as functions and constants. Those have a That way we do not rely on 'magic' renaming / creating of structs. |
59c2cc1
to
9eaf73b
Compare
|
||
#[derive(Debug, Copy, Clone, FromMeta, Default)] | ||
pub enum RenameRule { | ||
/// Methods won't be renamed. | ||
#[darling(rename = "none")] | ||
None, | ||
/// Methods will be converted to camelCase. | ||
#[darling(rename = "camelCase")] | ||
#[default] | ||
Camel, | ||
/// Methods will be converted to snake_case. | ||
#[darling(rename = "snake_case")] | ||
Snake, | ||
} | ||
|
||
pub trait Rename { | ||
fn renmae(self, rule: &RenameRule) -> Self; | ||
} | ||
|
||
impl Rename for String { | ||
fn renmae(self, rule: &RenameRule) -> Self { | ||
match *rule { | ||
RenameRule::None => self, | ||
RenameRule::Camel => ident_case::RenameRule::CamelCase.apply_to_field(self), | ||
RenameRule::Snake => ident_case::RenameRule::SnakeCase.apply_to_field(self), | ||
} | ||
} | ||
} |
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.
Just want to let you know that this was just changed in #413. You might wanna rebase onto master
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 see. I think do separate PR
@Xenira What do we need to make this happen? |
@kakserpom will make this happen. Just need the time... Doing my best to get stuff done, got work and personal life though. Did a lot in recent weeks so will prob need to cut back a little. |
I try too, and will be a new pr |
@Norbytus thank you! Thought this was abandoned, nice to hear you are still working on it ❤️ |
No, but I think i back, with some thoughts about interfaces |
@Norbytus Nice, mind sharing them in an issue? That way we can discuss them beforehand. As interfaces would be a big feature it would be nice to have a well thought through implementation. |
Close this PR, open new one |
Impl interface registration.
I start impl interface registration, for now i just take ClassBuilder and use it in InterfaceBuilder to hide method to add property and extend other classes.
And i have question how we can make better this separation in rust form, or we can just use ClassBuilder every where, and if some one use ClassBuilder with ClassFlagInterface, and add property, extends. Its they problem)