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 <stdbool.h>
5 #include <stdint.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 # define Dict(name) KeyDict_##name
23 #endif
24 
25 // Basic types
26 typedef enum {
30 } ErrorType;
31 
32 typedef enum {
34  // Per msgpack-rpc spec.
38 } MessageType;
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 {
109  // EXT types, cannot be split or reordered, see #EXT_OBJECT_TYPE_SHIFT
113 } ObjectType;
114 
115 struct object {
117  union {
125  } data;
126 };
127 
131 };
132 
133 typedef Object *(*field_hash)(void *retval, const char *str, size_t len);
134 typedef struct {
135  char *str;
136  size_t ptr_off;
137 } KeySetLink;
138 
139 #ifdef INCLUDE_GENERATED_DECLARATIONS
140 # include "keysets_defs.generated.h"
141 #endif
142 
143 #endif // NVIM_API_PRIVATE_DEFS_H
Error::msg
char * msg
Definition: defs.h:64
object
Definition: defs.h:115
retval
long retval
Definition: funcs.c:8556
kMessageTypeUnknown
@ kMessageTypeUnknown
Definition: defs.h:33
types.h
kMessageTypeResponse
@ kMessageTypeResponse
Definition: defs.h:36
kErrorTypeException
@ kErrorTypeException
Definition: defs.h:28
Boolean
bool Boolean
Definition: defs.h:67
MessageType
MessageType
Definition: defs.h:32
Error
Definition: defs.h:62
Float
double Float
Definition: defs.h:69
object::array
Array array
Definition: defs.h:122
Error::type
ErrorType type
Definition: defs.h:63
ObjectType
ObjectType
Definition: defs.h:100
Array
Definition: defs.h:88
key_value_pair
Definition: defs.h:128
object::data
union object::@8 data
Array::items
Object * items
Definition: defs.h:89
LuaRef
int LuaRef
Definition: types.h:23
ErrorType
ErrorType
Definition: defs.h:26
object::integer
Integer integer
Definition: defs.h:119
Integer
int64_t Integer
Definition: defs.h:68
kObjectTypeLuaRef
@ kObjectTypeLuaRef
Definition: defs.h:108
object::type
ObjectType type
Definition: defs.h:116
key_value_pair::key
String key
Definition: defs.h:129
kObjectTypeDictionary
@ kObjectTypeDictionary
Definition: defs.h:107
kObjectTypeBoolean
@ kObjectTypeBoolean
Definition: defs.h:102
Dictionary::size
size_t size
Definition: defs.h:97
kErrorTypeNone
@ kErrorTypeNone
Definition: defs.h:27
kObjectTypeNil
@ kObjectTypeNil
Definition: defs.h:101
kObjectTypeArray
@ kObjectTypeArray
Definition: defs.h:106
String::data
char * data
Definition: defs.h:78
REAL_FATTR_CONST
#define REAL_FATTR_CONST
Definition: func_attr.h:167
Dictionary::items
KeyValuePair * items
Definition: defs.h:96
String::size
size_t size
Definition: defs.h:79
String
Definition: defs.h:77
kObjectTypeBuffer
@ kObjectTypeBuffer
Definition: defs.h:110
kObjectTypeFloat
@ kObjectTypeFloat
Definition: defs.h:104
object::dictionary
Dictionary dictionary
Definition: defs.h:123
kObjectTypeString
@ kObjectTypeString
Definition: defs.h:105
Dictionary
Definition: defs.h:95
kObjectTypeTabpage
@ kObjectTypeTabpage
Definition: defs.h:112
REMOTE_TYPE
#define REMOTE_TYPE(type)
Definition: defs.h:15
Array::size
size_t size
Definition: defs.h:90
kMessageTypeRequest
@ kMessageTypeRequest
Definition: defs.h:35
key_value_pair::value
Object value
Definition: defs.h:130
kObjectTypeInteger
@ kObjectTypeInteger
Definition: defs.h:103
kErrorTypeValidation
@ kErrorTypeValidation
Definition: defs.h:29
object::floating
Float floating
Definition: defs.h:120
INTERNAL_CALL_MASK
#define INTERNAL_CALL_MASK
Mask for all internal calls.
Definition: defs.h:41
kMessageTypeNotification
@ kMessageTypeNotification
Definition: defs.h:37
object::boolean
Boolean boolean
Definition: defs.h:118
func_attr.h
REAL_FATTR_ALWAYS_INLINE
static int REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE
Definition: typval_encode.c.h:265
object::string
String string
Definition: defs.h:121
object::luaref
LuaRef luaref
Definition: defs.h:124
len
int len
Definition: helpers.c:1034
kObjectTypeWindow
@ kObjectTypeWindow
Definition: defs.h:111