From ed99198ff1a3c2b6aad88b03e838a1337f83c4dc Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 23 May 2014 15:49:30 -0300 Subject: API: Refactor: Register/unregister created/destroyed buffers - Add the 'handle' field to `buf_T` - Add declare/implement functions for registering/unregistering/retrieving buffers - Register/unregister buffers when they are created/destroyed. --- src/nvim/api/private/handle.c | 5 +++++ src/nvim/api/private/handle.h | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'src/nvim/api') diff --git a/src/nvim/api/private/handle.c b/src/nvim/api/private/handle.c index 3bf519bc58..97f5cd88b5 100644 --- a/src/nvim/api/private/handle.c +++ b/src/nvim/api/private/handle.c @@ -26,6 +26,11 @@ map_del(uint64_t)(name##_handles, name->handle); \ } +static uint64_t next_handle = 1; + +HANDLE_IMPL(buf_T, buffer) + void handle_init() { + HANDLE_INIT(buffer); } diff --git a/src/nvim/api/private/handle.h b/src/nvim/api/private/handle.h index b9ed507ce9..846b20dff2 100644 --- a/src/nvim/api/private/handle.h +++ b/src/nvim/api/private/handle.h @@ -2,13 +2,17 @@ #define NVIM_API_HANDLE_H #include "nvim/vim.h" +#include "nvim/buffer_defs.h" #define HANDLE_DECLS(type, name) \ type *handle_get_##name(uint64_t handle); \ void handle_register_##name(type *name); \ void handle_unregister_##name(type *name); +HANDLE_DECLS(buf_T, buffer) + void handle_init(void); + #endif // NVIM_API_HANDLE_H -- cgit