defs.h
Go to the documentation of this file.
1 #ifndef NVIM_API_PRIVATE_DEFS_H
2 #define NVIM_API_PRIVATE_DEFS_H
3 
4 #include <stdint.h>
5 #include <stdbool.h>
6 #include <string.h>
7 
8 #include "nvim/func_attr.h"
9 #include "nvim/types.h"
10 
11 #define ARRAY_DICT_INIT {.size = 0, .capacity = 0, .items = NULL}
12 #define STRING_INIT {.data = NULL, .size = 0}
13 #define OBJECT_INIT { .type = kObjectTypeNil }
14 #define ERROR_INIT { .type = kErrorTypeNone, .msg = NULL }
15 #define REMOTE_TYPE(type) typedef handle_T type
16 
17 #define ERROR_SET(e) ((e)->type != kErrorTypeNone)
18 
19 #ifdef INCLUDE_GENERATED_DECLARATIONS
20 # define ArrayOf(...) Array
21 # define DictionaryOf(...) Dictionary
22 #endif
23 
24 // Basic types
25 typedef enum {
29 } ErrorType;
30 
31 typedef enum {
35 } MessageType;
36 
38 #define NO_RESPONSE UINT64_MAX
39 
41 #define INTERNAL_CALL_MASK (((uint64_t)1) << (sizeof(uint64_t) * 8 - 1))
42 
44 #define VIML_INTERNAL_CALL INTERNAL_CALL_MASK
45 
47 #define LUA_INTERNAL_CALL (VIML_INTERNAL_CALL + 1)
48 
49 static inline bool is_internal_call(const uint64_t channel_id)
51 
57 static inline bool is_internal_call(const uint64_t channel_id)
58 {
59  return !!(channel_id & INTERNAL_CALL_MASK);
60 }
61 
62 typedef struct {
64  char *msg;
65 } Error;
66 
67 typedef bool Boolean;
68 typedef int64_t Integer;
69 typedef double Float;
70 
72 #define API_INTEGER_MAX INT64_MAX
73 
75 #define API_INTEGER_MIN INT64_MIN
76 
77 typedef struct {
78  char *data;
79  size_t size;
80 } String;
81 
82 REMOTE_TYPE(Buffer);
83 REMOTE_TYPE(Window);
84 REMOTE_TYPE(Tabpage);
85 
86 typedef struct object Object;
87 
88 typedef struct {
90  size_t size, capacity;
91 } Array;
92 
94 
95 typedef struct {
97  size_t size, capacity;
98 } Dictionary;
99 
100 typedef enum {
108  // EXT types, cannot be split or reordered, see #EXT_OBJECT_TYPE_SHIFT
112 } ObjectType;
113 
114 struct object {
116  union {
123  } data;
124 };
125 
129 };
130 
131 
132 #endif // NVIM_API_PRIVATE_DEFS_H
ObjectType
Definition: defs.h:100
double Float
Definition: defs.h:69
size_t size
Definition: defs.h:90
Float floating
Definition: defs.h:119
Definition: defs.h:107
#define REMOTE_TYPE(type)
Definition: defs.h:15
Array array
Definition: defs.h:121
Definition: defs.h:27
Definition: defs.h:110
char * msg
Definition: defs.h:64
size_t size
Definition: defs.h:79
char * data
Definition: defs.h:78
Definition: defs.h:77
Object * items
Definition: defs.h:89
Definition: defs.h:33
Definition: defs.h:32
bool Boolean
Definition: defs.h:67
Definition: defs.h:114
#define INTERNAL_CALL_MASK
Mask for all internal calls.
Definition: defs.h:41
ErrorType type
Definition: defs.h:63
Definition: defs.h:103
ErrorType
Definition: defs.h:25
Definition: defs.h:126
KeyValuePair * items
Definition: defs.h:96
Integer integer
Definition: defs.h:118
Definition: defs.h:62
size_t size
Definition: defs.h:97
ObjectType type
Definition: defs.h:115
Definition: defs.h:34
#define REAL_FATTR_CONST
Definition: func_attr.h:167
String key
Definition: defs.h:127
Definition: defs.h:88
String string
Definition: defs.h:120
int64_t Integer
Definition: defs.h:68
Definition: defs.h:105
union object::@0 data
Definition: defs.h:102
Definition: defs.h:109
Definition: defs.h:95
Definition: defs.h:104
static int REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE
Definition: typval_encode.c.h:258
MessageType
Definition: defs.h:31
Definition: defs.h:106
Definition: defs.h:26
Boolean boolean
Definition: defs.h:117
Definition: defs.h:28
Definition: defs.h:101
Dictionary dictionary
Definition: defs.h:122
Object value
Definition: defs.h:128
Definition: defs.h:111