1 //===-- MsgPack.h - MessagePack Constants -----------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// This file contains constants used for implementing MessagePack support.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_BINARYFORMAT_MSGPACK_H
15 #define LLVM_BINARYFORMAT_MSGPACK_H
17 #include "llvm/Support/DataTypes.h"
18 #include "llvm/Support/Endian.h"
23 /// The endianness of all multi-byte encoded values in MessagePack.
24 constexpr support::endianness Endianness
= support::big
;
26 /// The first byte identifiers of MessagePack object formats.
28 #define HANDLE_MP_FIRST_BYTE(ID, NAME) constexpr uint8_t NAME = ID;
29 #include "llvm/BinaryFormat/MsgPack.def"
32 /// Most significant bits used to identify "Fix" variants in MessagePack.
34 /// For example, FixStr objects encode their size in the five least significant
35 /// bits of their first byte, which is identified by the bit pattern "101" in
36 /// the three most significant bits. So FixBits::String contains 0b10100000.
38 /// A corresponding mask of the bit pattern is found in \c FixBitsMask.
40 #define HANDLE_MP_FIX_BITS(ID, NAME) constexpr uint8_t NAME = ID;
41 #include "llvm/BinaryFormat/MsgPack.def"
44 /// Mask of bits used to identify "Fix" variants in MessagePack.
46 /// For example, FixStr objects encode their size in the five least significant
47 /// bits of their first byte, which is identified by the bit pattern "101" in
48 /// the three most significant bits. So FixBitsMask::String contains
51 /// The corresponding bit pattern to mask for is found in FixBits.
52 namespace FixBitsMask
{
53 #define HANDLE_MP_FIX_BITS_MASK(ID, NAME) constexpr uint8_t NAME = ID;
54 #include "llvm/BinaryFormat/MsgPack.def"
57 /// The maximum value or size encodable in "Fix" variants of formats.
59 /// For example, FixStr objects encode their size in the five least significant
60 /// bits of their first byte, so the largest encodable size is 0b00011111.
62 #define HANDLE_MP_FIX_MAX(ID, NAME) constexpr uint8_t NAME = ID;
63 #include "llvm/BinaryFormat/MsgPack.def"
66 /// The exact size encodable in "Fix" variants of formats.
68 /// The only objects for which an exact size makes sense are of Extension type.
70 /// For example, FixExt4 stores an extension type containing exactly four bytes.
72 #define HANDLE_MP_FIX_LEN(ID, NAME) constexpr uint8_t NAME = ID;
73 #include "llvm/BinaryFormat/MsgPack.def"
76 /// The minimum value or size encodable in "Fix" variants of formats.
78 /// The only object for which a minimum makes sense is a negative FixNum.
80 /// Negative FixNum objects encode their signed integer value in one byte, but
81 /// they must have the pattern "111" as their three most significant bits. This
82 /// means all values are negative, and the smallest representable value is
85 #define HANDLE_MP_FIX_MIN(ID, NAME) constexpr int8_t NAME = ID;
86 #include "llvm/BinaryFormat/MsgPack.def"
89 } // end namespace msgpack
90 } // end namespace llvm
92 #endif // LLVM_BINARYFORMAT_MSGPACK_H