From 3a4736b83622fa4752e34fff6e966da05210c536 Mon Sep 17 00:00:00 2001 From: TimePath Date: Fri, 6 Nov 2015 09:37:51 +1100 Subject: [PATCH] Registry: checksum --- qcsrc/lib/registry.qh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/qcsrc/lib/registry.qh b/qcsrc/lib/registry.qh index 8da286195..7ff94fbaa 100644 --- a/qcsrc/lib/registry.qh +++ b/qcsrc/lib/registry.qh @@ -11,7 +11,11 @@ const int id##_MAX = max; \ noref entity _##id[id##_MAX], id##_first, id##_last; \ int id##_COUNT; \ - entity _##id##_from(int i, entity null) { if (i >= 0 && i < id##_COUNT) { entity e = _##id[i]; if (e) return e; } return null; } + entity _##id##_from(int i, entity null) { if (i >= 0 && i < id##_COUNT) { entity e = _##id[i]; if (e) return e; } return null; } \ + REGISTRY_CHECK(id) + +/** registered item identifier */ +.string registered_id; /** * Register a new entity with a global constructor. @@ -44,6 +48,7 @@ if (array##_COUNT >= array##_MAX) LOG_FATALF("Registry capacity exceeded (%s)", ftos(array##_MAX)); \ entity this = inst; \ ns##_##id = this; \ + this.registered_id = #id; \ this.fld = array##_COUNT; \ _##array[array##_COUNT++] = this; \ if (!array##_first) array##_first = this; \ @@ -90,4 +95,15 @@ heapsort(id##_COUNT - (skip), _REGISTRY_SWAP_##id, _REGISTRY_CMP_##id, NULL); \ } +#define REGISTRY_CHECK(id) \ + STATIC_INIT_LATE(Registry_check_##id) \ + { \ + string algo = "SHA256"; \ + string join = ":"; \ + string s = ""; \ + FOREACH(id, true, LAMBDA(s = strcat(s, join, it.registered_id))); \ + s = substring(s, strlen(join), -1); \ + LOG_TRACEF(#id ": %s\n[%s]\n", digest_hex(algo, s), s); \ + } + #endif -- 2.39.2