neovim/neovim — pull request #509 by tarruda (2014-04-10 19:45:51+00:00)
Title: [WIP/RFC] Msgpack remote api

This PR will add necessary infrastructure for implementing the remote msgpack API, but I've decoupled it from msgpack so we can reuse it with other protocols if necessary.

I've added prototypes and empty bodies for the functions I believe will be necessary to re-implement Vim python API(I will probably steal/adapt most of them from the current python interface but this is for another PR). Some function prototypes are still missing, mostly functions for talking to remote objects obtained by `bindeval` (those will also go in separate PRs). For now, the only new function is `push_keys` which is for sending keys to Neovim, but that is more useful for UIs.

While I'm following the architecture proposed in the fundraiser, this is open for suggestions, so feel free to comment.

It's worth mentioning that this does not implement the [official msgpack-rpc specification](http://wiki.msgpack.org/display/MSGPACK/RPC+specification), but something very similar. Some differences I can think of: Method names are replaced by integer ids and a metadata object is provided to clients that need to associate names with ids. This metadata object is obtained by calling the method '0' and will probably be the first method called by scripting engines(it can be used to build their wrappers for the API)

My reasons for not following the official specification 100% are these:

- This is a very small protocol that is also trivial to implement in languages with msgpack support
- Using integers instead of strings for dispatching function calls is more efficient.
- Since we provide a metadata object to associate names, it won't make any difference to API users. In fact, it's better because much validation can be done in the client.

Notice that a mapping between some C types and msgpack types is used by the code generator:

- char * -> raw
- char ** -> array (string array delimited by a NULL slot)
- uint32_t -> positive integer

These types are enough for now but later we'll probably add more.

@jszakmeister what do you think of the Cmake code I added? I tried to follow your examples(by not relying on shell scripts for example), but if I did something you don't approve just let me know.