mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 19:06:31 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user