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