mirror of
https://github.com/neovim/neovim.git
synced 2025-10-18 07:41:51 +00:00

- Add macros supporting typed arrays in the remote API - Refactor StringArray-related functions on top of the new macros
85 lines
1.5 KiB
C
85 lines
1.5 KiB
C
#ifndef NVIM_API_DEFS_H
|
|
#define NVIM_API_DEFS_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
|
|
#define REMOTE_TYPE(type) typedef Integer type
|
|
|
|
#define TYPED_ARRAY_OF(type) \
|
|
typedef struct { \
|
|
type *items; \
|
|
size_t size; \
|
|
} type##Array
|
|
|
|
// Basic types
|
|
typedef struct {
|
|
char msg[256];
|
|
bool set;
|
|
} Error;
|
|
|
|
typedef bool Boolean;
|
|
typedef int64_t Integer;
|
|
typedef double Float;
|
|
|
|
typedef struct {
|
|
char *data;
|
|
size_t size;
|
|
} String;
|
|
|
|
REMOTE_TYPE(Buffer);
|
|
REMOTE_TYPE(Window);
|
|
REMOTE_TYPE(Tabpage);
|
|
|
|
typedef struct object Object;
|
|
|
|
TYPED_ARRAY_OF(String);
|
|
|
|
typedef struct {
|
|
Integer row, col;
|
|
} Position;
|
|
|
|
typedef struct {
|
|
Object *items;
|
|
size_t size;
|
|
} Array;
|
|
|
|
typedef struct key_value_pair KeyValuePair;
|
|
|
|
typedef struct {
|
|
KeyValuePair *items;
|
|
size_t size;
|
|
} Dictionary;
|
|
|
|
typedef enum {
|
|
kObjectTypeNil,
|
|
kObjectTypeBoolean,
|
|
kObjectTypeInteger,
|
|
kObjectTypeFloat,
|
|
kObjectTypeString,
|
|
kObjectTypeArray,
|
|
kObjectTypeDictionary
|
|
} ObjectType;
|
|
|
|
struct object {
|
|
ObjectType type;
|
|
union {
|
|
Boolean boolean;
|
|
Integer integer;
|
|
Float floating;
|
|
String string;
|
|
Array array;
|
|
Dictionary dictionary;
|
|
} data;
|
|
};
|
|
|
|
struct key_value_pair {
|
|
String key;
|
|
Object value;
|
|
};
|
|
|
|
|
|
#endif // NVIM_API_DEFS_H
|
|
|