1 
2 //          Copyright 2018 - 2022 Michael D. Parker
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.sdl.bind.sdlversion;
8 
9 import bindbc.sdl.config;
10 
11 struct SDL_version {
12     ubyte major;
13     ubyte minor;
14     ubyte patch;
15 }
16 
17 enum SDL_MAJOR_VERSION = 2;
18 enum SDL_MINOR_VERSION = 0;
19 
20 version(SDL_2020) {
21     enum ubyte SDL_PATCHLEVEL = 20;
22 }
23 else version(SDL_2018) {
24     enum ubyte SDL_PATCHLEVEL = 18;
25 }
26 else version(SDL_2016) {
27     enum ubyte SDL_PATCHLEVEL = 16;
28 }
29 else version(SDL_2014) {
30     enum ubyte SDL_PATCHLEVEL = 14;
31 }
32 else version(SDL_2012) {
33     enum ubyte SDL_PATCHLEVEL = 12;
34 }
35 else version(SDL_2010) {
36     enum ubyte SDL_PATCHLEVEL = 10;
37 }
38 else version(SDL_209) {
39     enum ubyte SDL_PATCHLEVEL = 9;
40 }
41 else version(SDL_208) {
42     enum ubyte SDL_PATCHLEVEL = 8;
43 }
44 else version(SDL_207) {
45     enum ubyte SDL_PATCHLEVEL = 7;
46 }
47 else version(SDL_206) {
48     enum ubyte SDL_PATCHLEVEL = 6;
49 }
50 else version(SDL_205) {
51     enum ubyte SDL_PATCHLEVEL = 5;
52 }
53 else version(SDL_204) {
54     enum ubyte SDL_PATCHLEVEL = 4;
55 }
56 else version(SDL_203) {
57     enum ubyte SDL_PATCHLEVEL = 3;
58 }
59 else version(SDL_202) {
60     enum ubyte SDL_PATCHLEVEL = 2;
61 }
62 else version(SDL_201) {
63     enum ubyte SDL_PATCHLEVEL = 1;
64 }
65 else {
66     enum ubyte SDL_PATCHLEVEL = 0;
67 }
68 
69 @nogc nothrow pure
70 void SDL_VERSION(SDL_version* x) {
71     pragma(inline, true);
72     x.major = SDL_MAJOR_VERSION;
73     x.minor = SDL_MINOR_VERSION;
74     x.patch = SDL_PATCHLEVEL;
75 }
76 
77 enum SDL_VERSIONNUM(ubyte X, ubyte Y, ubyte Z) = X*1000 + Y*100 + Z;
78 enum SDL_COMPILEDVERSION = SDL_VERSIONNUM!(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
79 enum SDL_VERSION_ATLEAST(ubyte X, ubyte Y, ubyte Z) = SDL_COMPILEDVERSION >= SDL_VERSIONNUM!(X, Y, Z);
80 
81 static if(staticBinding) {
82     extern(C) @nogc nothrow {
83         void SDL_GetVersion(SDL_version* ver);
84         const(char)* SDL_GetRevision();
85         int SDL_GetRevisionNumber();
86     }
87 }
88 else {
89     extern(C) @nogc nothrow {
90         alias pSDL_GetVersion = void function(SDL_version* ver);
91         alias pSDL_GetRevision = const(char)* function();
92         alias pSDL_GetRevisionNumber = int function();
93     }
94 
95     __gshared {
96         pSDL_GetVersion SDL_GetVersion;
97         pSDL_GetRevision SDL_GetRevision;
98         pSDL_GetRevisionNumber SDL_GetRevisionNumber;
99     }
100 }