wikiheaders: Allow blank lines in post-typedef #define blocks.

Reference Issue #9557.
This commit is contained in:
Ryan C. Gordon 2024-04-25 14:26:49 -04:00
parent ac5a61cd60
commit d29b861a76
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
4 changed files with 28 additions and 7 deletions

View File

@ -859,20 +859,33 @@ while (my $d = readdir(DH)) {
next;
}
# 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!
# We assume any `#define`s directly after the typedef are related to it: probably bitflags for an integer typedef.
# Blank lines are allowed, anything else, even comments, are not.
my $blank_lines = 0;
my $lastpos = tell(FH);
my $additional_decl = '';
while (<FH>) {
chomp;
if (not /\A\s*\#define\s+/) {
seek(FH, $lastpos, 0); # re-read this line again next time.
if (/\A\s*\Z/) {
$blank_lines++;
} elsif (/\A\s*\#define\s+/) {
if ($blank_lines > 0) {
while ($blank_lines > 0) {
$additional_decl .= "\n";
push @decllines, '';
$blank_lines--;
}
}
$additional_decl .= "\n$_";
push @decllines, $_;
$lastpos = tell(FH);
} else {
seek(FH, $lastpos, 0); # re-read eaten lines again next time.
last;
}
$additional_decl .= "$_\n";
push @decllines, $_;
$lastpos = tell(FH);
}
$decl .= "\n$additional_decl" if ($additional_decl ne '');
$decl .= $additional_decl;
} else {
die("Unexpected symtype $symtype");
}

View File

@ -85,16 +85,21 @@ extern "C" {
* \sa SDL_AUDIO_ISUNSIGNED
*/
typedef Uint16 SDL_AudioFormat;
#define SDL_AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */
#define SDL_AUDIO_S8 0x8008 /**< Signed 8-bit samples */
#define SDL_AUDIO_S16LE 0x8010 /**< Signed 16-bit samples */
#define SDL_AUDIO_S16BE 0x9010 /**< As above, but big-endian byte order */
#define SDL_AUDIO_S32LE 0x8020 /**< 32-bit integer samples */
#define SDL_AUDIO_S32BE 0x9020 /**< As above, but big-endian byte order */
#define SDL_AUDIO_F32LE 0x8120 /**< 32-bit floating point samples */
#define SDL_AUDIO_F32BE 0x9120 /**< As above, but big-endian byte order */
/* masks for different parts of SDL_AudioFormat. */
#define SDL_AUDIO_MASK_BITSIZE (0xFF)
#define SDL_AUDIO_MASK_FLOAT (1<<8)
#define SDL_AUDIO_MASK_BIG_ENDIAN (1<<12)

View File

@ -47,6 +47,7 @@
* \sa SDL_KeyCode
*/
typedef Sint32 SDL_Keycode;
#define SDLK_SCANCODE_MASK (1<<30)
#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK)
#define SDLK_UNKNOWN 0

View File

@ -131,6 +131,7 @@ typedef struct SDL_Window SDL_Window;
* \sa SDL_GetWindowFlags
*/
typedef Uint32 SDL_WindowFlags;
#define SDL_WINDOW_FULLSCREEN 0x00000001U /**< window is in fullscreen mode */
#define SDL_WINDOW_OPENGL 0x00000002U /**< window usable with OpenGL context */
#define SDL_WINDOW_OCCLUDED 0x00000004U /**< window is occluded */
@ -155,6 +156,7 @@ typedef Uint32 SDL_WindowFlags;
#define SDL_WINDOW_TRANSPARENT 0x40000000U /**< window with transparent buffer */
#define SDL_WINDOW_NOT_FOCUSABLE 0x80000000U /**< window should not be focusable */
/**
* Used to indicate that you don't care what the window position is.
*