mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00

Enhance msgpack-gen.lua to extract custom api type codes from the ObjectType enum in api/private/defs.h. The type information is made available from the api metadata and clients can use to correctly serialize/deserialize these types using msgpack EXT type.
93 lines
1.6 KiB
C
93 lines
1.6 KiB
C
#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
|
|
|
|
// 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;
|
|
|
|
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 {
|
|
// The following comments are markers that msgpack-gen.lua uses to extract
|
|
// types, don't remove!
|
|
// start custom types
|
|
kObjectTypePosition,
|
|
kObjectTypeBuffer,
|
|
kObjectTypeWindow,
|
|
kObjectTypeTabpage,
|
|
// end custom types
|
|
kObjectTypeNil,
|
|
kObjectTypeBoolean,
|
|
kObjectTypeInteger,
|
|
kObjectTypeFloat,
|
|
kObjectTypeString,
|
|
kObjectTypeArray,
|
|
kObjectTypeDictionary,
|
|
} ObjectType;
|
|
|
|
struct object {
|
|
ObjectType type;
|
|
union {
|
|
Position position;
|
|
Buffer buffer;
|
|
Window window;
|
|
Tabpage tabpage;
|
|
Boolean boolean;
|
|
Integer integer;
|
|
Float floating;
|
|
String string;
|
|
Array array;
|
|
Dictionary dictionary;
|
|
} data;
|
|
};
|
|
|
|
struct key_value_pair {
|
|
String key;
|
|
Object value;
|
|
};
|
|
|
|
|
|
#endif // NVIM_API_PRIVATE_DEFS_H
|
|
|