aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-12-10 00:20:05 +0300
committerZyX <kp-pav@yandex.ru>2017-12-10 03:40:34 +0300
commit49dd615693c9f6d86a180371abcd09d32ac8aeca (patch)
treedac4d3f866d9562cfb3391577c92a316142f03e3
parentddce5bca03067ce7adf70496a3493cf12c016364 (diff)
downloadrneovim-49dd615693c9f6d86a180371abcd09d32ac8aeca.tar.gz
rneovim-49dd615693c9f6d86a180371abcd09d32ac8aeca.tar.bz2
rneovim-49dd615693c9f6d86a180371abcd09d32ac8aeca.zip
eval/typval: Add macros useful for hiding list item implementation
-rw-r--r--src/nvim/eval/typval.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h
index 9caf3f7b60..b00f43f625 100644
--- a/src/nvim/eval/typval.h
+++ b/src/nvim/eval/typval.h
@@ -456,6 +456,35 @@ extern bool tv_in_free_unref_items;
#define TV_LIST_ITER_CONST(l, li, code) \
_TV_LIST_ITER_MOD(const, l, li, code)
+// Below macros are macros to avoid duplicating code for functionally identical
+// const and non-const function variants.
+
+/// Get typval_T out of list item
+///
+/// @param[in] li List item to get typval_T from, must not be NULL.
+///
+/// @return Pointer to typval_T.
+#define TV_LIST_ITEM_TV(li) (&(li)->li_tv)
+
+/// Get next list item given the current one
+///
+/// @param[in] l List to get item from.
+/// @param[in] li List item to get typval_T from.
+///
+/// @return Pointer to the next item or NULL.
+#define TV_LIST_ITEM_NEXT(l, li) ((li)->li_next)
+
+/// Get previous list item given the current one
+///
+/// @param[in] l List to get item from.
+/// @param[in] li List item to get typval_T from.
+///
+/// @return Pointer to the previous item or NULL.
+#define TV_LIST_ITEM_PREV(l, li) ((li)->li_prev)
+// List argument is not used currently, but it is a must for lists implemented
+// as a pair (size(in list), array) without terminator - basically for lists on
+// top of kvec.
+
/// Iterate over a dictionary
///
/// @param[in] d Dictionary to iterate over.