1 /+
2 +            Copyright 2022 – 2023 Aya Partridge
3 +          Copyright 2018 - 2022 Michael D. Parker
4 + Distributed under the Boost Software License, Version 1.0.
5 +     (See accompanying file LICENSE_1_0.txt or copy at
6 +           http://www.boost.org/LICENSE_1_0.txt)
7 +/
8 module sdl.version_;
9 
10 import bindbc.sdl.config;
11 import bindbc.sdl.codegen;
12 
13 struct SDL_version{
14 	ubyte major;
15 	ubyte minor;
16 	ubyte patch;
17 	
18 	int opCmp(SDL_version x) @nogc nothrow pure{
19 		if(major != x.major)
20 			return major - x.major;
21 		else if(minor != x.minor)
22 			return minor - x.minor;
23 		else
24 			return patch - x.patch;
25 	}
26 }
27 
28 enum SDL_MAJOR_VERSION = sdlSupport.major;
29 enum SDL_MINOR_VERSION = sdlSupport.minor;
30 enum SDL_PATCHLEVEL    = sdlSupport.patch;
31 
32 pragma(inline, true) void SDL_VERSION(SDL_version* x) @nogc nothrow pure @safe{
33 	x.major = SDL_MAJOR_VERSION;
34 	x.minor = SDL_MINOR_VERSION;
35 	x.patch = SDL_PATCHLEVEL;
36 }
37 
38 deprecated("Please use SDL_version() instead")
39 	enum SDL_VERSIONNUM(ubyte X, ubyte Y, ubyte Z) = X*1000 + Y*100 + Z;
40 
41 deprecated("Please use SDL_VERSION_ATLEAST or SDL_version() instead")
42 	enum SDL_COMPILEDVERSION = SDL_version(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
43 
44 pragma(inline, true) @nogc nothrow{
45 	bool SDL_VERSION_ATLEAST(ubyte x, ubyte y, ubyte z){ return SDL_version(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) >= SDL_version(x, y, z); }
46 }
47 deprecated("Please use the non-template variant instead"){
48 	enum SDL_VERSION_ATLEAST(ubyte X, ubyte Y, ubyte Z) = SDL_version(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) >= SDL_version(X, Y, Z);
49 }
50 
51 mixin(joinFnBinds((){
52 	string[][] ret;
53 	ret ~= makeFnBinds([
54 		[q{void}, q{SDL_GetVersion}, q{SDL_version* ver}],
55 		[q{const(char)*}, q{SDL_GetRevision}, q{}],
56 		[q{int}, q{SDL_GetRevisionNumber}, q{}], //NOTE: this function is deprecated
57 	]);
58 	return ret;
59 }()));