mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
API: Refactor: Use macro for initializing all arrays
This commit is contained in:
parent
1156360fe7
commit
9815688fbd
@ -71,7 +71,7 @@ void buffer_set_line(Buffer buffer, Integer index, String line, Error *err)
|
|||||||
|
|
||||||
void buffer_del_line(Buffer buffer, Integer index, Error *err)
|
void buffer_del_line(Buffer buffer, Integer index, Error *err)
|
||||||
{
|
{
|
||||||
StringArray array = {.size = 0};
|
StringArray array = ARRAY_DICT_INIT;
|
||||||
buffer_set_slice(buffer, index, index, true, true, array, err);
|
buffer_set_slice(buffer, index, index, true, true, array, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ StringArray buffer_get_slice(Buffer buffer,
|
|||||||
Boolean include_end,
|
Boolean include_end,
|
||||||
Error *err)
|
Error *err)
|
||||||
{
|
{
|
||||||
StringArray rv = {.size = 0};
|
StringArray rv = ARRAY_DICT_INIT;
|
||||||
buf_T *buf = find_buffer(buffer, err);
|
buf_T *buf = find_buffer(buffer, err);
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define ARRAY_DICT_INIT {.size = 0, .items = NULL}
|
||||||
#define REMOTE_TYPE(type) typedef uint64_t type
|
#define REMOTE_TYPE(type) typedef uint64_t type
|
||||||
|
|
||||||
#define TYPED_ARRAY_OF(type) \
|
#define TYPED_ARRAY_OF(type) \
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
WindowArray tabpage_get_windows(Tabpage tabpage, Error *err)
|
WindowArray tabpage_get_windows(Tabpage tabpage, Error *err)
|
||||||
{
|
{
|
||||||
WindowArray rv = {.size = 0};
|
WindowArray rv = ARRAY_DICT_INIT;
|
||||||
tabpage_T *tab = find_tab(tabpage, err);
|
tabpage_T *tab = find_tab(tabpage, err);
|
||||||
|
|
||||||
if (!tab) {
|
if (!tab) {
|
||||||
|
@ -81,7 +81,7 @@ Integer vim_strwidth(String str, Error *err)
|
|||||||
|
|
||||||
StringArray vim_list_runtime_paths(void)
|
StringArray vim_list_runtime_paths(void)
|
||||||
{
|
{
|
||||||
StringArray rv = {.size = 0};
|
StringArray rv = ARRAY_DICT_INIT;
|
||||||
uint8_t *rtp = p_rtp;
|
uint8_t *rtp = p_rtp;
|
||||||
|
|
||||||
if (*rtp == NUL) {
|
if (*rtp == NUL) {
|
||||||
@ -192,7 +192,7 @@ void vim_err_write(String str)
|
|||||||
|
|
||||||
BufferArray vim_get_buffers(void)
|
BufferArray vim_get_buffers(void)
|
||||||
{
|
{
|
||||||
BufferArray rv = {.size = 0};
|
BufferArray rv = ARRAY_DICT_INIT;
|
||||||
buf_T *b = firstbuf;
|
buf_T *b = firstbuf;
|
||||||
|
|
||||||
while (b) {
|
while (b) {
|
||||||
@ -242,7 +242,7 @@ void vim_set_current_buffer(Buffer buffer, Error *err)
|
|||||||
|
|
||||||
WindowArray vim_get_windows(void)
|
WindowArray vim_get_windows(void)
|
||||||
{
|
{
|
||||||
WindowArray rv = {.size = 0};
|
WindowArray rv = ARRAY_DICT_INIT;
|
||||||
tabpage_T *tp;
|
tabpage_T *tp;
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ void vim_set_current_window(Window window, Error *err)
|
|||||||
|
|
||||||
TabpageArray vim_get_tabpages(void)
|
TabpageArray vim_get_tabpages(void)
|
||||||
{
|
{
|
||||||
TabpageArray rv = {.size = 0};
|
TabpageArray rv = ARRAY_DICT_INIT;
|
||||||
tabpage_T *tp = first_tabpage;
|
tabpage_T *tp = first_tabpage;
|
||||||
|
|
||||||
while (tp) {
|
while (tp) {
|
||||||
|
@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
|
|
||||||
#define ARRAY_DICT_INIT {.size = 0, .items = NULL}
|
|
||||||
|
|
||||||
/// Validates the basic structure of the msgpack-rpc call and fills `res`
|
/// Validates the basic structure of the msgpack-rpc call and fills `res`
|
||||||
/// with the basic response structure.
|
/// with the basic response structure.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user