diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-06-22 08:50:18 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-06-23 23:16:20 -0400 |
commit | d5329c0331a4e899ea88277b745df8d1bf3a99fa (patch) | |
tree | 200c2403379bf041d27b7cf2634b8304ed8a1976 /src/nvim/eval/typval.c | |
parent | 24e0c16fd6cb33a399772330cb80dfa4c1306284 (diff) | |
download | rneovim-d5329c0331a4e899ea88277b745df8d1bf3a99fa.tar.gz rneovim-d5329c0331a4e899ea88277b745df8d1bf3a99fa.tar.bz2 rneovim-d5329c0331a4e899ea88277b745df8d1bf3a99fa.zip |
vim-patch:8.1.1437: code to handle callbacks is duplicated
Problem: Code to handle callbacks is duplicated.
Solution: Add callback_T and functions to deal with it.
https://github.com/vim/vim/commit/3a97bb3f0f8bd118ae23f1c97e55d84ff42eef20
Port Vim's put_callback() as callback_put()
because Neovim's naming convention is {type}_{action},
not {action}_{type}.
Renaming put_callback type as PutCallback.
https://neovim.io/develop/style-guide.xml#Type_Names
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r-- | src/nvim/eval/typval.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 61de83fc21..4118ec407c 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1164,6 +1164,21 @@ void callback_free(Callback *callback) callback->type = kCallbackNone; } +/// Copy a callback into a typval_T. +void callback_put(Callback *cb, typval_T *tv) + FUNC_ATTR_NONNULL_ALL +{ + if (cb->type == kCallbackPartial) { + tv->v_type = VAR_PARTIAL; + tv->vval.v_partial = cb->data.partial; + cb->data.partial->pt_refcount++; + } else if (cb->type == kCallbackFuncref) { + tv->v_type = VAR_FUNC; + tv->vval.v_string = vim_strsave(cb->data.funcref); + func_ref(cb->data.funcref); + } +} + /// Remove watcher from a dictionary /// /// @param dict Dictionary to remove watcher from. |