diff options
Diffstat (limited to 'src/nvim/api/private/defs.h')
-rw-r--r-- | src/nvim/api/private/defs.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/nvim/api/private/defs.h b/src/nvim/api/private/defs.h new file mode 100644 index 0000000000..a91907f4f8 --- /dev/null +++ b/src/nvim/api/private/defs.h @@ -0,0 +1,88 @@ +#ifndef NVIM_API_DEFS_H +#define NVIM_API_DEFS_H + +#include <stdint.h> +#include <stdbool.h> +#include <string.h> + +#define ARRAY_DICT_INIT {.size = 0, .items = NULL} +#define REMOTE_TYPE(type) typedef uint64_t 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(Buffer); +TYPED_ARRAY_OF(Window); +TYPED_ARRAY_OF(Tabpage); +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 + |