aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/tables.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-13 12:01:52 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-13 12:01:52 -0400
commit981da7f0c6c47f66120482e7a7885cb5719d6959 (patch)
treec0d5bf912e7e477a0486120b8ac4aea8c49833f9 /src/stdlib/tables.h
parent3a8841af6d15763e4c322c2c7671582ed6c3b006 (diff)
parentb4f2d03db2cd20688d6bb537904998e997bc48aa (diff)
Merge branch 'optional-list-indexing' into dev
Diffstat (limited to 'src/stdlib/tables.h')
-rw-r--r--src/stdlib/tables.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/stdlib/tables.h b/src/stdlib/tables.h
index 208bf6b2..129aa5ec 100644
--- a/src/stdlib/tables.h
+++ b/src/stdlib/tables.h
@@ -49,6 +49,18 @@ void *Table$get(Table_t t, const void *key, const TypeInfo_t *type);
val_t *nonnull_var = Table$get(t, &k, info_expr); \
nonnull_var ? nonnull_expr : null_expr; \
})
+#define Table$get_checked(table_expr, key_t, val_t, key_expr, start, end, info_expr) \
+ ({ \
+ const Table_t t = table_expr; \
+ const key_t key = key_expr; \
+ const TypeInfo_t *info = info_expr; \
+ val_t *value = Table$get(t, &key, info); \
+ if (unlikely(value == NULL)) \
+ fail_source(__SOURCE_FILE__, start, end, \
+ "This key was not found in the table: ", generic_as_text(&key, false, info->TableInfo.key), \
+ "\n"); \
+ *value; \
+ })
#define Table$get_or_setdefault(table_expr, key_t, val_t, key_expr, default_expr, info_expr) \
({ \
Table_t *t = table_expr; \