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 {
33  // Per msgpack-rpc spec.
37 } MessageType;
38 
40 #define INTERNAL_CALL_MASK (((uint64_t)1) << (sizeof(uint64_t) * 8 - 1))
41 
43 #define VIML_INTERNAL_CALL INTERNAL_CALL_MASK
44 
46 #define LUA_INTERNAL_CALL (VIML_INTERNAL_CALL + 1)
47 
48 static inline bool is_internal_call(const uint64_t channel_id)
50 
56 static inline bool is_internal_call(const uint64_t channel_id)
57 {
58  return !!(channel_id & INTERNAL_CALL_MASK);
59 }
60 
61 typedef struct {
63  char *msg;
64 } Error;
65 
66 typedef bool Boolean;
67 typedef int64_t Integer;
68 typedef double Float;
69 
71 #define API_INTEGER_MAX INT64_MAX
72 
74 #define API_INTEGER_MIN INT64_MIN
75 
76 typedef struct {
77  char *data;
78  size_t size;
79 } String;
80 
81 REMOTE_TYPE(Buffer);
82 REMOTE_TYPE(Window);
83 REMOTE_TYPE(Tabpage);
84 
85 typedef struct object Object;
86 
87 typedef struct {
89  size_t size, capacity;
90 } Array;
91 
93 
94 typedef struct {
96  size_t size, capacity;
97 } Dictionary;
98 
99 typedef enum {
108  // EXT types, cannot be split or reordered, see #EXT_OBJECT_TYPE_SHIFT
112 } ObjectType;
113 
114 struct object {
116  union {
124  } data;
125 };
126 
130 };
131 
132 
133 #endif // NVIM_API_PRIVATE_DEFS_H
ObjectType
Definition: defs.h:99
double Float
Definition: defs.h:68
size_t size
Definition: defs.h:89
Float floating
Definition: defs.h:119
Definition: defs.h:106
#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:63
size_t size
Definition: defs.h:78
char * data
Definition: defs.h:77
Definition: defs.h:76
Object * items
Definition: defs.h:88
Definition: defs.h:35
Definition: defs.h:34
Definition: defs.h:32
bool Boolean
Definition: defs.h:66
Definition: defs.h:114
#define INTERNAL_CALL_MASK
Mask for all internal calls.
Definition: defs.h:40
ErrorType type
Definition: defs.h:62
Definition: defs.h:102
ErrorType
Definition: defs.h:25
LuaRef luaref
Definition: defs.h:123
Definition: defs.h:127
KeyValuePair * items
Definition: defs.h:95
Integer integer
Definition: defs.h:118
Definition: defs.h:61
size_t size
Definition: defs.h:96
ObjectType type
Definition: defs.h:115
Definition: defs.h:107
Definition: defs.h:36
#define REAL_FATTR_CONST
Definition: func_attr.h:167
String key
Definition: defs.h:128
Definition: defs.h:87
String string
Definition: defs.h:120
int64_t Integer
Definition: defs.h:67
Definition: defs.h:104
union object::@0 data
Definition: defs.h:101
Definition: defs.h:109
Definition: defs.h:94
Definition: defs.h:103
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:105
Definition: defs.h:26
Boolean boolean
Definition: defs.h:117
int LuaRef
Definition: types.h:22
Definition: defs.h:28
Definition: defs.h:100
Dictionary dictionary
Definition: defs.h:122
Object value
Definition: defs.h:129
Definition: defs.h:111