1 /+
2 +            Copyright 2022 – 2024 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 bindbc.sdl.config;
9 
10 public import bindbc.common.types: c_long, c_ulong, va_list, wchar_t;
11 
12 struct SDL_version{
13 	ubyte major;
14 	ubyte minor;
15 	ubyte patch;
16 	
17 	int opCmp(SDL_version x) nothrow @nogc pure{
18 		if(major != x.major)
19 			return major - x.major;
20 		else if(minor != x.minor)
21 			return minor - x.minor;
22 		else
23 			return patch - x.patch;
24 	}
25 }
26 
27 enum SDLSupport: SDL_version{
28 	noLibrary   = SDL_version(0,0,0),
29 	badLibrary  = SDL_version(0,0,255),
30 	v2_0_0      = SDL_version(2,0,0),
31 	v2_0_1      = SDL_version(2,0,1),
32 	v2_0_2      = SDL_version(2,0,2),
33 	v2_0_3      = SDL_version(2,0,3),
34 	v2_0_4      = SDL_version(2,0,4),
35 	v2_0_5      = SDL_version(2,0,5),
36 	v2_0_6      = SDL_version(2,0,6),
37 	v2_0_7      = SDL_version(2,0,7),
38 	v2_0_8      = SDL_version(2,0,8),
39 	v2_0_9      = SDL_version(2,0,9),
40 	v2_0_10     = SDL_version(2,0,10),
41 	v2_0_12     = SDL_version(2,0,12),
42 	v2_0_14     = SDL_version(2,0,14),
43 	v2_0_16     = SDL_version(2,0,16),
44 	v2_0_18     = SDL_version(2,0,18),
45 	v2_0_20     = SDL_version(2,0,20),
46 	v2_0_22     = SDL_version(2,0,22),
47 	v2_24       = SDL_version(2,24,0),
48 	v2_26       = SDL_version(2,26,0),
49 	v2_28       = SDL_version(2,28,0),
50 	v2_30       = SDL_version(2,30,0),
51 	
52 	deprecated("Please use `v2_0_0` instead")  sdl200  = v2_0_0,
53 	deprecated("Please use `v2_0_1` instead")  sdl201  = v2_0_1,
54 	deprecated("Please use `v2_0_2` instead")  sdl202  = v2_0_2,
55 	deprecated("Please use `v2_0_3` instead")  sdl203  = v2_0_3,
56 	deprecated("Please use `v2_0_4` instead")  sdl204  = v2_0_4,
57 	deprecated("Please use `v2_0_5` instead")  sdl205  = v2_0_5,
58 	deprecated("Please use `v2_0_6` instead")  sdl206  = v2_0_6,
59 	deprecated("Please use `v2_0_7` instead")  sdl207  = v2_0_7,
60 	deprecated("Please use `v2_0_8` instead")  sdl208  = v2_0_8,
61 	deprecated("Please use `v2_0_9` instead")  sdl209  = v2_0_9,
62 	deprecated("Please use `v2_0_10` instead") sdl2010 = v2_0_10,
63 	deprecated("Please use `v2_0_12` instead") sdl2012 = v2_0_12,
64 	deprecated("Please use `v2_0_14` instead") sdl2014 = v2_0_14,
65 	deprecated("Please use `v2_0_16` instead") sdl2016 = v2_0_16,
66 	deprecated("Please use `v2_0_18` instead") sdl2018 = v2_0_18,
67 	deprecated("Please use `v2_0_20` instead") sdl2020 = v2_0_20,
68 	deprecated("Please use `v2_0_22` instead") sdl2022 = v2_0_22,
69 }
70 
71 enum staticBinding = (){
72 	version(BindBC_Static)       return true;
73 	else version(BindSDL_Static) return true;
74 	else return false;
75 }();
76 
77 enum sdlSupport = (){
78 	version(SDL_2_30)      return SDLSupport.v2_30;
79 	else version(SDL_2_28) return SDLSupport.v2_28;
80 	else version(SDL_2_26) return SDLSupport.v2_26;
81 	else version(SDL_2_24) return SDLSupport.v2_24;
82 	else version(SDL_2022) return SDLSupport.v2_0_22;
83 	else version(SDL_2020) return SDLSupport.v2_0_20;
84 	else version(SDL_2018) return SDLSupport.v2_0_18;
85 	else version(SDL_2016) return SDLSupport.v2_0_16;
86 	else version(SDL_2014) return SDLSupport.v2_0_14;
87 	else version(SDL_2012) return SDLSupport.v2_0_12;
88 	else version(SDL_2010) return SDLSupport.v2_0_10;
89 	else version(SDL_209)  return SDLSupport.v2_0_9;
90 	else version(SDL_208)  return SDLSupport.v2_0_8;
91 	else version(SDL_207)  return SDLSupport.v2_0_7;
92 	else version(SDL_206)  return SDLSupport.v2_0_6;
93 	else version(SDL_205)  return SDLSupport.v2_0_5;
94 	else version(SDL_204)  return SDLSupport.v2_0_4;
95 	else version(SDL_203)  return SDLSupport.v2_0_3;
96 	else version(SDL_202)  return SDLSupport.v2_0_2;
97 	else version(SDL_201)  return SDLSupport.v2_0_1;
98 	else                   return SDLSupport.v2_0_0;
99 }();
100 
101 enum bindSDLImage = (){
102 	version(SDL_Image){ pragma(msg, "`SDL_Image` is deprecated. If you want the earliest supported version of SDL Image then please use version `SDL_Image_200`, otherwise you can safely remove it from your version list"); return true; }
103 	else version(SDL_Image_200) return true;
104 	else version(SDL_Image_201) return true;
105 	else version(SDL_Image_202) return true;
106 	else version(SDL_Image_203) return true;
107 	else version(SDL_Image_204) return true;
108 	else version(SDL_Image_205) return true;
109 	else version(SDL_Image_2_6) return true;
110 	else version(SDL_Image_2_8) return true;
111 	else return false;
112 }();
113 
114 enum bindSDLMixer = (){
115 	version(SDL_Mixer){ pragma(msg, "`SDL_Mixer` is deprecated. If you want the earliest supported version of SDL Mixer then please use version `SDL_Mixer_200`, otherwise you can safely remove it from your version list"); return true; }
116 	else version(SDL_Mixer_200) return true;
117 	else version(SDL_Mixer_201) return true;
118 	else version(SDL_Mixer_202) return true;
119 	else version(SDL_Mixer_204) return true;
120 	else version(SDL_Mixer_260){ pragma(msg, "`SDL_Mixer_260` is deprecated. Please use version `SDL_Mixer_2_6` instead"); return true; }
121 	else version(SDL_Mixer_2_6) return true;
122 	else version(SDL_Mixer_2_8) return true;
123 	else return false;
124 }();
125 
126 enum bindSDLNet = (){
127 	version(SDL_Net){ pragma(msg, "`SDL_Net` is deprecated. If you want the earliest supported version of SDL Net then please use version `SDL_Net_200`, otherwise you can safely remove it from your version list"); return true; }
128 	else version(SDL_Net_200) return true;
129 	else version(SDL_Net_201) return true;
130 	else version(SDL_Net_2_2) return true;
131 	else return false;
132 }();
133 
134 enum bindSDLTTF = (){
135 	version(SDL_TTF){ pragma(msg, "`SDL_TTF` is deprecated. If you want the earliest supported version of SDL TTF then please use version `SDL_TTF_2012`, otherwise you can safely remove it from your version list"); return true; }
136 	else version(SDL_TTF_2012) return true;
137 	else version(SDL_TTF_2013) return true;
138 	else version(SDL_TTF_2014) return true;
139 	else version(SDL_TTF_2015) return true;
140 	else version(SDL_TTF_2018) return true;
141 	else version(SDL_TTF_2_20) return true;
142 	else version(SDL_TTF_2_22) return true;
143 	else return false;
144 }();
145 
146 
147 deprecated("This template will be moved to bindbc.common.codegen.makeExpandedEnum in the future") enum expandEnum(EnumType, string fqnEnumType = EnumType.stringof) = () nothrow pure @safe{
148 	string expandEnum;
149 	foreach(m;__traits(allMembers, EnumType)){
150 		expandEnum ~= `alias `~m~` = `~fqnEnumType~`.`~m~`;`;
151 	}
152 	return expandEnum;
153 }();