Sync to Async Transformation

Lu Wang edited this page Dec 12, 2013 · 2 revisions
Clone this wiki locally

Vim has been ported to different environments, all of which have a non-busy synchronous sleep() function. Therefore it is possible to do something like this:


But it is not the case for JavaScript: JavaScript is a single threaded asynchronous language, and we have to transform the code somehow.

Most works are automatically done by web/transform.js, read the comments inside for more detail. But there are a few left, mainly function pointers, which cannot be automatically identified. Whenever vim.js crashes and you see callback function is not specified! in the browser console, congratulations, you have found one more async function at large.

Async functions can be wrapped with vimjs_async_cmd_call* functions, where * is the number of arguments. You may locate the function according to the stack trace in the console, and wrap it accordingly, and don't forget to include the vimjs.h header file and check the FEAT_GUI_BROWSER macro. Search for existing wrappers for examples.

Please file a pull request if you have fixed one of these issues.