mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 10:56:31 +00:00
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.
3a97bb3f0f
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
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user