Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-112205: Support @getter annotation from AC#112396
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
corona10 commented Nov 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@AlexWaygood@erlend-aasland@colesbury This is the first draft version of getter annotation for AC. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
corona10 commented Nov 25, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Now logic for clinic.py become straightforward. PTAL :) |
corona10 commented Nov 25, 2023
And I am going to implementer |
Uh oh!
There was an error while loading. Please reload this page.
Tools/clinic/clinic.py Outdated
| """) | ||
| GETTERDEF_PROTOTYPE_DEFINE: Final[str] =normalize_snippet(r""" | ||
| #define{methoddef_name} \ | ||
| {{"{name}",{methoddef_cast}{c_basename}{methoddef_cast_end}, NULL, NULL}}, |
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.
We may need to reform the template for the setter case too. But not sure we should handle this at this PR :)
erlend-aasland commented Nov 27, 2023
Thanks, Donghee! Can you also create a docs PR for the devguide? |
corona10 commented Nov 27, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Sure, Do you have any recommended section for this? |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
corona10 commented Nov 27, 2023
@erlend-aasland@AlexWaygood |
Uh oh!
There was an error while loading. Please reload this page.
colesbury left a comment
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 looks great. I don't have any comments on top of what Erlend and Alex wrote.
AlexWaygood left a comment
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.
The Python code LGTM, thanks! As always, I'll leave review of the generated C code to the other two :)
corona10 commented Nov 28, 2023
I will wait @erlend-aasland 1-2days :) |
Tools/clinic/clinic.py Outdated
| parser_code: list[str] |None | ||
| ifnotrequires_defining_class: | ||
| iff.kindisGETTER: | ||
| flags="NULL" |
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 looks strange to me; AFAICS, we don't use flags for getters (methoddef_flags is not included in the template). And if we were to supply a zero default for flags, it would have to be an int literal (0, not NULL).
Ideally we should not have to specify flags here, but a lot of the following code expect it to be defined. I suggest we either set it to the empty string or the zero int literal.
| flags="NULL" | |
| flags="0" |
| flags="NULL" | |
| flags=""# This should end up unused |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Ah please ignore my previous comment, now I understood what you want to say :)
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.
You may already know: the reason I don't use methodef_flags to the template is due to the structure of getset.
Lines 11 to 17 in a194938
| structPyGetSetDef{ | |
| constchar*name; | |
| getterget; | |
| setterset; | |
| constchar*doc; | |
| void*closure; | |
| }; |
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.
We're not creating a PyMethodDef struct here, so the template field naming is now confusing. For example, the methoddef_name and methoddef_cast names are just confusing when we're generating a PyGetSetDef struct. I think we should fix the naming sooner than later.
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.
We're not creating a PyMethodDef struct here, so the template field naming is now confusing. For example, the methoddef_name and methoddef_cast names are just confusing when we're generating a PyGetSetDef struct. I think we should fix the naming sooner than later.
We need to refactor some of the code while implementing @setter, Can we handle this issue on the @setter PR? or Do you want to handle it as this PR?
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.
dde933e
Remove unnecessary template :)
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'm not sure my suggested comment is good enough :) Wording it more explicit might be better (cc. @AlexWaygood).
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 think this is fine... or, at least, I can't think of anything better :)
Looking at this function gives me a headache; this change doesn't really make my head hurt significantly more tbh :)
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.
Yes, the urge to refactor is growing. I suggest we take a stab at it pretty soon, Alex :)
Uh oh!
There was an error while loading. Please reload this page.
corona10 commented Nov 29, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@erlend-aasland If the current status is enough to be merged, I will merge this PR at this weekend :) |
Uh oh!
There was an error while loading. Please reload this page.