aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.c
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2014-05-23 15:49:44 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-05-23 16:06:58 -0300
commita842fe4dc1e0624a6332ee0fef40517e7925dfb4 (patch)
treea7a870dcff8ddbaaf00d7a4eb78b209dfc0b1ad5 /src/nvim/api/private/helpers.c
parentf70f9bfac1ae62828d222bc6ccb528e6e93be523 (diff)
downloadrneovim-a842fe4dc1e0624a6332ee0fef40517e7925dfb4.tar.gz
rneovim-a842fe4dc1e0624a6332ee0fef40517e7925dfb4.tar.bz2
rneovim-a842fe4dc1e0624a6332ee0fef40517e7925dfb4.zip
API: Refactor: Return handles instead of indexes
- Define specialized arrays for each remote object type - Implement msgpack_rpc functions for dealing with the new types - Refactor all functions dealing with buffers, windows and tabpages to return/accept handles instead of list indexes.
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r--src/nvim/api/private/helpers.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 64aa0a2013..c4340ddd89 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -4,6 +4,7 @@
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/defs.h"
+#include "nvim/api/private/handle.h"
#include "nvim/vim.h"
#include "nvim/buffer.h"
#include "nvim/window.h"
@@ -285,43 +286,29 @@ Object vim_to_object(typval_T *obj)
buf_T *find_buffer(Buffer buffer, Error *err)
{
- if (buffer > INT_MAX) {
- set_api_error("Invalid buffer id", err);
- return NULL;
- }
-
- buf_T *buf = buflist_findnr((int)buffer);
+ buf_T *rv = handle_get_buffer(buffer);
- if (buf == NULL) {
+ if (!rv) {
set_api_error("Invalid buffer id", err);
}
- return buf;
+ return rv;
}
win_T * find_window(Window window, Error *err)
{
- tabpage_T *tp;
- win_T *wp;
+ win_T *rv = handle_get_window(window);
- FOR_ALL_TAB_WINDOWS(tp, wp) {
- if (!--window) {
- return wp;
- }
+ if (!rv) {
+ set_api_error("Invalid window id", err);
}
- set_api_error("Invalid window id", err);
- return NULL;
+ return rv;
}
tabpage_T * find_tab(Tabpage tabpage, Error *err)
{
- if (tabpage > INT_MAX) {
- set_api_error("Invalid tabpage id", err);
- return NULL;
- }
-
- tabpage_T *rv = find_tabpage((int)tabpage);
+ tabpage_T *rv = handle_get_tabpage(tabpage);
if (!rv) {
set_api_error("Invalid tabpage id", err);