provider: Add support functions for calling external interpreters

This uses the provider module infrastructure to implement common code for
vimscript commands/functions that need to communicate with external
interpreters, eg: pydo, rubydo, pyfile, rubyfile, etc.
This commit is contained in:
Thiago de Arruda
2014-06-26 18:22:34 -03:00
parent 887d32e546
commit 8a091e7f5c
2 changed files with 59 additions and 0 deletions

View File

@@ -83,6 +83,7 @@
#include "nvim/os/time.h"
#include "nvim/os/channel.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/defs.h"
#include "nvim/os/msgpack_rpc_helpers.h"
#include "nvim/os/dl.h"
#include "nvim/os/provider.h"
@@ -19125,3 +19126,20 @@ static void apply_job_autocmds(Job *job, char *name, char *type, char *str)
apply_autocmds(EVENT_JOBACTIVITY, (uint8_t *)name, NULL, TRUE, NULL);
}
static void script_host_eval(char *method, typval_T *argvars, typval_T *rettv)
{
Object result = provider_call(method, vim_to_object(argvars));
if (result.type == kObjectTypeNil) {
return;
}
Error err = {.set = false};
object_to_vim(result, rettv, &err);
msgpack_rpc_free_object(result);
if (err.set) {
EMSG("Error converting value back to vim");
}
}