aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/msgpack_rpc/unpacker.h
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-06-02 23:01:21 +0200
committerGitHub <noreply@github.com>2022-06-02 23:01:21 +0200
commit9745941ef620da86bf18f965f85e8fc2ce8206b5 (patch)
tree083649c7f958c9292b4fe6307d97d08e52358156 /src/nvim/msgpack_rpc/unpacker.h
parent26966688aa622b448e3ef46d8f1155d57b099211 (diff)
parentd5f047bee04a42f40425c34061c84b39af846e1f (diff)
downloadrneovim-9745941ef620da86bf18f965f85e8fc2ce8206b5.tar.gz
rneovim-9745941ef620da86bf18f965f85e8fc2ce8206b5.tar.bz2
rneovim-9745941ef620da86bf18f965f85e8fc2ce8206b5.zip
Merge pull request #18730 from bfredl/apiconvert
convert API types using mpack instead of msgpack
Diffstat (limited to 'src/nvim/msgpack_rpc/unpacker.h')
-rw-r--r--src/nvim/msgpack_rpc/unpacker.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/nvim/msgpack_rpc/unpacker.h b/src/nvim/msgpack_rpc/unpacker.h
new file mode 100644
index 0000000000..bbd6b1ef4f
--- /dev/null
+++ b/src/nvim/msgpack_rpc/unpacker.h
@@ -0,0 +1,40 @@
+#ifndef NVIM_MSGPACK_RPC_UNPACKER_H
+#define NVIM_MSGPACK_RPC_UNPACKER_H
+
+#include <inttypes.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include "mpack/mpack_core.h"
+#include "mpack/object.h"
+#include "nvim/api/private/dispatch.h"
+#include "nvim/api/private/helpers.h"
+
+typedef struct {
+ mpack_parser_t parser;
+ mpack_tokbuf_t reader;
+
+ const char *read_ptr;
+ size_t read_size;
+
+#define MAX_EXT_LEN 9 // byte + 8-byte integer
+ char ext_buf[MAX_EXT_LEN];
+
+ int state;
+ MessageType type;
+ uint32_t request_id;
+ size_t method_name_len;
+ MsgpackRpcRequestHandler handler;
+ Object error; // error return
+ Object result; // arg list or result
+ Error unpack_error;
+} Unpacker;
+
+// unrecovareble error. unpack_error should be set!
+#define unpacker_closed(p) ((p)->state < 0)
+
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "msgpack_rpc/unpacker.h.generated.h"
+#endif
+
+#endif // NVIM_MSGPACK_RPC_UNPACKER_H