diff options
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r-- | src/nvim/eval/typval.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 2c76741891..97726da5f4 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1205,6 +1205,30 @@ void callback_copy(Callback *dest, Callback *src) } } +/// Generate a string description of a callback +char *callback_to_string(Callback *cb) +{ + size_t msglen = 100; + char *msg = (char *)xmallocz(msglen); + + switch (cb->type) { + case kCallbackLua: + snprintf(msg, msglen, "<lua: %d>", cb->data.luaref); + break; + case kCallbackFuncref: + // TODO(tjdevries): Is this enough space for this? + snprintf(msg, msglen, "<vim function: %s>", cb->data.funcref); + break; + case kCallbackPartial: + snprintf(msg, msglen, "<vim partial: %s>", cb->data.partial->pt_name); + break; + default: + snprintf(msg, msglen, "%s", ""); + break; + } + return msg; +} + /// Remove watcher from a dictionary /// /// @param dict Dictionary to remove watcher from. |