-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Argument Clinic: multiple macro definition #67688
Comments
Argument Clinic generates multiple definitions in non-block mode for functions with alternating signature. See example file. If FOO is not defines, SPAM_METHODDEF is defined twice. First time in: #ifndef SPAM_METHODDEF
#define SPAM_METHODDEF
#endif /* !defined(SPAM_METHODDEF) */ Second time in: #if !defined(FOO)
...
#define SPAM_METHODDEF \
|
Can you give me a test case? |
Oh, sorry. Here is a sample. Other sample see in bpo-23501. |
Here is a patch which moves all methoddef_ifndef to the end of the buffer or file, so they are not conflicts with other definitions. |
Here is a sample file generated by fixed clinic.py. |
In your sample output we still get two #ifndef SPAM_METHODDEF stanzas. Wouldn't it be better to only have one? Maybe Clinic needs to be smarter about generating those anyway. Let me think about it. |
Actually in this sample output no one #ifndef SPAM_METHODDEF stanza is needed, because SPAM_METHODDEF is defined in any case. |
How about this approach? Only ever emit the #ifndef stanza once per symbol. |
(see larry.ac_multiple_macro_definitions.diff.1.txt posted above) |
Oops, I should have run "make clinic", so you could see all the changes that result from this patch. |
It doesn't fix the issue, because the #ifndef stanza is emitted before second definition. Try to run clinic.py with your patch on sample.c. But may be this idea can be used with my patch. |
Yes, this works. Here is combined patch and proceeded sample file. |
What do you think of this approach? Now a "Destination" object behaves like an array of text accumulators. If you ask for one that doesn't exist it's created for you. When the Destination is dumped, the output from each accumulator is joined together, like buffer[0] + buffer[1] + buffer[2]. (You can even specify negative indices, if you want text that goes *before* the default text accumulator.) With this approach, all the #ifndef stanzas are at the end of the emitted text. |
This looks as generalization of my patch. It produces the same output. I left comments on Rietveld, but in any case the patch LGTM. |
Could you please commit your patch (may be with changes) Larry? |
I want to redo it--it's smelly. I hope to get it done this week. |
As promised, here's a cleaned-up version of the patch. The taxonomy of objects now makes sense: a Destination contains a BufferSeries object, rather than Destinations weirdly supporting __getitem__ to reference different objects. I tripped over myself a little with the "two-pass" destination / preset. It was an experiment long ago but nobody's using it. So rather than fix it I just turned it off. |
Looks as you didn't notice my comments on Rietveld. |
I did, I just didn't respond. I'll do that now. |
Updated patch, removed all references to two-pass. Also realized I needed to make the default behavior for methoddef_ifndef go to the end. And, finally, I forgot to merge the "only print each #ifndef block once" code I wrote before when I redid the patch, so that's in now. |
larry.ac_multiple_macro_definitions.diff.5.txt LGTM. |
New changeset 25eef0ecb9c1 by Larry Hastings in branch 'default': |
Does this really need a backport to 3.4? |
I think this is not needed. |
Thank you Larry. |
Removing 3.4 from the version list as I close the bug, then. If we decide we need it backported please reopen (or create a new bug, either is fine). |
The code that manipulated 'second_pass_replacements' was removed in 2015 with commit 0759f84 (pythongh-67688, bpo-23500).
The code that manipulated 'second_pass_replacements' was removed in 2015 with commit 0759f84 (pythongh-67688, bpo-23500).
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: