1 /+
2 +                Copyright 2023 Aya Partridge
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 sdl.main;
8 
9 import bindbc.sdl.config;
10 import bindbc.sdl.codegen;
11 
12 /*
13 This file is intentionally not included with the rest of BindBC SDL,
14 since SDL does not do this either. This file is provided in case the
15 user needs the functions located within it for their application.
16 Feel free to submit a PR if there is a better way this could be laid out.
17 */
18 
19 alias SDL_main_func = int function(int argc, char** argv);
20 
21 mixin(joinFnBinds((){
22 	string[][] ret;
23 	ret ~= makeFnBinds([
24 		[q{int}, q{SDL_main}, q{int argc, char** argv}],
25 		[q{void}, q{SDL_SetMainReady}, q{}],
26 	]);
27 	static if(sdlSupport >= SDLSupport.v2_0_2 && (){
28 		version(Windows)     return true;
29 		else version(WinGDK) return true;
30 		else return false;
31 	}()){
32 		ret ~= makeFnBinds([
33 			[q{int}, q{SDL_RegisterApp}, q{const(char)* name, uint style, void* hInst}],
34 			[q{void}, q{SDL_UnregisterApp}, q{}],
35 		]);
36 	}
37 	version(WinRT){
38 		static if(sdlSupport >= SDLSupport.v2_0_3){
39 			ret ~= makeFnBinds([
40 				[q{int}, q{SDL_WinRTRunApp}, q{SDL_main_func mainFunction, void* reserved}],
41 			]);
42 		}
43 	}
44 	version(iOS){
45 		static if(sdlSupport >= SDLSupport.v2_0_10){
46 			ret ~= makeFnBinds([
47 				[q{int}, q{SDL_UIKitRunApp}, q{int argc, char** argv, SDL_main_func mainFunction}],
48 			]);
49 		}
50 	}
51 	version(WinGDK){
52 		static if(sdlSupport >= SDLSupport.v2_24){
53 			ret ~= makeFnBinds([
54 				[q{int}, q{SDL_GDKRunApp}, q{SDL_main_func mainFunction, void* reserved}],
55 			]);
56 		}
57 	}
58 	return ret;
59 }()));