Skip to content

Commit 2fb024a

Browse files
committed
wikiheaders: Defines directly following a non-struct typedef are documented.
The idea is that if you have a `typedef Uint32 MyFlags` that has a bunch of defines that are meant to be bitflags, you can pack them into the same wiki page automatically. This only works with `typedef`s that are _not_ struct/union/enums, and it only pulls in `#define` lines that immediately follow the typedef line. Even a blank line or a comment will signal to stop including lines for this page!
1 parent 47ff4ad commit 2fb024a

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

build-scripts/wikiheaders.pl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,21 @@ sub print_undocumented_section {
858858
}
859859
next;
860860
}
861+
862+
# We assume any `#define`s directly after the typedef are related to it: probably bitflags for an integer typedef. Even a blank line will signify an end!
863+
my $lastpos = tell(FH);
864+
my $additional_decl = '';
865+
while (<FH>) {
866+
chomp;
867+
if (not /\A\s*\#define\s+/) {
868+
seek(FH, $lastpos, 0); # re-read this line again next time.
869+
last;
870+
}
871+
$additional_decl .= "$_\n";
872+
push @decllines, $_;
873+
$lastpos = tell(FH);
874+
}
875+
$decl .= "\n$additional_decl" if ($additional_decl ne '');
861876
} else {
862877
die("Unexpected symtype $symtype");
863878
}

include/SDL3/SDL_keycode.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,8 @@
4747
* \sa SDL_KeyCode
4848
*/
4949
typedef Sint32 SDL_Keycode;
50-
5150
#define SDLK_SCANCODE_MASK (1<<30)
5251
#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK)
53-
54-
/**
55-
* A subset of possible virtual key values.
56-
*/
5752
#define SDLK_UNKNOWN 0
5853
#define SDLK_RETURN '\r'
5954
#define SDLK_ESCAPE '\x1B'

include/SDL3/SDL_video.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ typedef struct SDL_Window SDL_Window;
131131
* \sa SDL_GetWindowFlags
132132
*/
133133
typedef Uint32 SDL_WindowFlags;
134-
135134
#define SDL_WINDOW_FULLSCREEN 0x00000001U /**< window is in fullscreen mode */
136135
#define SDL_WINDOW_OPENGL 0x00000002U /**< window usable with OpenGL context */
137136
#define SDL_WINDOW_OCCLUDED 0x00000004U /**< window is occluded */

0 commit comments

Comments
 (0)