Ai
5 Star 27 Fork 0

Gitee 极速下载/neovim

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/neovim/neovim
克隆/下载
mpack_core.h 2.33 KB
一键复制 编辑 原始数据 按行查看 历史
bfredl 提交于 2022-08-11 02:36 +08:00 . fix(mpack): make sure a bool always is a bool
#ifndef MPACK_CORE_H
#define MPACK_CORE_H
#ifndef MPACK_API
# define MPACK_API extern
#endif
#include <assert.h>
#include <limits.h>
#include <stddef.h>
#include <stdbool.h>
#ifdef __GNUC__
# define FPURE __attribute__((const))
# define FNONULL __attribute__((nonnull))
# define FNONULL_ARG(x) __attribute__((nonnull x))
# define FUNUSED __attribute__((unused))
#else
# define FPURE
# define FNONULL
# define FNONULL_ARG(x)
# define FUNUSED
#endif
#if UINT_MAX == 0xffffffff
typedef int mpack_sint32_t;
typedef unsigned int mpack_uint32_t;
#elif ULONG_MAX == 0xffffffff
typedef long mpack_sint32_t;
typedef unsigned long mpack_uint32_t;
#else
# error "can't find unsigned 32-bit integer type"
#endif
typedef struct mpack_value_s {
mpack_uint32_t lo, hi;
} mpack_value_t;
enum {
MPACK_OK = 0,
MPACK_EOF = 1,
MPACK_ERROR = 2
};
#define MPACK_MAX_TOKEN_LEN 9 /* 64-bit ints/floats plus type code */
typedef enum {
MPACK_TOKEN_NIL = 1,
MPACK_TOKEN_BOOLEAN = 2,
MPACK_TOKEN_UINT = 3,
MPACK_TOKEN_SINT = 4,
MPACK_TOKEN_FLOAT = 5,
MPACK_TOKEN_CHUNK = 6,
MPACK_TOKEN_ARRAY = 7,
MPACK_TOKEN_MAP = 8,
MPACK_TOKEN_BIN = 9,
MPACK_TOKEN_STR = 10,
MPACK_TOKEN_EXT = 11
} mpack_token_type_t;
typedef struct mpack_token_s {
mpack_token_type_t type; /* Type of token */
mpack_uint32_t length; /* Byte length for str/bin/ext/chunk/float/int/uint.
Item count for array/map. */
union {
mpack_value_t value; /* 32-bit parts of primitives (bool,int,float) */
const char *chunk_ptr; /* Chunk of data from str/bin/ext */
int ext_type; /* Type field for ext tokens */
} data;
} mpack_token_t;
typedef struct mpack_tokbuf_s {
char pending[MPACK_MAX_TOKEN_LEN];
mpack_token_t pending_tok;
size_t ppos, plen;
mpack_uint32_t passthrough;
} mpack_tokbuf_t;
#define MPACK_TOKBUF_INITIAL_VALUE { { 0 }, { 0, 0, { { 0, 0 } } }, 0, 0, 0 }
MPACK_API void mpack_tokbuf_init(mpack_tokbuf_t *tb) FUNUSED FNONULL;
MPACK_API int mpack_read(mpack_tokbuf_t *tb, const char **b, size_t *bl,
mpack_token_t *tok) FUNUSED FNONULL;
MPACK_API int mpack_write(mpack_tokbuf_t *tb, char **b, size_t *bl,
const mpack_token_t *tok) FUNUSED FNONULL;
int mpack_rtoken(const char **buf, size_t *buflen,
mpack_token_t *tok);
#endif /* MPACK_CORE_H */
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/neovim.git
git@gitee.com:mirrors/neovim.git
mirrors
neovim
neovim
master

搜索帮助