1 //===-- MsgPack.h - MessagePack Constants -----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file contains constants used for implementing MessagePack support.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_BINARYFORMAT_MSGPACK_H
16 #define LLVM_BINARYFORMAT_MSGPACK_H
18 #include "llvm/Support/DataTypes.h"
19 #include "llvm/Support/Endian.h"
24 /// The endianness of all multi-byte encoded values in MessagePack.
25 constexpr support::endianness Endianness = support::big;
27 /// The first byte identifiers of MessagePack object formats.
29 #define HANDLE_MP_FIRST_BYTE(ID, NAME) constexpr uint8_t NAME = ID;
30 #include "llvm/BinaryFormat/MsgPack.def"
33 /// Most significant bits used to identify "Fix" variants in MessagePack.
35 /// For example, FixStr objects encode their size in the five least significant
36 /// bits of their first byte, which is identified by the bit pattern "101" in
37 /// the three most significant bits. So FixBits::String contains 0b10100000.
39 /// A corresponding mask of the bit pattern is found in \c FixBitsMask.
41 #define HANDLE_MP_FIX_BITS(ID, NAME) constexpr uint8_t NAME = ID;
42 #include "llvm/BinaryFormat/MsgPack.def"
45 /// Mask of bits used to identify "Fix" variants in MessagePack.
47 /// For example, FixStr objects encode their size in the five least significant
48 /// bits of their first byte, which is identified by the bit pattern "101" in
49 /// the three most significant bits. So FixBitsMask::String contains
52 /// The corresponding bit pattern to mask for is found in FixBits.
53 namespace FixBitsMask {
54 #define HANDLE_MP_FIX_BITS_MASK(ID, NAME) constexpr uint8_t NAME = ID;
55 #include "llvm/BinaryFormat/MsgPack.def"
58 /// The maximum value or size encodable in "Fix" variants of formats.
60 /// For example, FixStr objects encode their size in the five least significant
61 /// bits of their first byte, so the largest encodable size is 0b00011111.
63 #define HANDLE_MP_FIX_MAX(ID, NAME) constexpr uint8_t NAME = ID;
64 #include "llvm/BinaryFormat/MsgPack.def"
67 /// The exact size encodable in "Fix" variants of formats.
69 /// The only objects for which an exact size makes sense are of Extension type.
71 /// For example, FixExt4 stores an extension type containing exactly four bytes.
73 #define HANDLE_MP_FIX_LEN(ID, NAME) constexpr uint8_t NAME = ID;
74 #include "llvm/BinaryFormat/MsgPack.def"
77 /// The minimum value or size encodable in "Fix" variants of formats.
79 /// The only object for which a minimum makes sense is a negative FixNum.
81 /// Negative FixNum objects encode their signed integer value in one byte, but
82 /// they must have the pattern "111" as their three most significant bits. This
83 /// means all values are negative, and the smallest representable value is
86 #define HANDLE_MP_FIX_MIN(ID, NAME) constexpr int8_t NAME = ID;
87 #include "llvm/BinaryFormat/MsgPack.def"
90 } // end namespace msgpack
91 } // end namespace llvm
93 #endif // LLVM_BINARYFORMAT_MSGPACK_H