aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.h
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-08-01 14:01:19 +0200
committerbfredl <bjorn.linse@gmail.com>2023-08-07 13:11:15 +0200
commit7bc93e0e2f246dd78026a3472d929a0fe450f70d (patch)
tree9e5b99830c3f08e0ffd75c7a0533b39033490a5b /src/nvim/api/private/helpers.h
parentc01e624b0762b24a4988bf9474a57d5b6278d180 (diff)
downloadrneovim-7bc93e0e2f246dd78026a3472d929a0fe450f70d.tar.gz
rneovim-7bc93e0e2f246dd78026a3472d929a0fe450f70d.tar.bz2
rneovim-7bc93e0e2f246dd78026a3472d929a0fe450f70d.zip
refactor(api): use typed keysets
Initially this is just for geting rid of boilerplate, but eventually the types could get exposed as metadata
Diffstat (limited to 'src/nvim/api/private/helpers.h')
-rw-r--r--src/nvim/api/private/helpers.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index cb74c655cd..95e5cf67c8 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -63,8 +63,9 @@
#define NIL ((Object)OBJECT_INIT)
#define NULL_STRING ((String)STRING_INIT)
-// currently treat key=vim.NIL as if the key was missing
-#define HAS_KEY(o) ((o).type != kObjectTypeNil)
+#define HAS_KEY(d, typ, key) (((d)->is_set__##typ##_ & (1 << KEYSET_OPTIDX_##typ##__##key)) != 0)
+
+#define GET_BOOL_OR_TRUE(d, typ, key) (HAS_KEY(d, typ, key) ? (d)->key : true)
#define PUT(dict, k, v) \
kv_push(dict, ((KeyValuePair) { .key = cstr_to_string(k), .value = v }))