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