diff options
author | David Robillard <d@drobilla.net> | 2020-12-26 19:21:17 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-12-26 19:21:17 +0100 |
commit | 882b9446cbf7316345de391188e68c2a7333da5b (patch) | |
tree | 5baf31e0a28313b380cc7e8694b09a2a517d14f3 /lv2/log | |
parent | 8d2251749da9e0ae4254502edfc8917236a9b8c0 (diff) | |
download | lv2-882b9446cbf7316345de391188e68c2a7333da5b.tar.xz |
Format all code with clang-format
Diffstat (limited to 'lv2/log')
-rw-r--r-- | lv2/log/log.h | 74 | ||||
-rw-r--r-- | lv2/log/logger.h | 84 |
2 files changed, 77 insertions, 81 deletions
diff --git a/lv2/log/log.h b/lv2/log/log.h index cf938ca..92422bd 100644 --- a/lv2/log/log.h +++ b/lv2/log/log.h @@ -53,9 +53,9 @@ extern "C" { /** @cond */ #ifdef __GNUC__ /** Allow type checking of printf-like functions. */ -# define LV2_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1))) +# define LV2_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1))) #else -# define LV2_LOG_FUNC(fmt, arg1) +# define LV2_LOG_FUNC(fmt, arg1) #endif /** @endcond */ @@ -68,48 +68,46 @@ typedef void* LV2_Log_Handle; Log feature (LV2_LOG__log) */ typedef struct { - /** - Opaque pointer to host data. - - This MUST be passed to methods in this struct whenever they are called. - Otherwise, it must not be interpreted in any way. - */ - LV2_Log_Handle handle; - - /** - Log a message, passing format parameters directly. - - The API of this function matches that of the standard C printf function, - except for the addition of the first two parameters. This function may - be called from any non-realtime context, or from any context if `type` - is @ref LV2_LOG__Trace. - */ - LV2_LOG_FUNC(3, 4) - int (*printf)(LV2_Log_Handle handle, - LV2_URID type, - const char* fmt, ...); - - /** - Log a message, passing format parameters in a va_list. - - The API of this function matches that of the standard C vprintf - function, except for the addition of the first two parameters. This - function may be called from any non-realtime context, or from any - context if `type` is @ref LV2_LOG__Trace. - */ - LV2_LOG_FUNC(3, 0) - int (*vprintf)(LV2_Log_Handle handle, - LV2_URID type, - const char* fmt, - va_list ap); + /** + Opaque pointer to host data. + + This MUST be passed to methods in this struct whenever they are called. + Otherwise, it must not be interpreted in any way. + */ + LV2_Log_Handle handle; + + /** + Log a message, passing format parameters directly. + + The API of this function matches that of the standard C printf function, + except for the addition of the first two parameters. This function may + be called from any non-realtime context, or from any context if `type` + is @ref LV2_LOG__Trace. + */ + LV2_LOG_FUNC(3, 4) + int (*printf)(LV2_Log_Handle handle, LV2_URID type, const char* fmt, ...); + + /** + Log a message, passing format parameters in a va_list. + + The API of this function matches that of the standard C vprintf + function, except for the addition of the first two parameters. This + function may be called from any non-realtime context, or from any + context if `type` is @ref LV2_LOG__Trace. + */ + LV2_LOG_FUNC(3, 0) + int (*vprintf)(LV2_Log_Handle handle, + LV2_URID type, + const char* fmt, + va_list ap); } LV2_Log_Log; #ifdef __cplusplus -} /* extern "C" */ +} /* extern "C" */ #endif /** @} */ -#endif /* LV2_LOG_H */ +#endif /* LV2_LOG_H */ diff --git a/lv2/log/logger.h b/lv2/log/logger.h index 669069c..80459a7 100644 --- a/lv2/log/logger.h +++ b/lv2/log/logger.h @@ -42,12 +42,12 @@ extern "C" { Logger convenience API state. */ typedef struct { - LV2_Log_Log* log; + LV2_Log_Log* log; - LV2_URID Error; - LV2_URID Note; - LV2_URID Trace; - LV2_URID Warning; + LV2_URID Error; + LV2_URID Note; + LV2_URID Trace; + LV2_URID Warning; } LV2_Log_Logger; /** @@ -59,14 +59,14 @@ typedef struct { static inline void lv2_log_logger_set_map(LV2_Log_Logger* logger, LV2_URID_Map* map) { - if (map) { - logger->Error = map->map(map->handle, LV2_LOG__Error); - logger->Note = map->map(map->handle, LV2_LOG__Note); - logger->Trace = map->map(map->handle, LV2_LOG__Trace); - logger->Warning = map->map(map->handle, LV2_LOG__Warning); - } else { - logger->Error = logger->Note = logger->Trace = logger->Warning = 0; - } + if (map) { + logger->Error = map->map(map->handle, LV2_LOG__Error); + logger->Note = map->map(map->handle, LV2_LOG__Note); + logger->Trace = map->map(map->handle, LV2_LOG__Trace); + logger->Warning = map->map(map->handle, LV2_LOG__Warning); + } else { + logger->Error = logger->Note = logger->Trace = logger->Warning = 0; + } } /** @@ -77,12 +77,10 @@ lv2_log_logger_set_map(LV2_Log_Logger* logger, LV2_URID_Map* map) in which case the implementation will fall back to printing to stderr. */ static inline void -lv2_log_logger_init(LV2_Log_Logger* logger, - LV2_URID_Map* map, - LV2_Log_Log* log) +lv2_log_logger_init(LV2_Log_Logger* logger, LV2_URID_Map* map, LV2_Log_Log* log) { - logger->log = log; - lv2_log_logger_set_map(logger, map); + logger->log = log; + lv2_log_logger_set_map(logger, map); } /** @@ -95,9 +93,9 @@ lv2_log_vprintf(LV2_Log_Logger* logger, const char* fmt, va_list args) { - return ((logger && logger->log) - ? logger->log->vprintf(logger->log->handle, type, fmt, args) - : vfprintf(stderr, fmt, args)); + return ((logger && logger->log) + ? logger->log->vprintf(logger->log->handle, type, fmt, args) + : vfprintf(stderr, fmt, args)); } /** Log an error via lv2_log_vprintf(). */ @@ -105,11 +103,11 @@ LV2_LOG_FUNC(2, 3) static inline int lv2_log_error(LV2_Log_Logger* logger, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - const int ret = lv2_log_vprintf(logger, logger->Error, fmt, args); - va_end(args); - return ret; + va_list args; + va_start(args, fmt); + const int ret = lv2_log_vprintf(logger, logger->Error, fmt, args); + va_end(args); + return ret; } /** Log a note via lv2_log_vprintf(). */ @@ -117,11 +115,11 @@ LV2_LOG_FUNC(2, 3) static inline int lv2_log_note(LV2_Log_Logger* logger, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - const int ret = lv2_log_vprintf(logger, logger->Note, fmt, args); - va_end(args); - return ret; + va_list args; + va_start(args, fmt); + const int ret = lv2_log_vprintf(logger, logger->Note, fmt, args); + va_end(args); + return ret; } /** Log a trace via lv2_log_vprintf(). */ @@ -129,11 +127,11 @@ LV2_LOG_FUNC(2, 3) static inline int lv2_log_trace(LV2_Log_Logger* logger, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - const int ret = lv2_log_vprintf(logger, logger->Trace, fmt, args); - va_end(args); - return ret; + va_list args; + va_start(args, fmt); + const int ret = lv2_log_vprintf(logger, logger->Trace, fmt, args); + va_end(args); + return ret; } /** Log a warning via lv2_log_vprintf(). */ @@ -141,19 +139,19 @@ LV2_LOG_FUNC(2, 3) static inline int lv2_log_warning(LV2_Log_Logger* logger, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - const int ret = lv2_log_vprintf(logger, logger->Warning, fmt, args); - va_end(args); - return ret; + va_list args; + va_start(args, fmt); + const int ret = lv2_log_vprintf(logger, logger->Warning, fmt, args); + va_end(args); + return ret; } #ifdef __cplusplus -} /* extern "C" */ +} /* extern "C" */ #endif /** @} */ -#endif /* LV2_LOG_LOGGER_H */ +#endif /* LV2_LOG_LOGGER_H */ |