Skip to content

Commit

Permalink
Updated for SDL3 version changes
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed May 15, 2024
1 parent 7cae5ed commit e4559c9
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .wikiheaders-options
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mainincludefname = SDL3_net/SDL_net.h
versionfname = include/SDL3_net/SDL_net.h
versionmajorregex = \A\#define\s+SDL_NET_MAJOR_VERSION\s+(\d+)\Z
versionminorregex = \A\#define\s+SDL_NET_MINOR_VERSION\s+(\d+)\Z
versionpatchregex = \A\#define\s+SDL_NET_PATCHLEVEL\s+(\d+)\Z
versionmicroregex = \A\#define\s+SDL_NET_MICRO_VERSION\s+(\d+)\Z
selectheaderregex = \ASDL_net\.h\Z
projecturl = https://libsdl.org/projects/SDL_net
wikiurl = https://wiki.libsdl.org/SDL_net
Expand Down
8 changes: 4 additions & 4 deletions VisualC/pkg-support/cmake/sdl3_net-config-version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ string(REGEX MATCH "#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major
set(_sdl_major "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_net_h}")
set(_sdl_minor "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+([0-9]+)" _sdl_patch_re "${_sdl_net_h}")
set(_sdl_patch "${CMAKE_MATCH_1}")
if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re)
set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}")
string(REGEX MATCH "#define[ \t]+SDL_NET_MICRO_VERSION[ \t]+([0-9]+)" _sdl_micro_re "${_sdl_net_h}")
set(_sdl_micro "${CMAKE_MATCH_1}")
if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re)
set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}")
else()
message(AUTHOR_WARNING "Could not extract version from SDL_net.h.")
return()
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/test-versioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export LC_CTYPE=C
header=include/SDL3_net/SDL_net.h
ref_major=$(sed -ne 's/^#define SDL_NET_MAJOR_VERSION *//p' $header)
ref_minor=$(sed -ne 's/^#define SDL_NET_MINOR_VERSION *//p' $header)
ref_micro=$(sed -ne 's/^#define SDL_NET_PATCHLEVEL *//p' $header)
ref_micro=$(sed -ne 's/^#define SDL_NET_MICRO_VERSION *//p' $header)
ref_version="${ref_major}.${ref_minor}.${ref_micro}"

tests=0
Expand Down
22 changes: 11 additions & 11 deletions build-scripts/wikiheaders.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
my $versionfname = 'include/SDL_version.h';
my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
my $versionminorregex = '\A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z';
my $versionpatchregex = '\A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z';
my $versionmicroregex = '\A\#define\s+SDL_MICRO_VERSION\s+(\d+)\Z';
my $mainincludefname = 'SDL.h';
my $selectheaderregex = '\ASDL.*?\.h\Z';
my $projecturl = 'https://libsdl.org/';
Expand Down Expand Up @@ -92,7 +92,7 @@
$readmesubdir = $val, next if $key eq 'readmesubdir';
$versionmajorregex = $val, next if $key eq 'versionmajorregex';
$versionminorregex = $val, next if $key eq 'versionminorregex';
$versionpatchregex = $val, next if $key eq 'versionpatchregex';
$versionmicroregex = $val, next if $key eq 'versionmicroregex';
$versionfname = $val, next if $key eq 'versionfname';
$mainincludefname = $val, next if $key eq 'mainincludefname';
$selectheaderregex = $val, next if $key eq 'selectheaderregex';
Expand Down Expand Up @@ -2036,19 +2036,19 @@ sub print_undocumented_section {
open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n");
my $majorver = 0;
my $minorver = 0;
my $patchver = 0;
my $microver = 0;
while (<FH>) {
chomp;
if (/$versionmajorregex/) {
$majorver = int($1);
} elsif (/$versionminorregex/) {
$minorver = int($1);
} elsif (/$versionpatchregex/) {
$patchver = int($1);
} elsif (/$versionmicroregex/) {
$microver = int($1);
}
}
close(FH);
my $fullversion = "$majorver.$minorver.$patchver";
my $fullversion = "$majorver.$minorver.$microver";

foreach (keys %headersyms) {
my $sym = $_;
Expand Down Expand Up @@ -2318,19 +2318,19 @@ sub print_undocumented_section {
open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n");
my $majorver = 0;
my $minorver = 0;
my $patchver = 0;
my $microver = 0;
while (<FH>) {
chomp;
if (/$versionmajorregex/) {
$majorver = int($1);
} elsif (/$versionminorregex/) {
$minorver = int($1);
} elsif (/$versionpatchregex/) {
$patchver = int($1);
} elsif (/$versionmicroregex/) {
$microver = int($1);
}
}
close(FH);
my $fullversion = "$majorver.$minorver.$patchver";
my $fullversion = "$majorver.$minorver.$microver";

my $latex_fname = "$srcpath/$projectshortname.tex";
my $latex_tmpfname = "$latex_fname.tmp";
Expand Down Expand Up @@ -2369,7 +2369,7 @@ sub print_undocumented_section {
\\begin{document}
\\frontmatter
\\title{$projectfullname $majorver.$minorver.$patchver Reference Manual}
\\title{$projectfullname $majorver.$minorver.$microver Reference Manual}
\\author{The $projectshortname Developers}
\\maketitle
Expand Down
48 changes: 19 additions & 29 deletions include/SDL3_net/SDL_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,45 +38,35 @@
extern "C" {
#endif

/* Version checks... */

/**
* Printable format: "%d.%d.%d", MAJOR, MINOR, MICRO
*/
#define SDL_NET_MAJOR_VERSION 3
#define SDL_NET_MINOR_VERSION 0
#define SDL_NET_PATCHLEVEL 0
#define SDL_NET_MICRO_VERSION 0

/**
* Query the verion of the SDL_net library in use at compile time.
*
* This macro copies the version listen in the SDL_net headers into a struct
* of the app's choosing.
*
* \threadsafety It is safe to use this macro from any thread.
*
* \since This macro is available since SDL_Net 3.0.0.
* This is the version number macro for the current SDL_net version.
*/
#define SDL_NET_VERSION(X) \
{ \
(X)->major = SDL_NET_MAJOR_VERSION; \
(X)->minor = SDL_NET_MINOR_VERSION; \
(X)->patch = SDL_NET_PATCHLEVEL; \
}
#define SDL_NET_VERSION \
SDL_VERSIONNUM(SDL_NET_MAJOR_VERSION, SDL_NET_MINOR_VERSION, SDL_NET_MICRO_VERSION)

/**
* Query the verion of the SDL_net library in use at runtime.
*
* The returned value points to static, internal, read-only memory. Do not
* modify or free it. The pointer remains valid as long as the library is
* loaded by the system.
*
* This function can be safely called before SDLNet_Init().
*
* \returns An object with the runtime library version. Never returns NULL.
* This macro will evaluate to true if compiled with SDL_net at least X.Y.Z.
*/
#define SDL_NET_VERSION_ATLEAST(X, Y, Z) \
((SDL_NET_MAJOR_VERSION >= X) && \
(SDL_NET_MAJOR_VERSION > X || SDL_NET_MINOR_VERSION >= Y) && \
(SDL_NET_MAJOR_VERSION > X || SDL_NET_MINOR_VERSION > Y || SDL_NET_MICRO_VERSION >= Z))

/**
* This function gets the version of the dynamically linked SDL_net library.
*
* \threadsafety It is safe to call this function from any thread.
* \returns SDL_net version
*
* \since This function is available since SDL_Net 3.0.0.
* \since This function is available since SDL_net 3.0.0.
*/
extern DECLSPEC const SDL_Version * SDLCALL SDLNet_LinkedVersion(void);
extern DECLSPEC int SDLCALL SDLNet_Version(void);


/* init/quit functions... */
Expand Down
7 changes: 2 additions & 5 deletions src/SDL_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,9 @@ typedef enum SDLNet_SocketType
} SDLNet_SocketType;


const SDL_Version *SDLNet_LinkedVersion(void)
int SDLNet_LinkedVersion(void)
{
static const SDL_Version linked_version = {
SDL_NET_MAJOR_VERSION, SDL_NET_MINOR_VERSION, SDL_NET_PATCHLEVEL
};
return &linked_version;
return SDL_NET_VERSION;
}

struct SDLNet_Address
Expand Down

0 comments on commit e4559c9

Please sign in to comment.