-
Notifications
You must be signed in to change notification settings - Fork 300
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
Override set_
method with #[frb(opaque)]
struct
#2079
Comments
Hmm.... maybe this suggestion is still imperfect. Because if FRB not generate the corresponding get/set reflection code, then user can't get/set the field directly in Dart. |
What about this: Currently, Line 31 in 954c966
set_thefieldname as dummy name. However, maybe we can change that single line to something like:
let rust_method_name = format!("auto_accessor_{}_{}", accessor_mode.verb_str(), field.name.rust_style()); Then there will be no conflict. |
Yes, I like this prefix solution. Actually, I just come up a similar way with suffix like Anyway, as long as the default reflection signature name has little chance to conflict with manual fn signature, then it is ok. |
Feel free to PR for this! Alternatively I will work on it in the next batch. |
@dbsxdbsx Do you want to PR for this? If not, I will work on it (since quite trivial). |
Yes, I want to give it a shot. |
Take your time and looking forward to it! |
By the way, I wonder what is the basic routine before pr. I've referred guidance here, but still unclear. For example, after modifying code in
Is it the correct output before pr? |
For your scenario, try
which runs codegen on all projects. Alternatively, suppose you are in |
After running |
It should not have that... Maybe paste the logs, is there any errors? |
By the way, I've eliminated the
@fzyzcjy, for local log, I only found one under
|
That's weird, which looks like Dart formatter is never executed... What if
|
for
And for the err of |
Hmm, then maybe execute the equivalent of
Manually? |
I've also tried to make a Maybe I should wait until there is refined version for windows developer. |
That's weird. The "run dart formatter" section is already there. Most importantly, CI does check windows codegen and it works well, and nobody using frb did say on windows the formatter is not run... For that formatter problem, maybe run |
Those are not formatted at all IIRC, so just leave them untouched (unformatted) and it will not have diff.
Looking forward to it! |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue. |
Env
Win10, FRB V2 DEV 39, Flutter 3.22.2, Rust 1.79
Issue
For a Rust struct with pub field named
a
along with#[frb(opaque)]
, if there is a method calledpub fn set_a(&mut self ....)
, then the generated filefrb_generated.rs
(along with correspondingly dart file) would be panic because of duplicated implementation.example screenshot for field
content
:WorkAround
Currently, if the field and the method is made to be exposed to Dart, a workaround is rename the
set_a
to another name.Suggestion
It seems to be related to the auto generated get/set reflection methods for each pub field of a
#[frb(opaque)]
Rust type. Hopefully, this could be refined by NOT generating corresponding get or set reflection methods correspondingly once FRB detects there is already a manual method in formpub fn set_<field_name>(&mut self,....)
orpub fn <field_name>(&self,....)->&a
.I am not sure what I said above is the correct way to refine it. Just intuitionally, it seems that it is related to the reflection field methods.
The text was updated successfully, but these errors were encountered: