Debian Codegraph @

src/messages-codes.h.jinja

raw
1 // NOTE: This file has been generated automatically by “{{script}}”.
2 // Do not edit manually!
3 #pragma once
4
5 #include "config.h"
6
7 #include <stdint.h>
8
9 /*
10 * Macro sorcery: PREPEND_MESSAGE_ID enables the log functions to format messages
11 * with the message ID only if the ID is not 0 (XKB_LOG_MESSAGE_NO_ID).
12 * This avoid checking the ID value at run time.
13 *
14 * The trick resides in CHECK_ID:
15 * • CHECK_ID(0) expands to:
16 * ‣ SECOND(MATCH0, WITH_ID, unused)
17 * ‣ SECOND(unused,WITHOUT_ID, WITH_ID, unused)
18 * ‣ WITHOUT_ID
19 * • CHECK_ID(123) expands to:
20 * ‣ SECOND(MATCH123, WITH_ID, unused)
21 * ‣ WITH_ID
22 */
23 #define EXPAND(...) __VA_ARGS__ /* needed for MSVC compatibility */
24
25 #define JOIN_EXPAND(a, b) a##b
26 #define JOIN(a, b) JOIN_EXPAND(a, b)
27
28 #define SECOND_EXPAND(a, b, ...) b
29 #define SECOND(...) EXPAND(SECOND_EXPAND(__VA_ARGS__))
30
31 #define MATCH0 unused,WITHOUT_ID
32 #define CHECK_ID(value) SECOND(JOIN(MATCH, value), WITH_ID, unused)
33
34 #define FORMAT_MESSAGE_WITHOUT_ID(id, fmt) fmt
35 #define FORMAT_MESSAGE_WITH_ID(id, fmt) "[XKB-%03d] " fmt, id
36 #define PREPEND_MESSAGE_ID(id, fmt) JOIN(FORMAT_MESSAGE_, CHECK_ID(id))(id, fmt)
37
38 /**
39 * Set of verbosity levels
40 */
41 enum xkb_log_verbosity {
42 XKB_LOG_VERBOSITY_SILENT = -1,
43 XKB_LOG_VERBOSITY_MINIMAL = 0,
44 XKB_LOG_VERBOSITY_BRIEF = 1,
45 XKB_LOG_VERBOSITY_DETAILED = 5,
46 XKB_LOG_VERBOSITY_VERBOSE = 10,
47 XKB_LOG_VERBOSITY_COMPREHENSIVE = 11,
48 XKB_LOG_VERBOSITY_DEFAULT = XKB_LOG_VERBOSITY_MINIMAL,
49 };
50
51 /**
52 * Special case when no message identifier is defined.
53 */
54 #define XKB_LOG_MESSAGE_NO_ID 0
55
56 /**
57 * @name Codes of the log messages
58 */
59 enum xkb_message_code {
60 _XKB_LOG_MESSAGE_MIN_CODE = {{ entries[0].code }},
61 {% for entry in entries %}
62 /** {{ entry.description }} */
63 {{ entry.message_code_constant }} = {{ entry.code }},
64 {% endfor %}
65 _XKB_LOG_MESSAGE_MAX_CODE = {{ entries[-1].code }}
66 };
67
68 typedef uint32_t xkb_message_code_t;