-
Notifications
You must be signed in to change notification settings - Fork 602
Document things from EXTERN.h/INTERN.h #23742
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9ba9690
autodoc: Need space separator in warning message
khwilliamson b37698b
autodoc: Preprocessor symbol has no arguments
khwilliamson 68d75bb
perlintern: Include section headings for non-empties
khwilliamson 9d2a16b
autodoc: Allow specifying a section may be empty
khwilliamson 7dede11
Document things in EXTERN.h, INTERN.h
khwilliamson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,11 +9,37 @@ | |
| */ | ||
|
|
||
| /* | ||
| * EXT designates a global var which is defined in perl.h | ||
| * dEXT designates a global var which is defined in another | ||
| * file, so we can't count on finding it in perl.h | ||
| * (this practice should be avoided). | ||
|
|
||
| =for apidoc CmU||EXT | ||
| =for apidoc_item EXTCONST | ||
| =for apidoc_item dEXT | ||
| =for apidoc_item dEXTCONST | ||
|
|
||
| These each designate a global variable. The C<CONST> forms indicate that it is | ||
| constant. | ||
|
|
||
| Use them like this: | ||
|
|
||
| Include either EXTERN.h or INTERN.h, but not both | ||
| ... | ||
| #include "perl.h" | ||
| ... | ||
| EXT char PL_WARN_ALL INIT(0); | ||
| EXTCONST U8 PL_revision INIT(PERL_REVISION); | ||
|
|
||
| This will handle everything for you regarding whether they are to actually be | ||
| defined and initialized or just declared C<extern>. | ||
|
|
||
| If the initialization is complex, you may have to use C<L</DOINIT>>. | ||
|
|
||
| If some constants you wish to reference will not become defined by #including | ||
| F<perl.h>, instead use C<dEXT> and C<dEXTCONST> for them and include whatever | ||
| files you need to to get them. This is currently very rare, and should be | ||
| avoided. | ||
|
|
||
| =cut | ||
| */ | ||
|
|
||
| #undef EXT | ||
| #undef dEXT | ||
| #undef EXTCONST | ||
|
|
@@ -45,7 +71,38 @@ | |
| # endif | ||
| # endif | ||
|
|
||
| /* | ||
| =for apidoc Cm||INIT|const_expr | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commit Document things in EXTERN.h, INTERN.h Wondering if this can/should contain an explanation of when one should use this. |
||
|
|
||
| Macro to initialize something, used like so: | ||
|
|
||
| EXTCONST char PL_memory_wrap[] INIT("panic: memory wrap"); | ||
|
|
||
| It expands to nothing in F<EXTERN.h>. | ||
|
|
||
| =cut | ||
| */ | ||
| #undef INIT | ||
| #define INIT(...) = __VA_ARGS__ | ||
|
|
||
| /* | ||
| =for apidoc C#||DOINIT | ||
|
|
||
| This is defined in F<INTERN.h>, undefined in F<EXTERN.h> | ||
|
|
||
| Most of the time you can use C<L</INIT>> to initialize your data structures. | ||
| But not always. In such cases, you can do the following: | ||
|
|
||
| #ifdef DOINIT | ||
| ... do the declaration and definition ... | ||
| #else | ||
| declaration only | ||
| #endif | ||
|
|
||
| A typical reason for needing this is when the definition includes #ifdef's. | ||
| You can't put that portably in a call to C<INIT>, as a macro generally can't | ||
| itself contain preprocessor directives. | ||
|
|
||
| =cut | ||
| */ | ||
| #define DOINIT | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Can you double check this is correct?
Just looking around I can't immediately see how including perl.h would cause INTERN.h/EXTERN.h to be included..
And looking at some files, av.c for example contains:
So it's loading both EXTERN.h and perl.h but if that is the "right" way to do it then I don't see how including onliny perl.h in the example works?
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.
how about now?