1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#ifndef NVIM_API_PRIVATE_DEFS_H
#define NVIM_API_PRIVATE_DEFS_H
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#define ARRAY_DICT_INIT {.size = 0, .items = NULL}
#define STRING_INIT {.data = NULL, .size = 0}
#define OBJECT_INIT { .type = kObjectTypeNil }
#define POSITION_INIT { .row = 0, .col = 0 }
#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, capacity;
} Array;
typedef struct key_value_pair KeyValuePair;
typedef struct {
KeyValuePair *items;
size_t size, capacity;
} Dictionary;
typedef enum {
kObjectTypeNil,
kObjectTypeBoolean,
kObjectTypeInteger,
kObjectTypeFloat,
kObjectTypeString,
kObjectTypeBuffer,
kObjectTypeWindow,
kObjectTypeTabpage,
kObjectTypeArray,
kObjectTypeDictionary,
kObjectTypePosition,
kObjectTypeStringArray,
kObjectTypeBufferArray,
kObjectTypeWindowArray,
kObjectTypeTabpageArray,
} ObjectType;
struct object {
ObjectType type;
union {
Boolean boolean;
Integer integer;
Float floating;
String string;
Buffer buffer;
Window window;
Tabpage tabpage;
Array array;
Dictionary dictionary;
Position position;
StringArray stringarray;
BufferArray bufferarray;
WindowArray windowarray;
TabpageArray tabpagearray;
} data;
};
struct key_value_pair {
String key;
Object value;
};
#endif // NVIM_API_PRIVATE_DEFS_H
|