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