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.sdllog;
8 
9 import core.stdc.stdarg : va_list;
10 import bindbc.sdl.config;
11 
12 enum SDL_MAX_LOG_MESSAGE = 4096;
13 
14 enum SDL_LogCategory {
15     SDL_LOG_CATEGORY_APPLICATION,
16     SDL_LOG_CATEGORY_ERROR,
17     SDL_LOG_CATEGORY_ASSERT,
18     SDL_LOG_CATEGORY_SYSTEM,
19     SDL_LOG_CATEGORY_AUDIO,
20     SDL_LOG_CATEGORY_VIDEO,
21     SDL_LOG_CATEGORY_RENDER,
22     SDL_LOG_CATEGORY_INPUT,
23     SDL_LOG_CATEGORY_TEST,
24 
25     SDL_LOG_CATEGORY_RESERVED1,
26     SDL_LOG_CATEGORY_RESERVED2,
27     SDL_LOG_CATEGORY_RESERVED3,
28     SDL_LOG_CATEGORY_RESERVED4,
29     SDL_LOG_CATEGORY_RESERVED5,
30     SDL_LOG_CATEGORY_RESERVED6,
31     SDL_LOG_CATEGORY_RESERVED7,
32     SDL_LOG_CATEGORY_RESERVED8,
33     SDL_LOG_CATEGORY_RESERVED9,
34     SDL_LOG_CATEGORY_RESERVED10,
35 
36     SDL_LOG_CATEGORY_CUSTOM
37 }
38 mixin(expandEnum!SDL_LogCategory);
39 
40 enum SDL_LogPriority {
41     SDL_LOG_PRIORITY_VERBOSE = 1,
42     SDL_LOG_PRIORITY_DEBUG,
43     SDL_LOG_PRIORITY_INFO,
44     SDL_LOG_PRIORITY_WARN,
45     SDL_LOG_PRIORITY_ERROR,
46     SDL_LOG_PRIORITY_CRITICAL,
47     SDL_NUM_LOG_PRIORITIES
48 }
49 mixin(expandEnum!SDL_LogPriority);
50 
51 extern(C) nothrow alias SDL_LogOutputFunction = void function(void*, int, SDL_LogPriority, const(char)*);
52 
53 static if(staticBinding) {
54     extern(C) @nogc nothrow {
55         void SDL_LogSetAllPriority(SDL_LogPriority priority);
56         void SDL_LogSetPriority(int,SDL_LogPriority priority);
57         SDL_LogPriority SDL_LogGetPriority(int category);
58         void SDL_LogResetPriorities();
59         void SDL_Log(const(char)* fmt,...);
60         void SDL_LogVerbose(int category, const(char)* fmt,...);
61         void SDL_LogDebug(int category, const(char)* fmt,...);
62         void SDL_LogInfo(int category, const(char)* fmt,...);
63         void SDL_LogWarn(int category, const(char)* fmt,...);
64         void SDL_LogError(int category, const(char)* fmt,...);
65         void SDL_LogCritical(int category, const(char)* fmt,...);
66         void SDL_LogMessage(int category,SDL_LogPriority, const(char)* fmt,...);
67         void SDL_LogMessageV(int category,SDL_LogPriority, const(char)* fmt, va_list ap);
68         void SDL_LogGetOutputFunction(SDL_LogOutputFunction callback, void** userdata);
69         void SDL_LogSetOutputFunction(SDL_LogOutputFunction callback,void* userdata);
70     }
71 }
72 else {
73     extern(C) @nogc nothrow {
74         alias pSDL_LogSetAllPriority = void function(SDL_LogPriority priority);
75         alias pSDL_LogSetPriority = void function(int category,SDL_LogPriority priority);
76         alias pSDL_LogGetPriority = SDL_LogPriority function(int category);
77         alias pSDL_LogResetPriorities = void function();
78         alias pSDL_Log = void function(const(char)* fmt,...);
79         alias pSDL_LogVerbose = void function(int category, const(char)* fmt,...);
80         alias pSDL_LogDebug = void function(int category, const(char)* fmt,...);
81         alias pSDL_LogInfo = void function(int category, const(char)* fmt,...);
82         alias pSDL_LogWarn = void function(int category, const(char)* fmt,...);
83         alias pSDL_LogError = void function(int category, const(char)* fmt,...);
84         alias pSDL_LogCritical = void function(int category, const(char)* fmt,...);
85         alias pSDL_LogMessage = void function(int category,SDL_LogPriority, const(char)* fmt,...);
86         alias pSDL_LogMessageV = void function(int category,SDL_LogPriority, const(char)* fmt, va_list ap);
87         alias pSDL_LogGetOutputFunction = void function(SDL_LogOutputFunction callback, void** userdata);
88         alias pSDL_LogSetOutputFunction = void function(SDL_LogOutputFunction callback,void* userdata);
89     }
90 
91     __gshared {
92         pSDL_LogSetAllPriority SDL_LogSetAllPriority;
93         pSDL_LogSetPriority SDL_LogSetPriority;
94         pSDL_LogGetPriority SDL_LogGetPriority;
95         pSDL_LogResetPriorities SDL_LogResetPriorities;
96         pSDL_Log SDL_Log;
97         pSDL_LogVerbose SDL_LogVerbose;
98         pSDL_LogDebug SDL_LogDebug;
99         pSDL_LogInfo SDL_LogInfo;
100         pSDL_LogWarn SDL_LogWarn;
101         pSDL_LogError SDL_LogError;
102         pSDL_LogCritical SDL_LogCritical;
103         pSDL_LogMessage SDL_LogMessage;
104         pSDL_LogMessageV SDL_LogMessageV;
105         pSDL_LogGetOutputFunction SDL_LogGetOutputFunction;
106         pSDL_LogSetOutputFunction SDL_LogSetOutputFunction;
107     }
108 }