aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/msgpack_rpc
Commit message (Collapse)AuthorAge
* msgpack_rpc: Allocate empty string in msgpack_rpc_to_objectJames McCoy2016-11-29
| | | | | | | | | | STR_CASE previously used a NULL data pointer for the String object, but this pushes the NULL checks to the rest of the code. Instead, allocating an empty string solves the same issue of there not being any data but ensures that we're not passing NULL to functions that don't expect it. Closes #5627
* Avoid serializing NULL string through msgpackJames McCoy2016-11-23
| | | | | | Attempting to serialize a NULL string through msgpack results in msgpack_sbuffer_write attempting to memcpy from a NULL pointer, which is undefined behavior.
* lintJames McCoy2016-11-02
|
* object_to_vim: Fix buffer/window/tabpage conversion on BE systemsJames McCoy2016-11-02
| | | | | | | | | | | Since data.integer is a different (larger) integer type than data.{buffer,window,tabpage}, we cannot abuse the union by using data.integer to access the value for all 4 types. Instead, remove the {buffer,window,tabpage} members and always use the integer member. In order to accomodate this, perform distinct validation and coercion between the Integer type and Buffer/Window/Tabpage types in object_to_vim, msgpack_rpc helpers, and gendispatch.lua.
* api: call multiple methods atomically (useful in async contexts)Björn Linse2016-10-22
| | | | remove unused response_id parameter of handle_nvim_... helpers
* event/multiqueue.c: Rename "queue" to "multiqueue".Justin M. Keyes2016-10-02
| | | | | | | | | | | | | | `lib/queue.h` implements a basic queue. `event/queue.c` implements a specialized data structure on top of lib/queue.h; it is not a "normal" queue. Rename the specialized multi-level queue implemented in event/queue.c to "multiqueue", to avoid confusion when reading the code. Before this change one can eventually notice that "macros (uppercase symbols) are for the normal queue, lowercase operations are for the multi-level queue", but that is unnecessary friction for new developers (or existing developers just visiting this part of the codebase).
* api: fix leak when a api function is incorrectly called with a list.Björn Linse2016-08-31
| | | | This applies both to msgpack-rpc and eval.
* api: unify buffer numbers and window ids with handlesBjörn Linse2016-08-31
| | | | also allow handle==0 meaning curbuf/curwin/curtab
* api: rename "msgpack_rpc/defs.h" to "api/private/dispatch.h" and use the ↵Björn Linse2016-08-31
| | | | header generator.
* job control: reuse common job code for rpc jobsBjörn Linse2016-08-20
| | | | This makes stderr and exit callbacks work for rpc jobs
* stream: set data together with callbackBjörn Linse2016-08-20
|
* server_init: Handle server_address_new() failure.Justin M. Keyes2016-07-18
| | | | Closes #3364
* *: Fix linter errorsZyX2016-06-24
| | | | | | | | | Also adds one exception to linter rules: typedef struct { kvec_t(Object) stack; } EncodedData; is completely valid (from the style guide point of view) code.
* msgpack_rpc: Fix crash in log_server_msgZyX2016-06-24
| | | | | | | | | | | It appears that used msgpack library is not able to parse back message created by msgpack_rpc_from_object() if nesting level is too high, so log_server_msg now cares about msgpack_unpack_next() return value. Also error message from server_notifications_spec.lua is not readable if something is wrong (though at least now it does not crash when parsing deeply nested structures). log_server_msg() in the test reports [msgpack-rpc] nvim -> client(1) [error] "parse error"
* msgpack_rpc: Also make msgpack_from_*/msgpack_to_* functions not recurZyX2016-06-24
| | | | | | This removes some stack overflows in new test regarding deeply nested variables. Now in place of crashing vim_to_object/msgpack_rpc_from_object/etc it crashes clear_tv with stack overflow.
* *: Fix errors from new linter checksZyX2016-06-11
|
* Merge pull request #4844 from ZyX-I/rename-main-loopJustin M. Keyes2016-05-31
|\ | | | | Rename main loop variable from loop to main_loop
| * *: Rename main loop variable from loop to main_loopZyX2016-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current name is inappropriate for the following reasons: 1. It is often masked by local `loop` variables. 2. It cannot be searched for. There are many `loop` variables where `loop` is some local variable. There are many cases when “loop” word is used in a comment. 3. It is in any case bad idea to use a generic name as a name of the global variable. Best if global has module prefix: this is why it is in `main.h`: `main_loop` both stands for “a main loop” and “a loop defined in `main.*`”. Since I have no idea how to list every occurrence of this variable method used to rename it is “remove it from globals.h, try to compile, fix errors”. Thus if some occurrence was hidden under false `#if` branch it was not replaced.
* | lib/kvec: Do not use kv_init unless neededZyX2016-05-30
| |
* | lib/kvec: Remove useless type argument from kv_push macrosZyX2016-05-30
|/
* api: refactor remote ui to use API dispatch generationBjörn Linse2016-05-27
|
* syntax: Add support for the "special" color used for undercurlsAdnoC2016-05-17
|
* *: Fix new linter errorsZyX2016-05-01
| | | | Originally there were 128 new errors, so I thought this is a good idea to fix all of them. Of course, this commit also fixes many suppressed errors.
* Merge tempfile.c back into fileio.cJurica Bradaric2016-04-20
|
* *: Make set_vim_var_\* functions have proper argument typesZyX2016-04-18
|
* bufhl: fix unittests and lintBjörn Linse2016-02-23
| | | | msgpack_rpc_dispatch doesn't exist anymore
* helpers.c: Handle msgpack str/bin objects with length 0 correctlyoni-link2015-12-21
| | | | | | | | | | | When converting a msgpack object to a String object, strings (and byte arrays) with length 0 are handled as errors. This is fixed by always using the msgpack data pointer as a valid pointer. For a NULL pointer there is nothing to copy. Test by @snoe Fixes #3844
* Allow server_start to accept a NULL argumentRui Abreu Ferreira2015-10-18
| | | | | | Return 1 if the endpoint argument is NULL, server_start() can get a NULL value when using server_address_new() or vim_tempname(). Removed the function attribute.
* Implement server_address_new()Rui Abreu Ferreira2015-10-18
| | | | | | | | | | | | | | | | When creating a local socket/pipe (server_start()) Neovim used vim_tempname() to generate a unique socket path. For Windows UNIX filepaths cannot be used as pipe names (they must start with \\.\pipe\). This commit replaces the use of vim_tempname() for server addresses with server_address_new(). server_address_new() generates unique names for local sockets/pipes - for UNIX it uses vim_tempname(), for Windows generates names in the form \\.\pipe\nvim-PID-COUNTER where PID is the current process id, and COUNTER is a static uint32_t counter incremented with every call. This function is now used for server_start() and server_init() when no address is available.
* api: represent api type String as msgpack type STR. closes #1250Björn Linse2015-10-08
|
* log: Make logging thread-safeThiago de Arruda2015-09-06
|
* Windows: avoid "uv_" naming conflicts. #3225Seth Jackson2015-08-27
|
* main: Initialize event loop before command_line_scanThiago de Arruda2015-08-21
| | | | | | | | The call to `event_init()` was too late. `command_line_scan()` in `main()` could already need the loop initialized. Ref https://github.com/neovim/neovim/issues/3045#issuecomment-123405833. A consequence of this change is that it was necessary to move the `channel_from_stdio()` call to `command_line_scan()` when embedded_mode is set.
* tui/remote_ui: Fix some regressionsThiago de Arruda2015-08-21
| | | | | | | | - Explicitly set the SignalWatcher event queue. Without this, the watcher will publish events to the fast queue, resulting in resize bugs for certain terminals(#2322). - Set `async = false` to the `remote_ui_attach` handler(It was a deferred before, this is the new equivalent)
* Notify attached UIs whenever menus changeRobin Allen2015-08-21
| | | | | This adds a redraw notification "update_menu" which is sent whenever Vim's menus are changed by the :menu command and friends.
* rstream: Pass read count to read eventsThiago de Arruda2015-08-13
| | | | This is necessary to keep events in the same order received from the OS.
* event: Refactor async event processingThiago de Arruda2015-08-13
| | | | | | | | | | - Improve the implementation of deferred/immediate events. - Use the new queue module to change how/when events are queued/processed by giving a private queue to each emitter. - Immediate events(which only exist to break uv_run recursion) are now represented in the `loop->fast_events` queue. - Events pushed to child queues are propagated to the event loop main queue and processed as K_EVENT keys.
* process: Pass loop reference during initializationThiago de Arruda2015-08-13
| | | | | Change the API so that it is passed to {uv,pty}_process_init instead of `process_spawn`.
* msgpack: Replace FUNC_ATTR_DEFERRED by FUNC_ATTR_ASYNCThiago de Arruda2015-08-13
| | | | | | | | | | | API functions exposed via msgpack-rpc now fall into two categories: - async functions, which are executed as soon as the request is parsed - sync functions, which are invoked in nvim main loop when processing the `K_EVENT special key Only a few functions which can be safely executed in any context are marked as async.
* channel.c: Only free a channel after close callbacks are executed #3132oni-link2015-08-05
| | | | | | | | | | | | parse_msgpack() closes a channel's stream on EOF error and the stream's close callback close_cb() is queued for the next libuv loop iteration. When parse_msgpack() returns, it has freed the channel and the queued stream callback will access this freed memory. To prevent this, increase the channel's reference count and let the stream's close callback call decref(). Fixes #3128
* tui: Use underline cursor in Replace modeOmar Sandoval2015-07-26
| | | | | | | This is a port of my original contribution to Vim, added in 7.4.687 (https://github.com/vim/vim/commit/v7-4-687). The TUI code has been heavily refactored (see esp. 25ceadab37edba13f5afa78d8b4723da03ef35f0), so this required some translation, but the logic is the same.
* api: Simplify UI API on mode changeOmar Sandoval2015-07-26
| | | | | | | Currently, there are two functions in the UI API that are called when the mode changes: insert_mode() and normal_mode(). These can be folded into a single mode_change() entrypoint which can do whatever it wants based on the mode it is passed, limited to INSERT and NORMAL for now.
* job: Replace by a better process abstraction layerThiago de Arruda2015-07-17
| | | | | | | | | | | | | - New libuv/pty process abstraction with simplified API and no globals. - Remove nvim/os/job*. Jobs are now a concept that apply only to programs spawned by vimscript job* functions. - Refactor shell.c/channel.c to use the new module, which brings a number of advantages: - Simplified API, less code - No slots in the user job table are used - Not possible to acidentally receive data from vimscript - Implement job table in eval.c, which is now a hash table with unilimited job slots and unique job ids.
* server: Extract most logic into the new socket abstractionThiago de Arruda2015-07-17
| | | | | | - Move event loop code into event/socket - Reimplement server.c on top of the new SocketWatcher class - Adapt msgpack_rpc/channel.c
* rstream/wstream: Unify structures and simplify APIThiago de Arruda2015-07-17
| | | | | | | | | | | | | - Simplify RStream/WStream API and make it more consistent with libuv. - Move into the event loop layer(event subdirectory) - Remove uv_helpers module. - Simplify job/process internal modules/API. - Unify RStream and WStream into a single structure. This is necessary because libuv streams can be readable and writable at the same time(and because the uv_helpers.c hack to associate multiple streams with libuv handle was removed) - Make struct definition public, allowing more flexible/simple memory management by users of the module. - Adapt channel/job modules to cope with the changes.
* event loop: New abstraction layer with refactored time/signal APIThiago de Arruda2015-07-17
| | | | | | | | | | - Add event loop abstraction module under src/nvim/event. The src/nvim/event/loop module replaces src/nvim/os/event - Remove direct dependency on libuv signal/timer API and use the new abstraction instead. - Replace all references to uv_default_loop() by &loop.uv, a new global variable that wraps libuv main event loop but allows the event loop functions to be reused in other contexts.
* rbuffer: Reimplement as a ring buffer and decouple from rstreamThiago de Arruda2015-07-01
| | | | | | | | | | | | | | | | | | | | Extract the RBuffer class from rstream.c and reimplement it as a ring buffer, a more efficient version that doesn't need to relocate memory. The old rbuffer_read/rbuffer_write interfaces are kept for simple reading/writing, and the RBUFFER_UNTIL_{FULL,EMPTY} macros are introduced to hide wrapping logic when more control is required(such as passing the buffer pointer to a library function that writes directly to the pointer) Also add a basic infrastructure for writing helper C files that are only compiled in the unit test library, and use this to write unit tests for RBuffer which contains some macros that can't be accessed directly by luajit. Helped-by: oni-link <knil.ino@gmail.com> Reviewed-by: oni-link <knil.ino@gmail.com> Reviewed-by: Scott Prager <splinterofchaos@gmail.com> Reviewed-by: Justin M. Keyes <justinkz@gmail.com> Reviewed-by: Michael Reed <m.reed@mykolab.com>
* ASan: Fix "null pointer passed for argument declared to never be null". #2925Florian Walch2015-06-30
| | | | | | | | Arguments passed to xmemdupz() are sometimes NULL, but xmemdupz() has FUNC_ATTR_NONNULL_ALL. Check pointers for NULL before calling xmemdupz(). Resolves #2533.
* getenv: return NULL if empty #2574Scott Prager2015-05-29
| | | | | | Making an environment variable empty can be a way of unsetting it for platforms that don't support unsetenv(). In most cases, we treat empty variables as having been unset. For all others, use os_env_exists().
* msgpack-rpc: handle failure to convert method arguments #2664Björn Linse2015-05-19
|