diff options
| author | Andre Weissflog <floooh@gmail.com> | 2022-10-22 15:14:22 +0200 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2022-10-22 15:14:22 +0200 |
| commit | 1eebe4c0d755d0c7f899be21007282321c4dc373 (patch) | |
| tree | bd40da7c19cef44a0d13b6de5ff4c8d7d626587e /util | |
| parent | e4b2aad7f27929b6ca58777c4f6884a23b1b0fbb (diff) | |
simplify logging preprocessor macros
Diffstat (limited to 'util')
| -rw-r--r-- | util/sokol_debugtext.h | 37 | ||||
| -rw-r--r-- | util/sokol_fontstash.h | 2 | ||||
| -rw-r--r-- | util/sokol_gl.h | 37 | ||||
| -rw-r--r-- | util/sokol_imgui.h | 2 | ||||
| -rw-r--r-- | util/sokol_memtrack.h | 2 | ||||
| -rw-r--r-- | util/sokol_nuklear.h | 2 |
6 files changed, 28 insertions, 54 deletions
diff --git a/util/sokol_debugtext.h b/util/sokol_debugtext.h index 3201d9e3..89f141db 100644 --- a/util/sokol_debugtext.h +++ b/util/sokol_debugtext.h @@ -567,7 +567,7 @@ typedef struct sdtx_allocator_t { sdtx_logger_t Used in sdtx_desc_t to provide custom log callbacks to sokol_debugtext.h. - Default behavior is SDTX_LOG_DEFAULT(message). + Default behavior is SOKOL_LOG(message). */ typedef struct sdtx_logger_t { void (*log_cb)(const char* message, void* user_data); @@ -596,7 +596,7 @@ typedef struct sdtx_desc_t { sdtx_font_desc_t fonts[SDTX_MAX_FONTS]; // up to 8 fonts descriptions sdtx_context_desc_t context; // the default context creation parameters sdtx_allocator_t allocator; // optional memory allocation overrides (default: malloc/free) - sdtx_logger_t logger; // optional log override functions (default: SDTX_LOG_DEFAULT(message)) + sdtx_logger_t logger; // optional log override functions (default: SOKOL_LOG(message)) } sdtx_desc_t; /* initialization/shutdown */ @@ -680,7 +680,7 @@ inline sdtx_context sdtx_make_context(const sdtx_context_desc_t& desc) { return #endif #ifndef SOKOL_DEBUG #ifndef NDEBUG - #define SOKOL_DEBUG (1) + #define SOKOL_DEBUG #endif #endif #ifndef SOKOL_ASSERT @@ -688,32 +688,19 @@ inline sdtx_context sdtx_make_context(const sdtx_context_desc_t& desc) { return #define SOKOL_ASSERT(c) assert(c) #endif -#if defined(SOKOL_LOG) -#error "SOKOL_LOG macro is no longer supported, please use sg_desc.logger to override log functions" -#endif -#ifndef SOKOL_NO_LOG - #ifdef SOKOL_DEBUG - #define SOKOL_NO_LOG 0 - #else - #define SOKOL_NO_LOG 1 - #endif -#endif -#if !SOKOL_NO_LOG - #define SDTX_LOG(s) { SOKOL_ASSERT(s); _sdtx_log(s); } - #ifndef SDTX_LOG_DEFAULT +#if !defined(SOKOL_DEBUG) + #define SDTX_LOG(s) +#else + #define SDTX_LOG(s) _sdtx_log(s) + #ifndef SOKOL_LOG #if defined(__ANDROID__) #include <android/log.h> - #define SDTX_LOG_DEFAULT(s) __android_log_write(ANDROID_LOG_INFO, "SOKOL_DEBUGTEXT", s) + #define SOKOL_LOG(s) __android_log_write(ANDROID_LOG_INFO, "SOKOL_DEBUGTEXT", s) #else #include <stdio.h> - #define SDTX_LOG_DEFAULT(s) puts(s) + #define SOKOL_LOG(s) puts(s) #endif #endif -#else - #define SDTX_LOG(s) -#endif -#ifndef SDTX_LOG_DEFAULT - #define SDTX_LOG_DEFAULT(s) #endif #ifndef SOKOL_UNREACHABLE @@ -3563,13 +3550,13 @@ static void _sdtx_free(void* ptr) { } } -#if !SOKOL_NO_LOG +#if defined(SOKOL_DEBUG) static void _sdtx_log(const char* msg) { SOKOL_ASSERT(msg); if (_sdtx.desc.logger.log_cb) { _sdtx.desc.logger.log_cb(msg, _sdtx.desc.logger.user_data); } else { - SDTX_LOG_DEFAULT(msg); + SOKOL_LOG(msg); } } #endif diff --git a/util/sokol_fontstash.h b/util/sokol_fontstash.h index 16d288ab..049d5e11 100644 --- a/util/sokol_fontstash.h +++ b/util/sokol_fontstash.h @@ -265,7 +265,7 @@ SOKOL_FONTSTASH_API_DECL uint32_t sfons_rgba(uint8_t r, uint8_t g, uint8_t b, ui #endif #ifndef SOKOL_DEBUG #ifndef NDEBUG - #define SOKOL_DEBUG (1) + #define SOKOL_DEBUG #endif #endif #ifndef SOKOL_ASSERT diff --git a/util/sokol_gl.h b/util/sokol_gl.h index 1f4f4d05..e5233d0a 100644 --- a/util/sokol_gl.h +++ b/util/sokol_gl.h @@ -700,7 +700,7 @@ typedef struct sgl_allocator_t { sgl_logger_t Used in sgl_desc_t to provide custom log callbacks to sokol_gl.h. - Default behavior is SGL_LOG_DEFAULT(message). + Default behavior is SOKOL_LOG(message). */ typedef struct sgl_logger_t { void (*log_cb)(const char* message, void* user_data); @@ -717,7 +717,7 @@ typedef struct sgl_desc_t { int sample_count; sg_face_winding face_winding; // default: SG_FACEWINDING_CCW sgl_allocator_t allocator; // optional memory allocation overrides (default: malloc/free) - sgl_logger_t logger; // optional memory allocation overrides (default: SGL_LOG_DEFAULT(message)) + sgl_logger_t logger; // optional memory allocation overrides (default: SOKOL_LOG(message)) } sgl_desc_t; /* the default context handle */ @@ -856,7 +856,7 @@ inline sgl_pipeline sgl_context_make_pipeline(sgl_context ctx, const sg_pipeline #endif #ifndef SOKOL_DEBUG #ifndef NDEBUG - #define SOKOL_DEBUG (1) + #define SOKOL_DEBUG #endif #endif #ifndef SOKOL_ASSERT @@ -864,32 +864,19 @@ inline sgl_pipeline sgl_context_make_pipeline(sgl_context ctx, const sg_pipeline #define SOKOL_ASSERT(c) assert(c) #endif -#if defined(SOKOL_LOG) -#error "SOKOL_LOG macro is no longer supported, please use sgl_desc_t.logger to override log functions" -#endif -#ifndef SOKOL_NO_LOG - #ifdef SOKOL_DEBUG - #define SOKOL_NO_LOG 0 - #else - #define SOKOL_NO_LOG 1 - #endif -#endif -#if !SOKOL_NO_LOG - #define SGL_LOG(s) { SOKOL_ASSERT(s); _sgl_log(s); } - #ifndef SGL_LOG_DEFAULT +#if !defined(SOKOL_DEBUG) + #define SGL_LOG(s) +#else + #define SGL_LOG(s) _sgl_log(s) + #ifndef SOKOL_LOG #if defined(__ANDROID__) #include <android/log.h> - #define SGL_LOG_DEFAULT(s) __android_log_write(ANDROID_LOG_INFO, "SOKOL_GL", s) + #define SOKOL_LOG(s) __android_log_write(ANDROID_LOG_INFO, "SOKOL_GL", s) #else #include <stdio.h> - #define SGL_LOG_DEFAULT(s) puts(s) + #define SOKOL_LOG(s) puts(s) #endif #endif -#else - #define SGL_LOG(s) -#endif -#ifndef SGL_LOG_DEFAULT - #define SGL_LOG_DEFAULT(s) #endif #define _sgl_def(val, def) (((val) == 0) ? (def) : (val)) @@ -2390,13 +2377,13 @@ static void _sgl_free(void* ptr) { } } -#if !SOKOL_NO_LOG +#if defined(SOKOL_DEBUG) static void _sgl_log(const char* msg) { SOKOL_ASSERT(msg); if (_sgl.desc.logger.log_cb) { _sgl.desc.logger.log_cb(msg, _sgl.desc.logger.user_data); } else { - SGL_LOG_DEFAULT(msg); + SOKOL_LOG(msg); } } #endif diff --git a/util/sokol_imgui.h b/util/sokol_imgui.h index 74421c87..df12ccfa 100644 --- a/util/sokol_imgui.h +++ b/util/sokol_imgui.h @@ -379,7 +379,7 @@ inline void simgui_new_frame(const simgui_frame_desc_t& desc) { return simgui_ne #endif #ifndef SOKOL_DEBUG #ifndef NDEBUG - #define SOKOL_DEBUG (1) + #define SOKOL_DEBUG #endif #endif #ifndef SOKOL_ASSERT diff --git a/util/sokol_memtrack.h b/util/sokol_memtrack.h index 82d0b219..dc0b469f 100644 --- a/util/sokol_memtrack.h +++ b/util/sokol_memtrack.h @@ -115,7 +115,7 @@ SOKOL_MEMTRACK_API_DECL void smemtrack_free(void* ptr, void* user_data); #endif #ifndef SOKOL_DEBUG #ifndef NDEBUG - #define SOKOL_DEBUG (1) + #define SOKOL_DEBUG #endif #endif #ifndef _SOKOL_PRIVATE diff --git a/util/sokol_nuklear.h b/util/sokol_nuklear.h index 0824a964..3d996061 100644 --- a/util/sokol_nuklear.h +++ b/util/sokol_nuklear.h @@ -267,7 +267,7 @@ inline void snk_setup(const snk_desc_t& desc) { return snk_setup(&desc); } #endif #ifndef SOKOL_DEBUG #ifndef NDEBUG - #define SOKOL_DEBUG (1) + #define SOKOL_DEBUG #endif #endif #ifndef SOKOL_ASSERT |