aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2013-02-23 10:50:14 +0000
committerJosé Fonseca <[email protected]>2013-02-23 13:32:34 +0000
commit0d760a8160bbbd65a8b101fafb16fabd976ae0c9 (patch)
tree64f57b72470988ffbb1982cbbe75dcc9ca587ed1 /src/gallium
parent2fa9e4c97cd7580010a8aa2eb3026e8f2bdb0035 (diff)
util/dump: Use static assertion to detect string table size mismatches.
Suggested by Brian Paul. Could probably be extended to other enums. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/u_dump_defines.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_dump_defines.c b/src/gallium/auxiliary/util/u_dump_defines.c
index 2a996b276de..cc626877382 100644
--- a/src/gallium/auxiliary/util/u_dump_defines.c
+++ b/src/gallium/auxiliary/util/u_dump_defines.c
@@ -73,6 +73,23 @@ util_dump_enum_continuous(unsigned value,
}
+/**
+ * Same as DEFINE_UTIL_DUMP_CONTINUOUS but with static assertions to detect
+ * failures to update lists.
+ */
+#define DEFINE_UTIL_DUMP_CONTINUOUS_COUNT(_name, _count) \
+ const char * \
+ util_dump_##_name(unsigned value, boolean shortened) \
+ { \
+ STATIC_ASSERT(Elements(util_dump_##_name##_names) == _count); \
+ STATIC_ASSERT(Elements(util_dump_##_name##_short_names) == _count); \
+ if(shortened) \
+ return util_dump_enum_continuous(value, Elements(util_dump_##_name##_short_names), util_dump_##_name##_short_names); \
+ else \
+ return util_dump_enum_continuous(value, Elements(util_dump_##_name##_names), util_dump_##_name##_names); \
+ }
+
+
static const char *
util_dump_blend_factor_names[] = {
UTIL_DUMP_INVALID_NAME, /* 0x0 */
@@ -282,7 +299,7 @@ util_dump_tex_target_short_names[] = {
"cube_array",
};
-DEFINE_UTIL_DUMP_CONTINUOUS(tex_target)
+DEFINE_UTIL_DUMP_CONTINUOUS_COUNT(tex_target, PIPE_MAX_TEXTURE_TYPES)
static const char *