1 
2 //          Copyright 2018 - 2021 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_2014) {
21     enum ubyte SDL_PATCHLEVEL = 14;
22 }
23 else version(SDL_2012) {
24     enum ubyte SDL_PATCHLEVEL = 12;
25 }
26 else version(SDL_2010) {
27     enum ubyte SDL_PATCHLEVEL = 10;
28 }
29 else version(SDL_209) {
30     enum ubyte SDL_PATCHLEVEL = 9;
31 }
32 else version(SDL_208) {
33     enum ubyte SDL_PATCHLEVEL = 8;
34 }
35 else version(SDL_207) {
36     enum ubyte SDL_PATCHLEVEL = 7;
37 }
38 else version(SDL_206) {
39     enum ubyte SDL_PATCHLEVEL = 6;
40 }
41 else version(SDL_205) {
42     enum ubyte SDL_PATCHLEVEL = 5;
43 }
44 else version(SDL_204) {
45     enum ubyte SDL_PATCHLEVEL = 4;
46 }
47 else version(SDL_203) {
48     enum ubyte SDL_PATCHLEVEL = 3;
49 }
50 else version(SDL_202) {
51     enum ubyte SDL_PATCHLEVEL = 2;
52 }
53 else version(SDL_201) {
54     enum ubyte SDL_PATCHLEVEL = 1;
55 }
56 else {
57     enum ubyte SDL_PATCHLEVEL = 0;
58 }
59 
60 @nogc nothrow pure
61 void SDL_VERSION(SDL_version* x) {
62     pragma(inline, true);
63     x.major = SDL_MAJOR_VERSION;
64     x.minor = SDL_MINOR_VERSION;
65     x.patch = SDL_PATCHLEVEL;
66 }
67 
68 enum SDL_VERSIONNUM(ubyte X, ubyte Y, ubyte Z) = X*1000 + Y*100 + Z;
69 enum SDL_COMPILEDVERSION = SDL_VERSIONNUM!(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
70 enum SDL_VERSION_ATLEAST(ubyte X, ubyte Y, ubyte Z) = SDL_COMPILEDVERSION >= SDL_VERSIONNUM!(X, Y, Z);
71 
72 static if(staticBinding) {
73     extern(C) @nogc nothrow {
74         void SDL_GetVersion(SDL_version* ver);
75         const(char)* SDL_GetRevision();
76         int SDL_GetRevisionNumber();
77     }
78 }
79 else {
80     extern(C) @nogc nothrow {
81         alias pSDL_GetVersion = void function(SDL_version* ver);
82         alias pSDL_GetRevision = const(char)* function();
83         alias pSDL_GetRevisionNumber = int function();
84     }
85 
86     __gshared {
87         pSDL_GetVersion SDL_GetVersion;
88         pSDL_GetRevision SDL_GetRevision;
89         pSDL_GetRevisionNumber SDL_GetRevisionNumber;
90     }
91 }